summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@sun.com>2009-11-03 13:58:28 +0400
committerSergey Vojtovich <svoj@sun.com>2009-11-03 13:58:28 +0400
commit41ebf9751f448a2a719fae5b62784a59ef512598 (patch)
tree335b56a3e9e559c9b3621a3d76694edeff7f060a
parentb703edd747a08a0bcd33d7f8f2be4298206f98b9 (diff)
downloadmariadb-git-41ebf9751f448a2a719fae5b62784a59ef512598.tar.gz
Applying InnoDB plugin snashot
Detailed revision comments: r6044 | pekka | 2009-10-06 17:44:54 +0300 (Tue, 06 Oct 2009) | 5 lines branches/zip: Add os_file_is_same() function for Hot Backup (inside ifdef UNIV_HOTBACKUP). This is part of the fix for Issue #186. Note! The Windows implementation is incomplete.
-rw-r--r--storage/innodb_plugin/include/os0file.h15
-rw-r--r--storage/innodb_plugin/os/os0file.c54
2 files changed, 69 insertions, 0 deletions
diff --git a/storage/innodb_plugin/include/os0file.h b/storage/innodb_plugin/include/os0file.h
index 8535ef092c3..20c3be1b228 100644
--- a/storage/innodb_plugin/include/os0file.h
+++ b/storage/innodb_plugin/include/os0file.h
@@ -260,6 +260,21 @@ library of Netware does not expose the delete-on-close flag.
FILE*
os_file_create_tmpfile(void);
/*========================*/
+#else
+/***********************************************************************//**
+Check if two paths refer to the same file or directory. On Unix-like systems
+the files are considered equal if they have the same inode (as returned by
+stat(2) system call).
+@return 1 if files are the same, 0 if they are not the same, and -1 on error
+(error number can be retrieved with os_file_get_last_error) */
+UNIV_INTERN
+int
+os_file_is_same(
+/*============*/
+ const char* pathname1, /*!< in: pathname of a file
+ or directory */
+ const char* pathname2); /*!< in: pathname of a file
+ or directory */
#endif /* !UNIV_HOTBACKUP */
/***********************************************************************//**
The os_file_opendir() function opens a directory stream corresponding to the
diff --git a/storage/innodb_plugin/os/os0file.c b/storage/innodb_plugin/os/os0file.c
index a1d3bad2add..f084789011b 100644
--- a/storage/innodb_plugin/os/os0file.c
+++ b/storage/innodb_plugin/os/os0file.c
@@ -612,6 +612,60 @@ os_file_create_tmpfile(void)
return(file);
}
+#else
+/***********************************************************************//**
+Check if two paths refer to the same file or directory. On Unix-like systems
+the files are considered equal if they have the same inode (as returned by
+stat(2) system call).
+@return 1 if files are the same, 0 if they are not the same, and -1 on error
+(error number can be retrieved with os_file_get_last_error) */
+UNIV_INTERN
+int
+os_file_is_same(
+/*============*/
+ const char* pathname1, /*!< in: pathname of a file
+ or directory */
+ const char* pathname2) /*!< in: pathname of a file
+ or directory */
+{
+#ifdef __WIN__
+ /* NOTE This Windows implementation is incomplete; we need to
+ check inodes of the files as we do on Unix-like systems.
+ */
+ if (0 == strcmp(pathname1, pathname2)) {
+ /* paths are the same */
+ return (1);
+ } else {
+ /* path are different */
+ return (0);
+ }
+#else
+ struct stat fileinfo1, fileinfo2;
+ int rcode;
+
+ if (0 == strcmp(pathname1, pathname2)) {
+ /* paths are the same */
+ return (1);
+ }
+
+ /* get inodes with stat(2)*/
+ rcode = stat(pathname1, &fileinfo1);
+ if (rcode < 0) {
+ /* failure */
+ os_file_handle_error_no_exit(pathname1, "os_file_is_same");
+ return (-1);
+ }
+ rcode = stat(pathname2, &fileinfo2);
+ if (rcode < 0) {
+ /* failure */
+ os_file_handle_error_no_exit(pathname2, "os_file_is_same");
+ return (-1);
+ }
+
+ return (fileinfo1.st_ino == fileinfo2.st_ino);
+#endif
+}
+
#endif /* !UNIV_HOTBACKUP */
/***********************************************************************//**