RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [email protected]
  Module: rpm                              Date:   14-Jul-2009 21:15:53
  Branch: HEAD                             Handle: 2009071419155300

  Modified files:
    rpm/rpmio               rpmdav.c

  Log:
    - rpmdav: compute st_nlink correctly on WebDAV collections.

  Summary:
    Revision    Changes     Path
    2.108       +28 -59     rpm/rpmio/rpmdav.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmdav.c
  ============================================================================
  $ cvs diff -u -r2.107 -r2.108 rpmdav.c
  --- rpm/rpmio/rpmdav.c        14 Jul 2009 13:58:04 -0000      2.107
  +++ rpm/rpmio/rpmdav.c        14 Jul 2009 19:15:53 -0000      2.108
  @@ -880,6 +880,7 @@
       struct fetch_resource_s * resitem = NULL;
       ne_propfind_handler *pfh;
       struct fetch_resource_s *current, *next;
  +    struct stat * st = avx->st;
       mode_t st_mode;
       int rc = 0;
       int xx;
  @@ -900,6 +901,10 @@
   
       ne_propfind_destroy(pfh);
   
  +    /* XXX fts(3) needs/uses st_ino. */
  +    /* Hash the path to generate a st_ino analogue. */
  +    st->st_ino = hashFunctionString(0, avx->uri, 0);
  +
       for (current = resitem; current != NULL; current = next) {
        const char *s, *se;
        char * val;
  @@ -911,6 +916,13 @@
        se = current->uri + strlen(current->uri);
        if (se[-1] == '/') {
            if (strlen(current->uri) <= strlen(path)) {
  +             st->st_mode = (S_IFDIR|0755);
  +             st->st_nlink += 2;
  +             /* XXX TODO: current-size is 0 here. */
  +             st->st_size = current->size;
  +             st->st_blocks = (st->st_size + 511)/512;
  +             st->st_mtime = current->modtime;
  +             st->st_atime = st->st_ctime = st->st_mtime;        /* HACK */
                current = fetch_destroy_item(current);
                continue;
            }
  @@ -928,10 +940,12 @@
   
        switch (current->type) {
        case resr_normal:
  -         st_mode = S_IFREG;
  +         st_mode = S_IFREG | 0644;
            /*...@switchbreak@*/ break;
        case resr_collection:
  -         st_mode = S_IFDIR;
  +         st_mode = S_IFDIR | 0755;
  +         if (S_ISDIR(st->st_mode))
  +             st->st_nlink++;
            /*...@switchbreak@*/ break;
        case resr_reference:
        case resr_error:
  @@ -943,6 +957,15 @@
        xx = rpmavxAdd(avx, val, st_mode, current->size, current->modtime);
        ne_free(val);
   
  +     if (current == resitem && next == NULL) {
  +         st->st_mode = st_mode;
  +         st->st_nlink = S_ISDIR(st_mode) ? 2 : 1;
  +         st->st_size = current->size;
  +         st->st_blocks = (st->st_size + 511)/512;
  +         st->st_mtime = current->modtime;
  +         st->st_atime = st->st_ctime = st->st_mtime;        /* HACK */
  +     }
  +
        current = fetch_destroy_item(current);
       }
       avx->resrock = NULL;     /* HACK: avoid leaving stack reference. */
  @@ -2089,7 +2112,7 @@
        /*...@modifies *buf @*/
   {
       sprintf(buf,
  -     "*** dev 0x%x ino 0x%x mode 0%0o nlink %d uid %d gid %d rdev 0x%x size 
%u\n",
  +     "dev 0x%x ino 0x%x mode 0%0o nlink %d uid %d gid %d rdev 0x%x size %u",
        (unsigned)st->st_dev,
        (unsigned)st->st_ino,
        (unsigned)st->st_mode,
  @@ -2127,36 +2150,9 @@
        goto exit;
       }
   
  -    /* XXX this should be WebDAV only now. */
  -    if (st->st_mode == 0)
  -     st->st_mode = (avx->ac > 1 ? S_IFDIR : S_IFREG);
  -    if (S_ISDIR(st->st_mode)) {
  -     if (st->st_nlink == 0)
  -         st->st_nlink = 2;
  -     if ((st->st_mode & 0777) == 0)
  -         st->st_mode |= 0755;
  -    } else
  -    if (S_ISREG(st->st_mode)) {
  -     if (st->st_nlink == 0)
  -         st->st_nlink = 1;
  -     if ((st->st_mode & 0777) == 0)
  -         st->st_mode |= 0644;
  -    }
  -    if (st->st_mtime == 0) {
  -     st->st_size = (avx->sizes ? avx->sizes[0] : (size_t)st->st_size);
  -     st->st_blocks = (st->st_size + 511)/512;
  -     st->st_mtime = (avx->mtimes ? avx->mtimes[0] : st->st_mtime);
  -     st->st_atime = st->st_ctime = st->st_mtime;        /* HACK */
  -    }
  -
  -    /* XXX Fts(3) needs/uses st_ino. */
  -    /* Hash the path to generate a st_ino analogue. */
  -    if (st->st_ino == 0)
  -     st->st_ino = hashFunctionString(0, path, 0);
  -
   exit:
   if (_dav_debug < 0)
  -fprintf(stderr, "<-- davStat(%s) rc %d\n%s", path, rc, statstr(st, buf));
  +fprintf(stderr, "<-- davStat(%s) rc %d\n\t%s\n", path, rc, statstr(st, buf));
       avx = rpmavxFree(avx);
       return rc;
   }
  @@ -2185,35 +2181,8 @@
        goto exit;
       }
   
  -    /* XXX this should be WebDAV only now. */
  -    if (st->st_mode == 0)
  -     st->st_mode = (avx->ac > 1 ? S_IFDIR : S_IFREG);
  -    if (S_ISDIR(st->st_mode)) {
  -     if (st->st_nlink == 0)
  -         st->st_nlink = 2;
  -     if ((st->st_mode & 0777) == 0)
  -         st->st_mode |= 0755;
  -    } else
  -    if (S_ISREG(st->st_mode)) {
  -     if (st->st_nlink == 0)
  -         st->st_nlink = 1;
  -     if ((st->st_mode & 0777) == 0)
  -         st->st_mode |= 0644;
  -    }
  -    if (st->st_mtime == 0) {
  -     st->st_size = (avx->sizes ? avx->sizes[0] : (size_t)st->st_size);
  -     st->st_blocks = (st->st_size + 511)/512;
  -     st->st_mtime = (avx->mtimes ? avx->mtimes[0] : st->st_mtime);
  -     st->st_atime = st->st_ctime = st->st_mtime;        /* HACK */
  -    }
  -
  -    /* XXX fts(3) needs/uses st_ino. */
  -    /* Hash the path to generate a st_ino analogue. */
  -    if (st->st_ino == 0)
  -     st->st_ino = hashFunctionString(0, path, 0);
  -
   if (_dav_debug < 0)
  -fprintf(stderr, "*** davLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
  +fprintf(stderr, "*** davLstat(%s) rc %d\n\t%s\n", path, rc, statstr(st, 
buf));
   exit:
       avx = rpmavxFree(avx);
       return rc;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to