Mail Archives: cygwin/2003/02/21/10:28:15
--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Thu, Feb 20, 2003 at 06:47:39PM -0500, Paul Swartz wrote:
> On 20 Feb 2003 at 22:40, Corinna Vinschen wrote:
> > As you can see, there's also nothing which would help you in using the
> > result to identify the sockets as being the same. Even the timestamps
> > aren't identical.
>
> No one field can say it's the same file. All of them together, or a
> sufficiently large number of them, does.
Nope. How should they? The really interesting fields are not identical
as e. g. st_dev, st_ino, st_mode, st_ctime. Anyway, that's not a Cygwin
issue anymore.
> Even if it isn't completely portable, at the very least, things like the
> uid/gid definatly shouldn't change. The ctime/mtime probably shouldn't
> either, I'm less sure about atime. I don't have a copy of POSIX, does that
> say anything about the stat/fstat semantics?
SUSv3: http://www.opengroup.org/
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin AT cygwin DOT com
Red Hat, Inc.
--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sock-stat.c"
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/un.h>
#include <unistd.h>
int
main (int argc, char **argv)
{
int fd;
struct sockaddr_un addr;
socklen_t addrlen;
char buf[100];
struct stat st;
/* creating test unix domain socket pipe */
fd = socket(AF_UNIX, SOCK_DGRAM, 0);
/* SOCK_DGRAM require this to bind */
bzero((char *)&addr, sizeof(addr));
/* fill in addr structire */
addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, "pipe.101");
addrlen = sizeof(addr.sun_family) + strlen(addr.sun_path) + 1;
/* unlink old socket file */
unlink(addr.sun_path);
/* bind socket to special file named pipe.100 in current directory */
bind(fd, (struct sockaddr *)&addr, addrlen);
printf ("STAT : \"%s\"\n", addr.sun_path);
if (!stat (addr.sun_path, &st))
{
printf ("st_dev : 0x%x\n", st.st_dev);
printf ("st_ino : %lu\n", st.st_ino);
printf ("st_mode : 0%o\n", st.st_mode);
printf ("st_nlink : %d\n", st.st_nlink);
printf ("st_uid : %d\n", st.st_uid);
printf ("st_gid : %d\n", st.st_gid);
printf ("st_rdev : 0x%x\n", st.st_rdev);
printf ("st_size : %ld\n", st.st_size);
printf ("st_blksize: %ld\n", st.st_blksize);
printf ("st_blocks : %ld\n", st.st_blocks);
printf ("st_ctime : %ld\n", st.st_ctime);
printf ("st_mtime : %ld\n", st.st_mtime);
printf ("st_atime : %ld\n", st.st_atime);
}
printf ("FSTAT : \"%s\"\n", addr.sun_path);
if (!fstat (fd, &st))
{
printf ("st_dev : 0x%x\n", st.st_dev);
printf ("st_ino : %lu\n", st.st_ino);
printf ("st_mode : 0%o\n", st.st_mode);
printf ("st_nlink : %d\n", st.st_nlink);
printf ("st_uid : %d\n", st.st_uid);
printf ("st_gid : %d\n", st.st_gid);
printf ("st_rdev : 0x%x\n", st.st_rdev);
printf ("st_size : %ld\n", st.st_size);
printf ("st_blksize: %ld\n", st.st_blksize);
printf ("st_blocks : %ld\n", st.st_blocks);
printf ("st_ctime : %ld\n", st.st_ctime);
printf ("st_mtime : %ld\n", st.st_mtime);
printf ("st_atime : %ld\n", st.st_atime);
}
return 0;
}
--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--Kj7319i9nmIyA2yE--
- Raw text -