#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/mount.h>
#include "bless.h"
int getMountPoint(unsigned char f1[], unsigned char f2[], unsigned char mountp[]) {
struct statfs fsinfo;
int err;
unsigned char f2mount[MNAMELEN];
if(f1[0] != '\0') {
if(err = statfs(f1, &fsinfo)) {
errorprintf("No mount point for %s\n", f1);
return 1;
} else {
strncpy(mountp, fsinfo.f_mntonname, MNAMELEN-1);
mountp[MNAMELEN-1] = '\0';
verboseprintf("Mount point for %s is %s\n", f1, mountp);
}
}
if(f2[0] != '\0') {
if(err = statfs(f2, &fsinfo)) {
errorprintf("No mount point for %s\n", f2);
return 2;
} else {
strncpy(f2mount, fsinfo.f_mntonname, MNAMELEN-1);
f2mount[MNAMELEN-1] = '\0';
verboseprintf("Mount point for %s is %s\n", f2, f2mount);
}
}
if(f2[0] != '\0') {
if(f1[0] != '\0') {
if(strcmp(mountp, f2mount)) {
mountp[0] = '\0';
return 3;
} else {
return 0;
}
} else {
strncpy(mountp, f2mount, MNAMELEN);
return 0;
}
} else {
return 0;
}
errorprintf("No folders specified");
return 4;
}