2007-03-16 09:21:16 +01:00
|
|
|
$NetBSD: patch-ab,v 1.3 2007/03/16 08:21:16 pooka Exp $
|
Initial import of fuse-lzofs-20060306.
LZOlayer Filesystem is a filesystem which allows you to use transparently
compressed files, just as they would be normal files.
Both read and write operations are possible, along with other most common
system calls. It consumes little memory in my opinion, because files are
divided into blocks, which can be decompressed separetly. In other words,
if you (or an application) would like to read byte 4,500,000 in a file
sized 5,000,000 bytes, it only decompresses a block which constain wanted
data. Write operation is based on a packet gathering and after reaching its
limit it 'syncs' the data. It allows it's user to write/modify files pretty
fast, despite the fact it's block divided.
LZOlayer FileSystem was meant to support only LZO compression algorythm,
because it has extremely low compression/decompression time. However,
currently it supports LZO and ZLIB (but only one at the run-time!)
compression algorythms.
2007-02-21 00:00:08 +01:00
|
|
|
|
2007-03-16 09:21:16 +01:00
|
|
|
--- LZOlayer_fs.c.orig 2006-05-18 22:23:35.000000000 +0300
|
|
|
|
+++ LZOlayer_fs.c 2007-03-16 09:00:48.000000000 +0200
|
Initial import of fuse-lzofs-20060306.
LZOlayer Filesystem is a filesystem which allows you to use transparently
compressed files, just as they would be normal files.
Both read and write operations are possible, along with other most common
system calls. It consumes little memory in my opinion, because files are
divided into blocks, which can be decompressed separetly. In other words,
if you (or an application) would like to read byte 4,500,000 in a file
sized 5,000,000 bytes, it only decompresses a block which constain wanted
data. Write operation is based on a packet gathering and after reaching its
limit it 'syncs' the data. It allows it's user to write/modify files pretty
fast, despite the fact it's block divided.
LZOlayer FileSystem was meant to support only LZO compression algorythm,
because it has extremely low compression/decompression time. However,
currently it supports LZO and ZLIB (but only one at the run-time!)
compression algorythms.
2007-02-21 00:00:08 +01:00
|
|
|
@@ -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);
|
|
|
|
}
|
2007-03-08 06:14:38 +01:00
|
|
|
@@ -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 @@
|
Initial import of fuse-lzofs-20060306.
LZOlayer Filesystem is a filesystem which allows you to use transparently
compressed files, just as they would be normal files.
Both read and write operations are possible, along with other most common
system calls. It consumes little memory in my opinion, because files are
divided into blocks, which can be decompressed separetly. In other words,
if you (or an application) would like to read byte 4,500,000 in a file
sized 5,000,000 bytes, it only decompresses a block which constain wanted
data. Write operation is based on a packet gathering and after reaching its
limit it 'syncs' the data. It allows it's user to write/modify files pretty
fast, despite the fact it's block divided.
LZOlayer FileSystem was meant to support only LZO compression algorythm,
because it has extremely low compression/decompression time. However,
currently it supports LZO and ZLIB (but only one at the run-time!)
compression algorythms.
2007-02-21 00:00:08 +01:00
|
|
|
{
|
|
|
|
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);
|
2007-03-08 06:14:38 +01:00
|
|
|
@@ -193,7 +213,7 @@
|
Initial import of fuse-lzofs-20060306.
LZOlayer Filesystem is a filesystem which allows you to use transparently
compressed files, just as they would be normal files.
Both read and write operations are possible, along with other most common
system calls. It consumes little memory in my opinion, because files are
divided into blocks, which can be decompressed separetly. In other words,
if you (or an application) would like to read byte 4,500,000 in a file
sized 5,000,000 bytes, it only decompresses a block which constain wanted
data. Write operation is based on a packet gathering and after reaching its
limit it 'syncs' the data. It allows it's user to write/modify files pretty
fast, despite the fact it's block divided.
LZOlayer FileSystem was meant to support only LZO compression algorythm,
because it has extremely low compression/decompression time. However,
currently it supports LZO and ZLIB (but only one at the run-time!)
compression algorythms.
2007-02-21 00:00:08 +01:00
|
|
|
char *xPath = filePtr->path;
|
|
|
|
|
|
|
|
int done = 0;
|
|
|
|
- int fd = open(xPath, O_RDONLY|O_LARGEFILE);
|
|
|
|
+ int fd = open(xPath, ordonly);
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2007-03-08 06:14:38 +01:00
|
|
|
@@ -249,7 +269,7 @@
|
Initial import of fuse-lzofs-20060306.
LZOlayer Filesystem is a filesystem which allows you to use transparently
compressed files, just as they would be normal files.
Both read and write operations are possible, along with other most common
system calls. It consumes little memory in my opinion, because files are
divided into blocks, which can be decompressed separetly. In other words,
if you (or an application) would like to read byte 4,500,000 in a file
sized 5,000,000 bytes, it only decompresses a block which constain wanted
data. Write operation is based on a packet gathering and after reaching its
limit it 'syncs' the data. It allows it's user to write/modify files pretty
fast, despite the fact it's block divided.
LZOlayer FileSystem was meant to support only LZO compression algorythm,
because it has extremely low compression/decompression time. However,
currently it supports LZO and ZLIB (but only one at the run-time!)
compression algorythms.
2007-02-21 00:00:08 +01:00
|
|
|
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)
|
2007-03-08 06:14:38 +01:00
|
|
|
@@ -315,10 +335,10 @@
|
Initial import of fuse-lzofs-20060306.
LZOlayer Filesystem is a filesystem which allows you to use transparently
compressed files, just as they would be normal files.
Both read and write operations are possible, along with other most common
system calls. It consumes little memory in my opinion, because files are
divided into blocks, which can be decompressed separetly. In other words,
if you (or an application) would like to read byte 4,500,000 in a file
sized 5,000,000 bytes, it only decompresses a block which constain wanted
data. Write operation is based on a packet gathering and after reaching its
limit it 'syncs' the data. It allows it's user to write/modify files pretty
fast, despite the fact it's block divided.
LZOlayer FileSystem was meant to support only LZO compression algorythm,
because it has extremely low compression/decompression time. However,
currently it supports LZO and ZLIB (but only one at the run-time!)
compression algorythms.
2007-02-21 00:00:08 +01:00
|
|
|
{
|
|
|
|
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
|
2007-03-16 09:21:16 +01:00
|
|
|
@@ -357,15 +377,25 @@
|
|
|
|
static int LZOlayer_mknod(const char *path, mode_t mode, dev_t rdev)
|
|
|
|
{
|
|
|
|
char *xPath = LZOlayer_makePath(path);
|
|
|
|
- int res = mknod(xPath, mode, rdev);
|
|
|
|
-
|
|
|
|
+ int res;
|
|
|
|
+
|
|
|
|
+ if (S_ISREG(mode)) {
|
|
|
|
+ res = open(xPath, owronly | O_CREAT | O_TRUNC, 0700);
|
|
|
|
+ if (res != -1) {
|
|
|
|
+ close(res);
|
|
|
|
+ res = 0;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ res = mknod(xPath, mode, rdev);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (res == -1)
|
|
|
|
{
|
|
|
|
res = -errno;
|
Initial import of fuse-lzofs-20060306.
LZOlayer Filesystem is a filesystem which allows you to use transparently
compressed files, just as they would be normal files.
Both read and write operations are possible, along with other most common
system calls. It consumes little memory in my opinion, because files are
divided into blocks, which can be decompressed separetly. In other words,
if you (or an application) would like to read byte 4,500,000 in a file
sized 5,000,000 bytes, it only decompresses a block which constain wanted
data. Write operation is based on a packet gathering and after reaching its
limit it 'syncs' the data. It allows it's user to write/modify files pretty
fast, despite the fact it's block divided.
LZOlayer FileSystem was meant to support only LZO compression algorythm,
because it has extremely low compression/decompression time. However,
currently it supports LZO and ZLIB (but only one at the run-time!)
compression algorythms.
2007-02-21 00:00:08 +01:00
|
|
|
}
|
|
|
|
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));
|
2007-03-16 09:21:16 +01:00
|
|
|
@@ -373,6 +403,7 @@
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
chown(xPath, fuse_get_context()->uid, fuse_get_context()->gid);
|
|
|
|
+ chmod(xPath, mode);
|
|
|
|
}
|
|
|
|
free(xPath);
|
|
|
|
|
|
|
|
@@ -383,7 +414,7 @@
|
Initial import of fuse-lzofs-20060306.
LZOlayer Filesystem is a filesystem which allows you to use transparently
compressed files, just as they would be normal files.
Both read and write operations are possible, along with other most common
system calls. It consumes little memory in my opinion, because files are
divided into blocks, which can be decompressed separetly. In other words,
if you (or an application) would like to read byte 4,500,000 in a file
sized 5,000,000 bytes, it only decompresses a block which constain wanted
data. Write operation is based on a packet gathering and after reaching its
limit it 'syncs' the data. It allows it's user to write/modify files pretty
fast, despite the fact it's block divided.
LZOlayer FileSystem was meant to support only LZO compression algorythm,
because it has extremely low compression/decompression time. However,
currently it supports LZO and ZLIB (but only one at the run-time!)
compression algorythms.
2007-02-21 00:00:08 +01:00
|
|
|
{
|
|
|
|
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));
|
|
|
|
|