2011-03-30 05:46:40 -07:00
|
|
|
#include <u.h>
|
|
|
|
#include <libc.h>
|
|
|
|
#include <draw.h>
|
|
|
|
|
|
|
|
/* Connect us to new window, if possible */
|
|
|
|
int
|
|
|
|
newwindow(char *str)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
char *wsys;
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
wsys = getenv("wsys");
|
|
|
|
if(wsys == nil)
|
|
|
|
return -1;
|
|
|
|
fd = open(wsys, ORDWR);
|
2013-10-04 06:57:05 -07:00
|
|
|
if(fd < 0){
|
|
|
|
free(wsys);
|
2011-03-30 05:46:40 -07:00
|
|
|
return -1;
|
2013-10-04 06:57:05 -07:00
|
|
|
}
|
2011-03-30 05:46:40 -07:00
|
|
|
rfork(RFNAMEG);
|
2013-10-04 06:57:05 -07:00
|
|
|
unmount(wsys, "/dev"); /* drop reference to old window */
|
|
|
|
free(wsys);
|
2011-03-30 05:46:40 -07:00
|
|
|
if(str)
|
|
|
|
snprint(buf, sizeof buf, "new %s", str);
|
|
|
|
else
|
|
|
|
strcpy(buf, "new");
|
2020-05-02 08:05:17 -07:00
|
|
|
if(mount(fd, -1, "/mnt/wsys", MREPL, buf) == -1){
|
|
|
|
if(mount(fd, -1, "/dev", MBEFORE, buf) == -1){
|
|
|
|
close(fd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(bind("/mnt/wsys", "/dev", MBEFORE) == -1)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2011-03-30 05:46:40 -07:00
|
|
|
}
|
2015-08-25 02:35:10 -07:00
|
|
|
|