Samuel, et al. David Miller wrote:I finally got round to testing on FreeBSD. Linux and BSD are unfortunately not compatible. For the unnamed sockets, FreeBSD says the socket address length is 16 bytes (whereas Linux says it's 2 bytes). On the other hand, there doesn't seem to be much consistency across implementations: HP-UX's get{peer,sock}name() says that unnamed sockets have a zero-length address. Anyway, the situation we have is three address formats in the Unix domain on Linux: Named sockets (socket was given an string name with bind()) length >= 4 (i.e., sizeof(unsigned short) + at least one character for a pathname + 1 for the NUL sun_path is a null-terminated string Abstract sockets (socket was bound to a sun_path whose initial byte is 0) Length == sizeof(struct sockaddr_un) (i.e., 110) sun_path is an initial null byte, followed by 107 other bytes that make the name unique Unnamed sockets (created by socketpair(), or when we connect() a socket that was not bound to a name; the current unix.7 page suggests that when we connect() a socket that was not bound, then it gets a name in the abstract name space -- that's not true) Length = 2 sun_path is 108 null bytes . I have drafted a revision to section of the unix.7 page describing the address format to try and cover all of the above. Samuel (and David?) could you review please? Cheers, Michael Address Format A Unix domain socket address is represented in the following structure: #define UNIX_PATH_MAX 108 struct sockaddr_un { sa_family_t sun_family; /* AF_UNIX */ char sun_path[UNIX_PATH_MAX]; /* pathname */ }; sun_family always contains AF_UNIX. Three types of address are distinguished in this structure: * pathname: a Unix domain socket can be bound to a null-ter- minated file system pathname using bind(2). When the address of the socket is returned by getsockname(2), get- peername(2), and accept(2), its length is sizeof(sa_fam- ily_t) + strlen(sun_path) + 1, and sun_path contains the null-terminated pathname. * anonymous: A stream socket that is connect(2)ed to another socket without first being bound to an address is anony- mous. Likewise, the two sockets created by socketpair(2) are anonymous. When the address of an anonymous socket is returned by getsockname(2), getpeername(2), and accept(2), its length is sizeof(sa_family_t), and sun_path should not be inspected. * abstract: an abstract socket address is distinguished by the fact that sun_path[0] is a null byte (`\0'). All of the remaining bytes in sun_path define the "name" of the socket. (Null bytes in the name have no special signifi- cance.) The name has no connection with file system path- names. The socket's address in this namespace is given by the rest of the bytes in sun_path. When the address of an abstract socket is returned by getsockname(2), getpeer- name(2), and accept(2), its length is sizeof(struct sock- addr_un), and sun_path contains the abstract name. The abstract socket namespace is a non-portable Linux exten- sion. == END == --
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Linus Torvalds | Linux 2.6.27 |
| Eric Paris | [RFC 0/5] [TALPA] Intro to a linux interface for on access scanning |
git: | |
| Denis Bueno | Recovering from repository corruption |
| Linus Torvalds | I'm a total push-over.. |
| J. Bruce Fields | "failed to read delta base object at..." |
| Robin Rosenberg | Re: [wishlist] graphical diff |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Richard Stallman | Real men don't attack straw men |
| Marcos Laufer | dmesg IBM x3650 OpenBSD 4.3 |
| Paolo Supino | order |
| Simon Horman | Possible regression in HTB |
| Corey Hickey | SFQ: backport some features from ESFQ (try 4) |
| KOSAKI Motohiro | [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
| Ingo Molnar | Re: [crash] kernel BUG at net/core/dev.c:1328! |
| usb mic not detected | 20 minutes ago | Applications and Utilities |
| Problem in Inserting a module | 1 hour ago | Linux kernel |
| Treason Uncloaked | 6 hours ago | Linux kernel |
| Shared swap partition | 17 hours ago | Linux general |
| high memory | 2 days ago | Linux kernel |
| semaphore access speed | 2 days ago | Applications and Utilities |
| the kernel how to power off the machine | 2 days ago | Linux kernel |
| Easter Eggs in windows XP | 2 days ago | Windows |
| Root password | 2 days ago | Linux general |
| Where/when DNOTIFY is used? | 2 days ago | Linux kernel |
