Re: [PATCH] relay_open const filename

Stephen Hemminger
2003-07-16T22:14:32Z

Since relay_open takes a pathname, it should be "const char *".

diff -Nru a/fs/relayfs/relay.c b/fs/relayfs/relay.c
--- a/fs/relayfs/relay.c Wed Jul 16 15:23:36 2003
+++ b/fs/relayfs/relay.c Wed Jul 16 15:23:36 2003
@@ -660,7 +660,7 @@
* locking scheme can use buffers of any size, but is hardcoded at 2.
*/
static struct rchan *
-rchan_create(char *chanpath,
+rchan_create(const char *chanpath,
int bufsize_lockless,
int nbufs_lockless,
int bufsize_locking,
@@ -829,11 +829,11 @@
* to create the file.
*/
static int
-rchan_create_dir(char * chanpath,
- char **residual,
+rchan_create_dir(const char * chanpath,
+ const char **residual,
struct dentry **topdir)
{
- char *cp = chanpath, *next;
+ const char *cp = chanpath, *next;
struct dentry *parent = NULL;
int len, err = 0;

@@ -867,12 +867,12 @@
* Returns 0 if successful, negative otherwise.
*/
static int
-rchan_create_file(char * chanpath,
+rchan_create_file(const char * chanpath,
struct dentry **dentry,
struct rchan * data)
{
int err;
- char * fname;
+ const char * fname;
struct dentry *topdir;

err = rchan_create_dir(chanpath, &fname, &topdir);
@@ -1239,7 +1239,7 @@
* cause the channel to wrap around continuously.
*/
int
-relay_open(char *chanpath,
+relay_open(const char *chanpath,
int bufsize_lockless,
int nbufs_lockless,
int bufsize_locking,
@@ -1556,7 +1556,7 @@
int err = 0;
int try_bufcount, cur_bufno = 0, include_nbufs = 1;
u32 cur_idx, buf_size;
- size_t avail_count, avail_in_buf;
+ size_t avail_count = 0, avail_in_buf;
int unused_bytes = 0;

if (rchan->bufs_produced < rchan->n_bufs)
diff -Nru a/include/linux/relayfs_fs.h b/include/linux/relayfs_fs.h
--- a/include/linux/relayfs_fs.h Wed Jul 16 15:23:36 2003
+++ b/include/linux/relayfs_fs.h Wed Jul 16 15:23:36 2003
@@ -531,7 +531,7 @@
* High-level relayfs kernel API, fs/relayfs/relay.c
*/
extern int
-relay_open(char *chanpath,
+relay_open(const char *chanpath,
int bufsize_lockless,
int nbufs_lockless,
int bufsize_locking,