/* -------------------------------------------------------------------------- Print an error message to the standard error output and to the log file. - Parameters ------------------------------------------------------------- PSZ pszMsg : message to be printed. ULONG cbMsg : length of the message. - Return value ----------------------------------------------------------- VOID -------------------------------------------------------------------------- */ VOID printError(PSZ pszMsg, ULONG cbMsg) { if (!(g.mode & FSJQUIET)) { if (g.mode & FSJ_RUNNING) VioSetCurPos(20, 0, 0); DosPutMessage((HFILE)2, cbMsg, pszMsg); } if (FMO_ERROR != g.hfLog) { pszMsg[cbMsg++] = '\r', pszMsg[cbMsg++] = '\n'; DosPutMessage(g.hfLog, cbMsg, pszMsg); } }
WORD16 StratInit(RP FAR* _rp) { RPInit FAR* rp = (RPInit FAR*)_rp; int result=0; // HFILE FAR* File; // MANDATORY: Initialize the Device Driver libraries. DevInit(rp->In.DevHlp); // Signal that we've installed successfully by setting the size of // our code and data segments. rp->Out.FinalCS = OffsetFinalCS; rp->Out.FinalDS = OffsetFinalDS; // Print a sign on message to the debugging terminal. cdbg << ALL << endl; cdbg << MSG_DEBUG << endl; cdbg << MSG_CS << hex << setw(4) << OffsetFinalCS << setw() << dec << 'h' << endl; cdbg << MSG_DS << hex << setw(4) << OffsetFinalDS << setw() << dec << 'h' << endl; cdbg << endl; // Print a sign on message to the console. DosPutMessage(1, WELCOME_LENGTH, WELCOME); //user code return RPDONE; }
void PrintMessage(char **Table, int count, int msgno) { char MsgBuf[MAX_MSGLEN]; ULONG len; char lang[CCHMAXPATH], file[CCHMAXPATH], *langenv, *tmp; /* Change to the language directory if it exists */ if ((langenv=getenv("LANG"))!=NULL) { if ((strcpy(lang, langenv))!=NULL) { if ((tmp=strchr(lang, '_'))!=NULL) { *tmp=0; } } } else { strcpy(lang, "."); } sprintf(file, "%s\\%s", lang, MSGFILE); if (DosGetMessage(Table, count, MsgBuf, MAX_MSGLEN, msgno, file, &len)==NO_ERROR) { DosPutMessage((HFILE)2, len, MsgBuf); } else { fprintf(stderr, "IRM%04i\n", msgno); } return; }
int ptc_init(RP rp) { int i; TTY tp; char far *ptr = buf1; if (init_once(rp) == 2) return RP_EGEN; constty = 0; for (i=0; i<NPTY; i++) { ptr = i<16 ? buf1 : buf2; tp = (TTY) (ptr + ( (i%16) * sizeof(struct tty) )); ttys[i] = tp; tp->state = 0; tp->send = tp->ucntl = 0; qinit(&tp->inq); qinit(&tp->outq); tp->dev = i; tp->pgrp = tp->pid = 0; tp->ccnt = tp->scnt = 0; tp->ocol = 0; rpqinit(&tp->crq); rpqinit(&tp->cwq); rpqinit(&tp->srq); rpqinit(&tp->swq); tp->crsel = tp->srsel = tp->cxsel = 0; } #ifdef INTRO DosPutMessage(1,sizeof(pty_msg)-1,pty_msg); #endif return RPDONE; }
/* -------------------------------------------------------------------------- Handle error events. - Parameters ------------------------------------------------------------- BOOL bContinue : TRUE/FALSE (non-critical/critical error). BOOL bHelp : show the 'type FSJ ?' message. PSZ msg : error message holding formatting characters. ... : variable number of parameters. - Return value ----------------------------------------------------------- BOOL : FALSE when the program has to terminate, TRUE for non-critical errors. -------------------------------------------------------------------------- */ BOOL handleError(BOOL bContinue, BOOL bHelp, PSZ msg, ...) { CHAR buf[CBMSG_BUF]; ULONG cb; va_list ap; // build the error message: "Error: " + msg + ".\r\n" cb = sprintf(buf, SZ_ERRPREFIX); va_start(ap, msg); cb += vsprintf(buf + cb, msg, ap); va_end(ap); cb += sprintf(buf + cb, (bHelp ? SZ_READHELP : SZ_SUFFIX)); if (bContinue) { if (FMO_ERROR != g.hfLog) DosPutMessage(g.hfLog, cb, buf); if (g.mode & FSJUNATTENDED) return FALSE; sprintf(buf + cb, "\r\n%s", SZ_IGNOREABORT); if (ERROR_ABORT == showMenu(buf, ACH_IGNOREABORT)) return FALSE; g.rc = NO_ERROR; return TRUE; } printError(buf, cb); return FALSE; }
int io_init(RP rp) { if (init_once(rp)==2) return RP_EGEN; io_gdt32 = 0; #ifdef INTRO DosPutMessage(1,sizeof(io_msg)-1,io_msg); #endif return RPDONE; }
int init_once(RP rp) { switch (done_init) { case 2: /* fatal error */ return 2; case 0: /* must init */ Device_Help = rp->pk.init.devhlp; /* read cmd line params */ read_args(rp->pk.init.args); done_init = 1; /* allocate memory */ buf1 = AllocBuf(32l * sizeof(struct tty)); buf2 = AllocBuf(32l * sizeof(struct tty)); if (!buf1 || !buf2) { /* fatal */ rp->pk.initexit.cs = 0; rp->pk.initexit.ds = 0; done_init = 2; return 2; } DosPutMessage(1, sizeof(version_msg) - 1, version_msg); DosPutMessage(1, sizeof(once_msg) - 1, once_msg); if (dbgflag) { DosPutMessage(1, sizeof(dbg_msg) - 1, dbg_msg); int3(); } /* fall thru */ case 1: /* ok */ #define GETSEL(ptr) ((USHORT)(((ULONG)((void far*)ptr)>>16)&0xffff)) SegLimit(GETSEL(DiscardProc),&rp->pk.initexit.cs); SegLimit(GETSEL(&DiscardData),&rp->pk.initexit.ds); } return 1; }
/* -------------------------------------------------------------------------- Print a text message on the screen and on standard output. - Parameters ------------------------------------------------------------- LONG irow : row position of the message. If this is < 0 the cursor position is not changed. PSZ pszMsg : text message with formatting tags. ... : variable number of parameters. - Return value ----------------------------------------------------------- VOID -------------------------------------------------------------------------- */ VOID printMsg(ULONG irow, PSZ pszMsg, ...) { CHAR buf[CBMSG_BUF]; ULONG cb; va_list ap; va_start(ap, pszMsg); cb = vsprintf(buf, pszMsg, ap); va_end(ap); cb +=sprintf(buf + cb, "\r\n"); if (!(g.mode & FSJQUIET)) { if (irow > 0) { VioScrollUp(irow, 0, irow + 5, 80, 6, " \x00", 0); VioSetCurPos(irow, 0, 0); } DosPutMessage((HFILE)1, cb, buf); } if (g.hfLog) DosPutMessage(g.hfLog, cb, buf); }
int map_init(RP rp) { int i; if (init_once(rp) == 2) return RP_EGEN; for (i=0; i<NMAP; i++) { maps[i].sfnum = -1; maps[i].phys = maps[i].vmaddr = 0; } #ifdef INTRO DosPutMessage(1,sizeof(map_msg)-1,map_msg); #endif return RPDONE; }
int con_init(RP rp) { if (init_once(rp)==2) return RP_EGEN; conpos = 0; conlen = 0; conpid = 0; constty = 0; conrsel = 0; constate = 0; #ifdef INTRO DosPutMessage(1,sizeof(con_msg)-1,con_msg); #endif return RPDONE; }
/* * NAME: jfs_logform * FUNCTION: format file system log * * RETURN: 0 - successful * -1 - error occur * */ int32 jfs_logform( int32 fd, /* for inline log, this is a file descriptor * for an opened device to write log. * for outline log, it is -1 */ int32 aggr_blk_size, /* aggregate block size in bytes */ int32 s_l2bsize, /* log2 of aggregate block size in bytes */ uint32 s_flag, /* fs superblock s_flag is passed in */ int64 log_start, /* offset of the start of inline log in * number of aggr. blocks. for outline log * it is set as zero */ int32 log_len, /* inline log length in number of aggr. blks * for outline log, it is zero */ char * dev_name, /* logical volume of the outline log device * for inline log, it is NULL */ int32 nblks /* size of the outline log in 512 byte blocks * for inline log, it is zero */ ) { ULONG Action; int64 log_len_in_bytes; char parms = 0; unsigned long parmlen = sizeof(parms); ULONG actual; struct DPB dev; unsigned long devlen = sizeof(dev); int32 oflag,logfd,npages,rc,k,dblks,total_blks; char logpages[4 * LOGPSIZE]; logpage_t *logp; /* array of 4 log pages */ static logsuper_t log_sup; struct lrd *lrd_ptr; int64 log_begin; /* the location of the beginning of the log inside * of the file system. ( in bytes ) */ int64 log_contwt; char answer; int16 inlinelog = (s_flag & JFS_INLINELOG ); int Working_counter; char *Working[5]; #define LOGBUFSIZE 4 * LOGPSIZE logp = (logpage_t *) &logpages; Working[0] = " |\r"; Working[1] = " /\r"; Working[2] = " -\r"; Working[3] = " \\\r"; /* * check to see whether standard out has been redirected, and * set the flag accordingly. */ if( (ujfs_stdout_redirected()) != 0 ) { stdout_redirected = 1; } else { stdout_redirected = 0; } /* * if it is an outline log, do device check and open device */ if (!inlinelog ) { /* open the device */ if (DosOpen(dev_name, (unsigned long *)&logfd, &Action, 0, 0, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE, 0)) goto errout; fd = logfd; /* * Lock the drive */ rc = DosDevIOCtl(fd, IOCTL_DISK, DSK_LOCKDRIVE, &parms, sizeof(parms), &parmlen, &parms, sizeof(parms), &parmlen); /* * validate/determine device size. * for bringup allow ioctl to fail or to report zero size. */ rc = DosDevIOCtl(fd, IOCTL_DISK, DSK_GETDEVICEPARAMS, &parms, sizeof(parms), &parmlen, &dev, sizeof(dev), &devlen); if (rc == NO_ERROR) { total_blks = dev.dev_bpb.total_sectors + dev.dev_bpb.large_total_sectors; if (total_blks > 0) { dblks = (nblks == 0) ? total_blks : MIN(nblks,total_blks); } } if ((npages = dblks/(LOGPSIZE/512)) == 0) { printf("ioctl failed \n"); printf("try again but specify number of blocks \n"); return -1; } /* before we destroy anything in the log, try to * confirm with the user */ while(TRUE) { printf("logform: destroy %s (y)?",dev_name); fflush(stdout); answer = getchar(); if(answer == 'n' || answer == 'N') exit(1); else if(answer == 'y' || answer == 'Y' || answer == '\n') break; while((answer = getchar()) != '\n'); } rc = write_bootsec(fd, &(dev.dev_bpb), "jfslog", 1); } /***************************************************************************/ else { /* the fs has an inlinelog */ log_len_in_bytes = ((int64) log_len) << s_l2bsize; npages = log_len_in_bytes / LOGPSIZE; } /* * init log superblock: log page 1 */ log_sup.magic = LOGMAGIC; log_sup.version = LOGVERSION; log_sup.state = LOGREDONE; log_sup.flag = s_flag; /* assign fs s_flag to log superblock. * currently s_flag carries the inlinelog * info and commit option ( i.e. group commit * or lazy commit, etc.. ) */ log_sup.size = npages; log_sup.bsize = aggr_blk_size; log_sup.l2bsize = s_l2bsize; log_sup.end = 2*LOGPSIZE + LOGPHDRSIZE + LOGRDSIZE; /* find the log superblock location */ log_begin = log_start << s_l2bsize; rc = ujfs_rw_diskblocks(fd, (log_begin+LOGPSIZE), (unsigned)LOGPSIZE, (char *)&log_sup, PUT); if ( rc != 0 ) goto errout; /* * init device pages 2 to npages-1 as log data pages: * * log page sequence number (lpsn) initialization: * the N (= npages-2) data pages of the log is maintained as * a circular file for the log records; * lpsn grows by 1 monotonically as each log page is written * to the circular file of the log; * Since the AIX DUMMY log record is dropped for this XJFS, * and setLogpage() will not reset the page number even if * the eor is equal to LOGPHDRSIZE. In order for binary search * still work in find log end process, we have to simulate the * log wrap situation at the log format time. * The 1st log page written will have the highest lpsn. Then * the succeeding log pages will have ascending order of * the lspn starting from 0, ... (N-2) */ /* initialize 1st 2 log pages to be written: lpsn = N-1, 0 and also a SYNCPT log record is written to the N-1 page Since the log is always an even number of meg, if we write 2 pages before entering the loop, we are assured that the log will end after a 4 page buffer. */ logp[0].h.eor = logp[0].t.eor = LOGPHDRSIZE + LOGRDSIZE; logp[0].h.page = logp[0].t.page = npages - 3; lrd_ptr = (struct lrd *)&logp[0].data; lrd_ptr->logtid = 0; lrd_ptr->backchain = 0; lrd_ptr->type = LOG_SYNCPT; lrd_ptr->length = 0; lrd_ptr->log.syncpt.sync = 0; logp[1].h.eor = logp[1].t.eor = LOGPHDRSIZE; logp[1].h.page = logp[1].t.page = 0; lrd_ptr = (struct lrd *)&logp[1].data; lrd_ptr->logtid = 0; lrd_ptr->backchain = 0; lrd_ptr->type = LOG_SYNCPT; lrd_ptr->length = 0; lrd_ptr->log.syncpt.sync = 0; rc = ujfs_rw_diskblocks(fd, (log_begin+2*LOGPSIZE), (unsigned) 2*LOGPSIZE, (char *)&(logp[0]), PUT); if ( rc != 0 ) { printf("Error RW 2\n"); goto errout; } /* initialize buffer to write 4 pages at a time */ logp[0].h.eor = logp[0].t.eor = LOGPHDRSIZE; logp[2].h.eor = logp[2].t.eor = LOGPHDRSIZE; lrd_ptr = (struct lrd *)&logp[2].data; lrd_ptr->logtid = 0; lrd_ptr->backchain = 0; lrd_ptr->type = LOG_SYNCPT; lrd_ptr->length = 0; lrd_ptr->log.syncpt.sync = 0; logp[3].h.eor = logp[3].t.eor = LOGPHDRSIZE; lrd_ptr = (struct lrd *)&logp[3].data; lrd_ptr->logtid = 0; lrd_ptr->backchain = 0; lrd_ptr->type = LOG_SYNCPT; lrd_ptr->length = 0; lrd_ptr->log.syncpt.sync = 0; /* initialize succeeding log pages: lpsn = 1, 2, ..., (N-2) */ Working_counter = 0; log_contwt = log_begin + LOGBUFSIZE; for ( k = 1; k < npages - 4; k+=4 ) { logp[0].h.page = logp[0].t.page = k; logp[1].h.page = logp[1].t.page = k + 1; logp[2].h.page = logp[2].t.page = k + 2; logp[3].h.page = logp[3].t.page = k + 3; rc = ujfs_rw_diskblocks(fd, log_contwt, (unsigned) LOGBUFSIZE, (char *)&(logp[0]), PUT); if (rc != 0 ) { printf("Error RW 3\n"); goto errout; } log_contwt += LOGBUFSIZE; if( !stdout_redirected ) { Working_counter++; switch( Working_counter ) { case( 100 ): DosPutMessage( 1, strlen(Working[0]), Working[0] ); fflush( stdout ); break; case( 200 ): DosPutMessage( 1, strlen(Working[1]), Working[1] ); fflush( stdout ); break; case( 300 ): DosPutMessage( 1, strlen(Working[2]), Working[2] ); fflush( stdout ); break; case( 400 ): DosPutMessage( 1, strlen(Working[3]), Working[3] ); fflush( stdout ); Working_counter = 0; break; default: break; } } } if (!inlinelog) { rc = DosDevIOCtl(fd, IOCTL_DISK, DSK_UNLOCKDRIVE, &parms, sizeof(parms), &parmlen, &parms, sizeof(parms), &parmlen); rc = DosClose(fd); } return(0); errout: if (rc == ERROR_WRITE_PROTECT) message_user(ERROR_WRITE_PROTECT, NULL, 0, STDOUT_CODE, NO_RESPONSE, OSO_MSG); return(-1); }
/***************************************************************************** * NAME: fsck_hbeat * * FUNCTION: * * PARAMETERS: none * * NOTES: * * RETURNS: * success: FSCK_OK * failure: something else */ void _System fsck_hbeat ( ULONG current_heartbeat ) { while( exit_flag == 0 ) { DosSleep( 500); /* sleep for a half second */ switch( current_heartbeat ) { case 0: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT0] ); current_heartbeat = 1; break; case 1: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT1] ); current_heartbeat = 2; break; case 2: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT2] ); current_heartbeat = 3; break; case 3: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT3] ); current_heartbeat = 4; break; case 4: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT4] ); current_heartbeat = 5; break; case 5: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT5] ); current_heartbeat = 6; break; case 6: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT6] ); current_heartbeat = 7; break; case 7: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT7] ); current_heartbeat = 8; break; case 8: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT8] ); current_heartbeat = 9; break; case 9: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT7] ); current_heartbeat = 10; break; case 10: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT6] ); current_heartbeat = 11; break; case 11: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT5] ); current_heartbeat = 12; break; case 12: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT4] ); current_heartbeat = 13; break; case 13: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT3] ); current_heartbeat = 14; break; case 14: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT2] ); current_heartbeat = 15; break; case 15: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT1] ); current_heartbeat = 0; break; default: sprintf( hb_msg_ptr, MsgText[fsck_HEARTBEAT0] ); current_heartbeat = 1; } DosPutMessage( 1, strlen(hb_msg_ptr), hb_msg_ptr ); fflush( stdout ); } /* end while */ exit_flag = 0; return; } /* end of fsck_hbeat() */
void main(void) { char msg[] = "I'm really small!\n"; DosPutMessage(1, sizeof(msg), &msg); }
/* -------------------------------------------------------------------------- Display the message press any key to continue. - Parameters ------------------------------------------------------------- VOID - Return value ----------------------------------------------------------- VOID -------------------------------------------------------------------------- */ VOID pause(VOID) { DosPutMessage(1, strlen(SZ_PRESSANYKEY), SZ_PRESSANYKEY); kbdKey(); }