Changeset 1763
- Timestamp:
- Apr 20, 2007, 2:05:07 AM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/fdlimit.c
r1441 r1763 68 68 * Local prototypes 69 69 **********************************************************************/ 70 static int ErrorFromErrno();71 70 static int OpenFile( int i, char * folder, char * name, int write ); 72 71 static void CloseFile( int i ); … … 408 407 409 408 /*********************************************************************** 410 * ErrorFromErrno411 **********************************************************************/412 static int ErrorFromErrno()413 {414 if( errno == EACCES || errno == EROFS )415 return TR_ERROR_IO_PERMISSIONS;416 return TR_ERROR_IO_OTHER;417 }418 419 /***********************************************************************420 409 * CheckFolder 421 410 *********************************************************************** … … 427 416 struct stat sb; 428 417 char * path; 418 int ret; 429 419 430 420 tr_dbg( "Opening %s in %s (%d)", name, folder, write ); … … 451 441 if( mkdir( path, 0777 ) ) 452 442 { 443 ret = tr_ioErrorFromErrno(); 453 444 tr_err( "Could not create folder '%s'", path ); 454 445 free( path ); 455 return ErrorFromErrno();446 return ret; 456 447 } 457 448 } … … 472 463 /* Now try to really open the file */ 473 464 file->file = open( path, write ? ( O_RDWR | O_CREAT ) : O_RDONLY, 0666 ); 474 free( path );475 476 465 if( file->file < 0 ) 477 466 { 478 int ret = ErrorFromErrno(); 467 ret = tr_ioErrorFromErrno(); 468 free( path ); 479 469 tr_err( "Could not open %s in %s (%d, %d)", name, folder, write, ret ); 480 470 return ret; 481 471 } 472 free( path ); 482 473 483 474 return TR_OK; -
trunk/libtransmission/inout.c
r1608 r1763 410 410 if( readOrWrite( file, buf, cur ) != cur ) 411 411 { 412 ret = tr_ioErrorFromErrno(); 412 413 tr_fdFileRelease( file ); 413 ret = TR_ERROR_IO_OTHER;414 414 goto cleanup; 415 415 } -
trunk/libtransmission/transmission.h
r1655 r1763 66 66 #define TR_ERROR_ASSERT 0x82000000 67 67 /* I/O errors */ 68 #define TR_ERROR_IO_MASK 0x000000 0F68 #define TR_ERROR_IO_MASK 0x000000FF 69 69 #define TR_ERROR_IO_PARENT 0x80000001 70 70 #define TR_ERROR_IO_PERMISSIONS 0x80000002 71 #define TR_ERROR_IO_OTHER 0x80000008 71 #define TR_ERROR_IO_SPACE 0x80000004 72 #define TR_ERROR_IO_RESOURCES 0x80000008 73 #define TR_ERROR_IO_OTHER 0x80000010 72 74 /* Misc */ 73 #define TR_ERROR_TC_MASK 0x00000 0F074 #define TR_ERROR_TC_ERROR 0x80000 01075 #define TR_ERROR_TC_WARNING 0x80000 02075 #define TR_ERROR_TC_MASK 0x00000F00 76 #define TR_ERROR_TC_ERROR 0x80000100 77 #define TR_ERROR_TC_WARNING 0x80000200 76 78 77 79 /*********************************************************************** -
trunk/libtransmission/utils.c
r1579 r1763 360 360 } 361 361 362 int 363 tr_ioErrorFromErrno( void ) 364 { 365 if( EACCES == errno || EROFS == errno ) 366 { 367 return TR_ERROR_IO_PERMISSIONS; 368 } 369 else if( ENOSPC == errno ) 370 { 371 return TR_ERROR_IO_SPACE; 372 } 373 else if( EMFILE == errno || EFBIG == errno ) 374 { 375 return TR_ERROR_IO_RESOURCES; 376 } 377 tr_dbg( "generic i/o errno from errno: %s", strerror( errno ) ); 378 return TR_ERROR_IO_OTHER; 379 } 380 362 381 char * 363 382 tr_errorString( int code ) … … 375 394 case TR_ERROR_IO_PERMISSIONS: 376 395 return "Insufficient permissions"; 396 case TR_ERROR_IO_SPACE: 397 return "Insufficient free space"; 398 case TR_ERROR_IO_RESOURCES: 399 return "Insufficient resources"; 377 400 case TR_ERROR_IO_OTHER: 378 401 return "Generic I/O error"; -
trunk/libtransmission/utils.h
r1579 r1763 74 74 char * tr_dupstr( const char * base, int len ); 75 75 76 int tr_ioErrorFromErrno( void ); 77 76 78 char * tr_errorString( int code ); 77 79
Note: See TracChangeset
for help on using the changeset viewer.