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