1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
--- mpeg3io.c.orig 2001-05-20 05:05:26.000000000 +0200
+++ mpeg3io.c 2005-06-08 00:54:51.000000000 +0200
@@ -1,11 +1,20 @@
#include "mpeg3private.h"
#include "mpeg3protos.h"
-#include <mntent.h>
-#include <sys/stat.h>
+#include <sys/param.h>
+#include <sys/mount.h>
#include <stdlib.h>
#include <string.h>
+#ifdef __NetBSD__
+# if __NetBSD_Version__ >= 200040000 /* 2.0D */
+# define statfs statvfs
+# endif
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
mpeg3_fs_t* mpeg3_new_fs(char *path)
{
mpeg3_fs_t *fs = calloc(1, sizeof(mpeg3_fs_t));
@@ -88,27 +97,15 @@
int mpeg3io_device(char *path, char *device)
{
- struct stat file_st, device_st;
- struct mntent *mnt;
- FILE *fp;
+ struct statfs file_st;
- if(stat(path, &file_st) < 0)
+ if(statfs(path, &file_st) < 0)
{
perror("mpeg3io_device");
return 1;
}
- fp = setmntent(MOUNTED, "r");
- while(fp && (mnt = getmntent(fp)))
- {
- if(stat(mnt->mnt_fsname, &device_st) < 0) continue;
- if(device_st.st_rdev == file_st.st_dev)
- {
- strncpy(device, mnt->mnt_fsname, MPEG3_STRLEN);
- break;
- }
- }
- endmntent(fp);
+ strncpy(device, file_st.f_mntfromname, MPEG3_STRLEN);
return 0;
}
|