Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * namei.c |
| 3 | * |
| 4 | * PURPOSE |
| 5 | * Inode name handling routines for the OSTA-UDF(tm) filesystem. |
| 6 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * COPYRIGHT |
| 8 | * This file is distributed under the terms of the GNU General Public |
| 9 | * License (GPL). Copies of the GPL can be obtained from: |
| 10 | * ftp://prep.ai.mit.edu/pub/gnu/GPL |
| 11 | * Each contributing author retains all rights to their own work. |
| 12 | * |
| 13 | * (C) 1998-2004 Ben Fennema |
| 14 | * (C) 1999-2000 Stelias Computing Inc |
| 15 | * |
| 16 | * HISTORY |
| 17 | * |
| 18 | * 12/12/98 blf Created. Split out the lookup code from dir.c |
| 19 | * 04/19/99 blf link, mknod, symlink support |
| 20 | */ |
| 21 | |
| 22 | #include "udfdecl.h" |
| 23 | |
| 24 | #include "udf_i.h" |
| 25 | #include "udf_sb.h" |
| 26 | #include <linux/string.h> |
| 27 | #include <linux/errno.h> |
| 28 | #include <linux/mm.h> |
| 29 | #include <linux/slab.h> |
| 30 | #include <linux/quotaops.h> |
| 31 | #include <linux/smp_lock.h> |
| 32 | #include <linux/buffer_head.h> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 33 | #include <linux/sched.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 35 | static inline int udf_match(int len1, const char *name1, int len2, |
| 36 | const char *name2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | { |
| 38 | if (len1 != len2) |
| 39 | return 0; |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | return !memcmp(name1, name2, len1); |
| 42 | } |
| 43 | |
| 44 | int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 45 | struct fileIdentDesc *sfi, struct udf_fileident_bh *fibh, |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 46 | uint8_t *impuse, uint8_t *fileident) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | { |
| 48 | uint16_t crclen = fibh->eoffset - fibh->soffset - sizeof(tag); |
| 49 | uint16_t crc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | int offset; |
| 51 | uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse); |
| 52 | uint8_t lfi = cfi->lengthFileIdent; |
| 53 | int padlen = fibh->eoffset - fibh->soffset - liu - lfi - |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 54 | sizeof(struct fileIdentDesc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | int adinicb = 0; |
| 56 | |
Marcin Slusarz | c0b3443 | 2008-02-08 04:20:42 -0800 | [diff] [blame] | 57 | if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | adinicb = 1; |
| 59 | |
| 60 | offset = fibh->soffset + sizeof(struct fileIdentDesc); |
| 61 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 62 | if (impuse) { |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 63 | if (adinicb || (offset + liu < 0)) { |
| 64 | memcpy((uint8_t *)sfi->impUse, impuse, liu); |
| 65 | } else if (offset >= 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | memcpy(fibh->ebh->b_data + offset, impuse, liu); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 67 | } else { |
| 68 | memcpy((uint8_t *)sfi->impUse, impuse, -offset); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 69 | memcpy(fibh->ebh->b_data, impuse - offset, |
| 70 | liu + offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | } |
| 72 | } |
| 73 | |
| 74 | offset += liu; |
| 75 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 76 | if (fileident) { |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 77 | if (adinicb || (offset + lfi < 0)) { |
| 78 | memcpy((uint8_t *)sfi->fileIdent + liu, fileident, lfi); |
| 79 | } else if (offset >= 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | memcpy(fibh->ebh->b_data + offset, fileident, lfi); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 81 | } else { |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 82 | memcpy((uint8_t *)sfi->fileIdent + liu, fileident, |
| 83 | -offset); |
| 84 | memcpy(fibh->ebh->b_data, fileident - offset, |
| 85 | lfi + offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } |
| 87 | } |
| 88 | |
| 89 | offset += lfi; |
| 90 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 91 | if (adinicb || (offset + padlen < 0)) { |
| 92 | memset((uint8_t *)sfi->padding + liu + lfi, 0x00, padlen); |
| 93 | } else if (offset >= 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | memset(fibh->ebh->b_data + offset, 0x00, padlen); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 95 | } else { |
| 96 | memset((uint8_t *)sfi->padding + liu + lfi, 0x00, -offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | memset(fibh->ebh->b_data, 0x00, padlen + offset); |
| 98 | } |
| 99 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 100 | crc = udf_crc((uint8_t *)cfi + sizeof(tag), |
| 101 | sizeof(struct fileIdentDesc) - sizeof(tag), 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 103 | if (fibh->sbh == fibh->ebh) { |
| 104 | crc = udf_crc((uint8_t *)sfi->impUse, |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 105 | crclen + sizeof(tag) - |
| 106 | sizeof(struct fileIdentDesc), crc); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 107 | } else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) { |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 108 | crc = udf_crc(fibh->ebh->b_data + |
| 109 | sizeof(struct fileIdentDesc) + |
| 110 | fibh->soffset, |
| 111 | crclen + sizeof(tag) - |
| 112 | sizeof(struct fileIdentDesc), |
| 113 | crc); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 114 | } else { |
| 115 | crc = udf_crc((uint8_t *)sfi->impUse, |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 116 | -fibh->soffset - sizeof(struct fileIdentDesc), |
| 117 | crc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc); |
| 119 | } |
| 120 | |
| 121 | cfi->descTag.descCRC = cpu_to_le16(crc); |
| 122 | cfi->descTag.descCRCLength = cpu_to_le16(crclen); |
Marcin Slusarz | 3f2587b | 2008-02-08 04:20:39 -0800 | [diff] [blame] | 123 | cfi->descTag.tagChecksum = udf_tag_checksum(&cfi->descTag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 125 | if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) { |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 126 | memcpy((uint8_t *)sfi, (uint8_t *)cfi, |
| 127 | sizeof(struct fileIdentDesc)); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 128 | } else { |
| 129 | memcpy((uint8_t *)sfi, (uint8_t *)cfi, -fibh->soffset); |
| 130 | memcpy(fibh->ebh->b_data, (uint8_t *)cfi - fibh->soffset, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 131 | sizeof(struct fileIdentDesc) + fibh->soffset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 134 | if (adinicb) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | mark_inode_dirty(inode); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 136 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | if (fibh->sbh != fibh->ebh) |
| 138 | mark_buffer_dirty_inode(fibh->ebh, inode); |
| 139 | mark_buffer_dirty_inode(fibh->sbh, inode); |
| 140 | } |
| 141 | return 0; |
| 142 | } |
| 143 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 144 | static struct fileIdentDesc *udf_find_entry(struct inode *dir, |
| 145 | struct dentry *dentry, |
| 146 | struct udf_fileident_bh *fibh, |
| 147 | struct fileIdentDesc *cfi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 149 | struct fileIdentDesc *fi = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | loff_t f_pos; |
| 151 | int block, flen; |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 152 | char *fname = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | char *nameptr; |
| 154 | uint8_t lfi; |
| 155 | uint16_t liu; |
KAMBAROV, ZAUR | ec471dc | 2005-06-28 20:45:10 -0700 | [diff] [blame] | 156 | loff_t size; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 157 | kernel_lb_addr eloc; |
| 158 | uint32_t elen; |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 159 | sector_t offset; |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 160 | struct extent_position epos = {}; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 161 | struct udf_inode_info *dinfo = UDF_I(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 163 | size = udf_ext0_offset(dir) + dir->i_size; |
| 164 | f_pos = udf_ext0_offset(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 166 | fibh->sbh = fibh->ebh = NULL; |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 167 | fibh->soffset = fibh->eoffset = f_pos & (dir->i_sb->s_blocksize - 1); |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 168 | if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { |
| 169 | if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits, &epos, |
| 170 | &eloc, &elen, &offset) != (EXT_RECORDED_ALLOCATED >> 30)) |
| 171 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 173 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 174 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 175 | epos.offset -= sizeof(short_ad); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 176 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 177 | epos.offset -= sizeof(long_ad); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 178 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | offset = 0; |
| 180 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 181 | fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block); |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 182 | if (!fibh->sbh) |
| 183 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 186 | fname = kmalloc(UDF_NAME_LEN, GFP_NOFS); |
| 187 | if (!fname) |
| 188 | goto out_err; |
| 189 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 190 | while (f_pos < size) { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 191 | fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, |
| 192 | &elen, &offset); |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 193 | if (!fi) |
| 194 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
| 196 | liu = le16_to_cpu(cfi->lengthOfImpUse); |
| 197 | lfi = cfi->lengthFileIdent; |
| 198 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 199 | if (fibh->sbh == fibh->ebh) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | nameptr = fi->fileIdent + liu; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 201 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | int poffset; /* Unpaded ending offset */ |
| 203 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 204 | poffset = fibh->soffset + sizeof(struct fileIdentDesc) + |
| 205 | liu + lfi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 207 | if (poffset >= lfi) |
| 208 | nameptr = (uint8_t *)(fibh->ebh->b_data + |
| 209 | poffset - lfi); |
| 210 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | nameptr = fname; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 212 | memcpy(nameptr, fi->fileIdent + liu, |
| 213 | lfi - poffset); |
| 214 | memcpy(nameptr + lfi - poffset, |
| 215 | fibh->ebh->b_data, poffset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 219 | if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { |
| 220 | if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | continue; |
| 222 | } |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 223 | |
| 224 | if ((cfi->fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) { |
| 225 | if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | continue; |
| 227 | } |
| 228 | |
| 229 | if (!lfi) |
| 230 | continue; |
| 231 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 232 | flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi); |
| 233 | if (flen && udf_match(flen, fname, dentry->d_name.len, |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 234 | dentry->d_name.name)) |
| 235 | goto out_ok; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | } |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 237 | |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 238 | out_err: |
| 239 | fi = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | if (fibh->sbh != fibh->ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 241 | brelse(fibh->ebh); |
| 242 | brelse(fibh->sbh); |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 243 | out_ok: |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 244 | brelse(epos.bh); |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 245 | kfree(fname); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 246 | |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 247 | return fi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 250 | static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, |
| 251 | struct nameidata *nd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | { |
| 253 | struct inode *inode = NULL; |
Jayachandran C | db9a369 | 2006-02-03 03:04:50 -0800 | [diff] [blame] | 254 | struct fileIdentDesc cfi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | struct udf_fileident_bh fibh; |
| 256 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 257 | if (dentry->d_name.len > UDF_NAME_LEN - 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | return ERR_PTR(-ENAMETOOLONG); |
| 259 | |
| 260 | lock_kernel(); |
| 261 | #ifdef UDF_RECOVERY |
| 262 | /* temporary shorthand for specifying files by inode number */ |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 263 | if (!strncmp(dentry->d_name.name, ".B=", 3)) { |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 264 | kernel_lb_addr lb = { |
| 265 | .logicalBlockNum = 0, |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 266 | .partitionReferenceNum = |
| 267 | simple_strtoul(dentry->d_name.name + 3, |
| 268 | NULL, 0), |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 269 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | inode = udf_iget(dir->i_sb, lb); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 271 | if (!inode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | unlock_kernel(); |
| 273 | return ERR_PTR(-EACCES); |
| 274 | } |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 275 | } else |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 276 | #endif /* UDF_RECOVERY */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 278 | if (udf_find_entry(dir, dentry, &fibh, &cfi)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 280 | brelse(fibh.ebh); |
| 281 | brelse(fibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
| 283 | inode = udf_iget(dir->i_sb, lelb_to_cpu(cfi.icb.extLocation)); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 284 | if (!inode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | unlock_kernel(); |
| 286 | return ERR_PTR(-EACCES); |
| 287 | } |
| 288 | } |
| 289 | unlock_kernel(); |
| 290 | d_add(dentry, inode); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 291 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | return NULL; |
| 293 | } |
| 294 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 295 | static struct fileIdentDesc *udf_add_entry(struct inode *dir, |
| 296 | struct dentry *dentry, |
| 297 | struct udf_fileident_bh *fibh, |
| 298 | struct fileIdentDesc *cfi, int *err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | { |
Marcin Slusarz | 6c79e98 | 2008-02-08 04:20:30 -0800 | [diff] [blame] | 300 | struct super_block *sb = dir->i_sb; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 301 | struct fileIdentDesc *fi = NULL; |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 302 | char *name = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | int namelen; |
| 304 | loff_t f_pos; |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 305 | loff_t size = udf_ext0_offset(dir) + dir->i_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | int nfidlen; |
| 307 | uint8_t lfi; |
| 308 | uint16_t liu; |
| 309 | int block; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 310 | kernel_lb_addr eloc; |
| 311 | uint32_t elen; |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 312 | sector_t offset; |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 313 | struct extent_position epos = {}; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 314 | struct udf_inode_info *dinfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 316 | fibh->sbh = fibh->ebh = NULL; |
| 317 | name = kmalloc(UDF_NAME_LEN, GFP_NOFS); |
| 318 | if (!name) { |
| 319 | *err = -ENOMEM; |
| 320 | goto out_err; |
| 321 | } |
| 322 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 323 | if (dentry) { |
| 324 | if (!dentry->d_name.len) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | *err = -EINVAL; |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 326 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | } |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 328 | namelen = udf_put_filename(sb, dentry->d_name.name, name, |
| 329 | dentry->d_name.len); |
| 330 | if (!namelen) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | *err = -ENAMETOOLONG; |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 332 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | } |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 334 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | namelen = 0; |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 336 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
| 338 | nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3; |
| 339 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 340 | f_pos = udf_ext0_offset(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 342 | fibh->soffset = fibh->eoffset = f_pos & (dir->i_sb->s_blocksize - 1); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 343 | dinfo = UDF_I(dir); |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 344 | if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { |
| 345 | if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits, &epos, |
| 346 | &eloc, &elen, &offset) != (EXT_RECORDED_ALLOCATED >> 30)) { |
| 347 | block = udf_get_lb_pblock(dir->i_sb, |
| 348 | dinfo->i_location, 0); |
| 349 | fibh->soffset = fibh->eoffset = sb->s_blocksize; |
| 350 | goto add; |
| 351 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 353 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 354 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 355 | epos.offset -= sizeof(short_ad); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 356 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 357 | epos.offset -= sizeof(long_ad); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 358 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | offset = 0; |
| 360 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 361 | fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block); |
| 362 | if (!fibh->sbh) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | *err = -EIO; |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 364 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 367 | block = dinfo->i_location.logicalBlockNum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 370 | while (f_pos < size) { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 371 | fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, |
| 372 | &elen, &offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 374 | if (!fi) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | *err = -EIO; |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 376 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | liu = le16_to_cpu(cfi->lengthOfImpUse); |
| 380 | lfi = cfi->lengthFileIdent; |
| 381 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 382 | if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 383 | if (((sizeof(struct fileIdentDesc) + |
| 384 | liu + lfi + 3) & ~3) == nfidlen) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | cfi->descTag.tagSerialNum = cpu_to_le16(1); |
| 386 | cfi->fileVersionNum = cpu_to_le16(1); |
| 387 | cfi->fileCharacteristics = 0; |
| 388 | cfi->lengthFileIdent = namelen; |
| 389 | cfi->lengthOfImpUse = cpu_to_le16(0); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 390 | if (!udf_write_fi(dir, cfi, fi, fibh, NULL, |
| 391 | name)) |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 392 | goto out_ok; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 393 | else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | *err = -EIO; |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 395 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | } |
| 397 | } |
| 398 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | } |
| 400 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 401 | add: |
Jan Kara | 05343c4 | 2008-02-08 04:20:51 -0800 | [diff] [blame] | 402 | if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { |
| 403 | elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1); |
| 404 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
| 405 | epos.offset -= sizeof(short_ad); |
| 406 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
| 407 | epos.offset -= sizeof(long_ad); |
| 408 | udf_write_aext(dir, &epos, eloc, elen, 1); |
| 409 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | f_pos += nfidlen; |
| 411 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 412 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 413 | sb->s_blocksize - fibh->eoffset < nfidlen) { |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 414 | brelse(epos.bh); |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 415 | epos.bh = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | fibh->soffset -= udf_ext0_offset(dir); |
| 417 | fibh->eoffset -= udf_ext0_offset(dir); |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 418 | f_pos -= udf_ext0_offset(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | if (fibh->sbh != fibh->ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 420 | brelse(fibh->ebh); |
| 421 | brelse(fibh->sbh); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 422 | fibh->sbh = fibh->ebh = |
| 423 | udf_expand_dir_adinicb(dir, &block, err); |
| 424 | if (!fibh->sbh) |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 425 | goto out_err; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 426 | epos.block = dinfo->i_location; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 427 | epos.offset = udf_file_entry_alloc_offset(dir); |
Jan Kara | 05343c4 | 2008-02-08 04:20:51 -0800 | [diff] [blame] | 428 | /* Load extent udf_expand_dir_adinicb() has created */ |
| 429 | udf_current_aext(dir, &epos, &eloc, &elen, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | } |
| 431 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 432 | if (sb->s_blocksize - fibh->eoffset >= nfidlen) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | fibh->soffset = fibh->eoffset; |
| 434 | fibh->eoffset += nfidlen; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 435 | if (fibh->sbh != fibh->ebh) { |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 436 | brelse(fibh->sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | fibh->sbh = fibh->ebh; |
| 438 | } |
| 439 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 440 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
| 441 | block = dinfo->i_location.logicalBlockNum; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 442 | fi = (struct fileIdentDesc *) |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 443 | (dinfo->i_ext.i_data + |
Marcin Slusarz | c0b3443 | 2008-02-08 04:20:42 -0800 | [diff] [blame] | 444 | fibh->soffset - |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 445 | udf_ext0_offset(dir) + |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 446 | dinfo->i_lenEAttr); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 447 | } else { |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 448 | block = eloc.logicalBlockNum + |
| 449 | ((elen - 1) >> |
| 450 | dir->i_sb->s_blocksize_bits); |
| 451 | fi = (struct fileIdentDesc *) |
| 452 | (fibh->sbh->b_data + fibh->soffset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | } |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 454 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | fibh->soffset = fibh->eoffset - sb->s_blocksize; |
| 456 | fibh->eoffset += nfidlen - sb->s_blocksize; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 457 | if (fibh->sbh != fibh->ebh) { |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 458 | brelse(fibh->sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | fibh->sbh = fibh->ebh; |
| 460 | } |
| 461 | |
| 462 | block = eloc.logicalBlockNum + ((elen - 1) >> |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 463 | dir->i_sb->s_blocksize_bits); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 464 | fibh->ebh = udf_bread(dir, |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 465 | f_pos >> dir->i_sb->s_blocksize_bits, 1, err); |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 466 | if (!fibh->ebh) |
| 467 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 469 | if (!fibh->soffset) { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 470 | if (udf_next_aext(dir, &epos, &eloc, &elen, 1) == |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 471 | (EXT_RECORDED_ALLOCATED >> 30)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | block = eloc.logicalBlockNum + ((elen - 1) >> |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 473 | dir->i_sb->s_blocksize_bits); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 474 | } else |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 475 | block++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 477 | brelse(fibh->sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | fibh->sbh = fibh->ebh; |
| 479 | fi = (struct fileIdentDesc *)(fibh->sbh->b_data); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 480 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | fi = (struct fileIdentDesc *) |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 482 | (fibh->sbh->b_data + sb->s_blocksize + |
| 483 | fibh->soffset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | } |
| 485 | } |
| 486 | |
| 487 | memset(cfi, 0, sizeof(struct fileIdentDesc)); |
Marcin Slusarz | 6c79e98 | 2008-02-08 04:20:30 -0800 | [diff] [blame] | 488 | if (UDF_SB(sb)->s_udfrev >= 0x0200) |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 489 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, |
| 490 | sizeof(tag)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | else |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 492 | udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, |
| 493 | sizeof(tag)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | cfi->fileVersionNum = cpu_to_le16(1); |
| 495 | cfi->lengthFileIdent = namelen; |
| 496 | cfi->lengthOfImpUse = cpu_to_le16(0); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 497 | if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | dir->i_size += nfidlen; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 499 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
| 500 | dinfo->i_lenAlloc += nfidlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | mark_inode_dirty(dir); |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 502 | goto out_ok; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 503 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | *err = -EIO; |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 505 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | } |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 507 | |
| 508 | out_err: |
| 509 | fi = NULL; |
| 510 | if (fibh->sbh != fibh->ebh) |
| 511 | brelse(fibh->ebh); |
| 512 | brelse(fibh->sbh); |
| 513 | out_ok: |
| 514 | brelse(epos.bh); |
| 515 | kfree(name); |
| 516 | return fi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | static int udf_delete_entry(struct inode *inode, struct fileIdentDesc *fi, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 520 | struct udf_fileident_bh *fibh, |
| 521 | struct fileIdentDesc *cfi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | { |
| 523 | cfi->fileCharacteristics |= FID_FILE_CHAR_DELETED; |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 524 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) |
| 526 | memset(&(cfi->icb), 0x00, sizeof(long_ad)); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 527 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL); |
| 529 | } |
| 530 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 531 | static int udf_create(struct inode *dir, struct dentry *dentry, int mode, |
| 532 | struct nameidata *nd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | { |
| 534 | struct udf_fileident_bh fibh; |
| 535 | struct inode *inode; |
| 536 | struct fileIdentDesc cfi, *fi; |
| 537 | int err; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 538 | struct udf_inode_info *iinfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | |
| 540 | lock_kernel(); |
| 541 | inode = udf_new_inode(dir, mode, &err); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 542 | if (!inode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | unlock_kernel(); |
| 544 | return err; |
| 545 | } |
| 546 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 547 | iinfo = UDF_I(inode); |
| 548 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | inode->i_data.a_ops = &udf_adinicb_aops; |
| 550 | else |
| 551 | inode->i_data.a_ops = &udf_aops; |
| 552 | inode->i_op = &udf_file_inode_operations; |
| 553 | inode->i_fop = &udf_file_operations; |
| 554 | inode->i_mode = mode; |
| 555 | mark_inode_dirty(inode); |
| 556 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 557 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
| 558 | if (!fi) { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 559 | inode->i_nlink--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | mark_inode_dirty(inode); |
| 561 | iput(inode); |
| 562 | unlock_kernel(); |
| 563 | return err; |
| 564 | } |
| 565 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 566 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 567 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 568 | cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
Marcin Slusarz | c0b3443 | 2008-02-08 04:20:42 -0800 | [diff] [blame] | 570 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | mark_inode_dirty(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 573 | brelse(fibh.ebh); |
| 574 | brelse(fibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | unlock_kernel(); |
| 576 | d_instantiate(dentry, inode); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 577 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | return 0; |
| 579 | } |
| 580 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 581 | static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, |
| 582 | dev_t rdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 584 | struct inode *inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | struct udf_fileident_bh fibh; |
| 586 | struct fileIdentDesc cfi, *fi; |
| 587 | int err; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 588 | struct udf_inode_info *iinfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | |
| 590 | if (!old_valid_dev(rdev)) |
| 591 | return -EINVAL; |
| 592 | |
| 593 | lock_kernel(); |
| 594 | err = -EIO; |
| 595 | inode = udf_new_inode(dir, mode, &err); |
| 596 | if (!inode) |
| 597 | goto out; |
| 598 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 599 | iinfo = UDF_I(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | inode->i_uid = current->fsuid; |
| 601 | init_special_inode(inode, mode, rdev); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 602 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
| 603 | if (!fi) { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 604 | inode->i_nlink--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | mark_inode_dirty(inode); |
| 606 | iput(inode); |
| 607 | unlock_kernel(); |
| 608 | return err; |
| 609 | } |
| 610 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 611 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 612 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 613 | cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
Marcin Slusarz | c0b3443 | 2008-02-08 04:20:42 -0800 | [diff] [blame] | 615 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | mark_inode_dirty(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | mark_inode_dirty(inode); |
| 618 | |
| 619 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 620 | brelse(fibh.ebh); |
| 621 | brelse(fibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | d_instantiate(dentry, inode); |
| 623 | err = 0; |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 624 | |
| 625 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | unlock_kernel(); |
| 627 | return err; |
| 628 | } |
| 629 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 630 | static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 632 | struct inode *inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | struct udf_fileident_bh fibh; |
| 634 | struct fileIdentDesc cfi, *fi; |
| 635 | int err; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 636 | struct udf_inode_info *dinfo = UDF_I(dir); |
| 637 | struct udf_inode_info *iinfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | |
| 639 | lock_kernel(); |
| 640 | err = -EMLINK; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 641 | if (dir->i_nlink >= (256 << sizeof(dir->i_nlink)) - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | goto out; |
| 643 | |
| 644 | err = -EIO; |
| 645 | inode = udf_new_inode(dir, S_IFDIR, &err); |
| 646 | if (!inode) |
| 647 | goto out; |
| 648 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 649 | iinfo = UDF_I(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | inode->i_op = &udf_dir_inode_operations; |
| 651 | inode->i_fop = &udf_dir_operations; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 652 | fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err); |
| 653 | if (!fi) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | inode->i_nlink--; |
| 655 | mark_inode_dirty(inode); |
| 656 | iput(inode); |
| 657 | goto out; |
| 658 | } |
| 659 | inode->i_nlink = 2; |
| 660 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 661 | cfi.icb.extLocation = cpu_to_lelb(dinfo->i_location); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 662 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 663 | cpu_to_le32(dinfo->i_unique & 0x00000000FFFFFFFFUL); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 664 | cfi.fileCharacteristics = |
| 665 | FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 667 | brelse(fibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | inode->i_mode = S_IFDIR | mode; |
| 669 | if (dir->i_mode & S_ISGID) |
| 670 | inode->i_mode |= S_ISGID; |
| 671 | mark_inode_dirty(inode); |
| 672 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 673 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
| 674 | if (!fi) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | inode->i_nlink = 0; |
| 676 | mark_inode_dirty(inode); |
| 677 | iput(inode); |
| 678 | goto out; |
| 679 | } |
| 680 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 681 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 682 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 683 | cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; |
| 685 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
Dave Hansen | d8c76e6 | 2006-09-30 23:29:04 -0700 | [diff] [blame] | 686 | inc_nlink(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | mark_inode_dirty(dir); |
| 688 | d_instantiate(dentry, inode); |
| 689 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 690 | brelse(fibh.ebh); |
| 691 | brelse(fibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | err = 0; |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 693 | |
| 694 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | unlock_kernel(); |
| 696 | return err; |
| 697 | } |
| 698 | |
| 699 | static int empty_dir(struct inode *dir) |
| 700 | { |
| 701 | struct fileIdentDesc *fi, cfi; |
| 702 | struct udf_fileident_bh fibh; |
| 703 | loff_t f_pos; |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 704 | loff_t size = udf_ext0_offset(dir) + dir->i_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | int block; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 706 | kernel_lb_addr eloc; |
| 707 | uint32_t elen; |
Jan Kara | 60448b1 | 2007-05-08 00:35:13 -0700 | [diff] [blame] | 708 | sector_t offset; |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 709 | struct extent_position epos = {}; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 710 | struct udf_inode_info *dinfo = UDF_I(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 712 | f_pos = udf_ext0_offset(dir); |
| 713 | fibh.soffset = fibh.eoffset = f_pos & (dir->i_sb->s_blocksize - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 715 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | fibh.sbh = fibh.ebh = NULL; |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 717 | else if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits, |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 718 | &epos, &eloc, &elen, &offset) == |
| 719 | (EXT_RECORDED_ALLOCATED >> 30)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 721 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 722 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 723 | epos.offset -= sizeof(short_ad); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 724 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 725 | epos.offset -= sizeof(long_ad); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 726 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | offset = 0; |
| 728 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 729 | fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block); |
| 730 | if (!fibh.sbh) { |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 731 | brelse(epos.bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | return 0; |
| 733 | } |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 734 | } else { |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 735 | brelse(epos.bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | return 0; |
| 737 | } |
| 738 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 739 | while (f_pos < size) { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 740 | fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc, |
| 741 | &elen, &offset); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 742 | if (!fi) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 744 | brelse(fibh.ebh); |
| 745 | brelse(fibh.sbh); |
| 746 | brelse(epos.bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | return 0; |
| 748 | } |
| 749 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 750 | if (cfi.lengthFileIdent && |
| 751 | (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 753 | brelse(fibh.ebh); |
| 754 | brelse(fibh.sbh); |
| 755 | brelse(epos.bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | return 0; |
| 757 | } |
| 758 | } |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 759 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 761 | brelse(fibh.ebh); |
| 762 | brelse(fibh.sbh); |
| 763 | brelse(epos.bh); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 764 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | return 1; |
| 766 | } |
| 767 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 768 | static int udf_rmdir(struct inode *dir, struct dentry *dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | { |
| 770 | int retval; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 771 | struct inode *inode = dentry->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | struct udf_fileident_bh fibh; |
| 773 | struct fileIdentDesc *fi, cfi; |
| 774 | kernel_lb_addr tloc; |
| 775 | |
| 776 | retval = -ENOENT; |
| 777 | lock_kernel(); |
| 778 | fi = udf_find_entry(dir, dentry, &fibh, &cfi); |
| 779 | if (!fi) |
| 780 | goto out; |
| 781 | |
| 782 | retval = -EIO; |
| 783 | tloc = lelb_to_cpu(cfi.icb.extLocation); |
| 784 | if (udf_get_lb_pblock(dir->i_sb, tloc, 0) != inode->i_ino) |
| 785 | goto end_rmdir; |
| 786 | retval = -ENOTEMPTY; |
| 787 | if (!empty_dir(inode)) |
| 788 | goto end_rmdir; |
| 789 | retval = udf_delete_entry(dir, fi, &fibh, &cfi); |
| 790 | if (retval) |
| 791 | goto end_rmdir; |
| 792 | if (inode->i_nlink != 2) |
| 793 | udf_warning(inode->i_sb, "udf_rmdir", |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 794 | "empty directory has nlink != 2 (%d)", |
| 795 | inode->i_nlink); |
Dave Hansen | ce71ec3 | 2006-09-30 23:29:06 -0700 | [diff] [blame] | 796 | clear_nlink(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | inode->i_size = 0; |
Stephen Mollett | c007c06 | 2007-05-08 00:31:31 -0700 | [diff] [blame] | 798 | inode_dec_link_count(dir); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 799 | inode->i_ctime = dir->i_ctime = dir->i_mtime = |
| 800 | current_fs_time(dir->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | mark_inode_dirty(dir); |
| 802 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 803 | end_rmdir: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 805 | brelse(fibh.ebh); |
| 806 | brelse(fibh.sbh); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 807 | |
| 808 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | unlock_kernel(); |
| 810 | return retval; |
| 811 | } |
| 812 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 813 | static int udf_unlink(struct inode *dir, struct dentry *dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | { |
| 815 | int retval; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 816 | struct inode *inode = dentry->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | struct udf_fileident_bh fibh; |
| 818 | struct fileIdentDesc *fi; |
| 819 | struct fileIdentDesc cfi; |
| 820 | kernel_lb_addr tloc; |
| 821 | |
| 822 | retval = -ENOENT; |
| 823 | lock_kernel(); |
| 824 | fi = udf_find_entry(dir, dentry, &fibh, &cfi); |
| 825 | if (!fi) |
| 826 | goto out; |
| 827 | |
| 828 | retval = -EIO; |
| 829 | tloc = lelb_to_cpu(cfi.icb.extLocation); |
| 830 | if (udf_get_lb_pblock(dir->i_sb, tloc, 0) != inode->i_ino) |
| 831 | goto end_unlink; |
| 832 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 833 | if (!inode->i_nlink) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | udf_debug("Deleting nonexistent file (%lu), %d\n", |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 835 | inode->i_ino, inode->i_nlink); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | inode->i_nlink = 1; |
| 837 | } |
| 838 | retval = udf_delete_entry(dir, fi, &fibh, &cfi); |
| 839 | if (retval) |
| 840 | goto end_unlink; |
| 841 | dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); |
| 842 | mark_inode_dirty(dir); |
Dave Hansen | 9a53c3a | 2006-09-30 23:29:03 -0700 | [diff] [blame] | 843 | inode_dec_link_count(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | inode->i_ctime = dir->i_ctime; |
| 845 | retval = 0; |
| 846 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 847 | end_unlink: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 849 | brelse(fibh.ebh); |
| 850 | brelse(fibh.sbh); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 851 | |
| 852 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 853 | unlock_kernel(); |
| 854 | return retval; |
| 855 | } |
| 856 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 857 | static int udf_symlink(struct inode *dir, struct dentry *dentry, |
| 858 | const char *symname) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 860 | struct inode *inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | struct pathComponent *pc; |
| 862 | char *compstart; |
| 863 | struct udf_fileident_bh fibh; |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 864 | struct extent_position epos = {}; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | int eoffset, elen = 0; |
| 866 | struct fileIdentDesc *fi; |
| 867 | struct fileIdentDesc cfi; |
| 868 | char *ea; |
| 869 | int err; |
| 870 | int block; |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 871 | char *name = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | int namelen; |
Marcin Slusarz | 6c79e98 | 2008-02-08 04:20:30 -0800 | [diff] [blame] | 873 | struct buffer_head *bh; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 874 | struct udf_inode_info *iinfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | |
| 876 | lock_kernel(); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 877 | inode = udf_new_inode(dir, S_IFLNK, &err); |
| 878 | if (!inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | goto out; |
| 880 | |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 881 | name = kmalloc(UDF_NAME_LEN, GFP_NOFS); |
| 882 | if (!name) { |
| 883 | err = -ENOMEM; |
| 884 | goto out_no_entry; |
| 885 | } |
| 886 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 887 | iinfo = UDF_I(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | inode->i_mode = S_IFLNK | S_IRWXUGO; |
| 889 | inode->i_data.a_ops = &udf_symlink_aops; |
| 890 | inode->i_op = &page_symlink_inode_operations; |
| 891 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 892 | if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 893 | kernel_lb_addr eloc; |
| 894 | uint32_t elen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | |
| 896 | block = udf_new_block(inode->i_sb, inode, |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 897 | iinfo->i_location.partitionReferenceNum, |
| 898 | iinfo->i_location.logicalBlockNum, &err); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | if (!block) |
| 900 | goto out_no_entry; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 901 | epos.block = iinfo->i_location; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 902 | epos.offset = udf_file_entry_alloc_offset(inode); |
| 903 | epos.bh = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | eloc.logicalBlockNum = block; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 905 | eloc.partitionReferenceNum = |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 906 | iinfo->i_location.partitionReferenceNum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | elen = inode->i_sb->s_blocksize; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 908 | iinfo->i_lenExtents = elen; |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 909 | udf_add_aext(inode, &epos, eloc, elen, 0); |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 910 | brelse(epos.bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | |
| 912 | block = udf_get_pblock(inode->i_sb, block, |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 913 | iinfo->i_location.partitionReferenceNum, |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 914 | 0); |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 915 | epos.bh = udf_tread(inode->i_sb, block); |
| 916 | lock_buffer(epos.bh); |
| 917 | memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); |
| 918 | set_buffer_uptodate(epos.bh); |
| 919 | unlock_buffer(epos.bh); |
| 920 | mark_buffer_dirty_inode(epos.bh, inode); |
| 921 | ea = epos.bh->b_data + udf_ext0_offset(inode); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 922 | } else |
| 923 | ea = iinfo->i_ext.i_data + iinfo->i_lenEAttr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | |
| 925 | eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode); |
| 926 | pc = (struct pathComponent *)ea; |
| 927 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 928 | if (*symname == '/') { |
| 929 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | symname++; |
| 931 | } while (*symname == '/'); |
| 932 | |
| 933 | pc->componentType = 1; |
| 934 | pc->lengthComponentIdent = 0; |
| 935 | pc->componentFileVersionNum = 0; |
| 936 | pc += sizeof(struct pathComponent); |
| 937 | elen += sizeof(struct pathComponent); |
| 938 | } |
| 939 | |
| 940 | err = -ENAMETOOLONG; |
| 941 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 942 | while (*symname) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | if (elen + sizeof(struct pathComponent) > eoffset) |
| 944 | goto out_no_entry; |
| 945 | |
| 946 | pc = (struct pathComponent *)(ea + elen); |
| 947 | |
| 948 | compstart = (char *)symname; |
| 949 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 950 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | symname++; |
| 952 | } while (*symname && *symname != '/'); |
| 953 | |
| 954 | pc->componentType = 5; |
| 955 | pc->lengthComponentIdent = 0; |
| 956 | pc->componentFileVersionNum = 0; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 957 | if (compstart[0] == '.') { |
| 958 | if ((symname - compstart) == 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | pc->componentType = 4; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 960 | else if ((symname - compstart) == 2 && |
| 961 | compstart[1] == '.') |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | pc->componentType = 3; |
| 963 | } |
| 964 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 965 | if (pc->componentType == 5) { |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 966 | namelen = udf_put_filename(inode->i_sb, compstart, name, |
| 967 | symname - compstart); |
| 968 | if (!namelen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | goto out_no_entry; |
| 970 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 971 | if (elen + sizeof(struct pathComponent) + namelen > |
| 972 | eoffset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | goto out_no_entry; |
| 974 | else |
| 975 | pc->lengthComponentIdent = namelen; |
| 976 | |
| 977 | memcpy(pc->componentIdent, name, namelen); |
| 978 | } |
| 979 | |
| 980 | elen += sizeof(struct pathComponent) + pc->lengthComponentIdent; |
| 981 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 982 | if (*symname) { |
| 983 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | symname++; |
| 985 | } while (*symname == '/'); |
| 986 | } |
| 987 | } |
| 988 | |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 989 | brelse(epos.bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | inode->i_size = elen; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 991 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
| 992 | iinfo->i_lenAlloc = inode->i_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | mark_inode_dirty(inode); |
| 994 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 995 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
| 996 | if (!fi) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | goto out_no_entry; |
| 998 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 999 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
Marcin Slusarz | 6c79e98 | 2008-02-08 04:20:30 -0800 | [diff] [blame] | 1000 | bh = UDF_SB(inode->i_sb)->s_lvid_bh; |
| 1001 | if (bh) { |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1002 | struct logicalVolIntegrityDesc *lvid = |
| 1003 | (struct logicalVolIntegrityDesc *)bh->b_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | struct logicalVolHeaderDesc *lvhd; |
| 1005 | uint64_t uniqueID; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1006 | lvhd = (struct logicalVolHeaderDesc *) |
| 1007 | lvid->logicalVolContentsUse; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | uniqueID = le64_to_cpu(lvhd->uniqueID); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 1009 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
| 1010 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
| 1012 | uniqueID += 16; |
| 1013 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
Marcin Slusarz | 6c79e98 | 2008-02-08 04:20:30 -0800 | [diff] [blame] | 1014 | mark_buffer_dirty(bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | } |
| 1016 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
Marcin Slusarz | c0b3443 | 2008-02-08 04:20:42 -0800 | [diff] [blame] | 1017 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | mark_inode_dirty(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1019 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 1020 | brelse(fibh.ebh); |
| 1021 | brelse(fibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | d_instantiate(dentry, inode); |
| 1023 | err = 0; |
| 1024 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 1025 | out: |
Jan Kara | b80697c | 2008-03-04 14:14:05 +0100 | [diff] [blame^] | 1026 | kfree(name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | unlock_kernel(); |
| 1028 | return err; |
| 1029 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 1030 | out_no_entry: |
Dave Hansen | 9a53c3a | 2006-09-30 23:29:03 -0700 | [diff] [blame] | 1031 | inode_dec_link_count(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | iput(inode); |
| 1033 | goto out; |
| 1034 | } |
| 1035 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1036 | static int udf_link(struct dentry *old_dentry, struct inode *dir, |
| 1037 | struct dentry *dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1038 | { |
| 1039 | struct inode *inode = old_dentry->d_inode; |
| 1040 | struct udf_fileident_bh fibh; |
| 1041 | struct fileIdentDesc cfi, *fi; |
| 1042 | int err; |
Marcin Slusarz | 6c79e98 | 2008-02-08 04:20:30 -0800 | [diff] [blame] | 1043 | struct buffer_head *bh; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | |
| 1045 | lock_kernel(); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1046 | if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | unlock_kernel(); |
| 1048 | return -EMLINK; |
| 1049 | } |
| 1050 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1051 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
| 1052 | if (!fi) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | unlock_kernel(); |
| 1054 | return err; |
| 1055 | } |
| 1056 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
Marcin Slusarz | c0b3443 | 2008-02-08 04:20:42 -0800 | [diff] [blame] | 1057 | cfi.icb.extLocation = cpu_to_lelb(UDF_I(inode)->i_location); |
Marcin Slusarz | 6c79e98 | 2008-02-08 04:20:30 -0800 | [diff] [blame] | 1058 | bh = UDF_SB(inode->i_sb)->s_lvid_bh; |
| 1059 | if (bh) { |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1060 | struct logicalVolIntegrityDesc *lvid = |
| 1061 | (struct logicalVolIntegrityDesc *)bh->b_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | struct logicalVolHeaderDesc *lvhd; |
| 1063 | uint64_t uniqueID; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1064 | lvhd = (struct logicalVolHeaderDesc *) |
| 1065 | (lvid->logicalVolContentsUse); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | uniqueID = le64_to_cpu(lvhd->uniqueID); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 1067 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
| 1068 | cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1069 | if (!(++uniqueID & 0x00000000FFFFFFFFUL)) |
| 1070 | uniqueID += 16; |
| 1071 | lvhd->uniqueID = cpu_to_le64(uniqueID); |
Marcin Slusarz | 6c79e98 | 2008-02-08 04:20:30 -0800 | [diff] [blame] | 1072 | mark_buffer_dirty(bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | } |
| 1074 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
Marcin Slusarz | c0b3443 | 2008-02-08 04:20:42 -0800 | [diff] [blame] | 1075 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | mark_inode_dirty(dir); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 1077 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | if (fibh.sbh != fibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 1079 | brelse(fibh.ebh); |
| 1080 | brelse(fibh.sbh); |
Dave Hansen | d8c76e6 | 2006-09-30 23:29:04 -0700 | [diff] [blame] | 1081 | inc_nlink(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1082 | inode->i_ctime = current_fs_time(inode->i_sb); |
| 1083 | mark_inode_dirty(inode); |
| 1084 | atomic_inc(&inode->i_count); |
| 1085 | d_instantiate(dentry, inode); |
| 1086 | unlock_kernel(); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 1087 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | return 0; |
| 1089 | } |
| 1090 | |
| 1091 | /* Anybody can rename anything with this: the permission checks are left to the |
| 1092 | * higher-level routines. |
| 1093 | */ |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1094 | static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 1095 | struct inode *new_dir, struct dentry *new_dentry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | { |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1097 | struct inode *old_inode = old_dentry->d_inode; |
| 1098 | struct inode *new_inode = new_dentry->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | struct udf_fileident_bh ofibh, nfibh; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1100 | struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = NULL; |
| 1101 | struct fileIdentDesc ocfi, ncfi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | struct buffer_head *dir_bh = NULL; |
| 1103 | int retval = -ENOENT; |
| 1104 | kernel_lb_addr tloc; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 1105 | struct udf_inode_info *old_iinfo = UDF_I(old_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1106 | |
| 1107 | lock_kernel(); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1108 | ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi); |
| 1109 | if (ofi) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | if (ofibh.sbh != ofibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 1111 | brelse(ofibh.ebh); |
| 1112 | brelse(ofibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | } |
| 1114 | tloc = lelb_to_cpu(ocfi.icb.extLocation); |
| 1115 | if (!ofi || udf_get_lb_pblock(old_dir->i_sb, tloc, 0) |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1116 | != old_inode->i_ino) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1117 | goto end_rename; |
| 1118 | |
| 1119 | nfi = udf_find_entry(new_dir, new_dentry, &nfibh, &ncfi); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1120 | if (nfi) { |
| 1121 | if (!new_inode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1122 | if (nfibh.sbh != nfibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 1123 | brelse(nfibh.ebh); |
| 1124 | brelse(nfibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | nfi = NULL; |
| 1126 | } |
| 1127 | } |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1128 | if (S_ISDIR(old_inode->i_mode)) { |
Marcin Slusarz | 7f3fbd0 | 2008-02-08 04:20:49 -0800 | [diff] [blame] | 1129 | int offset = udf_ext0_offset(old_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1131 | if (new_inode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | retval = -ENOTEMPTY; |
| 1133 | if (!empty_dir(new_inode)) |
| 1134 | goto end_rename; |
| 1135 | } |
| 1136 | retval = -EIO; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 1137 | if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1138 | dir_fi = udf_get_fileident( |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 1139 | old_iinfo->i_ext.i_data - |
| 1140 | (old_iinfo->i_efe ? |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1141 | sizeof(struct extendedFileEntry) : |
| 1142 | sizeof(struct fileEntry)), |
| 1143 | old_inode->i_sb->s_blocksize, &offset); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1144 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | dir_bh = udf_bread(old_inode, 0, 0, &retval); |
| 1146 | if (!dir_bh) |
| 1147 | goto end_rename; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1148 | dir_fi = udf_get_fileident(dir_bh->b_data, |
| 1149 | old_inode->i_sb->s_blocksize, &offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | } |
| 1151 | if (!dir_fi) |
| 1152 | goto end_rename; |
| 1153 | tloc = lelb_to_cpu(dir_fi->icb.extLocation); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1154 | if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) != |
| 1155 | old_dir->i_ino) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | goto end_rename; |
| 1157 | |
| 1158 | retval = -EMLINK; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1159 | if (!new_inode && |
| 1160 | new_dir->i_nlink >= |
| 1161 | (256 << sizeof(new_dir->i_nlink)) - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | goto end_rename; |
| 1163 | } |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1164 | if (!nfi) { |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1165 | nfi = udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, |
| 1166 | &retval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | if (!nfi) |
| 1168 | goto end_rename; |
| 1169 | } |
| 1170 | |
| 1171 | /* |
| 1172 | * Like most other Unix systems, set the ctime for inodes on a |
| 1173 | * rename. |
| 1174 | */ |
| 1175 | old_inode->i_ctime = current_fs_time(old_inode->i_sb); |
| 1176 | mark_inode_dirty(old_inode); |
| 1177 | |
| 1178 | /* |
| 1179 | * ok, that's it |
| 1180 | */ |
| 1181 | ncfi.fileVersionNum = ocfi.fileVersionNum; |
| 1182 | ncfi.fileCharacteristics = ocfi.fileCharacteristics; |
| 1183 | memcpy(&(ncfi.icb), &(ocfi.icb), sizeof(long_ad)); |
| 1184 | udf_write_fi(new_dir, &ncfi, nfi, &nfibh, NULL, NULL); |
| 1185 | |
| 1186 | /* The old fid may have moved - find it again */ |
| 1187 | ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi); |
| 1188 | udf_delete_entry(old_dir, ofi, &ofibh, &ocfi); |
| 1189 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1190 | if (new_inode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | new_inode->i_ctime = current_fs_time(new_inode->i_sb); |
Dave Hansen | 9a53c3a | 2006-09-30 23:29:03 -0700 | [diff] [blame] | 1192 | inode_dec_link_count(new_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | } |
| 1194 | old_dir->i_ctime = old_dir->i_mtime = current_fs_time(old_dir->i_sb); |
| 1195 | mark_inode_dirty(old_dir); |
| 1196 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1197 | if (dir_fi) { |
Marcin Slusarz | c0b3443 | 2008-02-08 04:20:42 -0800 | [diff] [blame] | 1198 | dir_fi->icb.extLocation = cpu_to_lelb(UDF_I(new_dir)->i_location); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1199 | udf_update_tag((char *)dir_fi, |
| 1200 | (sizeof(struct fileIdentDesc) + |
| 1201 | le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3); |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 1202 | if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | mark_inode_dirty(old_inode); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1204 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | mark_buffer_dirty_inode(dir_bh, old_inode); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1206 | |
Dave Hansen | 9a53c3a | 2006-09-30 23:29:03 -0700 | [diff] [blame] | 1207 | inode_dec_link_count(old_dir); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1208 | if (new_inode) |
Dave Hansen | 9a53c3a | 2006-09-30 23:29:03 -0700 | [diff] [blame] | 1209 | inode_dec_link_count(new_inode); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 1210 | else { |
Dave Hansen | d8c76e6 | 2006-09-30 23:29:04 -0700 | [diff] [blame] | 1211 | inc_nlink(new_dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1212 | mark_inode_dirty(new_dir); |
| 1213 | } |
| 1214 | } |
| 1215 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1216 | if (ofi) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | if (ofibh.sbh != ofibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 1218 | brelse(ofibh.ebh); |
| 1219 | brelse(ofibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | } |
| 1221 | |
| 1222 | retval = 0; |
| 1223 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 1224 | end_rename: |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 1225 | brelse(dir_bh); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 1226 | if (nfi) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | if (nfibh.sbh != nfibh.ebh) |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 1228 | brelse(nfibh.ebh); |
| 1229 | brelse(nfibh.sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1230 | } |
| 1231 | unlock_kernel(); |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 1232 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1233 | return retval; |
| 1234 | } |
| 1235 | |
Arjan van de Ven | c5ef1c4 | 2007-02-12 00:55:40 -0800 | [diff] [blame] | 1236 | const struct inode_operations udf_dir_inode_operations = { |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 1237 | .lookup = udf_lookup, |
| 1238 | .create = udf_create, |
| 1239 | .link = udf_link, |
| 1240 | .unlink = udf_unlink, |
| 1241 | .symlink = udf_symlink, |
| 1242 | .mkdir = udf_mkdir, |
| 1243 | .rmdir = udf_rmdir, |
| 1244 | .mknod = udf_mknod, |
| 1245 | .rename = udf_rename, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1246 | }; |