From 1551db2f9fa3ff6a9f7558aff8846d14b49c54c5 Mon Sep 17 00:00:00 2001 From: sfionov Date: Tue, 20 Oct 2009 01:22:43 +0300 Subject: [PATCH] Ticket #1642: filegui.c contains Linux-specific things mc 4.7.0-pre1 introduced dynamic "Save attributes" checkbox value in Copy/Move dialog. But code is Linux-specific, and not even isolated by macros. I suggest to add code specific for BSD and SVR4 systems. In BSD systems (MacOS X, NetBSD, FreeBSD) there is statfs.f_fstypename which contains name of filesystem. Valid FS names are: msdos, msdosfs (FreeBSD), ntfs, smbfs, procfs, fusefs (BSD), fusefs_subfstype (Mac) In SVR4 systems (Solaris and other SVR4 Unixes) there are statvfs.f_basetype and statvfs syscall instead of statfs and also autotools define STAT_STATVFS. Valid FS names are: pcfs, proc, ntfs, fuse, smbfs (Note that NetBSD 3.0+ also use statvfs but with BSD syntax.) For all other OSes we simply return 1. Signed-off-by: Slava Zanko --- m4.include/ac-get-fs-info.m4 | 5 ++++ src/filegui.c | 51 +++++++++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/m4.include/ac-get-fs-info.m4 b/m4.include/ac-get-fs-info.m4 index 5f25b4c82..97b64dae2 100644 --- a/m4.include/ac-get-fs-info.m4 +++ b/m4.include/ac-get-fs-info.m4 @@ -628,6 +628,11 @@ AC_DEFUN([gl_FSTYPENAME], #include #include ]) + AC_CHECK_MEMBERS([struct statvfs.f_fstypename, struct statvfs.f_basetype],,, + [ + AC_INCLUDES_DEFAULT + #include + ]) ]) dnl diff --git a/src/filegui.c b/src/filegui.c index ac706b1e0..15b3872d8 100644 --- a/src/filegui.c +++ b/src/filegui.c @@ -55,19 +55,23 @@ #include #include -#if defined (__FreeBSD__) +#if defined(STAT_STATVFS) \ + && (defined(HAVE_STRUCT_STATVFS_F_BASETYPE) \ + || defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME)) +# include +# define STRUCT_STATFS struct statvfs +# define STATFS statvfs +#elif defined(HAVE_STATFS) && !defined(STAT_STATFS4) +# ifdef HAVE_SYS_VFS_H +# include +# elif defined(HAVE_SYS_MOUNT_H) && defined(HAVE_SYS_PARAM_H) # include -#endif -#if defined(__APPLE__) || defined (__FreeBSD__) # include -#elif defined (__NetBSD__) -# include -#else -# ifdef HAVE_VFS -# include -# else -# include -# endif +# elif defined(HAVE_SYS_STATFS_H) +# include +# endif +# define STRUCT_STATFS struct statfs +# define STATFS statfs #endif #include @@ -164,14 +168,16 @@ enum { static int filegui__check_attrs_on_fs(const char *fs_path) { - struct statfs stfs; +#ifdef STATFS + STRUCT_STATFS stfs; if (!setup_copymove_persistent_attr) return 0; - if (statfs(fs_path, &stfs)!=0) + if (STATFS(fs_path, &stfs)!=0) return 1; +# ifdef __linux__ switch ((filegui_nonattrs_fs_t) stfs.f_type) { case MSDOS_SUPER_MAGIC: @@ -184,6 +190,25 @@ filegui__check_attrs_on_fs(const char *fs_path) return 0; break; } +# elif defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) \ + || defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME) + if (!strcmp(stfs.f_fstypename, "msdos") + || !strcmp(stfs.f_fstypename, "msdosfs") + || !strcmp(stfs.f_fstypename, "ntfs") + || !strcmp(stfs.f_fstypename, "procfs") + || !strcmp(stfs.f_fstypename, "smbfs") + || strstr(stfs.f_fstypename, "fusefs")) + return 0; +# elif defined(HAVE_STRUCT_STATVFS_F_BASETYPE) + if (!strcmp(stfs.f_basetype, "pcfs") + || !strcmp(stfs.f_basetype, "ntfs") + || !strcmp(stfs.f_basetype, "proc") + || !strcmp(stfs.f_basetype, "smbfs") + || !strcmp(stfs.f_basetype, "fuse")) + return 0; +# endif +#endif /* STATFS */ + return 1; }