Blame view
fs/jffs2/symlink.c
1.83 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 |
/* * JFFS2 -- Journalling Flash File System, Version 2. * |
c00c310ea [JFFS2] Tidy up l... |
4 |
* Copyright © 2001-2007 Red Hat, Inc. |
1da177e4c Linux-2.6.12-rc2 |
5 6 7 8 9 |
* * Created by David Woodhouse <dwmw2@infradead.org> * * For licensing information, see the file 'LICENCE' in this directory. * |
1da177e4c Linux-2.6.12-rc2 |
10 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
11 |
#include <linux/kernel.h> |
1da177e4c Linux-2.6.12-rc2 |
12 13 14 |
#include <linux/fs.h> #include <linux/namei.h> #include "nodelist.h" |
008b150a3 [PATCH] Fix up sy... |
15 |
static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd); |
1da177e4c Linux-2.6.12-rc2 |
16 |
|
92e1d5be9 [PATCH] mark stru... |
17 |
const struct inode_operations jffs2_symlink_inode_operations = |
182ec4eee [JFFS2] Clean up ... |
18 |
{ |
1da177e4c Linux-2.6.12-rc2 |
19 20 |
.readlink = generic_readlink, .follow_link = jffs2_follow_link, |
4e34e719e fs: take the ACL ... |
21 |
.get_acl = jffs2_get_acl, |
aa98d7cf5 [JFFS2][XATTR] XA... |
22 23 24 25 26 |
.setattr = jffs2_setattr, .setxattr = jffs2_setxattr, .getxattr = jffs2_getxattr, .listxattr = jffs2_listxattr, .removexattr = jffs2_removexattr |
1da177e4c Linux-2.6.12-rc2 |
27 |
}; |
008b150a3 [PATCH] Fix up sy... |
28 |
static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd) |
1da177e4c Linux-2.6.12-rc2 |
29 |
{ |
32f1a95d5 [JFFS2] Add symli... |
30 |
struct jffs2_inode_info *f = JFFS2_INODE_INFO(dentry->d_inode); |
2b79adcca [JFFS2] Use f->ta... |
31 |
char *p = (char *)f->target; |
32f1a95d5 [JFFS2] Add symli... |
32 33 |
/* * We don't acquire the f->sem mutex here since the only data we |
2b79adcca [JFFS2] Use f->ta... |
34 |
* use is f->target. |
32f1a95d5 [JFFS2] Add symli... |
35 |
* |
2b79adcca [JFFS2] Use f->ta... |
36 |
* 1. If we are here the inode has already built and f->target has |
32f1a95d5 [JFFS2] Add symli... |
37 |
* to point to the target path. |
2b79adcca [JFFS2] Use f->ta... |
38 39 |
* 2. Nobody uses f->target (if the inode is symlink's inode). The * exception is inode freeing function which frees f->target. But |
32f1a95d5 [JFFS2] Add symli... |
40 |
* it can't be called while we are here and before VFS has |
2b79adcca [JFFS2] Use f->ta... |
41 |
* stopped using our f->target string which we provide by means of |
32f1a95d5 [JFFS2] Add symli... |
42 43 |
* nd_set_link() call. */ |
182ec4eee [JFFS2] Clean up ... |
44 |
|
2fb1e3086 [PATCH] jffs2: fi... |
45 |
if (!p) { |
c7cf0c68e [JFFS2] Fix jffs2... |
46 47 |
printk(KERN_ERR "jffs2_follow_link(): can't find symlink target "); |
2fb1e3086 [PATCH] jffs2: fi... |
48 |
p = ERR_PTR(-EIO); |
32f1a95d5 [JFFS2] Add symli... |
49 |
} |
2b79adcca [JFFS2] Use f->ta... |
50 51 |
D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s' ", (char *) f->target)); |
32f1a95d5 [JFFS2] Add symli... |
52 |
|
2fb1e3086 [PATCH] jffs2: fi... |
53 |
nd_set_link(nd, p); |
182ec4eee [JFFS2] Clean up ... |
54 |
|
32f1a95d5 [JFFS2] Add symli... |
55 |
/* |
2b79adcca [JFFS2] Use f->ta... |
56 57 58 |
* We will unlock the f->sem mutex but VFS will use the f->target string. This is safe * since the only way that may cause f->target to be changed is iput() operation. * But VFS will not use f->target after iput() has been called. |
32f1a95d5 [JFFS2] Add symli... |
59 |
*/ |
008b150a3 [PATCH] Fix up sy... |
60 |
return NULL; |
1da177e4c Linux-2.6.12-rc2 |
61 |
} |