[guardian-dev] abeluck/libsqlfs comments on sqlfs_proc_open() O_TRUNC support

Hans-Christoph Steiner hans at guardianproject.info
Fri Aug 10 22:51:40 EDT 2012


https://github.com/abeluck/libsqlfs/commit/a24a79f4c194fd041386c188677381cf5e7696ce

The truncation test looks good.



https://github.com/abeluck/libsqlfs/commit/fc2cb97a93c81fb6574ff559c1184368c5105d27

First off, based on your commit message, I want point out a detail that
might become important: libsqlfs is actually an implementation of the
FUSE API, not the POSIX API.  They are similar, but different.

http://fuse.sourceforge.net/doxygen/structfuse__operations.html

I think we should stick to FUSE compatibility since that was the
original intention.  That means we have to translate some things on the
Java side since it was written using a POSIX API. There were already a
couple of things, but I don't recall off hand what they were.  The
potential bonus is that we might be able to turn this code into a
general Java-->FUSE and do fun stuff with other FUSE filesystems like sshfs.

On that note, looking at the FUSE docs above, "If an application
specifies O_TRUNC, fuse first calls truncate() and then open()."  So why
not use sqlfs_proc_truncate() there?

A small commit note detail: I'd prefer to see complete function names
like sqlfs_proc_open() instead of open() to keep things simple and clear.



https://github.com/abeluck/libsqlfs/commit/c1d05df1600b0d15b5d075826cfc4724465d1061

I think this commit breaks it, since in char randomdata[TESTSIZE];
TESTSIZE is the number of elements, while in randomdata[TESTSIZE-1] = 0
is the index in the array, starting at 0. Therefore the last element !=
the size.

I think you meant + randomdata[TESTSIZE+1] = 0; to be +
randomdata[TESTSIZE] = 0;

It also breaks the test later, so I think it was OK as it was:

Opening test.db
Running tests:
Opening database...passed
Testing mkdir with sleep...passed
Testing mkdir without sleep...passed
Testing whether mkdir does not make nested dirs...passed
Testing mkdir to make nested dirs one at a time...passed
Testing rmdir...passed
Testing creating a file with a small string...passed
Testing writing 5000 bytes of data...passed
Testing reading while requesting more bytes than will fit in the
buffer...passed
Testing reading a byte with offset 10000 times...passed
Testing truncating...size: 5001
lt-test: test.c:154: main: Assertion `sb.st_size == 5000' failed.
Aborted (core dumped)


More information about the Guardian-dev mailing list