Hello community,

here is the log from the commit of package clicfs for openSUSE:Factory
checked in at Tue Oct 18 13:58:39 CEST 2011.



--------
--- openSUSE:Factory/clicfs/clicfs.changes      2011-09-23 01:53:36.000000000 
+0200
+++ /mounts/work_src_done/STABLE/clicfs/clicfs.changes  2011-10-17 
16:44:50.000000000 +0200
@@ -1,0 +2,7 @@
+Mon Oct 17 14:44:14 UTC 2011 - [email protected]
+
+- update to 1.4.4
+   - provide clicfs_fsck to check if the cow file was
+     written consistently
+
+-------------------------------------------------------------------

calling whatdependson for head-i586


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ clicfs.spec ++++++
--- /var/tmp/diff_new_pack.svchxf/_old  2011-10-18 13:58:35.000000000 +0200
+++ /var/tmp/diff_new_pack.svchxf/_new  2011-10-18 13:58:35.000000000 +0200
@@ -18,7 +18,7 @@
 
 
 Name:           clicfs
-Version:        1.4.3
+Version:        1.4.4
 Release:        1
 License:        GPLv2
 Summary:        Compressed Loop Image Container
@@ -57,7 +57,7 @@
 %files
 %defattr(-,root,root)
 %doc LICENCE
