Commit faa1bb09 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] symlink 5/9: smbfs

smbfs - switched from on-stack allocation of buffer for link body (!) to
__getname()/putname(); switched to new scheme.
parent a2126997
......@@ -87,7 +87,5 @@ extern int smb_request_send_req(struct smb_request *req);
extern int smb_request_send_server(struct smb_sb_info *server);
extern int smb_request_recv(struct smb_sb_info *server);
/* symlink.c */
extern int smb_read_link(struct dentry *dentry, char *buffer, int len);
extern int smb_symlink(struct inode *inode, struct dentry *dentry, const char *oldname);
extern int smb_follow_link(struct dentry *dentry, struct nameidata *nd);
extern struct inode_operations smb_link_inode_operations;
......@@ -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>
......@@ -26,19 +27,6 @@
#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,
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment