+#include "redis.h"
+#include "lzf.h" /* LZF compression library */
+
#include <math.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <arpa/inet.h>
#include <sys/stat.h>
-#include "rdb.h"
-#include "lzf.h" /* LZF compression library */
static int rdbWriteRaw(rio *rdb, void *p, size_t len) {
if (rdb && rioWrite(rdb,p,len) == 0)
rio rdb;
fp = fopen(filename,"r");
- if (!fp) return REDIS_ERR;
+ if (!fp) {
+ errno = ENOENT;
+ return REDIS_ERR;
+ }
rioInitWithFile(&rdb,fp);
if (rioRead(&rdb,buf,9) == 0) goto eoferr;
buf[9] = '\0';
if (memcmp(buf,"REDIS",5) != 0) {
fclose(fp);
redisLog(REDIS_WARNING,"Wrong signature trying to load DB from file");
+ errno = EINVAL;
return REDIS_ERR;
}
rdbver = atoi(buf+5);
if (rdbver < 1 || rdbver > 2) {
fclose(fp);
redisLog(REDIS_WARNING,"Can't handle RDB format version %d",rdbver);
+ errno = EINVAL;
return REDIS_ERR;
}