From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683264088; x=1685856088; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=JcpQpxrgzuXrJJjrq18GW9MFSL0KsvcT7Tt9sPRokTg=; b=AgbzcyGj7vUVe809RTAOi7o0n5Y4hZ1wYxhI0LxKtZfCWbYizUFUxoQL2FMT7D0ODC EnlmYxWNVHEASsTkXzfqsCtbIGrMvk61aEvTuxHW0FYvjtOveqhPBJOGVzIy57UGpFsu KFuB7RWZEwZQVaBQIUZm6MxmhCpqZ7CY8iVJyGfmEohqKqdFJZCG2Cmy8j0ABHAZw1Xv BCO0tGOvZy+GgkHusgiVIwMaWwI1lOK5dqtxBZ/f9Nk1wNO7/1peJRfLqngl4wWlZixw FiXL6hsp6zIREYgQ5PJseIwQgmzvVyeJ20bVo4/yxcKBd1NKmH/1avDaPNsK55lwKjFz JlCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683264088; x=1685856088; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JcpQpxrgzuXrJJjrq18GW9MFSL0KsvcT7Tt9sPRokTg=; b=cCsoOMNZYf0cMpmxYPJ37eHfMnfVkpe19NJS0dVbIET1trX+T55eVKR5KAe7iLttDg 6K/fGmaELeMlHxiSgxipVi1B+XdaB6vfVloeX8VbSsQ/XvHZv+hz3hyrRX2PiATJ+RIi QTIuKG0JxShWbQSlaJgXu4a2qJR+btgrqdvonOfN5rGDZehuS+6RaQWDtI0YpcWEpv3m kS3VlsQS+0Du0I3iQKDRhyDVfcn4+k8WvY7h0daxdLtrAdgSwaPEoSi9EOz2MoaHCKof Vttu30/aAb0a9lczFrhXmXC+xtCuEVORlblspBHUylJNXQrfGdq2OzjJS9O41IqxCGDU a+pQ== X-Gm-Message-State: AC+VfDzG4dya6/gWRj2mS55V1VneAtDV77XYiew8TM5aSBdETI6oAuNM F2sqIzAADfRAw5b2K8KmkPShZloRWpM= X-Google-Smtp-Source: ACHHUZ65zMf2gAul77LW9MTLTclKvwr8yNe12g9zgfmiFyn3bs6VvZtKORAxsnedkFaUsrU2qxWO5Q== X-Received: by 2002:a0d:e701:0:b0:559:d495:7cc7 with SMTP id q1-20020a0de701000000b00559d4957cc7mr540699ywe.5.1683264086708; Thu, 04 May 2023 22:21:26 -0700 (PDT) Message-ID: <6868e911-b66b-431c-1164-f45158396dfa@gmail.com> Date: Fri, 5 May 2023 08:21:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.10.0 To: make-initrd@lists.altlinux.org References: <6b444ed922286eb3df8f5322b1bddf9c55753eb8.1683200226.git.gladkov.alexey@gmail.com> Content-Language: ru, en-US From: Leonid Krivoshein In-Reply-To: <6b444ed922286eb3df8f5322b1bddf9c55753eb8.1683200226.git.gladkov.alexey@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [make-initrd] [PATCH 1/3] Reimplement ueventd X-BeenThere: make-initrd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: make-initrd@lists.altlinux.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 May 2023 05:21:32 -0000 Archived-At: List-Archive: On 5/4/23 16:42, Alexey Gladkov wrote: > [...] > diff --git a/datasrc/ueventd/queue-processor.c b/datasrc/ueventd/queue-processor.c > new file mode 100644 > index 00000000..ab5e03e4 > --- /dev/null > +++ b/datasrc/ueventd/queue-processor.c > @@ -0,0 +1,116 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > + > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "ueventd.h" > + > [...] > +void move_files(char *srcdir, char *dstdir) > +{ > + struct dirent *ent; > + int srcfd, dstfd; > + > + if ((srcfd = open(srcdir, O_RDONLY | O_CLOEXEC)) < 0) > + fatal("open: %s: %m", srcdir); > + > + errno = 0; > + if ((dstfd = open(dstdir, O_RDONLY | O_CLOEXEC)) < 0) { > + if (errno == ENOENT) { open() тоже прерываемый примитив, но его ты оборачивать не стал. Так задумано? > + if (mkdir(dstdir, 0755) < 0) > + fatal("mkdir: %s: %m", dstdir); > + dstfd = open(dstdir, O_RDONLY | O_CLOEXEC); > + } > + if (dstfd < 0) > + fatal("open: %s: %m", dstdir); > + } > + > + DIR *d = fdopendir(srcfd); > + if (!d) > + fatal("fdopendir: %m"); > + > + while ((ent = xreaddir(d, srcdir)) != NULL) { > + if (ent->d_name[0] != '.' && ent->d_type == DT_REG && > + renameat(srcfd, ent->d_name, dstfd, ent->d_name) < 0) > + fatal("rename `%s/%s' -> `%s/%s': %m", srcdir, ent->d_name, dstdir, ent->d_name); > + } > + > + closedir(d); > + close(dstfd); Возможно тут и нет ошибки, но srcfd будет закрыт только при завершении программы, а что насчёт повторного вызова функции с такой же srcdir или такое невозможно? > +} > [...] -- WBR, Leonid Krivoshein.