dir.c (cd9a1c0e5ac681871d64804f82291649e2a0accb) dir.c (f46e0bd34ec002d0727761da52b8fd47f06d4440)
1/*
2 * linux/fs/nfs/dir.c
3 *
4 * Copyright (C) 1992 Rick Sladkey
5 *
6 * nfs directory handling functions
7 *
8 * 10 Apr 1996 Added silly rename for unlink --okir

--- 1070 unchanged lines hidden (view full) ---

1079 return ret;
1080}
1081
1082static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
1083{
1084 struct nfs_open_context *ctx;
1085 struct iattr attr;
1086 struct dentry *res = NULL;
1/*
2 * linux/fs/nfs/dir.c
3 *
4 * Copyright (C) 1992 Rick Sladkey
5 *
6 * nfs directory handling functions
7 *
8 * 10 Apr 1996 Added silly rename for unlink --okir

--- 1070 unchanged lines hidden (view full) ---

1079 return ret;
1080}
1081
1082static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
1083{
1084 struct nfs_open_context *ctx;
1085 struct iattr attr;
1086 struct dentry *res = NULL;
1087 struct inode *inode;
1087 int open_flags;
1088 int open_flags;
1088 int error;
1089
1090 dfprintk(VFS, "NFS: atomic_lookup(%s/%ld), %s\n",
1091 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1092
1093 /* Check that we are indeed trying to open this file */
1094 if (!is_atomic_open(nd))
1095 goto no_open;
1096

--- 23 unchanged lines hidden (view full) ---

1120 attr.ia_mode &= ~current_umask();
1121 } else {
1122 open_flags &= ~O_EXCL;
1123 attr.ia_valid = 0;
1124 BUG_ON(open_flags & O_CREAT);
1125 }
1126
1127 /* Open the file on the server */
1089
1090 dfprintk(VFS, "NFS: atomic_lookup(%s/%ld), %s\n",
1091 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
1092
1093 /* Check that we are indeed trying to open this file */
1094 if (!is_atomic_open(nd))
1095 goto no_open;
1096

--- 23 unchanged lines hidden (view full) ---

1120 attr.ia_mode &= ~current_umask();
1121 } else {
1122 open_flags &= ~O_EXCL;
1123 attr.ia_valid = 0;
1124 BUG_ON(open_flags & O_CREAT);
1125 }
1126
1127 /* Open the file on the server */
1128 res = nfs4_atomic_open(dir, ctx, open_flags, &attr);
1129 if (IS_ERR(res)) {
1128 nfs_block_sillyrename(dentry->d_parent);
1129 inode = nfs4_atomic_open(dir, ctx, open_flags, &attr);
1130 if (IS_ERR(inode)) {
1131 nfs_unblock_sillyrename(dentry->d_parent);
1130 put_nfs_open_context(ctx);
1132 put_nfs_open_context(ctx);
1131 error = PTR_ERR(res);
1132 switch (error) {
1133 switch (PTR_ERR(inode)) {
1133 /* Make a negative dentry */
1134 case -ENOENT:
1134 /* Make a negative dentry */
1135 case -ENOENT:
1136 d_add(dentry, NULL);
1135 res = NULL;
1136 goto out;
1137 /* This turned out not to be a regular file */
1138 case -EISDIR:
1139 case -ENOTDIR:
1140 goto no_open;
1141 case -ELOOP:
1142 if (!(nd->intent.open.flags & O_NOFOLLOW))
1143 goto no_open;
1144 /* case -EINVAL: */
1145 default:
1137 res = NULL;
1138 goto out;
1139 /* This turned out not to be a regular file */
1140 case -EISDIR:
1141 case -ENOTDIR:
1142 goto no_open;
1143 case -ELOOP:
1144 if (!(nd->intent.open.flags & O_NOFOLLOW))
1145 goto no_open;
1146 /* case -EINVAL: */
1147 default:
1148 res = ERR_CAST(inode);
1146 goto out;
1147 }
1148 }
1149 goto out;
1150 }
1151 }
1149 if (res != NULL)
1152 res = d_add_unique(dentry, inode);
1153 if (res != NULL) {
1154 dput(ctx->path.dentry);
1155 ctx->path.dentry = dget(res);
1150 dentry = res;
1156 dentry = res;
1157 }
1151 nfs_intent_set_file(nd, ctx);
1158 nfs_intent_set_file(nd, ctx);
1159 nfs_unblock_sillyrename(dentry->d_parent);
1152out:
1160out:
1161 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1153 return res;
1154no_open:
1155 return nfs_lookup(dir, dentry, nd);
1156}
1157
1158static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
1159{
1160 struct dentry *parent = NULL;

--- 918 unchanged lines hidden ---
1162 return res;
1163no_open:
1164 return nfs_lookup(dir, dentry, nd);
1165}
1166
1167static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
1168{
1169 struct dentry *parent = NULL;

--- 918 unchanged lines hidden ---