Changeset 1390 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Mar 9, 2007 8:52:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/darwin/filelock-darwin.cpp
r1388 r1390 29 29 #include <sys/types.h> 30 30 #include <sys/ioctl.h> 31 #include <sys/fcntl.h s>31 #include <sys/fcntl.h> 32 32 #include <fcntl.h> 33 33 #include <unistd.h> … … 80 80 if (fcntl(File, (fLock & RTFILE_LOCK_WAIT) ? F_SETLKW : F_SETLK, &fl) >= 0) 81 81 return VINF_SUCCESS; 82 int iErr = errno; 83 if (iErr == ENOTSUP) 84 { 85 /* 86 * This is really bad hack for getting VDIs to work somewhat 87 * safely on SMB mounts. 88 */ 89 /** @todo we need to keep track of these locks really. Anyone requiring to lock more 90 * than one part of a file will have to fix this. */ 91 unsigned f = 0; 92 Assert(RTFILE_LOCK_WAIT); 93 if (fLock & RTFILE_LOCK_WAIT) 94 f |= LOCK_NB; 95 if (fLock & RTFILE_LOCK_WRITE) 96 f |= LOCK_EX; 97 else 98 f |= LOCK_SH; 99 if (!flock(File, f)) 100 return VINF_SUCCESS; 101 iErr = errno; 102 if (iErr == EWOULDBLOCK) 103 return VERR_FILE_LOCK_VIOLATION; 104 } 82 105 83 int iErr = errno;84 106 if ( iErr == EAGAIN 85 107 || iErr == EACCES) … … 124 146 return VINF_SUCCESS; 125 147 126 /* @todo check error codes for non existing lock. */127 148 int iErr = errno; 149 if (iErr == ENOTSUP) 150 { 151 /* A SMB hack, see RTFileLock. */ 152 if (!flock(File, LOCK_UN)) 153 return VINF_SUCCESS; 154 } 155 156 /** @todo check error codes for non existing lock. */ 128 157 if ( iErr == EAGAIN 129 158 || iErr == EACCES) … … 133 162 } 134 163 135
Note:
See TracChangeset
for help on using the changeset viewer.