Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use relative paths (as symlinks to devices) #10

Open
ydirson opened this issue Oct 4, 2021 · 3 comments
Open

Cannot use relative paths (as symlinks to devices) #10

ydirson opened this issue Oct 4, 2021 · 3 comments

Comments

@ydirson
Copy link

ydirson commented Oct 4, 2021

I have created symlinks into /dev/serial/by-id/ to help working with several usb/serial adapters. I cannot refer to them using a relative path:

$ strace -efile bt ./ttyA35 
...
openat(AT_FDCWD, "/dev/./ttyA35", O_RDWR|O_NOCTTY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
Trying port ./ttyA35... Failed! (No such file or directory)
Failed to open port: No such file or directory
+++ exited with 2 +++

A workaround is to use bt $PWD/ttyA35 but it's pretty ugly :)

Probably the argument should be considered a usual relative pass when it contains a / ?

Is it really that much of a gain to spare the user from typing /dev/ when he likely has to enter tty anyway ? I'd think a string without a / would make more sense to use as bt USB0, but I guess it can be a matter of taste...

@wtarreau
Copy link
Owner

Hello,

sorry I seem to have missed your report. I agree that considering all '/' entries as absolute would be the best option. I considered it a while ago but abandoned the idea thinking that there was little use for devices outside of /dev. Right now this part is split not because we try to make it relative, but because that's actually how device names appear in /sys and at other places so we need to keep consistent names. Also regarding the use of "USB0" instead of "ttyUSB0", we can't realistically do that because not all devices start with "tty" (e.g. "cua0" or "serial/ttyUSB0").

I'll have a look, thanks for your report.

@wtarreau
Copy link
Owner

Hmm now I remember regarding the string containing a "/", it's precisely for stuff like "serial/ttyUSB0" or "modem/cua0" that are annoying.

We could maybe also consider that "./" and "../" are special prefixes. Just an idea.

@wtarreau
Copy link
Owner

After some thingking, I believe the best solution would be to consider that if the device number/name starts with "/", "./" or "../", then it designates an absolute device to be used, and in this case we ought to totally bypass discovery and try to use it as-is. Right now this is not the case because when you pass a name it can for example wait for that device to appear. And that name may also be a number designating a device in a list; thus all of these cases currently rely on discovery. Or we could have an option to enforce a direct device like -D path/to/dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants