mount: drop duplicated includes
[project/mountd.git] / mount.c
diff --git a/mount.c b/mount.c
index ddcd5b3..1d581ea 100644 (file)
--- a/mount.c
+++ b/mount.c
 #include <sys/wait.h>
 #include <sys/inotify.h>
 #include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/types.h>
 #include <glob.h>
 #include <libgen.h>
 #include <poll.h>
-#include <dirent.h>
 #include <syslog.h>
 
 #include "include/log.h"
@@ -604,6 +601,7 @@ static int mount_dev_del(struct mount *mount)
                log_printf("device %s has disappeared ... unmounting %s\n", mount->dev, tmp);
                if (umount(tmp)) {
                        err = -errno;
+                       umount2(tmp, MNT_DETACH);
                }
                rmdir(tmp);
                mount_dump_uci_state();
@@ -773,11 +771,13 @@ static void mount_enum_drives(void)
                }
                if(!check_block(q->dev)||del)
                {
-                       int err;
-
-                       err = mount_dev_del(q);
                        if (q->status == STATUS_MOUNTED || q->status == STATUS_EXPIRED) {
                                char dev_link[64];
+                               int err;
+
+                               system_printf("ACTION=remove DEVICE=%s NAME=%s /sbin/hotplug-call mount", q->dev, q->name);
+
+                               err = mount_dev_del(q);
 
                                snprintf(dev_link, sizeof(dev_link), "%s%s", uci_path, q->name);
                                if (err == -EBUSY) {
@@ -791,7 +791,6 @@ static void mount_enum_drives(void)
                                        log_printf("unlinking %s\n", dev_link);
                                        unlink(dev_link);
                                }
-                               system_printf("ACTION=remove DEVICE=%s NAME=%s /sbin/hotplug-call mount", q->dev, q->name);
                        }
 
                        p->prev->next = p->next;