Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memfile stuff #561

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

Memfile stuff #561

wants to merge 30 commits into from

Commits on Oct 31, 2023

  1. Use errors.Is

    This correctly handles wrapped errors as well.
    Zeph / Liz Loss-Cutler-Hull committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    b9d7f36 View commit details
    Browse the repository at this point in the history
  2. Start tracking the file mode.

    Zeph / Liz Loss-Cutler-Hull committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    8513fed View commit details
    Browse the repository at this point in the history
  3. Move memfile's Setstat function, add features.

    This makes it possible for memfile to handle mode changes, ctime
    changes, in addition to the already existing file size changes.
    Zeph / Liz Loss-Cutler-Hull committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    07a6b6a View commit details
    Browse the repository at this point in the history
  4. Make a new interface for direct SetStat access.

    I'm really not especially happy with this.
    
    It works, it's minimally invasive, and it feels like the wrong solution.
    
    I'm pretty sure that the right solution is a breaking change of the
    Request structure, to just flat out contain FileAttrFlags and FileStat,
    having requestFromPacket do the parsing into those structures.
    
    But that's an API change, and I doubt that we want a major version bump
    for this.
    
    As an alternative, we could have a new Request structure type, with that
    layout, and have public functions for converting between them.
    
    That would at least make it possible for someone to construct the
    Request structure for a Setstat command.
    
    The use case of this is being able to populate a memfile backed sftp
    server with test data that has specific timestamps, as part of the test
    framework of an internal program.
    
    I'm definitely open to other ideas on how to solve this problem.
    Zeph / Liz Loss-Cutler-Hull committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    7bf7a25 View commit details
    Browse the repository at this point in the history
  5. Add SetAttributes as an alternate option.

    This would replace the SetStat public function from the last commit.
    
    Instead, this makes it practical to construct a Setstat request.
    
    From some quick testing, this appears to do the job correctly, and it
    feels like a lot less of hack.
    
    It still doesn't feel entirely right, but it's closer.
    Zeph / Liz Loss-Cutler-Hull committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    6b2b978 View commit details
    Browse the repository at this point in the history

Commits on Nov 1, 2023

  1. Rip out SetAttributes.

    This is in favor of an alternate approach, we can always pull it back
    out of git history if we want to.
    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    688c055 View commit details
    Browse the repository at this point in the history
  2. Get rid of FileStatSetter.

    It will be replaced with an alternate method.
    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    a0a4a52 View commit details
    Browse the repository at this point in the history
  3. Use errors.Is everywhere.

    This should cover every single case where we were using == or != on an
    err.
    
    There may be other cases to address, but this covers a big one.
    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    8ee6563 View commit details
    Browse the repository at this point in the history
  4. Merge SetStat back into Filecmd.

    With us no longer offering an interface with SetStat, there is no reason
    for this to be it's own function anymore.
    
    This also cleaned up how we handle truncation errors.
    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    f215740 View commit details
    Browse the repository at this point in the history
  5. Export ToFileMode and FromFileMode.

    For the sake of sanity, we really should be offering _some_ way for
    users of memfile to get the file mode right.  These two are what we use
    internally, so they make perfect sense to expose.
    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    d41c7d4 View commit details
    Browse the repository at this point in the history
  6. Silence a linter warning.

    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    87fa218 View commit details
    Browse the repository at this point in the history
  7. memfile: Check file permissions.

    We now check to ensure that the permissions on a given file allow the
    user to perform the requested operation.
    
    For Filereader, the file must be readable.
    
    For Filewriter, the file must be writable.
    
    For OpenFile, the file must be readable and writable.
    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    a5d4316 View commit details
    Browse the repository at this point in the history
  8. Add some comments.

    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    4404cc8 View commit details
    Browse the repository at this point in the history
  9. Explictly forbid changing the mode of a symlink.

    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    656a9db View commit details
    Browse the repository at this point in the history
  10. Expose To/FromFileMode for plan9.

    Missed this in the first pass.
    Zeph / Liz Loss-Cutler-Hull committed Nov 1, 2023
    Configuration menu
    Copy the full SHA
    b1d53f7 View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2023

  1. Add FileStat.MarshalTo and FAF.ForRequest.

    FileStat.MarshalTo takes in flags, and generates the []byte that goes into
    Request.Attr
    
    FileAttrFlags.ForRequest() generates the uint32 bitmap that goes into
    Request.Flags
    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    cbf7fcd View commit details
    Browse the repository at this point in the history
  2. Don't put the flags in the attrs.

    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    4b73c93 View commit details
    Browse the repository at this point in the history
  3. FileOpenFlags.ForRequest

    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    82cd5ca View commit details
    Browse the repository at this point in the history
  4. Revert "Expose To/FromFileMode for plan9."

    This reverts commit b1d53f7.
    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    5fd4ff4 View commit details
    Browse the repository at this point in the history
  5. Revert "Export ToFileMode and FromFileMode."

    This reverts commit d41c7d4.
    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    660c973 View commit details
    Browse the repository at this point in the history
  6. Revert "Use errors.Is everywhere."

    This reverts commit 8ee6563.
    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    6c452cc View commit details
    Browse the repository at this point in the history
  7. Revert "Silence a linter warning."

    This reverts commit 87fa218.
    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    6563249 View commit details
    Browse the repository at this point in the history
  8. Comment fixes.

    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    ad0d7df View commit details
    Browse the repository at this point in the history
  9. Let Setstat follow symlinks, and rework comments.

    As best as I can tell, under POSIX chmod will follow symlinks.
    
    However I am definitely not sure if that is the case for common sftp
    servers on POSIX filesystems, we should consider checking...  Some day.
    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    7e1a518 View commit details
    Browse the repository at this point in the history
  10. Shadow err to avoid the value leaking.

    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    d3a55c7 View commit details
    Browse the repository at this point in the history
  11. Move the chmod logic to it's own method.

    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    bff300b View commit details
    Browse the repository at this point in the history
  12. Make marshalFileInfo use fileStat.MarshalTo

    This avoids logic duplication.
    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    1d040d6 View commit details
    Browse the repository at this point in the history
  13. Use 3 digit modes, not 4.

    That is, 0oNNN instead of 0oNNNN, this is because we don't have any
    current cases where we're using the 4th digit, and so things turned into
    0o0200.
    Zeph / Liz Loss-Cutler-Hull committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    706f4f1 View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2023

  1. MarshalTo now takes a []byte argument.

    Zeph / Liz Loss-Cutler-Hull committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    1ae2738 View commit details
    Browse the repository at this point in the history
  2. Add warning comments around the Extended logic.

    Zeph / Liz Loss-Cutler-Hull committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    3d7324a View commit details
    Browse the repository at this point in the history