/*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* fbc_open_master - Find and open the matching device
*/
#include <dirent.h> /* closedir(), opendir(), readdir() */
#include <errno.h> /* errno */
#include <fcntl.h>
#include <stdio.h> /* NULL */
#include <string.h> /* strcmp(), strcpy() */
#include <unistd.h> /* close(), ioctl() */
#include "fbc.h" /* Common fbconf_xorg(1M) definitions */
#include "fbc_dev.h" /* Identify the graphics device (-dev opt) */
#include "fbc_open_master.h" /* Find and open the matching device */
/*
* fbc_open_master()
*
* Given a VISUAL environment identifier (e.g. "SUNWkfb") and the
* for a second, matching FB device and open it. Return the file
* number of this second device, else -1.
*
* Note that the caller knows the slave device and wants to find the
* master, but this function doesn't care which device will be which.
*/
int
const char *const ident_name, /* VISUAL identifier name */
int slave_fd) /* Slave device fd */
{
/*
* Get the st_rdev device info
*/
return (-1);
}
/*
*/
/*
*/
return (-1);
}
/*
*/
master_fd = -1;
/*
* Ignore dot files
*/
continue;
}
/*
* Build the pathname unless it would overflow the buffer
*/
continue;
}
/*
* Get the device file status, ignoring it if there's an error
*/
continue;
}
/*
* Ignore this device file if:
* * it's not a character special file
* * it's not the same type of FB as the slave device
* * it's the self-same slave device
*/
continue;
}
/*
* Open the device file, ignoring it if it won't open
*/
if (temp_fd < 0) {
continue;
}
/*
* Ignore this device if:
* * the device identifier name can't be obtained
* * the identifier name doesn't match the slave's ID name
*/
continue;
}
/*
* Give up if more than one potential master is found
*/
if (master_fd >= 0) {
master_fd = -1;
break;
}
/*
* Assume this will be the master device, but look for others
*/
}
/*
* Return the open file descriptor number, else -1
*/
return (master_fd);
} /* fbc_open_master() */
/* End of fbc_open_master.c */