Skip to content

Commit

Permalink
xfs: merge xfs_mkdir into xfs_create
Browse files Browse the repository at this point in the history
xfs_create and xfs_mkdir only have minor differences, so merge both of them
into a sigle function.  While we're at it also make the error handling code
more straight-forward.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Dave Chinner <david@fromorbit.com>
  • Loading branch information
Christoph Hellwig authored and Christoph Hellwig committed Feb 9, 2009
1 parent a568778 commit 517b5e8
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 291 deletions.
30 changes: 9 additions & 21 deletions fs/xfs/linux-2.6/xfs_iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,13 @@ xfs_vn_mknod(
* Irix uses Missed'em'V split, but doesn't want to see
* the upper 5 bits of (14bit) major.
*/
if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
return -EINVAL;
if (S_ISCHR(mode) || S_ISBLK(mode)) {
if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
return -EINVAL;
rdev = sysv_encode_dev(rdev);
} else {
rdev = 0;
}

if (test_default_acl && test_default_acl(dir)) {
if (!_ACL_ALLOC(default_acl)) {
Expand All @@ -224,28 +229,11 @@ xfs_vn_mknod(
}
}

xfs_dentry_to_name(&name, dentry);

if (IS_POSIXACL(dir) && !default_acl)
mode &= ~current->fs->umask;

switch (mode & S_IFMT) {
case S_IFCHR:
case S_IFBLK:
case S_IFIFO:
case S_IFSOCK:
rdev = sysv_encode_dev(rdev);
case S_IFREG:
error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip, NULL);
break;
case S_IFDIR:
error = xfs_mkdir(XFS_I(dir), &name, mode, &ip, NULL);
break;
default:
error = EINVAL;
break;
}

xfs_dentry_to_name(&name, dentry);
error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip, NULL);
if (unlikely(error))
goto out_free_acl;

Expand Down
Loading

0 comments on commit 517b5e8

Please sign in to comment.