1313 *
1414 * Author : Stephen Smalley, <[email protected] > 1515 */
16+
1617#ifndef _SS_CONTEXT_H_
1718#define _SS_CONTEXT_H_
1819
@@ -28,17 +29,18 @@ struct context {
2829 u32 user ;
2930 u32 role ;
3031 u32 type ;
31- u32 len ; /* length of string in bytes */
32+ u32 len ; /* length of string in bytes */
3233 struct mls_range range ;
33- char * str ; /* string representation if context cannot be mapped. */
34+ char * str ; /* string representation if context cannot be mapped. */
3435};
3536
3637static inline void mls_context_init (struct context * c )
3738{
3839 memset (& c -> range , 0 , sizeof (c -> range ));
3940}
4041
41- static inline int mls_context_cpy (struct context * dst , const struct context * src )
42+ static inline int mls_context_cpy (struct context * dst ,
43+ const struct context * src )
4244{
4345 int rc ;
4446
@@ -58,7 +60,8 @@ static inline int mls_context_cpy(struct context *dst, const struct context *src
5860/*
5961 * Sets both levels in the MLS range of 'dst' to the low level of 'src'.
6062 */
61- static inline int mls_context_cpy_low (struct context * dst , const struct context * src )
63+ static inline int mls_context_cpy_low (struct context * dst ,
64+ const struct context * src )
6265{
6366 int rc ;
6467
@@ -78,7 +81,8 @@ static inline int mls_context_cpy_low(struct context *dst, const struct context
7881/*
7982 * Sets both levels in the MLS range of 'dst' to the high level of 'src'.
8083 */
81- static inline int mls_context_cpy_high (struct context * dst , const struct context * src )
84+ static inline int mls_context_cpy_high (struct context * dst ,
85+ const struct context * src )
8286{
8387 int rc ;
8488
@@ -95,9 +99,9 @@ static inline int mls_context_cpy_high(struct context *dst, const struct context
9599 return rc ;
96100}
97101
98-
99102static inline int mls_context_glblub (struct context * dst ,
100- const struct context * c1 , const struct context * c2 )
103+ const struct context * c1 ,
104+ const struct context * c2 )
101105{
102106 struct mls_range * dr = & dst -> range ;
103107 const struct mls_range * r1 = & c1 -> range , * r2 = & c2 -> range ;
@@ -114,21 +118,22 @@ static inline int mls_context_glblub(struct context *dst,
114118 /* Take the least of the high */
115119 dr -> level [1 ].sens = min (r1 -> level [1 ].sens , r2 -> level [1 ].sens );
116120
117- rc = ebitmap_and (& dr -> level [0 ].cat ,
118- & r1 -> level [ 0 ]. cat , & r2 -> level [0 ].cat );
121+ rc = ebitmap_and (& dr -> level [0 ].cat , & r1 -> level [ 0 ]. cat ,
122+ & r2 -> level [0 ].cat );
119123 if (rc )
120124 goto out ;
121125
122- rc = ebitmap_and (& dr -> level [1 ].cat ,
123- & r1 -> level [ 1 ]. cat , & r2 -> level [1 ].cat );
126+ rc = ebitmap_and (& dr -> level [1 ].cat , & r1 -> level [ 1 ]. cat ,
127+ & r2 -> level [1 ].cat );
124128 if (rc )
125129 goto out ;
126130
127131out :
128132 return rc ;
129133}
130134
131- static inline int mls_context_cmp (const struct context * c1 , const struct context * c2 )
135+ static inline int mls_context_cmp (const struct context * c1 ,
136+ const struct context * c2 )
132137{
133138 return ((c1 -> range .level [0 ].sens == c2 -> range .level [0 ].sens ) &&
134139 ebitmap_cmp (& c1 -> range .level [0 ].cat , & c2 -> range .level [0 ].cat ) &&
@@ -183,19 +188,17 @@ static inline void context_destroy(struct context *c)
183188 mls_context_destroy (c );
184189}
185190
186- static inline int context_cmp (const struct context * c1 , const struct context * c2 )
191+ static inline int context_cmp (const struct context * c1 ,
192+ const struct context * c2 )
187193{
188194 if (c1 -> len && c2 -> len )
189195 return (c1 -> len == c2 -> len && !strcmp (c1 -> str , c2 -> str ));
190196 if (c1 -> len || c2 -> len )
191197 return 0 ;
192- return ((c1 -> user == c2 -> user ) &&
193- (c1 -> role == c2 -> role ) &&
194- (c1 -> type == c2 -> type ) &&
195- mls_context_cmp (c1 , c2 ));
198+ return ((c1 -> user == c2 -> user ) && (c1 -> role == c2 -> role ) &&
199+ (c1 -> type == c2 -> type ) && mls_context_cmp (c1 , c2 ));
196200}
197201
198202u32 context_compute_hash (const struct context * c );
199203
200- #endif /* _SS_CONTEXT_H_ */
201-
204+ #endif /* _SS_CONTEXT_H_ */
0 commit comments