util.c revision 0c83a891bb3029b854c3ebe4d0467b839a68fa49
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libintl.h>
#include <time.h>
#include <pwd.h>
#include <auth_attr.h>
#include <auth_list.h>
#include <secdb.h>
#include "transport.h"
#include "util.h"
#include "mmc.h"
#include "msgs.h"
#include "misc_scsi.h"
#include "main.h"
#include "trackio.h"
#include "bstream.h"
char strbuf[81];
int priv_change_needed = 0;
void *
{
void *ret;
/* Lets wait a sec. and try again */
(void) sleep(1);
}
"Memory allocation failure, Exiting...\n"));
exit(1);
}
}
return (ret);
}
/*
* Prints a string after going back pos number of steps.
* Mainly used to show %age complete.
*/
int
{
}
}
/*
* dump the trackio_error struct.
*/
void
{
case TRACKIO_ERR_SYSTEM:
return;
case TRACKIO_ERR_TRANSPORT:
return;
}
return;
}
if (debug) {
} else {
}
return;
}
return;
case TRACKIO_ERR_USER_ABORT:
return;
default:
if (debug) {
}
}
}
char *
get_err_str(void)
{
if (str_errno != 0)
return (str_errno_to_string(str_errno));
}
int
get_audio_type(char *ext)
{
return (AUDIO_TYPE_SUN);
return (AUDIO_TYPE_WAV);
return (AUDIO_TYPE_CDA);
return (AUDIO_TYPE_AUR);
return (-1);
}
/*
* common routines for showing progress.
*/
int progress_pos;
static uint64_t last_total;
void
init_progress(void)
{
progress_pos = 0;
last_total = 0;
}
int
{
char s[BUFSIZE];
if (completed == -1) {
/* Got ^C. Add 2 to progress pos to compensate for ^ and C */
return (0);
}
if (total == 0) {
}
} else {
if (total == last_total)
return (0);
last_total = total;
if (total > 100) {
/* There is clearly a miscalculation somewhere */
if (debug)
(void) printf("\nWrote more than 100 %% !!\n");
return (0);
}
if (total == 100) {
/* l10n_NOTE : 'done' as in "Writing track 1...done" */
} else {
}
}
return (0);
}
void
raise_priv(void)
{
if (priv_change_needed && (cur_uid != 0)) {
if (seteuid(0) == 0)
cur_uid = 0;
}
}
void
lower_priv(void)
{
if (priv_change_needed && (cur_uid == 0)) {
}
}
int
{
/* fail if we cannot get password entry */
return (0);
}
/*
* check in the RBAC authority files to see if
* the user has permission to use CDRW
*/
/* user is not in database, return failure */
return (0);
} else {
return (1);
}
}
/*
* This will busy delay in ms milliseconds. Needed for cases
* where 1 sec wait is too long. This is needed for some newer
* drives which can empty the drive cache very quickly.
*/
void
{
yield();
}