博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ext4_file_open
阅读量:4154 次
发布时间:2019-05-25

本文共 1959 字,大约阅读时间需要 6 分钟。

static int ext4_file_open(struct inode * inode, struct file * filp){	struct super_block *sb = inode->i_sb;	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);	struct vfsmount *mnt = filp->f_path.mnt;	struct dentry *dir;	struct path path;	char buf[64], *cp;	int ret;	if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) &&		     !(sb->s_flags & MS_RDONLY))) {		sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED;		/*		 * Sample where the filesystem has been mounted and		 * store it in the superblock for sysadmin convenience		 * when trying to sort through large numbers of block		 * devices or filesystem images.		 */		memset(buf, 0, sizeof(buf));		path.mnt = mnt;		path.dentry = mnt->mnt_root;		cp = d_path(&path, buf, sizeof(buf));		if (!IS_ERR(cp)) {			handle_t *handle;			int err;			handle = ext4_journal_start_sb(sb, EXT4_HT_MISC, 1);			if (IS_ERR(handle))				return PTR_ERR(handle);			BUFFER_TRACE(sbi->s_sbh, "get_write_access");			err = ext4_journal_get_write_access(handle, sbi->s_sbh);			if (err) {				ext4_journal_stop(handle);				return err;			}			strlcpy(sbi->s_es->s_last_mounted, cp,				sizeof(sbi->s_es->s_last_mounted));			ext4_handle_dirty_super(handle, sb);			ext4_journal_stop(handle);		}	}	if (ext4_encrypted_inode(inode)) {		ret = fscrypt_get_encryption_info(inode);		if (ret)			return -EACCES;		if (!fscrypt_has_encryption_key(inode))			return -ENOKEY;	}	dir = dget_parent(file_dentry(filp));	if (ext4_encrypted_inode(d_inode(dir)) &&			!fscrypt_has_permitted_context(d_inode(dir), inode)) {		ext4_warning(inode->i_sb,			     "Inconsistent encryption contexts: %lu/%lu",			     (unsigned long) d_inode(dir)->i_ino,			     (unsigned long) inode->i_ino);		dput(dir);		return -EPERM;	}	dput(dir);	/*	 * Set up the jbd2_inode if we are opening the inode for	 * writing and the journal is present	 */	if (filp->f_mode & FMODE_WRITE) {		ret = ext4_inode_attach_jinode(inode);		if (ret < 0)			return ret;	}	return dquot_file_open(inode, filp);}

转载地址:http://emqti.baihongyu.com/

你可能感兴趣的文章
豆瓣爱问共享资料插件发布啦
查看>>
Ubuntu10.10 CAJView安装 读取nh\kdh\caj文件 成功
查看>>
kermit的安装和配置
查看>>
vim 配置
查看>>
openocd zylin
查看>>
进程创建时文件系统处理
查看>>
进程创建时信号处理函数处理
查看>>
进程创建时信号处理
查看>>
进程创建时内存描述符处理
查看>>
进程创建时命名空间处理
查看>>
进程创建时IO处理
查看>>
进程创建时线程栈处理
查看>>
进程创建时pid分配
查看>>
进程创建时安全计算处理
查看>>
进程创建时cgroup处理
查看>>
进程创建时共享内存处理
查看>>
idle进程创建
查看>>
内核线程创建
查看>>
linux elf tool readelf
查看>>
linux tool objdump
查看>>