mount-utils icon indicating copy to clipboard operation
mount-utils copied to clipboard

`getDiskFormat()` returns nil error if the given disk path doesn't exist.

Open derekbit opened this issue 11 months ago • 1 comments

We found that the getDiskFormat function (code) might return a nil error if the given disk path does not exist.

If the disk path does not exist, blkid -p ... returns errno 2, indicating that the disk format was not found. Consequently, getDiskFormat() returns a nil error to its caller. However, this nil error can be misleading because it does not clearly signal that the disk is missing.

We propose that before returning ("", nil), getDiskFormat() should explicitly verify whether the disk exists. If the disk does not exist, the function should return an appropriate error instead of nil.

More context: https://github.com/longhorn/longhorn/issues/10416

derekbit avatar Feb 13 '25 07:02 derekbit