8 #include <ashd/utils.h>
12 #include "statserve.h"
18 static struct fileinfo fsserve(struct source *src, char *nm)
20 struct fssrc *d = src->pdata;
26 if((nm[0] == '.') || strchr(nm, '/'))
27 return((struct fileinfo){});
28 p = sprintf2("%s/%s", d->path, nm);
31 flog(LOG_WARNING, "fssrc: %s: %s", p, strerror(errno));
33 return((struct fileinfo){});
35 if(!S_ISREG(sb.st_mode)) {
37 return((struct fileinfo){});
39 if((fd = open(p, O_RDONLY)) < 0) {
40 flog(LOG_WARNING, "fssrc: %s: %s", p, strerror(errno));
42 return((struct fileinfo){});
45 sizebuf(rb, sb.st_size);
48 if((ret = read(fd, rb.b + rb.d, rb.s - rb.d)) < 0) {
49 flog(LOG_ERR, "fssrc: %s: %s", p, strerror(errno));
53 return((struct fileinfo){});
60 return((struct fileinfo){.mtime = sb.st_mtime, .sz = rb.d, .data = rb.b, .ctype = "image/png"});
63 struct source *mkfssrc(char *path)
70 src->pdata = omalloc(d);
71 d->path = sstrdup(path);