summaryrefslogtreecommitdiff
path: root/filesystems/fuse-lzofs/patches/patch-ab
blob: d28a131e9da1056d0dec60923979e87b0cede470 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
$NetBSD: patch-ab,v 1.2 2007/03/08 05:14:38 pooka Exp $

--- LZOlayer_fs.c.orig	2006-05-19 04:23:35.000000000 +0900
+++ LZOlayer_fs.c	2007-03-08 14:12:22.000000000 +0900
@@ -21,6 +21,15 @@
 #define __USE_UNIX98
 #include <unistd.h>
 #include <zlib.h>
+#ifndef __NetBSD__
+#define ordwr		O_RDWR|O_LARGEFILE
+#define ordonly	O_RDONLY|O_LARGEFILE
+#define owronly	O_WRONLY|O_LARGEFILE
+#else
+#define ordwr		O_RDWR
+#define ordonly	O_RDONLY
+#define owronly	O_WRONLY
+#endif
 
 #include "minilzo.h"
 #define HEAP_ALLOC(var, size) \
@@ -124,7 +133,7 @@
   
   if (S_ISREG(stbuf->st_mode))
   {
-    int fd = open(xPath, O_RDONLY|O_LARGEFILE);
+    int fd = open(xPath, ordonly);
     read(fd, &stbuf->st_size, sizeof(off_t));
     close(fd);
   }
@@ -143,15 +152,26 @@
 
 static int LZOlayer_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi)
 {
+  char     dpath[MAXPATHLEN+1];
   char     *xPath = LZOlayer_makePath(path);
+  char     *p;
 
   DIR *dp = opendir(xPath);
   struct dirent *dirp;
+  struct stat sb;
+
+  strcpy(dpath, path);
+  p = dpath + strlen(path);
   
   while(dp)
   {
-    if ((dirp = readdir(dp)) != NULL)
-      filler(buf, dirp->d_name, NULL, 0);
+    if ((dirp = readdir(dp)) != NULL) {
+      strcpy(p, dirp->d_name);
+      if (LZOlayer_getattr(dpath, &sb))
+        filler(buf, dirp->d_name, NULL, 0);
+      else
+        filler(buf, dirp->d_name, &sb, 0);
+    }
     else break;
   }
   
@@ -166,7 +186,7 @@
 {
   char *xPath = LZOlayer_makePath(path);
   
-  int fd = open(xPath, O_RDONLY|O_LARGEFILE);
+  int fd = open(xPath, ordonly);
   off_t outLen = 0;
   read(fd, &outLen, sizeof(off_t));
   close(fd);
@@ -193,7 +213,7 @@
   char *xPath            = filePtr->path;
   
   int done = 0;
-  int fd = open(xPath, O_RDONLY|O_LARGEFILE);
+  int fd = open(xPath, ordonly);
   
   while(1)
   {
@@ -249,7 +269,7 @@
   off_t block_start   = (float)filePtr->packets[min_offset].offset / (float)block_size;
   
   char *xPath = filePtr->path;
-  int fd      = open(xPath, O_RDWR|O_LARGEFILE);
+  int fd      = open(xPath, ordwr);
   LZOlayer_block_seek(fd, block_start);
   
   off_t alloc_size = (filePtr->size-(block_start*block_size)
@@ -315,10 +335,10 @@
   {
     LZOlayer_packet_sync(path, fi);
     
-    int fd = open(filePtr->path, O_WRONLY|O_LARGEFILE);
+    int fd = open(filePtr->path, owronly);
     if(fd == -1)
     {
-      open(filePtr->path, O_CREAT|O_WRONLY|O_LARGEFILE);
+      open(filePtr->path, O_CREAT|owronly);
       chown(filePtr->path, fuse_get_context()->uid, fuse_get_context()->gid);
     }
 // old open/create for write
@@ -365,7 +385,7 @@
   }
   else
   {
-    int fd = open(xPath, O_WRONLY|O_LARGEFILE);
+    int fd = open(xPath, owronly);
     off_t null = 0;
     write(fd, &null, sizeof(off_t));
     write(fd, &null, sizeof(off_t));
@@ -383,7 +403,7 @@
 {
   char *xPath = LZOlayer_makePath(path);
   
-  int fd = open(xPath, O_RDWR|O_LARGEFILE);
+  int fd = open(xPath, ordwr);
   off_t file_size = 0;
   read(fd, &file_size, sizeof(off_t));