Does blockd intentionally skip mounts if device name exists in / ?
David Adair
djabhead at aol.com
Thu Jun 3 19:21:43 PDT 2021
This will block autofs from mounting volumes with names like "home" or "usr" -- was that
actually the intent ?
root at OpenWrt:/# touch /cv
root at OpenWrt:/# ls /mnt/cv
ls: /mnt/cv: No such file or directory
root at OpenWrt:/# rm /cv
root at OpenWrt:/# ls /mnt/cv
[ 205.014819] EXT4-fs (dm-3): mounted filesystem with ordered data mode. Opts:
hi keepme lost+found tt
root at OpenWrt:~# cat /proc/2520/cmdline && echo -n " " && ls -l /proc/2520/cwd
/sbin/blockd lrwxrwxrwx 1 root root 0 Jun 3 00:01 /proc/2520/cwd -> /
Blockd does not forward mount request to block because of the lstat:
ULOG_ERR("kernel is requesting a mount -> %s\n", pkt->name);
if (lstat(pkt->name, &st) == -1)
if (block("autofs", "add", (char *)pkt->name))
cmd = AUTOFS_IOC_FAIL;
It seems like the intention was to check either /mnt or /tmp/run/blockd instead of / .
Since /mnt contains symlinks for mounts with the "autofs" property and directories
for anon mounts it seems to make sense but lstat will only work in /tmp/run/blockd.
Perhaps:
ULOG_ERR("kernel is requesting a mount -> %s\n", pkt->name);
if (asprintf(&mnt, "/mnt/%s", pkt->name) == -1)
exit(ENOMEM);
if (stat(mnt, &st) == -1)
if (block("autofs", "add", (char *)pkt->name))
cmd = AUTOFS_IOC_FAIL;
free(mnt);
Or: ( haven't tested this one )
ULOG_ERR("kernel is requesting a mount -> %s\n", pkt->name);
if (asprintf(&mnt, "/mnt/%s", pkt->name) == -1)
exit(ENOMEM);
if (!lstat(pkt->name, &st) && S_ISLNK(st.st_mode))
if (block("autofs", "add", (char *)pkt->name))
cmd = AUTOFS_IOC_FAIL;
free(mnt);
Or just no test at all since there has effectively been no test for years.
More information about the openwrt-devel
mailing list