Import 2.3.5
[davej-history.git] / fs / isofs / symlink.c
blob5de4a874839963003513f9c1efd387a8fcee01d8
1 /*
2 * linux/fs/isofs/symlink.c
4 * (C) 1992 Eric Youngdale Modified for ISO 9660 filesystem.
6 * Copyright (C) 1991, 1992 Linus Torvalds
8 * isofs symlink handling code. This is only used with the Rock Ridge
9 * extensions to iso9660
12 #include <linux/string.h>
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/fs.h>
16 #include <linux/iso_fs.h>
17 #include <linux/stat.h>
18 #include <linux/malloc.h>
20 #include <asm/uaccess.h>
22 static int isofs_readlink(struct dentry *, char *, int);
23 static struct dentry * isofs_follow_link(struct dentry *, struct dentry *, unsigned int);
26 * symlinks can't do much...
28 struct inode_operations isofs_symlink_inode_operations = {
29 NULL, /* no file-operations */
30 NULL, /* create */
31 NULL, /* lookup */
32 NULL, /* link */
33 NULL, /* unlink */
34 NULL, /* symlink */
35 NULL, /* mkdir */
36 NULL, /* rmdir */
37 NULL, /* mknod */
38 NULL, /* rename */
39 isofs_readlink, /* readlink */
40 isofs_follow_link, /* follow_link */
41 NULL, /* readpage */
42 NULL, /* writepage */
43 NULL, /* bmap */
44 NULL, /* truncate */
45 NULL /* permission */
48 static int isofs_readlink(struct dentry * dentry, char * buffer, int buflen)
50 char * pnt;
51 int i;
53 if (buflen > 1023)
54 buflen = 1023;
55 pnt = get_rock_ridge_symlink(dentry->d_inode);
57 if (!pnt)
58 return 0;
60 i = strlen(pnt);
61 if (i > buflen)
62 i = buflen;
63 if (copy_to_user(buffer, pnt, i))
64 i = -EFAULT;
65 kfree(pnt);
66 return i;
69 static struct dentry * isofs_follow_link(struct dentry * dentry,
70 struct dentry *base,
71 unsigned int follow)
73 char * pnt;
75 pnt = get_rock_ridge_symlink(dentry->d_inode);
76 if(!pnt) {
77 dput(base);
78 return ERR_PTR(-ELOOP);
81 base = lookup_dentry(pnt, base, follow);
83 kfree(pnt);
84 return base;