1 | /* |
---|
2 | This file is part of MutekP. |
---|
3 | |
---|
4 | MutekP is free software; you can redistribute it and/or modify it |
---|
5 | under the terms of the GNU General Public License as published by |
---|
6 | the Free Software Foundation; either version 2 of the License, or |
---|
7 | (at your option) any later version. |
---|
8 | |
---|
9 | MutekP is distributed in the hope that it will be useful, but |
---|
10 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | General Public License for more details. |
---|
13 | |
---|
14 | You should have received a copy of the GNU General Public License |
---|
15 | along with MutekP; if not, write to the Free Software Foundation, |
---|
16 | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
17 | |
---|
18 | UPMC / LIP6 / SOC (c) 2008 |
---|
19 | Copyright Ghassan Almaless <ghassan.almaless@gmail.com> |
---|
20 | */ |
---|
21 | |
---|
22 | #include <errno.h> |
---|
23 | #include <sys/types.h> |
---|
24 | #include <sys/syscall.h> |
---|
25 | #include <cpu-syscall.h> |
---|
26 | #include <dirent.h> |
---|
27 | #include <string.h> |
---|
28 | #include <limits.h> |
---|
29 | |
---|
30 | struct vfs_dirent_s |
---|
31 | { |
---|
32 | uint32_t d_ino; |
---|
33 | uint32_t d_type; |
---|
34 | uint8_t d_name[NAME_MAX]; |
---|
35 | }; |
---|
36 | |
---|
37 | struct dirent *readdir(DIR *dir) |
---|
38 | { |
---|
39 | int retval; |
---|
40 | struct vfs_dirent_s dirent; |
---|
41 | |
---|
42 | if(dir == NULL) |
---|
43 | return NULL; |
---|
44 | |
---|
45 | retval = (int) cpu_syscall((void*)(dir->fd),(void*)&dirent,NULL,NULL,SYS_READDIR); |
---|
46 | |
---|
47 | if(retval != 0) |
---|
48 | return NULL; |
---|
49 | |
---|
50 | dir->entry.d_ino = dirent.d_ino; |
---|
51 | dir->entry.d_type = dirent.d_type; |
---|
52 | //dir->entry.d_size = dirent.d_size; |
---|
53 | strcpy(dir->entry.d_name, (char*)dirent.d_name); |
---|
54 | |
---|
55 | return &dir->entry; |
---|
56 | } |
---|