From 69875c552d0554e2d33c8b9b56b16b3c9ddc8fec Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sat, 1 Jul 2006 16:58:35 +0200 Subject: * Implements -c (byte tail) * Small cleanups --- inotail.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/inotail.c b/inotail.c index bdabe9a..fadee12 100644 --- a/inotail.c +++ b/inotail.c @@ -40,7 +40,6 @@ #define VERSION "0.0" #define BUFFER_SIZE 4096 -#define DEFAULT_N_LINES 10 /* Print header with filename before tailing the file? */ static short verbose = 0; @@ -65,6 +64,8 @@ static off_t lines_to_offset(int fd, int file_size, unsigned int n_lines) char buf[BUFFER_SIZE]; off_t offset = file_size; + memset(&buf, 0, sizeof(buf)); + /* Negative offsets don't make sense here */ if (offset < 0) offset = 0; @@ -84,6 +85,8 @@ static off_t lines_to_offset(int fd, int file_size, unsigned int n_lines) lseek(fd, offset, SEEK_SET); rc = read(fd, &buf, block_size); + if (rc < 0) + return rc; for (i = block_size; i > 0; i--) { if (buf[i] == '\n') { @@ -101,7 +104,12 @@ static off_t lines_to_offset(int fd, int file_size, unsigned int n_lines) return offset; } -static int tail_file(struct file_struct *f, int n_lines) +static off_t bytes_to_offset(int fd, int file_size, unsigned int n_lines) +{ + return (file_size - n_lines); +} + +static int tail_file(struct file_struct *f, int n_lines, char mode) { int fd; ssize_t rc = 0; @@ -109,6 +117,7 @@ static int tail_file(struct file_struct *f, int n_lines) char buf[BUFFER_SIZE]; struct stat finfo; + dprintf(" Opening file: %s\n", f->name); fd = open(f->name, O_RDONLY); if (fd < 0) { perror("open()"); @@ -122,7 +131,10 @@ static int tail_file(struct file_struct *f, int n_lines) f->st_size = finfo.st_size; - offset = lines_to_offset(fd, f->st_size, n_lines); + if (mode == M_LINES) + offset = lines_to_offset(fd, f->st_size, n_lines); + else + offset = bytes_to_offset(fd, f->st_size, n_lines); if (verbose) write_header(f->name); @@ -156,7 +168,7 @@ static int watch_files(struct file_struct *f, int n_files) for (i = 0; i < n_files; i++) { f[i].i_watch = inotify_add_watch(ifd, f[i].name, - IN_MODIFY|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT); + IN_MODIFY|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT); dprintf(" Watch (%d) added to '%s' (%d)\n", f[i].i_watch, f[i].name, i); } @@ -226,6 +238,7 @@ static int watch_files(struct file_struct *f, int n_files) } if (inev->mask & IN_MOVE_SELF) { dprintf(" File '%s' moved.\n", fil->name); + /* TODO: Try to follow file/fd */ return -1; } if (inev->mask & IN_UNMOUNT) { @@ -244,7 +257,7 @@ int main(int argc, char **argv) int i, opt, ret = 0; int n_files = 0; int n_lines = DEFAULT_N_LINES; - short forever = 0; + char forever = 0, mode = M_LINES; char **filenames; struct file_struct *files; @@ -253,6 +266,12 @@ int main(int argc, char **argv) for (opt = 1; (opt < argc) && (argv[opt][0] == '-'); opt++) { switch (argv[opt][1]) { + case 'c': + mode = M_BYTES; + n_lines = strtoul(argv[++opt], NULL, 0); + if (n_lines < 0) + n_lines = 0; + break; case 'f': forever = 1; break; @@ -287,7 +306,7 @@ int main(int argc, char **argv) files = malloc(n_files * sizeof(struct file_struct)); for (i = 0; i < n_files; i++) { files[i].name = filenames[i]; - ret &= tail_file(&files[i], n_lines); + ret &= tail_file(&files[i], n_lines, mode); } if (forever) -- cgit v1.2.3-54-g00ecf ion>mode:
authorImre Deak <imre.deak@intel.com>2016-05-24 15:38:32 +0300
committerImre Deak <imre.deak@intel.com>2016-05-25 15:31:49 +0300
commit1c3f7700b2830cbcc25fda675ad5e997e1454703 (patch)
tree0e93a2cbdde4caf00d5490b3e294c95743e7d7a7
parent5a21b6650a239ebc020912968a44047701104159 (diff)
drm/i915/gen9: Assume CDCLK PLL is off if it's not locked
If the CDCLK PLL isn't locked or incorrectly configured we can just assume that it's off resulting in fully re-initializing both CDCLK PLL and CDCLK dividers. This way the CDCLK PLL sanitization added in the following patch can be done on BXT the same way as it's done on SKL. v2: (Ville) - Remove the remaining PLL specific checks from skl_sanitize_cdclk() and depend instead on the corresponding check in skl_dpll0_update(). - Use vco == 0 instead of the corresponding boolean check in skl_sanitize_cdclk(). CC: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1464093513-16258-1-git-send-email-imre.deak@intel.com
Diffstat