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

📄 vfs_intent-2.6-sles10.patch

📁 非常经典的一个分布式系统
💻 PATCH
📖 第 1 页 / 共 4 页
字号:
 	if (retval) 		return retval; Index: LINUX-SRC-TREE/fs/nfs/dir.c===================================================================--- LINUX-SRC-TREE.orig/fs/nfs/dir.c+++ LINUX-SRC-TREE/fs/nfs/dir.c@@ -834,7 +834,7 @@ int nfs_is_exclusive_create(struct inode 		return 0; 	if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_CREATE) == 0) 		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)@@ -911,7 +911,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; }@@ -932,7 +932,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) { 		d_add(dentry, NULL); 		goto out; 	}@@ -947,7 +947,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); 		res = nfs4_atomic_open(dir, dentry, nd); 		nfs_end_data_update(dir);@@ -966,7 +966,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:@@ -1002,7 +1002,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;@@ -1138,7 +1138,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;  	lock_kernel(); 	nfs_begin_data_update(dir);Index: LINUX-SRC-TREE/fs/nfs/nfs4proc.c===================================================================--- LINUX-SRC-TREE.orig/fs/nfs/nfs4proc.c+++ LINUX-SRC-TREE/fs/nfs/nfs4proc.c@@ -1220,7 +1220,7 @@ static void nfs4_intent_set_file(struct  		ctx = (struct nfs_open_context *)filp->private_data; 		ctx->state = state; 	} else-		nfs4_close_state(state, nd->intent.open.flags);+		nfs4_close_state(state, nd->intent.flags); }  struct dentry *@@ -1232,19 +1232,19 @@ nfs4_atomic_open(struct inode *dir, stru 	struct dentry *res;  	if (nd->flags & LOOKUP_CREATE) {-		attr.ia_mode = nd->intent.open.create_mode;+		attr.ia_mode = nd->intent.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.flags & O_CREAT); 	}  	cred = rpcauth_lookupcred(NFS_SERVER(dir)->client->cl_auth, 0); 	if (IS_ERR(cred)) 		return (struct dentry *)cred;-	state = nfs4_do_open(dir, dentry, nd->intent.open.flags, &attr, cred);+	state = nfs4_do_open(dir, dentry, nd->intent.flags, &attr, cred); 	put_rpccred(cred); 	if (IS_ERR(state)) { 		if (PTR_ERR(state) == -ENOENT)Index: LINUX-SRC-TREE/fs/nfsctl.c===================================================================--- LINUX-SRC-TREE.orig/fs/nfsctl.c+++ LINUX-SRC-TREE/fs/nfsctl.c@@ -26,6 +26,7 @@ static struct file *do_open(char *name,  	struct nameidata nd; 	int error; +	intent_init(&nd.intent, IT_OPEN); 	nd.mnt = do_kern_mount("nfsd", 0, "nfsd", NULL);  	if (IS_ERR(nd.mnt))Index: LINUX-SRC-TREE/fs/open.c===================================================================--- LINUX-SRC-TREE.orig/fs/open.c+++ LINUX-SRC-TREE/fs/open.c@@ -198,9 +198,10 @@ out: }  int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,-	struct file *filp)+	struct file *filp, int called_from_open) { 	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. */@@ -215,7 +216,17 @@ int do_truncate(struct dentry *dentry, l 	}  	mutex_lock(&dentry->d_inode->i_mutex);-	err = notify_change(dentry, &newattrs);+	if (called_from_open)+                newattrs.ia_valid |= ATTR_FROM_OPEN;+        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);+ 	mutex_unlock(&dentry->d_inode->i_mutex); 	return err; }@@ -225,12 +236,12 @@ static long do_sys_truncate(const char _ 	struct nameidata nd; 	struct inode * inode; 	int error;-+	intent_init(&nd.intent, IT_GETATTR); 	error = -EINVAL; 	if (length < 0)	/* sorry, but loff_t says... */ 		goto out; -	error = user_path_walk(path, &nd);+	error = user_path_walk_it(path, &nd); 	if (error) 		goto out; 	inode = nd.dentry->d_inode;@@ -270,7 +281,7 @@ static long do_sys_truncate(const char _ 	error = locks_verify_truncate(inode, NULL, length); 	if (!error) { 		DQUOT_INIT(inode);-		error = do_truncate(nd.dentry, length, 0, NULL);+		error = do_truncate(nd.dentry, length, 0, NULL, 0); 	} 	put_write_access(inode); @@ -322,7 +333,7 @@ static long do_sys_ftruncate(unsigned in  	error = locks_verify_truncate(inode, file, length); 	if (!error)-		error = do_truncate(dentry, length, 0, file);+		error = do_truncate(dentry, length, 0, file, 0); out_putf: 	fput(file); out:@@ -407,9 +418,20 @@ asmlinkage long sys_utime(char __user *  		    (error = vfs_permission(&nd, MAY_WRITE)) != 0) 			goto dput_and_out; 	}-	mutex_lock(&inode->i_mutex);-	error = notify_change(nd.dentry, &newattrs);-	mutex_unlock(&inode->i_mutex);+ 	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 {+		mutex_lock(&inode->i_mutex);+ 		error = notify_change(nd.dentry, &newattrs);+		mutex_unlock(&inode->i_mutex);+ 	}+ dput_and_out: 	path_release(&nd); out:@@ -495,6 +517,7 @@ asmlinkage long sys_faccessat(int dfd, c 	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;@@ -519,7 +542,7 @@ asmlinkage long sys_faccessat(int dfd, c 	else 		current->cap_effective = current->cap_permitted; -	res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);+	res = __user_walk_fd_it(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd); 	if (!res) { 		res = vfs_permission(&nd, mode); 		/* SuS v2 requires we report a read only fs too */@@ -545,8 +568,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; @@ -596,8 +620,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; @@ -618,38 +643,55 @@ out: 	return error; } -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; -	dentry = file->f_dentry;-	inode = dentry->d_inode;+	if (inode->i_op->setattr_raw) {+		struct inode_operations *op = dentry->d_inode->i_op; -	audit_inode(NULL, 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 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;+ 	mutex_lock(&inode->i_mutex); 	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); 	mutex_unlock(&inode->i_mutex);+out:+	return error;+}++asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)+{+	struct file * file;+	int err = -EBADF;++	file = fget(fd);+	if (!file)+		goto out;++	audit_inode(NULL, file->f_dentry->d_inode);++	err = chmod_common(file->f_dentry, mode); -out_putf: 	fput(file); out: 	return err;@@ -659,32 +701,12 @@ asmlinkage long sys_fchmodat(int dfd, co 			     mode_t mode) { 	struct nameidata nd;-	struct inode * inode; 	int error;-	struct iattr newattrs;  	error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &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;--	mutex_lock(&inode->i_mutex);-	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);-	mutex_unlock(&inode->i_mutex);--dput_and_out:+	error = chmod_common(nd.dentry, mode); 	path_release(&nd); out: 	return error;@@ -710,6 +732,18 @@ static int chown_common(struct dentry *  	if (IS_RDONLY(inode)) 		goto out; 	error = -EPERM;+	if (inode->i_op->setattr_raw) {+		struct inode_operations *op = dentry->d_inode->i_op;++		newattrs.ia_uid = user;+		newattrs.ia_gid = group;+		newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;+		newattrs.ia_valid |= ATTR_RAW;+		error = op->setattr_raw(inode, &newattrs);+		/* the file system wants to use normal vfs path now */+		if (error != -EOPNOTSUPP)+			return error;+	} 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 		goto out; 	newattrs.ia_valid =  ATTR_CTIME;@@ -823,6 +857,7 @@ static struct file *__dentry_open(struct

⌨️ 快捷键说明

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