dec di
mov [CmdLinePtr],di
+ mov byte [es:di],0 ; Null-terminate
pop es
ret
mov ds,P_ES
mov si,P_SI
mov di,InitRD
- pm_call mangle_name
+ pm_call pm_mangle_name
pop ds
pm_call pm_searchdir
jz comapi_err
mov ds,P_DS
mov si,P_SI
mov di,KernelName
- pm_call mangle_name
+ pm_call pm_mangle_name
pop ds
pm_call pm_searchdir
jz comapi_err
mov byte [si],0 ; Zero-terminate filename
mov si,VGAFileBuf
mov di,VGAFileMBuf
- pm_call mangle_name
+ pm_call pm_mangle_name
call core_open
jz msg_putcharnext ; Not there
call vgadisplayfile
extern hello
; fs.c
- extern fs_init, pm_searchdir, getfssec, mangle_name, load_config
- extern unmangle_name, close_file
+ extern fs_init, pm_searchdir, getfssec, pm_mangle_name, load_config
+ extern pm_unmangle_name, close_file
; chdir.c
extern pm_realpath
; readdir.c
extern opendir, readdir, closedir
+
+ ; newconfig.c
+ extern pm_is_config_file
+
%if IS_PXELINUX
; pxe.c
extern unload_pxe, reset_pxe
printf("ERROR: No configuration file found\n");
}
-void mangle_name(com32sys_t *regs)
+void pm_mangle_name(com32sys_t *regs)
{
const char *src = MK_PTR(regs->ds, regs->esi.w[0]);
char *dst = MK_PTR(regs->es, regs->edi.w[0]);
-
- this_fs->fs_ops->mangle_name(dst, src);
+
+ mangle_name(dst, src);
}
+void mangle_name(char *dst, const char *src)
+{
+ this_fs->fs_ops->mangle_name(dst, src);
+}
-void unmangle_name(com32sys_t *regs)
+/*
+ * XXX: current unmangle_name() is stpcpy() on all filesystems; consider
+ * eliminating it as a method.
+ */
+void pm_unmangle_name(com32sys_t *regs)
{
const char *src = MK_PTR(regs->ds, regs->esi.w[0]);
char *dst = MK_PTR(regs->es, regs->edi.w[0]);
- dst = this_fs->fs_ops->unmangle_name(dst, src);
+ dst = unmangle_name(dst, src);
/* Update the di register to point to the last null char */
regs->edi.w[0] = OFFS_WRT(dst, regs->es);
}
+char *unmangle_name(char *dst, const char *src)
+{
+ return this_fs->fs_ops->unmangle_name(dst, src);
+}
+
void getfssec(com32sys_t *regs)
{
int sectors;
extern char SubvolName[];
extern char ConfigName[];
extern char KernelName[];
+extern char cmd_line[];
+extern char ConfigFile[];
+extern char KernelCName[];
/* diskstart.inc isolinux.asm*/
extern void getlinsec(void);
}
/* fs.c */
-void mangle_name(com32sys_t *);
+void pm_mangle_name(com32sys_t *);
+void pm_unmangle_name(com32sys_t *);
void pm_searchdir(com32sys_t *);
+void mangle_name(char *, const char *);
+char *unmangle_name(char *, const char *);
int searchdir(const char *name);
void _close_file(struct file *);
cmd_line_here equ $ ; F800 Should be out of the way
endstruc
+ global cmd_line
+cmd_line equ (real_mode_seg << 4) + cmd_line_here
+
;
; Old kernel command line signature
;
--- /dev/null
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2010 Intel Corporation; author: H. Peter Anvin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston MA 02110-1301, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * newconfig.c
+ *
+ * Load a new configuration file
+ */
+
+#include "core.h"
+#include "fs.h"
+
+void pm_is_config_file(com32sys_t *regs)
+{
+ char target_cwd[FILENAME_MAX];
+ const char *p;
+
+ (void)regs;
+
+ /* Save configuration file as an absolute path for posterity */
+ realpath(ConfigName, KernelCName, FILENAME_MAX);
+
+ /* If we got anything on the command line, do a chdir */
+ p = cmd_line;
+ while (*p && !not_whitespace(*p))
+ p++;
+
+ if (*p) {
+ mangle_name(target_cwd, p);
+ chdir(target_cwd);
+ }
+}
section .bss16
KbdMap resb 256 ; Keyboard map
FKeyName resb MAX_FKEYS*FILENAME_MAX ; File names for F-key help
-KernelCNameLen resw 1 ; Length of unmangled kernel name
InitRDCNameLen resw 1 ; Length of unmangled initrd name
-%if IS_SYSLINUX
-KernelName resb FILENAME_MAX+1 ; Mangled name for kernel
-KernelCName resb FILENAME_MAX+2 ; Unmangled kernel name
-InitRDCName resb FILENAME_MAX+2 ; Unmangled initrd name
-%else
+ global KernelName, KernelCName
KernelName resb FILENAME_MAX ; Mangled name for kernel
KernelCName resb FILENAME_MAX ; Unmangled kernel name
InitRDCName resb FILENAME_MAX ; Unmangled initrd name
-%endif
MNameBuf resb FILENAME_MAX
InitRD resb FILENAME_MAX
mov [VKernelBuf+vk_type],al
call pc_getline
mov di,VKernelBuf+vk_rname
- pm_call mangle_name
+ pm_call pm_mangle_name
.err: ret
;
pc_filecmd: push ax ; Function to tailcall
call pc_getline
mov di,MNameBuf
- pm_call mangle_name
+ pm_call pm_mangle_name
pm_call pm_searchdir
jnz .ok
pop ax ; Drop the successor function
pc_opencmd: push ax ; Function to tailcall
call pc_getline
mov di,MNameBuf
- pm_call mangle_name
+ pm_call pm_mangle_name
call core_open
jnz .ok
pop ax ; Drop the successor function
pc_filename: push ax
call pc_getline
pop di
- pm_call mangle_name ; Mangle file name
+ pm_call pm_mangle_name ; Mangle file name
ret
;
mov byte [VKernel],1 ; We've seen a "label" statement
mov si,VKernelBuf+vk_vname ; By default, rname == mangled vname
mov di,VKernelBuf+vk_rname
- pm_call mangle_name
+ pm_call pm_mangle_name
mov si,AppendBuf ; Default append==global append
mov di,VKernelBuf+vk_append
mov cx,[AppendLen]
mov cx,7 ; "initrd="
rep movsb
mov si,InitRD
- pm_call unmangle_name
+ pm_call pm_unmangle_name
mov al,' '
stosb
mov cx,boot_image_len
rep movsb
mov si,KernelCName ; Unmangled kernel name
- mov cx,[KernelCNameLen]
- rep movsb
- mov al,' ' ; Space
- stosb
+ call strcpy
+ mov byte [es:di-1],' ' ; Follow by space
call do_ip_append ; Handle IPAppend
push di
mov di,InitRD ; Target buffer for mangled name
- pm_call mangle_name
+ pm_call pm_mangle_name
pop di
call loadinitrd
push edi
mov si,InitRD
mov di,InitRDCName
- pm_call unmangle_name ; Create human-readable name
+ pm_call pm_unmangle_name ; Create human-readable name
sub di,InitRDCName
mov [InitRDCNameLen],di
mov di,InitRD
mov si,command_line
mov di,KernelName
push si
- pm_call mangle_name
+ pm_call pm_mangle_name
pop si
;
; Fast-forward to first option (we start over from the beginning, since
-; mangle_name doesn't necessarily return a consistent ending state.)
+; pm_mangle_name doesn't necessarily return a consistent ending state.)
;
clin_non_wsp: lodsb
cmp al,' '
mov si,VKernelBuf+vk_append
mov cx,[VKernelBuf+vk_appendlen]
rep movsb
+ mov byte [es:di],cl ; Null-terminate
mov [CmdLinePtr],di ; Where to add rest of cmd
pop es
mov di,KernelName
mov di,cmd_line_here
mov cx,[AppendLen]
rep movsb
+ mov byte [es:di],cl ; Null-terminate
mov [CmdLinePtr],di
pop di
pop si
mov si,KernelName
mov di,KernelCName
push di
- pm_call unmangle_name ; Get human form
+ pm_call pm_unmangle_name ; Get human form
mov si,err_notfound ; Complain about missing kernel
call writestr
pop si ; KernelCName
mov si,KernelName
mov di,KernelCName
- pm_call unmangle_name
- sub di,KernelCName
- mov [KernelCNameLen],di
+ pm_call pm_unmangle_name
; Default memory limit, can be overridden by image loaders
mov eax,[HighMemRsvd]
is_config_file:
push si
- mov si,KernelCName ; Save the config file name, for posterity
- mov di,ConfigName
- pm_call pm_realpath
+ call make_plain_cmdline
+ pm_call pm_is_config_file
pop si
call openfd
call reset_config