+2006-09-16 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Rename new utimes() method to more logical utimens()
+
+2006-09-14 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Fuse tried to unlink already unlinked hidden files. Bug
+ reported by Milan Svoboda
+
2006-09-10 Miklos Szeredi <miklos@szeredi.hu>
* Released 2.6.0-rc1
http://sourceforge.net/projects/fuse
or alternatively you can use CVS to get the very latest development
-version by setting the cvsroot to
+version:
- :pserver:anonymous@cvs.sourceforge.net:/cvsroot/fuse
+ cvs -d :pserver:anonymous@fuse.cvs.sourceforge.net:/cvsroot/fuse co fuse
-and checking out the 'fuse' module.
Dependencies
============
return 0;
}
-static int xmp_utimes(const char *path, const struct timespec ts[2])
+static int xmp_utimens(const char *path, const struct timespec ts[2])
{
int res;
struct timeval tv[2];
.chmod = xmp_chmod,
.chown = xmp_chown,
.truncate = xmp_truncate,
- .utimes = xmp_utimes,
+ .utimens = xmp_utimens,
.open = xmp_open,
.read = xmp_read,
.write = xmp_write,
return 0;
}
-static int xmp_utimes(const char *path, const struct timespec ts[2])
+static int xmp_utimens(const char *path, const struct timespec ts[2])
{
int res;
struct timeval tv[2];
.chown = xmp_chown,
.truncate = xmp_truncate,
.ftruncate = xmp_ftruncate,
- .utimes = xmp_utimes,
+ .utimens = xmp_utimens,
.create = xmp_create,
.open = xmp_open,
.read = xmp_read,
*
* Introduced in version 2.6
*/
- int (*utimes) (const char *, const struct timespec tv[2]);
+ int (*utimens) (const char *, const struct timespec tv[2]);
};
/** Extra context that may be needed by some filesystems
return err;
}
-static int do_utimes(struct fuse *f, fuse_req_t req, const char *path,
- struct stat *attr)
+static int do_utimens(struct fuse *f, fuse_req_t req, const char *path,
+ struct stat *attr)
{
int err;
struct fuse_intr_data d;
err = -ENOSYS;
- if (f->op.utimes) {
+ if (f->op.utimens) {
struct timespec tv[2];
tv[0] = attr->st_atim;
tv[1] = attr->st_mtim;
fuse_prepare_interrupt(f, req, &d);
- err = f->op.utimes(path, tv);
+ err = f->op.utimens(path, tv);
fuse_finish_interrupt(f, req, &d);
} else if (f->op.utime) {
struct utimbuf buf;
if (!err && (valid & FUSE_SET_ATTR_SIZE))
err = do_truncate(f, req, path, attr, fi);
if (!err && (valid & (FUSE_SET_ATTR_ATIME | FUSE_SET_ATTR_MTIME)) == (FUSE_SET_ATTR_ATIME | FUSE_SET_ATTR_MTIME))
- err = do_utimes(f, req, path, attr);
+ err = do_utimens(f, req, path, attr);
if (!err)
err = fuse_do_getattr(f, req, path, &buf);
}
struct fuse *f = req_fuse_prepare(req);
char *path;
struct node *node;
- int unlink_hidden;
+ int unlink_hidden = 0;
pthread_rwlock_rdlock(&f->tree_lock);
path = get_path(f, ino);
node = get_node(f, ino);
assert(node->open_count > 0);
--node->open_count;
- unlink_hidden = (node->is_hidden && !node->open_count);
+ if (node->is_hidden && !node->open_count) {
+ unlink_hidden = 1;
+ node->is_hidden = 0;
+ }
pthread_mutex_unlock(&f->lock);
if(unlink_hidden && path)
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
+#include <utime.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
return 0;
}
+static int check_times(const char *path, time_t atime, time_t mtime)
+{
+ int err = 0;
+ struct stat stbuf;
+ int res = lstat(path, &stbuf);
+ if (res == -1) {
+ PERROR("lstat");
+ return -1;
+ }
+ if (stbuf.st_atime != atime) {
+ ERROR("atime %li instead of %li", stbuf.st_atime, atime);
+ err--;
+ }
+ if (stbuf.st_mtime != mtime) {
+ ERROR("mtime %li instead of %li", stbuf.st_mtime, mtime);
+ err--;
+ }
+ if (err)
+ return -1;
+
+ return 0;
+}
+
static int check_nlink(const char *path, nlink_t nlink)
{
struct stat stbuf;
PERROR("creat");
return -1;
}
- res = write(fd, data, len);
- if (res == -1) {
- PERROR("write");
- close(fd);
- return -1;
- }
- if (res != len) {
- ERROR("write is short: %u instead of %u", res, len);
- close(fd);
- return -1;
+ if (len) {
+ res = write(fd, data, len);
+ if (res == -1) {
+ PERROR("write");
+ close(fd);
+ return -1;
+ }
+ if (res != len) {
+ ERROR("write is short: %u instead of %u", res, len);
+ close(fd);
+ return -1;
+ }
}
res = close(fd);
if (res == -1) {
if (res == -1)
return -1;
- res = check_data(path, data, 0, len);
- if (res == -1)
- return -1;
+ if (len) {
+ res = check_data(path, data, 0, len);
+ if (res == -1)
+ return -1;
+ }
return 0;
}
return 0;
}
-int test_truncate(int len)
+static int test_truncate(int len)
{
const char *data = testdata;
int datalen = testdatalen;
PERROR("unlink");
return -1;
}
- res = check_nonexist(testfile2);
+ res = check_nonexist(testfile);
if (res == -1)
return -1;
return 0;
}
-int test_ftruncate(int len, int mode)
+static int test_ftruncate(int len, int mode)
{
const char *data = testdata;
int datalen = testdatalen;
PERROR("unlink");
return -1;
}
- res = check_nonexist(testfile2);
+ res = check_nonexist(testfile);
+ if (res == -1)
+ return -1;
+
+ success();
+ return 0;
+}
+
+static int test_utime(void)
+{
+ struct utimbuf utm;
+ time_t atime = 987631200;
+ time_t mtime = 123116400;
+ int res;
+
+ start_test("utime");
+ res = create_file(testfile, NULL, 0);
+ if (res == -1)
+ return -1;
+
+ utm.actime = atime;
+ utm.modtime = mtime;
+ res = utime(testfile, &utm);
+ if (res == -1) {
+ PERROR("utime");
+ return -1;
+ }
+ res = check_times(testfile, atime, mtime);
+ if (res == -1) {
+ return -1;
+ }
+ res = unlink(testfile);
+ if (res == -1) {
+ PERROR("unlink");
+ return -1;
+ }
+ res = check_nonexist(testfile);
if (res == -1)
return -1;
return 0;
}
-int test_mkfifo(void)
+static int test_mkfifo(void)
{
int res;
int err = 0;
return 0;
}
-int test_mkdir(void)
+static int test_mkdir(void)
{
int res;
int err = 0;
err += test_mkdir();
err += test_rename_file();
err += test_rename_dir();
+ err += test_utime();
err += test_truncate(0);
err += test_truncate(testdatalen / 2);
err += test_truncate(testdatalen);
rmdir(testdir);
rmdir(testdir2);
- if (err)
+ if (err) {
+ fprintf(stderr, "%i tests failed\n", -err);
return 1;
+ }
return 0;
}