From nobody Sat Aug 13 19:19:16 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M4r2J6JVVz4YgZB for ; Sat, 13 Aug 2022 19:19:20 +0000 (UTC) (envelope-from mgorny@moritz.systems) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M4r2H4fBmz3pZn for ; Sat, 13 Aug 2022 19:19:19 +0000 (UTC) (envelope-from mgorny@moritz.systems) Received: by mail-wm1-x32e.google.com with SMTP id ay12so2043356wmb.1 for ; Sat, 13 Aug 2022 12:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=moritz-systems.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc; bh=beFs/8MMrZU46L+L5STsiYWPs8mFik1RMW4nyraT3Jo=; b=qWFl64owy4wTbCmwBATDnj3BWqSosBdWJDBd97VqMEs+ud7zCXcgXEXayDiATXoke2 7lLuCldeaKG6hNpEm1Ra8yYZExeSEsGAqp0j7AqZviUQCw/HkDiGAthAd23T9DPOAutz ZLQy+pS7xUhsUXwtAyhx+v4t4OWugpGWVbApEzStpS2RCHSgk/TKPDtfv3bQw/zHgm6p EGPM5ENx7muRWSBe9vls0K7UBViEcNJ1k1ID3wM8Y9NA60SRcBe16RoPGtoloTp4JQVg qWmGShv+DgNzFTiL0ralXBdCTDe/3BNRbsOvi+5bve/U8yyXd5BfTe2bUinnFaX/edix +BiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc; bh=beFs/8MMrZU46L+L5STsiYWPs8mFik1RMW4nyraT3Jo=; b=a9XuH5ej9TxapAk2irCdfHWIaKE1XXY0ZDW5CH/OeR2mbVwOsrAmUsqZwJ0KHSQmji XWy0e1uMvQ4kfT9UH2u/s3+HC0JIdEuKW5Nq6cjUlPCApfBX19/TFfBd67ywhegiw6v0 cDkE+kU1b6bvWJBbdzXA6ujG3dIZAqouiL7lFr64V3RxkaQVYVZFZ+dKZO/07KlQgqja vVwsdNF8TJNCUVdZ7dmUOTiWyqFlNa3uS/Cimk8r5A4rOP8QhZLm2g77nUwYVd0NgpqV tZZ7T2+/YmLyb7IPz5hTMB/xAcHeQ5+Kem2gIvMuh1OY7iKOhfI3DfGtQ2ZOxol5nhyB WwkQ== X-Gm-Message-State: ACgBeo1oQ4Y/NLD1G72q4WYwKBCczK0sQ1j0Wj6GR7+PtTZCwAXccdoH BXehbPAW18JudoUaWNgoxXUREA== X-Google-Smtp-Source: AA6agR7J+ZX2q/7yRN9ObFxY1cRaGf0st1db0MxPGf69r0MyRRtcPBuFcJIprnMmufnusJzl5gRplg== X-Received: by 2002:a05:600c:4f84:b0:3a5:c6b4:e7c9 with SMTP id n4-20020a05600c4f8400b003a5c6b4e7c9mr5955113wmq.149.1660418357871; Sat, 13 Aug 2022 12:19:17 -0700 (PDT) Received: from [192.168.1.1] (c141-88.icpnet.pl. [85.221.141.88]) by smtp.gmail.com with ESMTPSA id h23-20020a05600c145700b003a529b7bc27sm3809541wmi.9.2022.08.13.12.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 12:19:17 -0700 (PDT) Message-ID: <0cb00216675d883162148e6dc1e0b90c4c8be5f2.camel@moritz.systems> Subject: Re: How to monitor a directory in FreeBSD? From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= To: meator , Gleb Popov Cc: freebsd-hackers Date: Sat, 13 Aug 2022 21:19:16 +0200 In-Reply-To: References: <652f3c12-388c-04d0-ebeb-753b76b2b742@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 X-Rspamd-Queue-Id: 4M4r2H4fBmz3pZn X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=moritz-systems.20210112.gappssmtp.com header.s=20210112 header.b=qWFl64ow; dmarc=none; spf=softfail (mx1.freebsd.org: 2a00:1450:4864:20::32e is neither permitted nor denied by domain of mgorny@moritz.systems) smtp.mailfrom=mgorny@moritz.systems X-Spamd-Result: default: False [-1.30 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; R_MIXED_CHARSET(1.00)[subject]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[moritz-systems.20210112.gappssmtp.com:s=20210112]; MIME_GOOD(-0.10)[text/plain]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TAGGED_RCPT(0.00)[]; DMARC_NA(0.00)[moritz.systems]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[moritz-systems.20210112.gappssmtp.com:+]; RCVD_COUNT_THREE(0.00)[3]; R_SPF_SOFTFAIL(0.00)[~all]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::32e:from]; FREEMAIL_TO(0.00)[gmail.com,freebsd.org]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; MIME_TRACE(0.00)[0:+]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org] X-ThisMailContainsUnwantedMimeParts: N On Sat, 2022-08-13 at 21:09 +0200, meator wrote: > On 8/13/22 17:35, Gleb Popov wrote: > >=20 > > Yes, there is no native API to monitor directories. You can use=20 > > libinotify from ports, which replicates Linux inotify API and it does= =20 > > have ability to monitor directories. > >=20 >=20 > I would like to avoid extra dependencies. If I would like to do this,=20 > than I would probably choose FAM of Gamin. The Linux Programming=20 > Interface book references these two as a more cross platform=20 > alternatives to inotify. The program I'm working on should also work on= =20 > Linux. I'm currently want to implement both inotify and kqueue and make= =20 > the preprocessor pick the right one when compiling. >=20 > But I didn't know inotify for BSD exists. This would mean that I=20 > wouldn't have to implement the directory monitoring twice. I'll take=20 > this into consideration. Thanks! I'm afraid I'm going to be a bit of spoilsport but please bear in mind that inotify -- at least on Linux -- is not 100% reliable (or at least it wasn't the last time I've used it). In general, it's a great optimization but your program also needs to have fallback logic to periodically check for changes that weren't reported. --=20 Best regards, Micha=C5=82 G=C3=B3rny