From a5e22b6d8a9e8a5e813b9e3519c43cbddddf9ca5 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 22 Sep 2003 14:10:49 -0700 Subject: [NET]: rtnetlink -- rtattr_strcmp const args. --- include/linux/rtnetlink.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 502a1389f689..61fb1f2224d2 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -618,7 +618,7 @@ enum #include -static __inline__ int rtattr_strcmp(struct rtattr *rta, char *str) +static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str) { int len = strlen(str) + 1; return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len); -- cgit v1.2.3 From 70a209fbe4794269d101d46cb1ef386aee5df413 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 22 Sep 2003 14:11:18 -0700 Subject: [NET]: rtnetlink -- RTA_PUT unlikely. --- include/linux/rtnetlink.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 61fb1f2224d2..3406e8cfc32c 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -642,8 +642,9 @@ extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data); #define RTA_PUT(skb, attrtype, attrlen, data) \ -({ if (skb_tailroom(skb) < (int)RTA_SPACE(attrlen)) goto rtattr_failure; \ - __rta_fill(skb, attrtype, attrlen, data); }) +({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \ + goto rtattr_failure; \ + __rta_fill(skb, attrtype, attrlen, data); }) static inline struct rtattr * __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen) @@ -658,8 +659,9 @@ __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen) } #define __RTA_PUT(skb, attrtype, attrlen) \ -({ if (skb_tailroom(skb) < (int)RTA_SPACE(attrlen)) goto rtattr_failure; \ - __rta_reserve(skb, attrtype, attrlen); }) +({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \ + goto rtattr_failure; \ + __rta_reserve(skb, attrtype, attrlen); }) extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change); -- cgit v1.2.3 From f3b65b776ea63fc3e77b4185685f8050765f71d3 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 22 Sep 2003 14:12:56 -0700 Subject: [NET]: rtnetlink -- ASSERT_RTNL and BUG_TRAP. Change ASSERT_RTNL and BUG_TRAP - unlikely to occur - tag message as error - dump_stack in ASSERT_RTNL to aide finding code path - make all format's which a smart compiler can optimize --- include/linux/rtnetlink.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'include/linux') diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 3406e8cfc32c..1141ec3c5321 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -683,11 +683,21 @@ extern void rtnl_lock(void); extern void rtnl_unlock(void); extern void rtnetlink_init(void); -#define ASSERT_RTNL() do { if (down_trylock(&rtnl_sem) == 0) { up(&rtnl_sem); \ -printk("RTNL: assertion failed at " __FILE__ "(%d)\n", __LINE__); } \ - } while(0) -#define BUG_TRAP(x) if (!(x)) { printk("KERNEL: assertion (" #x ") failed at " __FILE__ "(%d)\n", __LINE__); } - +#define ASSERT_RTNL() do { \ + if (unlikely(down_trylock(&rtnl_sem) == 0)) { \ + up(&rtnl_sem); \ + printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \ + __FILE__, __LINE__); \ + dump_stack(); \ + } \ +} while(0) + +#define BUG_TRAP(x) do { \ + if (unlikely(!(x))) { \ + printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \ + #x, __FILE__ , __LINE__); \ + } \ +} while(0) #endif /* __KERNEL__ */ -- cgit v1.2.3 From 845602f87a1abb60bbd9b35288d4a2774db6439b Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Mon, 22 Sep 2003 22:50:15 -0700 Subject: [PATCH] prepare for 32-bit dev_t: reiserfs/procfs.c fs/reiserfs/procfs.c made sane. It used to store dev_t of filesystem in the proc_dir_entry->data (which is void *) and played very odd games after that. Switched to seq_file, stores pointer to superblock, uses sget() to validate it, avoids use of dev_t completely. --- fs/reiserfs/procfs.c | 386 ++++++++++++++++------------------------- fs/reiserfs/super.c | 24 +-- include/linux/reiserfs_fs.h | 19 -- include/linux/reiserfs_fs_sb.h | 2 +- 4 files changed, 158 insertions(+), 273 deletions(-) (limited to 'include/linux') diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c index 073cafd04548..90074d247eb6 100644 --- a/fs/reiserfs/procfs.c +++ b/fs/reiserfs/procfs.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -29,58 +30,10 @@ * */ -static struct super_block *procinfo_prologue(dev_t dev) +static int show_version(struct seq_file *m, struct super_block *sb) { - struct super_block *result; - - /* get super-block by device */ - result = user_get_super(dev); - if( result != NULL ) { - if( !is_reiserfs_super( result ) ) { - printk( KERN_DEBUG "reiserfs: procfs-52: " - "non-reiserfs super found\n" ); - drop_super( result ); - result = NULL; - } - } else - printk( KERN_DEBUG "reiserfs: procfs-74: " - "race between procinfo and umount\n" ); - return result; -} - -int procinfo_epilogue( struct super_block *super ) -{ - drop_super( super ); - return 0; -} - -int reiserfs_proc_tail( int len, char *buffer, char **start, - off_t offset, int count, int *eof ) -{ - /* this is black procfs magic */ - if( offset >= len ) { - *start = buffer; - *eof = 1; - return 0; - } - *start = buffer + offset; - if( ( len -= offset ) > count ) { - return count; - } - *eof = 1; - return len; -} - -int reiserfs_version_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) -{ - int len = 0; - struct super_block *sb; char *format; - sb = procinfo_prologue((int)data); - if( sb == NULL ) - return -ENOENT; if ( REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6) ) { format = "3.6"; } else if ( REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5) ) { @@ -89,7 +42,7 @@ int reiserfs_version_in_proc( char *buffer, char **start, off_t offset, format = "unknown"; } - len += sprintf( &buffer[ len ], "%s format\twith checks %s\n", + seq_printf(m, "%s format\twith checks %s\n", format, #if defined( CONFIG_REISERFS_CHECK ) "on" @@ -97,15 +50,15 @@ int reiserfs_version_in_proc( char *buffer, char **start, off_t offset, "off" #endif ); - procinfo_epilogue( sb ); - return reiserfs_proc_tail( len, buffer, start, offset, count, eof ); + return 0; } int reiserfs_global_version_in_proc( char *buffer, char **start, off_t offset, int count, int *eof, void *data ) { - int len = 0; - return reiserfs_proc_tail( len, buffer, start, offset, count, eof ); + *start = buffer; + *eof = 1; + return 0; } #define SF( x ) ( r -> x ) @@ -129,19 +82,11 @@ int reiserfs_global_version_in_proc( char *buffer, char **start, off_t offset, #define DJP( x ) le32_to_cpu( jp -> x ) #define JF( x ) ( r -> s_journal -> x ) -int reiserfs_super_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) +static int show_super(struct seq_file *m, struct super_block *sb) { - struct super_block *sb; - struct reiserfs_sb_info *r; - int len = 0; + struct reiserfs_sb_info *r = REISERFS_SB(sb); - sb = procinfo_prologue((int)data); - if( sb == NULL ) - return -ENOENT; - r = REISERFS_SB(sb); - len += sprintf( &buffer[ len ], - "state: \t%s\n" + seq_printf(m, "state: \t%s\n" "mount options: \t%s%s%s%s%s%s%s%s%s%s%s%s\n" "gen. counter: \t%i\n" "s_kmallocs: \t%i\n" @@ -217,25 +162,15 @@ int reiserfs_super_in_proc( char *buffer, char **start, off_t offset, SFP( leaked_oid ), SFP( leaves_removable ) ); - procinfo_epilogue( sb ); - return reiserfs_proc_tail( len, buffer, start, offset, count, eof ); + return 0; } -int reiserfs_per_level_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) +static int show_per_level(struct seq_file *m, struct super_block *sb) { - struct super_block *sb; - struct reiserfs_sb_info *r; - int len = 0; + struct reiserfs_sb_info *r = REISERFS_SB(sb); int level; - - sb = procinfo_prologue((int)data); - if( sb == NULL ) - return -ENOENT; - r = REISERFS_SB(sb); - - len += sprintf( &buffer[ len ], - "level\t" + + seq_printf(m, "level\t" " balances" " [sbk: reads" " fs_changed" @@ -256,12 +191,7 @@ int reiserfs_per_level_in_proc( char *buffer, char **start, off_t offset, ); for( level = 0 ; level < MAX_HEIGHT ; ++ level ) { - if( len > PAGE_SIZE - 240 ) { - len += sprintf( &buffer[ len ], "... and more\n" ); - break; - } - len += sprintf( &buffer[ len ], - "%i\t" + seq_printf(m, "%i\t" " %12lu" " %12lu" " %12lu" @@ -296,24 +226,14 @@ int reiserfs_per_level_in_proc( char *buffer, char **start, off_t offset, SFPL( need_r_neighbor ) ); } - - procinfo_epilogue( sb ); - return reiserfs_proc_tail( len, buffer, start, offset, count, eof ); + return 0; } -int reiserfs_bitmap_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) +static int show_bitmap(struct seq_file *m, struct super_block *sb) { - struct super_block *sb; - struct reiserfs_sb_info *r; - int len = 0; - - sb = procinfo_prologue((int)data); - if( sb == NULL ) - return -ENOENT; - r = REISERFS_SB(sb); + struct reiserfs_sb_info *r = REISERFS_SB(sb); - len += sprintf( &buffer[ len ], "free_block: %lu\n" + seq_printf(m, "free_block: %lu\n" " scan_bitmap:" " wait" " bmap" @@ -339,30 +259,17 @@ int reiserfs_bitmap_in_proc( char *buffer, char **start, off_t offset, SFPF( in_journal_hint ), SFPF( in_journal_nohint ) ); - procinfo_epilogue( sb ); - return reiserfs_proc_tail( len, buffer, start, offset, count, eof ); + return 0; } -int reiserfs_on_disk_super_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) +static int show_on_disk_super(struct seq_file *m, struct super_block *sb) { - struct super_block *sb; - struct reiserfs_sb_info *sb_info; - struct reiserfs_super_block *rs; - int hash_code; - __u32 flags; - int len = 0; - - sb = procinfo_prologue((int)data); - if( sb == NULL ) - return -ENOENT; - sb_info = REISERFS_SB(sb); - rs = sb_info -> s_rs; - hash_code = DFL( s_hash_function_code ); - flags = DJF( s_flags ); - - len += sprintf( &buffer[ len ], - "block_count: \t%i\n" + struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); + struct reiserfs_super_block *rs = sb_info -> s_rs; + int hash_code = DFL( s_hash_function_code ); + __u32 flags = DJF( s_flags ); + + seq_printf(m, "block_count: \t%i\n" "free_blocks: \t%i\n" "root_block: \t%i\n" "blocksize: \t%i\n" @@ -399,84 +306,49 @@ int reiserfs_on_disk_super_in_proc( char *buffer, char **start, off_t offset, ? "attrs_cleared" : "", DF (s_reserved_for_journal)); - procinfo_epilogue( sb ); - return reiserfs_proc_tail( len, buffer, start, offset, count, eof ); + return 0; } -int reiserfs_oidmap_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) +static int show_oidmap(struct seq_file *m, struct super_block *sb) { - struct super_block *sb; - struct reiserfs_sb_info *sb_info; - struct reiserfs_super_block *rs; + struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); + struct reiserfs_super_block *rs = sb_info -> s_rs; + unsigned int mapsize = le16_to_cpu( rs -> s_v1.s_oid_cursize ); + unsigned long total_used = 0; int i; - unsigned int mapsize; - unsigned long total_used; - int len = 0; - int exact; - - sb = procinfo_prologue((int)data); - if( sb == NULL ) - return -ENOENT; - sb_info = REISERFS_SB(sb); - rs = sb_info -> s_rs; - mapsize = le16_to_cpu( rs -> s_v1.s_oid_cursize ); - total_used = 0; for( i = 0 ; i < mapsize ; ++i ) { __u32 right; right = ( i == mapsize - 1 ) ? MAX_KEY_OBJECTID : MAP( i + 1 ); - len += sprintf( &buffer[ len ], "%s: [ %x .. %x )\n", + seq_printf(m, "%s: [ %x .. %x )\n", ( i & 1 ) ? "free" : "used", MAP( i ), right ); if( ! ( i & 1 ) ) { total_used += right - MAP( i ); } - if( len > PAGE_SIZE - 100 ) { - len += sprintf( &buffer[ len ], "... and more\n" ); - break; - } } #if defined( REISERFS_USE_OIDMAPF ) if( sb_info -> oidmap.use_file && ( sb_info -> oidmap.mapf != NULL ) ) { - loff_t size; - - size = sb_info -> oidmap.mapf -> f_dentry -> d_inode -> i_size; + loff_t size = sb_info->oidmap.mapf->f_dentry->d_inode->i_size; total_used += size / sizeof( reiserfs_oidinterval_d_t ); - exact = 1; - } else -#endif - { - exact = ( i == mapsize ); } - len += sprintf( &buffer[ len ], "total: \t%i [%i/%i] used: %lu [%s]\n", - i, +#endif + seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n", + mapsize, mapsize, le16_to_cpu( rs -> s_v1.s_oid_maxsize ), - total_used, exact ? "exact" : "estimation" ); - - procinfo_epilogue( sb ); - return reiserfs_proc_tail( len, buffer, start, offset, count, eof ); + total_used); + return 0; } -int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) +static int show_journal(struct seq_file *m, struct super_block *sb) { - struct super_block *sb; - struct reiserfs_sb_info *r; - struct reiserfs_super_block *rs; - struct journal_params *jp; - int len = 0; + struct reiserfs_sb_info *r = REISERFS_SB(sb); + struct reiserfs_super_block *rs = r -> s_rs; + struct journal_params *jp = &rs->s_v1.s_journal; char b[BDEVNAME_SIZE]; - sb = procinfo_prologue((int)data); - if( sb == NULL ) - return -ENOENT; - r = REISERFS_SB(sb); - rs = r -> s_rs; - jp = &rs->s_v1.s_journal; - - len += sprintf( &buffer[ len ], - /* on-disk fields */ + + seq_printf(m, /* on-disk fields */ "jp_journal_1st_block: \t%i\n" "jp_journal_dev: \t%s[%x]\n" "jp_journal_size: \t%i\n" @@ -567,21 +439,115 @@ int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset, SFPJ( prepare ), SFPJ( prepare_retry ) ); + return 0; +} + +/* iterator */ +static int test_sb(struct super_block *sb, void *data) +{ + return data == sb; +} + +static int set_sb(struct super_block *sb, void *data) +{ + return -ENOENT; +} + +static void *r_start(struct seq_file *m, loff_t *pos) +{ + struct proc_dir_entry *de = m->private; + struct super_block *s = de->parent->data; + loff_t l = *pos; + + if (l) + return NULL; + + if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, s))) + return NULL; - procinfo_epilogue( sb ); - return reiserfs_proc_tail( len, buffer, start, offset, count, eof ); + up_write(&s->s_umount); + + if (de->deleted) { + deactivate_super(s); + return NULL; + } + + return s; +} + +static void *r_next(struct seq_file *m, void *v, loff_t *pos) +{ + ++*pos; + return NULL; +} + +static void r_stop(struct seq_file *m, void *v) +{ + struct proc_dir_entry *de = m->private; + struct super_block *s = de->data; + deactivate_super(s); +} + +static int r_show(struct seq_file *m, void *v) +{ + struct proc_dir_entry *de = m->private; + int (*show)(struct seq_file *, struct super_block *) = de->data; + return show(m, v); } +static struct seq_operations r_ops = { + .start = r_start, + .next = r_next, + .stop = r_stop, + .show = r_show, +}; + +static int r_open(struct inode *inode, struct file *file) +{ + int ret = seq_open(file, &r_ops); + + if (!ret) { + struct seq_file *m = file->private_data; + m->private = PDE(inode); + } + return ret; +} + +static struct file_operations r_file_operations = { + .open = r_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; static struct proc_dir_entry *proc_info_root = NULL; static const char proc_info_root_name[] = "fs/reiserfs"; +static void add_file(struct super_block *sb, char *name, + int (*func)(struct seq_file *, struct super_block *)) +{ + struct proc_dir_entry *de; + de = create_proc_entry(name, 0, REISERFS_SB(sb)->procdir); + if (de) { + de->data = func; + de->proc_fops = &r_file_operations; + } +} + int reiserfs_proc_info_init( struct super_block *sb ) { spin_lock_init( & __PINFO( sb ).lock ); REISERFS_SB(sb)->procdir = proc_mkdir(reiserfs_bdevname (sb), proc_info_root); if( REISERFS_SB(sb)->procdir ) { - REISERFS_SB(sb)->procdir -> owner = THIS_MODULE; + REISERFS_SB(sb)->procdir->owner = THIS_MODULE; + REISERFS_SB(sb)->procdir->data = sb; + add_file(sb, "version", show_version); + add_file(sb, "super", show_super); + add_file(sb, "per-level", show_per_level); + add_file(sb, "bitmap", show_bitmap); + add_file(sb, "on-disk-super", show_on_disk_super); + add_file(sb, "oidmap", show_oidmap); + add_file(sb, "journal", show_journal); return 0; } reiserfs_warning( "reiserfs: cannot create /proc/%s/%s\n", @@ -589,9 +555,18 @@ int reiserfs_proc_info_init( struct super_block *sb ) return 1; } - int reiserfs_proc_info_done( struct super_block *sb ) { + struct proc_dir_entry *de = REISERFS_SB(sb)->procdir; + if (de) { + remove_proc_entry("journal", de); + remove_proc_entry("oidmap", de); + remove_proc_entry("on-disk-super", de); + remove_proc_entry("bitmap", de); + remove_proc_entry("per-level", de); + remove_proc_entry("super", de); + remove_proc_entry("version", de); + } spin_lock( & __PINFO( sb ).lock ); __PINFO( sb ).exiting = 1; spin_unlock( & __PINFO( sb ).lock ); @@ -602,23 +577,6 @@ int reiserfs_proc_info_done( struct super_block *sb ) return 0; } -/* Create /proc/fs/reiserfs/DEV/name and attach read procedure @func - to it. Other parts of reiserfs use this function to make their - per-device statistics available via /proc */ - -struct proc_dir_entry *reiserfs_proc_register( struct super_block *sb, - char *name, read_proc_t *func ) -{ - return ( REISERFS_SB(sb)->procdir ) ? create_proc_read_entry - ( name, 0, REISERFS_SB(sb)->procdir, func, - ( void * )(int) sb->s_bdev->bd_dev) : NULL; -} - -void reiserfs_proc_unregister( struct super_block *sb, const char *name ) -{ - remove_proc_entry( name, REISERFS_SB(sb)->procdir ); -} - struct proc_dir_entry *reiserfs_proc_register_global( char *name, read_proc_t *func ) { @@ -662,14 +620,6 @@ int reiserfs_proc_info_global_done( void ) int reiserfs_proc_info_init( struct super_block *sb ) { return 0; } int reiserfs_proc_info_done( struct super_block *sb ) { return 0; } -struct proc_dir_entry *reiserfs_proc_register( struct super_block *sb, - char *name, - read_proc_t *func ) -{ return NULL; } - -void reiserfs_proc_unregister( struct super_block *sb, const char *name ) -{;} - struct proc_dir_entry *reiserfs_proc_register_global( char *name, read_proc_t *func ) { return NULL; } @@ -684,34 +634,6 @@ int reiserfs_global_version_in_proc( char *buffer, char **start, int count, int *eof, void *data ) { return 0; } -int reiserfs_version_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) -{ return 0; } - -int reiserfs_super_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) -{ return 0; } - -int reiserfs_per_level_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) -{ return 0; } - -int reiserfs_bitmap_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) -{ return 0; } - -int reiserfs_on_disk_super_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) -{ return 0; } - -int reiserfs_oidmap_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) -{ return 0; } - -int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ) -{ return 0; } - /* REISERFS_PROC_INFO */ #endif diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index fd4ca1a92836..b5926f911776 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -23,7 +23,7 @@ #include #include -static struct file_system_type reiserfs_fs_type; +struct file_system_type reiserfs_fs_type; const char reiserfs_3_5_magic_string[] = REISERFS_SUPER_MAGIC_STRING; const char reiserfs_3_6_magic_string[] = REISER2FS_SUPER_MAGIC_STRING; @@ -56,11 +56,6 @@ static int is_any_reiserfs_magic_string (struct reiserfs_super_block * rs) is_reiserfs_jr (rs)); } -int is_reiserfs_super (struct super_block *s) -{ - return s -> s_type == & reiserfs_fs_type ; -} - static int reiserfs_remount (struct super_block * s, int * flags, char * data); static int reiserfs_statfs (struct super_block * s, struct kstatfs * buf); @@ -391,13 +386,6 @@ static void reiserfs_put_super (struct super_block * s) REISERFS_SB(s)->reserved_blocks); } - reiserfs_proc_unregister( s, "journal" ); - reiserfs_proc_unregister( s, "oidmap" ); - reiserfs_proc_unregister( s, "on-disk-super" ); - reiserfs_proc_unregister( s, "bitmap" ); - reiserfs_proc_unregister( s, "per-level" ); - reiserfs_proc_unregister( s, "super" ); - reiserfs_proc_unregister( s, "version" ); reiserfs_proc_info_done( s ); kfree(s->s_fs_info); @@ -1389,13 +1377,7 @@ static int reiserfs_fill_super (struct super_block * s, void * data, int silent) handle_attrs( s ); reiserfs_proc_info_init( s ); - reiserfs_proc_register( s, "version", reiserfs_version_in_proc ); - reiserfs_proc_register( s, "super", reiserfs_super_in_proc ); - reiserfs_proc_register( s, "per-level", reiserfs_per_level_in_proc ); - reiserfs_proc_register( s, "bitmap", reiserfs_bitmap_in_proc ); - reiserfs_proc_register( s, "on-disk-super", reiserfs_on_disk_super_in_proc ); - reiserfs_proc_register( s, "oidmap", reiserfs_oidmap_in_proc ); - reiserfs_proc_register( s, "journal", reiserfs_journal_in_proc ); + init_waitqueue_head (&(sbi->s_wait)); sbi->bitmap_lock = SPIN_LOCK_UNLOCKED; @@ -1480,7 +1462,7 @@ exit_reiserfs_fs ( void ) destroy_inodecache (); } -static struct file_system_type reiserfs_fs_type = { +struct file_system_type reiserfs_fs_type = { .owner = THIS_MODULE, .name = "reiserfs", .get_sb = get_super_block, diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h index 0d8f3ad21fdd..a34e79044978 100644 --- a/include/linux/reiserfs_fs.h +++ b/include/linux/reiserfs_fs.h @@ -1931,32 +1931,13 @@ struct dentry *reiserfs_get_parent(struct dentry *) ; int reiserfs_proc_info_init( struct super_block *sb ); int reiserfs_proc_info_done( struct super_block *sb ); -struct proc_dir_entry *reiserfs_proc_register( struct super_block *sb, - char *name, read_proc_t *func ); -void reiserfs_proc_unregister( struct super_block *sb, const char *name ); struct proc_dir_entry *reiserfs_proc_register_global( char *name, read_proc_t *func ); void reiserfs_proc_unregister_global( const char *name ); int reiserfs_proc_info_global_init( void ); int reiserfs_proc_info_global_done( void ); -int reiserfs_proc_tail( int len, char *buffer, char **start, - off_t offset, int count, int *eof ); int reiserfs_global_version_in_proc( char *buffer, char **start, off_t offset, int count, int *eof, void *data ); -int reiserfs_version_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ); -int reiserfs_super_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ); -int reiserfs_per_level_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ); -int reiserfs_bitmap_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ); -int reiserfs_on_disk_super_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ); -int reiserfs_oidmap_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ); -int reiserfs_journal_in_proc( char *buffer, char **start, off_t offset, - int count, int *eof, void *data ); #if defined( REISERFS_PROC_INFO ) diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h index 956b0d22d500..4c675f30a8ae 100644 --- a/include/linux/reiserfs_fs_sb.h +++ b/include/linux/reiserfs_fs_sb.h @@ -468,7 +468,7 @@ struct reiserfs_sb_info void reiserfs_file_buffer (struct buffer_head * bh, int list); -int is_reiserfs_super(struct super_block *s) ; +extern struct file_system_type reiserfs_fs_type; int journal_mark_dirty(struct reiserfs_transaction_handle *, struct super_block *, struct buffer_head *bh) ; int flush_old_commits(struct super_block *s, int) ; int show_reiserfs_locks(void) ; -- cgit v1.2.3 From 7f904771736fc6a6465a80541a0cb607d69772d3 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Mon, 22 Sep 2003 22:50:42 -0700 Subject: [PATCH] prepare for 32-bit dev_t: tty usage tty->device had been used only in a couple of places and can be calculated by tty->index and tty->driver. Field removed, its users switched to static inline dev_t tty_devnum(tty). --- arch/x86_64/ia32/ia32_ioctl.c | 2 +- drivers/char/tty_io.c | 3 --- drivers/net/slip.c | 4 ++-- fs/proc/array.c | 2 +- include/linux/tty.h | 6 +++++- kernel/acct.c | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) (limited to 'include/linux') diff --git a/arch/x86_64/ia32/ia32_ioctl.c b/arch/x86_64/ia32/ia32_ioctl.c index d31ac9f27488..4c1a4c2e6779 100644 --- a/arch/x86_64/ia32/ia32_ioctl.c +++ b/arch/x86_64/ia32/ia32_ioctl.c @@ -35,7 +35,7 @@ static int tiocgdev(unsigned fd, unsigned cmd, unsigned int *ptr) real_tty = (struct tty_struct *)file->private_data; if (!real_tty) return -EINVAL; - return put_user(real_tty->device, ptr); + return put_user(tty_devnum(real_tty), ptr); } diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 41935ac3e375..2ea337b26d51 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -826,7 +826,6 @@ static int init_dev(struct tty_driver *driver, int idx, if(!tty) goto fail_no_mem; initialize_tty_struct(tty); - tty->device = MKDEV(driver->major, driver->minor_start) + idx; tty->driver = driver; tty->index = idx; tty_line_name(driver, idx, tty->name); @@ -854,8 +853,6 @@ static int init_dev(struct tty_driver *driver, int idx, if (!o_tty) goto free_mem_out; initialize_tty_struct(o_tty); - o_tty->device = MKDEV(driver->other->major, - driver->other->minor_start) + idx; o_tty->driver = driver->other; o_tty->index = idx; tty_line_name(driver->other, idx, o_tty->name); diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 221a89e880af..601df52ebb29 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -869,12 +869,12 @@ slip_open(struct tty_struct *tty) /* OK. Find a free SLIP channel to use. */ err = -ENFILE; - if ((sl = sl_alloc(tty->device)) == NULL) + if ((sl = sl_alloc(tty_devnum(tty))) == NULL) goto err_exit; sl->tty = tty; tty->disc_data = sl; - sl->line = tty->device; + sl->line = tty_devnum(tty); sl->pid = current->pid; if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty); diff --git a/fs/proc/array.c b/fs/proc/array.c index bf39eb5013b0..f38e5d249fab 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -306,7 +306,7 @@ int proc_pid_stat(struct task_struct *task, char * buffer) mm = mmgrab(mm); if (task->tty) { tty_pgrp = task->tty->pgrp; - tty_nr = task->tty->device; + tty_nr = tty_devnum(task->tty); } task_unlock(task); if (mm) { diff --git a/include/linux/tty.h b/include/linux/tty.h index c575197f00b3..946702c37e6e 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -264,7 +264,6 @@ struct tty_struct { char name[64]; int pgrp; int session; - dev_t device; unsigned long flags; int count; struct winsize winsize; @@ -419,5 +418,10 @@ extern void console_print(const char *); extern int vt_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); +static inline dev_t tty_devnum(struct tty_struct *tty) +{ + return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index; +} + #endif /* __KERNEL__ */ #endif diff --git a/kernel/acct.c b/kernel/acct.c index 0009dfb25dcb..edb2ba573e70 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -342,7 +342,7 @@ static void do_acct_process(long exitcode, struct file *file) ac.ac_stime = encode_comp_t(current->stime); ac.ac_uid = current->uid; ac.ac_gid = current->gid; - ac.ac_tty = current->tty ? current->tty->device : 0; + ac.ac_tty = current->tty ? tty_devnum(current->tty) : 0; ac.ac_flag = 0; if (current->flags & PF_FORKNOEXEC) -- cgit v1.2.3 From 9e2135245918b261e7500bb6410cd7b207596c31 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Mon, 22 Sep 2003 22:50:51 -0700 Subject: [PATCH] prepare for 32-bit dev_t: NFS NFS made dev_t-agnostic. Aside of minor fixes in debugging printks, and adding old_encode_dev()/old_decode_dev(), the main part is in handling of exports with large dev_t. New fhandle format introduced, fh_verify(), fh_compose() and exports cache taught to deal with it. Format is used when ->s_dev of exported fs doesn't fit into 256:256; in that case we put major and minor in separate words in fhandle; ->fh_fsid_type is set to 2. --- fs/nfs/nfs3proc.c | 3 +- fs/nfs/nfs4xdr.c | 2 +- fs/nfs/proc.c | 2 +- fs/nfsd/export.c | 97 +++++++++++++++++++++++++++------------------ fs/nfsd/nfs3xdr.c | 12 ++---- fs/nfsd/nfsfh.c | 62 ++++++++++++++++++++--------- fs/nfsd/nfsproc.c | 20 +++++----- fs/nfsd/nfsxdr.c | 8 ++-- include/linux/nfsd/export.h | 2 +- include/linux/nfsd/nfsd.h | 12 ++++++ include/linux/nfsd/nfsfh.h | 26 +++--------- 11 files changed, 141 insertions(+), 105 deletions(-) (limited to 'include/linux') diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 334ead4e4dd3..d359e7df87c7 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -651,7 +651,8 @@ nfs3_proc_mknod(struct inode *dir, struct qstr *name, struct iattr *sattr, default: return -EINVAL; } - dprintk("NFS call mknod %s %x\n", name->name, (unsigned)rdev); + dprintk("NFS call mknod %s %u:%u\n", name->name, + MAJOR(rdev), MINOR(rdev)); dir_attr.valid = 0; fattr->valid = 0; status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKNOD, &arg, &res, 0); diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 2d8cfbda8698..a2d040f3cd5e 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1503,7 +1503,7 @@ decode_getattr(struct xdr_stream *xdr, struct nfs4_getattr *getattr, READ32(major); READ32(minor); nfp->rdev = MKDEV(major, minor); - dprintk("read_attrs: rdev=0x%x\n", nfp->rdev); + dprintk("read_attrs: rdev=%u:%u\n", major, minor); } if (bmval1 & FATTR4_WORD1_SPACE_AVAIL) { READ_BUF(8); diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 658fb1cf5932..7f713974b7ab 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -277,7 +277,7 @@ nfs_proc_mknod(struct inode *dir, struct qstr *name, struct iattr *sattr, sattr->ia_valid &= ~ATTR_SIZE; } else if (S_ISCHR(mode) || S_ISBLK(mode)) { sattr->ia_valid |= ATTR_SIZE; - sattr->ia_size = rdev; /* get out your barf bag */ + sattr->ia_size = old_encode_dev(rdev);/* get out your barf bag */ } fattr->valid = 0; diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 5bbbc3c7ed0e..340d21c624da 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -55,11 +55,16 @@ static int exp_verify_string(char *cp, int max); #define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1) static struct cache_head *expkey_table[EXPKEY_HASHMAX]; +static inline int key_len(int type) +{ + return type == 0 ? 8 : type == 1 ? 4 : 12; +} + static inline int svc_expkey_hash(struct svc_expkey *item) { int hash = item->ek_fsidtype; char * cp = (char*)item->ek_fsid; - int len = (item->ek_fsidtype==0)?8:4; + int len = key_len(item->ek_fsidtype); hash ^= hash_mem(cp, len, EXPKEY_HASHBITS); hash ^= hash_ptr(item->ek_client, EXPKEY_HASHBITS); @@ -89,7 +94,7 @@ void expkey_request(struct cache_detail *cd, qword_add(bpp, blen, ek->ek_client->name); snprintf(type, 5, "%d", ek->ek_fsidtype); qword_add(bpp, blen, type); - qword_addhex(bpp, blen, (char*)ek->ek_fsid, ek->ek_fsidtype==0?8:4); + qword_addhex(bpp, blen, (char*)ek->ek_fsid, key_len(ek->ek_fsidtype)); (*bpp)[-1] = '\n'; } @@ -130,12 +135,12 @@ int expkey_parse(struct cache_detail *cd, char *mesg, int mlen) if (*ep) goto out; dprintk("found fsidtype %d\n", fsidtype); - if (fsidtype > 1) + if (fsidtype > 2) goto out; if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0) goto out; dprintk("found fsid length %d\n", len); - if (len != ((fsidtype==0)?8:4)) + if (len != key_len(fsidtype)) goto out; /* OK, we seem to have a valid key */ @@ -206,8 +211,10 @@ static int expkey_show(struct seq_file *m, ek = container_of(h, struct svc_expkey, h); seq_printf(m, "%s %d 0x%08x", ek->ek_client->name, ek->ek_fsidtype, ek->ek_fsid[0]); - if (ek->ek_fsid == 0) - seq_printf(m, "%08x", ek->ek_fsid[0]); + if (ek->ek_fsidtype != 1) + seq_printf(m, "%08x", ek->ek_fsid[1]); + if (ek->ek_fsidtype == 2) + seq_printf(m, "%08x", ek->ek_fsid[2]); if (test_bit(CACHE_VALID, &h->flags) && !test_bit(CACHE_NEGATIVE, &h->flags)) { seq_printf(m, " "); @@ -230,13 +237,8 @@ struct cache_detail svc_expkey_cache = { static inline int svc_expkey_match (struct svc_expkey *a, struct svc_expkey *b) { if (a->ek_fsidtype != b->ek_fsidtype || - a->ek_client != b->ek_client) - return 0; - if (a->ek_fsid[0] != b->ek_fsid[0]) - return 0; - if (a->ek_fsidtype == 1) - return 1; - if (a->ek_fsid[1] != b->ek_fsid[1]) + a->ek_client != b->ek_client || + memcmp(a->ek_fsid, b->ek_fsid, key_len(a->ek_fsidtype)) != 0) return 0; return 1; } @@ -248,6 +250,7 @@ static inline void svc_expkey_init(struct svc_expkey *new, struct svc_expkey *it new->ek_fsidtype = item->ek_fsidtype; new->ek_fsid[0] = item->ek_fsid[0]; new->ek_fsid[1] = item->ek_fsid[1]; + new->ek_fsid[2] = item->ek_fsid[2]; } static inline void svc_expkey_update(struct svc_expkey *new, struct svc_expkey *item) @@ -502,8 +505,7 @@ exp_find_key(svc_client *clp, int fsid_type, u32 *fsidv, struct cache_req *reqp) key.ek_client = clp; key.ek_fsidtype = fsid_type; - key.ek_fsid[0] = fsidv[0]; - key.ek_fsid[1] = fsidv[1]; + memcpy(key.ek_fsid, fsidv, key_len(fsid_type)); ek = svc_expkey_lookup(&key, 0); if (ek != NULL) @@ -519,8 +521,7 @@ int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv, key.ek_client = clp; key.ek_fsidtype = fsid_type; - key.ek_fsid[0] = fsidv[0]; - key.ek_fsid[1] = fsidv[1]; + memcpy(key.ek_fsid, fsidv, key_len(fsid_type)); key.ek_export = exp; key.h.expiry_time = NEVER; key.h.flags = 0; @@ -539,10 +540,14 @@ int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv, static inline struct svc_expkey * exp_get_key(svc_client *clp, dev_t dev, ino_t ino) { - u32 fsidv[2]; + u32 fsidv[3]; - mk_fsid_v0(fsidv, dev, ino); - return exp_find_key(clp, 0, fsidv, NULL); + if (old_valid_dev(dev)) { + mk_fsid_v0(fsidv, dev, ino); + return exp_find_key(clp, 0, fsidv, NULL); + } + mk_fsid_v2(fsidv, dev, ino); + return exp_find_key(clp, 2, fsidv, NULL); } /* @@ -671,11 +676,15 @@ static int exp_fsid_hash(svc_client *clp, struct svc_export *exp) static int exp_hash(struct auth_domain *clp, struct svc_export *exp) { u32 fsid[2]; - struct inode *inode; + struct inode *inode = exp->ex_dentry->d_inode; + dev_t dev = inode->i_sb->s_dev; - inode = exp->ex_dentry->d_inode; - mk_fsid_v0(fsid, inode->i_sb->s_dev, inode->i_ino); - return exp_set_key(clp, 0, fsid, exp); + if (old_valid_dev(dev)) { + mk_fsid_v0(fsid, dev, inode->i_ino); + return exp_set_key(clp, 0, fsid, exp); + } + mk_fsid_v2(fsid, dev, inode->i_ino); + return exp_set_key(clp, 2, fsid, exp); } static void exp_unhash(struct svc_export *exp) @@ -819,32 +828,42 @@ int exp_unexport(struct nfsctl_export *nxp) { struct auth_domain *dom; + svc_export *exp; + struct nameidata nd; int err; /* Consistency check */ - if (!exp_verify_string(nxp->ex_client, NFSCLNT_IDMAX)) + if (!exp_verify_string(nxp->ex_path, NFS_MAXPATHLEN) || + !exp_verify_string(nxp->ex_client, NFSCLNT_IDMAX)) return -EINVAL; exp_writelock(); err = -EINVAL; dom = auth_domain_find(nxp->ex_client); - - if (dom) { - struct svc_expkey *key = exp_get_key(dom, nxp->ex_dev, nxp->ex_ino); - if (key && !IS_ERR(key) && key->ek_export) { - exp_do_unexport(key->ek_export); - err = 0; - expkey_put(&key->h, &svc_expkey_cache); - } else - dprintk("nfsd: no export %x/%lx for %s\n", - (unsigned)nxp->ex_dev, - (unsigned long) nxp->ex_ino, nxp->ex_client); - auth_domain_put(dom); - cache_flush(); - } else + if (!dom) { dprintk("nfsd: unexport couldn't find %s\n", nxp->ex_client); + goto out_unlock; + } + + err = path_lookup(nxp->ex_path, 0, &nd); + if (err) + goto out_domain; + err = -EINVAL; + exp = exp_get_by_name(dom, nd.mnt, nd.dentry, NULL); + path_release(&nd); + if (!exp) + goto out_domain; + + exp_do_unexport(exp); + exp_put(exp); + err = 0; + +out_domain: + auth_domain_put(dom); + cache_flush(); +out_unlock: exp_writeunlock(); return err; } diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 71ca4d0e2019..11eff232b35a 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -186,12 +186,10 @@ encode_fattr3(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) p = xdr_encode_hyper(p, ((u64)stat.blocks) << 9); *p++ = htonl((u32) MAJOR(stat.rdev)); *p++ = htonl((u32) MINOR(stat.rdev)); - if (rqstp->rq_reffh->fh_version == 1 - && rqstp->rq_reffh->fh_fsid_type == 1 - && (fhp->fh_export->ex_flags & NFSEXP_FSID)) + if (is_fsid(fhp, rqstp->rq_reffh)) p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid); else - p = xdr_encode_hyper(p, (u64) stat.dev); + p = xdr_encode_hyper(p, (u64) old_encode_dev(stat.dev)); p = xdr_encode_hyper(p, (u64) stat.ino); p = encode_time3(p, &stat.atime); lease_get_mtime(dentry->d_inode, &time); @@ -222,12 +220,10 @@ encode_saved_post_attr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) p = xdr_encode_hyper(p, ((u64)fhp->fh_post_blocks) << 9); *p++ = fhp->fh_post_rdev[0]; *p++ = fhp->fh_post_rdev[1]; - if (rqstp->rq_reffh->fh_version == 1 - && rqstp->rq_reffh->fh_fsid_type == 1 - && (fhp->fh_export->ex_flags & NFSEXP_FSID)) + if (is_fsid(fhp, rqstp->rq_reffh)) p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid); else - p = xdr_encode_hyper(p, (u64) inode->i_sb->s_dev); + p = xdr_encode_hyper(p, (u64)old_encode_dev(inode->i_sb->s_dev)); p = xdr_encode_hyper(p, (u64) inode->i_ino); p = encode_time3(p, &fhp->fh_post_atime); p = encode_time3(p, &fhp->fh_post_mtime); diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 32a50f1bed11..9d16338bad4b 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -125,6 +125,9 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) case 1: len = 1; break; + case 2: + len = 3; + break; default: goto out; } @@ -137,7 +140,7 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) if (fh->fh_size != NFS_FHSIZE) goto out; /* assume old filehandle format */ - xdev = u32_to_dev_t(fh->ofh_xdev); + xdev = old_decode_dev(fh->ofh_xdev); xino = u32_to_ino_t(fh->ofh_xino); mk_fsid_v0(tfh, xdev, xino); exp = exp_find(rqstp->rq_client, 0, tfh, &rqstp->rq_chandle); @@ -329,12 +332,21 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, st parent->d_name.name, dentry->d_name.name, (inode ? inode->i_ino : 0)); - if (ref_fh) { + /* for large devnums rules are simple */ + if (!old_valid_dev(ex_dev)) { + ref_fh_version = 1; + if (exp->ex_flags & NFSEXP_FSID) + ref_fh_fsid_type = 1; + else + ref_fh_fsid_type = 2; + } else if (ref_fh) { ref_fh_version = ref_fh->fh_handle.fh_version; ref_fh_fsid_type = ref_fh->fh_handle.fh_fsid_type; - if (ref_fh == fhp) - fh_put(ref_fh); + if (!(exp->ex_flags & NFSEXP_FSID) || ref_fh_fsid_type == 2) + ref_fh_fsid_type = 0; } + if (ref_fh == fhp) + fh_put(ref_fh); if (fhp->fh_locked || fhp->fh_dentry) { printk(KERN_ERR "fh_compose: fh %s/%s not initialized!\n", @@ -353,7 +365,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, st memset(&fhp->fh_handle.fh_base, 0, NFS_FHSIZE); fhp->fh_handle.fh_size = NFS_FHSIZE; fhp->fh_handle.ofh_dcookie = 0xfeebbaca; - fhp->fh_handle.ofh_dev = htonl((MAJOR(ex_dev)<<16)| MINOR(ex_dev)); + fhp->fh_handle.ofh_dev = old_encode_dev(ex_dev); fhp->fh_handle.ofh_xdev = fhp->fh_handle.ofh_dev; fhp->fh_handle.ofh_xino = ino_t_to_u32(exp->ex_dentry->d_inode->i_ino); fhp->fh_handle.ofh_dirino = ino_t_to_u32(parent_ino(dentry)); @@ -363,19 +375,33 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, st fhp->fh_handle.fh_version = 1; fhp->fh_handle.fh_auth_type = 0; datap = fhp->fh_handle.fh_auth+0; - if ((exp->ex_flags & NFSEXP_FSID) && - (ref_fh_fsid_type == 1)) { - fhp->fh_handle.fh_fsid_type = 1; - /* fsid_type 1 == 4 bytes filesystem id */ - mk_fsid_v1(datap, exp->ex_fsid); - datap += 1; - fhp->fh_handle.fh_size = 2*4; - } else { - fhp->fh_handle.fh_fsid_type = 0; - /* fsid_type 0 == 2byte major, 2byte minor, 4byte inode */ - mk_fsid_v0(datap, ex_dev, exp->ex_dentry->d_inode->i_ino); - datap += 2; - fhp->fh_handle.fh_size = 3*4; + fhp->fh_handle.fh_fsid_type = ref_fh_fsid_type; + switch (ref_fh_fsid_type) { + case 1: + /* fsid_type 1 == 4 bytes filesystem id */ + mk_fsid_v1(datap, exp->ex_fsid); + datap += 1; + fhp->fh_handle.fh_size = 2*4; + break; + case 2: + /* + * fsid_type 2: + * 4byte major, 4byte minor, 4byte inode + */ + mk_fsid_v2(datap, ex_dev, + exp->ex_dentry->d_inode->i_ino); + datap += 3; + fhp->fh_handle.fh_size = 4*4; + break; + default: + /* + * fsid_type 0: + * 2byte major, 2byte minor, 4byte inode + */ + mk_fsid_v0(datap, ex_dev, + exp->ex_dentry->d_inode->i_ino); + datap += 2; + fhp->fh_handle.fh_size = 3*4; } if (inode) { int size = fhp->fh_maxsize/4 - 3; diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index c64ebaf8818e..b72c5232d3fd 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -184,7 +184,7 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp, struct inode *inode; struct dentry *dchild; int nfserr, type, mode; - dev_t rdev = 0; + dev_t rdev = 0, wanted = old_decode_dev(attr->ia_size); dprintk("nfsd: CREATE %s %.*s\n", SVCFH_fmt(dirfhp), argp->len, argp->name); @@ -230,7 +230,7 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp, inode = newfhp->fh_dentry->d_inode; /* Unfudge the mode bits */ - if (attr->ia_valid & ATTR_MODE) { + if (attr->ia_valid & ATTR_MODE) { type = attr->ia_mode & S_IFMT; mode = attr->ia_mode & ~S_IFMT; if (!type) { @@ -242,7 +242,7 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp, case S_IFCHR: case S_IFBLK: /* reserve rdev for later checking */ - attr->ia_size = inode->i_rdev; + rdev = inode->i_rdev; attr->ia_valid |= ATTR_SIZE; /* FALLTHROUGH */ @@ -277,22 +277,21 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp, */ if (type != S_IFREG) { int is_borc = 0; - u32 size = attr->ia_size; - - /* may need to change when we widen dev_t */ - rdev = old_decode_dev(size); if (type != S_IFBLK && type != S_IFCHR) { rdev = 0; } else if (type == S_IFCHR && !(attr->ia_valid & ATTR_SIZE)) { /* If you think you've seen the worst, grok this. */ type = S_IFIFO; - } else if (size != rdev) { + } else if (!rdev && attr->ia_size != old_encode_dev(wanted)) { /* dev got truncated because of 16bit Linux dev_t */ + /* may need to change when we widen dev_t */ nfserr = nfserr_inval; goto out_unlock; } else { /* Okay, char or block special */ is_borc = 1; + if (!rdev) + rdev = wanted; } /* we've used the SIZE information, so discard it */ @@ -300,11 +299,10 @@ nfsd_proc_create(struct svc_rqst *rqstp, struct nfsd_createargs *argp, /* Make sure the type and device matches */ nfserr = nfserr_exist; - if (inode && (type != (inode->i_mode & S_IFMT) || - (is_borc && inode->i_rdev != rdev))) + if (inode && type != (inode->i_mode & S_IFMT)) goto out_unlock; } - + nfserr = 0; if (!inode) { /* File doesn't exist. Create it and set attrs */ diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index aa6b481595ea..37bafa6f1eec 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -159,16 +159,14 @@ encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) } *p++ = htonl((u32) stat.blksize); if (S_ISCHR(type) || S_ISBLK(type)) - *p++ = htonl((u32) stat.rdev); + *p++ = htonl((u32) old_encode_dev(stat.rdev)); else *p++ = htonl(0xffffffff); *p++ = htonl((u32) stat.blocks); - if (rqstp->rq_reffh->fh_version == 1 - && rqstp->rq_reffh->fh_fsid_type == 1 - && (fhp->fh_export->ex_flags & NFSEXP_FSID)) + if (is_fsid(fhp, rqstp->rq_reffh)) *p++ = htonl((u32) fhp->fh_export->ex_fsid); else - *p++ = htonl((u32) stat.dev); + *p++ = htonl((u32) old_encode_dev(stat.dev)); *p++ = htonl((u32) stat.ino); *p++ = htonl((u32) stat.atime.tv_sec); *p++ = htonl(stat.atime.tv_nsec ? stat.atime.tv_nsec / 1000 : 0); diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h index 74272d6a562e..204294616cf1 100644 --- a/include/linux/nfsd/export.h +++ b/include/linux/nfsd/export.h @@ -65,7 +65,7 @@ struct svc_expkey { struct auth_domain * ek_client; int ek_fsidtype; - u32 ek_fsid[2]; + u32 ek_fsid[3]; struct svc_export * ek_export; }; diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h index 8c4fb5cfff21..97a57608a6e6 100644 --- a/include/linux/nfsd/nfsd.h +++ b/include/linux/nfsd/nfsd.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -209,6 +210,17 @@ void nfsd_lockd_shutdown(void); */ extern struct timeval nfssvc_boot; +static inline int is_fsid(struct svc_fh *fh, struct knfsd_fh *reffh) +{ + if (fh->fh_export->ex_flags & NFSEXP_FSID) { + struct vfsmount *mnt = fh->fh_export->ex_mnt; + if (!old_valid_dev(mnt->mnt_sb->s_dev) || + (reffh->fh_version == 1 && reffh->fh_fsid_type == 1)) + return 1; + } + return 0; +} + #ifdef CONFIG_NFSD_V4 diff --git a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h index d4d63cc8e5fa..555793d69ddc 100644 --- a/include/linux/nfsd/nfsfh.h +++ b/include/linux/nfsd/nfsfh.h @@ -117,26 +117,6 @@ struct knfsd_fh { #ifdef __KERNEL__ -/* - * Conversion macros for the filehandle fields. - * - * Keep the device numbers in "backwards compatible - * format", ie the low 16 bits contain the low 8 bits - * of the 20-bit minor and the 12-bit major number. - * - * The high 16 bits contain the rest (4 bits major - * and 12 bits minor), - */ - -static inline dev_t u32_to_dev_t(__u32 udev) -{ - unsigned int minor, major; - - minor = (udev & 0xff) | ((udev >> 8) & 0xfff00); - major = ((udev >> 8) & 0xff) | ((udev >> 20) & 0xf00); - return MKDEV(major, minor); -} - static inline __u32 ino_t_to_u32(ino_t ino) { return (__u32) ino; @@ -196,6 +176,12 @@ static inline void mk_fsid_v1(u32 *fsidv, u32 fsid) fsidv[0] = fsid; } +static inline void mk_fsid_v2(u32 *fsidv, dev_t dev, ino_t ino) +{ + fsidv[0] = htonl(MAJOR(dev)); + fsidv[1] = htonl(MINOR(dev)); + fsidv[2] = ino_t_to_u32(ino); +} /* * Shorthand for dprintk()'s -- cgit v1.2.3 From 18d0c6d3ba8df654d99677ab070037d6c0d9c055 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Mon, 22 Sep 2003 22:52:09 -0700 Subject: [PATCH] prepare for 32-bit dev_t: stat() Added old_encode_dev() to assorted stat() variants. Fixed bug in s390 emulation on s390x: stat64() should never truncate UID and GID. Ditto for i386 emulation on x86_64. Replaced dev_t in various struct stat with explicit integer type. Replaced __kernel_dev_t with __old_kernel_dev_t in dm-ioctl-v1.h Now we are free to change dev_t in any way we want - on all boundaries we have explicit conversions. Took __kernel_dev_t definition to linux/types.h and changed it with __u16. We are ready to proceed to 32bit now. --- arch/ia64/ia32/sys_ia32.c | 8 +-- arch/mips/kernel/linux32.c | 4 +- arch/parisc/hpux/fs.c | 4 +- arch/parisc/kernel/sys_parisc32.c | 4 +- arch/ppc64/kernel/sys_ppc32.c | 4 +- arch/s390/kernel/compat_linux.c | 116 +++++++++++++------------------------- arch/sparc64/kernel/sys_sparc32.c | 4 +- arch/x86_64/ia32/sys_ia32.c | 92 +++++++++++------------------- fs/stat.c | 12 ++-- include/asm-alpha/posix_types.h | 1 - include/asm-arm/posix_types.h | 1 - include/asm-arm26/posix_types.h | 1 - include/asm-cris/posix_types.h | 1 - include/asm-h8300/posix_types.h | 1 - include/asm-i386/posix_types.h | 1 - include/asm-ia64/posix_types.h | 1 - include/asm-m68k/posix_types.h | 1 - include/asm-mips/posix_types.h | 1 - include/asm-mips/stat.h | 8 +-- include/asm-parisc/posix_types.h | 1 - include/asm-parisc/stat.h | 16 +++--- include/asm-ppc/posix_types.h | 1 - include/asm-ppc/stat.h | 4 +- include/asm-ppc64/posix_types.h | 1 - include/asm-ppc64/stat.h | 4 +- include/asm-s390/posix_types.h | 2 - include/asm-sh/posix_types.h | 1 - include/asm-sparc/posix_types.h | 1 - include/asm-sparc64/posix_types.h | 1 - include/asm-sparc64/stat.h | 4 +- include/asm-v850/posix_types.h | 1 - include/asm-x86_64/posix_types.h | 1 - include/linux/dm-ioctl-v1.h | 4 +- include/linux/types.h | 2 + 34 files changed, 112 insertions(+), 197 deletions(-) (limited to 'include/linux') diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c index d4931dc98dbd..074d2056522b 100644 --- a/arch/ia64/ia32/sys_ia32.c +++ b/arch/ia64/ia32/sys_ia32.c @@ -186,13 +186,13 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat *ubuf) if (clear_user(ubuf, sizeof(*ubuf))) return -EFAULT; - err = __put_user(stat->dev, &ubuf->st_dev); + err = __put_user(old_encode_dev(stat->dev), &ubuf->st_dev); err |= __put_user(stat->ino, &ubuf->st_ino); err |= __put_user(stat->mode, &ubuf->st_mode); err |= __put_user(stat->nlink, &ubuf->st_nlink); err |= __put_user(high2lowuid(stat->uid), &ubuf->st_uid); err |= __put_user(high2lowgid(stat->gid), &ubuf->st_gid); - err |= __put_user(stat->rdev, &ubuf->st_rdev); + err |= __put_user(old_encode_dev(stat->rdev), &ubuf->st_rdev); err |= __put_user(stat->size, &ubuf->st_size); err |= __put_user(stat->atime.tv_sec, &ubuf->st_atime); err |= __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec); @@ -2488,7 +2488,7 @@ putstat64 (struct stat64 *ubuf, struct kstat *kbuf) if (clear_user(ubuf, sizeof(*ubuf))) return -EFAULT; - err = __put_user(kbuf->dev, &ubuf->st_dev); + err = __put_user(old_encode_dev(kbuf->dev), &ubuf->st_dev); err |= __put_user(kbuf->ino, &ubuf->__st_ino); err |= __put_user(kbuf->ino, &ubuf->st_ino_lo); err |= __put_user(kbuf->ino >> 32, &ubuf->st_ino_hi); @@ -2496,7 +2496,7 @@ putstat64 (struct stat64 *ubuf, struct kstat *kbuf) err |= __put_user(kbuf->nlink, &ubuf->st_nlink); err |= __put_user(kbuf->uid, &ubuf->st_uid); err |= __put_user(kbuf->gid, &ubuf->st_gid); - err |= __put_user(kbuf->rdev, &ubuf->st_rdev); + err |= __put_user(old_encode_dev(kbuf->rdev), &ubuf->st_rdev); err |= __put_user(kbuf->size, &ubuf->st_size_lo); err |= __put_user((kbuf->size >> 32), &ubuf->st_size_hi); err |= __put_user(kbuf->atime.tv_sec, &ubuf->st_atime); diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c index 71cd8d6f62e3..2bf7a6606bf0 100644 --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c @@ -72,13 +72,13 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat *statbuf) struct compat_stat tmp; memset(&tmp, 0, sizeof(tmp)); - tmp.st_dev = stat->dev; + tmp.st_dev = old_encode_dev(stat->dev); tmp.st_ino = stat->ino; tmp.st_mode = stat->mode; tmp.st_nlink = stat->nlink; SET_STAT_UID(tmp, stat->uid); SET_STAT_GID(tmp, stat->gid); - tmp.st_rdev = stat->rdev; + tmp.st_rdev = old_encode_dev(stat->rdev); tmp.st_size = stat->size; tmp.st_atime = stat->atime.tv_sec; tmp.st_mtime = stat->mtime.tv_sec; diff --git a/arch/parisc/hpux/fs.c b/arch/parisc/hpux/fs.c index c22c789091e1..4c6d90523a20 100644 --- a/arch/parisc/hpux/fs.c +++ b/arch/parisc/hpux/fs.c @@ -124,13 +124,13 @@ static int cp_hpux_stat(struct kstat *stat, struct hpux_stat64 *statbuf) struct hpux_stat64 tmp; memset(&tmp, 0, sizeof(tmp)); - tmp.st_dev = stat->dev; + tmp.st_dev = old_encode_dev(stat->dev); tmp.st_ino = stat->ino; tmp.st_mode = stat->mode; tmp.st_nlink = stat->nlink; tmp.st_uid = stat->uid; tmp.st_gid = stat->gid; - tmp.st_rdev = stat->rdev; + tmp.st_rdev = old_encode_dev(stat->rdev); tmp.st_size = stat->size; tmp.st_atime = stat->atime.tv_sec; tmp.st_mtime = stat->mtime.tv_sec; diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c index f251f86c86ec..ecee05505944 100644 --- a/arch/parisc/kernel/sys_parisc32.c +++ b/arch/parisc/kernel/sys_parisc32.c @@ -442,13 +442,13 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat *statbuf) if (stat->size > MAX_NON_LFS) return -EOVERFLOW; - err = put_user(stat->dev, &statbuf->st_dev); + err = put_user(old_encode_dev(stat->dev), &statbuf->st_dev); err |= put_user(stat->ino, &statbuf->st_ino); err |= put_user(stat->mode, &statbuf->st_mode); err |= put_user(stat->nlink, &statbuf->st_nlink); err |= put_user(0, &statbuf->st_reserved1); err |= put_user(0, &statbuf->st_reserved2); - err |= put_user(stat->rdev, &statbuf->st_rdev); + err |= put_user(old_encode_dev(stat->rdev), &statbuf->st_rdev); err |= put_user(stat->size, &statbuf->st_size); err |= put_user(stat->atime.tv_sec, &statbuf->st_atime); err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec); diff --git a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c index eb233031bbb6..cb05a6b38497 100644 --- a/arch/ppc64/kernel/sys_ppc32.c +++ b/arch/ppc64/kernel/sys_ppc32.c @@ -751,13 +751,13 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat *statbuf) if (stat->size > MAX_NON_LFS) return -EOVERFLOW; - err = put_user(stat->dev, &statbuf->st_dev); + err = put_user(old_encode_dev(stat->dev), &statbuf->st_dev); err |= put_user(stat->ino, &statbuf->st_ino); err |= put_user(stat->mode, &statbuf->st_mode); err |= put_user(stat->nlink, &statbuf->st_nlink); err |= put_user(stat->uid, &statbuf->st_uid); err |= put_user(stat->gid, &statbuf->st_gid); - err |= put_user(stat->rdev, &statbuf->st_rdev); + err |= put_user(old_encode_dev(stat->rdev), &statbuf->st_rdev); err |= put_user(stat->size, &statbuf->st_size); err |= put_user(stat->atime.tv_sec, &statbuf->st_atime); err |= put_user(0, &statbuf->__unused1); diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c index 8c701ecb92e4..4e41cbebf8b8 100644 --- a/arch/s390/kernel/compat_linux.c +++ b/arch/s390/kernel/compat_linux.c @@ -1316,13 +1316,13 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat *statbuf) { int err; - err = put_user(stat->dev, &statbuf->st_dev); + err = put_user(old_encode_dev(stat->dev), &statbuf->st_dev); err |= put_user(stat->ino, &statbuf->st_ino); err |= put_user(stat->mode, &statbuf->st_mode); err |= put_user(stat->nlink, &statbuf->st_nlink); err |= put_user(high2lowuid(stat->uid), &statbuf->st_uid); err |= put_user(high2lowgid(stat->gid), &statbuf->st_gid); - err |= put_user(stat->rdev, &statbuf->st_rdev); + err |= put_user(old_encode_dev(stat->rdev), &statbuf->st_rdev); err |= put_user(stat->size, &statbuf->st_size); err |= put_user(stat->atime.tv_sec, &statbuf->st_atime); err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec); @@ -2543,8 +2543,7 @@ extern asmlinkage long sys32_sysctl(struct __sysctl_args32 *args) } struct stat64_emu31 { - unsigned char __pad0[6]; - unsigned short st_dev; + unsigned long long st_dev; unsigned int __pad1; #define STAT64_HAS_BROKEN_ST_INO 1 u32 __st_ino; @@ -2552,8 +2551,7 @@ struct stat64_emu31 { unsigned int st_nlink; u32 st_uid; u32 st_gid; - unsigned char __pad2[6]; - unsigned short st_rdev; + unsigned long long st_rdev; unsigned int __pad3; long st_size; u32 st_blksize; @@ -2569,93 +2567,55 @@ struct stat64_emu31 { unsigned long st_ino; }; -static inline int -putstat64 (struct stat64_emu31 *ubuf, struct stat *kbuf) +static int cp_stat64(struct stat64_emu31 *ubuf, struct kstat *stat) { - struct stat64_emu31 tmp; - - memset(&tmp, 0, sizeof(tmp)); + struct stat64_emu31 tmp; - tmp.st_dev = (unsigned short)kbuf->st_dev; - tmp.st_ino = kbuf->st_ino; - tmp.__st_ino = (u32)kbuf->st_ino; - tmp.st_mode = kbuf->st_mode; - tmp.st_nlink = (unsigned int)kbuf->st_nlink; - tmp.st_uid = kbuf->st_uid; - tmp.st_gid = kbuf->st_gid; - tmp.st_rdev = (unsigned short)kbuf->st_rdev; - tmp.st_size = kbuf->st_size; - tmp.st_blksize = (u32)kbuf->st_blksize; - tmp.st_blocks = (u32)kbuf->st_blocks; - tmp.st_atime = (u32)kbuf->st_atime; - tmp.st_mtime = (u32)kbuf->st_mtime; - tmp.st_ctime = (u32)kbuf->st_ctime; + memset(&tmp, 0, sizeof(tmp)); - return copy_to_user(ubuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; -} + tmp.st_dev = old_encode_dev(stat->dev); + tmp.st_ino = stat->ino; + tmp.__st_ino = (u32)stat->ino; + tmp.st_mode = stat->mode; + tmp.st_nlink = (unsigned int)stat->nlink; + tmp.uid = stat->uid; + tmp.gid = stat->gid; + tmp.st_rdev = old_encode_dev(stat->rdev); + tmp.st_size = stat->st_size; + tmp.st_blksize = (u32)stat->blksize; + tmp.st_blocks = (u32)stat->blocks; + tmp.st_atime = (u32)stat->atime.tv_sec; + tmp.st_mtime = (u32)stat->mtime.tv_sec; + tmp.st_ctime = (u32)stat->ctime.tv_sec; -extern asmlinkage long sys_newstat(char * filename, struct stat * statbuf); + return copy_to_user(ubuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; +} asmlinkage long sys32_stat64(char * filename, struct stat64_emu31 * statbuf, long flags) { - int ret; - struct stat s; - char * tmp; - int err; - mm_segment_t old_fs = get_fs(); - - tmp = getname(filename); - err = PTR_ERR(tmp); - if (IS_ERR(tmp)) - return err; - - set_fs (KERNEL_DS); - ret = sys_newstat(tmp, &s); - set_fs (old_fs); - putname(tmp); - if (putstat64 (statbuf, &s)) - return -EFAULT; - return ret; + struct kstat stat; + int ret = vfs_stat(filename, &stat); + if (!ret) + ret = cp_stat64(statbuf, &stat); + return ret; } -extern asmlinkage long sys_newlstat(char * filename, struct stat * statbuf); - asmlinkage long sys32_lstat64(char * filename, struct stat64_emu31 * statbuf, long flags) { - int ret; - struct stat s; - char * tmp; - int err; - mm_segment_t old_fs = get_fs(); - - tmp = getname(filename); - err = PTR_ERR(tmp); - if (IS_ERR(tmp)) - return err; - - set_fs (KERNEL_DS); - ret = sys_newlstat(tmp, &s); - set_fs (old_fs); - putname(tmp); - if (putstat64 (statbuf, &s)) - return -EFAULT; - return ret; + struct kstat stat; + int ret = vfs_lstat(filename, &stat); + if (!ret) + ret = cp_stat64(statbuf, &stat); + return ret; } -extern asmlinkage long sys_newfstat(unsigned int fd, struct stat * statbuf); - asmlinkage long sys32_fstat64(unsigned long fd, struct stat64_emu31 * statbuf, long flags) { - int ret; - struct stat s; - mm_segment_t old_fs = get_fs(); - - set_fs (KERNEL_DS); - ret = sys_newfstat(fd, &s); - set_fs (old_fs); - if (putstat64 (statbuf, &s)) - return -EFAULT; - return ret; + struct kstat stat; + int ret = vfs_fstat(fd, &stat); + if (!ret) + ret = cp_stat64(statbuf, &stat); + return ret; } /* diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c index fe64eda04546..1bebed9e4265 100644 --- a/arch/sparc64/kernel/sys_sparc32.c +++ b/arch/sparc64/kernel/sys_sparc32.c @@ -1307,13 +1307,13 @@ int cp_compat_stat(struct kstat *stat, struct compat_stat *statbuf) if (stat->size > MAX_NON_LFS) return -EOVERFLOW; - err = put_user(stat->dev, &statbuf->st_dev); + err = put_user(old_encode_dev(stat->dev), &statbuf->st_dev); err |= put_user(stat->ino, &statbuf->st_ino); err |= put_user(stat->mode, &statbuf->st_mode); err |= put_user(stat->nlink, &statbuf->st_nlink); err |= put_user(high2lowuid(stat->uid), &statbuf->st_uid); err |= put_user(high2lowgid(stat->gid), &statbuf->st_gid); - err |= put_user(stat->rdev, &statbuf->st_rdev); + err |= put_user(old_encode_dev(stat->rdev), &statbuf->st_rdev); err |= put_user(stat->size, &statbuf->st_size); err |= put_user(stat->atime.tv_sec, &statbuf->st_atime); err |= put_user(0, &statbuf->__unused1); diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c index f28b2ebcf90a..f27648237908 100644 --- a/arch/x86_64/ia32/sys_ia32.c +++ b/arch/x86_64/ia32/sys_ia32.c @@ -89,27 +89,16 @@ #define low2highgid(gid) ((gid) == (u16)-1) ? (gid_t)-1 : (gid_t)(gid) extern int overflowuid,overflowgid; - -extern asmlinkage long sys_newstat(char * filename, struct stat * statbuf); -extern asmlinkage long sys_newlstat(char * filename, struct stat * statbuf); -extern asmlinkage long sys_newfstat(unsigned int fd, struct stat * statbuf); - - -extern asmlinkage long sys_newstat(char * filename, struct stat * statbuf); -extern asmlinkage long sys_newlstat(char * filename, struct stat * statbuf); -extern asmlinkage long sys_newfstat(unsigned int fd, struct stat * statbuf); - - int cp_compat_stat(struct kstat *kbuf, struct compat_stat *ubuf) { if (verify_area(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) || - __put_user (kbuf->dev, &ubuf->st_dev) || + __put_user (old_encode_dev(kbuf->dev), &ubuf->st_dev) || __put_user (kbuf->ino, &ubuf->st_ino) || __put_user (kbuf->mode, &ubuf->st_mode) || __put_user (kbuf->nlink, &ubuf->st_nlink) || __put_user (kbuf->uid, &ubuf->st_uid) || __put_user (kbuf->gid, &ubuf->st_gid) || - __put_user (kbuf->rdev, &ubuf->st_rdev) || + __put_user (old_encode_dev(kbuf->rdev), &ubuf->st_rdev) || __put_user (kbuf->size, &ubuf->st_size) || __put_user (kbuf->atime.tv_sec, &ubuf->st_atime) || __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) || @@ -127,26 +116,26 @@ int cp_compat_stat(struct kstat *kbuf, struct compat_stat *ubuf) support for 64bit inode numbers. */ static int -putstat64(struct stat64 *ubuf, struct stat *kbuf) +cp_stat64(struct stat64 *ubuf, struct kstat *stat) { if (verify_area(VERIFY_WRITE, ubuf, sizeof(struct stat64)) || - __put_user (kbuf->st_dev, &ubuf->st_dev) || - __put_user (kbuf->st_ino, &ubuf->__st_ino) || - __put_user (kbuf->st_ino, &ubuf->st_ino) || - __put_user (kbuf->st_mode, &ubuf->st_mode) || - __put_user (kbuf->st_nlink, &ubuf->st_nlink) || - __put_user (kbuf->st_uid, &ubuf->st_uid) || - __put_user (kbuf->st_gid, &ubuf->st_gid) || - __put_user (kbuf->st_rdev, &ubuf->st_rdev) || - __put_user (kbuf->st_size, &ubuf->st_size) || - __put_user (kbuf->st_atime, &ubuf->st_atime) || - __put_user (kbuf->st_atime_nsec, &ubuf->st_atime_nsec) || - __put_user (kbuf->st_mtime, &ubuf->st_mtime) || - __put_user (kbuf->st_mtime_nsec, &ubuf->st_mtime_nsec) || - __put_user (kbuf->st_ctime, &ubuf->st_ctime) || - __put_user (kbuf->st_ctime_nsec, &ubuf->st_ctime_nsec) || - __put_user (kbuf->st_blksize, &ubuf->st_blksize) || - __put_user (kbuf->st_blocks, &ubuf->st_blocks)) + __put_user(old_encode_dev(stat->dev), &ubuf->st_dev) || + __put_user (stat->ino, &ubuf->__st_ino) || + __put_user (stat->ino, &ubuf->st_ino) || + __put_user (stat->mode, &ubuf->st_mode) || + __put_user (stat->nlink, &ubuf->st_nlink) || + __put_user (stat->uid, &ubuf->st_uid) || + __put_user (stat->gid, &ubuf->st_gid) || + __put_user (old_encode_dev(stat->rdev), &ubuf->st_rdev) || + __put_user (stat->size, &ubuf->st_size) || + __put_user (stat->atime.tv_sec, &ubuf->st_atime) || + __put_user (stat->atime.tv_nsec, &ubuf->st_atime_nsec) || + __put_user (stat->mtime.tv_sec, &ubuf->st_mtime) || + __put_user (stat->mtime.tv_nsec, &ubuf->st_mtime_nsec) || + __put_user (stat->ctime.tv_sec, &ubuf->st_ctime) || + __put_user (stat->ctime.tv_nsec, &ubuf->st_ctime_nsec) || + __put_user (stat->blksize, &ubuf->st_blksize) || + __put_user (stat->blocks, &ubuf->st_blocks)) return -EFAULT; return 0; } @@ -154,50 +143,33 @@ putstat64(struct stat64 *ubuf, struct stat *kbuf) asmlinkage long sys32_stat64(char * filename, struct stat64 *statbuf) { - int ret; - struct stat s; - mm_segment_t old_fs = get_fs(); - - set_fs (KERNEL_DS); - ret = sys_newstat(filename, &s); - set_fs (old_fs); - if (putstat64 (statbuf, &s)) - return -EFAULT; + struct kstat stat; + int ret = vfs_stat(filename, &stat); + if (!ret) + ret = cp_stat64(statbuf, &stat); return ret; } asmlinkage long sys32_lstat64(char * filename, struct stat64 *statbuf) { - int ret; - struct stat s; - mm_segment_t old_fs = get_fs(); - - set_fs (KERNEL_DS); - ret = sys_newlstat(filename, &s); - set_fs (old_fs); - if (putstat64 (statbuf, &s)) - return -EFAULT; + struct kstat stat; + int ret = vfs_lstat(filename, &stat); + if (!ret) + ret = cp_stat64(statbuf, &stat); return ret; } asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 *statbuf) { - int ret; - struct stat s; - mm_segment_t old_fs = get_fs(); - - set_fs (KERNEL_DS); - ret = sys_newfstat(fd, &s); - set_fs (old_fs); - if (putstat64 (statbuf, &s)) - return -EFAULT; + struct kstat stat; + int ret = vfs_fstat(fd, &stat); + if (!ret) + ret = cp_stat64(statbuf, &stat); return ret; } - - /* * Linux/i386 didn't use to be able to handle more than * 4 system call parameters, so these system calls used a memory diff --git a/fs/stat.c b/fs/stat.c index a1f3d7d874fa..e5deeb33741c 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -117,13 +117,13 @@ static int cp_old_stat(struct kstat *stat, struct __old_kernel_stat __user * sta } memset(&tmp, 0, sizeof(struct __old_kernel_stat)); - tmp.st_dev = stat->dev; + tmp.st_dev = old_encode_dev(stat->dev); tmp.st_ino = stat->ino; tmp.st_mode = stat->mode; tmp.st_nlink = stat->nlink; SET_OLDSTAT_UID(tmp, stat->uid); SET_OLDSTAT_GID(tmp, stat->gid); - tmp.st_rdev = stat->rdev; + tmp.st_rdev = old_encode_dev(stat->rdev); #if BITS_PER_LONG == 32 if (stat->size > MAX_NON_LFS) return -EOVERFLOW; @@ -173,13 +173,13 @@ static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf) struct stat tmp; memset(&tmp, 0, sizeof(tmp)); - tmp.st_dev = stat->dev; + tmp.st_dev = old_encode_dev(stat->dev); tmp.st_ino = stat->ino; tmp.st_mode = stat->mode; tmp.st_nlink = stat->nlink; SET_STAT_UID(tmp, stat->uid); SET_STAT_GID(tmp, stat->gid); - tmp.st_rdev = stat->rdev; + tmp.st_rdev = old_encode_dev(stat->rdev); #if BITS_PER_LONG == 32 if (stat->size > MAX_NON_LFS) return -EOVERFLOW; @@ -263,7 +263,7 @@ static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf) struct stat64 tmp; memset(&tmp, 0, sizeof(struct stat64)); - tmp.st_dev = stat->dev; + tmp.st_dev = old_encode_dev(stat->dev); tmp.st_ino = stat->ino; #ifdef STAT64_HAS_BROKEN_ST_INO tmp.__st_ino = stat->ino; @@ -272,7 +272,7 @@ static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf) tmp.st_nlink = stat->nlink; tmp.st_uid = stat->uid; tmp.st_gid = stat->gid; - tmp.st_rdev = stat->rdev; + tmp.st_rdev = old_encode_dev(stat->rdev); tmp.st_atime = stat->atime.tv_sec; tmp.st_atime_nsec = stat->atime.tv_nsec; tmp.st_mtime = stat->mtime.tv_sec; diff --git a/include/asm-alpha/posix_types.h b/include/asm-alpha/posix_types.h index 9c613d79189d..c78c04a94f4e 100644 --- a/include/asm-alpha/posix_types.h +++ b/include/asm-alpha/posix_types.h @@ -7,7 +7,6 @@ * assume GCC is being used. */ -typedef unsigned int __kernel_dev_t; typedef unsigned int __kernel_ino_t; typedef unsigned int __kernel_mode_t; typedef unsigned int __kernel_nlink_t; diff --git a/include/asm-arm/posix_types.h b/include/asm-arm/posix_types.h index 23ad09424723..cdf4b69149f0 100644 --- a/include/asm-arm/posix_types.h +++ b/include/asm-arm/posix_types.h @@ -19,7 +19,6 @@ * assume GCC is being used. */ -typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; diff --git a/include/asm-arm26/posix_types.h b/include/asm-arm26/posix_types.h index 9aeff7c2cb98..94ef6edce3e2 100644 --- a/include/asm-arm26/posix_types.h +++ b/include/asm-arm26/posix_types.h @@ -19,7 +19,6 @@ * assume GCC is being used. */ -typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; diff --git a/include/asm-cris/posix_types.h b/include/asm-cris/posix_types.h index d1c87c652619..6d26fee4a614 100644 --- a/include/asm-cris/posix_types.h +++ b/include/asm-cris/posix_types.h @@ -14,7 +14,6 @@ * assume GCC is being used. */ -typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; diff --git a/include/asm-h8300/posix_types.h b/include/asm-h8300/posix_types.h index 77c22770a5ba..7de94b1fd0e5 100644 --- a/include/asm-h8300/posix_types.h +++ b/include/asm-h8300/posix_types.h @@ -7,7 +7,6 @@ * assume GCC is being used. */ -typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; diff --git a/include/asm-i386/posix_types.h b/include/asm-i386/posix_types.h index d391865fd502..4e47ed059ad6 100644 --- a/include/asm-i386/posix_types.h +++ b/include/asm-i386/posix_types.h @@ -7,7 +7,6 @@ * assume GCC is being used. */ -typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; diff --git a/include/asm-ia64/posix_types.h b/include/asm-ia64/posix_types.h index 50db61f18469..59a50b0e4e38 100644 --- a/include/asm-ia64/posix_types.h +++ b/include/asm-ia64/posix_types.h @@ -10,7 +10,6 @@ * David Mosberger-Tang */ -typedef unsigned int __kernel_dev_t; typedef unsigned int __kernel_ino_t; typedef unsigned int __kernel_mode_t; typedef unsigned int __kernel_nlink_t; diff --git a/include/asm-m68k/posix_types.h b/include/asm-m68k/posix_types.h index d10b7bb9cb9e..fa166ee30286 100644 --- a/include/asm-m68k/posix_types.h +++ b/include/asm-m68k/posix_types.h @@ -7,7 +7,6 @@ * assume GCC is being used. */ -typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; diff --git a/include/asm-mips/posix_types.h b/include/asm-mips/posix_types.h index 8fce1f864ce4..9ec09821c5fd 100644 --- a/include/asm-mips/posix_types.h +++ b/include/asm-mips/posix_types.h @@ -17,7 +17,6 @@ * assume GCC is being used. */ -typedef unsigned int __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned int __kernel_mode_t; #if (_MIPS_SZLONG == 32) diff --git a/include/asm-mips/stat.h b/include/asm-mips/stat.h index 53ce689129a0..6e00f751ab6d 100644 --- a/include/asm-mips/stat.h +++ b/include/asm-mips/stat.h @@ -16,14 +16,14 @@ #if (_MIPS_SIM == _MIPS_SIM_ABI32) || (_MIPS_SIM == _MIPS_SIM_NABI32) struct stat { - dev_t st_dev; + unsigned st_dev; long st_pad1[3]; /* Reserved for network id */ ino_t st_ino; mode_t st_mode; nlink_t st_nlink; uid_t st_uid; gid_t st_gid; - dev_t st_rdev; + unsigned st_rdev; long st_pad2[2]; off_t st_size; long st_pad3; @@ -90,7 +90,7 @@ struct stat64 { /* The memory layout is the same as of struct stat64 of the 32-bit kernel. */ struct stat { - dev_t st_dev; + unsigned int st_dev; unsigned int st_pad0[3]; /* Reserved for st_dev expansion */ unsigned long st_ino; @@ -101,7 +101,7 @@ struct stat { uid_t st_uid; gid_t st_gid; - dev_t st_rdev; + unsigned int st_rdev; unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */ off_t st_size; diff --git a/include/asm-parisc/posix_types.h b/include/asm-parisc/posix_types.h index 6d241ab7ed19..dc91ca54b78f 100644 --- a/include/asm-parisc/posix_types.h +++ b/include/asm-parisc/posix_types.h @@ -6,7 +6,6 @@ * be a little careful about namespace pollution etc. Also, we cannot * assume GCC is being used. */ -typedef unsigned int __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; diff --git a/include/asm-parisc/stat.h b/include/asm-parisc/stat.h index bfb286a02f3c..9d5fbbc5c31f 100644 --- a/include/asm-parisc/stat.h +++ b/include/asm-parisc/stat.h @@ -4,13 +4,13 @@ #include struct stat { - dev_t st_dev; /* dev_t is 32 bits on parisc */ + unsigned int st_dev; /* dev_t is 32 bits on parisc */ ino_t st_ino; /* 32 bits */ mode_t st_mode; /* 16 bits */ nlink_t st_nlink; /* 16 bits */ unsigned short st_reserved1; /* old st_uid */ unsigned short st_reserved2; /* old st_gid */ - dev_t st_rdev; + unsigned int st_rdev; off_t st_size; time_t st_atime; unsigned int st_atime_nsec; @@ -21,12 +21,12 @@ struct stat { int st_blksize; int st_blocks; unsigned int __unused1; /* ACL stuff */ - dev_t __unused2; /* network */ + unsigned int __unused2; /* network */ ino_t __unused3; /* network */ unsigned int __unused4; /* cnodes */ unsigned short __unused5; /* netsite */ short st_fstype; - dev_t st_realdev; + unsigned int st_realdev; unsigned short st_basemode; unsigned short st_spareshort; uid_t st_uid; @@ -39,13 +39,13 @@ struct stat { typedef __kernel_off64_t off64_t; struct hpux_stat64 { - dev_t st_dev; /* dev_t is 32 bits on parisc */ + unsigned int st_dev; /* dev_t is 32 bits on parisc */ ino_t st_ino; /* 32 bits */ mode_t st_mode; /* 16 bits */ nlink_t st_nlink; /* 16 bits */ unsigned short st_reserved1; /* old st_uid */ unsigned short st_reserved2; /* old st_gid */ - dev_t st_rdev; + unsigned int st_rdev; off64_t st_size; time_t st_atime; unsigned int st_spare1; @@ -56,12 +56,12 @@ struct hpux_stat64 { int st_blksize; __u64 st_blocks; unsigned int __unused1; /* ACL stuff */ - dev_t __unused2; /* network */ + unsigned int __unused2; /* network */ ino_t __unused3; /* network */ unsigned int __unused4; /* cnodes */ unsigned short __unused5; /* netsite */ short st_fstype; - dev_t st_realdev; + unsigned int st_realdev; unsigned short st_basemode; unsigned short st_spareshort; uid_t st_uid; diff --git a/include/asm-ppc/posix_types.h b/include/asm-ppc/posix_types.h index 537bee4d8eee..a14a82abe8d2 100644 --- a/include/asm-ppc/posix_types.h +++ b/include/asm-ppc/posix_types.h @@ -7,7 +7,6 @@ * assume GCC is being used. */ -typedef unsigned int __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned int __kernel_mode_t; typedef unsigned short __kernel_nlink_t; diff --git a/include/asm-ppc/stat.h b/include/asm-ppc/stat.h index 12b48c8cb880..cadb34298496 100644 --- a/include/asm-ppc/stat.h +++ b/include/asm-ppc/stat.h @@ -22,13 +22,13 @@ struct __old_kernel_stat { #define STAT_HAVE_NSEC 1 struct stat { - dev_t st_dev; + unsigned st_dev; ino_t st_ino; mode_t st_mode; nlink_t st_nlink; uid_t st_uid; gid_t st_gid; - dev_t st_rdev; + unsigned st_rdev; off_t st_size; unsigned long st_blksize; unsigned long st_blocks; diff --git a/include/asm-ppc64/posix_types.h b/include/asm-ppc64/posix_types.h index c3cff412a3eb..ff8ba3a73050 100644 --- a/include/asm-ppc64/posix_types.h +++ b/include/asm-ppc64/posix_types.h @@ -12,7 +12,6 @@ * 2 of the License, or (at your option) any later version. */ -typedef unsigned long __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned long __kernel_nlink_t; typedef unsigned int __kernel_mode_t; diff --git a/include/asm-ppc64/stat.h b/include/asm-ppc64/stat.h index 51625e24830c..973a5f97951d 100644 --- a/include/asm-ppc64/stat.h +++ b/include/asm-ppc64/stat.h @@ -11,13 +11,13 @@ #include struct stat { - dev_t st_dev; + unsigned long st_dev; ino_t st_ino; nlink_t st_nlink; mode_t st_mode; uid_t st_uid; gid_t st_gid; - dev_t st_rdev; + unsigned long st_rdev; off_t st_size; unsigned long st_blksize; unsigned long st_blocks; diff --git a/include/asm-s390/posix_types.h b/include/asm-s390/posix_types.h index 0d97ef9ee846..a6ac95dc9576 100644 --- a/include/asm-s390/posix_types.h +++ b/include/asm-s390/posix_types.h @@ -34,7 +34,6 @@ typedef long long __kernel_loff_t; #ifndef __s390x__ -typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; @@ -51,7 +50,6 @@ typedef unsigned short __kernel_old_dev_t; #else /* __s390x__ */ -typedef unsigned int __kernel_dev_t; typedef unsigned int __kernel_ino_t; typedef unsigned int __kernel_mode_t; typedef unsigned int __kernel_nlink_t; diff --git a/include/asm-sh/posix_types.h b/include/asm-sh/posix_types.h index 7d0cd1b36d67..0a3d2f54ab27 100644 --- a/include/asm-sh/posix_types.h +++ b/include/asm-sh/posix_types.h @@ -7,7 +7,6 @@ * assume GCC is being used. */ -typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; diff --git a/include/asm-sparc/posix_types.h b/include/asm-sparc/posix_types.h index b4731a3c12a4..9ef1b3db4cbf 100644 --- a/include/asm-sparc/posix_types.h +++ b/include/asm-sparc/posix_types.h @@ -17,7 +17,6 @@ typedef int __kernel_pid_t; typedef unsigned short __kernel_ipc_pid_t; typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; -typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_umode_t; diff --git a/include/asm-sparc64/posix_types.h b/include/asm-sparc64/posix_types.h index 9341bb220fd8..133444385364 100644 --- a/include/asm-sparc64/posix_types.h +++ b/include/asm-sparc64/posix_types.h @@ -16,7 +16,6 @@ typedef int __kernel_pid_t; typedef int __kernel_ipc_pid_t; typedef unsigned int __kernel_uid_t; typedef unsigned int __kernel_gid_t; -typedef unsigned int __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned int __kernel_mode_t; typedef unsigned short __kernel_umode_t; diff --git a/include/asm-sparc64/stat.h b/include/asm-sparc64/stat.h index fedc7885aa8f..48e06618a5a4 100644 --- a/include/asm-sparc64/stat.h +++ b/include/asm-sparc64/stat.h @@ -5,13 +5,13 @@ #include struct stat { - dev_t st_dev; + unsigned st_dev; ino_t st_ino; mode_t st_mode; short st_nlink; uid_t st_uid; gid_t st_gid; - dev_t st_rdev; + unsigned st_rdev; off_t st_size; time_t st_atime; time_t st_mtime; diff --git a/include/asm-v850/posix_types.h b/include/asm-v850/posix_types.h index 4f2f0d8eefea..865c87cadc2b 100644 --- a/include/asm-v850/posix_types.h +++ b/include/asm-v850/posix_types.h @@ -14,7 +14,6 @@ #ifndef __V850_POSIX_TYPES_H__ #define __V850_POSIX_TYPES_H__ -typedef unsigned int __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned long long __kernel_ino64_t; typedef unsigned int __kernel_mode_t; diff --git a/include/asm-x86_64/posix_types.h b/include/asm-x86_64/posix_types.h index 33a1dccf45da..b28ed4955fa3 100644 --- a/include/asm-x86_64/posix_types.h +++ b/include/asm-x86_64/posix_types.h @@ -7,7 +7,6 @@ * assume GCC is being used. */ -typedef unsigned long __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned int __kernel_mode_t; typedef unsigned long __kernel_nlink_t; diff --git a/include/linux/dm-ioctl-v1.h b/include/linux/dm-ioctl-v1.h index 21bef9ec14b0..8a20b91c0e45 100644 --- a/include/linux/dm-ioctl-v1.h +++ b/include/linux/dm-ioctl-v1.h @@ -50,7 +50,7 @@ struct dm_ioctl { uint32_t open_count; /* out */ uint32_t flags; /* in/out */ - __kernel_dev_t dev; /* in/out */ + __kernel_old_dev_t dev; /* in/out */ char name[DM_NAME_LEN]; /* device name */ char uuid[DM_UUID_LEN]; /* unique identifier for @@ -87,7 +87,7 @@ struct dm_target_spec { struct dm_target_deps { uint32_t count; - __kernel_dev_t dev[0]; /* out */ + __kernel_old_dev_t dev[0]; /* out */ }; /* diff --git a/include/linux/types.h b/include/linux/types.h index 87a71f8f2416..e3a3d8b1b6bb 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -17,6 +17,8 @@ #ifndef __KERNEL_STRICT_NAMES +typedef __u16 __kernel_dev_t; + typedef __kernel_fd_set fd_set; typedef __kernel_dev_t dev_t; typedef __kernel_ino_t ino_t; -- cgit v1.2.3 From 40d2adc65cc233bbbd5437efe1df224b04a5ebf1 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Mon, 22 Sep 2003 22:52:17 -0700 Subject: [PATCH] 32-bit dev_t: internal use Starting the conversion: * internal dev_t made 32bit. * new helpers - new_encode_dev(), new_decode_dev(), huge_encode_dev(), huge_decode_dev(), new_valid_dev(). They do encoding/decoding of 32bit and 64bit values; for now huge_... are aliases for new_... and new_valid_dev() is always true. We do 12:20 for 32bit; representation is compatible with 16bit one - we have major in bits 19--8 and minor in 31--20,7--0. That's what the userland sees; internally we have (major << 20)|minor, of course. * MKDEV(), MAJOR() and MINOR() updated. * several places used to handle Missed'em'V dev_t (14:18 split) manually; that stuff had been taken into common helpers. Now we can start replacing old_... with new_... and huge_..., depending on the width available. MKDEV() callers should (for now) make sure that major and minor are within 12:20. That's what the next chunk will do. --- arch/mips/kernel/sysirix.c | 34 +++++++++----------- arch/sparc64/solaris/fs.c | 41 ++++++++++-------------- drivers/s390/block/dasd_int.h | 3 +- fs/libfs.c | 19 ----------- fs/xfs/linux/xfs_iops.c | 8 +++-- fs/xfs/linux/xfs_super.c | 2 +- fs/xfs/xfs_types.h | 16 ---------- include/linux/fs.h | 3 -- include/linux/kdev_t.h | 74 +++++++++++++++++++++++++++++++++++++++++-- include/linux/raid/md_k.h | 6 +--- include/linux/types.h | 2 +- 11 files changed, 115 insertions(+), 93 deletions(-) (limited to 'include/linux') diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c index 0b9426f0aa9a..4e0e6c4290ba 100644 --- a/arch/mips/kernel/sysirix.c +++ b/arch/mips/kernel/sysirix.c @@ -1187,13 +1187,7 @@ asmlinkage int irix_uname(struct iuname *buf) #undef DEBUG_XSTAT -static inline u32 -linux_to_irix_dev_t(dev_t t) -{ - return MAJOR (t) << 18 | MINOR (t); -} - -static inline int irix_xstat32_xlate(struct kstat *stat, void *ubuf) +static int irix_xstat32_xlate(struct kstat *stat, void *ubuf) { struct xstat32 { u32 st_dev, st_pad1[3], st_ino, st_mode, st_nlink, st_uid, st_gid; @@ -1206,13 +1200,15 @@ static inline int irix_xstat32_xlate(struct kstat *stat, void *ubuf) u32 st_pad4[8]; } ub; - ub.st_dev = linux_to_irix_dev_t(stat->dev); + if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev)) + return -EOVERFLOW; + ub.st_dev = sysv_encode_dev(stat->dev); ub.st_ino = stat->ino; ub.st_mode = stat->mode; ub.st_nlink = stat->nlink; SET_STAT_UID(ub, stat->uid); SET_STAT_GID(ub, stat->gid); - ub.st_rdev = linux_to_irix_dev_t(stat->rdev); + ub.st_rdev = sysv_encode_dev(stat->rdev); #if BITS_PER_LONG == 32 if (stat->size > MAX_NON_LFS) return -EOVERFLOW; @@ -1231,7 +1227,7 @@ static inline int irix_xstat32_xlate(struct kstat *stat, void *ubuf) return copy_to_user(ubuf, &ub, sizeof(ub)) ? -EFAULT : 0; } -static inline void irix_xstat64_xlate(struct kstat *stat, void *ubuf) +static int irix_xstat64_xlate(struct kstat *stat, void *ubuf) { struct xstat64 { u32 st_dev; s32 st_pad1[3]; @@ -1248,14 +1244,17 @@ static inline void irix_xstat64_xlate(struct kstat *stat, void *ubuf) s32 st_pad4[8]; } ks; - ks.st_dev = linux_to_irix_dev_t(stat->dev); + if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev)) + return -EOVERFLOW; + + ks.st_dev = sysv_encode_dev(stat->dev); ks.st_pad1[0] = ks.st_pad1[1] = ks.st_pad1[2] = 0; ks.st_ino = (unsigned long long) stat->ino; ks.st_mode = (u32) stat->mode; ks.st_nlink = (u32) stat->nlink; ks.st_uid = (s32) stat->uid; ks.st_gid = (s32) stat->gid; - ks.st_rdev = linux_to_irix_dev_t (stat->rdev); + ks.st_rdev = sysv_encode_dev (stat->rdev); ks.st_pad2[0] = ks.st_pad2[1] = 0; ks.st_size = (long long) stat->size; ks.st_pad3 = 0; @@ -1275,7 +1274,7 @@ static inline void irix_xstat64_xlate(struct kstat *stat, void *ubuf) ks.st_pad4[4] = ks.st_pad4[5] = ks.st_pad4[6] = ks.st_pad4[7] = 0; /* Now write it all back. */ - copy_to_user(ubuf, &ks, sizeof(struct xstat64)); + return copy_to_user(ubuf, &ub, sizeof(ub)) ? -EFAULT : 0; } asmlinkage int irix_xstat(int version, char *filename, struct stat *statbuf) @@ -1295,8 +1294,7 @@ asmlinkage int irix_xstat(int version, char *filename, struct stat *statbuf) retval = irix_xstat32_xlate(&stat, statbuf); break; case 3: - irix_xstat64_xlate(&stat, statbuf); - retval = 0; /* Really? */ + retval = irix_xstat64_xlate(&stat, statbuf); break; default: retval = -EINVAL; @@ -1323,8 +1321,7 @@ asmlinkage int irix_lxstat(int version, char *filename, struct stat *statbuf) error = irix_xstat32_xlate(&stat, statbuf); break; case 3: - irix_xstat64_xlate(&stat, statbuf); - error = 0; + error = irix_xstat64_xlate(&stat, statbuf); break; default: error = -EINVAL; @@ -1350,8 +1347,7 @@ asmlinkage int irix_fxstat(int version, int fd, struct stat *statbuf) error = irix_xstat32_xlate(&stat, statbuf); break; case 3: - irix_xstat64_xlate(&stat, statbuf); - error = 0; + error = irix_xstat64_xlate(&stat, statbuf); break; default: error = -EINVAL; diff --git a/arch/sparc64/solaris/fs.c b/arch/sparc64/solaris/fs.c index f0693bfb472e..eea867e632ad 100644 --- a/arch/sparc64/solaris/fs.c +++ b/arch/sparc64/solaris/fs.c @@ -28,21 +28,6 @@ #include "conv.h" -static inline u32 R4_DEV(dev_t DEV) -{ - return MINOR(DEV) | (MAJOR(DEV) << 18); -} - -static inline unsigned R4_MAJOR(u32 DEV) -{ - return (DEV >> 18) & 0x3fff; -} - -static inline unsigned R4_MINOR(u32 DEV) -{ - return DEV & 0x3ffff; -} - #define R3_VERSION 1 #define R4_VERSION 2 @@ -96,15 +81,17 @@ struct sol_stat64 { static inline int putstat(struct sol_stat *ubuf, struct kstat *kbuf) { - if (kbuf->size > MAX_NON_LFS) + if (kbuf->size > MAX_NON_LFS || + !sysv_valid_dev(kbuf->dev) || + !sysv_valid_dev(kbuf->rdev)) return -EOVERFLOW; - if (put_user (R4_DEV(kbuf->dev), &ubuf->st_dev) || + if (put_user (sysv_encode_dev(kbuf->dev), &ubuf->st_dev) || __put_user (kbuf->ino, &ubuf->st_ino) || __put_user (kbuf->mode, &ubuf->st_mode) || __put_user (kbuf->nlink, &ubuf->st_nlink) || __put_user (kbuf->uid, &ubuf->st_uid) || __put_user (kbuf->gid, &ubuf->st_gid) || - __put_user (R4_DEV(kbuf->rdev), &ubuf->st_rdev) || + __put_user (sysv_encode_dev(kbuf->rdev), &ubuf->st_rdev) || __put_user (kbuf->size, &ubuf->st_size) || __put_user (kbuf->atime.tv_sec, &ubuf->st_atime.tv_sec) || __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime.tv_nsec) || @@ -121,13 +108,15 @@ static inline int putstat(struct sol_stat *ubuf, struct kstat *kbuf) static inline int putstat64(struct sol_stat64 *ubuf, struct kstat *kbuf) { - if (put_user (R4_DEV(kbuf->dev), &ubuf->st_dev) || + if (!sysv_valid_dev(kbuf->dev) || !sysv_valid_dev(kbuf->rdev)) + return -EOVERFLOW; + if (put_user (sysv_encode_dev(kbuf->dev), &ubuf->st_dev) || __put_user (kbuf->ino, &ubuf->st_ino) || __put_user (kbuf->mode, &ubuf->st_mode) || __put_user (kbuf->nlink, &ubuf->st_nlink) || __put_user (kbuf->uid, &ubuf->st_uid) || __put_user (kbuf->gid, &ubuf->st_gid) || - __put_user (R4_DEV(kbuf->rdev), &ubuf->st_rdev) || + __put_user (sysv_encode_dev(kbuf->rdev), &ubuf->st_rdev) || __put_user (kbuf->size, &ubuf->st_size) || __put_user (kbuf->atime.tv_sec, &ubuf->st_atime.tv_sec) || __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime.tv_nsec) || @@ -261,8 +250,8 @@ asmlinkage int solaris_mknod(u32 path, u32 mode, s32 dev) (int (*)(const char *,int,unsigned))SYS(mknod); int major, minor; - if ((major = R4_MAJOR(dev)) > 255 || - (minor = R4_MINOR(dev)) > 255) return -EINVAL; + if ((major = sysv_major(dev)) > 255 || + (minor = sysv_minor(dev)) > 255) return -EINVAL; return sys_mknod((const char *)A(path), mode, old_encode_dev(MKDEV(major,minor))); } @@ -415,6 +404,8 @@ static int report_statvfs(struct vfsmount *mnt, struct inode *inode, u32 buf) if (j > 15) j = 15; if (IS_RDONLY(inode)) i = 1; if (mnt->mnt_flags & MNT_NOSUID) i |= 2; + if (!sysv_valid_dev(inode->i_sb->s_dev)) + return -EOVERFLOW; if (put_user (s.f_bsize, &ss->f_bsize) || __put_user (0, &ss->f_frsize) || __put_user (s.f_blocks, &ss->f_blocks) || @@ -423,7 +414,7 @@ static int report_statvfs(struct vfsmount *mnt, struct inode *inode, u32 buf) __put_user (s.f_files, &ss->f_files) || __put_user (s.f_ffree, &ss->f_ffree) || __put_user (s.f_ffree, &ss->f_favail) || - __put_user (R4_DEV(inode->i_sb->s_dev), &ss->f_fsid) || + __put_user (sysv_encode_dev(inode->i_sb->s_dev), &ss->f_fsid) || __copy_to_user (ss->f_basetype,p,j) || __put_user (0, (char *)&ss->f_basetype[j]) || __put_user (s.f_namelen, &ss->f_namemax) || @@ -449,6 +440,8 @@ static int report_statvfs64(struct vfsmount *mnt, struct inode *inode, u32 buf) if (j > 15) j = 15; if (IS_RDONLY(inode)) i = 1; if (mnt->mnt_flags & MNT_NOSUID) i |= 2; + if (!sysv_valid_dev(inode->i_sb->s_dev)) + return -EOVERFLOW; if (put_user (s.f_bsize, &ss->f_bsize) || __put_user (0, &ss->f_frsize) || __put_user (s.f_blocks, &ss->f_blocks) || @@ -457,7 +450,7 @@ static int report_statvfs64(struct vfsmount *mnt, struct inode *inode, u32 buf) __put_user (s.f_files, &ss->f_files) || __put_user (s.f_ffree, &ss->f_ffree) || __put_user (s.f_ffree, &ss->f_favail) || - __put_user (R4_DEV(inode->i_sb->s_dev), &ss->f_fsid) || + __put_user (sysv_encode_dev(inode->i_sb->s_dev), &ss->f_fsid) || __copy_to_user (ss->f_basetype,p,j) || __put_user (0, (char *)&ss->f_basetype[j]) || __put_user (s.f_namelen, &ss->f_namemax) || diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h index 0f2cdea8070d..9d36b632c5a9 100644 --- a/drivers/s390/block/dasd_int.h +++ b/drivers/s390/block/dasd_int.h @@ -14,7 +14,8 @@ #ifdef __KERNEL__ -#define DASD_PER_MAJOR ( 1U<<(MINORBITS-DASD_PARTN_BITS)) +/* we keep old device allocation scheme; IOW, minors are still in 0..255 */ +#define DASD_PER_MAJOR ( 1U<<(8-DASD_PARTN_BITS)) #define DASD_PARTN_MASK ((1 << DASD_PARTN_BITS) - 1) /* diff --git a/fs/libfs.c b/fs/libfs.c index fbf1d0e6e3e4..f323ac963d6d 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -429,22 +429,3 @@ void simple_release_fs(struct vfsmount **mount, int *count) spin_unlock(&pin_fs_lock); mntput(mnt); } - -/* acceptable for old filesystems */ -int old_valid_dev(dev_t dev) -{ - return MAJOR(dev) < 256 && MINOR(dev) < 256; -} -EXPORT_SYMBOL(old_valid_dev); - -u16 old_encode_dev(dev_t dev) -{ - return (MAJOR(dev) << 8) | MINOR(dev); -} -EXPORT_SYMBOL(old_encode_dev); - -dev_t old_decode_dev(u16 val) -{ - return MKDEV((val >> 8) & 255, val & 255); -} -EXPORT_SYMBOL(old_decode_dev); diff --git a/fs/xfs/linux/xfs_iops.c b/fs/xfs/linux/xfs_iops.c index 11c1736bf4f7..b37ac6166c20 100644 --- a/fs/xfs/linux/xfs_iops.c +++ b/fs/xfs/linux/xfs_iops.c @@ -113,7 +113,11 @@ linvfs_mknod( xattr_exists_t test_default_acl = _ACL_DEFAULT_EXISTS; int error; - if (!old_valid_dev(rdev)) + /* + * Irix uses Missed'em'V split, but doesn't want to see + * the upper 5 bits of (14bit) major. + */ + if (!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff) return -EINVAL; if (test_default_acl && test_default_acl(dvp)) { @@ -135,7 +139,7 @@ linvfs_mknod( switch (mode & S_IFMT) { case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK: - va.va_rdev = XFS_MKDEV(MAJOR(rdev), MINOR(rdev)); + va.va_rdev = sysv_encode_dev(rdev); va.va_mask |= XFS_AT_RDEV; /*FALLTHROUGH*/ case S_IFREG: diff --git a/fs/xfs/linux/xfs_super.c b/fs/xfs/linux/xfs_super.c index c58952d14f6b..326dfe0553fa 100644 --- a/fs/xfs/linux/xfs_super.c +++ b/fs/xfs/linux/xfs_super.c @@ -174,7 +174,7 @@ xfs_revalidate_inode( inode->i_rdev = 0; } else { xfs_dev_t dev = ip->i_df.if_u2.if_rdev; - inode->i_rdev = XFS_DEV_TO_DEVT(dev); + inode->i_rdev = MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev)); } inode->i_blksize = PAGE_CACHE_SIZE; inode->i_generation = ip->i_d.di_gen; diff --git a/fs/xfs/xfs_types.h b/fs/xfs/xfs_types.h index 59634d447545..a4cc7be2127e 100644 --- a/fs/xfs/xfs_types.h +++ b/fs/xfs/xfs_types.h @@ -197,20 +197,4 @@ typedef enum { XFS_BTNUM_MAX } xfs_btnum_t; - -/* - * Juggle IRIX device numbers - still used in ondisk structures - */ -#define XFS_DEV_BITSMAJOR 14 -#define XFS_DEV_BITSMINOR 18 -#define XFS_DEV_MAXMAJ 0x1ff -#define XFS_DEV_MAXMIN 0x3ffff -#define XFS_DEV_MAJOR(dev) ((int)(((unsigned)(dev)>>XFS_DEV_BITSMINOR) \ - & XFS_DEV_MAXMAJ)) -#define XFS_DEV_MINOR(dev) ((int)((dev)&XFS_DEV_MAXMIN)) -#define XFS_MKDEV(major,minor) ((xfs_dev_t)(((major)<> MINORBITS)) @@ -18,6 +17,77 @@ buffer; \ }) +/* acceptable for old filesystems */ +static inline int old_valid_dev(dev_t dev) +{ + return MAJOR(dev) < 256 && MINOR(dev) < 256; +} + +static inline u16 old_encode_dev(dev_t dev) +{ + return (MAJOR(dev) << 8) | MINOR(dev); +} + +static inline dev_t old_decode_dev(u16 val) +{ + return MKDEV((val >> 8) & 255, val & 255); +} + +static inline int new_valid_dev(dev_t dev) +{ + return 1; +} + +static inline u32 new_encode_dev(dev_t dev) +{ + unsigned major = MAJOR(dev); + unsigned minor = MINOR(dev); + return (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12); +} + +static inline dev_t new_decode_dev(u32 dev) +{ + unsigned major = (dev & 0xfff00) >> 8; + unsigned minor = (dev & 0xff) | ((dev >> 12) & 0xfff00); + return MKDEV(major, minor); +} + +static inline int huge_valid_dev(dev_t dev) +{ + return 1; +} + +static inline u64 huge_encode_dev(dev_t dev) +{ + return new_encode_dev(dev); +} + +static inline dev_t huge_decode_dev(u64 dev) +{ + return new_decode_dev(dev); +} + +static inline int sysv_valid_dev(dev_t dev) +{ + return MAJOR(dev) < (1<<14) && MINOR(dev) < (1<<18); +} + +static inline u32 sysv_encode_dev(dev_t dev) +{ + return MINOR(dev) | (MAJOR(dev) << 18); +} + +static inline unsigned sysv_major(u32 dev) +{ + return (dev >> 18) & 0x3fff; +} + +static inline unsigned sysv_minor(u32 dev) +{ + return dev & 0x3ffff; +} + + #else /* __KERNEL__ */ /* diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 70c5d117da8d..c9466321a2b2 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h @@ -64,11 +64,7 @@ static inline int level_to_pers (int level) typedef struct mddev_s mddev_t; typedef struct mdk_rdev_s mdk_rdev_t; -#if (MINORBITS != 8) -#error MD does not handle bigger kdev yet -#endif - -#define MAX_MD_DEVS (1< Date: Tue, 23 Sep 2003 09:43:01 -0700 Subject: [PATCH] kill some leftovers from the big sysrq syncing rewrite From: Christoph Hellwig Some junk which was needed before we did the big cleansweep for the sysrq syncing stuff. --- drivers/char/sysrq.c | 1 - include/linux/major.h | 30 ------------------------------ 2 files changed, 31 deletions(-) (limited to 'include/linux') diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index ea238b20a194..bd1e49780a86 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c @@ -37,7 +37,6 @@ #include extern void reset_vc(unsigned int); -extern struct list_head super_blocks; /* Whether we react on sysrq keys or just ignore them */ int sysrq_enabled = 1; diff --git a/include/linux/major.h b/include/linux/major.h index 0e2d112c89e5..39a77a2c7035 100644 --- a/include/linux/major.h +++ b/include/linux/major.h @@ -160,34 +160,4 @@ #define IBM_TTY3270_MAJOR 227 #define IBM_FS3270_MAJOR 228 -/* - * Tests for SCSI devices. - */ - -#define SCSI_DISK_MAJOR(M) ((M) == SCSI_DISK0_MAJOR || \ - ((M) >= SCSI_DISK1_MAJOR && (M) <= SCSI_DISK7_MAJOR) || \ - ((M) >= SCSI_DISK8_MAJOR && (M) <= SCSI_DISK15_MAJOR)) - -#define SCSI_BLK_MAJOR(M) \ - (SCSI_DISK_MAJOR(M) \ - || (M) == SCSI_CDROM_MAJOR) - -static __inline__ int scsi_blk_major(int m) { - return SCSI_BLK_MAJOR(m); -} - -/* - * Tests for IDE devices - */ -#define IDE_DISK_MAJOR(M) ((M) == IDE0_MAJOR || (M) == IDE1_MAJOR || \ - (M) == IDE2_MAJOR || (M) == IDE3_MAJOR || \ - (M) == IDE4_MAJOR || (M) == IDE5_MAJOR || \ - (M) == IDE6_MAJOR || (M) == IDE7_MAJOR || \ - (M) == IDE8_MAJOR || (M) == IDE9_MAJOR) - -static __inline__ int ide_blk_major(int m) -{ - return IDE_DISK_MAJOR(m); -} - #endif -- cgit v1.2.3 From f751e52a867c5092ebbb0d9f3402eb476df3135f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 23 Sep 2003 09:43:28 -0700 Subject: [PATCH] switch remaining serial drivers to initcalls From: Christoph Hellwig All drivers that compile on ppc with CONFIG_ISA set (= all but some m68-only drivers), I looked at the compile warnings very closely and there are no new warnings or even errors this time :) drivers/char/Makefile needed to be reordered big time to keep the intialization order the same. --- arch/ppc/8260_io/uart.c | 7 ++--- arch/ppc/8xx_io/uart.c | 7 ++--- drivers/char/Makefile | 63 +++++++++++++++++++-------------------- drivers/char/cyclades.c | 12 +++----- drivers/char/ip2.c | 48 +++--------------------------- drivers/char/moxa.c | 68 +++++++++++++++++-------------------------- drivers/char/pcxx.c | 14 ++++----- drivers/char/pty.c | 3 +- drivers/char/ser_a2232.c | 17 ++++------- drivers/char/serial167.c | 8 ++--- drivers/char/serial_tx3912.c | 3 +- drivers/char/specialix.c | 13 ++++----- drivers/char/tty_io.c | 52 --------------------------------- drivers/char/vme_scc.c | 8 ++--- drivers/macintosh/macserial.c | 3 +- drivers/s390/char/tuball.c | 33 +++++++++------------ include/linux/tty.h | 16 ---------- 17 files changed, 111 insertions(+), 264 deletions(-) (limited to 'include/linux') diff --git a/arch/ppc/8260_io/uart.c b/arch/ppc/8260_io/uart.c index a2aca963a594..2b240daef6eb 100644 --- a/arch/ppc/8260_io/uart.c +++ b/arch/ppc/8260_io/uart.c @@ -18,10 +18,6 @@ * It still needs lots of work........When it was easy, I included code * to support the SCCs. * Only the SCCs support modem control, so that is not complete either. - * - * This module exports the following rs232 io functions: - * - * int rs_8xx_init(void); */ #include @@ -2507,7 +2503,7 @@ static struct tty_operations rs_8xx_ops = { /* * The serial driver boot-time initialization code! */ -int __init rs_8xx_init(void) +static int __init rs_8xx_init(void) { struct serial_state * state; ser_info_t *info; @@ -2867,6 +2863,7 @@ int __init rs_8xx_init(void) } return 0; } +module_init(rs_8xx_init); /* This must always be called before the rs_8xx_init() function, otherwise * it blows away the port control information. diff --git a/arch/ppc/8xx_io/uart.c b/arch/ppc/8xx_io/uart.c index ec14afca7c9e..d0701bd03381 100644 --- a/arch/ppc/8xx_io/uart.c +++ b/arch/ppc/8xx_io/uart.c @@ -12,10 +12,6 @@ * It still needs lots of work........When it was easy, I included code * to support the SCCs, but this has never been tested, nor is it complete. * Only the SCCs support modem control, so that is not complete either. - * - * This module exports the following rs232 io functions: - * - * int rs_8xx_init(void); */ #include @@ -2499,7 +2495,7 @@ static struct tty_operations rs_8xx_ops = { /* * The serial driver boot-time initialization code! */ -int __init rs_8xx_init(void) +static int __init rs_8xx_init(void) { struct serial_state * state; ser_info_t *info; @@ -2846,6 +2842,7 @@ int __init rs_8xx_init(void) return 0; } +module_init(rs_8xx_init); /* This must always be called before the rs_8xx_init() function, otherwise * it blows away the port control information. diff --git a/drivers/char/Makefile b/drivers/char/Makefile index b53d91f5c10d..65eeb6b8ca7d 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -9,38 +9,39 @@ FONTMAPFILE = cp437.uni obj-y += mem.o random.o tty_io.o n_tty.o tty_ioctl.o pty.o misc.o -obj-$(CONFIG_VT) += vt_ioctl.o vc_screen.o consolemap.o consolemap_deftbl.o selection.o keyboard.o -obj-$(CONFIG_HW_CONSOLE) += vt.o defkeymap.o -obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o -obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o -obj-$(CONFIG_ROCKETPORT) += rocket.o -obj-$(CONFIG_MOXA_SMARTIO) += mxser.o -obj-$(CONFIG_MOXA_INTELLIO) += moxa.o -obj-$(CONFIG_DIGI) += pcxx.o -obj-$(CONFIG_DIGIEPCA) += epca.o -obj-$(CONFIG_CYCLADES) += cyclades.o -obj-$(CONFIG_STALLION) += stallion.o -obj-$(CONFIG_ISTALLION) += istallion.o -obj-$(CONFIG_COMPUTONE) += ip2.o ip2main.o -obj-$(CONFIG_RISCOM8) += riscom8.o -obj-$(CONFIG_ISI) += isicom.o -obj-$(CONFIG_ESPSERIAL) += esp.o -obj-$(CONFIG_SYNCLINK) += synclink.o -obj-$(CONFIG_SYNCLINKMP) += synclinkmp.o -obj-$(CONFIG_N_HDLC) += n_hdlc.o -obj-$(CONFIG_SPECIALIX) += specialix.o +obj-$(CONFIG_VT) += vt_ioctl.o vc_screen.o consolemap.o \ + consolemap_deftbl.o selection.o keyboard.o +obj-$(CONFIG_HW_CONSOLE) += vt.o defkeymap.o +obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o +obj-$(CONFIG_ESPSERIAL) += esp.o +obj-$(CONFIG_MVME147_SCC) += generic_serial.o vme_scc.o +obj-$(CONFIG_MVME162_SCC) += generic_serial.o vme_scc.o +obj-$(CONFIG_BVME6000_SCC) += generic_serial.o vme_scc.o +obj-$(CONFIG_SERIAL_TX3912) += generic_serial.o serial_tx3912.o +obj-$(CONFIG_ROCKETPORT) += rocket.o +obj-$(CONFIG_SERIAL167) += serial167.o +obj-$(CONFIG_CYCLADES) += cyclades.o +obj-$(CONFIG_STALLION) += stallion.o +obj-$(CONFIG_ISTALLION) += istallion.o +obj-$(CONFIG_DIGI) += pcxx.o +obj-$(CONFIG_DIGIEPCA) += epca.o +obj-$(CONFIG_SPECIALIX) += specialix.o +obj-$(CONFIG_MOXA_INTELLIO) += moxa.o +obj-$(CONFIG_A2232) += ser_a2232.o generic_serial.o +obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o +obj-$(CONFIG_MOXA_SMARTIO) += mxser.o +obj-$(CONFIG_COMPUTONE) += ip2.o ip2main.o +obj-$(CONFIG_RISCOM8) += riscom8.o +obj-$(CONFIG_ISI) += isicom.o +obj-$(CONFIG_SYNCLINK) += synclink.o +obj-$(CONFIG_SYNCLINKMP) += synclinkmp.o +obj-$(CONFIG_N_HDLC) += n_hdlc.o obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o -obj-$(CONFIG_A2232) += ser_a2232.o generic_serial.o -obj-$(CONFIG_SX) += sx.o generic_serial.o -obj-$(CONFIG_RIO) += rio/ generic_serial.o -obj-$(CONFIG_SH_SCI) += sh-sci.o generic_serial.o -obj-$(CONFIG_SERIAL167) += serial167.o -obj-$(CONFIG_MVME147_SCC) += generic_serial.o vme_scc.o -obj-$(CONFIG_MVME162_SCC) += generic_serial.o vme_scc.o -obj-$(CONFIG_BVME6000_SCC) += generic_serial.o vme_scc.o -obj-$(CONFIG_SERIAL_TX3912) += generic_serial.o serial_tx3912.o -obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o -obj-$(CONFIG_RAW_DRIVER) += raw.o +obj-$(CONFIG_SX) += sx.o generic_serial.o +obj-$(CONFIG_RIO) += rio/ generic_serial.o +obj-$(CONFIG_SH_SCI) += sh-sci.o generic_serial.o +obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o +obj-$(CONFIG_RAW_DRIVER) += raw.o obj-$(CONFIG_PRINTER) += lp.o obj-$(CONFIG_TIPAR) += tipar.o diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 74ba43ec4206..401e040ed0b0 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -5433,7 +5433,7 @@ static struct tty_operations cy_ops = { .read_proc = cyclades_get_proc_info, }; -int __init +static int __init cy_init(void) { struct cyclades_port *info; @@ -5660,13 +5660,10 @@ cy_init(void) } /* cy_init */ -#ifdef MODULE -void +static void __exit cy_cleanup_module(void) { - int i; - int e1, e2; - unsigned long flags; + int i, e1; #ifndef CONFIG_CYZ_INTR if (cyz_timeron){ @@ -5702,11 +5699,10 @@ cy_cleanup_module(void) } } /* cy_cleanup_module */ -/* Module entry-points */ module_init(cy_init); module_exit(cy_cleanup_module); -#else /* MODULE */ +#ifndef MODULE /* called by linux/init/main.c to parse command line options */ void cy_setup(char *str, int *ints) diff --git a/drivers/char/ip2.c b/drivers/char/ip2.c index 28aefc023688..8e62d6d3d6e9 100644 --- a/drivers/char/ip2.c +++ b/drivers/char/ip2.c @@ -34,8 +34,6 @@ ip2_loadmain(int *, int *, unsigned char *, int ); // ref into ip2main.c static int io[IP2_MAX_BOARDS]= { 0, 0, 0, 0 }; static int irq[IP2_MAX_BOARDS] = { -1, -1, -1, -1 }; -#ifdef MODULE - static int poll_only = 0; MODULE_AUTHOR("Doug McNash"); @@ -48,48 +46,20 @@ MODULE_PARM(poll_only,"1i"); MODULE_PARM_DESC(poll_only,"Do not use card interrupts"); -//====================================================================== -int -init_module(void) +static int __init ip2_init(void) { - int rc; - - MOD_INC_USE_COUNT; // hold till done - if( poll_only ) { /* Hard lock the interrupts to zero */ irq[0] = irq[1] = irq[2] = irq[3] = 0; } - rc = ip2_loadmain(io,irq,(unsigned char *)fip_firm,sizeof(fip_firm)); - // The call to lock and load main, create dep - - MOD_DEC_USE_COUNT; //done - kerneld now can unload us - return rc; -} - -//====================================================================== -int -ip2_init(void) -{ - // call to this is in tty_io.c so we need this - return 0; -} - -//====================================================================== -void -cleanup_module(void) -{ + return ip2_loadmain(io,irq,(unsigned char *)fip_firm,sizeof(fip_firm)); } +module_init(ip2_init); MODULE_LICENSE("GPL"); -#else // !MODULE - -#ifndef NULL -# define NULL ((void *) 0) -#endif - +#ifndef MODULE /****************************************************************************** * ip2_setup: * str: kernel command line string @@ -136,15 +106,5 @@ static int __init ip2_setup(char *str) } return 1; } - -int -ip2_init(void) { - return ip2_loadmain(io,irq,(unsigned char *)fip_firm,sizeof(fip_firm)); -} - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)) __setup("ip2=", ip2_setup); -__initcall(ip2_init); -#endif - #endif /* !MODULE */ diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index bf63034c0703..9d0650837807 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c @@ -189,7 +189,6 @@ static struct mxser_mstatus GMStatus[MAX_PORTS]; static int verbose = 0; static int ttymajor = MOXAMAJOR; -#ifdef MODULE /* Variables for insmod */ static int baseaddr[] = {0, 0, 0, 0}; static int type[] = {0, 0, 0, 0}; @@ -204,8 +203,6 @@ MODULE_PARM(numports, "1-4i"); MODULE_PARM(ttymajor, "i"); MODULE_PARM(verbose, "i"); -#endif //MODULE - static struct tty_driver *moxaDriver; static struct moxa_str moxaChannels[MAX_PORTS]; static unsigned char *moxaXmitBuff; @@ -215,8 +212,6 @@ static int moxaEmptyTimer_on[MAX_PORTS]; static struct timer_list moxaEmptyTimer[MAX_PORTS]; static struct semaphore moxaBuffSem; -int moxa_init(void); - /* * static functions: */ @@ -278,42 +273,6 @@ static int moxa_get_serial_info(struct moxa_str *, struct serial_struct *); static int moxa_set_serial_info(struct moxa_str *, struct serial_struct *); static void MoxaSetFifo(int port, int enable); -#ifdef MODULE -int init_module(void) -{ - int ret; - - if (verbose) - printk("Loading module moxa ...\n"); - ret = moxa_init(); - if (verbose) - printk("Done\n"); - return (ret); -} - -void cleanup_module(void) -{ - int i; - - if (verbose) - printk("Unloading module moxa ...\n"); - - if (moxaTimer_on) - del_timer(&moxaTimer); - - for (i = 0; i < MAX_PORTS; i++) - if (moxaEmptyTimer_on[i]) - del_timer(&moxaEmptyTimer[i]); - - if (tty_unregister_driver(moxaDriver)) - printk("Couldn't unregister MOXA Intellio family serial driver\n"); - put_tty_driver(moxaDriver); - if (verbose) - printk("Done\n"); - -} -#endif - static struct tty_operations moxa_ops = { .open = moxa_open, .close = moxa_close, @@ -332,7 +291,7 @@ static struct tty_operations moxa_ops = { .hangup = moxa_hangup, }; -int moxa_init(void) +static int __init moxa_init(void) { int i, n, numBoards; struct moxa_str *ch; @@ -479,6 +438,31 @@ int moxa_init(void) return (0); } +static void __exit moxa_exit(void) +{ + int i; + + if (verbose) + printk("Unloading module moxa ...\n"); + + if (moxaTimer_on) + del_timer(&moxaTimer); + + for (i = 0; i < MAX_PORTS; i++) + if (moxaEmptyTimer_on[i]) + del_timer(&moxaEmptyTimer[i]); + + if (tty_unregister_driver(moxaDriver)) + printk("Couldn't unregister MOXA Intellio family serial driver\n"); + put_tty_driver(moxaDriver); + if (verbose) + printk("Done\n"); + +} + +module_init(moxa_init); +module_exit(moxa_exit); + static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board) { board->baseAddr = pci_resource_start (p, 2); diff --git a/drivers/char/pcxx.c b/drivers/char/pcxx.c index a86e164fff56..78aa18b4e81c 100644 --- a/drivers/char/pcxx.c +++ b/drivers/char/pcxx.c @@ -200,13 +200,7 @@ static void cleanup_board_resources(void) } } -/*****************************************************************************/ - -#ifdef MODULE - -/*****************************************************************************/ - -static void pcxe_cleanup() +static void __exit pcxe_cleanup(void) { unsigned long flags; @@ -232,7 +226,6 @@ static void pcxe_cleanup() */ module_init(pcxe_init); module_cleanup(pcxe_cleanup); -#endif static inline struct channel *chan(register struct tty_struct *tty) { @@ -1018,6 +1011,9 @@ void __init pcxx_setup(char *str, int *ints) } #endif +module_init(pcxe_init) +module_exit(pcxe_exit) + static struct tty_operations pcxe_ops = { .open = pcxe_open, .close = pcxe_close, @@ -1040,7 +1036,7 @@ static struct tty_operations pcxe_ops = { * function to initialize the driver with the given parameters, which are either * the default values from this file or the parameters given at boot. */ -int __init pcxe_init(void) +static int __init pcxe_init(void) { ulong memory_seg=0, memory_size=0; int lowwater, enabled_cards=0, i, crd, shrinkmem=0, topwin = 0xff00L, botwin=0x100L; diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 85fa5d9503cb..135a4b6463a1 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -313,7 +313,7 @@ static struct tty_operations pty_ops = { .set_termios = pty_set_termios, }; -int __init pty_init(void) +static int __init pty_init(void) { /* Traditional BSD devices */ @@ -414,3 +414,4 @@ int __init pty_init(void) #endif return 0; } +module_init(pty_init); diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c index eb168a011cd6..c6a04abc1215 100644 --- a/drivers/char/ser_a2232.c +++ b/drivers/char/ser_a2232.c @@ -122,8 +122,6 @@ static void a2232_init_portstructs(void); /* Initialize and register TTY drivers. */ /* returns 0 IFF successful */ static int a2232_init_drivers(void); -/* Initialize all A2232 boards; main entry point. */ -int a2232board_init(void); /* BEGIN GENERIC_SERIAL PROTOTYPES */ static void a2232_disable_tx_interrupts(void *ptr); @@ -720,7 +718,7 @@ static int a2232_init_drivers(void) return 0; } -int a2232board_init(void) +static int __init a2232board_init(void) { struct zorro_dev *z; @@ -813,13 +811,7 @@ int a2232board_init(void) return 0; } -#ifdef MODULE -int init_module(void) -{ - return a2232board_init(); -} - -void cleanup_module(void) +static void __exit a2232board_exit(void) { int i; @@ -831,8 +823,9 @@ void cleanup_module(void) put_tty_driver(a2232_driver); free_irq(IRQ_AMIGA_VERTB, a2232_driver_ID); } -#endif -/***************************** End of Functions *********************/ + +module_init(a2232board_init); +module_exit(a2232board_exit); MODULE_AUTHOR("Enver Haase"); MODULE_DESCRIPTION("Amiga A2232 multi-serial board driver"); diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c index 82b815099f1b..a656925ef83f 100644 --- a/drivers/char/serial167.c +++ b/drivers/char/serial167.c @@ -23,10 +23,6 @@ * * This version does not support shared irq's. * - * This module exports the following rs232 io functions: - * int cy_init(void); - * int cy_open(struct tty_struct *tty, struct file *filp); - * * $Log: cyclades.c,v $ * Revision 1.36.1.4 1995/03/29 06:14:14 bentson * disambiguate between Cyclom-16Y and Cyclom-32Ye; @@ -2321,7 +2317,7 @@ static struct tty_operations cy_ops = { If there are more cards with more ports than have been statically allocated above, a warning is printed and the extra ports are ignored. */ -int +static int __init serial167_init(void) { struct cyclades_port *info; @@ -2497,6 +2493,8 @@ cleanup_serial_driver: return ret; } /* serial167_init */ +module_init(serial167_init); + #ifdef CYCLOM_SHOW_STATUS static void diff --git a/drivers/char/serial_tx3912.c b/drivers/char/serial_tx3912.c index 426273039273..8be447a76a3d 100644 --- a/drivers/char/serial_tx3912.c +++ b/drivers/char/serial_tx3912.c @@ -812,7 +812,7 @@ static int rs_init_drivers(void) } -void __init tx3912_rs_init(void) +static void __init tx3912_rs_init(void) { int rc; @@ -877,6 +877,7 @@ void __init tx3912_rs_init(void) func_exit(); } +module_init(tx3912_rs_init); /* * Begin serial console routines diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c index a65506e8f6bd..68bacdd1841a 100644 --- a/drivers/char/specialix.c +++ b/drivers/char/specialix.c @@ -1362,7 +1362,6 @@ static int sx_open(struct tty_struct * tty, struct file * filp) int error; struct specialix_port * port; struct specialix_board * bp; - unsigned long flags; board = SX_BOARD(tty->index); @@ -2205,7 +2204,7 @@ void specialix_setup(char *str, int * ints) /* * This routine must be called by kernel at boot time */ -int specialix_init(void) +static int __init specialix_init(void) { int i; int found = 0; @@ -2263,7 +2262,6 @@ int specialix_init(void) return 0; } -#ifdef MODULE int iobase[SX_NBOARD] = {0,}; int irq [SX_NBOARD] = {0,}; @@ -2280,7 +2278,7 @@ MODULE_PARM(irq,"1-" __MODULE_STRING(SX_NBOARD) "i"); * only use 4 different interrupts. * */ -int init_module(void) +static int __init specialix_init_module(void) { int i; @@ -2294,8 +2292,7 @@ int init_module(void) return specialix_init(); } - -void cleanup_module(void) +static void __exit specialix_exit_module(void) { int i; @@ -2308,6 +2305,8 @@ void cleanup_module(void) #endif } -#endif /* MODULE */ + +module_init(specialix_init_module); +module_exit(specialix_exit_module); MODULE_LICENSE("GPL"); diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 2ea337b26d51..31a43060d708 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -138,12 +138,7 @@ static int tty_release(struct inode *, struct file *); int tty_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg); static int tty_fasync(int fd, struct file * filp, int on); -extern int vme_scc_init (void); -extern int serial167_init(void); -extern int rs_8xx_init(void); -extern void tub3270_init(void); extern void rs_360_init(void); -extern void tx3912_rs_init(void); static struct tty_struct *alloc_tty_struct(void) { @@ -2462,53 +2457,6 @@ static int __init tty_init(void) vty_init(); #endif - -#ifdef CONFIG_ESPSERIAL /* init ESP before rs, so rs doesn't see the port */ - espserial_init(); -#endif -#if defined(CONFIG_MVME162_SCC) || defined(CONFIG_BVME6000_SCC) || defined(CONFIG_MVME147_SCC) - vme_scc_init(); -#endif -#ifdef CONFIG_SERIAL_TX3912 - tx3912_rs_init(); -#endif -#ifdef CONFIG_ROCKETPORT - rp_init(); -#endif -#ifdef CONFIG_SERIAL167 - serial167_init(); -#endif -#ifdef CONFIG_CYCLADES - cy_init(); -#endif -#ifdef CONFIG_STALLION - stl_init(); -#endif -#ifdef CONFIG_ISTALLION - stli_init(); -#endif -#ifdef CONFIG_DIGI - pcxe_init(); -#endif -#ifdef CONFIG_DIGIEPCA - pc_init(); -#endif -#ifdef CONFIG_SPECIALIX - specialix_init(); -#endif -#if (defined(CONFIG_8xx) || defined(CONFIG_8260)) - rs_8xx_init(); -#endif /* CONFIG_8xx */ - pty_init(); -#ifdef CONFIG_MOXA_INTELLIO - moxa_init(); -#endif -#ifdef CONFIG_TN3270 - tub3270_init(); -#endif -#ifdef CONFIG_A2232 - a2232board_init(); -#endif return 0; } module_init(tty_init); diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c index 8938a30942c7..2c84b2314ffb 100644 --- a/drivers/char/vme_scc.c +++ b/drivers/char/vme_scc.c @@ -396,14 +396,10 @@ static int bvme6000_scc_init(void) #endif -int vme_scc_init(void) +static int vme_scc_init(void) { int res = -ENODEV; - static int called = 0; - if (called) - return res; - called = 1; #ifdef CONFIG_MVME147_SCC if (MACH_IS_MVME147) res = mvme147_scc_init(); @@ -419,6 +415,8 @@ int vme_scc_init(void) return res; } +module_init(vme_scc_init); + /*--------------------------------------------------------------------------- * Interrupt handlers diff --git a/drivers/macintosh/macserial.c b/drivers/macintosh/macserial.c index 9f4b7cdd2f68..9d6eb9890b62 100644 --- a/drivers/macintosh/macserial.c +++ b/drivers/macintosh/macserial.c @@ -2490,8 +2490,7 @@ static struct tty_operations serial_ops = { .read_proc = macserial_read_proc, }; -/* rs_init inits the driver */ -int macserial_init(void) +static int macserial_init(void) { int channel, i; struct mac_serial *info; diff --git a/drivers/s390/char/tuball.c b/drivers/s390/char/tuball.c index a35b3f27b28b..8f7b5350a542 100644 --- a/drivers/s390/char/tuball.c +++ b/drivers/s390/char/tuball.c @@ -74,8 +74,6 @@ unsigned char tub_ebcgraf[64] = 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f }; -int tub3270_init(void); - #ifndef MODULE /* @@ -193,31 +191,18 @@ int tub3270_con_copy(tub_t *tubp) return rc; } #endif /* CONFIG_TN3270_CONSOLE */ -#else /* If generated as a MODULE */ -/* - * module init: find tubes; get a major nbr - */ -int -init_module(void) -{ - if (tubnummins != 0) { - printk(KERN_ERR "EEEK!! Tube driver cobbigling!!\n"); - return -1; - } - return tub3270_init(); -} +#endif /* * remove driver: unregister the major number */ -void -cleanup_module(void) +static void __exit +tub3270_exit(void) { fs3270_fini(); tty3270_fini(); tubfiniminors(); } -#endif /* Not a MODULE or a MODULE */ static int tub3270_is_ours(s390_dev_info_t *dp) @@ -232,12 +217,19 @@ tub3270_is_ours(s390_dev_info_t *dp) /* * tub3270_init() called by kernel or module initialization */ -int +static int __init tub3270_init(void) { s390_dev_info_t d; int i, rc; +#ifdef MODULE + if (tubnummins != 0) { + printk(KERN_ERR "EEEK!! Tube driver cobbigling!!\n"); + return -1; + } +#endif + /* * Copy and correct ebcdic - ascii translate tables */ @@ -624,3 +616,6 @@ tubfiniirqs(void) tubirqs = NULL; } } + +module_init(tub3270_init); +module_exit(tub3270_exit); diff --git a/include/linux/tty.h b/include/linux/tty.h index 946702c37e6e..0626d1b321aa 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -347,23 +347,7 @@ extern int fg_console, last_console, want_console; extern int kmsg_redirect; extern void console_init(void); - -extern int lp_init(void); -extern int pty_init(void); -extern int mxser_init(void); -extern int moxa_init(void); -extern int ip2_init(void); -extern int pcxe_init(void); -extern int pc_init(void); extern int vcs_init(void); -extern int rp_init(void); -extern int cy_init(void); -extern int stl_init(void); -extern int stli_init(void); -extern int specialix_init(void); -extern int espserial_init(void); -extern int macserial_init(void); -extern int a2232board_init(void); extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, const char *routine); -- cgit v1.2.3 From 41cffedc07d938ed655a95ef0309d79f203d8add Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 23 Sep 2003 09:43:45 -0700 Subject: [PATCH] Hugetlb FS quota accounting problem From: "Chen, Kenneth W" We found a problem in hugetlbfs file system quota when using huge page via mmap. The mmap method in hugetlbfs_file_operation always takes quota for every mmap even for pages that are already allocated on that inode. This results in taxing the same hugepage multiple times and causing mmap to fail on existing file when quota mistakenly runs out. --- arch/i386/mm/hugetlbpage.c | 7 ++++++ arch/ia64/mm/hugetlbpage.c | 7 ++++++ fs/hugetlbfs/inode.c | 56 ++++++++++++++++++++++++---------------------- include/linux/hugetlb.h | 2 ++ 4 files changed, 45 insertions(+), 27 deletions(-) (limited to 'include/linux') diff --git a/arch/i386/mm/hugetlbpage.c b/arch/i386/mm/hugetlbpage.c index f4e073471958..d14cbbeaf864 100644 --- a/arch/i386/mm/hugetlbpage.c +++ b/arch/i386/mm/hugetlbpage.c @@ -355,14 +355,21 @@ int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma) + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT)); page = find_get_page(mapping, idx); if (!page) { + /* charge the fs quota first */ + if (hugetlb_get_quota(mapping)) { + ret = -ENOMEM; + goto out; + } page = alloc_hugetlb_page(); if (!page) { + hugetlb_put_quota(mapping); ret = -ENOMEM; goto out; } ret = add_to_page_cache(page, mapping, idx, GFP_ATOMIC); unlock_page(page); if (ret) { + hugetlb_put_quota(mapping); free_huge_page(page); goto out; } diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c index 20426c58c63b..6a2e5a23f87d 100644 --- a/arch/ia64/mm/hugetlbpage.c +++ b/arch/ia64/mm/hugetlbpage.c @@ -297,14 +297,21 @@ int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma) + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT)); page = find_get_page(mapping, idx); if (!page) { + /* charge the fs quota first */ + if (hugetlb_get_quota(mapping)) { + ret = -ENOMEM; + goto out; + } page = alloc_hugetlb_page(); if (!page) { + hugetlb_put_quota(mapping); ret = -ENOMEM; goto out; } ret = add_to_page_cache(page, mapping, idx, GFP_ATOMIC); unlock_page(page); if (ret) { + hugetlb_put_quota(mapping); free_huge_page(page); goto out; } diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index effaa5bc5a96..86803c7262a5 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -47,7 +47,6 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) { struct inode *inode = file->f_dentry->d_inode; struct address_space *mapping = inode->i_mapping; - struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(inode->i_sb); loff_t len, vma_len; int ret; @@ -61,19 +60,8 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) return -EINVAL; vma_len = (loff_t)(vma->vm_end - vma->vm_start); - if (sbinfo->free_blocks >= 0) { /* Check if there is any size limit. */ - spin_lock(&sbinfo->stat_lock); - if ((vma_len >> HPAGE_SHIFT) <= sbinfo->free_blocks) { - sbinfo->free_blocks -= (vma_len >> HPAGE_SHIFT); - spin_unlock(&sbinfo->stat_lock); - } else { - spin_unlock(&sbinfo->stat_lock); - return -ENOMEM; - } - } down(&inode->i_sem); - update_atime(inode); vma->vm_flags |= VM_HUGETLB | VM_RESERVED; vma->vm_ops = &hugetlb_vm_ops; @@ -83,15 +71,6 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) inode->i_size = len; up(&inode->i_sem); - /* - * If the huge page allocation has failed then increment free_blocks. - */ - if ((ret != 0) && (sbinfo->free_blocks >= 0)) { - spin_lock(&sbinfo->stat_lock); - sbinfo->free_blocks += (vma_len >> HPAGE_SHIFT); - spin_unlock(&sbinfo->stat_lock); - } - return ret; } @@ -178,7 +157,6 @@ void truncate_huge_page(struct page *page) void truncate_hugepages(struct address_space *mapping, loff_t lstart) { - struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(mapping->host->i_sb); const pgoff_t start = lstart >> HPAGE_SHIFT; struct pagevec pvec; pgoff_t next; @@ -203,11 +181,7 @@ void truncate_hugepages(struct address_space *mapping, loff_t lstart) ++next; truncate_huge_page(page); unlock_page(page); - if (sbinfo->free_blocks >= 0) { - spin_lock(&sbinfo->stat_lock); - sbinfo->free_blocks++; - spin_unlock(&sbinfo->stat_lock); - } + hugetlb_put_quota(mapping); } huge_pagevec_release(&pvec); } @@ -712,6 +686,34 @@ hugetlbfs_fill_super(struct super_block *sb, void *data, int silent) return 0; } +int hugetlb_get_quota(struct address_space *mapping) +{ + int ret = 0; + struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(mapping->host->i_sb); + + if (sbinfo->free_blocks > -1) { + spin_lock(&sbinfo->stat_lock); + if (sbinfo->free_blocks > 0) + sbinfo->free_blocks--; + else + ret = -ENOMEM; + spin_unlock(&sbinfo->stat_lock); + } + + return ret; +} + +void hugetlb_put_quota(struct address_space *mapping) +{ + struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(mapping->host->i_sb); + + if (sbinfo->free_blocks > -1) { + spin_lock(&sbinfo->stat_lock); + sbinfo->free_blocks++; + spin_unlock(&sbinfo->stat_lock); + } +} + static struct super_block *hugetlbfs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index edc512ee628f..b3dd00de8dc3 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -98,6 +98,8 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb) extern struct file_operations hugetlbfs_file_operations; extern struct vm_operations_struct hugetlb_vm_ops; struct file *hugetlb_zero_setup(size_t); +int hugetlb_get_quota(struct address_space *mapping); +void hugetlb_put_quota(struct address_space *mapping); static inline int is_file_hugepages(struct file *file) { -- cgit v1.2.3