From owner-freebsd-embedded@freebsd.org Fri Sep 27 21:31:39 2019 Return-Path: Delivered-To: freebsd-embedded@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 7C27212E02D for ; Fri, 27 Sep 2019 21:31:39 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) 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 46g4k22NCcz4PnS for ; Fri, 27 Sep 2019 21:31:38 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x72d.google.com with SMTP id q203so3206983qke.1 for ; Fri, 27 Sep 2019 14:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DyCmALwV3ldKmGeKvnv9ZJAI+1s6g9rSp6sdfDlLwIY=; b=t2vwjBwecQGv+XHdcLLy1i1frM2h/cvRadNn9AdUhN9ZdFrK+sC/6k5yfHjXo+/J+T RZYVg9X/ypkgsSCovuSd6eTcUPFScCm1tWRKLwjcus4c/Fb0TV8J9SNSEdo3rKHuz7BY 0ktopvnmRnTa9uG+zHqjRFNCQJi+QXhXGHZ9Aq8NfAn1r8/MnZ8YmMkmuov76kdGbvuR aJL1dJdM/f8zJ1tPkk3eN2zK1TygexMJa+qFWvUmSOnYKyI/rGCh6hXZEljEDDpgojd+ BXbu/BwoFjcxE3zmPCgNBcW5dTABYLpgUVdFxjHiIf8pERc2NOcvDRnJG6uS6XAkhAZ2 C16A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DyCmALwV3ldKmGeKvnv9ZJAI+1s6g9rSp6sdfDlLwIY=; b=rwbpoip3BIwhI+jv5b2+dQ4YgfhtRSijV9wmnHVsTSXEbruIsW53HjoOvk93+VELRn 3bxTRLPTFe2ItJmgDizxi891t7ubezGPXjt263ubfl2xpYzRgg3J7rXXezV8JTXzYbh/ XSsR5eMTzWaR4nQG+2DxJ0/bQx2ojT4H1W6P00D9TOue1NCmodJ5bUfUdHGMydMN8fgA PfEhQQlJMtr29NUlWl9HtsfIiT6qSrrEfHRHw/pqgnj9FUvHYMKDTDqsWa4pWNpph4X8 pKJGfd0u4+0OW1sAkKIHrDJYdDTUSAlw9WNxoVl0tpk9ty1ExWeazrp3Wp/RX99kluNp TocQ== X-Gm-Message-State: APjAAAXhyG3a8NPTk3IQ6HCpy/mBwrC+oyYTNgMyaksRYOQoFwle5xMP 3ktk+LiwjwYdj+j5YyQRi8rGwouQzlD9lF8ICOoSBw== X-Google-Smtp-Source: APXvYqykRhDbh/zmcrbnS5mkBdhXw4FUbeRH2bYckyitG/CQRKXpwm/Jbn0+RzNn7r3oV9qTGHxmZtEE6haL6Si2H0U= X-Received: by 2002:a05:620a:6af:: with SMTP id i15mr6946967qkh.380.1569619897010; Fri, 27 Sep 2019 14:31:37 -0700 (PDT) MIME-Version: 1.0 References: <5eba25eb-9ba4-0c93-27c8-e834491298ad@sentex.net> <83831ae6-9275-4f0c-a23d-c9cca3dc28f4@sentex.net> In-Reply-To: From: Warner Losh Date: Fri, 27 Sep 2019 15:31:25 -0600 Message-ID: Subject: Re: watchdogd stat location To: mike tancsa Cc: Aleksandr Rybalko , freebsd-embedded X-Rspamd-Queue-Id: 46g4k22NCcz4PnS X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=t2vwjBwe; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::72d) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-4.74 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-embedded@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; MIME_BASE64_TEXT(0.10)[]; RCVD_IN_DNSWL_NONE(0.00)[d.2.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-2.84)[ip: (-9.36), ipnet: 2607:f8b0::/32(-2.59), asn: 15169(-2.17), country: US(-0.05)]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Sep 2019 21:31:39 -0000 On Fri, Sep 27, 2019 at 2:30 PM mike tancsa wrote: > On 9/27/2019 3:53 PM, Warner Losh wrote: > > > > > > > I am all for that too. Just something other than /etc or /var > > which are > > often mounted on ramdisk. > > > > > > I think that / is too special to cause disk IO to ever happen. Other > > dirs will sometimes not be in the cache.... The notion here, perhaps > > bogus, is that we want to check the root FS is sane. The stat(2) is a > > cheap way to do this that will eventually fail if / goes wonky enough. > > It's weak. > > > > > Would something like this buy any extra sanity ? or not worth it. I > guess fancier checks belong in a passed program > > > # diff -u watchdogd.c.orig watchdogd.c > --- watchdogd.c.orig 2019-09-27 16:27:14.456973000 -0400 > +++ watchdogd.c 2019-09-27 16:27:18.904885000 -0400 > @@ -364,9 +364,23 @@ > > if (test_cmd != NULL) > failed = system(test_cmd); > - else > - failed = stat("/etc", &sb); > - > + else { > + > + srand(time(NULL)); > + switch(rand() % 4) { > + case 0: > + failed = stat("/", &sb); > + break; > + case 1: > + failed = stat("/bin", &sb); > + break; > + case 2: > + failed = stat("/sbin", &sb); > + break; > + default: > + failed = stat("/usr", &sb); > + } > + } > error = watchdog_getuptime(&ts_end); > if (error) { > end_program = 1; > I don't think the rand helps at all. I think you'd really rather do things sequentially. And this introduces more assumptions about the underlying filesystem(s). Warner