File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -497,8 +497,33 @@ func symlink(from, to *byte) int32 {
497
497
//
498
498
//go:export fsync
499
499
func fsync (fd int32 ) int32 {
500
- return 0
500
+ if _ , ok := wasiStreams [fd ]; ok {
501
+ // can't sync a stream
502
+ libcErrno = EBADF
503
+ return - 1
504
+ }
501
505
506
+ streams , ok := wasiFiles [fd ]
507
+ if ! ok {
508
+ libcErrno = EBADF
509
+ return - 1
510
+ }
511
+ if streams .d == cm .ResourceNone {
512
+ libcErrno = EBADF
513
+ return - 1
514
+ }
515
+ if streams .oflag & O_WRONLY == 0 {
516
+ libcErrno = EBADF
517
+ return - 1
518
+ }
519
+
520
+ result := streams .d .SyncData ()
521
+ if err := result .Err (); err != nil {
522
+ libcErrno = errorCodeToErrno (* err )
523
+ return - 1
524
+ }
525
+
526
+ return 0
502
527
}
503
528
504
529
// ssize_t readlink(const char *path, void *buf, size_t count);
You can’t perform that action at this time.
0 commit comments