static int local_link(FsContext *ctx, V9fsPath *oldpath,

                      V9fsPath *dirpath, const char *name)

{

    int ret;

    V9fsString newpath;

    char *buffer, *buffer1;

    int serrno;



    v9fs_string_init(&newpath);

    v9fs_string_sprintf(&newpath, "%s/%s", dirpath->data, name);



    buffer = rpath(ctx, oldpath->data);

    buffer1 = rpath(ctx, newpath.data);

    ret = link(buffer, buffer1);

    g_free(buffer);

    if (ret < 0) {

        goto out;

    }



    /* now link the virtfs_metadata files */

    if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {

        char *vbuffer, *vbuffer1;



        /* Link the .virtfs_metadata files. Create the metada directory */

        ret = local_create_mapped_attr_dir(ctx, newpath.data);

        if (ret < 0) {

            goto err_out;

        }

        vbuffer = local_mapped_attr_path(ctx, oldpath->data);

        vbuffer1 = local_mapped_attr_path(ctx, newpath.data);

        ret = link(vbuffer, vbuffer1);

        g_free(vbuffer);

        g_free(vbuffer1);

        if (ret < 0 && errno != ENOENT) {

            goto err_out;

        }

    }

    goto out;



err_out:

    serrno = errno;

    remove(buffer1);

    errno = serrno;

out:

    g_free(buffer1);

    v9fs_string_free(&newpath);

    return ret;

}

static int local_link(FsContext *ctx, V9fsPath *oldpath,

                      V9fsPath *dirpath, const char *name)

{

    int ret;

    V9fsString newpath;

    char *buffer, *buffer1;

    int serrno;



    v9fs_string_init(&newpath);

    v9fs_string_sprintf(&newpath, "%s/%s", dirpath->data, name);



    buffer = rpath(ctx, oldpath->data);

    buffer1 = rpath(ctx, newpath.data);

    ret = link(buffer, buffer1);

    g_free(buffer);

    if (ret < 0) {

        goto out;

    }



    

    if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {

        char *vbuffer, *vbuffer1;



        

        ret = local_create_mapped_attr_dir(ctx, newpath.data);

        if (ret < 0) {

            goto err_out;

        }

        vbuffer = local_mapped_attr_path(ctx, oldpath->data);

        vbuffer1 = local_mapped_attr_path(ctx, newpath.data);

        ret = link(vbuffer, vbuffer1);

        g_free(vbuffer);

        g_free(vbuffer1);

        if (ret < 0 && errno != ENOENT) {

            goto err_out;

        }

    }

    goto out;



err_out:

    serrno = errno;

    remove(buffer1);

    errno = serrno;

out:

    g_free(buffer1);

    v9fs_string_free(&newpath);

    return ret;

}

    int ret;     V9fsString newpath;     char *buffer, *buffer1;     int serrno;     v9fs_string_init(&newpath);     v9fs_string_sprintf(&newpath, "%s/%s", dirpath->data, name);     buffer = rpath(ctx, oldpath->data);     buffer1 = rpath(ctx, newpath.data);     ret = link(buffer, buffer1);     g_free(buffer);     if (ret < 0) {         char *vbuffer, *vbuffer1;         ret = local_create_mapped_attr_dir(ctx, newpath.data);         if (ret < 0) {             goto err_out;         vbuffer = local_mapped_attr_path(ctx, oldpath->data);         vbuffer1 = local_mapped_attr_path(ctx, newpath.data);         ret = link(vbuffer, vbuffer1);         g_free(vbuffer);         g_free(vbuffer1);             goto err_out;     goto out; err_out:     serrno = errno;     remove(buffer1);     errno = serrno;     g_free(buffer1);     v9fs_string_free(&newpath);
static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,

                      V9fsPath *VAR_2, const char *VAR_3)

{

    int VAR_4;

    V9fsString newpath;

    char *VAR_5, *VAR_6;

    int VAR_7;



    v9fs_string_init(&newpath);

    v9fs_string_sprintf(&newpath, "%s/%s", VAR_2->data, VAR_3);



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

    VAR_6 = rpath(VAR_0, newpath.data);

    VAR_4 = link(VAR_5, VAR_6);

    g_free(VAR_5);

    if (VAR_4 < 0) {

        goto out;

    }



    

    if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) {

        char *VAR_8, *VAR_9;



        

        VAR_4 = local_create_mapped_attr_dir(VAR_0, newpath.data);

        if (VAR_4 < 0) {

            goto err_out;

        }

        VAR_8 = local_mapped_attr_path(VAR_0, VAR_1->data);

        VAR_9 = local_mapped_attr_path(VAR_0, newpath.data);

        VAR_4 = link(VAR_8, VAR_9);

        g_free(VAR_8);

        g_free(VAR_9);

        if (VAR_4 < 0 && errno != ENOENT) {

            goto err_out;

        }

    }

    goto out;



err_out:

    VAR_7 = errno;

    remove(VAR_6);

    errno = VAR_7;

out:

    g_free(VAR_6);

    v9fs_string_free(&newpath);

    return VAR_4;

}

static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
V9fsPath *VAR_2, const char *VAR_3)
{ int VAR_4; V9fsString newpath; char *VAR_5, *VAR_6; int VAR_7; v9fs_string_init(&newpath); v9fs_string_sprintf(&newpath, "%s/%s", VAR_2->data, VAR_3); VAR_5 = rpath(VAR_0, VAR_1->data); VAR_6 = rpath(VAR_0, newpath.data); VAR_4 = link(VAR_5, VAR_6); g_free(VAR_5); if (VAR_4 < 0) { goto out; } if (VAR_0->export_flags & V9FS_SM_MAPPED_FILE) { char *VAR_8, *VAR_9; VAR_4 = local_create_mapped_attr_dir(VAR_0, newpath.data); if (VAR_4 < 0) { goto err_out; } VAR_8 = local_mapped_attr_path(VAR_0, VAR_1->data); VAR_9 = local_mapped_attr_path(VAR_0, newpath.data); VAR_4 = link(VAR_8, VAR_9); g_free(VAR_8); g_free(VAR_9); if (VAR_4 < 0 && errno != ENOENT) { goto err_out; } } goto out; err_out:
VAR_7 = errno; remove(VAR_6); errno = VAR_7; out:
g_free(VAR_6); v9fs_string_free(&newpath); return VAR_4; }