mount: remove directory if mounting fails
authorRafał Miłecki <rafal@milecki.pl>
Wed, 3 Jan 2018 10:31:22 +0000 (11:31 +0100)
committerJohn Crispin <john@phrozen.org>
Sun, 7 Jan 2018 11:49:17 +0000 (12:49 +0100)
Aside from just cleaning up mountd's tmp dir it's also important for
autofs support. With such an empty directory autofs_process_request
believed device is mounted and it kept replying AUTOFS_IOC_READY to the
kernel. It was causing a log storm like:
mountd[1015]: Got a autofs packet
mountd[1015]: kernel is requesting a mount -> sda1
mountd[1015]: Got a autofs packet
mountd[1015]: kernel is requesting a mount -> sda1
mountd[1015]: Got a autofs packet
mountd[1015]: kernel is requesting a mount -> sda1

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
mount.c

diff --git a/mount.c b/mount.c
index 803acc1fa8c7b644da82fb4d1bdf3573d59cf9f1..a88ca6d469ac79661f6927e10fc73e0a0155f771 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -292,8 +292,10 @@ int mount_new(char *path, char *dev)
        pid = waitpid(pid, &ret, 0);
        ret = WEXITSTATUS(ret);
        log_printf("----------> mount ret = %d\n", ret);
-       if(ret && (ret != 0xff))
+       if (ret && ret != 0xff) {
+               rmdir(tmp);
                return -1;
+       }
        if(mount_wait_for_disc(mount->dev) == 0)
        {
                mount->mounted = 1;