/* After parsing, but before sending to various devices. Will repeat 3 times if needed */ SIZE_OR_ERROR FS_read_postparse(struct one_wire_query *owq) { struct parsedname *pn = PN(owq); SIZE_OR_ERROR read_or_error; // ServerRead jumps in here, perhaps with non-file entry if (pn->selected_device == NO_DEVICE || pn->selected_filetype == NO_FILETYPE) { return -EISDIR; } /* Normal read. Try three times */ LEVEL_DEBUG("%s", pn->path); STATLOCK; AVERAGE_IN(&read_avg); AVERAGE_IN(&all_avg); STATUNLOCK; /* First try */ STAT_ADD1(read_tries[0]); read_or_error = (pn->type == ePN_real) ? FS_read_real(owq) : FS_r_virtual(owq); STATLOCK; if (read_or_error >= 0) { ++read_success; /* statistics */ read_bytes += read_or_error; /* statistics */ } AVERAGE_OUT(&read_avg); AVERAGE_OUT(&all_avg); STATUNLOCK; LEVEL_DEBUG("%s return %d", pn->path, read_or_error); return read_or_error; }
/* After parsing, but before sending to various devices. Will repeat 3 times if needed */ SIZE_OR_ERROR FS_read_postparse(struct one_wire_query *owq) { struct parsedname *pn = PN(owq); SIZE_OR_ERROR read_or_error; /* Normal read. Try three times */ LEVEL_DEBUG("%s", pn->path); STATLOCK; AVERAGE_IN(&read_avg); AVERAGE_IN(&all_avg); STATUNLOCK; /* First try */ STAT_ADD1(read_tries[0]); /* Check file type. */ if (pn->selected_device == NO_DEVICE || pn->selected_filetype == NO_FILETYPE) { if (KnownBus(pn) && BusIsServer(pn->selected_connection)) { /* Pass unknown remote filetype to remote owserver. */ read_or_error = FS_r_given_bus(owq); } else { /* Local unknown filetypes are directories. */ return -EISDIR; } } else { /* Local known filetypes are handled here. */ read_or_error = (pn->type == ePN_real) ? FS_read_real(owq) : FS_r_virtual(owq); } STATLOCK; if (read_or_error >= 0) { ++read_success; /* statistics */ read_bytes += read_or_error; /* statistics */ } AVERAGE_OUT(&read_avg); AVERAGE_OUT(&all_avg); STATUNLOCK; LEVEL_DEBUG("%s return %d", pn->path, read_or_error); return read_or_error; }