+static inline
+int ctf_pos_access_ok(struct ctf_stream_pos *pos, uint64_t bit_len)
+{
+ uint64_t max_len;
+
+ if (unlikely(pos->offset == EOF))
+ return 0;
+ if (pos->prot == PROT_READ) {
+ /*
+ * Reads may only reach up to the "content_size",
+ * regardless of the packet_size.
+ */
+ max_len = pos->content_size;
+ } else {
+ /* Writes may take place up to the end of the packet. */
+ max_len = pos->packet_size;
+ }
+ if (unlikely(pos->offset + bit_len > max_len))
+ return 0;
+ return 1;
+}
+