#include <unistd.h>
#include <string.h>
#include <errno.h>
-#include <fcntl.h>
#include <termios.h>
#include "chan_user.h"
#include "user.h"
#include "user_util.h"
#include "kern_util.h"
+#include "os.h"
struct pty_chan {
void (*announce)(char *dev_name, int dev);
{
struct pty_chan *data;
- if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL);
+ data = um_kmalloc(sizeof(*data));
+ if(data == NULL) return(NULL);
*data = ((struct pty_chan) { .announce = opts->announce,
.dev = device,
.raw = opts->raw });
char *dev;
int fd;
- if((fd = get_pty()) < 0){
+ fd = get_pty();
+ if(fd < 0){
printk("open_pts : Failed to open pts\n");
return(-errno);
}
int getmaster(char *line)
{
- struct stat stb;
char *pty, *bank, *cp;
- int master;
+ int master, err;
pty = &line[strlen("/dev/ptyp")];
for (bank = "pqrs"; *bank; bank++) {
line[strlen("/dev/pty")] = *bank;
*pty = '0';
- if (stat(line, &stb) < 0)
+ if (os_stat_file(line, NULL) < 0)
break;
for (cp = "0123456789abcdef"; *cp; cp++) {
*pty = *cp;
- master = open(line, O_RDWR);
+ master = os_open_file(line, of_rdwr(OPENFLAGS()), 0);
if (master >= 0) {
char *tp = &line[strlen("/dev/")];
- int ok;
/* verify slave side is usable */
*tp = 't';
- ok = access(line, R_OK|W_OK) == 0;
+ err = os_access(line, OS_ACC_RW_OK);
*tp = 'p';
- if (ok) return(master);
- (void) close(master);
+ if(err == 0) return(master);
+ (void) os_close_file(master);
}
}
}