Fork me on GitHub

root/kernel/syscalls/fstat.c

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

DEFINITIONS

This source file includes following definitions.
  1. sys_fstat

   1 /*
   2  * fiwix/kernel/syscalls/fstat.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/syscalls.h>
  10 #include <fiwix/statbuf.h>
  11 #include <fiwix/errno.h>
  12 
  13 #ifdef __DEBUG__
  14 #include <fiwix/stdio.h>
  15 #include <fiwix/process.h>
  16 #endif /*__DEBUG__ */
  17 
  18 int sys_fstat(unsigned int ufd, struct old_stat *statbuf)
  19 {
  20         struct inode *i;
  21         int errno;
  22 
  23 #ifdef __DEBUG__
  24         printk("(pid %d) sys_fstat(%d, 0x%08x) -> returning structure\n", current->pid, ufd, (unsigned int )statbuf);
  25 #endif /*__DEBUG__ */
  26 
  27         CHECK_UFD(ufd);
  28         if((errno = check_user_area(VERIFY_WRITE, statbuf, sizeof(struct old_stat)))) {
  29                 return errno;
  30         }
  31         i = fd_table[current->fd[ufd]].inode;
  32         statbuf->st_dev = i->dev;
  33         statbuf->st_ino = i->inode;
  34         statbuf->st_mode = i->i_mode;
  35         statbuf->st_nlink = i->i_nlink;
  36         statbuf->st_uid = i->i_uid;
  37         statbuf->st_gid = i->i_gid;
  38         statbuf->st_rdev = i->rdev;
  39         statbuf->st_size = i->i_size;
  40         statbuf->st_atime = i->i_atime;
  41         statbuf->st_mtime = i->i_mtime;
  42         statbuf->st_ctime = i->i_ctime;
  43         return 0;
  44 }

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