From eb7a808f9811f08880319ccb3e22b4388a9f4434 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 20 Oct 2005 18:15:44 +0000 Subject: r11233: Forgot to add the statvfs file. Oops. Jeremy. (This used to be commit 797b9f47e98bed500dc3dd6ec8de51a0ec3e2bd7) --- source3/smbd/statvfs.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 source3/smbd/statvfs.c (limited to 'source3/smbd/statvfs.c') diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c new file mode 100644 index 0000000000..8f981a6328 --- /dev/null +++ b/source3/smbd/statvfs.c @@ -0,0 +1,65 @@ +/* + Unix SMB/CIFS implementation. + VFS API's statvfs abstraction + Copyright (C) Alexander Bokovoy 2005 + Copyright (C) Steve French 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +#if defined(LINUX) +static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf) +{ + struct statvfs statvfs_buf; + int result; + + result = statvfs(path, &statvfs_buf); + + if (!result) { + statbuf->OptimalTransferSize = statvfs_buf.f_frsize; + statbuf->BlockSize = statvfs_buf.f_bsize; + statbuf->TotalBlocks = statvfs_buf.f_blocks; + statbuf->BlocksAvail = statvfs_buf.f_bfree; + statbuf->UserBlocksAvail = statvfs_buf.f_bavail; + statbuf->TotalFileNodes = statvfs_buf.f_files; + statbuf->FreeFileNodes = statvfs_buf.f_ffree; + statbuf->FsIdentifier = statvfs_buf.f_fsid; + } + return result; +} +#endif + +/* + sys_statvfs() is an abstraction layer over system-dependent statvfs()/statfs() + for particular POSIX systems. Due to controversy of what is considered more important + between LSB and FreeBSD/POSIX.1 (IEEE Std 1003.1-2001) we need to abstract the interface + so that particular OS would use its preffered interface. +*/ +int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf) +{ +#if defined(LINUX) + return linux_statvfs(path, statbuf); +#else + /* BB change this to return invalid level */ +#ifdef EOPNOTSUPP + return EOPNOTSUPP; +#else + return -1; +#endif /* EOPNOTSUPP */ +#endif /* LINUX */ + +} -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/smbd/statvfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/statvfs.c') diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c index 8f981a6328..300b14a7c0 100644 --- a/source3/smbd/statvfs.c +++ b/source3/smbd/statvfs.c @@ -21,7 +21,7 @@ #include "includes.h" -#if defined(LINUX) +#if defined(LINUX) && defined(HAVE_FSID_INT) static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf) { struct statvfs statvfs_buf; @@ -51,7 +51,7 @@ static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf) */ int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf) { -#if defined(LINUX) +#if defined(LINUX) && defined(HAVE_FSID_INT) return linux_statvfs(path, statbuf); #else /* BB change this to return invalid level */ -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/smbd/statvfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/statvfs.c') diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c index 300b14a7c0..d836930daf 100644 --- a/source3/smbd/statvfs.c +++ b/source3/smbd/statvfs.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/smbd/statvfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/statvfs.c') diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c index d836930daf..f6663208ea 100644 --- a/source3/smbd/statvfs.c +++ b/source3/smbd/statvfs.c @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 2403b319a76c3b425d618a3ff937e7ff05d211b4 Mon Sep 17 00:00:00 2001 From: James Peach Date: Mon, 15 Oct 2007 14:03:40 -0700 Subject: Add filesystem capabilities bitmask to statfs info. This patch adds Darwin support for the Samba statfs VFS call. It also adds a filesystem capabilities bitmask to the information returned by the call. (This used to be commit 555173eb3f6511e88798d6ef3d1fed0c219a9921) --- source3/smbd/statvfs.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) (limited to 'source3/smbd/statvfs.c') diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c index f6663208ea..5fc0afdd79 100644 --- a/source3/smbd/statvfs.c +++ b/source3/smbd/statvfs.c @@ -3,6 +3,7 @@ VFS API's statvfs abstraction Copyright (C) Alexander Bokovoy 2005 Copyright (C) Steve French 2005 + Copyright (C) James Peach 2006 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,11 +38,93 @@ static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf) statbuf->TotalFileNodes = statvfs_buf.f_files; statbuf->FreeFileNodes = statvfs_buf.f_ffree; statbuf->FsIdentifier = statvfs_buf.f_fsid; + + /* Good defaults for Linux filesystems are case sensitive + * and case preserving. + */ + statbuf->FsCapabilities = + FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVING_NAMES; } return result; } #endif +#if defined(DARWINOS) + +#include + +static int darwin_fs_capabilities(const char * path) +{ + int caps = 0; + vol_capabilities_attr_t *vcaps; + struct attrlist attrlist; + char attrbuf[sizeof(u_int32_t) + sizeof(vol_capabilities_attr_t)]; + +#define FORMAT_CAP(vinfo, cap) \ + ( ((vinfo)->valid[VOL_CAPABILITIES_FORMAT] & (cap)) && \ + ((vinfo)->capabilities[VOL_CAPABILITIES_FORMAT] & (cap)) ) + +#define INTERFACE_CAP(vinfo, cap) \ + ( ((vinfo)->valid[VOL_CAPABILITIES_INTERFACES] & (cap)) && \ + ((vinfo)->capabilities[VOL_CAPABILITIES_INTERFACES] & (cap)) ) + + ZERO_STRUCT(attrlist); + attrlist.bitmapcount = ATTR_BIT_MAP_COUNT; + attrlist.volattr = ATTR_VOL_CAPABILITIES; + + if (getattrlist(path, &attrlist, attrbuf, sizeof(attrbuf), 0) != 0) { + DEBUG(0, ("getattrlist for %s capabilities failed: %s\n", + path, strerror(errno))); + /* Return no capabilities on failure. */ + return 0; + } + + vcaps = + (vol_capabilities_attr_t *)(attrbuf + sizeof(u_int32_t)); + + if (FORMAT_CAP(vcaps, VOL_CAP_FMT_SPARSE_FILES)) { + caps |= FILE_SUPPORTS_SPARSE_FILES; + } + + if (FORMAT_CAP(vcaps, VOL_CAP_FMT_CASE_SENSITIVE)) { + caps |= FILE_CASE_SENSITIVE_SEARCH; + } + + if (FORMAT_CAP(vcaps, VOL_CAP_FMT_CASE_PRESERVING)) { + caps |= FILE_CASE_PRESERVED_NAMES; + } + + if (INTERFACE_CAP(vcaps, VOL_CAP_INT_EXTENDED_SECURITY)) { + caps |= FILE_PERSISTENT_ACLS; + } + + return caps; +} + +static int darwin_statvfs(const char *path, vfs_statvfs_struct *statbuf) +{ + struct statfs sbuf; + int ret; + + ret = statfs(path, &sbuf); + if (ret != 0) { + return ret; + } + + statbuf->OptimalTransferSize = sbuf.f_iosize; + statbuf->BlockSize = sbuf.f_bsize; + statbuf->TotalBlocks = sbuf.f_blocks; + statbuf->BlocksAvail = sbuf.f_bfree; + statbuf->UserBlocksAvail = sbuf.f_bavail; + statbuf->TotalFileNodes = sbuf.f_files; + statbuf->FreeFileNodes = sbuf.f_ffree; + statbuf->FsIdentifier = *(SMB_BIG_UINT *)(&sbuf.f_fsid); /* Ick. */ + statbuf->FsCapabilities = darwin_fs_capabilities(sbuf.f_mntonname); + + return 0; +} +#endif + /* sys_statvfs() is an abstraction layer over system-dependent statvfs()/statfs() for particular POSIX systems. Due to controversy of what is considered more important @@ -52,6 +135,8 @@ int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf) { #if defined(LINUX) && defined(HAVE_FSID_INT) return linux_statvfs(path, statbuf); +#elif defined(DARWINOS) + return darwin_statvfs(path, statbuf); #else /* BB change this to return invalid level */ #ifdef EOPNOTSUPP -- cgit From 8804f5bdd7cbc0bc8166c7a4a9a09fbcb4402afd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Dec 2007 10:33:13 +0100 Subject: Attempt to fix the build James, at least on my Linux system neither FILE_CASE_SENSITIVE_SEARCH nor FILE_CASE_PRESERVING_NAMES seem to be defined anywhere. Is it possible that this is a MacOS/X specific thing? If so, could you add configure tests for this? Thanks, Volker (This used to be commit 465fd4385013c95f9778d710d70796feae4eb858) --- source3/smbd/statvfs.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/smbd/statvfs.c') diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c index 5fc0afdd79..431489032c 100644 --- a/source3/smbd/statvfs.c +++ b/source3/smbd/statvfs.c @@ -39,11 +39,13 @@ static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf) statbuf->FreeFileNodes = statvfs_buf.f_ffree; statbuf->FsIdentifier = statvfs_buf.f_fsid; +#if defined(FILE_CASE_SENSITIVE_SEARCH) && defined(FILE_CASE_PRESERVING_NAMES) /* Good defaults for Linux filesystems are case sensitive * and case preserving. */ statbuf->FsCapabilities = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVING_NAMES; +#endif } return result; } -- cgit From 4c3c483fbfd870335f77ab610eb7230639d3d258 Mon Sep 17 00:00:00 2001 From: James Peach Date: Thu, 20 Dec 2007 08:31:27 -0800 Subject: Fix typo in filesystem capabilities bits. (This used to be commit 08fee0d28a20648d74c6b03d120eaf628f4de70c) --- source3/smbd/statvfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/smbd/statvfs.c') diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c index 431489032c..0e9a2c2ebe 100644 --- a/source3/smbd/statvfs.c +++ b/source3/smbd/statvfs.c @@ -39,13 +39,11 @@ static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf) statbuf->FreeFileNodes = statvfs_buf.f_ffree; statbuf->FsIdentifier = statvfs_buf.f_fsid; -#if defined(FILE_CASE_SENSITIVE_SEARCH) && defined(FILE_CASE_PRESERVING_NAMES) /* Good defaults for Linux filesystems are case sensitive * and case preserving. */ statbuf->FsCapabilities = - FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVING_NAMES; -#endif + FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; } return result; } -- cgit