From 58f89cdc774af967833bca7d3524c5c7957b05ca Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 1 Jul 2007 01:50:14 +0000 Subject: [PATCH] replace the unhelpful error message "error: insufficient resources" with more descriptive cases --- libtransmission/ipcparse.c | 8 ++++++-- libtransmission/transmission.h | 13 +++++++------ libtransmission/utils.c | 9 ++++++--- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/libtransmission/ipcparse.c b/libtransmission/ipcparse.c index f558e719c..bf53485f5 100644 --- a/libtransmission/ipcparse.c +++ b/libtransmission/ipcparse.c @@ -799,9 +799,13 @@ ipc_addstat( benc_val_t * list, int tor, { tr_bencInitStr( item, "io-space", -1, 1 ); } - else if( TR_ERROR_ISSET( TR_ERROR_IO_RESOURCES, error ) ) + else if( TR_ERROR_ISSET( TR_ERROR_IO_FILE_TOO_BIG, error ) ) { - tr_bencInitStr( item, "io-resources", -1, 1 ); + tr_bencInitStr( item, "io-file-too-big", -1, 1 ); + } + else if( TR_ERROR_ISSET( TR_ERROR_IO_OPEN_FILES, error ) ) + { + tr_bencInitStr( item, "io-open-files", -1, 1 ); } else if( TR_ERROR_ISSET( TR_ERROR_IO_MASK, error ) ) { diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index cd35f9e6c..0624f09a8 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -77,12 +77,13 @@ extern "C" { #define TR_ERROR_ASSERT 0x82000000 /* I/O errors */ #define TR_ERROR_IO_MASK 0x000000FF -#define TR_ERROR_IO_PARENT 0x80000001 -#define TR_ERROR_IO_PERMISSIONS 0x80000002 -#define TR_ERROR_IO_SPACE 0x80000004 -#define TR_ERROR_IO_RESOURCES 0x80000008 -#define TR_ERROR_IO_DUP_DOWNLOAD 0x8000000A -#define TR_ERROR_IO_OTHER 0x80000010 +#define TR_ERROR_IO_PARENT ((1<<31) | (1<<0)) +#define TR_ERROR_IO_PERMISSIONS ((1<<31) | (1<<1)) +#define TR_ERROR_IO_SPACE ((1<<31) | (1<<2)) +#define TR_ERROR_IO_FILE_TOO_BIG ((1<<31) | (1<<3)) +#define TR_ERROR_IO_OPEN_FILES ((1<<31) | (1<<4)) +#define TR_ERROR_IO_DUP_DOWNLOAD ((1<<31) | (1<<5)) +#define TR_ERROR_IO_OTHER ((1<<31) | (1<<6)) /* Misc */ #define TR_ERROR_TC_MASK 0x00000F00 #define TR_ERROR_TC_ERROR 0x80000100 diff --git a/libtransmission/utils.c b/libtransmission/utils.c index f1ee07951..94fbb3bb6 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -342,8 +342,9 @@ tr_ioErrorFromErrno( void ) case ENOSPC: return TR_ERROR_IO_SPACE; case EMFILE: + return TR_ERROR_IO_FILE_TOO_BIG; case EFBIG: - return TR_ERROR_IO_RESOURCES; + return TR_ERROR_IO_OPEN_FILES; default: tr_dbg( "generic i/o errno from errno: %s", strerror( errno ) ); return TR_ERROR_IO_OTHER; @@ -369,8 +370,10 @@ tr_errorString( int code ) return "Insufficient free space"; case TR_ERROR_IO_DUP_DOWNLOAD: return "Already active transfer with same name and download folder"; - case TR_ERROR_IO_RESOURCES: - return "Insufficient resources"; + case TR_ERROR_IO_FILE_TOO_BIG: + return "File too large"; + case TR_ERROR_IO_OPEN_FILES: + return "Too many open files"; case TR_ERROR_IO_OTHER: return "Generic I/O error"; }