~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools-precise.sid-merge1

« back to all changes in this revision

Viewing changes to lib/file/fileIOPosix.c

  • Committer: Evan Broder
  • Date: 2010-05-29 17:35:25 UTC
  • mfrom: (2.4.16 sid)
  • Revision ID: evan@mingo-20100529173525-u1clyo2h18k7l0kx
Tags: 2010.04.25-253928-2+ubuntu1
* Merge from debian testing, remaining changes:
    - Recommend open-vm-toolbox in open-vm-tools.
* Dropping la files.
* Updating rules for pvscsi removal (Closes: #581160).
* Merging upstream version 2010.04.25-253928.
* Updating packaging for upstreams pvscsi module removal.
* Removing remote_fs from initscript again (Closes: #577163).
* Updating lintian overrides for open-vm-tools.
* Updating date and version in manpage headers.
* Adding manpage for vmxnet3.
* Adding manpage for vmci.
* Fixing spelling typo in vmsync manpage.
* Adding manpage for vmsock.
* Update formating of newly added manpages.
* Adding vmware-toolbox-cmd manpage.
* Adding guestlib manpage.
* Adding libvmtools manpage.
* Renaming guestlib manpage to libguestlib.
* Including vmware-toolbox-cmd manpage in open-vm-tools package.
* Updating initscript start/stop declarations (Closes: #576843,
  #577163).
* Adding misc depends.
* Running open-vm-dkms postinst script with set -e.
* Adding remote_fs to init depends.
* Avoid including license files in open-vm-dkms.
* Marking makefiles in open-vm-dkms executable to please lintian.
* Adding make to open-vm-dkms depends.
* Also stopping in runlevel 1.
* Addding dkms support based on the work of Evan Broder
  <broder@mit.edu> on the ubuntu package (Closes: #516251).
* Simplyfing initramfs triggers (Closes: #516355).
* Merging upstream version 2010.03.20-243334.
* Moving local Makefile to subdirectory.
* Adding build-depends to libfuse-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
/* Check for non-matching prototypes */
80
80
#include "vmware.h"
81
81
#include "str.h"
 
82
#include "err.h"
82
83
#include "posix.h"
83
84
#include "file.h"
84
85
#include "fileIO.h"
87
88
#include "util.h"
88
89
#include "iovector.h"
89
90
#include "stats_file.h"
 
91
#include "hostType.h"
90
92
 
91
93
#include "unicodeOperations.h"
92
94
#include "memaligned.h"
172
174
 */
173
175
 
174
176
static FileIOResult
175
 
FileIOErrno2Result(int error) // IN: errno to convert
 
177
FileIOErrno2Result(int error)  // IN: errno to convert
176
178
{
177
179
   switch (error) {
178
180
   case EEXIST:
229
231
{
230
232
   if (!filePosixOptions.initialized) {
231
233
      filePosixOptions.enabled =
232
 
         Config_GetBool(TRUE, "filePosix.coalesce.enable");
 
234
                            Config_GetBool(TRUE, "filePosix.coalesce.enable");
 
235
 
233
236
      /*
234
 
       * Aligned malloc starts failing to allocate memory during
235
 
       * heavy I/O on Linux.  We're not sure why -- maybe we
236
 
       * are running out of mmaps?  Turn it off by default
237
 
       * for now.
 
237
       * Aligned malloc starts failing to allocate memory during heavy I/O on
 
238
       * Linux. We're not sure why -- maybe we are running out of mmaps?
 
239
       * Turn it off by default for now.
238
240
       */
 
241
 
239
242
      filePosixOptions.aligned =
240
 
         Config_GetBool(FALSE, "filePosix.coalesce.aligned");
 
243
                           Config_GetBool(FALSE, "filePosix.coalesce.aligned");
 
244
 
241
245
      filePosixOptions.countThreshold =
242
 
         Config_GetLong(5, "filePosix.coalesce.count");
 
246
                           Config_GetLong(5, "filePosix.coalesce.count");
 
247
 
243
248
      filePosixOptions.sizeThreshold =
244
 
         Config_GetLong(16*1024, "filePosix.coalesce.size");
 
249
                           Config_GetLong(16*1024, "filePosix.coalesce.size");
 
250
 
245
251
      filePosixOptions.aioNumThreads =
246
 
         Config_GetLong(0, "aiomgr.numThreads");
 
252
                           Config_GetLong(0, "aiomgr.numThreads");
 
253
 
247
254
      filePosixOptions.initialized = TRUE;
248
255
   }
249
256
}
266
273
 */
267
274
 
268
275
void
269
 
FileIO_Invalidate(FileIODescriptor *fd) // OUT
 
276
FileIO_Invalidate(FileIODescriptor *fd)  // OUT:
270
277
{
271
278
   ASSERT(fd);
272
279
 
292
299
 */
293
300
 
294
301
Bool
295
 
FileIO_IsValid(const FileIODescriptor *fd)      // IN
 
302
FileIO_IsValid(const FileIODescriptor *fd)  // IN:
296
303
{
297
304
   ASSERT(fd);
298
305
 
350
357
#endif
351
358
 
352
359
   fd.posix = posix;
 
360
 
353
361
   return fd;
354
362
}
355
363
 
402
410
 */
403
411
 
404
412
static void
405
 
ProxySendResults(int sock_fd,    // IN:
406
 
                 int send_fd,    // IN:
407
 
                 int send_errno) // IN:
 
413
ProxySendResults(int sock_fd,     // IN:
 
414
                 int send_fd,     // IN:
 
415
                 int send_errno)  // IN:
408
416
{
409
417
   struct iovec iov;
410
418
   struct msghdr msg;
460
468
 */
461
469
 
462
470
static void
463
 
ProxyReceiveResults(int sock_fd,     // IN:
464
 
                    int *recv_fd,    // OUT:
465
 
                    int *recv_errno) // OUT:
 
471
ProxyReceiveResults(int sock_fd,      // IN:
 
472
                    int *recv_fd,     // OUT:
 
473
                    int *recv_errno)  // OUT:
466
474
{
467
475
   int err;
468
476
   struct iovec iov;
609
617
   if ((Posix_Lstat(pathName, &statbuf) == 0) &&
610
618
       S_ISLNK(statbuf.st_mode)) {
611
619
      *useProxy = TRUE;
 
620
 
612
621
      return 0;
613
622
   }
614
623
 
692
701
      err = ProxyUse(pathName, &useProxy);
693
702
      if (err != 0) {
694
703
         errno = err;
 
704
 
695
705
         return -1;
696
706
      }
697
707
   } else {
728
738
 */
729
739
 
730
740
FileIOResult
731
 
FileIO_Create(FileIODescriptor *file,    // OUT:
732
 
              ConstUnicode pathName,     // IN:
733
 
              int access,                // IN:
734
 
              FileIOOpenAction action,   // IN:
735
 
              int mode)                  // IN: mode_t for creation
 
741
FileIO_Create(FileIODescriptor *file,   // OUT:
 
742
              ConstUnicode pathName,    // IN:
 
743
              int access,               // IN:
 
744
              FileIOOpenAction action,  // IN:
 
745
              int mode)                 // IN: mode_t for creation
736
746
{
737
747
   uid_t uid = -1;
738
748
   int fd = -1;
744
754
 
745
755
   if (pathName == NULL) {
746
756
      errno = EFAULT;
 
757
 
747
758
      return FILEIO_ERROR;
748
759
   }
749
760
 
750
761
#if defined(VMX86_STATS)
751
762
   {
752
763
      Unicode tmp;
 
764
 
753
765
      File_SplitName(pathName, NULL, NULL, &tmp);
754
766
      STATS_USER_INIT_MODULE_ONCE();
755
767
      file->stats = STATS_USER_INIT_INST(tmp);
771
783
    * (FILEIO_OPEN_ACCESS_READ | FILEIO_OPEN_LOCKED) are passed, and we are
772
784
    * on VMFS, then pass in special flags to get exclusive, multiwriter, or
773
785
    * cross-host read-only mode.  The first if statement is to avoid calling
774
 
    * File_OnVMFS() unless really necessary.
 
786
    * HostType_OSIsVMK() unless really necessary.
775
787
    *
776
788
    * If the above conditions are met FILEIO_OPEN_LOCKED, is filtered out --
777
789
    * vmfs will be handling the locking, so there is no need to create
782
794
       (access & (FILEIO_OPEN_ACCESS_READ | FILEIO_OPEN_ACCESS_WRITE |
783
795
                  FILEIO_OPEN_LOCKED)) ==
784
796
       (FILEIO_OPEN_ACCESS_READ | FILEIO_OPEN_LOCKED)) {
785
 
      if (File_OnVMFS(pathName)) {
 
797
      if (HostType_OSIsVMK()) {
786
798
         access &= ~FILEIO_OPEN_LOCKED;
 
799
 
787
800
         if ((access & FILEIO_OPEN_MULTIWRITER_LOCK) != 0) {
788
801
            flags |= O_MULTIWRITER_LOCK;
789
802
         } else {
868
881
    *   Time Machine backs up EVERY file unless explicitly told not to, so this
869
882
    *   option uses the API to exclude the file that was just opened.
870
883
    */
 
884
 
871
885
   if ((access & FILEIO_OPEN_NO_TIME_MACHINE)) {
872
886
      if (!FileIO_SetExcludedFromTimeMachine(pathName, TRUE)) {
873
887
         ret = FILEIO_ERROR;
880
894
       *   10.5.2, so if the user is in 10.5.2 and the option isn't set, then
881
895
       *   we want to reset the exclusion of the file.
882
896
       *
883
 
       *   Note that this call ignores errors because there are some files (like
884
 
       *   raw devices) that will fail checking xattrs and Time Machine Exclusion
885
 
       *   status, but we can't detect them at this point.
 
897
       *   Note that this call ignores errors because there are some files
 
898
       *   (like raw devices) that will fail checking xattrs and Time
 
899
       *   Machine Exclusion status, but we can't detect them at this point.
886
900
       */
 
901
 
887
902
      FileIO_ResetExcludedFromTimeMachine(pathName);
888
903
   }
889
904
#endif
893
908
       * Remove the name from the name space. The file remains laid out on the
894
909
       * disk and accessible through the file descriptor until it is closed.
895
910
       */
 
911
 
896
912
      if (Posix_Unlink(pathName) == -1) {
897
913
         ret = FileIOErrno2Result(errno);
898
914
         goto error;
988
1004
#endif
989
1005
 
990
1006
uint64
991
 
FileIO_Seek(const FileIODescriptor *file, // IN
992
 
            int64 distance,               // IN
993
 
            FileIOSeekOrigin origin)      // IN
 
1007
FileIO_Seek(const FileIODescriptor *file,  // IN:
 
1008
            int64 distance,                // IN:
 
1009
            FileIOSeekOrigin origin)       // IN:
994
1010
{
995
1011
   ASSERT(file);
996
1012
 
1017
1033
    */
1018
1034
 
1019
1035
   loff_t res;
 
1036
 
1020
1037
   if (_llseek(file->posix, distance >> 32, distance & 0xFFFFFFFF,
1021
1038
               &res, FileIO_SeekOrigins[origin]) == -1) {
1022
1039
      res = -1;
1023
1040
   }
 
1041
 
1024
1042
   return res;
1025
 
 
1026
1043
#elif defined(__USE_LARGEFILE64) && !defined(__USE_LARGEFILE)
1027
1044
   /*
1028
1045
    * This is a Linux system with glibc that has lseek64 available, but not a
1033
1050
    */
1034
1051
 
1035
1052
    return lseek64(file->posix, distance, FileIO_SeekOrigins[origin]);
1036
 
 
1037
1053
#else
1038
1054
    /*
1039
1055
     * We're taking this route because either we know lseek() can support
1045
1061
     */
1046
1062
 
1047
1063
    return lseek(file->posix, distance, FileIO_SeekOrigins[origin]);
1048
 
 
1049
1064
#endif
1050
1065
}
1051
1066
 
1076
1091
 */
1077
1092
 
1078
1093
FileIOResult
1079
 
FileIO_Write(FileIODescriptor *fd,      // IN
1080
 
             const void *bufIn,         // IN
1081
 
             size_t requested,          // IN
1082
 
             size_t *actual)            // OUT
 
1094
FileIO_Write(FileIODescriptor *fd,  // IN:
 
1095
             const void *bufIn,     // IN:
 
1096
             size_t requested,      // IN:
 
1097
             size_t *actual)        // OUT:
1083
1098
{
1084
1099
   const uint8 *buf = (const uint8 *)bufIn;
1085
1100
   size_t initial_requested;
1147
1162
 */
1148
1163
 
1149
1164
FileIOResult
1150
 
FileIO_Read(FileIODescriptor *fd,       // IN
1151
 
            void *bufIn,                // OUT
1152
 
            size_t requested,           // IN
1153
 
            size_t *actual)             // OUT
 
1165
FileIO_Read(FileIODescriptor *fd,  // IN:
 
1166
            void *bufIn,           // OUT:
 
1167
            size_t requested,      // IN:
 
1168
            size_t *actual)        // OUT:
1154
1169
{
1155
 
   uint8 *buf = (uint8 *)bufIn;
 
1170
   uint8 *buf = (uint8 *) bufIn;
1156
1171
   size_t initial_requested;
1157
1172
   FileIOResult fret = FILEIO_SUCCESS;
1158
1173
 
1180
1195
         }
1181
1196
         fret = FileIOErrno2Result(errno);
1182
1197
         if (FILEIO_ERROR == fret) {
1183
 
            Log("read failed, errno=%d, %s\n", errno, strerror(errno));
 
1198
            Log("read failed, errno=%d, %s\n", errno, Err_Errno2String(errno));
1184
1199
         }
1185
1200
         break;
1186
1201
      }
1219
1234
 */
1220
1235
 
1221
1236
Bool
1222
 
FileIO_Truncate(FileIODescriptor *file, // IN
1223
 
                uint64 newLength)       // IN
 
1237
FileIO_Truncate(FileIODescriptor *file,  // IN:
 
1238
                uint64 newLength)        // IN:
1224
1239
{
1225
1240
   ASSERT(file);
1226
1241
 
1247
1262
 */
1248
1263
 
1249
1264
Bool
1250
 
FileIO_Close(FileIODescriptor *file) // IN
 
1265
FileIO_Close(FileIODescriptor *file)  // IN:
1251
1266
{
1252
1267
   int err;
1253
1268
 
1289
1304
 */
1290
1305
 
1291
1306
int
1292
 
FileIO_Sync(const FileIODescriptor *file) // IN
 
1307
FileIO_Sync(const FileIODescriptor *file)  // IN:
1293
1308
{
1294
1309
   ASSERT(file);
1295
1310
 
1321
1336
 */
1322
1337
 
1323
1338
static Bool
1324
 
FileIOCoalesce(struct iovec *inVec,     // IN:  Vector to coalesce from
1325
 
               int inCount,             // IN:  count for inVec
1326
 
               size_t inTotalSize,      // IN:  totalSize (bytes) in inVec
1327
 
               Bool isWrite,            // IN:  coalesce for writing (or reading)
1328
 
               Bool forceCoalesce,      // IN:  if TRUE always coalesce
1329
 
               int flags,               // IN: fileIO open flags
1330
 
               struct iovec *outVec)    // OUT: Coalesced (1-entry) iovec
 
1339
FileIOCoalesce(struct iovec *inVec,   // IN:  Vector to coalesce from
 
1340
               int inCount,           // IN:  count for inVec
 
1341
               size_t inTotalSize,    // IN:  totalSize (bytes) in inVec
 
1342
               Bool isWrite,          // IN:  coalesce for writing (or reading)
 
1343
               Bool forceCoalesce,    // IN:  if TRUE always coalesce
 
1344
               int flags,             // IN: fileIO open flags
 
1345
               struct iovec *outVec)  // OUT: Coalesced (1-entry) iovec
1331
1346
{
1332
1347
   uint8 *cBuf;
1333
1348
 
1345
1360
    * Only coalesce when the number of entries is above our count threshold
1346
1361
    * and the average size of an entry is less than our size threshold
1347
1362
    */
 
1363
 
1348
1364
   if (!forceCoalesce &&
1349
1365
       (!filePosixOptions.enabled ||
1350
1366
       inCount <= filePosixOptions.countThreshold ||
1355
1371
   // XXX: Wouldn't it be nice if we could log from here!
1356
1372
   //LOG(5, ("FILE: Coalescing %s of %d elements and %d size\n",
1357
1373
   //        isWrite ? "write" : "read", inCount, inTotalSize));
 
1374
 
1358
1375
   if (filePosixOptions.aligned || flags & FILEIO_OPEN_UNBUFFERED) {
1359
1376
      cBuf = Aligned_Malloc(sizeof(uint8) * inTotalSize);
1360
1377
   } else {
1370
1387
 
1371
1388
   outVec->iov_base = cBuf;
1372
1389
   outVec->iov_len = inTotalSize;
 
1390
 
1373
1391
   return TRUE;
1374
1392
}
1375
1393
 
1442
1460
 */
1443
1461
 
1444
1462
FileIOResult
1445
 
FileIO_Readv(FileIODescriptor *fd,      // IN
1446
 
             struct iovec *v,           // IN
1447
 
             int numEntries,            // IN
1448
 
             size_t totalSize,          // IN
1449
 
             size_t *actual)            // OUT
 
1463
FileIO_Readv(FileIODescriptor *fd,  // IN:
 
1464
             struct iovec *v,       // IN:
 
1465
             int numEntries,        // IN:
 
1466
             size_t totalSize,      // IN:
 
1467
             size_t *actual)        // OUT:
1450
1468
{
1451
1469
   size_t bytesRead = 0, sum = 0;
1452
1470
   FileIOResult fret = FILEIO_ERROR;
1478
1496
 
1479
1497
   while (nRetries < maxRetries) {
1480
1498
      ssize_t retval;
 
1499
 
1481
1500
      ASSERT(numVec > 0);
1482
1501
      STATS_ONLY(fd->readvDirect++;)
1483
1502
      retval = readv(fd->posix, vPtr, numVec);
 
1503
 
1484
1504
      if (retval == -1) {
1485
1505
         if (errno == EINTR) {
1486
1506
            NOT_TESTED();
1498
1518
         fret = FILEIO_READ_ERROR_EOF;
1499
1519
         break;
1500
1520
      }
 
1521
 
1501
1522
      /*
1502
1523
       * Ambigous case. Stupid Linux. If the bytesRead matches an
1503
1524
       * exact iovector boundary, we need to retry from the next
1506
1527
       * ambiguity handling may need to change.
1507
1528
       * --Ganesh, 08/15/2001.
1508
1529
       */
 
1530
 
1509
1531
      for (; sum <= bytesRead; vPtr++, numVec--) {
1510
1532
         sum += vPtr->iov_len;
 
1533
 
1511
1534
         /*
1512
1535
          * In each syscall, we will process atleast one iovec
1513
1536
          * or get an error back. We will therefore retry atmost
1514
1537
          * count times. If multiple iovecs were processed before
1515
1538
          * an error hit, we will retry a lesser number of times.
1516
1539
          */
 
1540
 
1517
1541
         nRetries++;
1518
1542
      }
1519
1543
      if (sum > bytesRead) {
1530
1554
   if (actual) {
1531
1555
      *actual = bytesRead;
1532
1556
   }
 
1557
 
1533
1558
   return fret;
1534
1559
}
1535
1560
 
1558
1583
 */
1559
1584
 
1560
1585
FileIOResult
1561
 
FileIO_Writev(FileIODescriptor *fd,     // IN
1562
 
              struct iovec *v,          // IN
1563
 
              int numEntries,           // IN
1564
 
              size_t totalSize,         // IN
1565
 
              size_t *actual)           // OUT
 
1586
FileIO_Writev(FileIODescriptor *fd,  // IN:
 
1587
              struct iovec *v,       // IN:
 
1588
              int numEntries,        // IN:
 
1589
              size_t totalSize,      // IN:
 
1590
              size_t *actual)        // OUT:
1566
1591
{
1567
1592
   size_t bytesWritten = 0, sum = 0;
1568
1593
   FileIOResult fret = FILEIO_ERROR;
1594
1619
 
1595
1620
   while (nRetries < maxRetries) {
1596
1621
      ssize_t retval;
 
1622
 
1597
1623
      ASSERT(numVec > 0);
1598
1624
      STATS_ONLY(fd->writevDirect++;)
1599
1625
      retval = writev(fd->posix, vPtr, numVec);
 
1626
 
1600
1627
      if (retval == -1) {
1601
1628
         fret = FileIOErrno2Result(errno);
1602
1629
         break;
1612
1639
         sum += vPtr->iov_len;
1613
1640
         nRetries++;
1614
1641
      }
 
1642
 
1615
1643
      /*
1616
1644
       * writev only seems to produce a partial iovec when the disk is
1617
1645
       * out of space.  Just call it an error. --probin
1618
1646
       */
 
1647
 
1619
1648
      if (sum != bytesWritten) {
1620
1649
         fret = FILEIO_WRITE_ERROR_NOSPC;
1621
1650
         break;
1629
1658
   if (actual) {
1630
1659
      *actual = bytesWritten;
1631
1660
   }
 
1661
 
1632
1662
   return fret;
1633
1663
}
1634
1664
 
1655
1685
 */
1656
1686
 
1657
1687
FileIOResult
1658
 
FileIO_Preadv(FileIODescriptor *fd,    // IN: File descriptor
1659
 
              struct iovec *entries,   // IN: Vector to read into
1660
 
              int numEntries,          // IN: Number of vector entries
1661
 
              uint64 offset,           // IN: Offset to start reading
1662
 
              size_t totalSize)        // IN: totalSize (bytes) in entries
 
1688
FileIO_Preadv(FileIODescriptor *fd,   // IN: File descriptor
 
1689
              struct iovec *entries,  // IN: Vector to read into
 
1690
              int numEntries,         // IN: Number of vector entries
 
1691
              uint64 offset,          // IN: Offset to start reading
 
1692
              size_t totalSize)       // IN: totalSize (bytes) in entries
1663
1693
{
1664
1694
   size_t sum = 0;
1665
1695
   struct iovec *vPtr;
1693
1723
   fileOffset = offset;
1694
1724
   while (count > 0) {
1695
1725
      size_t leftToRead = vPtr->iov_len;
1696
 
      uint8 *buf = (uint8 *)vPtr->iov_base;
 
1726
      uint8 *buf = (uint8 *) vPtr->iov_base;
1697
1727
      STATS_ONLY(fd->preadDirect++;)
1698
1728
 
1699
1729
      while (leftToRead > 0) {
1919
1949
 */
1920
1950
 
1921
1951
Bool
1922
 
FileIO_SetAllocSize(const FileIODescriptor *fd,  // IN
1923
 
                    uint64 size)                 // IN
 
1952
FileIO_SetAllocSize(const FileIODescriptor *fd,  // IN:
 
1953
                    uint64 size)                 // IN:
1924
1954
{
1925
1955
 
1926
1956
#if defined(__APPLE__) || defined(__linux__)
1933
1963
   curSize = FileIO_GetAllocSize(fd);
1934
1964
   if (curSize > size) {
1935
1965
      errno = EINVAL;
 
1966
 
1936
1967
      return FALSE;
1937
1968
   }
1938
1969
   preallocLen = size - curSize;
1952
1983
 
1953
1984
#else
1954
1985
   errno = ENOSYS;
 
1986
 
1955
1987
   return FALSE;
1956
1988
#endif
1957
1989
}
2004
2036
 */
2005
2037
 
2006
2038
FileIOResult
2007
 
FileIO_Access(ConstUnicode pathName,  // IN: Path name to be tested. May be NULL.
 
2039
FileIO_Access(ConstUnicode pathName,  // IN: Path name. May be NULL.
2008
2040
              int accessMode)         // IN: Access modes to be asserted
2009
2041
{
2010
2042
   int mode = 0;
2011
2043
 
2012
2044
   if (pathName == NULL) {
2013
2045
      errno = EFAULT;
 
2046
 
2014
2047
      return FILEIO_ERROR;
2015
2048
   }
2016
2049
 
2048
2081
 */
2049
2082
 
2050
2083
uint32
2051
 
FileIO_GetFlags(FileIODescriptor *fd)   // IN
 
2084
FileIO_GetFlags(FileIODescriptor *fd)  // IN:
2052
2085
{
2053
2086
   ASSERT(fd);
2054
2087
   ASSERT(FileIO_IsValid(fd));
2101
2134
      newPos = FileIO_Seek(fd, oldPos, FILEIO_SEEK_BEGIN);
2102
2135
      ASSERT_NOT_IMPLEMENTED(oldPos == newPos);
2103
2136
   }
 
2137
 
2104
2138
   return supported;
2105
2139
#elif defined(__APPLE__)
2106
2140
   struct statfs buf;
2107
2141
 
2108
2142
   if (fstatfs(fd->posix, &buf) == -1) {
2109
 
      Log(LGPFX" %s fstatfs failure: %s\n", __FUNCTION__, strerror(errno));
 
2143
      Log(LGPFX" %s fstatfs failure: %s\n", __FUNCTION__,
 
2144
          Err_Errno2String(errno));
2110
2145
      /* Be optimistic despite failure */
2111
2146
      return TRUE;
2112
2147
   }
2144
2179
 */
2145
2180
 
2146
2181
int64
2147
 
FileIO_GetModTime(const FileIODescriptor *fd)
 
2182
FileIO_GetModTime(const FileIODescriptor *fd)  // IN:
2148
2183
{
2149
2184
   struct stat statbuf;
2150
2185
 
2182
2217
 
2183
2218
   if (pathName == NULL) {
2184
2219
      errno = EFAULT;
 
2220
 
2185
2221
      return -1;
2186
2222
   }
2187
2223
 
2297
2333
 */
2298
2334
 
2299
2335
Bool
2300
 
FileIO_ResetExcludedFromTimeMachine(char const *pathName) // IN
 
2336
FileIO_ResetExcludedFromTimeMachine(char const *pathName)  // IN:
2301
2337
{
2302
2338
   bool result = TRUE;
2303
2339
   char xattr;
2311
2347
   }
2312
2348
   if (errno != ENOATTR) {
2313
2349
      LOG_ONCE((LGPFX" %s Couldn't get xattr on path [%s]: %s.\n",
2314
 
                __func__, pathName, strerror(errno)));
 
2350
                __func__, pathName, Err_Errno2String(errno)));
2315
2351
      result = FALSE;
2316
2352
      goto exit;
2317
2353
   }
2324
2360
                           &xattr, sizeof(xattr), 0, 0);
2325
2361
   if (sXattrResult == -1) {
2326
2362
      LOG_ONCE((LGPFX" %s Couldn't set xattr on path [%s]: %s.\n",
2327
 
                __func__, pathName, strerror(errno)));
 
2363
                __func__, pathName, Err_Errno2String(errno)));
2328
2364
      result = FALSE;
2329
2365
      goto exit;
2330
2366
   }
2352
2388
 */
2353
2389
 
2354
2390
Bool
2355
 
FileIO_SetExcludedFromTimeMachine(char const *pathName, // IN
2356
 
                                  Bool isExcluded)      // IN
 
2391
FileIO_SetExcludedFromTimeMachine(char const *pathName,  // IN:
 
2392
                                  Bool isExcluded)       // IN:
2357
2393
{
2358
2394
   Bool result = TRUE;
2359
2395
   CSBackupSetItemExcludedFunction *backupFunc;
2368
2404
      goto exit;
2369
2405
   }
2370
2406
 
2371
 
   image = dlopen(libPath, RTLD_LAZY|RTLD_GLOBAL);
 
2407
   image = dlopen(libPath, RTLD_LAZY | RTLD_GLOBAL);
2372
2408
 
2373
2409
   if (!image) {
2374
2410
      LOG_ONCE((LGPFX" %s Couldn't dlopen [%s]: %s.\n",
2375
 
               __func__, libPath, strerror(errno)));
 
2411
               __func__, libPath, Err_Errno2String(errno)));
2376
2412
      goto exit;
2377
2413
   }
2378
2414
 
2379
 
   backupFunc = (CSBackupSetItemExcludedFunction *)dlsym(image,
2380
 
                                                         symbolName);
 
2415
   backupFunc = (CSBackupSetItemExcludedFunction *) dlsym(image, symbolName);
2381
2416
 
2382
2417
   if (!backupFunc) {
2383
2418
      LOG_ONCE((LGPFX" %s Couldn't dlsym [%s]: %s.\n",
2384
 
               __func__, symbolName, strerror(errno)));
 
2419
               __func__, symbolName, Err_Errno2String(errno)));
2385
2420
      goto exit;
2386
2421
   }
2387
2422
 
2388
 
   item = CFURLCreateFromFileSystemRepresentation(NULL,
2389
 
                                                  pathName,
 
2423
   item = CFURLCreateFromFileSystemRepresentation(NULL, pathName,
2390
2424
                                                  strlen((const char *)pathName),
2391
2425
                                                  FALSE);
2392
2426
 
2413
2447
       * mark as excluded. Simply logging produces way too many log satements
2414
2448
       * and logging once would only note when this fails on the first file.
2415
2449
       */
 
2450
 
2416
2451
      goto exit;
2417
2452
   }
2418
2453
 
2479
2514
 
2480
2515
   num = sscanf(curRel, "%u.%u.%u%c%u", &cur[0], &cur[1], &cur[2], &type,
2481
2516
                &cur[3]);
 
2517
 
2482
2518
   if (num < 3) {
2483
2519
      goto exit;
2484
2520
   }
2495
2531
      ret = req[3] <= cur[3];
2496
2532
      goto exit;
2497
2533
   }
 
2534
 
2498
2535
   /*
2499
2536
    * If we get a type with no letter (num == 4), thats odd.
2500
2537
    * Consider it mal-formatted and fail.
2501
2538
    */
 
2539
 
2502
2540
   ret = num != 4;
2503
2541
 
2504
2542
exit:
2505
2543
   if (!ret && filePosixOptions.initialized && 
2506
2544
       filePosixOptions.aioNumThreads == 1) {
2507
2545
      ret =TRUE;
2508
 
   } 
 
2546
   }
 
2547
 
2509
2548
   return  ret;
2510
2549
}
2511
2550
 
2560
2599
 */
2561
2600
 
2562
2601
Bool
2563
 
FileIO_SupportsPrealloc(const char *pathName,   // IN
2564
 
                        Bool fsCheck)           // IN
 
2602
FileIO_SupportsPrealloc(const char *pathName,  // IN:
 
2603
                        Bool fsCheck)          // IN:
2565
2604
{
2566
2605
   Bool ret = TRUE;
2567
2606
 
2570
2609
   }
2571
2610
 
2572
2611
   if (!fsCheck) {
2573
 
         return ret;
 
2612
      return ret;
2574
2613
   }
2575
2614
 
2576
2615
#if (defined( __linux__) && !defined(VMX86_SERVER))
2595
2634
      Unicode_Free(fullPath);
2596
2635
   }
2597
2636
#endif
 
2637
 
2598
2638
   return ret;
2599
2639
}
2600
2640