1 | /* |
---|
2 | * COPYRIGHT (c) 2009 Chris Johns <chrisj@rtems.org> |
---|
3 | * |
---|
4 | * The license and distribution terms for this file may be |
---|
5 | * found in the file LICENSE in this distribution or at |
---|
6 | * http://www.rtems.com/license/LICENSE. |
---|
7 | * |
---|
8 | * $Id$ |
---|
9 | */ |
---|
10 | /* |
---|
11 | * The statvfs as defined by the SUS: |
---|
12 | * http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/statvfs.h.html |
---|
13 | */ |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems/libio_.h> |
---|
20 | #include <rtems/seterr.h> |
---|
21 | |
---|
22 | #include <sys/statvfs.h> |
---|
23 | |
---|
24 | /* |
---|
25 | * Data structures and routines private to mount/unmount pair. |
---|
26 | */ |
---|
27 | extern rtems_chain_control rtems_filesystem_mount_table_control; |
---|
28 | |
---|
29 | int |
---|
30 | statvfs (const char *path, struct statvfs *sb) |
---|
31 | { |
---|
32 | rtems_filesystem_location_info_t loc; |
---|
33 | rtems_filesystem_location_info_t *fs_mount_root; |
---|
34 | rtems_filesystem_mount_table_entry_t *mt_entry; |
---|
35 | int result; |
---|
36 | |
---|
37 | /* |
---|
38 | * Get |
---|
39 | * The root node of the mounted filesytem. |
---|
40 | * The node for the directory that the fileystem is mounted on. |
---|
41 | * The mount entry that is being refered to. |
---|
42 | */ |
---|
43 | |
---|
44 | if ( rtems_filesystem_evaluate_path( path, strlen( path ), 0x0, &loc, true ) ) |
---|
45 | return -1; |
---|
46 | |
---|
47 | mt_entry = loc.mt_entry; |
---|
48 | fs_mount_root = &mt_entry->mt_fs_root; |
---|
49 | |
---|
50 | if ( !fs_mount_root->ops->statvfs_h ) |
---|
51 | rtems_set_errno_and_return_minus_one( ENOTSUP ); |
---|
52 | |
---|
53 | memset (sb, 0, sizeof (struct statvfs)); |
---|
54 | |
---|
55 | result = ( fs_mount_root->ops->statvfs_h )( fs_mount_root, sb ); |
---|
56 | |
---|
57 | rtems_filesystem_freenode( &loc ); |
---|
58 | |
---|
59 | return result; |
---|
60 | } |
---|