Bug 845488

Summary: Long filenames on NTFS cause tar-out, copy-out etc to fail with error "Cannot open: File name too long"
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: dyasny, mbooth
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-03 10:54:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Richard W.M. Jones 2012-08-03 08:32:23 UTC
Description of problem:
(reported by Evaggelos Balaskas)

NTFS allows filenames up to 255 characters.  The tar format seems
to have a smaller limit (although not according to the documentation
I'm reading so I'm not exactly sure what's going on ...)

An example filename which fails:

tar: ./Desktop/ΔΗΜΗΤΡΗΣ/ΣΥΝΤΕΛΕΣΤΕΣ ΑΠΟΣΒΕΣΗΣ Νέοι συντελεστές
απόσβεσεις πάγιων περιουσιακών στοιχείων Οι συντελεστές απόσβεσης,
ανώτεροι και κατώτεροι που προβλέπει το ΠΔ για κάθε είδος
επιχειρηματικής δραστηριότητας.htm: Cannot open: File name too long

Version-Release number of selected component (if applicable):

libguestfs 1.19.28

Additional info:

https://www.redhat.com/archives/libguestfs/2012-August/msg00028.html

Comment 1 Richard W.M. Jones 2012-08-03 10:06:30 UTC
Reproducer (note this command is a single line):

$ guestfish -N fs:ntfs -m /dev/sda1 mkdir /Desktop : mkdir /Desktop/ΔΗΜΗΤΡΗΣ : touch "/Desktop/ΔΗΜΗΤΡΗΣ/ΣΥΝΤΕΛΕΣΤΕΣ ΑΠΟΣΒΕΣΗΣ Νέοι συντελεστές απόσβεσεις πάγιων περιουσιακών στοιχείων Οι συντελεστές απόσβεσης, ανώτεροι και κατώτεροι που προβλέπει το ΠΔ για κάθε είδος επιχειρηματικής δραστηριότητας.htm" : copy-out /Desktop .

Comment 2 Richard W.M. Jones 2012-08-03 10:11:03 UTC
Smaller reproducer:

$ guestfish -N fs:ntfs -m /dev/sda1 mkdir /foo : touch /foo/$(perl -e 'print "Σ"x200') : copy-out /foo /tmp

Note this seems to be something to do with bytes vs characters.

If we use 200 ASCII characters, then the tar command works fine.

If we use 200 sigma characters (in UTF 16 as used in NTFS this is
400 bytes, in UTF 8 it's also 400 bytes since each sigma is encoded
as 0xCE 0xA3), then the command fails.

Comment 3 Richard W.M. Jones 2012-08-03 10:15:27 UTC
Changing ntfs -> ext4 causes the touch command to break, ie.
such a filename cannot be created in the first place.  Presumably
this is because ext4 only allows filenames up to 255 *bytes*
where as ntfs allows filenames up to 255 characters.

Comment 4 Richard W.M. Jones 2012-08-03 10:31:51 UTC
I think I'm being an idiot here.  The problem is on the
host side not the appliance side.

Replacing copy-out with tar-out:

$ guestfish -N fs:ntfs -m /dev/sda1 mkdir /foo : touch /foo/$(perl -e 'print "Σ"x200') : tar-out /foo /dev/null

the command runs successfully.  This indicates that the bug
occurs when we create the file on the host filesystem (which
being ext4 will naturally fail because the name is too long).

Comment 5 Richard W.M. Jones 2012-08-03 10:42:17 UTC
Likely NOTABUG, but should be documented.

For a longer explanation see:
https://www.redhat.com/archives/libguestfs/2012-August/msg00031.html

Comment 6 Richard W.M. Jones 2012-08-03 10:54:33 UTC
Fixed upstream by documentation in
commit 7fa67427c6b2725bdcce52c08511f8813b7bd42e.