OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1505 lines
46 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../lvm/24-header.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. diff -urN 1.0.8-orig/asm/ioctl.h 1.0.8/asm/ioctl.h
  17. --- 1.0.8-orig/asm/ioctl.h 1970-01-01 01:00:00.000000000 +0100
  18. +++ 1.0.8/asm/ioctl.h 2004-09-30 22:11:26.419448359 +0200
  19. @@ -0,0 +1,75 @@
  20. +/* $Id: ioctl.h,v 1.5 1993/07/19 21:53:50 root Exp root $
  21. + *
  22. + * linux/ioctl.h for Linux by H.H. Bergman.
  23. + */
  24. +
  25. +#ifndef _ASMI386_IOCTL_H
  26. +#define _ASMI386_IOCTL_H
  27. +
  28. +/* ioctl command encoding: 32 bits total, command in lower 16 bits,
  29. + * size of the parameter structure in the lower 14 bits of the
  30. + * upper 16 bits.
  31. + * Encoding the size of the parameter structure in the ioctl request
  32. + * is useful for catching programs compiled with old versions
  33. + * and to avoid overwriting user space outside the user buffer area.
  34. + * The highest 2 bits are reserved for indicating the ``access mode''.
  35. + * NOTE: This limits the max parameter size to 16kB -1 !
  36. + */
  37. +
  38. +/*
  39. + * The following is for compatibility across the various Linux
  40. + * platforms. The i386 ioctl numbering scheme doesn't really enforce
  41. + * a type field. De facto, however, the top 8 bits of the lower 16
  42. + * bits are indeed used as a type field, so we might just as well make
  43. + * this explicit here. Please be sure to use the decoding macros
  44. + * below from now on.
  45. + */
  46. +#define _IOC_NRBITS 8
  47. +#define _IOC_TYPEBITS 8
  48. +#define _IOC_SIZEBITS 14
  49. +#define _IOC_DIRBITS 2
  50. +
  51. +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
  52. +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
  53. +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
  54. +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
  55. +
  56. +#define _IOC_NRSHIFT 0
  57. +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
  58. +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
  59. +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
  60. +
  61. +/*
  62. + * Direction bits.
  63. + */
  64. +#define _IOC_NONE 0U
  65. +#define _IOC_WRITE 1U
  66. +#define _IOC_READ 2U
  67. +
  68. +#define _IOC(dir,type,nr,size) \
  69. + (((dir) << _IOC_DIRSHIFT) | \
  70. + ((type) << _IOC_TYPESHIFT) | \
  71. + ((nr) << _IOC_NRSHIFT) | \
  72. + ((size) << _IOC_SIZESHIFT))
  73. +
  74. +/* used to create numbers */
  75. +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
  76. +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
  77. +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
  78. +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
  79. +
  80. +/* used to decode ioctl numbers.. */
  81. +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
  82. +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
  83. +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
  84. +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
  85. +
  86. +/* ...and for the drivers/sound files... */
  87. +
  88. +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
  89. +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
  90. +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
  91. +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
  92. +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
  93. +
  94. +#endif /* _ASMI386_IOCTL_H */
  95. diff -urN 1.0.8-orig/linux/genhd.h 1.0.8/linux/genhd.h
  96. --- 1.0.8-orig/linux/genhd.h 1970-01-01 01:00:00.000000000 +0100
  97. +++ 1.0.8/linux/genhd.h 2004-09-30 22:09:05.360962069 +0200
  98. @@ -0,0 +1,318 @@
  99. +#ifndef _LINUX_GENHD_H
  100. +#define _LINUX_GENHD_H
  101. +
  102. +/*
  103. + * genhd.h Copyright (C) 1992 Drew Eckhardt
  104. + * Generic hard disk header file by
  105. + * Drew Eckhardt
  106. + *
  107. + * <drew@colorado.edu>
  108. + */
  109. +
  110. +#include <linux/config.h>
  111. +#include <linux/types.h>
  112. +#include <linux/major.h>
  113. +
  114. +enum {
  115. +/* These three have identical behaviour; use the second one if DOS fdisk gets
  116. + confused about extended/logical partitions starting past cylinder 1023. */
  117. + DOS_EXTENDED_PARTITION = 5,
  118. + LINUX_EXTENDED_PARTITION = 0x85,
  119. + WIN98_EXTENDED_PARTITION = 0x0f,
  120. +
  121. + LINUX_SWAP_PARTITION = 0x82,
  122. + LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
  123. +
  124. + SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION,
  125. +
  126. + DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */
  127. + EZD_PARTITION = 0x55, /* EZ-DRIVE */
  128. + DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */
  129. + DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */
  130. +
  131. + FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */
  132. + OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */
  133. + NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */
  134. + BSDI_PARTITION = 0xb7, /* BSDI Partition ID */
  135. +/* Ours is not to wonder why.. */
  136. + BSD_PARTITION = FREEBSD_PARTITION,
  137. + MINIX_PARTITION = 0x81, /* Minix Partition ID */
  138. + PLAN9_PARTITION = 0x39, /* Plan 9 Partition ID */
  139. + UNIXWARE_PARTITION = 0x63, /* Partition ID, same as */
  140. + /* GNU_HURD and SCO Unix */
  141. +};
  142. +
  143. +struct partition {
  144. + unsigned char boot_ind; /* 0x80 - active */
  145. + unsigned char head; /* starting head */
  146. + unsigned char sector; /* starting sector */
  147. + unsigned char cyl; /* starting cylinder */
  148. + unsigned char sys_ind; /* What partition type */
  149. + unsigned char end_head; /* end head */
  150. + unsigned char end_sector; /* end sector */
  151. + unsigned char end_cyl; /* end cylinder */
  152. + unsigned int start_sect; /* starting sector counting from 0 */
  153. + unsigned int nr_sects; /* nr of sectors in partition */
  154. +} __attribute__((packed));
  155. +
  156. +#ifdef __KERNEL__
  157. +# include <linux/devfs_fs_kernel.h>
  158. +
  159. +struct hd_struct {
  160. + unsigned long start_sect;
  161. + unsigned long nr_sects;
  162. + devfs_handle_t de; /* primary (master) devfs entry */
  163. +#ifdef CONFIG_DEVFS_FS
  164. + int number;
  165. +#endif /* CONFIG_DEVFS_FS */
  166. +#ifdef CONFIG_BLK_STATS
  167. + /* Performance stats: */
  168. + unsigned int ios_in_flight;
  169. + unsigned int io_ticks;
  170. + unsigned int last_idle_time;
  171. + unsigned int last_queue_change;
  172. + unsigned int aveq;
  173. +
  174. + unsigned int rd_ios;
  175. + unsigned int rd_merges;
  176. + unsigned int rd_ticks;
  177. + unsigned int rd_sectors;
  178. + unsigned int wr_ios;
  179. + unsigned int wr_merges;
  180. + unsigned int wr_ticks;
  181. + unsigned int wr_sectors;
  182. +#endif /* CONFIG_BLK_STATS */
  183. +};
  184. +
  185. +#define GENHD_FL_REMOVABLE 1
  186. +
  187. +struct gendisk {
  188. + int major; /* major number of driver */
  189. + const char *major_name; /* name of major driver */
  190. + int minor_shift; /* number of times minor is shifted to
  191. + get real minor */
  192. + int max_p; /* maximum partitions per device */
  193. +
  194. + struct hd_struct *part; /* [indexed by minor] */
  195. + int *sizes; /* [idem], device size in blocks */
  196. + int nr_real; /* number of real devices */
  197. +
  198. + void *real_devices; /* internal use */
  199. + struct gendisk *next;
  200. + struct block_device_operations *fops;
  201. +
  202. + devfs_handle_t *de_arr; /* one per physical disc */
  203. + char *flags; /* one per physical disc */
  204. +};
  205. +
  206. +/* drivers/block/genhd.c */
  207. +extern struct gendisk *gendisk_head;
  208. +
  209. +extern void add_gendisk(struct gendisk *gp);
  210. +extern void del_gendisk(struct gendisk *gp);
  211. +extern struct gendisk *get_gendisk(kdev_t dev);
  212. +extern int walk_gendisk(int (*walk)(struct gendisk *, void *), void *);
  213. +
  214. +#endif /* __KERNEL__ */
  215. +
  216. +#ifdef CONFIG_SOLARIS_X86_PARTITION
  217. +
  218. +#define SOLARIS_X86_NUMSLICE 8
  219. +#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
  220. +
  221. +struct solaris_x86_slice {
  222. + ushort s_tag; /* ID tag of partition */
  223. + ushort s_flag; /* permission flags */
  224. + unsigned int s_start; /* start sector no of partition */
  225. + unsigned int s_size; /* # of blocks in partition */
  226. +};
  227. +
  228. +struct solaris_x86_vtoc {
  229. + unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */
  230. + unsigned int v_sanity; /* to verify vtoc sanity */
  231. + unsigned int v_version; /* layout version */
  232. + char v_volume[8]; /* volume name */
  233. + ushort v_sectorsz; /* sector size in bytes */
  234. + ushort v_nparts; /* number of partitions */
  235. + unsigned int v_reserved[10]; /* free space */
  236. + struct solaris_x86_slice
  237. + v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */
  238. + unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */
  239. + char v_asciilabel[128]; /* for compatibility */
  240. +};
  241. +
  242. +#endif /* CONFIG_SOLARIS_X86_PARTITION */
  243. +
  244. +#ifdef CONFIG_BSD_DISKLABEL
  245. +/*
  246. + * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il>
  247. + * updated by Marc Espie <Marc.Espie@openbsd.org>
  248. + */
  249. +
  250. +/* check against BSD src/sys/sys/disklabel.h for consistency */
  251. +
  252. +#define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */
  253. +#define BSD_MAXPARTITIONS 8
  254. +#define OPENBSD_MAXPARTITIONS 16
  255. +#define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */
  256. +struct bsd_disklabel {
  257. + __u32 d_magic; /* the magic number */
  258. + __s16 d_type; /* drive type */
  259. + __s16 d_subtype; /* controller/d_type specific */
  260. + char d_typename[16]; /* type name, e.g. "eagle" */
  261. + char d_packname[16]; /* pack identifier */
  262. + __u32 d_secsize; /* # of bytes per sector */
  263. + __u32 d_nsectors; /* # of data sectors per track */
  264. + __u32 d_ntracks; /* # of tracks per cylinder */
  265. + __u32 d_ncylinders; /* # of data cylinders per unit */
  266. + __u32 d_secpercyl; /* # of data sectors per cylinder */
  267. + __u32 d_secperunit; /* # of data sectors per unit */
  268. + __u16 d_sparespertrack; /* # of spare sectors per track */
  269. + __u16 d_sparespercyl; /* # of spare sectors per cylinder */
  270. + __u32 d_acylinders; /* # of alt. cylinders per unit */
  271. + __u16 d_rpm; /* rotational speed */
  272. + __u16 d_interleave; /* hardware sector interleave */
  273. + __u16 d_trackskew; /* sector 0 skew, per track */
  274. + __u16 d_cylskew; /* sector 0 skew, per cylinder */
  275. + __u32 d_headswitch; /* head switch time, usec */
  276. + __u32 d_trkseek; /* track-to-track seek, usec */
  277. + __u32 d_flags; /* generic flags */
  278. +#define NDDATA 5
  279. + __u32 d_drivedata[NDDATA]; /* drive-type specific information */
  280. +#define NSPARE 5
  281. + __u32 d_spare[NSPARE]; /* reserved for future use */
  282. + __u32 d_magic2; /* the magic number (again) */
  283. + __u16 d_checksum; /* xor of data incl. partitions */
  284. +
  285. + /* filesystem and partition information: */
  286. + __u16 d_npartitions; /* number of partitions in following */
  287. + __u32 d_bbsize; /* size of boot area at sn0, bytes */
  288. + __u32 d_sbsize; /* max size of fs superblock, bytes */
  289. + struct bsd_partition { /* the partition table */
  290. + __u32 p_size; /* number of sectors in partition */
  291. + __u32 p_offset; /* starting sector */
  292. + __u32 p_fsize; /* filesystem basic fragment size */
  293. + __u8 p_fstype; /* filesystem type, see below */
  294. + __u8 p_frag; /* filesystem fragments per block */
  295. + __u16 p_cpg; /* filesystem cylinders per group */
  296. + } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
  297. +};
  298. +
  299. +#endif /* CONFIG_BSD_DISKLABEL */
  300. +
  301. +#ifdef CONFIG_UNIXWARE_DISKLABEL
  302. +/*
  303. + * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
  304. + * and Krzysztof G. Baranowski <kgb@knm.org.pl>
  305. + */
  306. +
  307. +#define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */
  308. +#define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */
  309. +#define UNIXWARE_NUMSLICE 16
  310. +#define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */
  311. +
  312. +struct unixware_slice {
  313. + __u16 s_label; /* label */
  314. + __u16 s_flags; /* permission flags */
  315. + __u32 start_sect; /* starting sector */
  316. + __u32 nr_sects; /* number of sectors in slice */
  317. +};
  318. +
  319. +struct unixware_disklabel {
  320. + __u32 d_type; /* drive type */
  321. + __u32 d_magic; /* the magic number */
  322. + __u32 d_version; /* version number */
  323. + char d_serial[12]; /* serial number of the device */
  324. + __u32 d_ncylinders; /* # of data cylinders per device */
  325. + __u32 d_ntracks; /* # of tracks per cylinder */
  326. + __u32 d_nsectors; /* # of data sectors per track */
  327. + __u32 d_secsize; /* # of bytes per sector */
  328. + __u32 d_part_start; /* # of first sector of this partition */
  329. + __u32 d_unknown1[12]; /* ? */
  330. + __u32 d_alt_tbl; /* byte offset of alternate table */
  331. + __u32 d_alt_len; /* byte length of alternate table */
  332. + __u32 d_phys_cyl; /* # of physical cylinders per device */
  333. + __u32 d_phys_trk; /* # of physical tracks per cylinder */
  334. + __u32 d_phys_sec; /* # of physical sectors per track */
  335. + __u32 d_phys_bytes; /* # of physical bytes per sector */
  336. + __u32 d_unknown2; /* ? */
  337. + __u32 d_unknown3; /* ? */
  338. + __u32 d_pad[8]; /* pad */
  339. +
  340. + struct unixware_vtoc {
  341. + __u32 v_magic; /* the magic number */
  342. + __u32 v_version; /* version number */
  343. + char v_name[8]; /* volume name */
  344. + __u16 v_nslices; /* # of slices */
  345. + __u16 v_unknown1; /* ? */
  346. + __u32 v_reserved[10]; /* reserved */
  347. + struct unixware_slice
  348. + v_slice[UNIXWARE_NUMSLICE]; /* slice headers */
  349. + } vtoc;
  350. +
  351. +}; /* 408 */
  352. +
  353. +#endif /* CONFIG_UNIXWARE_DISKLABEL */
  354. +
  355. +#ifdef CONFIG_MINIX_SUBPARTITION
  356. +# define MINIX_NR_SUBPARTITIONS 4
  357. +#endif /* CONFIG_MINIX_SUBPARTITION */
  358. +
  359. +#ifdef __KERNEL__
  360. +
  361. +char *disk_name (struct gendisk *hd, int minor, char *buf);
  362. +
  363. +/*
  364. + * Account for the completion of an IO request (used by drivers which
  365. + * bypass the normal end_request processing)
  366. + */
  367. +struct request;
  368. +
  369. +#ifdef CONFIG_BLK_STATS
  370. +extern void disk_round_stats(struct hd_struct *hd);
  371. +extern void req_new_io(struct request *req, int merge, int sectors);
  372. +extern void req_merged_io(struct request *req);
  373. +extern void req_finished_io(struct request *req);
  374. +#else
  375. +static inline void req_new_io(struct request *req, int merge, int sectors) { }
  376. +static inline void req_merged_io(struct request *req) { }
  377. +static inline void req_finished_io(struct request *req) { }
  378. +#endif /* CONFIG_BLK_STATS */
  379. +
  380. +extern void devfs_register_partitions (struct gendisk *dev, int minor,
  381. + int unregister);
  382. +
  383. +
  384. +
  385. +/*
  386. + * FIXME: this should use genhd->minor_shift, but that is slow to look up.
  387. + */
  388. +static inline unsigned int disk_index (kdev_t dev)
  389. +{
  390. + int major = MAJOR(dev);
  391. + int minor = MINOR(dev);
  392. + unsigned int index;
  393. +
  394. + switch (major) {
  395. + case DAC960_MAJOR+0:
  396. + index = (minor & 0x00f8) >> 3;
  397. + break;
  398. + case SCSI_DISK0_MAJOR:
  399. + index = (minor & 0x00f0) >> 4;
  400. + break;
  401. + case IDE0_MAJOR: /* same as HD_MAJOR */
  402. + case XT_DISK_MAJOR:
  403. + index = (minor & 0x0040) >> 6;
  404. + break;
  405. + case IDE1_MAJOR:
  406. + index = ((minor & 0x0040) >> 6) + 2;
  407. + break;
  408. + default:
  409. + return 0;
  410. + }
  411. + return index;
  412. +}
  413. +
  414. +#endif
  415. +
  416. +#endif
  417. diff -urN 1.0.8-orig/linux/kdev_t.h 1.0.8/linux/kdev_t.h
  418. --- 1.0.8-orig/linux/kdev_t.h 1970-01-01 01:00:00.000000000 +0100
  419. +++ 1.0.8/linux/kdev_t.h 2004-09-30 22:08:53.714820651 +0200
  420. @@ -0,0 +1,123 @@
  421. +#ifndef _LINUX_KDEV_T_H
  422. +#define _LINUX_KDEV_T_H
  423. +#if defined(__KERNEL__) || defined(_LVM_H_INCLUDE)
  424. +/*
  425. +As a preparation for the introduction of larger device numbers,
  426. +we introduce a type kdev_t to hold them. No information about
  427. +this type is known outside of this include file.
  428. +
  429. +Objects of type kdev_t designate a device. Outside of the kernel
  430. +the corresponding things are objects of type dev_t - usually an
  431. +integral type with the device major and minor in the high and low
  432. +bits, respectively. Conversion is done by
  433. +
  434. +extern kdev_t to_kdev_t(int);
  435. +
  436. +It is up to the various file systems to decide how objects of type
  437. +dev_t are stored on disk.
  438. +The only other point of contact between kernel and outside world
  439. +are the system calls stat and mknod, new versions of which will
  440. +eventually have to be used in libc.
  441. +
  442. +[Unfortunately, the floppy control ioctls fail to hide the internal
  443. +kernel structures, and the fd_device field of a struct floppy_drive_struct
  444. +is user-visible. So, it remains a dev_t for the moment, with some ugly
  445. +conversions in floppy.c.]
  446. +
  447. +Inside the kernel, we aim for a kdev_t type that is a pointer
  448. +to a structure with information about the device (like major,
  449. +minor, size, blocksize, sectorsize, name, read-only flag,
  450. +struct file_operations etc.).
  451. +
  452. +However, for the time being we let kdev_t be almost the same as dev_t:
  453. +
  454. +typedef struct { unsigned short major, minor; } kdev_t;
  455. +
  456. +Admissible operations on an object of type kdev_t:
  457. +- passing it along
  458. +- comparing it for equality with another such object
  459. +- storing it in ROOT_DEV, inode->i_dev, inode->i_rdev, sb->s_dev,
  460. + bh->b_dev, req->rq_dev, de->dc_dev, tty->device
  461. +- using its bit pattern as argument in a hash function
  462. +- finding its major and minor
  463. +- complaining about it
  464. +
  465. +An object of type kdev_t is created only by the function MKDEV(),
  466. +with the single exception of the constant 0 (no device).
  467. +
  468. +Right now the other information mentioned above is usually found
  469. +in static arrays indexed by major or major,minor.
  470. +
  471. +An obstacle to immediately using
  472. + typedef struct { ... (* lots of information *) } *kdev_t
  473. +is the case of mknod used to create a block device that the
  474. +kernel doesn't know about at present (but first learns about
  475. +when some module is inserted).
  476. +
  477. +aeb - 950811
  478. +*/
  479. +
  480. +/* Since MINOR(dev) is used as index in static arrays,
  481. + the kernel is not quite ready yet for larger minors.
  482. + However, everything runs fine with an arbitrary kdev_t type. */
  483. +
  484. +#define MINORBITS 8
  485. +#define MINORMASK ((1U << MINORBITS) - 1)
  486. +
  487. +typedef unsigned short kdev_t;
  488. +
  489. +#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
  490. +#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
  491. +#define HASHDEV(dev) ((unsigned int) (dev))
  492. +#define NODEV 0
  493. +#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
  494. +#define B_FREE 0xffff /* yuk */
  495. +
  496. +extern const char * kdevname(kdev_t); /* note: returns pointer to static data! */
  497. +
  498. +/* 2.5.x compatibility */
  499. +#define mk_kdev(a,b) MKDEV(a,b)
  500. +#define major(d) MAJOR(d)
  501. +#define minor(d) MINOR(d)
  502. +#define kdev_same(a,b) ((a) == (b))
  503. +#define kdev_none(d) (!(d))
  504. +#define kdev_val(d) ((unsigned int)(d))
  505. +#define val_to_kdev(d) ((kdev_t)(d))
  506. +
  507. +/*
  508. +As long as device numbers in the outside world have 16 bits only,
  509. +we use these conversions.
  510. +*/
  511. +
  512. +static inline unsigned int kdev_t_to_nr(kdev_t dev) {
  513. + return (MAJOR(dev)<<8) | MINOR(dev);
  514. +}
  515. +
  516. +static inline kdev_t to_kdev_t(int dev)
  517. +{
  518. + int major, minor;
  519. +#if 0
  520. + major = (dev >> 16);
  521. + if (!major) {
  522. + major = (dev >> 8);
  523. + minor = (dev & 0xff);
  524. + } else
  525. + minor = (dev & 0xffff);
  526. +#else
  527. + major = (dev >> 8);
  528. + minor = (dev & 0xff);
  529. +#endif
  530. + return MKDEV(major, minor);
  531. +}
  532. +
  533. +#else /* __KERNEL__ || _LVM_H_INCLUDE */
  534. +
  535. +/*
  536. +Some programs want their definitions of MAJOR and MINOR and MKDEV
  537. +from the kernel sources. These must be the externally visible ones.
  538. +*/
  539. +#define MAJOR(dev) ((dev)>>8)
  540. +#define MINOR(dev) ((dev) & 0xff)
  541. +#define MKDEV(ma,mi) ((ma)<<8 | (mi))
  542. +#endif /* __KERNEL__ || _LVM_H_INCLUDE */
  543. +#endif
  544. diff -urN 1.0.8-orig/linux/lvm.h 1.0.8/linux/lvm.h
  545. --- 1.0.8-orig/linux/lvm.h 1970-01-01 01:00:00.000000000 +0100
  546. +++ 1.0.8/linux/lvm.h 2004-09-30 22:08:45.037205472 +0200
  547. @@ -0,0 +1,756 @@
  548. +/*
  549. + * include/linux/lvm.h
  550. + * kernel/lvm.h
  551. + * tools/lib/lvm.h
  552. + *
  553. + * Copyright (C) 1997 - 2002 Heinz Mauelshagen, Sistina Software
  554. + *
  555. + * February-November 1997
  556. + * May-July 1998
  557. + * January-March,July,September,October,Dezember 1999
  558. + * January,February,July,November 2000
  559. + * January-March,June,July 2001
  560. + * May 2002
  561. + *
  562. + * lvm is free software; you can redistribute it and/or modify
  563. + * it under the terms of the GNU General Public License as published by
  564. + * the Free Software Foundation; either version 2, or (at your option)
  565. + * any later version.
  566. + *
  567. + * lvm is distributed in the hope that it will be useful,
  568. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  569. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  570. + * GNU General Public License for more details.
  571. + *
  572. + * You should have received a copy of the GNU General Public License
  573. + * along with GNU CC; see the file COPYING. If not, write to
  574. + * the Free Software Foundation, 59 Temple Place - Suite 330,
  575. + * Boston, MA 02111-1307, USA.
  576. + *
  577. + */
  578. +
  579. +/*
  580. + * Changelog
  581. + *
  582. + * 10/10/1997 - beginning of new structure creation
  583. + * 12/05/1998 - incorporated structures from lvm_v1.h and deleted lvm_v1.h
  584. + * 07/06/1998 - avoided LVM_KMALLOC_MAX define by using vmalloc/vfree
  585. + * instead of kmalloc/kfree
  586. + * 01/07/1998 - fixed wrong LVM_MAX_SIZE
  587. + * 07/07/1998 - extended pe_t structure by ios member (for statistic)
  588. + * 02/08/1998 - changes for official char/block major numbers
  589. + * 07/08/1998 - avoided init_module() and cleanup_module() to be static
  590. + * 29/08/1998 - seprated core and disk structure type definitions
  591. + * 01/09/1998 - merged kernel integration version (mike)
  592. + * 20/01/1999 - added LVM_PE_DISK_OFFSET macro for use in
  593. + * vg_read_with_pv_and_lv(), pv_move_pe(), pv_show_pe_text()...
  594. + * 18/02/1999 - added definition of time_disk_t structure for;
  595. + * keeps time stamps on disk for nonatomic writes (future)
  596. + * 15/03/1999 - corrected LV() and VG() macro definition to use argument
  597. + * instead of minor
  598. + * 03/07/1999 - define for genhd.c name handling
  599. + * 23/07/1999 - implemented snapshot part
  600. + * 08/12/1999 - changed LVM_LV_SIZE_MAX macro to reflect current 1TB limit
  601. + * 01/01/2000 - extended lv_v2 core structure by wait_queue member
  602. + * 12/02/2000 - integrated Andrea Arcagnelli's snapshot work
  603. + * 18/02/2000 - seperated user and kernel space parts by
  604. + * #ifdef them with __KERNEL__
  605. + * 08/03/2000 - implemented cluster/shared bits for vg_access
  606. + * 26/06/2000 - implemented snapshot persistency and resizing support
  607. + * 02/11/2000 - added hash table size member to lv structure
  608. + * 12/11/2000 - removed unneeded timestamp definitions
  609. + * 24/12/2000 - removed LVM_TO_{CORE,DISK}*, use cpu_{from, to}_le*
  610. + * instead - Christoph Hellwig
  611. + * 22/01/2001 - Change ulong to uint32_t
  612. + * 14/02/2001 - changed LVM_SNAPSHOT_MIN_CHUNK to 1 page
  613. + * 20/02/2001 - incremented IOP version to 11 because of incompatible
  614. + * change in VG activation (in order to support devfs better)
  615. + * 01/03/2001 - Revert to IOP10 and add VG_CREATE_OLD call for compatibility
  616. + * 08/03/2001 - new lv_t (in core) version number 5: changed page member
  617. + * to (struct kiobuf *) to use for COW exception table io
  618. + * 26/03/2001 - changed lv_v4 to lv_v5 in structure definition (HM)
  619. + * 21/06/2001 - changed BLOCK_SIZE back to 1024 for non S/390
  620. + * 22/06/2001 - added Andreas Dilger's PE on 4k boundary alignment enhancements
  621. + * 19/07/2001 - added rwsem compatibility macros for 2.2 kernels
  622. + * 13/11/2001 - reduced userspace inclusion of kernel headers to a minimum
  623. + *
  624. + */
  625. +
  626. +
  627. +#ifndef _LVM_H_INCLUDE
  628. +#define _LVM_H_INCLUDE
  629. +
  630. +#define LVM_RELEASE_NAME "1.0.5+"
  631. +#define LVM_RELEASE_DATE "22/07/2002"
  632. +
  633. +#define _LVM_KERNEL_H_VERSION "LVM "LVM_RELEASE_NAME" ("LVM_RELEASE_DATE")"
  634. +
  635. +#include <linux/version.h>
  636. +
  637. +/*
  638. + * preprocessor definitions
  639. + */
  640. +/* if you like emergency reset code in the driver */
  641. +#define LVM_TOTAL_RESET
  642. +
  643. +#ifdef __KERNEL__
  644. +#undef LVM_HD_NAME /* display nice names in /proc/partitions */
  645. +
  646. +/* lots of debugging output (see driver source)
  647. + #define DEBUG_LVM_GET_INFO
  648. + #define DEBUG
  649. + #define DEBUG_MAP
  650. + #define DEBUG_MAP_SIZE
  651. + #define DEBUG_IOCTL
  652. + #define DEBUG_READ
  653. + #define DEBUG_GENDISK
  654. + #define DEBUG_VG_CREATE
  655. + #define DEBUG_DEVICE
  656. + #define DEBUG_KFREE
  657. + */
  658. +
  659. +#include <linux/kdev_t.h>
  660. +#include <linux/list.h>
  661. +#include <asm/types.h>
  662. +#include <linux/major.h>
  663. +#else
  664. +/* This prevents the need to include <linux/list.h> which
  665. + causes problems on some platforms. It's not nice but then
  666. + neither is the alternative. */
  667. +struct list_head {
  668. + struct list_head *next, *prev;
  669. +};
  670. +#define __KERNEL__
  671. +#include <linux/kdev_t.h>
  672. +#undef __KERNEL__
  673. +#endif /* #ifndef __KERNEL__ */
  674. +
  675. +
  676. +#ifdef __KERNEL__
  677. +#include <linux/spinlock.h>
  678. +
  679. +#include <asm/semaphore.h>
  680. +#endif /* #ifdef __KERNEL__ */
  681. +
  682. +
  683. +#include <asm/page.h>
  684. +
  685. +#if !defined ( LVM_BLK_MAJOR) || !defined ( LVM_CHAR_MAJOR)
  686. +#error Bad include/linux/major.h - LVM MAJOR undefined
  687. +#endif
  688. +
  689. +#ifdef BLOCK_SIZE
  690. +#undef BLOCK_SIZE
  691. +#endif
  692. +
  693. +#ifdef CONFIG_ARCH_S390
  694. +#define BLOCK_SIZE 4096
  695. +#else
  696. +#define BLOCK_SIZE 1024
  697. +#endif
  698. +
  699. +#ifndef SECTOR_SIZE
  700. +#define SECTOR_SIZE 512
  701. +#endif
  702. +
  703. +/* structure version */
  704. +#define LVM_STRUCT_VERSION 1
  705. +
  706. +#define LVM_DIR_PREFIX "/dev/"
  707. +
  708. +/*
  709. + * i/o protocol version
  710. + *
  711. + * defined here for the driver and defined seperate in the
  712. + * user land tools/lib/liblvm.h
  713. + *
  714. + */
  715. +#define LVM_DRIVER_IOP_VERSION 10
  716. +
  717. +#define LVM_NAME "lvm"
  718. +#define LVM_GLOBAL "global"
  719. +#define LVM_DIR "lvm"
  720. +#define LVM_VG_SUBDIR "VGs"
  721. +#define LVM_LV_SUBDIR "LVs"
  722. +#define LVM_PV_SUBDIR "PVs"
  723. +
  724. +/*
  725. + * VG/LV indexing macros
  726. + */
  727. +/* character minor maps directly to volume group */
  728. +#define VG_CHR(a) ( a)
  729. +
  730. +/* block minor indexes into a volume group/logical volume indirection table */
  731. +#define VG_BLK(a) ( vg_lv_map[a].vg_number)
  732. +#define LV_BLK(a) ( vg_lv_map[a].lv_number)
  733. +
  734. +/*
  735. + * absolute limits for VGs, PVs per VG and LVs per VG
  736. + */
  737. +#define ABS_MAX_VG 99
  738. +#define ABS_MAX_PV 256
  739. +#define ABS_MAX_LV 256 /* caused by 8 bit minor */
  740. +
  741. +#define MAX_VG ABS_MAX_VG
  742. +#define MAX_LV ABS_MAX_LV
  743. +#define MAX_PV ABS_MAX_PV
  744. +
  745. +#if ( MAX_VG > ABS_MAX_VG)
  746. +#undef MAX_VG
  747. +#define MAX_VG ABS_MAX_VG
  748. +#endif
  749. +
  750. +#if ( MAX_LV > ABS_MAX_LV)
  751. +#undef MAX_LV
  752. +#define MAX_LV ABS_MAX_LV
  753. +#endif
  754. +
  755. +
  756. +/*
  757. + * VGDA: default disk spaces and offsets
  758. + *
  759. + * there's space after the structures for later extensions.
  760. + *
  761. + * offset what size
  762. + * --------------- ---------------------------------- ------------
  763. + * 0 physical volume structure ~500 byte
  764. + *
  765. + * 1K volume group structure ~200 byte
  766. + *
  767. + * 6K namelist of physical volumes 128 byte each
  768. + *
  769. + * 6k + n * ~300byte n logical volume structures ~300 byte each
  770. + *
  771. + * + m * 4byte m physical extent alloc. structs 4 byte each
  772. + *
  773. + * End of disk - first physical extent typically 4 megabyte
  774. + * PE total *
  775. + * PE size
  776. + *
  777. + *
  778. + */
  779. +
  780. +/* DONT TOUCH THESE !!! */
  781. +
  782. +
  783. +
  784. +
  785. +
  786. +
  787. +
  788. +/*
  789. + * LVM_PE_T_MAX corresponds to:
  790. + *
  791. + * 8KB PE size can map a ~512 MB logical volume at the cost of 1MB memory,
  792. + *
  793. + * 128MB PE size can map a 8TB logical volume at the same cost of memory.
  794. + *
  795. + * Default PE size of 4 MB gives a maximum logical volume size of 256 GB.
  796. + *
  797. + * Maximum PE size of 16GB gives a maximum logical volume size of 1024 TB.
  798. + *
  799. + * AFAIK, the actual kernels limit this to 1 TB.
  800. + *
  801. + * Should be a sufficient spectrum ;*)
  802. + */
  803. +
  804. +/* This is the usable size of pe_disk_t.le_num !!! v v */
  805. +#define LVM_PE_T_MAX ( ( 1 << ( sizeof ( uint16_t) * 8)) - 2)
  806. +
  807. +#define LVM_LV_SIZE_MAX(a) ( ( long long) LVM_PE_T_MAX * (a)->pe_size > ( long long) 1024*1024/SECTOR_SIZE*1024*1024 ? ( long long) 1024*1024/SECTOR_SIZE*1024*1024 : ( long long) LVM_PE_T_MAX * (a)->pe_size)
  808. +#define LVM_MIN_PE_SIZE ( 8192L / SECTOR_SIZE) /* 8 KB in sectors */
  809. +#define LVM_MAX_PE_SIZE ( 16L * 1024L * 1024L / SECTOR_SIZE * 1024) /* 16GB in sectors */
  810. +#define LVM_DEFAULT_PE_SIZE ( 4096L * 1024 / SECTOR_SIZE) /* 4 MB in sectors */
  811. +#define LVM_DEFAULT_STRIPE_SIZE 16L /* 16 KB */
  812. +#define LVM_MIN_STRIPE_SIZE ( PAGE_SIZE/SECTOR_SIZE) /* PAGESIZE in sectors */
  813. +#define LVM_MAX_STRIPE_SIZE ( 512L * 1024 / SECTOR_SIZE) /* 512 KB in sectors */
  814. +#define LVM_MAX_STRIPES 128 /* max # of stripes */
  815. +#define LVM_MAX_SIZE ( 1024LU * 1024 / SECTOR_SIZE * 1024 * 1024) /* 1TB[sectors] */
  816. +#define LVM_MAX_MIRRORS 2 /* future use */
  817. +#define LVM_MIN_READ_AHEAD 0 /* minimum read ahead sectors */
  818. +#define LVM_DEFAULT_READ_AHEAD 1024 /* sectors for 512k scsi segments */
  819. +#define LVM_MAX_READ_AHEAD 1024 /* maximum read ahead sectors */
  820. +#define LVM_MAX_LV_IO_TIMEOUT 60 /* seconds I/O timeout (future use) */
  821. +#define LVM_PARTITION 0xfe /* LVM partition id */
  822. +#define LVM_NEW_PARTITION 0x8e /* new LVM partition id (10/09/1999) */
  823. +#define LVM_PE_SIZE_PV_SIZE_REL 5 /* max relation PV size and PE size */
  824. +
  825. +#define LVM_SNAPSHOT_MAX_CHUNK 1024 /* 1024 KB */
  826. +#define LVM_SNAPSHOT_DEF_CHUNK 64 /* 64 KB */
  827. +#define LVM_SNAPSHOT_MIN_CHUNK (PAGE_SIZE/1024) /* 4 or 8 KB */
  828. +
  829. +#define UNDEF -1
  830. +
  831. +/*
  832. + * ioctls
  833. + * FIXME: the last parameter to _IO{W,R,WR} is a data type. The macro will
  834. + * expand this using sizeof(), so putting "1" there is misleading
  835. + * because sizeof(1) = sizeof(int) = sizeof(2) = 4 on a 32-bit machine!
  836. + */
  837. +/* volume group */
  838. +#define VG_CREATE_OLD _IOW ( 0xfe, 0x00, 1)
  839. +#define VG_REMOVE _IOW ( 0xfe, 0x01, 1)
  840. +
  841. +#define VG_EXTEND _IOW ( 0xfe, 0x03, 1)
  842. +#define VG_REDUCE _IOW ( 0xfe, 0x04, 1)
  843. +
  844. +#define VG_STATUS _IOWR ( 0xfe, 0x05, 1)
  845. +#define VG_STATUS_GET_COUNT _IOWR ( 0xfe, 0x06, 1)
  846. +#define VG_STATUS_GET_NAMELIST _IOWR ( 0xfe, 0x07, 1)
  847. +
  848. +#define VG_SET_EXTENDABLE _IOW ( 0xfe, 0x08, 1)
  849. +#define VG_RENAME _IOW ( 0xfe, 0x09, 1)
  850. +
  851. +/* Since 0.9beta6 */
  852. +#define VG_CREATE _IOW ( 0xfe, 0x0a, 1)
  853. +
  854. +/* logical volume */
  855. +#define LV_CREATE _IOW ( 0xfe, 0x20, 1)
  856. +#define LV_REMOVE _IOW ( 0xfe, 0x21, 1)
  857. +
  858. +#define LV_ACTIVATE _IO ( 0xfe, 0x22)
  859. +#define LV_DEACTIVATE _IO ( 0xfe, 0x23)
  860. +
  861. +#define LV_EXTEND _IOW ( 0xfe, 0x24, 1)
  862. +#define LV_REDUCE _IOW ( 0xfe, 0x25, 1)
  863. +
  864. +#define LV_STATUS_BYNAME _IOWR ( 0xfe, 0x26, 1)
  865. +#define LV_STATUS_BYINDEX _IOWR ( 0xfe, 0x27, 1)
  866. +
  867. +#define LV_SET_ACCESS _IOW ( 0xfe, 0x28, 1)
  868. +#define LV_SET_ALLOCATION _IOW ( 0xfe, 0x29, 1)
  869. +#define LV_SET_STATUS _IOW ( 0xfe, 0x2a, 1)
  870. +
  871. +#define LE_REMAP _IOW ( 0xfe, 0x2b, 1)
  872. +
  873. +#define LV_SNAPSHOT_USE_RATE _IOWR ( 0xfe, 0x2c, 1)
  874. +
  875. +#define LV_STATUS_BYDEV _IOWR ( 0xfe, 0x2e, 1)
  876. +
  877. +#define LV_RENAME _IOW ( 0xfe, 0x2f, 1)
  878. +
  879. +#define LV_BMAP _IOWR ( 0xfe, 0x30, 1)
  880. +
  881. +
  882. +/* physical volume */
  883. +#define PV_STATUS _IOWR ( 0xfe, 0x40, 1)
  884. +#define PV_CHANGE _IOWR ( 0xfe, 0x41, 1)
  885. +#define PV_FLUSH _IOW ( 0xfe, 0x42, 1)
  886. +
  887. +/* physical extent */
  888. +#define PE_LOCK_UNLOCK _IOW ( 0xfe, 0x50, 1)
  889. +
  890. +/* i/o protocol version */
  891. +#define LVM_GET_IOP_VERSION _IOR ( 0xfe, 0x98, 1)
  892. +
  893. +#ifdef LVM_TOTAL_RESET
  894. +/* special reset function for testing purposes */
  895. +#define LVM_RESET _IO ( 0xfe, 0x99)
  896. +#endif
  897. +
  898. +/* lock the logical volume manager */
  899. +#if LVM_DRIVER_IOP_VERSION > 11
  900. +#define LVM_LOCK_LVM _IO ( 0xfe, 0x9A)
  901. +#else
  902. +/* This is actually the same as _IO ( 0xff, 0x00), oops. Remove for IOP 12+ */
  903. +#define LVM_LOCK_LVM _IO ( 0xfe, 0x100)
  904. +#endif
  905. +/* END ioctls */
  906. +
  907. +
  908. +/*
  909. + * Status flags
  910. + */
  911. +/* volume group */
  912. +#define VG_ACTIVE 0x01 /* vg_status */
  913. +#define VG_EXPORTED 0x02 /* " */
  914. +#define VG_EXTENDABLE 0x04 /* " */
  915. +
  916. +#define VG_READ 0x01 /* vg_access */
  917. +#define VG_WRITE 0x02 /* " */
  918. +#define VG_CLUSTERED 0x04 /* " */
  919. +#define VG_SHARED 0x08 /* " */
  920. +
  921. +/* logical volume */
  922. +#define LV_ACTIVE 0x01 /* lv_status */
  923. +#define LV_SPINDOWN 0x02 /* " */
  924. +
  925. +#define LV_READ 0x01 /* lv_access */
  926. +#define LV_WRITE 0x02 /* " */
  927. +#define LV_SNAPSHOT 0x04 /* " */
  928. +#define LV_SNAPSHOT_ORG 0x08 /* " */
  929. +
  930. +#define LV_BADBLOCK_ON 0x01 /* lv_badblock */
  931. +
  932. +#define LV_STRICT 0x01 /* lv_allocation */
  933. +#define LV_CONTIGUOUS 0x02 /* " */
  934. +
  935. +/* physical volume */
  936. +#define PV_ACTIVE 0x01 /* pv_status */
  937. +#define PV_ALLOCATABLE 0x02 /* pv_allocatable */
  938. +
  939. +
  940. +/* misc */
  941. +#define LVM_SNAPSHOT_DROPPED_SECTOR 1
  942. +
  943. +/*
  944. + * Structure definitions core/disk follow
  945. + *
  946. + * conditional conversion takes place on big endian architectures
  947. + * in functions * pv_copy_*(), vg_copy_*() and lv_copy_*()
  948. + *
  949. + */
  950. +
  951. +#define NAME_LEN 128 /* don't change!!! */
  952. +#define UUID_LEN 32 /* don't change!!! */
  953. +
  954. +/* copy on write tables in disk format */
  955. +typedef struct lv_COW_table_disk_v1 {
  956. + uint64_t pv_org_number;
  957. + uint64_t pv_org_rsector;
  958. + uint64_t pv_snap_number;
  959. + uint64_t pv_snap_rsector;
  960. +} lv_COW_table_disk_t;
  961. +
  962. +/* remap physical sector/rdev pairs including hash */
  963. +typedef struct lv_block_exception_v1 {
  964. + struct list_head hash;
  965. + uint32_t rsector_org;
  966. + kdev_t rdev_org;
  967. + uint32_t rsector_new;
  968. + kdev_t rdev_new;
  969. +} lv_block_exception_t;
  970. +
  971. +/* disk stored pe information */
  972. +typedef struct {
  973. + uint16_t lv_num;
  974. + uint16_t le_num;
  975. +} pe_disk_t;
  976. +
  977. +/* disk stored PV, VG, LV and PE size and offset information */
  978. +typedef struct {
  979. + uint32_t base;
  980. + uint32_t size;
  981. +} lvm_disk_data_t;
  982. +
  983. +
  984. +/*
  985. + * physical volume structures
  986. + */
  987. +
  988. +/* core */
  989. +typedef struct pv_v2 {
  990. + char id[2]; /* Identifier */
  991. + unsigned short version; /* HM lvm version */
  992. + lvm_disk_data_t pv_on_disk;
  993. + lvm_disk_data_t vg_on_disk;
  994. + lvm_disk_data_t pv_uuidlist_on_disk;
  995. + lvm_disk_data_t lv_on_disk;
  996. + lvm_disk_data_t pe_on_disk;
  997. + char pv_name[NAME_LEN];
  998. + char vg_name[NAME_LEN];
  999. + char system_id[NAME_LEN]; /* for vgexport/vgimport */
  1000. + kdev_t pv_dev;
  1001. + uint pv_number;
  1002. + uint pv_status;
  1003. + uint pv_allocatable;
  1004. + uint pv_size; /* HM */
  1005. + uint lv_cur;
  1006. + uint pe_size;
  1007. + uint pe_total;
  1008. + uint pe_allocated;
  1009. + uint pe_stale; /* for future use */
  1010. + pe_disk_t *pe; /* HM */
  1011. + struct block_device *bd;
  1012. + char pv_uuid[UUID_LEN+1];
  1013. +
  1014. +#ifndef __KERNEL__
  1015. + uint32_t pe_start; /* in sectors */
  1016. +#endif
  1017. +} pv_t;
  1018. +
  1019. +
  1020. +/* disk */
  1021. +typedef struct pv_disk_v2 {
  1022. + uint8_t id[2]; /* Identifier */
  1023. + uint16_t version; /* HM lvm version */
  1024. + lvm_disk_data_t pv_on_disk;
  1025. + lvm_disk_data_t vg_on_disk;
  1026. + lvm_disk_data_t pv_uuidlist_on_disk;
  1027. + lvm_disk_data_t lv_on_disk;
  1028. + lvm_disk_data_t pe_on_disk;
  1029. + uint8_t pv_uuid[NAME_LEN];
  1030. + uint8_t vg_name[NAME_LEN];
  1031. + uint8_t system_id[NAME_LEN]; /* for vgexport/vgimport */
  1032. + uint32_t pv_major;
  1033. + uint32_t pv_number;
  1034. + uint32_t pv_status;
  1035. + uint32_t pv_allocatable;
  1036. + uint32_t pv_size; /* HM */
  1037. + uint32_t lv_cur;
  1038. + uint32_t pe_size;
  1039. + uint32_t pe_total;
  1040. + uint32_t pe_allocated;
  1041. +
  1042. + /* new in struct version 2 */
  1043. + uint32_t pe_start; /* in sectors */
  1044. +
  1045. +} pv_disk_t;
  1046. +
  1047. +
  1048. +/*
  1049. + * Structures for Logical Volume (LV)
  1050. + */
  1051. +
  1052. +/* core PE information */
  1053. +typedef struct {
  1054. + kdev_t dev;
  1055. + uint32_t pe; /* to be changed if > 2TB */
  1056. + uint32_t reads;
  1057. + uint32_t writes;
  1058. +} pe_t;
  1059. +
  1060. +typedef struct {
  1061. + char lv_name[NAME_LEN];
  1062. + kdev_t old_dev;
  1063. + kdev_t new_dev;
  1064. + uint32_t old_pe;
  1065. + uint32_t new_pe;
  1066. +} le_remap_req_t;
  1067. +
  1068. +typedef struct lv_bmap {
  1069. + uint32_t lv_block;
  1070. + dev_t lv_dev;
  1071. +} lv_bmap_t;
  1072. +
  1073. +/*
  1074. + * Structure Logical Volume (LV) Version 3
  1075. + */
  1076. +
  1077. +/* core */
  1078. +typedef struct lv_v5 {
  1079. + char lv_name[NAME_LEN];
  1080. + char vg_name[NAME_LEN];
  1081. + uint lv_access;
  1082. + uint lv_status;
  1083. + uint lv_open; /* HM */
  1084. + kdev_t lv_dev; /* HM */
  1085. + uint lv_number; /* HM */
  1086. + uint lv_mirror_copies; /* for future use */
  1087. + uint lv_recovery; /* " */
  1088. + uint lv_schedule; /* " */
  1089. + uint lv_size;
  1090. + pe_t *lv_current_pe; /* HM */
  1091. + uint lv_current_le; /* for future use */
  1092. + uint lv_allocated_le;
  1093. + uint lv_stripes;
  1094. + uint lv_stripesize;
  1095. + uint lv_badblock; /* for future use */
  1096. + uint lv_allocation;
  1097. + uint lv_io_timeout; /* for future use */
  1098. + uint lv_read_ahead;
  1099. +
  1100. + /* delta to version 1 starts here */
  1101. + struct lv_v5 *lv_snapshot_org;
  1102. + struct lv_v5 *lv_snapshot_prev;
  1103. + struct lv_v5 *lv_snapshot_next;
  1104. + lv_block_exception_t *lv_block_exception;
  1105. + uint lv_remap_ptr;
  1106. + uint lv_remap_end;
  1107. + uint lv_chunk_size;
  1108. + uint lv_snapshot_minor;
  1109. +#ifdef __KERNEL__
  1110. + struct kiobuf *lv_iobuf;
  1111. + struct kiobuf *lv_COW_table_iobuf;
  1112. + struct rw_semaphore lv_lock;
  1113. + struct list_head *lv_snapshot_hash_table;
  1114. + uint32_t lv_snapshot_hash_table_size;
  1115. + uint32_t lv_snapshot_hash_mask;
  1116. + wait_queue_head_t lv_snapshot_wait;
  1117. + int lv_snapshot_use_rate;
  1118. + struct vg_v3 *vg;
  1119. +
  1120. + uint lv_allocated_snapshot_le;
  1121. +#else
  1122. + char dummy[200];
  1123. +#endif
  1124. +} lv_t;
  1125. +
  1126. +/* disk */
  1127. +typedef struct lv_disk_v3 {
  1128. + uint8_t lv_name[NAME_LEN];
  1129. + uint8_t vg_name[NAME_LEN];
  1130. + uint32_t lv_access;
  1131. + uint32_t lv_status;
  1132. + uint32_t lv_open; /* HM */
  1133. + uint32_t lv_dev; /* HM */
  1134. + uint32_t lv_number; /* HM */
  1135. + uint32_t lv_mirror_copies; /* for future use */
  1136. + uint32_t lv_recovery; /* " */
  1137. + uint32_t lv_schedule; /* " */
  1138. + uint32_t lv_size;
  1139. + uint32_t lv_snapshot_minor;/* minor number of original */
  1140. + uint16_t lv_chunk_size; /* chunk size of snapshot */
  1141. + uint16_t dummy;
  1142. + uint32_t lv_allocated_le;
  1143. + uint32_t lv_stripes;
  1144. + uint32_t lv_stripesize;
  1145. + uint32_t lv_badblock; /* for future use */
  1146. + uint32_t lv_allocation;
  1147. + uint32_t lv_io_timeout; /* for future use */
  1148. + uint32_t lv_read_ahead; /* HM */
  1149. +} lv_disk_t;
  1150. +
  1151. +/*
  1152. + * Structure Volume Group (VG) Version 1
  1153. + */
  1154. +
  1155. +/* core */
  1156. +typedef struct vg_v3 {
  1157. + char vg_name[NAME_LEN]; /* volume group name */
  1158. + uint vg_number; /* volume group number */
  1159. + uint vg_access; /* read/write */
  1160. + uint vg_status; /* active or not */
  1161. + uint lv_max; /* maximum logical volumes */
  1162. + uint lv_cur; /* current logical volumes */
  1163. + uint lv_open; /* open logical volumes */
  1164. + uint pv_max; /* maximum physical volumes */
  1165. + uint pv_cur; /* current physical volumes FU */
  1166. + uint pv_act; /* active physical volumes */
  1167. + uint dummy; /* was obsolete max_pe_per_pv */
  1168. + uint vgda; /* volume group descriptor arrays FU */
  1169. + uint pe_size; /* physical extent size in sectors */
  1170. + uint pe_total; /* total of physical extents */
  1171. + uint pe_allocated; /* allocated physical extents */
  1172. + uint pvg_total; /* physical volume groups FU */
  1173. + struct proc_dir_entry *proc;
  1174. + pv_t *pv[ABS_MAX_PV + 1]; /* physical volume struct pointers */
  1175. + lv_t *lv[ABS_MAX_LV + 1]; /* logical volume struct pointers */
  1176. + char vg_uuid[UUID_LEN+1]; /* volume group UUID */
  1177. +#ifdef __KERNEL__
  1178. + struct proc_dir_entry *vg_dir_pde;
  1179. + struct proc_dir_entry *lv_subdir_pde;
  1180. + struct proc_dir_entry *pv_subdir_pde;
  1181. +#else
  1182. + char dummy1[200];
  1183. +#endif
  1184. +} vg_t;
  1185. +
  1186. +
  1187. +/* disk */
  1188. +typedef struct vg_disk_v2 {
  1189. + uint8_t vg_uuid[UUID_LEN]; /* volume group UUID */
  1190. + uint8_t vg_name_dummy[NAME_LEN-UUID_LEN]; /* rest of v1 VG name */
  1191. + uint32_t vg_number; /* volume group number */
  1192. + uint32_t vg_access; /* read/write */
  1193. + uint32_t vg_status; /* active or not */
  1194. + uint32_t lv_max; /* maximum logical volumes */
  1195. + uint32_t lv_cur; /* current logical volumes */
  1196. + uint32_t lv_open; /* open logical volumes */
  1197. + uint32_t pv_max; /* maximum physical volumes */
  1198. + uint32_t pv_cur; /* current physical volumes FU */
  1199. + uint32_t pv_act; /* active physical volumes */
  1200. + uint32_t dummy;
  1201. + uint32_t vgda; /* volume group descriptor arrays FU */
  1202. + uint32_t pe_size; /* physical extent size in sectors */
  1203. + uint32_t pe_total; /* total of physical extents */
  1204. + uint32_t pe_allocated; /* allocated physical extents */
  1205. + uint32_t pvg_total; /* physical volume groups FU */
  1206. +} vg_disk_t;
  1207. +
  1208. +
  1209. +/*
  1210. + * Request structures for ioctls
  1211. + */
  1212. +
  1213. +/* Request structure PV_STATUS_BY_NAME... */
  1214. +typedef struct {
  1215. + char pv_name[NAME_LEN];
  1216. + pv_t *pv;
  1217. +} pv_status_req_t, pv_change_req_t;
  1218. +
  1219. +/* Request structure PV_FLUSH */
  1220. +typedef struct {
  1221. + char pv_name[NAME_LEN];
  1222. + kdev_t pv_dev;
  1223. +} pv_flush_req_t;
  1224. +
  1225. +
  1226. +/* Request structure PE_MOVE */
  1227. +typedef struct {
  1228. + enum {
  1229. + LOCK_PE, UNLOCK_PE
  1230. + } lock;
  1231. + struct {
  1232. + kdev_t lv_dev;
  1233. + kdev_t pv_dev;
  1234. + uint32_t pv_offset;
  1235. + } data;
  1236. +} pe_lock_req_t;
  1237. +
  1238. +
  1239. +/* Request structure LV_STATUS_BYNAME */
  1240. +typedef struct {
  1241. + char lv_name[NAME_LEN];
  1242. + lv_t *lv;
  1243. +} lv_status_byname_req_t, lv_req_t;
  1244. +
  1245. +/* Request structure LV_STATUS_BYINDEX */
  1246. +typedef struct {
  1247. + uint32_t lv_index;
  1248. + lv_t *lv;
  1249. + /* Transfer size because user space and kernel space differ */
  1250. + ushort size;
  1251. +} lv_status_byindex_req_t;
  1252. +
  1253. +/* Request structure LV_STATUS_BYDEV... */
  1254. +typedef struct {
  1255. + dev_t dev;
  1256. + lv_t *lv;
  1257. +} lv_status_bydev_req_t;
  1258. +
  1259. +
  1260. +/* Request structure LV_SNAPSHOT_USE_RATE */
  1261. +typedef struct {
  1262. + int block;
  1263. + int rate;
  1264. +} lv_snapshot_use_rate_req_t;
  1265. +
  1266. +
  1267. +
  1268. +/* useful inlines */
  1269. +static inline ulong round_up(ulong n, ulong size) {
  1270. + size--;
  1271. + return (n + size) & ~size;
  1272. +}
  1273. +
  1274. +static inline ulong div_up(ulong n, ulong size) {
  1275. + return round_up(n, size) / size;
  1276. +}
  1277. +
  1278. +/* FIXME: nasty capital letters */
  1279. +static int inline LVM_GET_COW_TABLE_CHUNKS_PER_PE(vg_t *vg, lv_t *lv) {
  1280. + return vg->pe_size / lv->lv_chunk_size;
  1281. +}
  1282. +
  1283. +static int inline LVM_GET_COW_TABLE_ENTRIES_PER_PE(vg_t *vg, lv_t *lv) {
  1284. + ulong chunks = vg->pe_size / lv->lv_chunk_size;
  1285. + ulong entry_size = sizeof(lv_COW_table_disk_t);
  1286. + ulong chunk_size = lv->lv_chunk_size * SECTOR_SIZE;
  1287. + ulong entries = (vg->pe_size * SECTOR_SIZE) /
  1288. + (entry_size + chunk_size);
  1289. +
  1290. + if(chunks < 2)
  1291. + return 0;
  1292. +
  1293. + for(; entries; entries--)
  1294. + if((div_up(entries * entry_size, chunk_size) + entries) <=
  1295. + chunks)
  1296. + break;
  1297. +
  1298. + return entries;
  1299. +}
  1300. +
  1301. +
  1302. +#endif /* #ifndef _LVM_H_INCLUDE */
  1303. +
  1304. diff -urN 1.0.8-orig/linux/major.h 1.0.8/linux/major.h
  1305. --- 1.0.8-orig/linux/major.h 1970-01-01 01:00:00.000000000 +0100
  1306. +++ 1.0.8/linux/major.h 2004-09-30 22:08:49.775449320 +0200
  1307. @@ -0,0 +1,198 @@
  1308. +#ifndef _LINUX_MAJOR_H
  1309. +#define _LINUX_MAJOR_H
  1310. +
  1311. +/*
  1312. + * This file has definitions for major device numbers.
  1313. + * For the device number assignments, see Documentation/devices.txt.
  1314. + */
  1315. +
  1316. +/* limits */
  1317. +
  1318. +/*
  1319. + * Important: Don't change this to 256. Major number 255 is and must be
  1320. + * reserved for future expansion into a larger dev_t space.
  1321. + */
  1322. +#define MAX_CHRDEV 255
  1323. +#define MAX_BLKDEV 255
  1324. +
  1325. +#define UNNAMED_MAJOR 0
  1326. +#define MEM_MAJOR 1
  1327. +#define RAMDISK_MAJOR 1
  1328. +#define FLOPPY_MAJOR 2
  1329. +#define PTY_MASTER_MAJOR 2
  1330. +#define IDE0_MAJOR 3
  1331. +#define PTY_SLAVE_MAJOR 3
  1332. +#define HD_MAJOR IDE0_MAJOR
  1333. +#define TTY_MAJOR 4
  1334. +#define TTYAUX_MAJOR 5
  1335. +#define LP_MAJOR 6
  1336. +#define VCS_MAJOR 7
  1337. +#define LOOP_MAJOR 7
  1338. +#define SCSI_DISK0_MAJOR 8
  1339. +#define SCSI_TAPE_MAJOR 9
  1340. +#define MD_MAJOR 9
  1341. +#define MISC_MAJOR 10
  1342. +#define SCSI_CDROM_MAJOR 11
  1343. +#define MUX_MAJOR 11 /* PA-RISC only */
  1344. +#define QIC02_TAPE_MAJOR 12
  1345. +#define XT_DISK_MAJOR 13
  1346. +#define SOUND_MAJOR 14
  1347. +#define CDU31A_CDROM_MAJOR 15
  1348. +#define JOYSTICK_MAJOR 15
  1349. +#define GOLDSTAR_CDROM_MAJOR 16
  1350. +#define OPTICS_CDROM_MAJOR 17
  1351. +#define SANYO_CDROM_MAJOR 18
  1352. +#define CYCLADES_MAJOR 19
  1353. +#define CYCLADESAUX_MAJOR 20
  1354. +#define MITSUMI_X_CDROM_MAJOR 20
  1355. +#define MFM_ACORN_MAJOR 21 /* ARM Linux /dev/mfm */
  1356. +#define SCSI_GENERIC_MAJOR 21
  1357. +#define Z8530_MAJOR 34
  1358. +#define DIGI_MAJOR 23
  1359. +#define IDE1_MAJOR 22
  1360. +#define DIGICU_MAJOR 22
  1361. +#define MITSUMI_CDROM_MAJOR 23
  1362. +#define CDU535_CDROM_MAJOR 24
  1363. +#define STL_SERIALMAJOR 24
  1364. +#define MATSUSHITA_CDROM_MAJOR 25
  1365. +#define STL_CALLOUTMAJOR 25
  1366. +#define MATSUSHITA_CDROM2_MAJOR 26
  1367. +#define QIC117_TAPE_MAJOR 27
  1368. +#define MATSUSHITA_CDROM3_MAJOR 27
  1369. +#define MATSUSHITA_CDROM4_MAJOR 28
  1370. +#define STL_SIOMEMMAJOR 28
  1371. +#define ACSI_MAJOR 28
  1372. +#define AZTECH_CDROM_MAJOR 29
  1373. +#define GRAPHDEV_MAJOR 29 /* SparcLinux & Linux/68k /dev/fb */
  1374. +#define SHMIQ_MAJOR 85 /* Linux/mips, SGI /dev/shmiq */
  1375. +#define CM206_CDROM_MAJOR 32
  1376. +#define IDE2_MAJOR 33
  1377. +#define IDE3_MAJOR 34
  1378. +#define XPRAM_MAJOR 35 /* expanded storage on S/390 = "slow ram" */
  1379. + /* proposed by Peter */
  1380. +#define NETLINK_MAJOR 36
  1381. +#define PS2ESDI_MAJOR 36
  1382. +#define IDETAPE_MAJOR 37
  1383. +#define Z2RAM_MAJOR 37
  1384. +#define APBLOCK_MAJOR 38 /* AP1000 Block device */
  1385. +#define DDV_MAJOR 39 /* AP1000 DDV block device */
  1386. +#define NBD_MAJOR 43 /* Network block device */
  1387. +#define RISCOM8_NORMAL_MAJOR 48
  1388. +#define DAC960_MAJOR 48 /* 48..55 */
  1389. +#define RISCOM8_CALLOUT_MAJOR 49
  1390. +#define MKISS_MAJOR 55
  1391. +#define DSP56K_MAJOR 55 /* DSP56001 processor device */
  1392. +
  1393. +#define IDE4_MAJOR 56
  1394. +#define IDE5_MAJOR 57
  1395. +
  1396. +#define LVM_BLK_MAJOR 58 /* Logical Volume Manager */
  1397. +
  1398. +#define SCSI_DISK1_MAJOR 65
  1399. +#define SCSI_DISK2_MAJOR 66
  1400. +#define SCSI_DISK3_MAJOR 67
  1401. +#define SCSI_DISK4_MAJOR 68
  1402. +#define SCSI_DISK5_MAJOR 69
  1403. +#define SCSI_DISK6_MAJOR 70
  1404. +#define SCSI_DISK7_MAJOR 71
  1405. +
  1406. +
  1407. +#define COMPAQ_SMART2_MAJOR 72
  1408. +#define COMPAQ_SMART2_MAJOR1 73
  1409. +#define COMPAQ_SMART2_MAJOR2 74
  1410. +#define COMPAQ_SMART2_MAJOR3 75
  1411. +#define COMPAQ_SMART2_MAJOR4 76
  1412. +#define COMPAQ_SMART2_MAJOR5 77
  1413. +#define COMPAQ_SMART2_MAJOR6 78
  1414. +#define COMPAQ_SMART2_MAJOR7 79
  1415. +
  1416. +#define SPECIALIX_NORMAL_MAJOR 75
  1417. +#define SPECIALIX_CALLOUT_MAJOR 76
  1418. +
  1419. +#define COMPAQ_CISS_MAJOR 104
  1420. +#define COMPAQ_CISS_MAJOR1 105
  1421. +#define COMPAQ_CISS_MAJOR2 106
  1422. +#define COMPAQ_CISS_MAJOR3 107
  1423. +#define COMPAQ_CISS_MAJOR4 108
  1424. +#define COMPAQ_CISS_MAJOR5 109
  1425. +#define COMPAQ_CISS_MAJOR6 110
  1426. +#define COMPAQ_CISS_MAJOR7 111
  1427. +
  1428. +#define ATARAID_MAJOR 114
  1429. +
  1430. +#define DASD_MAJOR 94 /* Official assignations from Peter */
  1431. +
  1432. +#define MDISK_MAJOR 95 /* Official assignations from Peter */
  1433. +
  1434. +#define I2O_MAJOR 80 /* 80->87 */
  1435. +
  1436. +#define IDE6_MAJOR 88
  1437. +#define IDE7_MAJOR 89
  1438. +#define IDE8_MAJOR 90
  1439. +#define IDE9_MAJOR 91
  1440. +
  1441. +#define UBD_MAJOR 98
  1442. +
  1443. +#define AURORA_MAJOR 79
  1444. +
  1445. +#define JSFD_MAJOR 99
  1446. +
  1447. +#define PHONE_MAJOR 100
  1448. +
  1449. +#define LVM_CHAR_MAJOR 109 /* Logical Volume Manager */
  1450. +
  1451. +#define UMEM_MAJOR 116 /* http://www.umem.com/ Battery Backed RAM */
  1452. +
  1453. +#define RTF_MAJOR 150
  1454. +#define RAW_MAJOR 162
  1455. +
  1456. +#define USB_ACM_MAJOR 166
  1457. +#define USB_ACM_AUX_MAJOR 167
  1458. +#define USB_CHAR_MAJOR 180
  1459. +
  1460. +#define UNIX98_PTY_MASTER_MAJOR 128
  1461. +#define UNIX98_PTY_MAJOR_COUNT 8
  1462. +#define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT)
  1463. +
  1464. +#define VXVM_MAJOR 199 /* VERITAS volume i/o driver */
  1465. +#define VXSPEC_MAJOR 200 /* VERITAS volume config driver */
  1466. +#define VXDMP_MAJOR 201 /* VERITAS volume multipath driver */
  1467. +
  1468. +#define MSR_MAJOR 202
  1469. +#define CPUID_MAJOR 203
  1470. +
  1471. +#define OSST_MAJOR 206 /* OnStream-SCx0 SCSI tape */
  1472. +
  1473. +#define IBM_TTY3270_MAJOR 227 /* Official allocations now */
  1474. +#define IBM_FS3270_MAJOR 228
  1475. +
  1476. +/*
  1477. + * Tests for SCSI devices.
  1478. + */
  1479. +
  1480. +#define SCSI_DISK_MAJOR(M) ((M) == SCSI_DISK0_MAJOR || \
  1481. + ((M) >= SCSI_DISK1_MAJOR && (M) <= SCSI_DISK7_MAJOR))
  1482. +
  1483. +#define SCSI_BLK_MAJOR(M) \
  1484. + (SCSI_DISK_MAJOR(M) \
  1485. + || (M) == SCSI_CDROM_MAJOR)
  1486. +
  1487. +static __inline__ int scsi_blk_major(int m) {
  1488. + return SCSI_BLK_MAJOR(m);
  1489. +}
  1490. +
  1491. +/*
  1492. + * Tests for IDE devices
  1493. + */
  1494. +#define IDE_DISK_MAJOR(M) ((M) == IDE0_MAJOR || (M) == IDE1_MAJOR || \
  1495. + (M) == IDE2_MAJOR || (M) == IDE3_MAJOR || \
  1496. + (M) == IDE4_MAJOR || (M) == IDE5_MAJOR || \
  1497. + (M) == IDE6_MAJOR || (M) == IDE7_MAJOR || \
  1498. + (M) == IDE8_MAJOR || (M) == IDE9_MAJOR)
  1499. +
  1500. +static __inline__ int ide_blk_major(int m)
  1501. +{
  1502. + return IDE_DISK_MAJOR(m);
  1503. +}
  1504. +
  1505. +#endif