LCOV - code coverage report
Current view: top level - arch/um/os-Linux - tty.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 23 0.0 %
Date: 2023-08-24 13:40:31 Functions: 0 2 0.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0
       2             : /*
       3             :  * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
       4             :  */
       5             : 
       6             : #include <stdlib.h>
       7             : #include <unistd.h>
       8             : #include <errno.h>
       9             : #include <fcntl.h>
      10             : #include <kern_util.h>
      11             : #include <os.h>
      12             : 
      13             : struct grantpt_info {
      14             :         int fd;
      15             :         int res;
      16             :         int err;
      17             : };
      18             : 
      19           0 : static void grantpt_cb(void *arg)
      20             : {
      21           0 :         struct grantpt_info *info = arg;
      22             : 
      23           0 :         info->res = grantpt(info->fd);
      24           0 :         info->err = errno;
      25           0 : }
      26             : 
      27           0 : int get_pty(void)
      28             : {
      29             :         struct grantpt_info info;
      30             :         int fd, err;
      31             : 
      32           0 :         fd = open("/dev/ptmx", O_RDWR);
      33           0 :         if (fd < 0) {
      34           0 :                 err = -errno;
      35           0 :                 printk(UM_KERN_ERR "get_pty : Couldn't open /dev/ptmx - "
      36             :                        "err = %d\n", errno);
      37           0 :                 return err;
      38             :         }
      39             : 
      40           0 :         info.fd = fd;
      41           0 :         initial_thread_cb(grantpt_cb, &info);
      42             : 
      43           0 :         if (info.res < 0) {
      44           0 :                 err = -info.err;
      45           0 :                 printk(UM_KERN_ERR "get_pty : Couldn't grant pty - "
      46             :                        "errno = %d\n", -info.err);
      47           0 :                 goto out;
      48             :         }
      49             : 
      50           0 :         if (unlockpt(fd) < 0) {
      51           0 :                 err = -errno;
      52           0 :                 printk(UM_KERN_ERR "get_pty : Couldn't unlock pty - "
      53             :                        "errno = %d\n", errno);
      54           0 :                 goto out;
      55             :         }
      56             :         return fd;
      57             : out:
      58           0 :         close(fd);
      59           0 :         return err;
      60             : }

Generated by: LCOV version 1.14