From: Matthew Dillon Date: Thu, 18 Feb 2010 18:02:29 +0000 (-0800) Subject: utilities - TMPFS - Pass tmpfs_args to mount() X-Git-Tag: v2.7.0~178 X-Git-Url: https://gitweb.dragonflybsd.org/~nant/dragonfly.git/commitdiff_plain/ef20d7548cdf6a09a8b0d66da2e9665deec5074c utilities - TMPFS - Pass tmpfs_args to mount() * Pass parameters to mount(). Parameters were being ignored. * Use dehumanize_number() so suffixes can be specified for numbers when using -s, -n. --- diff --git a/sbin/mount_tmpfs/Makefile b/sbin/mount_tmpfs/Makefile index 8c430bcc40..c84942f926 100644 --- a/sbin/mount_tmpfs/Makefile +++ b/sbin/mount_tmpfs/Makefile @@ -4,6 +4,7 @@ PROG= mount_tmpfs SRCS= mount_tmpfs.c getmntopts.c MAN= mount_tmpfs.8 +LDADD+= -lutil MOUNT= ${.CURDIR}/../mount CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT} diff --git a/sbin/mount_tmpfs/mount_tmpfs.c b/sbin/mount_tmpfs/mount_tmpfs.c index 24d934a372..98d221d231 100644 --- a/sbin/mount_tmpfs/mount_tmpfs.c +++ b/sbin/mount_tmpfs/mount_tmpfs.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "mntopts.h" #include "mount_tmpfs.h" @@ -81,9 +82,8 @@ mount_tmpfs_parseargs(int argc, char *argv[], gid_t gid; uid_t uid; mode_t mode; - int64_t tmpnumber = 0; + int64_t tmpnumber; struct stat sb; - char *a; /* Set default values for mount point arguments. */ memset(args, 0, sizeof(*args)); @@ -110,10 +110,10 @@ mount_tmpfs_parseargs(int argc, char *argv[], break; case 'n': - for (a = optarg; *optarg && isdigit(*optarg); ++optarg); - if (!*optarg) - tmpnumber = strtoimax(a, NULL, 10); - + if (dehumanize_number(optarg, &tmpnumber) < 0) { + fprintf(stderr, "bad number for -n\n"); + usage(); + } args->ta_nodes_max = tmpnumber; break; @@ -122,10 +122,10 @@ mount_tmpfs_parseargs(int argc, char *argv[], break; case 's': - for (a = optarg; *optarg && isdigit(*optarg); ++optarg); - if (!*optarg) - tmpnumber = strtoimax(a, NULL, 10); - + if (dehumanize_number(optarg, &tmpnumber) < 0) { + fprintf(stderr, "bad number for -s\n"); + usage(); + } args->ta_size_max = tmpnumber; break; @@ -246,7 +246,7 @@ mount_tmpfs(int argc, char *argv[]) if (error) errx(EX_OSERR, "%s filesystem not available", "tmpfs"); - if (mount(vfc.vfc_name, canon_dir, mntflags, 0) == -1) + if (mount(vfc.vfc_name, canon_dir, mntflags, &args) == -1) err(EXIT_FAILURE, "tmpfs on %s", canon_dir); return EXIT_SUCCESS;