Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RunCPM can't execute COM file that's definitely there -- filename case issue? #204

Closed
Kroc opened this issue Feb 8, 2025 · 20 comments
Closed

Comments

@Kroc
Copy link

Kroc commented Feb 8, 2025

The filenames are lowercase on the filesystem, but whilst RunCPM cannot list the files, it can't execute them regardless of case typed!

Image

@MockbaTheBorg
Copy link
Owner

MockbaTheBorg commented Feb 9, 2025

I see it happens on Linux (maybe Mac also, and others).
I wonder ... if we have 'xpto.COM', 'XPTO.com' and 'xpto.com' in the same folder, which are perfectly fine Linux names, which one should RunCPM execute when you type XPTO?
The answer is: none! because none of them are XPTO.COM.
Specifically for this situation I had added the following to our readme:
All the letters for folders/subfolders and file names should be kept in uppercase, to avoid any issues of case-sensitive filesystems compatibility.
I can´t prevent the underlying operating system to give me all the names when I scan its directories.
So in this case I suggest just use uppercase across the board.
We can call it a filesystem "limitation".

@Kroc
Copy link
Author

Kroc commented Feb 9, 2025

Okay, that's fair but I wish I had a choice of uppercase vs. lowercase. Perhaps if a file doesn't exist in the all-uppercase form, check for the all-lowercase form?

@SEGStriker
Copy link

What if the subdirectory has both upper and lower characters, for example ProgAll? So, no way for such a smart check.

@Kroc
Copy link
Author

Kroc commented Feb 9, 2025

It wouldn't have to handle all possibilities -- just ALL CAPS and all lower as the two predominate styles.

@SEGStriker
Copy link

I would say that one of predominate styles is to have capital letter at the beginning. Which means it depends on the logic.

@MockbaTheBorg
Copy link
Owner

I will actually see if I can make it use the first one. Doesn't matter caps combination.
Then it becomes up to us to prevent duplicates.
But it would ignore case.
I think this would be the best behavior.

@feilipu
Copy link

feilipu commented Feb 10, 2025

Just to point out the obvious, the repo is RunCPM. Allowing lowercase would make it RunSomethingLikeCPMish.

CPM expects all uppercase filenames, and many original utilities rely on this. So imho, keep to the standard of CPM 2.2 or later.

@Kroc
Copy link
Author

Kroc commented Feb 10, 2025

Nothing changes within the CP/M environment, this would be entirely a convenience on the host side

@MockbaTheBorg
Copy link
Owner

MockbaTheBorg commented Feb 10, 2025 via email

@SEGStriker
Copy link

On the host side it is fully OS dependent - DOS/Windows doesn't really care about the case (Windows can use both upper and lowercase in file names, but still doesn't really care). Simple example:

C:>dir f*
Volume in drive C is OS

Directory of C:\

01/22/2025 04:45 PM

Files
0 File(s) 0 bytes
1 Dir(s) 229,678,669,824 bytes free

C:>dir F*
Volume in drive C is OS

Directory of C:\

01/22/2025 04:45 PM

Files
0 File(s) 0 bytes
1 Dir(s) 229,678,620,672 bytes free

As shown, it will find "Files" in both cases, even though it contains one capital letter and the rest are lowercase. Same in more complex situations.
But in Linux it is completely the opposite - it really cares about upper/lowercase. So in theory we could have /Files, /files and /FILES in one directory:

[root@server]# mkdir files
[root@server]# mkdir Files
[root@server]# mkdir FILES
[root@server]# ls -la
total 5
drwxr-xr-x 6 root root 99 Feb 10 01:39 .
dr-xr-x---. 17 root root 4096 Dec 12 20:09 ..
drwxr-xr-x 2 root root 6 Feb 10 01:39 files
drwxr-xr-x 2 root root 6 Feb 10 01:39 Files
drwxr-xr-x 2 root root 6 Feb 10 01:39 FILES

