aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ntfs/super.c')
-rw-r--r--fs/ntfs/super.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 2bc149d6a784..da01c165067d 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -102,8 +102,8 @@ static bool parse_options(ntfs_volume *vol, char *opt)
102 char *p, *v, *ov; 102 char *p, *v, *ov;
103 static char *utf8 = "utf8"; 103 static char *utf8 = "utf8";
104 int errors = 0, sloppy = 0; 104 int errors = 0, sloppy = 0;
105 uid_t uid = (uid_t)-1; 105 kuid_t uid = INVALID_UID;
106 gid_t gid = (gid_t)-1; 106 kgid_t gid = INVALID_GID;
107 umode_t fmask = (umode_t)-1, dmask = (umode_t)-1; 107 umode_t fmask = (umode_t)-1, dmask = (umode_t)-1;
108 int mft_zone_multiplier = -1, on_errors = -1; 108 int mft_zone_multiplier = -1, on_errors = -1;
109 int show_sys_files = -1, case_sensitive = -1, disable_sparse = -1; 109 int show_sys_files = -1, case_sensitive = -1, disable_sparse = -1;
@@ -128,6 +128,30 @@ static bool parse_options(ntfs_volume *vol, char *opt)
128 if (*v) \ 128 if (*v) \
129 goto needs_val; \ 129 goto needs_val; \
130 } 130 }
131#define NTFS_GETOPT_UID(option, variable) \
132 if (!strcmp(p, option)) { \
133 uid_t uid_value; \
134 if (!v || !*v) \
135 goto needs_arg; \
136 uid_value = simple_strtoul(ov = v, &v, 0); \
137 if (*v) \
138 goto needs_val; \
139 variable = make_kuid(current_user_ns(), uid_value); \
140 if (!uid_valid(variable)) \
141 goto needs_val; \
142 }
143#define NTFS_GETOPT_GID(option, variable) \
144 if (!strcmp(p, option)) { \
145 gid_t gid_value; \
146 if (!v || !*v) \
147 goto needs_arg; \
148 gid_value = simple_strtoul(ov = v, &v, 0); \
149 if (*v) \
150 goto needs_val; \
151 variable = make_kgid(current_user_ns(), gid_value); \
152 if (!gid_valid(variable)) \
153 goto needs_val; \
154 }
131#define NTFS_GETOPT_OCTAL(option, variable) \ 155#define NTFS_GETOPT_OCTAL(option, variable) \
132 if (!strcmp(p, option)) { \ 156 if (!strcmp(p, option)) { \
133 if (!v || !*v) \ 157 if (!v || !*v) \
@@ -165,8 +189,8 @@ static bool parse_options(ntfs_volume *vol, char *opt)
165 while ((p = strsep(&opt, ","))) { 189 while ((p = strsep(&opt, ","))) {
166 if ((v = strchr(p, '='))) 190 if ((v = strchr(p, '=')))
167 *v++ = 0; 191 *v++ = 0;
168 NTFS_GETOPT("uid", uid) 192 NTFS_GETOPT_UID("uid", uid)
169 else NTFS_GETOPT("gid", gid) 193 else NTFS_GETOPT_GID("gid", gid)
170 else NTFS_GETOPT_OCTAL("umask", fmask = dmask) 194 else NTFS_GETOPT_OCTAL("umask", fmask = dmask)
171 else NTFS_GETOPT_OCTAL("fmask", fmask) 195 else NTFS_GETOPT_OCTAL("fmask", fmask)
172 else NTFS_GETOPT_OCTAL("dmask", dmask) 196 else NTFS_GETOPT_OCTAL("dmask", dmask)
@@ -283,9 +307,9 @@ no_mount_options:
283 vol->on_errors = on_errors; 307 vol->on_errors = on_errors;
284 if (!vol->on_errors || vol->on_errors == ON_ERRORS_RECOVER) 308 if (!vol->on_errors || vol->on_errors == ON_ERRORS_RECOVER)
285 vol->on_errors |= ON_ERRORS_CONTINUE; 309 vol->on_errors |= ON_ERRORS_CONTINUE;
286 if (uid != (uid_t)-1) 310 if (uid_valid(uid))
287 vol->uid = uid; 311 vol->uid = uid;
288 if (gid != (gid_t)-1) 312 if (gid_valid(gid))
289 vol->gid = gid; 313 vol->gid = gid;
290 if (fmask != (umode_t)-1) 314 if (fmask != (umode_t)-1)
291 vol->fmask = fmask; 315 vol->fmask = fmask;
@@ -1023,7 +1047,8 @@ static bool load_and_init_mft_mirror(ntfs_volume *vol)
1023 * ntfs_read_inode() will have set up the default ones. 1047 * ntfs_read_inode() will have set up the default ones.
1024 */ 1048 */
1025 /* Set uid and gid to root. */ 1049 /* Set uid and gid to root. */
1026 tmp_ino->i_uid = tmp_ino->i_gid = 0; 1050 tmp_ino->i_uid = GLOBAL_ROOT_UID;
1051 tmp_ino->i_gid = GLOBAL_ROOT_GID;
1027 /* Regular file. No access for anyone. */ 1052 /* Regular file. No access for anyone. */
1028 tmp_ino->i_mode = S_IFREG; 1053 tmp_ino->i_mode = S_IFREG;
1029 /* No VFS initiated operations allowed for $MFTMirr. */ 1054 /* No VFS initiated operations allowed for $MFTMirr. */