Re: [ot] named sockets
On Mon, 7 May 2001 21:47:33 -0400 (EDT), Adam <[EMAIL PROTECTED]> wrote: >So I'm wondering, is there a way, kind of like "relink" system call which >coule take existing file descriptor (they are still so the fd is there, >just unlinked) and link it back to file name? POSIX' fattach(int fd, const char *path) library call does that, although it's often limited to STREAMS fd:s. It's usually implemented as mounting "namefs" at the path (SVR4) or setting a magic mount option (OSF1), with the fd passed in as mount-point specific data. Regular users are allowed to do this special mount(). Linux currently doesn't have this functionality, but it could probably be implemented as a pseudo-fs in 2.4, assuming the 2.4 VFS properly supports stacking of file systems. (There's some gotchas concerning chown/chmod changes and restoring the original object after the fd is unmounted.) Not that I think Linux really needs this creeping featurism ... /Mikael - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [ot] named sockets
On Mon, 7 May 2001 21:47:33 -0400 (EDT), Adam [EMAIL PROTECTED] wrote: So I'm wondering, is there a way, kind of like relink system call which coule take existing file descriptor (they are still so the fd is there, just unlinked) and link it back to file name? POSIX' fattach(int fd, const char *path) library call does that, although it's often limited to STREAMS fd:s. It's usually implemented as mounting namefs at the path (SVR4) or setting a magic mount option (OSF1), with the fd passed in as mount-point specific data. Regular users are allowed to do this special mount(). Linux currently doesn't have this functionality, but it could probably be implemented as a pseudo-fs in 2.4, assuming the 2.4 VFS properly supports stacking of file systems. (There's some gotchas concerning chown/chmod changes and restoring the original object after the fd is unmounted.) Not that I think Linux really needs this creeping featurism ... /Mikael - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[ot] named sockets
I kind of carelessly deleted /tmp/.X11-unix/X0. Now the thing is that some programs which had not opened the socket before, can't connect to X. The simplest solution would be just restart X, but that's too much effort to me. So I'm wondering, is there a way, kind of like "relink" system call which coule take existing file descriptor (they are still so the fd is there, just unlinked) and link it back to file name? doing mksock X0 [*], does not do the trick as the fd is different. [*] /* mksock - make a Unix domain socket */ #include #include #include int main(int argc, char **argv) { int sd; struct sockaddr_un sin; if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) exit(1); strcpy(sin.sun_path, argv[1]); sin.sun_family = AF_UNIX; if ((bind(sd, , sizeof(sin)) == -1)) exit(1); exit(0); } -- Adam http://www.eax.com The Supreme Headquarters of the 32 bit registers - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[ot] named sockets
I kind of carelessly deleted /tmp/.X11-unix/X0. Now the thing is that some programs which had not opened the socket before, can't connect to X. The simplest solution would be just restart X, but that's too much effort to me. So I'm wondering, is there a way, kind of like relink system call which coule take existing file descriptor (they are still so the fd is there, just unlinked) and link it back to file name? doing mksock X0 [*], does not do the trick as the fd is different. [*] /* mksock - make a Unix domain socket */ #include sys/types.h #include sys/socket.h #include sys/un.h int main(int argc, char **argv) { int sd; struct sockaddr_un sin; if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) exit(1); strcpy(sin.sun_path, argv[1]); sin.sun_family = AF_UNIX; if ((bind(sd, sin, sizeof(sin)) == -1)) exit(1); exit(0); } -- Adam http://www.eax.com The Supreme Headquarters of the 32 bit registers - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/