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

Abel Luck abel at outcomedubious.im
Thu Aug 16 11:45:32 EDT 2012


Hans-Christoph Steiner:
> 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.

Ah, I see. The libsqlfs README could be more clear about that I suppose.

> 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.

Agreed. One such thing we need to translate is the passing of O_TRUNC.
Java FileOutputStream says: "The file will be truncated if it exists,
and created if it doesn't exist."

But we're already doing this [1] :)

> 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?

Yup. I'll rework the patch to do so.


> 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;

Hm. First, for me the test isn't broken, it's passing. Which commit are
you running the test on? :|

"char randomdata[TESTSIZE]" is actually "char randombuf[TESTSIZE+1];"
(see the commit)

TESTSIZE is meant to be the resulting size of the test file on disk. But
since the test is using strlen(randomdata) to write the data, it expects
a terminating null byte, so the effective size of the array must be
TESTSIZE+1.

[1]:
https://github.com/abeluck/IOCipher/commit/3e86d770a804ca3b79ba74f99883dbfe4dad992c


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 630 bytes
Desc: OpenPGP digital signature
URL: <http://lists.mayfirst.org/pipermail/guardian-dev/attachments/20120816/8edeb40d/attachment.pgp>


More information about the Guardian-dev mailing list