Only in mhddfs-0.1.35/: build-stamp
Only in mhddfs-0.1.35//debian: files
Only in mhddfs-0.1.35//debian: mhddfs
Only in mhddfs-0.1.35//debian: mhddfs.debhelper.log
Only in mhddfs-0.1.35//debian: mhddfs.substvars
Only in mhddfs-0.1.35/: mhddfs
Only in mhddfs-0.1.35/: obj
diff -urd orig/mhddfs-0.1.35//src/parse_options.c mhddfs-0.1.35//src/parse_options.c
--- orig/mhddfs-0.1.35//src/parse_options.c	2010-06-15 06:54:46.000000000 +0100
+++ mhddfs-0.1.35//src/parse_options.c	2010-07-04 15:29:00.904499481 +0100
@@ -246,10 +246,11 @@
 		setvbuf(mhdd.debug, NULL, _IONBF, 0);
 	}
 
-	mhdd.move_limit=4ll*1024*1024*1024;
+	mhdd.move_limit=25;  /* In percent, Old limit bytes= 4ll*1024*1024*1024; */
 	if (mhdd.mlimit_str)
 	{
 		int len=strlen(mhdd.mlimit_str);
+		int ch = 0;
 		if (len)
 		{
 			switch(mhdd.mlimit_str[len-1])
@@ -274,15 +275,26 @@
 					mhdd.move_limit*=1024;
 					break;
 
+				case '%':
+					mhdd.mlimit_str[len-1]=0;
+					mhdd.move_limit=atoll(mhdd.mlimit_str);
+					ch = '%';
+					break;
+
 				default:
 					mhdd.move_limit=atoll(mhdd.mlimit_str);
 					break;
 			}
 		}
-		if (mhdd.move_limit<50*1024*1024) mhdd.move_limit=50*1024*1024;
+		if (mhdd.move_limit<50*1024*1024 && (ch != '%' || mhdd.move_limit > 100))
+			mhdd.move_limit=50*1024*1024;
 	}
-	fprintf(stderr, "mhddfs: move size limit %lld bytes\n",
-			(long long)mhdd.move_limit);
+	if (mhdd.move_limit <= 100)
+		fprintf(stderr, "mhddfs: move size limit %lld%\n",
+				(long long)mhdd.move_limit);
+	else
+		fprintf(stderr, "mhddfs: move size limit %lld bytes\n",
+				(long long)mhdd.move_limit);
 
 	mhdd_debug(MHDD_MSG, " >>>>> mhdd " VERSION " started <<<<<\n");
 
diff -urd orig/mhddfs-0.1.35//src/tools.c mhddfs-0.1.35//src/tools.c
--- orig/mhddfs-0.1.35//src/tools.c	2010-06-15 06:54:46.000000000 +0100
+++ mhddfs-0.1.35//src/tools.c	2010-07-04 16:07:01.796162790 +0100
@@ -43,7 +43,7 @@
 // get diridx for maximum free space
 int get_free_dir(void)
 {
-	int i, max;
+	int i, max, max_perc, max_perc_space=0;
 	struct statvfs stf;
 	fsblkcnt_t max_space=0;
 
@@ -53,7 +53,22 @@
 		fsblkcnt_t space  = stf.f_bsize;
 		space *= stf.f_bavail;
 
-		if (space>=mhdd.move_limit) return i;
+		if (mhdd.move_limit <= 100) {
+			fsblkcnt_t perclimit = stf.f_blocks * (mhdd.move_limit+1) / 100;
+			int perc;
+			
+			if (stf.f_bavail>=perclimit) return i;
+
+			perc = 100 * stf.f_bavail / stf.f_blocks;
+
+			if (perc>max_perc_space)
+			{
+				max_perc_space=perc;
+				max_perc=i;
+			}
+		} else {
+			if (space>=mhdd.move_limit) return i;
+		}
 
 		if(space>max_space)
 		{
@@ -62,12 +77,14 @@
 		}
 	}
 
-	if (!max_space)
+	if (!max_space && !max_perc_space)
 	{
 		mhdd_debug(MHDD_INFO,
 			"get_free_dir: Can't find freespace\n");
 		return -1;
 	}
+	if (max_perc_space) 
+		return max_perc;
 	return max;
 }
 
