Пример #1
0
static struct cl_attr *
new_cl_attr(char *cl_name)
{
	struct cl_attr *class, **class_ptr;

	if (cl_handle == -1) {
		cl_handle = ar_create(MALSIZ, sizeof (struct cl_attr),
		    "package class");
		if (cl_handle == -1) {
			progerr(gettext(ERR_MEMORY));
			return (NULL);
		}
	}

	class_ptr = (struct cl_attr **)ar_next_avail(cl_handle);

	if (class_ptr == NULL || *class_ptr == NULL) {
		progerr(gettext(ERR_MEMORY));
		return (NULL);
	}

	class = *class_ptr;

	strcpy(class->name, cl_name);
	class->inst_script = NULL;
	class->rem_script = NULL;
	class->src_verify = s_verify(cl_name);
	class->dst_verify = d_verify(cl_name);
	class->relpath_2_CAS = s_pathtype(cl_name);

	return (class);
}
Пример #2
0
/* This function sets up the standard parts of the fs_tab. */
static struct fstable *
fs_tab_init(char *mountp, char *fstype)
{
	struct fstable *nfte;

	/* Create the array if necessary. */
	if (fs_list == -1) {
		fs_list = ar_create(ALLOC_CHUNK,
		    (unsigned)sizeof (struct fstable),
		    "filesystem mount data");
		if (fs_list == -1) {
			progerr(ERR_MALLOC, "fs_list", errno, strerror(errno));
			return (NULL);
		}
	}

	/*
	 * Allocate an fstable entry for this mnttab entry.
	 */
	if ((nfte = *(struct fstable **)ar_next_avail(fs_list))
	    == NULL) {
		progerr(ERR_MALLOC, "nfte", errno, strerror(errno));
		return (NULL);
	}

	/*
	 * Point fs_tab at the head of the array again, since it may have
	 * moved due to realloc in ar_next_avail(). If ar_next_avail() realizes
	 * that there is no more room to grow the array, it reallocates the
	 * array. Because we stored pointer to that array in fs_tab, we need
	 * to make sure that it is updated as well.
	 */
	if ((fs_tab = (struct fstable **)ar_get_head(fs_list)) == NULL) {
		progerr(ERR_NOTABLE, "mount", MOUNT_TABLE, strerror(errno));
		return (NULL);
	}

	/*
	 * Get the length of the 'mount point' name.
	 */
	nfte->namlen = strlen(mountp);
	/*
	 * Allocate space for the 'mount point' name.
	 */
	if ((nfte->name = malloc(nfte->namlen+1)) == NULL) {
		progerr(ERR_MALLOC, "name", errno, strerror(errno));
		return (NULL);
	}
	(void) strcpy(nfte->name, mountp);

	if ((nfte->fstype = malloc(strlen(fstype)+1)) == NULL) {
		progerr(ERR_MALLOC, "fstype", errno, strerror(errno));
		return (NULL);
	}
	(void) strcpy(nfte->fstype, fstype);

	fs_tab_used++;

	return (nfte);
}