Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/misc/far2l/files/patch-far2l_src_farwinapi.cpp
50018 views
1
--- far2l/src/farwinapi.cpp.orig 2025-10-26 08:39:52 UTC
2
+++ far2l/src/farwinapi.cpp
3
@@ -38,6 +38,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF S
4
#include <fcntl.h>
5
#include <errno.h>
6
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__CYGWIN__)
7
+#include <sys/disk.h>
8
#include <sys/mount.h>
9
#elif !defined(__HAIKU__)
10
#include <sys/statfs.h>
11
@@ -472,8 +473,8 @@ bool apiExpandEnvironmentStrings(const wchar_t *src, F
12
}
13
14
BOOL apiGetVolumeInformation(const wchar_t *lpwszRootPathName, FARString *pVolumeName,
15
- DWORD64 *lpVolumeSerialNumber, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags,
16
- FARString *pFileSystemName, FARString *pFileSystemMountPoint)
17
+ FARString *pDiskIdent, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags,
18
+ FARString *pFileSystemName, FARString *pDeviceName, FARString *pFileSystemMountPoint)
19
{
20
struct statvfs svfs {};
21
const std::string &path = Wide2MB(lpwszRootPathName);
22
@@ -483,13 +484,9 @@ BOOL apiGetVolumeInformation(const wchar_t *lpwszRootP
23
24
if (lpMaximumComponentLength)
25
*lpMaximumComponentLength = svfs.f_namemax;
26
- if (lpVolumeSerialNumber)
27
- *lpVolumeSerialNumber = (DWORD)svfs.f_fsid;
28
if (lpFileSystemFlags)
29
*lpFileSystemFlags = (DWORD)svfs.f_flag;
30
31
- if (pVolumeName) {
32
- pVolumeName->Clear();
33
#if 0
34
#if defined(FS_IOC_GETFSLABEL) && defined(FSLABEL_MAX)
35
int fd = open(path.c_str(), O_RDONLY);
36
@@ -502,13 +499,35 @@ BOOL apiGetVolumeInformation(const wchar_t *lpwszRootP
37
}
38
#endif
39
#endif
40
- }
41
42
if (pFileSystemName) {
43
*pFileSystemName = MountInfo().GetFileSystem(path);
44
}
45
- if (*pFileSystemMountPoint) {
46
+ if (pFileSystemMountPoint) {
47
*pFileSystemMountPoint = MountInfo().GetFileSystemMountPoint(lpwszRootPathName);
48
+ }
49
+ // XXX: can we avoid calling GetFileSystemMountPoint() twice?
50
+ const std::string devname = MountInfo().GetFileSystemMountPoint(lpwszRootPathName, true);
51
+ if (pDeviceName) {
52
+ *pDeviceName = devname;
53
+ }
54
+ if (pDiskIdent) {
55
+ int fd = open(devname.c_str(), O_RDONLY);
56
+ if (fd != -1) {
57
+ char ident[DISK_IDENT_SIZE];
58
+ if (ioctl(fd, DIOCGIDENT, ident) != -1)
59
+ *pDiskIdent = ident;
60
+ close(fd);
61
+ }
62
+ }
63
+ if (pVolumeName) {
64
+ std::string reply{}, cmd{"fstyp -l " + devname};
65
+ if (POpen(reply, cmd.c_str())) {
66
+ const auto pos = reply.find(' ') + 1;
67
+ if (pos > 0) {
68
+ *pVolumeName = reply.substr(pos, reply.size() - pos - 1);
69
+ } //else pVolumeName->Clear();
70
+ } //else pVolumeName->Clear();
71
}
72
73
return TRUE;
74
75