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