static gid_t arg_gid = GID_INVALID;
static bool arg_fsck = true;
static bool arg_aggressive_gc = false;
+static bool arg_tmpfs = false;
STATIC_DESTRUCTOR_REGISTER(arg_mount_what, freep);
STATIC_DESTRUCTOR_REGISTER(arg_mount_where, freep);
STATIC_DESTRUCTOR_REGISTER(arg_property, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_automount_property, strv_freep);
+static int parse_where(const char *input, char **ret_where) {
+ _cleanup_free_ char *where = NULL;
+ int r;
+
+ assert(input);
+ assert(ret_where);
+
+ if (arg_transport == BUS_TRANSPORT_LOCAL) {
+ r = chase(input, NULL, CHASE_NONEXISTENT, &where, NULL);
+ if (r < 0)
+ return log_error_errno(r, "Failed to make path %s absolute: %m", input);
+ } else {
+ where = strdup(input);
+ if (!where)
+ return log_oom();
+
+ path_simplify(where);
+
+ if (!path_is_absolute(where))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Path must be absolute when operating remotely: %s",
+ where);
+ }
+
+ *ret_where = TAKE_PTR(where);
+ return 0;
+}
+
static int help(void) {
_cleanup_free_ char *link = NULL;
int r;
return log_oom();
printf("systemd-mount [OPTIONS...] WHAT [WHERE]\n"
+ "systemd-mount [OPTIONS...] --tmpfs [NAME] WHERE\n"
"systemd-mount [OPTIONS...] --list\n"
"%s [OPTIONS...] %sWHAT|WHERE...\n\n"
"Establish a mount or auto-mount point transiently.\n\n"
" --list List mountable block devices\n"
" -u --umount Unmount mount points\n"
" -G --collect Unload unit after it stopped, even when failed\n"
+ " -T --tmpfs Create a new tmpfs on the mount point\n"
"\nSee the %s for details.\n",
program_invocation_short_name,
streq(program_invocation_short_name, "systemd-umount") ? "" : "--umount ",
{ "umount", no_argument, NULL, 'u' },
{ "unmount", no_argument, NULL, 'u' },
{ "collect", no_argument, NULL, 'G' },
+ { "tmpfs", no_argument, NULL, 'T' },
{},
};
if (invoked_as(argv, "systemd-umount"))
arg_action = ACTION_UMOUNT;
- while ((c = getopt_long(argc, argv, "hqH:M:t:o:p:AuGl", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "hqH:M:t:o:p:AuGlT", options, NULL)) >= 0)
switch (c) {
arg_aggressive_gc = true;
break;
+ case 'T':
+ arg_tmpfs = true;
+ break;
+
case '?':
return -EINVAL;
for (i = optind; i < argc; i++)
if (!path_is_absolute(argv[i]) )
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Only absolute path is supported: %s", argv[i]);
+ "Path must be absolute when operating remotely: %s",
+ argv[i]);
}
} else {
if (optind >= argc)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"At most two arguments required.");
- if (arg_mount_type && !fstype_is_blockdev_backed(arg_mount_type)) {
- arg_mount_what = strdup(argv[optind]);
- if (!arg_mount_what)
- return log_oom();
+ if (arg_tmpfs) {
+ if (argc <= optind+1) {
+ arg_mount_what = strdup("tmpfs");
+ if (!arg_mount_what)
+ return log_oom();
- } else if (arg_transport == BUS_TRANSPORT_LOCAL) {
- _cleanup_free_ char *u = NULL;
+ r = parse_where(argv[optind], &arg_mount_where);
+ if (r < 0)
+ return r;
+ } else {
+ arg_mount_what = strdup(argv[optind]);
+ if (!arg_mount_what)
+ return log_oom();
+ }
- u = fstab_node_to_udev_node(argv[optind]);
- if (!u)
+ if (!strv_contains(arg_property, "Type=tmpfs") &&
+ strv_extend(&arg_property, "Type=tmpfs") < 0)
return log_oom();
-
- r = chase(u, NULL, 0, &arg_mount_what, NULL);
- if (r < 0)
- return log_error_errno(r, "Failed to make path %s absolute: %m", u);
} else {
- arg_mount_what = strdup(argv[optind]);
- if (!arg_mount_what)
- return log_oom();
+ if (arg_mount_type && !fstype_is_blockdev_backed(arg_mount_type)) {
+ arg_mount_what = strdup(argv[optind]);
+ if (!arg_mount_what)
+ return log_oom();
- path_simplify(arg_mount_what);
+ } else if (arg_transport == BUS_TRANSPORT_LOCAL) {
+ _cleanup_free_ char *u = NULL;
- if (!path_is_absolute(arg_mount_what))
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Only absolute path is supported: %s", arg_mount_what);
- }
+ u = fstab_node_to_udev_node(argv[optind]);
+ if (!u)
+ return log_oom();
- if (argc > optind+1) {
- if (arg_transport == BUS_TRANSPORT_LOCAL) {
- r = chase(argv[optind+1], NULL, CHASE_NONEXISTENT, &arg_mount_where, NULL);
+ r = chase(u, NULL, 0, &arg_mount_what, NULL);
if (r < 0)
- return log_error_errno(r, "Failed to make path %s absolute: %m", argv[optind+1]);
+ return log_error_errno(r, "Failed to make path %s absolute: %m", u);
} else {
- arg_mount_where = strdup(argv[optind+1]);
- if (!arg_mount_where)
+ arg_mount_what = strdup(argv[optind]);
+ if (!arg_mount_what)
return log_oom();
- path_simplify(arg_mount_where);
+ path_simplify(arg_mount_what);
- if (!path_is_absolute(arg_mount_where))
+ if (!path_is_absolute(arg_mount_what))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Only absolute path is supported: %s", arg_mount_where);
+ "Path must be absolute when operating remotely: %s",
+ arg_mount_what);
}
- } else
+ }
+
+ if (argc > optind+1) {
+ r = parse_where(argv[optind+1], &arg_mount_where);
+ if (r < 0)
+ return r;
+ } else if (!arg_tmpfs)
arg_discover = true;
if (arg_discover && arg_transport != BUS_TRANSPORT_LOCAL)