View | Details | Raw Unified | Return to bug 114847 | Differences between
and this patch

Collapse All | Expand All

(-)src/sbin/mount_ntfs/mount_ntfs.c (-7 / +21 lines)
Lines 75-92 Link Here
75
{
75
{
76
	struct ntfs_args args;
76
	struct ntfs_args args;
77
	struct stat sb;
77
	struct stat sb;
78
	int c, mntflags, set_gid, set_uid, set_mask;
78
	int c, mntflags, set_gid, set_uid, set_mask, set_dirmask;
79
	char *dev, *dir, mntpath[MAXPATHLEN];
79
	char *dev, *dir, mntpath[MAXPATHLEN];
80
80
81
	mntflags = set_gid = set_uid = set_mask = 0;
81
	mntflags = set_gid = set_uid = set_mask = set_dirmask = 0;
82
	(void)memset(&args, '\0', sizeof(args));
82
	(void)memset(&args, '\0', sizeof(args));
83
	args.cs_ntfs = NULL;
83
	args.cs_ntfs = NULL;
84
	args.cs_local = NULL;
84
	args.cs_local = NULL;
85
85
86
#ifdef TRANSITION_PERIOD_HACK
86
#ifdef TRANSITION_PERIOD_HACK
87
	while ((c = getopt(argc, argv, "aiu:g:m:o:C:W:")) !=  -1) {
87
	while ((c = getopt(argc, argv, "aiu:g:m:M:o:C:W:")) !=  -1) {
88
#else
88
#else
89
	while ((c = getopt(argc, argv, "aiu:g:m:o:C:")) !=  -1) {
89
	while ((c = getopt(argc, argv, "aiu:g:m:M:o:C:")) !=  -1) {
90
#endif
90
#endif
91
		switch (c) {
91
		switch (c) {
92
		case 'u':
92
		case 'u':
Lines 101-106 Link Here
101
			args.mode = a_mask(optarg);
101
			args.mode = a_mask(optarg);
102
			set_mask = 1;
102
			set_mask = 1;
103
			break;
103
			break;
104
		case 'M':
105
			args.dirmode = a_mask(optarg);
106
			set_dirmask = 1;
107
			break;
104
		case 'i':
108
		case 'i':
105
			args.flag |= NTFS_MFLAG_CASEINS;
109
			args.flag |= NTFS_MFLAG_CASEINS;
106
			break;
110
			break;
Lines 146-151 Link Here
146
	if (optind + 2 != argc)
150
	if (optind + 2 != argc)
147
		usage();
151
		usage();
148
152
153
	if (set_mask && !set_dirmask) {
154
		args.dirmode = args.mode;
155
		set_dirmask = 1;
156
	}
157
	else if (set_dirmask && !set_mask) {
158
		args.mode = args.dirmode;
159
		set_mask = 1;
160
	}
161
149
	dev = argv[optind];
162
	dev = argv[optind];
150
	dir = argv[optind + 1];
163
	dir = argv[optind + 1];
151
164
Lines 183-189 Link Here
183
		if (!set_gid)
196
		if (!set_gid)
184
			args.gid = sb.st_gid;
197
			args.gid = sb.st_gid;
185
		if (!set_mask)
198
		if (!set_mask)
186
			args.mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
199
			args.mode = args.dirmode =
200
				sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
187
	}
201
	}
188
202
189
	if (mount("ntfs", mntpath, mntflags, &args) < 0)
203
	if (mount("ntfs", mntpath, mntflags, &args) < 0)
Lines 254-263 Link Here
254
{
268
{
255
#ifdef TRANSITION_PERIOD_HACK
269
#ifdef TRANSITION_PERIOD_HACK
256
	fprintf(stderr, "%s\n%s\n",
270
	fprintf(stderr, "%s\n%s\n",
257
	"usage: mount_ntfs [-a] [-i] [-u user] [-g group] [-m mask]",
271
	"usage: mount_ntfs [-a] [-i] [-u user] [-g group] [-M mask] [-m mask]",
258
	"                  [-C charset] [-W u2wtable] special node");
272
	"                  [-C charset] [-W u2wtable] special node");
259
#else
273
#else
260
	fprintf(stderr, "usage: mount_ntfs [-a] [-i] [-u user] [-g group] [-m mask] [-C charset] special node\n");
274
	fprintf(stderr, "usage: mount_ntfs [-a] [-i] [-u user] [-g group] [-M mask] [-m mask] [-C charset] special node\n");
261
#endif
275
#endif
262
	exit(EX_USAGE);
276
	exit(EX_USAGE);
263
}
277
}
(-)src/sbin/mount_ntfs/mount_ntfs.8 (+32 lines)
Lines 42-47 Link Here
42
.Op Fl i
42
.Op Fl i
43
.Op Fl u Ar user
43
.Op Fl u Ar user
44
.Op Fl g Ar group
44
.Op Fl g Ar group
45
.Op Fl M Ar mask
45
.Op Fl m Ar mask
46
.Op Fl m Ar mask
46
.Op Fl C Ar charset
47
.Op Fl C Ar charset
47
.Op Fl W Ar u2wtable
48
.Op Fl W Ar u2wtable
Lines 82-87 Link Here
82
.It Fl m Ar mask
83
.It Fl m Ar mask
83
Specify the maximum file permissions for files
84
Specify the maximum file permissions for files
84
in the file system.
85
in the file system.
86
(For example, a
87
.Ar mask
88
of
89
.Li 755
90
specifies that, by default, the owner should have
91
read, write, and execute permissions for files, but
92
others should only have read and execute permissions.
93
See
94
.Xr chmod 1
95
for more information about octal file modes.
96
Only the nine low-order bits of
97
.Ar mask
98
are used.
99
The value of
100
.Ar -M
101
is used if it is supplied and
102
.Ar -m
103
is omitted.
104
The default
105
.Ar mask
106
is taken from the
107
directory on which the file system is being mounted.
108
.It Fl M Ar mask
109
Specify the maximum file permissions for directories
110
in the file system.
111
The value of
112
.Ar -m
113
is used if it is supplied and
114
.Ar -M
115
is omitted.
116
See the previous option's description for details.                                   
85
.It Fl C Ar charset
117
.It Fl C Ar charset
86
Specify local
118
Specify local
87
.Ar charset
119
.Ar charset
(-)src/sys/fs/ntfs/ntfs.h (+1 lines)
Lines 249-254 Link Here
249
	uid_t           ntm_uid;
249
	uid_t           ntm_uid;
250
	gid_t           ntm_gid;
250
	gid_t           ntm_gid;
251
	mode_t          ntm_mode;
251
	mode_t          ntm_mode;
252
	mode_t		ntm_dirmode;
252
	u_int           ntm_flag;
253
	u_int           ntm_flag;
253
	cn_t		ntm_cfree;
254
	cn_t		ntm_cfree;
254
	struct ntvattrdef *ntm_ad;
255
	struct ntvattrdef *ntm_ad;
(-)src/sys/fs/ntfs/ntfsmount.h (+1 lines)
Lines 38-43 Link Here
38
	uid_t	uid;			/* uid that owns ntfs files */
38
	uid_t	uid;			/* uid that owns ntfs files */
39
	gid_t	gid;			/* gid that owns ntfs files */
39
	gid_t	gid;			/* gid that owns ntfs files */
40
	mode_t	mode;			/* mask to be applied for ntfs perms */
40
	mode_t	mode;			/* mask to be applied for ntfs perms */
41
	mode_t	dirmode;		/* mask to be applied for directories */
41
	u_long	flag;			/* additional flags */
42
	u_long	flag;			/* additional flags */
42
	char	*cs_ntfs;		/* NTFS Charset */
43
	char	*cs_ntfs;		/* NTFS Charset */
43
	char	*cs_local;		/* Local Charset */
44
	char	*cs_local;		/* Local Charset */
(-)src/sys/fs/ntfs/ntfs_vfsops.c (-4 / +8 lines)
Lines 42-47 Link Here
42
#include <sys/fcntl.h>
42
#include <sys/fcntl.h>
43
#include <sys/malloc.h>
43
#include <sys/malloc.h>
44
#include <sys/systm.h>
44
#include <sys/systm.h>
45
#include <sys/stat.h>			/* ACCESSPERMS */
45
46
46
#include <geom/geom.h>
47
#include <geom/geom.h>
47
#include <geom/geom_vfs.h>
48
#include <geom/geom_vfs.h>
Lines 131-136 Link Here
131
	ma = mount_argf(ma, "uid", "%d", args.uid);
132
	ma = mount_argf(ma, "uid", "%d", args.uid);
132
	ma = mount_argf(ma, "gid", "%d", args.gid);
133
	ma = mount_argf(ma, "gid", "%d", args.gid);
133
	ma = mount_argf(ma, "mode", "%d", args.mode);
134
	ma = mount_argf(ma, "mode", "%d", args.mode);
135
	ma = mount_argf(ma, "dirmode", "%d", args.dirmode);
134
	ma = mount_argb(ma, args.flag & NTFS_MFLAG_CASEINS, "nocaseins");
136
	ma = mount_argb(ma, args.flag & NTFS_MFLAG_CASEINS, "nocaseins");
135
	ma = mount_argb(ma, args.flag & NTFS_MFLAG_ALLNAMES, "noallnames");
137
	ma = mount_argb(ma, args.flag & NTFS_MFLAG_ALLNAMES, "noallnames");
136
	if (args.flag & NTFS_MFLAG_KICONV) {
138
	if (args.flag & NTFS_MFLAG_KICONV) {
Lines 144-150 Link Here
144
}
146
}
145
147
146
static const char *ntfs_opts[] = {
148
static const char *ntfs_opts[] = {
147
	"from", "export", "uid", "gid", "mode", "caseins", "allnames",
149
	"from", "export", "uid", "gid", "mode", "dirmode", "caseins", "allnames",
148
	"kiconv", "cs_ntfs", "cs_local", NULL
150
	"kiconv", "cs_ntfs", "cs_local", NULL
149
};
151
};
150
152
Lines 318-324 Link Here
318
	if (1 == vfs_scanopt(mp->mnt_optnew, "gid", "%d", &v))
320
	if (1 == vfs_scanopt(mp->mnt_optnew, "gid", "%d", &v))
319
		ntmp->ntm_gid = v;
321
		ntmp->ntm_gid = v;
320
	if (1 == vfs_scanopt(mp->mnt_optnew, "mode", "%d", &v))
322
	if (1 == vfs_scanopt(mp->mnt_optnew, "mode", "%d", &v))
321
		ntmp->ntm_mode = v;
323
		ntmp->ntm_mode = v & ACCESSPERMS;
324
	if (1 == vfs_scanopt(mp->mnt_optnew, "dirmode", "%d", &v))
325
		ntmp->ntm_dirmode = v & ACCESSPERMS;
322
	vfs_flagopt(mp->mnt_optnew,
326
	vfs_flagopt(mp->mnt_optnew,
323
	    "caseins", &ntmp->ntm_flag, NTFS_MFLAG_CASEINS);
327
	    "caseins", &ntmp->ntm_flag, NTFS_MFLAG_CASEINS);
324
	vfs_flagopt(mp->mnt_optnew,
328
	vfs_flagopt(mp->mnt_optnew,
Lines 342-351 Link Here
342
346
343
	mp->mnt_data = (qaddr_t)ntmp;
347
	mp->mnt_data = (qaddr_t)ntmp;
344
348
345
	dprintf(("ntfs_mountfs(): case-%s,%s uid: %d, gid: %d, mode: %o\n",
349
	dprintf(("ntfs_mountfs(): case-%s,%s uid: %d, gid: %d, mode: %o, dirmode: %o\n",
346
		(ntmp->ntm_flag & NTFS_MFLAG_CASEINS)?"insens.":"sens.",
350
		(ntmp->ntm_flag & NTFS_MFLAG_CASEINS)?"insens.":"sens.",
347
		(ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)?" allnames,":"",
351
		(ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)?" allnames,":"",
348
		ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode));
352
		ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode, ntmp->ntm_dirmode));
349
353
350
	/*
354
	/*
351
	 * We read in some system nodes to do not allow 
355
	 * We read in some system nodes to do not allow 
(-)src/sys/fs/ntfs/ntfs_vnops.c (-3 / +7 lines)
Lines 186-192 Link Here
186
186
187
	vap->va_fsid = dev2udev(ip->i_dev);
187
	vap->va_fsid = dev2udev(ip->i_dev);
188
	vap->va_fileid = ip->i_number;
188
	vap->va_fileid = ip->i_number;
189
	vap->va_mode = ip->i_mp->ntm_mode;
189
	vap->va_mode = (vp->v_type == VDIR) ?
190
	    ip->i_mp->ntm_dirmode : ip->i_mp->ntm_mode;
190
	vap->va_nlink = (ip->i_nlink || ip->i_flag & IN_LOADED ? ip->i_nlink : 1);
191
	vap->va_nlink = (ip->i_nlink || ip->i_flag & IN_LOADED ? ip->i_nlink : 1);
191
	vap->va_uid = ip->i_mp->ntm_uid;
192
	vap->va_uid = ip->i_mp->ntm_uid;
192
	vap->va_gid = ip->i_mp->ntm_gid;
193
	vap->va_gid = ip->i_mp->ntm_gid;
Lines 392-404 Link Here
392
{
393
{
393
	struct vnode *vp = ap->a_vp;
394
	struct vnode *vp = ap->a_vp;
394
	struct ntnode *ip = VTONT(vp);
395
	struct ntnode *ip = VTONT(vp);
395
	mode_t mode = ap->a_mode;
396
	mode_t file_mode, mode = ap->a_mode;
396
#ifdef QUOTA
397
#ifdef QUOTA
397
	int error;
398
	int error;
398
#endif
399
#endif
399
400
400
	dprintf(("ntfs_access: %d\n",ip->i_number));
401
	dprintf(("ntfs_access: %d\n",ip->i_number));
401
402
403
	file_mode = (vp->v_type == VDIR) ?
404
	    ip->i_mp->ntm_dirmode : ip->i_mp->ntm_mode;
405
402
	/*
406
	/*
403
	 * Disallow write attempts on read-only filesystems;
407
	 * Disallow write attempts on read-only filesystems;
404
	 * unless the file is a socket, fifo, or a block or
408
	 * unless the file is a socket, fifo, or a block or
Lines 419-425 Link Here
419
		}
423
		}
420
	}
424
	}
421
425
422
	return (vaccess(vp->v_type, ip->i_mp->ntm_mode, ip->i_mp->ntm_uid,
426
	return (vaccess(vp->v_type, file_mode, ip->i_mp->ntm_uid,
423
	    ip->i_mp->ntm_gid, ap->a_mode, ap->a_cred, NULL));
427
	    ip->i_mp->ntm_gid, ap->a_mode, ap->a_cred, NULL));
424
} 
428
} 
425
429

Return to bug 114847