GithubHelp home page GithubHelp logo

Comments (2)

CPestka avatar CPestka commented on August 11, 2024

Think I found the issue.

From the kernel, in open.c line 1255:

/* Now handle the creative implementation of O_TMPFILE. */
	    if (flags & __O_TMPFILE) {
	    /*
	     * In order to ensure programs get explicit errors when trying
	     * to use O_TMPFILE on old kernels we enforce that O_DIRECTORY
	     * is raised alongside __O_TMPFILE.
	     */
	    if (!(flags & O_DIRECTORY))
	  	    return -EINVAL;
	    if (!(acc_mode & MAY_WRITE))
		    return -EINVAL;
            }

Adding .DIRECTORY = true to the flags indeed "solves" the problem, as that makes the call succeed.

I'm not sure what the "correct" behavior of zig should be in this case. The documentation of open(3) does not say that O_DIRECTORY should be supplied when O_TMPFILE is supplied and the c++ version apparently silently adds the flag, as it works without it. The options I guess would be to either also silently add that flag if the TMPFILE flag is set or to return an error if it is set, but missing the DIRECTORY flag.

from zig.

CPestka avatar CPestka commented on August 11, 2024

Btw. I think that there might be two more cases that also would result in .INVAL being returned and thus crash.

  1. .TMPFILE=true and .ACCMODE= .RDONLY
  2. .DIRECT and missing fs support

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.