blob: b10194c5dcf4e668c160a25f3fd55a74bbd8ea76 (
plain)
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
|
#include <reent.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include "fio.h"
int _fstat_r(struct _reent * reent, int fd, struct stat * buf) {
off_t c;
memset(buf, 0, sizeof(struct stat));
if (!fio_is_open(fd)) {
reent->_errno = EBADF;
return -1;
}
buf->st_mode = S_IFCHR;
buf->st_blksize = 1024;
c = fio_seek(fd, 0, SEEK_CUR);
if (c >= 0) {
buf->st_size = fio_seek(fd, 0, SEEK_END);
fio_seek(fd, c, SEEK_SET);
}
return 0;
}
|