X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=src%2Fdevice.c;h=3abb836d75bd52d1e66cb467a8931b3c66916086;hb=HEAD;hp=fb7a9f77d50c413501d4eb0eb85cd50d6a12a745;hpb=23c77cc092dbbb1e12c47c2b0021d4476b543702;p=rrq%2Fmaintain_lilo.git diff --git a/src/device.c b/src/device.c index fb7a9f7..3abb836 100644 --- a/src/device.c +++ b/src/device.c @@ -1,13 +1,13 @@ -/* device.c - Device access */ -/* -Copyright 1992-1997 Werner Almesberger. -Copyright 1999-2006 John Coffman. -All rights reserved. - -Licensed under the terms contained in the file 'COPYING' in the -source directory. - -*/ +/* device.c - Device access + * + * Copyright 1992-1997 Werner Almesberger + * Copyright 1999-2006 John Coffman + * Copyright 2009-2015 Joachim Wiedorn + * All rights reserved. + * + * Licensed under the terms contained in the file 'COPYING' + * in the source directory. + */ #define _GNU_SOURCE #include @@ -197,6 +197,7 @@ int dev_open(DEVICE *dev,int number,int flags) char name[PATH_MAX]; ST_BUF st; int count; + int err; if (lookup_dev(name,dev,number)) dev->delete = 0; else { @@ -235,11 +236,12 @@ int dev_open(DEVICE *dev,int number,int flags) #endif if (flags == O_BYPASS) dev->fd = -1; else if ((dev->fd = open(name,flags)) < 0) { - fprintf (errstd, "Cannot proceed. Maybe you need to add " + err = errno; + fprintf (errstd, "Cannot proceed. Maybe you need to add " "this to your lilo.conf:\n" "\tdisk=%s inaccessible\n" "(real error shown below)\n", name); - die("open %s: %s",name,strerror(errno)); + die("open %s: %s",name,strerror(err)); } dev->name = stralloc(name); return dev->fd; @@ -345,7 +347,6 @@ void preload_dev_cache(void) cache_add(DEV_DIR "/fd1", 0x0201); } -#if 1 cache_ide(DEV_DISK_DIR "/hdt", MAJOR_IDE10); cache_ide(DEV_DISK_DIR "/hds", MAJOR_IDE10); cache_ide(DEV_DISK_DIR "/hdr", MAJOR_IDE9); @@ -358,11 +359,9 @@ void preload_dev_cache(void) cache_ide(DEV_DISK_DIR "/hdl", MAJOR_IDE6); cache_ide(DEV_DISK_DIR "/hdk", MAJOR_IDE6); -#ifdef MAJOR_IDE5 + cache_ide(DEV_DISK_DIR "/hdj", MAJOR_IDE5); cache_ide(DEV_DISK_DIR "/hdi", MAJOR_IDE5); -#endif -#endif for (i = MAX; i >= 0; i--) { sprintf(tmp, is_devfs() ? DEV_DISK_DIR "/md/%d" : DEV_DISK_DIR "/md%d", i); @@ -383,8 +382,8 @@ void preload_dev_cache(void) cache_ide(DEV_DISK_DIR "/hdd", MAJOR_IDE2); cache_ide(DEV_DISK_DIR "/hdc", MAJOR_IDE2); - cache_ide(DEV_DISK_DIR "/hdb", MAJOR_HD); - cache_ide(DEV_DISK_DIR "/hda", MAJOR_HD); + cache_ide(DEV_DISK_DIR "/hdb", MAJOR_IDE); + cache_ide(DEV_DISK_DIR "/hda", MAJOR_IDE); verbose = vsave; } @@ -639,7 +638,7 @@ unsigned int register_bios(int bios, int device) *(int*)&buff.sector[PART_TABLE_OFFSET-6] = serial; if (*(short*)&buff.sector[PART_TABLE_OFFSET - 2] == 0) - *(short*)&buff.sector[PART_TABLE_OFFSET - 2] = MAGIC_SERIAL; + *(unsigned short*)&buff.sector[PART_TABLE_OFFSET - 2] = MAGIC_SERIAL; if (verbose) printf("Assigning new Volume ID to (%04X) '%s' ID = %08X\n", device, dev.name, (int)serial); @@ -655,7 +654,7 @@ unsigned int register_bios(int bios, int device) if (device_code[i]==device) die("register_bios: device code duplicated: %04X", device); if (serial_no[i]==serial) - die("register_bios: volume ID serial no. duplicated: %08lX", serial); + die("register_bios: volume ID serial no. duplicated: %08X", serial); } device_code[bios] = device; serial_no[bios] = serial; @@ -714,11 +713,11 @@ static int volid_get_set(int device, int vol_in, int option) fd = dev_open(&dev, device, option ? O_RDWR : O_RDONLY); if (read(fd, &buf, sizeof(buf)) != sizeof(buf)) { - fprintf (errstd, "Cannot proceed. Maybe you need to add " + fprintf (errstd, "Cannot proceed. Maybe you need to add " "this to your lilo.conf:\n" "\tdisk=%s inaccessible\n" "(real error shown below)\n", dev.name); - die("VolumeID read error: sector 0 of %s not readable", dev.name); + die("VolumeID read error: sector 0 of %s not readable", dev.name); } if (option==ID_SET) { make_backup(NULL, 0, &buf, device, @@ -887,7 +886,7 @@ static int warned = 0, called = 0; struct stat st; int duplicate = 0, invalid = 0, ret = 0, ntcaution = 0; int raidcaution = 0; - long codes = 0L; + int32_t codes = 0L; /* called from raid_setup & from geo_open */ /* allow only 1 call */ @@ -1168,7 +1167,7 @@ static int warned = 0, called = 0; walk->next = disktab; vm[j].dt = disktab = walk; #if BETA_TEST - if (verbose >= 4) printf("Allocated DT entry for device %04X ptr=%08lx\n", vm[j].device, (long)walk); + if (verbose >= 4) printf("Allocated DT entry for device %04X ptr=%0*" PRIxPTR "\n", vm[j].device, , PTR_WIDTH, (intptr_t)walk); #endif } @@ -1282,7 +1281,7 @@ static int warned = 0, called = 0; - if (verbose>=2) printf("device codes (user assigned pf) = %lX\n", codes); + if (verbose>=2) printf("device codes (user assigned pf) = %" PRIX32 "\n", codes); /* mark those BIOS codes that are already used in the disk=/bios= table */ @@ -1312,7 +1311,7 @@ static int warned = 0, called = 0; } } - if (verbose>=2) printf("device codes (user assigned) = %lX\n", codes); + if (verbose>=2) printf("device codes (user assigned) = %" PRIX32 "\n", codes); for (i=0; i=2) printf("device codes (BIOS assigned) = %lX\n", codes); + if (verbose>=2) printf("device codes (BIOS assigned) = %" PRIX32 "\n", codes); for (bios=i=0; inext = disktab; vm[i].dt = disktab = walk; #if BETA_TEST - if (verbose >= 4) printf("Allocated DT entry for device %04X ptr=%08lx\n", vm[i].device, (long)walk); + if (verbose >= 4) printf("Allocated DT entry for device %04X ptr=%0*" PRIxPTR "\n", vm[i].device, PTR_WIDTH, (intptr_t)walk); #endif } j = vm[i].dt->bios = vm[i].bios.actual; @@ -1377,7 +1376,7 @@ static int warned = 0, called = 0; inited = 1; } - if (verbose>=2) printf("device codes (canonical) = %lX\n", codes); + if (verbose>=2) printf("device codes (canonical) = %" PRIX32 "\n", codes); for (bios=8*sizeof(codes)-1; !(codes&(1L<=0; ) bios--;