Fork me on GitHub

root/kernel/syscalls/lstat.c

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

DEFINITIONS

This source file includes following definitions.
  1. sys_lstat

   1 /*
   2  * fiwix/kernel/syscalls/lstat.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/stat.h>
  10 #include <fiwix/string.h>
  11 
  12 #ifdef __DEBUG__
  13 #include <fiwix/stdio.h>
  14 #include <fiwix/process.h>
  15 #endif /*__DEBUG__ */
  16 
  17 int sys_lstat(const char *filename, struct old_stat *statbuf)
  18 {
  19         struct inode *i;
  20         char *tmp_name;
  21         int errno;
  22 
  23 #ifdef __DEBUG__
  24         printk("(pid %d) sys_lstat('%s', 0x%08x) -> returning structure\n", current->pid, filename, (unsigned int )statbuf);
  25 #endif /*__DEBUG__ */
  26 
  27         if((errno = check_user_area(VERIFY_WRITE, statbuf, sizeof(struct old_stat)))) {
  28                 return errno;
  29         }
  30         if((errno = malloc_name(filename, &tmp_name)) < 0) {
  31                 return errno;
  32         }
  33         if((errno = namei(tmp_name, &i, NULL, !FOLLOW_LINKS))) {
  34                 free_name(tmp_name);
  35                 return errno;
  36         }
  37         statbuf->st_dev = i->dev;
  38         statbuf->st_ino = i->inode;
  39         statbuf->st_mode = i->i_mode;
  40         statbuf->st_nlink = i->i_nlink;
  41         statbuf->st_uid = i->i_uid;
  42         statbuf->st_gid = i->i_gid;
  43         statbuf->st_rdev = i->rdev;
  44         statbuf->st_size = i->i_size;
  45         statbuf->st_atime = i->i_atime;
  46         statbuf->st_mtime = i->i_mtime;
  47         statbuf->st_ctime = i->i_ctime;
  48         iput(i);
  49         free_name(tmp_name);
  50         return 0;
  51 }

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