Giter VIP home page Giter VIP logo

Comments (4)

cactusbento avatar cactusbento commented on May 31, 2024

I took a cursory look through some man pages for access(2) and found that OpenBSD and man7 lists EPERM as possible errors. Debian and Arch Linux don't list EPERM.

In both OpenBSD and man7, EPERM is related to the immutable flag of a file (set by chflags or ioctl_iflags).

Maybe error.FileImmutable should be added to os.AccessError. Although, since EPERM is a permission error, error.PermissionDenied could be sufficient.

from zig.

mrschyte avatar mrschyte commented on May 31, 2024

Adding error.FileImmutable seems like a sensible approach if nothing else can trigger the EPERM errno. Looking at the linux kernel sources, this seems to be the case.

The do_faccessat function invokes inode_permission which returns the permission error
https://github.com/torvalds/linux/blob/90d35da658da8cff0d4ecbb5113f5fac9d00eb72/fs/open.c#L504C8-L504C24

https://github.com/torvalds/linux/blob/90d35da658da8cff0d4ecbb5113f5fac9d00eb72/fs/namei.c#L517

Maybe we could check where else inode_permission is called from to discover other places where a FileImmutable error should be returned.

from zig.

garrisonhh avatar garrisonhh commented on May 31, 2024

AccessError.PermissionDenied corresponds to EACCESS:

EACCES The requested access would be denied to the file, or
search permission is denied for one of the directories in
the path prefix of pathname. (See also
path_resolution(7).

I think this is distinct enough from the semantics of EPERM to demand a separate error

from zig.

garrisonhh avatar garrisonhh commented on May 31, 2024

Actually, looking at functions like mmap, EACCES corresponds to MMapError.AccessDenied while EPERM corresponds to MMAPError.PermissionDenied. It would be more consistent to make AccessError match the set precedent

from zig.

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.