From 688e5699e6d9af879358cd34caf8a166c3a81ac9 Mon Sep 17 00:00:00 2001 From: okuji Date: Sat, 15 Oct 2005 09:22:32 +0000 Subject: [PATCH] 2005-10-15 Yoshinori K. Okuji * fs/xfs.c (grub_xfs_iterate_dir): Change the type of BLK to grub_uint64_t. Call the hook with a NUL-terminated filename. (grub_xfs_mount): Use grub_be_to_cpu32 instead of grub_cpu_to_be32. * kern/term.c (cursor_state): New variable. (grub_term_set_current): Reset the cursor state on a new terminal. (grub_setcursor): Rewritten to use CURSOR_STATE. (grub_getcursor): New function. * include/grub/term.h (grub_getcursor): New prototype. * io/gzio.c (test_header): Align BUF for accessing it as 32-bit integers on ARM. Reported by Timothy Baldwin . --- ChangeLog | 20 ++++++++++++++++++++ fs/xfs.c | 28 +++++++++++++++++----------- include/grub/term.h | 1 + io/gzio.c | 2 +- kern/term.c | 15 ++++++++++++--- 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index d53f92215..f07e8da7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2005-10-15 Yoshinori K. Okuji + + * fs/xfs.c (grub_xfs_iterate_dir): Change the type of BLK to + grub_uint64_t. + Call the hook with a NUL-terminated filename. + (grub_xfs_mount): Use grub_be_to_cpu32 instead of + grub_cpu_to_be32. + + * kern/term.c (cursor_state): New variable. + (grub_term_set_current): Reset the cursor state on a new + terminal. + (grub_setcursor): Rewritten to use CURSOR_STATE. + (grub_getcursor): New function. + + * include/grub/term.h (grub_getcursor): New prototype. + + * io/gzio.c (test_header): Align BUF for accessing it as 32-bit + integers on ARM. Reported by Timothy Baldwin + . + 2005-10-11 Marco Gerards * fs/sfs.c (grub_sfs_open): Don't free `data->label' if it is not diff --git a/fs/xfs.c b/fs/xfs.c index d5726f493..44b1cec07 100644 --- a/fs/xfs.c +++ b/fs/xfs.c @@ -156,8 +156,9 @@ static grub_dl_t my_mod; #define GRUB_XFS_NEXT_DIRENT(pos,len) \ (pos) + GRUB_XFS_ROUND_TO_DIRENT (8 + 1 + len + 2) -static inline int grub_xfs_inode_block (struct grub_xfs_data *data, - grub_uint64_t ino) +static inline int +grub_xfs_inode_block (struct grub_xfs_data *data, + grub_uint64_t ino) { long long int inoinag = GRUB_XFS_INO_INOINAG (data, ino); long long ag = GRUB_XFS_INO_AG (data, ino); @@ -169,8 +170,9 @@ static inline int grub_xfs_inode_block (struct grub_xfs_data *data, } -static inline int grub_xfs_inode_offset (struct grub_xfs_data *data, - grub_uint64_t ino) +static inline int +grub_xfs_inode_offset (struct grub_xfs_data *data, + grub_uint64_t ino) { int inoag = GRUB_XFS_INO_INOINAG (data, ino); return (inoag & ((1 << 4) - 1)) << 8; @@ -361,8 +363,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, { grub_uint64_t ino; void *inopos = (((char *) de) - + sizeof (struct grub_xfs_dir_entry) + de->len - 1); - + + sizeof (struct grub_xfs_dir_entry) + + de->len - 1); + char name[de->len + 1]; + if (smallino) { ino = grub_be_to_cpu32 (*(grub_uint32_t *) inopos); @@ -371,7 +375,9 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, else ino = *(grub_uint64_t *) inopos; - if (call_hook (ino, de->name)) + grub_memcpy (name, de->name, de->len); + name[de->len] = '\0'; + if (call_hook (ino, name)) return 1; de = ((struct grub_xfs_dir_entry *) @@ -387,10 +393,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, { grub_ssize_t numread; char *dirblock; - unsigned int blk; + grub_uint64_t blk; dirblock = grub_malloc (dir->data->bsize); - if (!dirblock) + if (! dirblock) return 0; /* Iterate over every block the directory has. */ @@ -495,8 +501,8 @@ grub_xfs_mount (grub_disk_t disk) data->diropen.data = data; data->diropen.ino = data->sblock.rootino; data->diropen.inode_read = 1; - data->bsize = grub_cpu_to_be32 (data->sblock.bsize); - data->agsize = grub_cpu_to_be32 (data->sblock.agsize); + data->bsize = grub_be_to_cpu32 (data->sblock.bsize); + data->agsize = grub_be_to_cpu32 (data->sblock.agsize); data->disk = disk; data->inode = &data->diropen.inode; diff --git a/include/grub/term.h b/include/grub/term.h index a27ab4011..c104b1c51 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -199,6 +199,7 @@ void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state); void EXPORT_FUNC(grub_setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color); int EXPORT_FUNC(grub_setcursor) (int on); +int EXPORT_FUNC(grub_getcursor) (void); void EXPORT_FUNC(grub_refresh) (void); void EXPORT_FUNC(grub_set_more) (int onoff); diff --git a/io/gzio.c b/io/gzio.c index 28aa5210b..f02fc1cb6 100644 --- a/io/gzio.c +++ b/io/gzio.c @@ -165,7 +165,7 @@ typedef unsigned long ulg; static int test_header (grub_file_t file) { - unsigned char buf[10]; + unsigned char buf[10] __attribute__ ((aligned)); grub_gzio_t gzio = file->data; if (grub_file_tell (gzio->file) != 0) diff --git a/kern/term.c b/kern/term.c index f5e397653..cc4dd98d4 100644 --- a/kern/term.c +++ b/kern/term.c @@ -34,6 +34,9 @@ static int grub_more_lines; /* If the more pager is active. */ static int grub_more; +/* The current cursor state. */ +static int cursor_state = 1; + void grub_term_register (grub_term_t term) { @@ -77,6 +80,7 @@ grub_term_set_current (grub_term_t term) grub_cur_term = term; grub_cls (); + grub_setcursor (grub_getcursor ()); return GRUB_ERR_NONE; } @@ -229,18 +233,23 @@ grub_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color) int grub_setcursor (int on) { - static int prev = 1; - int ret = prev; + int ret = cursor_state; if (grub_cur_term->setcursor) { (grub_cur_term->setcursor) (on); - prev = on; + cursor_state = on; } return ret; } +int +grub_getcursor (void) +{ + return cursor_state; +} + void grub_refresh (void) {