This is a real test, not just manipulation :)
So, how will RunCPM distinguish these 3 directories if all of them exist and are converted by the emulator to uppercase?

@MockbaTheBorg
Copy link
Owner

MockbaTheBorg commented Feb 10, 2025 via email

@SEGStriker
Copy link

Yeah, it is same with files. Directories are nothing else but special kind of files, you know that.
OK, whatever you decide.

@MockbaTheBorg
Copy link
Owner

MockbaTheBorg commented Feb 10, 2025 via email

@MockbaTheBorg
Copy link
Owner

Ok ... upon revisiting the disk code after all these years the conclusion is:
can´t be done.
RunCPM treats all filenames internally as uppercase, as it should be.
So, even though I am using the glob() function to collect the directory on Linux in a case insensitive manner today (which means a:v65.com appears as A:V65.COM when you DIR), when you try to run that program it will ultimately be converted to a fopen() request to ./A/0/V65.COM, which doesn´t exist.
To make that exist it would require RunCPM to either work with the names internally everywhere without converting them to uppercase or keep a translation table somehow (which is a different can of worms, as there might be multiple instances of the "same" name with different case combinations.
It is a lot of code to modify for what is actually a documented "limitation" specific to Linux (remember, RunCPM was born on Windows, Linux is already a port of it).
So at this point, for the specific Linux use case I can only offer one proposition:
Have your CPM filesystem created in an image or USB device formatted with vfat, cd to there and run RunCPM. It will be case insensitive now and everything will work.
I actually use the USB solution, so I can move my CP/M collection between my Windows desktop, my Linux laptop and bring it with me to work when I want to procrastinate.

@MockbaTheBorg
Copy link
Owner

Tried to get rid of all the 'toupper' internally to see what would happen. But there's a problem hiding there.
When we type v65 I need to append the .COM extension to make it be looked up and run. That is done by the CCP, not by RunCPM, so we're out of luck there as well.

@Xalior
Copy link

Xalior commented Feb 10, 2025

ext4 has support for marking specific directories as case insensitive, which also has options as a workaround.

@MockbaTheBorg
Copy link
Owner

That's a good option, I didn´t know about that ... but looks like the ext4 filesystem must have been created with the casefold option enabled to accept it. On my laptop, for example, even though the casefold option seems to be supported by the kernel, the filesystem won't accept it. So I am out of look. You mileage may vary on this one.

@Xalior
Copy link

Xalior commented Feb 10, 2025 via email

@MockbaTheBorg
Copy link
Owner

So, turns out that enabling casefold on my Linux laptop's filesystem, so I could make my CPM directory case insensitive, solved two problems:

  1. Files and executables can be named lowercase, uppercase, comination, doesn't matter.
  2. You cannot have multiple files with the same name in the folder, because the folder now is case insensitive. (behaves just like Windows folder)

This is then the ideal solution for Linux it seems. Requires a kernel higher than 5.2 though. I would recommend way higher. Mine is 6.11.

Here is how I made it work:

  1. Logoff from the laptop completely so I can log in back as root and dismount /home. Needs to be dismounted.
  2. Log back as root and enable casefold onto the /home filesystem device:
    umount /home
    tune2fs -O casefold /dev/sdb3 (my /home is at /dev/sdb3, your's may/will be not)
    reboot
  3. Create an empty CPM folder inside my /home/mockba. (you can create somewhere else)
  4. Enable casefolding on that folder (has to be done on an empty folder):
    chattr +F CPM
    reboot (somehow it only worked well after I rebooted again)
  5. Copy all the folders and files from my old CPM folder recursively onto this one.
  6. Great success!

Now it works under Linux precisely the same as it would on a FAT filesystem.

@Kroc
Copy link
Author

Kroc commented Feb 10, 2025

Changing the folder's case-folding is not something that's going to transfer across Git if others download / clone the repo, so I'll switch to using all uppercase for files. Thanks for the consideration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants