Re: [PATCH 2/7] fsmonitor: determine if filesystem is local or remote

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Le 15/02/2024 à 11:29, Eric DeCosta via GitGitGadget a écrit :
From: Eric DeCosta <edecosta@xxxxxxxxxxxxx>

Compare the given path to the mounted filesystems. Find the mount that is
the longest prefix of the path (if any) and determine if that mount is on a
local or remote filesystem.

Signed-off-by: Eric DeCosta <edecosta@xxxxxxxxxxxxx>
---
  Makefile                                |   4 +
  compat/fsmonitor/fsm-path-utils-linux.c | 195 ++++++++++++++++++++++++
  compat/fsmonitor/fsm-path-utils-linux.h |  91 +++++++++++
  config.mak.uname                        |  11 ++
  4 files changed, 301 insertions(+)
  create mode 100644 compat/fsmonitor/fsm-path-utils-linux.c
  create mode 100644 compat/fsmonitor/fsm-path-utils-linux.h

diff --git a/Makefile b/Makefile
index 78e874099d9..0f36a0fd83a 100644
--- a/Makefile
+++ b/Makefile
@@ -2088,6 +2088,10 @@ ifdef HAVE_CLOCK_GETTIME
  	BASIC_CFLAGS += -DHAVE_CLOCK_GETTIME
  endif
+ifdef HAVE_LINUX_MAGIC_H
+	BASIC_CFLAGS += -DHAVE_LINUX_MAGIC_H
+endif
+
  ifdef HAVE_CLOCK_MONOTONIC
  	BASIC_CFLAGS += -DHAVE_CLOCK_MONOTONIC
  endif
diff --git a/compat/fsmonitor/fsm-path-utils-linux.c b/compat/fsmonitor/fsm-path-utils-linux.c
new file mode 100644
index 00000000000..c21d1349532
--- /dev/null
+++ b/compat/fsmonitor/fsm-path-utils-linux.c
@@ -0,0 +1,195 @@
+#include "git-compat-util.h"
+#include "abspath.h"
+#include "fsmonitor.h"
+#include "fsmonitor-path-utils.h"
+#include "fsm-path-utils-linux.h"
+#include <errno.h>
+#include <mntent.h>
+#include <sys/mount.h>
+#include <sys/vfs.h>
+#include <sys/statvfs.h>
+
+static int is_remote_fs(const char *path)
+{
+	struct statfs fs;
+
+	if (statfs(path, &fs))
+		return error_errno(_("statfs('%s') failed"), path);

For the sake of simplifying of the work of translators, would it be wise to change this to

+	if (statfs(path, &fs))
+		/* TRANSLATORS: %s('%s') is a libc function call */
+		return error_errno(_("%s('%s') failed"), "statfs", +				path);

and generalize this to all other messages?

Thanks,

JN





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux