C++ C++;检查装载路径是否仍在装载
我有使用C++ C++;检查装载路径是否仍在装载,c++,linux,mount,C++,Linux,Mount,我有使用getmntent 在以下定义的结构中: struct mntent { char *mnt_fsname; /* name of mounted file system */ char *mnt_dir; /* file system path prefix */ char *mnt_type; /* mount type (see mntent.h) */ char *mnt_opts; /* mount options
getmntent
在以下定义的结构中:
struct mntent {
char *mnt_fsname; /* name of mounted file system */
char *mnt_dir; /* file system path prefix */
char *mnt_type; /* mount type (see mntent.h) */
char *mnt_opts; /* mount options (see mntent.h) */
int mnt_freq; /* dump frequency in days */
int mnt_passno; /* pass number on parallel fsck */
};
使用mnt\u dir
我想检查装载路径是否在一段时间后仍然装载,因为在对其进行某些处理之前,它可能已经卸载。
检查路径是否仍然装入的最有效方法是什么
还有一种方法可以在卸载路径时获得回调吗?我认为最有效的方法是缓存
st\u dev
和st\u ino
返回的stat()
(尽管可能只缓存st\u dev
就足够了)
如果卷被卸载,装载点将恢复到最初装载卷的父文件系统中的空子目录,并且stat()
将为相同的文件路径返回不同的设备+索引节点
在收到通知之前,查看inotify(7)界面,注意
IN_UNMOUNT
事件。旁注:让设备保持忙碌状态,这样就无法卸载设备了?这无法完成,我无法控制设备您无法打开文件:)不应该对设备做任何事情:(fanotify(7)是否提供了类似的通知也一样?通过使用stat
我需要不断检查st\u dev
是否定期更改,对吗?我有一个要检查的路径列表,在这种情况下,继续检查会不会造成太多开销?