cleverca22
1/23/2016 - 3:31 AM

bash source

https://github.com/zfsonlinux/zfs/blob/master/module/zfs/zfs_ctldir.c

#define	SET_MOUNT_CMD \
	"exec 0</dev/null " \
	"     1>/dev/null " \
	"     2>/dev/null; " \
	"mount -t zfs -n '%s' '%s'"

	char *argv[] = { "/bin/sh", "-c", NULL, NULL };
	char *envp[] = { NULL };

	/*
	 * Attempt to mount the snapshot from user space.  Normally this
	 * would be done using the vfs_kern_mount() function, however that
	 * function is marked GPL-only and cannot be used.  On error we
	 * careful to log the real error to the console and return EISDIR
	 * to safely abort the automount.  This should be very rare.
	 */
	dprintf("mount; name=%s path=%s\n", full_name, full_path);
	argv[2] = kmem_asprintf(SET_MOUNT_CMD, full_name, full_path);
	error = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
[root@nas:~]# strace -e execve,stat -f env -i /bin/sh -c "mount -t zfs naspool/mc1@zfs-auto-snap_frequent-2016-01-23-04h15 /tmp/t -v"
execve("/run/current-system/sw/bin/env", ["env", "-i", "/bin/sh", "-c", "mount -t zfs naspool/mc1@zfs-aut"...], [/* 53 vars */]) = 0
execve("/bin/sh", ["/bin/sh", "-c", "mount -t zfs naspool/mc1@zfs-aut"...], [/* 0 vars */]) = 0
stat("/no-such-path/mount", 0x7ffeeb7aa9f0) = -1 ENOENT (No such file or directory)
/bin/sh: mount: command not found
+++ exited with 127 +++
https://github.com/NixOS/nixpkgs/blob/master/pkgs/shells/bash/default.nix
    -DDEFAULT_PATH_VALUE="/no-such-path"

bash source:
  /* Now make our own defaults in case the vars that we think are
     important are missing. */
  temp_var = set_if_not ("PATH", DEFAULT_PATH_VALUE);