aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-05 22:17:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-05 22:17:50 -0400
commitbe88751f320a716a4327596adfe834e162c14532 (patch)
tree4015f6d1da204e6228dfcbc3984ac9ddf7d988de
parent5e4d659713f52c1c9dfc2fea9d319b80a53d4bc9 (diff)
parentb91ed9d8082c394dda63f94f935219cd0a565938 (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull misc filesystem updates from Jan Kara: "udf, ext2, quota, fsnotify fixes & cleanups: - udf fixes for handling of media without uid/gid - udf fixes for some corner cases in parsing of volume recognition sequence - improvements of fsnotify handling of ENOMEM - new ioctl to allow setting of watch descriptor id for inotify (for checkpoint - restart) - small ext2, reiserfs, quota cleanups" * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: quota: Kill an unused extern entry form quota.h reiserfs: Remove VLA from fs/reiserfs/reiserfs.h udf: fix potential refcnt problem of nls module ext2: change return code to -ENOMEM when failing memory allocation udf: Do not mark possibly inconsistent filesystems as closed fsnotify: Let userspace know about lost events due to ENOMEM fanotify: Avoid lost events due to ENOMEM for unlimited queues udf: Remove never implemented mount options udf: Update mount option documentation udf: Provide saner default for invalid uid / gid udf: Clean up handling of invalid uid/gid udf: Apply uid/gid mount options also to new inodes & chown udf: Ignore [ug]id=ignore mount options udf: Fix handling of Partition Descriptors udf: Unify common handling of descriptors udf: Convert descriptor index definitions to enum udf: Allow volume descriptor sequence to be terminated by unrecorded block udf: Simplify handling of Volume Descriptor Pointers udf: Fix off-by-one in volume descriptor sequence length inotify: Extend ioctl to allow to request id of new watch descriptor
-rw-r--r--Documentation/filesystems/udf.txt26
-rw-r--r--fs/ext2/super.c4
-rw-r--r--fs/notify/fanotify/fanotify.c28
-rw-r--r--fs/notify/fanotify/fanotify.h3
-rw-r--r--fs/notify/fanotify/fanotify_user.c2
-rw-r--r--fs/notify/inotify/inotify_fsnotify.c8
-rw-r--r--fs/notify/inotify/inotify_user.c14
-rw-r--r--fs/notify/notification.c3
-rw-r--r--fs/reiserfs/reiserfs.h2
-rw-r--r--fs/udf/file.c10
-rw-r--r--fs/udf/ialloc.c4
-rw-r--r--fs/udf/inode.c23
-rw-r--r--fs/udf/super.c260
-rw-r--r--fs/udf/udf_sb.h15
-rw-r--r--fs/udf/udfdecl.h2
-rw-r--r--include/linux/fsnotify_backend.h6
-rw-r--r--include/linux/quota.h1
-rw-r--r--include/uapi/linux/inotify.h8
18 files changed, 240 insertions, 179 deletions
diff --git a/Documentation/filesystems/udf.txt b/Documentation/filesystems/udf.txt
index d3d0e3218f86..e2f2faf32f18 100644
--- a/Documentation/filesystems/udf.txt
+++ b/Documentation/filesystems/udf.txt
@@ -36,18 +36,14 @@ The following mount options are supported:
36 iocharset= Set the NLS character set 36 iocharset= Set the NLS character set
37 37
38The uid= and gid= options need a bit more explaining. They will accept a 38The uid= and gid= options need a bit more explaining. They will accept a
39decimal numeric value which will be used as the default ID for that mount. 39decimal numeric value and all inodes on that mount will then appear as
40They will also accept the string "ignore" and "forget". For files on the disk 40belonging to that uid and gid. Mount options also accept the string "forget".
41that are owned by nobody ( -1 ), they will instead look as if they are owned 41The forget option causes all IDs to be written to disk as -1 which is a way
42by the default ID. The ignore option causes the default ID to override all 42of UDF standard to indicate that IDs are not supported for these files .
43IDs on the disk, not just -1. The forget option causes all IDs to be written
44to disk as -1, so when the media is later remounted, they will appear to be
45owned by whatever default ID it is mounted with at that time.
46 43
47For typical desktop use of removable media, you should set the ID to that 44For typical desktop use of removable media, you should set the ID to that of
48of the interactively logged on user, and also specify both the forget and 45the interactively logged on user, and also specify the forget option. This way
49ignore options. This way the interactive user will always see the files 46the interactive user will always see the files on the disk as belonging to him.
50on the disk as belonging to him.
51 47
52The remaining are for debugging and disaster recovery: 48The remaining are for debugging and disaster recovery:
53 49
@@ -57,16 +53,8 @@ The following expect a offset from 0.
57 53
58 session= Set the CDROM session (default= last session) 54 session= Set the CDROM session (default= last session)
59 anchor= Override standard anchor location. (default= 256) 55 anchor= Override standard anchor location. (default= 256)
60 volume= Override the VolumeDesc location. (unused)
61 partition= Override the PartitionDesc location. (unused)
62 lastblock= Set the last block of the filesystem/ 56 lastblock= Set the last block of the filesystem/
63 57
64The following expect a offset from the partition root.
65
66 fileset= Override the fileset block location. (unused)
67 rootdir= Override the root directory location. (unused)
68 WARNING: overriding the rootdir to a non-directory may
69 yield highly unpredictable results.
70------------------------------------------------------------------------------- 58-------------------------------------------------------------------------------
71 59
72 60
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 7666c065b96f..de1694512f1f 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -827,7 +827,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
827 unsigned long logic_sb_block; 827 unsigned long logic_sb_block;
828 unsigned long offset = 0; 828 unsigned long offset = 0;
829 unsigned long def_mount_opts; 829 unsigned long def_mount_opts;
830 long ret = -EINVAL; 830 long ret = -ENOMEM;
831 int blocksize = BLOCK_SIZE; 831 int blocksize = BLOCK_SIZE;
832 int db_count; 832 int db_count;
833 int i, j; 833 int i, j;
@@ -835,7 +835,6 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
835 int err; 835 int err;
836 struct ext2_mount_options opts; 836 struct ext2_mount_options opts;
837 837
838 err = -ENOMEM;
839 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 838 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
840 if (!sbi) 839 if (!sbi)
841 goto failed; 840 goto failed;
@@ -851,6 +850,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
851 sbi->s_daxdev = dax_dev; 850 sbi->s_daxdev = dax_dev;
852 851
853 spin_lock_init(&sbi->s_lock); 852 spin_lock_init(&sbi->s_lock);
853 ret = -EINVAL;
854 854
855 /* 855 /*
856 * See what the current blocksize for the device is, and 856 * See what the current blocksize for the device is, and
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 6702a6a0bbb5..d51e1bb781cf 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -139,23 +139,32 @@ static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark,
139 return false; 139 return false;
140} 140}
141 141
142struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask, 142struct fanotify_event_info *fanotify_alloc_event(struct fsnotify_group *group,
143 struct inode *inode, u32 mask,
143 const struct path *path) 144 const struct path *path)
144{ 145{
145 struct fanotify_event_info *event; 146 struct fanotify_event_info *event;
147 gfp_t gfp = GFP_KERNEL;
148
149 /*
150 * For queues with unlimited length lost events are not expected and
151 * can possibly have security implications. Avoid losing events when
152 * memory is short.
153 */
154 if (group->max_events == UINT_MAX)
155 gfp |= __GFP_NOFAIL;
146 156
147 if (fanotify_is_perm_event(mask)) { 157 if (fanotify_is_perm_event(mask)) {
148 struct fanotify_perm_event_info *pevent; 158 struct fanotify_perm_event_info *pevent;
149 159
150 pevent = kmem_cache_alloc(fanotify_perm_event_cachep, 160 pevent = kmem_cache_alloc(fanotify_perm_event_cachep, gfp);
151 GFP_KERNEL);
152 if (!pevent) 161 if (!pevent)
153 return NULL; 162 return NULL;
154 event = &pevent->fae; 163 event = &pevent->fae;
155 pevent->response = 0; 164 pevent->response = 0;
156 goto init; 165 goto init;
157 } 166 }
158 event = kmem_cache_alloc(fanotify_event_cachep, GFP_KERNEL); 167 event = kmem_cache_alloc(fanotify_event_cachep, gfp);
159 if (!event) 168 if (!event)
160 return NULL; 169 return NULL;
161init: __maybe_unused 170init: __maybe_unused
@@ -210,10 +219,17 @@ static int fanotify_handle_event(struct fsnotify_group *group,
210 return 0; 219 return 0;
211 } 220 }
212 221
213 event = fanotify_alloc_event(inode, mask, data); 222 event = fanotify_alloc_event(group, inode, mask, data);
214 ret = -ENOMEM; 223 ret = -ENOMEM;
215 if (unlikely(!event)) 224 if (unlikely(!event)) {
225 /*
226 * We don't queue overflow events for permission events as
227 * there the access is denied and so no event is in fact lost.
228 */
229 if (!fanotify_is_perm_event(mask))
230 fsnotify_queue_overflow(group);
216 goto finish; 231 goto finish;
232 }
217 233
218 fsn_event = &event->fse; 234 fsn_event = &event->fse;
219 ret = fsnotify_add_event(group, fsn_event, fanotify_merge); 235 ret = fsnotify_add_event(group, fsn_event, fanotify_merge);
diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h
index 256d9d1ddea9..8609ba06f474 100644
--- a/fs/notify/fanotify/fanotify.h
+++ b/fs/notify/fanotify/fanotify.h
@@ -52,5 +52,6 @@ static inline struct fanotify_event_info *FANOTIFY_E(struct fsnotify_event *fse)
52 return container_of(fse, struct fanotify_event_info, fse); 52 return container_of(fse, struct fanotify_event_info, fse);
53} 53}
54 54
55struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask, 55struct fanotify_event_info *fanotify_alloc_event(struct fsnotify_group *group,
56 struct inode *inode, u32 mask,
56 const struct path *path); 57 const struct path *path);
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index fa803a58a605..ec4d8c59d0e3 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -757,7 +757,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
757 group->fanotify_data.user = user; 757 group->fanotify_data.user = user;
758 atomic_inc(&user->fanotify_listeners); 758 atomic_inc(&user->fanotify_listeners);
759 759
760 oevent = fanotify_alloc_event(NULL, FS_Q_OVERFLOW, NULL); 760 oevent = fanotify_alloc_event(group, NULL, FS_Q_OVERFLOW, NULL);
761 if (unlikely(!oevent)) { 761 if (unlikely(!oevent)) {
762 fd = -ENOMEM; 762 fd = -ENOMEM;
763 goto out_destroy_group; 763 goto out_destroy_group;
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
index 8b73332735ba..40dedb37a1f3 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -99,8 +99,14 @@ int inotify_handle_event(struct fsnotify_group *group,
99 fsn_mark); 99 fsn_mark);
100 100
101 event = kmalloc(alloc_len, GFP_KERNEL); 101 event = kmalloc(alloc_len, GFP_KERNEL);
102 if (unlikely(!event)) 102 if (unlikely(!event)) {
103 /*
104 * Treat lost event due to ENOMEM the same way as queue
105 * overflow to let userspace know event was lost.
106 */
107 fsnotify_queue_overflow(group);
103 return -ENOMEM; 108 return -ENOMEM;
109 }
104 110
105 fsn_event = &event->fse; 111 fsn_event = &event->fse;
106 fsnotify_init_event(fsn_event, inode, mask); 112 fsnotify_init_event(fsn_event, inode, mask);
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 43c23653ce2e..ef32f3657958 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -307,6 +307,20 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
307 spin_unlock(&group->notification_lock); 307 spin_unlock(&group->notification_lock);
308 ret = put_user(send_len, (int __user *) p); 308 ret = put_user(send_len, (int __user *) p);
309 break; 309 break;
310#ifdef CONFIG_CHECKPOINT_RESTORE
311 case INOTIFY_IOC_SETNEXTWD:
312 ret = -EINVAL;
313 if (arg >= 1 && arg <= INT_MAX) {
314 struct inotify_group_private_data *data;
315
316 data = &group->inotify_data;
317 spin_lock(&data->idr_lock);
318 idr_set_cursor(&data->idr, (unsigned int)arg);
319 spin_unlock(&data->idr_lock);
320 ret = 0;
321 }
322 break;
323#endif /* CONFIG_CHECKPOINT_RESTORE */
310 } 324 }
311 325
312 return ret; 326 return ret;
diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index 66f85c651c52..3c3e36745f59 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -111,7 +111,8 @@ int fsnotify_add_event(struct fsnotify_group *group,
111 return 2; 111 return 2;
112 } 112 }
113 113
114 if (group->q_len >= group->max_events) { 114 if (event == group->overflow_event ||
115 group->q_len >= group->max_events) {
115 ret = 2; 116 ret = 2;
116 /* Queue overflow event only if it isn't already queued */ 117 /* Queue overflow event only if it isn't already queued */
117 if (!list_empty(&group->overflow_event->list)) { 118 if (!list_empty(&group->overflow_event->list)) {
diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
index 48835a659948..ae4811fecc1f 100644
--- a/fs/reiserfs/reiserfs.h
+++ b/fs/reiserfs/reiserfs.h
@@ -1916,7 +1916,7 @@ struct reiserfs_de_head {
1916 1916
1917/* empty directory contains two entries "." and ".." and their headers */ 1917/* empty directory contains two entries "." and ".." and their headers */
1918#define EMPTY_DIR_SIZE \ 1918#define EMPTY_DIR_SIZE \
1919(DEH_SIZE * 2 + ROUND_UP (strlen (".")) + ROUND_UP (strlen (".."))) 1919(DEH_SIZE * 2 + ROUND_UP (sizeof(".") - 1) + ROUND_UP (sizeof("..") - 1))
1920 1920
1921/* old format directories have this size when empty */ 1921/* old format directories have this size when empty */
1922#define EMPTY_DIR_SIZE_V1 (DEH_SIZE * 2 + 3) 1922#define EMPTY_DIR_SIZE_V1 (DEH_SIZE * 2 + 3)
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 356c2bf148a5..cd31e4f6d6da 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -257,12 +257,22 @@ const struct file_operations udf_file_operations = {
257static int udf_setattr(struct dentry *dentry, struct iattr *attr) 257static int udf_setattr(struct dentry *dentry, struct iattr *attr)
258{ 258{
259 struct inode *inode = d_inode(dentry); 259 struct inode *inode = d_inode(dentry);
260 struct super_block *sb = inode->i_sb;
260 int error; 261 int error;
261 262
262 error = setattr_prepare(dentry, attr); 263 error = setattr_prepare(dentry, attr);
263 if (error) 264 if (error)
264 return error; 265 return error;
265 266
267 if ((attr->ia_valid & ATTR_UID) &&
268 UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET) &&
269 !uid_eq(attr->ia_uid, UDF_SB(sb)->s_uid))
270 return -EPERM;
271 if ((attr->ia_valid & ATTR_GID) &&
272 UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET) &&
273 !gid_eq(attr->ia_gid, UDF_SB(sb)->s_gid))
274 return -EPERM;
275
266 if ((attr->ia_valid & ATTR_SIZE) && 276 if ((attr->ia_valid & ATTR_SIZE) &&
267 attr->ia_size != i_size_read(inode)) { 277 attr->ia_size != i_size_read(inode)) {
268 error = udf_setsize(inode, attr->ia_size); 278 error = udf_setsize(inode, attr->ia_size);
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index b6e420c1bfeb..b7a0d4b4bda1 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -104,6 +104,10 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
104 } 104 }
105 105
106 inode_init_owner(inode, dir, mode); 106 inode_init_owner(inode, dir, mode);
107 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET))
108 inode->i_uid = sbi->s_uid;
109 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET))
110 inode->i_gid = sbi->s_gid;
107 111
108 iinfo->i_location.logicalBlockNum = block; 112 iinfo->i_location.logicalBlockNum = block;
109 iinfo->i_location.partitionReferenceNum = 113 iinfo->i_location.partitionReferenceNum =
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index c23744d5ae5c..c80765d62f7e 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1275,6 +1275,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
1275 unsigned int indirections = 0; 1275 unsigned int indirections = 0;
1276 int bs = inode->i_sb->s_blocksize; 1276 int bs = inode->i_sb->s_blocksize;
1277 int ret = -EIO; 1277 int ret = -EIO;
1278 uint32_t uid, gid;
1278 1279
1279reread: 1280reread:
1280 if (iloc->partitionReferenceNum >= sbi->s_partitions) { 1281 if (iloc->partitionReferenceNum >= sbi->s_partitions) {
@@ -1400,17 +1401,19 @@ reread:
1400 1401
1401 ret = -EIO; 1402 ret = -EIO;
1402 read_lock(&sbi->s_cred_lock); 1403 read_lock(&sbi->s_cred_lock);
1403 i_uid_write(inode, le32_to_cpu(fe->uid)); 1404 uid = le32_to_cpu(fe->uid);
1404 if (!uid_valid(inode->i_uid) || 1405 if (uid == UDF_INVALID_ID ||
1405 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) ||
1406 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET)) 1406 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET))
1407 inode->i_uid = UDF_SB(inode->i_sb)->s_uid; 1407 inode->i_uid = sbi->s_uid;
1408 else
1409 i_uid_write(inode, uid);
1408 1410
1409 i_gid_write(inode, le32_to_cpu(fe->gid)); 1411 gid = le32_to_cpu(fe->gid);
1410 if (!gid_valid(inode->i_gid) || 1412 if (gid == UDF_INVALID_ID ||
1411 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) ||
1412 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET)) 1413 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET))
1413 inode->i_gid = UDF_SB(inode->i_sb)->s_gid; 1414 inode->i_gid = sbi->s_gid;
1415 else
1416 i_gid_write(inode, gid);
1414 1417
1415 if (fe->icbTag.fileType != ICBTAG_FILE_TYPE_DIRECTORY && 1418 if (fe->icbTag.fileType != ICBTAG_FILE_TYPE_DIRECTORY &&
1416 sbi->s_fmode != UDF_INVALID_MODE) 1419 sbi->s_fmode != UDF_INVALID_MODE)
@@ -1655,12 +1658,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1655 } 1658 }
1656 1659
1657 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET)) 1660 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET))
1658 fe->uid = cpu_to_le32(-1); 1661 fe->uid = cpu_to_le32(UDF_INVALID_ID);
1659 else 1662 else
1660 fe->uid = cpu_to_le32(i_uid_read(inode)); 1663 fe->uid = cpu_to_le32(i_uid_read(inode));
1661 1664
1662 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET)) 1665 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET))
1663 fe->gid = cpu_to_le32(-1); 1666 fe->gid = cpu_to_le32(UDF_INVALID_ID);
1664 else 1667 else
1665 fe->gid = cpu_to_le32(i_gid_read(inode)); 1668 fe->gid = cpu_to_le32(i_gid_read(inode));
1666 1669
diff --git a/fs/udf/super.c b/fs/udf/super.c
index f73239a9a97d..7949c338efa5 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -64,14 +64,13 @@
64#include <linux/init.h> 64#include <linux/init.h>
65#include <linux/uaccess.h> 65#include <linux/uaccess.h>
66 66
67#define VDS_POS_PRIMARY_VOL_DESC 0 67enum {
68#define VDS_POS_UNALLOC_SPACE_DESC 1 68 VDS_POS_PRIMARY_VOL_DESC,
69#define VDS_POS_LOGICAL_VOL_DESC 2 69 VDS_POS_UNALLOC_SPACE_DESC,
70#define VDS_POS_PARTITION_DESC 3 70 VDS_POS_LOGICAL_VOL_DESC,
71#define VDS_POS_IMP_USE_VOL_DESC 4 71 VDS_POS_IMP_USE_VOL_DESC,
72#define VDS_POS_VOL_DESC_PTR 5 72 VDS_POS_LENGTH
73#define VDS_POS_TERMINATING_DESC 6 73};
74#define VDS_POS_LENGTH 7
75 74
76#define VSD_FIRST_SECTOR_OFFSET 32768 75#define VSD_FIRST_SECTOR_OFFSET 32768
77#define VSD_MAX_SECTOR_OFFSET 0x800000 76#define VSD_MAX_SECTOR_OFFSET 0x800000
@@ -223,10 +222,6 @@ struct udf_options {
223 unsigned int session; 222 unsigned int session;
224 unsigned int lastblock; 223 unsigned int lastblock;
225 unsigned int anchor; 224 unsigned int anchor;
226 unsigned int volume;
227 unsigned short partition;
228 unsigned int fileset;
229 unsigned int rootdir;
230 unsigned int flags; 225 unsigned int flags;
231 umode_t umask; 226 umode_t umask;
232 kgid_t gid; 227 kgid_t gid;
@@ -349,12 +344,8 @@ static int udf_show_options(struct seq_file *seq, struct dentry *root)
349 seq_puts(seq, ",shortad"); 344 seq_puts(seq, ",shortad");
350 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_FORGET)) 345 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_FORGET))
351 seq_puts(seq, ",uid=forget"); 346 seq_puts(seq, ",uid=forget");
352 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_IGNORE))
353 seq_puts(seq, ",uid=ignore");
354 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_FORGET)) 347 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_FORGET))
355 seq_puts(seq, ",gid=forget"); 348 seq_puts(seq, ",gid=forget");
356 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_IGNORE))
357 seq_puts(seq, ",gid=ignore");
358 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET)) 349 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UID_SET))
359 seq_printf(seq, ",uid=%u", from_kuid(&init_user_ns, sbi->s_uid)); 350 seq_printf(seq, ",uid=%u", from_kuid(&init_user_ns, sbi->s_uid));
360 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET)) 351 if (UDF_QUERY_FLAG(sb, UDF_FLAG_GID_SET))
@@ -371,10 +362,6 @@ static int udf_show_options(struct seq_file *seq, struct dentry *root)
371 seq_printf(seq, ",lastblock=%u", sbi->s_last_block); 362 seq_printf(seq, ",lastblock=%u", sbi->s_last_block);
372 if (sbi->s_anchor != 0) 363 if (sbi->s_anchor != 0)
373 seq_printf(seq, ",anchor=%u", sbi->s_anchor); 364 seq_printf(seq, ",anchor=%u", sbi->s_anchor);
374 /*
375 * volume, partition, fileset and rootdir seem to be ignored
376 * currently
377 */
378 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) 365 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8))
379 seq_puts(seq, ",utf8"); 366 seq_puts(seq, ",utf8");
380 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP) && sbi->s_nls_map) 367 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP) && sbi->s_nls_map)
@@ -487,14 +474,9 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
487 int option; 474 int option;
488 475
489 uopt->novrs = 0; 476 uopt->novrs = 0;
490 uopt->partition = 0xFFFF;
491 uopt->session = 0xFFFFFFFF; 477 uopt->session = 0xFFFFFFFF;
492 uopt->lastblock = 0; 478 uopt->lastblock = 0;
493 uopt->anchor = 0; 479 uopt->anchor = 0;
494 uopt->volume = 0xFFFFFFFF;
495 uopt->rootdir = 0xFFFFFFFF;
496 uopt->fileset = 0xFFFFFFFF;
497 uopt->nls_map = NULL;
498 480
499 if (!options) 481 if (!options)
500 return 1; 482 return 1;
@@ -582,42 +564,30 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
582 uopt->anchor = option; 564 uopt->anchor = option;
583 break; 565 break;
584 case Opt_volume: 566 case Opt_volume:
585 if (match_int(args, &option))
586 return 0;
587 uopt->volume = option;
588 break;
589 case Opt_partition: 567 case Opt_partition:
590 if (match_int(args, &option))
591 return 0;
592 uopt->partition = option;
593 break;
594 case Opt_fileset: 568 case Opt_fileset:
595 if (match_int(args, &option))
596 return 0;
597 uopt->fileset = option;
598 break;
599 case Opt_rootdir: 569 case Opt_rootdir:
600 if (match_int(args, &option)) 570 /* Ignored (never implemented properly) */
601 return 0;
602 uopt->rootdir = option;
603 break; 571 break;
604 case Opt_utf8: 572 case Opt_utf8:
605 uopt->flags |= (1 << UDF_FLAG_UTF8); 573 uopt->flags |= (1 << UDF_FLAG_UTF8);
606 break; 574 break;
607#ifdef CONFIG_UDF_NLS 575#ifdef CONFIG_UDF_NLS
608 case Opt_iocharset: 576 case Opt_iocharset:
609 uopt->nls_map = load_nls(args[0].from); 577 if (!remount) {
610 uopt->flags |= (1 << UDF_FLAG_NLS_MAP); 578 if (uopt->nls_map)
579 unload_nls(uopt->nls_map);
580 uopt->nls_map = load_nls(args[0].from);
581 uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
582 }
611 break; 583 break;
612#endif 584#endif
613 case Opt_uignore:
614 uopt->flags |= (1 << UDF_FLAG_UID_IGNORE);
615 break;
616 case Opt_uforget: 585 case Opt_uforget:
617 uopt->flags |= (1 << UDF_FLAG_UID_FORGET); 586 uopt->flags |= (1 << UDF_FLAG_UID_FORGET);
618 break; 587 break;
588 case Opt_uignore:
619 case Opt_gignore: 589 case Opt_gignore:
620 uopt->flags |= (1 << UDF_FLAG_GID_IGNORE); 590 /* These options are superseeded by uid=<number> */
621 break; 591 break;
622 case Opt_gforget: 592 case Opt_gforget:
623 uopt->flags |= (1 << UDF_FLAG_GID_FORGET); 593 uopt->flags |= (1 << UDF_FLAG_GID_FORGET);
@@ -660,6 +630,7 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
660 uopt.umask = sbi->s_umask; 630 uopt.umask = sbi->s_umask;
661 uopt.fmode = sbi->s_fmode; 631 uopt.fmode = sbi->s_fmode;
662 uopt.dmode = sbi->s_dmode; 632 uopt.dmode = sbi->s_dmode;
633 uopt.nls_map = NULL;
663 634
664 if (!udf_parse_options(options, &uopt, true)) 635 if (!udf_parse_options(options, &uopt, true))
665 return -EINVAL; 636 return -EINVAL;
@@ -1592,6 +1563,60 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_
1592 sbi->s_lvid_bh = NULL; 1563 sbi->s_lvid_bh = NULL;
1593} 1564}
1594 1565
1566/*
1567 * Step for reallocation of table of partition descriptor sequence numbers.
1568 * Must be power of 2.
1569 */
1570#define PART_DESC_ALLOC_STEP 32
1571
1572struct desc_seq_scan_data {
1573 struct udf_vds_record vds[VDS_POS_LENGTH];
1574 unsigned int size_part_descs;
1575 struct udf_vds_record *part_descs_loc;
1576};
1577
1578static struct udf_vds_record *handle_partition_descriptor(
1579 struct buffer_head *bh,
1580 struct desc_seq_scan_data *data)
1581{
1582 struct partitionDesc *desc = (struct partitionDesc *)bh->b_data;
1583 int partnum;
1584
1585 partnum = le16_to_cpu(desc->partitionNumber);
1586 if (partnum >= data->size_part_descs) {
1587 struct udf_vds_record *new_loc;
1588 unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP);
1589
1590 new_loc = kzalloc(sizeof(*new_loc) * new_size, GFP_KERNEL);
1591 if (!new_loc)
1592 return ERR_PTR(-ENOMEM);
1593 memcpy(new_loc, data->part_descs_loc,
1594 data->size_part_descs * sizeof(*new_loc));
1595 kfree(data->part_descs_loc);
1596 data->part_descs_loc = new_loc;
1597 data->size_part_descs = new_size;
1598 }
1599 return &(data->part_descs_loc[partnum]);
1600}
1601
1602
1603static struct udf_vds_record *get_volume_descriptor_record(uint16_t ident,
1604 struct buffer_head *bh, struct desc_seq_scan_data *data)
1605{
1606 switch (ident) {
1607 case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */
1608 return &(data->vds[VDS_POS_PRIMARY_VOL_DESC]);
1609 case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */
1610 return &(data->vds[VDS_POS_IMP_USE_VOL_DESC]);
1611 case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */
1612 return &(data->vds[VDS_POS_LOGICAL_VOL_DESC]);
1613 case TAG_IDENT_USD: /* ISO 13346 3/10.8 */
1614 return &(data->vds[VDS_POS_UNALLOC_SPACE_DESC]);
1615 case TAG_IDENT_PD: /* ISO 13346 3/10.5 */
1616 return handle_partition_descriptor(bh, data);
1617 }
1618 return NULL;
1619}
1595 1620
1596/* 1621/*
1597 * Process a main/reserve volume descriptor sequence. 1622 * Process a main/reserve volume descriptor sequence.
@@ -1608,18 +1633,23 @@ static noinline int udf_process_sequence(
1608 struct kernel_lb_addr *fileset) 1633 struct kernel_lb_addr *fileset)
1609{ 1634{
1610 struct buffer_head *bh = NULL; 1635 struct buffer_head *bh = NULL;
1611 struct udf_vds_record vds[VDS_POS_LENGTH];
1612 struct udf_vds_record *curr; 1636 struct udf_vds_record *curr;
1613 struct generic_desc *gd; 1637 struct generic_desc *gd;
1614 struct volDescPtr *vdp; 1638 struct volDescPtr *vdp;
1615 bool done = false; 1639 bool done = false;
1616 uint32_t vdsn; 1640 uint32_t vdsn;
1617 uint16_t ident; 1641 uint16_t ident;
1618 long next_s = 0, next_e = 0;
1619 int ret; 1642 int ret;
1620 unsigned int indirections = 0; 1643 unsigned int indirections = 0;
1621 1644 struct desc_seq_scan_data data;
1622 memset(vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH); 1645 unsigned int i;
1646
1647 memset(data.vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH);
1648 data.size_part_descs = PART_DESC_ALLOC_STEP;
1649 data.part_descs_loc = kzalloc(sizeof(*data.part_descs_loc) *
1650 data.size_part_descs, GFP_KERNEL);
1651 if (!data.part_descs_loc)
1652 return -ENOMEM;
1623 1653
1624 /* 1654 /*
1625 * Read the main descriptor sequence and find which descriptors 1655 * Read the main descriptor sequence and find which descriptors
@@ -1628,79 +1658,51 @@ static noinline int udf_process_sequence(
1628 for (; (!done && block <= lastblock); block++) { 1658 for (; (!done && block <= lastblock); block++) {
1629 1659
1630 bh = udf_read_tagged(sb, block, block, &ident); 1660 bh = udf_read_tagged(sb, block, block, &ident);
1631 if (!bh) { 1661 if (!bh)
1632 udf_err(sb, 1662 break;
1633 "Block %llu of volume descriptor sequence is corrupted or we could not read it\n",
1634 (unsigned long long)block);
1635 return -EAGAIN;
1636 }
1637 1663
1638 /* Process each descriptor (ISO 13346 3/8.3-8.4) */ 1664 /* Process each descriptor (ISO 13346 3/8.3-8.4) */
1639 gd = (struct generic_desc *)bh->b_data; 1665 gd = (struct generic_desc *)bh->b_data;
1640 vdsn = le32_to_cpu(gd->volDescSeqNum); 1666 vdsn = le32_to_cpu(gd->volDescSeqNum);
1641 switch (ident) { 1667 switch (ident) {
1642 case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */
1643 curr = &vds[VDS_POS_PRIMARY_VOL_DESC];
1644 if (vdsn >= curr->volDescSeqNum) {
1645 curr->volDescSeqNum = vdsn;
1646 curr->block = block;
1647 }
1648 break;
1649 case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ 1668 case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */
1650 curr = &vds[VDS_POS_VOL_DESC_PTR]; 1669 if (++indirections > UDF_MAX_TD_NESTING) {
1651 if (vdsn >= curr->volDescSeqNum) { 1670 udf_err(sb, "too many Volume Descriptor "
1652 curr->volDescSeqNum = vdsn; 1671 "Pointers (max %u supported)\n",
1653 curr->block = block; 1672 UDF_MAX_TD_NESTING);
1654 1673 brelse(bh);
1655 vdp = (struct volDescPtr *)bh->b_data; 1674 return -EIO;
1656 next_s = le32_to_cpu(
1657 vdp->nextVolDescSeqExt.extLocation);
1658 next_e = le32_to_cpu(
1659 vdp->nextVolDescSeqExt.extLength);
1660 next_e = next_e >> sb->s_blocksize_bits;
1661 next_e += next_s;
1662 } 1675 }
1676
1677 vdp = (struct volDescPtr *)bh->b_data;
1678 block = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation);
1679 lastblock = le32_to_cpu(
1680 vdp->nextVolDescSeqExt.extLength) >>
1681 sb->s_blocksize_bits;
1682 lastblock += block - 1;
1683 /* For loop is going to increment 'block' again */
1684 block--;
1663 break; 1685 break;
1686 case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */
1664 case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ 1687 case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */
1665 curr = &vds[VDS_POS_IMP_USE_VOL_DESC];
1666 if (vdsn >= curr->volDescSeqNum) {
1667 curr->volDescSeqNum = vdsn;
1668 curr->block = block;
1669 }
1670 break;
1671 case TAG_IDENT_PD: /* ISO 13346 3/10.5 */
1672 curr = &vds[VDS_POS_PARTITION_DESC];
1673 if (!curr->block)
1674 curr->block = block;
1675 break;
1676 case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ 1688 case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */
1677 curr = &vds[VDS_POS_LOGICAL_VOL_DESC];
1678 if (vdsn >= curr->volDescSeqNum) {
1679 curr->volDescSeqNum = vdsn;
1680 curr->block = block;
1681 }
1682 break;
1683 case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ 1689 case TAG_IDENT_USD: /* ISO 13346 3/10.8 */
1684 curr = &vds[VDS_POS_UNALLOC_SPACE_DESC]; 1690 case TAG_IDENT_PD: /* ISO 13346 3/10.5 */
1691 curr = get_volume_descriptor_record(ident, bh, &data);
1692 if (IS_ERR(curr)) {
1693 brelse(bh);
1694 return PTR_ERR(curr);
1695 }
1696 /* Descriptor we don't care about? */
1697 if (!curr)
1698 break;
1685 if (vdsn >= curr->volDescSeqNum) { 1699 if (vdsn >= curr->volDescSeqNum) {
1686 curr->volDescSeqNum = vdsn; 1700 curr->volDescSeqNum = vdsn;
1687 curr->block = block; 1701 curr->block = block;
1688 } 1702 }
1689 break; 1703 break;
1690 case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ 1704 case TAG_IDENT_TD: /* ISO 13346 3/10.9 */
1691 if (++indirections > UDF_MAX_TD_NESTING) { 1705 done = true;
1692 udf_err(sb, "too many TDs (max %u supported)\n", UDF_MAX_TD_NESTING);
1693 brelse(bh);
1694 return -EIO;
1695 }
1696
1697 vds[VDS_POS_TERMINATING_DESC].block = block;
1698 if (next_e) {
1699 block = next_s;
1700 lastblock = next_e;
1701 next_s = next_e = 0;
1702 } else
1703 done = true;
1704 break; 1706 break;
1705 } 1707 }
1706 brelse(bh); 1708 brelse(bh);
@@ -1709,31 +1711,27 @@ static noinline int udf_process_sequence(
1709 * Now read interesting descriptors again and process them 1711 * Now read interesting descriptors again and process them
1710 * in a suitable order 1712 * in a suitable order
1711 */ 1713 */
1712 if (!vds[VDS_POS_PRIMARY_VOL_DESC].block) { 1714 if (!data.vds[VDS_POS_PRIMARY_VOL_DESC].block) {
1713 udf_err(sb, "Primary Volume Descriptor not found!\n"); 1715 udf_err(sb, "Primary Volume Descriptor not found!\n");
1714 return -EAGAIN; 1716 return -EAGAIN;
1715 } 1717 }
1716 ret = udf_load_pvoldesc(sb, vds[VDS_POS_PRIMARY_VOL_DESC].block); 1718 ret = udf_load_pvoldesc(sb, data.vds[VDS_POS_PRIMARY_VOL_DESC].block);
1717 if (ret < 0) 1719 if (ret < 0)
1718 return ret; 1720 return ret;
1719 1721
1720 if (vds[VDS_POS_LOGICAL_VOL_DESC].block) { 1722 if (data.vds[VDS_POS_LOGICAL_VOL_DESC].block) {
1721 ret = udf_load_logicalvol(sb, 1723 ret = udf_load_logicalvol(sb,
1722 vds[VDS_POS_LOGICAL_VOL_DESC].block, 1724 data.vds[VDS_POS_LOGICAL_VOL_DESC].block,
1723 fileset); 1725 fileset);
1724 if (ret < 0) 1726 if (ret < 0)
1725 return ret; 1727 return ret;
1726 } 1728 }
1727 1729
1728 if (vds[VDS_POS_PARTITION_DESC].block) { 1730 /* Now handle prevailing Partition Descriptors */
1729 /* 1731 for (i = 0; i < data.size_part_descs; i++) {
1730 * We rescan the whole descriptor sequence to find 1732 if (data.part_descs_loc[i].block) {
1731 * partition descriptor blocks and process them. 1733 ret = udf_load_partdesc(sb,
1732 */ 1734 data.part_descs_loc[i].block);
1733 for (block = vds[VDS_POS_PARTITION_DESC].block;
1734 block < vds[VDS_POS_TERMINATING_DESC].block;
1735 block++) {
1736 ret = udf_load_partdesc(sb, block);
1737 if (ret < 0) 1735 if (ret < 0)
1738 return ret; 1736 return ret;
1739 } 1737 }
@@ -1760,13 +1758,13 @@ static int udf_load_sequence(struct super_block *sb, struct buffer_head *bh,
1760 main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); 1758 main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation);
1761 main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength); 1759 main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength);
1762 main_e = main_e >> sb->s_blocksize_bits; 1760 main_e = main_e >> sb->s_blocksize_bits;
1763 main_e += main_s; 1761 main_e += main_s - 1;
1764 1762
1765 /* Locate the reserve sequence */ 1763 /* Locate the reserve sequence */
1766 reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation); 1764 reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation);
1767 reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength); 1765 reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
1768 reserve_e = reserve_e >> sb->s_blocksize_bits; 1766 reserve_e = reserve_e >> sb->s_blocksize_bits;
1769 reserve_e += reserve_s; 1767 reserve_e += reserve_s - 1;
1770 1768
1771 /* Process the main & reserve sequences */ 1769 /* Process the main & reserve sequences */
1772 /* responsible for finding the PartitionDesc(s) */ 1770 /* responsible for finding the PartitionDesc(s) */
@@ -1994,7 +1992,10 @@ static void udf_open_lvid(struct super_block *sb)
1994 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; 1992 lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1995 ktime_get_real_ts(&ts); 1993 ktime_get_real_ts(&ts);
1996 udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts); 1994 udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
1997 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN); 1995 if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE)
1996 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
1997 else
1998 UDF_SET_FLAG(sb, UDF_FLAG_INCONSISTENT);
1998 1999
1999 lvid->descTag.descCRC = cpu_to_le16( 2000 lvid->descTag.descCRC = cpu_to_le16(
2000 crc_itu_t(0, (char *)lvid + sizeof(struct tag), 2001 crc_itu_t(0, (char *)lvid + sizeof(struct tag),
@@ -2034,7 +2035,8 @@ static void udf_close_lvid(struct super_block *sb)
2034 lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); 2035 lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev);
2035 if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) 2036 if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev))
2036 lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); 2037 lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev);
2037 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); 2038 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT))
2039 lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
2038 2040
2039 lvid->descTag.descCRC = cpu_to_le16( 2041 lvid->descTag.descCRC = cpu_to_le16(
2040 crc_itu_t(0, (char *)lvid + sizeof(struct tag), 2042 crc_itu_t(0, (char *)lvid + sizeof(struct tag),
@@ -2091,11 +2093,13 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
2091 bool lvid_open = false; 2093 bool lvid_open = false;
2092 2094
2093 uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); 2095 uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
2094 uopt.uid = INVALID_UID; 2096 /* By default we'll use overflow[ug]id when UDF inode [ug]id == -1 */
2095 uopt.gid = INVALID_GID; 2097 uopt.uid = make_kuid(current_user_ns(), overflowuid);
2098 uopt.gid = make_kgid(current_user_ns(), overflowgid);
2096 uopt.umask = 0; 2099 uopt.umask = 0;
2097 uopt.fmode = UDF_INVALID_MODE; 2100 uopt.fmode = UDF_INVALID_MODE;
2098 uopt.dmode = UDF_INVALID_MODE; 2101 uopt.dmode = UDF_INVALID_MODE;
2102 uopt.nls_map = NULL;
2099 2103
2100 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 2104 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
2101 if (!sbi) 2105 if (!sbi)
@@ -2276,8 +2280,8 @@ error_out:
2276 iput(sbi->s_vat_inode); 2280 iput(sbi->s_vat_inode);
2277parse_options_failure: 2281parse_options_failure:
2278#ifdef CONFIG_UDF_NLS 2282#ifdef CONFIG_UDF_NLS
2279 if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) 2283 if (uopt.nls_map)
2280 unload_nls(sbi->s_nls_map); 2284 unload_nls(uopt.nls_map);
2281#endif 2285#endif
2282 if (lvid_open) 2286 if (lvid_open)
2283 udf_close_lvid(sb); 2287 udf_close_lvid(sb);
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 68c9f1d618f5..9dd3e1b9619e 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -23,14 +23,13 @@
23#define UDF_FLAG_NLS_MAP 9 23#define UDF_FLAG_NLS_MAP 9
24#define UDF_FLAG_UTF8 10 24#define UDF_FLAG_UTF8 10
25#define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */ 25#define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */
26#define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */ 26#define UDF_FLAG_GID_FORGET 12
27#define UDF_FLAG_GID_FORGET 13 27#define UDF_FLAG_UID_SET 13
28#define UDF_FLAG_GID_IGNORE 14 28#define UDF_FLAG_GID_SET 14
29#define UDF_FLAG_UID_SET 15 29#define UDF_FLAG_SESSION_SET 15
30#define UDF_FLAG_GID_SET 16 30#define UDF_FLAG_LASTBLOCK_SET 16
31#define UDF_FLAG_SESSION_SET 17 31#define UDF_FLAG_BLOCKSIZE_SET 17
32#define UDF_FLAG_LASTBLOCK_SET 18 32#define UDF_FLAG_INCONSISTENT 18
33#define UDF_FLAG_BLOCKSIZE_SET 19
34 33
35#define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 34#define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001
36#define UDF_PART_FLAG_UNALLOC_TABLE 0x0002 35#define UDF_PART_FLAG_UNALLOC_TABLE 0x0002
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index f5e0fe78979e..68e8a64d22e0 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -48,6 +48,8 @@ extern __printf(3, 4) void _udf_warn(struct super_block *sb,
48#define UDF_EXTENT_LENGTH_MASK 0x3FFFFFFF 48#define UDF_EXTENT_LENGTH_MASK 0x3FFFFFFF
49#define UDF_EXTENT_FLAG_MASK 0xC0000000 49#define UDF_EXTENT_FLAG_MASK 0xC0000000
50 50
51#define UDF_INVALID_ID ((uint32_t)-1)
52
51#define UDF_NAME_PAD 4 53#define UDF_NAME_PAD 4
52#define UDF_NAME_LEN 254 54#define UDF_NAME_LEN 254
53#define UDF_NAME_LEN_CS0 255 55#define UDF_NAME_LEN_CS0 255
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 067d52e95f02..9f1edb92c97e 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -331,6 +331,12 @@ extern int fsnotify_add_event(struct fsnotify_group *group,
331 struct fsnotify_event *event, 331 struct fsnotify_event *event,
332 int (*merge)(struct list_head *, 332 int (*merge)(struct list_head *,
333 struct fsnotify_event *)); 333 struct fsnotify_event *));
334/* Queue overflow event to a notification group */
335static inline void fsnotify_queue_overflow(struct fsnotify_group *group)
336{
337 fsnotify_add_event(group, group->overflow_event, NULL);
338}
339
334/* true if the group notification queue is empty */ 340/* true if the group notification queue is empty */
335extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group); 341extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group);
336/* return, but do not dequeue the first event on the notification queue */ 342/* return, but do not dequeue the first event on the notification queue */
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 5ac9de4fcd6f..ca9772c8e48b 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -267,7 +267,6 @@ struct dqstats {
267 struct percpu_counter counter[_DQST_DQSTAT_LAST]; 267 struct percpu_counter counter[_DQST_DQSTAT_LAST];
268}; 268};
269 269
270extern struct dqstats *dqstats_pcpu;
271extern struct dqstats dqstats; 270extern struct dqstats dqstats;
272 271
273static inline void dqstats_inc(unsigned int type) 272static inline void dqstats_inc(unsigned int type)
diff --git a/include/uapi/linux/inotify.h b/include/uapi/linux/inotify.h
index 5474461683db..4800bf2a531d 100644
--- a/include/uapi/linux/inotify.h
+++ b/include/uapi/linux/inotify.h
@@ -71,5 +71,13 @@ struct inotify_event {
71#define IN_CLOEXEC O_CLOEXEC 71#define IN_CLOEXEC O_CLOEXEC
72#define IN_NONBLOCK O_NONBLOCK 72#define IN_NONBLOCK O_NONBLOCK
73 73
74/*
75 * ioctl numbers: inotify uses 'I' prefix for all ioctls,
76 * except historical FIONREAD, which is based on 'T'.
77 *
78 * INOTIFY_IOC_SETNEXTWD: set desired number of next created
79 * watch descriptor.
80 */
81#define INOTIFY_IOC_SETNEXTWD _IOW('I', 0, __s32)
74 82
75#endif /* _UAPI_LINUX_INOTIFY_H */ 83#endif /* _UAPI_LINUX_INOTIFY_H */