From owner-freebsd-hackers@freebsd.org Fri Jul 10 07:22:40 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 94F3A36146F for ; Fri, 10 Jul 2020 07:22:40 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B34Hz45DWz4F9t for ; Fri, 10 Jul 2020 07:22:39 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm1-x341.google.com with SMTP id j18so4896690wmi.3 for ; Fri, 10 Jul 2020 00:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=adIeQdLhfzA9h7CwjQ2V6pySJMjWRl0QGeCbmDvuSls=; b=BioQlFB2xLk7pRZ7KaaVXdqrHa5AES5uTWO+tTM8QiVmqj9Ndlwsml7F3GgIVyqpxM YmhAg4p/Gf3P0TVK8Fl4WjYwoO/eh8kkmYK/AJJAUVCowQKdUK94ug4X3AoHlrJIt+iE Hxw5F+9UM5V5dwrIhYOzWmIqdN+VTrj0Tpk0dYgEDWHqgupwOcEFzvAIqxLC8rzQQeRM ELg2jpUTYGrT9pMOtO5bKj4OxcSzz//Femdf81GLkeuss5NkMLkl71F7dOS955GFKtVb acX4aWFB4fK+vzrrZPBjaYZ/iG7K4+tU8/ZjgVtZ4utLg1Of5XgAEayyHWFEVRGoi82c xinQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=adIeQdLhfzA9h7CwjQ2V6pySJMjWRl0QGeCbmDvuSls=; b=Js29yDepgc9LHERWvZ1503CFm5K+XnN/GvhN5xgx6etGl6AL1CE69CG8dMkBx0I6oK AmttTXWOMtA0J6Xp+zagRLjBwFWUGJa0W3OkzJqbTWtKGCLf9X9D3M28jlI2gzbRqdh+ bprQi4AmvWcGxuKunlm3f5cG/6XzWgN/au5sSOQaPZrgC1X75E6JRw1Jn+B1yCEAmeLa rF1EoZQUyS/r0iD62k0cxiJpPns/eGKdx1h7earGzxUm4JF5AZY/42jCWxiMl/3ajp4T MqGFzaJPXQ8NWV42gQ1YIr9SAPsF78Z20aotgOixO8g7N1T5rBEVa5K3WJC24vyHlsGO g3yA== X-Gm-Message-State: AOAM532RNObw5LXspx8i1y5wyhPnqP8OIChabNjQ1pXdgeY1Cd9vWj8l cMs5VinY6tLix809NFxFxh2R11JshcniXe/4Tnc= X-Google-Smtp-Source: ABdhPJw8rpN7fiNwzHYDOlZr8btu49nUUyByq6WZsJM02ylLKEVPU6MQ1UHmY/PEjmxHSBP0FuhX1pmNZPbX5ovhftc= X-Received: by 2002:a05:600c:20d3:: with SMTP id y19mr4039988wmm.10.1594365758171; Fri, 10 Jul 2020 00:22:38 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:adf:9d84:0:0:0:0:0 with HTTP; Fri, 10 Jul 2020 00:22:37 -0700 (PDT) In-Reply-To: <21b0280d-c290-f27f-98a9-0c2242380718@rawbw.com> References: <21b0280d-c290-f27f-98a9-0c2242380718@rawbw.com> From: Mateusz Guzik Date: Fri, 10 Jul 2020 09:22:37 +0200 Message-ID: Subject: Re: Is it possible to determine the open file path based on the file descriptor? To: Yuri Cc: Freebsd hackers list Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4B34Hz45DWz4F9t X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=BioQlFB2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::341 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-2.72 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.98)[-0.984]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; NEURAL_HAM_LONG(-1.04)[-1.037]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::341:from]; NEURAL_HAM_SHORT(-0.70)[-0.700]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jul 2020 07:22:40 -0000 On 7/8/20, Yuri wrote: > Hi Hackers, > > > One of the ports (sysutils/watchman) attempts to find the path of the > file based on the file descriptor assuming that this descriptor > represents an open file. > I had a look at the program at hand. It seems to predominantly use F_GETPATH for de facto realpath, it looks like this: auto handle = openFileHandle(path, options); return handle.getOpenedPath(); That said, for this program on FreeBSD, the right thing to do is to convert it to actual realpath(3). In head this will be performant just fine as it is implemented as a syscall. I can MFC it for stable/12. -- Mateusz Guzik