Changeset 988 for vendor/current/source3/smbd/statvfs.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/statvfs.c
r740 r988 24 24 #include "smbd/smbd.h" 25 25 26 #if defined(LINUX) && defined(HAVE_FSID_INT)27 static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf)28 {29 struct statvfs statvfs_buf;30 int result;31 32 result = statvfs(path, &statvfs_buf);33 34 if (!result) {35 statbuf->OptimalTransferSize = statvfs_buf.f_frsize;36 statbuf->BlockSize = statvfs_buf.f_bsize;37 statbuf->TotalBlocks = statvfs_buf.f_blocks;38 statbuf->BlocksAvail = statvfs_buf.f_bfree;39 statbuf->UserBlocksAvail = statvfs_buf.f_bavail;40 statbuf->TotalFileNodes = statvfs_buf.f_files;41 statbuf->FreeFileNodes = statvfs_buf.f_ffree;42 statbuf->FsIdentifier = statvfs_buf.f_fsid;43 44 /* Good defaults for Linux filesystems are case sensitive45 * and case preserving.46 */47 statbuf->FsCapabilities =48 FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;49 }50 return result;51 }52 #endif53 54 26 #if defined(DARWINOS) 55 56 27 #include <sys/attr.h> 57 28 … … 103 74 return caps; 104 75 } 76 #endif /* DARWINOS */ 105 77 106 static int darwin_statvfs(const char *path, vfs_statvfs_struct *statbuf) 78 #if defined(BSD_STYLE_STATVFS) 79 static int bsd_statvfs(const char *path, vfs_statvfs_struct *statbuf) 107 80 { 108 81 struct statfs sbuf; … … 110 83 111 84 ret = statfs(path, &sbuf); 112 if (ret != 0) { 113 return ret; 85 if (ret == 0) { 86 statbuf->OptimalTransferSize = sbuf.f_iosize; 87 statbuf->BlockSize = sbuf.f_bsize; 88 statbuf->TotalBlocks = sbuf.f_blocks; 89 statbuf->BlocksAvail = sbuf.f_bfree; 90 statbuf->UserBlocksAvail = sbuf.f_bavail; 91 statbuf->TotalFileNodes = sbuf.f_files; 92 statbuf->FreeFileNodes = sbuf.f_ffree; 93 statbuf->FsIdentifier = 94 (((uint64_t) sbuf.f_fsid.val[0] << 32) & 0xffffffff00000000LL) | 95 (uint64_t) sbuf.f_fsid.val[1]; 96 #ifdef DARWINOS 97 statbuf->FsCapabilities = darwin_fs_capabilities(sbuf.f_mntonname); 98 #else 99 /* Try to extrapolate some of the fs flags into the 100 * capabilities 101 */ 102 statbuf->FsCapabilities = 103 FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; 104 #ifdef MNT_ACLS 105 if (sbuf.f_flags & MNT_ACLS) 106 statbuf->FsCapabilities |= FILE_PERSISTENT_ACLS; 107 #endif 108 #endif 109 if (sbuf.f_flags & MNT_QUOTA) 110 statbuf->FsCapabilities |= FILE_VOLUME_QUOTAS; 111 if (sbuf.f_flags & MNT_RDONLY) 112 statbuf->FsCapabilities |= FILE_READ_ONLY_VOLUME; 114 113 } 115 114 116 statbuf->OptimalTransferSize = sbuf.f_iosize; 117 statbuf->BlockSize = sbuf.f_bsize; 118 statbuf->TotalBlocks = sbuf.f_blocks; 119 statbuf->BlocksAvail = sbuf.f_bfree; 120 statbuf->UserBlocksAvail = sbuf.f_bavail; 121 statbuf->TotalFileNodes = sbuf.f_files; 122 statbuf->FreeFileNodes = sbuf.f_ffree; 123 statbuf->FsIdentifier = *(uint64_t *)(&sbuf.f_fsid); /* Ick. */ 124 statbuf->FsCapabilities = darwin_fs_capabilities(sbuf.f_mntonname); 115 return ret; 116 } 117 #elif defined(STAT_STATVFS) && defined(HAVE_FSID_INT) 118 static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf) 119 { 120 struct statvfs statvfs_buf; 121 int result; 125 122 126 return 0; 123 result = statvfs(path, &statvfs_buf); 124 125 if (!result) { 126 statbuf->OptimalTransferSize = statvfs_buf.f_frsize; 127 statbuf->BlockSize = statvfs_buf.f_bsize; 128 statbuf->TotalBlocks = statvfs_buf.f_blocks; 129 statbuf->BlocksAvail = statvfs_buf.f_bfree; 130 statbuf->UserBlocksAvail = statvfs_buf.f_bavail; 131 statbuf->TotalFileNodes = statvfs_buf.f_files; 132 statbuf->FreeFileNodes = statvfs_buf.f_ffree; 133 statbuf->FsIdentifier = statvfs_buf.f_fsid; 134 /* Try to extrapolate some of the fs flags into the 135 * capabilities 136 */ 137 statbuf->FsCapabilities = 138 FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES; 139 #ifdef ST_QUOTA 140 if (statvfs_buf.f_flag & ST_QUOTA) 141 statbuf->FsCapabilities |= FILE_VOLUME_QUOTAS; 142 #endif 143 if (statvfs_buf.f_flag & ST_RDONLY) 144 statbuf->FsCapabilities |= FILE_READ_ONLY_VOLUME; 145 146 #if defined(HAVE_FALLOC_FL_PUNCH_HOLE) && defined(HAVE_LSEEK_HOLE_DATA) 147 /* 148 * Only flag sparse file support if ZERO_DATA can be used to 149 * deallocate blocks, and SEEK_HOLE / SEEK_DATA can be used 150 * to provide QUERY_ALLOCATED_RANGES information. 151 */ 152 statbuf->FsCapabilities |= FILE_SUPPORTS_SPARSE_FILES; 153 #endif 154 } 155 return result; 127 156 } 128 157 #endif … … 132 161 for particular POSIX systems. Due to controversy of what is considered more important 133 162 between LSB and FreeBSD/POSIX.1 (IEEE Std 1003.1-2001) we need to abstract the interface 134 so that particular OS would use its pref fered interface.163 so that particular OS would use its preferred interface. 135 164 */ 136 165 int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf) 137 166 { 138 #if defined(LINUX) && defined(HAVE_FSID_INT) 167 #if defined(BSD_STYLE_STATVFS) 168 return bsd_statvfs(path, statbuf); 169 #elif defined(STAT_STATVFS) && defined(HAVE_FSID_INT) 139 170 return linux_statvfs(path, statbuf); 140 #elif defined(DARWINOS)141 return darwin_statvfs(path, statbuf);142 171 #else 143 172 /* BB change this to return invalid level */
Note:
See TracChangeset
for help on using the changeset viewer.