Re: [SSI] openssi/udev Makefile, NONE, 1.1.7.1.4.2 udevd.c, 1.1.15.1, 1.1.15.2 udevd.h, 1.1.15.1, 1.1.15.2
John Hughes <[email protected]> Mon, 12 Jul 2010 11:25:57 +0200
| Newsgroups | gmane.linux.cluster.ssic.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------000808060101020709010906
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Roger Tsang wrote:
> Update of /cvsroot/ssic-linux/openssi/udev
> In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv14066
>
> Modified Files:
> Tag: CENTOS
> udevd.c udevd.h
For the future Debian versions of OpenSSI I have modified libc6 so the
localdomain socket connect/send/receive calls allow per-node diversion
of socket addresses. This means we don't need modifications to programs
like udev.
How it works:
There is a CDSL /cluster/socket that points to /cluster/node{nodenum}/socket
There is a directory /cluster/node{nodenum}/socket which contains a
symlink for each socket that is diverted:
# ls -l /cluster/socket
lrwxrwxrwx 1 root root 29 2010-01-28 16:21 /cluster/socket -> /cluster/node{nodenum}/socket
# ls -lR /cluster/node1/socket
/cluster/node1/socket:
total 8
drwxr-xr-x 3 root root 4096 2008-07-02 17:02 @
/cluster/node1/socket/@:
total 4
drwxr-xr-x 4 root root 4096 2008-07-04 18:56 org
/cluster/node1/socket/@/org:
total 8
drwxr-xr-x 3 root root 4096 2008-07-04 18:56 freedesktop
drwxr-xr-x 3 root root 4096 2008-07-02 17:02 kernel
/cluster/node1/socket/@/org/freedesktop:
total 4
drwxr-xr-x 2 root root 4096 2010-04-13 16:26 hal
/cluster/node1/socket/@/org/freedesktop/hal:
total 0
lrwxrwxrwx 1 root root 34 2010-04-13 16:26 udev_event -> @/org/freedesktop/hal/udev_event/1
/cluster/node1/socket/@/org/kernel:
total 4
drwxr-xr-x 2 root root 4096 2010-04-13 16:26 udev
/cluster/node1/socket/@/org/kernel/udev:
total 0
lrwxrwxrwx 1 root root 27 2010-04-13 16:26 monitor -> @/org/kernel/udev/monitor/1
lrwxrwxrwx 1 root root 25 2010-04-13 16:26 udevd -> @/org/kernel/udev/udevd/1
So when a program connetcts to the socket "@/org/kernel/udev/udevd" on
node1 it is diverted to
"@/org/kernel/udev/udevd/1".
There is a little script ssi-divert-socket to maintain the
/cluster/node{nodenum}/socket directories.
--------------000808060101020709010906
Content-Type: text/plain;
name="ssi-divert-socket"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ssi-divert-socket"
#! /usr/bin/perl
=head1 NAME
ssi-divert-socket - Allow per-node definition of local domain socket
=head1 SYNOPSIS
ssi-divert-socket socket-name
ssi-divert-socket -r socket-name
ssi-divert-socket -n nodenum
ssi-divert-socket
=head1 DESCRIPTION
The ssi-divert-socket command allows a local domain (AF_FILE aka
AF_UNIX) socket to be made per node.
If an application uses a socket, for example udev-socket, but we need the
socket to be node specific, for example to run independant copies of udev on
each node, then ssi-divert-socket arranges that each node will have it's
own copy of the socket.
This avoids the necessity of modifiying many packages (for example udev, hal,
gnome-vfs) for OpenSSI.
=head1 USAGE
To make a socket per-node do:
ssi-divert-socket socket-name
Then when an application accesses socket-name it will be redirected to
socket-name/node-number, i.e. on node 1 socket-name/1, on node 23
socket-name/23.
If the socket is an "abstract" socket put the character "@" at the start
of the socket name, for example:
ssi-divert-socket @/org/kernel/udev
To delete a redirection do
ssi-divert-socket -r socket-name
To initialise socket redirections for a node do
ssi-divert-socket -n nodenum
To list current diversions do:
ssi-divert-socket
=head1 IMPLEMENTATION
The redirections are stored as symbolic links in /cluster/nodeXXX/socket.
The standard C library is modified to check for redirections before a
connect(2), bind(2) or sendto(2)/sendmsg(2) operation.
=cut
use Errno qw (EEXIST ENOENT);
use File::Basename qw (dirname);
# Create initial symlink if it doesn't exist
symlink "/cluster/node{nodenum}/socket", "/cluster/socket";
my $remove;
if ($ARGV[0] eq "-r") {
shift;
++$remove;
}
my $nodenum;
if ($ARGV[0] eq '-n') {
shift;
unless (@ARGV == 1) {
die "Usage: $0 -n nodenum\n";
}
$nodenum = shift;
walk_redirects (
sub {
unlink "/cluster/node$nodenum/socket/$_[0]";
symlink "$_[0]/$nodenum",
"/cluster/node$nodenum/socket/$_[0]";
}
);
exit (0);
}
unless (@ARGV || $remove) {
walk_redirects (sub { print $_[0], "\n"});
exit (0);
}
while (my $SOCKADDR = shift) {
if ($remove) {
remove_redirect ($SOCKADDR);
}
else {
create_redirect ($SOCKADDR);
}
}
exit 0;
sub create_redirect {
my $SOCKADDR = shift;
# Setup the template link so links will be created on node add
my $dir = dirname ($SOCKADDR);
$dir = "" if $dir eq ".";
system "mkdir -p /cluster/nodetemplate/socket/$dir";
unless (symlink $SOCKADDR, "/cluster/nodetemplate/socket/$SOCKADDR") {
die "Can't make $SOCKADDR: $!\n" unless $! == EEXIST;
}
# Now make per-node links
for (glob "/cluster/node*") {
next unless m{^/cluster/node(\d+)$};
my $node = $1;
system "mkdir -p $_/socket/$dir";
unless (symlink "$SOCKADDR/$node", "$_/socket/$SOCKADDR") {
die "Can't make $_/socket/$SOCKADDR: $!\n"
unless $! == EEXIST;
}
}
}
sub remove_redirect {
my $SOCKADDR = shift;
# remove the template link
my $dir = dirname ($SOCKADDR);
$dir = "" if $dir eq ".";
unless (unlink "/cluster/nodetemplate/socket/$SOCKADDR") {
die "Can't remove $SOCKADDR: $!\n" unless $! == ENOENT;
}
system "rmdir -p /cluster/nodetemplate/socket/$dir 2>/dev/null";
# Now remove per-node links
for (glob "/cluster/node*/socket") {
next unless m{^/cluster/node(\d+)/};
my $node = $1;
unless (unlink "$_/$SOCKADDR") {
die "Can't remove $_/$SOCKADDR: $!\n"
unless $! == ENOENT;
}
system "rmdir --ignore-fail-on-non-empty -p $_/$dir";
}
}
sub walk_redirects {
walk_redirect ($_[0], "", "/cluster/nodetemplate/socket");
}
sub walk_redirect {
my ($sub, $prefix, $dir) = @_;
local *DIR;
opendir DIR, $dir
or return;
while (my $f = readdir DIR) {
next if $f =~ /^\./;
my $file = "$dir/$f";
if (-l $file) {
& $sub ("$prefix$f");
}
elsif (-d _) {
walk_redirect ($sub, "$prefix$f/", $file);
}
}
}
--------------000808060101020709010906
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
--------------000808060101020709010906
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ssic-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ssic-linux-devel
--------------000808060101020709010906--