linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / 9p / vfs_file.c
index c3c47ed..de3a129 100644 (file)
@@ -7,8 +7,9 @@
  *  Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  *
  *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2
- *  as published by the Free Software Foundation.
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,6 +32,7 @@
 #include <linux/string.h>
 #include <linux/smp_lock.h>
 #include <linux/inet.h>
+#include <linux/version.h>
 #include <linux/list.h>
 #include <asm/uaccess.h>
 #include <linux/idr.h>
@@ -67,36 +69,29 @@ int v9fs_file_open(struct inode *inode, struct file *file)
 
        fid = v9fs_get_idpool(&v9ses->fidpool);
        if (fid < 0) {
-               eprintk(KERN_WARNING, "newfid fails!\n");
-               return -ENOSPC;
-       }
-
-       err = v9fs_t_walk(v9ses, vfid->fid, fid, NULL, &fcall);
-       if (err < 0) {
-               dprintk(DEBUG_ERROR, "rewalk didn't work\n");
-               if (fcall && fcall->id == RWALK)
-                       goto clunk_fid;
-               else {
-                       v9fs_put_idpool(fid, &v9ses->fidpool);
-                       goto free_fcall;
+                       eprintk(KERN_WARNING, "newfid fails!\n");
+                       return -ENOSPC;
                }
-       }
-       kfree(fcall);
 
-       /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */
-       /* translate open mode appropriately */
-       omode = v9fs_uflags2omode(file->f_flags);
-       err = v9fs_t_open(v9ses, fid, omode, &fcall);
+       err = v9fs_t_walk(v9ses, vfid->fid, fid, NULL, NULL);
        if (err < 0) {
-               PRINT_FCALL_ERROR("open failed", fcall);
-               goto clunk_fid;
+                       dprintk(DEBUG_ERROR, "rewalk didn't work\n");
+               goto put_fid;
        }
 
        vfid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL);
        if (vfid == NULL) {
                dprintk(DEBUG_ERROR, "out of memory\n");
-               err = -ENOMEM;
                goto clunk_fid;
+               }
+
+               /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */
+               /* translate open mode appropriately */
+       omode = v9fs_uflags2omode(file->f_flags);
+       err = v9fs_t_open(v9ses, fid, omode, &fcall);
+       if (err < 0) {
+               PRINT_FCALL_ERROR("open failed", fcall);
+               goto destroy_vfid;
        }
 
        file->private_data = vfid;
@@ -111,11 +106,15 @@ int v9fs_file_open(struct inode *inode, struct file *file)
 
        return 0;
 
+destroy_vfid:
+       v9fs_fid_destroy(vfid);
+
 clunk_fid:
        v9fs_t_clunk(v9ses, fid);
 
-free_fcall:
-       kfree(fcall);
+put_fid:
+       v9fs_put_idpool(fid, &v9ses->fidpool);
+               kfree(fcall);
 
        return err;
 }
@@ -270,7 +269,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
        return total;
 }
 
-const struct file_operations v9fs_file_operations = {
+struct file_operations v9fs_file_operations = {
        .llseek = generic_file_llseek,
        .read = v9fs_file_read,
        .write = v9fs_file_write,