aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-01-23 23:07:57 -0800
committerH. Peter Anvin <hpa@zytor.com>2007-01-23 23:07:57 -0800
commitd0c3ada6595e3d86f41c27b5a9b5ea6e399edfe9 (patch)
treeac7822843a2f363f187af1b86c11f9900b60cb4e
parenta603406936e7277ff9847a4ed697122761d53cf5 (diff)
downloadsyslinux-d0c3ada6595e3d86f41c27b5a9b5ea6e399edfe9.tar.gz
syslinux-d0c3ada6595e3d86f41c27b5a9b5ea6e399edfe9.tar.xz
syslinux-d0c3ada6595e3d86f41c27b5a9b5ea6e399edfe9.zip
Win32 FAT installer: support installing in a subdirectorysyslinux-3.35-pre2
-rw-r--r--win32/syslinux.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/win32/syslinux.c b/win32/syslinux.c
index db5007db..1b5b8fda 100644
--- a/win32/syslinux.c
+++ b/win32/syslinux.c
@@ -233,7 +233,7 @@ int libfat_readfile(intptr_t pp, void *buf, size_t secsize, libfat_sector_t sect
noreturn usage(void)
{
- fprintf(stderr, "Usage: syslinux.exe [-sfma] <drive>: [bootsecfile]\n");
+ fprintf(stderr, "Usage: syslinux.exe [-sfma][-d directory] <drive>: [bootsecfile]\n");
exit(1);
}
@@ -256,6 +256,7 @@ int main(int argc, char *argv[])
uint32_t ldlinux_cluster;
int nsectors;
const char *bootsecfile = NULL;
+ const char *subdir = NULL;
int force = 0; /* -f (force) option */
int mbr = 0; /* -m (MBR) option */
@@ -291,6 +292,10 @@ int main(int argc, char *argv[])
case 'a': /* Mark this partition active */
setactive = 1;
break;
+ case 'd':
+ if ( argp[1] )
+ subdir = *++argp;
+ break;
default:
usage();
break;
@@ -446,6 +451,46 @@ int main(int argc, char *argv[])
/* Close file */
CloseHandle(f_handle);
+ /* Move the file to the desired location */
+ if (subdir) {
+ char new_ldlinux_name[strlen(subdir)+16];
+ char *cp = new_ldlinux_name+3;
+ const char *sd;
+ int slash = 1;
+
+ new_ldlinux_name[0] = drive[0];
+ new_ldlinux_name[1] = ':';
+ new_ldlinux_name[2] = '\\';
+
+ for (sd = subdir; *sd; sd++) {
+ if (*sd == '/' || *sd == '\\') {
+ if (slash)
+ continue;
+ *cp++ = '\\';
+ }
+ }
+
+ /* Skip if subdirectory == root */
+ if (cp > new_ldlinux_name+3) {
+ if (!slash)
+ *cp++ = '\\';
+
+ memcpy(cp, "ldlinux.sys", 12);
+
+ /* Delete any previous file */
+ SetFileAttributes(new_ldlinux_name, FILE_ATTRIBUTE_NORMAL);
+ DeleteFile(new_ldlinux_name);
+ if (!MoveFile(ldlinux_name, new_ldlinux_name))
+ SetFileAttributes(ldlinux_name, FILE_ATTRIBUTE_READONLY |
+ FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ else
+ SetFileAttributes(new_ldlinux_name, FILE_ATTRIBUTE_READONLY |
+ FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
+ }
+ }
+
+
+
/* Make the syslinux boot sector */
syslinux_make_bootsect(sectbuf);