author | Alberto Bertogli
<albertito@gmail.com> 2004-04-05 15:31:59 UTC |
committer | Alberto Bertogli
<albertito@gmail.com> 2007-07-15 12:31:26 UTC |
parent | ef306c1f95fe67b48916fd80a4a8c499c68c5ecd |
doc/libjio.3 | +1 | -1 |
libjio.c | +7 | -4 |
libjio.h | +1 | -1 |
diff --git a/doc/libjio.3 b/doc/libjio.3 index 8439f6d..9584cd6 100644 --- a/doc/libjio.3 +++ b/doc/libjio.3 @@ -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 " ); diff --git a/libjio.c b/libjio.c index 876a255..552b5f2 100644 --- a/libjio.c +++ b/libjio.c @@ -101,7 +101,7 @@ static ssize_t spwrite(int fd, void *buf, size_t count, off_t offset) } /* 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 *jdir) } /* 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, int flags, int mode, int jflags) 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 --git a/libjio.h b/libjio.h index 50582ab..23f5296 100644 --- a/libjio.h +++ b/libjio.h @@ -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);