2 Copyright © 2004, 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>
17 short getnixfilesystemtype(LONG id_DiskType
)
22 case ID_FASTDIR_DOS_DISK
:
23 return MOUNT_ADOS_OFS
;
24 case ID_INTER_DOS_DISK
:
25 return MOUNT_ADOS_IOFS
;
27 case ID_FASTDIR_FFS_DISK
:
28 return MOUNT_ADOS_FFS
;
29 case ID_INTER_FFS_DISK
:
30 return MOUNT_ADOS_IFFS
;
36 /*****************************************************************************
39 #include <sys/mount.h>
49 Gets information about mounted filesystems.
52 buf - pointer to statfs structures where information about filesystems
53 will be stored or NULL
54 bufsize - size of buf in bytes
58 If buf is NULL number of mounted filesystems is returned. If buf is
59 not null, information about mounted filesystems is stored in statfs
60 structures up to bufsize bytes
67 f_flags, f_files, f_ffree and f_fsid.val are always set to 0
68 f_mntfromname is set to an empty string
74 ******************************************************************************/
78 struct DosList
*dlist
;
80 int fscount
= 0; /* number of filesystems */
83 dlist
= LockDosList(LDF_READ
| LDF_VOLUMES
);
84 while ((dlist
= NextDosEntry(dlist
, LDF_VOLUMES
)) != NULL
)
86 if(IsFileSystem(dlist
->dol_Name
) == FALSE
)
90 /* If buf is NULL just count filesystems */
94 /* See if another structure can be stored */
95 bufsize
-= sizeof(struct statfs
);
102 /* Create a volume name */
103 if(!(name
= (STRPTR
) AllocVec(strlen(dlist
->dol_Name
) + 2,
104 MEMF_CLEAR
| MEMF_ANY
)))
106 ioerr
= ERROR_NO_FREE_STORE
;
110 strcpy(name
, dlist
->dol_Name
);
113 /* Get filesystem data from lock */
114 if((lock
= Lock(name
, SHARED_LOCK
)))
116 if(Info(lock
, &data
))
118 /* Fill statfs structure */
119 buf
[fscount
- 1].f_type
= getnixfilesystemtype(
121 buf
[fscount
- 1].f_flags
= 0;
122 buf
[fscount
- 1].f_fsize
= data
.id_BytesPerBlock
;
123 buf
[fscount
- 1].f_bsize
= data
.id_BytesPerBlock
;
124 buf
[fscount
- 1].f_blocks
= data
.id_NumBlocks
;
125 buf
[fscount
- 1].f_bfree
= data
.id_NumBlocks
-
126 data
.id_NumBlocksUsed
;
127 buf
[fscount
- 1].f_bavail
= data
.id_NumBlocks
-
128 data
.id_NumBlocksUsed
;
129 buf
[fscount
- 1].f_files
= 0;
130 buf
[fscount
- 1].f_ffree
= 0;
131 buf
[fscount
- 1].f_fsid
.val
[0] = 0;
132 buf
[fscount
- 1].f_fsid
.val
[1] = 0;
133 strncpy(buf
[fscount
- 1].f_mntonname
, __path_a2u(name
),
135 buf
[fscount
- 1].f_mntfromname
[0] = '\0';
151 UnLockDosList(LDF_READ
| LDF_VOLUMES
);
154 errno
= IoErr2errno(ioerr
);