bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

split module openat


From: Bruno Haible
Subject: split module openat
Date: Sat, 5 Nov 2011 10:36:59 +0100
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Hi Jim,

The module 'openat' is still a mix of two different functionalities:
  - It provides the POSIX function openat(),
  - It compiles the openat_proc_name() function on which the implementations
    of fdopendir(), faccessat(), fchmodat(), fchownat(), fstatat(), mkdirat(),
    mkfifoat(), mknodat(), readlinkat(), areadlinkat(), symlinkat(),
    unlinkat(), linkat(), renameat(), utimensat() rely.

So that programs that need one of these functions but not openat() don't
include unnecessary code, it's advisable to split off the helper function
openat_proc_name() from the openat() module.

While doing this, I also noticed that openat.h has a number of dependencies
(stdbool etc. - Paul removed 'dirent' from this list just yesterday), and
it makes the dependency managemant easier if we can put openat.h in a module
of its own.

Here's the proposed patch. It also revisits the dependencies of all *at
modules. Tested through a megatestdir on a dozen of platforms.

It has the side effect that in packages that use 'fdopendir' but not 'openat',
lib/openat-proc.c will now be compiled unconditionally, even on platforms
that don't need it. This is mitigated through --conditional-dependencies,
so IMO is acceptable.


2011-11-05  Bruno Haible  <address@hidden>

        New modules 'at-internal', 'openat-h', split off from module 'openat'.
        * m4/openat.m4 (gl_FUNC_OPENAT): Don't set GNULIB_OPENAT. Don't
        invoke gl_PREREQ_OPENAT and gl_MODULE_INDICATOR.
        * modules/openat (Description): Add reference to POSIX function.
        (Files): Remove lib/openat.h, lib/openat-proc.c.
        (Depends-on): Add at-internal, openat-h. Remove fdopendir, gettext-h,
        intprops, unistd.
        (configure.ac): Remove AC_LIBOBJ of openat-proc. Invoke
        gl_PREREQ_OPENAT, gl_MODULE_INDICATOR here. Invoke
        gl_FCNTL_MODULE_INDICATOR.
        (Include): Remove unistd.h, openat.h.
        * modules/areadlinkat (Files): Add lib/at-func.c.
        (Depends-on): Add at-internal, dosname, errno, extensions, fchdir,
        openat-die, openat-h, save-cwd.
        * modules/areadlinkat-with-size (Files): Add lib/at-func.c.
        (Depends-on): Add at-internal, dosname, errno, extensions, fchdir,
        openat-die, openat-h, save-cwd, unistd.
        * modules/faccessat (Files): Add lib/at-func.c, lib/openat-priv.h.
        (Depends-on): Add at-internal, dosname, errno, fchdir, openat-die,
        openat-h, save-cwd. Remove fcntl-h, openat.
        * modules/fchmodat (Files): Remove lib/openat.h.
        (Depends-on): Add at-internal, openat-h. Remove dirent, fcntl-h,
        openat, stdbool, unistd.
        * modules/fchownat (Files): Remove lib/openat.h.
        (Depends-on): Add at-internal, openat-h. Remove dirent, fcntl-h,
        openat, stdbool, sys_stat.
        * modules/fdopendir (Files): Remove lib/openat-priv.h,
        lib/openat-proc.c.
        (Depends-on): Add at-internal.
        (condigure.ac): Remove AC_LIBOBJ of openat-proc.
        * modules/fstatat (Files): Remove lib/openat.h.
        (Depends-on): Add at-internal, openat-h. Remove dirent, openat,
        stdbool, unistd.
        * modules/fts (Depends-on): Add openat-h.
        * modules/linkat (Depends-on): Add at-internal, openat-h. Remove
        openat.
        * modules/mkdirat (Files): Remove lib/openat.h.
        (Depends-on): Add at-internal, openat-h. Remove dirent, fcntl-h,
        openat, stdbool, sys_stat.
        * modules/mkfifoat (Files): Add lib/at-func.c.
        (Depends-on): Add at-internal, dosname, errno, fchdir, openat-die,
        openat-h, save-cwd. Remove fcntl-h, openat.
        * modules/openat-die (Depends-on): Add openat-h. Remove openat.
        * modules/readlinkat (Files): Add lib/at-func.c.
        (Depends-on): Add at-internal, dosname, errno, fchdir, openat-die,
        openat-h, save-cwd. Remove fcntl-h, openat.
        * modules/renameat (Depends-on): Add at-internal, openat-h. Remove
        openat.
        * modules/selinux-at (Files): Add lib/at-func.c.
        (Depends-on): Add at-internal, dosname, errno, extensions, fchdir,
        fcntl-h, openat-die, openat-h, save-cwd, unistd. Remove openat.
        * modules/symlinkat (Files): Add lib/at-func.c.
        (Depends-on): Add at-internal, dosname, errno, fchdir, openat-die,
        openat-h, save-cwd. Remove fcntl-h, openat.
        * modules/unlinkat (Files): Remove lib/openat.h.
        (Depends-on): Add at-internal, openat-h. Remove dirent, openat,
        stdbool.
        * modules/utimensat (Files): Add lib/at-func.c.
        (Depends-on): Add at-internal, dosname, errno, fchdir, fcntl-h,
        openat-die, openat-h, save-cwd.
        * modules/fchownat-tests (Depends-on): Add openat-h. Remove openat.
        * modules/fdutimensat-tests (Depends-on): Add openat.
        * modules/fstatat-tests (Depends-on): Add openat-h.
        * modules/readlinkat-tests (Depends-on): Add openat.
        * modules/symlinkat-tests (Depends-on): Add openat.

