#include "terminal-util.h"
#include "time-util.h"
#include "util.h"
+#include "path-util.h"
static volatile unsigned cached_columns = 0;
static volatile unsigned cached_lines = 0;
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) */
- if (!startswith(name, "/dev/"))
+ e = path_startswith(name, "/dev/");
+ if (!e)
return -EINVAL;
if (!tty_is_vc(name)) {
return 0;
}
- if (!startswith(name, "/dev/tty"))
+ n = startswith(e, "tty");
+ if (!n)
return -EINVAL;
- r = safe_atou(name+8, &u);
+ r = safe_atou(n, &u);
if (r < 0)
return r;
acc[k++] = 0;
- if (startswith(a->path, "/dev/"))
+ if (path_startswith(a->path, "/dev/"))
whitelist_device(path, a->path, acc);
else if ((val = startswith(a->path, "block-")))
whitelist_major(path, val, 'b', acc);
while ((r = sd_bus_message_read(message, "(ss)", &path, &rwm)) > 0) {
- if ((!startswith(path, "/dev/") &&
- !startswith(path, "/run/systemd/inaccessible/") &&
+ if ((!path_startswith(path, "/dev/") &&
+ !path_startswith(path, "/run/systemd/inaccessible/") &&
!startswith(path, "block-") &&
!startswith(path, "char-")) ||
strpbrk(path, WHITESPACE))
#include "bus-util.h"
#include "format-util.h"
#include "logind.h"
+#include "path-util.h"
#include "special.h"
#include "strv.h"
#include "unit-name.h"
}
bool logind_wall_tty_filter(const char *tty, void *userdata) {
-
Manager *m = userdata;
+ const char *p;
assert(m);
- if (!startswith(tty, "/dev/") || !m->scheduled_shutdown_tty)
+ if (!m->scheduled_shutdown_tty)
+ return true;
+
+ p = path_startswith(tty, "/dev/");
+ if (!p)
return true;
- return !streq(tty + 5, m->scheduled_shutdown_tty);
+ return !streq(p, m->scheduled_shutdown_tty);
}
static int warn_wall(Manager *m, usec_t n) {
* sysctl name available. */
sysctl_normalize(optarg);
- if (startswith(optarg, "/proc/sys"))
+ if (path_startswith(optarg, "/proc/sys"))
p = strdup(optarg);
else
p = strappend("/proc/sys/", optarg);
#include <stdio.h>
#include <stdlib.h>
+#include "path-util.h"
#include "string-util.h"
#include "udev.h"
}
/* add /sys if needed */
- if (!startswith(syspath, "/sys"))
+ if (!path_startswith(syspath, "/sys"))
strscpyl(filename, sizeof(filename), "/sys", syspath, NULL);
else
strscpy(filename, sizeof(filename), syspath);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "path-util.h"
#include "string-util.h"
#include "udevadm-util.h"
if (prefix && !startswith(id, prefix))
id = strjoina(prefix, id);
- if (startswith(id, "/dev/")) {
+ if (path_startswith(id, "/dev/")) {
struct stat statbuf;
char type;
return NULL;
return udev_device_new_from_devnum(udev, type, statbuf.st_rdev);
- } else if (startswith(id, "/sys/"))
+ } else if (path_startswith(id, "/sys/"))
return udev_device_new_from_syspath(udev, id);
else
return NULL;