]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/attr.c
ebl use tokyocabinet by default instead of htable
[bacula/bacula] / bacula / src / lib / attr.c
index 138dad8ad4b2b61288c5051f2bb3a53d610af472..5e5210e4af538903762c136e07c918870f00016d 100644 (file)
@@ -1,21 +1,14 @@
-/*
- *   attr.c  Unpack an Attribute record returned from the tape
- *
- *    Kern Sibbald, June MMIII  (code pulled from filed/restore.c and updated)
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2003-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
    modify it under the terms of version two of the GNU General Public
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *   attr.c  Unpack an Attribute record returned from the tape
+ *
+ *    Kern Sibbald, June MMIII  (code pulled from filed/restore.c and updated)
+ *
+ *   Version $Id$
+ */
+
 
 #include "bacula.h"
 #include "jcr.h"
 #include "lib/breg.h"
 
-ATTR *new_attr()
+ATTR *new_attr(JCR *jcr)
 {
    ATTR *attr = (ATTR *)malloc(sizeof(ATTR));
    memset(attr, 0, sizeof(ATTR));
    attr->ofname = get_pool_memory(PM_FNAME);
    attr->olname = get_pool_memory(PM_FNAME);
    attr->attrEx = get_pool_memory(PM_FNAME);
+   attr->jcr = jcr;
+   attr->uid = getuid();
    return attr;
 }
 
@@ -149,11 +152,7 @@ void build_attr_output_fnames(JCR *jcr, ATTR *attr)
     *
     */
 
-   if (jcr->where[0] == 0) {
-      pm_strcpy(attr->ofname, attr->fname);
-      pm_strcpy(attr->olname, attr->lname);
-
-   } else if (jcr->where_bregexp) { 
+   if (jcr->where_bregexp) { 
       char *ret;
       apply_bregexps(attr->fname, jcr->where_bregexp, &ret);
       pm_strcpy(attr->ofname, ret);
@@ -172,6 +171,10 @@ void build_attr_output_fnames(JCR *jcr, ATTR *attr)
          }
       }
       
+   } else if (jcr->where[0] == 0) {
+      pm_strcpy(attr->ofname, attr->fname);
+      pm_strcpy(attr->olname, attr->lname);
+
    } else {
       const char *fn;
       int wherelen = strlen(jcr->where);
@@ -237,12 +240,26 @@ void print_ls_output(JCR *jcr, ATTR *attr)
    char ec1[30];
    char en1[30], en2[30];
    char *p, *f;
+   guid_list *guid;
 
+   if (attr->type == FT_DELETED) { /* TODO: change this to get last seen values */
+      bsnprintf(buf, sizeof(buf),
+               "----------   - -        -                - ---------- --------  %s\n", attr->ofname);
+      Dmsg1(20, "%s", buf);
+      Jmsg(jcr, M_RESTORED, 1, "%s", buf);
+      return;
+   }
+
+   if (!jcr->id_list) {
+      jcr->id_list = new_guid_list();
+   }
+   guid = jcr->id_list;
    p = encode_mode(attr->statp.st_mode, buf);
    p += sprintf(p, "  %2d ", (uint32_t)attr->statp.st_nlink);
-   p += sprintf(p, "%-8.8s %-8.8s", getuser(attr->statp.st_uid, en1, sizeof(en1)),
-                getgroup(attr->statp.st_gid, en2, sizeof(en2)));
-   p += sprintf(p, "%10.10s ", edit_uint64(attr->statp.st_size, ec1));
+   p += sprintf(p, "%-8.8s %-8.8s", 
+                guid->uid_to_name(attr->statp.st_uid, en1, sizeof(en1)),
+                guid->gid_to_name(attr->statp.st_gid, en2, sizeof(en2)));
+   p += sprintf(p, "%10.10s ", edit_int64(attr->statp.st_size, ec1));
    p = encode_time(attr->statp.st_ctime, p);
    *p++ = ' ';
    *p++ = ' ';