~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/udf/namei.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/udf/namei.c (Architecture i386) and /fs/udf/namei.c (Architecture sparc)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*                                                  2 /*
  3  * namei.c                                          3  * namei.c
  4  *                                                  4  *
  5  * PURPOSE                                          5  * PURPOSE
  6  *      Inode name handling routines for the O      6  *      Inode name handling routines for the OSTA-UDF(tm) filesystem.
  7  *                                                  7  *
  8  * COPYRIGHT                                        8  * COPYRIGHT
  9  *  (C) 1998-2004 Ben Fennema                       9  *  (C) 1998-2004 Ben Fennema
 10  *  (C) 1999-2000 Stelias Computing Inc            10  *  (C) 1999-2000 Stelias Computing Inc
 11  *                                                 11  *
 12  * HISTORY                                         12  * HISTORY
 13  *                                                 13  *
 14  *  12/12/98 blf  Created. Split out the looku     14  *  12/12/98 blf  Created. Split out the lookup code from dir.c
 15  *  04/19/99 blf  link, mknod, symlink support     15  *  04/19/99 blf  link, mknod, symlink support
 16  */                                                16  */
 17                                                    17 
 18 #include "udfdecl.h"                               18 #include "udfdecl.h"
 19                                                    19 
 20 #include "udf_i.h"                                 20 #include "udf_i.h"
 21 #include "udf_sb.h"                                21 #include "udf_sb.h"
 22 #include <linux/string.h>                          22 #include <linux/string.h>
 23 #include <linux/errno.h>                           23 #include <linux/errno.h>
 24 #include <linux/mm.h>                              24 #include <linux/mm.h>
 25 #include <linux/slab.h>                            25 #include <linux/slab.h>
 26 #include <linux/sched.h>                           26 #include <linux/sched.h>
 27 #include <linux/crc-itu-t.h>                       27 #include <linux/crc-itu-t.h>
 28 #include <linux/exportfs.h>                        28 #include <linux/exportfs.h>
 29 #include <linux/iversion.h>                        29 #include <linux/iversion.h>
 30                                                    30 
 31 static inline int udf_match(int len1, const un     31 static inline int udf_match(int len1, const unsigned char *name1, int len2,
 32                             const unsigned cha     32                             const unsigned char *name2)
 33 {                                                  33 {
 34         if (len1 != len2)                          34         if (len1 != len2)
 35                 return 0;                          35                 return 0;
 36                                                    36 
 37         return !memcmp(name1, name2, len1);        37         return !memcmp(name1, name2, len1);
 38 }                                                  38 }
 39                                                    39 
 40 /**                                                40 /**
 41  * udf_fiiter_find_entry - find entry in given     41  * udf_fiiter_find_entry - find entry in given directory.
 42  *                                                 42  *
 43  * @dir:        directory inode to search in       43  * @dir:        directory inode to search in
 44  * @child:      qstr of the name                   44  * @child:      qstr of the name
 45  * @iter:       iter to use for searching          45  * @iter:       iter to use for searching
 46  *                                                 46  *
 47  * This function searches in the directory @di     47  * This function searches in the directory @dir for a file name @child. When
 48  * found, @iter points to the position in the      48  * found, @iter points to the position in the directory with given entry.
 49  *                                                 49  *
 50  * Returns 0 on success, < 0 on error (includi     50  * Returns 0 on success, < 0 on error (including -ENOENT).
 51  */                                                51  */
 52 static int udf_fiiter_find_entry(struct inode      52 static int udf_fiiter_find_entry(struct inode *dir, const struct qstr *child,
 53                                  struct udf_fi     53                                  struct udf_fileident_iter *iter)
 54 {                                                  54 {
 55         int flen;                                  55         int flen;
 56         unsigned char *fname = NULL;               56         unsigned char *fname = NULL;
 57         struct super_block *sb = dir->i_sb;        57         struct super_block *sb = dir->i_sb;
 58         int isdotdot = child->len == 2 &&          58         int isdotdot = child->len == 2 &&
 59                 child->name[0] == '.' && child     59                 child->name[0] == '.' && child->name[1] == '.';
 60         int ret;                                   60         int ret;
 61                                                    61 
 62         fname = kmalloc(UDF_NAME_LEN, GFP_KERN     62         fname = kmalloc(UDF_NAME_LEN, GFP_KERNEL);
 63         if (!fname)                                63         if (!fname)
 64                 return -ENOMEM;                    64                 return -ENOMEM;
 65                                                    65 
 66         for (ret = udf_fiiter_init(iter, dir,      66         for (ret = udf_fiiter_init(iter, dir, 0);
 67              !ret && iter->pos < dir->i_size;      67              !ret && iter->pos < dir->i_size;
 68              ret = udf_fiiter_advance(iter)) {     68              ret = udf_fiiter_advance(iter)) {
 69                 if (iter->fi.fileCharacteristi     69                 if (iter->fi.fileCharacteristics & FID_FILE_CHAR_DELETED) {
 70                         if (!UDF_QUERY_FLAG(sb     70                         if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNDELETE))
 71                                 continue;          71                                 continue;
 72                 }                                  72                 }
 73                                                    73 
 74                 if (iter->fi.fileCharacteristi     74                 if (iter->fi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) {
 75                         if (!UDF_QUERY_FLAG(sb     75                         if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNHIDE))
 76                                 continue;          76                                 continue;
 77                 }                                  77                 }
 78                                                    78 
 79                 if ((iter->fi.fileCharacterist     79                 if ((iter->fi.fileCharacteristics & FID_FILE_CHAR_PARENT) &&
 80                     isdotdot)                      80                     isdotdot)
 81                         goto out_ok;               81                         goto out_ok;
 82                                                    82 
 83                 if (!iter->fi.lengthFileIdent)     83                 if (!iter->fi.lengthFileIdent)
 84                         continue;                  84                         continue;
 85                                                    85 
 86                 flen = udf_get_filename(sb, it     86                 flen = udf_get_filename(sb, iter->name,
 87                                 iter->fi.lengt     87                                 iter->fi.lengthFileIdent, fname, UDF_NAME_LEN);
 88                 if (flen < 0) {                    88                 if (flen < 0) {
 89                         ret = flen;                89                         ret = flen;
 90                         goto out_err;              90                         goto out_err;
 91                 }                                  91                 }
 92                                                    92 
 93                 if (udf_match(flen, fname, chi     93                 if (udf_match(flen, fname, child->len, child->name))
 94                         goto out_ok;               94                         goto out_ok;
 95         }                                          95         }
 96         if (!ret)                                  96         if (!ret)
 97                 ret = -ENOENT;                     97                 ret = -ENOENT;
 98                                                    98 
 99 out_err:                                           99 out_err:
100         udf_fiiter_release(iter);                 100         udf_fiiter_release(iter);
101 out_ok:                                           101 out_ok:
102         kfree(fname);                             102         kfree(fname);
103                                                   103 
104         return ret;                               104         return ret;
105 }                                                 105 }
106                                                   106 
107 static struct dentry *udf_lookup(struct inode     107 static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
108                                  unsigned int     108                                  unsigned int flags)
109 {                                                 109 {
110         struct inode *inode = NULL;               110         struct inode *inode = NULL;
111         struct udf_fileident_iter iter;           111         struct udf_fileident_iter iter;
112         int err;                                  112         int err;
113                                                   113 
114         if (dentry->d_name.len > UDF_NAME_LEN)    114         if (dentry->d_name.len > UDF_NAME_LEN)
115                 return ERR_PTR(-ENAMETOOLONG);    115                 return ERR_PTR(-ENAMETOOLONG);
116                                                   116 
117         err = udf_fiiter_find_entry(dir, &dent    117         err = udf_fiiter_find_entry(dir, &dentry->d_name, &iter);
118         if (err < 0 && err != -ENOENT)            118         if (err < 0 && err != -ENOENT)
119                 return ERR_PTR(err);              119                 return ERR_PTR(err);
120                                                   120 
121         if (err == 0) {                           121         if (err == 0) {
122                 struct kernel_lb_addr loc;        122                 struct kernel_lb_addr loc;
123                                                   123 
124                 loc = lelb_to_cpu(iter.fi.icb.    124                 loc = lelb_to_cpu(iter.fi.icb.extLocation);
125                 udf_fiiter_release(&iter);        125                 udf_fiiter_release(&iter);
126                                                   126 
127                 inode = udf_iget(dir->i_sb, &l    127                 inode = udf_iget(dir->i_sb, &loc);
128         }                                         128         }
129                                                   129 
130         return d_splice_alias(inode, dentry);     130         return d_splice_alias(inode, dentry);
131 }                                                 131 }
132                                                   132 
133 static int udf_expand_dir_adinicb(struct inode    133 static int udf_expand_dir_adinicb(struct inode *inode, udf_pblk_t *block)
134 {                                                 134 {
135         udf_pblk_t newblock;                      135         udf_pblk_t newblock;
136         struct buffer_head *dbh = NULL;           136         struct buffer_head *dbh = NULL;
137         struct kernel_lb_addr eloc;               137         struct kernel_lb_addr eloc;
138         struct extent_position epos;              138         struct extent_position epos;
139         uint8_t alloctype;                        139         uint8_t alloctype;
140         struct udf_inode_info *iinfo = UDF_I(i    140         struct udf_inode_info *iinfo = UDF_I(inode);
141         struct udf_fileident_iter iter;           141         struct udf_fileident_iter iter;
142         uint8_t *impuse;                          142         uint8_t *impuse;
143         int ret;                                  143         int ret;
144                                                   144 
145         if (UDF_QUERY_FLAG(inode->i_sb, UDF_FL    145         if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
146                 alloctype = ICBTAG_FLAG_AD_SHO    146                 alloctype = ICBTAG_FLAG_AD_SHORT;
147         else                                      147         else
148                 alloctype = ICBTAG_FLAG_AD_LON    148                 alloctype = ICBTAG_FLAG_AD_LONG;
149                                                   149 
150         if (!inode->i_size) {                     150         if (!inode->i_size) {
151                 iinfo->i_alloc_type = alloctyp    151                 iinfo->i_alloc_type = alloctype;
152                 mark_inode_dirty(inode);          152                 mark_inode_dirty(inode);
153                 return 0;                         153                 return 0;
154         }                                         154         }
155                                                   155 
156         /* alloc block, and copy data to it */    156         /* alloc block, and copy data to it */
157         *block = udf_new_block(inode->i_sb, in    157         *block = udf_new_block(inode->i_sb, inode,
158                                iinfo->i_locati    158                                iinfo->i_location.partitionReferenceNum,
159                                iinfo->i_locati    159                                iinfo->i_location.logicalBlockNum, &ret);
160         if (!(*block))                            160         if (!(*block))
161                 return ret;                       161                 return ret;
162         newblock = udf_get_pblock(inode->i_sb,    162         newblock = udf_get_pblock(inode->i_sb, *block,
163                                   iinfo->i_loc    163                                   iinfo->i_location.partitionReferenceNum,
164                                 0);               164                                 0);
165         if (newblock == 0xffffffff)               165         if (newblock == 0xffffffff)
166                 return -EFSCORRUPTED;             166                 return -EFSCORRUPTED;
167         dbh = sb_getblk(inode->i_sb, newblock)    167         dbh = sb_getblk(inode->i_sb, newblock);
168         if (!dbh)                                 168         if (!dbh)
169                 return -ENOMEM;                   169                 return -ENOMEM;
170         lock_buffer(dbh);                         170         lock_buffer(dbh);
171         memcpy(dbh->b_data, iinfo->i_data, ino    171         memcpy(dbh->b_data, iinfo->i_data, inode->i_size);
172         memset(dbh->b_data + inode->i_size, 0,    172         memset(dbh->b_data + inode->i_size, 0,
173                inode->i_sb->s_blocksize - inod    173                inode->i_sb->s_blocksize - inode->i_size);
174         set_buffer_uptodate(dbh);                 174         set_buffer_uptodate(dbh);
175         unlock_buffer(dbh);                       175         unlock_buffer(dbh);
176                                                   176 
177         /* Drop inline data, add block instead    177         /* Drop inline data, add block instead */
178         iinfo->i_alloc_type = alloctype;          178         iinfo->i_alloc_type = alloctype;
179         memset(iinfo->i_data + iinfo->i_lenEAt    179         memset(iinfo->i_data + iinfo->i_lenEAttr, 0, iinfo->i_lenAlloc);
180         iinfo->i_lenAlloc = 0;                    180         iinfo->i_lenAlloc = 0;
181         eloc.logicalBlockNum = *block;            181         eloc.logicalBlockNum = *block;
182         eloc.partitionReferenceNum =              182         eloc.partitionReferenceNum =
183                                 iinfo->i_locat    183                                 iinfo->i_location.partitionReferenceNum;
184         iinfo->i_lenExtents = inode->i_size;      184         iinfo->i_lenExtents = inode->i_size;
185         epos.bh = NULL;                           185         epos.bh = NULL;
186         epos.block = iinfo->i_location;           186         epos.block = iinfo->i_location;
187         epos.offset = udf_file_entry_alloc_off    187         epos.offset = udf_file_entry_alloc_offset(inode);
188         ret = udf_add_aext(inode, &epos, &eloc    188         ret = udf_add_aext(inode, &epos, &eloc, inode->i_size, 0);
189         brelse(epos.bh);                          189         brelse(epos.bh);
190         if (ret < 0) {                            190         if (ret < 0) {
191                 brelse(dbh);                      191                 brelse(dbh);
192                 udf_free_blocks(inode->i_sb, i    192                 udf_free_blocks(inode->i_sb, inode, &eloc, 0, 1);
193                 return ret;                       193                 return ret;
194         }                                         194         }
195         mark_inode_dirty(inode);                  195         mark_inode_dirty(inode);
196                                                   196 
197         /* Now fixup tags in moved directory e    197         /* Now fixup tags in moved directory entries */
198         for (ret = udf_fiiter_init(&iter, inod    198         for (ret = udf_fiiter_init(&iter, inode, 0);
199              !ret && iter.pos < inode->i_size;    199              !ret && iter.pos < inode->i_size;
200              ret = udf_fiiter_advance(&iter))     200              ret = udf_fiiter_advance(&iter)) {
201                 iter.fi.descTag.tagLocation =     201                 iter.fi.descTag.tagLocation = cpu_to_le32(*block);
202                 if (iter.fi.lengthOfImpUse !=     202                 if (iter.fi.lengthOfImpUse != cpu_to_le16(0))
203                         impuse = dbh->b_data +    203                         impuse = dbh->b_data + iter.pos +
204                                                   204                                                 sizeof(struct fileIdentDesc);
205                 else                              205                 else
206                         impuse = NULL;            206                         impuse = NULL;
207                 udf_fiiter_write_fi(&iter, imp    207                 udf_fiiter_write_fi(&iter, impuse);
208         }                                         208         }
209         brelse(dbh);                              209         brelse(dbh);
210         /*                                        210         /*
211          * We don't expect the iteration to fa    211          * We don't expect the iteration to fail as the directory has been
212          * already verified to be correct         212          * already verified to be correct
213          */                                       213          */
214         WARN_ON_ONCE(ret);                        214         WARN_ON_ONCE(ret);
215         udf_fiiter_release(&iter);                215         udf_fiiter_release(&iter);
216                                                   216 
217         return 0;                                 217         return 0;
218 }                                                 218 }
219                                                   219 
220 static int udf_fiiter_add_entry(struct inode *    220 static int udf_fiiter_add_entry(struct inode *dir, struct dentry *dentry,
221                                 struct udf_fil    221                                 struct udf_fileident_iter *iter)
222 {                                                 222 {
223         struct udf_inode_info *dinfo = UDF_I(d    223         struct udf_inode_info *dinfo = UDF_I(dir);
224         int nfidlen, namelen = 0;                 224         int nfidlen, namelen = 0;
225         int ret;                                  225         int ret;
226         int off, blksize = 1 << dir->i_blkbits    226         int off, blksize = 1 << dir->i_blkbits;
227         udf_pblk_t block;                         227         udf_pblk_t block;
228         char name[UDF_NAME_LEN_CS0];              228         char name[UDF_NAME_LEN_CS0];
229                                                   229 
230         if (dentry) {                             230         if (dentry) {
231                 namelen = udf_put_filename(dir    231                 namelen = udf_put_filename(dir->i_sb, dentry->d_name.name,
232                                            den    232                                            dentry->d_name.len,
233                                            nam    233                                            name, UDF_NAME_LEN_CS0);
234                 if (!namelen)                     234                 if (!namelen)
235                         return -ENAMETOOLONG;     235                         return -ENAMETOOLONG;
236         }                                         236         }
237         nfidlen = ALIGN(sizeof(struct fileIden    237         nfidlen = ALIGN(sizeof(struct fileIdentDesc) + namelen, UDF_NAME_PAD);
238                                                   238 
239         for (ret = udf_fiiter_init(iter, dir,     239         for (ret = udf_fiiter_init(iter, dir, 0);
240              !ret && iter->pos < dir->i_size;     240              !ret && iter->pos < dir->i_size;
241              ret = udf_fiiter_advance(iter)) {    241              ret = udf_fiiter_advance(iter)) {
242                 if (iter->fi.fileCharacteristi    242                 if (iter->fi.fileCharacteristics & FID_FILE_CHAR_DELETED) {
243                         if (udf_dir_entry_len(    243                         if (udf_dir_entry_len(&iter->fi) == nfidlen) {
244                                 iter->fi.descT    244                                 iter->fi.descTag.tagSerialNum = cpu_to_le16(1);
245                                 iter->fi.fileV    245                                 iter->fi.fileVersionNum = cpu_to_le16(1);
246                                 iter->fi.fileC    246                                 iter->fi.fileCharacteristics = 0;
247                                 iter->fi.lengt    247                                 iter->fi.lengthFileIdent = namelen;
248                                 iter->fi.lengt    248                                 iter->fi.lengthOfImpUse = cpu_to_le16(0);
249                                 memcpy(iter->n    249                                 memcpy(iter->namebuf, name, namelen);
250                                 iter->name = i    250                                 iter->name = iter->namebuf;
251                                 return 0;         251                                 return 0;
252                         }                         252                         }
253                 }                                 253                 }
254         }                                         254         }
255         if (ret) {                                255         if (ret) {
256                 udf_fiiter_release(iter);         256                 udf_fiiter_release(iter);
257                 return ret;                       257                 return ret;
258         }                                         258         }
259         if (dinfo->i_alloc_type == ICBTAG_FLAG    259         if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB &&
260             blksize - udf_ext0_offset(dir) - i    260             blksize - udf_ext0_offset(dir) - iter->pos < nfidlen) {
261                 udf_fiiter_release(iter);         261                 udf_fiiter_release(iter);
262                 ret = udf_expand_dir_adinicb(d    262                 ret = udf_expand_dir_adinicb(dir, &block);
263                 if (ret)                          263                 if (ret)
264                         return ret;               264                         return ret;
265                 ret = udf_fiiter_init(iter, di    265                 ret = udf_fiiter_init(iter, dir, dir->i_size);
266                 if (ret < 0)                      266                 if (ret < 0)
267                         return ret;               267                         return ret;
268         }                                         268         }
269                                                   269 
270         /* Get blocknumber to use for entry ta    270         /* Get blocknumber to use for entry tag */
271         if (dinfo->i_alloc_type == ICBTAG_FLAG    271         if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
272                 block = dinfo->i_location.logi    272                 block = dinfo->i_location.logicalBlockNum;
273         } else {                                  273         } else {
274                 block = iter->eloc.logicalBloc    274                 block = iter->eloc.logicalBlockNum +
275                                 ((iter->elen -    275                                 ((iter->elen - 1) >> dir->i_blkbits);
276         }                                         276         }
277         off = iter->pos & (blksize - 1);          277         off = iter->pos & (blksize - 1);
278         if (!off)                                 278         if (!off)
279                 off = blksize;                    279                 off = blksize;
280         /* Entry fits into current block? */      280         /* Entry fits into current block? */
281         if (blksize - udf_ext0_offset(dir) - o    281         if (blksize - udf_ext0_offset(dir) - off >= nfidlen)
282                 goto store_fi;                    282                 goto store_fi;
283                                                   283 
284         ret = udf_fiiter_append_blk(iter);        284         ret = udf_fiiter_append_blk(iter);
285         if (ret) {                                285         if (ret) {
286                 udf_fiiter_release(iter);         286                 udf_fiiter_release(iter);
287                 return ret;                       287                 return ret;
288         }                                         288         }
289                                                   289 
290         /* Entry will be completely in the new    290         /* Entry will be completely in the new block? Update tag location... */
291         if (!(iter->pos & (blksize - 1)))         291         if (!(iter->pos & (blksize - 1)))
292                 block = iter->eloc.logicalBloc    292                 block = iter->eloc.logicalBlockNum +
293                                 ((iter->elen -    293                                 ((iter->elen - 1) >> dir->i_blkbits);
294 store_fi:                                         294 store_fi:
295         memset(&iter->fi, 0, sizeof(struct fil    295         memset(&iter->fi, 0, sizeof(struct fileIdentDesc));
296         if (UDF_SB(dir->i_sb)->s_udfrev >= 0x0    296         if (UDF_SB(dir->i_sb)->s_udfrev >= 0x0200)
297                 udf_new_tag((char *)(&iter->fi    297                 udf_new_tag((char *)(&iter->fi), TAG_IDENT_FID, 3, 1, block,
298                             sizeof(struct tag)    298                             sizeof(struct tag));
299         else                                      299         else
300                 udf_new_tag((char *)(&iter->fi    300                 udf_new_tag((char *)(&iter->fi), TAG_IDENT_FID, 2, 1, block,
301                             sizeof(struct tag)    301                             sizeof(struct tag));
302         iter->fi.fileVersionNum = cpu_to_le16(    302         iter->fi.fileVersionNum = cpu_to_le16(1);
303         iter->fi.lengthFileIdent = namelen;       303         iter->fi.lengthFileIdent = namelen;
304         iter->fi.lengthOfImpUse = cpu_to_le16(    304         iter->fi.lengthOfImpUse = cpu_to_le16(0);
305         memcpy(iter->namebuf, name, namelen);     305         memcpy(iter->namebuf, name, namelen);
306         iter->name = iter->namebuf;               306         iter->name = iter->namebuf;
307                                                   307 
308         dir->i_size += nfidlen;                   308         dir->i_size += nfidlen;
309         if (dinfo->i_alloc_type == ICBTAG_FLAG    309         if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
310                 dinfo->i_lenAlloc += nfidlen;     310                 dinfo->i_lenAlloc += nfidlen;
311         } else {                                  311         } else {
312                 /* Truncate last extent to pro    312                 /* Truncate last extent to proper size */
313                 udf_fiiter_update_elen(iter, i    313                 udf_fiiter_update_elen(iter, iter->elen -
314                                         (dinfo    314                                         (dinfo->i_lenExtents - dir->i_size));
315         }                                         315         }
316         mark_inode_dirty(dir);                    316         mark_inode_dirty(dir);
317                                                   317 
318         return 0;                                 318         return 0;
319 }                                                 319 }
320                                                   320 
321 static void udf_fiiter_delete_entry(struct udf    321 static void udf_fiiter_delete_entry(struct udf_fileident_iter *iter)
322 {                                                 322 {
323         iter->fi.fileCharacteristics |= FID_FI    323         iter->fi.fileCharacteristics |= FID_FILE_CHAR_DELETED;
324                                                   324 
325         if (UDF_QUERY_FLAG(iter->dir->i_sb, UD    325         if (UDF_QUERY_FLAG(iter->dir->i_sb, UDF_FLAG_STRICT))
326                 memset(&iter->fi.icb, 0x00, si    326                 memset(&iter->fi.icb, 0x00, sizeof(struct long_ad));
327                                                   327 
328         udf_fiiter_write_fi(iter, NULL);          328         udf_fiiter_write_fi(iter, NULL);
329 }                                                 329 }
330                                                   330 
331 static void udf_add_fid_counter(struct super_b    331 static void udf_add_fid_counter(struct super_block *sb, bool dir, int val)
332 {                                                 332 {
333         struct logicalVolIntegrityDescImpUse *    333         struct logicalVolIntegrityDescImpUse *lvidiu = udf_sb_lvidiu(sb);
334                                                   334 
335         if (!lvidiu)                              335         if (!lvidiu)
336                 return;                           336                 return;
337         mutex_lock(&UDF_SB(sb)->s_alloc_mutex)    337         mutex_lock(&UDF_SB(sb)->s_alloc_mutex);
338         if (dir)                                  338         if (dir)
339                 le32_add_cpu(&lvidiu->numDirs,    339                 le32_add_cpu(&lvidiu->numDirs, val);
340         else                                      340         else
341                 le32_add_cpu(&lvidiu->numFiles    341                 le32_add_cpu(&lvidiu->numFiles, val);
342         udf_updated_lvid(sb);                     342         udf_updated_lvid(sb);
343         mutex_unlock(&UDF_SB(sb)->s_alloc_mute    343         mutex_unlock(&UDF_SB(sb)->s_alloc_mutex);
344 }                                                 344 }
345                                                   345 
346 static int udf_add_nondir(struct dentry *dentr    346 static int udf_add_nondir(struct dentry *dentry, struct inode *inode)
347 {                                                 347 {
348         struct udf_inode_info *iinfo = UDF_I(i    348         struct udf_inode_info *iinfo = UDF_I(inode);
349         struct inode *dir = d_inode(dentry->d_    349         struct inode *dir = d_inode(dentry->d_parent);
350         struct udf_fileident_iter iter;           350         struct udf_fileident_iter iter;
351         int err;                                  351         int err;
352                                                   352 
353         err = udf_fiiter_add_entry(dir, dentry    353         err = udf_fiiter_add_entry(dir, dentry, &iter);
354         if (err) {                                354         if (err) {
355                 inode_dec_link_count(inode);      355                 inode_dec_link_count(inode);
356                 discard_new_inode(inode);         356                 discard_new_inode(inode);
357                 return err;                       357                 return err;
358         }                                         358         }
359         iter.fi.icb.extLength = cpu_to_le32(in    359         iter.fi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
360         iter.fi.icb.extLocation = cpu_to_lelb(    360         iter.fi.icb.extLocation = cpu_to_lelb(iinfo->i_location);
361         *(__le32 *)((struct allocDescImpUse *)    361         *(__le32 *)((struct allocDescImpUse *)iter.fi.icb.impUse)->impUse =
362                 cpu_to_le32(iinfo->i_unique &     362                 cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL);
363         udf_fiiter_write_fi(&iter, NULL);         363         udf_fiiter_write_fi(&iter, NULL);
364         inode_set_mtime_to_ts(dir, inode_set_c    364         inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
365         mark_inode_dirty(dir);                    365         mark_inode_dirty(dir);
366         udf_fiiter_release(&iter);                366         udf_fiiter_release(&iter);
367         udf_add_fid_counter(dir->i_sb, false,     367         udf_add_fid_counter(dir->i_sb, false, 1);
368         d_instantiate_new(dentry, inode);         368         d_instantiate_new(dentry, inode);
369                                                   369 
370         return 0;                                 370         return 0;
371 }                                                 371 }
372                                                   372 
373 static int udf_create(struct mnt_idmap *idmap,    373 static int udf_create(struct mnt_idmap *idmap, struct inode *dir,
374                       struct dentry *dentry, u    374                       struct dentry *dentry, umode_t mode, bool excl)
375 {                                                 375 {
376         struct inode *inode = udf_new_inode(di    376         struct inode *inode = udf_new_inode(dir, mode);
377                                                   377 
378         if (IS_ERR(inode))                        378         if (IS_ERR(inode))
379                 return PTR_ERR(inode);            379                 return PTR_ERR(inode);
380                                                   380 
381         inode->i_data.a_ops = &udf_aops;          381         inode->i_data.a_ops = &udf_aops;
382         inode->i_op = &udf_file_inode_operatio    382         inode->i_op = &udf_file_inode_operations;
383         inode->i_fop = &udf_file_operations;      383         inode->i_fop = &udf_file_operations;
384         mark_inode_dirty(inode);                  384         mark_inode_dirty(inode);
385                                                   385 
386         return udf_add_nondir(dentry, inode);     386         return udf_add_nondir(dentry, inode);
387 }                                                 387 }
388                                                   388 
389 static int udf_tmpfile(struct mnt_idmap *idmap    389 static int udf_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
390                        struct file *file, umod    390                        struct file *file, umode_t mode)
391 {                                                 391 {
392         struct inode *inode = udf_new_inode(di    392         struct inode *inode = udf_new_inode(dir, mode);
393                                                   393 
394         if (IS_ERR(inode))                        394         if (IS_ERR(inode))
395                 return PTR_ERR(inode);            395                 return PTR_ERR(inode);
396                                                   396 
397         inode->i_data.a_ops = &udf_aops;          397         inode->i_data.a_ops = &udf_aops;
398         inode->i_op = &udf_file_inode_operatio    398         inode->i_op = &udf_file_inode_operations;
399         inode->i_fop = &udf_file_operations;      399         inode->i_fop = &udf_file_operations;
400         mark_inode_dirty(inode);                  400         mark_inode_dirty(inode);
401         d_tmpfile(file, inode);                   401         d_tmpfile(file, inode);
402         unlock_new_inode(inode);                  402         unlock_new_inode(inode);
403         return finish_open_simple(file, 0);       403         return finish_open_simple(file, 0);
404 }                                                 404 }
405                                                   405 
406 static int udf_mknod(struct mnt_idmap *idmap,     406 static int udf_mknod(struct mnt_idmap *idmap, struct inode *dir,
407                      struct dentry *dentry, um    407                      struct dentry *dentry, umode_t mode, dev_t rdev)
408 {                                                 408 {
409         struct inode *inode;                      409         struct inode *inode;
410                                                   410 
411         if (!old_valid_dev(rdev))                 411         if (!old_valid_dev(rdev))
412                 return -EINVAL;                   412                 return -EINVAL;
413                                                   413 
414         inode = udf_new_inode(dir, mode);         414         inode = udf_new_inode(dir, mode);
415         if (IS_ERR(inode))                        415         if (IS_ERR(inode))
416                 return PTR_ERR(inode);            416                 return PTR_ERR(inode);
417                                                   417 
418         init_special_inode(inode, mode, rdev);    418         init_special_inode(inode, mode, rdev);
419         return udf_add_nondir(dentry, inode);     419         return udf_add_nondir(dentry, inode);
420 }                                                 420 }
421                                                   421 
422 static int udf_mkdir(struct mnt_idmap *idmap,     422 static int udf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
423                      struct dentry *dentry, um    423                      struct dentry *dentry, umode_t mode)
424 {                                                 424 {
425         struct inode *inode;                      425         struct inode *inode;
426         struct udf_fileident_iter iter;           426         struct udf_fileident_iter iter;
427         int err;                                  427         int err;
428         struct udf_inode_info *dinfo = UDF_I(d    428         struct udf_inode_info *dinfo = UDF_I(dir);
429         struct udf_inode_info *iinfo;             429         struct udf_inode_info *iinfo;
430                                                   430 
431         inode = udf_new_inode(dir, S_IFDIR | m    431         inode = udf_new_inode(dir, S_IFDIR | mode);
432         if (IS_ERR(inode))                        432         if (IS_ERR(inode))
433                 return PTR_ERR(inode);            433                 return PTR_ERR(inode);
434                                                   434 
435         iinfo = UDF_I(inode);                     435         iinfo = UDF_I(inode);
436         inode->i_op = &udf_dir_inode_operation    436         inode->i_op = &udf_dir_inode_operations;
437         inode->i_fop = &udf_dir_operations;       437         inode->i_fop = &udf_dir_operations;
438         err = udf_fiiter_add_entry(inode, NULL    438         err = udf_fiiter_add_entry(inode, NULL, &iter);
439         if (err) {                                439         if (err) {
440                 clear_nlink(inode);               440                 clear_nlink(inode);
441                 discard_new_inode(inode);         441                 discard_new_inode(inode);
442                 return err;                       442                 return err;
443         }                                         443         }
444         set_nlink(inode, 2);                      444         set_nlink(inode, 2);
445         iter.fi.icb.extLength = cpu_to_le32(in    445         iter.fi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
446         iter.fi.icb.extLocation = cpu_to_lelb(    446         iter.fi.icb.extLocation = cpu_to_lelb(dinfo->i_location);
447         *(__le32 *)((struct allocDescImpUse *)    447         *(__le32 *)((struct allocDescImpUse *)iter.fi.icb.impUse)->impUse =
448                 cpu_to_le32(dinfo->i_unique &     448                 cpu_to_le32(dinfo->i_unique & 0x00000000FFFFFFFFUL);
449         iter.fi.fileCharacteristics =             449         iter.fi.fileCharacteristics =
450                         FID_FILE_CHAR_DIRECTOR    450                         FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT;
451         udf_fiiter_write_fi(&iter, NULL);         451         udf_fiiter_write_fi(&iter, NULL);
452         udf_fiiter_release(&iter);                452         udf_fiiter_release(&iter);
453         mark_inode_dirty(inode);                  453         mark_inode_dirty(inode);
454                                                   454 
455         err = udf_fiiter_add_entry(dir, dentry    455         err = udf_fiiter_add_entry(dir, dentry, &iter);
456         if (err) {                                456         if (err) {
457                 clear_nlink(inode);               457                 clear_nlink(inode);
458                 discard_new_inode(inode);         458                 discard_new_inode(inode);
459                 return err;                       459                 return err;
460         }                                         460         }
461         iter.fi.icb.extLength = cpu_to_le32(in    461         iter.fi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
462         iter.fi.icb.extLocation = cpu_to_lelb(    462         iter.fi.icb.extLocation = cpu_to_lelb(iinfo->i_location);
463         *(__le32 *)((struct allocDescImpUse *)    463         *(__le32 *)((struct allocDescImpUse *)iter.fi.icb.impUse)->impUse =
464                 cpu_to_le32(iinfo->i_unique &     464                 cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL);
465         iter.fi.fileCharacteristics |= FID_FIL    465         iter.fi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY;
466         udf_fiiter_write_fi(&iter, NULL);         466         udf_fiiter_write_fi(&iter, NULL);
467         udf_fiiter_release(&iter);                467         udf_fiiter_release(&iter);
468         udf_add_fid_counter(dir->i_sb, true, 1    468         udf_add_fid_counter(dir->i_sb, true, 1);
469         inc_nlink(dir);                           469         inc_nlink(dir);
470         inode_set_mtime_to_ts(dir, inode_set_c    470         inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
471         mark_inode_dirty(dir);                    471         mark_inode_dirty(dir);
472         d_instantiate_new(dentry, inode);         472         d_instantiate_new(dentry, inode);
473                                                   473 
474         return 0;                                 474         return 0;
475 }                                                 475 }
476                                                   476 
477 static int empty_dir(struct inode *dir)           477 static int empty_dir(struct inode *dir)
478 {                                                 478 {
479         struct udf_fileident_iter iter;           479         struct udf_fileident_iter iter;
480         int ret;                                  480         int ret;
481                                                   481 
482         for (ret = udf_fiiter_init(&iter, dir,    482         for (ret = udf_fiiter_init(&iter, dir, 0);
483              !ret && iter.pos < dir->i_size;      483              !ret && iter.pos < dir->i_size;
484              ret = udf_fiiter_advance(&iter))     484              ret = udf_fiiter_advance(&iter)) {
485                 if (iter.fi.lengthFileIdent &&    485                 if (iter.fi.lengthFileIdent &&
486                     !(iter.fi.fileCharacterist    486                     !(iter.fi.fileCharacteristics & FID_FILE_CHAR_DELETED)) {
487                         udf_fiiter_release(&it    487                         udf_fiiter_release(&iter);
488                         return 0;                 488                         return 0;
489                 }                                 489                 }
490         }                                         490         }
491         udf_fiiter_release(&iter);                491         udf_fiiter_release(&iter);
492                                                   492 
493         return 1;                                 493         return 1;
494 }                                                 494 }
495                                                   495 
496 static int udf_rmdir(struct inode *dir, struct    496 static int udf_rmdir(struct inode *dir, struct dentry *dentry)
497 {                                                 497 {
498         int ret;                                  498         int ret;
499         struct inode *inode = d_inode(dentry);    499         struct inode *inode = d_inode(dentry);
500         struct udf_fileident_iter iter;           500         struct udf_fileident_iter iter;
501         struct kernel_lb_addr tloc;               501         struct kernel_lb_addr tloc;
502                                                   502 
503         ret = udf_fiiter_find_entry(dir, &dent    503         ret = udf_fiiter_find_entry(dir, &dentry->d_name, &iter);
504         if (ret)                                  504         if (ret)
505                 goto out;                         505                 goto out;
506                                                   506 
507         ret = -EFSCORRUPTED;                      507         ret = -EFSCORRUPTED;
508         tloc = lelb_to_cpu(iter.fi.icb.extLoca    508         tloc = lelb_to_cpu(iter.fi.icb.extLocation);
509         if (udf_get_lb_pblock(dir->i_sb, &tloc    509         if (udf_get_lb_pblock(dir->i_sb, &tloc, 0) != inode->i_ino)
510                 goto end_rmdir;                   510                 goto end_rmdir;
511         ret = -ENOTEMPTY;                         511         ret = -ENOTEMPTY;
512         if (!empty_dir(inode))                    512         if (!empty_dir(inode))
513                 goto end_rmdir;                   513                 goto end_rmdir;
514         udf_fiiter_delete_entry(&iter);           514         udf_fiiter_delete_entry(&iter);
515         if (inode->i_nlink != 2)                  515         if (inode->i_nlink != 2)
516                 udf_warn(inode->i_sb, "empty d    516                 udf_warn(inode->i_sb, "empty directory has nlink != 2 (%u)\n",
517                          inode->i_nlink);         517                          inode->i_nlink);
518         clear_nlink(inode);                       518         clear_nlink(inode);
519         inode->i_size = 0;                        519         inode->i_size = 0;
520         inode_dec_link_count(dir);                520         inode_dec_link_count(dir);
521         udf_add_fid_counter(dir->i_sb, true, -    521         udf_add_fid_counter(dir->i_sb, true, -1);
522         inode_set_mtime_to_ts(dir,                522         inode_set_mtime_to_ts(dir,
523                               inode_set_ctime_    523                               inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
524         mark_inode_dirty(dir);                    524         mark_inode_dirty(dir);
525         ret = 0;                                  525         ret = 0;
526 end_rmdir:                                        526 end_rmdir:
527         udf_fiiter_release(&iter);                527         udf_fiiter_release(&iter);
528 out:                                              528 out:
529         return ret;                               529         return ret;
530 }                                                 530 }
531                                                   531 
532 static int udf_unlink(struct inode *dir, struc    532 static int udf_unlink(struct inode *dir, struct dentry *dentry)
533 {                                                 533 {
534         int ret;                                  534         int ret;
535         struct inode *inode = d_inode(dentry);    535         struct inode *inode = d_inode(dentry);
536         struct udf_fileident_iter iter;           536         struct udf_fileident_iter iter;
537         struct kernel_lb_addr tloc;               537         struct kernel_lb_addr tloc;
538                                                   538 
539         ret = udf_fiiter_find_entry(dir, &dent    539         ret = udf_fiiter_find_entry(dir, &dentry->d_name, &iter);
540         if (ret)                                  540         if (ret)
541                 goto out;                         541                 goto out;
542                                                   542 
543         ret = -EFSCORRUPTED;                      543         ret = -EFSCORRUPTED;
544         tloc = lelb_to_cpu(iter.fi.icb.extLoca    544         tloc = lelb_to_cpu(iter.fi.icb.extLocation);
545         if (udf_get_lb_pblock(dir->i_sb, &tloc    545         if (udf_get_lb_pblock(dir->i_sb, &tloc, 0) != inode->i_ino)
546                 goto end_unlink;                  546                 goto end_unlink;
547                                                   547 
548         if (!inode->i_nlink) {                    548         if (!inode->i_nlink) {
549                 udf_debug("Deleting nonexisten    549                 udf_debug("Deleting nonexistent file (%lu), %u\n",
550                           inode->i_ino, inode-    550                           inode->i_ino, inode->i_nlink);
551                 set_nlink(inode, 1);              551                 set_nlink(inode, 1);
552         }                                         552         }
553         udf_fiiter_delete_entry(&iter);           553         udf_fiiter_delete_entry(&iter);
554         inode_set_mtime_to_ts(dir, inode_set_c    554         inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
555         mark_inode_dirty(dir);                    555         mark_inode_dirty(dir);
556         inode_dec_link_count(inode);              556         inode_dec_link_count(inode);
557         udf_add_fid_counter(dir->i_sb, false,     557         udf_add_fid_counter(dir->i_sb, false, -1);
558         inode_set_ctime_to_ts(inode, inode_get    558         inode_set_ctime_to_ts(inode, inode_get_ctime(dir));
559         ret = 0;                                  559         ret = 0;
560 end_unlink:                                       560 end_unlink:
561         udf_fiiter_release(&iter);                561         udf_fiiter_release(&iter);
562 out:                                              562 out:
563         return ret;                               563         return ret;
564 }                                                 564 }
565                                                   565 
566 static int udf_symlink(struct mnt_idmap *idmap    566 static int udf_symlink(struct mnt_idmap *idmap, struct inode *dir,
567                        struct dentry *dentry,     567                        struct dentry *dentry, const char *symname)
568 {                                                 568 {
569         struct inode *inode;                      569         struct inode *inode;
570         struct pathComponent *pc;                 570         struct pathComponent *pc;
571         const char *compstart;                    571         const char *compstart;
572         struct extent_position epos = {};         572         struct extent_position epos = {};
573         int eoffset, elen = 0;                    573         int eoffset, elen = 0;
574         uint8_t *ea;                              574         uint8_t *ea;
575         int err;                                  575         int err;
576         udf_pblk_t block;                         576         udf_pblk_t block;
577         unsigned char *name = NULL;               577         unsigned char *name = NULL;
578         int namelen;                              578         int namelen;
579         struct udf_inode_info *iinfo;             579         struct udf_inode_info *iinfo;
580         struct super_block *sb = dir->i_sb;       580         struct super_block *sb = dir->i_sb;
581                                                   581 
582         name = kmalloc(UDF_NAME_LEN_CS0, GFP_K    582         name = kmalloc(UDF_NAME_LEN_CS0, GFP_KERNEL);
583         if (!name) {                              583         if (!name) {
584                 err = -ENOMEM;                    584                 err = -ENOMEM;
585                 goto out;                         585                 goto out;
586         }                                         586         }
587                                                   587 
588         inode = udf_new_inode(dir, S_IFLNK | 0    588         inode = udf_new_inode(dir, S_IFLNK | 0777);
589         if (IS_ERR(inode)) {                      589         if (IS_ERR(inode)) {
590                 err = PTR_ERR(inode);             590                 err = PTR_ERR(inode);
591                 goto out;                         591                 goto out;
592         }                                         592         }
593                                                   593 
594         iinfo = UDF_I(inode);                     594         iinfo = UDF_I(inode);
595         down_write(&iinfo->i_data_sem);           595         down_write(&iinfo->i_data_sem);
596         inode->i_data.a_ops = &udf_symlink_aop    596         inode->i_data.a_ops = &udf_symlink_aops;
597         inode->i_op = &udf_symlink_inode_opera    597         inode->i_op = &udf_symlink_inode_operations;
598         inode_nohighmem(inode);                   598         inode_nohighmem(inode);
599                                                   599 
600         if (iinfo->i_alloc_type != ICBTAG_FLAG    600         if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
601                 struct kernel_lb_addr eloc;       601                 struct kernel_lb_addr eloc;
602                 uint32_t bsize;                   602                 uint32_t bsize;
603                                                   603 
604                 block = udf_new_block(sb, inod    604                 block = udf_new_block(sb, inode,
605                                 iinfo->i_locat    605                                 iinfo->i_location.partitionReferenceNum,
606                                 iinfo->i_locat    606                                 iinfo->i_location.logicalBlockNum, &err);
607                 if (!block)                       607                 if (!block)
608                         goto out_no_entry;        608                         goto out_no_entry;
609                 epos.block = iinfo->i_location    609                 epos.block = iinfo->i_location;
610                 epos.offset = udf_file_entry_a    610                 epos.offset = udf_file_entry_alloc_offset(inode);
611                 epos.bh = NULL;                   611                 epos.bh = NULL;
612                 eloc.logicalBlockNum = block;     612                 eloc.logicalBlockNum = block;
613                 eloc.partitionReferenceNum =      613                 eloc.partitionReferenceNum =
614                                 iinfo->i_locat    614                                 iinfo->i_location.partitionReferenceNum;
615                 bsize = sb->s_blocksize;          615                 bsize = sb->s_blocksize;
616                 iinfo->i_lenExtents = bsize;      616                 iinfo->i_lenExtents = bsize;
617                 err = udf_add_aext(inode, &epo    617                 err = udf_add_aext(inode, &epos, &eloc, bsize, 0);
618                 brelse(epos.bh);                  618                 brelse(epos.bh);
619                 if (err < 0) {                    619                 if (err < 0) {
620                         udf_free_blocks(sb, in    620                         udf_free_blocks(sb, inode, &eloc, 0, 1);
621                         goto out_no_entry;        621                         goto out_no_entry;
622                 }                                 622                 }
623                                                   623 
624                 block = udf_get_pblock(sb, blo    624                 block = udf_get_pblock(sb, block,
625                                 iinfo->i_locat    625                                 iinfo->i_location.partitionReferenceNum,
626                                 0);               626                                 0);
627                 epos.bh = sb_getblk(sb, block)    627                 epos.bh = sb_getblk(sb, block);
628                 if (unlikely(!epos.bh)) {         628                 if (unlikely(!epos.bh)) {
629                         err = -ENOMEM;            629                         err = -ENOMEM;
630                         udf_free_blocks(sb, in    630                         udf_free_blocks(sb, inode, &eloc, 0, 1);
631                         goto out_no_entry;        631                         goto out_no_entry;
632                 }                                 632                 }
633                 lock_buffer(epos.bh);             633                 lock_buffer(epos.bh);
634                 memset(epos.bh->b_data, 0x00,     634                 memset(epos.bh->b_data, 0x00, bsize);
635                 set_buffer_uptodate(epos.bh);     635                 set_buffer_uptodate(epos.bh);
636                 unlock_buffer(epos.bh);           636                 unlock_buffer(epos.bh);
637                 mark_buffer_dirty_inode(epos.b    637                 mark_buffer_dirty_inode(epos.bh, inode);
638                 ea = epos.bh->b_data + udf_ext    638                 ea = epos.bh->b_data + udf_ext0_offset(inode);
639         } else                                    639         } else
640                 ea = iinfo->i_data + iinfo->i_    640                 ea = iinfo->i_data + iinfo->i_lenEAttr;
641                                                   641 
642         eoffset = sb->s_blocksize - udf_ext0_o    642         eoffset = sb->s_blocksize - udf_ext0_offset(inode);
643         pc = (struct pathComponent *)ea;          643         pc = (struct pathComponent *)ea;
644                                                   644 
645         if (*symname == '/') {                    645         if (*symname == '/') {
646                 do {                              646                 do {
647                         symname++;                647                         symname++;
648                 } while (*symname == '/');        648                 } while (*symname == '/');
649                                                   649 
650                 pc->componentType = 1;            650                 pc->componentType = 1;
651                 pc->lengthComponentIdent = 0;     651                 pc->lengthComponentIdent = 0;
652                 pc->componentFileVersionNum =     652                 pc->componentFileVersionNum = 0;
653                 elen += sizeof(struct pathComp    653                 elen += sizeof(struct pathComponent);
654         }                                         654         }
655                                                   655 
656         err = -ENAMETOOLONG;                      656         err = -ENAMETOOLONG;
657                                                   657 
658         while (*symname) {                        658         while (*symname) {
659                 if (elen + sizeof(struct pathC    659                 if (elen + sizeof(struct pathComponent) > eoffset)
660                         goto out_no_entry;        660                         goto out_no_entry;
661                                                   661 
662                 pc = (struct pathComponent *)(    662                 pc = (struct pathComponent *)(ea + elen);
663                                                   663 
664                 compstart = symname;              664                 compstart = symname;
665                                                   665 
666                 do {                              666                 do {
667                         symname++;                667                         symname++;
668                 } while (*symname && *symname     668                 } while (*symname && *symname != '/');
669                                                   669 
670                 pc->componentType = 5;            670                 pc->componentType = 5;
671                 pc->lengthComponentIdent = 0;     671                 pc->lengthComponentIdent = 0;
672                 pc->componentFileVersionNum =     672                 pc->componentFileVersionNum = 0;
673                 if (compstart[0] == '.') {        673                 if (compstart[0] == '.') {
674                         if ((symname - compsta    674                         if ((symname - compstart) == 1)
675                                 pc->componentT    675                                 pc->componentType = 4;
676                         else if ((symname - co    676                         else if ((symname - compstart) == 2 &&
677                                         compst    677                                         compstart[1] == '.')
678                                 pc->componentT    678                                 pc->componentType = 3;
679                 }                                 679                 }
680                                                   680 
681                 if (pc->componentType == 5) {     681                 if (pc->componentType == 5) {
682                         namelen = udf_put_file    682                         namelen = udf_put_filename(sb, compstart,
683                                                   683                                                    symname - compstart,
684                                                   684                                                    name, UDF_NAME_LEN_CS0);
685                         if (!namelen)             685                         if (!namelen)
686                                 goto out_no_en    686                                 goto out_no_entry;
687                                                   687 
688                         if (elen + sizeof(stru    688                         if (elen + sizeof(struct pathComponent) + namelen >
689                                         eoffse    689                                         eoffset)
690                                 goto out_no_en    690                                 goto out_no_entry;
691                         else                      691                         else
692                                 pc->lengthComp    692                                 pc->lengthComponentIdent = namelen;
693                                                   693 
694                         memcpy(pc->componentId    694                         memcpy(pc->componentIdent, name, namelen);
695                 }                                 695                 }
696                                                   696 
697                 elen += sizeof(struct pathComp    697                 elen += sizeof(struct pathComponent) + pc->lengthComponentIdent;
698                                                   698 
699                 if (*symname) {                   699                 if (*symname) {
700                         do {                      700                         do {
701                                 symname++;        701                                 symname++;
702                         } while (*symname == '    702                         } while (*symname == '/');
703                 }                                 703                 }
704         }                                         704         }
705                                                   705 
706         brelse(epos.bh);                          706         brelse(epos.bh);
707         inode->i_size = elen;                     707         inode->i_size = elen;
708         if (iinfo->i_alloc_type == ICBTAG_FLAG    708         if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
709                 iinfo->i_lenAlloc = inode->i_s    709                 iinfo->i_lenAlloc = inode->i_size;
710         else                                      710         else
711                 udf_truncate_tail_extent(inode    711                 udf_truncate_tail_extent(inode);
712         mark_inode_dirty(inode);                  712         mark_inode_dirty(inode);
713         up_write(&iinfo->i_data_sem);             713         up_write(&iinfo->i_data_sem);
714                                                   714 
715         err = udf_add_nondir(dentry, inode);      715         err = udf_add_nondir(dentry, inode);
716 out:                                              716 out:
717         kfree(name);                              717         kfree(name);
718         return err;                               718         return err;
719                                                   719 
720 out_no_entry:                                     720 out_no_entry:
721         up_write(&iinfo->i_data_sem);             721         up_write(&iinfo->i_data_sem);
722         inode_dec_link_count(inode);              722         inode_dec_link_count(inode);
723         discard_new_inode(inode);                 723         discard_new_inode(inode);
724         goto out;                                 724         goto out;
725 }                                                 725 }
726                                                   726 
727 static int udf_link(struct dentry *old_dentry,    727 static int udf_link(struct dentry *old_dentry, struct inode *dir,
728                     struct dentry *dentry)        728                     struct dentry *dentry)
729 {                                                 729 {
730         struct inode *inode = d_inode(old_dent    730         struct inode *inode = d_inode(old_dentry);
731         struct udf_fileident_iter iter;           731         struct udf_fileident_iter iter;
732         int err;                                  732         int err;
733                                                   733 
734         err = udf_fiiter_add_entry(dir, dentry    734         err = udf_fiiter_add_entry(dir, dentry, &iter);
735         if (err)                                  735         if (err)
736                 return err;                       736                 return err;
737         iter.fi.icb.extLength = cpu_to_le32(in    737         iter.fi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
738         iter.fi.icb.extLocation = cpu_to_lelb(    738         iter.fi.icb.extLocation = cpu_to_lelb(UDF_I(inode)->i_location);
739         if (UDF_SB(inode->i_sb)->s_lvid_bh) {     739         if (UDF_SB(inode->i_sb)->s_lvid_bh) {
740                 *(__le32 *)((struct allocDescI    740                 *(__le32 *)((struct allocDescImpUse *)iter.fi.icb.impUse)->impUse =
741                         cpu_to_le32(lvid_get_u    741                         cpu_to_le32(lvid_get_unique_id(inode->i_sb));
742         }                                         742         }
743         udf_fiiter_write_fi(&iter, NULL);         743         udf_fiiter_write_fi(&iter, NULL);
744         udf_fiiter_release(&iter);                744         udf_fiiter_release(&iter);
745                                                   745 
746         inc_nlink(inode);                         746         inc_nlink(inode);
747         udf_add_fid_counter(dir->i_sb, false,     747         udf_add_fid_counter(dir->i_sb, false, 1);
748         inode_set_ctime_current(inode);           748         inode_set_ctime_current(inode);
749         mark_inode_dirty(inode);                  749         mark_inode_dirty(inode);
750         inode_set_mtime_to_ts(dir, inode_set_c    750         inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
751         mark_inode_dirty(dir);                    751         mark_inode_dirty(dir);
752         ihold(inode);                             752         ihold(inode);
753         d_instantiate(dentry, inode);             753         d_instantiate(dentry, inode);
754                                                   754 
755         return 0;                                 755         return 0;
756 }                                                 756 }
757                                                   757 
758 /* Anybody can rename anything with this: the     758 /* Anybody can rename anything with this: the permission checks are left to the
759  * higher-level routines.                         759  * higher-level routines.
760  */                                               760  */
761 static int udf_rename(struct mnt_idmap *idmap,    761 static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
762                       struct dentry *old_dentr    762                       struct dentry *old_dentry, struct inode *new_dir,
763                       struct dentry *new_dentr    763                       struct dentry *new_dentry, unsigned int flags)
764 {                                                 764 {
765         struct inode *old_inode = d_inode(old_    765         struct inode *old_inode = d_inode(old_dentry);
766         struct inode *new_inode = d_inode(new_    766         struct inode *new_inode = d_inode(new_dentry);
767         struct udf_fileident_iter oiter, niter    767         struct udf_fileident_iter oiter, niter, diriter;
768         bool has_diriter = false, is_dir = fal    768         bool has_diriter = false, is_dir = false;
769         int retval;                               769         int retval;
770         struct kernel_lb_addr tloc;               770         struct kernel_lb_addr tloc;
771                                                   771 
772         if (flags & ~RENAME_NOREPLACE)            772         if (flags & ~RENAME_NOREPLACE)
773                 return -EINVAL;                   773                 return -EINVAL;
774                                                   774 
775         retval = udf_fiiter_find_entry(old_dir    775         retval = udf_fiiter_find_entry(old_dir, &old_dentry->d_name, &oiter);
776         if (retval)                               776         if (retval)
777                 return retval;                    777                 return retval;
778                                                   778 
779         tloc = lelb_to_cpu(oiter.fi.icb.extLoc    779         tloc = lelb_to_cpu(oiter.fi.icb.extLocation);
780         if (udf_get_lb_pblock(old_dir->i_sb, &    780         if (udf_get_lb_pblock(old_dir->i_sb, &tloc, 0) != old_inode->i_ino) {
781                 retval = -ENOENT;                 781                 retval = -ENOENT;
782                 goto out_oiter;                   782                 goto out_oiter;
783         }                                         783         }
784                                                   784 
785         if (S_ISDIR(old_inode->i_mode)) {         785         if (S_ISDIR(old_inode->i_mode)) {
786                 if (new_inode) {                  786                 if (new_inode) {
787                         retval = -ENOTEMPTY;      787                         retval = -ENOTEMPTY;
788                         if (!empty_dir(new_ino    788                         if (!empty_dir(new_inode))
789                                 goto out_oiter    789                                 goto out_oiter;
790                 }                                 790                 }
791                 is_dir = true;                    791                 is_dir = true;
792         }                                         792         }
793         if (is_dir && old_dir != new_dir) {       793         if (is_dir && old_dir != new_dir) {
794                 retval = udf_fiiter_find_entry    794                 retval = udf_fiiter_find_entry(old_inode, &dotdot_name,
795                                                   795                                                &diriter);
796                 if (retval == -ENOENT) {          796                 if (retval == -ENOENT) {
797                         udf_err(old_inode->i_s    797                         udf_err(old_inode->i_sb,
798                                 "directory (in    798                                 "directory (ino %lu) has no '..' entry\n",
799                                 old_inode->i_i    799                                 old_inode->i_ino);
800                         retval = -EFSCORRUPTED    800                         retval = -EFSCORRUPTED;
801                 }                                 801                 }
802                 if (retval)                       802                 if (retval)
803                         goto out_oiter;           803                         goto out_oiter;
804                 has_diriter = true;               804                 has_diriter = true;
805                 tloc = lelb_to_cpu(diriter.fi.    805                 tloc = lelb_to_cpu(diriter.fi.icb.extLocation);
806                 if (udf_get_lb_pblock(old_inod    806                 if (udf_get_lb_pblock(old_inode->i_sb, &tloc, 0) !=
807                                 old_dir->i_ino    807                                 old_dir->i_ino) {
808                         retval = -EFSCORRUPTED    808                         retval = -EFSCORRUPTED;
809                         udf_err(old_inode->i_s    809                         udf_err(old_inode->i_sb,
810                                 "directory (in    810                                 "directory (ino %lu) has parent entry pointing to another inode (%lu != %u)\n",
811                                 old_inode->i_i    811                                 old_inode->i_ino, old_dir->i_ino,
812                                 udf_get_lb_pbl    812                                 udf_get_lb_pblock(old_inode->i_sb, &tloc, 0));
813                         goto out_oiter;           813                         goto out_oiter;
814                 }                                 814                 }
815         }                                         815         }
816                                                   816 
817         retval = udf_fiiter_find_entry(new_dir    817         retval = udf_fiiter_find_entry(new_dir, &new_dentry->d_name, &niter);
818         if (retval && retval != -ENOENT)          818         if (retval && retval != -ENOENT)
819                 goto out_oiter;                   819                 goto out_oiter;
820         /* Entry found but not passed by VFS?     820         /* Entry found but not passed by VFS? */
821         if (!retval && !new_inode) {              821         if (!retval && !new_inode) {
822                 retval = -EFSCORRUPTED;           822                 retval = -EFSCORRUPTED;
823                 udf_fiiter_release(&niter);       823                 udf_fiiter_release(&niter);
824                 goto out_oiter;                   824                 goto out_oiter;
825         }                                         825         }
826         /* Entry not found? Need to add one...    826         /* Entry not found? Need to add one... */
827         if (retval) {                             827         if (retval) {
828                 udf_fiiter_release(&niter);       828                 udf_fiiter_release(&niter);
829                 retval = udf_fiiter_add_entry(    829                 retval = udf_fiiter_add_entry(new_dir, new_dentry, &niter);
830                 if (retval)                       830                 if (retval)
831                         goto out_oiter;           831                         goto out_oiter;
832         }                                         832         }
833                                                   833 
834         /*                                        834         /*
835          * Like most other Unix systems, set t    835          * Like most other Unix systems, set the ctime for inodes on a
836          * rename.                                836          * rename.
837          */                                       837          */
838         inode_set_ctime_current(old_inode);       838         inode_set_ctime_current(old_inode);
839         mark_inode_dirty(old_inode);              839         mark_inode_dirty(old_inode);
840                                                   840 
841         /*                                        841         /*
842          * ok, that's it                          842          * ok, that's it
843          */                                       843          */
844         niter.fi.fileVersionNum = oiter.fi.fil    844         niter.fi.fileVersionNum = oiter.fi.fileVersionNum;
845         niter.fi.fileCharacteristics = oiter.f    845         niter.fi.fileCharacteristics = oiter.fi.fileCharacteristics;
846         memcpy(&(niter.fi.icb), &(oiter.fi.icb    846         memcpy(&(niter.fi.icb), &(oiter.fi.icb), sizeof(oiter.fi.icb));
847         udf_fiiter_write_fi(&niter, NULL);        847         udf_fiiter_write_fi(&niter, NULL);
848         udf_fiiter_release(&niter);               848         udf_fiiter_release(&niter);
849                                                   849 
850         /*                                        850         /*
851          * The old entry may have moved due to    851          * The old entry may have moved due to new entry allocation. Find it
852          * again.                                 852          * again.
853          */                                       853          */
854         udf_fiiter_release(&oiter);               854         udf_fiiter_release(&oiter);
855         retval = udf_fiiter_find_entry(old_dir    855         retval = udf_fiiter_find_entry(old_dir, &old_dentry->d_name, &oiter);
856         if (retval) {                             856         if (retval) {
857                 udf_err(old_dir->i_sb,            857                 udf_err(old_dir->i_sb,
858                         "failed to find rename    858                         "failed to find renamed entry again in directory (ino %lu)\n",
859                         old_dir->i_ino);          859                         old_dir->i_ino);
860         } else {                                  860         } else {
861                 udf_fiiter_delete_entry(&oiter    861                 udf_fiiter_delete_entry(&oiter);
862                 udf_fiiter_release(&oiter);       862                 udf_fiiter_release(&oiter);
863         }                                         863         }
864                                                   864 
865         if (new_inode) {                          865         if (new_inode) {
866                 inode_set_ctime_current(new_in    866                 inode_set_ctime_current(new_inode);
867                 inode_dec_link_count(new_inode    867                 inode_dec_link_count(new_inode);
868                 udf_add_fid_counter(old_dir->i    868                 udf_add_fid_counter(old_dir->i_sb, S_ISDIR(new_inode->i_mode),
869                                     -1);          869                                     -1);
870         }                                         870         }
871         inode_set_mtime_to_ts(old_dir, inode_s    871         inode_set_mtime_to_ts(old_dir, inode_set_ctime_current(old_dir));
872         inode_set_mtime_to_ts(new_dir, inode_s    872         inode_set_mtime_to_ts(new_dir, inode_set_ctime_current(new_dir));
873         mark_inode_dirty(old_dir);                873         mark_inode_dirty(old_dir);
874         mark_inode_dirty(new_dir);                874         mark_inode_dirty(new_dir);
875                                                   875 
876         if (has_diriter) {                        876         if (has_diriter) {
877                 diriter.fi.icb.extLocation =      877                 diriter.fi.icb.extLocation =
878                                         cpu_to    878                                         cpu_to_lelb(UDF_I(new_dir)->i_location);
879                 udf_fiiter_write_fi(&diriter,     879                 udf_fiiter_write_fi(&diriter, NULL);
880                 udf_fiiter_release(&diriter);     880                 udf_fiiter_release(&diriter);
881         }                                         881         }
882                                                   882 
883         if (is_dir) {                             883         if (is_dir) {
884                 inode_dec_link_count(old_dir);    884                 inode_dec_link_count(old_dir);
885                 if (new_inode)                    885                 if (new_inode)
886                         inode_dec_link_count(n    886                         inode_dec_link_count(new_inode);
887                 else {                            887                 else {
888                         inc_nlink(new_dir);       888                         inc_nlink(new_dir);
889                         mark_inode_dirty(new_d    889                         mark_inode_dirty(new_dir);
890                 }                                 890                 }
891         }                                         891         }
892         return 0;                                 892         return 0;
893 out_oiter:                                        893 out_oiter:
894         if (has_diriter)                          894         if (has_diriter)
895                 udf_fiiter_release(&diriter);     895                 udf_fiiter_release(&diriter);
896         udf_fiiter_release(&oiter);               896         udf_fiiter_release(&oiter);
897                                                   897 
898         return retval;                            898         return retval;
899 }                                                 899 }
900                                                   900 
901 static struct dentry *udf_get_parent(struct de    901 static struct dentry *udf_get_parent(struct dentry *child)
902 {                                                 902 {
903         struct kernel_lb_addr tloc;               903         struct kernel_lb_addr tloc;
904         struct udf_fileident_iter iter;           904         struct udf_fileident_iter iter;
905         int err;                                  905         int err;
906                                                   906 
907         err = udf_fiiter_find_entry(d_inode(ch    907         err = udf_fiiter_find_entry(d_inode(child), &dotdot_name, &iter);
908         if (err)                                  908         if (err)
909                 return ERR_PTR(err);              909                 return ERR_PTR(err);
910                                                   910 
911         tloc = lelb_to_cpu(iter.fi.icb.extLoca    911         tloc = lelb_to_cpu(iter.fi.icb.extLocation);
912         udf_fiiter_release(&iter);                912         udf_fiiter_release(&iter);
913         return d_obtain_alias(udf_iget(child->    913         return d_obtain_alias(udf_iget(child->d_sb, &tloc));
914 }                                                 914 }
915                                                   915 
916                                                   916 
917 static struct dentry *udf_nfs_get_inode(struct    917 static struct dentry *udf_nfs_get_inode(struct super_block *sb, u32 block,
918                                         u16 pa    918                                         u16 partref, __u32 generation)
919 {                                                 919 {
920         struct inode *inode;                      920         struct inode *inode;
921         struct kernel_lb_addr loc;                921         struct kernel_lb_addr loc;
922                                                   922 
923         if (block == 0)                           923         if (block == 0)
924                 return ERR_PTR(-ESTALE);          924                 return ERR_PTR(-ESTALE);
925                                                   925 
926         loc.logicalBlockNum = block;              926         loc.logicalBlockNum = block;
927         loc.partitionReferenceNum = partref;      927         loc.partitionReferenceNum = partref;
928         inode = udf_iget(sb, &loc);               928         inode = udf_iget(sb, &loc);
929                                                   929 
930         if (IS_ERR(inode))                        930         if (IS_ERR(inode))
931                 return ERR_CAST(inode);           931                 return ERR_CAST(inode);
932                                                   932 
933         if (generation && inode->i_generation     933         if (generation && inode->i_generation != generation) {
934                 iput(inode);                      934                 iput(inode);
935                 return ERR_PTR(-ESTALE);          935                 return ERR_PTR(-ESTALE);
936         }                                         936         }
937         return d_obtain_alias(inode);             937         return d_obtain_alias(inode);
938 }                                                 938 }
939                                                   939 
940 static struct dentry *udf_fh_to_dentry(struct     940 static struct dentry *udf_fh_to_dentry(struct super_block *sb,
941                                        struct     941                                        struct fid *fid, int fh_len, int fh_type)
942 {                                                 942 {
943         if (fh_len < 3 ||                         943         if (fh_len < 3 ||
944             (fh_type != FILEID_UDF_WITH_PARENT    944             (fh_type != FILEID_UDF_WITH_PARENT &&
945              fh_type != FILEID_UDF_WITHOUT_PAR    945              fh_type != FILEID_UDF_WITHOUT_PARENT))
946                 return NULL;                      946                 return NULL;
947                                                   947 
948         return udf_nfs_get_inode(sb, fid->udf.    948         return udf_nfs_get_inode(sb, fid->udf.block, fid->udf.partref,
949                         fid->udf.generation);     949                         fid->udf.generation);
950 }                                                 950 }
951                                                   951 
952 static struct dentry *udf_fh_to_parent(struct     952 static struct dentry *udf_fh_to_parent(struct super_block *sb,
953                                        struct     953                                        struct fid *fid, int fh_len, int fh_type)
954 {                                                 954 {
955         if (fh_len < 5 || fh_type != FILEID_UD    955         if (fh_len < 5 || fh_type != FILEID_UDF_WITH_PARENT)
956                 return NULL;                      956                 return NULL;
957                                                   957 
958         return udf_nfs_get_inode(sb, fid->udf.    958         return udf_nfs_get_inode(sb, fid->udf.parent_block,
959                                  fid->udf.pare    959                                  fid->udf.parent_partref,
960                                  fid->udf.pare    960                                  fid->udf.parent_generation);
961 }                                                 961 }
962 static int udf_encode_fh(struct inode *inode,     962 static int udf_encode_fh(struct inode *inode, __u32 *fh, int *lenp,
963                          struct inode *parent)    963                          struct inode *parent)
964 {                                                 964 {
965         int len = *lenp;                          965         int len = *lenp;
966         struct kernel_lb_addr location = UDF_I    966         struct kernel_lb_addr location = UDF_I(inode)->i_location;
967         struct fid *fid = (struct fid *)fh;       967         struct fid *fid = (struct fid *)fh;
968         int type = FILEID_UDF_WITHOUT_PARENT;     968         int type = FILEID_UDF_WITHOUT_PARENT;
969                                                   969 
970         if (parent && (len < 5)) {                970         if (parent && (len < 5)) {
971                 *lenp = 5;                        971                 *lenp = 5;
972                 return FILEID_INVALID;            972                 return FILEID_INVALID;
973         } else if (len < 3) {                     973         } else if (len < 3) {
974                 *lenp = 3;                        974                 *lenp = 3;
975                 return FILEID_INVALID;            975                 return FILEID_INVALID;
976         }                                         976         }
977                                                   977 
978         *lenp = 3;                                978         *lenp = 3;
979         fid->udf.block = location.logicalBlock    979         fid->udf.block = location.logicalBlockNum;
980         fid->udf.partref = location.partitionR    980         fid->udf.partref = location.partitionReferenceNum;
981         fid->udf.parent_partref = 0;              981         fid->udf.parent_partref = 0;
982         fid->udf.generation = inode->i_generat    982         fid->udf.generation = inode->i_generation;
983                                                   983 
984         if (parent) {                             984         if (parent) {
985                 location = UDF_I(parent)->i_lo    985                 location = UDF_I(parent)->i_location;
986                 fid->udf.parent_block = locati    986                 fid->udf.parent_block = location.logicalBlockNum;
987                 fid->udf.parent_partref = loca    987                 fid->udf.parent_partref = location.partitionReferenceNum;
988                 fid->udf.parent_generation = i    988                 fid->udf.parent_generation = inode->i_generation;
989                 *lenp = 5;                        989                 *lenp = 5;
990                 type = FILEID_UDF_WITH_PARENT;    990                 type = FILEID_UDF_WITH_PARENT;
991         }                                         991         }
992                                                   992 
993         return type;                              993         return type;
994 }                                                 994 }
995                                                   995 
996 const struct export_operations udf_export_ops     996 const struct export_operations udf_export_ops = {
997         .encode_fh      = udf_encode_fh,          997         .encode_fh      = udf_encode_fh,
998         .fh_to_dentry   = udf_fh_to_dentry,       998         .fh_to_dentry   = udf_fh_to_dentry,
999         .fh_to_parent   = udf_fh_to_parent,       999         .fh_to_parent   = udf_fh_to_parent,
1000         .get_parent     = udf_get_parent,        1000         .get_parent     = udf_get_parent,
1001 };                                               1001 };
1002                                                  1002 
1003 const struct inode_operations udf_dir_inode_o    1003 const struct inode_operations udf_dir_inode_operations = {
1004         .lookup                         = udf    1004         .lookup                         = udf_lookup,
1005         .create                         = udf    1005         .create                         = udf_create,
1006         .link                           = udf    1006         .link                           = udf_link,
1007         .unlink                         = udf    1007         .unlink                         = udf_unlink,
1008         .symlink                        = udf    1008         .symlink                        = udf_symlink,
1009         .mkdir                          = udf    1009         .mkdir                          = udf_mkdir,
1010         .rmdir                          = udf    1010         .rmdir                          = udf_rmdir,
1011         .mknod                          = udf    1011         .mknod                          = udf_mknod,
1012         .rename                         = udf    1012         .rename                         = udf_rename,
1013         .tmpfile                        = udf    1013         .tmpfile                        = udf_tmpfile,
1014 };                                               1014 };
1015                                                  1015 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php