Rolf Eike Beer
2017-Oct-12 09:57 UTC
[PATCH][RESEND] apply the struct dirent penalty only when needed
Hi, attached is a patch that reduces the memory in use on all systems where BROKEN_ONE_BYTE_DIRENT_D_NAME is not defined. It would be good if there was a ac_something variable that could be given to configure to tell it if this workaround is needed or not when cross compiling. We currently do it another way after running configure: ===cat >>conftest.c <<EOF #include <sys/types.h> #include <dirent.h> #include <assert.h> int main() { struct dirent d; static_assert(sizeof(d.d_name) > sizeof(char), "struct to small"); return 0; } EOF ${target_platform}-gcc ${optflags} conftest.c && \ sed -ri 's/#define (BROKEN_ONE_BYTE_DIRENT_D_NAME) 1/#undef \1/' config.h === Of course that only works when one has a compiler that is new enough (what we can guarantee). Greetings, Eike -- Rolf Eike Beer, emlix GmbH, http://www.emlix.com Fon +49 551 30664-0, Fax +49 551 30664-11 Bertha-von-Suttner-Str. 9, 37085 G?ttingen, Germany Sitz der Gesellschaft: G?ttingen, Amtsgericht G?ttingen HR B 3160 Gesch?ftsf?hrung: Heike Jordan, Dr. Uwe Kracke ? Ust-IdNr.: DE 205 198 055 emlix ? smart embedded open source -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-apply-the-struct-dirent-penalty-only-when-needed.patch Type: text/x-patch Size: 1385 bytes Desc: not available URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20171012/adbffe3c/attachment.bin> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 313 bytes Desc: This is a digitally signed message part. URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20171012/adbffe3c/attachment.asc>
Corinna Vinschen
2017-Oct-12 15:51 UTC
[PATCH][RESEND] apply the struct dirent penalty only when needed
On Oct 12 11:57, Rolf Eike Beer wrote:> Subject: [PATCH 1/3] apply the struct dirent penalty only when needed > > Many systems have a struct dirent that already has enough space to hold the > entries names, others like Solaris have not. For the latter extra space needs > to be allocated, but this was also done for the former systems leading to > needlessly reserved memory. > --- > sftp-glob.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/sftp-glob.c b/sftp-glob.c > index 43a1beba..8edd28ac 100644 > --- a/sftp-glob.c > +++ b/sftp-glob.c > @@ -64,9 +64,14 @@ fudge_opendir(const char *path) > static struct dirent * > fudge_readdir(struct SFTP_OPENDIR *od) > { > +#ifdef BROKEN_ONE_BYTE_DIRENT_D_NAME > /* Solaris needs sizeof(dirent) + path length (see below) */ > static char buf[sizeof(struct dirent) + MAXPATHLEN];I know this code was already there, but isn't MAXPATHLEN rather wasteful? Shouldn't that be NAME_LEN + 1 instead? Corinna -- Corinna Vinschen Cygwin Maintainer Red Hat -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20171012/76724f1a/attachment.asc>