X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=lib_internal%2Funify-copy.c;h=81102e5c098f8880e6a7483f3403ab725aeb4fd0;hb=ec4370f7ebd7fb0ce7f002f5bf2c74f03acd3ec1;hp=1eae0814a52e930a90b29fdc75e2642fac79ee3a;hpb=3b34449070c0846fdc49436d1edd5916512f1644;p=util-vserver.git diff --git a/lib_internal/unify-copy.c b/lib_internal/unify-copy.c index 1eae081..81102e5 100644 --- 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:16Z ensc $ --*- c -*-- +// $Id: unify-copy.c 2485 2007-02-04 17:18:27Z ensc $ --*- c -*-- // Copyright (C) 2004 Enrico Scholz // @@ -83,6 +83,8 @@ static void 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); @@ -119,9 +121,7 @@ copyMMap(int in_fd, int out_fd) 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; @@ -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); - 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 ||