From 2acba746d510b460fffd29ec5538962fec3cebda Mon Sep 17 00:00:00 2001 From: Pierre-Alexandre Meyer Date: Wed, 5 Aug 2009 15:09:47 -0700 Subject: [PATCH] gpllib: More errno fixes * Fix header files due to previous commit * Prefix disk errnos with ED to avoid conflicts with classic errno * Fix swsusp code to use errno_disk Signed-off-by: Pierre-Alexandre Meyer --- com32/gplinclude/disk/errno_disk.h | 68 ++++++++++++++++++++------------------ com32/gplinclude/disk/msdos.h | 2 +- com32/gplinclude/disk/swsusp.h | 2 +- com32/gpllib/disk/error.c | 2 +- com32/gpllib/disk/swsusp.c | 16 ++++----- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/com32/gplinclude/disk/errno_disk.h b/com32/gplinclude/disk/errno_disk.h index 0c4dccb..055eaf5 100644 --- a/com32/gplinclude/disk/errno_disk.h +++ b/com32/gplinclude/disk/errno_disk.h @@ -10,40 +10,44 @@ #ifndef _ERRNO_DISK_H #define _ERRNO_DISK_H +/* Max length of the error string */ +#define MAX_DISK_ERRNO 9 + extern int errno_disk; -#define EINV 0x01 /* Invalid function in AH or invalid parameter */ -#define EADDR 0x02 /* Address mark not found */ -#define ERO 0x03 /* Disk write-protected */ -#define ENOFND 0x04 /* Sector not found/read error */ -#define ERFAIL 0x05 /* Reset failed (hard disk) */ -#define ECHANG 0x06 /* Disk changed (floppy) */ +/* Prefix with ED to avoid confusion with errno */ +#define EDINV 0x01 /* Invalid function in AH or invalid parameter */ +#define EDADDR 0x02 /* Address mark not found */ +#define EDRO 0x03 /* Disk write-protected */ +#define EDNOFND 0x04 /* Sector not found/read error */ +#define EDRFAIL 0x05 /* Reset failed (hard disk) */ +#define EDCHANG 0x06 /* Disk changed (floppy) */ #define EDFAIL 0x07 /* Drive parameter activity failed (hard disk) */ -#define EDMA 0x08 /* DMA overrun */ -#define EBOUND 0x09 /* Data boundary error (attempted DMA across 64K boundary or >80h sectors) */ -#define EBADS 0x0A /* Bad sector detected (hard disk) */ -#define EBADT 0x0B /* Bad track detected (hard disk) */ -#define EINVM 0x0C /* Unsupported track or invalid media */ -#define EINVS 0x0D /* Invalid number of sectors on format (PS/2 hard disk) */ -#define EADDRM 0x0E /* Control data address mark detected (hard disk) */ -#define EDMARG 0x0F /* DMA arbitration level out of range (hard disk) */ -#define ECRCF 0x10 /* Uncorrectable CRC or ECC error on read */ -#define ECRCV 0x11 /* Data ECC corrected (hard disk) */ -#define ECTRL 0x20 /* Controller failure */ -#define EMEDIA 0x31 /* No media in drive (IBM/MS INT 13 extensions) */ -#define ECMOS 0x32 /* Incorrect drive type stored in CMOS (Compaq) */ -#define ESEEKF 0x40 /* Seek failed */ -#define ETIME 0x80 /* Timeout (not ready) */ -#define EREADY 0xAA /* Drive not ready (hard disk) */ -#define ENLOCK 0xB0 /* Volume not locked in drive (INT 13 extensions) */ -#define ELOCK 0xB1 /* Volume locked in drive (INT 13 extensions) */ -#define EREMOV 0xB2 /* Volume not removable (INT 13 extensions) */ -#define EUSED 0xB3 /* Volume in use (INT 13 extensions) */ -#define ECOUNT 0xB4 /* Lock count exceeded (INT 13 extensions) */ -#define EEJF 0xB5 /* Valid eject request failed (INT 13 extensions) */ -#define EUNKOWN 0xBB /* Undefined error (hard disk) */ -#define EWF 0xCC /* Write fault (hard disk) */ -#define ERF 0xE0 /* Status register error (hard disk) */ -#define ESF 0xFF /* Sense operation failed (hard disk) */ +#define EDDMA 0x08 /* DMA overrun */ +#define EDBOUND 0x09 /* Data boundary error (attempted DMA across 64K boundary or >80h sectors) */ +#define EDBADS 0x0A /* Bad sector detected (hard disk) */ +#define EDBADT 0x0B /* Bad track detected (hard disk) */ +#define EDINVM 0x0C /* Unsupported track or invalid media */ +#define EDINVS 0x0D /* Invalid number of sectors on format (PS/2 hard disk) */ +#define EDADDRM 0x0E /* Control data address mark detected (hard disk) */ +#define EDDMARG 0x0F /* DMA arbitration level out of range (hard disk) */ +#define EDCRCF 0x10 /* Uncorrectable CRC or ECC error on read */ +#define EDCRCV 0x11 /* Data ECC corrected (hard disk) */ +#define EDCTRL 0x20 /* Controller failure */ +#define EDMEDIA 0x31 /* No media in drive (IBM/MS INT 13 extensions) */ +#define EDCMOS 0x32 /* Incorrect drive type stored in CMOS (Compaq) */ +#define EDSEEKF 0x40 /* Seek failed */ +#define EDTIME 0x80 /* Timeout (not ready) */ +#define EDREADY 0xAA /* Drive not ready (hard disk) */ +#define EDNLOCK 0xB0 /* Volume not locked in drive (INT 13 extensions) */ +#define EDLOCK 0xB1 /* Volume locked in drive (INT 13 extensions) */ +#define EDREMOV 0xB2 /* Volume not removable (INT 13 extensions) */ +#define EDUSED 0xB3 /* Volume in use (INT 13 extensions) */ +#define EDCOUNT 0xB4 /* Lock count exceeded (INT 13 extensions) */ +#define EDEJF 0xB5 /* Valid eject request failed (INT 13 extensions) */ +#define EDUNKOWN 0xBB /* Undefined error (hard disk) */ +#define EDWF 0xCC /* Write fault (hard disk) */ +#define EDRF 0xE0 /* Status register error (hard disk) */ +#define EDSF 0xFF /* Sense operation failed (hard disk) */ #endif /* _ERRNO_DISK_H */ diff --git a/com32/gplinclude/disk/msdos.h b/com32/gplinclude/disk/msdos.h index 1f565f3..c8dcb1d 100644 --- a/com32/gplinclude/disk/msdos.h +++ b/com32/gplinclude/disk/msdos.h @@ -12,6 +12,6 @@ #include -int parse_partition_table(struct driveinfo *, void *, int *); +int parse_partition_table(struct driveinfo *, void *); #endif /* _MSDOS_H_ */ diff --git a/com32/gplinclude/disk/swsusp.h b/com32/gplinclude/disk/swsusp.h index 54140b3..1d77c87 100644 --- a/com32/gplinclude/disk/swsusp.h +++ b/com32/gplinclude/disk/swsusp.h @@ -15,5 +15,5 @@ struct swsusp_header { char sig[10]; } __attribute__((packed)); -int swsusp_check(struct driveinfo*, struct part_entry*, int*); +int swsusp_check(struct driveinfo*, struct part_entry*); #endif /* _SWSUSP_H */ diff --git a/com32/gpllib/disk/error.c b/com32/gpllib/disk/error.c index 5491b99..2b82c35 100644 --- a/com32/gpllib/disk/error.c +++ b/com32/gpllib/disk/error.c @@ -20,5 +20,5 @@ **/ void get_error(void* buffer_ptr) { - sprintf(buffer_ptr, "Disklib: error %d\n", errno_disk); + snprintf(buffer_ptr, MAX_DISK_ERRNO, "Disklib: error %d\n", errno_disk); } diff --git a/com32/gpllib/disk/swsusp.c b/com32/gpllib/disk/swsusp.c index f627aca..ac9724a 100644 --- a/com32/gpllib/disk/swsusp.c +++ b/com32/gpllib/disk/swsusp.c @@ -9,23 +9,19 @@ * swsusp_check - check if a (swap) partition contains the swsusp signature * @drive_info: driveinfo struct describing the disk containing the partition * @ptab; Partition table of the partition - * @error: Return the error code on failure **/ -int swsusp_check(struct driveinfo *drive_info, struct part_entry *ptab, int *error) +int swsusp_check(struct driveinfo *drive_info, struct part_entry *ptab) { - struct swsusp_header *header_p; + struct swsusp_header header_p; int offset; int found; /* Read first page of the swap device */ offset = ptab->start_lba; - header_p = (struct swsusp_header *) read_sectors(drive_info, offset, PAGE_SIZE/SECTOR, error); - - if (!header_p) - return -1; /* The error code has been stored in `error' */ - else { - found = !memcmp(SWSUSP_SIG, header_p->sig, 10); - free(header_p); + if (read_sectors(drive_info, &header_p, offset, PAGE_SIZE/SECTOR) == -1) { + return -1; + } else { + found = !memcmp(SWSUSP_SIG, header_p.sig, 10); return found; } } -- 2.7.4