Skip to content

Commit b58fed8

Browse files
Ram PaiLinus Torvalds
authored andcommitted
[PATCH] lindent fs/namespace.c
Signed-off-by: Ram Pai <[email protected]> Signed-off-by: Al Viro <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 5addc5d commit b58fed8

File tree

1 file changed

+48
-49
lines changed

1 file changed

+48
-49
lines changed

fs/namespace.c

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,29 @@ static int event;
4343

4444
static struct list_head *mount_hashtable;
4545
static int hash_mask __read_mostly, hash_bits __read_mostly;
46-
static kmem_cache_t *mnt_cache;
46+
static kmem_cache_t *mnt_cache;
4747

4848
static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
4949
{
50-
unsigned long tmp = ((unsigned long) mnt / L1_CACHE_BYTES);
51-
tmp += ((unsigned long) dentry / L1_CACHE_BYTES);
50+
unsigned long tmp = ((unsigned long)mnt / L1_CACHE_BYTES);
51+
tmp += ((unsigned long)dentry / L1_CACHE_BYTES);
5252
tmp = tmp + (tmp >> hash_bits);
5353
return tmp & hash_mask;
5454
}
5555

5656
struct vfsmount *alloc_vfsmnt(const char *name)
5757
{
58-
struct vfsmount *mnt = kmem_cache_alloc(mnt_cache, GFP_KERNEL);
58+
struct vfsmount *mnt = kmem_cache_alloc(mnt_cache, GFP_KERNEL);
5959
if (mnt) {
6060
memset(mnt, 0, sizeof(struct vfsmount));
61-
atomic_set(&mnt->mnt_count,1);
61+
atomic_set(&mnt->mnt_count, 1);
6262
INIT_LIST_HEAD(&mnt->mnt_hash);
6363
INIT_LIST_HEAD(&mnt->mnt_child);
6464
INIT_LIST_HEAD(&mnt->mnt_mounts);
6565
INIT_LIST_HEAD(&mnt->mnt_list);
6666
INIT_LIST_HEAD(&mnt->mnt_expire);
6767
if (name) {
68-
int size = strlen(name)+1;
68+
int size = strlen(name) + 1;
6969
char *newname = kmalloc(size, GFP_KERNEL);
7070
if (newname) {
7171
memcpy(newname, name, size);
@@ -88,8 +88,8 @@ void free_vfsmnt(struct vfsmount *mnt)
8888
*/
8989
struct vfsmount *lookup_mnt(struct vfsmount *mnt, struct dentry *dentry)
9090
{
91-
struct list_head * head = mount_hashtable + hash(mnt, dentry);
92-
struct list_head * tmp = head;
91+
struct list_head *head = mount_hashtable + hash(mnt, dentry);
92+
struct list_head *tmp = head;
9393
struct vfsmount *p, *found = NULL;
9494

9595
spin_lock(&vfsmount_lock);
@@ -144,7 +144,7 @@ static void attach_mnt(struct vfsmount *mnt, struct nameidata *nd)
144144
{
145145
mnt->mnt_parent = mntget(nd->mnt);
146146
mnt->mnt_mountpoint = dget(nd->dentry);
147-
list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
147+
list_add(&mnt->mnt_hash, mount_hashtable + hash(nd->mnt, nd->dentry));
148148
list_add_tail(&mnt->mnt_child, &nd->mnt->mnt_mounts);
149149
nd->dentry->d_mounted++;
150150
}
@@ -165,8 +165,7 @@ static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root)
165165
return list_entry(next, struct vfsmount, mnt_child);
166166
}
167167

168-
static struct vfsmount *
169-
clone_mnt(struct vfsmount *old, struct dentry *root)
168+
static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root)
170169
{
171170
struct super_block *sb = old->mnt_sb;
172171
struct vfsmount *mnt = alloc_vfsmnt(old->mnt_devname);
@@ -258,7 +257,7 @@ static void *m_next(struct seq_file *m, void *v, loff_t *pos)
258257
struct namespace *n = m->private;
259258
struct list_head *p = ((struct vfsmount *)v)->mnt_list.next;
260259
(*pos)++;
261-
return p==&n->list ? NULL : list_entry(p, struct vfsmount, mnt_list);
260+
return p == &n->list ? NULL : list_entry(p, struct vfsmount, mnt_list);
262261
}
263262

264263
static void m_stop(struct seq_file *m, void *v)
@@ -344,7 +343,8 @@ int may_umount_tree(struct vfsmount *mnt)
344343
next = this_parent->mnt_mounts.next;
345344
resume:
346345
while (next != &this_parent->mnt_mounts) {
347-
struct vfsmount *p = list_entry(next, struct vfsmount, mnt_child);
346+
struct vfsmount *p =
347+
list_entry(next, struct vfsmount, mnt_child);
348348

349349
next = next->next;
350350

@@ -425,7 +425,7 @@ static void umount_tree(struct vfsmount *mnt)
425425

426426
static int do_umount(struct vfsmount *mnt, int flags)
427427
{
428-
struct super_block * sb = mnt->mnt_sb;
428+
struct super_block *sb = mnt->mnt_sb;
429429
int retval;
430430

431431
retval = security_sb_umount(mnt, flags);
@@ -461,7 +461,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
461461
*/
462462

463463
lock_kernel();
464-
if( (flags&MNT_FORCE) && sb->s_op->umount_begin)
464+
if ((flags & MNT_FORCE) && sb->s_op->umount_begin)
465465
sb->s_op->umount_begin(sb);
466466
unlock_kernel();
467467

@@ -543,12 +543,11 @@ asmlinkage long sys_umount(char __user * name, int flags)
543543
#ifdef __ARCH_WANT_SYS_OLDUMOUNT
544544

545545
/*
546-
* The 2.0 compatible umount. No flags.
546+
* The 2.0 compatible umount. No flags.
547547
*/
548-
549548
asmlinkage long sys_oldumount(char __user * name)
550549
{
551-
return sys_umount(name,0);
550+
return sys_umount(name, 0);
552551
}
553552

554553
#endif
@@ -571,8 +570,7 @@ static int mount_is_safe(struct nameidata *nd)
571570
#endif
572571
}
573572

574-
static int
575-
lives_below_in_same_fs(struct dentry *d, struct dentry *dentry)
573+
static int lives_below_in_same_fs(struct dentry *d, struct dentry *dentry)
576574
{
577575
while (1) {
578576
if (d == dentry)
@@ -616,7 +614,7 @@ static struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry)
616614
}
617615
}
618616
return res;
619-
Enomem:
617+
Enomem:
620618
if (res) {
621619
spin_lock(&vfsmount_lock);
622620
umount_tree(res);
@@ -718,12 +716,11 @@ static int do_loopback(struct nameidata *nd, char *old_name, int recurse)
718716
* If you've mounted a non-root directory somewhere and want to do remount
719717
* on it - tough luck.
720718
*/
721-
722719
static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
723720
void *data)
724721
{
725722
int err;
726-
struct super_block * sb = nd->mnt->mnt_sb;
723+
struct super_block *sb = nd->mnt->mnt_sb;
727724

728725
if (!capable(CAP_SYS_ADMIN))
729726
return -EPERM;
@@ -737,7 +734,7 @@ static int do_remount(struct nameidata *nd, int flags, int mnt_flags,
737734
down_write(&sb->s_umount);
738735
err = do_remount_sb(sb, flags, data, 0);
739736
if (!err)
740-
nd->mnt->mnt_flags=mnt_flags;
737+
nd->mnt->mnt_flags = mnt_flags;
741738
up_write(&sb->s_umount);
742739
if (!err)
743740
security_sb_post_remount(nd->mnt, flags, data);
@@ -758,7 +755,7 @@ static int do_move_mount(struct nameidata *nd, char *old_name)
758755
return err;
759756

760757
down_write(&current->namespace->sem);
761-
while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry))
758+
while (d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry))
762759
;
763760
err = -EINVAL;
764761
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt))
@@ -785,7 +782,7 @@ static int do_move_mount(struct nameidata *nd, char *old_name)
785782
goto out2;
786783

