Looking for a reliable way to determine if a drive letter is in use
#21
@hanness - A drive has first no partition but only a letter (Windows). There can be different partitions on this drive - can be.

So somehow I don't know what your problem is. . .  Huh
Reply
#22
(05-09-2023, 10:16 PM)Kernelpanic Wrote: A drive has first no partition but only a letter (Windows). There can be different partitions on this drive - can be.

Remember that Windows is notorious for being unpredictable and for poor performance with some things. Once Windows10 zapped an USB disk because I was plugging it into an external hub that wasn't powered. At that time I didn't have Internet and I didn't have a Linux installation to do anything about it. So I lost my data on that disk, but luckily most of it was backed up somewhere else.

Sometimes Windows is so unpredictable an user like me who is a bit paranoid could be stuck looking at the "Devices and Printers" screen, at one of the drives that the OS puts a clock icon over one of the icons of the drive that was just plugged in. Once in a while there is a drive to plug in where the clock takes a long time to go away. Then expect poor performance and forget about writing to that drive. I have seen a 32GB USB v3.0 disk failing on me this year, but not because of Windows, it just happened from a flimsy thing.

Because Windows is unpredictable, it could decide to reserve drive letters. This could also happen out of using "SUBST" terminal command, which allows a drive letter to refer to a long-named directory existing on the system. It could also happen from a disk that is plugged in which has at least one partition Windows recognizes, but also "ext4" or something out of FreeBSD or Linux that Windows refuses to recognize; in fact, it could offer to format that partition. I don't know if WSL changes anything about that.

I would have trouble using hanness' program on Linux with Wine. Because that is craziness altogether different about drive letters. Sure things are the first three letters and "Z". "Z" represents the root directory of the Linux system. In other words, a Windows program is shown that "/home/myuser/Documents/thisdoc.txt" is called "Z:\home\myuser\Documents\thisdoc.txt" for that program. Have multiple partitions on the internal disk, including ones that cannot be used sensibly (Linux "swap"), and pluggable disks and you will see how Wine assigns drive letters which could wreck things for some programmers.

Linux could irritate in another way reserving device names. Try booting Clonezilla from a pluggable disk, with the mode that copies the operating system virtual machine to RAM. After it's ready the loading disk could be unplugged in favor of another one. However that will be reserved as "/dev/sdb" for a system which has an internal HDD, or as "/dev/sda" for a system which has a board-card ("mmcblk") or the ordinary SSD ("nvme").

Otherwise it's what I already said for a disk that is plugged in and activated. If it's plugged in and not activated then it won't be found inside "/media", and it won't be listed as one of the active mounts.
Reply
#23
(05-09-2023, 10:16 PM)Kernelpanic Wrote: @hanness - A drive has first no partition but only a letter (Windows). There can be different partitions on this drive - can be.

So somehow I don't know what your problem is. . .  Huh

Yeah, in Windows a drive will have a letter if a volume is present, even if it's not partitioned and/or formatted. If you try to double-click on a drive letter that has no partition or has not been formatted Windows will pop up a screen telling you this and offer to format the drive for you.

I suppose it was the simplest solution for Microsoft to come up with for the wildly non-technical crowd that makes up most of the Windows user base. And hence, this is one of the reasons most Windows are so inept and clueless when it comes to drive and partition management. Microsoft has dumbed down the process to the point of stupidity. But, that's exactly what they want, clueless Windows users, has been all along. Sorry, got on a bit of a rant there. It's this and MANY more reasons why I tell people that Microsoft has set computing back 30+ years. Don't even get me started on not including a programming language with the OS. Another way to dumb down users.
Software and cathedrals are much the same — first we build them, then we pray.
QB64 Tutorial
Reply
#24
Yes, I wrote this little programme in 2019 (Working with files located on USB devices)

Please have a look here:  https://qb64forum.alephc.xyz/index.php?t...#msg107056
Why not yes ?
Reply
#25
euklides, thanks for that information, but it does not address the issue that I was trying to convey.

But I do appreciate the information.
Reply




Users browsing this thread: 3 Guest(s)