linux系統程式設計手冊 檔案系統

2021-07-14 21:06:10 字數 3408 閱讀 8207

我們可以通過proc/mounts來檢視當前已經掛載的檔案系統的列表,下面是android手機上面cat該目錄後的結果:

rootfs / rootfs ro,seclabel 0 0

tmpfs /dev tmpfs rw,seclabel,nosuid,relatime,mode=755 0 0

devpts /dev/pts devpts rw,seclabel,relatime,mode=600 0 0

proc /proc proc rw,relatime 0 0

sysfs /sys sysfs rw,seclabel,relatime 0 0

selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0

debugfs /sys/kernel/debug debugfs rw,seclabel,relatime 0 0

none /acct cgroup rw,relatime,cpuacct 0 0

none /sys/fs/cgroup tmpfs rw,seclabel,relatime,mode=750,gid=1000 0 0

none /sys/fs/cgroup/memory cgroup rw,relatime,memory 0 0

tmpfs /mnt tmpfs rw,seclabel,relatime,mode=755,gid=1000 0 0

none /dev/memcg cgroup rw,relatime,memory 0 0

none /dev/cpuctl cgroup rw,relatime,cpu 0 0

tmpfs /tmp tmpfs rw,seclabel,relatime 0 0

/dev/block/platform/comip-mmc.1/by-name/system /system ext4 ro,seclabel,relatime,data=ordered 0 0

/dev/block/platform/comip-mmc.1/by-name/cache /cache ext4 rw,seclabel,nosuid,nodev,noatime,data=ordered 0 0

/dev/block/platform/comip-mmc.1/by-name/userdata /data ext4 rw,seclabel,nosuid,nodev,noatime,noauto_da_alloc,data=ordered 0 0

/dev/block/platform/comip-mmc.1/by-name/amt /amt ext4 rw,seclabel,relatime,data=ordered 0 0

tmpfs /storage tmpfs rw,seclabel,relatime,mode=755,gid=1000 0 0

/dev/fuse /mnt/runtime/default/emulated fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

/dev/fuse /storage/emulated fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

/dev/fuse /mnt/runtime/read/emulated fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

/dev/fuse /mnt/runtime/write/emulated fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

/dev/block/vold/public:179,129 /mnt/media_rw/c439-1bf7 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0

/dev/fuse /mnt/runtime/default/c439-1bf7 fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

/dev/fuse /storage/c439-1bf7 fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

/dev/fuse /mnt/runtime/read/c439-1bf7 fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

/dev/fuse /mnt/runtime/write/c439-1bf7 fuse rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0

int mount(const char* source, const char *target, const char* fstype, unsigned long mountflags, const void *data);

source:指定裝置所包含的檔案系統

target:掛載目錄

fstype:標識裝置所含檔案系統型別  ext4等

mountflags:掩碼,各個不同位代表不同功能

unmount(const char* target);

解除安裝已掛載的檔案系統。

無法解除安裝正在使用中的檔案系統,如果這個檔案系統上有檔案被開啟,或者程序當前工作目錄駐留在此檔案系統上。此時系統返回ebusy。

umount2(const char* target, int flags);

unmount2是unmount的擴充套件版,通過flags引數可以更加精確控制。

其中之前unmount不能解除安裝,我們可以使用unmount2函式其中的mnt_force這個flag可以強制解除安裝,但是可能造成資料丟失。

另外檔案系統可以掛載在多個地方

系統程式設計之檔案系統程式設計

系統呼叫 所有的作業系統都提供多種服務的入口點,程式由此向核心請求服務。這些可直接進入核心的入口點被稱為系統呼叫。不同作業系統提供了自己的一套系統呼叫,所以系統呼叫無法實現跨平台使用。而且頻繁地系統呼叫,在使用者態和核心態之間切換,很耗費資源,效率不高。c標準庫提供了操作檔案的標準i o函式庫,與系...

檔案系統 編寫檔案系統

8.5 編寫乙個檔案系統 如果寫乙個實際檔案系統,但是涉及的東西太多,不容易簡明扼要的理解檔案系統的實現。linux核心中提供的romfs檔案系統是個非常理想的例子,既有實際應用架構,也清晰明了,故以romfs為例項分析檔案系統的實現。一 linux檔案系統的實現要素 編寫新檔案系統涉及一些基本物件...

Linux系統程式設計 檔案

linux檔案描述符 系統呼叫 作業系統的五大功能之一就是對檔案管理 在現代作業系統中,要利用大量的程式和資料,由於記憶體容量有限,而且不能長期儲存,於是把這些資料以檔案的形式放在外存中,需要的時候再將它調入記憶體,從此就有了檔案系統。負責管理在外存上的檔案,並把訪問和共享 保護等手段提供給使用者。...