You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running the code snippet below yields an EPERM: operation not permitted, fsync on my Windowws 8 machine:
varfs=require('fs');varfile='yam.js';// Whatever existing file you choosefs.open(file,'r',function(err,fd){console.log(err);// Outputs nullfs.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?
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 ?
@louischatriotfsync 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.
@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?
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.
Activity
JungMinu commentedon Nov 17, 2015
@louischatriot It worked for me after disabling Anti-Virus software, would you try this?
louischatriot commentedon Nov 17, 2015
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 ?
saghul commentedon Nov 17, 2015
@louischatriot
fsynccaused 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.louischatriot commentedon Nov 17, 2015
@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?
saghul commentedon Nov 17, 2015
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.
bnoordhuis commentedon Nov 17, 2015
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.
louischatriot commentedon Nov 17, 2015
Thanks for your it makes perfect sense.