Amanda-Users

Re: amtape update command missing?

2006-04-13 08:21:41
Subject: Re: amtape update command missing?
From: Jean-Louis Martineau <martineau AT zmanda DOT com>
To: Charles Smith <charon AT cyc DOT com>, jedlow AT u.washington DOT edu
Date: Thu, 13 Apr 2006 08:17:53 -0400
Charles, Alan,

Could you try the attached patch?

Jean-Louis

Jean-Louis Martineau wrote:
Charles, Alan,

The update command was added to the 2.4 branch but not to the 2.5 branch. I will send you
a patch when it will be ready.

Jean-Louis

Charles Smith wrote:
Hello,

Was there ever a response to this question? I couldn't find one in the
archives. I'm having the same problem. chg-zd-mtx says to use `amtape
<conf> update` to populate the changer-barcodes file, but amtape has no
such command, at least not in 2.5.0. (FYI  I'm using the opensuse10
rpms)

If it was deprecated, how do I tell chg-zd-mtx/amanda which labels are
associated with what barcodes? Do I just have to manually add entries
in the changer-barcodes file? And will it actually use it?

Thank you,
-Charles Smith

On Thu, 30 Mar 2006 10:53:15 -0800, Alan Jedlow wrote:
Hi,

How do I update the "changer-barcodes" file under AMANDA 2.5.0?  The
update command is missing from amtape:

amtape: unknown command "update"
Usage: amtape <conf> <command>
       Valid commands are:
               reset                Reset changer to known state
               eject                Eject current tape from drive
               clean                Clean the drive
               show                 Show contents of all slots
               current              Show contents of current slot
               slot <slot #>        load tape from slot <slot #>
               slot current         load tape from current slot
               slot prev            load tape from previous slot
               slot next            load tape from next slot
slot advance advance to next slot but do not load
               slot first           load tape from first slot
               slot last            load tape from last slot
               label <label>        find and load labeled tape
               taper                perform taper's scan alg.
               device               show current tape device


... it's still mentioned in the man page:

update Update the changer label database, if it has one, to match the tapes now available.
thanks,
 alan



diff -u -r --show-c-function --exclude-from=amanda.diff 
server-src/amtape.c.orig server-src/amtape.c
--- server-src/amtape.c.orig    2006-01-13 23:37:19.000000000 -0500
+++ server-src/amtape.c 2006-04-13 07:20:12.000000000 -0400
@@ -47,8 +47,10 @@ void load_slot P((int argc, char **argv)
 void load_label P((int argc, char **argv));
 void show_slots P((int argc, char **argv));
 void show_current P((int argc, char **argv));
+void update_labeldb P((int argc, char **argv));
 void amtape_taper_scan P((int argc, char **argv));
 void show_device P((int argc, char **argv));
+int update_one_slot P((void *ud, int rc, char *slotstr, char *device));
 int loadlabel_slot P((void *ud, int rc, char *slotstr, char *device));
 int show_init P((void *ud, int rc, int ns, int bk, int s));
 int show_init_all P((void *ud, int rc, int ns, int bk, int s));
@@ -90,6 +92,8 @@ static const struct {
        "taper                perform taper's scan alg." },
     { "device", show_device,
        "device               show current tape device" },
+    { "update", update_labeldb,
+       "update               update the label matchingdatabase"},
 };
 #define        NCMDS   (sizeof(cmdtab) / sizeof(cmdtab[0]))
 
@@ -509,3 +514,43 @@ char **argv;
     amfree(slot);
     amfree(device);
 }
+
+/* ---------------------------- */
+
+int update_one_slot(ud, rc, slotstr, device)
+    void *ud;
+    int rc;
+    char *slotstr;
+    char *device;
+{
+    char *errstr = NULL;
+    char *datestamp = NULL;
+    char *label = NULL;
+
+    if(rc > 1)
+       error("could not load slot %s: %s", slotstr, changer_resultstr);
+    else if(rc == 1)
+       fprintf(stderr, "slot %s: %s\n", slotstr, changer_resultstr);
+    else if((errstr = tape_rdlabel(device, &datestamp, &label)) != NULL)
+       fprintf(stderr, "slot %s: %s\n", slotstr, errstr);
+    else {
+       fprintf(stderr, "slot %s: date %-8s label %s\n",
+               slotstr, datestamp, label);
+       changer_label(slotstr, label);
+    }
+    amfree(errstr);
+    amfree(datestamp);
+    amfree(label);
+    return 0;
+}
+
+void update_labeldb(argc, argv)
+int argc;
+char **argv;
+{
+    if(argc != 1)
+       usage();
+
+    changer_find(NULL, show_init_all, update_one_slot, NULL);
+}
+