summaryrefslogtreecommitdiffstats
path: root/sys-utils/mount.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys-utils/mount.c')
-rw-r--r--sys-utils/mount.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index dba6fca..50e66de 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -1,4 +1,6 @@
/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
* mount(8) -- mount a filesystem
*
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
@@ -8,17 +10,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -482,7 +474,7 @@ static void __attribute__((__noreturn__)) usage(void)
FILE *out = stdout;
fputs(USAGE_HEADER, out);
- printf(_(
+ fprintf(out, _(
" %1$s [-lhV]\n"
" %1$s -a [options]\n"
" %1$s [options] [--source] <source> | [--target] <directory>\n"
@@ -501,6 +493,12 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -T, --fstab <path> alternative file to /etc/fstab\n"), out);
fputs(_(" -i, --internal-only don't call the mount.<type> helpers\n"), out);
fputs(_(" -l, --show-labels show also filesystem labels\n"), out);
+ fputs(_(" --map-groups <inner>:<outer>:<count>\n"
+ " add the specified GID map to an ID-mapped mount\n"), out);
+ fputs(_(" --map-users <inner>:<outer>:<count>\n"
+ " add the specified UID map to an ID-mapped mount\n"), out);
+ fputs(_(" --map-users /proc/<pid>/ns/user\n"
+ " specify the user namespace for an ID-mapped mount\n"), out);
fputs(_(" -m, --mkdir[=<mode>] alias to '-o X-mount.mkdir[=<mode>]'\n"), out);
fputs(_(" -n, --no-mtab don't write to /etc/mtab\n"), out);
fputs(_(" --options-mode <mode>\n"
@@ -523,7 +521,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -N, --namespace <ns> perform mount in another namespace\n"), out);
fputs(USAGE_SEPARATOR, out);
- printf(USAGE_HELP_OPTIONS(25));
+ fprintf(out, USAGE_HELP_OPTIONS(25));
fputs(USAGE_SEPARATOR, out);
fputs(_("Source:\n"), out);
@@ -552,7 +550,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" --make-rprivate recursively mark a whole subtree as private\n"), out);
fputs(_(" --make-runbindable recursively mark a whole subtree as unbindable\n"), out);
- printf(USAGE_MAN_TAIL("mount(8)"));
+ fprintf(out, USAGE_MAN_TAIL("mount(8)"));
exit(MNT_EX_SUCCESS);
}
@@ -615,6 +613,7 @@ int main(int argc, char **argv)
int c, rc = MNT_EX_SUCCESS, all = 0, show_labels = 0;
struct libmnt_context *cxt;
struct libmnt_table *fstab = NULL;
+ char *idmap = NULL;
char *srcbuf = NULL;
char *types = NULL;
int oper = 0, is_move = 0;
@@ -630,6 +629,8 @@ int main(int argc, char **argv)
MOUNT_OPT_RSLAVE,
MOUNT_OPT_RPRIVATE,
MOUNT_OPT_RUNBINDABLE,
+ MOUNT_OPT_MAP_GROUPS,
+ MOUNT_OPT_MAP_USERS,
MOUNT_OPT_TARGET,
MOUNT_OPT_TARGET_PREFIX,
MOUNT_OPT_SOURCE,
@@ -668,6 +669,8 @@ int main(int argc, char **argv)
{ "make-rslave", no_argument, NULL, MOUNT_OPT_RSLAVE },
{ "make-rprivate", no_argument, NULL, MOUNT_OPT_RPRIVATE },
{ "make-runbindable", no_argument, NULL, MOUNT_OPT_RUNBINDABLE },
+ { "map-groups", required_argument, NULL, MOUNT_OPT_MAP_GROUPS },
+ { "map-users", required_argument, NULL, MOUNT_OPT_MAP_USERS },
{ "mkdir", optional_argument, NULL, 'm' },
{ "no-canonicalize", no_argument, NULL, 'c' },
{ "internal-only", no_argument, NULL, 'i' },
@@ -850,6 +853,23 @@ int main(int argc, char **argv)
append_option(cxt, "runbindable", NULL);
propa = 1;
break;
+ case MOUNT_OPT_MAP_GROUPS:
+ case MOUNT_OPT_MAP_USERS:
+ if (*optarg == '=')
+ optarg++;
+ if (idmap && (*idmap == '/' || *optarg == '/')) {
+ warnx(_("bad usage"));
+ errtryhelp(MNT_EX_USAGE);
+ } else if (*optarg == '/') {
+ idmap = xstrdup(optarg);
+ } else {
+ char *tmp;
+ xasprintf(&tmp, "%s%s%s%s", idmap ? idmap : "", idmap ? " " : "",
+ c == MOUNT_OPT_MAP_GROUPS ? "g:" : "u:", optarg);
+ free(idmap);
+ idmap = tmp;
+ }
+ break;
case MOUNT_OPT_TARGET:
mnt_context_disable_swapmatch(cxt, 1);
mnt_context_set_target(cxt, optarg);
@@ -898,6 +918,9 @@ int main(int argc, char **argv)
argc -= optind;
argv += optind;
+ if (idmap)
+ append_option(cxt, "X-mount.idmap", idmap);
+
optmode |= optmode_mode | optmode_src;
if (optmode) {
if (!optmode_mode)