super.c

来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 2,327 行 · 第 1/5 页

C
2,327
字号
		INIT_LIST_HEAD(&ei->i_orphan);#ifdef CONFIG_EXT3_FS_XATTR		init_rwsem(&ei->xattr_sem);#endif		init_MUTEX(&ei->truncate_sem);		inode_init_once(&ei->vfs_inode);	}} static int init_inodecache(void){	ext3_inode_cachep = kmem_cache_create("ext3_inode_cache",					     sizeof(struct ext3_inode_info),					     0, SLAB_RECLAIM_ACCOUNT,					     init_once, NULL);	if (ext3_inode_cachep == NULL)		return -ENOMEM;	return 0;}static void destroy_inodecache(void){	if (kmem_cache_destroy(ext3_inode_cachep))		printk(KERN_INFO "ext3_inode_cache: not all structures were freed\n");}#ifdef CONFIG_EXT3_FS_POSIX_ACLstatic void ext3_clear_inode(struct inode *inode){       if (EXT3_I(inode)->i_acl &&           EXT3_I(inode)->i_acl != EXT3_ACL_NOT_CACHED) {               posix_acl_release(EXT3_I(inode)->i_acl);               EXT3_I(inode)->i_acl = EXT3_ACL_NOT_CACHED;       }       if (EXT3_I(inode)->i_default_acl &&           EXT3_I(inode)->i_default_acl != EXT3_ACL_NOT_CACHED) {               posix_acl_release(EXT3_I(inode)->i_default_acl);               EXT3_I(inode)->i_default_acl = EXT3_ACL_NOT_CACHED;       }}#else# define ext3_clear_inode NULL#endif#ifdef CONFIG_QUOTA#define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group")#define QTYPE2MOPT(on, t) ((t)==USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA))static int ext3_dquot_initialize(struct inode *inode, int type);static int ext3_dquot_drop(struct inode *inode);static int ext3_write_dquot(struct dquot *dquot);static int ext3_acquire_dquot(struct dquot *dquot);static int ext3_release_dquot(struct dquot *dquot);static int ext3_mark_dquot_dirty(struct dquot *dquot);static int ext3_write_info(struct super_block *sb, int type);static int ext3_quota_on(struct super_block *sb, int type, int format_id, char *path);static int ext3_quota_on_mount(struct super_block *sb, int type);static int ext3_quota_off_mount(struct super_block *sb, int type);static struct dquot_operations ext3_quota_operations = {	.initialize	= ext3_dquot_initialize,	.drop		= ext3_dquot_drop,	.alloc_space	= dquot_alloc_space,	.alloc_inode	= dquot_alloc_inode,	.free_space	= dquot_free_space,	.free_inode	= dquot_free_inode,	.transfer	= dquot_transfer,	.write_dquot	= ext3_write_dquot,	.acquire_dquot	= ext3_acquire_dquot,	.release_dquot	= ext3_release_dquot,	.mark_dirty	= ext3_mark_dquot_dirty,	.write_info	= ext3_write_info};static struct quotactl_ops ext3_qctl_operations = {	.quota_on	= ext3_quota_on,	.quota_off	= vfs_quota_off,	.quota_sync	= vfs_quota_sync,	.get_info	= vfs_get_dqinfo,	.set_info	= vfs_set_dqinfo,	.get_dqblk	= vfs_get_dqblk,	.set_dqblk	= vfs_set_dqblk};#endifstatic struct super_operations ext3_sops = {	.alloc_inode	= ext3_alloc_inode,	.destroy_inode	= ext3_destroy_inode,	.read_inode	= ext3_read_inode,	.write_inode	= ext3_write_inode,	.dirty_inode	= ext3_dirty_inode,	.put_inode	= ext3_put_inode,	.delete_inode	= ext3_delete_inode,	.put_super	= ext3_put_super,	.write_super	= ext3_write_super,	.sync_fs	= ext3_sync_fs,	.write_super_lockfs = ext3_write_super_lockfs,	.unlockfs	= ext3_unlockfs,	.statfs		= ext3_statfs,	.remount_fs	= ext3_remount,	.clear_inode	= ext3_clear_inode,};struct dentry *ext3_get_parent(struct dentry *child);static struct export_operations ext3_export_ops = {	.get_parent = ext3_get_parent,};enum {	Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,	Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,	Opt_nouid32, Opt_check, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov,	Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_noload,	Opt_commit, Opt_journal_update, Opt_journal_inum,	Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,	Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0,	Opt_ignore, Opt_barrier, Opt_err,};static match_table_t tokens = {	{Opt_bsd_df, "bsddf"},	{Opt_minix_df, "minixdf"},	{Opt_grpid, "grpid"},	{Opt_grpid, "bsdgroups"},	{Opt_nogrpid, "nogrpid"},	{Opt_nogrpid, "sysvgroups"},	{Opt_resgid, "resgid=%u"},	{Opt_resuid, "resuid=%u"},	{Opt_sb, "sb=%u"},	{Opt_err_cont, "errors=continue"},	{Opt_err_panic, "errors=panic"},	{Opt_err_ro, "errors=remount-ro"},	{Opt_nouid32, "nouid32"},	{Opt_nocheck, "nocheck"},	{Opt_nocheck, "check=none"},	{Opt_check, "check"},	{Opt_debug, "debug"},	{Opt_oldalloc, "oldalloc"},	{Opt_orlov, "orlov"},	{Opt_user_xattr, "user_xattr"},	{Opt_nouser_xattr, "nouser_xattr"},	{Opt_acl, "acl"},	{Opt_noacl, "noacl"},	{Opt_noload, "noload"},	{Opt_commit, "commit=%u"},	{Opt_journal_update, "journal=update"},	{Opt_journal_inum, "journal=%u"},	{Opt_abort, "abort"},	{Opt_data_journal, "data=journal"},	{Opt_data_ordered, "data=ordered"},	{Opt_data_writeback, "data=writeback"},	{Opt_offusrjquota, "usrjquota="},	{Opt_usrjquota, "usrjquota=%s"},	{Opt_offgrpjquota, "grpjquota="},	{Opt_grpjquota, "grpjquota=%s"},	{Opt_jqfmt_vfsold, "jqfmt=vfsold"},	{Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},	{Opt_ignore, "grpquota"},	{Opt_ignore, "noquota"},	{Opt_ignore, "quota"},	{Opt_ignore, "usrquota"},	{Opt_barrier, "barrier=%u"},	{Opt_err, NULL}};static unsigned long get_sb_block(void **data){	unsigned long 	sb_block;	char 		*options = (char *) *data;	if (!options || strncmp(options, "sb=", 3) != 0)		return 1;	/* Default location */	options += 3;	sb_block = simple_strtoul(options, &options, 0);	if (*options && *options != ',') {		printk("EXT3-fs: Invalid sb specification: %s\n",		       (char *) *data);		return 1;	}	if (*options == ',')		options++;	*data = (void *) options;	return sb_block;}static int parse_options (char * options, struct super_block *sb,			  unsigned long * inum, int is_remount){	struct ext3_sb_info *sbi = EXT3_SB(sb);	char * p;	substring_t args[MAX_OPT_ARGS];	int data_opt = 0;	int option;#ifdef CONFIG_QUOTA	int qtype;#endif	if (!options)		return 1;	while ((p = strsep (&options, ",")) != NULL) {		int token;		if (!*p)			continue;		token = match_token(p, tokens, args);		switch (token) {		case Opt_bsd_df:			clear_opt (sbi->s_mount_opt, MINIX_DF);			break;		case Opt_minix_df:			set_opt (sbi->s_mount_opt, MINIX_DF);			break;		case Opt_grpid:			set_opt (sbi->s_mount_opt, GRPID);			break;		case Opt_nogrpid:			clear_opt (sbi->s_mount_opt, GRPID);			break;		case Opt_resuid:			if (match_int(&args[0], &option))				return 0;			sbi->s_resuid = option;			break;		case Opt_resgid:			if (match_int(&args[0], &option))				return 0;			sbi->s_resgid = option;			break;		case Opt_sb:			/* handled by get_sb_block() instead of here */			/* *sb_block = match_int(&args[0]); */			break;		case Opt_err_panic:			clear_opt (sbi->s_mount_opt, ERRORS_CONT);			clear_opt (sbi->s_mount_opt, ERRORS_RO);			set_opt (sbi->s_mount_opt, ERRORS_PANIC);			break;		case Opt_err_ro:			clear_opt (sbi->s_mount_opt, ERRORS_CONT);			clear_opt (sbi->s_mount_opt, ERRORS_PANIC);			set_opt (sbi->s_mount_opt, ERRORS_RO);			break;		case Opt_err_cont:			clear_opt (sbi->s_mount_opt, ERRORS_RO);			clear_opt (sbi->s_mount_opt, ERRORS_PANIC);			set_opt (sbi->s_mount_opt, ERRORS_CONT);			break;		case Opt_nouid32:			set_opt (sbi->s_mount_opt, NO_UID32);			break;		case Opt_check:#ifdef CONFIG_EXT3_CHECK			set_opt (sbi->s_mount_opt, CHECK);#else			printk(KERN_ERR			       "EXT3 Check option not supported\n");#endif			break;		case Opt_nocheck:			clear_opt (sbi->s_mount_opt, CHECK);			break;		case Opt_debug:			set_opt (sbi->s_mount_opt, DEBUG);			break;		case Opt_oldalloc:			set_opt (sbi->s_mount_opt, OLDALLOC);			break;		case Opt_orlov:			clear_opt (sbi->s_mount_opt, OLDALLOC);			break;#ifdef CONFIG_EXT3_FS_XATTR		case Opt_user_xattr:			set_opt (sbi->s_mount_opt, XATTR_USER);			break;		case Opt_nouser_xattr:			clear_opt (sbi->s_mount_opt, XATTR_USER);			break;#else		case Opt_user_xattr:		case Opt_nouser_xattr:			printk("EXT3 (no)user_xattr options not supported\n");			break;#endif#ifdef CONFIG_EXT3_FS_POSIX_ACL		case Opt_acl:			set_opt(sbi->s_mount_opt, POSIX_ACL);			break;		case Opt_noacl:			clear_opt(sbi->s_mount_opt, POSIX_ACL);			break;#else		case Opt_acl:		case Opt_noacl:			printk("EXT3 (no)acl options not supported\n");			break;#endif		case Opt_journal_update:			/* @@@ FIXME */			/* Eventually we will want to be able to create			   a journal file here.  For now, only allow the			   user to specify an existing inode to be the			   journal file. */			if (is_remount) {				printk(KERN_ERR "EXT3-fs: cannot specify "				       "journal on remount\n");				return 0;			}			set_opt (sbi->s_mount_opt, UPDATE_JOURNAL);			break;		case Opt_journal_inum:			if (is_remount) {				printk(KERN_ERR "EXT3-fs: cannot specify "				       "journal on remount\n");				return 0;			}			if (match_int(&args[0], &option))				return 0;			*inum = option;			break;		case Opt_noload:			set_opt (sbi->s_mount_opt, NOLOAD);			break;		case Opt_commit:			if (match_int(&args[0], &option))				return 0;			if (option < 0)				return 0;			if (option == 0)				option = JBD_DEFAULT_MAX_COMMIT_AGE;			sbi->s_commit_interval = HZ * option;			break;		case Opt_data_journal:			data_opt = EXT3_MOUNT_JOURNAL_DATA;			goto datacheck;		case Opt_data_ordered:			data_opt = EXT3_MOUNT_ORDERED_DATA;			goto datacheck;		case Opt_data_writeback:			data_opt = EXT3_MOUNT_WRITEBACK_DATA;		datacheck:			if (is_remount) {				if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS)						!= data_opt) {					printk(KERN_ERR						"EXT3-fs: cannot change data "						"mode on remount\n");					return 0;				}			} else {				sbi->s_mount_opt &= ~EXT3_MOUNT_DATA_FLAGS;				sbi->s_mount_opt |= data_opt;			}			break;#ifdef CONFIG_QUOTA		case Opt_usrjquota:			qtype = USRQUOTA;			goto set_qf_name;		case Opt_grpjquota:			qtype = GRPQUOTA;set_qf_name:			if (sb_any_quota_enabled(sb)) {				printk(KERN_ERR					"EXT3-fs: Cannot change journalled "					"quota options when quota turned on.\n");				return 0;			}			if (sbi->s_qf_names[qtype]) {				printk(KERN_ERR					"EXT3-fs: %s quota file already "					"specified.\n", QTYPE2NAME(qtype));				return 0;			}			sbi->s_qf_names[qtype] = match_strdup(&args[0]);			if (!sbi->s_qf_names[qtype]) {				printk(KERN_ERR					"EXT3-fs: not enough memory for "					"storing quotafile name.\n");				return 0;			}			if (strchr(sbi->s_qf_names[qtype], '/')) {				printk(KERN_ERR					"EXT3-fs: quotafile must be on "					"filesystem root.\n");				kfree(sbi->s_qf_names[qtype]);				sbi->s_qf_names[qtype] = NULL;				return 0;			}			break;		case Opt_offusrjquota:			qtype = USRQUOTA;			goto clear_qf_name;		case Opt_offgrpjquota:			qtype = GRPQUOTA;clear_qf_name:			if (sb_any_quota_enabled(sb)) {				printk(KERN_ERR "EXT3-fs: Cannot change "					"journalled quota options when "					"quota turned on.\n");				return 0;			}			if (sbi->s_qf_names[qtype]) {				kfree(sbi->s_qf_names[qtype]);				sbi->s_qf_names[qtype] = NULL;			}			break;		case Opt_jqfmt_vfsold:			sbi->s_jquota_fmt = QFMT_VFS_OLD;			break;		case Opt_jqfmt_vfsv0:			sbi->s_jquota_fmt = QFMT_VFS_V0;			break;#else		case Opt_usrjquota:		case Opt_grpjquota:		case Opt_offusrjquota:		case Opt_offgrpjquota:		case Opt_jqfmt_vfsold:		case Opt_jqfmt_vfsv0:			printk(KERN_ERR				"EXT3-fs: journalled quota options not "				"supported.\n");			break;#endif		case Opt_abort:			set_opt(sbi->s_mount_opt, ABORT);			break;		case Opt_barrier:			if (match_int(&args[0], &option))				return 0;			if (option)				set_opt(sbi->s_mount_opt, BARRIER);			else				clear_opt(sbi->s_mount_opt, BARRIER);			break;		case Opt_ignore:			break;		default:			printk (KERN_ERR				"EXT3-fs: Unrecognized mount option \"%s\" "				"or missing value\n", p);			return 0;		}	}#ifdef CONFIG_QUOTA	if (!sbi->s_jquota_fmt && (sbi->s_qf_names[USRQUOTA] ||	    sbi->s_qf_names[GRPQUOTA])) {		printk(KERN_ERR			"EXT3-fs: journalled quota format not specified.\n");		return 0;	}#endif	return 1;}static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,			    int read_only){	struct ext3_sb_info *sbi = EXT3_SB(sb);	int res = 0;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?