doulimit.c revision 5c51f1241dbbdf2656d0e10011981411ed0c9673
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <sys/resource.h>
#include <string.h>
#include <signal.h>
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <locale.h>
#include <libintl.h>
#include <ctype.h>
#include <pkglib.h>
#include <libinst.h>
#define ERR_SET_ULIMIT "unable to set ulimit to <%ld> blocks"
#define ERR_DO_ULIMIT "An attempt was made to create a file larger than " \
"ULIMIT. Source of fault is unknown."
#define ERR_SCRULIMIT "Script <%s> attempted to create a file exceeding " \
"ULIMIT."
static int limit_is_set = 0, fail_return = 0;
void ulimit_quit(); /* XFSZ controlled signal handler. */
int clr_ulimit(); /* Clear the user supplied file size limit. */
void set_limit(); /* Called from installf to undo ulimit */
int assign_ulimit(char *fslimit);
extern int warnflag;
void
{
limit_is_set = 1;
}
int
{
if (limit_is_set) {
if (script_name)
script_name = NULL;
if (scr_error)
fail_return = 99;
/* Clear out the limit to infinity. */
} else
return (0);
}
/*
* This sets up the ULIMIT facility for the signal retrieval. This sets up
* the static pointers to the message constants for indicating where the
* error occurred.
*/
int
{
int n;
if (limit_is_set) {
if (script_name)
if (scr_error)
fail_return = 99;
return (n);
} else
return (0);
}
/* Validate ULIMIT and set accordingly. */
int
assign_ulimit(char *fslimit)
{
int cnt = 0;
/* fslimit must be a simple unsigned integer. */
do {
return (-1);
limit_is_set = 1;
return (0);
} else
return (-1);
}
/*
* This is the signal handler for ULIMIT.
*/
void
ulimit_quit(int n)
{
#ifdef lint
int i = n;
n = i;
#endif /* lint */
if (script_name) {
if (scr_error)
} else
}