Whamcloud - gitweb
include/linux/obdfs.h: add symlink_inode_operations, prototypes
[fs/lustre-release.git] / lustre / obdfs / symlink.c
index 53bb167..c933a1a 100644 (file)
 
 #include <linux/errno.h>
 #include <linux/fs.h>
-#include <linux/ext2_fs.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/stat.h>
+#include <linux/locks.h>
+
+#include <linux/obd_support.h> /* for ENTRY and EXIT only */
+#include <linux/obdfs.h>
 
 static int obdfs_readlink (struct dentry *, char *, int);
 static struct dentry *obdfs_follow_link(struct dentry *, struct dentry *, unsigned int);
 
-static struct dentry * ext2_follow_link(struct dentry * dentry,
-                                       struct dentry *base,
-                                       unsigned int follow)
+/*
+ * symlinks can't do much...
+ */
+struct inode_operations obdfs_symlink_inode_operations = {
+       NULL,                   /* no file-operations */
+       NULL,                   /* create */
+       NULL,                   /* lookup */
+       NULL,                   /* link */
+       NULL,                   /* unlink */
+       NULL,                   /* symlink */
+       NULL,                   /* mkdir */
+       NULL,                   /* rmdir */
+       NULL,                   /* mknod */
+       NULL,                   /* rename */
+       obdfs_readlink,         /* readlink */
+       obdfs_follow_link,      /* follow_link */
+       NULL,                   /* get_block */
+       NULL,                   /* readpage */
+       NULL,                   /* writepage */
+       NULL,                   /* truncate */
+       NULL,                   /* permission */
+       NULL                    /* revalidate */
+};
+
+static struct dentry * obdfs_follow_link(struct dentry * dentry,
+                                        struct dentry *base,
+                                        unsigned int follow)
 {
        struct inode *inode = dentry->d_inode;
        struct page *page = NULL;
-       int error;
        char * link;
 
+       ENTRY;
        link = (char *) inode->u.ext2_i.i_data;
        if (inode->i_blocks) {
-               if (!(page = obdfs_getpage(inode, 0, 0, &error))) {
+               IDEBUG(inode);
+               page = obdfs_getpage(inode, 0, 0, 0);
+               PDEBUG(page, "follow_link");
+               if (!page) {
                        dput(base);
+                       EXIT;
                        return ERR_PTR(-EIO);
                }
-               link = bh->b_data;
+               link = (char *)page_address(page);
        }
        UPDATE_ATIME(inode);
        base = lookup_dentry(link, base, follow);
-       if (bh)
-               brelse(bh);
+       if (page) {
+               page_cache_release(page);
+       }
+       EXIT;
        return base;
 }
 
-static int ext2_readlink (struct dentry * dentry, char * buffer, int buflen)
+static int obdfs_readlink (struct dentry * dentry, char * buffer, int buflen)
 {
        struct inode *inode = dentry->d_inode;
-       struct buffer_head * bh = NULL;
+       struct page *page = NULL;
        char * link;
        int i;
 
+       ENTRY;
        if (buflen > inode->i_sb->s_blocksize - 1)
                buflen = inode->i_sb->s_blocksize - 1;
 
        link = (char *) inode->u.ext2_i.i_data;
        if (inode->i_blocks) {
-               int err;
-               bh = ext2_bread (inode, 0, 0, &err);
-               if (!bh) {
-                       if(err < 0) /* indicate type of error */
-                               return err;
+               IDEBUG(inode);
+               page = obdfs_getpage(inode, 0, 0, 0);
+               PDEBUG(page, "readlink");
+               if (!page) {
+                       EXIT;
                        return 0;
                }
-               link = bh->b_data;
+               link = (char *)page_address(page);
        }
 
        i = 0;
@@ -81,7 +115,9 @@ static int ext2_readlink (struct dentry * dentry, char * buffer, int buflen)
                i++;
        if (copy_to_user(buffer, link, i))
                i = -EFAULT;
-       if (bh)
-               brelse (bh);
+       if (page) {
+               page_cache_release(page);
+       }
+       EXIT;
        return i;
-}
+} /* obdfs_readlink */