Commit 00bce6f7 authored by Jan Kara's avatar Jan Kara

udf: Convert udf_mkdir() to new directory iteration code

Convert udf_mkdir() to new directory iteration code.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent ef91f999
...@@ -928,8 +928,7 @@ static int udf_mkdir(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -928,8 +928,7 @@ static int udf_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
struct dentry *dentry, umode_t mode) struct dentry *dentry, umode_t mode)
{ {
struct inode *inode; struct inode *inode;
struct udf_fileident_bh fibh; struct udf_fileident_iter iter;
struct fileIdentDesc cfi, *fi;
int err; int err;
struct udf_inode_info *dinfo = UDF_I(dir); struct udf_inode_info *dinfo = UDF_I(dir);
struct udf_inode_info *iinfo; struct udf_inode_info *iinfo;
...@@ -941,47 +940,42 @@ static int udf_mkdir(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -941,47 +940,42 @@ static int udf_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
iinfo = UDF_I(inode); iinfo = UDF_I(inode);
inode->i_op = &udf_dir_inode_operations; inode->i_op = &udf_dir_inode_operations;
inode->i_fop = &udf_dir_operations; inode->i_fop = &udf_dir_operations;
fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err); err = udf_fiiter_add_entry(inode, NULL, &iter);
if (!fi) { if (err) {
inode_dec_link_count(inode); clear_nlink(inode);
discard_new_inode(inode); discard_new_inode(inode);
goto out; return err;
} }
set_nlink(inode, 2); set_nlink(inode, 2);
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); iter.fi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
cfi.icb.extLocation = cpu_to_lelb(dinfo->i_location); iter.fi.icb.extLocation = cpu_to_lelb(dinfo->i_location);
*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = *(__le32 *)((struct allocDescImpUse *)iter.fi.icb.impUse)->impUse =
cpu_to_le32(dinfo->i_unique & 0x00000000FFFFFFFFUL); cpu_to_le32(dinfo->i_unique & 0x00000000FFFFFFFFUL);
cfi.fileCharacteristics = iter.fi.fileCharacteristics =
FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT;
udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); udf_fiiter_write_fi(&iter, NULL);
brelse(fibh.sbh); udf_fiiter_release(&iter);
mark_inode_dirty(inode); mark_inode_dirty(inode);
fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); err = udf_fiiter_add_entry(dir, dentry, &iter);
if (!fi) { if (err) {
clear_nlink(inode); clear_nlink(inode);
mark_inode_dirty(inode);
discard_new_inode(inode); discard_new_inode(inode);
goto out; return err;
} }
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); iter.fi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); iter.fi.icb.extLocation = cpu_to_lelb(iinfo->i_location);
*(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = *(__le32 *)((struct allocDescImpUse *)iter.fi.icb.impUse)->impUse =
cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL);
cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; iter.fi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY;
udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); udf_fiiter_write_fi(&iter, NULL);
udf_fiiter_release(&iter);
inc_nlink(dir); inc_nlink(dir);
dir->i_ctime = dir->i_mtime = current_time(dir); dir->i_ctime = dir->i_mtime = current_time(dir);
mark_inode_dirty(dir); mark_inode_dirty(dir);
d_instantiate_new(dentry, inode); d_instantiate_new(dentry, inode);
if (fibh.sbh != fibh.ebh)
brelse(fibh.ebh);
brelse(fibh.sbh);
err = 0;
out: return 0;
return err;
} }
static int empty_dir(struct inode *dir) static int empty_dir(struct inode *dir)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment