int probe_source(const char *vid_file, const char *aud_file, int range, int flags, vob_t *vob) { ProbeInfo vinfo, ainfo; // video and audio info structures /* Probe the video file, if present */ if (vid_file) { if (!do_probe(vid_file, vob->nav_seek_file, vob->dvd_title, range, (flags & TC_PROBE_NO_BUILTIN), (verbose >= TC_DEBUG) ? verbose : 0, &vinfo) ) { if (verbose & TC_DEBUG) { tc_log_warn(PACKAGE, "(%s) failed to probe video source", __FILE__); } return 0; } } else { vob->has_video = 0; } /* Probe the audio file, if present */ if (aud_file) { if (!do_probe(aud_file, vob->nav_seek_file, vob->dvd_title, range, (flags & TC_PROBE_NO_BUILTIN), (verbose >= TC_DEBUG) ? verbose : 0, &ainfo) ) { if (verbose & TC_DEBUG) { tc_log_warn(PACKAGE, "(%s) failed to probe audio source", __FILE__); } return 0; } } /* else it might be contained in the video file */ /* Set global parameters based on probed data */ probe_to_vob(vid_file ? &vinfo : NULL, aud_file ? &ainfo : NULL, flags, vob); if (verbose & TC_DEBUG) { tc_log_info(PACKAGE, "(%s) V format=0x%lx, A format=0x%lx," " V codec=0x%lx, A codec=0x%lx", __FILE__, vob->v_format_flag, vob->a_format_flag, vob->v_codec_flag, vob->a_codec_flag); tc_log_info(PACKAGE, "(%s) V format=%s, A format=%s, V codec=%s," " A codec=%s", __FILE__, tc_format_to_comment(vob->v_format_flag), tc_format_to_comment(vob->a_format_flag), tc_codec_to_comment(vob->v_codec_flag), tc_codec_to_comment(vob->a_codec_flag)); } /* All done, return success */ return 1; }
/*===========================================================================* * sef_cb_init_fresh * *===========================================================================*/ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) { /* Initialize the printer driver. */ /* If no printer is present, do not start. */ if (!do_probe()) return ENODEV; /* arbitrary error code */ /* Announce we are up! */ chardriver_announce(); return OK; }
/** * probe_stream_data: Probe a single source file and store the stream * informations in data structure. * * Parameters: * file: File name to probe. * range: Amount of input file to probe, in MB. * info: Structure to be filled in with probed data. * Return value: * Nonzero on success, zero on error. * Preconditions: * info != NULL, range > 0 */ int probe_stream_data(const char *file, int range, ProbeInfo *info) { if (!info || range <= 0) { tc_log_error(PACKAGE, "wrong probing parameters"); return 0; } if (!file) { tc_log_warn(PACKAGE, "missing source to probe"); memset(info, 0, sizeof(ProbeInfo)); } else { if (!do_probe(file, NULL, 0, range, 0, (verbose >= TC_DEBUG) ? verbose : 0, info) ) { if (verbose & TC_DEBUG) { tc_log_warn(PACKAGE, "(%s) failed to probe stream '%s'", __FILE__, file); } return 0; } } return 1; }
/* * This function is called from di_walk_minor() when any PROBE is processed */ static int probe_nexus_node(di_node_t di_node, di_minor_t minor, void *arg) { probe_info_t *pinfo = (probe_info_t *)arg; char *nexus_name, *nexus_dev_path; nexus_t *nexus; int fd; char nexus_path[MAXPATHLEN]; di_prop_t prop; char *strings; int *ints; int numval; int pci_node = 0; int first_bus = 0, last_bus = PCI_REG_BUS_G(PCI_REG_BUS_M); int domain = 0; #ifdef __sparc int bus_range_found = 0; int device_type_found = 0; di_prom_prop_t prom_prop; #endif #ifdef DEBUG nexus_name = di_devfs_minor_path(minor); fprintf(stderr, "-- device name: %s\n", nexus_name); #endif for (prop = di_prop_next(di_node, NULL); prop != NULL; prop = di_prop_next(di_node, prop)) { const char *prop_name = di_prop_name(prop); #ifdef DEBUG fprintf(stderr, " property: %s\n", prop_name); #endif if (strcmp(prop_name, "device_type") == 0) { numval = di_prop_strings(prop, &strings); if (numval == 1) { if (strncmp(strings, "pci", 3) != 0) /* not a PCI node, bail */ return (DI_WALK_CONTINUE); else { pci_node = 1; #ifdef __sparc device_type_found = 1; #endif } } } else if (strcmp(prop_name, "class-code") == 0) { /* not a root bus node, bail */ return (DI_WALK_CONTINUE); } else if (strcmp(prop_name, "bus-range") == 0) { numval = di_prop_ints(prop, &ints); if (numval == 2) { first_bus = ints[0]; last_bus = ints[1]; #ifdef __sparc bus_range_found = 1; #endif } } else if (strcmp(prop_name, "pciseg") == 0) { numval = di_prop_ints(prop, &ints); if (numval == 1) { domain = ints[0]; } } } #ifdef __sparc if ((!device_type_found) && di_phdl) { numval = di_prom_prop_lookup_strings(di_phdl, di_node, "device_type", &strings); if (numval == 1) { if (strncmp(strings, "pci", 3) != 0) return (DI_WALK_CONTINUE); else pci_node = 1; } } if ((!bus_range_found) && di_phdl) { numval = di_prom_prop_lookup_ints(di_phdl, di_node, "bus-range", &ints); if (numval == 2) { first_bus = ints[0]; last_bus = ints[1]; } } #endif if (pci_node != 1) return (DI_WALK_CONTINUE); /* we have a PCI root bus node. */ nexus = calloc(1, sizeof(nexus_t)); if (nexus == NULL) { (void) fprintf(stderr, "Error allocating memory for nexus: %s\n", strerror(errno)); return (DI_WALK_TERMINATE); } nexus->first_bus = first_bus; nexus->last_bus = last_bus; nexus->domain = domain; #ifdef __sparc if ((nexus->devlist = calloc(INITIAL_NUM_DEVICES, sizeof (struct pci_device *))) == NULL) { (void) fprintf(stderr, "Error allocating memory for nexus devlist: %s\n", strerror(errno)); free (nexus); return (DI_WALK_TERMINATE); } nexus->num_allocated_elems = INITIAL_NUM_DEVICES; nexus->num_devices = 0; #endif nexus_name = di_devfs_minor_path(minor); if (nexus_name == NULL) { (void) fprintf(stderr, "Error getting nexus path: %s\n", strerror(errno)); free(nexus); return (DI_WALK_CONTINUE); } snprintf(nexus_path, sizeof(nexus_path), "/devices%s", nexus_name); di_devfs_path_free(nexus_name); #ifdef DEBUG fprintf(stderr, "nexus = %s, bus-range = %d - %d\n", nexus_path, first_bus, last_bus); #endif if ((fd = open(nexus_path, O_RDWR | O_CLOEXEC)) >= 0) { nexus->fd = fd; nexus->path = strdup(nexus_path); nexus_dev_path = di_devfs_path(di_node); nexus->dev_path = strdup(nexus_dev_path); di_devfs_path_free(nexus_dev_path); if ((do_probe(nexus, pinfo) != 0) && (errno != ENXIO)) { (void) fprintf(stderr, "Error probing node %s: %s\n", nexus_path, strerror(errno)); (void) close(fd); free(nexus->path); free(nexus->dev_path); free(nexus); } else { nexus->next = nexus_list; nexus_list = nexus; } } else { (void) fprintf(stderr, "Error opening %s: %s\n", nexus_path, strerror(errno)); free(nexus); } return DI_WALK_CONTINUE; }
int main (int argc, char *argv[]) { int err = 0; struct stat sbuf; char *parsed_options = NULL; struct fuse_args fargs = FUSE_ARGS_INIT(0, NULL); struct extfs_data opts; debugf("version:'%s', fuse_version:'%d'", VERSION, fuse_version()); memset(&opts, 0, sizeof(opts)); if (parse_options(argc, argv, &opts)) { usage(); return -1; } if (stat(opts.device, &sbuf)) { debugf_main("Failed to access '%s'", opts.device); err = -3; goto err_out; } if (do_probe(&opts) != 0) { debugf_main("Probe failed"); err = -4; goto err_out; } parsed_options = parse_mount_options(opts.options ? opts.options : "", &opts); if (!parsed_options) { err = -2; goto err_out; } debugf_main("opts.device: %s", opts.device); debugf_main("opts.mnt_point: %s", opts.mnt_point); debugf_main("opts.volname: %s", (opts.volname != NULL) ? opts.volname : ""); debugf_main("opts.options: %s", opts.options); debugf_main("parsed_options: %s", parsed_options); if (fuse_opt_add_arg(&fargs, PACKAGE) == -1 || fuse_opt_add_arg(&fargs, "-s") == -1 || fuse_opt_add_arg(&fargs, "-o") == -1 || fuse_opt_add_arg(&fargs, parsed_options) == -1 || fuse_opt_add_arg(&fargs, opts.mnt_point) == -1) { debugf_main("Failed to set FUSE options"); fuse_opt_free_args(&fargs); err = -5; goto err_out; } if (opts.readonly == 0) { debugf_main("mounting read-write"); } else { debugf_main("mounting read-only"); } fuse_main(fargs.argc, fargs.argv, &ext2fs_ops, &opts); err_out: fuse_opt_free_args(&fargs); free(parsed_options); free(opts.options); free(opts.device); free(opts.volname); return err; }