From 0f2708a50893911bd650e3b855e7b470b6c316a9 Mon Sep 17 00:00:00 2001
From: zhangyao2022 <zhangyao108@huawei.com>
Date: Mon, 15 Apr 2024 08:14:58 +0800
Subject: [PATCH] fix: resolve not mount home

---
 exts/fstab/src/main.rs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/exts/fstab/src/main.rs b/exts/fstab/src/main.rs
index 09d7dd34..4eea27dd 100644
--- a/exts/fstab/src/main.rs
+++ b/exts/fstab/src/main.rs
@@ -136,7 +136,7 @@ fn watch_devices(fstab_items: &[FSTabItem]) -> (Inotify, HashSet<String>) {
             file_path.file_name().unwrap().to_str().unwrap(),
         ));
         inotify
-            .add_watch(dir_path, WatchMask::CREATE)
+            .add_watch(dir_path, WatchMask::CREATE | WatchMask::MOVED_TO)
             .expect("Failed to add watch.");
     }
     (inotify, watch_set)
@@ -171,8 +171,10 @@ fn main() {
                 .read_events_blocking(&mut buffer)
                 .expect("Failed to read events.");
             for event in events {
-                if event.mask == EventMask::CREATE {
-                    log::debug!("File created: {:?}", event.name.unwrap());
+                if event.mask == EventMask::CREATE || event.mask == EventMask::MOVED_TO {
+                    if let Some(name) = event.name {
+                        log::debug!("File created or moved: {:?}", name);
+                    }
                     watch_updated = true;
                 }
             }
-- 
2.33.0

