~ubuntu-branches/ubuntu/precise/util-linux/precise-proposed

« back to all changes in this revision

Viewing changes to shlibs/blkid/src/partitions/ultrix.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-06-20 22:31:50 UTC
  • mfrom: (1.6.3 upstream) (4.5.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110620223150-lz8wrv0946ihcz3z
Tags: 2.19.1-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Build for multiarch.
  - Add pre-depends on multiarch-support.
  - configure.ac: don't try to be clever about extracting a path name from
    $libdir to append to /usr in a way that's not overridable; instead,
    reuse the built-in configurable libexecdir.
  - Fix up the .pc.in files to know about libexecdir, so our substitutions
    don't leave us with unusable pkg-config files.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.
  - Since upstart is required in Ubuntu, the hwclock.sh init script is not
    called on startup and the hwclockfirst.sh init script is removed.
  - Drop depends on initscripts for the above.
  - Replace hwclock udev rule with an Upstart job.
  - For the case where mount is called with a directory to mount, look
    that directory up in mountall's /lib/init/fstab if we couldn't find
    it mentioned anywhere else.  This means "mount /proc", "mount /sys",
    etc. work.
  - mount.8 points to the cifs-utils package, not the obsolete smbfs one. 
* Dropped changes:
  - mount.preinst: lsb_release has been fixed in lucid and above to be
    usable without configuration, so we don't have to diverge from Debian
    here anymore.
* Changes merged upstream:
  - sfdisk support for '+' with '-N'
  - mount/umount.c: fix a segfault on umount with empty mtab entry
  - Fix arbitrary unmount with fuse security issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * uktrix partition parsing code
 
3
 *
 
4
 * Copyright (C) 2010 Karel Zak <kzak@redhat.com>
 
5
 *
 
6
 * This file may be redistributed under the terms of the
 
7
 * GNU Lesser General Public License.
 
8
 *
 
9
 */
 
10
#include <stdio.h>
 
11
#include <string.h>
 
12
#include <stdlib.h>
 
13
#include <stdint.h>
 
14
 
 
15
#include "partitions.h"
 
16
 
 
17
#define ULTRIX_MAXPARTITIONS    8
 
18
#define ULTRIX_MAGIC            0x032957
 
19
 
 
20
/* sector with partition table */
 
21
#define ULTRIX_SECTOR           ((16384 - sizeof(struct ultrix_disklabel)) >> 9)
 
22
/* position of partition table within ULTRIX_SECTOR */
 
23
#define ULTRIX_OFFSET           (512 - sizeof(struct ultrix_disklabel))
 
24
 
 
25
struct ultrix_disklabel {
 
26
        int32_t pt_magic;       /* magic no. indicating part. info exits */
 
27
        int32_t pt_valid;       /* set by driver if pt is current */
 
28
        struct  pt_info {
 
29
                int32_t         pi_nblocks; /* no. of sectors */
 
30
                uint32_t        pi_blkoff;  /* block offset for start */
 
31
        } pt_part[ULTRIX_MAXPARTITIONS];
 
32
} __attribute__((packed));
 
33
 
 
34
 
 
35
static int probe_ultrix_pt(blkid_probe pr, const struct blkid_idmag *mag)
 
36
{
 
37
        unsigned char *data;
 
38
        struct ultrix_disklabel *l;
 
39
        blkid_parttable tab = NULL;
 
40
        blkid_partlist ls;
 
41
        int i;
 
42
 
 
43
        data = blkid_probe_get_sector(pr, ULTRIX_SECTOR);
 
44
        if (!data)
 
45
                goto nothing;
 
46
 
 
47
        l = (struct ultrix_disklabel *) (data + ULTRIX_OFFSET);
 
48
 
 
49
        if (l->pt_magic != ULTRIX_MAGIC || l->pt_valid != 1)
 
50
                goto nothing;
 
51
 
 
52
        if (blkid_partitions_need_typeonly(pr))
 
53
                /* caller does not ask for details about partitions */
 
54
                return 0;
 
55
 
 
56
        ls = blkid_probe_get_partlist(pr);
 
57
        if (!ls)
 
58
                goto err;
 
59
 
 
60
        tab = blkid_partlist_new_parttable(ls, "ultrix", 0);
 
61
        if (!tab)
 
62
                goto err;
 
63
 
 
64
        for (i = 0; i < ULTRIX_MAXPARTITIONS; i++) {
 
65
                if (!l->pt_part[i].pi_nblocks)
 
66
                         blkid_partlist_increment_partno(ls);
 
67
                else {
 
68
                        if (!blkid_partlist_add_partition(ls, tab,
 
69
                                                l->pt_part[i].pi_blkoff,
 
70
                                                l->pt_part[i].pi_nblocks))
 
71
                                goto err;
 
72
                }
 
73
        }
 
74
 
 
75
        return 0;
 
76
nothing:
 
77
        return 1;
 
78
err:
 
79
        return -1;
 
80
}
 
81
 
 
82
const struct blkid_idinfo ultrix_pt_idinfo =
 
83
{
 
84
        .name           = "ultrix",
 
85
        .probefunc      = probe_ultrix_pt,
 
86
        .magics         = BLKID_NONE_MAGIC
 
87
};
 
88