linux 檔案系統註冊

2021-06-18 03:40:55 字數 1225 閱讀 7923

以fat檔案系統為例 linux2.6.35

fs\fat\namei_msdos.c 

module_init(init_msdos_fs) //insmod載入模組時呼叫init_msdos_fs

static int __init init_msdos_fs(void)

先看引數&msdos_fs_type

static struct file_system_type msdos_fs_type = ;

include\linux\fs.h

struct file_system_type ;

name:檔案系統名字

fs_flags:檔案系統型別

get_sb:一般在mount掛載檔案系統時呼叫

syscall_define5(mount, ...)  //fs\namespace.c

-->do_mount  //fs\namespace.c

-->do_new_mount  //fs\namespace.c

-->do_kern_mount  //fs\super.c

-->vfs_kern_mount  //fs\super.c

-->get_sb  //fs\fat\namei_msdos.c

kill_sb:一般在umount解除安裝檔案系統時呼叫

再看register_filesystem函式

fs\filesystems.c

int register_filesystem(struct file_system_type * fs)

根據名字查詢系統中是否已經註冊了此檔案系統,沒有註冊則將file_system_type連線到file_systems鍊錶的尾部

fs\filesystems.c

static struct file_system_type *file_systems;
static struct file_system_type **find_filesystem(const char *name, unsigned len)

檔案系統註冊

前面主要把vfs物件,以及他們如何串聯起來的內容介紹得差不多了。相信走大現在,大家對大概的vfs工作機制有了相應的了解,接下來要做的事,就是把那些重要的細節描述清楚。首先,linux核心支援很多不同的檔案系統型別。本篇博文,我們將討 件系統註冊 也就是通常在系統初始化期間並且在使用檔案系統型別之前必...

linux 檔案系統模組的註冊

用cramfs.ko做的實驗,斷點放在init cramfs fs void 函式的rv register filesystem cramfs fs type 行,執行register filesystem函式 register filesystem fs 0xda7142e0 at fs file...

linux 檔案系統 Linux 檔案系統結構介紹

ubuntu 像所有類unix系統一樣 在分層樹中組織檔案,其中的關係就像父母和孩子一樣。目錄可以包含其他目錄以及常規檔案,它們是樹的 葉子 樹的任何元素都可以通過路徑名引用 絕對路徑以字元 標識根目錄,其中包含所有其他目錄和檔案 開頭,然後列出必須遍歷以到達該元素的每個子目錄,每個子目錄用 符號分...