aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2026-11-29 18:53:52 +0100
committerJavier <dev.git@javispedro.com>2026-11-29 18:53:52 +0100
commit5898f13480921e1c1ab362852f88794ea955ffce (patch)
treefec95835799d78708c49ea144e1955a7d22f9ede
parent8e9df5624d56a91eaa71a1ceac4932b7c5c5ee48 (diff)
downloadvbados-5898f13480921e1c1ab362852f88794ea955ffce.tar.gz
vbados-5898f13480921e1c1ab362852f88794ea955ffce.zip
vbsf: add ability to build without hashing of long filenames
-rw-r--r--lfn.h10
-rw-r--r--sfmain.c8
-rw-r--r--sftsr.c4
-rw-r--r--sftsr.h2
4 files changed, 23 insertions, 1 deletions
diff --git a/lfn.h b/lfn.h
index 3f25330..ec50e75 100644
--- a/lfn.h
+++ b/lfn.h
@@ -25,6 +25,8 @@
#include "vboxshfl.h"
#include "sftsr.h"
+#if USE_LFN_TO_SHORT
+
#define REVERSE_HASH 1
static inline bool translate_filename_from_host(SHFLSTRING *, bool, bool);
@@ -426,6 +428,14 @@ return_name:
return len;
}
+#else
+static uint16_t get_true_host_name_n(TSRDATAPTR data, int drive, uint8_t *dst, char __far *src, uint16_t buflen, uint16_t count)
+{
+ // Do unicode conversion but not LFN
+ return local_to_utf8_n(data, dst, src, buflen, count);
+}
+
+#endif // USE_LFN_TO_SHORT
static inline uint16_t get_true_host_name(TSRDATAPTR data, int drive, uint8_t *dst, char __far *src, uint16_t buflen)
{
diff --git a/sfmain.c b/sfmain.c
index 4f102bb..0c3038d 100644
--- a/sfmain.c
+++ b/sfmain.c
@@ -204,7 +204,7 @@ static int unmount_shfl(LPTSRDATA data, int drive)
static void set_mountopts_defaults(MOUNTOPTS *opts)
{
- opts->generate_sfn = true;
+ opts->generate_sfn = USE_LFN_TO_SHORT;
opts->require_uppercase = false;
opts->use_host_sfn = false;
opts->hash_chars = DEF_HASH_CHARS;
@@ -726,10 +726,12 @@ static void print_help(void)
puts( _(0, 5, " uninstall Uninstall the driver from memory."));
puts( _(0, 6, " list List available shared folders."));
puts( _(0, 7, " mount <FOLD> <X:> ... Mount a shared folder into drive X:."));
+#if USE_LFN_TO_SHORT
puts( _(0, 8, " /hash <n> Number of hash chars following the '~'"));
puts( _(0, 9, " for generated DOS short filenames."));
printf(_(0, 10, " (between %d and %d; default %d; 0 to disable)\n"),
MIN_HASH_CHARS, MAX_HASH_CHARS, DEF_HASH_CHARS);
+#endif
puts( _(0, 11, " /host Use short file names from Windows hosts."));
puts( _(0, 12, " /upper Require uppercase host filenames."));
puts( _(0, 13, " remount <X:> ... Change mount options for mounted drive X:."));
@@ -778,6 +780,7 @@ static int parse_mountopts(MOUNTOPTS *opts, int *argi, int argc, const char *arg
int i = *argi;
while (argv[i][0] == '/' && i < argc) {
if (stricmp(argv[i], "/hash") == 0) {
+#if USE_LFN_TO_SHORT
i++;
if (i >= argc) return arg_required("/hash");
@@ -793,6 +796,9 @@ static int parse_mountopts(MOUNTOPTS *opts, int *argi, int argc, const char *arg
} else {
return invalid_arg(argv[i]);
}
+#else
+ return invalid_arg(argv[i]);
+#endif
} else if (stricmp(argv[i], "/nohash") == 0) {
opts->generate_sfn = false;
} else if (stricmp(argv[i], "/host") == 0) {
diff --git a/sftsr.c b/sftsr.c
index 6db709e..9222c87 100644
--- a/sftsr.c
+++ b/sftsr.c
@@ -1089,11 +1089,13 @@ static vboxerr find_next_from_vbox(unsigned openfile, char __far *path)
// Now convert the filename
+#if USE_LFN_TO_SHORT
// Calculate hash now using host file name before any conversion
if (data.drives[drive].opt.generate_sfn) {
hash = lfn_name_hash(shfldirinfo.dirinfo.name.ach, shfldirinfo.dirinfo.name.u16Length,
data.drives[drive].opt.hash_chars);
}
+#endif
if (data.drives[drive].opt.use_host_sfn && shfldirinfo.dirinfo.cucShortName != 0) {
// Use shortname provided by host OS
@@ -1121,12 +1123,14 @@ static vboxerr find_next_from_vbox(unsigned openfile, char __far *path)
dputs("detected invalid characters in filename");
}
+#if USE_LFN_TO_SHORT
if (data.drives[drive].opt.generate_sfn && !valid) {
dputs("using mangled long filename");
mangle_to_8_3_filename(hash, data.drives[drive].opt.hash_chars,
found_file->filename, &shfldirinfo.dirinfo.name);
valid = true;
}
+#endif
if (!valid) {
dputs("hiding file with invalid filename");
diff --git a/sftsr.h b/sftsr.h
index 2a0cab0..f424297 100644
--- a/sftsr.h
+++ b/sftsr.h
@@ -26,6 +26,8 @@
#include "vbox.h"
#include "int21dos.h"
+/** Transform long file names into short DOS names. */
+#define USE_LFN_TO_SHORT 1
/** Trace all int2F calls into dlog */
#define TRACE_CALLS 0