Re: [PATCH 2/7] fsmonitor: determine if filesystem is local or remote
- From
Jean-Noël Avila <avila.jn@gmail.com>
- Date
- Feb 15, 2024, 11:24 UTC
- Message-ID
- <3e3d733f-d7d7-4dee-9ee9-d52ea215b36f@gmail.com>
- In-Reply-To
- <d26de10866662a5bcd16d562cd1063dedd21cf02.1707992978.git.gitgitgadget@gmail.com>
Hello,
Le 15/02/2024 à 11:29, Eric DeCosta via GitGitGadget a écrit :
Show 54 quoted lines
> From: Eric DeCosta <edecosta@mathworks.com>
>
> 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@mathworks.com>
> ---
> 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