/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* BSD 3 Clause License
*
* Copyright (c) 2007, The Storage Networking Industry Association.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* - Neither the name of The Storage Networking Industry Association (SNIA)
* nor the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include "tlm.h"
#include "tlm_proto.h"
/*
* Mutex for concurrent access to job_stats
*/
/*
* get the number of libraries
*/
int
tlm_library_count(void)
{
int lib;
library->tl_drive_count == 0) {
return (0);
}
}
return (tlm_info.ti_library_count);
}
/*
* get the library whose number matches
*/
{
return (library);
}
}
return (NULL);
}
/*
* get the info about this drive
*/
{
return (NULL);
}
return (drive);
}
}
return (NULL);
}
/*
* get the info about this slot
*/
{
return (slot);
}
}
return (NULL);
}
/*
* add a link to the INFO chain
*/
{
if (new_link == 0)
return (0);
if (job_stats == 0) {
return (0);
}
(void) mutex_lock(&jstat_mtx);
if (tlm_info.ti_job_stats == 0) {
} else {
}
(void) mutex_unlock(&jstat_mtx);
return (job_stats);
}
/*
* make sure this Job Stats buffer is not deleted while we use it
*/
{
(void) mutex_lock(&jstat_mtx);
if (link == 0) {
/*
* our tables are empty
*/
(void) mutex_unlock(&jstat_mtx);
return (&fake_job_stats);
}
do {
link->tc_ref_count++;
(void) mutex_unlock(&jstat_mtx);
return (job_stats);
}
"TAPE BACKUP> Ref for job [%s] was not found", name);
(void) mutex_unlock(&jstat_mtx);
return (&fake_job_stats);
}
/*
* remove a link to the INFO chain
*/
void
{
(void) mutex_lock(&jstat_mtx);
if (link == 0) {
" Internal error for job [%s], could not delete", name);
return;
}
do {
(void) mutex_unlock(&jstat_mtx);
return;
}
(void) mutex_unlock(&jstat_mtx);
"TAPE BACKUP> Delete for job [%s] was not found", name);
}
/*
* one party does not care about this blob, can we let it go?
*/
{
/*
* count down the number of
* interested parties for this blob
*/
link->tc_ref_count--;
if (link->tc_ref_count > 0) {
/*
* there is still interest in this blob,
* no change yet
*
* returning "old_top" means there is no change in the links
*/
return (old_top);
}
/*
* no one cares about this data anymore
* find out how to delete it
*/
do {
if (chain_link == link) {
/*
* If there are one or two elements in the list, then
* the prev and next pointers point to one element in
* the list, the element itself and the other element
* correspondingly. So we must distinguish if there
* are only one or two elements in the list. If
* either of the 'prev' or 'next' pointers point to
* the link itself, then we have only one element in
* the list.
*/
/*
* there is only this one link in the chain
* delete this and the chain is empty
*/
new_top = 0;
} else {
}
return (new_top);
}
} while (chain_link != old_top);
return (old_top);
}
/*
* the following section is global, but not really part of the
* public interface. Use of this outside of the tlm_*.c files
* is for special cases only.
*/
/*
* add a new tape library data blob to the list of libraries
* returns the new tape library data blob just created
*/
int
{
}
}
/*
* add a new tape drive data blob to the list of drives in a library
* returns the new tape drive data blob just created
*/
int
{
}
}
/*
* add a new tape slot data blob to the list of slots in a library
* returns the new tape slot data blob just created
*/
int
{
}
library->tl_slot_count++;
}