Created
March 14, 2014 20:20
-
-
Save andresriancho/9555961 to your computer and use it in GitHub Desktop.
Learning about max filename sizes in Ubuntu with encryptedfs home
This file contains hidden or 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
| pablo@eulogia:/tmp$ cat main.c | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #ifdef __APPLE__ | |
| #include <sys/param.h> | |
| #include <sys/mount.h> | |
| #else | |
| #include <sys/statfs.h> | |
| #endif | |
| long get_max_namelen(struct statfs* buf) { | |
| #ifdef __APPLE__ | |
| return MNAMELEN; | |
| #else | |
| return buf->f_namelen; | |
| #endif | |
| } | |
| int main(int argc, const char** argv) { | |
| char path_buf[1024]; | |
| const char *path = (argc == 2) ? strcpy(path_buf, argv[1]) : getcwd(path_buf, 1024); | |
| struct statfs *buf; | |
| statfs(path, buf); | |
| printf("statsfs for %s\n", path); | |
| printf("--------\n"); | |
| printf("max namelen: %ld\n", get_max_namelen(buf)); | |
| return 0; | |
| } | |
| pablo@eulogia:/tmp$ | |
| pablo@eulogia:/tmp$ gcc main.c -o main | |
| pablo@eulogia:/tmp$ ./main | |
| statsfs for /tmp | |
| -------- | |
| max namelen: 255 | |
| pablo@eulogia:/tmp$ ./main /home/pablo/ | |
| statsfs for /home/pablo/ | |
| -------- | |
| max namelen: 143 | |
| pablo@eulogia:/tmp$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment