Created
May 8, 2018 20:22
-
-
Save dvdfreitag/87a17a59a6f78843b10528c73f7f123e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <errno.h> | |
#include <sys/stat.h> | |
#include <stdio.h> | |
#include <string.h> | |
void print_usage(void) | |
{ | |
printf("Usage: blksize DIRECTORY\n"); | |
printf("Attempts to determine the optimal block size using stat\n"); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 2) | |
{ | |
print_usage(); | |
return 1; | |
} | |
struct stat stats; | |
int rc = stat(argv[1], &stats); | |
if (rc != 0) | |
{ | |
printf("Error: %s\n\n", strerror(errno)); | |
print_usage(); | |
return rc; | |
} | |
printf("%ld\n", stats.st_blksize); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment