mirror of the now-defunct rocklinux.org
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.

3227 lines
107 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/powerpc/mac-fdisk/own-kernel-headers.patch
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  10. #
  11. # This patch file is dual-licensed. It is available under the license the
  12. # patched project is licensed under, as long as it is an OpenSource license
  13. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  14. # of the GNU General Public License as published by the Free Software
  15. # Foundation; either version 2 of the License, or (at your option) any later
  16. # version.
  17. #
  18. # --- ROCK-COPYRIGHT-NOTE-END ---
  19. --- ./linux/fs.h 1970-01-01 00:00:00.000000000 +0000
  20. +++ ./linux/fs.h 2004-08-20 03:20:18.126182280 +0000
  21. @@ -0,0 +1,1724 @@
  22. +#ifndef _LINUX_FS_H
  23. +#define _LINUX_FS_H
  24. +
  25. +/*
  26. + * This file has definitions for some important file table
  27. + * structures etc.
  28. + */
  29. +
  30. +#include <linux/config.h>
  31. +#include <linux/linkage.h>
  32. +#include <linux/limits.h>
  33. +#include <linux/wait.h>
  34. +#include <linux/types.h>
  35. +#include "vfs.h"
  36. +#include <linux/net.h>
  37. +#include <linux/kdev_t.h>
  38. +#include <linux/ioctl.h>
  39. +#include "list.h"
  40. +#include <linux/dcache.h>
  41. +#include <linux/stat.h>
  42. +#include <linux/cache.h>
  43. +#include <linux/stddef.h>
  44. +#include <linux/string.h>
  45. +
  46. +#include <asm/atomic.h>
  47. +#include <asm/bitops.h>
  48. +
  49. +struct poll_table_struct;
  50. +
  51. +
  52. +/*
  53. + * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
  54. + * the file limit at runtime and only root can increase the per-process
  55. + * nr_file rlimit, so it's safe to set up a ridiculously high absolute
  56. + * upper limit on files-per-process.
  57. + *
  58. + * Some programs (notably those using select()) may have to be
  59. + * recompiled to take full advantage of the new limits..
  60. + */
  61. +
  62. +/* Fixed constants first: */
  63. +#undef NR_OPEN
  64. +#define NR_OPEN (1024*1024) /* Absolute upper limit on fd num */
  65. +#define INR_OPEN 1024 /* Initial setting for nfile rlimits */
  66. +
  67. +#define BLOCK_SIZE_BITS 10
  68. +#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
  69. +
  70. +/* And dynamically-tunable limits and defaults: */
  71. +struct files_stat_struct {
  72. + int nr_files; /* read only */
  73. + int nr_free_files; /* read only */
  74. + int max_files; /* tunable */
  75. +};
  76. +extern struct files_stat_struct files_stat;
  77. +
  78. +struct inodes_stat_t {
  79. + int nr_inodes;
  80. + int nr_unused;
  81. + int dummy[5];
  82. +};
  83. +extern struct inodes_stat_t inodes_stat;
  84. +
  85. +extern int leases_enable, dir_notify_enable, lease_break_time;
  86. +
  87. +#define NR_FILE 8192 /* this can well be larger on a larger system */
  88. +#define NR_RESERVED_FILES 10 /* reserved for root */
  89. +#define NR_SUPER 256
  90. +
  91. +#define MAY_EXEC 1
  92. +#define MAY_WRITE 2
  93. +#define MAY_READ 4
  94. +
  95. +#define FMODE_READ 1
  96. +#define FMODE_WRITE 2
  97. +
  98. +#define READ 0
  99. +#define WRITE 1
  100. +#define READA 2 /* read-ahead - don't block if no resources */
  101. +#define SPECIAL 4 /* For non-blockdevice requests in request queue */
  102. +
  103. +#define SEL_IN 1
  104. +#define SEL_OUT 2
  105. +#define SEL_EX 4
  106. +
  107. +/* public flags for file_system_type */
  108. +#define FS_REQUIRES_DEV 1
  109. +#define FS_NO_DCACHE 2 /* Only dcache the necessary things. */
  110. +#define FS_NO_PRELIM 4 /* prevent preloading of dentries, even if
  111. + * FS_NO_DCACHE is not set.
  112. + */
  113. +#define FS_SINGLE 8 /* Filesystem that can have only one superblock */
  114. +#define FS_NOMOUNT 16 /* Never mount from userland */
  115. +#define FS_LITTER 32 /* Keeps the tree in dcache */
  116. +#define FS_ODD_RENAME 32768 /* Temporary stuff; will go away as soon
  117. + * as nfs_rename() will be cleaned up
  118. + */
  119. +/*
  120. + * These are the fs-independent mount-flags: up to 32 flags are supported
  121. + */
  122. +#define MS_RDONLY 1 /* Mount read-only */
  123. +#define MS_NOSUID 2 /* Ignore suid and sgid bits */
  124. +#define MS_NODEV 4 /* Disallow access to device special files */
  125. +#define MS_NOEXEC 8 /* Disallow program execution */
  126. +#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
  127. +#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
  128. +#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
  129. +#define MS_NOATIME 1024 /* Do not update access times. */
  130. +#define MS_NODIRATIME 2048 /* Do not update directory access times */
  131. +#define MS_BIND 4096
  132. +#define MS_MOVE 8192
  133. +#define MS_REC 16384
  134. +#define MS_VERBOSE 32768
  135. +#define MS_ACTIVE (1<<30)
  136. +#define MS_NOUSER (1<<31)
  137. +
  138. +/*
  139. + * Superblock flags that can be altered by MS_REMOUNT
  140. + */
  141. +#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|\
  142. + MS_NODIRATIME)
  143. +
  144. +/*
  145. + * Old magic mount flag and mask
  146. + */
  147. +#define MS_MGC_VAL 0xC0ED0000
  148. +#define MS_MGC_MSK 0xffff0000
  149. +
  150. +/* Inode flags - they have nothing to superblock flags now */
  151. +
  152. +#define S_SYNC 1 /* Writes are synced at once */
  153. +#define S_NOATIME 2 /* Do not update access times */
  154. +#define S_QUOTA 4 /* Quota initialized for file */
  155. +#define S_APPEND 8 /* Append-only file */
  156. +#define S_IMMUTABLE 16 /* Immutable file */
  157. +#define S_DEAD 32 /* removed, but still open directory */
  158. +#define S_NOQUOTA 64 /* Inode is not counted to quota */
  159. +
  160. +/*
  161. + * Note that nosuid etc flags are inode-specific: setting some file-system
  162. + * flags just means all the inodes inherit those flags by default. It might be
  163. + * possible to override it selectively if you really wanted to with some
  164. + * ioctl() that is not currently implemented.
  165. + *
  166. + * Exception: MS_RDONLY is always applied to the entire file system.
  167. + *
  168. + * Unfortunately, it is possible to change a filesystems flags with it mounted
  169. + * with files in use. This means that all of the inodes will not have their
  170. + * i_flags updated. Hence, i_flags no longer inherit the superblock mount
  171. + * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
  172. + */
  173. +#define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
  174. +
  175. +#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
  176. +#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || ((inode)->i_flags & S_SYNC))
  177. +#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
  178. +
  179. +#define IS_QUOTAINIT(inode) ((inode)->i_flags & S_QUOTA)
  180. +#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
  181. +#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
  182. +#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
  183. +#define IS_NOATIME(inode) (__IS_FLG(inode, MS_NOATIME) || ((inode)->i_flags & S_NOATIME))
  184. +#define IS_NODIRATIME(inode) __IS_FLG(inode, MS_NODIRATIME)
  185. +
  186. +#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
  187. +
  188. +/* the read-only stuff doesn't really belong here, but any other place is
  189. + probably as bad and I don't want to create yet another include file. */
  190. +
  191. +#define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
  192. +#define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
  193. +#define BLKRRPART _IO(0x12,95) /* re-read partition table */
  194. +#define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
  195. +#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
  196. +#define BLKRASET _IO(0x12,98) /* Set read ahead for block device */
  197. +#define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
  198. +#define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
  199. +#define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
  200. +#define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
  201. +#define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
  202. +#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
  203. +#if 0
  204. +#define BLKPG _IO(0x12,105)/* See blkpg.h */
  205. +#define BLKELVGET _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))/* elevator get */
  206. +#define BLKELVSET _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))/* elevator set */
  207. +/* This was here just to show that the number is taken -
  208. + probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
  209. +#endif
  210. +/* A jump here: 108-111 have been used for various private purposes. */
  211. +#define BLKBSZGET _IOR(0x12,112,sizeof(int))
  212. +#define BLKBSZSET _IOW(0x12,113,sizeof(int))
  213. +#define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64)) /* return device size in bytes (u64 *arg) */
  214. +
  215. +#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
  216. +#define FIBMAP _IO(0x00,1) /* bmap access */
  217. +#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
  218. +
  219. +#ifdef __KERNEL__
  220. +
  221. +#include <asm/semaphore.h>
  222. +#include <asm/byteorder.h>
  223. +
  224. +extern void update_atime (struct inode *);
  225. +extern void update_mctime (struct inode *);
  226. +#define UPDATE_ATIME(inode) update_atime (inode)
  227. +
  228. +extern void buffer_init(unsigned long);
  229. +extern void inode_init(unsigned long);
  230. +extern void mnt_init(unsigned long);
  231. +extern void files_init(unsigned long mempages);
  232. +
  233. +/* bh state bits */
  234. +enum bh_state_bits {
  235. + BH_Uptodate, /* 1 if the buffer contains valid data */
  236. + BH_Dirty, /* 1 if the buffer is dirty */
  237. + BH_Lock, /* 1 if the buffer is locked */
  238. + BH_Req, /* 0 if the buffer has been invalidated */
  239. + BH_Mapped, /* 1 if the buffer has a disk mapping */
  240. + BH_New, /* 1 if the buffer is new and not yet written out */
  241. + BH_Async, /* 1 if the buffer is under end_buffer_io_async I/O */
  242. + BH_Wait_IO, /* 1 if we should write out this buffer */
  243. + BH_Launder, /* 1 if we can throttle on this buffer */
  244. + BH_Attached, /* 1 if b_inode_buffers is linked into a list */
  245. + BH_JBD, /* 1 if it has an attached journal_head */
  246. + BH_Sync, /* 1 if the buffer is a sync read */
  247. + BH_Delay, /* 1 if the buffer is delayed allocate */
  248. +
  249. + BH_PrivateStart,/* not a state bit, but the first bit available
  250. + * for private allocation by other entities
  251. + */
  252. +};
  253. +
  254. +#define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)
  255. +
  256. +/*
  257. + * Try to keep the most commonly used fields in single cache lines (16
  258. + * bytes) to improve performance. This ordering should be
  259. + * particularly beneficial on 32-bit processors.
  260. + *
  261. + * We use the first 16 bytes for the data which is used in searches
  262. + * over the block hash lists (ie. getblk() and friends).
  263. + *
  264. + * The second 16 bytes we use for lru buffer scans, as used by
  265. + * sync_buffers() and refill_freelist(). -- sct
  266. + */
  267. +struct buffer_head {
  268. + /* First cache line: */
  269. + struct buffer_head *b_next; /* Hash queue list */
  270. + unsigned long b_blocknr; /* block number */
  271. + unsigned short b_size; /* block size */
  272. + unsigned short b_list; /* List that this buffer appears */
  273. + kdev_t b_dev; /* device (B_FREE = free) */
  274. +
  275. + atomic_t b_count; /* users using this block */
  276. + kdev_t b_rdev; /* Real device */
  277. + unsigned long b_state; /* buffer state bitmap (see above) */
  278. + unsigned long b_flushtime; /* Time when (dirty) buffer should be written */
  279. +
  280. + struct buffer_head *b_next_free;/* lru/free list linkage */
  281. + struct buffer_head *b_prev_free;/* doubly linked list of buffers */
  282. + struct buffer_head *b_this_page;/* circular list of buffers in one page */
  283. + struct buffer_head *b_reqnext; /* request queue */
  284. +
  285. + struct buffer_head **b_pprev; /* doubly linked list of hash-queue */
  286. + char * b_data; /* pointer to data block */
  287. + struct page *b_page; /* the page this bh is mapped to */
  288. + void (*b_end_io)(struct buffer_head *bh, int uptodate); /* I/O completion */
  289. + void *b_private; /* reserved for b_end_io */
  290. +
  291. + unsigned long b_rsector; /* Real buffer location on disk */
  292. + wait_queue_head_t b_wait;
  293. +
  294. + struct list_head b_inode_buffers; /* doubly linked list of inode dirty buffers */
  295. +};
  296. +
  297. +typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
  298. +void init_buffer(struct buffer_head *, bh_end_io_t *, void *);
  299. +
  300. +#define __buffer_state(bh, state) (((bh)->b_state & (1UL << BH_##state)) != 0)
  301. +
  302. +#define buffer_uptodate(bh) __buffer_state(bh,Uptodate)
  303. +#define buffer_dirty(bh) __buffer_state(bh,Dirty)
  304. +#define buffer_locked(bh) __buffer_state(bh,Lock)
  305. +#define buffer_req(bh) __buffer_state(bh,Req)
  306. +#define buffer_mapped(bh) __buffer_state(bh,Mapped)
  307. +#define buffer_new(bh) __buffer_state(bh,New)
  308. +#define buffer_async(bh) __buffer_state(bh,Async)
  309. +#define buffer_launder(bh) __buffer_state(bh,Launder)
  310. +#define buffer_delay(bh) __buffer_state(bh,Delay)
  311. +
  312. +#define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
  313. +
  314. +extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long offset);
  315. +
  316. +#define touch_buffer(bh) mark_page_accessed(bh->b_page)
  317. +
  318. +
  319. +#include <linux/pipe_fs_i.h>
  320. +#include <linux/minix_fs_i.h>
  321. +#include <linux/ext2_fs_i.h>
  322. +#include <linux/ext3_fs_i.h>
  323. +#include <linux/hpfs_fs_i.h>
  324. +#include <linux/ntfs_fs_i.h>
  325. +#include <linux/msdos_fs_i.h>
  326. +#include <linux/umsdos_fs_i.h>
  327. +#include <linux/iso_fs_i.h>
  328. +#include <linux/nfs_fs_i.h>
  329. +#include <linux/sysv_fs_i.h>
  330. +#include <linux/affs_fs_i.h>
  331. +#include <linux/ufs_fs_i.h>
  332. +#include <linux/efs_fs_i.h>
  333. +#include <linux/coda_fs_i.h>
  334. +#include <linux/romfs_fs_i.h>
  335. +#include <linux/shmem_fs.h>
  336. +#include <linux/smb_fs_i.h>
  337. +#include <linux/hfs_fs_i.h>
  338. +#include <linux/adfs_fs_i.h>
  339. +#include <linux/qnx4_fs_i.h>
  340. +#include <linux/reiserfs_fs_i.h>
  341. +#include <linux/bfs_fs_i.h>
  342. +#include <linux/udf_fs_i.h>
  343. +#include <linux/ncp_fs_i.h>
  344. +#include <linux/proc_fs_i.h>
  345. +#include <linux/usbdev_fs_i.h>
  346. +#include <linux/jffs2_fs_i.h>
  347. +#include <linux/cramfs_fs_sb.h>
  348. +
  349. +/*
  350. + * Attribute flags. These should be or-ed together to figure out what
  351. + * has been changed!
  352. + */
  353. +#define ATTR_MODE 1
  354. +#define ATTR_UID 2
  355. +#define ATTR_GID 4
  356. +#define ATTR_SIZE 8
  357. +#define ATTR_ATIME 16
  358. +#define ATTR_MTIME 32
  359. +#define ATTR_CTIME 64
  360. +#define ATTR_ATIME_SET 128
  361. +#define ATTR_MTIME_SET 256
  362. +#define ATTR_FORCE 512 /* Not a change, but a change it */
  363. +#define ATTR_ATTR_FLAG 1024
  364. +
  365. +/*
  366. + * This is the Inode Attributes structure, used for notify_change(). It
  367. + * uses the above definitions as flags, to know which values have changed.
  368. + * Also, in this manner, a Filesystem can look at only the values it cares
  369. + * about. Basically, these are the attributes that the VFS layer can
  370. + * request to change from the FS layer.
  371. + *
  372. + * Derek Atkins <warlord@MIT.EDU> 94-10-20
  373. + */
  374. +struct iattr {
  375. + unsigned int ia_valid;
  376. + umode_t ia_mode;
  377. + uid_t ia_uid;
  378. + gid_t ia_gid;
  379. + loff_t ia_size;
  380. + time_t ia_atime;
  381. + time_t ia_mtime;
  382. + time_t ia_ctime;
  383. + unsigned int ia_attr_flags;
  384. +};
  385. +
  386. +/*
  387. + * This is the inode attributes flag definitions
  388. + */
  389. +#define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */
  390. +#define ATTR_FLAG_NOATIME 2 /* Don't update atime */
  391. +#define ATTR_FLAG_APPEND 4 /* Append-only file */
  392. +#define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
  393. +#define ATTR_FLAG_NODIRATIME 16 /* Don't update atime for directory */
  394. +
  395. +/*
  396. + * Includes for diskquotas and mount structures.
  397. + */
  398. +#include <linux/quota.h>
  399. +#include <linux/mount.h>
  400. +
  401. +/*
  402. + * oh the beauties of C type declarations.
  403. + */
  404. +struct page;
  405. +struct address_space;
  406. +struct kiobuf;
  407. +
  408. +struct address_space_operations {
  409. + int (*writepage)(struct page *);
  410. + int (*readpage)(struct file *, struct page *);
  411. + int (*sync_page)(struct page *);
  412. + /*
  413. + * ext3 requires that a successful prepare_write() call be followed
  414. + * by a commit_write() call - they must be balanced
  415. + */
  416. + int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
  417. + int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
  418. + /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
  419. + int (*bmap)(struct address_space *, long);
  420. + int (*flushpage) (struct page *, unsigned long);
  421. + int (*releasepage) (struct page *, int);
  422. +#define KERNEL_HAS_O_DIRECT /* this is for modules out of the kernel */
  423. + int (*direct_IO)(int, struct inode *, struct kiobuf *, unsigned long, int);
  424. +#define KERNEL_HAS_DIRECT_FILEIO /* Unfortunate kludge due to lack of foresight */
  425. + int (*direct_fileIO)(int, struct file *, struct kiobuf *, unsigned long, int);
  426. + void (*removepage)(struct page *); /* called when page gets removed from the inode */
  427. +};
  428. +
  429. +struct address_space {
  430. + struct list_head clean_pages; /* list of clean pages */
  431. + struct list_head dirty_pages; /* list of dirty pages */
  432. + struct list_head locked_pages; /* list of locked pages */
  433. + unsigned long nrpages; /* number of total pages */
  434. + struct address_space_operations *a_ops; /* methods */
  435. + struct inode *host; /* owner: inode, block_device */
  436. + struct vm_area_struct *i_mmap; /* list of private mappings */
  437. + struct vm_area_struct *i_mmap_shared; /* list of shared mappings */
  438. + spinlock_t i_shared_lock; /* and spinlock protecting it */
  439. + int gfp_mask; /* how to allocate the pages */
  440. +};
  441. +
  442. +struct char_device {
  443. + struct list_head hash;
  444. + atomic_t count;
  445. + dev_t dev;
  446. + atomic_t openers;
  447. + struct semaphore sem;
  448. +};
  449. +
  450. +struct block_device {
  451. + struct list_head bd_hash;
  452. + atomic_t bd_count;
  453. + struct inode * bd_inode;
  454. + dev_t bd_dev; /* not a kdev_t - it's a search key */
  455. + int bd_openers;
  456. + const struct block_device_operations *bd_op;
  457. + struct semaphore bd_sem; /* open/close mutex */
  458. + struct list_head bd_inodes;
  459. +};
  460. +
  461. +struct inode {
  462. + struct list_head i_hash;
  463. + struct list_head i_list;
  464. + struct list_head i_dentry;
  465. +
  466. + struct list_head i_dirty_buffers;
  467. + struct list_head i_dirty_data_buffers;
  468. +
  469. + unsigned long i_ino;
  470. + atomic_t i_count;
  471. + kdev_t i_dev;
  472. + umode_t i_mode;
  473. + nlink_t i_nlink;
  474. + uid_t i_uid;
  475. + gid_t i_gid;
  476. + kdev_t i_rdev;
  477. + loff_t i_size;
  478. + time_t i_atime;
  479. + time_t i_mtime;
  480. + time_t i_ctime;
  481. + unsigned int i_blkbits;
  482. + unsigned long i_blksize;
  483. + unsigned long i_blocks;
  484. + unsigned long i_version;
  485. + unsigned short i_bytes;
  486. + struct semaphore i_sem;
  487. + struct rw_semaphore i_alloc_sem;
  488. + struct semaphore i_zombie;
  489. + struct inode_operations *i_op;
  490. + struct file_operations *i_fop; /* former ->i_op->default_file_ops */
  491. + struct super_block *i_sb;
  492. + wait_queue_head_t i_wait;
  493. + struct file_lock *i_flock;
  494. + struct address_space *i_mapping;
  495. + struct address_space i_data;
  496. + struct dquot *i_dquot[MAXQUOTAS];
  497. + /* These three should probably be a union */
  498. + struct list_head i_devices;
  499. + struct pipe_inode_info *i_pipe;
  500. + struct block_device *i_bdev;
  501. + struct char_device *i_cdev;
  502. +
  503. + unsigned long i_dnotify_mask; /* Directory notify events */
  504. + struct dnotify_struct *i_dnotify; /* for directory notifications */
  505. +
  506. + unsigned long i_state;
  507. +
  508. + unsigned int i_flags;
  509. + unsigned char i_sock;
  510. +
  511. + atomic_t i_writecount;
  512. + unsigned int i_attr_flags;
  513. + __u32 i_generation;
  514. + union {
  515. + struct minix_inode_info minix_i;
  516. + struct ext2_inode_info ext2_i;
  517. + struct ext3_inode_info ext3_i;
  518. + struct hpfs_inode_info hpfs_i;
  519. + struct ntfs_inode_info ntfs_i;
  520. + struct msdos_inode_info msdos_i;
  521. + struct umsdos_inode_info umsdos_i;
  522. + struct iso_inode_info isofs_i;
  523. + struct nfs_inode_info nfs_i;
  524. + struct sysv_inode_info sysv_i;
  525. + struct affs_inode_info affs_i;
  526. + struct ufs_inode_info ufs_i;
  527. + struct efs_inode_info efs_i;
  528. + struct romfs_inode_info romfs_i;
  529. + struct shmem_inode_info shmem_i;
  530. + struct coda_inode_info coda_i;
  531. + struct smb_inode_info smbfs_i;
  532. + struct hfs_inode_info hfs_i;
  533. + struct adfs_inode_info adfs_i;
  534. + struct qnx4_inode_info qnx4_i;
  535. + struct reiserfs_inode_info reiserfs_i;
  536. + struct bfs_inode_info bfs_i;
  537. + struct udf_inode_info udf_i;
  538. + struct ncp_inode_info ncpfs_i;
  539. + struct proc_inode_info proc_i;
  540. + struct socket socket_i;
  541. + struct usbdev_inode_info usbdev_i;
  542. + struct jffs2_inode_info jffs2_i;
  543. + void *generic_ip;
  544. + } u;
  545. +};
  546. +
  547. +static inline void inode_add_bytes(struct inode *inode, loff_t bytes)
  548. +{
  549. + inode->i_blocks += bytes >> 9;
  550. + bytes &= 511;
  551. + inode->i_bytes += bytes;
  552. + if (inode->i_bytes >= 512) {
  553. + inode->i_blocks++;
  554. + inode->i_bytes -= 512;
  555. + }
  556. +}
  557. +
  558. +static inline void inode_sub_bytes(struct inode *inode, loff_t bytes)
  559. +{
  560. + inode->i_blocks -= bytes >> 9;
  561. + bytes &= 511;
  562. + if (inode->i_bytes < bytes) {
  563. + inode->i_blocks--;
  564. + inode->i_bytes += 512;
  565. + }
  566. + inode->i_bytes -= bytes;
  567. +}
  568. +
  569. +static inline loff_t inode_get_bytes(struct inode *inode)
  570. +{
  571. + return (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
  572. +}
  573. +
  574. +static inline void inode_set_bytes(struct inode *inode, loff_t bytes)
  575. +{
  576. + inode->i_blocks = bytes >> 9;
  577. + inode->i_bytes = bytes & 511;
  578. +}
  579. +
  580. +struct fown_struct {
  581. + int pid; /* pid or -pgrp where SIGIO should be sent */
  582. + uid_t uid, euid; /* uid/euid of process setting the owner */
  583. + int signum; /* posix.1b rt signal to be delivered on IO */
  584. +};
  585. +
  586. +struct file {
  587. + struct list_head f_list;
  588. + struct dentry *f_dentry;
  589. + struct vfsmount *f_vfsmnt;
  590. + struct file_operations *f_op;
  591. + atomic_t f_count;
  592. + unsigned int f_flags;
  593. + mode_t f_mode;
  594. + loff_t f_pos;
  595. + unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
  596. + struct fown_struct f_owner;
  597. + unsigned int f_uid, f_gid;
  598. + int f_error;
  599. +
  600. + unsigned long f_version;
  601. +
  602. + /* needed for tty driver, and maybe others */
  603. + void *private_data;
  604. +
  605. + /* preallocated helper kiobuf to speedup O_DIRECT */
  606. + struct kiobuf *f_iobuf;
  607. + long f_iobuf_lock;
  608. +};
  609. +extern spinlock_t files_lock;
  610. +#define file_list_lock() spin_lock(&files_lock);
  611. +#define file_list_unlock() spin_unlock(&files_lock);
  612. +
  613. +#define get_file(x) atomic_inc(&(x)->f_count)
  614. +#define file_count(x) atomic_read(&(x)->f_count)
  615. +
  616. +extern int init_private_file(struct file *, struct dentry *, int);
  617. +
  618. +#define MAX_NON_LFS ((1UL<<31) - 1)
  619. +
  620. +/* Page cache limit. The filesystems should put that into their s_maxbytes
  621. + limits, otherwise bad things can happen in VM. */
  622. +#if BITS_PER_LONG==32
  623. +#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
  624. +#elif BITS_PER_LONG==64
  625. +#define MAX_LFS_FILESIZE 0x7fffffffffffffff
  626. +#endif
  627. +
  628. +#define FL_POSIX 1
  629. +#define FL_FLOCK 2
  630. +#define FL_BROKEN 4 /* broken flock() emulation */
  631. +#define FL_ACCESS 8 /* for processes suspended by mandatory locking */
  632. +#define FL_LOCKD 16 /* lock held by rpc.lockd */
  633. +#define FL_LEASE 32 /* lease held on this file */
  634. +
  635. +/*
  636. + * The POSIX file lock owner is determined by
  637. + * the "struct files_struct" in the thread group
  638. + * (or NULL for no owner - BSD locks).
  639. + *
  640. + * Lockd stuffs a "host" pointer into this.
  641. + */
  642. +typedef struct files_struct *fl_owner_t;
  643. +
  644. +struct file_lock {
  645. + struct file_lock *fl_next; /* singly linked list for this inode */
  646. + struct list_head fl_link; /* doubly linked list of all locks */
  647. + struct list_head fl_block; /* circular list of blocked processes */
  648. + fl_owner_t fl_owner;
  649. + unsigned int fl_pid;
  650. + wait_queue_head_t fl_wait;
  651. + struct file *fl_file;
  652. + unsigned char fl_flags;
  653. + unsigned char fl_type;
  654. + loff_t fl_start;
  655. + loff_t fl_end;
  656. +
  657. + void (*fl_notify)(struct file_lock *); /* unblock callback */
  658. + void (*fl_insert)(struct file_lock *); /* lock insertion callback */
  659. + void (*fl_remove)(struct file_lock *); /* lock removal callback */
  660. +
  661. + struct fasync_struct * fl_fasync; /* for lease break notifications */
  662. + unsigned long fl_break_time; /* for nonblocking lease breaks */
  663. +
  664. + union {
  665. + struct nfs_lock_info nfs_fl;
  666. + } fl_u;
  667. +};
  668. +
  669. +/* The following constant reflects the upper bound of the file/locking space */
  670. +#ifndef OFFSET_MAX
  671. +#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))
  672. +#define OFFSET_MAX INT_LIMIT(loff_t)
  673. +#define OFFT_OFFSET_MAX INT_LIMIT(off_t)
  674. +#endif
  675. +
  676. +extern struct list_head file_lock_list;
  677. +
  678. +#include <linux/fcntl.h>
  679. +
  680. +extern int fcntl_getlk(unsigned int, struct flock *);
  681. +extern int fcntl_setlk(unsigned int, unsigned int, struct flock *);
  682. +
  683. +extern int fcntl_getlk64(unsigned int, struct flock64 *);
  684. +extern int fcntl_setlk64(unsigned int, unsigned int, struct flock64 *);
  685. +
  686. +/* fs/locks.c */
  687. +extern void locks_init_lock(struct file_lock *);
  688. +extern void locks_copy_lock(struct file_lock *, struct file_lock *);
  689. +extern void locks_remove_posix(struct file *, fl_owner_t);
  690. +extern void locks_remove_flock(struct file *);
  691. +extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);
  692. +extern int posix_lock_file(struct file *, struct file_lock *, unsigned int);
  693. +extern void posix_block_lock(struct file_lock *, struct file_lock *);
  694. +extern void posix_unblock_lock(struct file_lock *);
  695. +extern int posix_locks_deadlock(struct file_lock *, struct file_lock *);
  696. +extern int __get_lease(struct inode *inode, unsigned int flags);
  697. +extern time_t lease_get_mtime(struct inode *);
  698. +extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
  699. +extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
  700. +extern void steal_locks(fl_owner_t from);
  701. +
  702. +struct fasync_struct {
  703. + int magic;
  704. + int fa_fd;
  705. + struct fasync_struct *fa_next; /* singly linked list */
  706. + struct file *fa_file;
  707. +};
  708. +
  709. +#define FASYNC_MAGIC 0x4601
  710. +
  711. +/* SMP safe fasync helpers: */
  712. +extern int fasync_helper(int, struct file *, int, struct fasync_struct **);
  713. +/* can be called from interrupts */
  714. +extern void kill_fasync(struct fasync_struct **, int, int);
  715. +/* only for net: no internal synchronization */
  716. +extern void __kill_fasync(struct fasync_struct *, int, int);
  717. +
  718. +struct nameidata {
  719. + struct dentry *dentry;
  720. + struct vfsmount *mnt;
  721. + struct qstr last;
  722. + unsigned int flags;
  723. + int last_type;
  724. +};
  725. +
  726. +/*
  727. + * Umount options
  728. + */
  729. +
  730. +#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
  731. +#define MNT_DETACH 0x00000002 /* Just detach from the tree */
  732. +
  733. +#include <linux/minix_fs_sb.h>
  734. +#include <linux/ext2_fs_sb.h>
  735. +#include <linux/ext3_fs_sb.h>
  736. +#include <linux/hpfs_fs_sb.h>
  737. +#include <linux/ntfs_fs_sb.h>
  738. +#include <linux/msdos_fs_sb.h>
  739. +#include <linux/iso_fs_sb.h>
  740. +#include <linux/nfs_fs_sb.h>
  741. +#include <linux/sysv_fs_sb.h>
  742. +#include <linux/affs_fs_sb.h>
  743. +#include <linux/ufs_fs_sb.h>
  744. +#include <linux/efs_fs_sb.h>
  745. +#include <linux/romfs_fs_sb.h>
  746. +#include <linux/smb_fs_sb.h>
  747. +#include <linux/hfs_fs_sb.h>
  748. +#include <linux/adfs_fs_sb.h>
  749. +#include <linux/qnx4_fs_sb.h>
  750. +#include <linux/reiserfs_fs_sb.h>
  751. +#include <linux/bfs_fs_sb.h>
  752. +#include <linux/udf_fs_sb.h>
  753. +#include <linux/ncp_fs_sb.h>
  754. +#include <linux/usbdev_fs_sb.h>
  755. +#include <linux/cramfs_fs_sb.h>
  756. +#include <linux/jffs2_fs_sb.h>
  757. +
  758. +extern struct list_head super_blocks;
  759. +extern spinlock_t sb_lock;
  760. +
  761. +#define sb_entry(list) list_entry((list), struct super_block, s_list)
  762. +#define S_BIAS (1<<30)
  763. +struct super_block {
  764. + struct list_head s_list; /* Keep this first */
  765. + kdev_t s_dev;
  766. + unsigned long s_blocksize;
  767. + unsigned char s_blocksize_bits;
  768. + unsigned char s_dirt;
  769. + unsigned long long s_maxbytes; /* Max file size */
  770. + struct file_system_type *s_type;
  771. + struct super_operations *s_op;
  772. + struct dquot_operations *dq_op;
  773. + struct quotactl_ops *s_qcop;
  774. + unsigned long s_flags;
  775. + unsigned long s_magic;
  776. + struct dentry *s_root;
  777. + struct rw_semaphore s_umount;
  778. + struct semaphore s_lock;
  779. + int s_count;
  780. + atomic_t s_active;
  781. +
  782. + struct list_head s_dirty; /* dirty inodes */
  783. + struct list_head s_locked_inodes;/* inodes being synced */
  784. + struct list_head s_files;
  785. +
  786. + struct block_device *s_bdev;
  787. + struct list_head s_instances;
  788. + struct quota_info s_dquot; /* Diskquota specific options */
  789. +
  790. + union {
  791. + struct minix_sb_info minix_sb;
  792. + struct ext2_sb_info ext2_sb;
  793. + struct ext3_sb_info ext3_sb;
  794. + struct hpfs_sb_info hpfs_sb;
  795. + struct ntfs_sb_info ntfs_sb;
  796. + struct msdos_sb_info msdos_sb;
  797. + struct isofs_sb_info isofs_sb;
  798. + struct nfs_sb_info nfs_sb;
  799. + struct sysv_sb_info sysv_sb;
  800. + struct affs_sb_info affs_sb;
  801. + struct ufs_sb_info ufs_sb;
  802. + struct efs_sb_info efs_sb;
  803. + struct shmem_sb_info shmem_sb;
  804. + struct romfs_sb_info romfs_sb;
  805. + struct smb_sb_info smbfs_sb;
  806. + struct hfs_sb_info hfs_sb;
  807. + struct adfs_sb_info adfs_sb;
  808. + struct qnx4_sb_info qnx4_sb;
  809. + struct reiserfs_sb_info reiserfs_sb;
  810. + struct bfs_sb_info bfs_sb;
  811. + struct udf_sb_info udf_sb;
  812. + struct ncp_sb_info ncpfs_sb;
  813. + struct usbdev_sb_info usbdevfs_sb;
  814. + struct jffs2_sb_info jffs2_sb;
  815. + struct cramfs_sb_info cramfs_sb;
  816. + void *generic_sbp;
  817. + } u;
  818. + /*
  819. + * The next field is for VFS *only*. No filesystems have any business
  820. + * even looking at it. You had been warned.
  821. + */
  822. + struct semaphore s_vfs_rename_sem; /* Kludge */
  823. +
  824. + /* The next field is used by knfsd when converting a (inode number based)
  825. + * file handle into a dentry. As it builds a path in the dcache tree from
  826. + * the bottom up, there may for a time be a subpath of dentrys which is not
  827. + * connected to the main tree. This semaphore ensure that there is only ever
  828. + * one such free path per filesystem. Note that unconnected files (or other
  829. + * non-directories) are allowed, but not unconnected diretories.
  830. + */
  831. + struct semaphore s_nfsd_free_path_sem;
  832. +};
  833. +
  834. +/*
  835. + * VFS helper functions..
  836. + */
  837. +extern int vfs_create(struct inode *, struct dentry *, int);
  838. +extern int vfs_mkdir(struct inode *, struct dentry *, int);
  839. +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
  840. +extern int vfs_symlink(struct inode *, struct dentry *, const char *);
  841. +extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
  842. +extern int vfs_rmdir(struct inode *, struct dentry *);
  843. +extern int vfs_unlink(struct inode *, struct dentry *);
  844. +extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
  845. +
  846. +/*
  847. + * File types
  848. + */
  849. +#define DT_UNKNOWN 0
  850. +#define DT_FIFO 1
  851. +#define DT_CHR 2
  852. +#define DT_DIR 4
  853. +#define DT_BLK 6
  854. +#define DT_REG 8
  855. +#define DT_LNK 10
  856. +#define DT_SOCK 12
  857. +#define DT_WHT 14
  858. +
  859. +/*
  860. + * This is the "filldir" function type, used by readdir() to let
  861. + * the kernel specify what kind of dirent layout it wants to have.
  862. + * This allows the kernel to read directories into kernel space or
  863. + * to have different dirent layouts depending on the binary type.
  864. + */
  865. +typedef int (*filldir_t)(void *, const char *, int, loff_t, ino_t, unsigned);
  866. +
  867. +struct block_device_operations {
  868. + int (*open) (struct inode *, struct file *);
  869. + int (*release) (struct inode *, struct file *);
  870. + int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
  871. + int (*check_media_change) (kdev_t);
  872. + int (*revalidate) (kdev_t);
  873. + struct module *owner;
  874. +};
  875. +
  876. +/*
  877. + * NOTE:
  878. + * read, write, poll, fsync, readv, writev can be called
  879. + * without the big kernel lock held in all filesystems.
  880. + */
  881. +struct file_operations {
  882. + struct module *owner;
  883. + loff_t (*llseek) (struct file *, loff_t, int);
  884. + ssize_t (*read) (struct file *, char *, size_t, loff_t *);
  885. + ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
  886. + int (*readdir) (struct file *, void *, filldir_t);
  887. + unsigned int (*poll) (struct file *, struct poll_table_struct *);
  888. + int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
  889. + int (*mmap) (struct file *, struct vm_area_struct *);
  890. + int (*open) (struct inode *, struct file *);
  891. + int (*flush) (struct file *);
  892. + int (*release) (struct inode *, struct file *);
  893. + int (*fsync) (struct file *, struct dentry *, int datasync);
  894. + int (*fasync) (int, struct file *, int);
  895. + int (*lock) (struct file *, int, struct file_lock *);
  896. + ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
  897. + ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);
  898. + ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
  899. + unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
  900. +};
  901. +
  902. +struct inode_operations {
  903. + int (*create) (struct inode *,struct dentry *,int);
  904. + struct dentry * (*lookup) (struct inode *,struct dentry *);
  905. + int (*link) (struct dentry *,struct inode *,struct dentry *);
  906. + int (*unlink) (struct inode *,struct dentry *);
  907. + int (*symlink) (struct inode *,struct dentry *,const char *);
  908. + int (*mkdir) (struct inode *,struct dentry *,int);
  909. + int (*rmdir) (struct inode *,struct dentry *);
  910. + int (*mknod) (struct inode *,struct dentry *,int,int);
  911. + int (*rename) (struct inode *, struct dentry *,
  912. + struct inode *, struct dentry *);
  913. + int (*readlink) (struct dentry *, char *,int);
  914. + int (*follow_link) (struct dentry *, struct nameidata *);
  915. + void (*truncate) (struct inode *);
  916. + int (*permission) (struct inode *, int);
  917. + int (*revalidate) (struct dentry *);
  918. + int (*setattr) (struct dentry *, struct iattr *);
  919. + int (*getattr) (struct dentry *, struct iattr *);
  920. + int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
  921. + ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
  922. + ssize_t (*listxattr) (struct dentry *, char *, size_t);
  923. + int (*removexattr) (struct dentry *, const char *);
  924. +};
  925. +
  926. +struct seq_file;
  927. +
  928. +/*
  929. + * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
  930. + * without the big kernel lock held in all filesystems.
  931. + */
  932. +struct super_operations {
  933. + struct inode *(*alloc_inode)(struct super_block *sb);
  934. + void (*destroy_inode)(struct inode *);
  935. +
  936. + void (*read_inode) (struct inode *);
  937. +
  938. + /* reiserfs kludge. reiserfs needs 64 bits of information to
  939. + ** find an inode. We are using the read_inode2 call to get
  940. + ** that information. We don't like this, and are waiting on some
  941. + ** VFS changes for the real solution.
  942. + ** iget4 calls read_inode2, iff it is defined
  943. + */
  944. + void (*read_inode2) (struct inode *, void *) ;
  945. + void (*dirty_inode) (struct inode *);
  946. + void (*write_inode) (struct inode *, int);
  947. + void (*put_inode) (struct inode *);
  948. + void (*delete_inode) (struct inode *);
  949. + void (*put_super) (struct super_block *);
  950. + void (*write_super) (struct super_block *);
  951. + int (*sync_fs) (struct super_block *);
  952. + void (*write_super_lockfs) (struct super_block *);
  953. + void (*unlockfs) (struct super_block *);
  954. + int (*statfs) (struct super_block *, struct statfs *);
  955. + int (*remount_fs) (struct super_block *, int *, char *);
  956. + void (*clear_inode) (struct inode *);
  957. + void (*umount_begin) (struct super_block *);
  958. +
  959. + /* Following are for knfsd to interact with "interesting" filesystems
  960. + * Currently just reiserfs, but possibly FAT and others later
  961. + *
  962. + * fh_to_dentry is given a filehandle fragement with length, and a type flag
  963. + * and must return a dentry for the referenced object or, if "parent" is
  964. + * set, a dentry for the parent of the object.
  965. + * If a dentry cannot be found, a "root" dentry should be created and
  966. + * flaged as DCACHE_NFSD_DISCONNECTED. nfsd_iget is an example implementation.
  967. + *
  968. + * dentry_to_fh is given a dentry and must generate the filesys specific
  969. + * part of the file handle. Available length is passed in *lenp and used
  970. + * length should be returned therein.
  971. + * If need_parent is set, then dentry_to_fh should encode sufficient information
  972. + * to find the (current) parent.
  973. + * dentry_to_fh should return a 1byte "type" which will be passed back in
  974. + * the fhtype arguement to fh_to_dentry. Type of 0 is reserved.
  975. + * If filesystem was exportable before the introduction of fh_to_dentry,
  976. + * types 1 and 2 should be used is that same way as the generic code.
  977. + * Type 255 means error.
  978. + *
  979. + * Lengths are in units of 4bytes, not bytes.
  980. + */
  981. + struct dentry * (*fh_to_dentry)(struct super_block *sb, __u32 *fh, int len, int fhtype, int parent);
  982. + int (*dentry_to_fh)(struct dentry *, __u32 *fh, int *lenp, int need_parent);
  983. + int (*show_options)(struct seq_file *, struct vfsmount *);
  984. +};
  985. +
  986. +/* Inode state bits.. */
  987. +#define I_DIRTY_SYNC 1 /* Not dirty enough for O_DATASYNC */
  988. +#define I_DIRTY_DATASYNC 2 /* Data-related inode changes pending */
  989. +#define I_DIRTY_PAGES 4 /* Data-related inode changes pending */
  990. +#define I_LOCK 8
  991. +#define I_FREEING 16
  992. +#define I_CLEAR 32
  993. +#define I_NEW 64
  994. +
  995. +#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
  996. +
  997. +extern void __mark_inode_dirty(struct inode *, int);
  998. +static inline void mark_inode_dirty(struct inode *inode)
  999. +{
  1000. + __mark_inode_dirty(inode, I_DIRTY);
  1001. +}
  1002. +
  1003. +static inline void mark_inode_dirty_sync(struct inode *inode)
  1004. +{
  1005. + __mark_inode_dirty(inode, I_DIRTY_SYNC);
  1006. +}
  1007. +
  1008. +static inline void mark_inode_dirty_pages(struct inode *inode)
  1009. +{
  1010. + __mark_inode_dirty(inode, I_DIRTY_PAGES);
  1011. +}
  1012. +
  1013. +struct file_system_type {
  1014. + const char *name;
  1015. + int fs_flags;
  1016. + struct super_block *(*read_super) (struct super_block *, void *, int);
  1017. + struct module *owner;
  1018. + struct file_system_type * next;
  1019. + struct list_head fs_supers;
  1020. +};
  1021. +
  1022. +#define DECLARE_FSTYPE(var,type,read,flags) \
  1023. +struct file_system_type var = { \
  1024. + name: type, \
  1025. + read_super: read, \
  1026. + fs_flags: flags, \
  1027. + owner: THIS_MODULE, \
  1028. +}
  1029. +
  1030. +#define DECLARE_FSTYPE_DEV(var,type,read) \
  1031. + DECLARE_FSTYPE(var,type,read,FS_REQUIRES_DEV)
  1032. +
  1033. +/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
  1034. +#define fops_get(fops) \
  1035. + (((fops) && (fops)->owner) \
  1036. + ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \
  1037. + : (fops))
  1038. +
  1039. +#define fops_put(fops) \
  1040. +do { \
  1041. + if ((fops) && (fops)->owner) \
  1042. + __MOD_DEC_USE_COUNT((fops)->owner); \
  1043. +} while(0)
  1044. +
  1045. +extern int register_filesystem(struct file_system_type *);
  1046. +extern int unregister_filesystem(struct file_system_type *);
  1047. +extern struct vfsmount *kern_mount(struct file_system_type *);
  1048. +extern int may_umount(struct vfsmount *);
  1049. +extern long do_mount(char *, char *, char *, unsigned long, void *);
  1050. +
  1051. +#define kern_umount mntput
  1052. +
  1053. +extern int vfs_statfs(struct super_block *, struct statfs *);
  1054. +
  1055. +/* Return value for VFS lock functions - tells locks.c to lock conventionally
  1056. + * REALLY kosha for root NFS and nfs_lock
  1057. + */
  1058. +#define LOCK_USE_CLNT 1
  1059. +
  1060. +#define FLOCK_VERIFY_READ 1
  1061. +#define FLOCK_VERIFY_WRITE 2
  1062. +
  1063. +extern int locks_mandatory_locked(struct inode *);
  1064. +extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
  1065. +
  1066. +/*
  1067. + * Candidates for mandatory locking have the setgid bit set
  1068. + * but no group execute bit - an otherwise meaningless combination.
  1069. + */
  1070. +#define MANDATORY_LOCK(inode) \
  1071. + (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
  1072. +
  1073. +static inline int locks_verify_locked(struct inode *inode)
  1074. +{
  1075. + if (MANDATORY_LOCK(inode))
  1076. + return locks_mandatory_locked(inode);
  1077. + return 0;
  1078. +}
  1079. +
  1080. +static inline int locks_verify_area(int read_write, struct inode *inode,
  1081. + struct file *filp, loff_t offset,
  1082. + size_t count)
  1083. +{
  1084. + if (inode->i_flock && MANDATORY_LOCK(inode))
  1085. + return locks_mandatory_area(read_write, inode, filp, offset, count);
  1086. + return 0;
  1087. +}
  1088. +
  1089. +static inline int locks_verify_truncate(struct inode *inode,
  1090. + struct file *filp,
  1091. + loff_t size)
  1092. +{
  1093. + if (inode->i_flock && MANDATORY_LOCK(inode))
  1094. + return locks_mandatory_area(
  1095. + FLOCK_VERIFY_WRITE, inode, filp,
  1096. + size < inode->i_size ? size : inode->i_size,
  1097. + (size < inode->i_size ? inode->i_size - size
  1098. + : size - inode->i_size)
  1099. + );
  1100. + return 0;
  1101. +}
  1102. +
  1103. +static inline int get_lease(struct inode *inode, unsigned int mode)
  1104. +{
  1105. + if (inode->i_flock)
  1106. + return __get_lease(inode, mode);
  1107. + return 0;
  1108. +}
  1109. +
  1110. +/* fs/open.c */
  1111. +
  1112. +asmlinkage long sys_open(const char *, int, int);
  1113. +asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
  1114. +extern int do_truncate(struct dentry *, loff_t start);
  1115. +
  1116. +extern struct file *filp_open(const char *, int, int);
  1117. +extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
  1118. +extern int filp_close(struct file *, fl_owner_t id);
  1119. +extern char * getname(const char *);
  1120. +
  1121. +/* fs/dcache.c */
  1122. +extern void vfs_caches_init(unsigned long);
  1123. +
  1124. +#define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL)
  1125. +#define putname(name) kmem_cache_free(names_cachep, (void *)(name))
  1126. +
  1127. +enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDEV_RAW};
  1128. +extern int register_blkdev(unsigned int, const char *, struct block_device_operations *);
  1129. +extern int unregister_blkdev(unsigned int, const char *);
  1130. +extern struct block_device *bdget(dev_t);
  1131. +extern int bd_acquire(struct inode *inode);
  1132. +extern void bd_forget(struct inode *inode);
  1133. +extern void bdput(struct block_device *);
  1134. +extern struct char_device *cdget(dev_t);
  1135. +extern void cdput(struct char_device *);
  1136. +extern int blkdev_open(struct inode *, struct file *);
  1137. +extern int blkdev_close(struct inode *, struct file *);
  1138. +extern struct file_operations def_blk_fops;
  1139. +extern struct address_space_operations def_blk_aops;
  1140. +extern struct file_operations def_fifo_fops;
  1141. +extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
  1142. +extern int blkdev_get(struct block_device *, mode_t, unsigned, int);
  1143. +extern int blkdev_put(struct block_device *, int);
  1144. +
  1145. +/* fs/devices.c */
  1146. +extern const struct block_device_operations *get_blkfops(unsigned int);
  1147. +extern int register_chrdev(unsigned int, const char *, struct file_operations *);
  1148. +extern int unregister_chrdev(unsigned int, const char *);
  1149. +extern int chrdev_open(struct inode *, struct file *);
  1150. +extern const char * bdevname(kdev_t);
  1151. +extern const char * cdevname(kdev_t);
  1152. +extern const char * kdevname(kdev_t);
  1153. +extern void init_special_inode(struct inode *, umode_t, int);
  1154. +
  1155. +/* Invalid inode operations -- fs/bad_inode.c */
  1156. +extern void make_bad_inode(struct inode *);
  1157. +extern int is_bad_inode(struct inode *);
  1158. +
  1159. +extern struct file_operations read_fifo_fops;
  1160. +extern struct file_operations write_fifo_fops;
  1161. +extern struct file_operations rdwr_fifo_fops;
  1162. +extern struct file_operations read_pipe_fops;
  1163. +extern struct file_operations write_pipe_fops;
  1164. +extern struct file_operations rdwr_pipe_fops;
  1165. +
  1166. +extern int fs_may_remount_ro(struct super_block *);
  1167. +
  1168. +extern int FASTCALL(try_to_free_buffers(struct page *, unsigned int));
  1169. +extern void refile_buffer(struct buffer_head * buf);
  1170. +extern void create_empty_buffers(struct page *, kdev_t, unsigned long);
  1171. +extern void end_buffer_io_sync(struct buffer_head *bh, int uptodate);
  1172. +extern void end_buffer_io_async(struct buffer_head *bh, int uptodate);
  1173. +
  1174. +/* reiserfs_writepage needs this */
  1175. +extern void set_buffer_async_io(struct buffer_head *bh) ;
  1176. +
  1177. +#define BUF_CLEAN 0
  1178. +#define BUF_LOCKED 1 /* Buffers scheduled for write */
  1179. +#define BUF_DIRTY 2 /* Dirty buffers, not yet scheduled for write */
  1180. +#define NR_LIST 3
  1181. +
  1182. +static inline void get_bh(struct buffer_head * bh)
  1183. +{
  1184. + atomic_inc(&(bh)->b_count);
  1185. +}
  1186. +
  1187. +static inline void put_bh(struct buffer_head *bh)
  1188. +{
  1189. + smp_mb__before_atomic_dec();
  1190. + atomic_dec(&bh->b_count);
  1191. +}
  1192. +
  1193. +/*
  1194. + * This is called by bh->b_end_io() handlers when I/O has completed.
  1195. + */
  1196. +static inline void mark_buffer_uptodate(struct buffer_head * bh, int on)
  1197. +{
  1198. + if (on)
  1199. + set_bit(BH_Uptodate, &bh->b_state);
  1200. + else
  1201. + clear_bit(BH_Uptodate, &bh->b_state);
  1202. +}
  1203. +
  1204. +#define atomic_set_buffer_clean(bh) test_and_clear_bit(BH_Dirty, &(bh)->b_state)
  1205. +
  1206. +static inline void __mark_buffer_clean(struct buffer_head *bh)
  1207. +{
  1208. + refile_buffer(bh);
  1209. +}
  1210. +
  1211. +static inline void mark_buffer_clean(struct buffer_head * bh)
  1212. +{
  1213. + if (atomic_set_buffer_clean(bh))
  1214. + __mark_buffer_clean(bh);
  1215. +}
  1216. +
  1217. +extern void FASTCALL(__mark_dirty(struct buffer_head *bh));
  1218. +extern void FASTCALL(__mark_buffer_dirty(struct buffer_head *bh));
  1219. +extern void FASTCALL(mark_buffer_dirty(struct buffer_head *bh));
  1220. +
  1221. +extern void FASTCALL(buffer_insert_list(struct buffer_head *, struct list_head *));
  1222. +
  1223. +static inline void buffer_insert_inode_queue(struct buffer_head *bh, struct inode *inode)
  1224. +{
  1225. + buffer_insert_list(bh, &inode->i_dirty_buffers);
  1226. +}
  1227. +
  1228. +static inline void buffer_insert_inode_data_queue(struct buffer_head *bh, struct inode *inode)
  1229. +{
  1230. + buffer_insert_list(bh, &inode->i_dirty_data_buffers);
  1231. +}
  1232. +
  1233. +static inline int atomic_set_buffer_dirty(struct buffer_head *bh)
  1234. +{
  1235. + return test_and_set_bit(BH_Dirty, &bh->b_state);
  1236. +}
  1237. +
  1238. +static inline void mark_buffer_async(struct buffer_head * bh, int on)
  1239. +{
  1240. + if (on)
  1241. + set_bit(BH_Async, &bh->b_state);
  1242. + else
  1243. + clear_bit(BH_Async, &bh->b_state);
  1244. +}
  1245. +
  1246. +static inline void set_buffer_attached(struct buffer_head *bh)
  1247. +{
  1248. + set_bit(BH_Attached, &bh->b_state);
  1249. +}
  1250. +
  1251. +static inline void clear_buffer_attached(struct buffer_head *bh)
  1252. +{
  1253. + clear_bit(BH_Attached, &bh->b_state);
  1254. +}
  1255. +
  1256. +static inline int buffer_attached(struct buffer_head *bh)
  1257. +{
  1258. + return test_bit(BH_Attached, &bh->b_state);
  1259. +}
  1260. +
  1261. +/*
  1262. + * If an error happens during the make_request, this function
  1263. + * has to be recalled. It marks the buffer as clean and not
  1264. + * uptodate, and it notifys the upper layer about the end
  1265. + * of the I/O.
  1266. + */
  1267. +static inline void buffer_IO_error(struct buffer_head * bh)
  1268. +{
  1269. + mark_buffer_clean(bh);
  1270. + /*
  1271. + * b_end_io has to clear the BH_Uptodate bitflag in the error case!
  1272. + */
  1273. + bh->b_end_io(bh, 0);
  1274. +}
  1275. +
  1276. +static inline void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode)
  1277. +{
  1278. + mark_buffer_dirty(bh);
  1279. + buffer_insert_inode_queue(bh, inode);
  1280. +}
  1281. +
  1282. +extern void set_buffer_flushtime(struct buffer_head *);
  1283. +extern inline int get_buffer_flushtime(void);
  1284. +extern void balance_dirty(void);
  1285. +extern int check_disk_change(kdev_t);
  1286. +extern int invalidate_inodes(struct super_block *);
  1287. +extern int invalidate_device(kdev_t, int);
  1288. +extern void invalidate_inode_pages(struct inode *);
  1289. +extern void invalidate_inode_pages2(struct address_space *);
  1290. +extern void invalidate_inode_buffers(struct inode *);
  1291. +#define invalidate_buffers(dev) __invalidate_buffers((dev), 0)
  1292. +#define destroy_buffers(dev) __invalidate_buffers((dev), 1)
  1293. +extern void invalidate_bdev(struct block_device *, int);
  1294. +extern void __invalidate_buffers(kdev_t dev, int);
  1295. +extern void sync_inodes(kdev_t);
  1296. +extern void sync_unlocked_inodes(void);
  1297. +extern void write_inode_now(struct inode *, int);
  1298. +extern int sync_buffers(kdev_t, int);
  1299. +extern void sync_dev(kdev_t);
  1300. +extern int fsync_dev(kdev_t);
  1301. +extern int fsync_super(struct super_block *);
  1302. +extern int fsync_no_super(kdev_t);
  1303. +extern void sync_inodes_sb(struct super_block *);
  1304. +extern int fsync_buffers_list(struct list_head *);
  1305. +static inline int fsync_inode_buffers(struct inode *inode)
  1306. +{
  1307. + return fsync_buffers_list(&inode->i_dirty_buffers);
  1308. +}
  1309. +static inline int fsync_inode_data_buffers(struct inode *inode)
  1310. +{
  1311. + return fsync_buffers_list(&inode->i_dirty_data_buffers);
  1312. +}
  1313. +extern int inode_has_buffers(struct inode *);
  1314. +extern int do_fdatasync(struct file *);
  1315. +extern int filemap_fdatawrite(struct address_space *);
  1316. +extern int filemap_fdatasync(struct address_space *);
  1317. +extern int filemap_fdatawait(struct address_space *);
  1318. +extern void sync_supers(kdev_t dev, int wait);
  1319. +extern int bmap(struct inode *, int);
  1320. +extern int notify_change(struct dentry *, struct iattr *);
  1321. +extern int permission(struct inode *, int);
  1322. +extern int vfs_permission(struct inode *, int);
  1323. +extern int get_write_access(struct inode *);
  1324. +extern int deny_write_access(struct file *);
  1325. +static inline void put_write_access(struct inode * inode)
  1326. +{
  1327. + atomic_dec(&inode->i_writecount);
  1328. +}
  1329. +static inline void allow_write_access(struct file *file)
  1330. +{
  1331. + if (file)
  1332. + atomic_inc(&file->f_dentry->d_inode->i_writecount);
  1333. +}
  1334. +extern int do_pipe(int *);
  1335. +
  1336. +extern int open_namei(const char *, int, int, struct nameidata *);
  1337. +
  1338. +extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
  1339. +extern struct file * open_exec(const char *);
  1340. +
  1341. +/* fs/dcache.c -- generic fs support functions */
  1342. +extern int is_subdir(struct dentry *, struct dentry *);
  1343. +extern ino_t find_inode_number(struct dentry *, struct qstr *);
  1344. +
  1345. +/*
  1346. + * Kernel pointers have redundant information, so we can use a
  1347. + * scheme where we can return either an error code or a dentry
  1348. + * pointer with the same return value.
  1349. + *
  1350. + * This should be a per-architecture thing, to allow different
  1351. + * error and pointer decisions.
  1352. + */
  1353. +static inline void *ERR_PTR(long error)
  1354. +{
  1355. + return (void *) error;
  1356. +}
  1357. +
  1358. +static inline long PTR_ERR(const void *ptr)
  1359. +{
  1360. + return (long) ptr;
  1361. +}
  1362. +
  1363. +static inline long IS_ERR(const void *ptr)
  1364. +{
  1365. + return (unsigned long)ptr > (unsigned long)-1000L;
  1366. +}
  1367. +
  1368. +/*
  1369. + * The bitmask for a lookup event:
  1370. + * - follow links at the end
  1371. + * - require a directory
  1372. + * - ending slashes ok even for nonexistent files
  1373. + * - internal "there are more path compnents" flag
  1374. + */
  1375. +#define LOOKUP_FOLLOW (1)
  1376. +#define LOOKUP_DIRECTORY (2)
  1377. +#define LOOKUP_CONTINUE (4)
  1378. +#define LOOKUP_POSITIVE (8)
  1379. +#define LOOKUP_PARENT (16)
  1380. +#define LOOKUP_NOALT (32)
  1381. +/*
  1382. + * Type of the last component on LOOKUP_PARENT
  1383. + */
  1384. +enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
  1385. +
  1386. +/*
  1387. + * "descriptor" for what we're up to with a read for sendfile().
  1388. + * This allows us to use the same read code yet
  1389. + * have multiple different users of the data that
  1390. + * we read from a file.
  1391. + *
  1392. + * The simplest case just copies the data to user
  1393. + * mode.
  1394. + */
  1395. +typedef struct {
  1396. + size_t written;
  1397. + size_t count;
  1398. + char * buf;
  1399. + int error;
  1400. +} read_descriptor_t;
  1401. +
  1402. +typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
  1403. +
  1404. +/* needed for stackable file system support */
  1405. +extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
  1406. +
  1407. +extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
  1408. +extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
  1409. +extern int FASTCALL(path_walk(const char *, struct nameidata *));
  1410. +extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
  1411. +extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
  1412. +extern void path_release(struct nameidata *);
  1413. +extern int follow_down(struct vfsmount **, struct dentry **);
  1414. +extern int follow_up(struct vfsmount **, struct dentry **);
  1415. +extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
  1416. +extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
  1417. +#define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
  1418. +#define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
  1419. +
  1420. +extern void inode_init_once(struct inode *);
  1421. +extern void __inode_init_once(struct inode *);
  1422. +extern void iput(struct inode *);
  1423. +extern void refile_inode(struct inode *inode);
  1424. +extern void force_delete(struct inode *);
  1425. +extern struct inode * igrab(struct inode *);
  1426. +extern struct inode * ilookup(struct super_block *, unsigned long);
  1427. +extern ino_t iunique(struct super_block *, ino_t);
  1428. +extern void unlock_new_inode(struct inode *);
  1429. +
  1430. +typedef int (*find_inode_t)(struct inode *, unsigned long, void *);
  1431. +
  1432. +extern struct inode * iget4_locked(struct super_block *, unsigned long,
  1433. + find_inode_t, void *);
  1434. +
  1435. +static inline struct inode *iget4(struct super_block *sb, unsigned long ino,
  1436. + find_inode_t find_actor, void *opaque)
  1437. +{
  1438. + struct inode *inode = iget4_locked(sb, ino, find_actor, opaque);
  1439. +
  1440. + if (inode && (inode->i_state & I_NEW)) {
  1441. + /*
  1442. + * reiserfs-specific kludge that is expected to go away ASAP.
  1443. + */
  1444. + if (sb->s_op->read_inode2)
  1445. + sb->s_op->read_inode2(inode, opaque);
  1446. + else
  1447. + sb->s_op->read_inode(inode);
  1448. + unlock_new_inode(inode);
  1449. + }
  1450. +
  1451. + return inode;
  1452. +}
  1453. +
  1454. +static inline struct inode *iget(struct super_block *sb, unsigned long ino)
  1455. +{
  1456. + struct inode *inode = iget4_locked(sb, ino, NULL, NULL);
  1457. +
  1458. + if (inode && (inode->i_state & I_NEW)) {
  1459. + sb->s_op->read_inode(inode);
  1460. + unlock_new_inode(inode);
  1461. + }
  1462. +
  1463. + return inode;
  1464. +}
  1465. +
  1466. +static inline struct inode *iget_locked(struct super_block *sb, unsigned long ino)
  1467. +{
  1468. + return iget4_locked(sb, ino, NULL, NULL);
  1469. +}
  1470. +
  1471. +extern void clear_inode(struct inode *);
  1472. +extern struct inode *new_inode(struct super_block *sb);
  1473. +extern void remove_suid(struct inode *inode);
  1474. +
  1475. +extern void insert_inode_hash(struct inode *);
  1476. +extern void remove_inode_hash(struct inode *);
  1477. +extern struct file * get_empty_filp(void);
  1478. +extern void file_move(struct file *f, struct list_head *list);
  1479. +extern struct buffer_head * get_hash_table(kdev_t, int, int);
  1480. +extern struct buffer_head * getblk(kdev_t, int, int);
  1481. +extern void ll_rw_block(int, int, struct buffer_head * bh[]);
  1482. +extern void submit_bh(int, struct buffer_head *);
  1483. +extern int is_read_only(kdev_t);
  1484. +extern void __brelse(struct buffer_head *);
  1485. +static inline void brelse(struct buffer_head *buf)
  1486. +{
  1487. + if (buf)
  1488. + __brelse(buf);
  1489. +}
  1490. +extern void __bforget(struct buffer_head *);
  1491. +static inline void bforget(struct buffer_head *buf)
  1492. +{
  1493. + if (buf)
  1494. + __bforget(buf);
  1495. +}
  1496. +extern int set_blocksize(kdev_t, int);
  1497. +extern int sb_set_blocksize(struct super_block *, int);
  1498. +extern int sb_min_blocksize(struct super_block *, int);
  1499. +extern struct buffer_head * bread(kdev_t, int, int);
  1500. +static inline struct buffer_head * sb_bread(struct super_block *sb, int block)
  1501. +{
  1502. + return bread(sb->s_dev, block, sb->s_blocksize);
  1503. +}
  1504. +static inline struct buffer_head * sb_getblk(struct super_block *sb, int block)
  1505. +{
  1506. + return getblk(sb->s_dev, block, sb->s_blocksize);
  1507. +}
  1508. +static inline struct buffer_head * sb_get_hash_table(struct super_block *sb, int block)
  1509. +{
  1510. + return get_hash_table(sb->s_dev, block, sb->s_blocksize);
  1511. +}
  1512. +extern void wakeup_bdflush(void);
  1513. +extern void wakeup_kupdate(void);
  1514. +extern void put_unused_buffer_head(struct buffer_head * bh);
  1515. +extern struct buffer_head * get_unused_buffer_head(int async);
  1516. +extern int block_dump;
  1517. +
  1518. +extern int brw_page(int, struct page *, kdev_t, int [], int);
  1519. +
  1520. +typedef int (get_block_t)(struct inode*,long,struct buffer_head*,int);
  1521. +
  1522. +/* Generic buffer handling for block filesystems.. */
  1523. +extern int try_to_release_page(struct page * page, int gfp_mask);
  1524. +extern int discard_bh_page(struct page *, unsigned long, int);
  1525. +#define block_flushpage(page, offset) discard_bh_page(page, offset, 1)
  1526. +#define block_invalidate_page(page) discard_bh_page(page, 0, 0)
  1527. +extern int block_symlink(struct inode *, const char *, int);
  1528. +extern int block_write_full_page(struct page*, get_block_t*);
  1529. +extern int block_read_full_page(struct page*, get_block_t*);
  1530. +extern int block_prepare_write(struct page*, unsigned, unsigned, get_block_t*);
  1531. +extern int cont_prepare_write(struct page*, unsigned, unsigned, get_block_t*,
  1532. + unsigned long *);
  1533. +extern int generic_cont_expand(struct inode *inode, loff_t size) ;
  1534. +extern int block_commit_write(struct page *page, unsigned from, unsigned to);
  1535. +extern int block_sync_page(struct page *);
  1536. +
  1537. +int generic_block_bmap(struct address_space *, long, get_block_t *);
  1538. +int generic_commit_write(struct file *, struct page *, unsigned, unsigned);
  1539. +int block_truncate_page(struct address_space *, loff_t, get_block_t *);
  1540. +extern int generic_direct_IO(int, struct inode *, struct kiobuf *, unsigned long, int, get_block_t *);
  1541. +extern int waitfor_one_page(struct page *);
  1542. +extern int writeout_one_page(struct page *);
  1543. +
  1544. +extern int generic_file_mmap(struct file *, struct vm_area_struct *);
  1545. +extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
  1546. +extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
  1547. +extern inline ssize_t do_generic_direct_read(struct file *, char *, size_t, loff_t *);
  1548. +extern int precheck_file_write(struct file *, struct inode *, size_t *, loff_t *);
  1549. +extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *);
  1550. +extern void do_generic_file_read(struct file *, loff_t *, read_descriptor_t *, read_actor_t);
  1551. +extern ssize_t do_generic_file_write(struct file *, const char *, size_t, loff_t *);
  1552. +extern ssize_t do_generic_direct_write(struct file *, const char *, size_t, loff_t *);
  1553. +extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
  1554. +extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
  1555. +extern ssize_t generic_read_dir(struct file *, char *, size_t, loff_t *);
  1556. +extern int generic_file_open(struct inode * inode, struct file * filp);
  1557. +
  1558. +extern struct file_operations generic_ro_fops;
  1559. +
  1560. +extern int vfs_readlink(struct dentry *, char *, int, const char *);
  1561. +extern int vfs_follow_link(struct nameidata *, const char *);
  1562. +extern int page_readlink(struct dentry *, char *, int);
  1563. +extern int page_follow_link(struct dentry *, struct nameidata *);
  1564. +extern struct inode_operations page_symlink_inode_operations;
  1565. +
  1566. +extern int vfs_readdir(struct file *, filldir_t, void *);
  1567. +extern int dcache_dir_open(struct inode *, struct file *);
  1568. +extern int dcache_dir_close(struct inode *, struct file *);
  1569. +extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
  1570. +extern int dcache_dir_fsync(struct file *, struct dentry *, int);
  1571. +extern int dcache_readdir(struct file *, void *, filldir_t);
  1572. +extern struct file_operations dcache_dir_ops;
  1573. +
  1574. +extern struct file_system_type *get_fs_type(const char *name);
  1575. +extern struct super_block *get_super(kdev_t);
  1576. +extern void drop_super(struct super_block *sb);
  1577. +static inline int is_mounted(kdev_t dev)
  1578. +{
  1579. + struct super_block *sb = get_super(dev);
  1580. + if (sb) {
  1581. + drop_super(sb);
  1582. + return 1;
  1583. + }
  1584. + return 0;
  1585. +}
  1586. +unsigned long generate_cluster(kdev_t, int b[], int);
  1587. +unsigned long generate_cluster_swab32(kdev_t, int b[], int);
  1588. +extern kdev_t ROOT_DEV;
  1589. +extern char root_device_name[];
  1590. +
  1591. +
  1592. +extern void show_buffers(void);
  1593. +
  1594. +#ifdef CONFIG_BLK_DEV_INITRD
  1595. +extern unsigned int real_root_dev;
  1596. +#endif
  1597. +
  1598. +extern ssize_t char_read(struct file *, char *, size_t, loff_t *);
  1599. +extern ssize_t block_read(struct file *, char *, size_t, loff_t *);
  1600. +extern int read_ahead[];
  1601. +
  1602. +extern ssize_t char_write(struct file *, const char *, size_t, loff_t *);
  1603. +extern ssize_t block_write(struct file *, const char *, size_t, loff_t *);
  1604. +
  1605. +extern int file_fsync(struct file *, struct dentry *, int);
  1606. +extern int generic_buffer_fdatasync(struct inode *inode, unsigned long start_idx, unsigned long end_idx);
  1607. +extern int generic_osync_inode(struct inode *, int);
  1608. +#define OSYNC_METADATA (1<<0)
  1609. +#define OSYNC_DATA (1<<1)
  1610. +#define OSYNC_INODE (1<<2)
  1611. +
  1612. +extern int inode_change_ok(struct inode *, struct iattr *);
  1613. +extern int inode_setattr(struct inode *, struct iattr *);
  1614. +
  1615. +/* kernel/fork.c */
  1616. +extern int unshare_files(void);
  1617. +
  1618. +/*
  1619. + * Common dentry functions for inclusion in the VFS
  1620. + * or in other stackable file systems. Some of these
  1621. + * functions were in linux/fs/ C (VFS) files.
  1622. + *
  1623. + */
  1624. +
  1625. +/*
  1626. + * Locking the parent is needed to:
  1627. + * - serialize directory operations
  1628. + * - make sure the parent doesn't change from
  1629. + * under us in the middle of an operation.
  1630. + *
  1631. + * NOTE! Right now we'd rather use a "struct inode"
  1632. + * for this, but as I expect things to move toward
  1633. + * using dentries instead for most things it is
  1634. + * probably better to start with the conceptually
  1635. + * better interface of relying on a path of dentries.
  1636. + */
  1637. +static inline struct dentry *lock_parent(struct dentry *dentry)
  1638. +{
  1639. + struct dentry *dir = dget(dentry->d_parent);
  1640. +
  1641. + down(&dir->d_inode->i_sem);
  1642. + return dir;
  1643. +}
  1644. +
  1645. +static inline struct dentry *get_parent(struct dentry *dentry)
  1646. +{
  1647. + return dget(dentry->d_parent);
  1648. +}
  1649. +
  1650. +static inline void unlock_dir(struct dentry *dir)
  1651. +{
  1652. + up(&dir->d_inode->i_sem);
  1653. + dput(dir);
  1654. +}
  1655. +
  1656. +/*
  1657. + * Whee.. Deadlock country. Happily there are only two VFS
  1658. + * operations that does this..
  1659. + */
  1660. +static inline void double_down(struct semaphore *s1, struct semaphore *s2)
  1661. +{
  1662. + if (s1 != s2) {
  1663. + if ((unsigned long) s1 < (unsigned long) s2) {
  1664. + struct semaphore *tmp = s2;
  1665. + s2 = s1; s1 = tmp;
  1666. + }
  1667. + down(s1);
  1668. + }
  1669. + down(s2);
  1670. +}
  1671. +
  1672. +/*
  1673. + * Ewwwwwwww... _triple_ lock. We are guaranteed that the 3rd argument is
  1674. + * not equal to 1st and not equal to 2nd - the first case (target is parent of
  1675. + * source) would be already caught, the second is plain impossible (target is
  1676. + * its own parent and that case would be caught even earlier). Very messy.
  1677. + * I _think_ that it works, but no warranties - please, look it through.
  1678. + * Pox on bloody lusers who mandated overwriting rename() for directories...
  1679. + */
  1680. +
  1681. +static inline void triple_down(struct semaphore *s1,
  1682. + struct semaphore *s2,
  1683. + struct semaphore *s3)
  1684. +{
  1685. + if (s1 != s2) {
  1686. + if ((unsigned long) s1 < (unsigned long) s2) {
  1687. + if ((unsigned long) s1 < (unsigned long) s3) {
  1688. + struct semaphore *tmp = s3;
  1689. + s3 = s1; s1 = tmp;
  1690. + }
  1691. + if ((unsigned long) s1 < (unsigned long) s2) {
  1692. + struct semaphore *tmp = s2;
  1693. + s2 = s1; s1 = tmp;
  1694. + }
  1695. + } else {
  1696. + if ((unsigned long) s1 < (unsigned long) s3) {
  1697. + struct semaphore *tmp = s3;
  1698. + s3 = s1; s1 = tmp;
  1699. + }
  1700. + if ((unsigned long) s2 < (unsigned long) s3) {
  1701. + struct semaphore *tmp = s3;
  1702. + s3 = s2; s2 = tmp;
  1703. + }
  1704. + }
  1705. + down(s1);
  1706. + } else if ((unsigned long) s2 < (unsigned long) s3) {
  1707. + struct semaphore *tmp = s3;
  1708. + s3 = s2; s2 = tmp;
  1709. + }
  1710. + down(s2);
  1711. + down(s3);
  1712. +}
  1713. +
  1714. +static inline void double_up(struct semaphore *s1, struct semaphore *s2)
  1715. +{
  1716. + up(s1);
  1717. + if (s1 != s2)
  1718. + up(s2);
  1719. +}
  1720. +
  1721. +static inline void triple_up(struct semaphore *s1,
  1722. + struct semaphore *s2,
  1723. + struct semaphore *s3)
  1724. +{
  1725. + up(s1);
  1726. + if (s1 != s2)
  1727. + up(s2);
  1728. + up(s3);
  1729. +}
  1730. +
  1731. +static inline void double_lock(struct dentry *d1, struct dentry *d2)
  1732. +{
  1733. + double_down(&d1->d_inode->i_sem, &d2->d_inode->i_sem);
  1734. +}
  1735. +
  1736. +static inline void double_unlock(struct dentry *d1, struct dentry *d2)
  1737. +{
  1738. + double_up(&d1->d_inode->i_sem,&d2->d_inode->i_sem);
  1739. + dput(d1);
  1740. + dput(d2);
  1741. +}
  1742. +
  1743. +#endif /* __KERNEL__ */
  1744. +
  1745. +#endif /* _LINUX_FS_H */
  1746. --- ./linux/genhd.h 1970-01-01 00:00:00.000000000 +0000
  1747. +++ ./linux/genhd.h 2004-08-20 03:16:52.152495040 +0000
  1748. @@ -0,0 +1,318 @@
  1749. +#ifndef _LINUX_GENHD_H
  1750. +#define _LINUX_GENHD_H
  1751. +
  1752. +/*
  1753. + * genhd.h Copyright (C) 1992 Drew Eckhardt
  1754. + * Generic hard disk header file by
  1755. + * Drew Eckhardt
  1756. + *
  1757. + * <drew@colorado.edu>
  1758. + */
  1759. +
  1760. +#include <linux/config.h>
  1761. +#include <linux/types.h>
  1762. +#include <linux/major.h>
  1763. +
  1764. +enum {
  1765. +/* These three have identical behaviour; use the second one if DOS fdisk gets
  1766. + confused about extended/logical partitions starting past cylinder 1023. */
  1767. + DOS_EXTENDED_PARTITION = 5,
  1768. + LINUX_EXTENDED_PARTITION = 0x85,
  1769. + WIN98_EXTENDED_PARTITION = 0x0f,
  1770. +
  1771. + LINUX_SWAP_PARTITION = 0x82,
  1772. + LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
  1773. +
  1774. + SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION,
  1775. +
  1776. + DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */
  1777. + EZD_PARTITION = 0x55, /* EZ-DRIVE */
  1778. + DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */
  1779. + DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */
  1780. +
  1781. + FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */
  1782. + OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */
  1783. + NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */
  1784. + BSDI_PARTITION = 0xb7, /* BSDI Partition ID */
  1785. +/* Ours is not to wonder why.. */
  1786. + BSD_PARTITION = FREEBSD_PARTITION,
  1787. + MINIX_PARTITION = 0x81, /* Minix Partition ID */
  1788. + PLAN9_PARTITION = 0x39, /* Plan 9 Partition ID */
  1789. + UNIXWARE_PARTITION = 0x63, /* Partition ID, same as */
  1790. + /* GNU_HURD and SCO Unix */
  1791. +};
  1792. +
  1793. +struct partition {
  1794. + unsigned char boot_ind; /* 0x80 - active */
  1795. + unsigned char head; /* starting head */
  1796. + unsigned char sector; /* starting sector */
  1797. + unsigned char cyl; /* starting cylinder */
  1798. + unsigned char sys_ind; /* What partition type */
  1799. + unsigned char end_head; /* end head */
  1800. + unsigned char end_sector; /* end sector */
  1801. + unsigned char end_cyl; /* end cylinder */
  1802. + unsigned int start_sect; /* starting sector counting from 0 */
  1803. + unsigned int nr_sects; /* nr of sectors in partition */
  1804. +} __attribute__((packed));
  1805. +
  1806. +#ifdef __KERNEL__
  1807. +# include <linux/devfs_fs_kernel.h>
  1808. +
  1809. +struct hd_struct {
  1810. + unsigned long start_sect;
  1811. + unsigned long nr_sects;
  1812. + devfs_handle_t de; /* primary (master) devfs entry */
  1813. +#ifdef CONFIG_DEVFS_FS
  1814. + int number;
  1815. +#endif /* CONFIG_DEVFS_FS */
  1816. +#ifdef CONFIG_BLK_STATS
  1817. + /* Performance stats: */
  1818. + unsigned int ios_in_flight;
  1819. + unsigned int io_ticks;
  1820. + unsigned int last_idle_time;
  1821. + unsigned int last_queue_change;
  1822. + unsigned int aveq;
  1823. +
  1824. + unsigned int rd_ios;
  1825. + unsigned int rd_merges;
  1826. + unsigned int rd_ticks;
  1827. + unsigned int rd_sectors;
  1828. + unsigned int wr_ios;
  1829. + unsigned int wr_merges;
  1830. + unsigned int wr_ticks;
  1831. + unsigned int wr_sectors;
  1832. +#endif /* CONFIG_BLK_STATS */
  1833. +};
  1834. +
  1835. +#define GENHD_FL_REMOVABLE 1
  1836. +
  1837. +struct gendisk {
  1838. + int major; /* major number of driver */
  1839. + const char *major_name; /* name of major driver */
  1840. + int minor_shift; /* number of times minor is shifted to
  1841. + get real minor */
  1842. + int max_p; /* maximum partitions per device */
  1843. +
  1844. + struct hd_struct *part; /* [indexed by minor] */
  1845. + int *sizes; /* [idem], device size in blocks */
  1846. + int nr_real; /* number of real devices */
  1847. +
  1848. + void *real_devices; /* internal use */
  1849. + struct gendisk *next;
  1850. + struct block_device_operations *fops;
  1851. +
  1852. + devfs_handle_t *de_arr; /* one per physical disc */
  1853. + char *flags; /* one per physical disc */
  1854. +};
  1855. +
  1856. +/* drivers/block/genhd.c */
  1857. +extern struct gendisk *gendisk_head;
  1858. +
  1859. +extern void add_gendisk(struct gendisk *gp);
  1860. +extern void del_gendisk(struct gendisk *gp);
  1861. +extern struct gendisk *get_gendisk(kdev_t dev);
  1862. +extern int walk_gendisk(int (*walk)(struct gendisk *, void *), void *);
  1863. +
  1864. +#endif /* __KERNEL__ */
  1865. +
  1866. +#ifdef CONFIG_SOLARIS_X86_PARTITION
  1867. +
  1868. +#define SOLARIS_X86_NUMSLICE 8
  1869. +#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
  1870. +
  1871. +struct solaris_x86_slice {
  1872. + ushort s_tag; /* ID tag of partition */
  1873. + ushort s_flag; /* permission flags */
  1874. + unsigned int s_start; /* start sector no of partition */
  1875. + unsigned int s_size; /* # of blocks in partition */
  1876. +};
  1877. +
  1878. +struct solaris_x86_vtoc {
  1879. + unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */
  1880. + unsigned int v_sanity; /* to verify vtoc sanity */
  1881. + unsigned int v_version; /* layout version */
  1882. + char v_volume[8]; /* volume name */
  1883. + ushort v_sectorsz; /* sector size in bytes */
  1884. + ushort v_nparts; /* number of partitions */
  1885. + unsigned int v_reserved[10]; /* free space */
  1886. + struct solaris_x86_slice
  1887. + v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */
  1888. + unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */
  1889. + char v_asciilabel[128]; /* for compatibility */
  1890. +};
  1891. +
  1892. +#endif /* CONFIG_SOLARIS_X86_PARTITION */
  1893. +
  1894. +#ifdef CONFIG_BSD_DISKLABEL
  1895. +/*
  1896. + * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il>
  1897. + * updated by Marc Espie <Marc.Espie@openbsd.org>
  1898. + */
  1899. +
  1900. +/* check against BSD src/sys/sys/disklabel.h for consistency */
  1901. +
  1902. +#define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */
  1903. +#define BSD_MAXPARTITIONS 8
  1904. +#define OPENBSD_MAXPARTITIONS 16
  1905. +#define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */
  1906. +struct bsd_disklabel {
  1907. + __u32 d_magic; /* the magic number */
  1908. + __s16 d_type; /* drive type */
  1909. + __s16 d_subtype; /* controller/d_type specific */
  1910. + char d_typename[16]; /* type name, e.g. "eagle" */
  1911. + char d_packname[16]; /* pack identifier */
  1912. + __u32 d_secsize; /* # of bytes per sector */
  1913. + __u32 d_nsectors; /* # of data sectors per track */
  1914. + __u32 d_ntracks; /* # of tracks per cylinder */
  1915. + __u32 d_ncylinders; /* # of data cylinders per unit */
  1916. + __u32 d_secpercyl; /* # of data sectors per cylinder */
  1917. + __u32 d_secperunit; /* # of data sectors per unit */
  1918. + __u16 d_sparespertrack; /* # of spare sectors per track */
  1919. + __u16 d_sparespercyl; /* # of spare sectors per cylinder */
  1920. + __u32 d_acylinders; /* # of alt. cylinders per unit */
  1921. + __u16 d_rpm; /* rotational speed */
  1922. + __u16 d_interleave; /* hardware sector interleave */
  1923. + __u16 d_trackskew; /* sector 0 skew, per track */
  1924. + __u16 d_cylskew; /* sector 0 skew, per cylinder */
  1925. + __u32 d_headswitch; /* head switch time, usec */
  1926. + __u32 d_trkseek; /* track-to-track seek, usec */
  1927. + __u32 d_flags; /* generic flags */
  1928. +#define NDDATA 5
  1929. + __u32 d_drivedata[NDDATA]; /* drive-type specific information */
  1930. +#define NSPARE 5
  1931. + __u32 d_spare[NSPARE]; /* reserved for future use */
  1932. + __u32 d_magic2; /* the magic number (again) */
  1933. + __u16 d_checksum; /* xor of data incl. partitions */
  1934. +
  1935. + /* filesystem and partition information: */
  1936. + __u16 d_npartitions; /* number of partitions in following */
  1937. + __u32 d_bbsize; /* size of boot area at sn0, bytes */
  1938. + __u32 d_sbsize; /* max size of fs superblock, bytes */
  1939. + struct bsd_partition { /* the partition table */
  1940. + __u32 p_size; /* number of sectors in partition */
  1941. + __u32 p_offset; /* starting sector */
  1942. + __u32 p_fsize; /* filesystem basic fragment size */
  1943. + __u8 p_fstype; /* filesystem type, see below */
  1944. + __u8 p_frag; /* filesystem fragments per block */
  1945. + __u16 p_cpg; /* filesystem cylinders per group */
  1946. + } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
  1947. +};
  1948. +
  1949. +#endif /* CONFIG_BSD_DISKLABEL */
  1950. +
  1951. +#ifdef CONFIG_UNIXWARE_DISKLABEL
  1952. +/*
  1953. + * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
  1954. + * and Krzysztof G. Baranowski <kgb@knm.org.pl>
  1955. + */
  1956. +
  1957. +#define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */
  1958. +#define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */
  1959. +#define UNIXWARE_NUMSLICE 16
  1960. +#define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */
  1961. +
  1962. +struct unixware_slice {
  1963. + __u16 s_label; /* label */
  1964. + __u16 s_flags; /* permission flags */
  1965. + __u32 start_sect; /* starting sector */
  1966. + __u32 nr_sects; /* number of sectors in slice */
  1967. +};
  1968. +
  1969. +struct unixware_disklabel {
  1970. + __u32 d_type; /* drive type */
  1971. + __u32 d_magic; /* the magic number */
  1972. + __u32 d_version; /* version number */
  1973. + char d_serial[12]; /* serial number of the device */
  1974. + __u32 d_ncylinders; /* # of data cylinders per device */
  1975. + __u32 d_ntracks; /* # of tracks per cylinder */
  1976. + __u32 d_nsectors; /* # of data sectors per track */
  1977. + __u32 d_secsize; /* # of bytes per sector */
  1978. + __u32 d_part_start; /* # of first sector of this partition */
  1979. + __u32 d_unknown1[12]; /* ? */
  1980. + __u32 d_alt_tbl; /* byte offset of alternate table */
  1981. + __u32 d_alt_len; /* byte length of alternate table */
  1982. + __u32 d_phys_cyl; /* # of physical cylinders per device */
  1983. + __u32 d_phys_trk; /* # of physical tracks per cylinder */
  1984. + __u32 d_phys_sec; /* # of physical sectors per track */
  1985. + __u32 d_phys_bytes; /* # of physical bytes per sector */
  1986. + __u32 d_unknown2; /* ? */
  1987. + __u32 d_unknown3; /* ? */
  1988. + __u32 d_pad[8]; /* pad */
  1989. +
  1990. + struct unixware_vtoc {
  1991. + __u32 v_magic; /* the magic number */
  1992. + __u32 v_version; /* version number */
  1993. + char v_name[8]; /* volume name */
  1994. + __u16 v_nslices; /* # of slices */
  1995. + __u16 v_unknown1; /* ? */
  1996. + __u32 v_reserved[10]; /* reserved */
  1997. + struct unixware_slice
  1998. + v_slice[UNIXWARE_NUMSLICE]; /* slice headers */
  1999. + } vtoc;
  2000. +
  2001. +}; /* 408 */
  2002. +
  2003. +#endif /* CONFIG_UNIXWARE_DISKLABEL */
  2004. +
  2005. +#ifdef CONFIG_MINIX_SUBPARTITION
  2006. +# define MINIX_NR_SUBPARTITIONS 4
  2007. +#endif /* CONFIG_MINIX_SUBPARTITION */
  2008. +
  2009. +#ifdef __KERNEL__
  2010. +
  2011. +char *disk_name (struct gendisk *hd, int minor, char *buf);
  2012. +
  2013. +/*
  2014. + * Account for the completion of an IO request (used by drivers which
  2015. + * bypass the normal end_request processing)
  2016. + */
  2017. +struct request;
  2018. +
  2019. +#ifdef CONFIG_BLK_STATS
  2020. +extern void disk_round_stats(struct hd_struct *hd);
  2021. +extern void req_new_io(struct request *req, int merge, int sectors);
  2022. +extern void req_merged_io(struct request *req);
  2023. +extern void req_finished_io(struct request *req);
  2024. +#else
  2025. +static inline void req_new_io(struct request *req, int merge, int sectors) { }
  2026. +static inline void req_merged_io(struct request *req) { }
  2027. +static inline void req_finished_io(struct request *req) { }
  2028. +#endif /* CONFIG_BLK_STATS */
  2029. +
  2030. +extern void devfs_register_partitions (struct gendisk *dev, int minor,
  2031. + int unregister);
  2032. +
  2033. +
  2034. +
  2035. +/*
  2036. + * FIXME: this should use genhd->minor_shift, but that is slow to look up.
  2037. + */
  2038. +static inline unsigned int disk_index (kdev_t dev)
  2039. +{
  2040. + int major = MAJOR(dev);
  2041. + int minor = MINOR(dev);
  2042. + unsigned int index;
  2043. +
  2044. + switch (major) {
  2045. + case DAC960_MAJOR+0:
  2046. + index = (minor & 0x00f8) >> 3;
  2047. + break;
  2048. + case SCSI_DISK0_MAJOR:
  2049. + index = (minor & 0x00f0) >> 4;
  2050. + break;
  2051. + case IDE0_MAJOR: /* same as HD_MAJOR */
  2052. + case XT_DISK_MAJOR:
  2053. + index = (minor & 0x0040) >> 6;
  2054. + break;
  2055. + case IDE1_MAJOR:
  2056. + index = ((minor & 0x0040) >> 6) + 2;
  2057. + break;
  2058. + default:
  2059. + return 0;
  2060. + }
  2061. + return index;
  2062. +}
  2063. +
  2064. +#endif
  2065. +
  2066. +#endif
  2067. --- ./linux/hdreg.h 1970-01-01 00:00:00.000000000 +0000
  2068. +++ ./linux/hdreg.h 2004-08-20 03:17:00.838174616 +0000
  2069. @@ -0,0 +1,746 @@
  2070. +#ifndef _LINUX_HDREG_H
  2071. +#define _LINUX_HDREG_H
  2072. +
  2073. +/*
  2074. + * This file contains some defines for the AT-hd-controller.
  2075. + * Various sources.
  2076. + */
  2077. +
  2078. +#define HD_IRQ 14 /* the standard disk interrupt */
  2079. +
  2080. +/* ide.c has its own port definitions in "ide.h" */
  2081. +
  2082. +/* Hd controller regs. Ref: IBM AT Bios-listing */
  2083. +#define HD_DATA 0x1f0 /* _CTL when writing */
  2084. +#define HD_ERROR 0x1f1 /* see err-bits */
  2085. +#define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */
  2086. +#define HD_SECTOR 0x1f3 /* starting sector */
  2087. +#define HD_LCYL 0x1f4 /* starting cylinder */
  2088. +#define HD_HCYL 0x1f5 /* high byte of starting cyl */
  2089. +#define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */
  2090. +#define HD_STATUS 0x1f7 /* see status-bits */
  2091. +#define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */
  2092. +#define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */
  2093. +#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
  2094. +
  2095. +#define HD_CMD 0x3f6 /* used for resets */
  2096. +#define HD_ALTSTATUS 0x3f6 /* same as HD_STATUS but doesn't clear irq */
  2097. +
  2098. +/* remainder is shared between hd.c, ide.c, ide-cd.c, and the hdparm utility */
  2099. +
  2100. +/* Bits of HD_STATUS */
  2101. +#define ERR_STAT 0x01
  2102. +#define INDEX_STAT 0x02
  2103. +#define ECC_STAT 0x04 /* Corrected error */
  2104. +#define DRQ_STAT 0x08
  2105. +#define SEEK_STAT 0x10
  2106. +#define SRV_STAT 0x10
  2107. +#define WRERR_STAT 0x20
  2108. +#define READY_STAT 0x40
  2109. +#define BUSY_STAT 0x80
  2110. +
  2111. +/* Bits for HD_ERROR */
  2112. +#define MARK_ERR 0x01 /* Bad address mark */
  2113. +#define TRK0_ERR 0x02 /* couldn't find track 0 */
  2114. +#define ABRT_ERR 0x04 /* Command aborted */
  2115. +#define MCR_ERR 0x08 /* media change request */
  2116. +#define ID_ERR 0x10 /* ID field not found */
  2117. +#define MC_ERR 0x20 /* media changed */
  2118. +#define ECC_ERR 0x40 /* Uncorrectable ECC error */
  2119. +#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */
  2120. +#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */
  2121. +
  2122. +/* Bits of HD_NSECTOR */
  2123. +#define CD 0x01
  2124. +#define IO 0x02
  2125. +#define REL 0x04
  2126. +#define TAG_MASK 0xf8
  2127. +
  2128. +
  2129. +/*
  2130. + * Command Header sizes for IOCTL commands
  2131. + * HDIO_DRIVE_CMD, HDIO_DRIVE_TASK, and HDIO_DRIVE_TASKFILE
  2132. + */
  2133. +
  2134. +#if 0
  2135. +#include <asm/hdreg.h>
  2136. +typedef ide_ioreg_t task_ioreg_t;
  2137. +#else
  2138. +typedef unsigned char task_ioreg_t;
  2139. +#endif
  2140. +
  2141. +typedef unsigned long sata_ioreg_t;
  2142. +
  2143. +#define HDIO_DRIVE_CMD_HDR_SIZE 4*sizeof(task_ioreg_t)
  2144. +#define HDIO_DRIVE_TASK_HDR_SIZE 8*sizeof(task_ioreg_t)
  2145. +#define HDIO_DRIVE_HOB_HDR_SIZE 8*sizeof(task_ioreg_t)
  2146. +
  2147. +#define IDE_DRIVE_TASK_INVALID -1
  2148. +#define IDE_DRIVE_TASK_NO_DATA 0
  2149. +#define IDE_DRIVE_TASK_SET_XFER 1
  2150. +
  2151. +#define IDE_DRIVE_TASK_IN 2
  2152. +
  2153. +#define IDE_DRIVE_TASK_OUT 3
  2154. +#define IDE_DRIVE_TASK_RAW_WRITE 4
  2155. +
  2156. +struct hd_drive_cmd_hdr {
  2157. + task_ioreg_t command;
  2158. + task_ioreg_t sector_number;
  2159. + task_ioreg_t feature;
  2160. + task_ioreg_t sector_count;
  2161. +};
  2162. +
  2163. +typedef struct hd_drive_task_hdr {
  2164. + task_ioreg_t data;
  2165. + task_ioreg_t feature;
  2166. + task_ioreg_t sector_count;
  2167. + task_ioreg_t sector_number;
  2168. + task_ioreg_t low_cylinder;
  2169. + task_ioreg_t high_cylinder;
  2170. + task_ioreg_t device_head;
  2171. + task_ioreg_t command;
  2172. +} task_struct_t;
  2173. +
  2174. +typedef struct hd_drive_hob_hdr {
  2175. + task_ioreg_t data;
  2176. + task_ioreg_t feature;
  2177. + task_ioreg_t sector_count;
  2178. + task_ioreg_t sector_number;
  2179. + task_ioreg_t low_cylinder;
  2180. + task_ioreg_t high_cylinder;
  2181. + task_ioreg_t device_head;
  2182. + task_ioreg_t control;
  2183. +} hob_struct_t;
  2184. +
  2185. +typedef union ide_reg_valid_s {
  2186. + unsigned all : 16;
  2187. + struct {
  2188. + unsigned data : 1;
  2189. + unsigned error_feature : 1;
  2190. + unsigned sector : 1;
  2191. + unsigned nsector : 1;
  2192. + unsigned lcyl : 1;
  2193. + unsigned hcyl : 1;
  2194. + unsigned select : 1;
  2195. + unsigned status_command : 1;
  2196. +
  2197. + unsigned data_hob : 1;
  2198. + unsigned error_feature_hob : 1;
  2199. + unsigned sector_hob : 1;
  2200. + unsigned nsector_hob : 1;
  2201. + unsigned lcyl_hob : 1;
  2202. + unsigned hcyl_hob : 1;
  2203. + unsigned select_hob : 1;
  2204. + unsigned control_hob : 1;
  2205. + } b;
  2206. +} ide_reg_valid_t;
  2207. +
  2208. +/*
  2209. + * Define standard taskfile in/out register
  2210. + */
  2211. +#define IDE_TASKFILE_STD_OUT_FLAGS 0xFE
  2212. +#define IDE_TASKFILE_STD_IN_FLAGS 0xFE
  2213. +#define IDE_HOB_STD_OUT_FLAGS 0x3C
  2214. +#define IDE_HOB_STD_IN_FLAGS 0x3C
  2215. +
  2216. +typedef struct ide_task_request_s {
  2217. + task_ioreg_t io_ports[8];
  2218. + task_ioreg_t hob_ports[8];
  2219. + ide_reg_valid_t out_flags;
  2220. + ide_reg_valid_t in_flags;
  2221. + int data_phase;
  2222. + int req_cmd;
  2223. + unsigned long out_size;
  2224. + unsigned long in_size;
  2225. +} ide_task_request_t;
  2226. +
  2227. +typedef struct ide_ioctl_request_s {
  2228. + ide_task_request_t *task_request;
  2229. + unsigned char *out_buffer;
  2230. + unsigned char *in_buffer;
  2231. +} ide_ioctl_request_t;
  2232. +
  2233. +#define TASKFILE_INVALID 0x7fff
  2234. +#define TASKFILE_48 0x8000
  2235. +
  2236. +#define TASKFILE_NO_DATA 0x0000
  2237. +
  2238. +#define TASKFILE_IN 0x0001
  2239. +#define TASKFILE_MULTI_IN 0x0002
  2240. +
  2241. +#define TASKFILE_OUT 0x0004
  2242. +#define TASKFILE_MULTI_OUT 0x0008
  2243. +#define TASKFILE_IN_OUT 0x0010
  2244. +
  2245. +#define TASKFILE_IN_DMA 0x0020
  2246. +#define TASKFILE_OUT_DMA 0x0040
  2247. +#define TASKFILE_IN_DMAQ 0x0080
  2248. +#define TASKFILE_OUT_DMAQ 0x0100
  2249. +
  2250. +#define TASKFILE_P_IN 0x0200
  2251. +#define TASKFILE_P_OUT 0x0400
  2252. +#define TASKFILE_P_IN_DMA 0x0800
  2253. +#define TASKFILE_P_OUT_DMA 0x1000
  2254. +#define TASKFILE_P_IN_DMAQ 0x2000
  2255. +#define TASKFILE_P_OUT_DMAQ 0x4000
  2256. +
  2257. +/* ATA/ATAPI Commands pre T13 Spec */
  2258. +#define WIN_NOP 0x00
  2259. +/*
  2260. + * 0x01->0x02 Reserved
  2261. + */
  2262. +#define CFA_REQ_EXT_ERROR_CODE 0x03 /* CFA Request Extended Error Code */
  2263. +/*
  2264. + * 0x04->0x07 Reserved
  2265. + */
  2266. +#define WIN_SRST 0x08 /* ATAPI soft reset command */
  2267. +#define WIN_DEVICE_RESET 0x08
  2268. +/*
  2269. + * 0x09->0x0F Reserved
  2270. + */
  2271. +#define WIN_RECAL 0x10
  2272. +#define WIN_RESTORE WIN_RECAL
  2273. +/*
  2274. + * 0x10->0x1F Reserved
  2275. + */
  2276. +#define WIN_READ 0x20 /* 28-Bit */
  2277. +#define WIN_READ_ONCE 0x21 /* 28-Bit without retries */
  2278. +#define WIN_READ_LONG 0x22 /* 28-Bit */
  2279. +#define WIN_READ_LONG_ONCE 0x23 /* 28-Bit without retries */
  2280. +#define WIN_READ_EXT 0x24 /* 48-Bit */
  2281. +#define WIN_READDMA_EXT 0x25 /* 48-Bit */
  2282. +#define WIN_READDMA_QUEUED_EXT 0x26 /* 48-Bit */
  2283. +#define WIN_READ_NATIVE_MAX_EXT 0x27 /* 48-Bit */
  2284. +/*
  2285. + * 0x28
  2286. + */
  2287. +#define WIN_MULTREAD_EXT 0x29 /* 48-Bit */
  2288. +/*
  2289. + * 0x2A->0x2F Reserved
  2290. + */
  2291. +#define WIN_WRITE 0x30 /* 28-Bit */
  2292. +#define WIN_WRITE_ONCE 0x31 /* 28-Bit without retries */
  2293. +#define WIN_WRITE_LONG 0x32 /* 28-Bit */
  2294. +#define WIN_WRITE_LONG_ONCE 0x33 /* 28-Bit without retries */
  2295. +#define WIN_WRITE_EXT 0x34 /* 48-Bit */
  2296. +#define WIN_WRITEDMA_EXT 0x35 /* 48-Bit */
  2297. +#define WIN_WRITEDMA_QUEUED_EXT 0x36 /* 48-Bit */
  2298. +#define WIN_SET_MAX_EXT 0x37 /* 48-Bit */
  2299. +#define CFA_WRITE_SECT_WO_ERASE 0x38 /* CFA Write Sectors without erase */
  2300. +#define WIN_MULTWRITE_EXT 0x39 /* 48-Bit */
  2301. +/*
  2302. + * 0x3A->0x3B Reserved
  2303. + */
  2304. +#define WIN_WRITE_VERIFY 0x3C /* 28-Bit */
  2305. +/*
  2306. + * 0x3D->0x3F Reserved
  2307. + */
  2308. +#define WIN_VERIFY 0x40 /* 28-Bit - Read Verify Sectors */
  2309. +#define WIN_VERIFY_ONCE 0x41 /* 28-Bit - without retries */
  2310. +#define WIN_VERIFY_EXT 0x42 /* 48-Bit */
  2311. +/*
  2312. + * 0x43->0x4F Reserved
  2313. + */
  2314. +#define WIN_FORMAT 0x50
  2315. +/*
  2316. + * 0x51->0x5F Reserved
  2317. + */
  2318. +#define WIN_INIT 0x60
  2319. +/*
  2320. + * 0x61->0x5F Reserved
  2321. + */
  2322. +#define WIN_SEEK 0x70 /* 0x70-0x7F Reserved */
  2323. +#define CFA_TRANSLATE_SECTOR 0x87 /* CFA Translate Sector */
  2324. +#define WIN_DIAGNOSE 0x90
  2325. +#define WIN_SPECIFY 0x91 /* set drive geometry translation */
  2326. +#define WIN_DOWNLOAD_MICROCODE 0x92
  2327. +#define WIN_STANDBYNOW2 0x94
  2328. +#define WIN_STANDBY2 0x96
  2329. +#define WIN_SETIDLE2 0x97
  2330. +#define WIN_CHECKPOWERMODE2 0x98
  2331. +#define WIN_SLEEPNOW2 0x99
  2332. +/*
  2333. + * 0x9A VENDOR
  2334. + */
  2335. +#define WIN_PACKETCMD 0xA0 /* Send a packet command. */
  2336. +#define WIN_PIDENTIFY 0xA1 /* identify ATAPI device */
  2337. +#define WIN_QUEUED_SERVICE 0xA2
  2338. +#define WIN_SMART 0xB0 /* self-monitoring and reporting */
  2339. +#define CFA_ERASE_SECTORS 0xC0
  2340. +#define WIN_MULTREAD 0xC4 /* read sectors using multiple mode*/
  2341. +#define WIN_MULTWRITE 0xC5 /* write sectors using multiple mode */
  2342. +#define WIN_SETMULT 0xC6 /* enable/disable multiple mode */
  2343. +#define WIN_READDMA_QUEUED 0xC7 /* read sectors using Queued DMA transfers */
  2344. +#define WIN_READDMA 0xC8 /* read sectors using DMA transfers */
  2345. +#define WIN_READDMA_ONCE 0xC9 /* 28-Bit - without retries */
  2346. +#define WIN_WRITEDMA 0xCA /* write sectors using DMA transfers */
  2347. +#define WIN_WRITEDMA_ONCE 0xCB /* 28-Bit - without retries */
  2348. +#define WIN_WRITEDMA_QUEUED 0xCC /* write sectors using Queued DMA transfers */
  2349. +#define CFA_WRITE_MULTI_WO_ERASE 0xCD /* CFA Write multiple without erase */
  2350. +#define WIN_GETMEDIASTATUS 0xDA
  2351. +#define WIN_ACKMEDIACHANGE 0xDB /* ATA-1, ATA-2 vendor */
  2352. +#define WIN_POSTBOOT 0xDC
  2353. +#define WIN_PREBOOT 0xDD
  2354. +#define WIN_DOORLOCK 0xDE /* lock door on removable drives */
  2355. +#define WIN_DOORUNLOCK 0xDF /* unlock door on removable drives */
  2356. +#define WIN_STANDBYNOW1 0xE0
  2357. +#define WIN_IDLEIMMEDIATE 0xE1 /* force drive to become "ready" */
  2358. +#define WIN_STANDBY 0xE2 /* Set device in Standby Mode */
  2359. +#define WIN_SETIDLE1 0xE3
  2360. +#define WIN_READ_BUFFER 0xE4 /* force read only 1 sector */
  2361. +#define WIN_CHECKPOWERMODE1 0xE5
  2362. +#define WIN_SLEEPNOW1 0xE6
  2363. +#define WIN_FLUSH_CACHE 0xE7
  2364. +#define WIN_WRITE_BUFFER 0xE8 /* force write only 1 sector */
  2365. +#define WIN_WRITE_SAME 0xE9 /* read ata-2 to use */
  2366. + /* SET_FEATURES 0x22 or 0xDD */
  2367. +#define WIN_FLUSH_CACHE_EXT 0xEA /* 48-Bit */
  2368. +#define WIN_IDENTIFY 0xEC /* ask drive to identify itself */
  2369. +#define WIN_MEDIAEJECT 0xED
  2370. +#define WIN_IDENTIFY_DMA 0xEE /* same as WIN_IDENTIFY, but DMA */
  2371. +#define WIN_SETFEATURES 0xEF /* set special drive features */
  2372. +#define EXABYTE_ENABLE_NEST 0xF0
  2373. +#define WIN_SECURITY_SET_PASS 0xF1
  2374. +#define WIN_SECURITY_UNLOCK 0xF2
  2375. +#define WIN_SECURITY_ERASE_PREPARE 0xF3
  2376. +#define WIN_SECURITY_ERASE_UNIT 0xF4
  2377. +#define WIN_SECURITY_FREEZE_LOCK 0xF5
  2378. +#define WIN_SECURITY_DISABLE 0xF6
  2379. +#define WIN_READ_NATIVE_MAX 0xF8 /* return the native maximum address */
  2380. +#define WIN_SET_MAX 0xF9
  2381. +#define DISABLE_SEAGATE 0xFB
  2382. +
  2383. +/* WIN_SMART sub-commands */
  2384. +
  2385. +#define SMART_READ_VALUES 0xD0
  2386. +#define SMART_READ_THRESHOLDS 0xD1
  2387. +#define SMART_AUTOSAVE 0xD2
  2388. +#define SMART_SAVE 0xD3
  2389. +#define SMART_IMMEDIATE_OFFLINE 0xD4
  2390. +#define SMART_READ_LOG_SECTOR 0xD5
  2391. +#define SMART_WRITE_LOG_SECTOR 0xD6
  2392. +#define SMART_WRITE_THRESHOLDS 0xD7
  2393. +#define SMART_ENABLE 0xD8
  2394. +#define SMART_DISABLE 0xD9
  2395. +#define SMART_STATUS 0xDA
  2396. +#define SMART_AUTO_OFFLINE 0xDB
  2397. +
  2398. +/* Password used in TF4 & TF5 executing SMART commands */
  2399. +
  2400. +#define SMART_LCYL_PASS 0x4F
  2401. +#define SMART_HCYL_PASS 0xC2
  2402. +
  2403. +/* WIN_SETFEATURES sub-commands */
  2404. +#define SETFEATURES_EN_8BIT 0x01 /* Enable 8-Bit Transfers */
  2405. +#define SETFEATURES_EN_WCACHE 0x02 /* Enable write cache */
  2406. +#define SETFEATURES_XFER 0x03 /* Set transfer mode */
  2407. +# define XFER_UDMA_7 0x47 /* 0100|0111 */
  2408. +# define XFER_UDMA_6 0x46 /* 0100|0110 */
  2409. +# define XFER_UDMA_5 0x45 /* 0100|0101 */
  2410. +# define XFER_UDMA_4 0x44 /* 0100|0100 */
  2411. +# define XFER_UDMA_3 0x43 /* 0100|0011 */
  2412. +# define XFER_UDMA_2 0x42 /* 0100|0010 */
  2413. +# define XFER_UDMA_1 0x41 /* 0100|0001 */
  2414. +# define XFER_UDMA_0 0x40 /* 0100|0000 */
  2415. +# define XFER_MW_DMA_2 0x22 /* 0010|0010 */
  2416. +# define XFER_MW_DMA_1 0x21 /* 0010|0001 */
  2417. +# define XFER_MW_DMA_0 0x20 /* 0010|0000 */
  2418. +# define XFER_SW_DMA_2 0x12 /* 0001|0010 */
  2419. +# define XFER_SW_DMA_1 0x11 /* 0001|0001 */
  2420. +# define XFER_SW_DMA_0 0x10 /* 0001|0000 */
  2421. +# define XFER_PIO_4 0x0C /* 0000|1100 */
  2422. +# define XFER_PIO_3 0x0B /* 0000|1011 */
  2423. +# define XFER_PIO_2 0x0A /* 0000|1010 */
  2424. +# define XFER_PIO_1 0x09 /* 0000|1001 */
  2425. +# define XFER_PIO_0 0x08 /* 0000|1000 */
  2426. +# define XFER_PIO_SLOW 0x00 /* 0000|0000 */
  2427. +#define SETFEATURES_DIS_DEFECT 0x04 /* Disable Defect Management */
  2428. +#define SETFEATURES_EN_APM 0x05 /* Enable advanced power management */
  2429. +#define SETFEATURES_EN_SAME_R 0x22 /* for a region ATA-1 */
  2430. +#define SETFEATURES_DIS_MSN 0x31 /* Disable Media Status Notification */
  2431. +#define SETFEATURES_DIS_RETRY 0x33 /* Disable Retry */
  2432. +#define SETFEATURES_EN_AAM 0x42 /* Enable Automatic Acoustic Management */
  2433. +#define SETFEATURES_RW_LONG 0x44 /* Set Lenght of VS bytes */
  2434. +#define SETFEATURES_SET_CACHE 0x54 /* Set Cache segments to SC Reg. Val */
  2435. +#define SETFEATURES_DIS_RLA 0x55 /* Disable read look-ahead feature */
  2436. +#define SETFEATURES_EN_RI 0x5D /* Enable release interrupt */
  2437. +#define SETFEATURES_EN_SI 0x5E /* Enable SERVICE interrupt */
  2438. +#define SETFEATURES_DIS_RPOD 0x66 /* Disable reverting to power on defaults */
  2439. +#define SETFEATURES_DIS_ECC 0x77 /* Disable ECC byte count */
  2440. +#define SETFEATURES_DIS_8BIT 0x81 /* Disable 8-Bit Transfers */
  2441. +#define SETFEATURES_DIS_WCACHE 0x82 /* Disable write cache */
  2442. +#define SETFEATURES_EN_DEFECT 0x84 /* Enable Defect Management */
  2443. +#define SETFEATURES_DIS_APM 0x85 /* Disable advanced power management */
  2444. +#define SETFEATURES_EN_ECC 0x88 /* Enable ECC byte count */
  2445. +#define SETFEATURES_EN_MSN 0x95 /* Enable Media Status Notification */
  2446. +#define SETFEATURES_EN_RETRY 0x99 /* Enable Retry */
  2447. +#define SETFEATURES_EN_RLA 0xAA /* Enable read look-ahead feature */
  2448. +#define SETFEATURES_PREFETCH 0xAB /* Sets drive prefetch value */
  2449. +#define SETFEATURES_EN_REST 0xAC /* ATA-1 */
  2450. +#define SETFEATURES_4B_RW_LONG 0xBB /* Set Lenght of 4 bytes */
  2451. +#define SETFEATURES_DIS_AAM 0xC2 /* Disable Automatic Acoustic Management */
  2452. +#define SETFEATURES_EN_RPOD 0xCC /* Enable reverting to power on defaults */
  2453. +#define SETFEATURES_DIS_RI 0xDD /* Disable release interrupt ATAPI */
  2454. +#define SETFEATURES_EN_SAME_M 0xDD /* for a entire device ATA-1 */
  2455. +#define SETFEATURES_DIS_SI 0xDE /* Disable SERVICE interrupt ATAPI */
  2456. +
  2457. +/* WIN_SECURITY sub-commands */
  2458. +
  2459. +#define SECURITY_SET_PASSWORD 0xBA
  2460. +#define SECURITY_UNLOCK 0xBB
  2461. +#define SECURITY_ERASE_PREPARE 0xBC
  2462. +#define SECURITY_ERASE_UNIT 0xBD
  2463. +#define SECURITY_FREEZE_LOCK 0xBE
  2464. +#define SECURITY_DISABLE_PASSWORD 0xBF
  2465. +
  2466. +struct hd_geometry {
  2467. + unsigned char heads;
  2468. + unsigned char sectors;
  2469. + unsigned short cylinders;
  2470. + unsigned long start;
  2471. +};
  2472. +
  2473. +/* BIG GEOMETRY */
  2474. +struct hd_big_geometry {
  2475. + unsigned char heads;
  2476. + unsigned char sectors;
  2477. + unsigned int cylinders;
  2478. + unsigned long start;
  2479. +};
  2480. +
  2481. +/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
  2482. +#define HDIO_GETGEO 0x0301 /* get device geometry */
  2483. +#define HDIO_GET_UNMASKINTR 0x0302 /* get current unmask setting */
  2484. +#define HDIO_GET_MULTCOUNT 0x0304 /* get current IDE blockmode setting */
  2485. +#define HDIO_GET_QDMA 0x0305 /* get use-qdma flag */
  2486. +
  2487. +#define HDIO_SET_XFER 0x0306 /* set transfer rate via proc */
  2488. +
  2489. +#define HDIO_OBSOLETE_IDENTITY 0x0307 /* OBSOLETE, DO NOT USE: returns 142 bytes */
  2490. +#define HDIO_GET_KEEPSETTINGS 0x0308 /* get keep-settings-on-reset flag */
  2491. +#define HDIO_GET_32BIT 0x0309 /* get current io_32bit setting */
  2492. +#define HDIO_GET_NOWERR 0x030a /* get ignore-write-error flag */
  2493. +#define HDIO_GET_DMA 0x030b /* get use-dma flag */
  2494. +#define HDIO_GET_NICE 0x030c /* get nice flags */
  2495. +#define HDIO_GET_IDENTITY 0x030d /* get IDE identification info */
  2496. +#define HDIO_GET_WCACHE 0x030e /* get write cache mode on|off */
  2497. +#define HDIO_GET_ACOUSTIC 0x030f /* get acoustic value */
  2498. +#define HDIO_GET_ADDRESS 0x0310 /* */
  2499. +
  2500. +#define HDIO_GET_BUSSTATE 0x031a /* get the bus state of the hwif */
  2501. +#define HDIO_TRISTATE_HWIF 0x031b /* execute a channel tristate */
  2502. +#define HDIO_DRIVE_RESET 0x031c /* execute a device reset */
  2503. +#define HDIO_DRIVE_TASKFILE 0x031d /* execute raw taskfile */
  2504. +#define HDIO_DRIVE_TASK 0x031e /* execute task and special drive command */
  2505. +#define HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
  2506. +
  2507. +#define HDIO_DRIVE_CMD_AEB HDIO_DRIVE_TASK
  2508. +
  2509. +/* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
  2510. +#define HDIO_SET_MULTCOUNT 0x0321 /* change IDE blockmode */
  2511. +#define HDIO_SET_UNMASKINTR 0x0322 /* permit other irqs during I/O */
  2512. +#define HDIO_SET_KEEPSETTINGS 0x0323 /* keep ioctl settings on reset */
  2513. +#define HDIO_SET_32BIT 0x0324 /* change io_32bit flags */
  2514. +#define HDIO_SET_NOWERR 0x0325 /* change ignore-write-error flag */
  2515. +#define HDIO_SET_DMA 0x0326 /* change use-dma flag */
  2516. +#define HDIO_SET_PIO_MODE 0x0327 /* reconfig interface to new speed */
  2517. +#define HDIO_SCAN_HWIF 0x0328 /* register and (re)scan interface */
  2518. +#define HDIO_SET_NICE 0x0329 /* set nice flags */
  2519. +#define HDIO_UNREGISTER_HWIF 0x032a /* unregister interface */
  2520. +#define HDIO_SET_WCACHE 0x032b /* change write cache enable-disable */
  2521. +#define HDIO_SET_ACOUSTIC 0x032c /* change acoustic behavior */
  2522. +#define HDIO_SET_BUSSTATE 0x032d /* set the bus state of the hwif */
  2523. +#define HDIO_SET_QDMA 0x032e /* change use-qdma flag */
  2524. +#define HDIO_SET_ADDRESS 0x032f /* change lba addressing modes */
  2525. +
  2526. +/* bus states */
  2527. +enum {
  2528. + BUSSTATE_OFF = 0,
  2529. + BUSSTATE_ON,
  2530. + BUSSTATE_TRISTATE
  2531. +};
  2532. +
  2533. +/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x033n/0x033n */
  2534. +#define HDIO_GETGEO_BIG 0x0330 /* */
  2535. +#define HDIO_GETGEO_BIG_RAW 0x0331 /* */
  2536. +
  2537. +#define HDIO_SET_IDE_SCSI 0x0338
  2538. +#define HDIO_SET_SCSI_IDE 0x0339
  2539. +
  2540. +#define __NEW_HD_DRIVE_ID
  2541. +/* structure returned by HDIO_GET_IDENTITY,
  2542. + * as per ANSI NCITS ATA6 rev.1b spec
  2543. + */
  2544. +struct hd_driveid {
  2545. + unsigned short config; /* lots of obsolete bit flags */
  2546. + unsigned short cyls; /* Obsolete, "physical" cyls */
  2547. + unsigned short reserved2; /* reserved (word 2) */
  2548. + unsigned short heads; /* Obsolete, "physical" heads */
  2549. + unsigned short track_bytes; /* unformatted bytes per track */
  2550. + unsigned short sector_bytes; /* unformatted bytes per sector */
  2551. + unsigned short sectors; /* Obsolete, "physical" sectors per track */
  2552. + unsigned short vendor0; /* vendor unique */
  2553. + unsigned short vendor1; /* vendor unique */
  2554. + unsigned short vendor2; /* Retired vendor unique */
  2555. + unsigned char serial_no[20]; /* 0 = not_specified */
  2556. + unsigned short buf_type; /* Retired */
  2557. + unsigned short buf_size; /* Retired, 512 byte increments
  2558. + * 0 = not_specified
  2559. + */
  2560. + unsigned short ecc_bytes; /* for r/w long cmds; 0 = not_specified */
  2561. + unsigned char fw_rev[8]; /* 0 = not_specified */
  2562. + unsigned char model[40]; /* 0 = not_specified */
  2563. + unsigned char max_multsect; /* 0=not_implemented */
  2564. + unsigned char vendor3; /* vendor unique */
  2565. + unsigned short dword_io; /* 0=not_implemented; 1=implemented */
  2566. + unsigned char vendor4; /* vendor unique */
  2567. + unsigned char capability; /* (upper byte of word 49)
  2568. + * 3: IORDYsup
  2569. + * 2: IORDYsw
  2570. + * 1: LBA
  2571. + * 0: DMA
  2572. + */
  2573. + unsigned short reserved50; /* reserved (word 50) */
  2574. + unsigned char vendor5; /* Obsolete, vendor unique */
  2575. + unsigned char tPIO; /* Obsolete, 0=slow, 1=medium, 2=fast */
  2576. + unsigned char vendor6; /* Obsolete, vendor unique */
  2577. + unsigned char tDMA; /* Obsolete, 0=slow, 1=medium, 2=fast */
  2578. + unsigned short field_valid; /* (word 53)
  2579. + * 2: ultra_ok word 88
  2580. + * 1: eide_ok words 64-70
  2581. + * 0: cur_ok words 54-58
  2582. + */
  2583. + unsigned short cur_cyls; /* Obsolete, logical cylinders */
  2584. + unsigned short cur_heads; /* Obsolete, l heads */
  2585. + unsigned short cur_sectors; /* Obsolete, l sectors per track */
  2586. + unsigned short cur_capacity0; /* Obsolete, l total sectors on drive */
  2587. + unsigned short cur_capacity1; /* Obsolete, (2 words, misaligned int) */
  2588. + unsigned char multsect; /* current multiple sector count */
  2589. + unsigned char multsect_valid; /* when (bit0==1) multsect is ok */
  2590. + unsigned int lba_capacity; /* Obsolete, total number of sectors */
  2591. + unsigned short dma_1word; /* Obsolete, single-word dma info */
  2592. + unsigned short dma_mword; /* multiple-word dma info */
  2593. + unsigned short eide_pio_modes; /* bits 0:mode3 1:mode4 */
  2594. + unsigned short eide_dma_min; /* min mword dma cycle time (ns) */
  2595. + unsigned short eide_dma_time; /* recommended mword dma cycle time (ns) */
  2596. + unsigned short eide_pio; /* min cycle time (ns), no IORDY */
  2597. + unsigned short eide_pio_iordy; /* min cycle time (ns), with IORDY */
  2598. + unsigned short words69_70[2]; /* reserved words 69-70
  2599. + * future command overlap and queuing
  2600. + */
  2601. + /* HDIO_GET_IDENTITY currently returns only words 0 through 70 */
  2602. + unsigned short words71_74[4]; /* reserved words 71-74
  2603. + * for IDENTIFY PACKET DEVICE command
  2604. + */
  2605. + unsigned short queue_depth; /* (word 75)
  2606. + * 15:5 reserved
  2607. + * 4:0 Maximum queue depth -1
  2608. + */
  2609. + unsigned short words76_79[4]; /* reserved words 76-79 */
  2610. + unsigned short major_rev_num; /* (word 80) */
  2611. + unsigned short minor_rev_num; /* (word 81) */
  2612. + unsigned short command_set_1; /* (word 82) supported
  2613. + * 15: Obsolete
  2614. + * 14: NOP command
  2615. + * 13: READ_BUFFER
  2616. + * 12: WRITE_BUFFER
  2617. + * 11: Obsolete
  2618. + * 10: Host Protected Area
  2619. + * 9: DEVICE Reset
  2620. + * 8: SERVICE Interrupt
  2621. + * 7: Release Interrupt
  2622. + * 6: look-ahead
  2623. + * 5: write cache
  2624. + * 4: PACKET Command
  2625. + * 3: Power Management Feature Set
  2626. + * 2: Removable Feature Set
  2627. + * 1: Security Feature Set
  2628. + * 0: SMART Feature Set
  2629. + */
  2630. + unsigned short command_set_2; /* (word 83)
  2631. + * 15: Shall be ZERO
  2632. + * 14: Shall be ONE
  2633. + * 13: FLUSH CACHE EXT
  2634. + * 12: FLUSH CACHE
  2635. + * 11: Device Configuration Overlay
  2636. + * 10: 48-bit Address Feature Set
  2637. + * 9: Automatic Acoustic Management
  2638. + * 8: SET MAX security
  2639. + * 7: reserved 1407DT PARTIES
  2640. + * 6: SetF sub-command Power-Up
  2641. + * 5: Power-Up in Standby Feature Set
  2642. + * 4: Removable Media Notification
  2643. + * 3: APM Feature Set
  2644. + * 2: CFA Feature Set
  2645. + * 1: READ/WRITE DMA QUEUED
  2646. + * 0: Download MicroCode
  2647. + */
  2648. + unsigned short cfsse; /* (word 84)
  2649. + * cmd set-feature supported extensions
  2650. + * 15: Shall be ZERO
  2651. + * 14: Shall be ONE
  2652. + * 13:6 reserved
  2653. + * 5: General Purpose Logging
  2654. + * 4: Streaming Feature Set
  2655. + * 3: Media Card Pass Through
  2656. + * 2: Media Serial Number Valid
  2657. + * 1: SMART selt-test supported
  2658. + * 0: SMART error logging
  2659. + */
  2660. + unsigned short cfs_enable_1; /* (word 85)
  2661. + * command set-feature enabled
  2662. + * 15: Obsolete
  2663. + * 14: NOP command
  2664. + * 13: READ_BUFFER
  2665. + * 12: WRITE_BUFFER
  2666. + * 11: Obsolete
  2667. + * 10: Host Protected Area
  2668. + * 9: DEVICE Reset
  2669. + * 8: SERVICE Interrupt
  2670. + * 7: Release Interrupt
  2671. + * 6: look-ahead
  2672. + * 5: write cache
  2673. + * 4: PACKET Command
  2674. + * 3: Power Management Feature Set
  2675. + * 2: Removable Feature Set
  2676. + * 1: Security Feature Set
  2677. + * 0: SMART Feature Set
  2678. + */
  2679. + unsigned short cfs_enable_2; /* (word 86)
  2680. + * command set-feature enabled
  2681. + * 15: Shall be ZERO
  2682. + * 14: Shall be ONE
  2683. + * 13: FLUSH CACHE EXT
  2684. + * 12: FLUSH CACHE
  2685. + * 11: Device Configuration Overlay
  2686. + * 10: 48-bit Address Feature Set
  2687. + * 9: Automatic Acoustic Management
  2688. + * 8: SET MAX security
  2689. + * 7: reserved 1407DT PARTIES
  2690. + * 6: SetF sub-command Power-Up
  2691. + * 5: Power-Up in Standby Feature Set
  2692. + * 4: Removable Media Notification
  2693. + * 3: APM Feature Set
  2694. + * 2: CFA Feature Set
  2695. + * 1: READ/WRITE DMA QUEUED
  2696. + * 0: Download MicroCode
  2697. + */
  2698. + unsigned short csf_default; /* (word 87)
  2699. + * command set-feature default
  2700. + * 15: Shall be ZERO
  2701. + * 14: Shall be ONE
  2702. + * 13:6 reserved
  2703. + * 5: General Purpose Logging enabled
  2704. + * 4: Valid CONFIGURE STREAM executed
  2705. + * 3: Media Card Pass Through enabled
  2706. + * 2: Media Serial Number Valid
  2707. + * 1: SMART selt-test supported
  2708. + * 0: SMART error logging
  2709. + */
  2710. + unsigned short dma_ultra; /* (word 88) */
  2711. + unsigned short trseuc; /* time required for security erase */
  2712. + unsigned short trsEuc; /* time required for enhanced erase */
  2713. + unsigned short CurAPMvalues; /* current APM values */
  2714. + unsigned short mprc; /* master password revision code */
  2715. + unsigned short hw_config; /* hardware config (word 93)
  2716. + * 15: Shall be ZERO
  2717. + * 14: Shall be ONE
  2718. + * 13:
  2719. + * 12:
  2720. + * 11:
  2721. + * 10:
  2722. + * 9:
  2723. + * 8:
  2724. + * 7:
  2725. + * 6:
  2726. + * 5:
  2727. + * 4:
  2728. + * 3:
  2729. + * 2:
  2730. + * 1:
  2731. + * 0: Shall be ONE
  2732. + */
  2733. + unsigned short acoustic; /* (word 94)
  2734. + * 15:8 Vendor's recommended value
  2735. + * 7:0 current value
  2736. + */
  2737. + unsigned short msrqs; /* min stream request size */
  2738. + unsigned short sxfert; /* stream transfer time */
  2739. + unsigned short sal; /* stream access latency */
  2740. + unsigned int spg; /* stream performance granularity */
  2741. + unsigned long long lba_capacity_2;/* 48-bit total number of sectors */
  2742. + unsigned short words104_125[22];/* reserved words 104-125 */
  2743. + unsigned short last_lun; /* (word 126) */
  2744. + unsigned short word127; /* (word 127) Feature Set
  2745. + * Removable Media Notification
  2746. + * 15:2 reserved
  2747. + * 1:0 00 = not supported
  2748. + * 01 = supported
  2749. + * 10 = reserved
  2750. + * 11 = reserved
  2751. + */
  2752. + unsigned short dlf; /* (word 128)
  2753. + * device lock function
  2754. + * 15:9 reserved
  2755. + * 8 security level 1:max 0:high
  2756. + * 7:6 reserved
  2757. + * 5 enhanced erase
  2758. + * 4 expire
  2759. + * 3 frozen
  2760. + * 2 locked
  2761. + * 1 en/disabled
  2762. + * 0 capability
  2763. + */
  2764. + unsigned short csfo; /* (word 129)
  2765. + * current set features options
  2766. + * 15:4 reserved
  2767. + * 3: auto reassign
  2768. + * 2: reverting
  2769. + * 1: read-look-ahead
  2770. + * 0: write cache
  2771. + */
  2772. + unsigned short words130_155[26];/* reserved vendor words 130-155 */
  2773. + unsigned short word156; /* reserved vendor word 156 */
  2774. + unsigned short words157_159[3];/* reserved vendor words 157-159 */
  2775. + unsigned short cfa_power; /* (word 160) CFA Power Mode
  2776. + * 15 word 160 supported
  2777. + * 14 reserved
  2778. + * 13
  2779. + * 12
  2780. + * 11:0
  2781. + */
  2782. + unsigned short words161_175[15];/* Reserved for CFA */
  2783. + unsigned short words176_205[30];/* Current Media Serial Number */
  2784. + unsigned short words206_254[49];/* reserved words 206-254 */
  2785. + unsigned short integrity_word; /* (word 255)
  2786. + * 15:8 Checksum
  2787. + * 7:0 Signature
  2788. + */
  2789. +};
  2790. +
  2791. +/*
  2792. + * IDE "nice" flags. These are used on a per drive basis to determine
  2793. + * when to be nice and give more bandwidth to the other devices which
  2794. + * share the same IDE bus.
  2795. + */
  2796. +#define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */
  2797. +#define IDE_NICE_ATAPI_OVERLAP (1) /* not supported yet */
  2798. +#define IDE_NICE_0 (2) /* when sure that it won't affect us */
  2799. +#define IDE_NICE_1 (3) /* when probably won't affect us much */
  2800. +#define IDE_NICE_2 (4) /* when we know it's on our expense */
  2801. +
  2802. +#ifdef __KERNEL__
  2803. +/*
  2804. + * These routines are used for kernel command line parameters from main.c:
  2805. + */
  2806. +#include <linux/config.h>
  2807. +
  2808. +#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
  2809. +int ide_register(int io_port, int ctl_port, int irq);
  2810. +int ide_unregister(unsigned int);
  2811. +#endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
  2812. +
  2813. +#endif /* __KERNEL__ */
  2814. +
  2815. +#endif /* _LINUX_HDREG_H */
  2816. --- ./linux/list.h 1970-01-01 00:00:00.000000000 +0000
  2817. +++ ./linux/list.h 2004-08-20 03:20:02.312586312 +0000
  2818. @@ -0,0 +1,259 @@
  2819. +#ifndef _LINUX_LIST_H
  2820. +#define _LINUX_LIST_H
  2821. +
  2822. +#if defined(__KERNEL__) || defined(_LVM_H_INCLUDE)
  2823. +
  2824. +#include <linux/prefetch.h>
  2825. +
  2826. +/*
  2827. + * Simple doubly linked list implementation.
  2828. + *
  2829. + * Some of the internal functions ("__xxx") are useful when
  2830. + * manipulating whole lists rather than single entries, as
  2831. + * sometimes we already know the next/prev entries and we can
  2832. + * generate better code by using them directly rather than
  2833. + * using the generic single-entry routines.
  2834. + */
  2835. +
  2836. +struct list_head {
  2837. + struct list_head *next, *prev;
  2838. +};
  2839. +
  2840. +#define LIST_HEAD_INIT(name) { &(name), &(name) }
  2841. +
  2842. +#define LIST_HEAD(name) \
  2843. + struct list_head name = LIST_HEAD_INIT(name)
  2844. +
  2845. +#define INIT_LIST_HEAD(ptr) do { \
  2846. + (ptr)->next = (ptr); (ptr)->prev = (ptr); \
  2847. +} while (0)
  2848. +
  2849. +/*
  2850. + * Insert a new entry between two known consecutive entries.
  2851. + *
  2852. + * This is only for internal list manipulation where we know
  2853. + * the prev/next entries already!
  2854. + */
  2855. +static inline void __list_add(struct list_head *new,
  2856. + struct list_head *prev,
  2857. + struct list_head *next)
  2858. +{
  2859. + next->prev = new;
  2860. + new->next = next;
  2861. + new->prev = prev;
  2862. + prev->next = new;
  2863. +}
  2864. +
  2865. +/**
  2866. + * list_add - add a new entry
  2867. + * @new: new entry to be added
  2868. + * @head: list head to add it after
  2869. + *
  2870. + * Insert a new entry after the specified head.
  2871. + * This is good for implementing stacks.
  2872. + */
  2873. +static inline void list_add(struct list_head *new, struct list_head *head)
  2874. +{
  2875. + __list_add(new, head, head->next);
  2876. +}
  2877. +
  2878. +/**
  2879. + * list_add_tail - add a new entry
  2880. + * @new: new entry to be added
  2881. + * @head: list head to add it before
  2882. + *
  2883. + * Insert a new entry before the specified head.
  2884. + * This is useful for implementing queues.
  2885. + */
  2886. +static inline void list_add_tail(struct list_head *new, struct list_head *head)
  2887. +{
  2888. + __list_add(new, head->prev, head);
  2889. +}
  2890. +
  2891. +/*
  2892. + * Delete a list entry by making the prev/next entries
  2893. + * point to each other.
  2894. + *
  2895. + * This is only for internal list manipulation where we know
  2896. + * the prev/next entries already!
  2897. + */
  2898. +static inline void __list_del(struct list_head *prev, struct list_head *next)
  2899. +{
  2900. + next->prev = prev;
  2901. + prev->next = next;
  2902. +}
  2903. +
  2904. +/**
  2905. + * list_del - deletes entry from list.
  2906. + * @entry: the element to delete from the list.
  2907. + * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
  2908. + */
  2909. +static inline void list_del(struct list_head *entry)
  2910. +{
  2911. + __list_del(entry->prev, entry->next);
  2912. + entry->next = (void *) 0;
  2913. + entry->prev = (void *) 0;
  2914. +}
  2915. +
  2916. +/**
  2917. + * list_del_init - deletes entry from list and reinitialize it.
  2918. + * @entry: the element to delete from the list.
  2919. + */
  2920. +static inline void list_del_init(struct list_head *entry)
  2921. +{
  2922. + __list_del(entry->prev, entry->next);
  2923. + INIT_LIST_HEAD(entry);
  2924. +}
  2925. +
  2926. +/**
  2927. + * list_move - delete from one list and add as another's head
  2928. + * @list: the entry to move
  2929. + * @head: the head that will precede our entry
  2930. + */
  2931. +static inline void list_move(struct list_head *list, struct list_head *head)
  2932. +{
  2933. + __list_del(list->prev, list->next);
  2934. + list_add(list, head);
  2935. +}
  2936. +
  2937. +/**
  2938. + * list_move_tail - delete from one list and add as another's tail
  2939. + * @list: the entry to move
  2940. + * @head: the head that will follow our entry
  2941. + */
  2942. +static inline void list_move_tail(struct list_head *list,
  2943. + struct list_head *head)
  2944. +{
  2945. + __list_del(list->prev, list->next);
  2946. + list_add_tail(list, head);
  2947. +}
  2948. +
  2949. +/**
  2950. + * list_empty - tests whether a list is empty
  2951. + * @head: the list to test.
  2952. + */
  2953. +static inline int list_empty(struct list_head *head)
  2954. +{
  2955. + return head->next == head;
  2956. +}
  2957. +
  2958. +static inline void __list_splice(struct list_head *list,
  2959. + struct list_head *head)
  2960. +{
  2961. + struct list_head *first = list->next;
  2962. + struct list_head *last = list->prev;
  2963. + struct list_head *at = head->next;
  2964. +
  2965. + first->prev = head;
  2966. + head->next = first;
  2967. +
  2968. + last->next = at;
  2969. + at->prev = last;
  2970. +}
  2971. +
  2972. +/**
  2973. + * list_splice - join two lists
  2974. + * @list: the new list to add.
  2975. + * @head: the place to add it in the first list.
  2976. + */
  2977. +static inline void list_splice(struct list_head *list, struct list_head *head)
  2978. +{
  2979. + if (!list_empty(list))
  2980. + __list_splice(list, head);
  2981. +}
  2982. +
  2983. +/**
  2984. + * list_splice_init - join two lists and reinitialise the emptied list.
  2985. + * @list: the new list to add.
  2986. + * @head: the place to add it in the first list.
  2987. + *
  2988. + * The list at @list is reinitialised
  2989. + */
  2990. +static inline void list_splice_init(struct list_head *list,
  2991. + struct list_head *head)
  2992. +{
  2993. + if (!list_empty(list)) {
  2994. + __list_splice(list, head);
  2995. + INIT_LIST_HEAD(list);
  2996. + }
  2997. +}
  2998. +
  2999. +/**
  3000. + * list_entry - get the struct for this entry
  3001. + * @ptr: the &struct list_head pointer.
  3002. + * @type: the type of the struct this is embedded in.
  3003. + * @member: the name of the list_struct within the struct.
  3004. + */
  3005. +#define list_entry(ptr, type, member) \
  3006. + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
  3007. +
  3008. +/**
  3009. + * list_for_each - iterate over a list
  3010. + * @pos: the &struct list_head to use as a loop counter.
  3011. + * @head: the head for your list.
  3012. + */
  3013. +#define list_for_each(pos, head) \
  3014. + for (pos = (head)->next, prefetch(pos->next); pos != (head); \
  3015. + pos = pos->next, prefetch(pos->next))
  3016. +/**
  3017. + * list_for_each_prev - iterate over a list backwards
  3018. + * @pos: the &struct list_head to use as a loop counter.
  3019. + * @head: the head for your list.
  3020. + */
  3021. +#define list_for_each_prev(pos, head) \
  3022. + for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \
  3023. + pos = pos->prev, prefetch(pos->prev))
  3024. +
  3025. +/**
  3026. + * list_for_each_safe - iterate over a list safe against removal of list entry
  3027. + * @pos: the &struct list_head to use as a loop counter.
  3028. + * @n: another &struct list_head to use as temporary storage
  3029. + * @head: the head for your list.
  3030. + */
  3031. +#define list_for_each_safe(pos, n, head) \
  3032. + for (pos = (head)->next, n = pos->next; pos != (head); \
  3033. + pos = n, n = pos->next)
  3034. +
  3035. +/**
  3036. + * list_for_each_entry - iterate over list of given type
  3037. + * @pos: the type * to use as a loop counter.
  3038. + * @head: the head for your list.
  3039. + * @member: the name of the list_struct within the struct.
  3040. + */
  3041. +#define list_for_each_entry(pos, head, member) \
  3042. + for (pos = list_entry((head)->next, typeof(*pos), member), \
  3043. + prefetch(pos->member.next); \
  3044. + &pos->member != (head); \
  3045. + pos = list_entry(pos->member.next, typeof(*pos), member), \
  3046. + prefetch(pos->member.next))
  3047. +
  3048. +/**
  3049. + * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  3050. + * @pos: the type * to use as a loop counter.
  3051. + * @n: another type * to use as temporary storage
  3052. + * @head: the head for your list.
  3053. + * @member: the name of the list_struct within the struct.
  3054. + */
  3055. +#define list_for_each_entry_safe(pos, n, head, member) \
  3056. + for (pos = list_entry((head)->next, typeof(*pos), member), \
  3057. + n = list_entry(pos->member.next, typeof(*pos), member); \
  3058. + &pos->member != (head); \
  3059. + pos = n, n = list_entry(n->member.next, typeof(*n), member))
  3060. +
  3061. +/**
  3062. + * list_for_each_entry_continue - iterate over list of given type
  3063. + * continuing after existing point
  3064. + * @pos: the type * to use as a loop counter.
  3065. + * @head: the head for your list.
  3066. + * @member: the name of the list_struct within the struct.
  3067. + */
  3068. +#define list_for_each_entry_continue(pos, head, member) \
  3069. + for (pos = list_entry(pos->member.next, typeof(*pos), member), \
  3070. + prefetch(pos->member.next); \
  3071. + &pos->member != (head); \
  3072. + pos = list_entry(pos->member.next, typeof(*pos), member), \
  3073. + prefetch(pos->member.next))
  3074. +
  3075. +#endif /* __KERNEL__ || _LVM_H_INCLUDE */
  3076. +
  3077. +#endif
  3078. --- ./linux/types.h 1970-01-01 00:00:00.000000000 +0000
  3079. +++ ./linux/types.h 2004-08-20 03:17:15.071010896 +0000
  3080. @@ -0,0 +1,137 @@
  3081. +#ifndef _LINUX_TYPES_H
  3082. +#define _LINUX_TYPES_H
  3083. +
  3084. +#ifdef __KERNEL__
  3085. +#include <linux/config.h>
  3086. +
  3087. +#define BITS_TO_LONGS(bits) \
  3088. + (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
  3089. +#define DECLARE_BITMAP(name,bits) \
  3090. + unsigned long name[BITS_TO_LONGS(bits)]
  3091. +#define CLEAR_BITMAP(name,bits) \
  3092. + memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long))
  3093. +#endif
  3094. +
  3095. +#include <linux/posix_types.h>
  3096. +#include <asm/types.h>
  3097. +
  3098. +#ifndef __KERNEL_STRICT_NAMES
  3099. +
  3100. +typedef __kernel_fd_set fd_set;
  3101. +typedef __kernel_dev_t dev_t;
  3102. +typedef __kernel_ino_t ino_t;
  3103. +typedef __kernel_mode_t mode_t;
  3104. +typedef __kernel_nlink_t nlink_t;
  3105. +typedef __kernel_off_t off_t;
  3106. +typedef __kernel_pid_t pid_t;
  3107. +typedef __kernel_daddr_t daddr_t;
  3108. +typedef __kernel_key_t key_t;
  3109. +typedef __kernel_suseconds_t suseconds_t;
  3110. +
  3111. +#ifdef __KERNEL__
  3112. +typedef __kernel_uid32_t uid_t;
  3113. +typedef __kernel_gid32_t gid_t;
  3114. +typedef __kernel_uid16_t uid16_t;
  3115. +typedef __kernel_gid16_t gid16_t;
  3116. +
  3117. +#ifdef CONFIG_UID16
  3118. +/* This is defined by include/asm-{arch}/posix_types.h */
  3119. +typedef __kernel_old_uid_t old_uid_t;
  3120. +typedef __kernel_old_gid_t old_gid_t;
  3121. +#endif /* CONFIG_UID16 */
  3122. +
  3123. +/* libc5 includes this file to define uid_t, thus uid_t can never change
  3124. + * when it is included by non-kernel code
  3125. + */
  3126. +#else
  3127. +typedef __kernel_uid_t uid_t;
  3128. +typedef __kernel_gid_t gid_t;
  3129. +#endif /* __KERNEL__ */
  3130. +
  3131. +#if defined(__GNUC__)
  3132. +typedef __kernel_loff_t loff_t;
  3133. +#endif
  3134. +
  3135. +/*
  3136. + * The following typedefs are also protected by individual ifdefs for
  3137. + * historical reasons:
  3138. + */
  3139. +#ifndef _SIZE_T
  3140. +#define _SIZE_T
  3141. +typedef __kernel_size_t size_t;
  3142. +#endif
  3143. +
  3144. +#ifndef _SSIZE_T
  3145. +#define _SSIZE_T
  3146. +typedef __kernel_ssize_t ssize_t;
  3147. +#endif
  3148. +
  3149. +#ifndef _PTRDIFF_T
  3150. +#define _PTRDIFF_T
  3151. +typedef __kernel_ptrdiff_t ptrdiff_t;
  3152. +#endif
  3153. +
  3154. +#ifndef _TIME_T
  3155. +#define _TIME_T
  3156. +typedef __kernel_time_t time_t;
  3157. +#endif
  3158. +
  3159. +#ifndef _CLOCK_T
  3160. +#define _CLOCK_T
  3161. +typedef __kernel_clock_t clock_t;
  3162. +#endif
  3163. +
  3164. +#ifndef _CADDR_T
  3165. +#define _CADDR_T
  3166. +typedef __kernel_caddr_t caddr_t;
  3167. +#endif
  3168. +
  3169. +/* bsd */
  3170. +typedef unsigned char u_char;
  3171. +typedef unsigned short u_short;
  3172. +typedef unsigned int u_int;
  3173. +typedef unsigned long u_long;
  3174. +
  3175. +/* sysv */
  3176. +typedef unsigned char unchar;
  3177. +typedef unsigned short ushort;
  3178. +typedef unsigned int uint;
  3179. +typedef unsigned long ulong;
  3180. +
  3181. +#ifndef __BIT_TYPES_DEFINED__
  3182. +#define __BIT_TYPES_DEFINED__
  3183. +
  3184. +typedef __u8 u_int8_t;
  3185. +typedef __s8 int8_t;
  3186. +typedef __u16 u_int16_t;
  3187. +typedef __s16 int16_t;
  3188. +typedef __u32 u_int32_t;
  3189. +typedef __s32 int32_t;
  3190. +
  3191. +#endif /* !(__BIT_TYPES_DEFINED__) */
  3192. +
  3193. +typedef __u8 uint8_t;
  3194. +typedef __u16 uint16_t;
  3195. +typedef __u32 uint32_t;
  3196. +
  3197. +#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
  3198. +typedef __u64 uint64_t;
  3199. +typedef __u64 u_int64_t;
  3200. +typedef __s64 int64_t;
  3201. +#endif
  3202. +
  3203. +#endif /* __KERNEL_STRICT_NAMES */
  3204. +
  3205. +/*
  3206. + * Below are truly Linux-specific types that should never collide with
  3207. + * any application/library that wants linux/types.h.
  3208. + */
  3209. +
  3210. +struct ustat {
  3211. + __kernel_daddr_t f_tfree;
  3212. + __kernel_ino_t f_tinode;
  3213. + char f_fname[6];
  3214. + char f_fpack[6];
  3215. +};
  3216. +
  3217. +#endif /* _LINUX_TYPES_H */
  3218. --- ./linux/vfs.h 1970-01-01 00:00:00.000000000 +0000
  3219. +++ ./linux/vfs.h 2004-08-20 03:18:36.751593560 +0000
  3220. @@ -0,0 +1,6 @@
  3221. +#ifndef _LINUX_VFS_H
  3222. +#define _LINUX_VFS_H
  3223. +
  3224. +#include <asm/statfs.h>
  3225. +
  3226. +#endif