1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <sysdeps.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <msg/msg.h>
#include <msg/wrap.h>
#include <str/str.h>
#include "bcron.h"
static void copystat(struct ministat* m, const struct stat* s)
{
memset(m, 0, sizeof *m);
m->exists = 1;
m->device = s->st_dev;
m->inode = s->st_ino;
m->mode = s->st_mode;
m->size = s->st_size;
m->mtime = s->st_mtime;
}
void minifstat(int fd, struct ministat* s)
{
struct stat st;
if (fstat(fd, &st) != 0)
die1sys(111, "Could not fstat");
else
copystat(s, &st);
}
void ministat(const char* path, struct ministat* s)
{
struct stat st;
if (stat(path, &st) != 0) {
if (errno == ENOENT)
memset(s, 0, sizeof *s);
else
die3sys(111, "Could not stat '", path, "'");
}
else
copystat(s, &st);
}
void ministat2(const char* base, const char* entry, struct ministat* s)
{
static str path;
wrap_str(str_copy3s(&path, base, "/", entry));
ministat(path.s, s);
}
|