Why write "VxWorks does not support O_CREAT on open, you have to use Creat"
745534Mar 5 2010 — edited Mar 16 2010In os_handle.c file, The BDB uses Creat function to creat the file, and write the notes below:
/*
* VxWorks does not support O_CREAT on open, you have to use
* creat() instead. (It does not support O_EXCL or O_TRUNC
* either, even though they are defined "for future support".)
* We really want the POSIX behavior that if O_CREAT is set,
* we open if it exists, or create it if it doesn't exist.
* If O_CREAT is specified, single thread and try to open the
* file. If successful, and O_EXCL return EEXIST. If
* unsuccessful call creat and then end single threading.
*/
but indeed , The Open function supports O_CREAT Flag in VxWorks.
My example is :
The OS:Vxworks 5.5.
Hard Disk: Flash using TFFS file system to store the DB data and log.
I can creat the log file successful when i first use the "Creat" function。
But When I restart the example, when open the pre_Created log file , in Log_put.c L1385
ret = __os_open(dbenv, *namep, 0, flags, mode, fhpp)
I get the file descripter is 0,
when read the log file after , The read Function get 0 file descripter, it is the stand input. the Program is waiting for your input, the program is dead.
but when i change the Program to Create file with open using O_CREAT flag , Everything is OK.
Why?
pls help me.
thank you
eric.