+ /*
+ * Validate UST buffer size and number of buffers: must both be power of 2
+ * and nonzero. We validate right here for UST, because applications will
+ * not report the error to the user (unlike kernel tracing).
+ */
+ if (!attr->attr.subbuf_size ||
+ (attr->attr.subbuf_size & (attr->attr.subbuf_size - 1))) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
+ /*
+ * Invalid subbuffer size if it's lower then the page size.
+ */
+ if (attr->attr.subbuf_size < page_size) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
+ if (!attr->attr.num_subbuf ||
+ (attr->attr.num_subbuf & (attr->attr.num_subbuf - 1))) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
+ if (attr->attr.output != LTTNG_EVENT_MMAP) {
+ ret = LTTNG_ERR_NOT_SUPPORTED;
+ goto error;
+ }
+
+ /*
+ * The tracefile_size should not be < to the subbuf_size, otherwise
+ * we won't be able to write the packets on disk
+ */
+ if ((attr->attr.tracefile_size > 0) &&
+ (attr->attr.tracefile_size < attr->attr.subbuf_size)) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }