Date: Fri, 27 Sep 2019 23:37:43 +0300 From: Oleksandr Rybalko <ray@ddteam.net> To: mike tancsa <mike@sentex.net> Cc: Warner Losh <imp@bsdimp.com>, freebsd-embedded <freebsd-embedded@freebsd.org> Subject: Re: watchdogd stat location Message-ID: <CAJ1Oi8HWrEHUTwSq%2B0QTGVCUdne9SEwsAOBOD8eJtZHmv-76_Q@mail.gmail.com> In-Reply-To: <fcdd9659-d7e4-c554-b501-6b8cd178f6d7@sentex.net> References: <5eba25eb-9ba4-0c93-27c8-e834491298ad@sentex.net> <CANCZdfp6bym5b6eFXFH0MxjYsAX%2B1Bi9fGXgp7sFM206zmsveQ@mail.gmail.com> <CAJ1Oi8FsG=nEBXdd0CS3U2zZSgh=SMcBO0ieY-KT5b1iDVFmJg@mail.gmail.com> <83831ae6-9275-4f0c-a23d-c9cca3dc28f4@sentex.net> <CANCZdfrRh7Ssf9vSSJ4Hopec1q7abLi9AdUqoPqZm4hPok6QUQ@mail.gmail.com> <fcdd9659-d7e4-c554-b501-6b8cd178f6d7@sentex.net>
next in thread | previous in thread | raw e-mail | index | archive | help
/sbin and /usr may fail in many case. Maybe readdir, then rand stat? =D0=BF=D1=82, 27 =D0=B2=D0=B5=D1=80. 2019 =D0=BE 23:30 mike tancsa <mike@se= ntex.net> =D0=BF=D0=B8=D1=88=D0=B5: > 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 !=3D NULL) > failed =3D system(test_cmd); > - else > - failed =3D stat("/etc", &sb); > - > + else { > + > + srand(time(NULL)); > + switch(rand() % 4) { > + case 0: > + failed =3D stat("/", &sb); > + break; > + case 1: > + failed =3D stat("/bin", &sb); > + break; > + case 2: > + failed =3D stat("/sbin", &sb); > + break; > + default: > + failed =3D stat("/usr", &sb); > + } > + } > error =3D watchdog_getuptime(&ts_end); > if (error) { > end_program =3D 1; > > > > > --=20 WBW ------- Rybalko Aleksandr <ray@ddteam.net>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ1Oi8HWrEHUTwSq%2B0QTGVCUdne9SEwsAOBOD8eJtZHmv-76_Q>