head	1.4;
access;
symbols;
locks;
comment	@ * @;


1.4
date	2002.03.23.18.14.44;	author Helios;	state Exp;
branches;
next	1.3;

1.3
date	99.10.14.23.13.51;	author helios;	state Exp;
branches;
next	1.2;

1.2
date	99.10.14.17.41.28;	author helios;	state Exp;
branches;
next	1.1;

1.1
date	99.10.07.22.36.37;	author helios;	state Exp;
branches;
next	;


desc
@SFSconfig sets and queries Smartfilesystem parameters.
@


1.4
log
@- now compiled with StormGCC, needed a *lot* of changes in this
  tiny piece of code
  (using NO_INLINE_LIBCALLS #define to work around severe problems
  when using inlines with tag based functions like Printf())
- not residentable anymore... linker moans about 32 bit amiga.lib
  references. well you can fix it, there's the source ...
- ... cause SFSconfig is under GPL now
- added proper returning of error codes... have to use exit() instead
  of return since something is broken in StormGCC startup code
@
text
@/*  $Id: SFSconfig.cpp 1.3 1999/10/14 23:13:51 helios Exp $

    Sets and queries SmartFilesystem parameters
*/

#include <dos/dos.h>
#include <dos/dosextens.h>
#include <utility/tagitem.h>
#include "fs/packets.h"
#include "fs/query.h"

#include <proto/dos.h>

const char *version_str = "\0$VER: SFSconfig 1.4 (23.3.2002) (C) by Martin Steigerwald\r\n";

#define TEMPLATE "DEVICE/A,LINES/N,READAHEAD=READAHEADSIZE/N,MAXNAMELENGTH=MAXNAME/N,ACTIVITYFLUSH/N,INACTIVITYFLUSH/N,COPYBACK/S,NOCOPYBACK/S"

int main(void);

