Remove references to CONFIG_PROFILE. Kernel profiling is no longer a
[linux-2.6/linux-mips.git] / fs / udf / symlink.c
blobcb575cbf9c9d8f1aeb3cc9bcf9e55342807cfb3f
1 /*
2 * symlink.c
4 * PURPOSE
5 * Symlink handling routines for the OSTA-UDF(tm) filesystem.
7 * CONTACTS
8 * E-mail regarding any portion of the Linux UDF file system should be
9 * directed to the development team mailing list (run by majordomo):
10 * linux_udf@hootie.lvld.hp.com
12 * COPYRIGHT
13 * This file is distributed under the terms of the GNU General Public
14 * License (GPL). Copies of the GPL can be obtained from:
15 * ftp://prep.ai.mit.edu/pub/gnu/GPL
16 * Each contributing author retains all rights to their own work.
18 * (C) 1998-2000 Ben Fennema
19 * (C) 1999 Stelias Computing Inc
21 * HISTORY
23 * 04/16/99 blf Created.
27 #include "udfdecl.h"
28 #include <asm/uaccess.h>
29 #include <linux/errno.h>
30 #include <linux/fs.h>
31 #include <linux/udf_fs.h>
32 #include <linux/sched.h>
33 #include <linux/mm.h>
34 #include <linux/stat.h>
35 #include <linux/malloc.h>
36 #include <linux/pagemap.h>
37 #include "udf_i.h"
39 static void udf_pc_to_char(char *from, int fromlen, char *to)
41 struct PathComponent *pc;
42 int elen = 0;
43 char *p = to;
45 while (elen < fromlen)
47 pc = (struct PathComponent *)(from + elen);
48 switch (pc->componentType)
50 case 1:
51 if (pc->lengthComponentIdent == 0)
53 p = to;
54 *p++ = '/';
56 break;
57 case 3:
58 memcpy(p, "../", 3);
59 p += 3;
60 break;
61 case 4:
62 memcpy(p, "./", 2);
63 p += 2;
64 /* that would be . - just ignore */
65 break;
66 case 5:
67 memcpy(p, pc->componentIdent, pc->lengthComponentIdent);
68 p += pc->lengthComponentIdent;
69 *p++ = '/';
71 elen += sizeof(struct PathComponent) + pc->lengthComponentIdent;
73 if (p > to+1)
74 p[-1] = '\0';
75 else
76 p[0] = '\0';
79 static int udf_symlink_filler(struct file *file, struct page *page)
81 struct inode *inode = (struct inode*)page->mapping->host;
82 struct buffer_head *bh = NULL;
83 char *symlink;
84 int err = -EIO;
85 char *p = (char *)kmap(page);
87 if (UDF_I_ALLOCTYPE(inode) == ICB_FLAG_AD_IN_ICB)
89 bh = udf_tread(inode->i_sb, inode->i_ino, inode->i_sb->s_blocksize);
91 if (!bh)
92 goto out;
94 symlink = bh->b_data + udf_file_entry_alloc_offset(inode);
96 else
98 bh = bread(inode->i_dev, udf_block_map(inode, 0),
99 inode->i_sb->s_blocksize);
101 if (!bh)
102 goto out;
104 symlink = bh->b_data;
107 udf_pc_to_char(symlink, inode->i_size, p);
108 udf_release_data(bh);
110 SetPageUptodate(page);
111 kunmap(page);
112 UnlockPage(page);
113 return 0;
114 out:
115 SetPageError(page);
116 kunmap(page);
117 UnlockPage(page);
118 return err;
122 * symlinks can't do much...
124 struct address_space_operations udf_symlink_aops = {
125 readpage: udf_symlink_filler,