libsffs: make path names constant

And a few other related warning fixes.

Change-Id: I1a49b9ee04c2b1bf80bc943272f72ffd6de77ef6
This commit is contained in:
David van Moolenbroek 2014-08-23 22:28:01 +00:00
parent 1dcfbcd173
commit 94e65446c4
20 changed files with 65 additions and 69 deletions

View file

@ -28,7 +28,7 @@ struct sffs_attr {
#define SFFS_ATTR_MODE 0x20 /* get/set file mode */
struct sffs_table {
int (*t_open)(char *path, int flags, int mode, sffs_file_t *handle);
int (*t_open)(const char *path, int flags, int mode, sffs_file_t *handle);
ssize_t (*t_read)(sffs_file_t handle, char *buf, size_t size, u64_t pos);
ssize_t (*t_write)(sffs_file_t handle, char *buf, size_t size, u64_t pos);
int (*t_close)(sffs_file_t handle);
@ -36,20 +36,20 @@ struct sffs_table {
size_t (*t_readbuf)(char **ptr);
size_t (*t_writebuf)(char **ptr);
int (*t_opendir)(char *path, sffs_dir_t *handle);
int (*t_opendir)(const char *path, sffs_dir_t *handle);
int (*t_readdir)(sffs_dir_t handle, unsigned int index, char *buf,
size_t size, struct sffs_attr *attr);
int (*t_closedir)(sffs_dir_t handle);
int (*t_getattr)(char *path, struct sffs_attr *attr);
int (*t_setattr)(char *path, struct sffs_attr *attr);
int (*t_getattr)(const char *path, struct sffs_attr *attr);
int (*t_setattr)(const char *path, struct sffs_attr *attr);
int (*t_mkdir)(char *path, int mode);
int (*t_unlink)(char *path);
int (*t_rmdir)(char *path);
int (*t_rename)(char *opath, char *npath);
int (*t_mkdir)(const char *path, int mode);
int (*t_unlink)(const char *path);
int (*t_rmdir)(const char *path);
int (*t_rename)(const char *opath, const char *npath);
int (*t_queryvol)(char *path, u64_t *free, u64_t *total);
int (*t_queryvol)(const char *path, u64_t *free, u64_t *total);
};
struct sffs_params {

View file

@ -7,7 +7,7 @@ typedef int vbox_conn_t;
extern int vbox_init(void);
extern vbox_conn_t vbox_open(char *name);
extern vbox_conn_t vbox_open(const char *name);
extern int vbox_close(vbox_conn_t conn);
extern int vbox_call(vbox_conn_t conn, u32_t function, vbox_param_t *param,
int count, int *code);

View file

@ -1,6 +1,3 @@
NOGCCERROR=yes
NOCLANGERROR=yes
# Makefile for HGFS library
LIB= hgfs

View file

@ -34,7 +34,7 @@ void attr_get(struct sffs_attr *attr)
/*===========================================================================*
* hgfs_getattr *
*===========================================================================*/
int hgfs_getattr(char *path, struct sffs_attr *attr)
int hgfs_getattr(const char *path, struct sffs_attr *attr)
{
/* Get selected attributes of a file by path name.
*/
@ -55,7 +55,7 @@ int hgfs_getattr(char *path, struct sffs_attr *attr)
/*===========================================================================*
* hgfs_setattr *
*===========================================================================*/
int hgfs_setattr(char *path, struct sffs_attr *attr)
int hgfs_setattr(const char *path, struct sffs_attr *attr)
{
/* Set selected attributes of a file by path name.
*/

View file

@ -5,7 +5,7 @@
/*===========================================================================*
* hgfs_opendir *
*===========================================================================*/
int hgfs_opendir(char *path, sffs_dir_t *handle)
int hgfs_opendir(const char *path, sffs_dir_t *handle)
{
/* Open a directory. Store a directory handle upon success.
*/

View file

@ -9,7 +9,7 @@
* hgfs_open *
*===========================================================================*/
int hgfs_open(
char *path, /* path name to open */
const char *path, /* path name to open */
int flags, /* open flags to use */
int mode, /* mode to create (user bits only) */
sffs_file_t *handle /* place to store resulting handle */
@ -60,7 +60,8 @@ ssize_t hgfs_read(
{
/* Read from an open file. Upon success, return the number of bytes read.
*/
int r, len, max;
size_t len, max;
int r;
RPC_REQUEST(HGFS_REQ_READ);
RPC_NEXT32 = (u32_t)handle;

View file

@ -5,7 +5,7 @@
/*===========================================================================*
* hgfs_queryvol *
*===========================================================================*/
int hgfs_queryvol(char *path, u64_t *free, u64_t *total)
int hgfs_queryvol(const char *path, u64_t *free, u64_t *total)
{
/* Retrieve information about available and total volume space associated with
* a given path.

View file

@ -7,7 +7,7 @@
/*===========================================================================*
* hgfs_mkdir *
*===========================================================================*/
int hgfs_mkdir(char *path, int mode)
int hgfs_mkdir(const char *path, int mode)
{
/* Create a new directory.
*/
@ -23,7 +23,7 @@ int hgfs_mkdir(char *path, int mode)
/*===========================================================================*
* hgfs_unlink *
*===========================================================================*/
int hgfs_unlink(char *path)
int hgfs_unlink(const char *path)
{
/* Delete a file.
*/
@ -38,7 +38,7 @@ int hgfs_unlink(char *path)
/*===========================================================================*
* hgfs_rmdir *
*===========================================================================*/
int hgfs_rmdir(char *path)
int hgfs_rmdir(const char *path)
{
/* Remove an empty directory.
*/
@ -53,7 +53,7 @@ int hgfs_rmdir(char *path)
/*===========================================================================*
* hgfs_rename *
*===========================================================================*/
int hgfs_rename(char *opath, char *npath)
int hgfs_rename(const char *opath, const char *npath)
{
/* Rename a file or directory.
*/

View file

@ -7,13 +7,14 @@
/*===========================================================================*
* path_put *
*===========================================================================*/
void path_put(char *path)
void path_put(const char *path)
{
/* Append the given path name in HGFS format to the RPC buffer. Truncate it
* if it is longer than PATH_MAX bytes.
*/
char *p, buf[PATH_MAX];
int len;
const char *p;
char buf[PATH_MAX];
unsigned int len;
/* No leading slashes are allowed. */
for (p = path; *p == '/'; p++);

View file

@ -3,8 +3,8 @@
/* attr.c */
#define attr_get PREFIX(attr_get)
void attr_get(struct sffs_attr *attr);
int hgfs_getattr(char *path, struct sffs_attr *attr);
int hgfs_setattr(char *path, struct sffs_attr *attr);
int hgfs_getattr(const char *path, struct sffs_attr *attr);
int hgfs_setattr(const char *path, struct sffs_attr *attr);
/* backdoor.s */
#define backdoor PREFIX(backdoor)
@ -25,7 +25,7 @@ int channel_send(struct channel *ch, char *buf, int len);
int channel_recv(struct channel *ch, char *buf, int max);
/* dir.c */
int hgfs_opendir(char *path, sffs_dir_t *handle);
int hgfs_opendir(const char *path, sffs_dir_t *handle);
int hgfs_readdir(sffs_dir_t handle, unsigned int index, char *buf, size_t size,
struct sffs_attr *attr);
int hgfs_closedir(sffs_dir_t handle);
@ -35,7 +35,7 @@ int hgfs_closedir(sffs_dir_t handle);
int error_convert(int err);
/* file.c */
int hgfs_open(char *path, int flags, int mode, sffs_file_t *handle);
int hgfs_open(const char *path, int flags, int mode, sffs_file_t *handle);
ssize_t hgfs_read(sffs_file_t handle, char *buf, size_t size, u64_t offset);
ssize_t hgfs_write(sffs_file_t handle, char *buf, size_t len, u64_t offset);
int hgfs_close(sffs_file_t handle);
@ -43,18 +43,18 @@ size_t hgfs_readbuf(char **ptr);
size_t hgfs_writebuf(char **ptr);
/* info.c */
int hgfs_queryvol(char *path, u64_t *free, u64_t *total);
int hgfs_queryvol(const char *path, u64_t *free, u64_t *total);
/* link.c */
int hgfs_mkdir(char *path, int mode);
int hgfs_unlink(char *path);
int hgfs_rmdir(char *path);
int hgfs_rename(char *opath, char *npath);
int hgfs_mkdir(const char *path, int mode);
int hgfs_unlink(const char *path);
int hgfs_rmdir(const char *path);
int hgfs_rename(const char *opath, const char *npath);
/* path.c */
#define path_put PREFIX(path_put)
#define path_get PREFIX(path_get)
void path_put(char *path);
void path_put(const char *path);
int path_get(char *path, int max);
/* rpc.c */

View file

@ -24,7 +24,7 @@ int vbox_init(void)
return OK;
}
vbox_conn_t vbox_open(char *name)
vbox_conn_t vbox_open(const char *name)
{
/* Open a VirtualBox HGCM connection.
*/

View file

@ -1,6 +1,3 @@
NOGCCERROR=yes
NOCLANGERROR=yes
# Makefile for libvboxfs
.include <bsd.own.mk>

View file

@ -49,7 +49,7 @@ vboxfs_get_attr(struct sffs_attr *attr, vboxfs_objinfo_t *info)
* Get file attributes.
*/
int
vboxfs_getattr(char *path, struct sffs_attr *attr)
vboxfs_getattr(const char *path, struct sffs_attr *attr)
{
vbox_param_t param[3];
vboxfs_path_t pathbuf;
@ -92,7 +92,7 @@ vboxfs_getattr(char *path, struct sffs_attr *attr)
* Set file size.
*/
static int
set_size(char *path, u64_t size)
set_size(const char *path, u64_t size)
{
vboxfs_objinfo_t info;
vboxfs_handle_t h;
@ -116,7 +116,7 @@ set_size(char *path, u64_t size)
* Set file attributes.
*/
int
vboxfs_setattr(char *path, struct sffs_attr *attr)
vboxfs_setattr(const char *path, struct sffs_attr *attr)
{
vboxfs_objinfo_t info;
vboxfs_handle_t h;

View file

@ -143,7 +143,7 @@ read_dir(vboxfs_handle_t handle, sffs_dir_t *dirp)
* Open a directory.
*/
int
vboxfs_opendir(char *path, sffs_dir_t *handle)
vboxfs_opendir(const char *path, sffs_dir_t *handle)
{
vboxfs_handle_t h;
int r;

View file

@ -21,7 +21,7 @@ static char iobuf[VBOXFS_MAX_FILEIO];
* Open a file.
*/
int
vboxfs_open(char *path, int flags, int mode, sffs_file_t *handle)
vboxfs_open(const char *path, int flags, int mode, sffs_file_t *handle)
{
vboxfs_handle_t *handlep;
int r;

View file

@ -6,8 +6,8 @@
* Create or open a file or directory.
*/
int
vboxfs_open_file(char *path, int flags, int mode, vboxfs_handle_t *handlep,
vboxfs_objinfo_t *infop)
vboxfs_open_file(const char *path, int flags, int mode,
vboxfs_handle_t *handlep, vboxfs_objinfo_t *infop)
{
vbox_param_t param[3];
vboxfs_path_t pathbuf;

View file

@ -24,7 +24,7 @@ vboxfs_getset_info(vboxfs_handle_t handle, u32_t flags, void *data,
* Query volume information.
*/
int
vboxfs_query_vol(char *path, vboxfs_volinfo_t *volinfo)
vboxfs_query_vol(const char *path, vboxfs_volinfo_t *volinfo)
{
vboxfs_handle_t h;
int r;
@ -44,7 +44,7 @@ vboxfs_query_vol(char *path, vboxfs_volinfo_t *volinfo)
* Query volume information.
*/
int
vboxfs_queryvol(char *path, u64_t *free, u64_t *total)
vboxfs_queryvol(const char *path, u64_t *free, u64_t *total)
{
vboxfs_volinfo_t volinfo;
int r;

View file

@ -6,7 +6,7 @@
* Create a directory.
*/
int
vboxfs_mkdir(char *path, int mode)
vboxfs_mkdir(const char *path, int mode)
{
vboxfs_handle_t h;
int r;
@ -26,7 +26,7 @@ vboxfs_mkdir(char *path, int mode)
* Remove a file or directory.
*/
static int
remove_file(char *path, int dir)
remove_file(const char *path, int dir)
{
vbox_param_t param[3];
vboxfs_path_t pathbuf;
@ -48,7 +48,7 @@ remove_file(char *path, int dir)
* Unlink a file.
*/
int
vboxfs_unlink(char *path)
vboxfs_unlink(const char *path)
{
return remove_file(path, FALSE /*dir*/);
@ -58,7 +58,7 @@ vboxfs_unlink(char *path)
* Remove a directory.
*/
int
vboxfs_rmdir(char *path)
vboxfs_rmdir(const char *path)
{
return remove_file(path, TRUE /*dir*/);
@ -68,7 +68,7 @@ vboxfs_rmdir(char *path)
* Rename a file or directory.
*/
static int
rename_file(char *opath, char *npath, int dir)
rename_file(const char *opath, const char *npath, int dir)
{
vbox_param_t param[4];
vboxfs_path_t opathbuf, npathbuf;
@ -98,7 +98,7 @@ rename_file(char *opath, char *npath, int dir)
* Rename a file or directory.
*/
int
vboxfs_rename(char *opath, char *npath)
vboxfs_rename(const char *opath, const char *npath)
{
int r;

View file

@ -9,7 +9,7 @@
* will be initialized to the empty string.
*/
int
vboxfs_set_path(vboxfs_path_t *path, char *name)
vboxfs_set_path(vboxfs_path_t *path, const char *name)
{
size_t len;

View file

@ -5,41 +5,41 @@
/* attr.c */
void vboxfs_get_attr(struct sffs_attr *attr, vboxfs_objinfo_t *info);
int vboxfs_getattr(char *path, struct sffs_attr *attr);
int vboxfs_setattr(char *path, struct sffs_attr *attr);
int vboxfs_getattr(const char *path, struct sffs_attr *attr);
int vboxfs_setattr(const char *path, struct sffs_attr *attr);
/* dir.c */
int vboxfs_opendir(char *path, sffs_dir_t *handle);
int vboxfs_opendir(const char *path, sffs_dir_t *handle);
int vboxfs_readdir(sffs_dir_t handle, unsigned int index, char *buf,
size_t size, struct sffs_attr *attr);
int vboxfs_closedir(sffs_dir_t handle);
/* file.c */
int vboxfs_open(char *path, int flags, int mode, sffs_file_t *handle);
int vboxfs_open(const char *path, int flags, int mode, sffs_file_t *handle);
ssize_t vboxfs_read(sffs_file_t handle, char *buf, size_t size, u64_t pos);
ssize_t vboxfs_write(sffs_file_t handle, char *buf, size_t len, u64_t pos);
int vboxfs_close(sffs_file_t handle);
size_t vboxfs_buffer(char **ptr);
/* handle.c */
int vboxfs_open_file(char *path, int flags, int mode, vboxfs_handle_t *handlep,
vboxfs_objinfo_t *infop);
int vboxfs_open_file(const char *path, int flags, int mode,
vboxfs_handle_t *handlep, vboxfs_objinfo_t *infop);
void vboxfs_close_file(vboxfs_handle_t handle);
/* info.c */
int vboxfs_getset_info(vboxfs_handle_t handle, u32_t flags, void *data,
size_t size);
int vboxfs_query_vol(char *path, vboxfs_volinfo_t *volinfo);
int vboxfs_queryvol(char *path, u64_t *free, u64_t *total);
int vboxfs_query_vol(const char *path, vboxfs_volinfo_t *volinfo);
int vboxfs_queryvol(const char *path, u64_t *free, u64_t *total);
/* link.c */
int vboxfs_mkdir(char *path, int mode);
int vboxfs_unlink(char *path);
int vboxfs_rmdir(char *path);
int vboxfs_rename(char *opath, char *npath);
int vboxfs_mkdir(const char *path, int mode);
int vboxfs_unlink(const char *path);
int vboxfs_rmdir(const char *path);
int vboxfs_rename(const char *opath, const char *npath);
/* path.c */
int vboxfs_set_path(vboxfs_path_t *path, char *name);
int vboxfs_set_path(vboxfs_path_t *path, const char *name);
int vboxfs_get_path(vboxfs_path_t *path, char *name, size_t size);
size_t vboxfs_get_path_size(vboxfs_path_t *path);