mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [ot] named sockets
@ 2001-05-08 16:21 Mikael Pettersson
  0 siblings, 0 replies; 2+ messages in thread
From: Mikael Pettersson @ 2001-05-08 16:21 UTC (permalink / raw)
  To: adam, linux-kernel

On Mon, 7 May 2001 21:47:33 -0400 (EDT), Adam <adam@cfar.umd.edu> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread
* [ot] named sockets
@ 2001-05-08  1:47 Adam
  0 siblings, 0 replies; 2+ messages in thread
From: Adam @ 2001-05-08  1:47 UTC (permalink / raw)
  To: linux-kernel


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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-05-08 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-08 16:21 [ot] named sockets Mikael Pettersson
  -- strict thread matches above, loose matches on Subject: below --
2001-05-08  1:47 Adam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®