2015-12-22 12:55:44 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the UCB release of Plan 9. It is subject to the license
|
|
|
|
* terms in the LICENSE file found in the top-level directory of this
|
|
|
|
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
|
|
|
|
* part of the UCB release of Plan 9, including this file, may be copied,
|
|
|
|
* modified, propagated, or distributed except according to the terms contained
|
|
|
|
* in the LICENSE file.
|
|
|
|
*/
|
2018-01-06 01:08:25 +01:00
|
|
|
/* Portions of this file are Copyright (C) 2015-2018 Giacomo Tesio <giacomo@tesio.it>
|
|
|
|
* See /doc/license/gpl-2.0.txt for details about the licensing.
|
|
|
|
*/
|
2015-12-22 12:55:44 +01:00
|
|
|
|
|
|
|
#include <u.h>
|
2017-04-19 23:33:14 +02:00
|
|
|
#include <lib9.h>
|
2017-10-20 00:55:05 +02:00
|
|
|
#include <envvars.h>
|
2016-11-25 17:18:40 +01:00
|
|
|
#include <draw.h>
|
2015-12-22 12:55:44 +01:00
|
|
|
|
2016-11-25 17:18:40 +01:00
|
|
|
/* Connect us to new window, if possible */
|
2015-12-22 12:55:44 +01:00
|
|
|
int
|
2016-11-25 17:18:40 +01:00
|
|
|
newwindow(char *str)
|
2015-12-22 12:55:44 +01:00
|
|
|
{
|
2016-11-25 17:18:40 +01:00
|
|
|
int fd;
|
|
|
|
char *wsys;
|
|
|
|
char buf[256];
|
2015-12-22 12:55:44 +01:00
|
|
|
|
2017-10-20 00:55:05 +02:00
|
|
|
wsys = getenv(ENV_WSYS);
|
2016-11-25 17:18:40 +01:00
|
|
|
if(wsys == nil)
|
2015-12-22 12:55:44 +01:00
|
|
|
return -1;
|
2016-11-25 17:18:40 +01:00
|
|
|
fd = open(wsys, ORDWR);
|
|
|
|
free(wsys);
|
|
|
|
if(fd < 0)
|
2015-12-22 12:55:44 +01:00
|
|
|
return -1;
|
2016-11-25 17:18:40 +01:00
|
|
|
rfork(RFNAMEG);
|
|
|
|
if(str)
|
|
|
|
snprint(buf, sizeof buf, "new %s", str);
|
|
|
|
else
|
|
|
|
strcpy(buf, "new");
|
2016-12-01 00:09:42 +01:00
|
|
|
return mount(fd, -1, "/dev", MBEFORE, buf, '9');
|
2015-12-22 12:55:44 +01:00
|
|
|
}
|
|
|
|
|