Commit Graph

36 Commits

Author SHA1 Message Date
Tor Arne Vestbø 4abe68dccd Implement zero-copy reads (read_buf) for FUSE 2.9 and above
FUSE 2.9 added support for zero copy reads/writes through two new
callbacks, read_buf and  write_buf. We now imeplement read_buf,
which iterates over the bands using the generic code, but instead
of opening and reading the content of the band into memory, we just
open the file and pass a structure back to FUSE with the file
descriptor, size, and offset, and FUSE will then use this on the
kernel side if possible (using splice on GNU/Linux).

For padding with zeroes we open /dev/zero and treat it as any
other file.

Since FUSE does not provide a callback when it's done with the
buffers there's no way for us to know when to close the bands
we opened. To work around this we keep the files open until
either the main image (dmg) file has been closed, or we run
out of file descriptors, at which point we gc the open files
and continue.
2012-10-14 21:46:47 +02:00
Tor Arne Vestbø 77945eadc7 Simplify logic when padding with zeroes 2012-10-14 21:46:47 +02:00
Tor Arne Vestbø 5ff5519435 Don't pass fuse_file_info to sparsebundle_iterate_bands 2012-10-14 21:46:47 +02:00
Tor Arne Vestbø 6f45e130ae Rename band_name to band_path 2012-10-14 21:46:47 +02:00
Tor Arne Vestbø 1b0f013ada Refactor band iteration to prepare for zero-copy implementation
The goal is to share the logic of iterating the bands, and only have
each mode implement the actual read and zero-padding operations.
2012-10-14 21:46:47 +02:00
Tor Arne Vestbø 320b1c143f Clean up use of error return codes 2012-10-14 21:45:56 +02:00
Tor Arne Vestbø a958e04b3c Add some debug logging 2012-10-14 21:45:55 +02:00
Tor Arne Vestbø c08a2b8728 Implement release callback
Not doing anything yet, but will be needed for zero-copy
2012-10-14 21:45:53 +02:00
Tor Arne Vestbø 4bcb457c24 Handle return value of asprintf 2012-10-14 01:49:16 +02:00
Tor Arne Vestbø 9800369652 Add a few missing includes 2012-10-14 01:47:42 +02:00
Tor Arne Vestbø a6aef18169 Fix unresolved symbols due to linker command line arguments ordering
The source file has to come first, so that the linker will know which
symbols to include from the fuse library (instead of throwing them
away).
2012-10-14 01:45:24 +02:00
Tor Arne Vestbø bfe906f853 Fix reads across band boundaries
If a read was requested at an offset just before the end of a band,
with a length sufficiently large to cross over to the next band, we
would pad the remaining space after the initial band with zeroes,
and never proceed to read the second band.

We now limit the size of each consecutive band read to the end of the
band, so that the while loop will correctly continue with the next
band if there's still more data to be read.
2012-10-07 22:27:36 +02:00
Tor Arne Vestbø c9e2a8ed53 Use const char foo[] over const char *foo for string literals
Saves one pointer in memory and is cleaner than const char * const.
2012-10-03 21:30:53 +02:00
Tor Arne Vestbø 7a58f90043 Force read-only mount by explicitly passing -o ro 2012-10-03 00:01:31 +02:00
Tor Arne Vestbø 4cb052473c Add new option -D, and only enable debug logging if passed 2012-10-02 23:34:06 +02:00
Tor Arne Vestbø a500b7b168 Simplify main()
No reason to clean up, we're exiting anyways, and syslog will
automatically closed on exit.
2012-10-02 23:13:21 +02:00
Tor Arne Vestbø 7d9274f28c Tweak usage text 2012-10-02 23:13:15 +02:00
Tor Arne Vestbø ff663449a9 Replace custom logging with syslog 2012-10-02 23:00:36 +02:00
Tor Arne Vestbø 5e36b62332 Remove duplicate include 2012-10-02 02:01:01 +02:00
Tor Arne Vestbø 04d2a2fc60 Minor code cleanup 2012-10-02 01:59:32 +02:00
Tor Arne Vestbø 516160b5ad Fix spelling 2012-10-02 01:44:51 +02:00
Tor Arne Vestbø 90d9cdc432 Fix spelling mistake 2012-10-02 01:36:00 +02:00
Tor Arne Vestbø cde62ed6b8 Add note about Time Machine backups 2012-10-02 01:34:14 +02:00
Tor Arne Vestbø 72093b4d32 Tweak wording in readme 2012-10-02 00:03:48 +02:00
Tor Arne Vestbø 34cb663656 Add readme, license and authors files 2012-10-01 23:27:11 +02:00
Tor Arne Vestbø 1be8425136 Reference band files by hex value instead of decimal 2012-10-01 21:09:55 +02:00
Tor Arne Vestbø f9c2e41d6e Fix warning about comparison between signed and unsigned ints
We assume numeric_limits<off_t>::max() will not return a negative
number, so casting should be safe.
2012-10-01 20:34:49 +02:00
Tor Arne Vestbø 357e446d94 Allow mounting of images larger than 2GB
Adds some sanity checking of the 'size' and 'band-size' values from the
Info.plist file, and ensures they are within the range of off_t, which
happens to be 64 bit due to FUSE forcing the use of _FILE_OFFSET_BITS=64.
2012-10-01 20:03:47 +02:00
Tor Arne Vestbø 672fd94c08 Use rpath on linux for FUSE
We should perhaps check if PKG_CONFIG_PATH has been set, which would
indicate that the FUSE libraries are in a non-default location, but
for now this is okey.
2012-09-28 14:53:48 +02:00
Tor Arne Vestbø cc7891445e Fix build on Synology NAS (DSM 4.1) 2012-09-28 14:27:26 +02:00
Tor Arne Vestbø a4ce2745a3 Always use FUSE version 26, not just on Mac OS 2012-09-28 14:10:35 +02:00
Tor Arne Vestbø 1b7932591a Optimize with -O2, not -O3 2012-09-28 14:09:28 +02:00
Tor Arne Vestbø 4998a33e19 Fix another warning about signed and unsigned comparison 2012-09-28 13:56:42 +02:00
Tor Arne Vestbø 6356cbc32a Remove use of C99 designated initializers 2012-09-28 13:54:06 +02:00
Tor Arne Vestbø 3a3a86bcdb Fix warning about signed and unsigned comparison 2012-09-28 13:38:10 +02:00
Tor Arne Vestbø 09f2c0e39a Initial commit 2012-09-28 13:16:17 +02:00