From nobody@FreeBSD.org  Mon Jun 13 12:57:08 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A85021065676
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Jun 2011 12:57:08 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 8E28F8FC1A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Jun 2011 12:57:08 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p5DCv7J9059270
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Jun 2011 12:57:07 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p5DCv7pV059269;
	Mon, 13 Jun 2011 12:57:07 GMT
	(envelope-from nobody)
Message-Id: <201106131257.p5DCv7pV059269@red.freebsd.org>
Date: Mon, 13 Jun 2011 12:57:07 GMT
From: "Vladislav V. Prodan" <universite@ukr.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Do not copy symlinks or through mtree, or via rsync
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         157835
>Category:       misc
>Synopsis:       Do not copy symlinks or through mtree, or via rsync
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 13 13:00:23 UTC 2011
>Closed-Date:    Thu Dec 29 17:12:36 UTC 2011
>Last-Modified:  Thu Dec 29 17:12:36 UTC 2011
>Originator:     Vladislav V. Prodan
>Release:        FreeBSD 8.2-STABLE amd64
>Organization:
>Environment:
FreeBSD mary-teresa 8.2-STABLE FreeBSD 8.2-STABLE #0: Tue Jun  7 17:56:08 EEST 2011     root@mary-teresa:/usr/obj/usr/src/sys/otrada.3  amd64

>Description:
You need to copy the skeleton directories without files contained therein, only subdirectories.
Problems arose with the symlinks.
Symlinks are ignored mtree and rsync.

# df -h /tmp
Filesystem    Size    Used   Avail Capacity  Mounted on
zroot/tmp     366G    168k    366G     0%    /tmp
# zfs get all zroot/tmp
NAME       PROPERTY              VALUE                 SOURCE
zroot/tmp  type                  filesystem            -
zroot/tmp  creation              &#1074;&#1090; &#1103;&#1085;&#1074;  1  3:15 2008  -
zroot/tmp  used                  284K                  -
zroot/tmp  available             366G                  -
zroot/tmp  referenced            168K                  -
zroot/tmp  compressratio         1.04x                 -
zroot/tmp  mounted               yes                   -
zroot/tmp  quota                 none                  default
zroot/tmp  reservation           none                  default
zroot/tmp  recordsize            128K                  default
zroot/tmp  mountpoint            /tmp                  local
zroot/tmp  sharenfs              off                   default
zroot/tmp  checksum              fletcher4             inherited from zroot
zroot/tmp  compression           on                    local
zroot/tmp  atime                 on                    default
zroot/tmp  devices               on                    default
zroot/tmp  exec                  on                    local
zroot/tmp  setuid                off                   local
zroot/tmp  readonly              off                   default
zroot/tmp  jailed                off                   default
zroot/tmp  snapdir               hidden                default
zroot/tmp  aclinherit            restricted            default
zroot/tmp  canmount              on                    default
zroot/tmp  xattr                 off                   temporary
zroot/tmp  copies                1                     default
zroot/tmp  version               4                     -
zroot/tmp  utf8only              off                   -
zroot/tmp  normalization         none                  -
zroot/tmp  casesensitivity       sensitive             -
zroot/tmp  vscan                 off                   default
zroot/tmp  nbmand                off                   default
zroot/tmp  sharesmb              off                   default
zroot/tmp  refquota              none                  default
zroot/tmp  refreservation        none                  default
zroot/tmp  primarycache          all                   default
zroot/tmp  secondarycache        all                   default
zroot/tmp  usedbysnapshots       115K                  -
zroot/tmp  usedbydataset         168K                  -
zroot/tmp  usedbychildren        0                     -
zroot/tmp  usedbyrefreservation  0                     -
zroot/tmp  logbias               latency               default
zroot/tmp  dedup                 off                   default
zroot/tmp  mlslabel                                    -
zroot/tmp  sync                  standard              default

>How-To-Repeat:
Creating a test directory with a symlink:
#!/bin/sh
symlink="ghgh gugh seee udjd"

mkdir -p /tmp/test/All /tmp/test-copy
cd /tmp/test/All

for i in $symlink; do
    mkdir ../$i
    ln -s ../$i $i
done

Script copying the skeleton directory using mtree:
#!/bin/sh
from_dir=/tmp/test
to_dir=/tmp/test-copy
mkdir -p $to_dir

cd $from_dir/;
mtree -c -d -i -n -k link,uname,gname,mode,flags > $to_dir/dir.txt

mtree -U -f $to_dir/dir.txt -p $to_dir

OR rsync:

#!/bin/sh
from_dir=/tmp/test
to_dir=/tmp/test-copy

rsync  -vraKz --include='*/' --exclude='*' $from_dir $to_dir





>Fix:


>Release-Note:
>Audit-Trail:

From: Alexander Panyushkin <vsityz@gmail.com>
To: bug-followup@FreeBSD.org, universite@ukr.net
Cc:  
Subject: Re: misc/157835: Do not copy symlinks or through mtree, or via rsync
Date: Tue, 14 Jun 2011 10:18:40 +0300

 change line
 mtree -c -d -i -n -k link,uname,gname,mode,flags > $to_dir/dir.txt
 
 to line
 mtree -c -r -i -n -k link,uname,gname,mode,flags > $to_dir/dir.txt
                ^^
 
 it`s work
 
 --
 Best regards.
 
 
State-Changed-From-To: open->closed 
State-Changed-By: jh 
State-Changed-When: Thu Dec 29 17:11:04 UTC 2011 
State-Changed-Why:  
This is not really a bug report. Please ask questions on the 
freebsd-questions@ mailing list. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=157835 
>Unformatted:
