X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=trunk%2Fltt-control%2Flttd%2Flttd.c;h=f21c411eb8940de479fb62980917c6880fae7e99;hb=42e99028d61b9ebf5d2a250fc99db0ec4941204a;hp=06af633741a319c6a13c410c2198bcfe9d98860c;hpb=083518b76f0614dc43b6a2fa06cc4ff337deb1f7;p=ltt-control.git diff --git a/trunk/ltt-control/lttd/lttd.c b/trunk/ltt-control/lttd/lttd.c index 06af633..f21c411 100644 --- a/trunk/ltt-control/lttd/lttd.c +++ b/trunk/ltt-control/lttd/lttd.c @@ -51,7 +51,8 @@ #define RELAY_GET_SUBBUF_SIZE _IOR(0xF5, 0x03,__u32) #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) -#include +#include +#if 0 /* should now be provided by libc. */ /* From the inotify-tools 2.6 package */ static inline int inotify_init (void) { @@ -67,6 +68,7 @@ static inline int inotify_rm_watch (int fd, __u32 wd) { return syscall (__NR_inotify_rm_watch, fd, wd); } +#endif //0 #define HAS_INOTIFY #else static inline int inotify_init (void) @@ -314,12 +316,16 @@ int open_buffer_file(char *filename, char *path_channel, char *path_trace, path_trace); fd_pairs->pair[fd_pairs->num_pairs-1].trace = - open(path_trace, O_WRONLY|O_APPEND, + open(path_trace, O_WRONLY, S_IRWXU|S_IRWXG|S_IRWXO); - if(fd_pairs->pair[fd_pairs->num_pairs-1].trace == -1) { perror(path_trace); } + ret = lseek(fd_pairs->pair[fd_pairs->num_pairs-1].trace, + 0, SEEK_END); + if (ret < 0) { + perror(path_trace); + } } else { printf("File %s exists, cannot open. Try append mode.\n", path_trace); open_ret = -1; @@ -437,7 +443,8 @@ int read_subbuffer(struct fd_pair *pair) unsigned int consumed_old; int err; long ret; - unsigned long len, offset; + unsigned long len; + off_t offset; err = ioctl(pair->channel, RELAY_GET_SUBBUF, &consumed_old); @@ -462,7 +469,8 @@ int read_subbuffer(struct fd_pair *pair) len = pair->subbuf_size; offset = 0; while (len > 0) { - printf_verbose("splice chan to pipe offset %lu\n", offset); + printf_verbose("splice chan to pipe offset %lu\n", + (unsigned long)offset); ret = splice(pair->channel, &offset, thread_pipe[1], NULL, len, SPLICE_F_MOVE); printf_verbose("splice chan to pipe ret %ld\n", ret); @@ -916,7 +924,11 @@ int channels_init() if(ret = open_channel_trace_pairs(channel_name, trace_name, &fd_pairs, &inotify_fd, &inotify_watch_array)) goto close_channel; - + if (fd_pairs.num_pairs == 0) { + printf("No channel available for reading, exiting\n"); + ret = -ENOENT; + goto close_channel; + } if(ret = map_channels(&fd_pairs, 0, fd_pairs.num_pairs)) goto close_channel; return 0;