This patch fixed the problem. Thanks to Mike Yuan

On Wed, 2023-11-08 at 16:10 +0000, Luca Boccassi wrote:
> On Wed, 08 Nov 2023 16:50:12 +0100 Michael Ott <mich...@k-c13.org>
> wrote:
> > Package: systemd
> > Version: 255~rc1-3
> > Severity: important
> > 
> > Dear Maintainer,
> > 
> > Since yesterday hibernate and suspend does not longer work.
> journalctl
> > show me this:
> > 
> > systemctl status systemd-suspend.service
> > × systemd-suspend.service - System Suspend
> >       Loaded: loaded (/usr/lib/systemd/system/systemd-
> > suspend.service;
> static)
> >       Active: failed (Result: signal) since Wed 2023-11-08 16:31:01
> CET; 12min ago
> >         Docs: man:systemd-suspend.service(8)
> >      Process: 7133 ExecStart=/usr/lib/systemd/systemd-sleep suspend
> (code=killed, signal=ABRT)
> >     Main PID: 7133 (code=killed, signal=ABRT)
> >          CPU: 44ms
> > 
> > Nov 08 16:31:01 k-c13 systemd[1]: Starting systemd-suspend.service
> > -
> System Suspend...
> > Nov 08 16:31:01 k-c13 systemd-sleep[7133]: Failed to lock home
> directories: Unknown object '/org/freedesktop/home1'.
> > Nov 08 16:31:01 k-c13 systemd-sleep[7133]: Performing sleep
> > operation
> 'suspend'...
> > Nov 08 16:31:01 k-c13 systemd-sleep[7133]: *** invalid open64 call:
> O_CREAT or O_TMPFILE without mode ***: terminated
> > Nov 08 16:31:01 k-c13 systemd[1]: systemd-suspend.service: Main
> process exited, code=killed, status=6/ABRT
> > Nov 08 16:31:01 k-c13 systemd[1]: systemd-suspend.service: Failed
> with result 'signal'.
> > Nov 08 16:31:01 k-c13 systemd[1]: Failed to start systemd-
> suspend.service - System Suspend.
> > 
> > I also got this output:
> > 
> > systemctl list-units --type=mount --all | grep home
> > ●
> home.mount                                                           
>   
>     not-found inactive dead    home.mount
> > 
> > My home directory looks like that:
> > ls -l /home
> > total 0
> > lrwxrwxrwx 1 root root 18 Nov 24  2018 michael ->
> > /srv/home/michael/
> > 
> > What is the problem? Since yesterday it works
> 
> Please open an issue upstream on Github:
> 
> https://github.com/systemd/systemd/issues/new
> 

-- 
CU  
         
  Michael
          
-- 
    ,''`.   
   : :' :   Michael Ott 
   `. `'    e-mail: michael at k-c13 dot org
     `-

Gem. Par. 28 Abs. 4 Bundesdatenschutzgesetz widerspreche ich derNutzung
sowie der Weitergabe meiner personenbezogenen Daten für Zwecke der
Werbung sowie der Markt- oder Meinungsforschung.
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 systemd (255~rc1-3.1) UNRELEASED; urgency=medium
 .
   * Non-maintainer upload.
   * test patch #29939 https://github.com/systemd/systemd/pull/29939
Author: Michael Ott <mich...@k-c13.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2023-11-09

--- systemd-255~rc1.orig/src/basic/fd-util.c
+++ systemd-255~rc1/src/basic/fd-util.c
@@ -761,9 +761,10 @@ finish:
 }
 
 int fd_reopen(int fd, int flags) {
-        int new_fd, r;
+        int r;
 
         assert(fd >= 0 || fd == AT_FDCWD);
+        assert(!FLAGS_SET(flags, O_CREAT));
 
         /* Reopens the specified fd with new flags. This is useful for convert an O_PATH fd into a regular one, or to
          * turn O_RDWR fds into O_RDONLY fds.
@@ -787,19 +788,12 @@ int fd_reopen(int fd, int flags) {
                  * the same way as the non-O_DIRECTORY case. */
                 return -ELOOP;
 
-        if (FLAGS_SET(flags, O_DIRECTORY) || fd == AT_FDCWD) {
+        if (FLAGS_SET(flags, O_DIRECTORY) || fd == AT_FDCWD)
                 /* If we shall reopen the fd as directory we can just go via "." and thus bypass the whole
                  * magic /proc/ directory, and make ourselves independent of that being mounted. */
-                new_fd = openat(fd, ".", flags | O_DIRECTORY);
-                if (new_fd < 0)
-                        return -errno;
-
-                return new_fd;
-        }
-
-        assert(fd >= 0);
+                return RET_NERRNO(openat(fd, ".", flags | O_DIRECTORY));
 
-        new_fd = open(FORMAT_PROC_FD_PATH(fd), flags);
+        int new_fd = open(FORMAT_PROC_FD_PATH(fd), flags);
         if (new_fd < 0) {
                 if (errno != ENOENT)
                         return -errno;
@@ -825,6 +819,7 @@ int fd_reopen_condition(
         int r, new_fd;
 
         assert(fd >= 0);
+        assert(!FLAGS_SET(flags, O_CREAT));
 
         /* Invokes fd_reopen(fd, flags), but only if the existing F_GETFL flags don't match the specified
          * flags (masked by the specified mask). This is useful for converting O_PATH fds into real fds if
--- systemd-255~rc1.orig/src/basic/fileio.c
+++ systemd-255~rc1/src/basic/fileio.c
@@ -1064,7 +1064,9 @@ int fdopen_independent(int fd, const cha
         if (mode_flags < 0)
                 return mode_flags;
 
-        copy_fd = fd_reopen(fd, mode_flags);
+        /* Flags returned by fopen_mode_to_flags might contain O_CREAT, but it doesn't make sense for fd_reopen
+         * since we're working on an existing fd anyway. Let's drop it here to avoid triggering assertion. */
+        copy_fd = fd_reopen(fd, mode_flags & ~O_CREAT);
         if (copy_fd < 0)
                 return copy_fd;
 

Reply via email to