Bug found in Arla CVS

Bo Branten bosse at acc.umu.se
Fri Jan 22 17:24:22 CET 2016


Hello,

when testing Arla I found a bug in the CVS version that I thought I should 
warn you about:

In the CVS version they changed from uppercase to lowercase file and dir 
names in the cache:

2c2
<  * Copyright (c) 2005-2006, Stockholms Universitet
---
>  * Copyright (c) 2005-2007, Stockholms Universitet
34c34
< /* $Id: nnpfs_blocks.h,v 1.2 2006/10/24 16:33:31 tol Exp $ */
---
> /* $Id: nnpfs_blocks.h,v 1.3 2007/01/24 17:09:17 tol Exp $ */
39,41c39,45
< #define NNPFS_CACHE_FILE_PATH    "%02X/%02X/%02llX"
< #define NNPFS_CACHE_DIR_PATH     "%02X/%02X@"
< #define NNPFS_CACHE_PATH_SIZE    ( 6 +1 +2+1 +16 +1)
---
> #define NNPFS_CACHE_FILE_DIR1        "%02x"
> #define NNPFS_CACHE_FILE_DIR_PATH    NNPFS_CACHE_FILE_DIR1 "/" NNPFS_CACHE_FILE_DIR1
> #define NNPFS_CACHE_FILE_BLOCK_PATH  "%02llx"
> 
> #define NNPFS_CACHE_FILE_PATH   NNPFS_CACHE_FILE_DIR_PATH "/" NNPFS_CACHE_FILE_BLOCK_PATH
> #define NNPFS_CACHE_DIR_PATH    NNPFS_CACHE_FILE_DIR_PATH "@"
> #define NNPFS_CACHE_PATH_SIZE   ( 6 +1 +2+1 +16 +1 )

However the old look was hardcoded in some places in arlad/fcache.c, here 
is a patch that corrects this: (Also remember this when mixing different 
versions of arlad and nnpfs)

--- src/arla-0.90/arlad/fcache.c	2006-12-11 17:23:24.000000000 +0100
+++ src/arla-0.90-new/arlad/fcache.c	2016-01-22 17:00:43.000000000 +0100
@@ -713,7 +713,7 @@ fcache_have_wanted(FCacheEntry *entry, u
  int
  fcache_dir_name (FCacheEntry *entry, char *s, size_t len)
  {
-    return snprintf (s, len, "%02X", entry->index / 0x100);
+    return snprintf (s, len, NNPFS_CACHE_FILE_DIR1, entry->index / 0x100);
  }

  /*
@@ -723,7 +723,7 @@ fcache_dir_name (FCacheEntry *entry, cha
  static int
  fcache_file_name (FCacheEntry *entry, char *s, size_t len)
  {
-    return snprintf (s, len, "%02X/%02X",
+    return snprintf (s, len, NNPFS_CACHE_FILE_DIR_PATH,
  		     entry->index / 0x100, entry->index % 0x100);
  }

@@ -815,7 +815,7 @@ fcache_fhget (char *filename, fcache_cac
  	int ret, a, b;
  	char buf[1024];

-	ret = sscanf(filename, "%02X/%02X", &a, &b);
+	ret = sscanf(filename, NNPFS_CACHE_FILE_DIR_PATH, &a, &b);
  	if (ret != 2)
  	    return EINVAL;

@@ -824,7 +824,7 @@ fcache_fhget (char *filename, fcache_cac

  	ret = snprintf((char *)handle->nnpfs_handle,
  		       sizeof(handle->nnpfs_handle),
-		       "%s\\%02X\\%02X", buf, a, b);
+		       "%s\\" NNPFS_CACHE_FILE_DIR_PATH, buf, a, b);

  	if (ret > 0 && ret < sizeof(handle->nnpfs_handle))
  	    handle->valid = 1;
-------------- next part --------------
--- src/arla-0.90/arlad/fcache.c	2006-12-11 17:23:24.000000000 +0100
+++ src/arla-0.90-new/arlad/fcache.c	2016-01-22 17:00:43.000000000 +0100
@@ -713,7 +713,7 @@ fcache_have_wanted(FCacheEntry *entry, u
 int
 fcache_dir_name (FCacheEntry *entry, char *s, size_t len)
 {
-    return snprintf (s, len, "%02X", entry->index / 0x100);
+    return snprintf (s, len, NNPFS_CACHE_FILE_DIR1, entry->index / 0x100);
 }
 
 /*
@@ -723,7 +723,7 @@ fcache_dir_name (FCacheEntry *entry, cha
 static int
 fcache_file_name (FCacheEntry *entry, char *s, size_t len)
 {
-    return snprintf (s, len, "%02X/%02X",
+    return snprintf (s, len, NNPFS_CACHE_FILE_DIR_PATH,
 		     entry->index / 0x100, entry->index % 0x100);
 }
 
@@ -815,7 +815,7 @@ fcache_fhget (char *filename, fcache_cac
 	int ret, a, b;
 	char buf[1024];
 
-	ret = sscanf(filename, "%02X/%02X", &a, &b);
+	ret = sscanf(filename, NNPFS_CACHE_FILE_DIR_PATH, &a, &b);
 	if (ret != 2)
 	    return EINVAL;
 
@@ -824,7 +824,7 @@ fcache_fhget (char *filename, fcache_cac
 	
 	ret = snprintf((char *)handle->nnpfs_handle, 
 		       sizeof(handle->nnpfs_handle),
-		       "%s\\%02X\\%02X", buf, a, b);
+		       "%s\\" NNPFS_CACHE_FILE_DIR_PATH, buf, a, b);
 
 	if (ret > 0 && ret < sizeof(handle->nnpfs_handle))
 	    handle->valid = 1;


More information about the Arla-drinkers mailing list