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

« back to all changes in this revision

Viewing changes to partx/partx.h

  • 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
 
#ifndef PARTX_H_INCLUDED
2
 
#define PARTX_H_INCLUDED
3
 
 
4
 
/*
5
 
 * For each partition type there is a routine that takes
6
 
 * a block device and a range, and returns the list of
7
 
 * slices found there in the supplied array SP that can
8
 
 * hold NS entries. The return value is the number of
9
 
 * entries stored, or -1 if the appropriate type is not
10
 
 * present.
11
 
 */
12
 
 
13
 
 
14
 
/* units: 512 byte sectors */
15
 
struct slice {
16
 
        unsigned int start;
17
 
        unsigned int size;
18
 
};
19
 
 
20
 
typedef int (ptreader)(int fd, struct slice all, struct slice *sp, int ns);
21
 
 
22
 
extern ptreader read_dos_pt, read_bsd_pt, read_solaris_pt, read_unixware_pt, read_gpt_pt;
23
 
 
24
 
unsigned char *getblock(int fd, unsigned int secnr);
25
 
 
26
 
static inline int
27
 
four2int(unsigned char *p) {
28
 
        return p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24);
29
 
}
30
 
 
31
 
#endif /* PARTX_H_INCLUDED */
 
1
#ifndef UTIL_LINUX_PARTX_H
 
2
#define UTIL_LINUX_PARTX_H
 
3
 
 
4
#include <sys/ioctl.h>
 
5
#include <linux/blkpg.h>
 
6
 
 
7
static inline int partx_del_partition(int fd, int partno)
 
8
{
 
9
        struct blkpg_ioctl_arg a;
 
10
        struct blkpg_partition p;
 
11
 
 
12
        p.pno = partno;
 
13
        p.start = 0;
 
14
        p.length = 0;
 
15
        p.devname[0] = 0;
 
16
        p.volname[0] = 0;
 
17
        a.op = BLKPG_DEL_PARTITION;
 
18
        a.flags = 0;
 
19
        a.datalen = sizeof(p);
 
20
        a.data = &p;
 
21
 
 
22
        return ioctl(fd, BLKPG, &a);
 
23
}
 
24
 
 
25
static inline int partx_add_partition(int fd, int partno,
 
26
                        unsigned long start, unsigned long size)
 
27
{
 
28
        struct blkpg_ioctl_arg a;
 
29
        struct blkpg_partition p;
 
30
 
 
31
        p.pno = partno;
 
32
        p.start = start << 9;
 
33
        p.length = size << 9;
 
34
        p.devname[0] = 0;
 
35
        p.volname[0] = 0;
 
36
        a.op = BLKPG_ADD_PARTITION;
 
37
        a.flags = 0;
 
38
        a.datalen = sizeof(p);
 
39
        a.data = &p;
 
40
 
 
41
        return ioctl(fd, BLKPG, &a);
 
42
}
 
43
 
 
44
#endif /*  UTIL_LINUX_PARTX_H */