📄 base.c
字号:
v0.82 19991104 Richard Gooch <rgooch@atnf.csiro.au> Removed unused <devfs_set_symlink_destination>. 19991105 Richard Gooch <rgooch@atnf.csiro.au> Do not hide entries from devfsd or children. Removed DEVFS_ FL_TTY_COMPAT flag. Removed "nottycompat" boot option. Removed <devfs_mk_compat>. Work sponsored by SGI. v0.83 19991107 Richard Gooch <rgooch@atnf.csiro.au> Added DEVFS_FL_WAIT flag. Work sponsored by SGI. v0.84 19991107 Richard Gooch <rgooch@atnf.csiro.au> Support new "disc" naming scheme in <get_removable_partition>. Allow NULL fops in <devfs_register>. Work sponsored by SGI. v0.85 19991110 Richard Gooch <rgooch@atnf.csiro.au> Fall back to major table if NULL fops given to <devfs_register>. Work sponsored by SGI. 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*/#include <linux/types.h>#include <linux/errno.h>#include <linux/sched.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/version.h>#include <linux/rwsem.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 "1.10 (20020120)"#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 IS_HIDDEN(de) ( (de)->hide && !is_devfsd_or_child(fs_info) )#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 OPTION_ONLY 0x02#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...)#endifstruct directory_type{ rwlock_t lock; /* Lock for searching(R)/updating(W) */ struct devfs_entry *first; struct devfs_entry *last; unsigned short num_removable; /* Lock for writing but not reading */ unsigned char no_more_additions:1;};struct file_type{ unsigned long size;};struct device_type{ unsigned short major; unsigned short minor;};struct fcb_type /* File, char, block type */{ void *ops; union { struct file_type file; struct device_type device; } u; unsigned char auto_owner:1; unsigned char aopen_notify:1; unsigned char removable:1; /* Belongs in device_type, but save space */ unsigned char open:1; /* Not entirely correct */ unsigned char autogen:1; /* Belongs in device_type, but save space */};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; time_t atime; time_t mtime;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -