Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r28 - in trunk: . fsvs/src

fsvs
Discussion topic

Back to topic list

svn commit: r28 - in trunk: . fsvs/src

Author pmarek
Full name P.Marek
Date 2005-10-09 23:16:37 PDT
Message Author: pmarek
Date: Sun Oct 9 23:16:37 2005
New Revision: 28

Modified:
   trunk/ (props changed)
   trunk/fsvs/src/direnum.c
   trunk/fsvs/src/est_ops.c
   trunk/fsvs/src/est_ops.h
   trunk/fsvs/src/global.h
   trunk/fsvs/src/waa.c
Log:
replaced subdir_count by file_index and child_count in struct estat
output_tree now reallocates *directory[][] if necessary
save_1entry now has explicit parent argument




Modified: trunk/fsvs/src/direnum.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/dir​enum.c?view=diff​&rev=28&p1=trunk​/fsvs/src/direnum.c​&r1=27&p2=tru​nk/fsvs/src/direnum.​c&r2=28
====================​====================​====================​==================
--- trunk/fsvs/src/direnum.c (original)
+++ trunk/fsvs/src/direnum.c Sun Oct 9 23:16:37 2005
@@ -273,7 +273,6 @@
 
     DEBUGP("after loop found %d entries, %d bytes string-space", count, mark);
     this->entry_count=count;
- this->subdir_count=0;
 
     /* free allocated, but not used, memory. */
     strings=realloc(strings, mark);
@@ -341,7 +340,6 @@
         sts[i].repos_rev=UNK​NOWN_REVISION;
         STOPIF_CODE_ERR( lstat64(sts[i].name, &(sts[i].st)) == -1, errno,
                 "lstat(%s)", sts[i].name);
- if (S_ISDIR(sts[i].st.st_mode)) this->subdir_count++;
     }
 
 

Modified: trunk/fsvs/src/est_ops.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/est​_ops.c?view=diff​&rev=28&p1=trunk​/fsvs/src/est_ops.c​&r1=27&p2=tru​nk/fsvs/src/est_ops.​c&r2=28
====================​====================​====================​==================
--- trunk/fsvs/src/est_ops.c (original)
+++ trunk/fsvs/src/est_ops.c Sun Oct 9 23:16:37 2005
@@ -241,6 +241,7 @@
 
 
 int ops__save_1entry(struct estat *sts,
+ ino_t parent_ino,
         int filehandle,
         char *path)
 {
@@ -251,15 +252,8 @@
         [sizeof(buffer)-1]=0xff,
         [sizeof(buffer)-2]=0x0,
     };
- ino_t parent_ino;
     int is_dir, is_dev, status;
 
-
- if (sts->parent)
- parent_ino=sts->p​arent->st.st_ino;​
- else
- parent_ino=0;
-
     is_dir = S_ISDIR(sts->st.st_mode);
     is_dev = S_ISBLK(sts->st.st_mode) || S_ISCHR(sts->st.st_mode);
 

Modified: trunk/fsvs/src/est_ops.h
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/est​_ops.h?view=diff​&rev=28&p1=trunk​/fsvs/src/est_ops.h​&r1=27&p2=tru​nk/fsvs/src/est_ops.​h&r2=28
====================​====================​====================​==================
--- trunk/fsvs/src/est_ops.h (original)
+++ trunk/fsvs/src/est_ops.h Sun Oct 9 23:16:37 2005
@@ -40,6 +40,7 @@
         struct estat **new_entries);
 
 int ops__save_1entry(struct estat *sts,
+ ino_t parent_ino,
         int filehandle,
         char *path);
 int ops__load_1entry(int filehandle, struct estat *sts, char **filename,

Modified: trunk/fsvs/src/global.h
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/glo​bal.h?view=diff&​rev=28&p1=trunk/​fsvs/src/global.h​&r1=27&p2=trunk​/fsvs/src/global.h​&r2=28
====================​====================​====================​==================
--- trunk/fsvs/src/global.h (original)
+++ trunk/fsvs/src/global.h Sun Oct 9 23:16:37 2005
@@ -104,7 +104,6 @@
         // directories
         struct {
             unsigned entry_count;
- unsigned subdir_count;
 
             // NULL-terminated
             struct estat **by_inode;
@@ -116,7 +115,7 @@
         };
     };
 
- /* these are for use with the commit/update actions. */
+ /* these are for temporary use, eg in the commit/update actions. */
     union {
         /* commit */
         struct {
@@ -126,6 +125,14 @@
         struct {
             apr_file_t *source, *target;
         };
+ /* input_tree */
+ struct {
+ unsigned child_count;
+ };
+ /* output_tree */
+ struct {
+ unsigned file_index;
+ };
     };
 
     /* common variables */

Modified: trunk/fsvs/src/waa.c
Url: http://fsvs.tigris.o​rg/source/browse/fsv​s/trunk/fsvs/src/waa​.c?view=diff&rev​=28&p1=trunk/fsv​s/src/waa.c&r1=2​7&p2=trunk/fsvs/​src/waa.c&r2=28
====================​====================​====================​==================
--- trunk/fsvs/src/waa.c (original)
+++ trunk/fsvs/src/waa.c Sun Oct 9 23:16:37 2005
@@ -475,8 +475,7 @@
 
             STOPIF( waa__build_tree(sts), NULL );
 
- root->subdir_coun​t+=sts->subdir_co​unt;
- /* can this fail ?? */
+ /* this can fail if the parent directories have been removed. */
             STOPIF_CODE_ERR( chdir("..") == -1, errno,
                     "parent has gone");
         }
