5 * This file has definitions for some important file table
9 #include <linux/config.h>
10 #include <linux/linkage.h>
11 #include <linux/limits.h>
12 #include <linux/wait.h>
13 #include <linux/types.h>
14 #include <linux/vfs.h>
15 #include <linux/net.h>
16 #include <linux/kdev_t.h>
17 #include <linux/ioctl.h>
18 #include <linux/list.h>
19 #include <linux/dcache.h>
21 #include <asm/atomic.h>
22 #include <asm/bitops.h>
27 * It's silly to have NR_OPEN bigger than NR_FILE, but I'll fix
28 * that later. Anyway, now the file code is no longer dependent
29 * on bitmaps in unsigned longs, but uses the new fd_set structure..
31 * Some programs (notably those using select()) may have to be
32 * recompiled to take full advantage of the new limits..
35 /* Fixed constants first: */
40 #define BLOCK_SIZE 1024
41 #define BLOCK_SIZE_BITS 10
43 /* And dynamically-tunable limits and defaults: */
44 extern int max_inodes
;
45 extern int max_files
, nr_files
;
46 #define NR_INODE 4096 /* this should be bigger than NR_FILE */
47 #define NR_FILE 1024 /* this can well be larger on a larger system */
58 #define READA 2 /* read-ahead - don't block if no resources */
59 #define WRITEA 3 /* write-ahead - don't block if no resources */
62 #define NULL ((void *) 0)
65 #define NIL_FILP ((struct file *)0)
70 /* public flags for file_system_type */
71 #define FS_REQUIRES_DEV 1
72 #define FS_NO_DCACHE 2 /* Only dcache the necessary things. */
73 #define FS_NO_PRELIM 4 /* prevent preloading of dentries, even if
74 * FS_NO_DCACHE is not set.
76 #define FS_IBASKET 8 /* FS does callback to free_ibasket() if space gets low. */
79 * These are the fs-independent mount-flags: up to 16 flags are supported
81 #define MS_RDONLY 1 /* Mount read-only */
82 #define MS_NOSUID 2 /* Ignore suid and sgid bits */
83 #define MS_NODEV 4 /* Disallow access to device special files */
84 #define MS_NOEXEC 8 /* Disallow program execution */
85 #define MS_SYNCHRONOUS 16 /* Writes are synced at once */
86 #define MS_REMOUNT 32 /* Alter flags of a mounted FS */
87 #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
88 #define S_WRITE 128 /* Write on file/directory/symlink */
89 #define S_APPEND 256 /* Append-only file */
90 #define S_IMMUTABLE 512 /* Immutable file */
91 #define MS_NOATIME 1024 /* Do not update access times. */
94 * Flags that can be altered by MS_REMOUNT
96 #define MS_RMT_MASK (MS_RDONLY|MS_MANDLOCK|MS_NOATIME)
99 * Magic mount flag number. Has to be or-ed to the flag values.
101 #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
102 #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
105 * Note that read-only etc flags are inode-specific: setting some file-system
106 * flags just means all the inodes inherit those flags by default. It might be
107 * possible to override it selectively if you really wanted to with some
108 * ioctl() that is not currently implemented.
110 * Exception: MS_RDONLY is always applied to the entire file system.
112 #define IS_RDONLY(inode) (((inode)->i_sb) && ((inode)->i_sb->s_flags & MS_RDONLY))
113 #define IS_NOSUID(inode) ((inode)->i_flags & MS_NOSUID)
114 #define IS_NODEV(inode) ((inode)->i_flags & MS_NODEV)
115 #define IS_NOEXEC(inode) ((inode)->i_flags & MS_NOEXEC)
116 #define IS_SYNC(inode) ((inode)->i_flags & MS_SYNCHRONOUS)
117 #define IS_MANDLOCK(inode) ((inode)->i_flags & MS_MANDLOCK)
119 #define IS_WRITABLE(inode) ((inode)->i_flags & S_WRITE)
120 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
121 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
122 #define IS_NOATIME(inode) ((inode)->i_flags & MS_NOATIME)
124 #define UPDATE_ATIME(inode) \
125 if (!IS_NOATIME(inode) && !IS_RDONLY(inode)) { \
126 inode->i_atime = CURRENT_TIME; \
127 mark_inode_dirty(inode); \
130 /* the read-only stuff doesn't really belong here, but any other place is
131 probably as bad and I don't want to create yet another include file. */
133 #define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
134 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
135 #define BLKRRPART _IO(0x12,95) /* re-read partition table */
136 #define BLKGETSIZE _IO(0x12,96) /* return device size */
137 #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
138 #define BLKRASET _IO(0x12,98) /* Set read ahead for block device */
139 #define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
141 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
142 #define FIBMAP _IO(0x00,1) /* bmap access */
143 #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
147 #include <asm/semaphore.h>
148 #include <asm/byteorder.h>
149 #include <asm/bitops.h>
151 extern void buffer_init(void);
152 extern void inode_init(void);
153 extern void file_table_init(void);
154 extern void dcache_init(void);
156 typedef char buffer_block
[BLOCK_SIZE
];
159 #define BH_Uptodate 0 /* 1 if the buffer contains valid data */
160 #define BH_Dirty 1 /* 1 if the buffer is dirty */
161 #define BH_Lock 2 /* 1 if the buffer is locked */
162 #define BH_Req 3 /* 0 if the buffer has been invalidated */
163 #define BH_Touched 4 /* 1 if the buffer has been touched (aging) */
164 #define BH_Has_aged 5 /* 1 if the buffer has been aged (aging) */
165 #define BH_Protected 6 /* 1 if the buffer is protected */
166 #define BH_FreeOnIO 7 /* 1 to discard the buffer_head after IO */
169 * Try to keep the most commonly used fields in single cache lines (16
170 * bytes) to improve performance. This ordering should be
171 * particularly beneficial on 32-bit processors.
173 * We use the first 16 bytes for the data which is used in searches
174 * over the block hash lists (ie. getblk(), find_buffer() and
177 * The second 16 bytes we use for lru buffer scans, as used by
178 * sync_buffers() and refill_freelist(). -- sct
181 /* First cache line: */
182 struct buffer_head
* b_next
; /* Hash queue list */
183 unsigned long b_blocknr
; /* block number */
184 unsigned long b_size
; /* block size */
185 kdev_t b_dev
; /* device (B_FREE = free) */
186 kdev_t b_rdev
; /* Real device */
187 unsigned long b_rsector
; /* Real buffer location on disk */
188 struct buffer_head
* b_this_page
; /* circular list of buffers in one page */
189 unsigned long b_state
; /* buffer state bitmap (see above) */
190 struct buffer_head
* b_next_free
;
191 unsigned int b_count
; /* users using this block */
193 /* Non-performance-critical data follows. */
194 char * b_data
; /* pointer to data block (1024 bytes) */
195 unsigned int b_list
; /* List that this buffer appears */
196 unsigned long b_flushtime
; /* Time when this (dirty) buffer
197 * should be written */
198 unsigned long b_lru_time
; /* Time when this buffer was
200 struct wait_queue
* b_wait
;
201 struct buffer_head
** b_pprev
; /* doubly linked list of hash-queue */
202 struct buffer_head
* b_prev_free
; /* doubly linked list of buffers */
203 struct buffer_head
* b_reqnext
; /* request queue */
206 static inline int buffer_uptodate(struct buffer_head
* bh
)
208 return test_bit(BH_Uptodate
, &bh
->b_state
);
211 static inline int buffer_dirty(struct buffer_head
* bh
)
213 return test_bit(BH_Dirty
, &bh
->b_state
);
216 static inline int buffer_locked(struct buffer_head
* bh
)
218 return test_bit(BH_Lock
, &bh
->b_state
);
221 static inline int buffer_req(struct buffer_head
* bh
)
223 return test_bit(BH_Req
, &bh
->b_state
);
226 static inline int buffer_touched(struct buffer_head
* bh
)
228 return test_bit(BH_Touched
, &bh
->b_state
);
231 static inline int buffer_has_aged(struct buffer_head
* bh
)
233 return test_bit(BH_Has_aged
, &bh
->b_state
);
236 static inline int buffer_protected(struct buffer_head
* bh
)
238 return test_bit(BH_Protected
, &bh
->b_state
);
241 #include <linux/pipe_fs_i.h>
242 #include <linux/minix_fs_i.h>
243 #include <linux/ext2_fs_i.h>
244 #include <linux/hpfs_fs_i.h>
245 #include <linux/msdos_fs_i.h>
246 #include <linux/umsdos_fs_i.h>
247 #include <linux/iso_fs_i.h>
248 #include <linux/nfs_fs_i.h>
249 #include <linux/sysv_fs_i.h>
250 #include <linux/affs_fs_i.h>
251 #include <linux/ufs_fs_i.h>
252 #include <linux/romfs_fs_i.h>
253 #include <linux/smb_fs_i.h>
256 * Attribute flags. These should be or-ed together to figure out what
263 #define ATTR_ATIME 16
264 #define ATTR_MTIME 32
265 #define ATTR_CTIME 64
266 #define ATTR_ATIME_SET 128
267 #define ATTR_MTIME_SET 256
268 #define ATTR_FORCE 512 /* Not a change, but a change it */
269 #define ATTR_ATTR_FLAG 1024
272 * This is the Inode Attributes structure, used for notify_change(). It
273 * uses the above definitions as flags, to know which values have changed.
274 * Also, in this manner, a Filesystem can look at only the values it cares
275 * about. Basically, these are the attributes that the VFS layer can
276 * request to change from the FS layer.
278 * Derek Atkins <warlord@MIT.EDU> 94-10-20
281 unsigned int ia_valid
;
289 unsigned int ia_attr_flags
;
293 * This is the inode attributes flag definitions
295 #define ATTR_FLAG_SYNCRONOUS 1 /* Syncronous write */
296 #define ATTR_FLAG_NOATIME 2 /* Don't update atime */
297 #define ATTR_FLAG_APPEND 4 /* Append-only file */
298 #define ATTR_FLAG_IMMUTABLE 8 /* Immutable file */
300 #include <linux/quota.h>
303 struct list_head i_hash
;
304 struct list_head i_list
;
308 unsigned short i_count
;
318 unsigned long i_blksize
;
319 unsigned long i_blocks
;
320 unsigned long i_version
;
321 unsigned long i_nrpages
;
322 struct semaphore i_sem
;
323 struct inode_operations
*i_op
;
324 struct super_block
*i_sb
;
325 struct wait_queue
*i_wait
;
326 struct file_lock
*i_flock
;
327 struct vm_area_struct
*i_mmap
;
328 struct page
*i_pages
;
329 struct dquot
*i_dquot
[MAXQUOTAS
];
331 unsigned long i_state
;
333 unsigned int i_flags
;
334 unsigned char i_pipe
;
335 unsigned char i_sock
;
338 unsigned int i_attr_flags
;
340 struct pipe_inode_info pipe_i
;
341 struct minix_inode_info minix_i
;
342 struct ext2_inode_info ext2_i
;
343 struct hpfs_inode_info hpfs_i
;
344 struct msdos_inode_info msdos_i
;
345 struct umsdos_inode_info umsdos_i
;
346 struct iso_inode_info isofs_i
;
347 struct nfs_inode_info nfs_i
;
348 struct sysv_inode_info sysv_i
;
349 struct affs_inode_info affs_i
;
350 struct ufs_inode_info ufs_i
;
351 struct romfs_inode_info romfs_i
;
352 struct smb_inode_info smbfs_i
;
353 struct socket socket_i
;
358 /* Inode state bits.. */
363 extern void __mark_inode_dirty(struct inode
*);
364 static inline void mark_inode_dirty(struct inode
*inode
)
366 if (!(inode
->i_state
& I_DIRTY
))
367 __mark_inode_dirty(inode
);
371 struct file
*f_next
, **f_pprev
;
372 struct dentry
*f_dentry
;
373 struct file_operations
*f_op
;
376 unsigned short f_count
, f_flags
;
377 unsigned long f_reada
, f_ramax
, f_raend
, f_ralen
, f_rawin
;
379 /* pid or -pgrp where SIGIO should be sent */
382 unsigned long f_version
;
384 /* needed for tty driver, and maybe others */
388 extern int init_private_file(struct file
*, struct dentry
*, int);
392 #define FL_BROKEN 4 /* broken flock() emulation */
393 #define FL_ACCESS 8 /* for processes suspended by mandatory locking */
394 #define FL_LOCKD 16 /* lock held by rpc.lockd */
397 struct file_lock
*fl_next
; /* singly linked list for this inode */
398 struct file_lock
*fl_nextlink
; /* doubly linked list of all locks */
399 struct file_lock
*fl_prevlink
; /* used to simplify lock removal */
400 struct file_lock
*fl_nextblock
; /* circular list of blocked processes */
401 struct file_lock
*fl_prevblock
;
402 void *fl_owner
; /* usu. the process' task_struct */
404 struct wait_queue
*fl_wait
;
405 struct file
*fl_file
;
406 unsigned char fl_flags
;
407 unsigned char fl_type
;
411 void (*fl_notify
)(struct file_lock
*); /* unblock callback */
414 struct nfs_lock_info nfs_fl
;
418 extern struct file_lock
*file_lock_table
;
420 #include <linux/fcntl.h>
422 extern int fcntl_getlk(unsigned int fd
, struct flock
*l
);
423 extern int fcntl_setlk(unsigned int fd
, unsigned int cmd
, struct flock
*l
);
424 extern void locks_remove_locks(struct task_struct
*task
, struct file
*filp
);
425 extern struct file_lock
*posix_test_lock(struct file
*, struct file_lock
*);
426 extern int posix_lock_file(struct file
*, struct file_lock
*, unsigned int);
427 extern void posix_block_lock(struct file_lock
*, struct file_lock
*);
428 extern void posix_unblock_lock(struct file_lock
*);
430 #include <linux/stat.h>
432 #define FLOCK_VERIFY_READ 1
433 #define FLOCK_VERIFY_WRITE 2
435 extern int locks_mandatory_locked(struct inode
*inode
);
436 extern int locks_mandatory_area(int read_write
, struct inode
*inode
,
437 struct file
*filp
, unsigned int offset
,
440 extern inline int locks_verify_locked(struct inode
*inode
)
442 /* Candidates for mandatory locking have the setgid bit set
443 * but no group execute bit - an otherwise meaningless combination.
445 if (IS_MANDLOCK(inode
) &&
446 (inode
->i_mode
& (S_ISGID
| S_IXGRP
)) == S_ISGID
)
447 return (locks_mandatory_locked(inode
));
450 extern inline int locks_verify_area(int read_write
, struct inode
*inode
,
451 struct file
*filp
, unsigned int offset
,
454 /* Candidates for mandatory locking have the setgid bit set
455 * but no group execute bit - an otherwise meaningless combination.
457 if (IS_MANDLOCK(inode
) &&
458 (inode
->i_mode
& (S_ISGID
| S_IXGRP
)) == S_ISGID
)
459 return (locks_mandatory_area(read_write
, inode
, filp
, offset
,
464 struct fasync_struct
{
466 struct fasync_struct
*fa_next
; /* singly linked list */
467 struct file
*fa_file
;
470 #define FASYNC_MAGIC 0x4601
472 extern int fasync_helper(struct inode
*, struct file
*, int, struct fasync_struct
**);
474 #include <linux/minix_fs_sb.h>
475 #include <linux/ext2_fs_sb.h>
476 #include <linux/hpfs_fs_sb.h>
477 #include <linux/msdos_fs_sb.h>
478 #include <linux/iso_fs_sb.h>
479 #include <linux/nfs_fs_sb.h>
480 #include <linux/sysv_fs_sb.h>
481 #include <linux/affs_fs_sb.h>
482 #include <linux/ufs_fs_sb.h>
483 #include <linux/romfs_fs_sb.h>
484 #include <linux/smb_fs_sb.h>
488 unsigned long s_blocksize
;
489 unsigned char s_blocksize_bits
;
490 unsigned char s_lock
;
491 unsigned char s_rd_only
;
492 unsigned char s_dirt
;
493 struct file_system_type
*s_type
;
494 struct super_operations
*s_op
;
495 struct dquot_operations
*dq_op
;
496 unsigned long s_flags
;
497 unsigned long s_magic
;
498 unsigned long s_time
;
499 struct dentry
*s_root
;
500 struct wait_queue
*s_wait
;
502 struct inode
*s_ibasket
;
503 short int s_ibasket_count
;
504 short int s_ibasket_max
;
505 struct list_head s_dirty
; /* dirty inodes */
508 struct minix_sb_info minix_sb
;
509 struct ext2_sb_info ext2_sb
;
510 struct hpfs_sb_info hpfs_sb
;
511 struct msdos_sb_info msdos_sb
;
512 struct isofs_sb_info isofs_sb
;
513 struct nfs_sb_info nfs_sb
;
514 struct sysv_sb_info sysv_sb
;
515 struct affs_sb_info affs_sb
;
516 struct ufs_sb_info ufs_sb
;
517 struct romfs_sb_info romfs_sb
;
518 struct smb_sb_info smbfs_sb
;
524 * This is the "filldir" function type, used by readdir() to let
525 * the kernel specify what kind of dirent layout it wants to have.
526 * This allows the kernel to read directories into kernel space or
527 * to have different dirent layouts depending on the binary type.
529 typedef int (*filldir_t
)(void *, const char *, int, off_t
, ino_t
);
531 struct file_operations
{
532 long long (*llseek
) (struct inode
*, struct file
*, long long, int);
533 long (*read
) (struct inode
*, struct file
*, char *, unsigned long);
534 long (*write
) (struct inode
*, struct file
*, const char *, unsigned long);
535 int (*readdir
) (struct file
*, void *, filldir_t
);
536 unsigned int (*poll
) (struct file
*, poll_table
*);
537 int (*ioctl
) (struct inode
*, struct file
*, unsigned int, unsigned long);
538 int (*mmap
) (struct inode
*, struct file
*, struct vm_area_struct
*);
539 int (*open
) (struct inode
*, struct file
*);
540 int (*release
) (struct inode
*, struct file
*);
541 int (*fsync
) (struct inode
*, struct file
*);
542 int (*fasync
) (struct inode
*, struct file
*, int);
543 int (*check_media_change
) (kdev_t dev
);
544 int (*revalidate
) (kdev_t dev
);
545 int (*lock
) (struct inode
*, struct file
*, int, struct file_lock
*);
548 struct inode_operations
{
549 struct file_operations
* default_file_ops
;
550 int (*create
) (struct inode
*,struct dentry
*,int);
551 int (*lookup
) (struct inode
*,struct dentry
*);
552 int (*link
) (struct inode
*,struct inode
*,struct dentry
*);
553 int (*unlink
) (struct inode
*,struct dentry
*);
554 int (*symlink
) (struct inode
*,struct dentry
*,const char *);
555 int (*mkdir
) (struct inode
*,struct dentry
*,int);
556 int (*rmdir
) (struct inode
*,struct dentry
*);
557 int (*mknod
) (struct inode
*,struct dentry
*,int,int);
558 int (*rename
) (struct inode
*,struct dentry
*,struct inode
*,struct dentry
*);
559 int (*readlink
) (struct inode
*,char *,int);
560 struct dentry
* (*follow_link
) (struct inode
*, struct dentry
*);
561 int (*readpage
) (struct inode
*, struct page
*);
562 int (*writepage
) (struct inode
*, struct page
*);
563 int (*bmap
) (struct inode
*,int);
564 void (*truncate
) (struct inode
*);
565 int (*permission
) (struct inode
*, int);
566 int (*smap
) (struct inode
*,int);
567 int (*updatepage
) (struct inode
*, struct page
*, const char *,
568 unsigned long, unsigned int, int);
569 int (*revalidate
) (struct inode
*);
572 struct super_operations
{
573 void (*read_inode
) (struct inode
*);
574 void (*write_inode
) (struct inode
*);
575 void (*put_inode
) (struct inode
*);
576 void (*delete_inode
) (struct inode
*);
577 int (*notify_change
) (struct inode
*, struct iattr
*);
578 void (*put_super
) (struct super_block
*);
579 void (*write_super
) (struct super_block
*);
580 int (*statfs
) (struct super_block
*, struct statfs
*, int);
581 int (*remount_fs
) (struct super_block
*, int *, char *);
584 struct dquot_operations
{
585 void (*initialize
) (struct inode
*, short);
586 void (*drop
) (struct inode
*);
587 int (*alloc_block
) (const struct inode
*, unsigned long);
588 int (*alloc_inode
) (const struct inode
*, unsigned long);
589 void (*free_block
) (const struct inode
*, unsigned long);
590 void (*free_inode
) (const struct inode
*, unsigned long);
591 int (*transfer
) (struct inode
*, struct iattr
*, char);
594 struct file_system_type
{
597 struct super_block
*(*read_super
) (struct super_block
*, void *, int);
598 struct file_system_type
* next
;
601 extern int register_filesystem(struct file_system_type
*);
602 extern int unregister_filesystem(struct file_system_type
*);
604 asmlinkage
int sys_open(const char *, int, int);
605 asmlinkage
int sys_close(unsigned int); /* yes, it's really unsigned */
607 extern void kill_fasync(struct fasync_struct
*fa
, int sig
);
609 extern char * getname(const char * filename
);
610 extern void putname(char * name
);
611 extern int do_truncate(struct inode
*, unsigned long);
612 extern int register_blkdev(unsigned int, const char *, struct file_operations
*);
613 extern int unregister_blkdev(unsigned int major
, const char * name
);
614 extern int blkdev_open(struct inode
* inode
, struct file
* filp
);
615 extern int blkdev_release (struct inode
* inode
);
616 extern struct file_operations def_blk_fops
;
617 extern struct inode_operations blkdev_inode_operations
;
619 extern int register_chrdev(unsigned int, const char *, struct file_operations
*);
620 extern int unregister_chrdev(unsigned int major
, const char * name
);
621 extern int chrdev_open(struct inode
* inode
, struct file
* filp
);
622 extern struct file_operations def_chr_fops
;
623 extern struct inode_operations chrdev_inode_operations
;
625 extern void init_fifo(struct inode
* inode
);
626 extern struct inode_operations fifo_inode_operations
;
628 extern struct file_operations connecting_fifo_fops
;
629 extern struct file_operations read_fifo_fops
;
630 extern struct file_operations write_fifo_fops
;
631 extern struct file_operations rdwr_fifo_fops
;
632 extern struct file_operations read_pipe_fops
;
633 extern struct file_operations write_pipe_fops
;
634 extern struct file_operations rdwr_pipe_fops
;
636 extern struct file_system_type
*get_fs_type(const char *name
);
638 extern int fs_may_mount(kdev_t dev
);
639 extern int fs_may_umount(struct super_block
*, struct dentry
* root
);
640 extern int fs_may_remount_ro(struct super_block
*);
642 extern struct file
*inuse_filps
;
643 extern struct super_block super_blocks
[NR_SUPER
];
645 extern void refile_buffer(struct buffer_head
* buf
);
646 extern void set_writetime(struct buffer_head
* buf
, int flag
);
647 extern int try_to_free_buffer(struct buffer_head
*, struct buffer_head
**, int);
649 extern int nr_buffers
;
650 extern int buffermem
;
651 extern int nr_buffer_heads
;
654 #define BUF_LOCKED 1 /* Buffers scheduled for write */
655 #define BUF_DIRTY 2 /* Dirty buffers, not yet scheduled for write */
658 void mark_buffer_uptodate(struct buffer_head
* bh
, int on
);
660 extern inline void mark_buffer_clean(struct buffer_head
* bh
)
662 if (test_and_clear_bit(BH_Dirty
, &bh
->b_state
)) {
663 if (bh
->b_list
== BUF_DIRTY
)
668 extern inline void mark_buffer_dirty(struct buffer_head
* bh
, int flag
)
670 if (!test_and_set_bit(BH_Dirty
, &bh
->b_state
)) {
671 set_writetime(bh
, flag
);
672 if (bh
->b_list
!= BUF_DIRTY
)
677 extern int check_disk_change(kdev_t dev
);
678 extern int invalidate_inodes(struct super_block
* sb
);
679 extern void invalidate_inode_pages(struct inode
*);
680 extern void invalidate_buffers(kdev_t dev
);
681 extern int floppy_is_wp(int minor
);
682 extern void sync_inodes(kdev_t dev
);
683 extern void write_inode_now(struct inode
*inode
);
684 extern void sync_dev(kdev_t dev
);
685 extern int fsync_dev(kdev_t dev
);
686 extern void sync_supers(kdev_t dev
);
687 extern int bmap(struct inode
* inode
,int block
);
688 extern int notify_change(struct inode
*, struct iattr
*);
689 extern int permission(struct inode
* inode
,int mask
);
690 extern int get_write_access(struct inode
*inode
);
691 extern void put_write_access(struct inode
*inode
);
692 extern struct dentry
* open_namei(const char * pathname
, int flag
, int mode
);
693 extern struct dentry
* do_mknod(const char * filename
, int mode
, dev_t dev
);
694 extern int do_pipe(int *);
697 * Kernel pointers have redundant information, so we can use a
698 * scheme where we can return either an error code or a dentry
699 * pointer with the same return value.
701 * This should be a per-architecture thing, to allow different
702 * error and pointer decisions.
704 #define ERR_PTR(err) ((void *)((long)(err)))
705 #define PTR_ERR(ptr) ((long)(ptr))
706 #define IS_ERR(ptr) ((unsigned long)(ptr) > (unsigned long)(-1000))
708 extern struct dentry
* lookup_dentry(const char *, struct dentry
*, int);
709 extern struct dentry
* __namei(const char *, int);
711 #define namei(pathname) __namei(pathname, 1)
712 #define lnamei(pathname) __namei(pathname, 0)
714 #include <asm/semaphore.h>
716 /* Intended for short locks of the global data structures in inode.c.
717 * Could be replaced with spinlocks completely, since there is
718 * no blocking during manipulation of the static data; however the
719 * lock in invalidate_inodes() may last relatively long.
721 extern struct semaphore vfs_sem
;
722 extern inline void vfs_lock(void)
731 extern inline void vfs_unlock(void)
740 /* Not to be used by ordinary vfs users */
741 extern void _get_inode(struct inode
* inode
);
742 extern void iput(struct inode
* inode
);
744 extern struct inode
* iget(struct super_block
* sb
, unsigned long nr
);
745 extern void clear_inode(struct inode
* inode
);
746 extern struct inode
* get_empty_inode(void);
748 /* Please prefer to use this function in future, instead of using
749 * a get_empty_inode()/insert_inode_hash() combination.
750 * It allows for better checking and less race conditions.
752 extern struct inode
* get_empty_inode_hashed(dev_t i_dev
, unsigned long i_ino
);
754 extern void insert_inode_hash(struct inode
*);
755 extern int get_unused_fd(void);
756 extern void put_unused_fd(int);
757 extern struct file
* get_empty_filp(void);
758 extern int close_fp(struct file
*filp
);
759 extern struct buffer_head
* get_hash_table(kdev_t dev
, int block
, int size
);
760 extern struct buffer_head
* getblk(kdev_t dev
, int block
, int size
);
761 extern void ll_rw_block(int rw
, int nr
, struct buffer_head
* bh
[]);
762 extern void ll_rw_page(int rw
, kdev_t dev
, unsigned long nr
, char * buffer
);
763 extern void ll_rw_swap_file(int rw
, kdev_t dev
, unsigned int *b
, int nb
, char *buffer
);
764 extern int is_read_only(kdev_t dev
);
765 extern void __brelse(struct buffer_head
*buf
);
766 extern inline void brelse(struct buffer_head
*buf
)
771 extern void __bforget(struct buffer_head
*buf
);
772 extern inline void bforget(struct buffer_head
*buf
)
777 extern void set_blocksize(kdev_t dev
, int size
);
778 extern unsigned int get_hardblocksize(kdev_t dev
);
779 extern struct buffer_head
* bread(kdev_t dev
, int block
, int size
);
780 extern struct buffer_head
* breada(kdev_t dev
,int block
, int size
,
781 unsigned int pos
, unsigned int filesize
);
783 extern int brw_page(int, struct page
*, kdev_t
, int [], int, int);
785 extern int generic_readpage(struct inode
*, struct page
*);
786 extern int generic_file_mmap(struct inode
*, struct file
*, struct vm_area_struct
*);
787 extern long generic_file_read(struct inode
*, struct file
*, char *, unsigned long);
788 extern long generic_file_write(struct inode
*, struct file
*, const char *, unsigned long);
790 extern struct super_block
*get_super(kdev_t dev
);
791 extern void put_super(kdev_t dev
);
792 unsigned long generate_cluster(kdev_t dev
, int b
[], int size
);
793 unsigned long generate_cluster_swab32(kdev_t dev
, int b
[], int size
);
794 extern kdev_t ROOT_DEV
;
796 extern void show_buffers(void);
797 extern void mount_root(void);
799 #ifdef CONFIG_BLK_DEV_INITRD
800 extern kdev_t real_root_dev
;
801 extern int change_root(kdev_t new_root_dev
,const char *put_old
);
804 extern long char_read(struct inode
*, struct file
*, char *, unsigned long);
805 extern long block_read(struct inode
*, struct file
*, char *, unsigned long);
806 extern int read_ahead
[];
808 extern long char_write(struct inode
*, struct file
*, const char *, unsigned long);
809 extern long block_write(struct inode
*, struct file
*, const char *, unsigned long);
811 extern int block_fsync(struct inode
*, struct file
*);
812 extern int file_fsync(struct inode
*, struct file
*);
814 extern void dcache_add(struct inode
*, const char *, int, unsigned long);
815 extern int dcache_lookup(struct inode
*, const char *, int, unsigned long *);
817 extern int inode_change_ok(struct inode
*, struct iattr
*);
818 extern void inode_setattr(struct inode
*, struct iattr
*);
819 extern int notify_change(struct inode
* inode
, struct iattr
* attr
);
821 /* kludge to get SCSI modules working */
822 #include <linux/minix_fs.h>
823 #include <linux/minix_fs_sb.h>
825 #endif /* __KERNEL__ */