long seekPos; /* current logical file position */
char *fileName; /* name of file, or NULL for unused VFD */
/* NB: fileName is malloc'd, and must be free'd when closing the VFD */
- int fileFlags; /* open(2) flags for opening the file */
+ int fileFlags; /* open(2) flags for (re)opening the file */
int fileMode; /* mode to pass to open(2) */
} Vfd;
vfdP->fileName = malloc(strlen(fileName) + 1);
strcpy(vfdP->fileName, fileName);
- vfdP->fileFlags = fileFlags & ~(O_TRUNC | O_EXCL);
+ /* Saved flags are adjusted to be OK for re-opening file */
+ vfdP->fileFlags = fileFlags & ~(O_CREAT | O_TRUNC | O_EXCL);
vfdP->fileMode = fileMode;
+
vfdP->seekPos = 0;
/*