diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/Makefile | 2 | ||||
-rw-r--r-- | fs/char_dev.c | 87 | ||||
-rw-r--r-- | fs/dcache.c | 50 | ||||
-rw-r--r-- | fs/hppfs/hppfs_kern.c | 14 | ||||
-rw-r--r-- | fs/locks.c | 45 | ||||
-rw-r--r-- | fs/msdos/namei.c | 15 | ||||
-rw-r--r-- | fs/namei.c | 3 | ||||
-rw-r--r-- | fs/proc/base.c | 13 | ||||
-rw-r--r-- | fs/proc/proc_misc.c | 163 | ||||
-rw-r--r-- | fs/select.c | 8 | ||||
-rw-r--r-- | fs/sync.c | 164 | ||||
-rw-r--r-- | fs/vfat/namei.c | 18 |
12 files changed, 284 insertions, 298 deletions
diff --git a/fs/Makefile b/fs/Makefile index f3a4f7077175..83bf478e786b 100644 --- a/fs/Makefile +++ b/fs/Makefile | |||
@@ -10,7 +10,7 @@ obj-y := open.o read_write.o file_table.o buffer.o bio.o super.o \ | |||
10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ | 10 | ioctl.o readdir.o select.o fifo.o locks.o dcache.o inode.o \ |
11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ | 11 | attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ |
12 | seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \ | 12 | seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \ |
13 | ioprio.o pnode.o drop_caches.o splice.o | 13 | ioprio.o pnode.o drop_caches.o splice.o sync.o |
14 | 14 | ||
15 | obj-$(CONFIG_INOTIFY) += inotify.o | 15 | obj-$(CONFIG_INOTIFY) += inotify.o |
16 | obj-$(CONFIG_EPOLL) += eventpoll.o | 16 | obj-$(CONFIG_EPOLL) += eventpoll.o |
diff --git a/fs/char_dev.c b/fs/char_dev.c index 4e1b849f912f..f3418f7a6e9d 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/smp_lock.h> | 16 | #include <linux/smp_lock.h> |
17 | #include <linux/devfs_fs_kernel.h> | 17 | #include <linux/devfs_fs_kernel.h> |
18 | #include <linux/seq_file.h> | ||
18 | 19 | ||
19 | #include <linux/kobject.h> | 20 | #include <linux/kobject.h> |
20 | #include <linux/kobj_map.h> | 21 | #include <linux/kobj_map.h> |
@@ -27,8 +28,6 @@ | |||
27 | 28 | ||
28 | static struct kobj_map *cdev_map; | 29 | static struct kobj_map *cdev_map; |
29 | 30 | ||
30 | #define MAX_PROBE_HASH 255 /* random */ | ||
31 | |||
32 | static DEFINE_MUTEX(chrdevs_lock); | 31 | static DEFINE_MUTEX(chrdevs_lock); |
33 | 32 | ||
34 | static struct char_device_struct { | 33 | static struct char_device_struct { |
@@ -39,93 +38,29 @@ static struct char_device_struct { | |||
39 | char name[64]; | 38 | char name[64]; |
40 | struct file_operations *fops; | 39 | struct file_operations *fops; |
41 | struct cdev *cdev; /* will die */ | 40 | struct cdev *cdev; /* will die */ |
42 | } *chrdevs[MAX_PROBE_HASH]; | 41 | } *chrdevs[CHRDEV_MAJOR_HASH_SIZE]; |
43 | 42 | ||
44 | /* index in the above */ | 43 | /* index in the above */ |
45 | static inline int major_to_index(int major) | 44 | static inline int major_to_index(int major) |
46 | { | 45 | { |
47 | return major % MAX_PROBE_HASH; | 46 | return major % CHRDEV_MAJOR_HASH_SIZE; |
48 | } | ||
49 | |||
50 | struct chrdev_info { | ||
51 | int index; | ||
52 | struct char_device_struct *cd; | ||
53 | }; | ||
54 | |||
55 | void *get_next_chrdev(void *dev) | ||
56 | { | ||
57 | struct chrdev_info *info; | ||
58 | |||
59 | if (dev == NULL) { | ||
60 | info = kmalloc(sizeof(*info), GFP_KERNEL); | ||
61 | if (!info) | ||
62 | goto out; | ||
63 | info->index=0; | ||
64 | info->cd = chrdevs[info->index]; | ||
65 | if (info->cd) | ||
66 | goto out; | ||
67 | } else { | ||
68 | info = dev; | ||
69 | } | ||
70 | |||
71 | while (info->index < ARRAY_SIZE(chrdevs)) { | ||
72 | if (info->cd) | ||
73 | info->cd = info->cd->next; | ||
74 | if (info->cd) | ||
75 | goto out; | ||
76 | /* | ||
77 | * No devices on this chain, move to the next | ||
78 | */ | ||
79 | info->index++; | ||
80 | info->cd = (info->index < ARRAY_SIZE(chrdevs)) ? | ||
81 | chrdevs[info->index] : NULL; | ||
82 | if (info->cd) | ||
83 | goto out; | ||
84 | } | ||
85 | |||
86 | out: | ||
87 | return info; | ||
88 | } | ||
89 | |||
90 | void *acquire_chrdev_list(void) | ||
91 | { | ||
92 | mutex_lock(&chrdevs_lock); | ||
93 | return get_next_chrdev(NULL); | ||
94 | } | ||
95 | |||
96 | void release_chrdev_list(void *dev) | ||
97 | { | ||
98 | mutex_unlock(&chrdevs_lock); | ||
99 | kfree(dev); | ||
100 | } | 47 | } |
101 | 48 | ||
49 | #ifdef CONFIG_PROC_FS | ||
102 | 50 | ||
103 | int count_chrdev_list(void) | 51 | void chrdev_show(struct seq_file *f, off_t offset) |
104 | { | 52 | { |
105 | struct char_device_struct *cd; | 53 | struct char_device_struct *cd; |
106 | int i, count; | ||
107 | |||
108 | count = 0; | ||
109 | 54 | ||
110 | for (i = 0; i < ARRAY_SIZE(chrdevs) ; i++) { | 55 | if (offset < CHRDEV_MAJOR_HASH_SIZE) { |
111 | for (cd = chrdevs[i]; cd; cd = cd->next) | 56 | mutex_lock(&chrdevs_lock); |
112 | count++; | 57 | for (cd = chrdevs[offset]; cd; cd = cd->next) |
58 | seq_printf(f, "%3d %s\n", cd->major, cd->name); | ||
59 | mutex_unlock(&chrdevs_lock); | ||
113 | } | 60 | } |
114 | |||
115 | return count; | ||
116 | } | 61 | } |
117 | 62 | ||
118 | int get_chrdev_info(void *dev, int *major, char **name) | 63 | #endif /* CONFIG_PROC_FS */ |
119 | { | ||
120 | struct chrdev_info *info = dev; | ||
121 | |||
122 | if (info->cd == NULL) | ||
123 | return 1; | ||
124 | |||
125 | *major = info->cd->major; | ||
126 | *name = info->cd->name; | ||
127 | return 0; | ||
128 | } | ||
129 | 64 | ||
130 | /* | 65 | /* |
131 | * Register a single major with a specified minor range. | 66 | * Register a single major with a specified minor range. |
diff --git a/fs/dcache.c b/fs/dcache.c index 19458d399502..940d188e5d14 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1101,6 +1101,32 @@ next: | |||
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | /** | 1103 | /** |
1104 | * d_hash_and_lookup - hash the qstr then search for a dentry | ||
1105 | * @dir: Directory to search in | ||
1106 | * @name: qstr of name we wish to find | ||
1107 | * | ||
1108 | * On hash failure or on lookup failure NULL is returned. | ||
1109 | */ | ||
1110 | struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) | ||
1111 | { | ||
1112 | struct dentry *dentry = NULL; | ||
1113 | |||
1114 | /* | ||
1115 | * Check for a fs-specific hash function. Note that we must | ||
1116 | * calculate the standard hash first, as the d_op->d_hash() | ||
1117 | * routine may choose to leave the hash value unchanged. | ||
1118 | */ | ||
1119 | name->hash = full_name_hash(name->name, name->len); | ||
1120 | if (dir->d_op && dir->d_op->d_hash) { | ||
1121 | if (dir->d_op->d_hash(dir, name) < 0) | ||
1122 | goto out; | ||
1123 | } | ||
1124 | dentry = d_lookup(dir, name); | ||
1125 | out: | ||
1126 | return dentry; | ||
1127 | } | ||
1128 | |||
1129 | /** | ||
1104 | * d_validate - verify dentry provided from insecure source | 1130 | * d_validate - verify dentry provided from insecure source |
1105 | * @dentry: The dentry alleged to be valid child of @dparent | 1131 | * @dentry: The dentry alleged to be valid child of @dparent |
1106 | * @dparent: The parent dentry (known to be valid) | 1132 | * @dparent: The parent dentry (known to be valid) |
@@ -1172,11 +1198,11 @@ void d_delete(struct dentry * dentry) | |||
1172 | spin_lock(&dentry->d_lock); | 1198 | spin_lock(&dentry->d_lock); |
1173 | isdir = S_ISDIR(dentry->d_inode->i_mode); | 1199 | isdir = S_ISDIR(dentry->d_inode->i_mode); |
1174 | if (atomic_read(&dentry->d_count) == 1) { | 1200 | if (atomic_read(&dentry->d_count) == 1) { |
1175 | /* remove this and other inotify debug checks after 2.6.18 */ | ||
1176 | dentry->d_flags &= ~DCACHE_INOTIFY_PARENT_WATCHED; | ||
1177 | |||
1178 | dentry_iput(dentry); | 1201 | dentry_iput(dentry); |
1179 | fsnotify_nameremove(dentry, isdir); | 1202 | fsnotify_nameremove(dentry, isdir); |
1203 | |||
1204 | /* remove this and other inotify debug checks after 2.6.18 */ | ||
1205 | dentry->d_flags &= ~DCACHE_INOTIFY_PARENT_WATCHED; | ||
1180 | return; | 1206 | return; |
1181 | } | 1207 | } |
1182 | 1208 | ||
@@ -1616,26 +1642,12 @@ ino_t find_inode_number(struct dentry *dir, struct qstr *name) | |||
1616 | struct dentry * dentry; | 1642 | struct dentry * dentry; |
1617 | ino_t ino = 0; | 1643 | ino_t ino = 0; |
1618 | 1644 | ||
1619 | /* | 1645 | dentry = d_hash_and_lookup(dir, name); |
1620 | * Check for a fs-specific hash function. Note that we must | 1646 | if (dentry) { |
1621 | * calculate the standard hash first, as the d_op->d_hash() | ||
1622 | * routine may choose to leave the hash value unchanged. | ||
1623 | */ | ||
1624 | name->hash = full_name_hash(name->name, name->len); | ||
1625 | if (dir->d_op && dir->d_op->d_hash) | ||
1626 | { | ||
1627 | if (dir->d_op->d_hash(dir, name) != 0) | ||
1628 | goto out; | ||
1629 | } | ||
1630 | |||
1631 | dentry = d_lookup(dir, name); | ||
1632 | if (dentry) | ||
1633 | { | ||
1634 | if (dentry->d_inode) | 1647 | if (dentry->d_inode) |
1635 | ino = dentry->d_inode->i_ino; | 1648 | ino = dentry->d_inode->i_ino; |
1636 | dput(dentry); | 1649 | dput(dentry); |
1637 | } | 1650 | } |
1638 | out: | ||
1639 | return ino; | 1651 | return ino; |
1640 | } | 1652 | } |
1641 | 1653 | ||
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs_kern.c index 2ba20cdb5baa..5e6363be246f 100644 --- a/fs/hppfs/hppfs_kern.c +++ b/fs/hppfs/hppfs_kern.c | |||
@@ -216,10 +216,10 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, | |||
216 | static struct inode_operations hppfs_file_iops = { | 216 | static struct inode_operations hppfs_file_iops = { |
217 | }; | 217 | }; |
218 | 218 | ||
219 | static ssize_t read_proc(struct file *file, char *buf, ssize_t count, | 219 | static ssize_t read_proc(struct file *file, char __user *buf, ssize_t count, |
220 | loff_t *ppos, int is_user) | 220 | loff_t *ppos, int is_user) |
221 | { | 221 | { |
222 | ssize_t (*read)(struct file *, char *, size_t, loff_t *); | 222 | ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); |
223 | ssize_t n; | 223 | ssize_t n; |
224 | 224 | ||
225 | read = file->f_dentry->d_inode->i_fop->read; | 225 | read = file->f_dentry->d_inode->i_fop->read; |
@@ -236,7 +236,7 @@ static ssize_t read_proc(struct file *file, char *buf, ssize_t count, | |||
236 | return n; | 236 | return n; |
237 | } | 237 | } |
238 | 238 | ||
239 | static ssize_t hppfs_read_file(int fd, char *buf, ssize_t count) | 239 | static ssize_t hppfs_read_file(int fd, char __user *buf, ssize_t count) |
240 | { | 240 | { |
241 | ssize_t n; | 241 | ssize_t n; |
242 | int cur, err; | 242 | int cur, err; |
@@ -274,7 +274,7 @@ static ssize_t hppfs_read_file(int fd, char *buf, ssize_t count) | |||
274 | return n; | 274 | return n; |
275 | } | 275 | } |
276 | 276 | ||
277 | static ssize_t hppfs_read(struct file *file, char *buf, size_t count, | 277 | static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count, |
278 | loff_t *ppos) | 278 | loff_t *ppos) |
279 | { | 279 | { |
280 | struct hppfs_private *hppfs = file->private_data; | 280 | struct hppfs_private *hppfs = file->private_data; |
@@ -313,12 +313,12 @@ static ssize_t hppfs_read(struct file *file, char *buf, size_t count, | |||
313 | return(count); | 313 | return(count); |
314 | } | 314 | } |
315 | 315 | ||
316 | static ssize_t hppfs_write(struct file *file, const char *buf, size_t len, | 316 | static ssize_t hppfs_write(struct file *file, const char __user *buf, size_t len, |
317 | loff_t *ppos) | 317 | loff_t *ppos) |
318 | { | 318 | { |
319 | struct hppfs_private *data = file->private_data; | 319 | struct hppfs_private *data = file->private_data; |
320 | struct file *proc_file = data->proc_file; | 320 | struct file *proc_file = data->proc_file; |
321 | ssize_t (*write)(struct file *, const char *, size_t, loff_t *); | 321 | ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); |
322 | int err; | 322 | int err; |
323 | 323 | ||
324 | write = proc_file->f_dentry->d_inode->i_fop->write; | 324 | write = proc_file->f_dentry->d_inode->i_fop->write; |
@@ -658,7 +658,7 @@ static struct super_operations hppfs_sbops = { | |||
658 | .statfs = hppfs_statfs, | 658 | .statfs = hppfs_statfs, |
659 | }; | 659 | }; |
660 | 660 | ||
661 | static int hppfs_readlink(struct dentry *dentry, char *buffer, int buflen) | 661 | static int hppfs_readlink(struct dentry *dentry, char __user *buffer, int buflen) |
662 | { | 662 | { |
663 | struct file *proc_file; | 663 | struct file *proc_file; |
664 | struct dentry *proc_dentry; | 664 | struct dentry *proc_dentry; |
diff --git a/fs/locks.c b/fs/locks.c index 4d9e71d43e7e..dda83d6cd48b 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -168,18 +168,9 @@ static void locks_release_private(struct file_lock *fl) | |||
168 | /* Free a lock which is not in use. */ | 168 | /* Free a lock which is not in use. */ |
169 | static void locks_free_lock(struct file_lock *fl) | 169 | static void locks_free_lock(struct file_lock *fl) |
170 | { | 170 | { |
171 | if (fl == NULL) { | 171 | BUG_ON(waitqueue_active(&fl->fl_wait)); |
172 | BUG(); | 172 | BUG_ON(!list_empty(&fl->fl_block)); |
173 | return; | 173 | BUG_ON(!list_empty(&fl->fl_link)); |
174 | } | ||
175 | if (waitqueue_active(&fl->fl_wait)) | ||
176 | panic("Attempting to free lock with active wait queue"); | ||
177 | |||
178 | if (!list_empty(&fl->fl_block)) | ||
179 | panic("Attempting to free lock with active block list"); | ||
180 | |||
181 | if (!list_empty(&fl->fl_link)) | ||
182 | panic("Attempting to free lock on active lock list"); | ||
183 | 174 | ||
184 | locks_release_private(fl); | 175 | locks_release_private(fl); |
185 | kmem_cache_free(filelock_cache, fl); | 176 | kmem_cache_free(filelock_cache, fl); |
@@ -735,8 +726,9 @@ EXPORT_SYMBOL(posix_locks_deadlock); | |||
735 | * at the head of the list, but that's secret knowledge known only to | 726 | * at the head of the list, but that's secret knowledge known only to |
736 | * flock_lock_file and posix_lock_file. | 727 | * flock_lock_file and posix_lock_file. |
737 | */ | 728 | */ |
738 | static int flock_lock_file(struct file *filp, struct file_lock *new_fl) | 729 | static int flock_lock_file(struct file *filp, struct file_lock *request) |
739 | { | 730 | { |
731 | struct file_lock *new_fl = NULL; | ||
740 | struct file_lock **before; | 732 | struct file_lock **before; |
741 | struct inode * inode = filp->f_dentry->d_inode; | 733 | struct inode * inode = filp->f_dentry->d_inode; |
742 | int error = 0; | 734 | int error = 0; |
@@ -751,17 +743,19 @@ static int flock_lock_file(struct file *filp, struct file_lock *new_fl) | |||
751 | continue; | 743 | continue; |
752 | if (filp != fl->fl_file) | 744 | if (filp != fl->fl_file) |
753 | continue; | 745 | continue; |
754 | if (new_fl->fl_type == fl->fl_type) | 746 | if (request->fl_type == fl->fl_type) |
755 | goto out; | 747 | goto out; |
756 | found = 1; | 748 | found = 1; |
757 | locks_delete_lock(before); | 749 | locks_delete_lock(before); |
758 | break; | 750 | break; |
759 | } | 751 | } |
760 | unlock_kernel(); | ||
761 | 752 | ||
762 | if (new_fl->fl_type == F_UNLCK) | 753 | if (request->fl_type == F_UNLCK) |
763 | return 0; | 754 | goto out; |
764 | 755 | ||
756 | new_fl = locks_alloc_lock(); | ||
757 | if (new_fl == NULL) | ||
758 | goto out; | ||
765 | /* | 759 | /* |
766 | * If a higher-priority process was blocked on the old file lock, | 760 | * If a higher-priority process was blocked on the old file lock, |
767 | * give it the opportunity to lock the file. | 761 | * give it the opportunity to lock the file. |
@@ -769,26 +763,27 @@ static int flock_lock_file(struct file *filp, struct file_lock *new_fl) | |||
769 | if (found) | 763 | if (found) |
770 | cond_resched(); | 764 | cond_resched(); |
771 | 765 | ||
772 | lock_kernel(); | ||
773 | for_each_lock(inode, before) { | 766 | for_each_lock(inode, before) { |
774 | struct file_lock *fl = *before; | 767 | struct file_lock *fl = *before; |
775 | if (IS_POSIX(fl)) | 768 | if (IS_POSIX(fl)) |
776 | break; | 769 | break; |
777 | if (IS_LEASE(fl)) | 770 | if (IS_LEASE(fl)) |
778 | continue; | 771 | continue; |
779 | if (!flock_locks_conflict(new_fl, fl)) | 772 | if (!flock_locks_conflict(request, fl)) |
780 | continue; | 773 | continue; |
781 | error = -EAGAIN; | 774 | error = -EAGAIN; |
782 | if (new_fl->fl_flags & FL_SLEEP) { | 775 | if (request->fl_flags & FL_SLEEP) |
783 | locks_insert_block(fl, new_fl); | 776 | locks_insert_block(fl, request); |
784 | } | ||
785 | goto out; | 777 | goto out; |
786 | } | 778 | } |
779 | locks_copy_lock(new_fl, request); | ||
787 | locks_insert_lock(&inode->i_flock, new_fl); | 780 | locks_insert_lock(&inode->i_flock, new_fl); |
788 | error = 0; | 781 | new_fl = NULL; |
789 | 782 | ||
790 | out: | 783 | out: |
791 | unlock_kernel(); | 784 | unlock_kernel(); |
785 | if (new_fl) | ||
786 | locks_free_lock(new_fl); | ||
792 | return error; | 787 | return error; |
793 | } | 788 | } |
794 | 789 | ||
@@ -1569,9 +1564,7 @@ asmlinkage long sys_flock(unsigned int fd, unsigned int cmd) | |||
1569 | error = flock_lock_file_wait(filp, lock); | 1564 | error = flock_lock_file_wait(filp, lock); |
1570 | 1565 | ||
1571 | out_free: | 1566 | out_free: |
1572 | if (list_empty(&lock->fl_link)) { | 1567 | locks_free_lock(lock); |
1573 | locks_free_lock(lock); | ||
1574 | } | ||
1575 | 1568 | ||
1576 | out_putf: | 1569 | out_putf: |
1577 | fput(filp); | 1570 | fput(filp); |
diff --git a/fs/msdos/namei.c b/fs/msdos/namei.c index 626a367bcd81..5b76ccd19e3f 100644 --- a/fs/msdos/namei.c +++ b/fs/msdos/namei.c | |||
@@ -12,14 +12,6 @@ | |||
12 | #include <linux/msdos_fs.h> | 12 | #include <linux/msdos_fs.h> |
13 | #include <linux/smp_lock.h> | 13 | #include <linux/smp_lock.h> |
14 | 14 | ||
15 | /* MS-DOS "device special files" */ | ||
16 | static const unsigned char *reserved_names[] = { | ||
17 | "CON ", "PRN ", "NUL ", "AUX ", | ||
18 | "LPT1 ", "LPT2 ", "LPT3 ", "LPT4 ", | ||
19 | "COM1 ", "COM2 ", "COM3 ", "COM4 ", | ||
20 | NULL | ||
21 | }; | ||
22 | |||
23 | /* Characters that are undesirable in an MS-DOS file name */ | 15 | /* Characters that are undesirable in an MS-DOS file name */ |
24 | static unsigned char bad_chars[] = "*?<>|\""; | 16 | static unsigned char bad_chars[] = "*?<>|\""; |
25 | static unsigned char bad_if_strict_pc[] = "+=,; "; | 17 | static unsigned char bad_if_strict_pc[] = "+=,; "; |
@@ -40,7 +32,6 @@ static int msdos_format_name(const unsigned char *name, int len, | |||
40 | */ | 32 | */ |
41 | { | 33 | { |
42 | unsigned char *walk; | 34 | unsigned char *walk; |
43 | const unsigned char **reserved; | ||
44 | unsigned char c; | 35 | unsigned char c; |
45 | int space; | 36 | int space; |
46 | 37 | ||
@@ -127,11 +118,7 @@ static int msdos_format_name(const unsigned char *name, int len, | |||
127 | } | 118 | } |
128 | while (walk - res < MSDOS_NAME) | 119 | while (walk - res < MSDOS_NAME) |
129 | *walk++ = ' '; | 120 | *walk++ = ' '; |
130 | if (!opts->atari) | 121 | |
131 | /* GEMDOS is less stupid and has no reserved names */ | ||
132 | for (reserved = reserved_names; *reserved; reserved++) | ||
133 | if (!strncmp(res, *reserved, 8)) | ||
134 | return -EINVAL; | ||
135 | return 0; | 122 | return 0; |
136 | } | 123 | } |
137 | 124 | ||
diff --git a/fs/namei.c b/fs/namei.c index 22f6e8d16aa8..96723ae83c89 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1254,7 +1254,7 @@ out: | |||
1254 | return dentry; | 1254 | return dentry; |
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | struct dentry * lookup_hash(struct nameidata *nd) | 1257 | static struct dentry *lookup_hash(struct nameidata *nd) |
1258 | { | 1258 | { |
1259 | return __lookup_hash(&nd->last, nd->dentry, nd); | 1259 | return __lookup_hash(&nd->last, nd->dentry, nd); |
1260 | } | 1260 | } |
@@ -2697,7 +2697,6 @@ EXPORT_SYMBOL(follow_up); | |||
2697 | EXPORT_SYMBOL(get_write_access); /* binfmt_aout */ | 2697 | EXPORT_SYMBOL(get_write_access); /* binfmt_aout */ |
2698 | EXPORT_SYMBOL(getname); | 2698 | EXPORT_SYMBOL(getname); |
2699 | EXPORT_SYMBOL(lock_rename); | 2699 | EXPORT_SYMBOL(lock_rename); |
2700 | EXPORT_SYMBOL(lookup_hash); | ||
2701 | EXPORT_SYMBOL(lookup_one_len); | 2700 | EXPORT_SYMBOL(lookup_one_len); |
2702 | EXPORT_SYMBOL(page_follow_link_light); | 2701 | EXPORT_SYMBOL(page_follow_link_light); |
2703 | EXPORT_SYMBOL(page_put_link); | 2702 | EXPORT_SYMBOL(page_put_link); |
diff --git a/fs/proc/base.c b/fs/proc/base.c index 8f1f49ceebec..a3a3eecef689 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -534,12 +534,15 @@ static int proc_oom_score(struct task_struct *task, char *buffer) | |||
534 | 534 | ||
535 | /* If the process being read is separated by chroot from the reading process, | 535 | /* If the process being read is separated by chroot from the reading process, |
536 | * don't let the reader access the threads. | 536 | * don't let the reader access the threads. |
537 | * | ||
538 | * note: this does dput(root) and mntput(vfsmnt) on exit. | ||
537 | */ | 539 | */ |
538 | static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt) | 540 | static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt) |
539 | { | 541 | { |
540 | struct dentry *de, *base; | 542 | struct dentry *de, *base; |
541 | struct vfsmount *our_vfsmnt, *mnt; | 543 | struct vfsmount *our_vfsmnt, *mnt; |
542 | int res = 0; | 544 | int res = 0; |
545 | |||
543 | read_lock(¤t->fs->lock); | 546 | read_lock(¤t->fs->lock); |
544 | our_vfsmnt = mntget(current->fs->rootmnt); | 547 | our_vfsmnt = mntget(current->fs->rootmnt); |
545 | base = dget(current->fs->root); | 548 | base = dget(current->fs->root); |
@@ -549,11 +552,11 @@ static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt) | |||
549 | de = root; | 552 | de = root; |
550 | mnt = vfsmnt; | 553 | mnt = vfsmnt; |
551 | 554 | ||
552 | while (vfsmnt != our_vfsmnt) { | 555 | while (mnt != our_vfsmnt) { |
553 | if (vfsmnt == vfsmnt->mnt_parent) | 556 | if (mnt == mnt->mnt_parent) |
554 | goto out; | 557 | goto out; |
555 | de = vfsmnt->mnt_mountpoint; | 558 | de = mnt->mnt_mountpoint; |
556 | vfsmnt = vfsmnt->mnt_parent; | 559 | mnt = mnt->mnt_parent; |
557 | } | 560 | } |
558 | 561 | ||
559 | if (!is_subdir(de, base)) | 562 | if (!is_subdir(de, base)) |
@@ -564,7 +567,7 @@ exit: | |||
564 | dput(base); | 567 | dput(base); |
565 | mntput(our_vfsmnt); | 568 | mntput(our_vfsmnt); |
566 | dput(root); | 569 | dput(root); |
567 | mntput(mnt); | 570 | mntput(vfsmnt); |
568 | return res; | 571 | return res; |
569 | out: | 572 | out: |
570 | spin_unlock(&vfsmount_lock); | 573 | spin_unlock(&vfsmount_lock); |
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index ef5a3323f4b5..5c10ea157425 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c | |||
@@ -249,144 +249,60 @@ static int cpuinfo_open(struct inode *inode, struct file *file) | |||
249 | return seq_open(file, &cpuinfo_op); | 249 | return seq_open(file, &cpuinfo_op); |
250 | } | 250 | } |
251 | 251 | ||
252 | enum devinfo_states { | 252 | static struct file_operations proc_cpuinfo_operations = { |
253 | CHR_HDR, | 253 | .open = cpuinfo_open, |
254 | CHR_LIST, | 254 | .read = seq_read, |
255 | BLK_HDR, | 255 | .llseek = seq_lseek, |
256 | BLK_LIST, | 256 | .release = seq_release, |
257 | DEVINFO_DONE | ||
258 | }; | ||
259 | |||
260 | struct devinfo_state { | ||
261 | void *chrdev; | ||
262 | void *blkdev; | ||
263 | unsigned int num_records; | ||
264 | unsigned int cur_record; | ||
265 | enum devinfo_states state; | ||
266 | }; | 257 | }; |
267 | 258 | ||
268 | static void *devinfo_start(struct seq_file *f, loff_t *pos) | 259 | static int devinfo_show(struct seq_file *f, void *v) |
269 | { | 260 | { |
270 | struct devinfo_state *info = f->private; | 261 | int i = *(loff_t *) v; |
271 | 262 | ||
272 | if (*pos) { | 263 | if (i < CHRDEV_MAJOR_HASH_SIZE) { |
273 | if ((info) && (*pos <= info->num_records)) | 264 | if (i == 0) |
274 | return info; | 265 | seq_printf(f, "Character devices:\n"); |
275 | return NULL; | 266 | chrdev_show(f, i); |
267 | } else { | ||
268 | i -= CHRDEV_MAJOR_HASH_SIZE; | ||
269 | if (i == 0) | ||
270 | seq_printf(f, "\nBlock devices:\n"); | ||
271 | blkdev_show(f, i); | ||
276 | } | 272 | } |
277 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 273 | return 0; |
278 | f->private = info; | ||
279 | info->chrdev = acquire_chrdev_list(); | ||
280 | info->blkdev = acquire_blkdev_list(); | ||
281 | info->state = CHR_HDR; | ||
282 | info->num_records = count_chrdev_list(); | ||
283 | info->num_records += count_blkdev_list(); | ||
284 | info->num_records += 2; /* Character and Block headers */ | ||
285 | *pos = 1; | ||
286 | info->cur_record = *pos; | ||
287 | return info; | ||
288 | } | 274 | } |
289 | 275 | ||
290 | static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos) | 276 | static void *devinfo_start(struct seq_file *f, loff_t *pos) |
291 | { | 277 | { |
292 | int idummy; | 278 | if (*pos < (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE)) |
293 | char *ndummy; | 279 | return pos; |
294 | struct devinfo_state *info = f->private; | 280 | return NULL; |
295 | |||
296 | switch (info->state) { | ||
297 | case CHR_HDR: | ||
298 | info->state = CHR_LIST; | ||
299 | (*pos)++; | ||
300 | /*fallthrough*/ | ||
301 | case CHR_LIST: | ||
302 | if (get_chrdev_info(info->chrdev,&idummy,&ndummy)) { | ||
303 | /* | ||
304 | * The character dev list is complete | ||
305 | */ | ||
306 | info->state = BLK_HDR; | ||
307 | } else { | ||
308 | info->chrdev = get_next_chrdev(info->chrdev); | ||
309 | } | ||
310 | (*pos)++; | ||
311 | break; | ||
312 | case BLK_HDR: | ||
313 | info->state = BLK_LIST; | ||
314 | (*pos)++; | ||
315 | /*fallthrough*/ | ||
316 | case BLK_LIST: | ||
317 | if (get_blkdev_info(info->blkdev,&idummy,&ndummy)) { | ||
318 | /* | ||
319 | * The block dev list is complete | ||
320 | */ | ||
321 | info->state = DEVINFO_DONE; | ||
322 | } else { | ||
323 | info->blkdev = get_next_blkdev(info->blkdev); | ||
324 | } | ||
325 | (*pos)++; | ||
326 | break; | ||
327 | case DEVINFO_DONE: | ||
328 | (*pos)++; | ||
329 | info->cur_record = *pos; | ||
330 | info = NULL; | ||
331 | break; | ||
332 | default: | ||
333 | break; | ||
334 | } | ||
335 | if (info) | ||
336 | info->cur_record = *pos; | ||
337 | return info; | ||
338 | } | 281 | } |
339 | 282 | ||
340 | static void devinfo_stop(struct seq_file *f, void *v) | 283 | static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos) |
341 | { | 284 | { |
342 | struct devinfo_state *info = f->private; | 285 | (*pos)++; |
343 | 286 | if (*pos >= (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE)) | |
344 | if (info) { | 287 | return NULL; |
345 | release_chrdev_list(info->chrdev); | 288 | return pos; |
346 | release_blkdev_list(info->blkdev); | ||
347 | f->private = NULL; | ||
348 | kfree(info); | ||
349 | } | ||
350 | } | 289 | } |
351 | 290 | ||
352 | static int devinfo_show(struct seq_file *f, void *arg) | 291 | static void devinfo_stop(struct seq_file *f, void *v) |
353 | { | 292 | { |
354 | int major; | 293 | /* Nothing to do */ |
355 | char *name; | ||
356 | struct devinfo_state *info = f->private; | ||
357 | |||
358 | switch(info->state) { | ||
359 | case CHR_HDR: | ||
360 | seq_printf(f,"Character devices:\n"); | ||
361 | /* fallthrough */ | ||
362 | case CHR_LIST: | ||
363 | if (!get_chrdev_info(info->chrdev,&major,&name)) | ||
364 | seq_printf(f,"%3d %s\n",major,name); | ||
365 | break; | ||
366 | case BLK_HDR: | ||
367 | seq_printf(f,"\nBlock devices:\n"); | ||
368 | /* fallthrough */ | ||
369 | case BLK_LIST: | ||
370 | if (!get_blkdev_info(info->blkdev,&major,&name)) | ||
371 | seq_printf(f,"%3d %s\n",major,name); | ||
372 | break; | ||
373 | default: | ||
374 | break; | ||
375 | } | ||
376 | |||
377 | return 0; | ||
378 | } | 294 | } |
379 | 295 | ||
380 | static struct seq_operations devinfo_op = { | 296 | static struct seq_operations devinfo_ops = { |
381 | .start = devinfo_start, | 297 | .start = devinfo_start, |
382 | .next = devinfo_next, | 298 | .next = devinfo_next, |
383 | .stop = devinfo_stop, | 299 | .stop = devinfo_stop, |
384 | .show = devinfo_show, | 300 | .show = devinfo_show |
385 | }; | 301 | }; |
386 | 302 | ||
387 | static int devinfo_open(struct inode *inode, struct file *file) | 303 | static int devinfo_open(struct inode *inode, struct file *filp) |
388 | { | 304 | { |
389 | return seq_open(file, &devinfo_op); | 305 | return seq_open(filp, &devinfo_ops); |
390 | } | 306 | } |
391 | 307 | ||
392 | static struct file_operations proc_devinfo_operations = { | 308 | static struct file_operations proc_devinfo_operations = { |
@@ -396,13 +312,6 @@ static struct file_operations proc_devinfo_operations = { | |||
396 | .release = seq_release, | 312 | .release = seq_release, |
397 | }; | 313 | }; |
398 | 314 | ||
399 | static struct file_operations proc_cpuinfo_operations = { | ||
400 | .open = cpuinfo_open, | ||
401 | .read = seq_read, | ||
402 | .llseek = seq_lseek, | ||
403 | .release = seq_release, | ||
404 | }; | ||
405 | |||
406 | extern struct seq_operations vmstat_op; | 315 | extern struct seq_operations vmstat_op; |
407 | static int vmstat_open(struct inode *inode, struct file *file) | 316 | static int vmstat_open(struct inode *inode, struct file *file) |
408 | { | 317 | { |
diff --git a/fs/select.c b/fs/select.c index b3a3a1326af6..071660fa7b01 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -314,7 +314,7 @@ static int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, | |||
314 | int ret, size, max_fdset; | 314 | int ret, size, max_fdset; |
315 | struct fdtable *fdt; | 315 | struct fdtable *fdt; |
316 | /* Allocate small arguments on the stack to save memory and be faster */ | 316 | /* Allocate small arguments on the stack to save memory and be faster */ |
317 | char stack_fds[SELECT_STACK_ALLOC]; | 317 | long stack_fds[SELECT_STACK_ALLOC/sizeof(long)]; |
318 | 318 | ||
319 | ret = -EINVAL; | 319 | ret = -EINVAL; |
320 | if (n < 0) | 320 | if (n < 0) |
@@ -639,8 +639,10 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout) | |||
639 | struct poll_list *walk; | 639 | struct poll_list *walk; |
640 | struct fdtable *fdt; | 640 | struct fdtable *fdt; |
641 | int max_fdset; | 641 | int max_fdset; |
642 | /* Allocate small arguments on the stack to save memory and be faster */ | 642 | /* Allocate small arguments on the stack to save memory and be |
643 | char stack_pps[POLL_STACK_ALLOC]; | 643 | faster - use long to make sure the buffer is aligned properly |
644 | on 64 bit archs to avoid unaligned access */ | ||
645 | long stack_pps[POLL_STACK_ALLOC/sizeof(long)]; | ||
644 | struct poll_list *stack_pp = NULL; | 646 | struct poll_list *stack_pp = NULL; |
645 | 647 | ||
646 | /* Do a sanity check on nfds ... */ | 648 | /* Do a sanity check on nfds ... */ |
diff --git a/fs/sync.c b/fs/sync.c new file mode 100644 index 000000000000..8616006d2094 --- /dev/null +++ b/fs/sync.c | |||
@@ -0,0 +1,164 @@ | |||
1 | /* | ||
2 | * High-level sync()-related operations | ||
3 | */ | ||
4 | |||
5 | #include <linux/kernel.h> | ||
6 | #include <linux/file.h> | ||
7 | #include <linux/fs.h> | ||
8 | #include <linux/module.h> | ||
9 | #include <linux/writeback.h> | ||
10 | #include <linux/syscalls.h> | ||
11 | #include <linux/linkage.h> | ||
12 | #include <linux/pagemap.h> | ||
13 | |||
14 | #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \ | ||
15 | SYNC_FILE_RANGE_WAIT_AFTER) | ||
16 | |||
17 | /* | ||
18 | * sys_sync_file_range() permits finely controlled syncing over a segment of | ||
19 | * a file in the range offset .. (offset+nbytes-1) inclusive. If nbytes is | ||
20 | * zero then sys_sync_file_range() will operate from offset out to EOF. | ||
21 | * | ||
22 | * The flag bits are: | ||
23 | * | ||
24 | * SYNC_FILE_RANGE_WAIT_BEFORE: wait upon writeout of all pages in the range | ||
25 | * before performing the write. | ||
26 | * | ||
27 | * SYNC_FILE_RANGE_WRITE: initiate writeout of all those dirty pages in the | ||
28 | * range which are not presently under writeback. | ||
29 | * | ||
30 | * SYNC_FILE_RANGE_WAIT_AFTER: wait upon writeout of all pages in the range | ||
31 | * after performing the write. | ||
32 | * | ||
33 | * Useful combinations of the flag bits are: | ||
34 | * | ||
35 | * SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE: ensures that all pages | ||
36 | * in the range which were dirty on entry to sys_sync_file_range() are placed | ||
37 | * under writeout. This is a start-write-for-data-integrity operation. | ||
38 | * | ||
39 | * SYNC_FILE_RANGE_WRITE: start writeout of all dirty pages in the range which | ||
40 | * are not presently under writeout. This is an asynchronous flush-to-disk | ||
41 | * operation. Not suitable for data integrity operations. | ||
42 | * | ||
43 | * SYNC_FILE_RANGE_WAIT_BEFORE (or SYNC_FILE_RANGE_WAIT_AFTER): wait for | ||
44 | * completion of writeout of all pages in the range. This will be used after an | ||
45 | * earlier SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE operation to wait | ||
46 | * for that operation to complete and to return the result. | ||
47 | * | ||
48 | * SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE|SYNC_FILE_RANGE_WAIT_AFTER: | ||
49 | * a traditional sync() operation. This is a write-for-data-integrity operation | ||
50 | * which will ensure that all pages in the range which were dirty on entry to | ||
51 | * sys_sync_file_range() are committed to disk. | ||
52 | * | ||
53 | * | ||
54 | * SYNC_FILE_RANGE_WAIT_BEFORE and SYNC_FILE_RANGE_WAIT_AFTER will detect any | ||
55 | * I/O errors or ENOSPC conditions and will return those to the caller, after | ||
56 | * clearing the EIO and ENOSPC flags in the address_space. | ||
57 | * | ||
58 | * It should be noted that none of these operations write out the file's | ||
59 | * metadata. So unless the application is strictly performing overwrites of | ||
60 | * already-instantiated disk blocks, there are no guarantees here that the data | ||
61 | * will be available after a crash. | ||
62 | */ | ||
63 | asmlinkage long sys_sync_file_range(int fd, loff_t offset, loff_t nbytes, | ||
64 | int flags) | ||
65 | { | ||
66 | int ret; | ||
67 | struct file *file; | ||
68 | loff_t endbyte; /* inclusive */ | ||
69 | int fput_needed; | ||
70 | umode_t i_mode; | ||
71 | |||
72 | ret = -EINVAL; | ||
73 | if (flags & ~VALID_FLAGS) | ||
74 | goto out; | ||
75 | |||
76 | endbyte = offset + nbytes; | ||
77 | |||
78 | if ((s64)offset < 0) | ||
79 | goto out; | ||
80 | if ((s64)endbyte < 0) | ||
81 | goto out; | ||
82 | if (endbyte < offset) | ||
83 | goto out; | ||
84 | |||
85 | if (sizeof(pgoff_t) == 4) { | ||
86 | if (offset >= (0x100000000ULL << PAGE_CACHE_SHIFT)) { | ||
87 | /* | ||
88 | * The range starts outside a 32 bit machine's | ||
89 | * pagecache addressing capabilities. Let it "succeed" | ||
90 | */ | ||
91 | ret = 0; | ||
92 | goto out; | ||
93 | } | ||
94 | if (endbyte >= (0x100000000ULL << PAGE_CACHE_SHIFT)) { | ||
95 | /* | ||
96 | * Out to EOF | ||
97 | */ | ||
98 | nbytes = 0; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | if (nbytes == 0) | ||
103 | endbyte = -1; | ||
104 | else | ||
105 | endbyte--; /* inclusive */ | ||
106 | |||
107 | ret = -EBADF; | ||
108 | file = fget_light(fd, &fput_needed); | ||
109 | if (!file) | ||
110 | goto out; | ||
111 | |||
112 | i_mode = file->f_dentry->d_inode->i_mode; | ||
113 | ret = -ESPIPE; | ||
114 | if (!S_ISREG(i_mode) && !S_ISBLK(i_mode) && !S_ISDIR(i_mode) && | ||
115 | !S_ISLNK(i_mode)) | ||
116 | goto out_put; | ||
117 | |||
118 | ret = do_sync_file_range(file, offset, endbyte, flags); | ||
119 | out_put: | ||
120 | fput_light(file, fput_needed); | ||
121 | out: | ||
122 | return ret; | ||
123 | } | ||
124 | |||
125 | /* | ||
126 | * `endbyte' is inclusive | ||
127 | */ | ||
128 | int do_sync_file_range(struct file *file, loff_t offset, loff_t endbyte, | ||
129 | int flags) | ||
130 | { | ||
131 | int ret; | ||
132 | struct address_space *mapping; | ||
133 | |||
134 | mapping = file->f_mapping; | ||
135 | if (!mapping) { | ||
136 | ret = -EINVAL; | ||
137 | goto out; | ||
138 | } | ||
139 | |||
140 | ret = 0; | ||
141 | if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { | ||
142 | ret = wait_on_page_writeback_range(mapping, | ||
143 | offset >> PAGE_CACHE_SHIFT, | ||
144 | endbyte >> PAGE_CACHE_SHIFT); | ||
145 | if (ret < 0) | ||
146 | goto out; | ||
147 | } | ||
148 | |||
149 | if (flags & SYNC_FILE_RANGE_WRITE) { | ||
150 | ret = __filemap_fdatawrite_range(mapping, offset, endbyte, | ||
151 | WB_SYNC_NONE); | ||
152 | if (ret < 0) | ||
153 | goto out; | ||
154 | } | ||
155 | |||
156 | if (flags & SYNC_FILE_RANGE_WAIT_AFTER) { | ||
157 | ret = wait_on_page_writeback_range(mapping, | ||
158 | offset >> PAGE_CACHE_SHIFT, | ||
159 | endbyte >> PAGE_CACHE_SHIFT); | ||
160 | } | ||
161 | out: | ||
162 | return ret; | ||
163 | } | ||
164 | EXPORT_SYMBOL_GPL(do_sync_file_range); | ||
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index ef46939c0c1a..a56cec3be5f0 100644 --- a/fs/vfat/namei.c +++ b/fs/vfat/namei.c | |||
@@ -185,24 +185,6 @@ static int vfat_valid_longname(const unsigned char *name, unsigned int len) | |||
185 | return -EINVAL; | 185 | return -EINVAL; |
186 | if (len >= 256) | 186 | if (len >= 256) |
187 | return -ENAMETOOLONG; | 187 | return -ENAMETOOLONG; |
188 | |||
189 | /* MS-DOS "device special files" */ | ||
190 | if (len == 3 || (len > 3 && name[3] == '.')) { /* basename == 3 */ | ||
191 | if (!strnicmp(name, "aux", 3) || | ||
192 | !strnicmp(name, "con", 3) || | ||
193 | !strnicmp(name, "nul", 3) || | ||
194 | !strnicmp(name, "prn", 3)) | ||
195 | return -EINVAL; | ||
196 | } | ||
197 | if (len == 4 || (len > 4 && name[4] == '.')) { /* basename == 4 */ | ||
198 | /* "com1", "com2", ... */ | ||
199 | if ('1' <= name[3] && name[3] <= '9') { | ||
200 | if (!strnicmp(name, "com", 3) || | ||
201 | !strnicmp(name, "lpt", 3)) | ||
202 | return -EINVAL; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | return 0; | 188 | return 0; |
207 | } | 189 | } |
208 | 190 | ||