tar protocol error on shared folder if archive has folder with colon in name

Discussions about using Linux guests in VirtualBox.
Post Reply
fencekicker
Posts: 33
Joined: 13. Oct 2022, 15:45

tar protocol error on shared folder if archive has folder with colon in name

Post by fencekicker »

Hi,

I'm running Ubuntu 20.04 (64-bit) in the guest, under VirtualBox 6.1.38 on Windows 10 64-bit. I've noticed that, if I try to decompress a tar.gz archive from the VM to a shared folder, and the archive contains a folder with a colon in the name, the decompression fails. Is this a known problem?

Code: Select all

stefan@spuiu-vm:~/tmp$ mkdir test:22
stefan@spuiu-vm:~/tmp$ ls > test\:22/ls
stefan@spuiu-vm:~/tmp$ date >test\:22/date
stefan@spuiu-vm:~/tmp$ tar cfz test_22.tgz test\:22/
stefan@spuiu-vm:~/tmp$ cd /media/sf_c/temp/
stefan@spuiu-vm:/media/sf_c/temp$ mkdir test
stefan@spuiu-vm:/media/sf_c/temp$ cd test/
stefan@spuiu-vm:/media/sf_c/temp/test$ tar xf ~/tmp/test_22.tgz 
tar: test\:22: Cannot mkdir: Protocol error
tar: test\:22: Cannot mkdir: Protocol error
tar: test\:22/ls: Cannot open: No such file or directory
tar: test\:22: Cannot mkdir: Protocol error
tar: test\:22/date: Cannot open: No such file or directory
tar: Exiting with failure status due to previous errors
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: tar protocol error on shared folder if archive has folder with colon in name

Post by mpack »

More to the point, why would that be a VirtualBox problem?

It doesn't surprise me that tar might have naming restrictions for files and folders.
fencekicker
Posts: 33
Joined: 13. Oct 2022, 15:45

Re: tar protocol error on shared folder if archive has folder with colon in name

Post by fencekicker »

Well, untarring the archive in Linux works fine:

Code: Select all

stefan@spuiu-vm:~$ cd /tmp/
stefan@spuiu-vm:/tmp$ tar xf ~/tmp/test
stefan@spuiu-vm:/tmp$ tar xf ~/tmp/test_22.tgz 
stefan@spuiu-vm:/tmp$ ls test\:22/
date  ls
Also, "Protocol error" is not exactly an error you expect from tar. If I google 'tar Cannot mkdir: Protocol error', the first entries I see are related to VirtualBox and shared folders. Unfortunately, the forum won't allow me to post links, since I've only been a member since today, but I can post some links I found tomorrow.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: tar protocol error on shared folder if archive has folder with colon in name

Post by scottgus1 »

fencekicker wrote:Ubuntu 20.04 (64-bit) in the guest, under VirtualBox 6.1.38 on Windows 10 64-bit. I've noticed that, if I try to decompress a tar.gz archive from the VM to a shared folder, and the archive contains a folder with a colon in the name, the decompression fails.
Windows can't have a file or folder name with a colon. Colons are only allowed between the drive letter and the first backslash, like C:\ So Windows, the host of the shared folder, will kick up when a colon'd file or folder name is attempted. How 'tar' in Linux complains about Windows kicking up would be a good question for the tar forums.
fencekicker
Posts: 33
Joined: 13. Oct 2022, 15:45

Re: tar protocol error on shared folder if archive has folder with colon in name

Post by fencekicker »

scottgus1 wrote:
fencekicker wrote:Ubuntu 20.04 (64-bit) in the guest, under VirtualBox 6.1.38 on Windows 10 64-bit. I've noticed that, if I try to decompress a tar.gz archive from the VM to a shared folder, and the archive contains a folder with a colon in the name, the decompression fails.
Windows can't have a file or folder name with a colon. Colons are only allowed between the drive letter and the first backslash, like C:\ So Windows, the host of the shared folder, will kick up when a colon'd file or folder name is attempted. How 'tar' in Linux complains about Windows kicking up would be a good question for the tar forums.
You're right, Windows doesn't allow that. The error in Windows is different, though:

Code: Select all

C:\temp\test>mkdir adfd:b
The directory name is invalid.
C:\temp\test>
I suspect VirtualBox, as the middleman, returns a generic error. As I said, "Protocol Error" comes up often related to VirtualBox. But yes, this looks like a Windows limitation that VBox can't do much about.
fencekicker
Posts: 33
Joined: 13. Oct 2022, 15:45

Re: tar protocol error on shared folder if archive has folder with colon in name

Post by fencekicker »

One good workaround, in my opinion, is to use tar's '--transform' option:

Code: Select all

stefan@spuiu-vm:/media/sf_c/temp/test$ tar xf ~/tmp/test_22.tgz --transform=s/:/_/g
stefan@spuiu-vm:/media/sf_c/temp/test$ ls 
test_22
I stumbled upon this while unpacking logs we collect from CentOS machines. On CentOS 7, kernel crashes are stored in folders with colons in the name, like '127.0.0.1-2022-09-26-05:45:56'.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: tar protocol error on shared folder if archive has folder with colon in name

Post by mpack »

fencekicker wrote: I suspect VirtualBox, as the middleman, returns a generic error.
Where do you see an error returned by VirtualBox?

VirtualBox disks read and write sectors, it knows nothing and cares less about about files and filenames, which are software (OS) concepts. It is up to the OS or to networking protocols to decide what characters they like in a file or path name.

The naming conventions for SAMBA shared folder contents are well known, i.e. as SMB is a Windows protocol they follow DOS/Windows conventions. I believe GA shared folders follow the same conventions, certainly so if the shared folder host is Windows.
fencekicker
Posts: 33
Joined: 13. Oct 2022, 15:45

Re: tar protocol error on shared folder if archive has folder with colon in name

Post by fencekicker »

mpack wrote: Where do you see an error returned by VirtualBox?
I suspect in this case it's the vboxsf kernel module that returns the error. In strace, I see:

Code: Select all

203589 08:41:05.648355 mkdir("test:a", 0777) = -1 EPROTO (Protocol error)
I don't have a Linux system with an NTFS partition handy, but I tried one with a FAT32 partition, and in that case, without VirtualBox involved, the mkdir system call returns EINVAL, which is more helpful. I suspect vboxsf returns EPROTO no matter what the underlying FS error.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: tar protocol error on shared folder if archive has folder with colon in name

Post by fth0 »

fencekicker wrote:I suspect in this case it's the vboxsf kernel module that returns the error.
You're probably right with that. There are several (> 20) situations when the vboxsf kernel module returns EPROTO, but there are also a lot of other error codes returned in other places.
Post Reply