Subject: Re: re-reading /etc/resolv.conf on change
To: None <tech-userlevel@NetBSD.ORG>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-userlevel
Date: 01/07/2004 12:01:48
"Greg A. Woods" wrote:

> and there's no way st_mtime can change more
> than once per second

Where do you get this idea from?

	#include <sys/stat.h>

	main()
	{
		struct stat a, b;
		int i, j;

		system(">foofoo");
		stat("foofoo", &a);
		usleep(1);
		system(">foofoo");
		stat("foofoo", &b);
		printf("a.mtime = %d.%09d\n", a.st_mtime, a.st_mtimensec);
		printf("b.mtime = %d.%09d\n", b.st_mtime, b.st_mtimensec);
		i = b.st_mtime - a.st_mtime;
		j = b.st_mtimensec - a.st_mtimensec;
		if (j < 0) {
			j += 1000000000;
			i--;
		}
		printf("diff    = %d.%09d\n", i, j);
		exit(0);
	}

when run gives:

	a.mtime = 1073437129.174145000
	b.mtime = 1073437129.194148000
	diff    = 0.020003000

In this case, the file changed and only st_mtimensec changed - st_mtime
remained the same.

_Please_ test your assertions before making them in public.

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD Support and Service:         http://www.wasabisystems.com/