LOCAL void
fifo_setparams()
{
	if (mp == NULL) {
		comerrno(EX_BAD, "Panic: NULL fifo parameter structure.\n");
		/* NOTREACHED */
		return;
	}
	mp->end = &mp->base[fs];
	mp->size = fs;
	mp->ibs = ibs;
	mp->obs = obs;

	if (hiw)
		mp->hiw = hiw;
	else
		mp->hiw = mp->size / 3 * 2;
	if (low)
		mp->low = low;
	else
		mp->low = mp->size / 3;
	if (mp->low < mp->obs)
		mp->low = mp->obs;
	if (mp->low > mp->hiw)
		mp->low = mp->hiw;

	if (ibs == 0 || mp->ibs > mp->size)
		mp->ibs = mp->size;
}
예제 #2
0
파일: files.c 프로젝트: Distrotech/cdrkit
void
add_file(char *filename)
{
	char	buff[PATH_MAX];
	FILE	*f;
	char	*ptr;
	char	*p2;
	int	count = 0;

	if (strcmp(filename, "-") == 0) {
		f = stdin;
	} else {
		f = fopen(filename, "r");
		if (f == NULL) {
#ifdef	USE_LIBSCHILY
			comerr("Cannot open '%s'.\n", filename);
#else
			perror("fopen");
			exit(1);
#endif
		}
	}
	while (fgets(buff, sizeof (buff), f)) {
		count++;
		ptr = buff;
		while (isspace(*ptr))
			ptr++;
		if (*ptr == 0)
			continue;
		if (*ptr == '#')
			continue;

		if (ptr[strlen(ptr) - 1] == '\n')
			ptr[strlen(ptr) - 1] = 0;
		p2 = strchr(ptr, '=');
		if (p2 == NULL) {
#ifdef	USE_LIBSCHILY
			comerrno(EX_BAD, "Error in file '%s' line %d: %s\n",
						filename, count, buff);
#else
			fprintf(stderr, "Error in file '%s' line %d: %s\n",
						filename, count, buff);
			exit(1);
#endif
		}
		*p2 = 0;
		p2++;
		add_one_file(ptr, p2);
	}
	if (f != stdin)
		fclose(f);
}
예제 #3
0
int add_boot_mips_filename(char *filename)
{
    if (boot_mips_num_files < MAX_NAMES)
    {
        boot_mips_filename[boot_mips_num_files] = filename;
        boot_mips_num_files++;
    }

    else
    {
#ifdef	USE_LIBSCHILY
        comerrno(EX_BAD, "Too many MIPS boot files!\n");
#else
        fprintf(stderr, "Too many MIPS boot files!\n");
        exit(1);
#endif
    }
    return 0;
}
예제 #4
0
static int boot_mips_write(FILE *outfile)
{
	struct directory_entry	*boot_file;	/* Boot file we need to search for */
    unsigned long length = 0;
    unsigned long extent = 0;
	int i;
	struct volume_header vh;
    unsigned long long iso_size = 0;
    char *filename = NULL;

	memset(&vh, 0, sizeof(vh));

    iso_size = last_extent * 2048;

    write_be32(VHMAGIC, (unsigned char *)&vh.vh_magic);

	/* Values from an IRIX cd */
    write_be16(BYTES_PER_SECTOR, (unsigned char *)&vh.vh_dp.dp_secbytes);
    write_be16(SECTORS_PER_TRACK, (unsigned char *)&vh.vh_dp.dp_secs);
    write_be32(DP_RESEEK|DP_IGNOREERRORS|DP_TRKFWD, (unsigned char *)&vh.vh_dp.dp_flags);
    write_be16(1, (unsigned char *)&vh.vh_dp.dp_trks0);

    write_be16((iso_size + BYTES_PER_SECTOR - 1) / (SECTORS_PER_TRACK * BYTES_PER_SECTOR),
               (unsigned char *)&vh.vh_dp.dp_cyls);

	for(i = 0; i < boot_mips_num_files; i++)
    {
        boot_file = search_tree_file(root, boot_mips_filename[i]);
        
        if (!boot_file) {
#ifdef	USE_LIBSCHILY
            comerrno(EX_BAD, "Uh oh, I cant find the MIPS boot file '%s'!\n",
                     boot_mips_filename[i]);
#else
            fprintf(stderr, "Uh oh, I cant find the MIPS boot file '%s'!\n",
                    boot_mips_filename[i]);
            exit(1);
#endif
        }

        extent = get_733(boot_file->isorec.extent) * 4;
        length = ((get_733(boot_file->isorec.size) + 2047) / 2048) * 2048;
        filename = file_base_name(boot_mips_filename[i]);

        strncpy((char *)vh.vh_vd[i].vd_name, filename, MIN(VDNAMESIZE, strlen(filename)));
        write_be32(extent, (unsigned char *)&vh.vh_vd[i].vd_lbn);
        write_be32(length, (unsigned char *)&vh.vh_vd[i].vd_nbytes);
        
        fprintf(stderr, "Found mips boot image %s, using extent %lu (0x%lX), #blocks %lu (0x%lX)\n",
                filename, extent, extent, length, length);
	}

	/* Create volume partition on whole cd iso */
    write_be32((iso_size + (BYTES_PER_SECTOR - 1))/ BYTES_PER_SECTOR, (unsigned char *)&vh.vh_pt[10].pt_nblks);
    write_be32(0, (unsigned char *)&vh.vh_pt[10].pt_firstlbn);
    write_be32(PTYPE_VOLUME, (unsigned char *)&vh.vh_pt[10].pt_type);

	/* Create volume header partition, also on WHOLE cd iso */
    write_be32((iso_size + (BYTES_PER_SECTOR - 1))/ BYTES_PER_SECTOR, (unsigned char *)&vh.vh_pt[8].pt_nblks);
    write_be32(0, (unsigned char *)&vh.vh_pt[8].pt_firstlbn);
    write_be32(PTYPE_VOLHDR, (unsigned char *)&vh.vh_pt[8].pt_type);

	/* Create checksum */
	vh_calc_checksum(&vh);

    jtwrite(&vh, sizeof(vh), 1, 0, FALSE);
    xfwrite(&vh, sizeof(vh), 1, outfile, 0, FALSE);
    last_extent_written++;

	return 0;
}
예제 #5
0
static int
usalo_dopen(SCSI *usalp, char *device)
{
	comerrno(EX_BAD, "SCSI open usage error.\n");
	return (-1);	/* Keep lint happy */
}
예제 #6
0
static int
usalo_dopen(SCSI *usalp, char *device)
{
	comerrno(EX_BAD, "No local SCSI transport implementation for this architecture.\n");
	return (-1);	/* Keep lint happy */
}
예제 #7
0
static int
usalo_ropen(SCSI *usalp, char *device)
{
	comerrno(EX_BAD, "No remote SCSI transport available.\n");
	return (-1);	/* Keep lint happy */
}