git://git.onelab.eu
/
util-vserver.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ready for tagging
[util-vserver.git]
/
lib_internal
/
unify-copy.c
diff --git
a/lib_internal/unify-copy.c
b/lib_internal/unify-copy.c
index
1eae081
..
c5c0062
100644
(file)
--- a/
lib_internal/unify-copy.c
+++ b/
lib_internal/unify-copy.c
@@
-1,4
+1,4
@@
-// $Id: unify-copy.c
1977 2005-03-24 12:42:16
Z ensc $ --*- c -*--
+// $Id: unify-copy.c
2544 2007-06-01 16:16:33
Z ensc $ --*- c -*--
// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
//
// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
//
@@
-83,6
+83,8
@@
static void
copyMem(void *dst_v, void const *src_v, size_t len_v)
{
#if 1
copyMem(void *dst_v, void const *src_v, size_t len_v)
{
#if 1
+ // Do not use memcpy because this would dirty pages consisting only of
+ // '\0'
int *dst = dst_v;
int const *src = src_v;
size_t len = len_v / sizeof(int);
int *dst = dst_v;
int const *src = src_v;
size_t len = len_v / sizeof(int);
@@
-119,9
+121,7
@@
copyMMap(int in_fd, int out_fd)
bool volatile res = false;
if (in_len==-1) return false;
bool volatile res = false;
if (in_len==-1) return false;
- if (in_len>0 &&
- (lseek(out_fd, in_len-1, SEEK_SET)==-1 ||
- write(out_fd, "\0", 1)!=1)) // create sparse file
+ if (in_len>0 && ftruncate(out_fd, in_len)==-1) // create sparse file
return false;
bus_error = 0;
return false;
bus_error = 0;
@@
-145,16
+145,16
@@
copyMMap(int in_fd, int out_fd)
TESTSUITE_COPY_CODE;
copyMem(out_buf, in_buf, buf_size);
TESTSUITE_COPY_CODE;
copyMem(out_buf, in_buf, buf_size);
- munmap(const_cast(void *)(in_buf), buf_size); in_buf = 0;
munmap(out_buf, buf_size); out_buf = 0;
munmap(out_buf, buf_size); out_buf = 0;
+ munmap(const_cast(void *)(in_buf), buf_size); in_buf = 0;
}
res = true;
}
out:
}
res = true;
}
out:
- if (in_buf !=0) munmap(const_cast(void *)(in_buf), buf_size);
if (out_buf!=0) munmap(out_buf, buf_size);
if (out_buf!=0) munmap(out_buf, buf_size);
+ if (in_buf !=0) munmap(const_cast(void *)(in_buf), buf_size);
return res;
}
return res;
}
@@
-164,7
+164,7
@@
copyReg(char const *src, struct stat const *src_stat,
char const *dst)
{
int in_fd = open(src, O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_LARGEFILE);
char const *dst)
{
int in_fd = open(src, O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_LARGEFILE);
- int out_fd = in_fd==-1 ? -1 : open(dst, O_RDWR|O_CREAT|O_EXCL, 0200);
+ int out_fd = in_fd==-1 ? -1 : open(dst, O_RDWR|O_CREAT|O_EXCL
|O_NOCTTY
, 0200);
bool res = false;
if (in_fd==-1 || out_fd==-1 ||
bool res = false;
if (in_fd==-1 || out_fd==-1 ||