push si ; mangle_dir mangles si
call mangle_name ; Mangle ramdisk name
pop si
- cmp byte [InitRD],' ' ; Null filename?
- seta byte [initrd_flag] ; Set flag if not
+ cmp byte [es:InitRD],' ' ; Null filename?
+ seta byte [es:initrd_flag] ; Set flag if not
not_initrd: pop es ; Restore ES->real_mode_seg
skip_this_opt: lodsb ; Load from command line
cmp al,' '
je vc0
call parseint ; vga=<number>
jc skip_this_opt ; Not an integer
-vc0: mov [es:bs_vidmode],bx ; Set video mode
+vc0: mov [bs_vidmode],bx ; Set video mode
jmp short skip_this_opt
is_mem_cmd:
add si,byte 4
cmp ebx,14*1024 ; Only trust < 15M point
jna memcmd_fair
mov bx,14*1024
-memcmd_fair: mov [HighMemSize],bx
+memcmd_fair: mov [es:HighMemSize],bx
jmp short skip_this_opt
cmdline_end:
push cs ; Restore standard DS
;
getc:
+ stc ; If we exit here -> EOF
mov ecx,[FBytes]
- jecxz getc_end
+ jecxz getc_ret
mov si,[FPtr]
cmp si,[EndOfGetCBuf]
jb getc_loaded
getc_loaded: lodsb ; Load a byte
mov [FPtr],si ; Update next byte pointer
dec dword [FBytes] ; Update bytes left counter (CF = 1)
-getc_end: cmc ; Set CF = 1 on EOF, 0 if not
- ret
+ clc ; Not EOF
+getc_ret: ret
;
; ungetc: Push a character (in AL) back into the getc buffer
;
getint:
mov di,NumBuf
-gi_getnum: cmp di,[NumBufEnd] ; Last byte in NumBuf
+gi_getnum: cmp di,NumBufEnd ; Last byte in NumBuf
jae gi_loaded
push di
call getc
cmp word [bx+dpbSectorSize],512 ; Sector size = 512 required
jne sectorsize_error
- cmp byte [bx+dpbClusterShift],6 ; Max size = 32K = 2^6 sectors
+ cmp byte [bx+dpbClusterShift],5 ; Max size = 16K = 2^5 sectors
jna read_bootsect
hugeclust_error:
msg_filesystem_err: db 'Filesystem not found on disk', 0Dh, 0Ah, '$'
msg_fat16_err: db 'FAT16 filesystems not supported at this time', 0Dh, 0Ah, '$'
msg_sectorsize_err: db 'Sector sizes other than 512 bytes not supported', 0Dh, 0Ah, '$'
-msg_hugeclust_err: db 'Clusters larger than 32K not supported', 0Dh, 0Ah, '$'
+msg_hugeclust_err: db 'Clusters larger than 16K not supported', 0Dh, 0Ah, '$'
msg_read_err: db 'Disk read failed', 0Dh, 0Ah, '$'
msg_write_err: db 'Disk write failed', 0Dh, 0Ah, '$'
* mount the disk. Either that or if Linux gets an fmount() system call
* we probably could do the mounting ourselves, and make this program
* setuid safe.
+ *
+ * Also, sync() between accessing the raw device and mount/umount seems
+ * to be necessary; I get data corruption otherwise.
*/
+#include <alloca.h>
#include <errno.h>
#include <fcntl.h>
#include <mntent.h>
pid_t f, w;
int status;
char *mntpath = NULL, mntname[64];
+ char *ldlinux_name;
int my_umask;
program = argv[0];
left -= nb;
}
close(dev_fd);
+
+ sync();
/*
* Check to see that what we got was indeed an MS-DOS boot sector/superblock
device);
exit(1);
}
- if ( sectbuf[bsSecPerClust] > 64 ) {
- fprintf(stderr, "%s: Cluster sizes larger than 32K not supported\n",
+ if ( sectbuf[bsSecPerClust] > 32 ) {
+ fprintf(stderr, "%s: Cluster sizes larger than 16K not supported\n",
device);
}
!strcmp(mnt->mnt_type, "auto") ) &&
hasmntopt(mnt, "user") &&
!hasmntopt(mnt, "ro") &&
+ mnt->mnt_dir[0] == '/' &&
!!hasmntopt(mnt, "loop") == !!S_ISREG(st.st_mode)) {
/* Okay, this is an fstab entry we should be able to live with. */
exit(1); /* Mount failed */
}
- if ( chdir(mntpath) ) {
- perror("chdir");
- if ( !euid )
- rmdir(mntpath);
- exit(1);
+ ldlinux_name = alloca(strlen(mntpath)+13);
+ if ( !ldlinux_name ) {
+ perror("malloc");
+ err = 1;
+ goto umount;
}
+ sprintf(ldlinux_name, "%s/ldlinux.sys", mntpath);
- unlink("ldlinux.sys");
- fd = open("ldlinux.sys", O_WRONLY|O_CREAT|O_TRUNC, 0444);
+ unlink(ldlinux_name);
+ fd = open(ldlinux_name, O_WRONLY|O_CREAT|O_TRUNC, 0444);
if ( fd < 0 ) {
perror(device);
err = 1;
close(fd);
umount:
- chdir("/");
-
f = fork();
if ( f < 0 ) {
perror("fork");
exit(1);
}
+ sync();
+
if ( !euid )
rmdir(mntpath);