Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / rom / filesys / SFS / SFSformat / SFSformat.c
blob07f989557bf9129ded2f939227b57d07ffde03b5
1 #include <dos/dos.h>
2 #include <dos/dosextens.h>
3 #include <proto/dos.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";
11 LONG main()
13 struct RDArgs *readarg;
14 UBYTE template[]="DEVICE=DRIVE/A/K,NAME/A/K,CASESENSITIVE/S,NORECYCLED/S,SHOWRECYCLED/S";
15 UBYTE choice='N';
17 struct {
18 char *device;
19 char *name;
20 IPTR casesensitive;
21 IPTR norecycled;
22 IPTR showrecycled;
23 } arglist={NULL};
25 if((DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",37))!=0)
27 if((readarg=ReadArgs(template,(IPTR *)&arglist,0))!=0)
29 struct MsgPort *msgport;
30 struct DosList *dl;
31 UBYTE *devname=arglist.device;
33 while(*devname!=0)
35 if(*devname==':')
37 // *devname=0;
38 break;
40 devname++;
43 dl=LockDosList(LDF_DEVICES|LDF_READ);
44 if((dl=FindDosEntry(dl,arglist.device,LDF_DEVICES))!=0)
46 LONG errorcode=0;
48 msgport=dl->dol_Task;
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')
59 //Printf("a");
60 if(Inhibit(arglist.device,DOSTRUE))
62 //Printf("b");
64 struct TagItem tags[5];
65 struct TagItem *tag=tags;
67 tag->ti_Tag=ASF_NAME;
68 tag->ti_Data=(IPTR)arglist.name;
69 tag++;
71 if(arglist.casesensitive!=0)
73 tag->ti_Tag=ASF_CASESENSITIVE;
74 tag->ti_Data=TRUE;
75 tag++;
78 if(arglist.norecycled!=0)
80 tag->ti_Tag=ASF_NORECYCLED;
81 tag->ti_Data=TRUE;
82 tag++;
85 if(arglist.showrecycled!=0)
87 tag->ti_Tag=ASF_SHOWRECYCLED;
88 tag->ti_Data=TRUE;
89 tag++;
92 tag->ti_Tag=TAG_END;
93 tag->ti_Data=0;
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);
103 else {
104 PrintFault(IoErr(),"error while locking the drive");
107 else if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
109 PutStr("\n***Break\n");
112 else {
113 Printf("Unknown device %s\n",arglist.device);
114 UnLockDosList(LDF_DEVICES|LDF_READ);
116 FreeArgs(readarg);
118 else {
119 PutStr("wrong args!\n");
122 CloseLibrary((struct Library *)DOSBase);
124 return(0);