Fork me on GitHub

root/kernel/syscalls/statfs.c

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

DEFINITIONS

This source file includes following definitions.
  1. sys_statfs

   1 /*
   2  * fiwix/kernel/syscalls/statfs.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/statfs.h>
  10 #include <fiwix/errno.h>
  11 #include <fiwix/string.h>
  12 
  13 #ifdef __DEBUG__
  14 #include <fiwix/stdio.h>
  15 #include <fiwix/process.h>
  16 #endif /*__DEBUG__ */
  17 
  18 int sys_statfs(const char *filename, struct statfs *statfsbuf)
  19 {
  20         struct inode *i;
  21         char *tmp_name;
  22         int errno;
  23 
  24 #ifdef __DEBUG__
  25         printk("(pid %d) sys_statfs('%s', 0x%08x)\n", current->pid, filename, (unsigned int)statfsbuf);
  26 #endif /*__DEBUG__ */
  27 
  28         if((errno = check_user_area(VERIFY_WRITE, statfsbuf, sizeof(struct statfs)))) {
  29                 return errno;
  30         }
  31         if((errno = malloc_name(filename, &tmp_name)) < 0) {
  32                 return errno;
  33         }
  34         if((errno = namei(tmp_name, &i, NULL, FOLLOW_LINKS))) {
  35                 free_name(tmp_name);
  36                 return errno;
  37         }
  38         if(i->sb && i->sb->fsop && i->sb->fsop->statfs) {
  39                 i->sb->fsop->statfs(i->sb, statfsbuf);
  40                 iput(i);
  41                 free_name(tmp_name);
  42                 return 0;
  43         }
  44         iput(i);
  45         free_name(tmp_name);
  46         return -ENOSYS;
  47 }

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