Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/smbd/statvfs.c

    r740 r988  
    2424#include "smbd/smbd.h"
    2525
    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 sensitive
    45                  * and case preserving.
    46                  */
    47                 statbuf->FsCapabilities =
    48                     FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
    49         }
    50         return result;
    51 }
    52 #endif
    53 
    5426#if defined(DARWINOS)
    55 
    5627#include <sys/attr.h>
    5728
     
    10374        return caps;
    10475}
     76#endif /* DARWINOS */
    10577
    106 static int darwin_statvfs(const char *path, vfs_statvfs_struct *statbuf)
     78#if defined(BSD_STYLE_STATVFS)
     79static int bsd_statvfs(const char *path, vfs_statvfs_struct *statbuf)
    10780{
    10881        struct statfs sbuf;
     
    11083
    11184        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;
    114113        }
    115114
    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)
     118static int linux_statvfs(const char *path, vfs_statvfs_struct *statbuf)
     119{
     120        struct statvfs statvfs_buf;
     121        int result;
    125122
    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;
    127156}
    128157#endif
     
    132161 for particular POSIX systems. Due to controversy of what is considered more important
    133162 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 preffered interface.
     163 so that particular OS would use its preferred interface.
    135164*/
    136165int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf)
    137166{
    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)
    139170        return linux_statvfs(path, statbuf);
    140 #elif defined(DARWINOS)
    141         return darwin_statvfs(path, statbuf);
    142171#else
    143172        /* BB change this to return invalid level */
Note: See TracChangeset for help on using the changeset viewer.