============================= modules/at-internal =============================
Description:
Internal functions for dealing with files relative to a directory.

Files:
lib/openat-priv.h
lib/openat-proc.c

Depends-on:
errno
fcntl-h
intprops
open
sys_stat
unistd

configure.ac:
AC_LIBOBJ([openat-proc])

Makefile.am:

Include:
"openat-priv.h"

License:
GPL

Maintainer:
Jim Meyering, Eric Blake
============================== modules/openat-h ===============================
Description:
Declarations of functions related to accessing files relative to a directory.

Files:
lib/openat.h

Depends-on:
fcntl-h
stdbool
sys_stat
unistd

configure.ac:

Makefile.am:

Include:
"openat.h"

License:
GPL

Maintainer:
Jim Meyering, Eric Blake
===============================================================================
--- m4/openat.m4.orig   Sat Nov  5 10:03:23 2011
+++ m4/openat.m4        Sat Nov  5 10:03:21 2011
@@ -1,4 +1,4 @@
-# serial 42
+# serial 43
 # See if we need to use our replacement for Solaris' openat et al functions.
 
 dnl Copyright (C) 2004-2011 Free Software Foundation, Inc.
@@ -11,8 +11,6 @@
 AC_DEFUN([gl_FUNC_OPENAT],
 [
   AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
-  GNULIB_OPENAT=1
-
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_CHECK_FUNCS_ONCE([openat])
   AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
@@ -26,13 +24,11 @@
     ;;
   *)
     HAVE_OPENAT=0
-    gl_PREREQ_OPENAT;;
+    ;;
   esac
-
-  dnl This is tested at least via getcwd.c.
-  gl_MODULE_INDICATOR([openat])
 ])
 
