From: David van Moolenbroek Date: Sat, 23 Aug 2014 22:28:01 +0000 (+0000) Subject: libsffs: make path names constant X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/pkcs11-keygen.html?a=commitdiff_plain;h=94e65446c4f963450ea94b8becc02cec062675cd;p=minix.git libsffs: make path names constant And a few other related warning fixes. Change-Id: I1a49b9ee04c2b1bf80bc943272f72ffd6de77ef6 --- diff --git a/minix/include/minix/sffs.h b/minix/include/minix/sffs.h index ee8425340..97389ab04 100644 --- a/minix/include/minix/sffs.h +++ b/minix/include/minix/sffs.h @@ -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 { diff --git a/minix/include/minix/vbox.h b/minix/include/minix/vbox.h index 0c0f16635..467f06701 100644 --- a/minix/include/minix/vbox.h +++ b/minix/include/minix/vbox.h @@ -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); diff --git a/minix/lib/libhgfs/Makefile b/minix/lib/libhgfs/Makefile index ca73f0baf..49dad1731 100644 --- a/minix/lib/libhgfs/Makefile +++ b/minix/lib/libhgfs/Makefile @@ -1,6 +1,3 @@ -NOGCCERROR=yes -NOCLANGERROR=yes - # Makefile for HGFS library LIB= hgfs diff --git a/minix/lib/libhgfs/attr.c b/minix/lib/libhgfs/attr.c index d87fb6084..61e1c1e96 100644 --- a/minix/lib/libhgfs/attr.c +++ b/minix/lib/libhgfs/attr.c @@ -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. */ diff --git a/minix/lib/libhgfs/dir.c b/minix/lib/libhgfs/dir.c index 3782b920f..e09c69304 100644 --- a/minix/lib/libhgfs/dir.c +++ b/minix/lib/libhgfs/dir.c @@ -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. */ diff --git a/minix/lib/libhgfs/file.c b/minix/lib/libhgfs/file.c index 2b158cb5b..1f5d7d530 100644 --- a/minix/lib/libhgfs/file.c +++ b/minix/lib/libhgfs/file.c @@ -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; diff --git a/minix/lib/libhgfs/info.c b/minix/lib/libhgfs/info.c index 006e6d72b..420977200 100644 --- a/minix/lib/libhgfs/info.c +++ b/minix/lib/libhgfs/info.c @@ -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. diff --git a/minix/lib/libhgfs/link.c b/minix/lib/libhgfs/link.c index c3a568477..937fee59c 100644 --- a/minix/lib/libhgfs/link.c +++ b/minix/lib/libhgfs/link.c @@ -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. */ diff --git a/minix/lib/libhgfs/path.c b/minix/lib/libhgfs/path.c index 40b4b9d70..9b905bcea 100644 --- a/minix/lib/libhgfs/path.c +++ b/minix/lib/libhgfs/path.c @@ -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++); diff --git a/minix/lib/libhgfs/proto.h b/minix/lib/libhgfs/proto.h index e213d409c..fcd1f1834 100644 --- a/minix/lib/libhgfs/proto.h +++ b/minix/lib/libhgfs/proto.h @@ -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 */ diff --git a/minix/lib/libsys/arch/i386/vbox.c b/minix/lib/libsys/arch/i386/vbox.c index 9fb25e049..f26acb996 100644 --- a/minix/lib/libsys/arch/i386/vbox.c +++ b/minix/lib/libsys/arch/i386/vbox.c @@ -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. */ diff --git a/minix/lib/libvboxfs/Makefile b/minix/lib/libvboxfs/Makefile index ee55c59f4..908c336a7 100644 --- a/minix/lib/libvboxfs/Makefile +++ b/minix/lib/libvboxfs/Makefile @@ -1,6 +1,3 @@ -NOGCCERROR=yes -NOCLANGERROR=yes - # Makefile for libvboxfs .include diff --git a/minix/lib/libvboxfs/attr.c b/minix/lib/libvboxfs/attr.c index d6dc34d22..e0ef7631c 100644 --- a/minix/lib/libvboxfs/attr.c +++ b/minix/lib/libvboxfs/attr.c @@ -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; diff --git a/minix/lib/libvboxfs/dir.c b/minix/lib/libvboxfs/dir.c index 00c7f3799..2d997eec9 100644 --- a/minix/lib/libvboxfs/dir.c +++ b/minix/lib/libvboxfs/dir.c @@ -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; diff --git a/minix/lib/libvboxfs/file.c b/minix/lib/libvboxfs/file.c index da96174f4..a99f16d61 100644 --- a/minix/lib/libvboxfs/file.c +++ b/minix/lib/libvboxfs/file.c @@ -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; diff --git a/minix/lib/libvboxfs/handle.c b/minix/lib/libvboxfs/handle.c index c264a8bee..e0ccd7a99 100644 --- a/minix/lib/libvboxfs/handle.c +++ b/minix/lib/libvboxfs/handle.c @@ -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; diff --git a/minix/lib/libvboxfs/info.c b/minix/lib/libvboxfs/info.c index 767744d71..87fa5a9ab 100644 --- a/minix/lib/libvboxfs/info.c +++ b/minix/lib/libvboxfs/info.c @@ -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; diff --git a/minix/lib/libvboxfs/link.c b/minix/lib/libvboxfs/link.c index b525d3d6e..7d61dac8b 100644 --- a/minix/lib/libvboxfs/link.c +++ b/minix/lib/libvboxfs/link.c @@ -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; diff --git a/minix/lib/libvboxfs/path.c b/minix/lib/libvboxfs/path.c index 6b8c021d8..98ceb7b19 100644 --- a/minix/lib/libvboxfs/path.c +++ b/minix/lib/libvboxfs/path.c @@ -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; diff --git a/minix/lib/libvboxfs/proto.h b/minix/lib/libvboxfs/proto.h index 99cf74a4f..bdbbec11e 100644 --- a/minix/lib/libvboxfs/proto.h +++ b/minix/lib/libvboxfs/proto.h @@ -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);