// // $Header: D:/ext2-os2/RCS/ifsdbg.c,v 1.6 1995/08/16 17:37:32 Willm Exp Willm $ // // Linux ext2 file system driver for OS/2 2.x and WARP - Allows OS/2 to // access your Linux ext2fs partitions as normal drive letters. // OS/2 implementation : Copyright (C) 1995 Matthieu WILLM // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define INCL_DOS #define INCL_DOSERRORS #include #include #include #include #include #include #include #include char Buf[8192]; extern char Msg_0[]; int trace = FALSE; void handler_signal(int sig) { APIRET rc; rc = DosFSCtl ( NULL, 0, 0, NULL, 0, 0, IFSDBG_CLOSE, "ext2", -1, FSCTL_FSDNAME); if ((rc != NO_ERROR) && (rc != 0xEE01)) { // ERROR_DEVICE_NOT_OPEN (custom IFS error) fprintf(stderr, "Couldn't stop dialog with ext2-os2.ifs - DosFsCtl returned %d\n", rc); exit(EXIT_FAILURE); } /* end if */ exit(EXIT_SUCCESS); } int main(int argc, char **argv) { APIRET rc; ULONG DataIO; int i; USHORT *Tmp; int lg; char *tmp; setbuf(stdout, NULL); setbuf(stderr, NULL); signal(SIGINT, handler_signal); signal(SIGTERM, handler_signal); signal(SIGABRT, handler_signal); printf("%s", Msg_0); for (i = 0 ; i < argc ; i++) { if (strcmp(argv[i], "-trace") == 0) { trace = TRUE; } else { trace = FALSE; } } if (trace) { if ((rc = DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 31, 0)) != NO_ERROR) { fprintf(stderr, "Couldn't switch to time critical priority - DosSetPriority returned %d\n", rc); exit(EXIT_FAILURE); } else { printf("Switched to time critical priority\n"); } /* end if */ } if ((rc = DosFSCtl ( NULL, 0, 0, NULL, 0, 0, IFSDBG_OPEN, "ext2", -1, FSCTL_FSDNAME)) != NO_ERROR) { fprintf(stderr, "Couldn't start dialog with ext2-os2.ifs - DosFsCtl returned %d\n", rc); exit(EXIT_FAILURE); } /* end if */ for (;;) { DataIO = 0; memset(Buf, 0, 8192); if ((rc = DosFSCtl ( Buf, 4096, &DataIO, NULL, 0, 0, IFSDBG_READ, "ext2", -1, FSCTL_FSDNAME)) != NO_ERROR) { fprintf(stderr, "Couldn't retrieve data from ext2-os2.ifs - DosFsCtl returned %d\n", rc); abort(); } else { tmp = Buf; while ((tmp[0] != '\0') && (tmp[1] != '\0')){ Tmp = (USHORT *)tmp; switch(Tmp[0]) { case LOG_FS_ERR : { err_record *err_rec = (err_record *)Tmp; printf( "===> ERROR : %s() called from %s() (%s - line %d) - rc = 0x%04X\n", func[err_rec->errfunction], func[err_rec->infunction], sourcefile[err_rec->sourcefile], err_rec->sourceline, err_rec->retcode ); tmp += sizeof(err_record); } break; default : printf("%s\n", tmp); tmp = &tmp[strlen(tmp) + 1]; break; } /* end switch */ fflush(stdout); } } } }