View Issue Details

IDProjectCategoryView StatusLast Update
00009431003.1(2013)/Issue7+TC1System Interfacespublic2019-06-10 08:54
ReporterEdSchouten Assigned Toajosey  
PrioritynormalSeverityCommentTypeOmission
Status ClosedResolutionAccepted As Marked 
NameEd Schouten
OrganizationNuxi
User Reference
Sectionopen() and openat()
Page Number1395
Line Number46152
Interp StatusApproved
Final Accepted TextSee 0000943:0002710.
Summary0000943: open() and openat() fail to describe what happens when opening a socket
DescriptionWhen I take a look at various operating systems, I observe the following:

NetBSD:

$ ls -l /var/run/log
srw-rw-rw- 1 root wheel 0 May 1 10:01 /var/run/log
$ cat /var/run/log
cat: /var/run/log: Operation not supported

FreeBSD:

$ ls -l /var/run/log
srw-rw-rw- 1 root wheel 0 Mar 15 15:32 /var/run/log=
$ cat /var/run/log
cat: /var/run/log: Protocol wrong type for socket

Linux:

$ ls -l /var/run/acpid.socket
srw-rw-rw- 1 root root 0 mei 1 09:58 /var/run/acpid.socket=
$ cat /var/run/acpid.socket
cat: /var/run/acpid.socket: No such device or address

Three different systems, three different error codes. If I look at the description of open() and openat(), it seems that there's also no error code reserved for this situation.
Desired ActionPick a relevant error code and have it documented, so that operating systems can come up with a uniform way of dealing with this condition.
Tagstc2-2008

Activities

geoffclare

2015-05-01 08:38

manager   bugnote:0002645

It could be argued that the standard already requires EOPNOTSUPP for this, as XSH 2.3 describes this error as "Operation not supported on socket" and says in the introductory paragraphs "Implementations shall not generate a different error number from one required by this volume of POSIX.1-2008 for an error condition described in this volume of POSIX.1-2008".

In this case, it would be just an editorial oversight that EOPNOTSUPP is not listed for open().

Solaris and HP-UX both give EOPNOTSUPP (which I assume is what the reported NetBSD error text corresponds to).

jilles

2015-05-01 15:36

reporter   bugnote:0002646

FreeBSD's [EPROTOTYPE] error is caused by an extension in cat, where catting a socket causes cat to connect to it (as a stream socket) and receives from it until the connection is closed. Trying to open a socket using open() fails with [EOPNOTSUPP] as in NetBSD.

joerg

2015-05-06 14:13

reporter   bugnote:0002653

How do you get EOPNOTSUPP? It is in the man page...

If you create a socket with mknod(), Solaris allows to open
this socket and returns EIO for a read() attempt.

EOPNOTSUPP seems to be the open() error for (still) actice sockets
that have been created in the filesystem namespace using a socket()
call.

geoffclare

2015-05-06 15:27

manager   bugnote:0002655

If there is a way to create a socket in the file system for which open() succeeds, then we should add EOPNOTSUPP as a "may fail" error instead of "shall fail".

However, I tried creating a socket using mknod() on Solaris 11.1 and got EOPNOTSUPP when trying to open it:

# truss ./a.out 2>&1 | grep mknod
mknod("/tmp/mysock2", 0140600, 0x00000000) = 0
# ls -l /tmp/mysock2
srw------- 1 root root 0 May 6 16:22 /tmp/mysock2
# truss cat /tmp/mysock2 2>&1 | grep mysock
open64("/tmp/mysock2", O_RDONLY) Err#122 EOPNOTSUPP

joerg

2015-05-06 15:34

reporter   bugnote:0002656

Last edited: 2015-05-06 15:36

Then the result seems to depend on the filesystem type.

The open() call fails for "tmpfs" and "ufs" (did not yet test ZFS),
but it succeeds on "lofs" as my first test has been made on /home/uname/*

My previous assumption about the status (active or not) seems to be wrong.

Don Cragun

2015-06-11 16:39

manager   bugnote:0002710

Interpretation response
------------------------
The standard clearly states that errno must be set to EOPNOTSUPP if an attempt is made to perform an operation on a socket that is not supported, and conforming implementations must conform to this.

Rationale:
-------------
The standard requires EOPNOTSUPP if open() fails to open a socket, as XSH 2.3 describes this error as "Operation not supported on socket" and says in the introductory paragraphs "Implementations shall not generate a different error number from one required by this volume of POSIX.1-2008 for an error condition described in this volume of POSIX.1-2008".

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
On page 1395 line 46152 insert before [ETXTBSY]:

    [EOPNOTSUPP] The path argument names a socket.

ajosey

2015-06-19 07:07

manager   bugnote:0002724

Interpretation Proposed: June 19 2015

ajosey

2015-09-07 11:33

manager   bugnote:0002820

Interpretation approved: 7 Sep 2015

Issue History

Date Modified Username Field Change
2015-05-01 08:14 EdSchouten New Issue
2015-05-01 08:14 EdSchouten Status New => Under Review
2015-05-01 08:14 EdSchouten Assigned To => ajosey
2015-05-01 08:14 EdSchouten Name => Ed Schouten
2015-05-01 08:14 EdSchouten Organization => Nuxi
2015-05-01 08:14 EdSchouten Section => open() and openat()
2015-05-01 08:14 EdSchouten Page Number => unknown
2015-05-01 08:14 EdSchouten Line Number => unknown
2015-05-01 08:38 geoffclare Note Added: 0002645
2015-05-01 15:36 jilles Note Added: 0002646
2015-05-06 14:13 joerg Note Added: 0002653
2015-05-06 15:27 geoffclare Note Added: 0002655
2015-05-06 15:34 joerg Note Added: 0002656
2015-05-06 15:36 joerg Note Edited: 0002656
2015-05-06 15:36 joerg Note Edited: 0002656
2015-06-11 16:34 geoffclare Project 1003.1(2008)/Issue 7 => 1003.1(2013)/Issue7+TC1
2015-06-11 16:39 Don Cragun Note Added: 0002710
2015-06-11 16:42 Don Cragun Page Number unknown => 1395
2015-06-11 16:42 Don Cragun Line Number unknown => 46152
2015-06-11 16:42 Don Cragun Interp Status => Pending
2015-06-11 16:42 Don Cragun Final Accepted Text => See 0000943:0002710.
2015-06-11 16:42 Don Cragun Status Under Review => Interpretation Required
2015-06-11 16:42 Don Cragun Resolution Open => Accepted As Marked
2015-06-11 16:42 Don Cragun Tag Attached: tc2-2008
2015-06-19 07:07 ajosey Interp Status Pending => Proposed
2015-06-19 07:07 ajosey Note Added: 0002724
2015-09-07 11:33 ajosey Interp Status Proposed => Approved
2015-09-07 11:33 ajosey Note Added: 0002820
2019-06-10 08:54 agadmin Status Interpretation Required => Closed