Fork me on GitHub

root/kernel/syscalls/fsync.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sys_fsync

   1 /*
   2  * fiwix/kernel/syscalls/fsync.c
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #include <fiwix/fs.h>
   9 #include <fiwix/filesystems.h>
  10 #include <fiwix/process.h>
  11 #include <fiwix/stat.h>
  12 #include <fiwix/buffer.h>
  13 #include <fiwix/errno.h>
  14 
  15 #ifdef __DEBUG__
  16 #include <fiwix/stdio.h>
  17 #endif /*__DEBUG__ */
  18 
  19 int sys_fsync(int ufd)
  20 {
  21         struct inode *i;
  22 
  23 #ifdef __DEBUG__
  24         printk("(pid %d) sys_fsync(%d)\n", current->pid, ufd);
  25 #endif /*__DEBUG__ */
  26 
  27         CHECK_UFD(ufd);
  28         i = fd_table[current->fd[ufd]].inode;
  29         if(!S_ISREG(i->i_mode)) {
  30                 return -EINVAL;
  31         }
  32         if(IS_RDONLY_FS(i)) {
  33                 return -EROFS;
  34         }
  35         sync_superblocks(i->dev);
  36         sync_inodes(i->dev);
  37         sync_buffers(i->dev);
  38         return 0;
  39 }

/* [previous][next][first][last][top][bottom][index][help] */