X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=sG3qli2pZ0sAj6np/0BONJIJgihTLMhI39gv0h0GOTc=; b=N+9wLIm92hpna+YEWj0hvYjpIsAoOKgM70UIAX1Qt06m5fkDeg5jQYFr7pEmvH2acw IxuZfmlzDnkjr/2nLyBzsjARNVvWcG3b8LUgpzYePUkETC7d8p7HMDaMJfbQPENmasuM 4QSLYQFyMPM4/VI8LAqHngvK4fW7lv3J/w8mpVMhu+hpX4YV4/iA3FWsXYIbPGLtWXTp zGIUvH1qhY8xq0GE9FKjimpxdcC23LwJgeQTRtsSdRfQYd9Lu9vGZy1PyTRfHd3XMIc6 IasHL+Igq/SHBoft+HHrXsqJKWIVX6aNc5ONxdfb5kAlU0HrroV+SIuj4uV0Uvt6sjfZ ZlYg== MIME-Version: 1.0 X-Received: by 10.50.49.44 with SMTP id r12mr39555356ign.41.1398876630258; Wed, 30 Apr 2014 09:50:30 -0700 (PDT) In-Reply-To: References: <83wqeh9pwq DOT fsf AT gnu DOT org> <83vbu19o4f DOT fsf AT gnu DOT org> <83r44p9mjr DOT fsf AT gnu DOT org> Date: Wed, 30 Apr 2014 19:50:29 +0300 Message-ID: Subject: Re: [PATCH] break xstat.c into pieces From: Ozkan Sezer To: djgpp-workers AT delorie DOT com Content-Type: multipart/mixed; boundary=047d7bdc1750a1bc4604f8455812 Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --047d7bdc1750a1bc4604f8455812 Content-Type: text/plain; charset=UTF-8 On 4/22/14, Ozkan Sezer wrote: > On 4/22/14, Eli Zaretskii wrote: [...] > OK, leaving things to you guys. > PING: If there is still interest in this, I've been using the two patches inlined below (also attached) for some time and they work well for me. * mkdir.c: replace access() call with _chmod(). this loses the extra _fixpath()+remote rootdir check done by access(), but it shortens things by not pulling in extra dependencies. Index: src/libc/posix/sys/stat/mkdir.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/mkdir.c,v retrieving revision 1.7 diff -u -p -r1.5 mkdir.c --- src/libc/posix/sys/stat/mkdir.c 2 Oct 2011 02:40:11 -0000 1.7 +++ src/libc/posix/sys/stat/mkdir.c 24 Apr 2014 07:51:10 -0000 @@ -73,7 +73,8 @@ do_mkdir: { /* see if the directory existed, in which case we should return EEXIST - DJ */ - if (access(mydirname, D_OK) == 0) + if ((attr = _chmod(dir_name,0,0)) != (unsigned)-1 + && (attr & 0x10)) errno = EEXIST; else errno = save_errno; * move _djstat_fail_bits and _djstat_flags out of xstat.c into new statbits.c, so that, e.g. mkdir() doesn't pull in unnecessary dependencies such as ctime.o. Index: src/libc/posix/sys/stat/makefile =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/makefile,v retrieving revision 1.5 diff -u -p -r1.5 makefile --- src/libc/posix/sys/stat/makefile 8 Mar 2003 00:41:17 -0000 1.5 +++ src/libc/posix/sys/stat/makefile 24 Apr 2014 07:51:10 -0000 @@ -16,6 +16,7 @@ SRC += mkfifo.c SRC += st_loss.c SRC += stat.c +SRC += statbits.c SRC += umask.c SRC += xstat.c Index: src/libc/posix/sys/stat/xstat.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/xstat.c,v retrieving revision 1.8 diff -u -p -r1.8 xstat.c --- src/libc/posix/sys/stat/xstat.c 10 Mar 2012 18:03:11 -0000 1.8 +++ src/libc/posix/sys/stat/xstat.c 24 Apr 2014 07:51:10 -0000 @@ -32,40 +32,6 @@ static int xstat_count = -1; -/* Some fields of struct stat are expensive to compute under DOS, - because they require multiple disk accesses. Fortunately, many - DOS programs don't care about these. To leave both pedants (like - me) and performance-oriented guys happy, a variable is provided - which controls which expensive fields should be computed. To get - the fastest stat() for your program, clear the bits for only those - features you need and set the others. - - This improvement was suggested by Charles Sandmann - and DJ Delorie . */ - -/* Please see the header file sys/stat.h for the definitions of _STAT_*. */ - -/* Should we bother about executables at all? */ -#define _STAT_EXECBIT (_STAT_EXEC_EXT | _STAT_EXEC_MAGIC) - -/* By default, all the bits are reset (including as yet unused ones), so - people who don't care will transparently have the full version. */ -unsigned short _djstat_flags; - -/* As we depend on undocumented DOS features, we could fail in some - incompatible environment or future DOS versions. If we do, the - following variable will have some of its bits set. Each bit - describes a single feature which we tried to use and failed. - The function _djstat_describe_lossage() may be called to print a - human-readable description of the bits which were set by the last - call to f?stat(). This should make debugging f?stat() failures - in an unanticipated environment a lot easier. - - This improvement was suggested by Charles Sandmann - . */ - -unsigned short _djstat_fail_bits; - /* ----------------------------------------------------------------------- */ /* Convert file date and time to time_t value suitable for --- /dev/null +++ src/libc/posix/sys/stat/statbits.c 24 Apr 2014 07:51:10 -0000 @@ -0,0 +1,42 @@ +/* Copyright (C) 2012 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include "xstat.h" + +/* Some fields of struct stat are expensive to compute under DOS, + because they require multiple disk accesses. Fortunately, many + DOS programs don't care about these. To leave both pedants (like + me) and performance-oriented guys happy, a variable is provided + which controls which expensive fields should be computed. To get + the fastest stat() for your program, clear the bits for only those + features you need and set the others. + + This improvement was suggested by Charles Sandmann + and DJ Delorie . */ + +/* Please see the header file sys/stat.h for the definitions of _STAT_*. */ + +/* Should we bother about executables at all? */ +#define _STAT_EXECBIT (_STAT_EXEC_EXT | _STAT_EXEC_MAGIC) + +/* By default, all the bits are reset (including as yet unused ones), so + people who don't care will transparently have the full version. */ +unsigned short _djstat_flags; + +/* As we depend on undocumented DOS features, we could fail in some + incompatible environment or future DOS versions. If we do, the + following variable will have some of its bits set. Each bit + describes a single feature which we tried to use and failed. + The function _djstat_describe_lossage() may be called to print a + human-readable description of the bits which were set by the last + call to f?stat(). This should make debugging f?stat() failures + in an unanticipated environment a lot easier. + + This improvement was suggested by Charles Sandmann + . */ + +unsigned short _djstat_fail_bits; + -- O.S. --047d7bdc1750a1bc4604f8455812 Content-Type: text/plain; charset=US-ASCII; name="djxstat.diff" Content-Disposition: attachment; filename="djxstat.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: file0 SW5kZXg6IHNyYy9saWJjL3Bvc2l4L3N5cy9zdGF0L21ha2VmaWxlCj09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KUkNTIGZp bGU6IC9jdnMvZGpncHAvZGpncHAvc3JjL2xpYmMvcG9zaXgvc3lzL3N0YXQvbWFrZWZpbGUsdgpy ZXRyaWV2aW5nIHJldmlzaW9uIDEuNQpkaWZmIC11IC1wIC1yMS41IG1ha2VmaWxlCi0tLSBzcmMv bGliYy9wb3NpeC9zeXMvc3RhdC9tYWtlZmlsZQk4IE1hciAyMDAzIDAwOjQxOjE3IC0wMDAwCTEu NQorKysgc3JjL2xpYmMvcG9zaXgvc3lzL3N0YXQvbWFrZWZpbGUJMjQgQXByIDIwMTQgMDc6NTE6 MTAgLTAwMDAKQEAgLTE2LDYgKzE2LDcgQEAKIFNSQyArPSBta2ZpZm8uYwogU1JDICs9IHN0X2xv c3MuYwogU1JDICs9IHN0YXQuYworU1JDICs9IHN0YXRiaXRzLmMKIFNSQyArPSB1bWFzay5jCiBT UkMgKz0geHN0YXQuYwogCkluZGV4OiBzcmMvbGliYy9wb3NpeC9zeXMvc3RhdC94c3RhdC5jCj09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT0KUkNTIGZpbGU6IC9jdnMvZGpncHAvZGpncHAvc3JjL2xpYmMvcG9zaXgvc3lzL3N0 YXQveHN0YXQuYyx2CnJ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yBkb24ndCBjYXJlIHdpbGwgdHJhbnNw YXJlbnRseSBoYXZlIHRoZSBmdWxsIHZlcnNpb24uICAqLwordW5zaWduZWQgc2hvcnQgX2Rqc3Rh dF9mbGFnczsKKworLyogQXMgd2UgZGVwZW5kIG9uIHVuZG9jdW1lbnRlZCBET1MgZmVhdHVyZXMs IHdlIGNvdWxkIGZhaWwgaW4gc29tZQorICAgaW5jb21wYXRpYmxlIGVudmlyb25tZW50IG9yIGZ1 dHVyZSBET1MgdmVyc2lvbnMuICBJZiB3ZSBkbywgdGhlCisgICBmb2xsb3dpbmcgdmFyaWFibGUg d2lsbCBoYXZlIHNvbWUgb2YgaXRzIGJpdHMgc2V0LiAgRWFjaCBiaXQKKyAgIGRlc2NyaWJlcyBh IHNpbmdsZSBmZWF0dXJlIHdoaWNoIHdlIHRyaWVkIHRvIHVzZSBhbmQgZmFpbGVkLgorICAgVGhl IGZ1bmN0aW9uIF9kanN0YXRfZGVzY3JpYmVfbG9zc2FnZSgpIG1heSBiZSBjYWxsZWQgdG8gcHJp bnQgYQorICAgaHVtYW4tcmVhZGFibGUgZGVzY3JpcHRpb24gb2YgdGhlIGJpdHMgd2hpY2ggd2Vy ZSBzZXQgYnkgdGhlIGxhc3QKKyAgIGNhbGwgdG8gZj9zdGF0KCkuICBUaGlzIHNob3VsZCBtYWtl IGRlYnVnZ2luZyBmP3N0YXQoKSBmYWlsdXJlcworICAgaW4gYW4gdW5hbnRpY2lwYXRlZCBlbnZp cm9ubWVudCBhIGxvdCBlYXNpZXIuCisKKyAgIFRoaXMgaW1wcm92ZW1lbnQgd2FzIHN1Z2dlc3Rl ZCBieSBDaGFybGVzIFNhbmRtYW5uCisgICA8c2FuZG1hbm5AY2xpby5yaWNlLmVkdT4uICAqLwor Cit1bnNpZ25lZCBzaG9ydCBfZGpzdGF0X2ZhaWxfYml0czsKKwo= --047d7bdc1750a1bc4604f8455812 Content-Type: text/plain; charset=US-ASCII; name="djmkdir.diff" Content-Disposition: attachment; filename="djmkdir.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: file0 SW5kZXg6IHNyYy9saWJjL3Bvc2l4L3N5cy9zdGF0L21rZGlyLmMKPT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpSQ1MgZmls ZTogL2N2cy9kamdwcC9kamdwcC9zcmMvbGliYy9wb3NpeC9zeXMvc3RhdC9ta2Rpci5jLHYKcmV0 cmlldmluZyByZXZpc2lvbiAxLjcKZGlmZiAtdSAtcCAtcjEuNSBta2Rpci5jCi0tLSBzcmMvbGli Yy9wb3NpeC9zeXMvc3RhdC9ta2Rpci5jCTIgT2N0IDIwMTEgMDI6NDA6MTEgLTAwMDAJMS43Cisr KyBzcmMvbGliYy9wb3NpeC9zeXMvc3RhdC9ta2Rpci5jCTI0IEFwciAyMDE0IDA3OjUxOjEwIC0w MDAwCkBAIC03Myw3ICs3Myw4IEBAIGRvX21rZGlyOgogICAgIHsKICAgICAgIC8qIHNlZSBpZiB0 aGUgZGlyZWN0b3J5IGV4aXN0ZWQsIGluIHdoaWNoIGNhc2UKICAgICAgICAgIHdlIHNob3VsZCBy ZXR1cm4gRUVYSVNUIC0gREogKi8KLSAgICAgIGlmIChhY2Nlc3MobXlkaXJuYW1lLCBEX09LKSA9 PSAwKQorICAgICAgaWYgKChhdHRyID0gX2NobW9kKGRpcl9uYW1lLDAsMCkpICE9ICh1bnNpZ25l ZCktMQorICAgICAgICAgICYmIChhdHRyICYgMHgxMCkpCiAgICAgICAgIGVycm5vID0gRUVYSVNU OwogICAgICAgZWxzZQogICAgICAgICBlcnJubyA9IHNhdmVfZXJybm87Cg== --047d7bdc1750a1bc4604f8455812--