Does Linux kernel create a file for an Internet domain socket? [duplicate]
This question already has an answer here:
Is there a file for each socket?
3 answers
The Linux kernel creates a file for a Unix domain socket bound to a pathname.
Does the Linux kernel create a file for an Internet domain socket?
linux socket
marked as duplicate by Sergiy Kolodyazhnyy, RalfFriedl, Isaac, Stephen Harris, Mr Shunz Jan 7 at 11:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Is there a file for each socket?
3 answers
The Linux kernel creates a file for a Unix domain socket bound to a pathname.
Does the Linux kernel create a file for an Internet domain socket?
linux socket
marked as duplicate by Sergiy Kolodyazhnyy, RalfFriedl, Isaac, Stephen Harris, Mr Shunz Jan 7 at 11:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Is there a file for each socket?
3 answers
The Linux kernel creates a file for a Unix domain socket bound to a pathname.
Does the Linux kernel create a file for an Internet domain socket?
linux socket
This question already has an answer here:
Is there a file for each socket?
3 answers
The Linux kernel creates a file for a Unix domain socket bound to a pathname.
Does the Linux kernel create a file for an Internet domain socket?
This question already has an answer here:
Is there a file for each socket?
3 answers
linux socket
linux socket
edited Jan 6 at 18:42
Peter Mortensen
91159
91159
asked Jan 6 at 2:07
TimTim
27.9k78269486
27.9k78269486
marked as duplicate by Sergiy Kolodyazhnyy, RalfFriedl, Isaac, Stephen Harris, Mr Shunz Jan 7 at 11:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Sergiy Kolodyazhnyy, RalfFriedl, Isaac, Stephen Harris, Mr Shunz Jan 7 at 11:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
No, not in the sense of a file on hard-drive or other block device.
If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.
This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:
The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.
Thus sockets have inode to have file-like access, but not present on physical filesystem.
However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.
1
@Tim I'd say yes. If you look at this they've referencedlsofoutput: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
– Sergiy Kolodyazhnyy
Jan 6 at 2:44
1
And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
– Sergiy Kolodyazhnyy
Jan 6 at 2:47
Thanks. Is it correct that an open file descriptor is exposed as a file under /proc/<pid>/fd/? If that is true, isn't it that both an internet domain socket and a Unix domain socket are exposed as a file?
– Tim
Feb 15 at 13:38
"Not In the sense of a file on hard-drive or other block device". @Tim have you ever notice this? Of course, there are very extreme corner cases like you use FUSE or write your own kernel module, in case you're extremely nitpicking.
– 炸鱼薯条德里克
Feb 15 at 14:58
add a comment |
The Linux kernel creates a file for a Unix domain socket bound to a pathname.
OK.
Does the Linux kernel create a file for an Internet domain socket?
No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.
bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
No, not in the sense of a file on hard-drive or other block device.
If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.
This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:
The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.
Thus sockets have inode to have file-like access, but not present on physical filesystem.
However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.
1
@Tim I'd say yes. If you look at this they've referencedlsofoutput: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
– Sergiy Kolodyazhnyy
Jan 6 at 2:44
1
And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
– Sergiy Kolodyazhnyy
Jan 6 at 2:47
Thanks. Is it correct that an open file descriptor is exposed as a file under /proc/<pid>/fd/? If that is true, isn't it that both an internet domain socket and a Unix domain socket are exposed as a file?
– Tim
Feb 15 at 13:38
"Not In the sense of a file on hard-drive or other block device". @Tim have you ever notice this? Of course, there are very extreme corner cases like you use FUSE or write your own kernel module, in case you're extremely nitpicking.
– 炸鱼薯条德里克
Feb 15 at 14:58
add a comment |
No, not in the sense of a file on hard-drive or other block device.
If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.
This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:
The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.
Thus sockets have inode to have file-like access, but not present on physical filesystem.
However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.
1
@Tim I'd say yes. If you look at this they've referencedlsofoutput: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
– Sergiy Kolodyazhnyy
Jan 6 at 2:44
1
And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
– Sergiy Kolodyazhnyy
Jan 6 at 2:47
Thanks. Is it correct that an open file descriptor is exposed as a file under /proc/<pid>/fd/? If that is true, isn't it that both an internet domain socket and a Unix domain socket are exposed as a file?
– Tim
Feb 15 at 13:38
"Not In the sense of a file on hard-drive or other block device". @Tim have you ever notice this? Of course, there are very extreme corner cases like you use FUSE or write your own kernel module, in case you're extremely nitpicking.
– 炸鱼薯条德里克
Feb 15 at 14:58
add a comment |
No, not in the sense of a file on hard-drive or other block device.
If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.
This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:
The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.
Thus sockets have inode to have file-like access, but not present on physical filesystem.
However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.
No, not in the sense of a file on hard-drive or other block device.
If you look at socket.c in Linux source code, you will see that it creates an inode for sockets, however data is in sockfs filesystem, which is a virtual filesystem within kernel itself, and space is allocated via kmalloc type of function. In that sense, sockets are anonymous files residing in memory.
This brings back to the concept of "everything is a file in Unix", which is a design pattern that focuses on having common utilities to perform same functions similar to files on real physical media. As Linus Torvalds stated:
The whole point with "everything is a file" is not that you have some random filename (indeed, sockets and pipes show that "file" and "filename" have nothing to do with each other), but the fact that you can use common tools to operate on different things.
Thus sockets have inode to have file-like access, but not present on physical filesystem.
However, note, there exist Unix domain sockets, which are IPC type of object intended for process networking, and do reside on disk filesystems.
answered Jan 6 at 2:30
Sergiy KolodyazhnyySergiy Kolodyazhnyy
10.6k42763
10.6k42763
1
@Tim I'd say yes. If you look at this they've referencedlsofoutput: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
– Sergiy Kolodyazhnyy
Jan 6 at 2:44
1
And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
– Sergiy Kolodyazhnyy
Jan 6 at 2:47
Thanks. Is it correct that an open file descriptor is exposed as a file under /proc/<pid>/fd/? If that is true, isn't it that both an internet domain socket and a Unix domain socket are exposed as a file?
– Tim
Feb 15 at 13:38
"Not In the sense of a file on hard-drive or other block device". @Tim have you ever notice this? Of course, there are very extreme corner cases like you use FUSE or write your own kernel module, in case you're extremely nitpicking.
– 炸鱼薯条德里克
Feb 15 at 14:58
add a comment |
1
@Tim I'd say yes. If you look at this they've referencedlsofoutput: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that
– Sergiy Kolodyazhnyy
Jan 6 at 2:44
1
And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
– Sergiy Kolodyazhnyy
Jan 6 at 2:47
Thanks. Is it correct that an open file descriptor is exposed as a file under /proc/<pid>/fd/? If that is true, isn't it that both an internet domain socket and a Unix domain socket are exposed as a file?
– Tim
Feb 15 at 13:38
"Not In the sense of a file on hard-drive or other block device". @Tim have you ever notice this? Of course, there are very extreme corner cases like you use FUSE or write your own kernel module, in case you're extremely nitpicking.
– 炸鱼薯条德里克
Feb 15 at 14:58
1
1
@Tim I'd say yes. If you look at this they've referenced
lsof output: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that– Sergiy Kolodyazhnyy
Jan 6 at 2:44
@Tim I'd say yes. If you look at this they've referenced
lsof output: "0xffff8803e256d9c0. That number is actually the address of the relevant in-kernel memory structure or type struct unix_sock". So there has to be an inode in kernel's virtual filesystem corresponding to that– Sergiy Kolodyazhnyy
Jan 6 at 2:44
1
1
And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
– Sergiy Kolodyazhnyy
Jan 6 at 2:47
And according to Gilles's answer " Unix socket which is not in the filesystem namespace (it can be in the abstract namespace or unnamed)"
– Sergiy Kolodyazhnyy
Jan 6 at 2:47
Thanks. Is it correct that an open file descriptor is exposed as a file under /proc/<pid>/fd/? If that is true, isn't it that both an internet domain socket and a Unix domain socket are exposed as a file?
– Tim
Feb 15 at 13:38
Thanks. Is it correct that an open file descriptor is exposed as a file under /proc/<pid>/fd/? If that is true, isn't it that both an internet domain socket and a Unix domain socket are exposed as a file?
– Tim
Feb 15 at 13:38
"Not In the sense of a file on hard-drive or other block device". @Tim have you ever notice this? Of course, there are very extreme corner cases like you use FUSE or write your own kernel module, in case you're extremely nitpicking.
– 炸鱼薯条德里克
Feb 15 at 14:58
"Not In the sense of a file on hard-drive or other block device". @Tim have you ever notice this? Of course, there are very extreme corner cases like you use FUSE or write your own kernel module, in case you're extremely nitpicking.
– 炸鱼薯条德里克
Feb 15 at 14:58
add a comment |
The Linux kernel creates a file for a Unix domain socket bound to a pathname.
OK.
Does the Linux kernel create a file for an Internet domain socket?
No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.
bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).
add a comment |
The Linux kernel creates a file for a Unix domain socket bound to a pathname.
OK.
Does the Linux kernel create a file for an Internet domain socket?
No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.
bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).
add a comment |
The Linux kernel creates a file for a Unix domain socket bound to a pathname.
OK.
Does the Linux kernel create a file for an Internet domain socket?
No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.
bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).
The Linux kernel creates a file for a Unix domain socket bound to a pathname.
OK.
Does the Linux kernel create a file for an Internet domain socket?
No. Binding a socket to an IP address+port does not synthesize a pathname. It does not create a file somewhere you can see.
bind() on a AF_INET / AF_INET6 socket does not create any file on any physical filesystem. The bind() call will not generate a file on any of the builtin virtual filesystems. (Of course you can write your own FUSE filesystem, which mimics netstat -46 in some way, so that it creates a new file).
answered Jan 6 at 19:26
sourcejedisourcejedi
25.2k444110
25.2k444110
add a comment |
add a comment |