]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_label.c
Fix couple of g++ warnings
[bacula/bacula] / bacula / src / dird / ua_label.c
index 6848c2b55b43cfc116f74216121df39cb09a61b4..df9578fd55a04c31961e767cb15e6292dc0e9184 100644 (file)
@@ -6,7 +6,7 @@
    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
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -84,6 +84,9 @@ static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots)
       slot_list[i] = 0;
    }
    i = find_arg_with_value(ua, "slots");
+   if (i == -1) {  /* not found */
+      i = find_arg_with_value(ua, "slot");
+   }
    if (i > 0) {
       /* scan slot list in ua->argv[i] */
       char *p, *e, *h;
@@ -154,6 +157,7 @@ static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots)
    return true;
 
 bail_out:
+   Dmsg1(100, "Problem with user selection ERR=%s\n", msg);
    return false;
 }
 
@@ -893,13 +897,28 @@ static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan)
          vl->next = vol_list;
          vol_list = vl;
       } else {
-         /* Add new entry to end of list */
+         vol_list_t *prev=vol_list;
+         /* Add new entry to the right place in the list */
          for (vol_list_t *tvl=vol_list; tvl; tvl=tvl->next) {
+            if (tvl->Slot > vl->Slot) {
+               /* no previous item, update vol_list directly */
+               if (prev == vol_list) {  
+                  vl->next = vol_list;
+                  vol_list = vl;
+
+               } else {     /* replace the previous pointer */
+                  prev->next = vl;
+                  vl->next = tvl;
+               }
+               break;
+            }
+            /* we are at the end */
             if (!tvl->next) {
                tvl->next = vl;
                vl->next = NULL;
                break;
             }
+            prev = tvl;
          }
       }
    }
@@ -1062,6 +1081,11 @@ static void content_send_info(UAContext *ua, char type, int Slot, char *vol_name
  * S:2:E               or S:Slot num:E
  * S:3:F:vol4
  *
+ * Import/Export tray slots:
+ * I:10:F:vol10           I:Slot num:F:Volume Name
+ * I:11:E              or I:Slot num:E
+ * I:12:F:vol40
+ *
  * If a drive is loaded, the slot *should* be empty 
  * 
  * Output:
@@ -1077,8 +1101,6 @@ static void content_send_info(UAContext *ua, char type, int Slot, char *vol_name
  * S|2||||||||
  * S|3|3|vol4|15869952|Append|LTO1-ANSI|Inc|1250858907|1282394907
  *
- * Type can be S or I (Slot or Import/Export)
- *
  * TODO: need to merge with status_slots()
  */
 void status_content(UAContext *ua, STORE *store)
@@ -1215,7 +1237,6 @@ void status_slots(UAContext *ua, STORE *store_r)
    }
    ua->send_msg(_(" Slot |   Volume Name    |   Status  |     Media Type       |      Pool          |\n"));
    ua->send_msg(_("------+------------------+-----------+----------------------+--------------------|\n"));
-   
 
    /* Walk through the list getting the media records */
    for (vl=vol_list; vl; vl=vl->next) {