GNU bug report logs -
#17179
[PATCH] cp: use an invalid dev_t for an unknown device
Previous Next
Reported by: Dave Reisner <dreisner <at> archlinux.org>
Date: Thu, 3 Apr 2014 15:40:02 UTC
Severity: normal
Tags: patch
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On 04/03/2014 09:03 AM, Dave Reisner wrote:
> On the initial call to copy_internal, we must use an invalid device
> number. As of linux 3.14, the mount table has shifted slightly, causing
> the initramfs filesystem to have a devno of 0. This is valid, but
> confuses cp when attempting to copy only a single filesystem (cp -x).
> Since dev_t is defined to be an integer type, we can simply use a
> negative value to identify the unknown device.
dev_t is defined as an integral type, but not necessarily a signed
integral type, and not necessarily a type as wide as int. Using -1 as a
sentinel might be okay, but if you do, you MUST use a cast for maximum
portability.
> @@ -2434,7 +2434,7 @@ copy_internal (char const *src_name, char const *dst_name,
> }
>
> /* Decide whether to copy the contents of the directory. */
> - if (x->one_file_system && device != 0 && device != src_sb.st_dev)
> + if (x->one_file_system && device != -1 && device != src_sb.st_dev)
For example, this comparison may fail to do what you want if dev_t is
uint16_t (it will ALWAYS be false, since ((uint16_t)-1) != -1).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 11 years and 55 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.