Skip to content

Commit

Permalink
A few helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Feh committed Apr 29, 2014
1 parent 1fb9cd9 commit 5f598ce
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions write-bench.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <unistd.h>
#include <assert.h>
#include <time.h>
Expand Down Expand Up @@ -50,6 +51,20 @@ int is_regular_file(int fd)
return (S_ISREG(st.st_mode));
}

ssize_t block_size(int fd)
{
struct statfs st;
assert(fstatfs(fd, &st) != -1);
return (ssize_t) st.f_bsize;
}

ssize_t filesize(int fd)
{
struct stat st;
assert(fstat(fd, &st) != -1);
return (ssize_t) st.st_size;
}

int main(int argc, char *argv[])
{
int i;
Expand Down

0 comments on commit 5f598ce

Please sign in to comment.