787784
err = -ELOOP;
788-
for (p = nd->mnt; p->mnt_parent!=p; p = p->mnt_parent)
785+
for (p = nd->mnt; p->mnt_parent != p; p = p->mnt_parent)
789786
if (p == old_nd.mnt)
790787
goto out2;
791788
err = 0;
@@ -843,7 +840,7 @@ int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd,
843840

844841
down_write(&current->namespace->sem);
845842
/* Something was mounted here while we slept */
846-
while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry))
843+
while (d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry))
847844
;
848845
err = -EINVAL;
849846
if (!check_mnt(nd->mnt))
@@ -986,8 +983,8 @@ EXPORT_SYMBOL_GPL(mark_mounts_for_expiry);
986983
* Note that this function differs from copy_from_user() in that it will oops
987984
* on bad values of `to', rather than returning a short copy.
988985
*/
989-
static long
990-
exact_copy_from_user(void *to, const void __user *from, unsigned long n)
986+
static long exact_copy_from_user(void *to, const void __user * from,
987+
unsigned long n)
991988
{
992989
char *t = to;
993990
const char __user *f = from;
@@ -1008,12 +1005,12 @@ exact_copy_from_user(void *to, const void __user *from, unsigned long n)
10081005
return n;
10091006
}
10101007

1011-
int copy_mount_options(const void __user *data, unsigned long *where)
1008+
int copy_mount_options(const void __user * data, unsigned long *where)
10121009
{
10131010
int i;
10141011
unsigned long page;
10151012
unsigned long size;
1016-
1013+
10171014
*where = 0;
10181015
if (!data)
10191016
return 0;
@@ -1032,7 +1029,7 @@ int copy_mount_options(const void __user *data, unsigned long *where)
10321029

10331030
i = size - exact_copy_from_user((void *)page, data, size);
10341031
if (!i) {
1035-
free_page(page);
1032+
free_page(page);
10361033
return -EFAULT;
10371034
}
10381035
if (i != PAGE_SIZE)
@@ -1055,7 +1052,7 @@ int copy_mount_options(const void __user *data, unsigned long *where)
10551052
* Therefore, if this magic number is present, it carries no information
10561053
* and must be discarded.
10571054
*/
1058-
long do_mount(char * dev_name, char * dir_name, char *type_page,
1055+
long do_mount(char *dev_name, char *dir_name, char *type_page,
10591056
unsigned long flags, void *data_page)
10601057
{
10611058
struct nameidata nd;
@@ -1083,7 +1080,7 @@ long do_mount(char * dev_name, char * dir_name, char *type_page,
10831080
mnt_flags |= MNT_NODEV;
10841081
if (flags & MS_NOEXEC)
10851082
mnt_flags |= MNT_NOEXEC;
1086-
flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);
1083+
flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE);
10871084

10881085
/* ... and get the mountpoint */
10891086
retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
@@ -1207,7 +1204,7 @@ asmlinkage long sys_mount(char __user * dev_name, char __user * dir_name,
12071204
unsigned long dev_page;
12081205
char *dir_page;
12091206

1210-
retval = copy_mount_options (type, &type_page);
1207+
retval = copy_mount_options(type, &type_page);
12111208
if (retval < 0)
12121209
return retval;
12131210

@@ -1216,17 +1213,17 @@ asmlinkage long sys_mount(char __user * dev_name, char __user * dir_name,
12161213
if (IS_ERR(dir_page))
12171214
goto out1;
12181215

1219-
retval = copy_mount_options (dev_name, &dev_page);
1216+
retval = copy_mount_options(dev_name, &dev_page);
12201217
if (retval < 0)
12211218
goto out2;
12221219

1223-
retval = copy_mount_options (data, &data_page);
1220+
retval = copy_mount_options(data, &data_page);
12241221
if (retval < 0)
12251222
goto out3;
12261223

12271224
lock_kernel();
1228-
retval = do_mount((char*)dev_page, dir_page, (char*)type_page,
1229-
flags, (void*)data_page);
1225+
retval = do_mount((char *)dev_page, dir_page, (char *)type_page,
1226+
flags, (void *)data_page);
12301227
unlock_kernel();
12311228
free_page(data_page);
12321229

@@ -1295,9 +1292,11 @@ static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
12951292
if (fs) {
12961293
atomic_inc(&fs->count);
12971294
task_unlock(p);
1298-
if (fs->root==old_nd->dentry&&fs->rootmnt==old_nd->mnt)
1295+
if (fs->root == old_nd->dentry
1296+
&& fs->rootmnt == old_nd->mnt)
12991297
set_fs_root(fs, new_nd->mnt, new_nd->dentry);
1300-
if (fs->pwd==old_nd->dentry&&fs->pwdmnt==old_nd->mnt)
1298+
if (fs->pwd == old_nd->dentry
1299+
&& fs->pwdmnt == old_nd->mnt)
13011300
set_fs_pwd(fs, new_nd->mnt, new_nd->dentry);
13021301
put_fs_struct(fs);
13031302
} else
@@ -1327,8 +1326,8 @@ static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
13271326
* though, so you may need to say mount --bind /nfs/my_root /nfs/my_root
13281327
* first.
13291328
*/
1330-
1331-
asmlinkage long sys_pivot_root(const char __user *new_root, const char __user *put_old)
1329+
asmlinkage long sys_pivot_root(const char __user * new_root,
1330+
const char __user * put_old)
13321331
{
13331332
struct vfsmount *tmp;
13341333
struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
@@ -1339,14 +1338,15 @@ asmlinkage long sys_pivot_root(const char __user *new_root, const char __user *p
13391338

13401339
lock_kernel();
13411340

1342-
error = __user_walk(new_root, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
1341+
error = __user_walk(new_root, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
1342+
&new_nd);
13431343
if (error)
13441344
goto out0;
13451345
error = -EINVAL;
13461346
if (!check_mnt(new_nd.mnt))
13471347
goto out1;
13481348

1349-
error = __user_walk(put_old, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
1349+
error = __user_walk(put_old, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &old_nd);
13501350
if (error)
13511351
goto out1;
13521352

@@ -1464,10 +1464,9 @@ void __init mnt_init(unsigned long mempages)
14641464
int i;
14651465

14661466
mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct vfsmount),
1467-
0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
1467+
0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL, NULL);
14681468

1469-
mount_hashtable = (struct list_head *)
1470-
__get_free_page(GFP_ATOMIC);
1469+
mount_hashtable = (struct list_head *)__get_free_page(GFP_ATOMIC);
14711470

14721471
if (!mount_hashtable)
14731472
panic("Failed to allocate mount hash table\n");
@@ -1489,7 +1488,7 @@ void __init mnt_init(unsigned long mempages)
14891488
* from the number of bits we can fit.
14901489
*/
14911490
nr_hash = 1UL << hash_bits;
1492-
hash_mask = nr_hash-1;
1491+
hash_mask = nr_hash - 1;
14931492

14941493
printk("Mount-cache hash table entries: %d\n", nr_hash);
14951494

0 commit comments

Comments
 (0)