Re: cp with verify?
- From: Stephane CHAZELAS <this.address@xxxxxxxxxx>
- Date: Fri, 12 Jan 2007 18:52:08 GMT
2007-01-12, 10:39(-08), RolandRB:
[...]
[...]cp "$file" "$dest" || echo "failed".
I am wondering if it is possible for "cp" to return a zero return code
but the copy not to be a perfect copy.
cp will return an error if any of the open, write or close
fails.
For instance
cp file /dev/null
will succeed.
even though cmp file /dev/null will fail (unless file is empty).
write or open may fail if the virtual filesystem interface of
the system fails. For NFS or other network filesystem, it will
check for the acknowledgement of the server that the write was
successful on the other end (I beleive).
For other filesystems (like for the write on the NFS server
side), errors are most likely to be due to filesystem space,
quotas or permissions. Then the data will be lying in kernel
pages in memory with flags saying that those pages need to be
flushed to whatever devices lays underneath (which may be a disk
partition, a mtd device, loop device... potentially other layers
before it is stored to a physical storage (possibly encrypted or
duplicated...)) at some point.
You can mount filesystems with a sync option or use the O_SYNC
flag for open(2) (I don't think cp has an option to enable
that). This will make sure all the data has been flushed to
hardware when the writes and the close are done (not sure about
NFS). That won't give you a lot more guarantee, just that you
may pull the plug now or remove the USB key.
--
Stéphane
.
- References:
- cp with verify?
- From: RolandRB
- Re: cp with verify?
- From: Michael Tosch
- Re: cp with verify?
- From: RolandRB
- cp with verify?
- Prev by Date: Re: cp with verify?
- Next by Date: Re: cp with verify?
- Previous by thread: Re: cp with verify?
- Next by thread: Re: cp with verify?
- Index(es):
Relevant Pages
|