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.

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