[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Info-mtools] [PATCH] permit empty disk in recursive mode
From: |
Alain Knaff |
Subject: |
Re: [Info-mtools] [PATCH] permit empty disk in recursive mode |
Date: |
Sun, 21 Nov 2021 20:27:13 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 |
Hi,
On 9/8/21 2:34 PM, twoj stary wrote:
> Hello,
>
> Attached is a patch to permit empty disk when the recursive directory
> listing option (via '-/' or '-s') is on.
>
> The current state of affairs is while the non-recursive mode returns 0
> on exit for an empty disk, the recursive mode will return a non-zero
> status for such a disk:
>
> $ dd if=/dev/zero of=./test.img count=360 bs=1024; mkfs.msdos ./test.img
> ...
> $ mdir -i ./test.img; echo $?
> Volume in drive : has no label
> Volume Serial Number is E723-8ABB
> Directory for ::/
>
> No files
> 362 496 bytes free
>
> 0
> $ mdir -s -i ./test.img; echo $?
> mdir: File "." not found
> 1
>
> Since an empty disk shouldn't necessarily trigger an error. I propose to
> add an environment variable to control it.
Thanks for the patch.
The behavior you observed is actually a Bug (IMHO), there is no reason
why empty (but existing) directories should trigger an error. And
actually, for non-recursive mode, they don't.
So, rather than making correct behavior conditional on an environment
variable, I applied the fix unconditionally.
This is now part of the new 4.0.36 release
[...]> Since some users may rely on the non-zero status in the recursive
mode
> (e.g. to detect empty disks), the existing behaviour is preserved:
IMHO, nobody should be relying on this peculiarity for checking whether
a disk is empty. Indeed, this is a potentially inefficient way to do so
if ever the disk is not empty with a well-supplied and deep directory
tree :-)
Regards,
Alain
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Info-mtools] [PATCH] permit empty disk in recursive mode,
Alain Knaff <=