Changeset 2485

Show
Ignore:
Timestamp:
02/04/07 18:18:27 (2 years ago)
Author:
ensc
Message:

- documented parts of the code were I needed to think >1min about its

sense

- use ftruncate(2) instead of a lseek(2)+write(2) sequence to create a

sparse file

- set O_NOCTTY flag for temp file

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib_internal/unify-copy.c

    r1977 r2485  
    8484{ 
    8585#if 1 
     86    // Do not use memcpy because this would dirty pages consisting only of 
     87    // '\0' 
    8688  int           *dst = dst_v; 
    8789  int const     *src = src_v; 
     
    120122 
    121123  if (in_len==-1) return false; 
    122   if (in_len>0 && 
    123       (lseek(out_fd, in_len-1, SEEK_SET)==-1 || 
    124        write(out_fd, "\0",     1)!=1))          // create sparse file 
     124  if (in_len>0 && ftruncate(out_fd, in_len)==-1)        // create sparse file 
    125125    return false; 
    126126   
     
    165165{ 
    166166  int           in_fd  = open(src, O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_LARGEFILE); 
    167   int           out_fd = in_fd==-1 ? -1 : open(dst, O_RDWR|O_CREAT|O_EXCL, 0200); 
     167  int           out_fd = in_fd==-1 ? -1 : open(dst, O_RDWR|O_CREAT|O_EXCL|O_NOCTTY, 0200); 
    168168  bool          res    = false; 
    169169