1 /*===========================================================================
2  *
3  *                            PUBLIC DOMAIN NOTICE
4  *               National Center for Biotechnology Information
5  *
6  *  This software/database is a "United States Government Work" under the
7  *  terms of the United States Copyright Act.  It was written as part of
8  *  the author's official duties as a United States Government employee and
9  *  thus cannot be copyrighted.  This software/database is freely available
10  *  to the public for use. The National Library of Medicine and the U.S.
11  *  Government have not placed any restriction on its use or reproduction.
12  *
13  *  Although all reasonable efforts have been taken to ensure the accuracy
14  *  and reliability of the software and data, the NLM and the U.S.
15  *  Government do not and cannot warrant the performance or results that
16  *  may be obtained by using this software or data. The NLM and the U.S.
17  *  Government disclaim all warranties, express or implied, including
18  *  warranties of performance, merchantability or fitness for any particular
19  *  purpose.
20  *
21  *  Please cite the author in any work or product based on this material.
22  *
23  * ===========================================================================
24  *
25  */
26 #include <klib/rc.h>
27 #include <klib/out.h>
28 #include <klib/text.h>
29 
30 #include <xfs/perm.h>
31 
32 #include "zehr.h"
33 
34 #include <sysalloc.h>
35 
36 #include <ctype.h>  /* isspace () */
37 #include <os-native.h>
38 
39 
40 /*)))
41  |||
42  +++    XFSPerm and all about
43  |||
44 (((*/
45 
46 static char _sUserDefault [ XFS_SIZE_128 ];
47 static char _sGroupDefault [ XFS_SIZE_128 ];
48 static char _sOtherDefault [ XFS_SIZE_128 ];
49 
50 /*))))))
51  //////  XFSAuth
52 ((((((*/
53 
54 /*))
55  ((     Structures itself
56   ))
57  ((*/
58 struct XFSAuth {
59     char * Name;
60     bool NameDefaulted;
61     bool CanRead;
62     bool CanWrite;
63     bool CanExecute;
64 };
65 
66 static
67 rc_t CC
_AuthDispose(const struct XFSAuth * self)68 _AuthDispose ( const struct XFSAuth * self )
69 {
70     struct XFSAuth * Auth = ( struct XFSAuth * ) self;
71 
72     if ( Auth != NULL ) {
73         if ( ! Auth -> NameDefaulted ) {
74             if ( Auth -> Name != NULL ) {
75                 free ( Auth -> Name );
76             }
77         }
78         else {
79             Auth -> Name = NULL;
80         }
81 
82         free ( Auth );
83     }
84 
85     return 0;
86 }   /* _AuthDispose () */
87 
88 static
89 rc_t CC
_AuthMake(const char * Name,bool NameDefaulted,bool CanRead,bool CanWrite,bool CanExecute,const struct XFSAuth ** Auth)90 _AuthMake (
91             const char * Name,
92             bool NameDefaulted,
93             bool CanRead,
94             bool CanWrite,
95             bool CanExecute,
96             const struct XFSAuth ** Auth
97 )
98 {
99     struct XFSAuth * TheAuth;
100 
101     if ( Name == NULL || Auth == NULL ) {
102         return XFS_RC ( rcNull );
103     }
104     * Auth = NULL;
105 
106     TheAuth = calloc ( 1, sizeof ( struct XFSAuth ) );
107     if ( TheAuth == NULL ) {
108         return XFS_RC ( rcExhausted );
109     }
110 
111     if ( ! NameDefaulted ) {
112         TheAuth -> Name = string_dup_measure ( Name, NULL );
113         if ( TheAuth -> Name == NULL ) {
114             _AuthDispose ( TheAuth );
115 
116             return XFS_RC ( rcExhausted );
117         }
118     }
119     else {
120         TheAuth -> Name = ( char * ) Name;
121     }
122 
123     TheAuth -> NameDefaulted = NameDefaulted;
124     TheAuth -> CanRead = CanRead;
125     TheAuth -> CanWrite = CanWrite;
126     TheAuth -> CanExecute = CanExecute;
127 
128     * Auth = TheAuth;
129 
130     return 0;
131 }   /* _AuthMake () */
132 
133 /*))))))
134  //////  XFSPerm
135 ((((((*/
136 /*))
137  ((     Structures itself : now it is just a three pointers, but
138   ))    I will make BStree in the case of something complex
139  ((*/
140 struct XFSPerm {
141     const struct XFSAuth * U;
142     const struct XFSAuth * G;
143     const struct XFSAuth * O;
144 };
145 
146 /*))
147  ((     Here we are.
148   ))
149  ((*/
150 static
151 const char * CC
_Perm_SkipTrail(const char * Start)152 _Perm_SkipTrail ( const char * Start )
153 {
154     if ( Start != NULL ) {
155         while ( true ) {
156             if ( * Start == 0 ) {
157                 return NULL;
158             }
159             if ( ! isspace ( * Start ) ) {
160                 return Start;
161             }
162 
163             Start ++;
164         }
165     }
166 
167     return NULL;
168 }   /* _Perm_SkipTrail () */
169 
170 static
171 rc_t CC
_Perm_ReadValue(const char * Start,const char ** Next,char ** Value)172 _Perm_ReadValue (
173                 const char * Start,
174                 const char ** Next,
175                 char ** Value
176 )
177 {
178     const char * End;
179 
180     if ( Value == NULL || Next == NULL ) {
181         return XFS_RC ( rcNull );
182     }
183     * Next = NULL;
184     * Value = NULL;
185 
186     if ( Start == NULL ) {
187         return 0;
188     }
189 
190     End = Start;
191 
192     while ( * End != 0 && * End != ':' ) { End ++; }
193 
194     if ( 0 == End - Start ) {
195         if ( * End == ':' ) {
196             * Next = End + 1;
197         }
198         return 0;
199     }
200 
201     * Value = string_dup ( Start, End - Start );
202     if ( * Value == NULL ) {
203         return XFS_RC ( rcExhausted );
204     }
205 
206     if ( * End == ':' ) {
207         * Next = End + 1;
208     }
209 
210     return 0;
211 }   /* _Perm_ReadString () */
212 
213 static
214 rc_t CC
_Perm_StringParse(const char * PermAsString,char ** Perm,char ** User,char ** Group,char ** Other)215 _Perm_StringParse (
216             const char * PermAsString,
217             char ** Perm,
218             char ** User,
219             char ** Group,
220             char ** Other
221 )
222 {
223     rc_t RCt;
224     const char * pStart, * pEnd;
225     char ch;
226     int llp;
227     const int _PLN = 9;
228 
229     RCt = 0;
230     pStart = pEnd = NULL;
231     ch = 0;
232     llp = 0;
233 
234         /*  We should get at least permissions
235          */
236     if ( PermAsString == NULL || Perm == NULL ) {
237         return XFS_RC ( rcNull );
238     }
239     * Perm = NULL;
240 
241     if ( User != NULL )  { * User = NULL;  }
242     if ( Group != NULL ) { * Group = NULL; }
243     if ( Other != NULL ) { * Other = NULL; }
244 
245     pStart = ( char * ) PermAsString;
246 
247 
248     pStart = _Perm_SkipTrail ( pStart );
249     if ( pStart == NULL ) {
250         return XFS_RC ( rcInvalid );
251     }
252 
253         /*  second we are reading permissions 9 characters;
254          */
255     for ( llp = 0; llp < _PLN ; llp ++ ) {
256         ch = * ( pStart + llp );
257         if ( ch == 0 ) {
258             return XFS_RC ( rcInvalid );
259         }
260 
261         if ( ch != '-' ) {
262             if ( llp % 3 == 0 && ch != 'r' ) {
263                 return XFS_RC ( rcInvalid );
264             }
265             if ( llp % 3 == 1 && ch != 'w' ) {
266                 return XFS_RC ( rcInvalid );
267             }
268             if ( llp % 3 == 2 && ch != 'x' ) {
269                 return XFS_RC ( rcInvalid );
270             }
271         }
272     }
273 
274     * Perm = string_dup ( pStart, _PLN );
275     if ( * Perm == NULL ) {
276         return XFS_RC ( rcExhausted );
277     }
278 
279     pStart += _PLN;
280 
281         /*  skipping to the next entry
282          */
283     pStart = _Perm_SkipTrail ( pStart );
284     if ( pStart == NULL ) {
285         return 0;
286     }
287 
288         /*  third we are reading user
289          */
290     RCt = _Perm_ReadValue ( pStart, & pEnd, User );
291     if ( RCt == 0 && pEnd != NULL ) {
292         RCt = _Perm_ReadValue ( pEnd, & pStart, Group );
293         if ( RCt == 0 && pStart != 0 ) {
294             RCt = _Perm_ReadValue ( pStart, & pEnd, Other );
295         }
296     }
297 
298     return RCt;
299 }   /* _Perm_StringParse () */
300 
301 static
302 rc_t CC
_MakeAuth(XFSAType Type,const char * Name,const char * Perm,const struct XFSAuth ** Auth)303 _MakeAuth (
304         XFSAType Type,
305         const char * Name,
306         const char * Perm,
307         const struct XFSAuth ** Auth
308 )
309 {
310     const char * RName;
311     bool DF, CR, CW, CE;
312 
313     RName = NULL;
314     DF = CR = CW = CE = false;
315 
316     if ( Auth == NULL || Perm == NULL ) {
317         return XFS_RC ( rcNull );
318     }
319     * Auth = NULL;
320 
321     DF = Name == NULL;
322     RName = DF ? XFSPermDefaultName ( Type ) : Name;
323 
324     CR = * ( Perm + ( Type * 3 ) + 0 ) == 'r';
325     CW = * ( Perm + ( Type * 3 ) + 1 ) == 'w';
326     CE = * ( Perm + ( Type * 3 ) + 2 ) == 'x';
327 
328     return _AuthMake ( RName, DF, CR, CW, CE, Auth );
329 }   /* _MakeAuth () */
330 
331 LIB_EXPORT
332 rc_t CC
XFSPermMake(const char * PermAsString,const struct XFSPerm ** Permissions)333 XFSPermMake (
334             const char * PermAsString,
335             const struct XFSPerm ** Permissions
336 )
337 {
338     rc_t RCt;
339     struct XFSPerm * Perm;
340     char * SPerm, * User, * Group, * Other;
341 
342     RCt = 0;
343     Perm = NULL;
344     SPerm = User = Group = Other = NULL;
345 
346     if ( PermAsString == NULL || Permissions == NULL ) {
347         return XFS_RC ( rcNull );
348     }
349     * Permissions = NULL;
350 
351     Perm = calloc ( 1, sizeof ( struct XFSPerm ) );
352     if ( Perm != NULL ) {
353         RCt = _Perm_StringParse (
354                             PermAsString,
355                             & SPerm,
356                             & User,
357                             & Group,
358                             & Other
359                         );
360         if ( RCt == 0 ) {
361             RCt = _MakeAuth ( kxfsUser, User, SPerm, & ( Perm -> U ) );
362             if ( RCt == 0 ) {
363                 RCt = _MakeAuth (
364                                 kxfsGroup,
365                                 Group,
366                                 SPerm,
367                                 & ( Perm -> G )
368                                 );
369                 if ( RCt == 0 ) {
370                     RCt = _MakeAuth (
371                                 kxfsOther,
372                                 Other,
373                                 SPerm,
374                                 & ( Perm -> O )
375                                 );
376                 }
377             }
378         }
379     }
380     else {
381         RCt = XFS_RC ( rcExhausted );
382     }
383 
384     if ( SPerm != NULL ) {
385         free ( SPerm );
386     }
387     if ( User != NULL ) {
388         free ( User );
389     }
390     if ( Group != NULL ) {
391         free ( Group );
392     }
393     if ( Other != NULL ) {
394         free ( Other );
395     }
396 
397     if ( RCt != 0 ) {
398         XFSPermDispose ( Perm );
399     }
400     else {
401         * Permissions = Perm;
402     }
403 
404     return RCt;
405 }   /* XFSPermMake () */
406 
407 LIB_EXPORT
408 rc_t CC
XFSPermDispose(const struct XFSPerm * self)409 XFSPermDispose ( const struct XFSPerm * self )
410 {
411     rc_t RCt;
412     struct XFSPerm * Perm;
413 
414     RCt = 0;
415 
416     Perm = ( struct XFSPerm * ) self;
417 
418     if ( Perm != NULL ) {
419         if ( Perm -> U != NULL ) {
420             _AuthDispose ( Perm -> U );
421             Perm -> U = NULL;
422         }
423 
424         if ( Perm -> G != NULL ) {
425             _AuthDispose ( Perm -> G );
426             Perm -> G = NULL;
427         }
428 
429         if ( Perm -> O != NULL ) {
430             _AuthDispose ( Perm -> O );
431             Perm -> O = NULL;
432         }
433 
434         free ( Perm );
435     }
436 
437     return RCt;
438 }   /* XFSPermDispose () */
439 
440 /*)))
441  ///    Defaults
442 (((*/
443 static
444 rc_t CC
_Perm_SetDefault(const char * Default,char * Buffer,size_t BufferSize)445 _Perm_SetDefault (
446                 const char * Default,
447                 char * Buffer,
448                 size_t BufferSize
449 )
450 {
451     size_t CYP;
452 
453     if ( Buffer == NULL || BufferSize == 0 ) {
454         return XFS_RC ( rcNull );
455     }
456 
457     if ( Default == NULL ) {
458         * Buffer = 0;
459         return 0;
460     }
461 
462     CYP = string_size ( Default );
463 
464     if ( BufferSize <= CYP ) {
465         return XFS_RC ( rcTooBig );
466     }
467 
468         /* he-he ... should we check if it happens ? */
469     string_copy ( Buffer, BufferSize, Default, CYP );
470 
471     return 0;
472 }   /* _Perm_SetDefault () */
473 
474 LIB_EXPORT
475 const struct XFSAuth * CC
XFSPermAuth(const struct XFSPerm * self,XFSAType Type)476 XFSPermAuth ( const struct XFSPerm * self, XFSAType Type )
477 {
478     if ( self != NULL ) {
479         switch ( Type ) {
480             case kxfsUser  : return self -> U;
481             case kxfsGroup : return self -> G;
482             case kxfsOther : return self -> O;
483         }
484     }
485     return NULL;
486 }   /* XFSPermAuth () */
487 
488 LIB_EXPORT
489 rc_t CC
XFSPermToString(const struct XFSPerm * self,char * Buffer,size_t BufferSize)490 XFSPermToString (
491             const struct XFSPerm * self,
492             char * Buffer,
493             size_t BufferSize
494 )
495 {
496     if ( self == NULL || Buffer == NULL || BufferSize == 0 ) {
497         return XFS_RC ( rcNull );
498     }
499     * Buffer = 0;
500 
501     if ( self -> U == NULL || self -> G == NULL || self -> O == NULL ) {
502         return XFS_RC ( rcInvalid );
503     }
504 
505     strcat ( Buffer, ( self -> U -> CanRead )    ? "r" : "-" );
506     strcat ( Buffer, ( self -> U -> CanWrite )   ? "w" : "-" );
507     strcat ( Buffer, ( self -> U -> CanExecute ) ? "x" : "-" );
508     strcat ( Buffer, ( self -> G -> CanRead )    ? "r" : "-" );
509     strcat ( Buffer, ( self -> G -> CanWrite )   ? "w" : "-" );
510     strcat ( Buffer, ( self -> G -> CanExecute ) ? "x" : "-" );
511     strcat ( Buffer, ( self -> O -> CanRead )    ? "r" : "-" );
512     strcat ( Buffer, ( self -> O -> CanWrite )   ? "w" : "-" );
513     strcat ( Buffer, ( self -> O -> CanExecute ) ? "x" : "-" );
514 
515     if (    ! self -> U -> NameDefaulted
516         ||  ! self -> G -> NameDefaulted
517         ||  ! self -> O -> NameDefaulted ) {
518 
519         strcat ( Buffer, " " );
520 
521         if ( ! self -> U -> NameDefaulted ) {
522             strcat ( Buffer, self -> U -> Name );
523         }
524 
525         if (    ! self -> G -> NameDefaulted
526             ||  ! self -> O -> NameDefaulted ) {
527             strcat ( Buffer, ":" );
528         }
529 
530         if ( ! self -> G -> NameDefaulted ) {
531             strcat ( Buffer, self -> G -> Name );
532         }
533 
534         if ( ! self -> O -> NameDefaulted ) {
535             strcat ( Buffer, ":" );
536 
537             strcat ( Buffer, self -> O -> Name );
538         }
539     }
540 
541     return 0;
542 }   /* XFSPermToString () */
543 
544 LIB_EXPORT
545 const char * CC
XFSPermDefaultName(XFSAType Type)546 XFSPermDefaultName ( XFSAType Type )
547 {
548     switch ( Type ) {
549         case kxfsUser :  return _sUserDefault;
550         case kxfsGroup : return _sGroupDefault;
551         case kxfsOther : return _sOtherDefault;
552     }
553     return NULL;
554 }   /* XFSPermDefaultName () */
555 
556 LIB_EXPORT
557 rc_t CC
XFSPermSetDefaultName(XFSAType Type,const char * Name)558 XFSPermSetDefaultName ( XFSAType Type, const char * Name )
559 {
560     switch ( Type ) {
561         case kxfsUser :
562                 return _Perm_SetDefault (
563                                         Name,
564                                         _sUserDefault,
565                                         sizeof ( _sUserDefault )
566                                         );
567         case kxfsGroup :
568                 return _Perm_SetDefault (
569                                         Name,
570                                         _sGroupDefault,
571                                         sizeof ( _sGroupDefault )
572                                         );
573         case kxfsOther :
574                 return _Perm_SetDefault (
575                                         Name,
576                                         _sOtherDefault,
577                                         sizeof ( _sOtherDefault )
578                                         );
579     }
580     return XFS_RC ( rcUnknown );
581 }   /* XFSPermSetDefaultName () */
582 
583 LIB_EXPORT
584 const char * CC
XFSAuthName(const struct XFSAuth * self)585 XFSAuthName ( const struct XFSAuth * self )
586 {
587     return self == NULL ? NULL : ( self -> Name );
588 }   /* XFSAuthName () */
589 
590 LIB_EXPORT
591 bool CC
XFSAuthCanRead(const struct XFSAuth * self)592 XFSAuthCanRead ( const struct XFSAuth * self )
593 {
594     return self == NULL ? false : ( self -> CanRead );
595 }   /* XFSAuthCanRead () */
596 
597 LIB_EXPORT
598 bool CC
XFSAuthCanWrite(const struct XFSAuth * self)599 XFSAuthCanWrite ( const struct XFSAuth * self )
600 {
601     return self == NULL ? false : ( self -> CanWrite );
602 }   /* XFSAuthCanWrite () */
603 
604 LIB_EXPORT
605 bool CC
XFSAuthCanExecute(const struct XFSAuth * self)606 XFSAuthCanExecute ( const struct XFSAuth * self )
607 {
608     return self == NULL ? false : ( self -> CanExecute );
609 }   /* XFSAuthCanExecute () */
610 
611 /*))))))
612  //////  Misc
613 ((((((*/
614 
615 LIB_EXPORT
616 rc_t CC
XFSPermToNum(const char * Perm,uint32_t * Num)617 XFSPermToNum ( const char * Perm, uint32_t * Num )
618 {
619     rc_t RCt;
620     uint32_t xNum;
621     const struct XFSPerm * xPerm;
622     const struct XFSAuth * xAuth;
623 
624     RCt = 0;
625     xNum = 0;
626     xPerm = NULL;
627     xAuth = NULL;
628 
629     if ( Num == NULL ) {
630         return XFS_RC ( rcNull );
631     }
632     * Num = 0;
633 
634     if ( Perm == NULL ) {
635         return XFS_RC ( rcNull );
636     }
637 
638     RCt = XFSPermMake ( Perm, & xPerm );
639     if ( RCt == 0 ) {
640         xAuth = XFSPermAuth ( xPerm, kxfsUser );
641         if ( xAuth != NULL ) {
642             if ( XFSAuthCanRead    ( xAuth ) ) { xNum |= 0400; }
643             if ( XFSAuthCanWrite   ( xAuth ) ) { xNum |= 0200; }
644             if ( XFSAuthCanExecute ( xAuth ) ) { xNum |= 0100; }
645         }
646 
647         xAuth = XFSPermAuth ( xPerm, kxfsGroup );
648         if ( xAuth != NULL ) {
649             if ( XFSAuthCanRead    ( xAuth ) ) { xNum |= 040; }
650             if ( XFSAuthCanWrite   ( xAuth ) ) { xNum |= 020; }
651             if ( XFSAuthCanExecute ( xAuth ) ) { xNum |= 010; }
652         }
653 
654         xAuth = XFSPermAuth ( xPerm, kxfsOther );
655         if ( xAuth != NULL ) {
656             if ( XFSAuthCanRead    ( xAuth ) ) { xNum |= 04; }
657             if ( XFSAuthCanWrite   ( xAuth ) ) { xNum |= 02; }
658             if ( XFSAuthCanExecute ( xAuth ) ) { xNum |= 01; }
659         }
660 
661         * Num = xNum;
662 
663         XFSPermDispose ( xPerm );
664     }
665 
666     return RCt;
667 }   /* XFSPermToNum () */
668 
669 
670 LIB_EXPORT
671 rc_t CC
XFSPermToChar(uint32_t Num,char * Buf,size_t BufSize)672 XFSPermToChar ( uint32_t Num, char * Buf, size_t BufSize )
673 {
674     rc_t RCt;
675 
676     RCt = 0;
677 
678     if ( Buf == NULL ) {
679         return XFS_RC ( rcNull );
680     }
681 
682     if ( BufSize <= 10 ) {
683         return XFS_RC ( rcInvalid );
684     }
685 
686     * Buf = 0;
687 
688         /* owner */
689     Buf [ 0 ] = ( Num & 0400 ) == 0400 ? 'r' : '-';
690     Buf [ 1 ] = ( Num & 0200 ) == 0200 ? 'w' : '-';
691     Buf [ 2 ] = ( Num & 0100 ) == 0100 ? 'x' : '-';
692         /* group */
693     Buf [ 3 ] = ( Num & 040 ) == 040 ? 'r' : '-';
694     Buf [ 4 ] = ( Num & 020 ) == 020 ? 'w' : '-';
695     Buf [ 5 ] = ( Num & 010 ) == 010 ? 'x' : '-';
696         /* others */
697     Buf [ 6 ] = ( Num & 04 ) == 04 ? 'r' : '-';
698     Buf [ 7 ] = ( Num & 02 ) == 02 ? 'w' : '-';
699     Buf [ 8 ] = ( Num & 01 ) == 01 ? 'x' : '-';
700 
701         /* internet users */
702     Buf [ 9 ] = 0;
703 
704     return RCt;
705 }   /* XFSPermToChar () */
706 
707 /*))))))
708  //////  Defaults ... sorry, hardcoding those
709 ((((((*/
710 static const char * _DefROPermForContainer = "r-xr-xr-x";
711 static const char * _DefROPermForNode = "r--r--r--";
712 static uint32_t _DefROPermForContainerNum = 0;
713 static uint32_t _DefROPermForNodeNum = 0;
714 
715 LIB_EXPORT
716 const char * CC
XFSPermRODefContChar()717 XFSPermRODefContChar ()
718 {
719     return _DefROPermForContainer;
720 }   /* XFSPermRODefContChar () */
721 
722 LIB_EXPORT
723 const char * CC
XFSPermRODefNodeChar()724 XFSPermRODefNodeChar ()
725 {
726     return _DefROPermForNode;
727 }   /* XFSPermRODefNodeChar () */
728 
729 LIB_EXPORT
730 uint32_t CC
XFSPermRODefContNum()731 XFSPermRODefContNum ()
732 {
733     uint32_t T;
734 
735     if ( _DefROPermForContainerNum == 0 ) {
736         XFSPermToNum ( XFSPermRODefContChar (), & T );
737         _DefROPermForContainerNum = T;
738     }
739 
740     return _DefROPermForContainerNum;
741 }   /* XFSPermRODefContNum () */
742 
743 LIB_EXPORT
744 uint32_t CC
XFSPermRODefNodeNum()745 XFSPermRODefNodeNum ()
746 {
747     uint32_t T;
748 
749     if ( _DefROPermForNodeNum == 0 ) {
750         XFSPermToNum ( XFSPermRODefNodeChar (), & T );
751         _DefROPermForNodeNum = T;
752     }
753 
754     return _DefROPermForNodeNum;
755 }   /* XFSPermRODefNodeNum () */
756 
757 /*))))))
758  //////  Defaults ... sorry, hardcoding those
759 ((((((*/
760 static const char * _DefRWPermForContainer = "rwxr-xr-x";
761 static const char * _DefRWPermForNode = "rw-r--r--";
762 static uint32_t _DefRWPermForContainerNum = 0;
763 static uint32_t _DefRWPermForNodeNum = 0;
764 
765 LIB_EXPORT
766 const char * CC
XFSPermRWDefContChar()767 XFSPermRWDefContChar ()
768 {
769     return _DefRWPermForContainer;
770 }   /* XFSPermRWDefContChar () */
771 
772 LIB_EXPORT
773 const char * CC
XFSPermRWDefNodeChar()774 XFSPermRWDefNodeChar ()
775 {
776     return _DefRWPermForNode;
777 }   /* XFSPermRWDefNodeChar () */
778 
779 LIB_EXPORT
780 uint32_t CC
XFSPermRWDefContNum()781 XFSPermRWDefContNum ()
782 {
783     uint32_t T;
784 
785     if ( _DefRWPermForContainerNum == 0 ) {
786         XFSPermToNum ( XFSPermRWDefContChar (), & T );
787         _DefRWPermForContainerNum = T;
788     }
789 
790     return _DefRWPermForContainerNum;
791 }   /* XFSPermRWDefContNum () */
792 
793 LIB_EXPORT
794 uint32_t CC
XFSPermRWDefNodeNum()795 XFSPermRWDefNodeNum ()
796 {
797     uint32_t T;
798 
799     if ( _DefRWPermForNodeNum == 0 ) {
800         XFSPermToNum ( XFSPermRWDefNodeChar (), & T );
801         _DefRWPermForNodeNum = T;
802     }
803 
804     return _DefRWPermForNodeNum;
805 }   /* XFSPermRWDefNodeNum () */
806