uid_t uid;
const char *name;
usec_t timestamp;
- int vtnr;
+ unsigned int vtnr;
const char *seat;
const char *tty;
const char *display;
return strv_contains(m->kill_only_users, user);
}
-static int vt_is_busy(int vtnr) {
+static int vt_is_busy(unsigned int vtnr) {
struct vt_stat vt_stat;
int r = 0, fd;
return r;
}
-int manager_spawn_autovt(Manager *m, int vtnr) {
+int manager_spawn_autovt(Manager *m, unsigned int vtnr) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *name = NULL;
int r;
assert(m);
assert(vtnr >= 1);
- if ((unsigned) vtnr > m->n_autovts &&
- (unsigned) vtnr != m->reserve_vt)
+ if (vtnr > m->n_autovts &&
+ vtnr != m->reserve_vt)
return 0;
- if ((unsigned) vtnr != m->reserve_vt) {
+ if (vtnr != m->reserve_vt) {
/* If this is the reserved TTY, we'll start the getty
* on it in any case, but otherwise only if it is not
* busy. */
return -EBUSY;
}
- if (asprintf(&name, "autovt@tty%i.service", vtnr) < 0)
+ if (asprintf(&name, "autovt@tty%u.service", vtnr) < 0)
return log_oom();
r = sd_bus_call_method(
if (v <= 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Cannot determine VT number from virtual console TTY %s", tty);
- if (vtnr <= 0)
+ if (!vtnr)
vtnr = (uint32_t) v;
else if (vtnr != (uint32_t) v)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Specified TTY and VT number do not match");
return 0;
}
-static int vt_allocate(int vtnr) {
+static int vt_allocate(unsigned int vtnr) {
_cleanup_free_ char *p = NULL;
_cleanup_close_ int fd = -1;
assert(vtnr >= 1);
- if (asprintf(&p, "/dev/tty%i", vtnr) < 0)
+ if (asprintf(&p, "/dev/tty%u", vtnr) < 0)
return -ENOMEM;
fd = open_terminal(p, O_RDWR|O_NOCTTY|O_CLOEXEC);
return 0;
}
-int seat_active_vt_changed(Seat *s, int vtnr) {
+int seat_active_vt_changed(Seat *s, unsigned int vtnr) {
Session *i, *new_active = NULL;
int r;
if (!seat_has_vts(s))
return -EINVAL;
- log_debug("VT changed to %i", vtnr);
+ log_debug("VT changed to %u", vtnr);
LIST_FOREACH(sessions_by_seat, i, s->sessions)
if (i->vtnr == vtnr) {
int seat_read_active_vt(Seat *s) {
char t[64];
ssize_t k;
- int r, vtnr;
+ unsigned int vtnr;
+ int r;
assert(s);
return -EIO;
}
- r = safe_atoi(t+3, &vtnr);
+ r = safe_atou(t+3, &vtnr);
if (r < 0) {
log_error("Failed to parse VT number %s", t+3);
return r;
}
- if (vtnr <= 0) {
+ if (!vtnr) {
log_error("VT number invalid: %s", t+3);
return -EIO;
}
int seat_apply_acls(Seat *s, Session *old_active);
int seat_set_active(Seat *s, Session *session);
-int seat_active_vt_changed(Seat *s, int vtnr);
+int seat_active_vt_changed(Seat *s, unsigned int vtnr);
int seat_read_active_vt(Seat *s);
int seat_preallocate_vts(Seat *s);
fprintf(f, "SERVICE=%s\n", s->service);
if (s->seat && seat_has_vts(s->seat))
- fprintf(f, "VTNR=%i\n", s->vtnr);
+ fprintf(f, "VTNR=%u\n", s->vtnr);
if (s->leader > 0)
fprintf(f, "LEADER=%lu\n", (unsigned long) s->leader);
}
if (vtnr && s->seat && seat_has_vts(s->seat)) {
- int v;
+ unsigned int v;
- k = safe_atoi(vtnr, &v);
+ k = safe_atou(vtnr, &v);
if (k >= 0 && v >= 1)
s->vtnr = v;
}
/* on seats with VTs, we let VTs manage session-switching */
if (seat_has_vts(s->seat)) {
- if (s->vtnr <= 0)
+ if (!s->vtnr)
return -ENOTSUP;
return chvt(s->vtnr);
static int session_open_vt(Session *s) {
char path[128];
- if (s->vtnr <= 0)
+ if (!s->vtnr)
return -1;
if (s->vtfd >= 0)
return s->vtfd;
- sprintf(path, "/dev/tty%d", s->vtnr);
+ sprintf(path, "/dev/tty%u", s->vtnr);
s->vtfd = open(path, O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY);
if (s->vtfd < 0) {
log_error("cannot open VT %s of session %s: %m", path, s->id);
return;
error:
- log_error("cannot mute VT %d for session %s (%d/%d)", s->vtnr, s->id, r, errno);
+ log_error("cannot mute VT %u for session %s (%d/%d)", s->vtnr, s->id, r, errno);
session_restore_vt(s);
}
char *scope_job;
Seat *seat;
- int vtnr;
+ unsigned int vtnr;
int vtfd;
sd_event_source *vt_source;
int manager_startup(Manager *m);
int manager_run(Manager *m);
-int manager_spawn_autovt(Manager *m, int vtnr);
+int manager_spawn_autovt(Manager *m, unsigned int vtnr);
void manager_gc(Manager *m, bool drop_not_started);
if (!isempty(cvtnr))
safe_atou32(cvtnr, &vtnr);
- if (!isempty(display) && vtnr <= 0) {
+ if (!isempty(display) && !vtnr) {
if (isempty(seat))
get_seat_from_display(display, &seat, &vtnr);
else if (streq(seat, "seat0"))