Date: Wed, 26 Nov 2025 15:19:52 +0000 From: Alexey Dokuchaev <danfe@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: 85b2ef443d0a - main - misc/far2l: revamp disk and memory display in the information panel Message-ID: <69271a98.2fdbd.49f65232@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by danfe: URL: https://cgit.FreeBSD.org/ports/commit/?id=85b2ef443d0ac9584fa7506cccca0eb62228c27c commit 85b2ef443d0ac9584fa7506cccca0eb62228c27c Author: Alexey Dokuchaev <danfe@FreeBSD.org> AuthorDate: 2025-11-26 15:18:18 +0000 Commit: Alexey Dokuchaev <danfe@FreeBSD.org> CommitDate: 2025-11-26 15:18:18 +0000 misc/far2l: revamp disk and memory display in the information panel - Replace Volume Serial Number obtained from `statvfs.f_fsid' field which is not meaningful on FreeBSD with GEOM::ident string - For RAM and swap numbers, employ sysinfo(3) library that provides GNU interface for gathering system information --- misc/far2l/Makefile | 4 +- misc/far2l/files/patch-far2l_CMakeLists.txt | 14 ++++++ misc/far2l/files/patch-far2l_src_farwinapi.cpp | 54 ++++++++++++++++++++++ misc/far2l/files/patch-far2l_src_farwinapi.hpp | 13 ++++++ misc/far2l/files/patch-far2l_src_mix_MountInfo.cpp | 20 ++++++++ misc/far2l/files/patch-far2l_src_mix_MountInfo.h | 11 +++++ .../files/patch-far2l_src_panels_infolist.cpp | 47 +++++++++++++++++++ 7 files changed, 162 insertions(+), 1 deletion(-) diff --git a/misc/far2l/Makefile b/misc/far2l/Makefile index 7025d0a89fd4..cc38f6e6025c 100644 --- a/misc/far2l/Makefile +++ b/misc/far2l/Makefile @@ -1,5 +1,6 @@ PORTNAME= far2l PORTVERSION= 2.7.0 +PORTREVISION= 1 DISTVERSIONPREFIX= v_ CATEGORIES= misc @@ -9,7 +10,8 @@ WWW= https://github.com/elfmz/far2l LICENSE= GPLv2 -LIB_DEPENDS= libuchardet.so:textproc/uchardet +LIB_DEPENDS= libsysinfo.so:devel/libsysinfo \ + libuchardet.so:textproc/uchardet RUN_DEPENDS= bash:shells/bash USE_GITHUB= yes diff --git a/misc/far2l/files/patch-far2l_CMakeLists.txt b/misc/far2l/files/patch-far2l_CMakeLists.txt new file mode 100644 index 000000000000..81fa1cdd83bf --- /dev/null +++ b/misc/far2l/files/patch-far2l_CMakeLists.txt @@ -0,0 +1,14 @@ +--- far2l/CMakeLists.txt.orig 2025-10-26 08:39:52 UTC ++++ far2l/CMakeLists.txt +@@ -263,9 +263,11 @@ set_target_properties(far2l + ENABLE_EXPORTS TRUE) + + if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") ++ find_library(SYSINFO_LIBRARY NAMES sysinfo) + target_link_libraries(far2l + PRIVATE ${WINPORT} + PRIVATE c ++ PRIVATE ${SYSINFO_LIBRARY} + PRIVATE ${UCHARDET_LIBRARIES}) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Haiku") + target_link_libraries(far2l diff --git a/misc/far2l/files/patch-far2l_src_farwinapi.cpp b/misc/far2l/files/patch-far2l_src_farwinapi.cpp new file mode 100644 index 000000000000..c5bc3cafab73 --- /dev/null +++ b/misc/far2l/files/patch-far2l_src_farwinapi.cpp @@ -0,0 +1,54 @@ +--- far2l/src/farwinapi.cpp.orig 2025-10-26 08:39:52 UTC ++++ far2l/src/farwinapi.cpp +@@ -38,6 +38,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF S + #include <fcntl.h> + #include <errno.h> + #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__CYGWIN__) ++#include <sys/disk.h> + #include <sys/mount.h> + #elif !defined(__HAIKU__) + #include <sys/statfs.h> +@@ -472,8 +473,8 @@ bool apiExpandEnvironmentStrings(const wchar_t *src, F + } + + BOOL apiGetVolumeInformation(const wchar_t *lpwszRootPathName, FARString *pVolumeName, +- DWORD64 *lpVolumeSerialNumber, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, +- FARString *pFileSystemName, FARString *pFileSystemMountPoint) ++ FARString *pDiskIdent, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, ++ FARString *pFileSystemName, FARString *pDeviceName, FARString *pFileSystemMountPoint) + { + struct statvfs svfs {}; + const std::string &path = Wide2MB(lpwszRootPathName); +@@ -483,8 +484,6 @@ BOOL apiGetVolumeInformation(const wchar_t *lpwszRootP + + if (lpMaximumComponentLength) + *lpMaximumComponentLength = svfs.f_namemax; +- if (lpVolumeSerialNumber) +- *lpVolumeSerialNumber = (DWORD)svfs.f_fsid; + if (lpFileSystemFlags) + *lpFileSystemFlags = (DWORD)svfs.f_flag; + +@@ -507,8 +506,22 @@ BOOL apiGetVolumeInformation(const wchar_t *lpwszRootP + if (pFileSystemName) { + *pFileSystemName = MountInfo().GetFileSystem(path); + } +- if (*pFileSystemMountPoint) { ++ if (pFileSystemMountPoint) { + *pFileSystemMountPoint = MountInfo().GetFileSystemMountPoint(lpwszRootPathName); ++ } ++ // XXX: can we avoid calling GetFileSystemMountPoint() twice? ++ const std::string devname = MountInfo().GetFileSystemMountPoint(lpwszRootPathName, true); ++ if (pDeviceName) { ++ *pDeviceName = devname; ++ } ++ if (pDiskIdent) { ++ int fd = open(devname.c_str(), O_RDONLY); ++ if (fd != -1) { ++ char ident[DISK_IDENT_SIZE]; ++ if (ioctl(fd, DIOCGIDENT, ident) != -1) ++ *pDiskIdent = ident; ++ close(fd); ++ } + } + + return TRUE; diff --git a/misc/far2l/files/patch-far2l_src_farwinapi.hpp b/misc/far2l/files/patch-far2l_src_farwinapi.hpp new file mode 100644 index 000000000000..4f7eb9510547 --- /dev/null +++ b/misc/far2l/files/patch-far2l_src_farwinapi.hpp @@ -0,0 +1,13 @@ +--- far2l/src/farwinapi.hpp.orig 2025-10-26 08:39:52 UTC ++++ far2l/src/farwinapi.hpp +@@ -180,8 +180,8 @@ void apiGetTempPath(FARString &strBuffer); + bool apiExpandEnvironmentStrings(const wchar_t *src, FARString &strDest); + + BOOL apiGetVolumeInformation(const wchar_t *lpwszRootPathName, FARString *pVolumeName, +- DWORD64 *lpVolumeSerialNumber, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, +- FARString *pFileSystemName, FARString *pFileSystemMountPoint = nullptr); ++ FARString *pDiskIdent, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, ++ FARString *pFileSystemName, FARString *pDeviceName, FARString *pFileSystemMountPoint); + + void apiFindDataToDataEx(const FAR_FIND_DATA *pSrc, FAR_FIND_DATA_EX *pDest); + diff --git a/misc/far2l/files/patch-far2l_src_mix_MountInfo.cpp b/misc/far2l/files/patch-far2l_src_mix_MountInfo.cpp new file mode 100644 index 000000000000..3fa268388fd4 --- /dev/null +++ b/misc/far2l/files/patch-far2l_src_mix_MountInfo.cpp @@ -0,0 +1,20 @@ +--- far2l/src/mix/MountInfo.cpp.orig 2025-10-26 08:39:52 UTC ++++ far2l/src/mix/MountInfo.cpp +@@ -384,7 +384,7 @@ std::string MountInfo::GetFileSystem(const std::string + return out; + } + +-std::string MountInfo::GetFileSystemMountPoint(const wchar_t *lpwsz_path) const ++std::string MountInfo::GetFileSystemMountPoint(const wchar_t *lpwsz_path, bool want_device) const + { + std::string out; + size_t longest_match = 0; +@@ -394,7 +394,7 @@ std::string MountInfo::GetFileSystemMountPoint(const w + for (const auto &it : *_mountpoints) { + if (it.path.size() > longest_match && StrStartsFrom(path, it.path.c_str())) { + longest_match = it.path.size(); +- out = it.path; ++ out = want_device ? it.device : it.path; + } + } + return out; diff --git a/misc/far2l/files/patch-far2l_src_mix_MountInfo.h b/misc/far2l/files/patch-far2l_src_mix_MountInfo.h new file mode 100644 index 000000000000..f8dd9beb1695 --- /dev/null +++ b/misc/far2l/files/patch-far2l_src_mix_MountInfo.h @@ -0,0 +1,11 @@ +--- far2l/src/mix/MountInfo.h.orig 2025-10-26 08:39:52 UTC ++++ far2l/src/mix/MountInfo.h +@@ -40,7 +40,7 @@ class MountInfo (public) + + std::string GetFileSystem(const std::string &path) const; + +- std::string GetFileSystemMountPoint(const wchar_t *lpwsz_path) const; ++ std::string GetFileSystemMountPoint(const wchar_t *lpwsz_path, bool want_device = false) const; + + /// Returns true if path fine to be used multi-threaded-ly + bool IsMultiThreadFriendly(const std::string &path) const; diff --git a/misc/far2l/files/patch-far2l_src_panels_infolist.cpp b/misc/far2l/files/patch-far2l_src_panels_infolist.cpp new file mode 100644 index 000000000000..f3b70d2fc3bc --- /dev/null +++ b/misc/far2l/files/patch-far2l_src_panels_infolist.cpp @@ -0,0 +1,47 @@ +--- far2l/src/panels/infolist.cpp.orig 2025-10-26 08:39:52 UTC ++++ far2l/src/panels/infolist.cpp +@@ -62,7 +62,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF S + // # include <sys/sysctl.h> + #include <mach/mach_host.h> + #include <mach/vm_statistics.h> +-#elif !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__HAIKU__) ++#elif !defined(__DragonFly__) && !defined(__HAIKU__) + #include <sys/sysinfo.h> + #endif + #include <sys/statvfs.h> +@@ -171,8 +171,7 @@ void InfoList::DisplayObject() + // FARString strDriveRoot; + FARString strVolumeName, strFileSystemName, strFileSystemMountPoint; + DWORD MaxNameLength, FileSystemFlags; +- DWORD64 VolumeNumber; +- FARString strDiskNumber; ++ FARString strDeviceName, strDiskNumber; // Serial Number, really. + CloseFile(); + ClearTitles(); + +@@ -223,13 +222,11 @@ void InfoList::DisplayObject() + ConvertNameToReal(strCurDir, strRealDir); + + fprintf(stderr, "apiGetVolumeInformation: %ls\n", strRealDir.CPtr()); +- bool b_info = apiGetVolumeInformation(strRealDir, &strVolumeName, &VolumeNumber, &MaxNameLength, &FileSystemFlags, +- &strFileSystemName, &strFileSystemMountPoint); ++ bool b_info = apiGetVolumeInformation(strRealDir, &strVolumeName, &strDiskNumber, &MaxNameLength, &FileSystemFlags, ++ &strFileSystemName, &strDeviceName, &strFileSystemMountPoint); + if (b_info) { + // strTitle=FARString(L" ")+DiskType+L" "+Msg::InfoDisk+L" "+(strDriveRoot)+L" ("+strFileSystemName+L") "; +- strTitle = L"(" + strFileSystemName + L")"; +- +- strDiskNumber.Format(L"%08X-%08X", (DWORD)(VolumeNumber >> 32), (DWORD)(VolumeNumber & 0xffffffff)); ++ strTitle = strDeviceName + L" (" + strFileSystemName + L")"; + } else // Error! + strTitle = strCurDir; // strDriveRoot; + +@@ -444,7 +441,7 @@ void InfoList::DisplayObject() + PrintInfo(strOutStr); + } + +-#elif !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__HAIKU__) ++#elif !defined(__DragonFly__) && !defined(__HAIKU__) + struct sysinfo si = {}; + if (sysinfo(&si) == 0) { + DWORD dwMemoryLoad = 100 - ToPercent64(si.freeram + si.freeswap, si.totalram + si.totalswap);home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69271a98.2fdbd.49f65232>
