VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / fs / smbfs / symlink.c
index 44d6f58..8b069e0 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 #include <linux/net.h>
+#include <linux/namei.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include "smb_debug.h"
 #include "proto.h"
 
-int smb_read_link(struct dentry *dentry, char *buffer, int len)
-{
-       char link[256];         /* FIXME: pain ... */
-       int r;
-       DEBUG1("read link buffer len = %d\n", len);
-
-       r = smb_proc_read_link(server_from_dentry(dentry), dentry, link,
-                              sizeof(link) - 1);
-       if (r < 0)
-               return -ENOENT;
-       return vfs_readlink(dentry, buffer, len, link);
-}
-
 int smb_symlink(struct inode *inode, struct dentry *dentry, const char *oldname)
 {
        DEBUG1("create symlink %s -> %s/%s\n", oldname, DENTRY_PATH(dentry));
@@ -46,24 +34,37 @@ int smb_symlink(struct inode *inode, struct dentry *dentry, const char *oldname)
        return smb_proc_symlink(server_from_dentry(dentry), dentry, oldname);
 }
 
-int smb_follow_link(struct dentry *dentry, struct nameidata *nd)
+static int smb_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
-       char link[256];         /* FIXME: pain ... */
-       int len;
+       char *link = __getname();
        DEBUG1("followlink of %s/%s\n", DENTRY_PATH(dentry));
 
-       len = smb_proc_read_link(server_from_dentry(dentry), dentry, link,
-                                sizeof(link) - 1);
-       if(len < 0)
-               return -ENOENT;
-
-       link[len] = 0;
-       return vfs_follow_link(nd, link);
+       if (!link) {
+               link = ERR_PTR(-ENOMEM);
+       } else {
+               int len = smb_proc_read_link(server_from_dentry(dentry),
+                                               dentry, link, PATH_MAX - 1);
+               if (len < 0) {
+                       putname(link);
+                       link = ERR_PTR(len);
+               } else {
+                       link[len] = 0;
+               }
+       }
+       nd_set_link(nd, link);
+       return 0;
 }
 
+static void smb_put_link(struct dentry *dentry, struct nameidata *nd)
+{
+       char *s = nd_get_link(nd);
+       if (!IS_ERR(s))
+               putname(s);
+}
 
 struct inode_operations smb_link_inode_operations =
 {
-       .readlink       = smb_read_link,
+       .readlink       = generic_readlink,
        .follow_link    = smb_follow_link,
+       .put_link       = smb_put_link,
 };