FW: cpio command and schg flags

joeb1 joeb1 at a1poweruser.com
Tue Sep 6 14:59:06 UTC 2011



> I am trying to use this code sequence to clone a directory tree.
> mkdir /usr/test1
> cd /var
> find . | cpio -dmp  /usr/test1
>
> The result is  /usr/test1 gets populated with the directory tree but
> all the schg flags get stripped off.
>
> How can I keep the schg flags in the cloned directory?

Did you copy under root? BSD cpio unlike GNU cpio does preserve file flags.

  $ cpio --version
  bsdcpio 2.8.4 -- libarchive 2.8.4

  $ find /lib | sudo cpio -dmp test
  56525 blocks

  $ ls -lo test/lib | awk '$5 != "-"'
  total 15595
  -r--r--r--  1 root  wheel  schg 4440677 Sep  5 22:24 libc.so.7
  -r--r--r--  1 root  wheel  schg  131655 Sep  5 22:24 libcrypt.so.5
  -r--r--r--  1 root  wheel  schg  592241 Sep  5 22:24 libthr.so.3



More information about the freebsd-questions mailing list