2 #include <dos/dosextens.h>
4 #include <proto/exec.h>
5 #include <utility/tagitem.h>
7 #include "../FS/packets.h"
9 const char version
[]="\0$VER: SFSformat 1.1 (" ADATE
")\r\n";
13 struct RDArgs
*readarg
;
14 UBYTE
template[]="DEVICE=DRIVE/A/K,NAME/A/K,CASESENSITIVE/S,NORECYCLED/S,SHOWRECYCLED/S";
25 if((DOSBase
=(struct DosLibrary
*)OpenLibrary("dos.library",37))!=0)
27 if((readarg
=ReadArgs(template,(IPTR
*)&arglist
,0))!=0)
29 struct MsgPort
*msgport
;
31 UBYTE
*devname
=arglist
.device
;
43 dl
=LockDosList(LDF_DEVICES
|LDF_READ
);
44 if((dl
=FindDosEntry(dl
,arglist
.device
,LDF_DEVICES
))!=0)
49 UnLockDosList(LDF_DEVICES
|LDF_READ
);
51 Printf("About to format drive %s. ", arglist
.device
);
52 Printf("This will destroy all data on the drive!\n");
53 Printf("Are you sure? (y/N)"); Flush(Output());
55 Read(Input(), &choice
, 1);
57 if(choice
== 'y' || choice
== 'Y')
60 if(Inhibit(arglist
.device
,DOSTRUE
))
64 struct TagItem tags
[5];
65 struct TagItem
*tag
=tags
;
68 tag
->ti_Data
=(IPTR
)arglist
.name
;
71 if(arglist
.casesensitive
!=0)
73 tag
->ti_Tag
=ASF_CASESENSITIVE
;
78 if(arglist
.norecycled
!=0)
80 tag
->ti_Tag
=ASF_NORECYCLED
;
85 if(arglist
.showrecycled
!=0)
87 tag
->ti_Tag
=ASF_SHOWRECYCLED
;
95 if((errorcode
=DoPkt(msgport
, ACTION_SFS_FORMAT
, (SIPTR
)&tags
, 0, 0, 0, 0))==DOSFALSE
)
97 PrintFault(IoErr(),"error while initializing the drive");
101 Inhibit(arglist
.device
,DOSFALSE
);
104 PrintFault(IoErr(),"error while locking the drive");
107 else if(SetSignal(0L,SIGBREAKF_CTRL_C
) & SIGBREAKF_CTRL_C
)
109 PutStr("\n***Break\n");
113 Printf("Unknown device %s\n",arglist
.device
);
114 UnLockDosList(LDF_DEVICES
|LDF_READ
);
119 PutStr("wrong args!\n");
122 CloseLibrary((struct Library
*)DOSBase
);