- Timestamp:
- Oct 13, 2010 12:09:23 PM (14 years ago)
- Location:
- trunk/src/VBox/Main/linux
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/linux/HostHardwareLinux.cpp
r32431 r33100 1123 1123 flags = fcntl(fd, F_GETFL, NULL); 1124 1124 if ( flags < 0 1125 || fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) 1125 || fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0 1126 || fcntl(fd, F_SETFD, FD_CLOEXEC) < 0 /* race here */) 1126 1127 { 1127 1128 Assert(errno > 0); … … 1227 1228 1228 1229 /* 1229 * Create the pipe and set the close-on-exec flag if requested.1230 * Create the pipe and set the close-on-exec flag. 1230 1231 */ 1231 1232 int aFds[2] = {-1, -1}; 1232 1233 if (pipe(aFds)) 1233 1234 return RTErrConvertFromErrno(errno); 1235 if ( fcntl(aFds[0], F_SETFD, FD_CLOEXEC) < 0 1236 || fcntl(aFds[1], F_SETFD, FD_CLOEXEC) < 0) 1237 { 1238 int rc = RTErrConvertFromErrno(errno); 1239 close(aFds[0]); 1240 close(aFds[1]); 1241 return rc; 1242 } 1234 1243 1235 1244 *phPipeRead = aFds[0]; -
trunk/src/VBox/Main/linux/USBGetDevices.cpp
r32469 r33100 93 93 int USBProxyLinuxCheckForUsbfs(const char *pcszDevices) 94 94 { 95 int fd ;95 int fd, rc = VINF_SUCCESS; 96 96 97 97 fd = open(pcszDevices, O_RDONLY, 00600); 98 if (fd )98 if (fd >= 0) 99 99 { 100 100 /* … … 104 104 if (!fstatfs(fd, &StFS)) 105 105 { 106 if (StFS.f_type == USBDEVICE_SUPER_MAGIC) 107 return VINF_SUCCESS; 108 else 109 return VERR_NOT_FOUND; 106 if (StFS.f_type != USBDEVICE_SUPER_MAGIC) 107 rc = VERR_NOT_FOUND; 110 108 } 111 109 else 112 return RTErrConvertFromErrno(errno); 110 rc = RTErrConvertFromErrno(errno); 111 close(fd); 113 112 } 114 113 else 115 r eturnRTErrConvertFromErrno(errno);116 return 0;114 rc = RTErrConvertFromErrno(errno); 115 return rc; 117 116 } 118 117 … … 548 547 Dev.enmState = USBDEVICESTATE_UNUSED; 549 548 550 rc = VINF_SUCCESS; 549 /* Set close on exit and hope no one is racing us. */ 550 rc = fcntl(fileno(pFile), F_SETFD, FD_CLOEXEC) >= 0 551 ? VINF_SUCCESS 552 : RTErrConvertFromErrno(errno); 551 553 while ( RT_SUCCESS(rc) 552 554 && fgets(szLine, sizeof(szLine), pFile)) … … 781 783 #undef PREFIX 782 784 } /* parse loop */ 785 fclose(pFile); 783 786 784 787 /* -
trunk/src/VBox/Main/linux/USBProxyServiceLinux.cpp
r32431 r33100 45 45 #include <stdio.h> 46 46 #include <errno.h> 47 #include <fcntl.h> 47 48 #include <unistd.h> 48 49 #include <sys/statfs.h> … … 181 182 if (!pipe(pipes)) 182 183 { 183 mWakeupPipeR = pipes[0]; 184 mWakeupPipeW = pipes[1]; 185 /* 186 * Start the poller thread. 187 */ 188 rc = start(); 189 if (RT_SUCCESS(rc)) 184 /* Set close on exec (race here!) */ 185 if ( fcntl(pipes[0], F_SETFD, FD_CLOEXEC) >= 0 186 && fcntl(pipes[1], F_SETFD, FD_CLOEXEC) >= 0) 190 187 { 191 RTStrFree(pszDevices); 192 LogFlowThisFunc(("returns successfully - mWakeupPipeR/W=%d/%d\n", 193 mWakeupPipeR, mWakeupPipeW)); 194 return VINF_SUCCESS; 188 mWakeupPipeR = pipes[0]; 189 mWakeupPipeW = pipes[1]; 190 /* 191 * Start the poller thread. 192 */ 193 rc = start(); 194 if (RT_SUCCESS(rc)) 195 { 196 RTStrFree(pszDevices); 197 LogFlowThisFunc(("returns successfully - mWakeupPipeR/W=%d/%d\n", 198 mWakeupPipeR, mWakeupPipeW)); 199 return VINF_SUCCESS; 200 } 201 202 RTFileClose(mWakeupPipeR); 203 RTFileClose(mWakeupPipeW); 204 mWakeupPipeW = mWakeupPipeR = NIL_RTFILE; 195 205 } 196 197 RTFileClose(mWakeupPipeR); 198 RTFileClose(mWakeupPipeW); 199 mWakeupPipeW = mWakeupPipeR = NIL_RTFILE; 206 else 207 { 208 rc = RTErrConvertFromErrno(errno); 209 Log(("USBProxyServiceLinux::USBProxyServiceLinux: fcntl failed, errno=%d\n", errno)); 210 close(pipes[0]); 211 close(pipes[1]); 212 } 200 213 } 201 214 else
Note:
See TracChangeset
for help on using the changeset viewer.