delorie.com/archives/browse.cgi | search |
From: | Chris_Schumann AT dgii DOT com (Chris Schumann) |
Subject: | Re: File operations speed-up |
18 Mar 1997 12:38:14 -0800 : | |
Approved: | cygnus DOT gnu-win32 AT cygnus DOT com |
Distribution: | cygnus |
Message-ID: | <1997Mar18.074816.1839.487459.cygnus.gnu-win32@msp-ln05.dgii.com> |
Mime-Version: | 1.0 |
Original-To: | sos AT prospect DOT com DOT ru (Sergey Okhapkin) |
Original-Cc: | Gnu-Win32 AT cygnus DOT com ('Gnu-Win32') |
X-Conversion-ID: | <PU-NOTES.2231.858692896.9269> |
X-Mailer: | Lotus Notes via PostalUnion/SMTP for Windows NT |
Original-Sender: | owner-gnu-win32 AT cygnus DOT com |
--===_1997Mar18.074816.1839.487459===_ Content-Type: text/plain; charset="US-ASCII" Isn't this useless for those who use backup software that uses the archive bit to indicate whether a file has been archived? ChrisS Sergey Okhapkin <sos @ prospect.com.ru> 03/17/97 08:03 PM To: 'Gnu-Win32' <gnu-win32 @ cygnus.com> @ SMTP cc: Subject: File operations speed-up Hi! This patch increases the speed of stat/lstat calls dramatically. The trick is simple. Cygwin's stat call implementation reads the beginning of stated file to look for a "magic cookie" to define "executable" and "symlink" attributes of a file. With this patch reading is performed only if file have "archive" bit cleared. All ordinary files (not executables/symlinks) have this bit set. After applying this patch You have to "chmod +x file" on all executables/symlinks. I made a "chmod +x *" on directories with binaries. Later I'll write a special utility "fssync" to examine all files in a given directory tree and to set archive bit according to file magic cookie. Compare the time of "du ." on cygwin's root without and with this patch :-) -- Sergey Okhapkin Moscow, Russia Looking for a job. --uuencoded file (archive.diff) attached... - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help". --===_1997Mar18.074816.1839.487459===_ Content-Type: application/octet-stream; name="archive.diff" Content-Transfer-Encoding: base64 KioqIHBhdGguY2Mub3JpZwlUaHUgSmFuIDAxIDAzOjAxOjA4IDE5NzAKLS0tIHBhdGguY2MJV2Vk IERlYyAxOCAxNzowNzoyNiAxOTk2CioqKioqKioqKioqKioqKgoqKiogOTkzLDk5OCAqKioqCi0t LSA5OTMsOTk5IC0tLS0KICAgICAgICBlbHNlCiAgCXsKICAJICBfY2xvc2UgKGZkKTsKKyAJICBj aG1vZChmcm9tcGF0aCwgU19JRkxOSyk7CiAgCSAgcmVzID0gMDsKICAJfQogICAgICB9CioqKioq KioqKioqKioqKgoqKiogMTAyNiwxMDMxICoqKioKLS0tIDEwMjcsMTAzMyAtLS0tCiAgc3ltbGlu a19jaGVjayAoY29uc3QgY2hhciAqcGF0aCwgY2hhciAqYnVmLCBpbnQgYnVmbGVuLCBpbnQgKnN5 bWwsIGludCAqZXhlYykKICB7CiAgICBpbnQgcmVzID0gLTE7CisgICBpbnQgbm93ID0gMDsKICAK ICAgIHBhdGhfY29udiBwYXRoYnVmIChwYXRoKTsKICAgIGlmIChwYXRoYnVmLmVycm9yKQoqKioq KioqKioqKioqKioKKioqIDEwMzQsMTAzOSAqKioqCi0tLSAxMDM2LDEwNTEgLS0tLQogICAgICAg IHN5c2NhbGxfcHJpbnRmICgiLTEgPSBzeW1saW5rX2NoZWNrICglcywgJXAsICVkKVxuIiwgcGF0 aCwgYnVmLCBidWZsZW4pOwogICAgICAgIHJldHVybiAtMTsKICAgICAgfQorICAgaWYgKChub3cg PSBHZXRGaWxlQXR0cmlidXRlc0EgKHBhdGhidWYuZ2V0X3dpbjMyICgpKSkgPT0gLTEpCisgICAg IHsKKyAgICAgICBfX3NldGVycm5vICgpOworICAgICB9CisgICBpZiAobm93ICYgRklMRV9BVFRS SUJVVEVfQVJDSElWRSkgeworICAgICAqc3ltbCA9IDA7CisgICAgICpleGVjID0gMDsKKyAgICAg cmV0dXJuIDA7CisgICB9CisgCiAgCiAgICBTRUNVUklUWV9BVFRSSUJVVEVTIHNhOwogICAgc2Eu bkxlbmd0aCA9IHNpemVvZiAoc2EpOwoqKiogc3lzY2FsbHMuY2Mub3JpZwlXZWQgRGVjIDE4IDE2 OjU5OjUxIDE5OTYKLS0tIHN5c2NhbGxzLmNjCVdlZCBEZWMgMTggMTg6MTc6MjAgMTk5NgoqKioq KioqKioqKioqKioKKioqIDU2OCw1NzMgKioqKgotLS0gNTY4LDU3OSAtLS0tCiAgICAgIH0KICAg IGVsc2UKICAgICAgeworICAgICAgIC8qIHJlc2V0IEFSQ0hJVkUgYXR0cmlidXRlIG9uIGV4ZWN1 dGFibGVzIGFuZCBzeW1saW5rcyAqLworICAgICAgIGlmIChtb2RlICYgU19JRkxOSykKKyAgICAg ICAgIG5vdyAmPSB+RklMRV9BVFRSSUJVVEVfQVJDSElWRTsKKyAgICAgICBlbHNlIHsKKyAgICAg ICAgIGlmIChtb2RlICYgU1REX1hCSVRTKQorICAgICAgICAgICBub3cgJj0gfkZJTEVfQVRUUklC VVRFX0FSQ0hJVkU7CiAgICAgICAgLyogaWYgdGhlIG1vZGUgd2Ugd2FudCBoYXMgYW55IHdyaXRl IGJpdHMgc2V0LCB3ZSBjYW4ndAogIAkgYmUgcmVhZCBvbmx5LiAqLwogICAgICAgIGlmIChtb2Rl ICYgU1REX1dCSVRTKQoqKioqKioqKioqKioqKioKKioqIDU3OCw1ODMgKioqKgotLS0gNTg0LDU5 MCAtLS0tCiAgCXsKICAJICBub3cgfD0gRklMRV9BVFRSSUJVVEVfUkVBRE9OTFk7CiAgCX0KKyAg ICAgICB9CiAgCiAgICAgICAgaWYgKFNldEZpbGVBdHRyaWJ1dGVzQSAod2luMzJfcGF0aC5nZXRf d2luMzIgKCksIG5vdykpCiAgCXJlcyA9IDA7CioqKioqKioqKioqKioqKgoqKiogNjk3LDcwMiAq KioqCi0tLSA3MDQsNzEwIC0tLS0KICAgIHJldHVybiAwOwogIH0KICAKKyAjaWYgMAogIHN0YXRp YyBpbnQKICBfc3RhdF93b3JrZXIgKGNvbnN0IGNoYXIgKmNhbGxlciwgY29uc3QgY2hhciAqbmFt ZSwgc3RydWN0IHN0YXQgKmJ1ZiwKICAJICAgICAgaW50IG5vZm9sbG93KQoqKioqKioqKioqKioq KioKKioqIDc2Myw3NjggKioqKgotLS0gNzcxLDkwMCAtLS0tCiAgCX0KICAgICAgfQogICAgCisg IGRvbmU6CisgICBzeXNjYWxsX3ByaW50ZiAoIiVkID0gJXMgKCVzLCAlcClcbiIsIHJlcywgY2Fs bGVyLCBuYW1lLCBidWYpOworICAgcmV0dXJuIHJlczsKKyB9CisgI2VuZGlmCisgCisgc3RhdGlj IGludAorIF9zdGF0X3dvcmtlciAoY29uc3QgY2hhciAqY2FsbGVyLCBjb25zdCBjaGFyICpuYW1l LCBzdHJ1Y3Qgc3RhdCAqYnVmLAorIAkgICAgICBpbnQgbm9mb2xsb3cpCisgeworICAgaW50IHJl cyA9IC0xOworICAgaW50IGxlbjsKKyAgIEhBTkRMRSBhdHRzOworICAgY2hhciB0bXBbTUFYX1BB VEhdOworICAgY2hhciAqd2luMzJfbmFtZTsKKyAgIFdJTjMyX0ZJTkRfREFUQSB3ZmQ7CisgCisg ICBkZWJ1Z19wcmludGYgKCIlcyAoJXMsICVwKVxuIiwgY2FsbGVyLCBuYW1lLCBidWYpOworICAg CisgICBwYXRoX2NvbnYgcmVhbF9wYXRoIChuYW1lKTsKKyAgIGlmIChyZWFsX3BhdGguZXJyb3Ip CisgICAgIHsKKyAgICAgICBzZXRfZXJybm8gKHJlYWxfcGF0aC5lcnJvcik7CisgICAgICAgZ290 byBkb25lOworICAgICB9CisgCisgICBtZW1zZXQgKGJ1ZiwgMCwgc2l6ZW9mIChzdHJ1Y3Qgc3Rh dCkpOworICAgbWVtc2V0ICgmd2ZkLCAwLCBzaXplb2YgKHdmZCkpOworIAorICAgd2luMzJfbmFt ZSA9IHJlYWxfcGF0aC5nZXRfd2luMzIgKCk7CisgICAvKiBSZW1vdmUgdHJhaWxpbmcgYmFja3Ns YXNoIGlmIHN0YXQgb2YgZGlyZWN0b3J5ICovCisgICBpZih3aW4zMl9uYW1lW3N0cmxlbih3aW4z Ml9uYW1lKS0xXSA9PSAnXFwnKQorICAgICB3aW4z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YnVmLT5zdF9zaXplICAgID0gd2ZkLm5GaWxlU2l6ZUxvdzsKKyAg ICAgICAgICAgYnVmLT5zdF9pbm8gICAgID0gLyp3ZmQubkZpbGVJbmRleExvdyBeKi8gaGFzaF9w YXRoX25hbWUgKHdpbjMyX25hbWUpOworICAgICAgICAgICBidWYtPnN0X2Jsa3NpemUgPSBTX0JM S1NJWkU7CisgICAgICAgICAgIGJ1Zi0+c3RfYmxvY2tzICA9IChidWYtPnN0X3NpemUgKyBTX0JM S1NJWkUtMSkgLyBTX0JMS1NJWkU7CisgICAgICAgICAgIGJ1Zi0+c3RfdWlkICAgICA9IGdldHVp ZCAoKTsKKyAgICAgICAgICAgYnVmLT5zdF9naWQgICAgID0gZ2V0Z2lkICgpOworICAgICAgICAg ICBidWYtPnN0X21vZGUgICAgPSBTVERfUkJJVFMgfCBTX0lGUkVHOworICAgCisgICAgICAgICAg IGlmICghICh3ZmQuZHdGaWxlQXR0cmlidXRlcyAmIEZJTEVfQVRUUklCVVRFX1JFQURPTkxZKSkK KyAgICAgICAgICAgICBidWYtPnN0X21vZGUgfD0gU1REX1dCSVRTOworICAgICAgICAgICByZXMg PSAwOworICAgICAgICAgfQorICAgICAgIGVsc2UKKyAgICAgICAgIHsKKyAJLyogTGV0IGZzdGF0 IGRvIGFsbCBkaXJ0eSB3b3JrICovCQorICAgICAgICAgICAgCisgICAgICAgICAgIGludCBoID0g X29wZW4gKHdpbjMyX25hbWUsIE9fUkRPTkxZIHwgT19CSU5BUlkgfCBub2ZvbGxvdyk7CisgICAg ICAgICAgIGlmIChoID49IDApCisgCSAgICB7CisgIAkgICAgICByZXMgPSBfZnN0YXQgKGgsIGJ1 Zik7CisgCSAgICAgIF9jbG9zZSAoaCk7CisgCSAgICB9CisgICAgICAgICB9CisgICAgIH0KKyAg IEZpbmRDbG9zZShhdHRzKTsgIAogICBkb25lOgogICAgc3lzY2FsbF9wcmludGYgKCIlZCA9ICVz ICglcywgJXApXG4iLCByZXMsIGNhbGxlciwgbmFtZSwgYnVmKTsKICAgIHJldHVybiByZXM7Cg== --===_1997Mar18.074816.1839.487459===_-- - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |