Skip to content

Can't fsync on Windows 8 #3879

Closed
Closed

Description

@louischatriot

Hi,

Running the code snippet below yields an EPERM: operation not permitted, fsync on my Windowws 8 machine:

var fs = require('fs');

var file = 'yam.js';   // Whatever existing file you choose

fs.open(file, 'r', function (err, fd) {
  console.log(err);    // Outputs null

  fs.fsync(fd, function (err) {
    console.log(err);   // Outputs 'EPERM: operation not permitted, fsync'
  });
})

I tried running this script from a cmd.exe and a Git Bash run as administrator to no avail, and couldn't find data on this on the internet and this repo's issues (not one mentions fsync!). Is it a known limitation in Windows?

Activity

  1. JungMinu commented on Nov 17, 2015

    @JungMinu
    Member

    @louischatriot It worked for me after disabling Anti-Virus software, would you try this?

  2. louischatriot commented on Nov 17, 2015

    @louischatriot
    Author

    Thanks for your reply. I still get the issue after disabling Windows Defender, the only anti virus I have. Did it fail for you before disabling anti virus then work ?

  3. saghul commented on Nov 17, 2015

    @saghul
    Member

    @louischatriot fsync caused the write buffers to be flushed and data to be written to the file, but you opened it in readonly mode AFAIS, so you have no permission to write to it.

  4. louischatriot commented on Nov 17, 2015

    @louischatriot
    Author

    @saghul indeed, when I change the flag to 'w' there is no complain anymore, thanks for pointing that out. That said fsync after having opened the file with the 'r' flag worked fine in Linux and OS X. Is that a difference between OSes, or is the 'r' flag a mistake in all OSes and it working an accident?

  5. added
    fsIssues and PRs related to file-system APIs and the fs module.
    on Nov 17, 2015
  6. saghul commented on Nov 17, 2015

    @saghul
    Member

    I'd say this is just OS differences. I guess OSX and Linux don't give an error, because there is nothing to sync.

    In this particular case, I consider using 'r' a mistake, since the file is not writable, so if you attempted to write to it and then flush, you'd get an error for the write.

    That said, and since there is nothing actionable IMHO, I move for closing this issue.

  7. bnoordhuis commented on Nov 17, 2015

    @bnoordhuis
    Member

    fsync() flushes the metadata on Unices, the access time in particular, and that's also updated when the file is opened in read-only mode.

    I'll close the issue.

  8. louischatriot commented on Nov 17, 2015

    @louischatriot
    Author

    Thanks for your it makes perfect sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to file-system APIs and the fs module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions