diff options
author | Simon Rettberg | 2017-11-08 16:14:32 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-11-08 16:14:32 +0100 |
commit | 01a2ebb9a402dc4c3f9183d457565685885f6fb9 (patch) | |
tree | b54fd8702865fcb02abf865536734987e1b52a01 /src/shared/log.c | |
parent | [SERVER] Add multiple config options for limiting stuff (diff) | |
download | dnbd3-01a2ebb9a402dc4c3f9183d457565685885f6fb9.tar.gz dnbd3-01a2ebb9a402dc4c3f9183d457565685885f6fb9.tar.xz dnbd3-01a2ebb9a402dc4c3f9183d457565685885f6fb9.zip |
[SERVER] rpc: Add q=logfile, q=altservers and q=config to /query
Diffstat (limited to 'src/shared/log.c')
-rw-r--r-- | src/shared/log.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/shared/log.c b/src/shared/log.c index 701bc89..a3ffe4a 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -129,17 +129,17 @@ void logadd(const logmask_t mask, const char *fmt, ...) } } -bool log_fetch(char *buffer, int size) +ssize_t log_fetch(char *buffer, int size) { if ( logFile == NULL || size <= 1 ) - return false; + return -1; int fd = open( logFile, O_RDONLY ); if ( fd < 0 ) - return false; + return -1; off_t off = lseek( fd, 0, SEEK_END ); if ( off == (off_t)-1 ) { close( fd ); - return false; + return -1; } if ( (off_t)size <= off ) { off -= size; @@ -148,10 +148,8 @@ bool log_fetch(char *buffer, int size) } ssize_t ret = pread( fd, buffer, size - 1, off ); close( fd ); - if ( ret < 0 ) - return false; buffer[ret] = '\0'; - return true; + return ret; } static int writeLevel(char *buffer, logmask_t level) |