From 59ecea5c803d3feb639bfa01144c957a04f30fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Thu, 20 Oct 2011 18:55:32 +0200 Subject: [PATCH] new : allow compression in default setup With the default mount options, compression of new files are now done if the parent directory is marked for compression. The mount option "compression" is not needed any more, but the option "nocompression" can be used to disable compression of new files. The default option also applies to applications using libntfs-3g with no mount command. --- include/ntfs-3g/param.h | 2 +- libntfs-3g/volume.c | 7 +++++++ src/lowntfs-3g.c | 2 ++ src/ntfs-3g.c | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/ntfs-3g/param.h b/include/ntfs-3g/param.h index 4480eea8..5d96b1c2 100644 --- a/include/ntfs-3g/param.h +++ b/include/ntfs-3g/param.h @@ -44,7 +44,7 @@ enum { */ /* default option for compression */ -#define DEFAULT_COMPRESSION FALSE +#define DEFAULT_COMPRESSION 1 /* (log2 of) number of clusters in a compression block for new files */ #define STANDARD_COMPRESSION_UNIT 4 /* maximum cluster size for allowing compression for new files */ diff --git a/libntfs-3g/volume.c b/libntfs-3g/volume.c index ae7dee8c..a18109f1 100644 --- a/libntfs-3g/volume.c +++ b/libntfs-3g/volume.c @@ -54,6 +54,7 @@ #include #endif +#include "param.h" #include "compat.h" #include "volume.h" #include "attrib.h" @@ -501,6 +502,12 @@ ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, unsigned long flags) NVolSetShowSysFiles(vol); NVolSetShowHidFiles(vol); NVolClearHideDotFiles(vol); + /* set default compression */ +#if DEFAULT_COMPRESSION + NVolSetCompression(vol); +#else + NVolClearCompression(vol); +#endif if (flags & MS_RDONLY) NVolSetReadOnly(vol); diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index 603ec823..a281da6f 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -3433,6 +3433,8 @@ static int ntfs_open(const char *device) NDevSetSync(ctx->vol->dev); if (ctx->compression) NVolSetCompression(ctx->vol); + else + NVolClearCompression(ctx->vol); #ifdef HAVE_SETXATTR /* archivers must see hidden files */ if (ctx->efs_raw) diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 73392483..8919761d 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -3350,6 +3350,8 @@ static int ntfs_open(const char *device) NDevSetSync(ctx->vol->dev); if (ctx->compression) NVolSetCompression(ctx->vol); + else + NVolClearCompression(ctx->vol); #ifdef HAVE_SETXATTR /* archivers must see hidden files */ if (ctx->efs_raw)