+# Prerequisites of lib/openat.c.
 AC_DEFUN([gl_PREREQ_OPENAT],
 [
   AC_REQUIRE([AC_C_INLINE])
--- modules/areadlinkat.orig    Sat Nov  5 10:03:23 2011
+++ modules/areadlinkat Sat Nov  5 03:23:32 2011
@@ -4,11 +4,20 @@
 Files:
 lib/areadlink.h
 lib/areadlinkat.c
+lib/at-func.c
 
 Depends-on:
 areadlink
 careadlinkat
 readlinkat
+at-internal
+dosname
+errno
+extensions
+fchdir
+openat-die
+openat-h
+save-cwd
 
 configure.ac:
 gl_MODULE_INDICATOR([areadlinkat])
--- modules/areadlinkat-with-size.orig  Sat Nov  5 10:03:23 2011
+++ modules/areadlinkat-with-size       Sat Nov  5 03:23:32 2011
@@ -4,11 +4,21 @@
 Files:
 lib/areadlink.h
 lib/areadlinkat-with-size.c
+lib/at-func.c
 
 Depends-on:
 areadlink-with-size
 stdint
 readlinkat
+at-internal
+dosname
+errno
+extensions
+fchdir
+openat-die
+openat-h
+save-cwd
+unistd
 
 configure.ac:
 gl_MODULE_INDICATOR([areadlinkat-with-size])
--- modules/faccessat.orig      Sat Nov  5 10:03:23 2011
+++ modules/faccessat   Sat Nov  5 03:23:32 2011
@@ -3,14 +3,21 @@
 
 Files:
 lib/faccessat.c
+lib/at-func.c
+lib/openat-priv.h
 m4/faccessat.m4
 
 Depends-on:
-unistd
+at-internal
+dosname
+errno
 extensions
-fcntl-h
+fchdir
+openat-die
+openat-h
+save-cwd
+unistd
 euidaccess      [test $HAVE_FACCESSAT = 0]
-openat          [test $HAVE_FACCESSAT = 0]
 
 configure.ac:
 gl_FUNC_FACCESSAT
--- modules/fchmodat.orig       Sat Nov  5 10:03:23 2011
+++ modules/fchmodat    Sat Nov  5 03:23:32 2011
@@ -4,23 +4,19 @@
 Files:
 lib/fchmodat.c
 lib/at-func.c
-lib/openat.h
 lib/openat-priv.h
 m4/fchmodat.m4
 
 Depends-on:
-dirent
+at-internal
 dosname
 errno
 extensions
 fchdir
-fcntl-h
-openat
 openat-die
+openat-h
 save-cwd
-stdbool
 sys_stat
-unistd
 
 configure.ac:
 gl_FUNC_FCHMODAT
--- modules/fchownat.orig       Sat Nov  5 10:03:23 2011
+++ modules/fchownat    Sat Nov  5 03:24:53 2011
@@ -4,24 +4,20 @@
 Files:
 lib/fchownat.c
 lib/at-func.c
-lib/openat.h
 lib/openat-priv.h
 m4/fchownat.m4
 
 Depends-on:
-dirent
+at-internal
 dosname
 errno
 extensions
 fchdir
-fcntl-h
 fstatat
 lchown          [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
-openat
 openat-die
+openat-h
 save-cwd
-stdbool
-sys_stat
 unistd
 
 configure.ac:
--- modules/fchownat-tests.orig Sat Nov  5 10:03:23 2011
+++ modules/fchownat-tests      Sat Nov  5 03:23:32 2011
@@ -9,7 +9,7 @@
 Depends-on:
 ignore-value
 mgetgroups
-openat
+openat-h
 progname
 usleep
 stat-time
--- modules/fdopendir.orig      Sat Nov  5 10:03:23 2011
+++ modules/fdopendir   Sat Nov  5 03:23:32 2011
@@ -3,13 +3,12 @@
 
 Files:
 lib/fdopendir.c
-lib/openat-priv.h
-lib/openat-proc.c
 m4/fdopendir.m4
 
 Depends-on:
 dirent
 extensions
+at-internal     [test $HAVE_FDOPENDIR = 0]
 dup             [test $HAVE_FDOPENDIR = 0]
 errno           [test $HAVE_FDOPENDIR = 0]
 fchdir          [test $HAVE_FDOPENDIR = 0]
@@ -23,9 +22,6 @@
 if test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1; then
   AC_LIBOBJ([fdopendir])
 fi
-if test $HAVE_FDOPENDIR = 0; then
-  AC_LIBOBJ([openat-proc])
-fi
 gl_DIRENT_MODULE_INDICATOR([fdopendir])
 gl_MODULE_INDICATOR([fdopendir])
 
--- modules/fdutimensat-tests.orig      Sat Nov  5 10:03:23 2011
+++ modules/fdutimensat-tests   Sat Nov  5 03:23:32 2011
@@ -9,6 +9,7 @@
 
 Depends-on:
 ignore-value
+openat
 timespec
 dup
 usleep
--- modules/fstatat.orig        Sat Nov  5 10:03:23 2011
+++ modules/fstatat     Sat Nov  5 03:23:32 2011
@@ -4,12 +4,11 @@
 Files:
 lib/fstatat.c
 lib/at-func.c
-lib/openat.h
 lib/openat-priv.h
 m4/fstatat.m4
 
 Depends-on:
-dirent
+at-internal
 dosname
 errno
 extensions
@@ -17,12 +16,10 @@
 fcntl-h
 fstat
 lstat
-openat
 openat-die
+openat-h
 save-cwd
-stdbool
 sys_stat
-unistd
 
 configure.ac:
 gl_FUNC_FSTATAT
--- modules/fstatat-tests.orig  Sat Nov  5 10:03:23 2011
+++ modules/fstatat-tests       Sat Nov  5 03:23:32 2011
@@ -8,6 +8,7 @@
 Depends-on:
 getcwd-lgpl
 ignore-value
+openat-h
 progname
 symlink
 
--- modules/fts.orig    Sat Nov  5 10:03:23 2011
+++ modules/fts Sat Nov  5 03:23:32 2011
@@ -23,6 +23,7 @@
 i-ring
 lstat
 memmove
+openat-h
 openat-safer
 opendir
 readdir
--- modules/linkat.orig Sat Nov  5 10:03:24 2011
+++ modules/linkat      Sat Nov  5 03:23:32 2011
@@ -11,6 +11,7 @@
 extensions
 areadlink        [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 areadlinkat      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
+at-internal      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 dirname-lgpl     [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 dosname          [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 errno            [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
@@ -19,7 +20,7 @@
 fstat            [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 fstatat          [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 getcwd-lgpl      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
-openat           [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
+openat-h         [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 openat-die       [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 link             [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 link-follow      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
--- modules/mkdirat.orig        Sat Nov  5 10:03:24 2011
+++ modules/mkdirat     Sat Nov  5 03:23:32 2011
@@ -4,23 +4,19 @@
 Files:
 lib/mkdirat.c
 lib/at-func.c
-lib/openat.h
 lib/openat-priv.h
 m4/mkdirat.m4
 
 Depends-on:
-dirent
+at-internal
 dosname
 errno
 extensions
 fchdir
-fcntl-h
 mkdir           [test $HAVE_MKDIRAT = 0]
-openat
 openat-die
+openat-h
 save-cwd
-stdbool
-sys_stat
 unistd
 
 configure.ac:
--- modules/mkfifoat.orig       Sat Nov  5 10:03:24 2011
+++ modules/mkfifoat    Sat Nov  5 03:23:32 2011
@@ -4,15 +4,21 @@
 Files:
 lib/mkfifoat.c
 lib/mknodat.c
+lib/at-func.c
 m4/mkfifoat.m4
 
 Depends-on:
-sys_stat
+at-internal
+dosname
+errno
 extensions
-fcntl-h
+fchdir
+openat-die
+openat-h
+save-cwd
+sys_stat
 mkfifo          [test $HAVE_MKFIFOAT = 0]
 mknod           [test $HAVE_MKNODAT = 0]
-openat          [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
 
 configure.ac:
 gl_FUNC_MKFIFOAT
--- modules/openat.orig Sat Nov  5 10:03:24 2011
+++ modules/openat      Sat Nov  5 03:23:32 2011
@@ -1,46 +1,42 @@
 Description:
-Open a file at a directory.
+openat() function: Open a file at a directory.
 
 Files:
 lib/at-func.c
 lib/openat.c
-lib/openat.h
 lib/openat-priv.h
-lib/openat-proc.c
 m4/openat.m4
 m4/mode_t.m4
 
 Depends-on:
+at-internal
 dosname
 errno
 extensions
 fchdir
 fcntl-h
-fdopendir
 fstat
-gettext-h
-intprops
 largefile
 open
 openat-die
+openat-h
 save-cwd
 stdbool
 sys_stat
-unistd
 
 configure.ac:
 gl_FUNC_OPENAT
-AC_LIBOBJ([openat-proc])
 if test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1; then
   AC_LIBOBJ([openat])
+  gl_PREREQ_OPENAT
 fi
+gl_MODULE_INDICATOR([openat]) dnl for lib/getcwd.c
+gl_FCNTL_MODULE_INDICATOR([openat])
 
 Makefile.am:
 
 Include:
 <fcntl.h>
-<unistd.h>
-"openat.h"
 
 License:
 GPL
--- modules/openat-die.orig     Sat Nov  5 10:03:24 2011
+++ modules/openat-die  Sat Nov  5 03:23:32 2011
@@ -5,10 +5,10 @@
 lib/openat-die.c
 
 Depends-on:
-openat
+openat-h
 error
-gettext-h
 exitfail
+gettext-h
 
 configure.ac:
 
--- modules/readlinkat.orig     Sat Nov  5 10:03:24 2011
+++ modules/readlinkat  Sat Nov  5 03:23:32 2011
@@ -3,13 +3,19 @@
 
 Files:
 lib/readlinkat.c
+lib/at-func.c
 m4/readlinkat.m4
 
 Depends-on:
-unistd
+at-internal
+dosname
+errno
 extensions
-fcntl-h
-openat          [test $HAVE_READLINKAT = 0]
+fchdir
+openat-die
+openat-h
+save-cwd
+unistd
 readlink        [test $HAVE_READLINKAT = 0]
 
 configure.ac:
--- modules/readlinkat-tests.orig       Sat Nov  5 10:03:24 2011
+++ modules/readlinkat-tests    Sat Nov  5 03:23:32 2011
@@ -6,6 +6,7 @@
 
 Depends-on:
 ignore-value
+openat
 symlinkat
 unlinkat
 
--- modules/renameat.orig       Sat Nov  5 10:03:24 2011
+++ modules/renameat    Sat Nov  5 03:23:32 2011
@@ -10,13 +10,14 @@
 stdio
 extensions
 fcntl-h
+at-internal      [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 dosname          [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 filenamecat-lgpl [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 fstat            [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 fstatat          [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 getcwd-lgpl      [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
-openat           [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 openat-die       [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
+openat-h         [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 rename           [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 same-inode       [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 save-cwd         [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
--- modules/selinux-at.orig     Sat Nov  5 10:03:24 2011
+++ modules/selinux-at  Sat Nov  5 03:23:32 2011
@@ -2,12 +2,22 @@
 openat-style fd-relative functions for SE Linux
 
 Files:
-lib/selinux-at.c
 lib/selinux-at.h
+lib/selinux-at.c
+lib/at-func.c
 
 Depends-on:
-openat
 selinux-h
+at-internal
+dosname
+errno
+extensions
+fchdir
+fcntl-h
+openat-die
+openat-h
+save-cwd
+unistd
 
 configure.ac:
 AC_CHECK_HEADERS([selinux/flask.h])
--- modules/symlinkat.orig      Sat Nov  5 10:03:24 2011
+++ modules/symlinkat   Sat Nov  5 03:23:32 2011
@@ -3,13 +3,19 @@
 
 Files:
 lib/symlinkat.c
+lib/at-func.c
 m4/symlinkat.m4
 
 Depends-on:
-unistd
+at-internal
+dosname
+errno
 extensions
-fcntl-h
-openat          [test $HAVE_SYMLINKAT = 0]
+fchdir
+openat-die
+openat-h
+save-cwd
+unistd
 symlink         [test $HAVE_SYMLINKAT = 0]
 
 configure.ac:
--- modules/symlinkat-tests.orig        Sat Nov  5 10:03:24 2011
+++ modules/symlinkat-tests     Sat Nov  5 03:23:32 2011
@@ -6,6 +6,7 @@
 
 Depends-on:
 ignore-value
+openat
 
 configure.ac:
 
--- modules/unlinkat.orig       Sat Nov  5 10:03:24 2011
+++ modules/unlinkat    Sat Nov  5 03:25:29 2011
@@ -4,23 +4,21 @@
 Files:
 lib/unlinkat.c
 lib/at-func.c
-lib/openat.h
 lib/openat-priv.h
 m4/unlinkat.m4
 
 Depends-on:
-dirent
+at-internal
 dosname
 errno
 extensions
 fchdir
 fcntl-h
 fstatat
-openat
 openat-die
+openat-h
 rmdir           [test $HAVE_UNLINKAT = 0]
 save-cwd
-stdbool
 sys_stat
 unistd
 unlink          [test $HAVE_UNLINKAT = 0]
--- modules/utimensat.orig      Sat Nov  5 10:03:24 2011
+++ modules/utimensat   Sat Nov  5 03:23:32 2011
@@ -3,11 +3,20 @@
 
 Files:
 lib/utimensat.c
+lib/at-func.c
 m4/utimensat.m4
 
 Depends-on:
-sys_stat
+at-internal
+dosname
+errno
 extensions
+fchdir
+fcntl-h
+openat-die
+openat-h
+save-cwd
+sys_stat
 fstatat         [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 utimens         [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 

-- 
In memoriam Bernhard Lichtenberg 
<http://en.wikipedia.org/wiki/Bernhard_Lichtenberg>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]