Skip site navigation (1)Skip section navigation (2)
Date:      05 Dec 1999 00:40:14 +0100
From:      Assar Westerlund <assar@sics.se>
To:        Randell Jesup <rjesup@wgate.com>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Portable way to compare struct stat's?
Message-ID:  <5laenqz34x.fsf@foo.sics.se>
In-Reply-To: Randell Jesup's message of "04 Dec 1999 15:49:59 -0500"
References:  <ybu4se3lomv.fsf@jesup.eng.tvol.net.jesup.eng.tvol.net> <3845712D.F4D51A70@softweyr.com> <v04210100b46cd2f23ff6@[128.113.24.47]> <5lwvqu7as2.fsf@foo.sics.se> <ybuk8muh1mw.fsf@jesup.eng.tvol.net.jesup.eng.tvol.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Randell Jesup <rjesup@wgate.com> writes:
> 	Sounds like what we'd want to build it upon.  If the FS doesn't
> support it, use st_dev/st_ino.

Actually, since it's in the kernel, the default implementation of the
vnode operation might be:

int
vop_default_cmp (struct vnode *v1, struct vnode *v2)
{
  return v1 == v2;
}

Or did you mean a fallback in the library function for when the kernel
doesn't provide the fdcmp (or whatever) system call?  That could be
something like:

/*
 * 1 if fd1 and fd2 point to the same file.
 * 0 if they are not
 * -1 if we can't compare them
 */

int
fdcmp (int fd1, int fd2)
{
  struct stat sb1, sb2;

  if(fstat(fd1, &sb1) < 0 || fstat(fd2, &sb2) < 0)
    return -1;
  return sb1.st_dev == sb2.st_dev && sb1.st_ino == sb2.st_ino;
}

> The real problem is getting people to switch.

You mean application programs?  Sure, but the only thing we can do
about that is implementing support for it, right?

/assar


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5laenqz34x.fsf>