|
|
1.1 ! root 1: # include <useful.h> ! 2: # include <opsys.h> ! 3: # include <sccs.h> ! 4: ! 5: SCCSID(@(#)markopen.c 7.1 2/5/81) ! 6: ! 7: /* ! 8: ** MARKOPEN -- mark all open files ! 9: ** ! 10: ** Marked files will not be closed later. ! 11: ** ! 12: ** Parameters: ! 13: ** ovect -- pointer to bitmap of open files. ! 14: ** ! 15: ** Returns: ! 16: ** none ! 17: ** ! 18: ** Side Effects: ! 19: ** Sets *ovect to represent the open files. ! 20: */ ! 21: ! 22: long CmOfiles; /* default set of files, used all over */ ! 23: ! 24: markopen(ovect) ! 25: register long *ovect; ! 26: { ! 27: register int i; ! 28: register int j; ! 29: extern int errno; ! 30: struct stat sbuf; ! 31: ! 32: if (ovect == NULL) ! 33: ovect = &CmOfiles; ! 34: ! 35: *ovect = 0; ! 36: for (i = 0; i < NOFILE; i++) ! 37: { ! 38: if (fstat(i, &sbuf) >= 0) ! 39: *ovect |= 1 << i; ! 40: } ! 41: errno = 0; ! 42: } ! 43: /* ! 44: ** CLOSEALL -- close all open files (except marked files) ! 45: ** ! 46: ** Parameters: ! 47: ** tell -- if set, report files that are open and should ! 48: ** not have been. ! 49: ** ovect -- vector of files to leave open. ! 50: ** ! 51: ** Returns: ! 52: ** none ! 53: ** ! 54: ** Side Effects: ! 55: ** none ! 56: ** ! 57: ** Trace Flags: ! 58: ** none ! 59: */ ! 60: ! 61: closeall(tell, ovect) ! 62: register int tell; ! 63: register long ovect; ! 64: { ! 65: register int i; ! 66: ! 67: ovect |= CmOfiles; ! 68: ! 69: for (i = 0; i < NOFILE; i++) ! 70: { ! 71: if (!bitset(1 << i, ovect)) ! 72: if (close(i) >= 0 && tell) ! 73: lprintf("File %d open\n", i); ! 74: } ! 75: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.