Better error handling.
[AROS.git] / workbench / c / DiskChange.c
blob5b0679a6857f44efa9490fd639f65258784ca8b6
1 /*
2 Copyright © 2007-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: DiskChange CLI command
6 Lang: English
7 */
8 /******************************************************************************
10 NAME
12 Diskchange
14 FORMAT
16 Diskchange DEVICE
18 SYNOPSIS
20 DEVICE/A
22 LOCATION
26 FUNCTION
28 Diskchange is intended only for removable media. For example if
29 you have a internal floppy disk dive set to noclick AROS will not
30 perform disk presence check. So you have to manually update any
31 disk change made.
33 INPUTS
35 DEVICE -- The disk device unit.
37 RESULT
39 NOTES
41 EXAMPLE
43 Diskchange df0:
45 BUGS
47 SEE ALSO
49 INTERNALS
51 HISTORY
53 ******************************************************************************//*****************************************************************************************/
55 #include <proto/dos.h>
57 #include <dos/dos.h>
58 #include <exec/types.h>
60 const TEXT __version__[] = "\0$VER: DiskChange 41.2 (2.4.2014)";
61 int __nocommandline;
63 int main(void)
65 struct RDArgs *ra;
66 STRPTR dev;
67 int rc = RETURN_FAIL;
68 LONG error = 0;
70 ra = ReadArgs("DEVICE/A", (IPTR *)&dev, NULL);
71 if (ra) {
72 if (Inhibit(dev, DOSTRUE) && Inhibit(dev, DOSFALSE))
73 rc = RETURN_OK;
74 error = IoErr();
75 FreeArgs(ra);
77 if (rc != RETURN_OK);
78 PrintFault(error, "DiskChange");
79 return rc;