2 Copyright © 2004-2012, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
10 #include <sys/mount.h>
11 #include <proto/dos.h>
13 #include <proto/exec.h>
16 short getnixfilesystemtype(LONG id_DiskType
)
21 case ID_FASTDIR_DOS_DISK
:
22 return MOUNT_ADOS_OFS
;
23 case ID_INTER_DOS_DISK
:
24 return MOUNT_ADOS_IOFS
;
26 case ID_FASTDIR_FFS_DISK
:
27 return MOUNT_ADOS_FFS
;
28 case ID_INTER_FFS_DISK
:
29 return MOUNT_ADOS_IFFS
;
35 /*****************************************************************************
38 #include <sys/mount.h>
48 Gets information about mounted filesystems.
51 buf - pointer to statfs structures where information about filesystems
52 will be stored or NULL
53 bufsize - size of buf in bytes
57 If buf is NULL number of mounted filesystems is returned. If buf is
58 not null, information about mounted filesystems is stored in statfs
59 structures up to bufsize bytes
66 f_flags, f_files, f_ffree and f_fsid.val are always set to 0
67 f_mntfromname is set to an empty string
73 ******************************************************************************/
77 struct DosList
*dlist
;
79 int fscount
= 0; /* number of filesystems */
82 dlist
= LockDosList(LDF_READ
| LDF_VOLUMES
);
83 while ((dlist
= NextDosEntry(dlist
, LDF_VOLUMES
)) != NULL
)
85 if(IsFileSystem(AROS_BSTR_ADDR(dlist
->dol_Name
)) == FALSE
)
89 /* If buf is NULL just count filesystems */
93 /* See if another structure can be stored */
94 bufsize
-= sizeof(struct statfs
);
101 /* Create a volume name */
102 if(!(name
= (STRPTR
) AllocVec(AROS_BSTR_strlen(dlist
->dol_Name
) + 2,
103 MEMF_CLEAR
| MEMF_ANY
)))
105 ioerr
= ERROR_NO_FREE_STORE
;
109 strcpy(name
, AROS_BSTR_ADDR(dlist
->dol_Name
));
112 /* Get filesystem data from lock */
113 if((lock
= Lock(name
, SHARED_LOCK
)))
115 if(Info(lock
, &data
))
117 /* Fill statfs structure */
118 buf
[fscount
- 1].f_type
= getnixfilesystemtype(
120 buf
[fscount
- 1].f_flags
= 0;
121 buf
[fscount
- 1].f_fsize
= data
.id_BytesPerBlock
;
122 buf
[fscount
- 1].f_bsize
= data
.id_BytesPerBlock
;
123 buf
[fscount
- 1].f_blocks
= data
.id_NumBlocks
;
124 buf
[fscount
- 1].f_bfree
= data
.id_NumBlocks
-
125 data
.id_NumBlocksUsed
;
126 buf
[fscount
- 1].f_bavail
= data
.id_NumBlocks
-
127 data
.id_NumBlocksUsed
;
128 buf
[fscount
- 1].f_files
= 0;
129 buf
[fscount
- 1].f_ffree
= 0;
130 buf
[fscount
- 1].f_fsid
.val
[0] = 0;
131 buf
[fscount
- 1].f_fsid
.val
[1] = 0;
132 strncpy(buf
[fscount
- 1].f_mntonname
, __path_a2u(name
),
134 buf
[fscount
- 1].f_mntfromname
[0] = '\0';
150 UnLockDosList(LDF_READ
| LDF_VOLUMES
);
153 errno
= __arosc_ioerr2errno(ioerr
);