Commit Graph

49 Commits

Author SHA1 Message Date
Tor Arne Vestbø
c831d584af Don't send syslog messages to console via LOG_CONS
It results in duplicate messages to the console when run in the
foreground on Ubuntu 16.04. We already get all messages to stderr
via LOG_PERROR.
2018-09-08 22:15:10 +02:00
Tor Arne Vestbø
49f8f323d5 Prospective build fix for attempted call of ‘min(size_t, uintmax_t) 2018-05-11 21:29:26 +02:00
Tor Arne Vestbø
d500e0c37b Enable -pedantic and fix use of %p with non-void* pointers 2018-05-04 00:43:50 +02:00
Tor Arne Vestbø
7414e516c2 Track the number of times a sparsebundle has been opened using uintmax_t
Instead of off_t, which doesn't make sense, being both unsigned and not
a very logical type to use for a counter.
2018-05-04 00:43:50 +02:00
Tor Arne Vestbø
90c81b1776 Move to size_t and other unsigned types, over off_t
We never expect the offset to be negative, so instead of keeping
it around as off_t,  and having to cast to size_t to deal with
signed vs unsigned comparisons, we just use size_t directly.

There's still a few uses of off_t and ssize_t around, but
those will need further refactoring to clean up.
2018-05-04 00:43:50 +02:00
Fedor Bezrukov
a5f9c89dd9 Fix narrowing from ssize_t to size_t in sparsebundle_read_buf_process_band 2018-05-04 00:43:50 +02:00
Paolo G. Giarrusso
f359ac8a0d Use correct printf format specifiers for size_t 2018-05-04 00:43:46 +02:00
Tor Arne Vestbø
f3ccd20bd6 Fix narrowing conversion of ‘-1’ from ‘int’ to ‘rlim_t‘
We were using -1 as a sentinel to determine if we had computed the
file descriptor limit, but rlim_t is unsigned. Also, RLIM_INFINITY
is typically -1 as well, so the choice of -1 as a sentinel was
probably not a good idea anyways.

Closes issue #19.
2016-09-27 23:50:42 +02:00
Tor Arne Vestbø
f5fb2f958b Log which file descriptors are closed 2016-06-17 18:56:19 +02:00
Tor Arne Vestbø
d3c85f2ab8 Add missing static keyword for sparsebundle_read_buf_prepare_file
Fixes warning about no previous prototype for function [-Wmissing-prototypes]
2016-06-17 18:56:15 +02:00
Tor Arne Vestbø
c8ac56d594 Clarify difference between bundle and exposed dmg path in logging
It's not the bundle that's opened by fuse, that's just our internal
pointer back to where the data lives. As far as fuse is concerned
the only file we have is sparsebundle.dmg, and that's the file that's
opened and released.
2016-06-17 18:56:14 +02:00
Tor Arne Vestbø
bc83f462d0 Verify bundle and mount point paths in sparsebundle_opt_proc 2016-06-17 18:56:14 +02:00
Tor Arne Vestbø
40e55df463 Add sparsebundle_fatal_error function for unifying fatal errors
The function is marked with the printf archetype, so that the compiler
will not complain that we're passing non-string-literals to vfprintf.
2016-06-17 18:56:14 +02:00
Tor Arne Vestbø
c325e3e4fc Parse and store the mountpoint from the command line arguments 2016-06-17 18:56:13 +02:00
Tor Arne Vestbø
b5dd50f6d0 Rename and change usage of sparsebundle_data macros
Instead of referencing SB_DATA all over the place, and hence also
calling fuse_get_context(), we now do it once of each function call,
through the renamed sparsebundle_current() macro.

This makes the code a bit more transparent and easier on the eye,
versus the more opaque 'data' type.
2016-06-17 18:56:13 +02:00
Tor Arne Vestbø
5b83abfa26 Fix unused parameter [-Wunused-parameter] warnings 2016-06-17 18:56:12 +02:00
Tor Arne Vestbø
e45953d427 Update license to 2016, and add license in source file as well 2016-06-17 18:56:10 +02:00
Tor Arne Vestbø
c89da71957 Prevent FUSE macro (FUSE_OPT_END) from adding designated initializer
It's a C99 feature and might break pedantic builds.
2013-02-07 22:45:26 +01:00
Tor Arne Vestbø
fda9993aea Document how to enable debug mode to troubleshoot issues 2012-11-18 15:57:18 +01:00
Tor Arne Vestbø
c2f9531811 Fix -Wformat warnings on platforms where off_t is not unsigned long long int
Use the 'j' modifier instead of 'll' and cast to uintmax_t.
2012-11-18 15:42:04 +01:00
Justin Edwards
9996c1cd80 Fix missing function declarations for pread and close
sparsebundlefs.cpp:171:56: error: 'pread' was not declared in this scope
sparsebundlefs.cpp:172:24: error: 'close' was not declared in this scope

We were missing unistd.h
2012-11-16 09:55:39 +01:00
Tor Arne Vestbø
596f8b6c33 Update permissions of the mountpoint to reflect that it's read-only 2012-10-18 18:39:41 +02:00
Tor Arne Vestbø
deeaf1957a Keep access/modification/change times in sync with sparsebundle 2012-10-16 20:31:58 +02:00
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ø
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ø
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ø
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