info-mtools
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Info-mtools] [PATCH] permit empty disk in recursive mode


From: twoj stary
Subject: [Info-mtools] [PATCH] permit empty disk in recursive mode
Date: Wed, 8 Sep 2021 14:34:42 +0200

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.

With MTOOLS_PERMIT_EMPTY set to a non-zero value, the return values are consistent in both modes:

$ MTOOLS_PERMIT_EMPTY=1 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
$ MTOOLS_PERMIT_EMPTY=1 mdir -s -i ./test.img; echo $?
0

Also, no error is printed about the missing directory entry. It shouldn't matter anyway, the error being opaque in the first place.

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:

$ 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

Regards,
Twój S.

Attachment: mtools-4.0.35-permit_empty.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]