@@ -642,7 +641,7 @@
 int waa__output_tree(struct estat *root)
 {
     struct estat ***directory, *sts, **sts_pp;
- int max_dir, i;
+ int max_dir, i, alloc_dir;
     unsigned this_len;
     int status, waa_info_hdl=-1;
     unsigned complete_count, string_space;
@@ -659,11 +658,15 @@
     STOPIF_CODE_ERR( i != sizeof(header), errno,
             "header was not written");
 
- directory=calloc(roo​t->subdir_count+1​, sizeof(*directory));
+
+ /* Take a page of pointers (on x86-32). Will be reallocated if
+ * necessary. */
+ alloc_dir=1024;
+ directory=calloc(alloc_dir+1, sizeof(*directory));
     STOPIF_ENOMEM(!directory);
 
- STOPIF( ops__save_1entry(root, waa_info_hdl, NULL), NULL);
- root->st.st_ino=c​omplete_count=1;
+ STOPIF( ops__save_1entry(root, 0, waa_info_hdl, NULL), NULL);
+ root->file_index=​complete_count=1;
 
     root->path_len=st​ring_space=strlen(ro​ot->name)+1;
     max_path_len=root->path_len;
@@ -683,11 +686,12 @@
         sts=( *directory[0] );
 
         // do current entry
- STOPIF( ops__save_1entry(sts, waa_info_hdl, NULL), NULL);
+ STOPIF( ops__save_1entry(sts, sts->parent->file_index,
+ waa_info_hdl, NULL), NULL);
 
         complete_count++;
         /* store position number for child -> parent relationship */
- sts->st.st_ino=co​mplete_count;
+ sts->file_index=c​omplete_count;
 
         this_len=strlen(sts-​>name)+1;
         string_space += this_len;
@@ -742,6 +746,24 @@
 
         if (S_ISDIR(sts->st.st_mode) && sts->entry_count>0)
         {
+ /* It's easy and possible to have always the correct number
+ * of subdirectories in root->subdir_count. We'd just have
+ * to walk up to the root in build_tree and add_directory
+ * and increment the number there.
+ *
+ * But
+ * - we don't really know if this size is really required and
+ * - we'd like to decrease the size of the structure,
+ * so we don't use that really anymore - we realloc the pointers
+ * if necessary. */
+ if (max_dir >= alloc_dir)
+ {
+ alloc_dir *= 2;
+ DEBUGP("reallocated directory pointers to %u entries", alloc_dir);
+ directory=realloc(directory, (alloc_dir+1) * sizeof(*directory));
+ STOPIF_ENOMEM(directory);
+ }
+
             /* sort into array */
             i=waa___find_positio​n(sts->by_inode, directory, max_dir);
 
@@ -773,7 +795,7 @@
     /* save header information */
     status=snprintf(header, sizeof(header), waa__header_line,
             WAA_VERSION, sizeof(header),
- complete_count, root->subdir_count, string_space,
+ complete_count, alloc_dir, string_space,
             max_path_len);
     BUG_ON(status >= sizeof(header)-1, "header space not large enough");
 
@@ -899,7 +921,6 @@
 
                     STOPIF( waa__build_tree(sts), NULL);
 
- /* again: can this fail ??? */
                     STOPIF_CODE_ERR( chdir("..") == -1, errno,
                             "parent went away");
                 }
@@ -1049,14 +1070,14 @@
             if (sts->parent->​entry_status & FS_REMOVED)
                 goto removed;
 
- sts->parent->by_inode[ sts->parent->s​ubdir_count++ ] = sts;
- BUG_ON(sts->paren​t->subdir_count > sts->parent->entry_count,
+ sts->parent->by_inode[ sts->parent->c​hild_count++ ] = sts;
+ BUG_ON(sts->paren​t->child_count > sts->parent->entry_count,
                     "too many children for parent");
 
 
             /* If this was the last entry (of its parent), and the parent
              * may have changed, check for new files. */
- if (sts->parent->​subdir_count == sts->parent->entry_count &&
+ if (sts->parent->child_count == sts->parent->entry_count &&
                     sts->parent->e​ntry_status)
             {
                 /* Check the parent for added elements.
@@ -1120,8 +1141,7 @@
             {
                 sts->by_inode=mal​loc(sizeof(*sts->​by_inode) * (sts->entry_count+1));
                 sts->by_inode[sts​->entry_count]=NU​LL;
- /* subdir_count is used as child counter */
- sts->subdir_count=0;
+ sts->child_count=0;
             }
             else if (sts->entry_status)
             {

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r28 - in trunk: . fsvs/src pmarek P.Marek 2005-10-09 23:16:37 PDT
Messages per page: