/* ** DRVALID.C - validate disk drives ** ** Original Copyright 1988-1991 by Bob Stout as part of ** the MicroFirm Function Library (MFL) ** ** This subset version is functionally identical to the ** version originally published by the author in Tech Specialist ** magazine and is hereby donated to the public domain. ** ** Uses ABSDISKC.C and ABSDISK.ASM in SNIPPETS. */ #include #include typedef enum {ERROR = -1, SUCCESS, FALSE = 0, TRUE} LOGICAL; /* ** Function to read an absolute disk sector */ int AbsDiskRead(unsigned short, size_t, size_t, void *); /* ** getdrv() ** ** Just as getcwd() returns the default directory, getdrv() returns ** the current drive. ** ** Arguments: None. ** ** Returns: Current drive (0 = A:, 1 = B:, etc.) ** ** Side effects: none */ int getdrv(void) { union REGS regs; regs.h.ah = 0x19; intdos(®s, ®s); return (regs.h.al); } /* ** chdrv() ** ** Like chdir(), except changes drives rather than directories. ** ** Arguments: 1 - target drive (0 = A:, 1 = B:, etc.) ** ** Returns: SUCCESS or ERROR ** ** Side effects: none */ LOGICAL chdrv(int drive) { union REGS regs; regs.h.ah = 0x0e; regs.h.dl = (char)drive; intdos(®s, ®s); if (drive != getdrv()) return ERROR; else return SUCCESS; } /* ** drvalid() ** ** Verifies whether a logical disk drive is available without ** triggering the DOS critical error handler. ** ** Arguments: 1 - target drive (0 = A;, 1 = B:, etc.) ** ** Returns: TRUE - drive is valid ** FALSE - drive is invalid ** ** Side effects: none */ LOGICAL drvalid(int drive) { int original, result; original = getdrv(); result = (SUCCESS == chdrv(drive)); chdrv(original); return result; } /* ** drvrdy() ** ** Checks whether a drive with removable media is ready. ** ** Arguments: 1 - target drive (0 = A;, 1 = B:, etc.) ** ** Returns: TRUE - drive is ready ** FALSE - drive is not ready ** ERROR - other read error ** ** Side effects: none */ LOGICAL drvrdy(int drive) { int status; char buf[2048]; /* nice & roomy */ status = AbsDiskRead(drive, 1, 0, buf); if (0 == status) return TRUE; status &= 0xff; if (2 == status) return FALSE; else return ERROR; } #ifdef TEST #include #include int main(int argc, char *argv[]) { int drive; if (2 > argc) { puts("Usage: DRVALID drive[:]"); return EXIT_FAILURE; } drive = toupper(*argv[1]); if (!isalpha(drive)) { puts("Error: Invalid drive name"); return EXIT_FAILURE; } printf("Drive %c: is %svalid\n", drive, drvalid(drive - 'A') ? "" : "not "); if (2 < _osmajor) { union REGS regs; regs.x.ax = 0x4408; regs.h.bl = (unsigned char)(drive - '@'); intdos(®s, ®s); printf("ioctl returned Cflag=%s\n", regs.x.cflag ? "TRUE" : "FALSE"); printf("ioctl returned AX=0x%X\n", regs.x.ax); printf("Drive %c is%s removable\n", drive, regs.x.ax ? " not" : ""); if (0 == regs.x.ax) { printf("Drive %c is %sready\n", drive, drvrdy(drive - 'A') ? "" : "not "); } } return EXIT_SUCCESS; } #endif /* TEST */ v class='content'>
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-02-01 12:46:17 -0500
committerDavid S. Miller <davem@davemloft.net>2017-02-01 12:46:17 -0500
commit889711a03e0fba427fb85317900e93c74e3be02a (patch)
tree05af2eda6502a95cf11935cce1e9b25a1340e7ca /drivers/usb/image/microtek.c
parentff1176f6164f3d151ee64c05d3f7b6662a81b982 (diff)
parent7243a1af37a4dc9225004546d9d0756c529ad3ce (diff)
Merge tag 'wireless-drivers-next-for-davem-2017-02-01' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next
Kalle Valo says: ==================== wireless-drivers-next patches for 4.11 It's nice to see rt2x00 development has becoming active, for example adding support for a new chip version. Also wcn36xx has been converted to use the recently merged QCOM_SMD subsystem. Otherwise new features and fixes it lots of drivers. Major changes: iwlwifi * some more work in preparation for A000 family support * add support for radiotap timestamps * some work on our firmware debugging capabilities wcn36xx * convert to a proper QCOM_SMD driver (from the platform_driver interface) ath10k * VHT160 support * dump Copy Engine registers during firmware crash * search board file extension from SMBIOS wil6210 * add disable_ap_sme module parameter rt2x00 * support RT3352 with external PA * support for RT3352 with 20MHz crystal * add support for RT5350 WiSoC brcmfmac * add support for BCM43455 sdio device rtl8xxxu * add support for D-Link DWA-131 rev E1, TP-Link TL-WN822N v4 and others ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/usb/image/microtek.c')