summaryrefslogtreecommitdiff
path: root/src/basic/copy.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-10 18:16:18 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-10 18:16:18 +0200
commit59f448cf15f94bc5ebfd5b254de6f2441d02fbec (patch)
tree1d52fd0935cca0205c78fde6870abddb7aafd360 /src/basic/copy.c
parentf33be3119806f96898dda6ade492fbdcdf8f79b8 (diff)
tree-wide: never use the off_t unless glibc makes us use it
off_t is a really weird type as it is usually 64bit these days (at least in sane programs), but could theoretically be 32bit. We don't support off_t as 32bit builds though, but still constantly deal with safely converting from off_t to other types and back for no point. Hence, never use the type anymore. Always use uint64_t instead. This has various benefits, including that we can expose these values directly as D-Bus properties, and also that the values parse the same in all cases.
Diffstat (limited to 'src/basic/copy.c')
-rw-r--r--src/basic/copy.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/basic/copy.c b/src/basic/copy.c
index cc5faa80a1..b8cbe644d4 100644
--- a/src/basic/copy.c
+++ b/src/basic/copy.c
@@ -29,7 +29,7 @@
#define COPY_BUFFER_SIZE (16*1024)
-int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
+int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
bool try_sendfile = true, try_splice = true;
int r;
@@ -37,7 +37,7 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
assert(fdt >= 0);
/* Try btrfs reflinks first. */
- if (try_reflink && max_bytes == (off_t) -1) {
+ if (try_reflink && max_bytes == (uint64_t) -1) {
r = btrfs_reflink(fdf, fdt);
if (r >= 0)
return r;
@@ -47,12 +47,12 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
size_t m = COPY_BUFFER_SIZE;
ssize_t n;
- if (max_bytes != (off_t) -1) {
+ if (max_bytes != (uint64_t) -1) {
if (max_bytes <= 0)
return -EFBIG;
- if ((off_t) m > max_bytes)
+ if ((uint64_t) m > max_bytes)
m = (size_t) max_bytes;
}
@@ -105,8 +105,8 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
}
next:
- if (max_bytes != (off_t) -1) {
- assert(max_bytes >= n);
+ if (max_bytes != (uint64_t) -1) {
+ assert(max_bytes >= (uint64_t) n);
max_bytes -= n;
}
}
@@ -152,7 +152,7 @@ static int fd_copy_regular(int df, const char *from, const struct stat *st, int
if (fdt < 0)
return -errno;
- r = copy_bytes(fdf, fdt, (off_t) -1, true);
+ r = copy_bytes(fdf, fdt, (uint64_t) -1, true);
if (r < 0) {
unlinkat(dt, to, 0);
return r;
@@ -371,7 +371,7 @@ int copy_file_fd(const char *from, int fdt, bool try_reflink) {
if (fdf < 0)
return -errno;
- r = copy_bytes(fdf, fdt, (off_t) -1, try_reflink);
+ r = copy_bytes(fdf, fdt, (uint64_t) -1, try_reflink);
(void) copy_times(fdf, fdt);
(void) copy_xattr(fdf, fdt);