Blame view

fs/nfs/symlink.c 1.62 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
  /*
   *  linux/fs/nfs/symlink.c
   *
   *  Copyright (C) 1992  Rick Sladkey
   *
   *  Optimization changes Copyright (C) 1994 Florian La Roche
   *
   *  Jun 7 1999, cache symlink lookups in the page cache.  -DaveM
   *
   *  nfs symlink handling code
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12
13
14
15
16
17
18
19
20
  #include <linux/time.h>
  #include <linux/errno.h>
  #include <linux/sunrpc/clnt.h>
  #include <linux/nfs.h>
  #include <linux/nfs2.h>
  #include <linux/nfs_fs.h>
  #include <linux/pagemap.h>
  #include <linux/stat.h>
  #include <linux/mm.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
  #include <linux/string.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
23
24
25
  #include <linux/namei.h>
  
  /* Symlink caching in the page cache is even more simplistic
   * and straight-forward than readdir caching.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
28
  static int nfs_symlink_filler(struct inode *inode, struct page *page)
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
  	int error;
cc314eef0   Linus Torvalds   Fix nasty ncpfs s...
30
  	error = NFS_PROTO(inode)->readlink(inode, page, 0, PAGE_SIZE);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
34
35
36
37
38
39
40
41
  	if (error < 0)
  		goto error;
  	SetPageUptodate(page);
  	unlock_page(page);
  	return 0;
  
  error:
  	SetPageError(page);
  	unlock_page(page);
  	return -EIO;
  }
cc314eef0   Linus Torvalds   Fix nasty ncpfs s...
42
  static void *nfs_follow_link(struct dentry *dentry, struct nameidata *nd)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
44
45
  {
  	struct inode *inode = dentry->d_inode;
  	struct page *page;
717d44e84   Trond Myklebust   [PATCH] NFS: Fix ...
46
  	void *err;
1cda707d5   Trond Myklebust   NFS: Remove requi...
47
  	err = ERR_PTR(nfs_revalidate_mapping(inode, inode->i_mapping));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
49
50
51
52
53
54
55
  	if (err)
  		goto read_failed;
  	page = read_cache_page(&inode->i_data, 0,
  				(filler_t *)nfs_symlink_filler, inode);
  	if (IS_ERR(page)) {
  		err = page;
  		goto read_failed;
  	}
cc314eef0   Linus Torvalds   Fix nasty ncpfs s...
56
57
  	nd_set_link(nd, kmap(page));
  	return page;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
60
  read_failed:
  	nd_set_link(nd, err);
cc314eef0   Linus Torvalds   Fix nasty ncpfs s...
61
  	return NULL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
64
65
  /*
   * symlinks can't do much...
   */
92e1d5be9   Arjan van de Ven   [PATCH] mark stru...
66
  const struct inode_operations nfs_symlink_inode_operations = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
68
  	.readlink	= generic_readlink,
  	.follow_link	= nfs_follow_link,
9bf2aa129   Alexey Dobriyan   nfs: remove nfs_p...
69
  	.put_link	= page_put_link,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
70
71
72
  	.getattr	= nfs_getattr,
  	.setattr	= nfs_setattr,
  };