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 */ #define SFFS_ATTR_MODE 0x20 /* get/set file mode */
struct sffs_table { 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_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); ssize_t (*t_write)(sffs_file_t handle, char *buf, size_t size, u64_t pos);
int (*t_close)(sffs_file_t handle); int (*t_close)(sffs_file_t handle);
@ -36,20 +36,20 @@ struct sffs_table {
size_t (*t_readbuf)(char **ptr); size_t (*t_readbuf)(char **ptr);
size_t (*t_writebuf)(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, int (*t_readdir)(sffs_dir_t handle, unsigned int index, char *buf,
size_t size, struct sffs_attr *attr); size_t size, struct sffs_attr *attr);
int (*t_closedir)(sffs_dir_t handle); int (*t_closedir)(sffs_dir_t handle);
int (*t_getattr)(char *path, struct sffs_attr *attr); int (*t_getattr)(const char *path, struct sffs_attr *attr);
int (*t_setattr)(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_mkdir)(const char *path, int mode);
int (*t_unlink)(char *path); int (*t_unlink)(const char *path);
int (*t_rmdir)(char *path); int (*t_rmdir)(const char *path);
int (*t_rename)(char *opath, char *npath); 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 { struct sffs_params {

View File

@ -7,7 +7,7 @@ typedef int vbox_conn_t;
extern int vbox_init(void); 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_close(vbox_conn_t conn);
extern int vbox_call(vbox_conn_t conn, u32_t function, vbox_param_t *param, extern int vbox_call(vbox_conn_t conn, u32_t function, vbox_param_t *param,
int count, int *code); int count, int *code);

View File

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

View File

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

View File

@ -5,7 +5,7 @@
/*===========================================================================* /*===========================================================================*
* hgfs_opendir * * 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. /* Open a directory. Store a directory handle upon success.
*/ */

View File

@ -9,7 +9,7 @@
* hgfs_open * * hgfs_open *
*===========================================================================*/ *===========================================================================*/
int 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 flags, /* open flags to use */
int mode, /* mode to create (user bits only) */ int mode, /* mode to create (user bits only) */
sffs_file_t *handle /* place to store resulting handle */ 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. /* 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_REQUEST(HGFS_REQ_READ);
RPC_NEXT32 = (u32_t)handle; RPC_NEXT32 = (u32_t)handle;

View File

@ -5,7 +5,7 @@
/*===========================================================================* /*===========================================================================*
* hgfs_queryvol * * 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 /* Retrieve information about available and total volume space associated with
* a given path. * a given path.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ static char iobuf[VBOXFS_MAX_FILEIO];
* Open a file. * Open a file.
*/ */
int 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; vboxfs_handle_t *handlep;
int r; int r;

View File

@ -6,8 +6,8 @@
* Create or open a file or directory. * Create or open a file or directory.
*/ */
int int
vboxfs_open_file(char *path, int flags, int mode, vboxfs_handle_t *handlep, vboxfs_open_file(const char *path, int flags, int mode,
vboxfs_objinfo_t *infop) vboxfs_handle_t *handlep, vboxfs_objinfo_t *infop)
{ {
vbox_param_t param[3]; vbox_param_t param[3];
vboxfs_path_t pathbuf; 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. * Query volume information.
*/ */
int int
vboxfs_query_vol(char *path, vboxfs_volinfo_t *volinfo) vboxfs_query_vol(const char *path, vboxfs_volinfo_t *volinfo)
{ {
vboxfs_handle_t h; vboxfs_handle_t h;
int r; int r;
@ -44,7 +44,7 @@ vboxfs_query_vol(char *path, vboxfs_volinfo_t *volinfo)
* Query volume information. * Query volume information.
*/ */
int 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; vboxfs_volinfo_t volinfo;
int r; int r;

View File

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

View File

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

View File

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