static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path,

                       const char *name, FsCred *credp)

{

    int err = -1;

    int dirfd;



    if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE &&

        local_is_mapped_file_metadata(fs_ctx, name)) {

        errno = EINVAL;

        return -1;

    }



    dirfd = local_opendir_nofollow(fs_ctx, dir_path->data);

    if (dirfd == -1) {

        return -1;

    }



    if (fs_ctx->export_flags & V9FS_SM_MAPPED ||

        fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {

        err = mknodat(dirfd, name, SM_LOCAL_MODE_BITS | S_IFREG, 0);

        if (err == -1) {

            goto out;

        }



        if (fs_ctx->export_flags & V9FS_SM_MAPPED) {

            err = local_set_xattrat(dirfd, name, credp);

        } else {

            err = local_set_mapped_file_attrat(dirfd, name, credp);

        }

        if (err == -1) {

            goto err_end;

        }

    } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH ||

               fs_ctx->export_flags & V9FS_SM_NONE) {

        err = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev);

        if (err == -1) {

            goto out;

        }

        err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp);

        if (err == -1) {

            goto err_end;

        }

    }

    goto out;



err_end:

    unlinkat_preserve_errno(dirfd, name, 0);

out:

    close_preserve_errno(dirfd);

    return err;

}

static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path,

                       const char *name, FsCred *credp)

{

    int err = -1;

    int dirfd;



    if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE &&

        local_is_mapped_file_metadata(fs_ctx, name)) {

        errno = EINVAL;

        return -1;

    }



    dirfd = local_opendir_nofollow(fs_ctx, dir_path->data);

    if (dirfd == -1) {

        return -1;

    }



    if (fs_ctx->export_flags & V9FS_SM_MAPPED ||

        fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {

        err = mknodat(dirfd, name, SM_LOCAL_MODE_BITS | S_IFREG, 0);

        if (err == -1) {

            goto out;

        }



        if (fs_ctx->export_flags & V9FS_SM_MAPPED) {

            err = local_set_xattrat(dirfd, name, credp);

        } else {

            err = local_set_mapped_file_attrat(dirfd, name, credp);

        }

        if (err == -1) {

            goto err_end;

        }

    } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH ||

               fs_ctx->export_flags & V9FS_SM_NONE) {

        err = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev);

        if (err == -1) {

            goto out;

        }

        err = local_set_cred_passthrough(fs_ctx, dirfd, name, credp);

        if (err == -1) {

            goto err_end;

        }

    }

    goto out;



err_end:

    unlinkat_preserve_errno(dirfd, name, 0);

out:

    close_preserve_errno(dirfd);

    return err;

}

static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,

                       const char *VAR_2, FsCred *VAR_3)

{

    int VAR_4 = -1;

    int VAR_5;



    if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE &&

        local_is_mapped_file_metadata(VAR_0, VAR_2)) {

        errno = EINVAL;

        return -1;

    }



    VAR_5 = local_opendir_nofollow(VAR_0, VAR_1->data);

    if (VAR_5 == -1) {

        return -1;

    }



    if (VAR_0->export_flags & V9FS_SM_MAPPED ||

        VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {

        VAR_4 = mknodat(VAR_5, VAR_2, SM_LOCAL_MODE_BITS | S_IFREG, 0);

        if (VAR_4 == -1) {

            goto out;

        }



        if (VAR_0->export_flags & V9FS_SM_MAPPED) {

            VAR_4 = local_set_xattrat(VAR_5, VAR_2, VAR_3);

        } else {

            VAR_4 = local_set_mapped_file_attrat(VAR_5, VAR_2, VAR_3);

        }

        if (VAR_4 == -1) {

            goto err_end;

        }

    } else if (VAR_0->export_flags & V9FS_SM_PASSTHROUGH ||

               VAR_0->export_flags & V9FS_SM_NONE) {

        VAR_4 = mknodat(VAR_5, VAR_2, VAR_3->fc_mode, VAR_3->fc_rdev);

        if (VAR_4 == -1) {

            goto out;

        }

        VAR_4 = local_set_cred_passthrough(VAR_0, VAR_5, VAR_2, VAR_3);

        if (VAR_4 == -1) {

            goto err_end;

        }

    }

    goto out;



err_end:

    unlinkat_preserve_errno(VAR_5, VAR_2, 0);

out:

    close_preserve_errno(VAR_5);

    return VAR_4;

}

static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
const char *VAR_2, FsCred *VAR_3)
{ int VAR_4 = -1; int VAR_5; if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE &&
local_is_mapped_file_metadata(VAR_0, VAR_2)) { errno = EINVAL; return -1; } VAR_5 = local_opendir_nofollow(VAR_0, VAR_1->data); if (VAR_5 == -1) { return -1; } if (VAR_0->export_flags & V9FS_SM_MAPPED ||
VAR_0->export_flags & V9FS_SM_MAPPED_FILE) { VAR_4 = mknodat(VAR_5, VAR_2, SM_LOCAL_MODE_BITS | S_IFREG, 0); if (VAR_4 == -1) { goto out; } if (VAR_0->export_flags & V9FS_SM_MAPPED) { VAR_4 = local_set_xattrat(VAR_5, VAR_2, VAR_3); } else { VAR_4 = local_set_mapped_file_attrat(VAR_5, VAR_2, VAR_3); } if (VAR_4 == -1) { goto err_end; } } else if (VAR_0->export_flags & V9FS_SM_PASSTHROUGH || VAR_0->export_flags & V9FS_SM_NONE) { VAR_4 = mknodat(VAR_5, VAR_2, VAR_3->fc_mode, VAR_3->fc_rdev); if (VAR_4 == -1) { goto out; } VAR_4 = local_set_cred_passthrough(VAR_0, VAR_5, VAR_2, VAR_3); if (VAR_4 == -1) { goto err_end; } } goto out; err_end:
unlinkat_preserve_errno(VAR_5, VAR_2, 0); out:
close_preserve_errno(VAR_5); return VAR_4; }