#define NFS_PARANOIA 1
/* #define NFS_DEBUG_VERBOSE 1 */
+static int nfs_opendir(struct inode *, struct file *);
static int nfs_readdir(struct file *, void *, filldir_t);
static struct dentry *nfs_lookup(struct inode *, struct dentry *);
static int nfs_cached_lookup(struct inode *, struct dentry *,
struct file_operations nfs_dir_operations = {
.read = generic_read_dir,
.readdir = nfs_readdir,
- .open = nfs_open,
+ .open = nfs_opendir,
.release = nfs_release,
};
.setattr = nfs_setattr,
};
+/*
+ * Open file
+ */
+static int
+nfs_opendir(struct inode *inode, struct file *filp)
+{
+ struct nfs_server *server = NFS_SERVER(inode);
+ int res = 0;
+
+ lock_kernel();
+ /* Do cto revalidation */
+ if (server->flags & NFS_MOUNT_NOCTO)
+ res = __nfs_revalidate_inode(server, inode);
+ /* Call generic open code in order to cache credentials */
+ if (!res)
+ res = nfs_open(inode, filp);
+ unlock_kernel();
+ return res;
+}
+
typedef u32 * (*decode_dirent_t)(u32 *, struct nfs_entry *, int);
typedef struct {
struct file *file;
#define NFSDBG_FACILITY NFSDBG_FILE
+static int nfs_file_open(struct inode *, struct file *);
static int nfs_file_mmap(struct file *, struct vm_area_struct *);
static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *);
static ssize_t nfs_file_read(struct kiocb *, char *, size_t, loff_t);
.aio_read = nfs_file_read,
.aio_write = nfs_file_write,
.mmap = nfs_file_mmap,
- .open = nfs_open,
+ .open = nfs_file_open,
.flush = nfs_file_flush,
.release = nfs_release,
.fsync = nfs_fsync,
# define IS_SWAPFILE(inode) (0)
#endif
+/*
+ * Open file
+ */
+static int
+nfs_file_open(struct inode *inode, struct file *filp)
+{
+ struct nfs_server *server = NFS_SERVER(inode);
+ int (*open)(struct inode *, struct file *);
+ int res = 0;
+
+ lock_kernel();
+ /* Do NFSv4 open() call */
+ if ((open = server->rpc_ops->file_open) != NULL)
+ res = open(inode, filp);
+ /* Do cto revalidation */
+ else if (server->flags & NFS_MOUNT_NOCTO)
+ res = __nfs_revalidate_inode(server, inode);
+ /* Call generic open code in order to cache credentials */
+ if (!res)
+ res = nfs_open(inode, filp);
+ unlock_kernel();
+ return res;
+}
+
/*
* Flush all dirty pages, and check for write errors.
*
{
struct rpc_auth *auth;
struct rpc_cred *cred;
- int err = 0;
- lock_kernel();
- /* Ensure that we revalidate the data cache */
- if (NFS_SERVER(inode)->flags & NFS_MOUNT_NOCTO) {
- err = __nfs_revalidate_inode(NFS_SERVER(inode),inode);
- if (err)
- goto out;
- }
auth = NFS_CLIENT(inode)->cl_auth;
cred = rpcauth_lookupcred(auth, 0);
filp->private_data = cred;
if (filp->f_mode & FMODE_WRITE)
nfs_set_mmcred(inode, cred);
-out:
- unlock_kernel();
- return err;
+ return 0;
}
int nfs_release(struct inode *inode, struct file *filp)
return rpc_execute(task);
}
+/*
+* To be changed into a real NFSv4 file_open soon.
+*/
+
+int
+nfs4_proc_file_open(struct inode *inode, struct file *filp)
+{
+ return 0;
+}
+
struct nfs_rpc_ops nfs_v4_clientops = {
.version = 4, /* protocol version */
.getroot = nfs4_proc_get_root,
.read_setup = nfs4_proc_read_setup,
.write_setup = nfs4_proc_write_setup,
.commit_setup = nfs4_proc_commit_setup,
+ .file_open = nfs4_proc_file_open,
};
/*
void (*read_setup) (struct nfs_read_data *, unsigned int count);
void (*write_setup) (struct nfs_write_data *, unsigned int count, int how);
void (*commit_setup) (struct nfs_write_data *, u64 start, u32 len, int how);
+ int (*file_open) (struct inode *, struct file *);
};
/*