Lua-RTOS-ESP32 icon indicating copy to clipboard operation
Lua-RTOS-ESP32 copied to clipboard

No way to specify where to keep the history file

Open TotallyNotSethP opened this issue 2 years ago • 3 comments

I need to be able to tell the os to always put the history file in ramfs, never in fat storage. This is not an option, it always defaults to fat storage.

TotallyNotSethP avatar Aug 30 '22 05:08 TotallyNotSethP

Using df I think it's possible to show the used/free space for each mounted file system. Maybe you can use that to check if the ramfs has been mounted. If not, you could add an option to the shell.history() call to make sure it's only activated if ramfs is properly mounted.

the0ne avatar Aug 30 '22 08:08 the0ne

Sorry I think you misunderstood... if both ramfs and fat are mounted, i want to be able to choose where the history file is stored. atm, it defaults to fat always

TotallyNotSethP avatar Aug 30 '22 13:08 TotallyNotSethP

It all comes down to function mount_history_file in components/sys/sys/mount.c It first checks for fat, then second it checks for ramfs.

    if (mount_is_mounted("fat")) {
        path = mount_get_mount_path("fat");
    } else if (mount_is_mounted("ramfs")) {
        path = mount_get_mount_path("ramfs");
    }

That's clearly because it reflects the idea of a history best: To preserve previous commands. Which, one has to admit, is better done on a FAT than on a RAMFS 😉

I'd say you could add an optional parameter to function os_history in loslib_adds.inc That parameter could say whether RAMFS should be preferred over FAT - with the default being the current behaviour. Then in mount_history_file that parameter could be used to check for RAMFS before FAT.

the0ne avatar Aug 31 '22 08:08 the0ne