Blame view
fs/udf/symlink.c
2.33 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 |
/* * symlink.c * * PURPOSE * Symlink handling routines for the OSTA-UDF(tm) filesystem. * |
1da177e4c Linux-2.6.12-rc2 |
7 8 9 10 11 12 13 |
* COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: * ftp://prep.ai.mit.edu/pub/gnu/GPL * Each contributing author retains all rights to their own work. * * (C) 1998-2001 Ben Fennema |
28de7948a UDF: coding style... |
14 |
* (C) 1999 Stelias Computing Inc |
1da177e4c Linux-2.6.12-rc2 |
15 16 17 18 19 20 21 22 23 24 25 |
* * HISTORY * * 04/16/99 blf Created. * */ #include "udfdecl.h" #include <asm/uaccess.h> #include <linux/errno.h> #include <linux/fs.h> |
1da177e4c Linux-2.6.12-rc2 |
26 27 28 29 30 31 32 33 |
#include <linux/time.h> #include <linux/mm.h> #include <linux/stat.h> #include <linux/slab.h> #include <linux/pagemap.h> #include <linux/smp_lock.h> #include <linux/buffer_head.h> #include "udf_i.h" |
4b11111ab udf: fix coding s... |
34 35 |
static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char *to) |
1da177e4c Linux-2.6.12-rc2 |
36 37 38 39 |
{ struct pathComponent *pc; int elen = 0; char *p = to; |
cb00ea352 UDF: coding style... |
40 |
while (elen < fromlen) { |
1da177e4c Linux-2.6.12-rc2 |
41 |
pc = (struct pathComponent *)(from + elen); |
cb00ea352 UDF: coding style... |
42 43 44 45 |
switch (pc->componentType) { case 1: if (pc->lengthComponentIdent == 0) { p = to; |
1da177e4c Linux-2.6.12-rc2 |
46 |
*p++ = '/'; |
cb00ea352 UDF: coding style... |
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
} break; case 3: memcpy(p, "../", 3); p += 3; break; case 4: memcpy(p, "./", 2); p += 2; /* that would be . - just ignore */ break; case 5: p += udf_get_filename(sb, pc->componentIdent, p, pc->lengthComponentIdent); *p++ = '/'; break; |
1da177e4c Linux-2.6.12-rc2 |
63 64 65 |
} elen += sizeof(struct pathComponent) + pc->lengthComponentIdent; } |
cb00ea352 UDF: coding style... |
66 |
if (p > to + 1) |
1da177e4c Linux-2.6.12-rc2 |
67 68 69 70 71 72 73 74 75 76 77 78 |
p[-1] = '\0'; else p[0] = '\0'; } static int udf_symlink_filler(struct file *file, struct page *page) { struct inode *inode = page->mapping->host; struct buffer_head *bh = NULL; char *symlink; int err = -EIO; char *p = kmap(page); |
48d6d8ff7 udf: cache struct... |
79 |
struct udf_inode_info *iinfo; |
1da177e4c Linux-2.6.12-rc2 |
80 81 |
lock_kernel(); |
48d6d8ff7 udf: cache struct... |
82 83 84 |
iinfo = UDF_I(inode); if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { symlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr; |
28de7948a UDF: coding style... |
85 |
} else { |
1da177e4c Linux-2.6.12-rc2 |
86 87 88 89 90 91 92 93 94 |
bh = sb_bread(inode->i_sb, udf_block_map(inode, 0)); if (!bh) goto out; symlink = bh->b_data; } udf_pc_to_char(inode->i_sb, symlink, inode->i_size, p); |
3bf25cb40 udf: use get_bh() |
95 |
brelse(bh); |
1da177e4c Linux-2.6.12-rc2 |
96 97 98 99 100 101 |
unlock_kernel(); SetPageUptodate(page); kunmap(page); unlock_page(page); return 0; |
28de7948a UDF: coding style... |
102 103 |
out: |
1da177e4c Linux-2.6.12-rc2 |
104 105 106 107 108 109 110 111 112 113 |
unlock_kernel(); SetPageError(page); kunmap(page); unlock_page(page); return err; } /* * symlinks can't do much... */ |
f5e54d6e5 [PATCH] mark addr... |
114 |
const struct address_space_operations udf_symlink_aops = { |
28de7948a UDF: coding style... |
115 |
.readpage = udf_symlink_filler, |
1da177e4c Linux-2.6.12-rc2 |
116 |
}; |