\hypertarget{g__virstor__md_8c_source}{}\doxysection{g\+\_\+virstor\+\_\+md.\+c}
\label{g__virstor__md_8c_source}\index{geom/virstor/g\_virstor\_md.c@{geom/virstor/g\_virstor\_md.c}}
\mbox{\hyperlink{g__virstor__md_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2005 Ivan Voras <ivoras@freebsd.org>}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00005}00005 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00007}00007 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00008}00008 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00009}00009 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00010}00010 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00012}00012 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00013}00013 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00014}00014 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00015}00015 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00016}00016 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00017}00017 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00018}00018 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00019}00019 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00020}00020 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00021}00021 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00022}00022 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00023}00023 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00024}00024 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00025}00025 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00026}00026 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00027}00027 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00028}00028 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00029}00029 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00030}\mbox{\hyperlink{g__virstor__md_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00030}} \mbox{\hyperlink{g__virstor__md_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00031}00031 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00033}00033 \textcolor{preprocessor}{\#include <sys/endian.h>}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00034}00034 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{g__virstor__md_8h}{geom/virstor/g\_virstor\_md.h}}>}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00036}00036 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{binstream_8h}{geom/virstor/binstream.h}}>}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00037}00037 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00038}00038 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00039}00039 \textcolor{comment}{ * Encode data from g\_virstor\_metadata structure into a endian-\/independant}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00040}00040 \textcolor{comment}{ * byte stream.}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00041}00041 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00042}00042 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00043}\mbox{\hyperlink{g__virstor__md_8c_ac94876d9c25ebc350671cb02cb57f453}{00043}} \mbox{\hyperlink{g__virstor__md_8c_ac94876d9c25ebc350671cb02cb57f453}{virstor\_metadata\_encode}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structg__virstor__metadata}{g\_virstor\_metadata}} *md, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} *\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}})}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00044}00044 \{}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00045}00045         \mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} bs;}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00046}00046 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00047}00047         \mbox{\hyperlink{binstream_8c_a34310e3fff53a416f50f8224e0cad834}{bs\_open}}(\&bs, \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00048}00048 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00049}00049         \mbox{\hyperlink{binstream_8c_abeae2577db74244a9e94ecc7f7daef34}{bs\_write\_buf}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a89a1c3d207cefb0e6219eda8d4fc4d18}{md\_magic}}, \textcolor{keyword}{sizeof}(md-\/>\mbox{\hyperlink{structg__virstor__metadata_a89a1c3d207cefb0e6219eda8d4fc4d18}{md\_magic}}));}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00050}00050         \mbox{\hyperlink{binstream_8c_abf0d72f40f346cc77b4dc011adc1a38e}{bs\_write\_u32}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_af29fb0300947a2daeccff157fe718b06}{md\_version}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00051}00051         \mbox{\hyperlink{binstream_8c_abeae2577db74244a9e94ecc7f7daef34}{bs\_write\_buf}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a854432c6c5df2e290745eb1afde09ef5}{md\_name}}, \textcolor{keyword}{sizeof}(md-\/>\mbox{\hyperlink{structg__virstor__metadata_a854432c6c5df2e290745eb1afde09ef5}{md\_name}}));}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00052}00052         \mbox{\hyperlink{binstream_8c_a51b8c8ff5832c4303922ffa9eda08bbe}{bs\_write\_u64}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a103ea533292580381c7580d768422b47}{md\_virsize}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00053}00053         \mbox{\hyperlink{binstream_8c_abf0d72f40f346cc77b4dc011adc1a38e}{bs\_write\_u32}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_abf1cf69aeff16740dc859aaf7064031d}{md\_chunk\_size}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00054}00054         \mbox{\hyperlink{binstream_8c_abf0d72f40f346cc77b4dc011adc1a38e}{bs\_write\_u32}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a687f856eec088a1b0246971ea87b34f3}{md\_id}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00055}00055         \mbox{\hyperlink{binstream_8c_ad4878308fcc606377044489082c95542}{bs\_write\_u16}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a46a5c1215427d92c2989efde58f1b856}{md\_count}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00056}00056 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00057}00057         \mbox{\hyperlink{binstream_8c_abeae2577db74244a9e94ecc7f7daef34}{bs\_write\_buf}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a04c28b3c99e63c96f502b526fac52ccf}{provider}}, \textcolor{keyword}{sizeof}(md-\/>\mbox{\hyperlink{structg__virstor__metadata_a04c28b3c99e63c96f502b526fac52ccf}{provider}}));}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00058}00058         \mbox{\hyperlink{binstream_8c_ad4878308fcc606377044489082c95542}{bs\_write\_u16}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a1e7fc8406bc6e730ebe304f197d8c18a}{no}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00059}00059         \mbox{\hyperlink{binstream_8c_a51b8c8ff5832c4303922ffa9eda08bbe}{bs\_write\_u64}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a639d81490cc84b4aef3d6a80d069d689}{provsize}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00060}00060         \mbox{\hyperlink{binstream_8c_abf0d72f40f346cc77b4dc011adc1a38e}{bs\_write\_u32}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_af52ad2322ff50f4774e0207c0a1949ce}{chunk\_count}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00061}00061         \mbox{\hyperlink{binstream_8c_abf0d72f40f346cc77b4dc011adc1a38e}{bs\_write\_u32}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_af4c097923bd3b928abd3a6d2d0ee1e7f}{chunk\_next}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00062}00062         \mbox{\hyperlink{binstream_8c_ad4878308fcc606377044489082c95542}{bs\_write\_u16}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a4eb5fea17fafea0194eeeaf907db9973}{chunk\_reserved}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00063}00063         \mbox{\hyperlink{binstream_8c_ad4878308fcc606377044489082c95542}{bs\_write\_u16}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_ab108e4b9f0b8a19ad91f05613a928f49}{flags}});}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00064}00064 \}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00065}00065 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00066}00066 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00067}00067 \textcolor{comment}{ * Decode data from endian-\/independant byte stream into g\_virstor\_metadata}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00068}00068 \textcolor{comment}{ * structure.}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00069}00069 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00070}00070 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00071}\mbox{\hyperlink{g__virstor__md_8c_aa9312b47d034e7773ab736440ed3b4a0}{00071}} \mbox{\hyperlink{g__virstor__md_8c_aa9312b47d034e7773ab736440ed3b4a0}{virstor\_metadata\_decode}}(\textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} *\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}}, \textcolor{keyword}{struct} \mbox{\hyperlink{structg__virstor__metadata}{g\_virstor\_metadata}} *md)}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00072}00072 \{}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00073}00073         \mbox{\hyperlink{structbin__stream__t}{bin\_stream\_t}} bs;}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00074}00074 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00075}00075         \mbox{\hyperlink{binstream_8c_a34310e3fff53a416f50f8224e0cad834}{bs\_open}}(\&bs, (\textcolor{keywordtype}{char} *)(\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}}));}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00076}00076 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00077}00077         \mbox{\hyperlink{binstream_8c_a32a576befe71da767c85299534312670}{bs\_read\_buf}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a89a1c3d207cefb0e6219eda8d4fc4d18}{md\_magic}}, \textcolor{keyword}{sizeof}(md-\/>\mbox{\hyperlink{structg__virstor__metadata_a89a1c3d207cefb0e6219eda8d4fc4d18}{md\_magic}}));}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00078}00078         md-\/>\mbox{\hyperlink{structg__virstor__metadata_af29fb0300947a2daeccff157fe718b06}{md\_version}} = \mbox{\hyperlink{binstream_8c_ac79b21cfa3bdf27d5da66e775c93a4cd}{bs\_read\_u32}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00079}00079         \mbox{\hyperlink{binstream_8c_a32a576befe71da767c85299534312670}{bs\_read\_buf}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a854432c6c5df2e290745eb1afde09ef5}{md\_name}}, \textcolor{keyword}{sizeof}(md-\/>\mbox{\hyperlink{structg__virstor__metadata_a854432c6c5df2e290745eb1afde09ef5}{md\_name}}));}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00080}00080         md-\/>\mbox{\hyperlink{structg__virstor__metadata_a103ea533292580381c7580d768422b47}{md\_virsize}} = \mbox{\hyperlink{binstream_8c_a3816c3b239b7062a2ceadf02ab83622b}{bs\_read\_u64}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00081}00081         md-\/>\mbox{\hyperlink{structg__virstor__metadata_abf1cf69aeff16740dc859aaf7064031d}{md\_chunk\_size}} = \mbox{\hyperlink{binstream_8c_ac79b21cfa3bdf27d5da66e775c93a4cd}{bs\_read\_u32}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00082}00082         md-\/>\mbox{\hyperlink{structg__virstor__metadata_a687f856eec088a1b0246971ea87b34f3}{md\_id}} = \mbox{\hyperlink{binstream_8c_ac79b21cfa3bdf27d5da66e775c93a4cd}{bs\_read\_u32}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00083}00083         md-\/>\mbox{\hyperlink{structg__virstor__metadata_a46a5c1215427d92c2989efde58f1b856}{md\_count}} = \mbox{\hyperlink{binstream_8c_ab83a737abf0b88fc3fbdcd7d9256e86f}{bs\_read\_u16}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00084}00084 }
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00085}00085         \mbox{\hyperlink{binstream_8c_a32a576befe71da767c85299534312670}{bs\_read\_buf}}(\&bs, md-\/>\mbox{\hyperlink{structg__virstor__metadata_a04c28b3c99e63c96f502b526fac52ccf}{provider}}, \textcolor{keyword}{sizeof}(md-\/>\mbox{\hyperlink{structg__virstor__metadata_a04c28b3c99e63c96f502b526fac52ccf}{provider}}));}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00086}00086         md-\/>\mbox{\hyperlink{structg__virstor__metadata_a1e7fc8406bc6e730ebe304f197d8c18a}{no}} = \mbox{\hyperlink{binstream_8c_ab83a737abf0b88fc3fbdcd7d9256e86f}{bs\_read\_u16}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00087}00087         md-\/>\mbox{\hyperlink{structg__virstor__metadata_a639d81490cc84b4aef3d6a80d069d689}{provsize}} = \mbox{\hyperlink{binstream_8c_a3816c3b239b7062a2ceadf02ab83622b}{bs\_read\_u64}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00088}00088         md-\/>\mbox{\hyperlink{structg__virstor__metadata_af52ad2322ff50f4774e0207c0a1949ce}{chunk\_count}} = \mbox{\hyperlink{binstream_8c_ac79b21cfa3bdf27d5da66e775c93a4cd}{bs\_read\_u32}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00089}00089         md-\/>\mbox{\hyperlink{structg__virstor__metadata_af4c097923bd3b928abd3a6d2d0ee1e7f}{chunk\_next}} = \mbox{\hyperlink{binstream_8c_ac79b21cfa3bdf27d5da66e775c93a4cd}{bs\_read\_u32}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00090}00090         md-\/>\mbox{\hyperlink{structg__virstor__metadata_a4eb5fea17fafea0194eeeaf907db9973}{chunk\_reserved}} = \mbox{\hyperlink{binstream_8c_ab83a737abf0b88fc3fbdcd7d9256e86f}{bs\_read\_u16}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00091}00091         md-\/>\mbox{\hyperlink{structg__virstor__metadata_ab108e4b9f0b8a19ad91f05613a928f49}{flags}} = \mbox{\hyperlink{binstream_8c_ab83a737abf0b88fc3fbdcd7d9256e86f}{bs\_read\_u16}}(\&bs);}
\DoxyCodeLine{\Hypertarget{g__virstor__md_8c_source_l00092}00092 \}}

\end{DoxyCode}
