diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-03-24 11:54:40 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-03-24 11:54:40 +0000 |
| commit | 068773b51fabd86aafc34e873b159794103a5aff (patch) | |
| tree | 84884ff9672b1850b308fa321654a36419c90b1c | |
| parent | f6d8955399b29f58bf7c99638c215db5d6f17c60 (diff) | |
| parent | fd3bae1de25e92d631934ef3a53f13bb040103bd (diff) | |
| download | illumos-joyent-068773b51fabd86aafc34e873b159794103a5aff.tar.gz | |
[illumos-gate merge]
commit fd3bae1de25e92d631934ef3a53f13bb040103bd
7754 need tmpfs size support in percent
commit 401bc9af09d3e2bcb61df16867750651ccb30004
7752 tmpfs should support gigabyte sizes
7753 tmpfs should support "mode" option
Conflicts:
usr/src/uts/common/sys/fs/tmp.h
usr/src/uts/common/fs/tmpfs/tmp_subr.c
| -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 *, |
