summaryrefslogtreecommitdiff
path: root/filesystems/fuse-loggedfs/patches/patch-aa
blob: dc899f85cfcba0c8f322b1bce042a69630808c51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
$NetBSD: patch-aa,v 1.2 2016/03/01 20:16:17 joerg Exp $

--- src/loggedfs.cpp.orig	2007-01-23 21:05:11.000000000 +0000
+++ src/loggedfs.cpp
@@ -30,7 +30,11 @@
 #include <fcntl.h>
 #include <dirent.h>
 #include <errno.h>
+#ifdef HAVE_SYS_STATVFS_H
+#include <sys/statvfs.h>
+#else
 #include <sys/statfs.h>
+#endif
 #ifdef HAVE_SETXATTR
 #include <sys/xattr.h>
 #endif
@@ -85,12 +89,14 @@ static bool isAbsolutePath( const char *
 
 static char* getAbsolutePath(const char *path)
 {
-    char *realPath=new char[strlen(path)+strlen(loggedfsArgs->mountPoint)+1];
+    char *realPath=new char[strlen(path)+strlen(loggedfsArgs->mountPoint)+2];
+
+    (void) snprintf(realPath, strlen(path)+strlen(loggedfsArgs->mountPoint)+2,
+    		"%s%s%s",
+		loggedfsArgs->mountPoint,
+		(path[0] == '/') ? "" : "/",
+		path);
 
-    strcpy(realPath,loggedfsArgs->mountPoint);
-    if (realPath[strlen(realPath)-1]=='/')
-        realPath[strlen(realPath)-1]='\0';
-    strcat(realPath,path);
     return realPath;
 
 }
@@ -121,7 +127,7 @@ static char* getcallername()
 
 static void loggedfs_log(const char* path,const char* action,const int returncode,const char *format,...)
 {
-    char *retname;
+    const char *retname;
     if (returncode >= 0)
         retname = "SUCCESS";
     else
@@ -156,7 +162,7 @@ static int loggedFS_getattr(const char *
 
     char *aPath=getAbsolutePath(path);
     path=getRelativePath(path);
-    res = lstat(path, stbuf);
+    res = lstat(aPath, stbuf);
     loggedfs_log(aPath,"getattr",res,"getattr %s",aPath);
     if(res == -1)
         return -errno;
@@ -210,7 +216,7 @@ static int loggedFS_readdir(const char *
     path=getRelativePath(path);
 
 
-    dp = opendir(path);
+    dp = opendir(aPath);
     if(dp == NULL) {
         res = -errno;
         loggedfs_log(aPath,"readdir",-1,"readdir %s",aPath);
@@ -427,7 +433,7 @@ static int loggedFS_truncate(const char 
     return 0;
 }
 
-#if (FUSE_USE_VERSION==25)
+#if (FUSE_USE_VERSION >= 25)
 static int loggedFS_utime(const char *path, struct utimbuf *buf)
 {
     int res;
@@ -650,7 +656,11 @@ bool processArgs(int argc, char *argv[],
 // logging the ~/.kde/share/config directory, in which hard links for lock
 // files are verified by their inode equivalency.
 
+#ifdef __NetBSD__
+#define COMMON_OPTS ""
+#else
 #define COMMON_OPTS "nonempty,use_ino"
+#endif
 
     while ((res = getopt (argc, argv, "hpfec:l:")) != -1)
     {
@@ -770,7 +780,7 @@ int main(int argc, char *argv[])
     loggedFS_oper.chmod	= loggedFS_chmod;
     loggedFS_oper.chown	= loggedFS_chown;
     loggedFS_oper.truncate	= loggedFS_truncate;
-#if (FUSE_USE_VERSION==25)
+#if (FUSE_USE_VERSION >= 25)
     loggedFS_oper.utime       = loggedFS_utime;
 #else
     loggedFS_oper.utimens	= loggedFS_utimens;