Bug 579608 - multiple commands in guestfish can not work for symbol links
multiple commands in guestfish can not work for symbol links
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
All Linux
low Severity medium
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks: 579677
  Show dependency treegraph
 
Reported: 2010-04-05 23:25 EDT by Pengzhen Cao
Modified: 2010-05-12 08:24 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 579677 (view as bug list)
Environment:
Last Closed: 2010-05-12 08:24:34 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Pengzhen Cao 2010-04-05 23:25:10 EDT
Description of problem:
Several commands in guestfish can not work for symbol links.
Commands that could not work are: "file, equal, strings, strings-e, wc-c, wc-l, wc-w, cp"

Version-Release number of selected component (if applicable):
1.0.85, on fedora12 x86_64

[pcao@pcao-test ~]$ rpm -qa |grep libguest
libguestfs-mount-1.0.85-1.fc12.2.x86_64
python-libguestfs-1.0.85-1.fc12.2.x86_64
libguestfs-tools-1.0.85-1.fc12.2.x86_64
perl-libguestfs-1.0.85-1.fc12.2.x86_64
libguestfs-1.0.85-1.fc12.2.x86_64


Steps to Reproduce:
1. start guestfish and mount a guest disk with symbol links and ordinary files on it 
2. run "file" command on an existing symbol link
3. same steps for “equal, strings, strings-e, wc-c, wc-l, wc-w, cp” commands
  
Actual results:
libguestfs: error: file: access: /file_test/link1: No such file or directory

Expected results:
xxx: symbolic link to xxx

Additional info:

guestfish logs:
><fs> add test.img
><fs> run
><fs> mount /dev/vol_test/vol_file /
><fs> ll /file_test/
total 71
drwxr-xr-x 7 root root  1024 Apr  2 09:42 .
drwxr-xr-x 6 root root  1024 Apr  1 10:13 ..
-rw-rw-r-- 1 root root  5930 Apr  2 06:20 a.txt
-rw-r--r-- 1 root root   540 Apr  2 06:00 b.txt
brwxr-xr-x 1 root root 3, 10 Apr  2 06:48 dev-block
crwxr-xr-x 1 root root 4, 44 Apr  2 06:49 dev-char
drwxr-xr-x 2 root root  1024 Apr  1 10:14 dir
-rw-rw-r-- 1 root root 51232 Apr  2 05:39 elf
-rw-r--r-- 1 root root    18 Apr  2 07:54 file_list
-rw-r--r-- 1 root root    34 Apr  2 06:36 fill
-rw-rw-r-- 1 root root   320 Apr  2 05:40 gzip
lrwxrwxrwx 1 root root    16 Apr  2 07:55 link1 -> /file_test/a.txt
lrwxrwxrwx 1 root root    16 Apr  2 07:55 link2 -> /file_test/a.txt
lrwxrwxrwx 1 root root    16 Apr  2 09:28 link2-cp -> /file_test/a.txt
lrwxrwxrwx 1 root root    15 Apr  2 07:55 link3 -> /file_test/gzip
-rw-r--r-- 1 root root   100 Apr  2 08:39 new.txt
drwxr-xr-x 3 root root  1024 Apr  2 09:33 newdir
prwxr-xr-x 1 root root     0 Apr  2 02:10 pipe
drwxr-xr-x 3 root root  1024 Apr  2 08:50 tar-in
lrwxrwxrwx 1 root root    17 Apr  2 09:12 tar-in-lns -> /file_test/tar-in
drwxr-xr-x 2 root root  1024 Apr  2 08:20 tgz-in
-rw-r--r-- 1 root root    37 Apr  2 08:26 touch
drwx------ 3 root root  1024 Apr  2 09:42 tttLlil0Q
-rw-rw-r-- 1 root root     0 Apr  2 03:41 umak002
--wx-ws-wt 1 root root     0 Apr  2 02:34 xattr


><fs> file /file_test/link1
libguestfs: error: file: access: /file_test/link1: No such file or directory
><fs> file /file_test/a.txt 
ASCII text, with very long lines


><fs> equal /file_test/link1 /file_test/link2
libguestfs: error: equal: 

><fs> strings /file_test/link1
libguestfs: error: strings: /file_test/link1: strings: '/sysroot/file_test/link1': No such file
><fs> strings-e s /file_test/link1 
libguestfs: error: strings_e: /file_test/link1: strings: '/sysroot/file_test/link1': No such file

><fs> wc-l /file_test/link1
libguestfs: error: wc_l: wc -l: wc: /sysroot/file_test/link1: No such file or directory
><fs> wc-w /file_test/link1
libguestfs: error: wc_w: wc -w: wc: /sysroot/file_test/link1: No such file or directory
><fs> wc-c /file_test/link1
libguestfs: error: wc_c: wc -c: wc: /sysroot/file_test/link1: No such file or directory

><fs> cp /file_test/link1 /file_test/link-cp
libguestfs: error: cp: cp: cannot stat `/sysroot/file_test/link1': No such file or directory
Comment 1 Richard W.M. Jones 2010-04-06 03:37:25 EDT
Agreed, we should make this work.

In fact the problem is a simple test in the generated code, so
it should be equally simple to fix, but I'll also add a regression
test so it doesn't get broken in future.
Comment 2 Richard W.M. Jones 2010-04-06 03:43:25 EDT
Actually, not so simple.

Because we mount the filesystem under /sysroot in the appliance,
absolute symbolic links get broken for any non-chrooted commands.

Jim, any ideas on this one?
Comment 3 Pengzhen Cao 2010-04-06 04:26:03 EDT
Richard, I think some commands should operate on the link itself.
Such as "file link1" should report link1 as a symbol link, rather than the destination it points to. And the same as ”cp“.While some commands like "equal, wc" should operate on the destination file it points to.

I have tested almost 70 commands related to file and dir operations, most could work, only these reported can not work. You can make a sanity check later.

And there is one thing I do not understand, "cp_a" can work on symbol links, but "cp" can not.
Comment 4 Jim Meyering 2010-04-06 05:12:40 EDT
Rich,

Using sysroot_path (that you mentioned on IRC) sounds like it might work.
How? (thinking out loud)...
One caveat: it would have to know when to apply the transformation.
Some commands require it, while others require no transformation.

And what if /symlink -> /a -> /b -> /c ?
Will sysroot_patch transform all of them?
Comment 6 Richard W.M. Jones 2010-05-06 17:13:37 EDT
Patch posted upstream:
https://www.redhat.com/archives/libguestfs/2010-May/msg00017.html
Comment 7 Richard W.M. Jones 2010-05-12 08:24:34 EDT
Fixed upstream:
http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=07369cb77a07f965cbf8e02f485c78a22c091f85
and subsequent commits.

Note You need to log in before you can comment on or make changes to this bug.