-%{_bindir}/*clicfs
+%{_bindir}/*
 %{_mandir}/man1/*
 
 %changelog

++++++ clicfs.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README new/README
--- old/README  2011-09-07 16:53:32.000000000 +0200
+++ new/README  2011-10-17 16:39:44.000000000 +0200
@@ -2,6 +2,7 @@
 
 COWFILE FORMAT:
   9 bytes: CLICCOW%02d
+  4 bytes: isready flag
   8 bytes: file size (including sparse)
   
   num_pages*:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/misc/makeiso.sh new/misc/makeiso.sh
--- old/misc/makeiso.sh 2011-09-07 16:53:32.000000000 +0200
+++ new/misc/makeiso.sh 2011-10-17 16:39:44.000000000 +0200
@@ -1,6 +1,12 @@
-set -e
-make 
-cp src/clicfs initrd/usr/bin/clicfs 
-(cd initrd ; find . | cpio --create --format=newc --quiet | gzip -9 -f > 
../CD1/boot/x86_64/loader/initrd)
-genisoimage -R -J -f -pad -joliet-long -no-emul-boot -boot-load-size 4 
-boot-info-table -b boot/x86_64/loader/isolinux.bin -o kde2.iso CD1/
-#isohybrid -id $(cat CD1/boot/grub/mbrid) kde2.iso  && dd if=/dev/zero 
seek=1000 count=1 bs=1M of=kde2.iso
+set -e 
+make
+cp src/clicfs initrd/usr/bin/clicfs
+loaderdir=$(cd CD1 ; ls -1 boot/*/loader/initrd)
+cd initrd 
+find . | cpio --create --format=newc --quiet | gzip -9 -f > ../CD1/$loaderdir
+cd ..
+loaderdir=$(cd CD1 ; ls -1 boot/*/loader/isolinux.bin)
+genisoimage -R -J -f -pad -joliet-long -no-emul-boot -boot-load-size 4 
-boot-info-table -b $loaderdir -o kde2.iso CD1/
+isohybrid -id $(cat CD1/boot/grub/mbrid) kde2.iso 
+dd if=/dev/zero seek=1000 count=1 bs=1M of=kde2.iso
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/src/CMakeLists.txt new/src/CMakeLists.txt
--- old/src/CMakeLists.txt      2011-09-07 16:53:32.000000000 +0200
+++ new/src/CMakeLists.txt      2011-10-17 16:39:44.000000000 +0200
@@ -8,4 +8,8 @@
 add_executable(unclicfs unclicfs.c clicfs_common.c)
 TARGET_LINK_LIBRARIES(unclicfs lzma)
 
-INSTALL(TARGETS mkclicfs clicfs unclicfs DESTINATION bin)
+add_executable(clicfs_fsck clicfs_check.c clicfs_common.c)
+TARGET_LINK_LIBRARIES(clicfs_fsck lzma)
+
+INSTALL(TARGETS clicfs_fsck mkclicfs clicfs unclicfs DESTINATION bin)
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/src/clicfs.c new/src/clicfs.c
--- old/src/clicfs.c    2011-09-07 16:53:32.000000000 +0200
+++ new/src/clicfs.c    2011-10-17 16:39:44.000000000 +0200
@@ -32,6 +32,7 @@
 #include <pthread.h>
 #include <sys/time.h>
 #include <sys/mman.h>
+#include <sys/sysinfo.h>
 
 //#define DEBUG 1
 
@@ -41,8 +42,8 @@
 static size_t sparse_memory = 0;
 static char *cowfilename = 0;
 static off_t memory_used = 0;
-static time_t last_sync = 0;
-static time_t last_write = 0;
+static long last_sync = 0;
+static long last_write = 0;
 
 static struct timeval start;
 
@@ -59,6 +60,8 @@
 static int clic_detach(size_t block);
 static int clic_write_cow();
 
+static long get_uptime();
+
 pthread_mutex_t cowfile_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t cowfile_mutex_writer = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t coms_by_part_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -78,6 +81,13 @@
   detachall = 1;
 }
 
+long get_uptime()
+{
+  struct sysinfo info;
+  sysinfo(&info);
+  return info.uptime;
+}
+
 static int clic_write_cow()
 {
     if (!cowfilename || cowfile_ro == 1 || !detached_allocated)
@@ -90,6 +100,12 @@
     
     pthread_mutex_lock(&cowfile_mutex);
 
+    char isready = 0;
+    // before we start, we reset the isready flag
+    assert(cow_index_isready > 0);
+    pwrite(cowfilefd, &isready, 1, cow_index_isready);
+    fdatasync(cowfilefd);
+
     uint32_t i;
     for (i = 0; i < num_pages; ++i)
     {
@@ -121,8 +137,15 @@
        }
     }
 
+    // now sync the pages
     fdatasync(cowfilefd);
-    last_sync = time(0);
+
+    isready = 1;
+    // as final step, set the isready flag back to 1
+    pwrite(cowfilefd, &isready, 1, cow_index_isready);
+    fdatasync(cowfilefd);
+
+    last_sync = get_uptime();
     // not true for threads assert(!detached_allocated);
 
 exit:
@@ -195,7 +218,7 @@
     off_t out_buffer_size;
     int mmapped;
     uint32_t part;
-    time_t last_used;
+    long last_used;
     struct buffer_combo *next_by_use;
     struct buffer_combo *prev_by_use;
 };
@@ -338,8 +361,8 @@
 
 static const unsigned char *clic_uncompress(uint32_t part)
 {
-    //if (logger) fprintf(logger, "clic_uncompress %d %d\n", part, parts);
-    time_t now = time(0);
+    if (logger) fprintf(logger, "clic_uncompress %d %d\n", part, parts);
+    long now = get_uptime();
 
     pthread_mutex_lock(&coms_by_part_mutex);
 
@@ -361,6 +384,7 @@
        com->last_used = now;
        clic_remove_com_from_use(com);
        clic_append_by_use(com);
+        if (logger) fprintf(logger, "unlock fast\n");
        pthread_mutex_unlock(&coms_by_part_mutex);
        return buf;
     }
@@ -397,6 +421,7 @@
 
     clic_insert_com(com, res);
 
+    if (logger) fprintf(logger, "unlock slow\n");
     pthread_mutex_unlock(&coms_by_part_mutex);
     unsigned char *inbuffer = malloc(sizes[part]);
     assert(inbuffer);
@@ -514,7 +539,7 @@
 
 static size_t clic_write_block(const char *buf, off_t block, off_t ioff, 
size_t size)
 {
-    //if (logger) fprintf(logger, "clic_write_block %ld\n", 
detached_allocated);
+  if (logger) fprintf(logger, "clic_write_block %ld block:%ld ioff:%ld 
size:%ld\n", detached_allocated, block, ioff, size);
     if (clic_detach(block)) {
       if (logger) fprintf(logger, "clic_detach FAILED\n");
       return -ENOSPC;
@@ -534,6 +559,9 @@
     if(path[0] == '/' && strcmp(path + 1, thefile) != 0)
        return -ENOENT;
 
+    if (logger) fprintf(logger, "clic_write offset %ld - size %ld (%ld)\n", 
offset, size, thefilesize);
+
+
     if (offset >= (off_t)thefilesize) {
         return 0;
     }
@@ -548,19 +576,20 @@
     off_t block = offset / pagesize;
     off_t ioff = offset - block * pagesize;
 
-    assert(ioff == 0 || ioff + size <= pagesize);
-
-    last_write = time(0);
+    last_write = get_uptime();
 
-    int ret = 0;
+    size_t ret = 0;
 
-    if (size <= pagesize) {
-        ret = clic_write_block(buf, block, ioff, size);
+    if (ioff + size <= pagesize) {
+      ret = clic_write_block(buf, block, ioff, size);
     } else {
        size_t wrote = 0;
        do
        {
-           size_t diff = clic_write_block(buf, block, ioff, size > pagesize ? 
pagesize : size);
+           size_t diff = size > pagesize ? pagesize : size;
+           if (ioff + diff > pagesize)
+                diff = pagesize - ioff;
+           diff = clic_write_block(buf, block, ioff, diff);
            ioff = 0;
            size -= diff;
            buf += diff;
@@ -799,8 +828,11 @@
        thefilesize += pagesize;
     bigfilesize += sparse_memory * 1024 * 1024;
   
-    assert( DOENER_MAGIC < 100 );
-    int index_len = fprintf(cow, "CLICCOW%02d", DOENER_MAGIC );
+    assert( DOENER_COW_MAGIC < 100 );
+    int index_len = fprintf(cow, "CLICCOW%02d", DOENER_COW_MAGIC );
+    char isready = 1;
+    cow_index_isready = index_len;
+    index_len += fwrite(&isready, 1, 1, cow);
     index_len += fwrite((char*)&bigfilesize, 1, sizeof(uint64_t), cow);
 
     char zeros[sizeof(uint32_t)];
@@ -850,7 +882,7 @@
     }
 
     if (clicfs_read_pack(packfilename)) {
-       perror("read_pack");
+        if (errno) perror("read_pack");
        return 1;
     }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/src/clicfs.h new/src/clicfs.h
--- old/src/clicfs.h    2011-09-07 16:53:32.000000000 +0200
+++ new/src/clicfs.h    2011-10-17 16:39:44.000000000 +0200
@@ -29,6 +29,10 @@
 // magic 2 added large parts
 #define DOENER_MAGIC 2
 
+// magic 3 split from DOENER_MAGIC
+//         and introduced consistent flag
+#define DOENER_COW_MAGIC 3
+
 #define PTR_CLASS(x) ((long)x & 0x3)
 
 enum { CLASS_MEMORY = 0,
@@ -57,6 +61,8 @@
 extern off_t cow_index_start;
 // the offset in the cow file where the pages start
 extern off_t cow_pages_start;
+// the offset in the cow file for the isready flag
+extern off_t cow_index_isready;
 // support temporary changes on ro medium
 extern int cowfile_ro;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/src/clicfs_check.c new/src/clicfs_check.c
--- old/src/clicfs_check.c      1970-01-01 01:00:00.000000000 +0100
+++ new/src/clicfs_check.c      2011-10-17 16:39:44.000000000 +0200
@@ -0,0 +1,25 @@
+/* This file is part of Clic FS
+   Copyright (C) 2011 Stephan Kulow ([email protected])
+
+   Clicfs is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+#include "clicfs.h"
+
+int main(int argc, char *argv[])
+{
+  int ret = clicfs_read_cow(argv[1]);
+  return ret;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/src/clicfs_common.c new/src/clicfs_common.c
--- old/src/clicfs_common.c     2011-09-07 16:53:32.000000000 +0200
+++ new/src/clicfs_common.c     2011-10-17 16:39:44.000000000 +0200
@@ -1,5 +1,5 @@
 /* This file is part of Clic FS
-   Copyright (C) 2009 Stephan Kulow ([email protected])
+   Copyright (C) 2009,2011 Stephan Kulow ([email protected])
 
    Clicfs is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
@@ -25,6 +25,7 @@
 #include <lzma.h>
 #include <string.h>
 #include <assert.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -53,6 +54,7 @@
 uint32_t *cows = 0;
 unsigned int cows_index = 0;
 int cowfile_ro = 0;
+off_t cow_index_isready = 0;
 
 static lzma_stream strm;
 static pthread_mutex_t lzma_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -98,14 +100,27 @@
        return 1;
     }
 
-    head[9] = 0;
-    sprintf(expected, "CLICCOW%02d", DOENER_MAGIC);
+    cow_index_start = 9;
+    head[cow_index_start] = 0;
+    sprintf(expected, "CLICCOW%02d", DOENER_COW_MAGIC);
     if (strcmp(head,expected)) {
        fprintf(stderr, "wrong magic: %s vs %s\n", head, expected);
        return 1;
     }
     
+    cow_index_isready = cow_index_start;
+    cow_index_start++;
+    char isready = 0;
+    read(cowfilefd, &isready, 1);
+    if (isready != 1) {
+      fprintf(stderr, "Inconsistent COW file\n");
+      return 1;
+    }
+
+    cow_index_start += sizeof(uint64_t);
     thefilesize = clic_readindex_fd64(cowfilefd);
+    
+    printf("filesize %lx\n", thefilesize);
     uint32_t newpages = thefilesize / pagesize;
     blockmap = realloc(blockmap, sizeof(unsigned char*)*newpages);
     uint32_t i;
@@ -123,8 +138,7 @@
     }
     cows = malloc(sizeof(uint32_t) * CLICFS_COW_COUNT);
     cows_index = 0;
-    
-    cow_index_start = 9 + sizeof(uint64_t);
+
     cow_pages_start = cow_index_start + num_pages * sizeof(uint32_t);
     // we do not round up but down here as cow pages start with 1
     cow_pages_start = ( cow_pages_start / pagesize + 0) * pagesize;
@@ -148,16 +162,19 @@
     head[6] = 0;
     sprintf(expected, "CLIC%02d", DOENER_MAGIC);
     if (strcmp(head,expected)) {
+        errno = 0;
        fprintf(stderr, "wrong magic: %s vs %s\n", head, expected);
        return 1;
     }
 
     uint32_t stringlen = clic_readindex_fd(packfilefd);
     if (stringlen == 0 || stringlen >= PATH_MAX) {
+        errno = ENAMETOOLONG;
        fprintf(stderr, "abnormal len %lx\n", (long)stringlen); 
         return 1;
     }
     if (read(packfilefd, thefile, stringlen) != stringlen) {
+        errno = EIO;
        fprintf(stderr, "short read %ld\n", (long)stringlen);
        return 1;
     }
@@ -189,17 +206,20 @@
                parts = 0;
        if (!sizes[i]) {
                fprintf(stderr, "unreasonable size 0 for part %d\n", i);
+               errno = EINVAL;
                return 1;
         }
        if (read(packfilefd, (char*)(offs + i), sizeof(uint64_t)) != 
sizeof(uint64_t))
                parts = 0;
        if (i > 0 && offs[i] <= offs[i-1]) {
          fprintf(stderr, "the offset for i is not larger than i-1: %ld\n", 
(long)i);
+         errno = EINVAL;
          return 1;
        }
     }
     if (parts == 0) {
         fprintf(stderr, "unreasonable part number 0\n");
+       errno = EINVAL;
        return 1;
     }
     lseek(packfilefd, (oparts-parts)*sizeof(uint64_t)*2, SEEK_CUR);
@@ -210,6 +230,7 @@
     strm = tmp;
     lzma_ret ret = lzma_auto_decoder(&strm, 
lzma_easy_decoder_memusage(preset), flags);
     if (ret != LZMA_OK) {
+      errno = EIO;
       return 1;
     }
 

continue with "q"...



Remember to have fun...

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to