@@ -1519,21 +1519,20 @@ static void Fdatasync(const FunctionCallbackInfo<Value>& args) {
15191519 Environment* env = Environment::GetCurrent (args);
15201520
15211521 const int argc = args.Length ();
1522- CHECK_GE (argc, 2 );
1523-
1524- CHECK (args[0 ]->IsInt32 ());
1525- const int fd = args[0 ].As <Int32>()->Value ();
1522+ CHECK_GE (argc, 1 );
15261523
1527- FSReqBase* req_wrap_async = GetReqWrap (args, 1 );
1528- if (req_wrap_async != nullptr ) {
1524+ const int fd = GetValidatedFd (env,args[0 ]);
1525+
1526+ if (argc > 1 ) { // fdatasync(fd, req)
1527+ FSReqBase* req_wrap_async = GetReqWrap (args, 1 );
1528+ CHECK_NOT_NULL (req_wrap_async);
15291529 FS_ASYNC_TRACE_BEGIN0 (UV_FS_FDATASYNC, req_wrap_async)
15301530 AsyncCall (env, req_wrap_async, args, " fdatasync" , UTF8, AfterNoArgs,
15311531 uv_fs_fdatasync, fd);
1532- } else {
1533- CHECK_EQ (argc, 3 );
1534- FSReqWrapSync req_wrap_sync;
1532+ } else { // fdatasync(fd)
1533+ FSReqWrapSync req_wrap_sync (" fdatasync" );
15351534 FS_SYNC_TRACE_BEGIN (fdatasync);
1536- SyncCall (env, args[ 2 ], &req_wrap_sync, " fdatasync " , uv_fs_fdatasync, fd);
1535+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_fdatasync, fd);
15371536 FS_SYNC_TRACE_END (fdatasync);
15381537 }
15391538}
@@ -3254,7 +3253,6 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
32543253 SetMethod (isolate, target, " readFileUtf8" , ReadFileUtf8);
32553254 SetMethod (isolate, target, " readBuffers" , ReadBuffers);
32563255 SetMethod (isolate, target, " fdatasync" , Fdatasync);
3257- SetMethod (isolate, target, " fdatasyncSync" , FdatasyncSync);
32583256 SetMethod (isolate, target, " fsync" , Fsync);
32593257 SetMethod (isolate, target, " rename" , Rename);
32603258 SetMethod (isolate, target, " ftruncate" , FTruncate);
0 commit comments