Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / fs / efs / symlink.c
blobb0d94e8136105b1292fac529364da8b69b8dfd9d
1 /*
2 * symlink.c
4 * Copyright (c) 1999 Al Smith
6 * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
7 */
9 #include <linux/string.h>
10 <<<<<<< HEAD:fs/efs/symlink.c
11 #include <linux/efs_fs.h>
12 =======
13 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:fs/efs/symlink.c
14 #include <linux/pagemap.h>
15 #include <linux/buffer_head.h>
16 #include <linux/smp_lock.h>
17 <<<<<<< HEAD:fs/efs/symlink.c
18 =======
19 #include "efs.h"
20 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:fs/efs/symlink.c
22 static int efs_symlink_readpage(struct file *file, struct page *page)
24 char *link = kmap(page);
25 struct buffer_head * bh;
26 struct inode * inode = page->mapping->host;
27 efs_block_t size = inode->i_size;
28 int err;
30 err = -ENAMETOOLONG;
31 if (size > 2 * EFS_BLOCKSIZE)
32 goto fail_notlocked;
34 lock_kernel();
35 /* read first 512 bytes of link target */
36 err = -EIO;
37 bh = sb_bread(inode->i_sb, efs_bmap(inode, 0));
38 if (!bh)
39 goto fail;
40 memcpy(link, bh->b_data, (size > EFS_BLOCKSIZE) ? EFS_BLOCKSIZE : size);
41 brelse(bh);
42 if (size > EFS_BLOCKSIZE) {
43 bh = sb_bread(inode->i_sb, efs_bmap(inode, 1));
44 if (!bh)
45 goto fail;
46 memcpy(link + EFS_BLOCKSIZE, bh->b_data, size - EFS_BLOCKSIZE);
47 brelse(bh);
49 link[size] = '\0';
50 unlock_kernel();
51 SetPageUptodate(page);
52 kunmap(page);
53 unlock_page(page);
54 return 0;
55 fail:
56 unlock_kernel();
57 fail_notlocked:
58 SetPageError(page);
59 kunmap(page);
60 unlock_page(page);
61 return err;
64 const struct address_space_operations efs_symlink_aops = {
65 .readpage = efs_symlink_readpage