Ejemplo n.º 1
0
/*
 * .bvfs_lsdirs jobid=1,2,3,4 pathid=10
 * .bvfs_lsdirs jobid=1,2,3,4 path=/
 * .bvfs_lsdirs jobid=1,2,3,4 path=
 */
bool dot_bvfs_lsdirs_cmd(UAContext *ua, const char *cmd)
{
   DBId_t pathid = 0;
   int limit = 2000, offset = 0;
   char *path = NULL, *jobid = NULL;

   if (!bvfs_parse_arg(ua, &pathid, &path, &jobid, &limit, &offset)) {
      ua->error_msg("Can't find jobid, pathid or path argument\n");
      return true;              /* not enough param */
   }

   if (!ua->guid) {
      ua->guid = new_guid_list();
   }

   Bvfs fs(ua->jcr, ua->db);
   fs.set_jobids(jobid);
   fs.set_limit(limit);
   fs.set_handler(bvfs_result_handler, ua);

   if (pathid) {
      fs.ch_dir(pathid);
   } else {
      fs.ch_dir(path);
   }

   fs.set_offset(offset);

   ua->send->array_start("directories");
   fs.ls_special_dirs();
   fs.ls_dirs();
   ua->send->array_end("directories");

   return true;
}
Ejemplo n.º 2
0
/*
 * .bvfs_versions jobid=0 client=<client-name> fnid=10 pathid=10 copies versions (jobid isn't used)
 */
bool dot_bvfs_versions_cmd(UAContext *ua, const char *cmd)
{
   DBId_t pathid = 0, fnid = 0;
   int limit = 2000, offset = 0;
   char *path = NULL, *jobid = NULL, *client = NULL;
   bool copies = false, versions = false;

   if (!bvfs_parse_arg(ua, &pathid, &path, &jobid, &limit, &offset)) {
      ua->error_msg("Can't find jobid, pathid or path argument\n");
      return false;             /* not enough param */
   }

   if (!bvfs_parse_arg_version(ua, &client, &fnid, &versions, &copies)) {
      ua->error_msg("Can't find client or fnid argument\n");
      return false;              /* not enough param */
   }

   if (!ua->guid) {
      ua->guid = new_guid_list();
   }

   Bvfs fs(ua->jcr, ua->db);
   fs.set_limit(limit);
   fs.set_see_all_versions(versions);
   fs.set_see_copies(copies);
   fs.set_handler(bvfs_result_handler, ua);
   fs.set_offset(offset);
   ua->send->array_start("versions");
   fs.get_all_file_versions(pathid, fnid, client);
   ua->send->array_end("versions");

   return true;
}
Ejemplo n.º 3
0
/*
 * Print an ls style message, also send M_RESTORED
 */
void print_ls_output(JCR *jcr, ATTR *attr)
{
   char buf[5000];
   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", 
                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++ = ' ';
   for (f=attr->ofname; *f && (p-buf) < (int)sizeof(buf)-10; ) {
      *p++ = *f++;
   }
   if (attr->type == FT_LNK) {
      *p++ = ' ';
      *p++ = '-';
      *p++ = '>';
      *p++ = ' ';
      /* Copy link name */
      for (f=attr->olname; *f && (p-buf) < (int)sizeof(buf)-10; ) {
         *p++ = *f++;
      }
   }
   *p++ = '\n';
   *p = 0;
   Dmsg1(20, "%s", buf);
   Jmsg(jcr, M_RESTORED, 1, "%s", buf);
}
Ejemplo n.º 4
0
/*
 * .bvfs_lsfiles jobid=1,2,3,4 pathid=10
 * .bvfs_lsfiles jobid=1,2,3,4 path=/
 */
bool dot_bvfs_lsfiles_cmd(UAContext *ua, const char *cmd)
{
   DBId_t pathid = 0;
   int limit = 2000, offset = 0;
   char *path = NULL, *jobid = NULL;
   char *pattern = NULL;
   int i;

   if (!bvfs_parse_arg(ua, &pathid, &path, &jobid, &limit, &offset)) {
      ua->error_msg("Can't find jobid, pathid or path argument\n");
      return false;             /* not enough param */
   }

   if ((i = find_arg_with_value(ua, "pattern")) >= 0) {
      pattern = ua->argv[i];
   }

   if (!ua->guid) {
      ua->guid = new_guid_list();
   }

   Bvfs fs(ua->jcr, ua->db);
   fs.set_jobids(jobid);
   fs.set_handler(bvfs_result_handler, ua);
   fs.set_limit(limit);
   if (pattern) {
      fs.set_pattern(pattern);
   }
   if (pathid) {
      fs.ch_dir(pathid);
   } else {
      fs.ch_dir(path);
   }

   fs.set_offset(offset);

   ua->send->array_start("files");
   fs.ls_files();
   ua->send->array_end("files");

   return true;
}