chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v228: Add remaining updates from upstream (2/3)
[elogind.git]
/
src
/
basic
/
copy.c
diff --git
a/src/basic/copy.c
b/src/basic/copy.c
index 163bbf7c7a7ee24cb66fb325f2ee5e0df0d2bd6d..c5cbbb79f44070f444e6aaeafda60b508583ba69 100644
(file)
--- a/
src/basic/copy.c
+++ b/
src/basic/copy.c
@@
-22,37
+22,52
@@
#include <sys/sendfile.h>
#include <sys/xattr.h>
#include <sys/sendfile.h>
#include <sys/xattr.h>
-
#include "
util.h"
-//
#include "btrfs-util.h"
-
#include "strv
.h"
+
//#include "alloc-
util.h"
+//#include "btrfs-util.h"
+
//#include "chattr-util
.h"
#include "copy.h"
#include "copy.h"
+//#include "dirent-util.h"
+//#include "fd-util.h"
+//#include "fileio.h"
+//#include "fs-util.h"
+#include "io-util.h"
+//#include "string-util.h"
+#include "strv.h"
+//#include "umask-util.h"
+#include "util.h"
+//#include "xattr-util.h"
#define COPY_BUFFER_SIZE (16*1024)
#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;
assert(fdf >= 0);
assert(fdt >= 0);
bool try_sendfile = true, try_splice = true;
int r;
assert(fdf >= 0);
assert(fdt >= 0);
+// UNNEEDED by elogind
#if 0
/* Try btrfs reflinks first. */
#if 0
/* Try btrfs reflinks first. */
- if (try_reflink && max_bytes == (off_t) -1) {
+ if (try_reflink &&
+ max_bytes == (uint64_t) -1 &&
+ lseek(fdf, 0, SEEK_CUR) == 0 &&
+ lseek(fdt, 0, SEEK_CUR) == 0) {
+
r = btrfs_reflink(fdf, fdt);
if (r >= 0)
r = btrfs_reflink(fdf, fdt);
if (r >= 0)
- return
r;
+ return
0; /* we copied the whole thing, hence hit EOF, return 0 */
}
#endif // 0
for (;;) {
size_t m = COPY_BUFFER_SIZE;
ssize_t n;
}
#endif // 0
for (;;) {
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 (max_bytes <= 0)
return -EFBIG;
- if ((
off
_t) m > max_bytes)
+ if ((
uint64
_t) m > max_bytes)
m = (size_t) max_bytes;
}
m = (size_t) max_bytes;
}
@@
-91,7
+106,7
@@
int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
/* As a fallback just copy bits by hand */
{
/* As a fallback just copy bits by hand */
{
-
char
buf[m];
+
uint8_t
buf[m];
n = read(fdf, buf, m);
if (n < 0)
n = read(fdf, buf, m);
if (n < 0)
@@
-105,13
+120,13
@@
int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
}
next:
}
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;
}
}
max_bytes -= n;
}
}
- return 0;
+ return 0;
/* return 0 if we hit EOF earlier than the size limit */
}
// UNNEEDED by elogind
}
// UNNEEDED by elogind
@@
-154,7
+169,7
@@
static int fd_copy_regular(int df, const char *from, const struct stat *st, int
if (fdt < 0)
return -errno;
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;
if (r < 0) {
unlinkat(dt, to, 0);
return r;
@@
-373,7
+388,7
@@
int copy_file_fd(const char *from, int fdt, bool try_reflink) {
if (fdf < 0)
return -errno;
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);
(void) copy_times(fdf, fdt);
(void) copy_xattr(fdf, fdt);