base.c

来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 2,003 行 · 第 1/5 页

C
2,003
字号
  v0.86    19991204   Richard Gooch <rgooch@atnf.csiro.au>	       Support fifos when unregistering.	       Work sponsored by SGI.  v0.87    19991209   Richard Gooch <rgooch@atnf.csiro.au>	       Removed obsolete DEVFS_ FL_COMPAT and DEVFS_ FL_TOLERANT flags.	       Work sponsored by SGI.  v0.88    19991214   Richard Gooch <rgooch@atnf.csiro.au>	       Removed kmod support.	       Work sponsored by SGI.  v0.89    19991216   Richard Gooch <rgooch@atnf.csiro.au>	       Improved debugging in <get_vfs_inode>.	       Ensure dentries created by devfsd will be cleaned up.	       Work sponsored by SGI.  v0.90    19991223   Richard Gooch <rgooch@atnf.csiro.au>	       Created <devfs_get_name>.	       Work sponsored by SGI.  v0.91    20000203   Richard Gooch <rgooch@atnf.csiro.au>	       Ported to kernel 2.3.42.	       Removed <devfs_fill_file>.	       Work sponsored by SGI.  v0.92    20000306   Richard Gooch <rgooch@atnf.csiro.au>	       Added DEVFS_ FL_NO_PERSISTENCE flag.	       Removed unnecessary call to <update_devfs_inode_from_entry> in	       <devfs_readdir>.	       Work sponsored by SGI.  v0.93    20000413   Richard Gooch <rgooch@atnf.csiro.au>	       Set inode->i_size to correct size for symlinks.    20000414   Richard Gooch <rgooch@atnf.csiro.au>	       Only give lookup() method to directories to comply with new VFS	       assumptions.	       Work sponsored by SGI.    20000415   Richard Gooch <rgooch@atnf.csiro.au>	       Remove unnecessary tests in symlink methods.	       Don't kill existing block ops in <devfs_read_inode>.	       Work sponsored by SGI.  v0.94    20000424   Richard Gooch <rgooch@atnf.csiro.au>	       Don't create missing directories in <devfs_find_handle>.	       Work sponsored by SGI.  v0.95    20000430   Richard Gooch <rgooch@atnf.csiro.au>	       Added CONFIG_DEVFS_MOUNT.	       Work sponsored by SGI.  v0.96    20000608   Richard Gooch <rgooch@atnf.csiro.au>	       Disabled multi-mount capability (use VFS bindings instead).	       Work sponsored by SGI.  v0.97    20000610   Richard Gooch <rgooch@atnf.csiro.au>	       Switched to FS_SINGLE to disable multi-mounts.    20000612   Richard Gooch <rgooch@atnf.csiro.au>	       Removed module support.	       Removed multi-mount code.	       Removed compatibility macros: VFS has changed too much.	       Work sponsored by SGI.  v0.98    20000614   Richard Gooch <rgooch@atnf.csiro.au>	       Merged devfs inode into devfs entry.	       Work sponsored by SGI.  v0.99    20000619   Richard Gooch <rgooch@atnf.csiro.au>	       Removed dead code in <devfs_register> which used to call	       <free_dentries>.	       Work sponsored by SGI.  v0.100    20000621   Richard Gooch <rgooch@atnf.csiro.au>	       Changed interface to <devfs_register>.	       Work sponsored by SGI.  v0.101    20000622   Richard Gooch <rgooch@atnf.csiro.au>	       Simplified interface to <devfs_mk_symlink> and <devfs_mk_dir>.	       Simplified interface to <devfs_find_handle>.	       Work sponsored by SGI.  v0.102    20010519   Richard Gooch <rgooch@atnf.csiro.au>	       Ensure <devfs_generate_path> terminates string for root entry.	       Exported <devfs_get_name> to modules.    20010520   Richard Gooch <rgooch@atnf.csiro.au>	       Make <devfs_mk_symlink> send events to devfsd.	       Cleaned up option processing in <devfs_setup>.    20010521   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed bugs in handling symlinks: could leak or cause Oops.    20010522   Richard Gooch <rgooch@atnf.csiro.au>	       Cleaned up directory handling by separating fops.  v0.103    20010601   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed handling of inverted options in <devfs_setup>.  v0.104    20010604   Richard Gooch <rgooch@atnf.csiro.au>	       Adjusted <try_modload> to account for <devfs_generate_path> fix.  v0.105    20010617   Richard Gooch <rgooch@atnf.csiro.au>	       Answered question posed by Al Viro and removed his comments.	       Moved setting of registered flag after other fields are changed.	       Fixed race between <devfsd_close> and <devfsd_notify_one>.	       Global VFS changes added bogus BKL to <devfsd_close>: removed.	       Widened locking in <devfs_readlink> and <devfs_follow_link>.	       Replaced <devfsd_read> stack usage with <devfsd_ioctl> kmalloc.	       Simplified locking in <devfsd_ioctl> and fixed memory leak.  v0.106    20010709   Richard Gooch <rgooch@atnf.csiro.au>	       Removed broken devnum allocation and use <devfs_alloc_devnum>.	       Fixed old devnum leak by calling new <devfs_dealloc_devnum>.  v0.107    20010712   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed bug in <devfs_setup> which could hang boot process.  v0.108    20010730   Richard Gooch <rgooch@atnf.csiro.au>	       Added DEVFSD_NOTIFY_DELETE event.    20010801   Richard Gooch <rgooch@atnf.csiro.au>	       Removed #include <asm/segment.h>.  v0.109    20010807   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed inode table races by removing it and using	       inode->u.generic_ip instead.	       Moved <devfs_read_inode> into <get_vfs_inode>.	       Moved <devfs_write_inode> into <devfs_notify_change>.  v0.110    20010808   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed race in <devfs_do_symlink> for uni-processor.  v0.111    20010818   Richard Gooch <rgooch@atnf.csiro.au>	       Removed remnant of multi-mount support in <devfs_mknod>.               Removed unused DEVFS_FL_SHOW_UNREG flag.  v0.112    20010820   Richard Gooch <rgooch@atnf.csiro.au>	       Removed nlink field from struct devfs_inode.  v0.113    20010823   Richard Gooch <rgooch@atnf.csiro.au>	       Replaced BKL with global rwsem to protect symlink data (quick	       and dirty hack).  v0.114    20010827   Richard Gooch <rgooch@atnf.csiro.au>	       Replaced global rwsem for symlink with per-link refcount.  v0.115    20010919   Richard Gooch <rgooch@atnf.csiro.au>	       Set inode->i_mapping->a_ops for block nodes in <get_vfs_inode>.  v0.116    20011008   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed overrun in <devfs_link> by removing function (not needed).    20011009   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed buffer underrun in <try_modload>.    20011029   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed race in <devfsd_ioctl> when setting event mask.    20011114   Richard Gooch <rgooch@atnf.csiro.au>	       First release of new locking code.  v1.0    20011117   Richard Gooch <rgooch@atnf.csiro.au>	       Discard temporary buffer, now use "%s" for dentry names.    20011118   Richard Gooch <rgooch@atnf.csiro.au>	       Don't generate path in <try_modload>: use fake entry instead.	       Use "existing" directory in <_devfs_make_parent_for_leaf>.    20011122   Richard Gooch <rgooch@atnf.csiro.au>	       Use slab cache rather than fixed buffer for devfsd events.  v1.1    20011125   Richard Gooch <rgooch@atnf.csiro.au>	       Send DEVFSD_NOTIFY_REGISTERED events in <devfs_mk_dir>.    20011127   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed locking bug in <devfs_d_revalidate_wait> due to typo.	       Do not send CREATE, CHANGE, ASYNC_OPEN or DELETE events from	       devfsd or children.  v1.2    20011202   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed bug in <devfsd_read>: was dereferencing freed pointer.  v1.3    20011203   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed bug in <devfsd_close>: was dereferencing freed pointer.	       Added process group check for devfsd privileges.  v1.4    20011204   Richard Gooch <rgooch@atnf.csiro.au>	       Use SLAB_ATOMIC in <devfsd_notify_de> from <devfs_d_delete>.  v1.5    20011211   Richard Gooch <rgooch@atnf.csiro.au>	       Return old entry in <devfs_mk_dir> for 2.4.x kernels.    20011212   Richard Gooch <rgooch@atnf.csiro.au>	       Increment refcount on module in <check_disc_changed>.    20011215   Richard Gooch <rgooch@atnf.csiro.au>	       Created <devfs_get_handle> and exported <devfs_put>.	       Increment refcount on module in <devfs_get_ops>.	       Created <devfs_put_ops>.  v1.6    20011216   Richard Gooch <rgooch@atnf.csiro.au>	       Added poisoning to <devfs_put>.	       Improved debugging messages.  v1.7    20011221   Richard Gooch <rgooch@atnf.csiro.au>	       Corrected (made useful) debugging message in <unregister>.	       Moved <kmem_cache_create> in <mount_devfs_fs> to <init_devfs_fs>    20011224   Richard Gooch <rgooch@atnf.csiro.au>	       Added magic number to guard against scribbling drivers.    20011226   Richard Gooch <rgooch@atnf.csiro.au>	       Only return old entry in <devfs_mk_dir> if a directory.	       Defined macros for error and debug messages.  v1.8    20020113   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed (rare, old) race in <devfs_lookup>.  v1.9    20020120   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed deadlock bug in <devfs_d_revalidate_wait>.	       Tag VFS deletable in <devfs_mk_symlink> if handle ignored.  v1.10    20020129   Richard Gooch <rgooch@atnf.csiro.au>	       Added KERN_* to remaining messages.	       Cleaned up declaration of <stat_read>.  v1.11    20020219   Richard Gooch <rgooch@atnf.csiro.au>	       Changed <devfs_rmdir> to allow later additions if not yet empty.  v1.12    20020406   Richard Gooch <rgooch@atnf.csiro.au>	       Removed silently introduced calls to lock_kernel() and	       unlock_kernel() due to recent VFS locking changes. BKL isn't	       required in devfs.  v1.13    20020428   Richard Gooch <rgooch@atnf.csiro.au>	       Removed 2.4.x compatibility code.  v1.14    20020510   Richard Gooch <rgooch@atnf.csiro.au>	       Added BKL to <devfs_open> because drivers still need it.  v1.15    20020512   Richard Gooch <rgooch@atnf.csiro.au>	       Protected <scan_dir_for_removable> and <get_removable_partition>	       from changing directory contents.  v1.16    20020514   Richard Gooch <rgooch@atnf.csiro.au>	       Minor cleanup of <scan_dir_for_removable>.  v1.17    20020721   Richard Gooch <rgooch@atnf.csiro.au>	       Switched to ISO C structure field initialisers.	       Switch to set_current_state() and move before add_wait_queue().    20020722   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed devfs entry leak in <devfs_readdir> when *readdir fails.  v1.18    20020725   Richard Gooch <rgooch@atnf.csiro.au>	       Created <devfs_find_and_unregister>.  v1.19    20020728   Richard Gooch <rgooch@atnf.csiro.au>	       Removed deprecated <devfs_find_handle>.  v1.20    20020820   Richard Gooch <rgooch@atnf.csiro.au>	       Fixed module unload race in <devfs_open>.  v1.21    20021013   Richard Gooch <rgooch@atnf.csiro.au>	       Removed DEVFS_ FL_AUTO_OWNER.	       Switched lingering structure field initialiser to ISO C.	       Added locking when updating FCB flags.  v1.22*/#include <linux/types.h>#include <linux/errno.h>#include <linux/time.h>#include <linux/tty.h>#include <linux/timer.h>#include <linux/config.h>#include <linux/kernel.h>#include <linux/wait.h>#include <linux/string.h>#include <linux/slab.h>#include <linux/ioport.h>#include <linux/delay.h>#include <linux/ctype.h>#include <linux/mm.h>#include <linux/module.h>#include <linux/init.h>#include <linux/devfs_fs.h>#include <linux/devfs_fs_kernel.h>#include <linux/smp_lock.h>#include <linux/smp.h>#include <linux/rwsem.h>#include <linux/sched.h>#include <linux/namei.h>#include <asm/uaccess.h>#include <asm/io.h>#include <asm/processor.h>#include <asm/system.h>#include <asm/pgtable.h>#include <asm/bitops.h>#include <asm/atomic.h>#define DEVFS_VERSION            "2004-01-31"#define DEVFS_NAME "devfs"#define FIRST_INODE 1#define STRING_LENGTH 256#define FAKE_BLOCK_SIZE 1024#define POISON_PTR ( *(void **) poison_array )#define MAGIC_VALUE 0x327db823#ifndef TRUE#  define TRUE 1#  define FALSE 0#endif#define MODE_DIR (S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO)#define DEBUG_NONE         0x0000000#define DEBUG_MODULE_LOAD  0x0000001#define DEBUG_REGISTER     0x0000002#define DEBUG_UNREGISTER   0x0000004#define DEBUG_FREE         0x0000008#define DEBUG_SET_FLAGS    0x0000010#define DEBUG_S_READ       0x0000100	/*  Break  */#define DEBUG_I_LOOKUP     0x0001000	/*  Break  */#define DEBUG_I_CREATE     0x0002000#define DEBUG_I_GET        0x0004000#define DEBUG_I_CHANGE     0x0008000#define DEBUG_I_UNLINK     0x0010000#define DEBUG_I_RLINK      0x0020000#define DEBUG_I_FLINK      0x0040000#define DEBUG_I_MKNOD      0x0080000#define DEBUG_F_READDIR    0x0100000	/*  Break  */#define DEBUG_D_DELETE     0x1000000	/*  Break  */#define DEBUG_D_RELEASE    0x2000000#define DEBUG_D_IPUT       0x4000000#define DEBUG_ALL          0xfffffff#define DEBUG_DISABLED     DEBUG_NONE#define OPTION_NONE             0x00#define OPTION_MOUNT            0x01#define PRINTK(format, args...) \   {printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);}#define OOPS(format, args...) \   {printk (KERN_CRIT "%s" format, __FUNCTION__ , ## args); \    printk ("Forcing Oops\n"); \    BUG();}#ifdef CONFIG_DEVFS_DEBUG#  define VERIFY_ENTRY(de) \   {if ((de) && (de)->magic_number != MAGIC_VALUE) \        OOPS ("(%p): bad magic value: %x\n", (de), (de)->magic_number);}#  define WRITE_ENTRY_MAGIC(de,magic) (de)->magic_number = (magic)#  define DPRINTK(flag, format, args...) \   {if (devfs_debug & flag) \	printk (KERN_INFO "%s" format, __FUNCTION__ , ## args);}#else#  define VERIFY_ENTRY(de)#  define WRITE_ENTRY_MAGIC(de,magic)#  define DPRINTK(flag, format, args...)#endiftypedef struct devfs_entry *devfs_handle_t;struct directory_type {	rwlock_t lock;		/*  Lock for searching(R)/updating(W)   */	struct devfs_entry *first;	struct devfs_entry *last;	unsigned char no_more_additions:1;};struct symlink_type {	unsigned int length;	/*  Not including the NULL-termimator       */	char *linkname;		/*  This is NULL-terminated                 */};struct devfs_inode {		/*  This structure is for "persistent" inode storage  */	struct dentry *dentry;	struct timespec atime;	struct timespec mtime;	struct timespec ctime;	unsigned int ino;	/*  Inode number as seen in the VFS         */	uid_t uid;	gid_t gid;};struct devfs_entry {#ifdef CONFIG_DEVFS_DEBUG	unsigned int magic_number;#endif	void *info;	atomic_t refcount;	/*  When this drops to zero, it's unused    */	union {		struct directory_type dir;		dev_t dev;		struct symlink_type symlink;		const char *name;	/*  Only used for (mode == 0)               */	} u;	struct devfs_entry *prev;	/*  Previous entry in the parent directory  */	struct devfs_entry *next;	/*  Next entry in the parent directory      */	struct devfs_entry *parent;	/*  The parent directory                    */	struct devfs_inode inode;	umode_t mode;	unsigned short namelen;	/*  I think 64k+ filenames are a way off... */	unsigned char vfs:1;	/*  Whether the VFS may delete the entry   */	char name[1];		/*  This is just a dummy: the allocated array				   is bigger. This is NULL-terminated      */};/*  The root of the device tree  */static struct devfs_entry *root_entry;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?