purpose of "open_a_console()" in get_console.c??

Robert P. J. Day rpjday at mindspring.com
Sun Mar 26 03:43:34 PST 2006


  from libbb/get_concole.c:

static int open_a_console(const char *fnam)
{
    int fd;

    fd = open(fnam, O_RDWR);           /* first, try read/write */

    if (fd < 0 && errno == EACCES)     /* else, try readonly */
        fd = open(fnam, O_RDONLY);

    if (fd < 0 && errno == EACCES)     /* else, try writeonly */
        fd = open(fnam, O_WRONLY);

    return fd;
}



  i don't see anything about that routine that is console-specific --
it just appears to try to open a file three different ways.  is there
perhaps a more general "open_file" BB routine somewhere that could be
used just as well so that this one could be deleted?


rday


More information about the busybox mailing list