static int handle_name_to_path(FsContext *ctx, V9fsPath *dir_path,

                              const char *name, V9fsPath *target)

{

    char buffer[PATH_MAX];

    struct file_handle *fh;

    int dirfd, ret, mnt_id;

    struct handle_data *data = (struct handle_data *)ctx->private;



    /* "." and ".." are not allowed */

    if (!strcmp(name, ".") || !strcmp(name, "..")) {

        errno = EINVAL;

        return -1;



    }

    if (dir_path) {

        dirfd = open_by_handle(data->mountfd, dir_path->data, O_PATH);

    } else {

        /* relative to export root */

        dirfd = open(rpath(ctx, ".", buffer), O_DIRECTORY);

    }

    if (dirfd < 0) {

        return dirfd;

    }

    fh = g_malloc(sizeof(struct file_handle) + data->handle_bytes);

    fh->handle_bytes = data->handle_bytes;

    /* add a "./" at the beginning of the path */

    snprintf(buffer, PATH_MAX, "./%s", name);

    /* flag = 0 imply don't follow symlink */

    ret = name_to_handle(dirfd, buffer, fh, &mnt_id, 0);

    if (!ret) {

        target->data = (char *)fh;

        target->size = sizeof(struct file_handle) + data->handle_bytes;

    } else {

        g_free(fh);

    }

    close(dirfd);

    return ret;

}

static int handle_name_to_path(FsContext *ctx, V9fsPath *dir_path,

                              const char *name, V9fsPath *target)

{

    char buffer[PATH_MAX];

    struct file_handle *fh;

    int dirfd, ret, mnt_id;

    struct handle_data *data = (struct handle_data *)ctx->private;



    

    if (!strcmp(name, ".") || !strcmp(name, "..")) {

        errno = EINVAL;

        return -1;



    }

    if (dir_path) {

        dirfd = open_by_handle(data->mountfd, dir_path->data, O_PATH);

    } else {

        

        dirfd = open(rpath(ctx, ".", buffer), O_DIRECTORY);

    }

    if (dirfd < 0) {

        return dirfd;

    }

    fh = g_malloc(sizeof(struct file_handle) + data->handle_bytes);

    fh->handle_bytes = data->handle_bytes;

    

    snprintf(buffer, PATH_MAX, "./%s", name);

    

    ret = name_to_handle(dirfd, buffer, fh, &mnt_id, 0);

    if (!ret) {

        target->data = (char *)fh;

        target->size = sizeof(struct file_handle) + data->handle_bytes;

    } else {

        g_free(fh);

    }

    close(dirfd);

    return ret;

}

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

                              const char *VAR_2, V9fsPath *VAR_3)

{

    char VAR_4[PATH_MAX];

    struct file_handle *VAR_5;

    int VAR_6, VAR_7, VAR_8;

    struct handle_data *VAR_9 = (struct handle_data *)VAR_0->private;



    

    if (!strcmp(VAR_2, ".") || !strcmp(VAR_2, "..")) {

        errno = EINVAL;

        return -1;



    }

    if (VAR_1) {

        VAR_6 = open_by_handle(VAR_9->mountfd, VAR_1->VAR_9, O_PATH);

    } else {

        

        VAR_6 = open(rpath(VAR_0, ".", VAR_4), O_DIRECTORY);

    }

    if (VAR_6 < 0) {

        return VAR_6;

    }

    VAR_5 = g_malloc(sizeof(struct file_handle) + VAR_9->handle_bytes);

    VAR_5->handle_bytes = VAR_9->handle_bytes;

    

    snprintf(VAR_4, PATH_MAX, "./%s", VAR_2);

    

    VAR_7 = name_to_handle(VAR_6, VAR_4, VAR_5, &VAR_8, 0);

    if (!VAR_7) {

        VAR_3->VAR_9 = (char *)VAR_5;

        VAR_3->size = sizeof(struct file_handle) + VAR_9->handle_bytes;

    } else {

        g_free(VAR_5);

    }

    close(VAR_6);

    return VAR_7;

}

static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,
const char *VAR_2, V9fsPath *VAR_3)
{ char VAR_4[PATH_MAX]; struct file_handle *VAR_5; int VAR_6, VAR_7, VAR_8; struct handle_data *VAR_9 = (struct handle_data *)VAR_0->private; if (!strcmp(VAR_2, ".") || !strcmp(VAR_2, "..")) { errno = EINVAL; return -1; } if (VAR_1) { VAR_6 = open_by_handle(VAR_9->mountfd, VAR_1->VAR_9, O_PATH); } else { VAR_6 = open(rpath(VAR_0, ".", VAR_4), O_DIRECTORY); } if (VAR_6 < 0) { return VAR_6; } VAR_5 = g_malloc(sizeof(struct file_handle) + VAR_9->handle_bytes); VAR_5->handle_bytes = VAR_9->handle_bytes; snprintf(VAR_4, PATH_MAX, "./%s", VAR_2); VAR_7 = name_to_handle(VAR_6, VAR_4, VAR_5, &VAR_8, 0); if (!VAR_7) { VAR_3->VAR_9 = (char *)VAR_5; VAR_3->size = sizeof(struct file_handle) + VAR_9->handle_bytes; } else { g_free(VAR_5); } close(VAR_6); return VAR_7; }