Hi, Eric. Thanks for the suggestion. That made it cleaner. Here's the new patch. On Mon, 2002-03-25 at 15:53, Eric Sandeen wrote: > hi Derek - > > Rather than parsing /etc/mtab, it would probably be better to look for > "XFSB" in the first 4 bytes of the target partition - that way you > _know_ the target has (or has had....) an xfs filesystem on it. > > -Eric > > -- > Eric Sandeen XFS for Linux http://oss.sgi.com/projects/xfs > sandeen@sgi.com SGI, Inc. -- ** Derek J Witt ** * Email: mailto:djw@flinthills.com * * Home Page: http://www.flinthills.com/~djw/ * *** "...and on the eighth day, God met Bill Gates." - Unknown **
--- lilo.c Sun Dec 30 16:10:26 2001
+++ ../lilo-xfs.c Mon Mar 25 16:43:40 2002
@@ -755,16 +755,40 @@
fprintf(errstd,"%7s%s -A /dev/XXX [ N ]\t\tactivate a partition\n","",name);
fprintf(errstd,"%7s%s -M /dev/XXX [ mbr_file ]\tinstall master boot record\n","",name);
fprintf(errstd,"%7s%s -T help \t\t\tlist additional options\n", "", name);
+ fprintf(errstd,"%7s%s -F \t\t\t\tforce install on XFS partition\n\t\t\t\t\tWARNING: This will corrupt\n\t\t\t\t\tthe superblock on XFS partitions.\n\n", "", name);
fprintf(errstd,"%7s%s -V [ -v ]\t\t\tversion information\n\n","",name);
exit(1);
}
+int is_xfs(char* device)
+{
+ FILE* mounts;
+ unsigned char xfs_sig[] = {'X','F','S','B'};
+ int got_xfs = 1, i;
+
+ if ((mounts = fopen(device, "rb")) == NULL)
+ { /* Just some insurance. If this does not exists, there's something
+ seriously wrong here. How are you even in Linux in the first place?
+ */
+ die("ERROR: I cannot find %s! Nothing done.\n",device);
+ }
+
+ for (i = 0; (i < 4) && (got_xfs == 1); i++)
+ if (xfs_sig[i] == fgetc(mounts)) got_xfs = 1; else got_xfs = 0;
+
+ fclose(mounts);
+
+ return got_xfs;
+}
+
int main(int argc,char **argv)
{
char *name,*reboot_arg,*identify,*ident_opt,*new_root;
char *tell_param, *uninst_dev, *param, *act1, *act2, ch;
int query,more,version,uninstall,validate,activate,instmbr,geom;
+ int force_xfs;
+ char *boot_device = NULL;
struct stat st;
int fd;
long raid_offset;
@@ -775,6 +799,7 @@
reboot_arg = identify = ident_opt = new_root = uninst_dev = NULL;
lowest = do_md_install = zflag =
query = version = uninstall = validate = activate = instmbr = 0;
+ force_xfs = 0;
verbose = -1;
name = *argv;
argc--;
@@ -806,6 +831,8 @@
break;
case 'b':
cfg_set(cf_options,"boot",param,NULL);
+ boot_device = (char*)malloc((sizeof (char)) * 255);
+ strcpy(boot_device,param);
break;
case 'c':
cfg_set(cf_options,"compact",NULL,NULL);
@@ -823,6 +850,11 @@
case 'f':
cfg_set(cf_options,"disktab",param,NULL);
break;
+ case 'F':
+ if (!nowarn)
+ fprintf(errstd,"WARNING: Forcing install on XFS partitions...\nBe prepared to run xfs_repair\non any XFS root partitions\nthat LILO selects as boot.\n");
+ force_xfs = 1;
+ break;
case 'g':
geometric |= 1;
break;
@@ -1104,6 +1136,13 @@
if (verbose >=2 && do_md_install)
printf("raid flags: at bsect_open 0x%02X\n", raid_flags);
+ if (boot_device == NULL)
+ {
+ boot_device = (char*)malloc((sizeof (char)) * 255);
+ strcpy(boot_device,cfg_get_strg(cf_options,"boot"));
+ }
+ if ((is_xfs(boot_device) == 1) && (force_xfs == 0)) die("root (%s) is XFS. Aborted.",boot_device);
+
bsect_open(cfg_get_strg(cf_options,"boot"),cfg_get_strg(cf_options,"map") ?
cfg_get_strg(cf_options,"map") : MAP_FILE,cfg_get_strg(cf_options,
"install"),cfg_get_strg(cf_options,"delay") ? to_number(cfg_get_strg(
Attachment:
signature.asc
Description: This is a digitally signed message part