diff options
| -rw-r--r-- | usr/src/uts/common/fs/tmpfs/tmp_subr.c | 34 | ||||
| -rw-r--r-- | usr/src/uts/common/fs/tmpfs/tmp_vfsops.c | 11 | ||||
| -rw-r--r-- | usr/src/uts/common/sys/fs/tmp.h | 2 | 
3 files changed, 43 insertions, 4 deletions
| diff --git a/usr/src/uts/common/fs/tmpfs/tmp_subr.c b/usr/src/uts/common/fs/tmpfs/tmp_subr.c index 6b752b3f5b..150ce2a220 100644 --- a/usr/src/uts/common/fs/tmpfs/tmp_subr.c +++ b/usr/src/uts/common/fs/tmpfs/tmp_subr.c @@ -196,9 +196,12 @@ int  tmp_convnum(char *str, size_t *maxbytes)  {  	u_longlong_t num = 0; -	u_longlong_t max_bytes = (uint64_t)SIZE_MAX; +#ifdef _LP64 +	u_longlong_t max_bytes = ULONG_MAX; +#else +	u_longlong_t max_bytes = PAGESIZE * (uint64_t)ULONG_MAX; +#endif  	size_t pages; -  	char *c;  	const struct convchar {  		char *cc_char; @@ -288,7 +291,6 @@ valid_char:  	}  done: -  	/*  	 * We've been given a size in bytes; however, we want to make sure that  	 * we have at least one page worth no matter what. Therefore we use @@ -333,3 +335,29 @@ tmp_convmode(char *str, mode_t *mode)  	*mode = VALIDMODEBITS & num;  	return (0);  } + +/* + * Parse an octal mode string for use as the permissions set for the root + * of the tmpfs mount. + */ +int +tmp_convmode(char *str, mode_t *mode) +{ +	ulong_t num; +	char *c; + +	if (str == NULL) { +		return (EINVAL); +	} + +	if (ddi_strtoul(str, &c, 8, &num) != 0) { +		return (EINVAL); +	} + +	if ((num & ~VALIDMODEBITS) != 0) { +		return (EINVAL); +	} + +	*mode = VALIDMODEBITS & num; +	return (0); +} diff --git a/usr/src/uts/common/fs/tmpfs/tmp_vfsops.c b/usr/src/uts/common/fs/tmpfs/tmp_vfsops.c index 6013134be2..cef582ab86 100644 --- a/usr/src/uts/common/fs/tmpfs/tmp_vfsops.c +++ b/usr/src/uts/common/fs/tmpfs/tmp_vfsops.c @@ -295,6 +295,17 @@ tmp_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)  		mode_arg = B_TRUE;  	} +	/* +	 * The "mode" mount argument allows the operator to override the +	 * permissions of the root of the tmpfs mount. +	 */ +	if (vfs_optionisset(vfsp, "mode", &argstr)) { +		if ((error = tmp_convmode(argstr, &root_mode)) != 0) { +			goto out; +		} +		mode_arg = B_TRUE; +	} +  	if (error = pn_get(uap->dir,  	    (uap->flags & MS_SYSSPACE) ? UIO_SYSSPACE : UIO_USERSPACE, &dpn))  		goto out; diff --git a/usr/src/uts/common/sys/fs/tmp.h b/usr/src/uts/common/sys/fs/tmp.h index e4e81cc498..f4cee09244 100644 --- a/usr/src/uts/common/sys/fs/tmp.h +++ b/usr/src/uts/common/sys/fs/tmp.h @@ -109,7 +109,7 @@ extern	int	tmp_resv(struct tmount *, struct tmpnode *, size_t, int);  extern	int	tmp_taccess(void *, int, struct cred *);  extern	int	tmp_sticky_remove_access(struct tmpnode *, struct tmpnode *,  	struct cred *); -extern	int	tmp_convnum(char *, size_t *); +extern	int	tmp_convnum(char *, pgcnt_t *);  extern	int	tmp_convmode(char *, mode_t *);  extern	int	tdirenter(struct tmount *, struct tmpnode *, char *,  	enum de_op, struct tmpnode *, struct tmpnode *, struct vattr *, | 
