I was doing some testing, and opening a file on host as O_RDWR, results in the file being truncated, and upon looking into this a bit more, I see that in utility.c O_TRUNC is added along with O_WRONLY on line 18(in the function fix_flags). There is a FIXME comment about how some programs require this, and I was curious as to which ones, so that I know what I am breaking by removing the O_TRUNC part.
See file here:
http://svn.ps2dev.org/filedetails.php?r ... rev=0&sc=0
Question about ps2client.
-
- Posts: 83
- Joined: Wed Jul 13, 2005 12:25 am
-
- Posts: 83
- Joined: Wed Jul 13, 2005 12:25 am
Sorry for the double post, but I did some more messing around with all of this:
The open flags on the ps2(in io_common.h) start at 0x0001 for read, 0x0002 for write, and 0x0003 for read/write(which means read/write is the same as O_RDONLY | O_WRONLY). On my linux computer, read is 0x0000, write is 0x0001, and read/write is 0x0002. Trying to open a file over host as read/write results in the file being opened write only. So my initial assumption that O_TRUNC was to blame, were quite off.
What is the proper way to handle this(if there is one)? And I guess I should wonder why the open flags are 1 off of what seems to be the standard on the ps2?
The open flags on the ps2(in io_common.h) start at 0x0001 for read, 0x0002 for write, and 0x0003 for read/write(which means read/write is the same as O_RDONLY | O_WRONLY). On my linux computer, read is 0x0000, write is 0x0001, and read/write is 0x0002. Trying to open a file over host as read/write results in the file being opened write only. So my initial assumption that O_TRUNC was to blame, were quite off.
What is the proper way to handle this(if there is one)? And I guess I should wonder why the open flags are 1 off of what seems to be the standard on the ps2?
I don't see anything weird in using OR functions to combine separate bit flags. The only problem here is that Linux apparently doesn't use any bit flags at all, but instead uses an arbitrary constant for each 'type' of opening. So in Linux the entire method of combining bit flags for this purpose becomes unusable, and you must instead remember to use each valid type constant.ooPo wrote:Blame Sony for the weird numbering, otherwise they wouldn't have needed to be fixed in the first place.
Neither method is more nor less weird than the other, and if you're just aware of which platform you're coding for, there should be no major problem adapting to it. The only problem is to write some generic code that will work on either platform. This may best be dealt with by some preprocessor '#ifdef' clauses identifying the platform type.
Best regards: dlanor