int main(void)
{
    int rc=RETURN_OK;
    struct RDArgs *rdargs=NULL;

    struct {
        char *device;
        LONG *lines;
        ULONG *readahead;
        ULONG *maxname;
        ULONG *activityflush;
        ULONG *inactivityflush;
        ULONG copyback;
        ULONG nocopyback;
    } args={NULL};

    rdargs = ReadArgs(TEMPLATE, (LONG *)&args, NULL);

    if (rdargs == NULL) {
        PrintFault(IoErr(), "SFSconfig");
        exit(RETURN_ERROR);
    }
    else {
        struct DosList *dl;
        struct MsgPort *port;
        UBYTE *devname=args.device;

        if (args.copyback!=0 && args.nocopyback!=0) {
            PutStr("SFSConfig: Make a decision. Copyback or not? ;-)\n");
            FreeArgs(rdargs);
            exit(RETURN_ERROR);
        }

        // remove colon from devicename
        while(*devname!=0) {
            if(*devname==':') {
                *devname=0;
                break;
            }
            devname++;
        }

        dl=LockDosList(LDF_DEVICES|LDF_READ);

        if ((dl = FindDosEntry(dl, args.device, LDF_DEVICES))!=0) {
            LONG errorcode;
            struct TagItem vtags[]={
                ASQ_VERSION, 0
            };

            port=dl->dol_Task;

            if ((errorcode = DoPkt(port, ACTION_SFS_QUERY, (LONG)&vtags, 0, 0, 0, 0))!=DOSFALSE) {
                LONG version, revision;
                // show all informations
                struct TagItem qtags[]={
                    ASQ_IS_CASESENSITIVE, 0,
                    ASQ_HAS_RECYCLED, 0,
                    ASQ_CACHE_LINES, 0,
                    ASQ_CACHE_READAHEADSIZE, 0,
                    ASQ_CACHE_MODE, 0,
                    TAG_DONE
                };

                version=vtags[0].ti_Data / 65536;
                revision=vtags[0].ti_Data - (version * 65536);

                // set filename length?
                if (args.maxname != 0) {
                    struct TagItem stags[]={
                        ASS_MAX_NAME_LENGTH, *args.maxname,
                        TAG_DONE
                    };

                    PutStr("Setting maximum filename length ...\n");
                    if ((errorcode = DoPkt(port, ACTION_SFS_SET, (LONG)&stags, 0, 0, 0, 0))==DOSFALSE) {
                        PrintFault(IoErr(), "SFSConfig");
                        rc=RETURN_WARN;
                    }
                }

                // set maximum activity flush time?
                if (args.activityflush != 0) {
                    struct TagItem stags[]={
                        ASS_ACTIVITY_FLUSH_TIMEOUT, *args.activityflush,
                        TAG_DONE
                    };

                    PutStr("Setting activity flush timeout ...\n");
                    if ((errorcode = DoPkt(port, ACTION_SFS_SET, (LONG)&stags, 0, 0, 0, 0))==DOSFALSE) {
                        PrintFault(IoErr(), "SFSconfig");
                        rc=RETURN_WARN;
                    }
                }

                // set maximum activity flush time?
                if (args.inactivityflush != 0) {
                    struct TagItem stags[]={
                        ASS_INACTIVITY_FLUSH_TIMEOUT, *args.inactivityflush,
                        TAG_DONE
                    };

                    PutStr("Setting inactivity flush timeout ...\n");
                    if ((errorcode = DoPkt(port, ACTION_SFS_SET, (LONG)&stags, 0, 0, 0, 0))==DOSFALSE) {
                        PrintFault(IoErr(), "SFSConfig");
                        rc=RETURN_WARN;
                    }
                }

                // set the cache?
                if (args.lines != 0 || args.readahead !=0 || args.copyback != 0 || args.nocopyback !=0) {
                    struct TagItem ctags[]={
                        ASQ_CACHE_LINES, 0,
                        ASQ_CACHE_READAHEADSIZE, 0,
                        ASQ_CACHE_MODE, 0,
                        TAG_DONE
                    };

                    PutStr("Setting cache ...\n");

                    if ((errorcode = DoPkt(port, ACTION_SFS_QUERY, (LONG)&ctags, 0, 0, 0, 0))!=DOSFALSE) {
                        LONG lines = ctags[0].ti_Data;
                        LONG readahead = ctags[1].ti_Data;
                        LONG copyback = ctags[2].ti_Data;

                        if (args.lines!=0) {
                            lines = *args.lines;
                        }
                        if (args.readahead!=0) {
                            readahead = *args.readahead;
                        }
                        if (args.copyback!=0) {
                            copyback=1;
                        }
                        if (args.nocopyback!=0) {
                            copyback=0;
                        }

                        if ((errorcode = DoPkt(port, ACTION_SET_CACHE, lines, readahead, copyback, 0, 0))==DOSFALSE) {
                            PrintFault(IoErr(), "SFSconfig");
                            rc=RETURN_WARN;
                        }

                    }
                    else {
                        PutStr("SFSConfig: Could not query cache parameters!\n");
                        PrintFault(IoErr(), "SFSconfig");
                        rc=RETURN_WARN;
                    } // query cache parameters
                } // set the cache?

                Printf("Devicename:     %s:\n", args.device);

                Printf("SFS version:    %ld.%ld\n", version, revision);

                if ((errorcode = DoPkt(port, ACTION_SFS_QUERY, (LONG)&qtags, 0, 0, 0, 0))!=DOSFALSE) {

                    Printf("Cache:          %ld lines * %ld bytes readahead size = %ld bytes.\n",
                        qtags[2].ti_Data, qtags[3].ti_Data, qtags[2].ti_Data * qtags[3].ti_Data);

                    Printf("                Copyback mode");

                    if (qtags[4].ti_Data==0) {
                        Printf(" disabled.\n");
                    }
                    else {
                        Printf(" enabled.\n");
                    }

                    Printf("Fixed options:  ");

                    if (qtags[0].ti_Data!=0) {
                        Printf("(case sensitive) ");
                    }
                    else {
                        Printf("(not case-sensitive) ");
                    }

                    if (qtags[1].ti_Data!=0) {
                        Printf("(recycled)");
                    }
                    else {
                        Printf("(no recycled)");
                    }

                    Printf("\n");
                }
                else {
                    Printf("SFSconfig: Second SFSQuery failed. This should rarely happen!\n");
                    PrintFault(IoErr(), "SFSconfig");
                    rc=RETURN_WARN;

                }
            }
            else {
                Printf("SFSconfig: SFSQUERY failed. Maybe no SFS device?\n");
                PrintFault(IoErr(), "SFSconfig");
                rc=RETURN_ERROR;
            }
        }
        else {
            Printf("Couldn't find device: '%s:'\n", args.device);
            rc=RETURN_ERROR;
        }
        UnLockDosList(LDF_DEVICES|LDF_READ);

        FreeArgs(rdargs);
    } // ReadArgs
    exit(rc);
}

