c - Read failed with error msg "Invalid argument" -
i try read data 1 fd, failed error message"invalid argument!".
struct inotify_event eventhdr; int head_read_len = (int)read(ctx->fd, (void *)&eventhdr, sizeof(inotify_event)); if(head_read_len == -1){ _debug("read eventhdr failed!!!!\n"); perror("read eventhdr!"); //print "invalid argument." } else{ _debug("read eventhdr succeed!!!!, head_read_len:%d, name:%s\n", head_read_len, eventhdr.name); lseek(ctx->fd, seek_cur, -head_read_len);
}
notes:
the
struct inotify_event
used inotify system call, man inotify more details.fd
guaranteed valid inotify file descriptor.
what seems problem? valuable insights?
the reason that: fd of inotify system call can not partially read.otherwise, return "invalid argument"!
use buffer large enough bytes!
Comments
Post a Comment