⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vfs_intent-2.6-rhel4.patch

📁 非常经典的一个分布式系统
💻 PATCH
📖 第 1 页 / 共 3 页
字号:
++		if (nd.dentry->d_inode->i_op->symlink_raw) {+			struct inode_operations *op = nd.dentry->d_inode->i_op;+			error = op->symlink_raw(&nd, from);+			/* the file system wants to use normal vfs path now */+			if (error != -EOPNOTSUPP)+				goto out2;+		}+ 		dentry = lookup_create(&nd, 0); 		error = PTR_ERR(dentry); 		if (!IS_ERR(dentry)) {@@ -1976,6 +2123,7 @@ asmlinkage long sys_symlink(const char _ 			dput(dentry); 		} 		up(&nd.dentry->d_inode->i_sem);+out2: 		path_release(&nd); out: 		putname(to);@@ -2045,15 +2193,26 @@ asmlinkage long sys_link(const char __us 	if (IS_ERR(to)) 		return PTR_ERR(to); -	error = __user_walk(oldname, 0, &old_nd);+	intent_init(&old_nd.intent, IT_LOOKUP);+	error = __user_walk_it(oldname, 0, &old_nd); 	if (error) 		goto exit;-	error = path_lookup(to, LOOKUP_PARENT, &nd);+		+	intent_init(&nd.intent, IT_LOOKUP);		+	error = path_lookup_it(to, LOOKUP_PARENT, &nd); 	if (error) 		goto out; 	error = -EXDEV; 	if (old_nd.mnt != nd.mnt) 		goto out_release;+	if (nd.dentry->d_inode->i_op->link_raw) {+		struct inode_operations *op = nd.dentry->d_inode->i_op;+		error = op->link_raw(&old_nd, &nd);+		/* the file system wants to use normal vfs path now */+		if (error != -EOPNOTSUPP)+			goto out_release;+	}+ 	new_dentry = lookup_create(&nd, 0); 	error = PTR_ERR(new_dentry); 	if (!IS_ERR(new_dentry)) {@@ -2229,11 +2388,13 @@ static inline int do_rename(const char * 	struct dentry * trap; 	struct nameidata oldnd, newnd; -	error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);+	intent_init(&oldnd.intent, IT_LOOKUP);+	error = path_lookup_it(oldname, LOOKUP_PARENT, &oldnd); 	if (error) 		goto exit; -	error = path_lookup(newname, LOOKUP_PARENT, &newnd);+	intent_init(&newnd.intent, IT_LOOKUP);+	error = path_lookup_it(newname, LOOKUP_PARENT, &newnd); 	if (error) 		goto exit1; @@ -2250,6 +2411,13 @@ static inline int do_rename(const char * 	if (newnd.last_type != LAST_NORM) 		goto exit2; +	if (old_dir->d_inode->i_op->rename_raw) {+		error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);+		/* the file system wants to use normal vfs path now */+		if (error != -EOPNOTSUPP)+			goto exit2;+	}+ 	trap = lock_rename(new_dir, old_dir);  	old_dentry = lookup_hash(&oldnd.last, old_dir);@@ -2281,8 +2449,7 @@ static inline int do_rename(const char * 	if (new_dentry == trap) 		goto exit5; -	error = vfs_rename(old_dir->d_inode, old_dentry,-				   new_dir->d_inode, new_dentry);+	error = vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry); exit5: 	dput(new_dentry); exit4:@@ -2473,6 +2640,7 @@ EXPORT_SYMBOL(page_readlink); EXPORT_SYMBOL(page_symlink); EXPORT_SYMBOL(page_symlink_inode_operations); EXPORT_SYMBOL(path_lookup);+EXPORT_SYMBOL(path_lookup_it); EXPORT_SYMBOL(path_release); EXPORT_SYMBOL(path_walk); EXPORT_SYMBOL(permission);diff -urNp RH_2_6_9_42_0_3.orig/fs/namespace.c RH_2_6_9_42_0_3/fs/namespace.c--- RH_2_6_9_42_0_3.orig/fs/namespace.c+++ RH_2_6_9_42_0_3/fs/namespace.c@@ -114,6 +115,7 @@ static inline int check_mnt(struct vfsmo  static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd) {+	memset(old_nd, 0, sizeof(*old_nd)); 	old_nd->dentry = mnt->mnt_mountpoint; 	old_nd->mnt = mnt->mnt_parent; 	mnt->mnt_parent = mnt;@@ -441,6 +442,8 @@ static int do_umount(struct vfsmount *mn 	 */  	lock_kernel();+	if (sb->s_op->umount_lustre)+		sb->s_op->umount_lustre(sb); 	if( (flags&MNT_FORCE) && sb->s_op->umount_begin) 		sb->s_op->umount_begin(sb); 	unlock_kernel();@@ -665,7 +668,8 @@ static int do_loopback(struct nameidata  		return err; 	if (!old_name || !*old_name) 		return -EINVAL;-	err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);+	intent_init(&old_nd.intent, IT_LOOKUP);+	err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd); 	if (err) 		return err; @@ -739,7 +743,8 @@ static int do_move_mount(struct nameidat 		return -EPERM; 	if (!old_name || !*old_name) 		return -EINVAL;-	err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);+	intent_init(&old_nd.intent, IT_LOOKUP);+	err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd); 	if (err) 		return err; @@ -1074,7 +1079,8 @@ long do_mount(char * dev_name, char * di 	flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);  	/* ... and get the mountpoint */-	retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);+	intent_init(&nd.intent, IT_LOOKUP);	+	retval = path_lookup_it(dir_name, LOOKUP_FOLLOW, &nd); 	if (retval) 		return retval; diff -rup RH_2_6_9_55.orig/fs/nfs/dir.c RH_2_6_9_55/fs/nfs/dir.c--- RH_2_6_9_55.orig/fs/nfs/dir.c+++ RH_2_6_9_55/fs/nfs/dir.c@@ -839,7 +839,7 @@ int nfs_is_exclusive_create(struct inode 		return 0; 	if (!nd || (nd->flags & LOOKUP_CONTINUE) || !(nd->flags & LOOKUP_CREATE)) 		return 0;-	return (nd->intent.open.flags & O_EXCL) != 0;+	return (nd->intent.it_flags & O_EXCL) != 0; }  static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)@@ -915,7 +915,7 @@ static int is_atomic_open(struct inode * 	if (nd->flags & LOOKUP_DIRECTORY) 		return 0; 	/* Are we trying to write to a read only partition? */-	if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))+	if (IS_RDONLY(dir) && (nd->intent.it_flags & (O_CREAT|O_TRUNC|FMODE_WRITE))) 		return 0; 	return 1; }@@ -936,7 +936,7 @@ static struct dentry *nfs_atomic_lookup( 	dentry->d_op = NFS_PROTO(dir)->dentry_ops;  	/* Let vfs_create() deal with O_EXCL */-	if (nd->intent.open.flags & O_EXCL)+	if (nd->intent.it_flags & O_EXCL) 		goto no_entry;  	/* Open the file on the server */@@ -948,7 +948,7 @@ static struct dentry *nfs_atomic_lookup( 		goto out; 	} -	if (nd->intent.open.flags & O_CREAT) {+	if (nd->intent.it_flags & O_CREAT) { 		nfs_begin_data_update(dir); 		inode = nfs4_atomic_open(dir, dentry, nd); 		nfs_end_data_update(dir);@@ -967,7 +967,7 @@ static struct dentry *nfs_atomic_lookup( 			case -ENOTDIR: 				goto no_open; 			case -ELOOP:-				if (!(nd->intent.open.flags & O_NOFOLLOW))+				if (!(nd->intent.it_flags & O_NOFOLLOW)) 					goto no_open; 			/* case -EINVAL: */ 			default:@@ -1005,7 +1005,7 @@ static int nfs_open_revalidate(struct de 	/* NFS only supports OPEN on regular files */ 	if (!S_ISREG(inode->i_mode)) 		goto no_open;-	openflags = nd->intent.open.flags;+	openflags = nd->intent.it_flags; 	/* We cannot do exclusive creation on a positive dentry */ 	if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) 		goto no_open;@@ -1213,7 +1213,7 @@ static int nfs_create(struct inode *dir, 	attr.ia_valid = ATTR_MODE;  	if (nd && (nd->flags & LOOKUP_CREATE))-		open_flags = nd->intent.open.flags;+		open_flags = nd->intent.it_flags;  	/* 	 * The 0 argument passed into the create function should one daydiff -rup RH_2_6_9_55.orig/fs/nfs/nfs4proc.c RH_2_6_9_55/fs/nfs/nfs4proc.c--- RH_2_6_9_55.orig/fs/nfs/nfs4proc.c+++ RH_2_6_9_55/fs/nfs/nfs4proc.c@@ -770,17 +770,17 @@ nfs4_atomic_open(struct inode *dir, stru 	struct nfs4_state *state;  	if (nd->flags & LOOKUP_CREATE) {-		attr.ia_mode = nd->intent.open.create_mode;+		attr.ia_mode = nd->intent.it_create_mode; 		attr.ia_valid = ATTR_MODE; 		if (!IS_POSIXACL(dir)) 			attr.ia_mode &= ~current->fs->umask; 	} else { 		attr.ia_valid = 0;-		BUG_ON(nd->intent.open.flags & O_CREAT);+		BUG_ON(nd->intent.it_flags & O_CREAT); 	}  	cred = rpcauth_lookupcred(NFS_SERVER(dir)->client->cl_auth, 0);-	state = nfs4_do_open(dir, &dentry->d_name, nd->intent.open.flags, &attr, cred);+	state = nfs4_do_open(dir, &dentry->d_name, nd->intent.it_flags, &attr, cred); 	put_rpccred(cred); 	if (IS_ERR(state)) 		return (struct inode *)state;diff -rup RH_2_6_9_55.orig/fs/open.c RH_2_6_9_55/fs/open.c--- RH_2_6_9_55.orig/fs/open.c+++ RH_2_6_9_55/fs/open.c@@ -195,6 +195,7 @@ out: int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs) { 	int err;+	struct inode_operations *op = dentry->d_inode->i_op; 	struct iattr newattrs;  	/* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */@@ -204,8 +205,16 @@ int do_truncate(struct dentry *dentry, l	newattrs.ia_size = length;	newattrs.ia_valid = ATTR_SIZE | time_attrs; 	down(&dentry->d_inode->i_sem);-	err = notify_change(dentry, &newattrs);-	up(&dentry->d_inode->i_sem);+	if (op->setattr_raw) {+		newattrs.ia_valid |= ATTR_RAW;+		newattrs.ia_ctime = CURRENT_TIME;+		down_write(&dentry->d_inode->i_alloc_sem);+		err = op->setattr_raw(dentry->d_inode, &newattrs);+		up_write(&dentry->d_inode->i_alloc_sem);+	} else+		err = notify_change(dentry, &newattrs);+	up(&dentry->d_inode->i_sem);		+ 	return err; }@@ -214,12 +223,13 @@ static inline long do_sys_truncate(const 	struct nameidata nd; 	struct inode * inode; 	int error;-+	 	error = -EINVAL; 	if (length < 0)	/* sorry, but loff_t says... */ 		goto out;--	error = user_path_walk(path, &nd);+		+	intent_init(&nd.intent, IT_GETATTR);+	error = user_path_walk_it(path, &nd); 	if (error) 		goto out; 	inode = nd.dentry->d_inode;@@ -390,9 +400,19 @@ asmlinkage long sys_utime(char __user *  		    (error = permission(inode,MAY_WRITE,&nd)) != 0) 			goto dput_and_out; 	}-	down(&inode->i_sem);-	error = notify_change(nd.dentry, &newattrs);-	up(&inode->i_sem);+	if (inode->i_op->setattr_raw) {+		struct inode_operations *op = nd.dentry->d_inode->i_op;++		newattrs.ia_valid |= ATTR_RAW;+		error = op->setattr_raw(inode, &newattrs);+		/* the file system wants to use normal vfs path now */+		if (error != -EOPNOTSUPP)+			goto dput_and_out;+	} else {+		down(&inode->i_sem);+		error = notify_change(nd.dentry, &newattrs);+		up(&inode->i_sem);+	} dput_and_out: 	path_release(&nd); out:@@ -443,9 +463,19 @@ long do_utimes(char __user * filename, s 		    (error = permission(inode,MAY_WRITE,&nd)) != 0) 			goto dput_and_out; 	}-	down(&inode->i_sem);-	error = notify_change(nd.dentry, &newattrs);-	up(&inode->i_sem);+	if (inode->i_op->setattr_raw) {+		struct inode_operations *op = nd.dentry->d_inode->i_op;++		newattrs.ia_valid |= ATTR_RAW;+		error = op->setattr_raw(inode, &newattrs);+		/* the file system wants to use normal vfs path now */+		if (error != -EOPNOTSUPP)+			goto dput_and_out;+	} else {+		down(&inode->i_sem);+		error = notify_change(nd.dentry, &newattrs);+		up(&inode->i_sem);+	} dput_and_out: 	path_release(&nd); out:@@ -473,6 +503,7 @@ asmlinkage long sys_access(const char __ 	int old_fsuid, old_fsgid; 	kernel_cap_t old_cap; 	int res;+	intent_init(&nd.intent, IT_GETATTR);  	if (mode & ~S_IRWXO)	/* where's F_OK, X_OK, W_OK, R_OK? */ 		return -EINVAL;@@ -497,13 +528,14 @@ asmlinkage long sys_access(const char __ 	else 		current->cap_effective = current->cap_permitted; -	res = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);+	res = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); 	if (!res) { 		res = permission(nd.dentry->d_inode, mode, &nd); 		/* SuS v2 requires we report a read only fs too */ 		if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode) 		   && !special_file(nd.dentry->d_inode->i_mode)) 			res = -EROFS;+ 		path_release(&nd); 	} @@ -518,8 +550,9 @@ asmlinkage long sys_chdir(const char __u { 	struct nameidata nd; 	int error;+	intent_init(&nd.intent, IT_GETATTR); -	error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);+	error = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd); 	if (error) 		goto out; @@ -571,8 +604,9 @@ asmlinkage long sys_chroot(const char __ { 	struct nameidata nd; 	int error;+	intent_init(&nd.intent, IT_GETATTR); -	error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);+	error = __user_walk_it(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd); 	if (error) 		goto out; @@ -595,36 +629,52 @@ out:  EXPORT_SYMBOL_GPL(sys_chroot); -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)+int chmod_common(struct dentry *dentry, mode_t mode) {-	struct inode * inode;-	struct dentry * dentry;-	struct file * file;-	int err = -EBADF;+	struct inode * inode = dentry->d_inode; 	struct iattr newattrs;+	int error = -EROFS; -	file = fget(fd);-	if (!file)+	if (IS_RDONLY(inode)) 		goto out;+	+	if (inode->i_op->setattr_raw) {+		struct inode_operations *op = dentry->d_inode->i_op; -	dentry = file->f_dentry;-	inode = dentry->d_inode;+		newattrs.ia_mode = mode;+		newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;+		newattrs.ia_valid |= ATTR_RAW;+		error = op->setattr_raw(inode, &newattrs);+		/* the file system wants to use the normal vfs path now */+		if (error != -EOPNOTSUPP)+			goto out;+	} -	err = -EROFS;-	if (IS_RDONLY(inode))-		goto out_putf;-	err = -EPERM;+	error = -EPERM; 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))-		goto out_putf;+		goto out;+ 	down(&inode->i_sem); 	if (mode == (mode_t) -1) 		mode = inode->i_mode; 	newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); 	newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;-	err = notify_change(dentry, &newattrs);+	error = notify_change(dentry, &newattrs); 	up(&inode->i_sem);+out:+	return error;+} -out_putf:+asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)+{+	struct file * file;+	int err = -EBADF;++	file = fget(fd);+	if (!file)+		goto out;++	err = chmod_common(file->f_dentry, mode); 	fput(file); out: 	return err;@@ -633,32 +683,13 @@ out: asmlinkage long sys_chmod(const char __user * filename, mode_t mode) { 	struct nameidata nd;-	struct inode * inode; 	int error;-	struct iattr newattrs;  	error = user_path_walk(filename, &nd); 	if (error) 		goto out;-	inode = nd.dentry->d_inode;-	error = -EROFS;-	if (IS_RDONLY(inode))-		goto dput_and_out;--	error = -EPERM;-	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))-		goto dput_and_out;--	down(&inode->i_sem);-	if (mode == (mode_t) -1)-		mode = inode->i_mode;-	newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);-	newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;-	error = notify_change(nd.dentry, &newattrs);-	up(&inode->i_sem);--dput_and_out:+	error = chmod_common(nd.dentry, mode); 	path_release(&nd); out: 	return error;@@ -679,6 +710,18 @@ static int chown_common(struct dentry *  	if (IS_RDONLY(inode)) 		goto out; 	error = -EPERM;

⌨️ 快捷键说明

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