diff mbox series

[LEDE-DEV,mountd,2/3] mount: remove directory if mounting fails

Message ID 20180103103123.10950-2-zajec5@gmail.com
State Accepted
Delegated to: John Crispin
Headers show
Series [LEDE-DEV,mountd,1/3] mount: call hotplug mount scripts only on success | expand

Commit Message

Rafał Miłecki Jan. 3, 2018, 10:31 a.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/mount.c b/mount.c
index 803acc1..a88ca6d 100644
--- 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;