@


1.3
log
@- adapted to StormC 4 beta. StormC found a few missing ";"
  StormC didn't moan about
- recompiled with StormC 4 beta. Executable 44 bytes
  smaller ;-)
@
text
@d1 1
a1 1
/*  $Id: SFSconfig.cpp 1.2 1999/10/14 17:41:28 helios Exp $
d12 1
a12 1
#include <pragmas/dos_pragmas.h>
d14 1
a14 1
const char *version_str = "\0$VER: SFSconfig 1.3 (15.10.1999) (W) by Martin Steigerwald\r\n";
d18 3
a20 1
main()
d22 1
d27 1
a27 1
        ULONG *lines;
d40 1
a40 1
        return RETURN_ERROR;
d43 4
d48 1
a48 1
            Printf("SFSConfig: Make a decision. Copyback or not? ;-)\n");
d50 1
a50 1
            return(5L);
a52 4
        struct DosList *dl;
        struct MsgPort *port;
        UBYTE *devname=args.device;

a65 3

            port=dl->dol_Task;

d70 2
d74 9
a88 1
                    Printf("Setting maximum filename length ...\n");
d93 2
d97 1
a102 1
                    Printf("Setting activity flush timeout ...\n");
d107 2
d111 1
a116 1
                    Printf("Setting inactivity flush timeout ...\n");
d121 2
d125 1
a128 1

a130 2
                    Printf("Setting cache ...\n");

d138 2
d141 3
a143 3
                        ULONG lines = ctags[0].ti_Data;
                        ULONG readahead = ctags[1].ti_Data;
                        ULONG copyback = ctags[2].ti_Data;
d160 1
d165 1
a165 1
                        Printf("SFSConfig: Could not query cache parameters!\n");
d167 1
a170 10
                // show all informations
                struct TagItem qtags[]={
                    ASQ_IS_CASESENSITIVE, 0,
                    ASQ_HAS_RECYCLED, 0,
                    ASQ_CACHE_LINES, 0,
                    ASQ_CACHE_READAHEADSIZE, 0,
                    ASQ_CACHE_MODE, 0,
                    TAG_DONE
                };

d208 1
a208 1
                    Printf("SFSconfig: Second SFSQuery failed!\n");
d210 2
d217 1
d222 1
d228 1
@


1.2
log
@- some cosmetic changes
- more PrintFault() calls
@
text
@d1 1
a1 1
/*  $Id: SFSconfig.c 1.1 1999/10/07 22:36:37 helios Exp $
d14 1
a14 1
const char *version_str = "\0$VER: SFSconfig 1.2 (14.10.1999) (W) by Martin Steigerwald\r\n";
d56 1
a56 1
            devname++
d136 1
a136 1
                            copyback=1
d139 1
a139 1
                            copyback=0
@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
/*  $Id$
d14 1
a14 1
const char *version_str = "\0$VER: SFSconfig 1.0 (7.10.1999) (W) by Martin Steigerwald\r\n";
d31 1
a31 1
    } args={NULL, NULL, NULL, NULL, 0, 0};
d149 1
d184 4
a187 1
                        Printf("[CASESENSITIVE]");
d191 4
a194 1
                        Printf("[RECYCLED]");
d201 1
d205 2
a206 1
                Printf("SFSConfig: SFSQUERY failed. Maybe no SFS device?\n");
a207 2


@
