The example code
FILE* fp = setmntent("/proc/mounts", "r");
if (fp == NULL) {
ALOGE("Error opening /proc/mounts: %s", strerror(errno));
return -errno;
}
// Some volumes can be stacked on each other, so force unmount in
// reverse order to give us the best chance of success.
std::list<std::string> toUnmount;
mntent* mentry;
while ((mentry = getmntent(fp)) != NULL) {
if (strncmp(mentry->mnt_dir, path, path_len) == 0) {
toUnmount.push_front(std::string(mentry->mnt_dir));
}
}
endmntent(fp);
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 */
};
# cat /proc/mounts | grep storage
/mnt/media_rw/F8BC-080E /storage/F8BC-080E sdcardfs rw,nosuid,nodev,noexec,noatime,low_uid=1023,low_gid=1023,gid=1015,mask=0006 0 0
mnt_fsname |
/mnt/media_rw/F8BC-080E |
mnt_dir |
/storage/emulated |
mnt_type |
sdcardfs |
mnt_opts |
rw,nosuid,nodev,noexec,noatime,low_uid=1023,low_gid=1023,gid=1015,mask=0006 |
mnt_freq |
0 |
mnt_passno | 0 |
'Programming > Linux_Platform' 카테고리의 다른 글
[systemd-analyze] systemd debugging & analyze method (0) | 2020.01.22 |
---|---|
SetUID / SetGID Special File Permissions (0) | 2017.11.22 |
signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr (0) | 2017.01.23 |
makedev (0) | 2016.10.31 |
파일의 속성을 check 하는 코드 - fstatat, fstat, stat, lstat (0) | 2016.10.31 |