From: Marc Alff Date: March 22 2010 9:08am Subject: bzr commit into mysql-next-mr-bugfixing branch (marc.alff:3138) Bug#52134 List-Archive: http://lists.mysql.com/commits/103937 X-Bug: 52134 Message-Id: <20100322090833.169AC2952ED@MarcBook.local> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_NqvqilEI3HvJmKXX5OMNdA)" --Boundary_(ID_NqvqilEI3HvJmKXX5OMNdA) MIME-version: 1.0 Content-type: text/plain; CHARSET=US-ASCII Content-transfer-encoding: 7BIT Content-disposition: inline #At file:///Users/malff/BZR_TREE/mysql-next-mr-bugfixing-52134/ based on revid:jack@stripped 3138 Marc Alff 2010-03-22 Bug#52134 performance schema file io, symlink in path Before this fix, a file named "/path/with/link/to/filename" would be normalized to: - "/path/with/link/to/filename" when the file did not exist (creation), - "/real/path/to/filename" when the file did exist (file io, deletion), causing instrumentation leak for file io in the performance schema. With this fix, file name normalization has been revisited to be more robust, and always resolve this case to "/real/path/to/filename". File instrumentation now works properly, even when a symbolic link is present in the directory name, which is the case when running tests with MTR_MEM=1, where the var directory is a link to shared memory. modified: mysql-test/suite/perfschema/t/misc.test storage/perfschema/pfs_instr.cc === modified file 'mysql-test/suite/perfschema/t/misc.test' --- a/mysql-test/suite/perfschema/t/misc.test 2010-03-16 14:19:45 +0000 +++ b/mysql-test/suite/perfschema/t/misc.test 2010-03-22 09:08:28 +0000 @@ -18,7 +18,6 @@ --source include/not_embedded.inc --source include/have_perfschema.inc ---source include/not_var_link.inc # # Bug#45496 Performance schema: assertion fails in === modified file 'storage/perfschema/pfs_instr.cc' --- a/storage/perfschema/pfs_instr.cc 2010-03-05 01:36:54 +0000 +++ b/storage/perfschema/pfs_instr.cc 2010-03-22 09:08:28 +0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2009 Sun Microsystems, Inc +/* Copyright (c) 2008, 2010 Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -770,16 +770,55 @@ find_or_create_file(PFS_thread *thread, Normalize the file name to avoid duplicates when using aliases: - absolute or relative paths - symbolic links + Names are resolved as follows: + - /real/path/to/real_file ==> same + - /path/with/link/to/real_file ==> /real/path/to/real_file + - real_file ==> /real/path/to/real_file + - ./real_file ==> /real/path/to/real_file + - /real/path/to/sym_link ==> same + - /path/with/link/to/sym_link ==> /real/path/to/sym_link + - sym_link ==> /real/path/to/sym_link + - ./sym_link ==> /real/path/to/sym_link + When the last component of a file is a symbolic link, + the last component is *not* resolved, so that all file io + operations on a link (create, read, write, delete) are counted + against the link itself, not the target file. + Resolving the name would lead to create counted against the link, + and read/write/delete counted against the target, leading to + incoherent results and instrumentation leaks. + Also note that, when creating files, this name resolution + works properly for files that do not exist (yet) on the file system. */ char buffer[FN_REFLEN]; + char dirbuffer[FN_REFLEN]; + size_t dirlen; const char *normalized_filename; int normalized_length; - /* - Ignore errors, the file may not exist. - my_realpath always provide a best effort result in buffer. - */ - (void) my_realpath(buffer, safe_filename, MYF(0)); + dirlen= dirname_length(safe_filename); + if (dirlen == 0) + { + dirbuffer[0]= FN_HOMELIB; + dirbuffer[1]= FN_LIBCHAR; + dirbuffer[2]= '\0'; + } + else + { + memcpy(dirbuffer, safe_filename, dirlen); + dirbuffer[dirlen]= '\0'; + } + + if (my_realpath(buffer, dirbuffer, MYF(0)) != 0) + { + file_lost++; + return NULL; + } + + /* Append the unresolved file name to the resolved path */ + char *ptr= buffer + strlen(buffer); + *ptr++= FN_LIBCHAR; + ptr= strmov(ptr, safe_filename + dirlen); + *ptr= '\0'; normalized_filename= buffer; normalized_length= strlen(normalized_filename); --Boundary_(ID_NqvqilEI3HvJmKXX5OMNdA) MIME-version: 1.0 Content-type: text/bzr-bundle; CHARSET=US-ASCII; name="bzr/marc.alff@stripped" Content-transfer-encoding: 7BIT Content-disposition: inline; filename="bzr/marc.alff@stripped" # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: marc.alff@stripped # target_branch: file:///Users/malff/BZR_TREE/mysql-next-mr-bugfixing-\ # 52134/ # testament_sha1: 22ae5db45e288426df4ceefbbb1f74291e3bc975 # timestamp: 2010-03-22 03:08:32 -0600 # base_revision_id: jack@stripped # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWYab8O8AA55fgEAQef///3tn lq6////6YAhOp3Lr7yerWHr2dy9qy6o7kZUpbgkkEim2INTanonplT0xGkM1DIaNqGgPU0eo9QSS CYmmiZTaTUMhoAAABoAAADQhoSg8pptJ+qZPUNDQaADEGQB6gYgSIiZER6Tygaifo0Uepp6gAeoN ANNAAHGTJoxDE0wEDAmmCMExNNNABhBJIE0mExNNJowTTRTYmmSDRoyGR6gHqDgMDIDgUbcRT5XM 1g77VWF6x/f4MZ2HcUWdtr4TJpW4n1wdHHXTnrVnAzhbsubdzqE1d9+uXtVqy7XQ0Q0X3udS7ifo vO5HfrNypCC6IRPl0mXw1rxlZ7X3OtmlP4872E5qDpTafq6WNi5Tj6w5KmZJBGu+ZpxiYThrrluL 7lzpvbw8TlXRyXx6ZnpbOs0ccmkT1uNjr1EIBhPZEMByCJfV8URqTGorh7BVRymM616ZWmnUJ7FY X7KQrNgjR23CjyWOBw5RZnRcZMXmA5Qxo1LT4LUIz33yWdY8UIsxvwvOFiutzrzjHmy0N+/HUhJb 8ARoaeiQnCo5g1FKUYiDXCSIYiqKEGZiUESdF6XBr6M9ttEYQjqXMz5TK04OAhDjeJY/GSKZd1NT 1oYP69FFO9ZnsumK0beQOiRG66LAmaeg7PHaYlDX3muG2+6txXdp4gY1jFAcnGtC5R6OCz8L3hm+ jZ3rICNVt9uOi53mOGWojRWOAMCV426mqbw0C22h5ezujoEamRWhJIGS95lGEPt2tg2DaMdPA6sQ 2NSw7I8Iy/dSPcz+5qJghkIcKfB6R/slES3wKx7ILFZvIgVBAgnfxE4jyPt1m4ku6y/AGZWDD/Lw vBGd5ItoRFy02C49075Z2KEUQdmqvFBVVbsCJls6panVLU87lnKy09Ijqo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