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 yesterday
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 yesterday
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 2 days ago
Peter Mortensen
88758
88758
asked Jan 6 at 2:07
TimTim
26.3k74246455
26.3k74246455
marked as duplicate by Sergiy Kolodyazhnyy, RalfFriedl, Isaac, Stephen Harris, Mr Shunz yesterday
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 yesterday
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 referencedlsof
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
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
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 referencedlsof
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
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
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 referencedlsof
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
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
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
8,49312254
8,49312254
1
@Tim I'd say yes. If you look at this they've referencedlsof
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
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
add a comment |
1
@Tim I'd say yes. If you look at this they've referencedlsof
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
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
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
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 2 days ago
sourcejedisourcejedi
23.1k437102
23.1k437102
add a comment |
add a comment |