\hypertarget{g__label__disk__ident_8c_source}{}\doxysection{g\+\_\+label\+\_\+disk\+\_\+ident.\+c}
\label{g__label__disk__ident_8c_source}\index{geom/label/g\_label\_disk\_ident.c@{geom/label/g\_label\_disk\_ident.c}}
\mbox{\hyperlink{g__label__disk__ident_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2012 Ivan Voras <ivoras@FreeBSD.org>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00005}00005 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00007}00007 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00008}00008 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00009}00009 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00010}00010 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00012}00012 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00013}00013 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00014}00014 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00015}00015 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00016}00016 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00017}00017 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00018}00018 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00019}00019 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00020}00020 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00021}00021 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00022}00022 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00023}00023 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00024}00024 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00025}00025 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00026}00026 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00027}00027 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00028}00028 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00029}00029 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00030}\mbox{\hyperlink{g__label__disk__ident_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00030}} \mbox{\hyperlink{g__label__disk__ident_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00031}00031 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00033}00033 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/malloc.h>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00036}00036 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{geom_8h}{geom/geom.h}}>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{geom__disk_8h}{geom/geom\_disk.h}}>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{g__label_8h}{geom/label/g\_label.h}}>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{g__multipath_8h}{geom/multipath/g\_multipath.h}}>}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00041}00041 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00042}\mbox{\hyperlink{g__label__disk__ident_8c_ab7641428505f9f188f5c824f44fd988d}{00042}} \textcolor{keyword}{static} \textcolor{keywordtype}{char}* \mbox{\hyperlink{g__label__disk__ident_8c_ab7641428505f9f188f5c824f44fd988d}{classes\_pass}}[] = \{ \mbox{\hyperlink{geom__disk_8h_aac7ca1f61277efbe4ebd68536dba04ba}{G\_DISK\_CLASS\_NAME}}, \mbox{\hyperlink{g__multipath_8h_a14a8e22fa7a7b9fb426260504ee48a7c}{G\_MULTIPATH\_CLASS\_NAME}},}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00043}00043     NULL \};}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00044}00044 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00045}00045 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00046}\mbox{\hyperlink{g__label__disk__ident_8c_a35dcc1205546a5ff29efd3c9d37759b8}{00046}} \mbox{\hyperlink{g__label__disk__ident_8c_a35dcc1205546a5ff29efd3c9d37759b8}{g\_label\_disk\_ident\_taste}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structg__consumer}{g\_consumer}} *\mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}, \textcolor{keywordtype}{char} *label, \textcolor{keywordtype}{size\_t} size)}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00047}00047 \{}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00048}00048         \textcolor{keyword}{struct }\mbox{\hyperlink{structg__class}{g\_class}} *cls;}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00049}00049         \textcolor{keywordtype}{char} ident[DISK\_IDENT\_SIZE];}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00050}00050         \textcolor{keywordtype}{int} ident\_len, found, i;}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00051}00051 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00052}00052         \mbox{\hyperlink{geom_8h_a71a3365bd3741226d2c0d1abada9fde7}{g\_topology\_assert\_not}}();}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00053}00053         label[0] = \textcolor{charliteral}{'\(\backslash\)0'};}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00054}00054 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00055}00055         cls = \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}-\/>\mbox{\hyperlink{structg__consumer_a6435d5aec0376e995dce3131fd3beb52}{provider}}-\/>\mbox{\hyperlink{structg__provider_afe5c92b8a2a9e4cdf1cab6daa96923c1}{geom}}-\/>\mbox{\hyperlink{structg__geom_a502c2ffb3c41ad9d30d9875c678f5404}{class}};}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00056}00056 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00057}00057         \textcolor{comment}{/* }}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00058}00058 \textcolor{comment}{         * Get the GEOM::ident string, and construct a label in the format}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00059}00059 \textcolor{comment}{         * "{}CLASS\_NAME-\/ident"{}}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00060}00060 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00061}00061         ident\_len = \textcolor{keyword}{sizeof}(ident);}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00062}00062         \textcolor{keywordflow}{if} (\mbox{\hyperlink{geom_8h_a63ec0c10c4635c215416171e7e804d17}{g\_io\_getattr}}(\textcolor{stringliteral}{"{}GEOM::ident"{}}, \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}, \&ident\_len, ident) == 0) \{}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00063}00063                 \textcolor{keywordflow}{if} (ident\_len == 0 || ident[0] == \textcolor{charliteral}{'\(\backslash\)0'})}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00064}00064                         \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00065}00065                 \textcolor{keywordflow}{for} (i = 0, found = 0; \mbox{\hyperlink{g__label__disk__ident_8c_ab7641428505f9f188f5c824f44fd988d}{classes\_pass}}[i] != NULL; i++)}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00066}00066                         \textcolor{keywordflow}{if} (strcmp(\mbox{\hyperlink{g__label__disk__ident_8c_ab7641428505f9f188f5c824f44fd988d}{classes\_pass}}[i], cls-\/>\mbox{\hyperlink{structg__class_a66bf8381cf0afbf7ccdebfa6b90a4a96}{name}}) == 0) \{}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00067}00067                                 found = 1;}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00068}00068                                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00069}00069                         \}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00070}00070                 \textcolor{keywordflow}{if} (!found)}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00071}00071                         \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00072}00072                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00073}00073 \textcolor{comment}{                 * We can safely ignore the result of snprintf(): the label}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00074}00074 \textcolor{comment}{                 * will simply be truncated, which at most is only annoying.}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00075}00075 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00076}00076                 (void)snprintf(label, size, \textcolor{stringliteral}{"{}\%s-\/\%s"{}}, cls-\/>\mbox{\hyperlink{structg__class_a66bf8381cf0afbf7ccdebfa6b90a4a96}{name}}, ident);}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00077}00077         \}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00078}00078 \}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00079}00079 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00080}\mbox{\hyperlink{g__label_8h_a0314b7a0dd527ba2cacc12f1d49e003d}{00080}} \textcolor{keyword}{struct }\mbox{\hyperlink{structg__label__desc}{g\_label\_desc}} \mbox{\hyperlink{g__label__disk__ident_8c_a0314b7a0dd527ba2cacc12f1d49e003d}{g\_label\_disk\_ident}} = \{}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00081}00081         .\mbox{\hyperlink{structg__label__desc_a5c38840bd2d369860b22fb12362fb4de}{ld\_taste}} = \mbox{\hyperlink{g__label__disk__ident_8c_a35dcc1205546a5ff29efd3c9d37759b8}{g\_label\_disk\_ident\_taste}},}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00082}00082         .ld\_dirprefix = \textcolor{stringliteral}{"{}diskid/"{}},}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00083}00083         .ld\_enabled = 1}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00084}00084 \};}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00085}00085 }
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00086}\mbox{\hyperlink{g__label__disk__ident_8c_ab23fb721ae60fe61d0aadc371663f996}{00086}} \mbox{\hyperlink{g__label__disk__ident_8c_ab23fb721ae60fe61d0aadc371663f996}{G\_LABEL\_INIT}}(disk\_ident, \mbox{\hyperlink{g__label__disk__ident_8c_a0314b7a0dd527ba2cacc12f1d49e003d}{g\_label\_disk\_ident}}, \textcolor{stringliteral}{"{}Create device nodes for drives "{}}}
\DoxyCodeLine{\Hypertarget{g__label__disk__ident_8c_source_l00087}00087     \textcolor{stringliteral}{"{}which export a disk identification string"{}});}

\end{DoxyCode}
