File test.patch of Package systemd

diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 02df893..cc71bc9 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -592,6 +592,7 @@ int terminal_reset_ioctl(int fd, bool switch_to_text) {
         if (ioctl(fd, TIOCNXCL) < 0)
                 log_debug_errno(errno, "TIOCNXCL ioctl failed on TTY, ignoring: %m");
 
+        log_debug("wxg: terminal_reset_ioctl text = %s", switch_to_text ? "true":"false");
         /* Switch to text mode */
         if (switch_to_text)
                 if (ioctl(fd, KDSETMODE, KD_TEXT) < 0)
@@ -1569,6 +1570,30 @@ bool underline_enabled(void) {
         return cached_underline_enabled;
 }
 
+#define PATH_MAX 4096
+static void get_device_path(int fd) {
+    char link_path[PATH_MAX];
+    char device_path[PATH_MAX];
+    ssize_t len;
+
+    // 1. Construct the path to the symbolic link: /proc/self/fd/N
+    if (snprintf(link_path, PATH_MAX, "/proc/self/fd/%d", fd) >= PATH_MAX) {
+        log_debug("wxg: Error: Buffer overflow when constructing link path");
+        return;
+    }
+
+    // 2. Read the target of the symbolic link
+    len = readlink(link_path, device_path, PATH_MAX - 1);
+
+    if (len != -1) {
+        // Null-terminate the string
+        device_path[len] = '\0';
+        log_debug("wxg: File Descriptor %d corresponds to device path: %s\n", fd, device_path);
+    } else {
+        log_debug("wxg: Error reading link for fd");
+    }
+}
+
 int vt_restore(int fd) {
 
         static const struct vt_mode mode = {
@@ -1579,9 +1604,13 @@ int vt_restore(int fd) {
 
         assert(fd >= 0);
 
+        log_debug("wxg: fd = %d", fd);
+        get_device_path(fd);
+        log_debug("wxg to 1");
         if (!isatty_safe(fd))
                 return log_debug_errno(SYNTHETIC_ERRNO(ENOTTY), "Asked to restore the VT for an fd that does not refer to a terminal: %m");
 
+        log_debug("wxg to 2");
         if (ioctl(fd, KDSETMODE, KD_TEXT) < 0)
                 RET_GATHER(ret, log_debug_errno(errno, "Failed to set VT to text mode, ignoring: %m"));
 
@@ -1589,6 +1618,7 @@ int vt_restore(int fd) {
         if (r < 0)
                 RET_GATHER(ret, log_debug_errno(r, "Failed to reset keyboard mode, ignoring: %m"));
 
+        log_debug("wxg to 3");
         if (ioctl(fd, VT_SETMODE, &mode) < 0)
                 RET_GATHER(ret, log_debug_errno(errno, "Failed to set VT_AUTO mode, ignoring: %m"));
 
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 57cc37c..04a1edc 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -1451,6 +1451,7 @@ static int session_prepare_vt(Session *s) {
         if (vt < 0)
                 return vt;
 
+        log_debug("wxg: session_prepare_vt: vt = %d", vt);
         r = fchown(vt, s->user->user_record->uid, -1);
         if (r < 0) {
                 r = log_error_errno(errno,
@@ -1467,6 +1468,7 @@ static int session_prepare_vt(Session *s) {
                 goto error;
         }
 
+        log_debug("wxg: session_prepare_vt: 1");
         r = ioctl(vt, KDSETMODE, KD_GRAPHICS);
         if (r < 0) {
                 r = log_error_errno(errno,
@@ -1481,6 +1483,7 @@ static int session_prepare_vt(Session *s) {
         mode.mode = VT_PROCESS;
         mode.relsig = SIGRTMIN;
         mode.acqsig = SIGRTMIN + 1;
+        log_debug("wxg: session_prepare_vt: 2");
         r = ioctl(vt, VT_SETMODE, &mode);
         if (r < 0) {
                 r = log_error_errno(errno,
openSUSE Build Service is sponsored by