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