[Fwd: [PATCH] Some pxe fixes.]
Hi, I was toying with pxe and noticed some errors in the code small errors in the code. In the file read method it is possible to return error codes instead of amount read. This patch fix that by setting the error and returning -1 instead. It also fix some coding style by removing tabs and use UNUSED macro. Michel Index: ChangeLog === --- ChangeLog (révision 2154) +++ ChangeLog (copie de travail) @@ -1,3 +1,9 @@ +2009-05-01 Michel Hermier + + * fs/i386/pc/pxe.c (grub_pxefs_read): Fix returned values. + Returning error codes as grub_size_t is a bad idea. Fixing + indent style and use UNUSED macro while at it. + 2009-04-30 David S. Miller * util/hostdisk.c (device_is_wholedisk): New function. Index: fs/i386/pc/pxe.c === --- fs/i386/pc/pxe.c(révision 2154) +++ fs/i386/pc/pxe.c(copie de travail) @@ -72,24 +72,24 @@ } static void -grub_pxe_close (grub_disk_t disk __attribute((unused))) +grub_pxe_close (grub_disk_t disk UNUSED) { } static grub_err_t -grub_pxe_read (grub_disk_t disk __attribute((unused)), - grub_disk_addr_t sector __attribute((unused)), - grub_size_t size __attribute((unused)), - char *buf __attribute((unused))) +grub_pxe_read (grub_disk_t disk UNUSED, + grub_disk_addr_t sector UNUSED, + grub_size_t size UNUSED, + char *buf UNUSED) { return GRUB_ERR_OUT_OF_RANGE; } static grub_err_t -grub_pxe_write (grub_disk_t disk __attribute((unused)), -grub_disk_addr_t sector __attribute((unused)), -grub_size_t size __attribute((unused)), -const char *buf __attribute((unused))) +grub_pxe_write (grub_disk_t disk UNUSED, +grub_disk_addr_t sector UNUSED, +grub_size_t size UNUSED, +const char *buf UNUSED) { return GRUB_ERR_OUT_OF_RANGE; } @@ -108,8 +108,8 @@ static grub_err_t grub_pxefs_dir (grub_device_t device UNUSED, const char *path UNUSED, - int (*hook) (const char *filename, -const struct grub_dirhook_info *info) UNUSED) +int (*hook) (const char *filename, + const struct grub_dirhook_info *info) UNUSED) { return GRUB_ERR_NONE; } @@ -189,8 +189,11 @@ pn = grub_divmod64 (file->offset, data->block_size, &r); if (r) -return grub_error (GRUB_ERR_BAD_FS, - "read access must be aligned to packet size"); +{ + grub_error (GRUB_ERR_BAD_FS, + "read access must be aligned to packet size"); + return -1; +} if ((curr_file != file) || (data->packet_number > pn)) { @@ -206,7 +209,10 @@ o.packet_size = data->block_size; grub_pxe_call (GRUB_PXENV_TFTP_OPEN, &o); if (o.status) -return grub_error (GRUB_ERR_BAD_FS, "open fails"); +{ + grub_error (GRUB_ERR_BAD_FS, "open fails"); + return -1; +} data->packet_number = 0; curr_file = file; } @@ -246,8 +252,8 @@ } static grub_err_t -grub_pxefs_label (grub_device_t device __attribute ((unused)), - char **label __attribute ((unused))) +grub_pxefs_label (grub_device_t device UNUSED, + char **label UNUSED) { *label = 0; return GRUB_ERR_NONE; ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: LVM & RAID10
FYI: I just tested latest revision (2154) and there is no error message about "multiple metadata areas". I suppose it was fixed (probably "by accident" ;) ) in on of latest patches ("Partitions can start at zero" ? just wild guess). Anyway I only tested grub-probe on my current system (with 2 disks attached in LVM @ RAID5 configuration), tomorrow I'll try to move my system to this array and see what happens (well, due to all that changes lately I don't even know if this revision can boot anything). ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] prevent duplicated entries due to symlinks
If there's both a symlink and a kernel at which the symlink is pointing in the list of detected kernels of 10_linux, two entries are created for actually the same kernel. This patch checks for this condition and only uses the symlink (usually the wanted behaviour), in case the target of the symlink doesn't exist, it uses neither. Furthermore there may be kernel images named e.g. /boot/vmlinuz, so to detect those the patch doesn't require a hyphen in the kernel name. In this case the sed used to determine the kernel version, won't return as expected an empty string. Therefore I replaced it by another one with the wanted behaviour. If the kernel version can be empty we don't want to have a "GNU/Linux, linux " menuentry. Accordingly this patch adds a check for empty kernel version, so that only "GNU/Linux" will be displayed. Finally there's quite a bunch of other names for initrds. This patch adds support for initrd.gz and initrd.splash. Both initrd.img and initrd.gz become or were yet supported with two different version positions and without version at all. For initrd.splash this isn't needed because it's not kernel version dependent. This is my first contribution and although I tried to inform myself as good as possible and double-checked everything, I could have missed something to you probably obvious. If there are any such problems, let me know, I'll do my best to get it sorted out. Andreas diff --git a/ChangeLog b/ChangeLog index 9097f25..ddf1c3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-05-01 Andreas Born + +* util/grub.d/10_linux.in: Prevent duplicated entries because both + symlink and symlinked kernel are detected, only use the symlink + then. Detect also kernels without a hyphen in a name and use an + empty version for those kernels. Don't display linux in + the menuentry title if version is empty. Detect more initrds e.g. + initrd.gz. + 2009-04-30 David S. Miller * util/hostdisk.c (device_is_wholedisk): New function. diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index c2da413..66768eb 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -112,9 +112,18 @@ EOF EOF } -list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do +list=`for i in /boot/vmlinu[xz]* /vmlinu[xz]* ; do if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi done` +for i in $list ; do + if test -h $i ; then +target="`readlink -f $i`" +list=`echo $list | tr ' ' '\n' | grep -vx $target | tr '\n' ' '` +if test ! -f $target ; then + list=`echo $list | tr ' ' '\n' | grep -vx $i | tr '\n' ' '` +fi + fi +done while [ "x$list" != "x" ] ; do linux=`find_latest $list` @@ -122,13 +131,16 @@ while [ "x$list" != "x" ] ; do basename=`basename $linux` dirname=`dirname $linux` rel_dirname=`make_system_path_relative_to_its_root $dirname` - version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` + version=`echo $basename | sed -e "s,^[^\-]*-*,,"` alt_version=`echo $version | sed -e "s,\.old$,,g"` linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" initrd= for i in "initrd.img-${version}" "initrd-${version}.img" \ - "initrd.img-${alt_version}" "initrd-${alt_version}.img"; do + "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ + "initrd.gz-${version}" "initrd-${version}.gz" \ + "initrd.gz-${alt_version}" "initrd-${alt_version}.gz" \ + "initrd.img" "initrd.gz" "initrd.splash"; do if test -e "${dirname}/${i}" ; then initrd="$i" break @@ -140,10 +152,16 @@ while [ "x$list" != "x" ] ; do # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here. linux_root_device_thisversion=${GRUB_DEVICE} fi + + if test -n "${version}" ; then +title="${OS}, linux ${version}" + else +title="${OS}" + fi - linux_entry "${OS}, linux ${version}" \ + linux_entry "${title}" \ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - linux_entry "${OS}, linux ${version} (recovery mode)" \ + linux_entry "${title} (recovery mode)" \ "single ${GRUB_CMDLINE_LINUX}" list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '` ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Split #2: parser/reader separation
Patch looks fine for me. I think you can commit it As for lua put the origin clearly and put the original copyright notice below grub's one. Tomorrow I'll do the same for freebsd64 patch and will merge it > Oh, I think it is quite compact already, have you got any suggestion >> to reduce its size ? >> > The only possibility I've seen is to move grub_parser_execute out of kernel. However I don't think it's practicable. > > >> > Also it would be good to write the current parser in "grub>" prompt (not >> > necessary for rescue prompt) >> >> Good point. >> >> -- >> Bean >> >> >> ___ >> Grub-devel mailing list >> Grub-devel@gnu.org >> http://lists.gnu.org/mailman/listinfo/grub-devel >> > > > > -- > Regards > Vladimir 'phcoder' Serbinenko > -- Regards Vladimir 'phcoder' Serbinenko ___ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel