This new helper removes a leading /dev if there is one. We have code
doing this all over the place, let's unify this, and correct it while
we are at it, by using path_startswith() rather than startswith() to
drop the prefix.
#include <unistd.h>
#include "alloc-util.h"
+#include "env-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "io-util.h"
#include "log.h"
#include "macro.h"
-#include "path-util.h"
#include "parse-util.h"
#include "process-util.h"
#include "socket-util.h"
int vt_disallocate(const char *name) {
_cleanup_close_ int fd = -1;
- const char *e, *n;
unsigned u;
int r;
* (i.e. because it is the active one), at least clear it
* entirely (including the scrollback buffer) */
- e = path_startswith(name, "/dev/");
- if (!e)
+ if (!startswith(name, "/dev/"))
return -EINVAL;
if (!tty_is_vc(name)) {
return 0;
}
- n = startswith(e, "tty");
- if (!n)
+ if (!startswith(name, "/dev/tty"))
return -EINVAL;
- r = safe_atou(n, &u);
+ r = safe_atou(name+8, &u);
if (r < 0)
return r;