From patchwork Mon Sep 18 12:32:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 141520 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2885675vqi; Mon, 18 Sep 2023 12:03:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErbHx5+fMvTR76AT9WgDD82A6NGEN3kutnrFM0ieLpLwsSwlEo5LHuDm3+L5McoVzUDV6L X-Received: by 2002:a05:6a20:4322:b0:133:1d62:dcbd with SMTP id h34-20020a056a20432200b001331d62dcbdmr424834pzk.28.1695063781449; Mon, 18 Sep 2023 12:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695063781; cv=none; d=google.com; s=arc-20160816; b=QtBZv60YKRZWYA2QjWBPw5YfClkSbdV8zFEqTX80MznK0ldBe0tQb3jfUj4Q9h0Ej/ qNe8eGw2RmmB2PZjFu7wSG8CFiNtszqJVIr+T55dkMeUWiEjSEY7yF8zFkPMvY46z5Vf noSoKj1ORjo1MCdVVklcUFJ8EKwgEA0YJutxjWkIRjZSjj1LMbo8QMIseHgH4auhCWOT lB2j4Tr7jducjpaesYH4hNJGbTxSDU1KYHWEn2eGF3SpfEgTJQAYiB7LHnWUdWZNjduB k/KkVVANe3WjSlIWD+csXHWca40NXbRiTyD0c0x+Hrj+jESBXgUD5MW7OF0t76mDz3Bw OseQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iVQUJ/L8+afXKT69wRIL26IHsJ0vcphHTUN9uWpD+6k=; fh=wd7qOuYAeNqOqTJ3FnCoYa4/XxYdErzLkNb6cLbRrzw=; b=tRsBGf1hITZ8H3dPxjusSOeZjjS/QUdptrhE/PblFUQyFMCDvtF82F09tFhQ4mSR+6 Lqga18ZEFlDdfWqWp3VXmZ6RTZnMSUhb9ywyVf6gWba1Ys1O89+laPlfx2vC54XjwdmV dQYlZN0WsEU65m5j0YYHnvGrjR7CX6tgmDMVG73Rm64z9GArgRIKWvWBQGo1HAV7fKWw 19uKdWm9W53rpzIDddsIJwejR5dWcFIBrjUUoa+QMesYppE5Vu5q4JvgKShdXfkEJYTY mp5dZI2IwvrXDi484rMKoyiR4C2ravU40QWo6v2JCXP+jRzCJpapOZwCpJ/VdXs4RdwA xtYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=ZVJDUei0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o66-20020a634145000000b005777bea0b5esi8082527pga.901.2023.09.18.12.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 12:03:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=ZVJDUei0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CEC7C802923D; Mon, 18 Sep 2023 05:33:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241362AbjIRMdX (ORCPT + 27 others); Mon, 18 Sep 2023 08:33:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241330AbjIRMc4 (ORCPT ); Mon, 18 Sep 2023 08:32:56 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0264BC7 for ; Mon, 18 Sep 2023 05:32:36 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2bfed7c4e6dso31780671fa.1 for ; Mon, 18 Sep 2023 05:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1695040354; x=1695645154; 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=iVQUJ/L8+afXKT69wRIL26IHsJ0vcphHTUN9uWpD+6k=; b=ZVJDUei0T8xfdtWX15tKcApO5DRgqvWossHyS/Yo7okNpQcav0LIfkrrJ/dRxgUtoS dMbR5D4WEUPreV7wBLTlKjgC7dtk35RGPlh2PVFlIfMDntYOfK/E81js+s0ZonC3rg1I 1HD3KVIWrjTxMGDjGor7LqciO2j6GqTk03MS44Ojh+pz/omTEf/GWwnZlsQsQR/ljbtA NF/fyLltWyB4hnvTKdEqgWtjiXyU/8lnwAxzcuDESpZ89rXQ0saDf2oE+/lVAIw1Hwi/ V6AgiaGj6W+9mljljF+gJWWeHZYBb6MvNOFyntHkdDF1zqjJRpIJIMmD0yJdP1E77rZX UA7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695040354; x=1695645154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iVQUJ/L8+afXKT69wRIL26IHsJ0vcphHTUN9uWpD+6k=; b=vRfx78iiIGx1Z7rIuYpFW5uCQSQJJqAIB+mxckxJ6rIWV40K/yRZWB5ddCN69dZ8F+ zg9vaD4WTvIajFBwIJ9ILJdN1/9lB9Uml0SxMjDo02rDinMmseQnSDpsFhj1B6aKAwY7 UqKyqODGNCnZmPMmAJxh4SJUhzmT3SFqHY5d6j8Q/rdQc/Stqw/YF0Ft0lr1oI8biSZV Ufkm+fYQfsDoJ4/in4uiYy25ahmalxGBtYDJkRFfJyfSArLDzVI9llTtXkpnzOOzBH6j PdRWYx2Z28IRDsjiGXiW93XXkaFvMx/Au75+qCeMIiIoNG/SUYhdBSijbhPoF245pf/Y 16LA== X-Gm-Message-State: AOJu0Yxp154QtULx21yXxKyPISsMvjbD1Em3Vh4k4YoudxnEMwJtupG4 qN+h60BhX+itoLesVLnXZrTimw== X-Received: by 2002:a2e:80d7:0:b0:2bc:ff80:f639 with SMTP id r23-20020a2e80d7000000b002bcff80f639mr7962895ljg.7.1695040354219; Mon, 18 Sep 2023 05:32:34 -0700 (PDT) Received: from heron.intern.cm-ag (p200300dc6f209c00529a4cfffe3dd983.dip0.t-ipconnect.de. [2003:dc:6f20:9c00:529a:4cff:fe3d:d983]) by smtp.gmail.com with ESMTPSA id sd5-20020a170906ce2500b00992a8a54f32sm6328834ejb.139.2023.09.18.05.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 05:32:33 -0700 (PDT) From: Max Kellermann To: jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: amir73il@gmail.com, max.kellermann@ionos.com Subject: [PATCH 3/4] inotify_user: add system call inotify_add_watch_at() Date: Mon, 18 Sep 2023 14:32:16 +0200 Message-Id: <20230918123217.932179-3-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230918123217.932179-1-max.kellermann@ionos.com> References: <20230918123217.932179-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 05:33:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777400033300350220 X-GMAIL-MSGID: 1777403199669237692 This implements a missing piece in the inotify API: referring to a file by a directory file descriptor and a path name. This can be solved in userspace currently only by doing something similar to: int old = open("."); fchdir(dfd); inotify_add_watch(....); fchdir(old); Support for LOOKUP_EMPTY is still missing. We could add another IN_* flag for that (which would clutter the IN_* flags list further) or add a "flags" parameter to the new system call (which would however duplicate features already present via special IN_* flags). To: Jan Kara Cc: Amir Goldstein To: linux-fsdevel@vger.kernel.org To: linux-kernel@vger.kernel.org Signed-off-by: Max Kellermann --- fs/notify/inotify/inotify_user.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index b6e6f6ab21f8..8a9096c5ebb1 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -797,6 +797,12 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, return do_inotify_add_watch(fd, AT_FDCWD, pathname, mask); } +SYSCALL_DEFINE4(inotify_add_watch_at, int, fd, int, dfd, const char __user *, pathname, + u32, mask) +{ + return do_inotify_add_watch(fd, dfd, pathname, mask); +} + SYSCALL_DEFINE2(inotify_rm_watch, int, fd, __s32, wd) { struct fsnotify_group *group;