Lines Matching refs:file

74  * forward -- display the file, from an offset, forward.
77 * files, by bytes or lines and from the beginning or end of the file.
79 * FBYTES byte offset from the beginning of the file
83 * FLINES line offset from the beginning of the file
87 * RBYTES byte offset from the end of the file
92 * REG mmap the file and step back until reach the correct offset.
188 * rlines -- display the last offset lines of the file.
227 /* Set the file pointer to reflect the length displayed. */
239 show(file_info_t *file)
243 while ((ch = getc(file->fp)) != EOF) {
244 if (last != file && no_files > 1) {
247 file->file_name);
248 last = file;
254 if (ferror(file->fp)) {
255 (void) fclose(file->fp);
256 file->fp = NULL;
257 ierr(file->file_name);
260 clearerr(file->fp);
265 associate(file_info_t *file, boolean_t assoc, port_event_t *ev)
270 if (action != USE_PORT || file->fp == NULL)
273 if (!S_ISREG(file->st.st_mode)) {
279 fileno(file->fp), POLLIN, file);
282 fileno(file->fp));
288 bzero(&file->fobj, sizeof (file->fobj));
292 * PORT_SOURCE_FILE only allows us to specify a file name, not
293 * a file descriptor. If we are following a specific file (as
294 * opposed to a file name) and we were to specify the name of
295 * the file to port_associate() and that file were moved
297 * we would not know a name that would resolve to the new file
298 * (indeed, there might not be such a name -- the file may
300 * maps to the file and doesn't change: the name of the
301 * representation of the open file descriptor in /proc. We
303 * file), not the name of the file as specified at the command
310 sizeof (buf), "/proc/self/fd/%d", fileno(file->fp));
313 name = file->file_name;
324 file->fobj[0].fo_name = name;
325 file->fobj[1].fo_name = name;
346 (uintptr_t)&file->fobj[0], FILE_TRUNC, file);
348 (uintptr_t)&file->fobj[1]);
355 (uintptr_t)&file->fobj[1], FILE_MODIFIED, file);
360 (uintptr_t)&file->fobj[i]);
369 file_info_t *file;
371 for (i = 0, file = files; i < no_files; i++, file++) {
372 if (! file->fp)
375 (void) fstat(fileno(file->fp), &file->st);
377 associate(file, B_TRUE, NULL);
382 * follow -- display the file, from an offset, forward.
390 file_info_t *file;
396 file = files;
399 for (i = 0; i < no_files; i++, file++) {
400 if (file->fp) {
405 file->file_name);
406 forward(file->fp, file->file_name, style, off,
407 &file->st);
408 if (Fflag && fileno(file->fp) != STDIN_FILENO)
415 last = --file;
427 for (i = 0, file = files; i < no_files; i++, file++) {
428 if (!file->fp) {
429 file->fp = fopen(file->file_name, "r");
430 if (file->fp != NULL &&
431 fstat(fileno(file->fp), &file->st)
433 (void) fclose(file->fp);
434 file->fp = NULL;
436 if (file->fp != NULL)
440 if (fileno(file->fp) == STDIN_FILENO)
442 if (stat(file->file_name, &sb2) == -1) {
444 ierr(file->file_name);
445 (void) show(file);
446 (void) fclose(file->fp);
447 file->fp = NULL;
452 if (sb2.st_ino != file->st.st_ino ||
453 sb2.st_dev != file->st.st_dev ||
455 (void) show(file);
456 associate(file, B_FALSE, NULL);
457 file->fp = freopen(file->file_name, "r",
458 file->fp);
459 if (file->fp != NULL) {
460 (void) memcpy(&file->st, &sb2,
463 ierr(file->file_name);
469 for (i = 0, file = files; i < no_files; i++, file++)
470 if (file->fp && !show(file))
483 * we re-stat the file at least once every second.
488 file = (file_info_t *)ev.portev_user;
489 associate(file, B_TRUE, &ev);
492 (void) fseek(file->fp, 0, SEEK_SET);