From nobody Fri Apr 3 01:25:53 2026 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD64E34D929 for ; Wed, 25 Mar 2026 19:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774465253; cv=none; b=TMhnoELiVtJaOF/yoszqZQIm07GxrVOXUHHfKOVMAwPKHQfpV/t8164fe3rXxBzNN/sndGYnxbN529/iNJ1PKpPYneioeJqkXhZpoOThCagrikhQC+r7lh+UN9oCnPoPH20wQ9O+15FE/wqAihMdVONUMX1y+0zXcAhME6In2h4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774465253; c=relaxed/simple; bh=Enw/zzJVJMDXaMMGM31CM+5uyNb3Ul/5hZTe/vhutLk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TUdFZVCcnccmZ1kVNeMdBJZVyZCNpv3KxJMylA8UgZtivNs6jP865Z06378Wd9mAI3tCw6Sg+sFhhVzgXT781RMBkCs/SCDRJo4mZi/TqS2qVs3D8v0RY896905mJPi5oIKN4wCUgOTh/+TJGTRJ7cfSkRl/JZdQkh3QoRLDnc0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ee.vjti.ac.in; spf=none smtp.mailfrom=ee.vjti.ac.in; dkim=pass (1024-bit key) header.d=vjti.ac.in header.i=@vjti.ac.in header.b=hZg5TDeu; arc=none smtp.client-ip=209.85.214.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ee.vjti.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ee.vjti.ac.in Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=vjti.ac.in header.i=@vjti.ac.in header.b="hZg5TDeu" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-2b04e6a989eso930395ad.3 for ; Wed, 25 Mar 2026 12:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vjti.ac.in; s=google; t=1774465247; x=1775070047; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QiX7Q0UkWwVNRq6H0KnVBDZPehmpnW8I6Y9xdRC1GFE=; b=hZg5TDeuKiGoKitY+K1cikB+gNHs6boOYL0N+KIBA+8uLZS604FRjRhEDuXRl14pGX 9+lP/J2UdVca8s1hbQwD2YhTrGLswAacjENQh5DdxNsubXo9unOo5dIFoeT5hX3LC/MS Sv2eKLNxMUwPgHfDVTGmeSgsBioI10q242kKg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774465247; x=1775070047; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=QiX7Q0UkWwVNRq6H0KnVBDZPehmpnW8I6Y9xdRC1GFE=; b=pt77pb6+0UVTf+IW2QLwxsDk2/1tIOAXiW6jfWcJfNNB22sRj5420GTaBTGWJchgjy uJzXJOkN2isVAfFUF40GTtG7boCQIsaEqa9u7GJ9WNX3mRmPpdifkS52PlZbhnS3iYqO bt7H/YasGWnPm8zNbOAAR/5JBg3J/uplxCmZ1c7cQzaPkojz33H90I6oe17szwBesGAu 8uMGiZ2sARKAQumDrphJJAtIzh02XyrNnT/xaxr2FI50dtqjJHi5raPX1kJTMqReojrN mVs31z34fKFvskHHPWC4TMb8FuaFWj5gMWuX9gLedqs2LtK8BS8kF7dUkZZAnuE/jb0z uVnw== X-Gm-Message-State: AOJu0YyF4j9cr0y9tVgZEI5yuOT/csBWRQewEGKhB+7X1PDDub4Q9f7C nmDHMge/V7z0DOArb7zL7eQG1y7u/5Ove4B0sNieRzmIr22TF5LjfnL76H9osGMUJXIHK2/dDnD RR51+9e4DQ4RX X-Gm-Gg: ATEYQzxDhJ5/3izSKxl7m0fdHQB23uBsZV+Txq/PtE+iOAwyMTOiJ8VoPRh+cA2FJQo zgOg++jiwmWl5G2hCRnTzrTEKHY5Lds/eZdlI7tdkG5DagB56/x8GJ7mGEZOBQOrcYlt+7xEdpK Uy8kB0SfbGGkDQLtV/H5pnHiFh17vczMnyO/Q6wRzs77WA2DN+9yu9rgOVDTuwOY7Jx4X6+0C5B Mm1U4bEIxqK4o02i5B52PzBQQu/+Sk/uko13kJGv0X1OPDf5NIIS9ZlcwIXGJH4LW3KPpoG0g3L zopAAo71iMaK4/vouJSVlShI0FcWT//BdEm1B+wHn8IY33wKP8OuZ9Rp8+FJYqKS32pxaeAXIMs Nukv2ypkdbmqDltvwxuImayF97Qu+8D3DC5WZEt1kJOvqSdjOZZiuZzLayIcmyNnA/K1wa4PAsc w/YgUsmUhYngt0k9trv2SxwlVBSfRoMX3sHVIRLM/ZJbxkauf6AyC64qSh19IdCJ67xlaF3WEa6 5oR2GmPaVf7488EjyNDcA== X-Received: by 2002:a17:903:1b43:b0:2aa:d671:e613 with SMTP id d9443c01a7336-2b0b0aac1c7mr55208405ad.38.1774465246593; Wed, 25 Mar 2026 12:00:46 -0700 (PDT) Received: from ranegod-HP-ENVY-x360-Convertible-13-bd0xxx.www.tendawifi.com ([14.139.108.62]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b0bc79f7dbsm6483485ad.25.2026.03.25.12.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2026 12:00:46 -0700 (PDT) From: Shaurya Rane To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: manfred@colorfullife.com, viro@zeniv.linux.org.uk, brauner@kernel.org, chuck.lever@oracle.com, jlayton@kernel.org, rstoyanov@fedoraproject.org, ptikhomirov@virtuozzo.com, Shaurya Rane Subject: [RFC PATCH 1/3] mqueue: uapi: add struct mq_peek_attr and F_MQ_PEEK Date: Thu, 26 Mar 2026 00:30:23 +0530 Message-Id: <20260325190025.40312-2-ssrane_b23@ee.vjti.ac.in> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260325190025.40312-1-ssrane_b23@ee.vjti.ac.in> References: <20260325190025.40312-1-ssrane_b23@ee.vjti.ac.in> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the user-visible interface for non-destructive POSIX message queue inspection via fcntl(2). POSIX message queues have no way to inspect queued messages without consuming them: mq_receive() always dequeues the message it returns. This makes it impossible for checkpoint/restore tools such as CRIU to save and replay message queue contents without destroying the queue state in the process. struct mq_peek_attr describes the request: the caller specifies an index into the queue in receive order (0 =3D next message that mq_receive() would return, i.e. highest priority, FIFO within same priority) and a buffer to receive the payload. On return, msg_prio is filled with the message priority and the return value is the number of bytes copied. F_MQ_PEEK =3D F_LINUX_SPECIFIC_BASE + 17 is the new fcntl command that accepts a pointer to struct mq_peek_attr. Link: https://github.com/checkpoint-restore/criu/issues/2285 Signed-off-by: Shaurya Rane --- include/uapi/linux/fcntl.h | 6 ++++++ include/uapi/linux/mqueue.h | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index aadfbf6e0cb3..ea34f87de0fb 100644 --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h @@ -84,6 +84,12 @@ #define F_GETDELEG (F_LINUX_SPECIFIC_BASE + 15) #define F_SETDELEG (F_LINUX_SPECIFIC_BASE + 16) =20 +/* + * Peek at a POSIX message queue message by index without consuming it. + * Argument is a pointer to struct mq_peek_attr (see ). + */ +#define F_MQ_PEEK (F_LINUX_SPECIFIC_BASE + 17) + /* Argument structure for F_GETDELEG and F_SETDELEG */ struct delegation { __u32 d_flags; /* Must be 0 */ diff --git a/include/uapi/linux/mqueue.h b/include/uapi/linux/mqueue.h index b516b66840ad..7133b84c70d1 100644 --- a/include/uapi/linux/mqueue.h +++ b/include/uapi/linux/mqueue.h @@ -53,4 +53,25 @@ struct mq_attr { =20 #define NOTIFY_COOKIE_LEN 32 =20 +/* + * Argument structure for fcntl(F_MQ_PEEK). + * + * Peek at a POSIX message queue message by index without removing it. + * @offset: Index in receive order (0 =3D highest priority, next to dequ= eue). + * FIFO ordering is preserved within the same priority level. + * @msg_prio: Output: priority of the message at @offset. + * @buf_len: Size of the caller-provided buffer at @buf. + * @buf: Output: message payload is written here; truncated to @buf_l= en + * bytes if the message is larger. + * + * Returns the number of bytes copied on success, -ENOMSG if @offset is + * >=3D mq_curmsgs, or a negative error code on failure. + */ +struct mq_peek_attr { + __s32 offset; + __u32 msg_prio; + __kernel_size_t buf_len; + char __user *buf; +}; + #endif --=20 2.34.1