aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf/namei.c')
-rw-r--r--fs/udf/namei.c298
1 files changed, 179 insertions, 119 deletions
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 86033d92824c..a126950d79e6 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -43,7 +43,7 @@ static inline int udf_match(int len1, const char *name1, int len2,
43 43
44int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi, 44int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
45 struct fileIdentDesc *sfi, struct udf_fileident_bh *fibh, 45 struct fileIdentDesc *sfi, struct udf_fileident_bh *fibh,
46 uint8_t * impuse, uint8_t * fileident) 46 uint8_t *impuse, uint8_t *fileident)
47{ 47{
48 uint16_t crclen = fibh->eoffset - fibh->soffset - sizeof(tag); 48 uint16_t crclen = fibh->eoffset - fibh->soffset - sizeof(tag);
49 uint16_t crc; 49 uint16_t crc;
@@ -68,7 +68,8 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
68 memcpy(fibh->ebh->b_data + offset, impuse, liu); 68 memcpy(fibh->ebh->b_data + offset, impuse, liu);
69 } else { 69 } else {
70 memcpy((uint8_t *)sfi->impUse, impuse, -offset); 70 memcpy((uint8_t *)sfi->impUse, impuse, -offset);
71 memcpy(fibh->ebh->b_data, impuse - offset, liu + offset); 71 memcpy(fibh->ebh->b_data, impuse - offset,
72 liu + offset);
72 } 73 }
73 } 74 }
74 75
@@ -80,8 +81,10 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
80 } else if (offset >= 0) { 81 } else if (offset >= 0) {
81 memcpy(fibh->ebh->b_data + offset, fileident, lfi); 82 memcpy(fibh->ebh->b_data + offset, fileident, lfi);
82 } else { 83 } else {
83 memcpy((uint8_t *)sfi->fileIdent + liu, fileident, -offset); 84 memcpy((uint8_t *)sfi->fileIdent + liu, fileident,
84 memcpy(fibh->ebh->b_data, fileident - offset, lfi + offset); 85 -offset);
86 memcpy(fibh->ebh->b_data, fileident - offset,
87 lfi + offset);
85 } 88 }
86 } 89 }
87 90
@@ -101,13 +104,19 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
101 104
102 if (fibh->sbh == fibh->ebh) { 105 if (fibh->sbh == fibh->ebh) {
103 crc = udf_crc((uint8_t *)sfi->impUse, 106 crc = udf_crc((uint8_t *)sfi->impUse,
104 crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc); 107 crclen + sizeof(tag) -
108 sizeof(struct fileIdentDesc), crc);
105 } else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) { 109 } else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) {
106 crc = udf_crc(fibh->ebh->b_data + sizeof(struct fileIdentDesc) + fibh->soffset, 110 crc = udf_crc(fibh->ebh->b_data +
107 crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc); 111 sizeof(struct fileIdentDesc) +
112 fibh->soffset,
113 crclen + sizeof(tag) -
114 sizeof(struct fileIdentDesc),
115 crc);
108 } else { 116 } else {
109 crc = udf_crc((uint8_t *)sfi->impUse, 117 crc = udf_crc((uint8_t *)sfi->impUse,
110 -fibh->soffset - sizeof(struct fileIdentDesc), crc); 118 -fibh->soffset - sizeof(struct fileIdentDesc),
119 crc);
111 crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc); 120 crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc);
112 } 121 }
113 122
@@ -121,7 +130,8 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
121 130
122 cfi->descTag.tagChecksum = checksum; 131 cfi->descTag.tagChecksum = checksum;
123 if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) { 132 if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) {
124 memcpy((uint8_t *)sfi, (uint8_t *)cfi, sizeof(struct fileIdentDesc)); 133 memcpy((uint8_t *)sfi, (uint8_t *)cfi,
134 sizeof(struct fileIdentDesc));
125 } else { 135 } else {
126 memcpy((uint8_t *)sfi, (uint8_t *)cfi, -fibh->soffset); 136 memcpy((uint8_t *)sfi, (uint8_t *)cfi, -fibh->soffset);
127 memcpy(fibh->ebh->b_data, (uint8_t *)cfi - fibh->soffset, 137 memcpy(fibh->ebh->b_data, (uint8_t *)cfi - fibh->soffset,
@@ -159,22 +169,24 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
159 size = (udf_ext0_offset(dir) + dir->i_size) >> 2; 169 size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
160 f_pos = (udf_ext0_offset(dir) >> 2); 170 f_pos = (udf_ext0_offset(dir) >> 2);
161 171
162 fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; 172 fibh->soffset = fibh->eoffset =
163 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 173 (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
174 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
164 fibh->sbh = fibh->ebh = NULL; 175 fibh->sbh = fibh->ebh = NULL;
165 } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 176 else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
166 &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { 177 &epos, &eloc, &elen, &offset) ==
178 (EXT_RECORDED_ALLOCATED >> 30)) {
167 block = udf_get_lb_pblock(dir->i_sb, eloc, offset); 179 block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
168 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { 180 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
169 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) 181 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
170 epos.offset -= sizeof(short_ad); 182 epos.offset -= sizeof(short_ad);
171 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) 183 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
172 epos.offset -= sizeof(long_ad); 184 epos.offset -= sizeof(long_ad);
173 } else { 185 } else
174 offset = 0; 186 offset = 0;
175 }
176 187
177 if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { 188 fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block);
189 if (!fibh->sbh) {
178 brelse(epos.bh); 190 brelse(epos.bh);
179 return NULL; 191 return NULL;
180 } 192 }
@@ -202,14 +214,18 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
202 } else { 214 } else {
203 int poffset; /* Unpaded ending offset */ 215 int poffset; /* Unpaded ending offset */
204 216
205 poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi; 217 poffset = fibh->soffset + sizeof(struct fileIdentDesc) +
218 liu + lfi;
206 219
207 if (poffset >= lfi) { 220 if (poffset >= lfi)
208 nameptr = (uint8_t *)(fibh->ebh->b_data + poffset - lfi); 221 nameptr = (uint8_t *)(fibh->ebh->b_data +
209 } else { 222 poffset - lfi);
223 else {
210 nameptr = fname; 224 nameptr = fname;
211 memcpy(nameptr, fi->fileIdent + liu, lfi - poffset); 225 memcpy(nameptr, fi->fileIdent + liu,
212 memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset); 226 lfi - poffset);
227 memcpy(nameptr + lfi - poffset,
228 fibh->ebh->b_data, poffset);
213 } 229 }
214 } 230 }
215 231
@@ -226,11 +242,11 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
226 if (!lfi) 242 if (!lfi)
227 continue; 243 continue;
228 244
229 if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi))) { 245 flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi);
230 if (udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) { 246 if (flen && udf_match(flen, fname, dentry->d_name.len,
231 brelse(epos.bh); 247 dentry->d_name.name)) {
232 return fi; 248 brelse(epos.bh);
233 } 249 return fi;
234 } 250 }
235 } 251 }
236 252
@@ -291,16 +307,16 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
291 if (!strncmp(dentry->d_name.name, ".B=", 3)) { 307 if (!strncmp(dentry->d_name.name, ".B=", 3)) {
292 kernel_lb_addr lb = { 308 kernel_lb_addr lb = {
293 .logicalBlockNum = 0, 309 .logicalBlockNum = 0,
294 .partitionReferenceNum = simple_strtoul(dentry->d_name.name + 3, 310 .partitionReferenceNum =
295 NULL, 0), 311 simple_strtoul(dentry->d_name.name + 3,
312 NULL, 0),
296 }; 313 };
297 inode = udf_iget(dir->i_sb, lb); 314 inode = udf_iget(dir->i_sb, lb);
298 if (!inode) { 315 if (!inode) {
299 unlock_kernel(); 316 unlock_kernel();
300 return ERR_PTR(-EACCES); 317 return ERR_PTR(-EACCES);
301 } 318 }
302 } 319 } else
303 else
304#endif /* UDF_RECOVERY */ 320#endif /* UDF_RECOVERY */
305 321
306 if (udf_find_entry(dir, dentry, &fibh, &cfi)) { 322 if (udf_find_entry(dir, dentry, &fibh, &cfi)) {
@@ -347,8 +363,9 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
347 *err = -EINVAL; 363 *err = -EINVAL;
348 return NULL; 364 return NULL;
349 } 365 }
350 if (!(namelen = udf_put_filename(sb, dentry->d_name.name, name, 366 namelen = udf_put_filename(sb, dentry->d_name.name, name,
351 dentry->d_name.len))) { 367 dentry->d_name.len);
368 if (!namelen) {
352 *err = -ENAMETOOLONG; 369 *err = -ENAMETOOLONG;
353 return NULL; 370 return NULL;
354 } 371 }
@@ -360,22 +377,24 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
360 377
361 f_pos = (udf_ext0_offset(dir) >> 2); 378 f_pos = (udf_ext0_offset(dir) >> 2);
362 379
363 fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; 380 fibh->soffset = fibh->eoffset =
364 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 381 (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
382 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
365 fibh->sbh = fibh->ebh = NULL; 383 fibh->sbh = fibh->ebh = NULL;
366 } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 384 else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
367 &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { 385 &epos, &eloc, &elen, &offset) ==
386 (EXT_RECORDED_ALLOCATED >> 30)) {
368 block = udf_get_lb_pblock(dir->i_sb, eloc, offset); 387 block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
369 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { 388 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
370 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) 389 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
371 epos.offset -= sizeof(short_ad); 390 epos.offset -= sizeof(short_ad);
372 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) 391 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
373 epos.offset -= sizeof(long_ad); 392 epos.offset -= sizeof(long_ad);
374 } else { 393 } else
375 offset = 0; 394 offset = 0;
376 }
377 395
378 if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { 396 fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block);
397 if (!fibh->sbh) {
379 brelse(epos.bh); 398 brelse(epos.bh);
380 *err = -EIO; 399 *err = -EIO;
381 return NULL; 400 return NULL;
@@ -406,33 +425,39 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
406 liu = le16_to_cpu(cfi->lengthOfImpUse); 425 liu = le16_to_cpu(cfi->lengthOfImpUse);
407 lfi = cfi->lengthFileIdent; 426 lfi = cfi->lengthFileIdent;
408 427
409 if (fibh->sbh == fibh->ebh) { 428 if (fibh->sbh == fibh->ebh)
410 nameptr = fi->fileIdent + liu; 429 nameptr = fi->fileIdent + liu;
411 } else { 430 else {
412 int poffset; /* Unpaded ending offset */ 431 int poffset; /* Unpaded ending offset */
413 432
414 poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi; 433 poffset = fibh->soffset + sizeof(struct fileIdentDesc) +
434 liu + lfi;
415 435
416 if (poffset >= lfi) { 436 if (poffset >= lfi)
417 nameptr = (char *)(fibh->ebh->b_data + poffset - lfi); 437 nameptr = (char *)(fibh->ebh->b_data +
418 } else { 438 poffset - lfi);
439 else {
419 nameptr = fname; 440 nameptr = fname;
420 memcpy(nameptr, fi->fileIdent + liu, lfi - poffset); 441 memcpy(nameptr, fi->fileIdent + liu,
421 memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset); 442 lfi - poffset);
443 memcpy(nameptr + lfi - poffset,
444 fibh->ebh->b_data, poffset);
422 } 445 }
423 } 446 }
424 447
425 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { 448 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
426 if (((sizeof(struct fileIdentDesc) + liu + lfi + 3) & ~3) == nfidlen) { 449 if (((sizeof(struct fileIdentDesc) +
450 liu + lfi + 3) & ~3) == nfidlen) {
427 brelse(epos.bh); 451 brelse(epos.bh);
428 cfi->descTag.tagSerialNum = cpu_to_le16(1); 452 cfi->descTag.tagSerialNum = cpu_to_le16(1);
429 cfi->fileVersionNum = cpu_to_le16(1); 453 cfi->fileVersionNum = cpu_to_le16(1);
430 cfi->fileCharacteristics = 0; 454 cfi->fileCharacteristics = 0;
431 cfi->lengthFileIdent = namelen; 455 cfi->lengthFileIdent = namelen;
432 cfi->lengthOfImpUse = cpu_to_le16(0); 456 cfi->lengthOfImpUse = cpu_to_le16(0);
433 if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) { 457 if (!udf_write_fi(dir, cfi, fi, fibh, NULL,
458 name))
434 return fi; 459 return fi;
435 } else { 460 else {
436 *err = -EIO; 461 *err = -EIO;
437 return NULL; 462 return NULL;
438 } 463 }
@@ -442,8 +467,9 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
442 if (!lfi || !dentry) 467 if (!lfi || !dentry)
443 continue; 468 continue;
444 469
445 if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)) && 470 flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi);
446 udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) { 471 if (flen && udf_match(flen, fname, dentry->d_name.len,
472 dentry->d_name.name)) {
447 if (fibh->sbh != fibh->ebh) 473 if (fibh->sbh != fibh->ebh)
448 brelse(fibh->ebh); 474 brelse(fibh->ebh);
449 brelse(fibh->sbh); 475 brelse(fibh->sbh);
@@ -466,11 +492,14 @@ add:
466 if (fibh->sbh != fibh->ebh) 492 if (fibh->sbh != fibh->ebh)
467 brelse(fibh->ebh); 493 brelse(fibh->ebh);
468 brelse(fibh->sbh); 494 brelse(fibh->sbh);
469 if (!(fibh->sbh = fibh->ebh = udf_expand_dir_adinicb(dir, &block, err))) 495 fibh->sbh = fibh->ebh =
496 udf_expand_dir_adinicb(dir, &block, err);
497 if (!fibh->sbh)
470 return NULL; 498 return NULL;
471 epos.block = UDF_I_LOCATION(dir); 499 epos.block = UDF_I_LOCATION(dir);
472 eloc.logicalBlockNum = block; 500 eloc.logicalBlockNum = block;
473 eloc.partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; 501 eloc.partitionReferenceNum =
502 UDF_I_LOCATION(dir).partitionReferenceNum;
474 elen = dir->i_sb->s_blocksize; 503 elen = dir->i_sb->s_blocksize;
475 epos.offset = udf_file_entry_alloc_offset(dir); 504 epos.offset = udf_file_entry_alloc_offset(dir);
476 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) 505 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
@@ -489,13 +518,16 @@ add:
489 518
490 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 519 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
491 block = UDF_I_LOCATION(dir).logicalBlockNum; 520 block = UDF_I_LOCATION(dir).logicalBlockNum;
492 fi = (struct fileIdentDesc *)(UDF_I_DATA(dir) + fibh->soffset - 521 fi = (struct fileIdentDesc *)
493 udf_ext0_offset(dir) + 522 (UDF_I_DATA(dir) + fibh->soffset -
494 UDF_I_LENEATTR(dir)); 523 udf_ext0_offset(dir) +
524 UDF_I_LENEATTR(dir));
495 } else { 525 } else {
496 block = eloc.logicalBlockNum + ((elen - 1) >> 526 block = eloc.logicalBlockNum +
497 dir->i_sb->s_blocksize_bits); 527 ((elen - 1) >>
498 fi = (struct fileIdentDesc *)(fibh->sbh->b_data + fibh->soffset); 528 dir->i_sb->s_blocksize_bits);
529 fi = (struct fileIdentDesc *)
530 (fibh->sbh->b_data + fibh->soffset);
499 } 531 }
500 } else { 532 } else {
501 fibh->soffset = fibh->eoffset - sb->s_blocksize; 533 fibh->soffset = fibh->eoffset - sb->s_blocksize;
@@ -507,7 +539,9 @@ add:
507 539
508 block = eloc.logicalBlockNum + ((elen - 1) >> 540 block = eloc.logicalBlockNum + ((elen - 1) >>
509 dir->i_sb->s_blocksize_bits); 541 dir->i_sb->s_blocksize_bits);
510 fibh->ebh = udf_bread(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 1, err); 542 fibh->ebh = udf_bread(dir,
543 f_pos >> (dir->i_sb->s_blocksize_bits - 2),
544 1, err);
511 if (!fibh->ebh) { 545 if (!fibh->ebh) {
512 brelse(epos.bh); 546 brelse(epos.bh);
513 brelse(fibh->sbh); 547 brelse(fibh->sbh);
@@ -519,24 +553,26 @@ add:
519 (EXT_RECORDED_ALLOCATED >> 30)) { 553 (EXT_RECORDED_ALLOCATED >> 30)) {
520 block = eloc.logicalBlockNum + ((elen - 1) >> 554 block = eloc.logicalBlockNum + ((elen - 1) >>
521 dir->i_sb->s_blocksize_bits); 555 dir->i_sb->s_blocksize_bits);
522 } else { 556 } else
523 block++; 557 block++;
524 }
525 558
526 brelse(fibh->sbh); 559 brelse(fibh->sbh);
527 fibh->sbh = fibh->ebh; 560 fibh->sbh = fibh->ebh;
528 fi = (struct fileIdentDesc *)(fibh->sbh->b_data); 561 fi = (struct fileIdentDesc *)(fibh->sbh->b_data);
529 } else { 562 } else {
530 fi = (struct fileIdentDesc *) 563 fi = (struct fileIdentDesc *)
531 (fibh->sbh->b_data + sb->s_blocksize + fibh->soffset); 564 (fibh->sbh->b_data + sb->s_blocksize +
565 fibh->soffset);
532 } 566 }
533 } 567 }
534 568
535 memset(cfi, 0, sizeof(struct fileIdentDesc)); 569 memset(cfi, 0, sizeof(struct fileIdentDesc));
536 if (UDF_SB(sb)->s_udfrev >= 0x0200) 570 if (UDF_SB(sb)->s_udfrev >= 0x0200)
537 udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, sizeof(tag)); 571 udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block,
572 sizeof(tag));
538 else 573 else
539 udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, sizeof(tag)); 574 udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block,
575 sizeof(tag));
540 cfi->fileVersionNum = cpu_to_le16(1); 576 cfi->fileVersionNum = cpu_to_le16(1);
541 cfi->lengthFileIdent = namelen; 577 cfi->lengthFileIdent = namelen;
542 cfi->lengthOfImpUse = cpu_to_le16(0); 578 cfi->lengthOfImpUse = cpu_to_le16(0);
@@ -593,7 +629,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
593 inode->i_mode = mode; 629 inode->i_mode = mode;
594 mark_inode_dirty(inode); 630 mark_inode_dirty(inode);
595 631
596 if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) { 632 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
633 if (!fi) {
597 inode->i_nlink--; 634 inode->i_nlink--;
598 mark_inode_dirty(inode); 635 mark_inode_dirty(inode);
599 iput(inode); 636 iput(inode);
@@ -605,9 +642,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
605 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 642 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
606 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); 643 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
607 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); 644 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
608 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 645 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
609 mark_inode_dirty(dir); 646 mark_inode_dirty(dir);
610 }
611 if (fibh.sbh != fibh.ebh) 647 if (fibh.sbh != fibh.ebh)
612 brelse(fibh.ebh); 648 brelse(fibh.ebh);
613 brelse(fibh.sbh); 649 brelse(fibh.sbh);
@@ -636,7 +672,8 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
636 672
637 inode->i_uid = current->fsuid; 673 inode->i_uid = current->fsuid;
638 init_special_inode(inode, mode, rdev); 674 init_special_inode(inode, mode, rdev);
639 if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) { 675 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
676 if (!fi) {
640 inode->i_nlink--; 677 inode->i_nlink--;
641 mark_inode_dirty(inode); 678 mark_inode_dirty(inode);
642 iput(inode); 679 iput(inode);
@@ -648,9 +685,8 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
648 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 685 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
649 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); 686 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
650 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); 687 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
651 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 688 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
652 mark_inode_dirty(dir); 689 mark_inode_dirty(dir);
653 }
654 mark_inode_dirty(inode); 690 mark_inode_dirty(inode);
655 691
656 if (fibh.sbh != fibh.ebh) 692 if (fibh.sbh != fibh.ebh)
@@ -683,7 +719,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
683 719
684 inode->i_op = &udf_dir_inode_operations; 720 inode->i_op = &udf_dir_inode_operations;
685 inode->i_fop = &udf_dir_operations; 721 inode->i_fop = &udf_dir_operations;
686 if (!(fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err))) { 722 fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err);
723 if (!fi) {
687 inode->i_nlink--; 724 inode->i_nlink--;
688 mark_inode_dirty(inode); 725 mark_inode_dirty(inode);
689 iput(inode); 726 iput(inode);
@@ -694,7 +731,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
694 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir)); 731 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir));
695 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 732 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
696 cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL); 733 cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL);
697 cfi.fileCharacteristics = FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; 734 cfi.fileCharacteristics =
735 FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT;
698 udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); 736 udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL);
699 brelse(fibh.sbh); 737 brelse(fibh.sbh);
700 inode->i_mode = S_IFDIR | mode; 738 inode->i_mode = S_IFDIR | mode;
@@ -702,7 +740,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
702 inode->i_mode |= S_ISGID; 740 inode->i_mode |= S_ISGID;
703 mark_inode_dirty(inode); 741 mark_inode_dirty(inode);
704 742
705 if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) { 743 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
744 if (!fi) {
706 inode->i_nlink = 0; 745 inode->i_nlink = 0;
707 mark_inode_dirty(inode); 746 mark_inode_dirty(inode);
708 iput(inode); 747 iput(inode);
@@ -741,23 +780,25 @@ static int empty_dir(struct inode *dir)
741 780
742 f_pos = (udf_ext0_offset(dir) >> 2); 781 f_pos = (udf_ext0_offset(dir) >> 2);
743 782
744 fibh.soffset = fibh.eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; 783 fibh.soffset = fibh.eoffset =
784 (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
745 785
746 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 786 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
747 fibh.sbh = fibh.ebh = NULL; 787 fibh.sbh = fibh.ebh = NULL;
748 } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 788 else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
749 &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { 789 &epos, &eloc, &elen, &offset) ==
790 (EXT_RECORDED_ALLOCATED >> 30)) {
750 block = udf_get_lb_pblock(dir->i_sb, eloc, offset); 791 block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
751 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { 792 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
752 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) 793 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
753 epos.offset -= sizeof(short_ad); 794 epos.offset -= sizeof(short_ad);
754 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) 795 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
755 epos.offset -= sizeof(long_ad); 796 epos.offset -= sizeof(long_ad);
756 } else { 797 } else
757 offset = 0; 798 offset = 0;
758 }
759 799
760 if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { 800 fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block);
801 if (!fibh.sbh) {
761 brelse(epos.bh); 802 brelse(epos.bh);
762 return 0; 803 return 0;
763 } 804 }
@@ -826,7 +867,8 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
826 clear_nlink(inode); 867 clear_nlink(inode);
827 inode->i_size = 0; 868 inode->i_size = 0;
828 inode_dec_link_count(dir); 869 inode_dec_link_count(dir);
829 inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); 870 inode->i_ctime = dir->i_ctime = dir->i_mtime =
871 current_fs_time(dir->i_sb);
830 mark_inode_dirty(dir); 872 mark_inode_dirty(dir);
831 873
832end_rmdir: 874end_rmdir:
@@ -902,7 +944,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
902 struct buffer_head *bh; 944 struct buffer_head *bh;
903 945
904 lock_kernel(); 946 lock_kernel();
905 if (!(inode = udf_new_inode(dir, S_IFLNK, &err))) 947 inode = udf_new_inode(dir, S_IFLNK, &err);
948 if (!inode)
906 goto out; 949 goto out;
907 950
908 inode->i_mode = S_IFLNK | S_IRWXUGO; 951 inode->i_mode = S_IFLNK | S_IRWXUGO;
@@ -914,22 +957,24 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
914 uint32_t elen; 957 uint32_t elen;
915 958
916 block = udf_new_block(inode->i_sb, inode, 959 block = udf_new_block(inode->i_sb, inode,
917 UDF_I_LOCATION(inode).partitionReferenceNum, 960 UDF_I_LOCATION(inode).partitionReferenceNum,
918 UDF_I_LOCATION(inode).logicalBlockNum, &err); 961 UDF_I_LOCATION(inode).logicalBlockNum, &err);
919 if (!block) 962 if (!block)
920 goto out_no_entry; 963 goto out_no_entry;
921 epos.block = UDF_I_LOCATION(inode); 964 epos.block = UDF_I_LOCATION(inode);
922 epos.offset = udf_file_entry_alloc_offset(inode); 965 epos.offset = udf_file_entry_alloc_offset(inode);
923 epos.bh = NULL; 966 epos.bh = NULL;
924 eloc.logicalBlockNum = block; 967 eloc.logicalBlockNum = block;
925 eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; 968 eloc.partitionReferenceNum =
969 UDF_I_LOCATION(inode).partitionReferenceNum;
926 elen = inode->i_sb->s_blocksize; 970 elen = inode->i_sb->s_blocksize;
927 UDF_I_LENEXTENTS(inode) = elen; 971 UDF_I_LENEXTENTS(inode) = elen;
928 udf_add_aext(inode, &epos, eloc, elen, 0); 972 udf_add_aext(inode, &epos, eloc, elen, 0);
929 brelse(epos.bh); 973 brelse(epos.bh);
930 974
931 block = udf_get_pblock(inode->i_sb, block, 975 block = udf_get_pblock(inode->i_sb, block,
932 UDF_I_LOCATION(inode).partitionReferenceNum, 0); 976 UDF_I_LOCATION(inode).partitionReferenceNum,
977 0);
933 epos.bh = udf_tread(inode->i_sb, block); 978 epos.bh = udf_tread(inode->i_sb, block);
934 lock_buffer(epos.bh); 979 lock_buffer(epos.bh);
935 memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); 980 memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize);
@@ -976,7 +1021,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
976 if (compstart[0] == '.') { 1021 if (compstart[0] == '.') {
977 if ((symname - compstart) == 1) 1022 if ((symname - compstart) == 1)
978 pc->componentType = 4; 1023 pc->componentType = 4;
979 else if ((symname - compstart) == 2 && compstart[1] == '.') 1024 else if ((symname - compstart) == 2 &&
1025 compstart[1] == '.')
980 pc->componentType = 3; 1026 pc->componentType = 3;
981 } 1027 }
982 1028
@@ -986,7 +1032,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
986 if (!namelen) 1032 if (!namelen)
987 goto out_no_entry; 1033 goto out_no_entry;
988 1034
989 if (elen + sizeof(struct pathComponent) + namelen > eoffset) 1035 if (elen + sizeof(struct pathComponent) + namelen >
1036 eoffset)
990 goto out_no_entry; 1037 goto out_no_entry;
991 else 1038 else
992 pc->lengthComponentIdent = namelen; 1039 pc->lengthComponentIdent = namelen;
@@ -1009,16 +1056,19 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
1009 UDF_I_LENALLOC(inode) = inode->i_size; 1056 UDF_I_LENALLOC(inode) = inode->i_size;
1010 mark_inode_dirty(inode); 1057 mark_inode_dirty(inode);
1011 1058
1012 if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) 1059 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
1060 if (!fi)
1013 goto out_no_entry; 1061 goto out_no_entry;
1014 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); 1062 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
1015 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); 1063 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
1016 bh = UDF_SB(inode->i_sb)->s_lvid_bh; 1064 bh = UDF_SB(inode->i_sb)->s_lvid_bh;
1017 if (bh) { 1065 if (bh) {
1018 struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)bh->b_data; 1066 struct logicalVolIntegrityDesc *lvid =
1067 (struct logicalVolIntegrityDesc *)bh->b_data;
1019 struct logicalVolHeaderDesc *lvhd; 1068 struct logicalVolHeaderDesc *lvhd;
1020 uint64_t uniqueID; 1069 uint64_t uniqueID;
1021 lvhd = (struct logicalVolHeaderDesc *)(lvid->logicalVolContentsUse); 1070 lvhd = (struct logicalVolHeaderDesc *)
1071 lvid->logicalVolContentsUse;
1022 uniqueID = le64_to_cpu(lvhd->uniqueID); 1072 uniqueID = le64_to_cpu(lvhd->uniqueID);
1023 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 1073 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
1024 cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); 1074 cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
@@ -1028,9 +1078,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
1028 mark_buffer_dirty(bh); 1078 mark_buffer_dirty(bh);
1029 } 1079 }
1030 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); 1080 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
1031 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 1081 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
1032 mark_inode_dirty(dir); 1082 mark_inode_dirty(dir);
1033 }
1034 if (fibh.sbh != fibh.ebh) 1083 if (fibh.sbh != fibh.ebh)
1035 brelse(fibh.ebh); 1084 brelse(fibh.ebh);
1036 brelse(fibh.sbh); 1085 brelse(fibh.sbh);
@@ -1062,7 +1111,8 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
1062 return -EMLINK; 1111 return -EMLINK;
1063 } 1112 }
1064 1113
1065 if (!(fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err))) { 1114 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
1115 if (!fi) {
1066 unlock_kernel(); 1116 unlock_kernel();
1067 return err; 1117 return err;
1068 } 1118 }
@@ -1070,10 +1120,12 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
1070 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); 1120 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
1071 bh = UDF_SB(inode->i_sb)->s_lvid_bh; 1121 bh = UDF_SB(inode->i_sb)->s_lvid_bh;
1072 if (bh) { 1122 if (bh) {
1073 struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *)bh->b_data; 1123 struct logicalVolIntegrityDesc *lvid =
1124 (struct logicalVolIntegrityDesc *)bh->b_data;
1074 struct logicalVolHeaderDesc *lvhd; 1125 struct logicalVolHeaderDesc *lvhd;
1075 uint64_t uniqueID; 1126 uint64_t uniqueID;
1076 lvhd = (struct logicalVolHeaderDesc *)(lvid->logicalVolContentsUse); 1127 lvhd = (struct logicalVolHeaderDesc *)
1128 (lvid->logicalVolContentsUse);
1077 uniqueID = le64_to_cpu(lvhd->uniqueID); 1129 uniqueID = le64_to_cpu(lvhd->uniqueID);
1078 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 1130 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
1079 cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); 1131 cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
@@ -1083,9 +1135,8 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
1083 mark_buffer_dirty(bh); 1135 mark_buffer_dirty(bh);
1084 } 1136 }
1085 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); 1137 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
1086 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 1138 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
1087 mark_inode_dirty(dir); 1139 mark_inode_dirty(dir);
1088 }
1089 1140
1090 if (fibh.sbh != fibh.ebh) 1141 if (fibh.sbh != fibh.ebh)
1091 brelse(fibh.ebh); 1142 brelse(fibh.ebh);
@@ -1109,13 +1160,15 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1109 struct inode *old_inode = old_dentry->d_inode; 1160 struct inode *old_inode = old_dentry->d_inode;
1110 struct inode *new_inode = new_dentry->d_inode; 1161 struct inode *new_inode = new_dentry->d_inode;
1111 struct udf_fileident_bh ofibh, nfibh; 1162 struct udf_fileident_bh ofibh, nfibh;
1112 struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = NULL, ocfi, ncfi; 1163 struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = NULL;
1164 struct fileIdentDesc ocfi, ncfi;
1113 struct buffer_head *dir_bh = NULL; 1165 struct buffer_head *dir_bh = NULL;
1114 int retval = -ENOENT; 1166 int retval = -ENOENT;
1115 kernel_lb_addr tloc; 1167 kernel_lb_addr tloc;
1116 1168
1117 lock_kernel(); 1169 lock_kernel();
1118 if ((ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi))) { 1170 ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi);
1171 if (ofi) {
1119 if (ofibh.sbh != ofibh.ebh) 1172 if (ofibh.sbh != ofibh.ebh)
1120 brelse(ofibh.ebh); 1173 brelse(ofibh.ebh);
1121 brelse(ofibh.sbh); 1174 brelse(ofibh.sbh);
@@ -1144,29 +1197,35 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1144 } 1197 }
1145 retval = -EIO; 1198 retval = -EIO;
1146 if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { 1199 if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) {
1147 dir_fi = udf_get_fileident(UDF_I_DATA(old_inode) - 1200 dir_fi = udf_get_fileident(
1148 (UDF_I_EFE(old_inode) ? 1201 UDF_I_DATA(old_inode) -
1149 sizeof(struct extendedFileEntry) : 1202 (UDF_I_EFE(old_inode) ?
1150 sizeof(struct fileEntry)), 1203 sizeof(struct extendedFileEntry) :
1151 old_inode->i_sb->s_blocksize, &offset); 1204 sizeof(struct fileEntry)),
1205 old_inode->i_sb->s_blocksize, &offset);
1152 } else { 1206 } else {
1153 dir_bh = udf_bread(old_inode, 0, 0, &retval); 1207 dir_bh = udf_bread(old_inode, 0, 0, &retval);
1154 if (!dir_bh) 1208 if (!dir_bh)
1155 goto end_rename; 1209 goto end_rename;
1156 dir_fi = udf_get_fileident(dir_bh->b_data, old_inode->i_sb->s_blocksize, &offset); 1210 dir_fi = udf_get_fileident(dir_bh->b_data,
1211 old_inode->i_sb->s_blocksize, &offset);
1157 } 1212 }
1158 if (!dir_fi) 1213 if (!dir_fi)
1159 goto end_rename; 1214 goto end_rename;
1160 tloc = lelb_to_cpu(dir_fi->icb.extLocation); 1215 tloc = lelb_to_cpu(dir_fi->icb.extLocation);
1161 if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) != old_dir->i_ino) 1216 if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) !=
1217 old_dir->i_ino)
1162 goto end_rename; 1218 goto end_rename;
1163 1219
1164 retval = -EMLINK; 1220 retval = -EMLINK;
1165 if (!new_inode && new_dir->i_nlink >= (256 << sizeof(new_dir->i_nlink)) - 1) 1221 if (!new_inode &&
1222 new_dir->i_nlink >=
1223 (256 << sizeof(new_dir->i_nlink)) - 1)
1166 goto end_rename; 1224 goto end_rename;
1167 } 1225 }
1168 if (!nfi) { 1226 if (!nfi) {
1169 nfi = udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, &retval); 1227 nfi = udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi,
1228 &retval);
1170 if (!nfi) 1229 if (!nfi)
1171 goto end_rename; 1230 goto end_rename;
1172 } 1231 }
@@ -1199,17 +1258,18 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1199 1258
1200 if (dir_fi) { 1259 if (dir_fi) {
1201 dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir)); 1260 dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir));
1202 udf_update_tag((char *)dir_fi, (sizeof(struct fileIdentDesc) + 1261 udf_update_tag((char *)dir_fi,
1203 le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3); 1262 (sizeof(struct fileIdentDesc) +
1204 if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { 1263 le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3);
1264 if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB)
1205 mark_inode_dirty(old_inode); 1265 mark_inode_dirty(old_inode);
1206 } else { 1266 else
1207 mark_buffer_dirty_inode(dir_bh, old_inode); 1267 mark_buffer_dirty_inode(dir_bh, old_inode);
1208 } 1268
1209 inode_dec_link_count(old_dir); 1269 inode_dec_link_count(old_dir);
1210 if (new_inode) { 1270 if (new_inode)
1211 inode_dec_link_count(new_inode); 1271 inode_dec_link_count(new_inode);
1212 } else { 1272 else {
1213 inc_nlink(new_dir); 1273 inc_nlink(new_dir);
1214 mark_inode_dirty(new_dir); 1274 mark_inode_dirty(new_dir);
1215 } 1275 }