1 /*
2 Copyright (C) 2005-2007 MySQL AB
3 All rights reserved. Use is subject to license terms.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8
9 This program is also distributed with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have included with MySQL.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 #include <signaldata/SignalData.hpp>
27 #include "diskpage.hpp"
28 #include <NdbOut.hpp>
29 #include <version.h>
30 #include <time.h>
31
32 void
init(File_type ft,Uint32 node_id,Uint32 version,Uint32 now)33 File_formats::Zero_page_header::init(File_type ft,
34 Uint32 node_id,
35 Uint32 version,
36 Uint32 now)
37 {
38 memcpy(m_magic, "NDBDISK", 8);
39 m_byte_order = 0x12345678;
40 m_page_size = File_formats::NDB_PAGE_SIZE;
41 m_ndb_version = version;
42 m_node_id = node_id;
43 m_file_type = ft;
44 m_time = now;
45 }
46
47 int
validate(File_type ft,Uint32 node_id,Uint32 version,Uint32 now)48 File_formats::Zero_page_header::validate(File_type ft,
49 Uint32 node_id,
50 Uint32 version,
51 Uint32 now)
52 {
53 return 0; // TODO Check header
54 }
55
56 NdbOut&
operator <<(NdbOut & out,const File_formats::Zero_page_header & obj)57 operator<<(NdbOut& out, const File_formats::Zero_page_header& obj)
58 {
59 char buf[256];
60 out << "page size: " << obj.m_page_size << endl;
61 out << "ndb version: " << obj.m_ndb_version << ", " <<
62 ndbGetVersionString(obj.m_ndb_version, 0, 0, buf, sizeof(buf)) << endl;
63 out << "ndb node id: " << obj.m_node_id << endl;
64 out << "file type: " << obj.m_file_type << endl;
65 out << "time: " << obj.m_time << ", "
66 << ctime((time_t*)&obj.m_time)<< endl;
67 return out;
68 }
69
70 NdbOut&
operator <<(NdbOut & out,const File_formats::Datafile::Zero_page & obj)71 operator<<(NdbOut& out, const File_formats::Datafile::Zero_page& obj)
72 {
73 out << obj.m_page_header << endl;
74 out << "m_file_no: " << obj.m_file_no << endl;
75 out << "m_tablespace_id: " << obj.m_tablespace_id << endl;
76 out << "m_tablespace_version: " << obj.m_tablespace_version << endl;
77 out << "m_data_pages: " << obj.m_data_pages << endl;
78 out << "m_extent_pages: " << obj.m_extent_pages << endl;
79 out << "m_extent_size: " << obj.m_extent_size << endl;
80 out << "m_extent_count: " << obj.m_extent_count << endl;
81 out << "m_extent_headers_per_page: " << obj.m_extent_headers_per_page << endl;
82 out << "m_extent_header_words: " << obj.m_extent_header_words << endl;
83 out << "m_extent_header_bits_per_page: " << obj.m_extent_header_bits_per_page << endl;
84
85 return out;
86 }
87
88 NdbOut&
operator <<(NdbOut & out,const File_formats::Undofile::Zero_page & obj)89 operator<<(NdbOut& out, const File_formats::Undofile::Zero_page& obj)
90 {
91 out << obj.m_page_header << endl;
92 out << "m_file_id: " << obj.m_file_id << endl;
93 out << "m_logfile_group_id: " << obj.m_logfile_group_id << endl;
94 out << "m_logfile_group_version: " << obj.m_logfile_group_version << endl;
95 out << "m_undo_pages: " << obj.m_undo_pages << endl;
96
97 return out;
98 }
99
100