

To match the unix definition, jopen()'s pathname argument should be const.



---

 cur-root/doc/libjio.3 |    2 +-
 cur-root/libjio.c     |   11 +++++++----
 cur-root/libjio.h     |    2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff -puN libjio.c~open_const_char libjio.c
--- cur/libjio.c~open_const_char	2004-04-05 12:31:46.000000000 -0300
+++ cur-root/libjio.c	2004-04-05 12:31:57.000000000 -0300
@@ -101,7 +101,7 @@ static ssize_t spwrite(int fd, void *buf
 }
 
 /* build the journal directory name out of the filename */
-static int get_jdir(char *filename, char *jdir)
+static int get_jdir(const char *filename, char *jdir)
 {
 	char *base, *baset;
 	char *dir, *dirt;
@@ -125,7 +125,7 @@ static int get_jdir(char *filename, char
 }
 
 /* build the filename of a given transaction */
-static int get_jtfile(char *filename, int tid, char *jtfile)
+static int get_jtfile(const char *filename, int tid, char *jtfile)
 {
 	char *base, *baset;
 	char *dir, *dirt;
@@ -440,7 +440,7 @@ int jtrans_rollback(struct jtrans *ts)
  */
 
 /* open a file */
-int jopen(struct jfs *fs, char *name, int flags, int mode, int jflags)
+int jopen(struct jfs *fs, const char *name, int flags, int mode, int jflags)
 {
 	int fd, jfd, rv;
 	unsigned int t;
@@ -452,7 +452,7 @@ int jopen(struct jfs *fs, char *name, in
 		return -1;
 
 	fs->fd = fd;
-	fs->name = name;
+	fs->name = strdup(name);
 	fs->flags = jflags;
 	
 	pthread_mutex_init( &(fs->lock), NULL);
@@ -652,6 +652,9 @@ int jclose(struct jfs *fs)
 		return -1;
 	if (close(fs->jfd))
 		return -1;
+	if (fs->name)
+		/* allocated by strdup() in jopen() */
+		free(fs->name);
 	return 0;
 }
 
diff -puN libjio.h~open_const_char libjio.h
--- cur/libjio.h~open_const_char	2004-04-05 12:31:46.000000000 -0300
+++ cur-root/libjio.h	2004-04-05 12:31:46.000000000 -0300
@@ -65,7 +65,7 @@ struct disk_trans {
 
 
 /* basic operations */
-int jopen(struct jfs *fs, char *name, int flags, int mode, int jflags);
+int jopen(struct jfs *fs, const char *name, int flags, int mode, int jflags);
 ssize_t jread(struct jfs *fs, void *buf, size_t count);
 ssize_t jpread(struct jfs *fs, void *buf, size_t count, off_t offset);
 ssize_t jreadv(struct jfs *fs, struct iovec *vector, int count);
diff -puN doc/libjio.3~open_const_char doc/libjio.3
--- cur/doc/libjio.3~open_const_char	2004-04-05 12:31:46.000000000 -0300
+++ cur-root/doc/libjio.3	2004-04-05 12:31:46.000000000 -0300
@@ -6,7 +6,7 @@ libjio - A library for Journaled I/O
 
 .B #include <libjio.h>
 
-.BI "int jopen(struct jfs *" fs ", char *" name ", int " flags ", int " mode ", int " jflags " );
+.BI "int jopen(struct jfs *" fs ", const char *" name ", int " flags ", int " mode ", int " jflags " );
 
 .BI "ssize_t jread(struct jfs *" fs ", void *" buf ", size_t " count " );
 

_

