mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-09 03:02:36 +08:00
POSIX: Fixed px4_open code to not create a file when opening a device
The code to created a virtual file was preventing the creation of device nodes. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -451,9 +451,9 @@ VDev *VDev::getDev(const char *path)
|
||||
printf("VDev::getDev\n");
|
||||
int i=0;
|
||||
for (; i<PX4_MAX_DEV; ++i) {
|
||||
if (devmap[i]) {
|
||||
printf("%s %s\n", devmap[i]->name, path);
|
||||
}
|
||||
//if (devmap[i]) {
|
||||
// printf("%s %s\n", devmap[i]->name, path);
|
||||
//}
|
||||
if (devmap[i] && (strcmp(devmap[i]->name, path) == 0)) {
|
||||
return (VDev *)(devmap[i]->cdev);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,9 @@ int px4_open(const char *path, int flags, ...)
|
||||
int i;
|
||||
mode_t mode;
|
||||
|
||||
if (!dev && (flags & (PX4_F_WRONLY|PX4_F_CREAT)) != 0)
|
||||
if (!dev && (flags & (PX4_F_WRONLY|PX4_F_CREAT)) != 0 &&
|
||||
strncmp(path, "/obj/", 5) != 0 &&
|
||||
strncmp(path, "/dev/", 5) != 0)
|
||||
{
|
||||
va_list p;
|
||||
va_start(p, flags);
|
||||
@@ -187,10 +189,10 @@ ssize_t px4_write(int fd, const void *buffer, size_t buflen)
|
||||
|
||||
int px4_ioctl(int fd, int cmd, unsigned long arg)
|
||||
{
|
||||
PX4_DEBUG("px4_ioctl fd = %d\n", fd);
|
||||
int ret = 0;
|
||||
if (valid_fd(fd)) {
|
||||
VDev *dev = (VDev *)(filemap[fd]->vdev);
|
||||
PX4_DEBUG("px4_ioctl fd = %d\n", fd);
|
||||
ret = dev->ioctl(filemap[fd], cmd, arg);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user