2003-12-03 Marco Gerards <metgerards@student.han.nl>

* fs/ext2.c (pupa_ext2_label): New function.
	(pupa_ext2_fs): Added label.
	* fs/fat.c (pupa_fat_label): New function.
	(pupa_fat_fs): Added label.
	* include/pupa/fs.h (struct pupa_fs): Added prototype label.

	* kern/misc.c (pupa_strndup): New function.
	* include/pupa/misc.h (pupa_strndup): New prototype.

	* include/pupa/normal.h: Include <pupa/err.h>.
	(pupa_set_history): New prototype.
	(pupa_iterate_commands): New prototype.
	* normal/cmdline.c: Include <pupa/machine/partition.h>,
	<pupa/disk.h>, <pupa/file.h>.
	(hist_size): New variable.
	(hist_lines): Likewise.
	(hist_end): Likewise.
	(hist_used): Likewise.
	(pupa_set_history): New function.
	(pupa_history_get): Likewise.
	(pupa_history_add): Likewise.
	(pupa_history_replace): Likewise.
	(pupa_tab_complete): Likewise.
	(pupa_cmdline_run): Added tab completion and history buffer.  Tab
	completion shows partitionnames while completing partitions, this
	feature was suggested by Jeff Bailey.
	* normal/command.c (pupa_iterate_commands): New function.
	* normal/main.c (PUPA_DEFAULT_HISTORY_SIZE): New macro.
	(pupa_normal_init): Initialize history buffer.
	(PUPA_MOD_INIT): Likewise.
	(pupa_normal_fini): Free the history buffer.
	(PUPA_MOD_FINI): Likewise.

	* util/console.c (pupa_ncurses_getkey): Accept 127 as backspace
	key.

	* aclocal.m4 (pupa_I386_CHECK_REGPARM_BUG): New DEFUN.
	* configure.ac [i386]: Check for regparam bug.
	(NESTED_FUNC_ATTR) [! i386]: Defined.
This commit is contained in:
marco_g 2003-12-03 19:17:27 +00:00
parent 1f7315a3de
commit 5aded270b6
15 changed files with 793 additions and 6 deletions

View file

@ -3,6 +3,7 @@
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2000,2001 Free Software Foundation, Inc.
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
* Copyright (C) 2003 Marco Gerards <metgerards@student.han.nl>.
*
* 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
@ -771,6 +772,70 @@ pupa_fat_close (pupa_file_t file)
return pupa_errno;
}
static pupa_err_t
pupa_fat_label (pupa_device_t device, char **label)
{
struct pupa_fat_data *data;
pupa_disk_t disk = device->disk;
pupa_ssize_t offset = -sizeof(struct pupa_fat_dir_entry);
#ifndef PUPA_UTIL
pupa_dl_ref (my_mod);
#endif
data = pupa_fat_mount (disk);
if (! data)
goto fail;
if (! (data->attr & PUPA_FAT_ATTR_DIRECTORY))
{
pupa_error (PUPA_ERR_BAD_FILE_TYPE, "not a directory");
return 0;
}
while (1)
{
struct pupa_fat_dir_entry dir;
/* Adjust the offset. */
offset += sizeof (dir);
/* Read a directory entry. */
if ((pupa_fat_read_data (disk, data, 0,
offset, sizeof (dir), (char *) &dir)
!= sizeof (dir))
|| dir.name[0] == 0)
{
if (pupa_errno != PUPA_ERR_NONE)
goto fail;
else
{
*label = 0;
return PUPA_ERR_NONE;
}
}
if (dir.attr == PUPA_FAT_ATTR_VOLUME_ID)
{
*label = pupa_strndup (dir.name, 11);
return PUPA_ERR_NONE;
}
}
*label = 0;
fail:
#ifndef PUPA_UTIL
pupa_dl_unref (my_mod);
#endif
pupa_free (data);
return pupa_errno;
}
static struct pupa_fs pupa_fat_fs =
{
.name = "fat",
@ -778,6 +843,7 @@ static struct pupa_fs pupa_fat_fs =
.open = pupa_fat_open,
.read = pupa_fat_read,
.close = pupa_fat_close,
.label = pupa_fat_label,
.next = 0
};