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

Bogus open() syscalls when looking for openttd.cfg #6421

Closed
DorpsGek opened this issue Feb 11, 2016 · 4 comments
Closed

Bogus open() syscalls when looking for openttd.cfg #6421

DorpsGek opened this issue Feb 11, 2016 · 4 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

Ketsuban opened the ticket and wrote:

I wanted OpenTTD on my PATH, so I symlinked the binary (in $HOME/.local/openttd) to $HOME/.local/bin and then ran it. At one point while debugging what I needed to do to make this work I used strace to track every instance in which OpenTTD used the open system call. These stood out to me.

open("/home/thomas//home/thomas/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/thomas/.openttd//home/thomas/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/games/openttd//home/thomas/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/thomas/.openttd/content_download//home/thomas/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/thomas/.openttd/openttd.cfg", O_RDONLY) = 3

From skimming the codebase I think this might be the result of a call to FioFindFullPath in fileio.cpp, but I could very well be wrong. Either way, I reckon bogus open syscalls are worthy of being filed as a low-severity bug.

Reported version: 1.5.3
Operating system: Linux


This issue was imported from FlySpray: https://bugs.openttd.org/task/6421
@DorpsGek
Copy link
Member Author

Alberth wrote:

Trying to just open a file at a number of places until you find the thing you are looking for is quite normal practice afaik.
What alternative would you suggest to find and read a file at an unknown location at the file system?


This comment was imported from FlySpray: https://bugs.openttd.org/task/6421#comment14124

@DorpsGek
Copy link
Member Author

peter1138 wrote:

We apparently already check for the cfg location earlier:

access("/home/petern/ottd/openttd.cfg", F_OK) = -1 ENOENT (No such file or directory)
access("/home/petern/.local/share/openttd/openttd.cfg", F_OK) = -1 ENOENT (No such file or directory)
access("/home/petern/.openttd/openttd.cfg", F_OK) = 0

Then later to actually open it, uses the chosen path but uses it in the search path:

open("/home/petern/ottd//home/petern/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/petern/.local/share/openttd//home/petern/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/petern/.openttd//home/petern/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/petern/ottd/bin//home/petern/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/games/openttd//home/petern/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/petern/.openttd/content_download//home/petern/.openttd/openttd.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/petern/.openttd/openttd.cfg", O_RDONLY) = 3

I'd say that is wrong in this case as we have already determined the path.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6421#comment14378

@DorpsGek
Copy link
Member Author

peter1138 wrote:

This patch fixes it with hopefully no side effects. Ha! The three paths have already been determined on start up so no searching is necessary.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6421#comment14379

@DorpsGek
Copy link
Member Author

peter1138 closed the ticket.

Reason for closing: Fixed

In r27816


This comment was imported from FlySpray: https://bugs.openttd.org/task/6421

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant