Git Product home page Git Product logo

Comments (18)

sp193 avatar sp193 commented on June 30, 2024 2

Regarding your other comment in the code about why alignment doesn't work without the static keyword, it's because alignment on the stack (as a local variable) is impossible to guarantee.

from ps2sdk.

sp193 avatar sp193 commented on June 30, 2024 1

Yes. We may always have done that over the many years, so POSIX'fication of the PS2SDK just made this problem more visible. libmc in this project is an EE library.

The original documentation from Sony did not specify the standard flags, but it became the standard flags in the homebrew SDK.

from ps2sdk.

TheAwesome98-Real avatar TheAwesome98-Real commented on June 30, 2024

What file are you trying to read?

from ps2sdk.

faissaloo avatar faissaloo commented on June 30, 2024

I was basically traversing the tree and trying to read anything that wasn't a directory, didn't really matter which file I tried reading. Don't have the code anymore tho.

from ps2sdk.

sp193 avatar sp193 commented on June 30, 2024

sceMcResDeniedPermit is defined in the Sony documentation, as an error which sceMcSync() returns. Its definition seems to defer, depending on what function you called.
For example:

  • If sceMcRead() was called: file was not opened with read privileges or a PS memory card is inserted.
  • If sceMcDelete() was called: the file is in use or is read-only, or a PS memory card is inserted.
  • If sceMcOpen() was called: the file was already opened with write priviledges and cannot be opened with write priviledges, the file has neither read nor write permissions, or a PS memory card is inserted.

from ps2sdk.

faissaloo avatar faissaloo commented on June 30, 2024

I hadn't opened the file before unless walking the directory or getting memory card info inadvertently opens the file or something weird like that. When I opened it I definitely opened it with read perms using O_RDONLY and it was a PS2 memory card.
Also I just realised that I actually still have the project, here's the zip: https://files.catbox.moe/rn47bc.zip

from ps2sdk.

sp193 avatar sp193 commented on June 30, 2024

Was this built with Newlib? What's the value of O_RDONLY? Is it still 1?
If it's no longer 1, then that may be why.

from ps2sdk.

faissaloo avatar faissaloo commented on June 30, 2024

@sp193 I don't really understand what Newlib is tbh, I just built it with the standard toolchain

from ps2sdk.

AKuHAK avatar AKuHAK commented on June 30, 2024

@sp193 I don't really understand what Newlib is tbh, I just built it with the standard toolchain

Newlib was introduced in toolchain version 1.1, version 1.0 is the latest before that changes, however, I am not quite sure how newlib invention can affect that problem.

from ps2sdk.

sp193 avatar sp193 commented on June 30, 2024

He passes O_RDONLY to sceMcOpen(). If this is not equal to 1 (it was equal to 1, with the classic libc), then this operation may not work.

from ps2sdk.

faissaloo avatar faissaloo commented on June 30, 2024

He passes O_RDONLY to sceMcOpen(). If this is not equal to 1 (it was equal to 1, with the classic libc), then this operation may not work.

Yeah you're right, I just tried printing the O_RDONLY and it gives me 0

from ps2sdk.

fjtrujy avatar fjtrujy commented on June 30, 2024

Hello guys,
Sorry for the late reply.
@faissaloo I think that you're mixing things.

As you know we fully integrated newlib in the past, making our toolchain more portable and standard.
Here watching your code I see you're mixing concepts, for instance:

mcOpen(0,0, currently_copying->fullpath, O_RDONLY);

You're using mcOpen which is a NON POSIX function, and using here the O_RDONLY flag.

If you want to use these specific mcOpen, mcRead functions you need to use the IOP specific flags for it.

However the main reason why we implemented newlib was to make the developer life easier, now you can use normal, open, read functions using the standard POSIX flags as O_RDONLY.

int main()
{
    int filedesc = open("mc0:/testfile.txt", O_WRONLY);
    if(filedesc < 0)
        return 1;
 
    return 0;
}

You can take a look to this file, to understand how it works.
https://github.com/ps2dev/ps2sdk/blob/master/ee/libc/src/ps2sdkapi.c

Thanks

from ps2sdk.

fjtrujy avatar fjtrujy commented on June 30, 2024

Was this built with Newlib? What's the value of O_RDONLY? Is it still 1?
If it's no longer 1, then that may be why.

Hello @sp193,
If you take a look to my previous response, I think that he was mixing internal ps2 functions for open/read/close file with POSIX flags from newlib.

Thanks

from ps2sdk.

faissaloo avatar faissaloo commented on June 30, 2024

@fjtrujy For this program I'd like to avoid using the POSIX functions since they're blocking and EE threads can't seem to use IO. What should I be #includeing to use those IOP_ values in my program? Or do I have to just copy them into my program manually?

from ps2sdk.

fjtrujy avatar fjtrujy commented on June 30, 2024

@fjtrujy For this program I'd like to avoid using the POSIX functions since they're blocking and EE threads can't seem to use IO. Thanks I'll take a look at the ps2sdkapi file you linked.

As I said before here you can the conversion done (IOP_O_RDONLY):
https://github.com/ps2dev/ps2sdk/blob/master/ee/libc/src/ps2sdkapi.c#L218-L225

Thanks

from ps2sdk.

rickgaiser avatar rickgaiser commented on June 30, 2024

Perhaps we need to expose these in a header?

#define IOP_O_RDONLY 0x0001
#define IOP_O_WRONLY 0x0002
#define IOP_O_RDWR 0x0003
#define IOP_O_DIROPEN 0x0008 // Internal use for dopen
#define IOP_O_NBLOCK 0x0010
#define IOP_O_APPEND 0x0100
#define IOP_O_CREAT 0x0200
#define IOP_O_TRUNC 0x0400
#define IOP_O_EXCL 0x0800
#define IOP_O_NOWAIT 0x8000

So functions like mcOpen can be used with IOP flags.

Or we make it dummy proof, and convert the flags in mcOpen, just like we do in open? Then we don't have 2 sets of flags, and no confusion.

// newlib frags differ from iop flags
if ((flags & 3) == O_RDONLY) iop_flags |= IOP_O_RDONLY;
if ((flags & 3) == O_WRONLY) iop_flags |= IOP_O_WRONLY;
if ((flags & 3) == O_RDWR ) iop_flags |= IOP_O_RDWR;
if (flags & O_NONBLOCK) iop_flags |= IOP_O_NBLOCK;
if (flags & O_APPEND) iop_flags |= IOP_O_APPEND;
if (flags & O_CREAT) iop_flags |= IOP_O_CREAT;
if (flags & O_TRUNC) iop_flags |= IOP_O_TRUNC;
if (flags & O_EXCL) iop_flags |= IOP_O_EXCL;

I wasn't aware of other functions using these flags. Are there more functions like this on the EE that use IOP flags?

from ps2sdk.

sp193 avatar sp193 commented on June 30, 2024

The only RPC libraries that use these flags are:

  • fileio (fileXio and fileio in the homebrew SDK).
  • libmc

Given that they were originally prefixed with "sce" and Sony never described them to be POSIX-compliant, I think giving them separate definitions from the standard POSIX flag bits is also a suitable approach.
Conversion is a possibility, but we may end up mixing the POSIX flags with non-standard Sony flags. For example, sceOpen() was designed to allow SCE_CdSTREAM to be passed, to open a file for streaming. It's a part of the original design, even if it's not used in the homebrew world.

from ps2sdk.

uyjulian avatar uyjulian commented on June 30, 2024

This doesn't seem to be an issue anymore. Reopen if this is not the case

from ps2sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.