1 Index: src/dird/ua_label.c
2 ===================================================================
3 --- src/dird/ua_label.c (révision 7144)
4 +++ src/dird/ua_label.c (copie de travail)
5 @@ -1015,3 +1015,142 @@
6 return strncmp(mr->VolumeName, ua->jcr->pool->cleaning_prefix,
7 strlen(ua->jcr->pool->cleaning_prefix)) == 0;
12 + * Print slots from AutoChanger
14 +void status_slots(UAContext *ua, STORE *store_r)
18 + vol_list_t *vl, *vol_list = NULL;
25 + if (!open_client_db(ua)) {
28 + store.store = store_r;
30 + pm_strcpy(store.store_source, _("command line"));
31 + set_wstorage(ua->jcr, &store);
32 + drive = get_storage_drive(ua, store.store);
34 + max_slots = get_num_slots_from_SD(ua);
36 + if (max_slots <= 0) {
37 + ua->warning_msg(_("No slots in changer to scan.\n"));
40 + slot_list = (char *)malloc(max_slots+1);
41 + if (!get_user_slot_list(ua, slot_list, max_slots)) {
46 + vol_list = get_vol_list_from_SD(ua, true /* want to see all slots */);
49 + ua->warning_msg(_("No Volumes found, or no barcodes.\n"));
53 + ua->info_msg(_(" Slot | Volume Name | Status | Type | Pool | Loaded |\n"));
54 + ua->info_msg(_("------+------------------+-----------+------------+--------------------+---------|\n"));
56 + /* Walk through the list getting the media records */
57 + for (vl=vol_list; vl; vl=vl->next) {
58 + if (vl->Slot > max_slots) {
59 + ua->warning_msg(_("Slot %d greater than max %d ignored.\n"),
60 + vl->Slot, max_slots);
63 + /* Check if user wants us to look at this slot */
64 + if (!slot_list[vl->Slot]) {
65 + Dmsg1(100, "Skipping slot=%d\n", vl->Slot);
69 + slot_list[vl->Slot] = 0; /* clear Slot */
72 + Dmsg1(100, "No VolName for Slot=%d.\n", vl->Slot);
74 + ua->info_msg(_(" %4i%c| %16s | %9s | %10s | %18s | %i |\n"),
76 + "?", "?", "?", "?", 0);
78 + ua->info_msg(_("%i||||||\n"), vl->Slot);
83 + /* Hope that slots are ordered */
84 + for (; i < vl->Slot; i++) {
87 + ua->info_msg(_(" %4i | %16s | %9s | %10s | %18s | %i |\n"),
88 + i, "", "", "", "", 0);
90 + ua->info_msg(_("%i||||||\n"), i);
96 + memset(&mr, 0, sizeof(mr));
97 + bstrncpy(mr.VolumeName, vl->VolName, sizeof(mr.VolumeName));
99 + if (mr.VolumeName[0] && db_get_media_record(ua->jcr, ua->db, &mr)) {
100 + memset(&pr, 0, sizeof(POOL_DBR));
101 + pr.PoolId = mr.PoolId;
102 + if (!db_get_pool_record(ua->jcr, ua->db, &pr)) {
103 + strcpy(pr.Name, "?");
107 + /* Print information */
108 + ua->info_msg(_(" %4i%c| %16s | %9s | %10s | %18s | %i |\n"),
109 + vl->Slot, ((vl->Slot==mr.Slot)?' ':'*'),
110 + mr.VolumeName, mr.VolStatus, mr.MediaType, pr.Name, 0);
112 + ua->info_msg(_("%i|%i|%s|%s|%s|%s|%i|\n"),
113 + vl->Slot, mr.Slot, mr.VolumeName, mr.VolStatus, mr.MediaType, pr.Name, 0);
118 + } else { /* TODO: get information from catalog */
119 + ua->info_msg(_(" %4i%c| %16s | %9s | %10s | %18s | %i |\n"),
121 + mr.VolumeName, "?", "?", "?", 0);
126 + /* Display the rest of the autochanger
128 + for (; i <= max_slots; i++) {
129 + if (slot_list[i]) {
131 + ua->info_msg(_(" %4i | %16s | %9s | %10s | %18s | %i |\n"),
132 + i, "", "", "", "", 0);
134 + ua->info_msg(_("%i||||||\n"), i);
142 + free_vol_list(vol_list);
144 + close_sd_bsock(ua);
148 Index: src/dird/ua_status.c
149 ===================================================================
150 --- src/dird/ua_status.c (révision 7144)
151 +++ src/dird/ua_status.c (copie de travail)
153 static void do_client_status(UAContext *ua, CLIENT *client, char *cmd);
154 static void do_director_status(UAContext *ua);
155 static void do_all_status(UAContext *ua);
156 +void status_slots(UAContext *ua, STORE *store);
158 static char OKqstatus[] = "1000 OK .status\n";
159 static char DotStatusJob[] = "JobId=%s JobStatus=%c JobErrors=%d\n";
162 store = get_storage_resource(ua, false/*no default*/);
164 - do_storage_status(ua, store, NULL);
165 + if (find_arg(ua, NT_("slots")) > 0) {
166 + status_slots(ua, store);
168 + do_storage_status(ua, store, NULL);