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

                       const char *name, FsCred *credp)

{

    char *path;

    int err = -1;

    int serrno = 0;

    V9fsString fullname;

    char buffer[PATH_MAX];



    v9fs_string_init(&fullname);

    v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);

    path = fullname.data;



    /* Determine the security model */

    if (fs_ctx->export_flags & V9FS_SM_MAPPED) {

        err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);

        if (err == -1) {

            goto out;

        }

        credp->fc_mode = credp->fc_mode|S_IFDIR;

        err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);

        if (err == -1) {

            serrno = errno;

            goto err_end;

        }

    } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {

        err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);

        if (err == -1) {

            goto out;

        }

        credp->fc_mode = credp->fc_mode|S_IFDIR;

        err = local_set_mapped_file_attr(fs_ctx, path, credp);

        if (err == -1) {

            serrno = errno;

            goto err_end;

        }

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

               (fs_ctx->export_flags & V9FS_SM_NONE)) {

        err = mkdir(rpath(fs_ctx, path, buffer), credp->fc_mode);

        if (err == -1) {

            goto out;

        }

        err = local_post_create_passthrough(fs_ctx, path, credp);

        if (err == -1) {

            serrno = errno;

            goto err_end;

        }

    }

    goto out;



err_end:

    remove(rpath(fs_ctx, path, buffer));

    errno = serrno;

out:

    v9fs_string_free(&fullname);

    return err;

}

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

                       const char *name, FsCred *credp)

{

    char *path;

    int err = -1;

    int serrno = 0;

    V9fsString fullname;

    char buffer[PATH_MAX];



    v9fs_string_init(&fullname);

    v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);

    path = fullname.data;



    

    if (fs_ctx->export_flags & V9FS_SM_MAPPED) {

        err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);

        if (err == -1) {

            goto out;

        }

        credp->fc_mode = credp->fc_mode|S_IFDIR;

        err = local_set_xattr(rpath(fs_ctx, path, buffer), credp);

        if (err == -1) {

            serrno = errno;

            goto err_end;

        }

    } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {

        err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS);

        if (err == -1) {

            goto out;

        }

        credp->fc_mode = credp->fc_mode|S_IFDIR;

        err = local_set_mapped_file_attr(fs_ctx, path, credp);

        if (err == -1) {

            serrno = errno;

            goto err_end;

        }

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

               (fs_ctx->export_flags & V9FS_SM_NONE)) {

        err = mkdir(rpath(fs_ctx, path, buffer), credp->fc_mode);

        if (err == -1) {

            goto out;

        }

        err = local_post_create_passthrough(fs_ctx, path, credp);

        if (err == -1) {

            serrno = errno;

            goto err_end;

        }

    }

    goto out;



err_end:

    remove(rpath(fs_ctx, path, buffer));

    errno = serrno;

out:

    v9fs_string_free(&fullname);

    return err;

}

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

                       const char *VAR_2, FsCred *VAR_3)

{

    char *VAR_4;

    int VAR_5 = -1;

    int VAR_6 = 0;

    V9fsString fullname;

    char VAR_7[PATH_MAX];



    v9fs_string_init(&fullname);

    v9fs_string_sprintf(&fullname, "%s/%s", VAR_1->data, VAR_2);

    VAR_4 = fullname.data;



    

    if (VAR_0->export_flags & V9FS_SM_MAPPED) {

        VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), SM_LOCAL_DIR_MODE_BITS);

        if (VAR_5 == -1) {

            goto out;

        }

        VAR_3->fc_mode = VAR_3->fc_mode|S_IFDIR;

        VAR_5 = local_set_xattr(rpath(VAR_0, VAR_4, VAR_7), VAR_3);

        if (VAR_5 == -1) {

            VAR_6 = errno;

            goto err_end;

        }

    } else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {

        VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), SM_LOCAL_DIR_MODE_BITS);

        if (VAR_5 == -1) {

            goto out;

        }

        VAR_3->fc_mode = VAR_3->fc_mode|S_IFDIR;

        VAR_5 = local_set_mapped_file_attr(VAR_0, VAR_4, VAR_3);

        if (VAR_5 == -1) {

            VAR_6 = errno;

            goto err_end;

        }

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

               (VAR_0->export_flags & V9FS_SM_NONE)) {

        VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), VAR_3->fc_mode);

        if (VAR_5 == -1) {

            goto out;

        }

        VAR_5 = local_post_create_passthrough(VAR_0, VAR_4, VAR_3);

        if (VAR_5 == -1) {

            VAR_6 = errno;

            goto err_end;

        }

    }

    goto out;



err_end:

    remove(rpath(VAR_0, VAR_4, VAR_7));

    errno = VAR_6;

out:

    v9fs_string_free(&fullname);

    return VAR_5;

}

static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
const char *VAR_2, FsCred *VAR_3)
{ char *VAR_4; int VAR_5 = -1; int VAR_6 = 0; V9fsString fullname; char VAR_7[PATH_MAX]; v9fs_string_init(&fullname); v9fs_string_sprintf(&fullname, "%s/%s", VAR_1->data, VAR_2); VAR_4 = fullname.data; if (VAR_0->export_flags & V9FS_SM_MAPPED) { VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), SM_LOCAL_DIR_MODE_BITS); if (VAR_5 == -1) { goto out; } VAR_3->fc_mode = VAR_3->fc_mode|S_IFDIR; VAR_5 = local_set_xattr(rpath(VAR_0, VAR_4, VAR_7), VAR_3); if (VAR_5 == -1) { VAR_6 = errno; goto err_end; } } else if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) { VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), SM_LOCAL_DIR_MODE_BITS); if (VAR_5 == -1) { goto out; } VAR_3->fc_mode = VAR_3->fc_mode|S_IFDIR; VAR_5 = local_set_mapped_file_attr(VAR_0, VAR_4, VAR_3); if (VAR_5 == -1) { VAR_6 = errno; goto err_end; } } else if ((VAR_0->export_flags & V9FS_SM_PASSTHROUGH) || (VAR_0->export_flags & V9FS_SM_NONE)) { VAR_5 = mkdir(rpath(VAR_0, VAR_4, VAR_7), VAR_3->fc_mode); if (VAR_5 == -1) { goto out; } VAR_5 = local_post_create_passthrough(VAR_0, VAR_4, VAR_3); if (VAR_5 == -1) { VAR_6 = errno; goto err_end; } } goto out; err_end:
remove(rpath(VAR_0, VAR_4, VAR_7)); errno = VAR_6; out:
v9fs_string_free(&fullname); return VAR_5; }