1 #include <sys/param.h>
\r
2 #include <sys/ucred.h>
\r
3 #include <sys/mount.h>
\r
5 #include "eyefi-config.h"
\r
10 int fd_flush(int fd)
\r
15 perror("fsync() failed");
\r
20 #define LINEBUFSZ 1024
\r
21 char *locate_eyefi_mount(void)
\r
23 static char eyefi_mount[PATHNAME_MAX]; // PATH_MAX anyone?
\r
25 if (strlen(eyefi_mount))
\r
26 return &eyefi_mount[0];
\r
30 struct statfs * fsbuf;
\r
33 if ((numfs = getfsstat(NULL, 0, MNT_WAIT)) < 0) {
\r
34 debug_printf(2, "unable to obtain the number of file systems\n");
\r
38 bufsize = (long)numfs *sizeof(struct statfs);
\r
39 if ((fsbuf = malloc(bufsize)) == NULL) {
\r
40 debug_printf(2, "unable to allocate space for filesystem list\n");
\r
44 if (getfsstat(fsbuf, bufsize, MNT_WAIT) < 0) {
\r
45 debug_printf(2, "unable to get the list of filesystems\n");
\r
49 for(i = 0; i < numfs; i++) {
\r
50 if(fsbuf[i].f_type != 5) continue; // Not MSDOS
\r
52 char *file = eyefi_file_on(REQM, fsbuf[i].f_mntonname);
\r
53 debug_printf(2, "looking for EyeFi file here: '%s'\n", file);
\r
55 struct stat statbuf;
\r
57 statret = stat(file, &statbuf);
\r
60 debug_printf(2, "fs at: %s is not an Eye-Fi card, skipping...\n",
\r
65 strcpy(&eyefi_mount[0], fsbuf[i].f_mntonname);
\r
66 debug_printf(1, "located EyeFi card at: '%s'\n", eyefi_mount);
\r
70 if (strlen(eyefi_mount))
\r
71 return &eyefi_mount[0];
\r
73 debug_printf(0, "unable to locate Eye-Fi card\n");
\r
74 if (eyefi_debug_level < 5) {
\r
75 debug_printf(0, "Please check that your card is inserted and mounted\n");
\r
76 debug_printf(0, "If you still have issues, please re-run with the '-d5' option and report the output\n");
\r
78 debug_printf(0, "----------------------------------------------\n");
\r
79 debug_printf(0, "Debug information:\n");
\r