From 502a79c799c437c6ee3d58ad0c6223c233cb7f23 Mon Sep 17 00:00:00 2001 From: okuji Date: Wed, 28 Nov 2001 18:43:56 +0000 Subject: [PATCH] hide and unhide support logical partitions. --- AUTHORS | 3 ++- ChangeLog | 6 +++++ Makefile.in | 5 ++-- NEWS | 1 + docs/grub-install.8 | 2 +- docs/grub-md5-crypt.8 | 2 +- docs/grub.8 | 2 +- docs/mbchk.1 | 2 +- docs/stamp-vti | 4 +-- docs/version.texi | 4 +-- stage2/disk_io.c | 59 ++++++++++++++++++++++++++++--------------- 11 files changed, 59 insertions(+), 31 deletions(-) diff --git a/AUTHORS b/AUTHORS index 8719c2f70..c16e381ec 100644 --- a/AUTHORS +++ b/AUTHORS @@ -40,4 +40,5 @@ Kristoffer Branemyr added VSTa filesystem support. Serguei Tzukanov added JFS and XFS support. -Jason Thomas added Linux DAC960 support. +Jason Thomas added Linux DAC960 support and support for hiding/unhiding +logical partitions. diff --git a/ChangeLog b/ChangeLog index 4b9f8b5a8..5ddd08f2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-11-29 Yoshinori K. Okuji + + From Jason Thomas: + * stage2/disk_io.c (set_partition_hidden_flag): Complete rewrite + of this function which now supports logical partitions. + 2001-11-12 Yoshinori K. Okuji * docs/grub.texi: The copyright of this file is only held by diff --git a/Makefile.in b/Makefile.in index 20de465f0..ffecbb43e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -103,8 +103,9 @@ RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ uninstall-recursive check-recursive installcheck-recursive DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ Makefile.am Makefile.in NEWS THANKS TODO acconfig.h \ - acinclude.m4 aclocal.m4 config.guess config.h.in config.sub \ - configure configure.in depcomp install-sh missing mkinstalldirs + acinclude.m4 aclocal.m4 compile config.guess config.h.in \ + config.sub configure configure.in depcomp install-sh missing \ + mkinstalldirs DIST_SUBDIRS = $(SUBDIRS) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive diff --git a/NEWS b/NEWS index 8e7c16766..c66678190 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ NEWS - list of user-visible changes between releases of GRUB New in 0.91: * Support for Linux DAC960 is added. * JFS and XFS support is added. +* The commands "hide" and "unhide" support logical partitions. * Important bugfixes are made for ReiserFS, APM, TFTP, etc. New in 0.90 - 2001-07-11: diff --git a/docs/grub-install.8 b/docs/grub-install.8 index 947ae3785..30051e632 100644 --- a/docs/grub-install.8 +++ b/docs/grub-install.8 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. -.TH GRUB-INSTALL "8" "October 2001" "grub-install (GNU GRUB 0.90)" FSF +.TH GRUB-INSTALL "8" "November 2001" "grub-install (GNU GRUB 0.90)" FSF .SH NAME grub-install \- install GRUB on your drive .SH SYNOPSIS diff --git a/docs/grub-md5-crypt.8 b/docs/grub-md5-crypt.8 index 22ba0bfcd..1995f7f5e 100644 --- a/docs/grub-md5-crypt.8 +++ b/docs/grub-md5-crypt.8 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. -.TH GRUB-MD5-CRYPT "8" "October 2001" "grub-md5-crypt (GNU GRUB )" FSF +.TH GRUB-MD5-CRYPT "8" "November 2001" "grub-md5-crypt (GNU GRUB )" FSF .SH NAME grub-md5-crypt \- Encrypt a password in MD5 format .SH SYNOPSIS diff --git a/docs/grub.8 b/docs/grub.8 index 7b967246a..cd5fb7cd3 100644 --- a/docs/grub.8 +++ b/docs/grub.8 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. -.TH GRUB "8" "October 2001" "grub (GNU GRUB 0.90)" FSF +.TH GRUB "8" "November 2001" "grub (GNU GRUB 0.90)" FSF .SH NAME grub \- the grub shell .SH SYNOPSIS diff --git a/docs/mbchk.1 b/docs/mbchk.1 index 89afb67c2..a611a29cd 100644 --- a/docs/mbchk.1 +++ b/docs/mbchk.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. -.TH MBCHK "1" "October 2001" "mbchk (GNU GRUB 0.90)" FSF +.TH MBCHK "1" "November 2001" "mbchk (GNU GRUB 0.90)" FSF .SH NAME mbchk \- check the format of a Multiboot kernel .SH SYNOPSIS diff --git a/docs/stamp-vti b/docs/stamp-vti index 770dd17d0..c81ca723b 100644 --- a/docs/stamp-vti +++ b/docs/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 13 October 2001 -@set UPDATED-MONTH October 2001 +@set UPDATED 12 November 2001 +@set UPDATED-MONTH November 2001 @set EDITION 0.90 @set VERSION 0.90 diff --git a/docs/version.texi b/docs/version.texi index 770dd17d0..c81ca723b 100644 --- a/docs/version.texi +++ b/docs/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 13 October 2001 -@set UPDATED-MONTH October 2001 +@set UPDATED 12 November 2001 +@set UPDATED-MONTH November 2001 @set EDITION 0.90 @set VERSION 0.90 diff --git a/stage2/disk_io.c b/stage2/disk_io.c index 173451177..12ca31f3e 100644 --- a/stage2/disk_io.c +++ b/stage2/disk_io.c @@ -460,30 +460,49 @@ make_saved_active (void) int set_partition_hidden_flag (int hidden) { + unsigned long part = 0xFFFFFF; + unsigned long start, len, offset, ext_offset; + int entry, type; char mbr[512]; - if (current_drive & 0x80) + /* The drive must be a hard disk. */ + if (! (current_drive & 0x80)) { - int part = current_partition >> 16; - - if (part > 3) - { - errnum = ERR_NO_PART; - return 0; - } - - if (! rawread (current_drive, 0, 0, SECTOR_SIZE, mbr)) - return 0; - - if (hidden) - PC_SLICE_TYPE (mbr, part) |= PC_SLICE_TYPE_HIDDEN_FLAG; - else - PC_SLICE_TYPE (mbr, part) &= ~PC_SLICE_TYPE_HIDDEN_FLAG; - - if (! rawwrite (current_drive, 0, mbr)) - return 0; + errnum = ERR_BAD_ARGUMENT; + return 1; } - + + /* The partition must be a PC slice. */ + if ((current_partition >> 16) == 0xFF + || (current_partition & 0xFFFF) != 0xFFFF) + { + errnum = ERR_BAD_ARGUMENT; + return 1; + } + + /* Look for the partition. */ + while (next_partition (current_drive, 0xFFFFFF, &part, &type, + &start, &len, &offset, &entry, + &ext_offset, mbr)) + { + if (part == current_partition) + { + /* Found. */ + if (hidden) + PC_SLICE_TYPE (mbr, entry) |= PC_SLICE_TYPE_HIDDEN_FLAG; + else + PC_SLICE_TYPE (mbr, entry) &= ~PC_SLICE_TYPE_HIDDEN_FLAG; + + /* Write back the MBR to the disk. */ + buf_track = -1; + if (! rawwrite (current_drive, offset, mbr)) + return 1; + + /* Succeed. */ + return 0; + } + } + return 1; }