Commit Graph

70 Commits

Author SHA1 Message Date
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ø
53ca0a682b Explicitly enable C++11 mode 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ø
046d0153b0 Revert df7c77a0 (Recommend and use 'apt install' over 'apt-get install')
The 'apt' binary is not available on e.g. TravisCI, so lets stick to
using 'apt-get' for a smoother out-of-the-box build process.

The list of packages updated in df7c77a0 have been kept the same.
2016-09-27 23:39:43 +02:00
Tor Arne Vestbø
df7c77a0fd Recommend and use 'apt install' over 'apt-get install'
Also limits the packages we recommend installing. The rest will
be installed as dependencies if needed.

Fixes issue #18.
2016-09-27 23:35:45 +02:00
Tor Arne Vestbø
3d0e187f14 Allow overriding CFLAGS from the command line when running 'make' 2016-09-27 23:33:20 +02:00
Tor Arne Vestbø
d3ffa4071c Add maxAge for license badge 2016-09-18 21:50:21 +02:00
Tor Arne Vestbø
b25ea1cd10 Add license badge 2016-09-18 21:47:36 +02:00
Tor Arne Vestbø
01586abc7b Use SVG for build status badge 2016-09-18 21:31:39 +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
Paolo G. Giarrusso
81b080cbd2 Enable debugging
Since the binary is so small, debugging info take insignificant space,
and they are rather convenient to have in case something goes wrong.
2015-03-26 10:44:00 +01: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ø
e3bc65fa6d Try to detect if we have GCC 4.2 or higher for enabling -march=native 2013-02-07 22:25:18 +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
Tor Arne Vestbø
033e8a2832 Add Travis CI build status to README 2012-11-17 18:48:07 +01:00
Tor Arne Vestbø
404396f78e Add configuration file for Travis CI 2012-11-17 18:40:34 +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ø
dcd99af04f Document how to mount disk images with the HFS+ partition at an offset 2012-10-22 18:15:51 +02: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ø
a59e55fbd3 Merge branch 'zero-copy' 2012-10-14 21:48:19 +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ø
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