快乐虾
http://blog.csdn.net/lights_joy/
lights@hb165.com
本文适用于
ADSP-BF561
优视BF561EVB开发板
uclinux-2008r1.5-rc3
Visual DSP++ 5.0(update 5)
欢迎转载,但请保留作者信息
文件系统类型用于表示各种不同的文件系统,如fat, sysfs, proc等等,对于每个不同的文件系统,都以struct file_system_type进行描述,内核将它们以单链表的形式链接起来,其表头由全局变量file_systems表示。
与此相关的代码都在fs/filesystems.c文件中。
此结构体定义了文件系统的类型,每种文件系统都必须定义一个此结构体并通过register_filesystem进行注册。
struct file_system_type {
const char *name;
int fs_flags;
int (*get_sb) (struct file_system_type *, int,
const char *, void *, struct vfsmount *);
void (*kill_sb) (struct super_block *);
struct module *owner;
struct file_system_type * next;
struct list_head fs_supers;
struct lock_class_key s_lock_key;
struct lock_class_key s_umount_key;
};
l name
文件系统的名称,在定义struct file_system_type的变量时指定且不再更改。
l fs_flags
一些特殊标记,但允许此值为0。支持的几个标记用宏定义表示为:
/* public flags for file_system_type */
#define FS_REQUIRES_DEV 1
#define FS_BINARY_MOUNTDATA 2
#define FS_HAS_SUBTYPE 4
#define FS_REVAL_DOT 16384 /* Check the paths ".", ".." for staleness */
#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move()
* during rename() internally.
*/
l get_sb
这个回调函数将在kern_mount函数中调用,用于取得本文件系统(分区)的super_block,并将之填充到struct vfsmount的mnt_sb成员中。
l next
这个成员用以将系统内所有的file_system_type以单链表的形式链接起来,单链表的表头由全局变量file_systems表示。
l fs_supers
这是一个双链表的表头,由此也可以看出同一个文件系统类型可以有很多个对应的super_block。
1.2 文件系统注册
每个文件系统都必须使用register_filesystem向内核注册后才可以使用,此函数为:
/**
* register_filesystem - register a new filesystem
* @fs: the file system structure
*
* Adds the file system passed to the list of file systems the kernel
* is aware of for mount and other syscalls. Returns 0 on success,
* or a negative errno code on an error.
*
* The &struct file_system_type that is passed is linked into the kernel
* structures and must not be freed until the file system has been
* unregistered.
*/
int register_filesystem(struct file_system_type * fs)
{
int res = 0;
struct file_system_type ** p;
BUG_ON(strchr(fs->name, '.'));
if (fs->next)
return -EBUSY;
INIT_LIST_HEAD(&fs->fs_supers);
write_lock(&file_systems_lock);
p = find_filesystem(fs->name, strlen(fs->name));
if (*p)
res = -EBUSY;
else
*p = fs;
write_unlock(&file_systems_lock);
return res;
}
注意这里的find_filesystem函数,它将查找一个合适的用于存放struct file_system_type 指针的位置,当第一次调用时,它将返回
static struct file_system_type *file_systems;
这一变量的地址,再通过赋值语句,file_systems就可以指向链表的第一个元素了。
看看find_filesystem函数:
static struct file_system_type **find_filesystem(const char *name, unsigned len)
{
struct file_system_type **p;
for (p=&file_systems; *p; p=&(*p)->next)
if (strlen((*p)->name) == len &&
strncmp((*p)->name, name, len) == 0)
break;
return p;
}
分享到:
相关推荐
uclinux 内核编译 与根文件系统制作
uClinux内核编程
如何交叉编译uclinux内核—屏幕录像:现场操作,肯定比看书时的印象来的深刻!
这是一款介绍uclinux内核编译的傻瓜教程,轻松教会你ulinx内核编译
如何交叉编译 uClinux 内核如何交叉编译 uClinux 内核如何交叉编译 uClinux 内核如何交叉编译 uClinux 内核
这个工程用于将uclinux内核的部分代码移植到vs2008下编译并模拟其运行,包括内存管理,设备管理和文件系统这三个部分的代码,删除了进程管理之类的功能。希望它能帮助对uclinux内核中这三个部分结构和算法的理解!
uclinux内核编译傻瓜教程.pdf,对于初及linux内核人员来说非常实用。
本文通过整理之前研发的一个项目(ARM7TDMI + uCLinux),分析内核启动过程及需要修改的文件,以供内核移植者参考。整理过程中也同时参考了众多网友的帖子,在此谢过。由于整理过程匆忙,难免错误及讲解的不够清楚之处...
uclinux内核配置与编程傻瓜教程 ,新手入门,老手入门.uclinux内核配置与编程傻瓜教程 ,新手入门,老手入门.
这篇文章主要讨论了bfin-uclinux-2008r1-rc8中的console实现。 适用的CPU为ADSP-BF561。 还不是很完整,仅供参考。 .......
Uclinux的配置和裁减也是利用的华恒...现成的源码包,所有的底层驱动都已经完成,我们所要做的只是选择自己需要的驱动、配置一下内核、做一些裁减工作而已。每每听到其他人提到“最近又完成了×××平台的linux移植”,
uclinux内核编译[参考].pdf
AXD + Multi-ICE进行裸机程序的功效相信已经为大家所接受。uClinux内核比较裸机程序,有较大的不同。这里简单介绍如何用AXD源代码级调试uClinux内核。
uClinux内核编程目录 1.Hello, world 3 Exhello.c 3 1.1内核模块的编译文件 4 1.2 多文件内核模块 5 2.字符设备文件 8 2.1多内核版本源文件 16 3./proc文件系统 17 4.使用/proc进行输入 22 5.和...
基于S3C44B0芯片的uClinux内核引导过程分析.pdf
这份文档是学习uclinux内核存储管理部分的笔记,适用于 uclinux-2008r1-rc8 adsp-bf561 内核移植到VDSP5。
学习bfin-uclinux内核的一些笔记。 这是对blog文章的总结。
此文件为已经编译好的linux内核镜像, 包括文件系统, 烧写时直接烧写接行了,保证没有问题
深入uCLinux嵌入式操作系统. 深入uCLinux嵌入式操作系统.
uClinux系统下载过程(编译内核),PDF格式