1 /* Part of libvboxfs - (c) 2012, D.C. van Moolenbroek */
9 vboxfs_mkdir(char *path
, int mode
)
14 assert(S_ISDIR(mode
));
16 if ((r
= vboxfs_open_file(path
, O_CREAT
| O_EXCL
| O_WRONLY
, mode
, &h
,
26 * Remove a file or directory.
29 remove_file(char *path
, int dir
)
31 vbox_param_t param
[3];
32 vboxfs_path_t pathbuf
;
35 if ((r
= vboxfs_set_path(&pathbuf
, path
)) != OK
)
38 /* FIXME: symbolic links are not supported at all yet */
39 vbox_set_u32(¶m
[0], vboxfs_root
);
40 vbox_set_ptr(¶m
[1], &pathbuf
, vboxfs_get_path_size(&pathbuf
),
42 vbox_set_u32(¶m
[2], dir
? VBOXFS_REMOVE_DIR
: VBOXFS_REMOVE_FILE
);
44 return vbox_call(vboxfs_conn
, VBOXFS_CALL_REMOVE
, param
, 3, NULL
);
51 vboxfs_unlink(char *path
)
54 return remove_file(path
, FALSE
/*dir*/);
61 vboxfs_rmdir(char *path
)
64 return remove_file(path
, TRUE
/*dir*/);
68 * Rename a file or directory.
71 rename_file(char *opath
, char *npath
, int dir
)
73 vbox_param_t param
[4];
74 vboxfs_path_t opathbuf
, npathbuf
;
78 if ((r
= vboxfs_set_path(&opathbuf
, opath
)) != OK
)
81 if ((r
= vboxfs_set_path(&npathbuf
, npath
)) != OK
)
84 flags
= dir
? VBOXFS_RENAME_DIR
: VBOXFS_RENAME_FILE
;
85 flags
|= VBOXFS_RENAME_REPLACE
;
87 vbox_set_u32(¶m
[0], vboxfs_root
);
88 vbox_set_ptr(¶m
[1], &opathbuf
, vboxfs_get_path_size(&opathbuf
),
90 vbox_set_ptr(¶m
[2], &npathbuf
, vboxfs_get_path_size(&npathbuf
),
92 vbox_set_u32(¶m
[3], flags
);
94 return vbox_call(vboxfs_conn
, VBOXFS_CALL_RENAME
, param
, 4, NULL
);
98 * Rename a file or directory.
101 vboxfs_rename(char *opath
, char *npath
)
105 if ((r
= rename_file(opath
, npath
, FALSE
/*dir*/)) != EISDIR
)
108 return rename_file(opath
, npath
, TRUE
/*dir*/);