help me to understand "rfcomm" symbol "->"
-
I do not get the symbol "->" . I am trying to have serial port "ttyUSB0 " linked with rfcomm0. Which command is correct ?
nov25-1@nov251-desktop:~$ sudo ln -s -v /dev/ttyUSB0 /dev/rfcomm0
[sudo] password for nov25-1:
'/dev/rfcomm0' -> '/dev/ttyUSB0'
nov25-1@nov251-desktop:~$ sudo ln -s -v /dev/rfcomm0 /dev/ttyUSB0
'/dev/ttyUSB0' -> '/dev/rfcomm0'
nov25-1@nov251-desktop:~$ -
I do not get the symbol "->" . I am trying to have serial port "ttyUSB0 " linked with rfcomm0. Which command is correct ?
nov25-1@nov251-desktop:~$ sudo ln -s -v /dev/ttyUSB0 /dev/rfcomm0
[sudo] password for nov25-1:
'/dev/rfcomm0' -> '/dev/ttyUSB0'
nov25-1@nov251-desktop:~$ sudo ln -s -v /dev/rfcomm0 /dev/ttyUSB0
'/dev/ttyUSB0' -> '/dev/rfcomm0'
nov25-1@nov251-desktop:~$ -
It shows that the device name on the left is a link to the actual device named on the right. So when you send any data to
/dev/rfcomm0
it will actually go to the device at/dev/ttyUSB0
.Thanks, would it make more sense , more generic, to say "data sent to device on the LEFT will get passed to device on the RIGHT" of the "->" (symbol ) ? Now for the follow-up question - more (confusing_) Linux terminology. physical, hard , symbolic ?? hence " which way's up " ? what would be the purpose of "symbolic" link ? if there is no -s option , is the link "hard" ? is "hard" == "physical" ?
-P, --physical make hard links directly to symbolic links -s, --symbolic make symbolic links instead of hard links
Cheers
-
Thanks, would it make more sense , more generic, to say "data sent to device on the LEFT will get passed to device on the RIGHT" of the "->" (symbol ) ? Now for the follow-up question - more (confusing_) Linux terminology. physical, hard , symbolic ?? hence " which way's up " ? what would be the purpose of "symbolic" link ? if there is no -s option , is the link "hard" ? is "hard" == "physical" ?
-P, --physical make hard links directly to symbolic links -s, --symbolic make symbolic links instead of hard links
Cheers
jana_hus wrote:
would it make more sense , more generic, to say "data sent to device on the LEFT will get passed to device on the RIGHT" of the "->" (symbol ) ?
Not really as the name on the left is just a node in the /dev directory tree, not an actual device. The link just associates one name with another. I have not looked at this for some time, but I think they are hard links. They are actually set up by the kernel when the system is initialised at boot time, based on the connected devices.
-
Thanks, would it make more sense , more generic, to say "data sent to device on the LEFT will get passed to device on the RIGHT" of the "->" (symbol ) ? Now for the follow-up question - more (confusing_) Linux terminology. physical, hard , symbolic ?? hence " which way's up " ? what would be the purpose of "symbolic" link ? if there is no -s option , is the link "hard" ? is "hard" == "physical" ?
-P, --physical make hard links directly to symbolic links -s, --symbolic make symbolic links instead of hard links
Cheers
Way back, the UNIX filesystem only supported a physical link. So a directory entry might have been
struct dirent {
unsigned long d_ino;
char d_name[30];
};So if your directory contained
8539501 foo
8539502 bar
8539503 baz
8539502 pawThen it should be clear that the files
bar, inode=8539502
andpaw inode=8539502
are the same file, i.e a Physical (or hard) link. If you list the directory you'll see something like[k5054@azure foo]$ ls -li
total 0
8539502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 bar
8539503 -rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 baz
8539501-rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 foo
8530502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 pawThe
-i
flag to ls add the inode, and so we can see bar and paw have the same inode (8359502). Also, column 3 shows the number of physical links to the inode, which for bar and paw are 2, but foo and baz are only one. Note that a hard link doesn't need to reside in the same directory, you can for example do something likeln foo/bar/baz ping/pong/paw
, which will create the physical link. There are 2 restrictions to hard links: 1) you can't create a hard link between directories, and 2) you can't create hard links across file systems. Symbolic (soft) links solve both these problems. In the case of a soft link, the link can be thought of as a reference. If we take the above directory and create a soft link between foo and bang via
ln -s foo bang we now get: k5054@azure foo]$ ls -li total 4 8539536 lrwxrwxrwx 1 k5054 k5064 3 Oct 13 06:48 bang -> foo 8539502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 bar 8539503 -rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 baz 8539501 -rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 foo 8539502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 paw This shows that the file `bang` is a symbolic link (file type "l") which points to "foo". Now "bang" acts as a pointer or an indirection. In order to get to the contents of , the OS has to open bang, read its contents and then open the file pointed to by the contents. Also, note that the size of bang is 3, ie "foo". Since we now have this indirection, we can link to files in other filesystems, and we can also create links to other directories. You're also not limited to only one indirection. A soft link can point to another soft link, to another soft link, etc. "A little song, a little dance, a little seltzer down your pants" Chuckles t
-
Way back, the UNIX filesystem only supported a physical link. So a directory entry might have been
struct dirent {
unsigned long d_ino;
char d_name[30];
};So if your directory contained
8539501 foo
8539502 bar
8539503 baz
8539502 pawThen it should be clear that the files
bar, inode=8539502
andpaw inode=8539502
are the same file, i.e a Physical (or hard) link. If you list the directory you'll see something like[k5054@azure foo]$ ls -li
total 0
8539502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 bar
8539503 -rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 baz
8539501-rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 foo
8530502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 pawThe
-i
flag to ls add the inode, and so we can see bar and paw have the same inode (8359502). Also, column 3 shows the number of physical links to the inode, which for bar and paw are 2, but foo and baz are only one. Note that a hard link doesn't need to reside in the same directory, you can for example do something likeln foo/bar/baz ping/pong/paw
, which will create the physical link. There are 2 restrictions to hard links: 1) you can't create a hard link between directories, and 2) you can't create hard links across file systems. Symbolic (soft) links solve both these problems. In the case of a soft link, the link can be thought of as a reference. If we take the above directory and create a soft link between foo and bang via
ln -s foo bang we now get: k5054@azure foo]$ ls -li total 4 8539536 lrwxrwxrwx 1 k5054 k5064 3 Oct 13 06:48 bang -> foo 8539502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 bar 8539503 -rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 baz 8539501 -rw-r--r-- 1 k5054 k5064 0 Oct 13 06:31 foo 8539502 -rw-r--r-- 2 k5054 k5064 0 Oct 13 06:31 paw This shows that the file `bang` is a symbolic link (file type "l") which points to "foo". Now "bang" acts as a pointer or an indirection. In order to get to the contents of , the OS has to open bang, read its contents and then open the file pointed to by the contents. Also, note that the size of bang is 3, ie "foo". Since we now have this indirection, we can link to files in other filesystems, and we can also create links to other directories. You're also not limited to only one indirection. A soft link can point to another soft link, to another soft link, etc. "A little song, a little dance, a little seltzer down your pants" Chuckles t
Thanks, it is getting more "convoluted"... Allow me to start over. The task is to "send (serial) data to /dev/ttyUSB0 and pass the same data to /dev/rfcomm0 ". Calling "/dev/ttyUSB0 " a node or device SHOULD be "technicality" - the task is still the same. However, the "link" option - "symbolic" or "hard /[physical " SHOULD make a difference as far as the task goes. My , probably incorrect, interpretation is: "symbolic" still accomplishes the task, but introduces another "intermediate process" - "pointer" etc. "hard / physical " accomplishes the task directly I do appreciate this discussion, very much, thank you.
-
Thanks, it is getting more "convoluted"... Allow me to start over. The task is to "send (serial) data to /dev/ttyUSB0 and pass the same data to /dev/rfcomm0 ". Calling "/dev/ttyUSB0 " a node or device SHOULD be "technicality" - the task is still the same. However, the "link" option - "symbolic" or "hard /[physical " SHOULD make a difference as far as the task goes. My , probably incorrect, interpretation is: "symbolic" still accomplishes the task, but introduces another "intermediate process" - "pointer" etc. "hard / physical " accomplishes the task directly I do appreciate this discussion, very much, thank you.
jana_hus wrote:
The task is to "send (serial) data to /dev/ttyUSB0 and pass the same data to /dev/rfcomm0 ".
In that case, the whole preceding discussion about links has been just a waste of time. You can't do that task with links. A link means a single object (file, device, directory, etc) can be accessed using multiple different names. If you create a link from /dev/ttyUSB0 to /dev/rfcomm0, then anything written to either ttyUSB0 or rfcomm0 will end up in rfcomm0. If there was a physical device associated with the name /dev/ttyUSB0 before creating the link, it will be bypassed by the new link.
-
jana_hus wrote:
The task is to "send (serial) data to /dev/ttyUSB0 and pass the same data to /dev/rfcomm0 ".
In that case, the whole preceding discussion about links has been just a waste of time. You can't do that task with links. A link means a single object (file, device, directory, etc) can be accessed using multiple different names. If you create a link from /dev/ttyUSB0 to /dev/rfcomm0, then anything written to either ttyUSB0 or rfcomm0 will end up in rfcomm0. If there was a physical device associated with the name /dev/ttyUSB0 before creating the link, it will be bypassed by the new link.