Exemple #1
0
/*
 * Rename a file or directory.
 */
static int
rename_file(char *opath, char *npath, int dir)
{
	vbox_param_t param[4];
	vboxfs_path_t opathbuf, npathbuf;
	u32_t flags;
	int r;

	if ((r = vboxfs_set_path(&opathbuf, opath)) != OK)
		return r;

	if ((r = vboxfs_set_path(&npathbuf, npath)) != OK)
		return r;

	flags = dir ? VBOXFS_RENAME_DIR : VBOXFS_RENAME_FILE;
	flags |= VBOXFS_RENAME_REPLACE;

	vbox_set_u32(&param[0], vboxfs_root);
	vbox_set_ptr(&param[1], &opathbuf, vboxfs_get_path_size(&opathbuf),
	    VBOX_DIR_OUT);
	vbox_set_ptr(&param[2], &npathbuf, vboxfs_get_path_size(&npathbuf),
	    VBOX_DIR_OUT);
	vbox_set_u32(&param[3], flags);

	return vbox_call(vboxfs_conn, VBOXFS_CALL_RENAME, param, 4, NULL);
}
Exemple #2
0
/*
 * Get or set file information.
 */
int
vboxfs_getset_info(vboxfs_handle_t handle, u32_t flags, void *data,
	size_t size)
{
	vbox_param_t param[5];

	vbox_set_u32(&param[0], vboxfs_root);
	vbox_set_u64(&param[1], handle);
	vbox_set_u32(&param[2], flags);
	vbox_set_u32(&param[3], size);
	vbox_set_ptr(&param[4], data, size, VBOX_DIR_INOUT);

	return vbox_call(vboxfs_conn, VBOXFS_CALL_INFO, param, 5, NULL);
}
Exemple #3
0
/*
 * Remove a file or directory.
 */
static int
remove_file(char *path, int dir)
{
	vbox_param_t param[3];
	vboxfs_path_t pathbuf;
	int r;

	if ((r = vboxfs_set_path(&pathbuf, path)) != OK)
		return r;

	/* FIXME: symbolic links are not supported at all yet */
	vbox_set_u32(&param[0], vboxfs_root);
	vbox_set_ptr(&param[1], &pathbuf, vboxfs_get_path_size(&pathbuf),
	    VBOX_DIR_OUT);
	vbox_set_u32(&param[2], dir ? VBOXFS_REMOVE_DIR : VBOXFS_REMOVE_FILE);

	return vbox_call(vboxfs_conn, VBOXFS_CALL_REMOVE, param, 3, NULL);
}
Exemple #4
0
/*
 * Get file attributes.
 */
int
vboxfs_getattr(char *path, struct sffs_attr *attr)
{
    vbox_param_t param[3];
    vboxfs_path_t pathbuf;
    vboxfs_crinfo_t crinfo;
    int r;

    if ((r = vboxfs_set_path(&pathbuf, path)) != OK)
        return r;

    memset(&crinfo, 0, sizeof(crinfo));
    crinfo.flags = VBOXFS_CRFLAG_LOOKUP;
    /* crinfo.info.attr.add is not checked */

    vbox_set_u32(&param[0], vboxfs_root);
    vbox_set_ptr(&param[1], &pathbuf, vboxfs_get_path_size(&pathbuf),
                 VBOX_DIR_OUT);
    vbox_set_ptr(&param[2], &crinfo, sizeof(crinfo), VBOX_DIR_INOUT);

    r = vbox_call(vboxfs_conn, VBOXFS_CALL_CREATE, param, 3, NULL);
    if (r != OK)
        return r;

    switch (crinfo.result) {
    case VBOXFS_PATH_NOT_FOUND:
    /* This could also be ENOTDIR. See note in handle.c. */
    case VBOXFS_FILE_NOT_FOUND:
        return ENOENT;
    case VBOXFS_FILE_EXISTS:
        break;			/* success */
    default:
        return EIO;		/* should never happen */
    }

    vboxfs_get_attr(attr, &crinfo.info);

    return OK;
}