diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-11-25 08:00:36 -0500 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-12-05 14:13:11 -0500 |
commit | 436bb435fcbe2d52678ec7e2abc45fd1938601ce (patch) | |
tree | 80ca37e5250dcca817d1982119a318b376a77445 | |
parent | 852e22950dc47e774bb602b16f55fed42afac5fb (diff) |
cifs: make compare_sids static
..nothing outside of cifsacl.c calls it. Also fix the incorrect
comment on the function. It returns 0 when they match.
Reviewed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
-rw-r--r-- | fs/cifs/cifsacl.c | 98 | ||||
-rw-r--r-- | fs/cifs/cifsacl.h | 2 |
2 files changed, 50 insertions, 50 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 18437c5561fe..5a312eb45a92 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -224,6 +224,56 @@ sid_to_str(struct cifs_sid *sidptr, char *sidstr) | |||
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | /* | ||
228 | * if the two SIDs (roughly equivalent to a UUID for a user or group) are | ||
229 | * the same returns zero, if they do not match returns non-zero. | ||
230 | */ | ||
231 | static int | ||
232 | compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) | ||
233 | { | ||
234 | int i; | ||
235 | int num_subauth, num_sat, num_saw; | ||
236 | |||
237 | if ((!ctsid) || (!cwsid)) | ||
238 | return 1; | ||
239 | |||
240 | /* compare the revision */ | ||
241 | if (ctsid->revision != cwsid->revision) { | ||
242 | if (ctsid->revision > cwsid->revision) | ||
243 | return 1; | ||
244 | else | ||
245 | return -1; | ||
246 | } | ||
247 | |||
248 | /* compare all of the six auth values */ | ||
249 | for (i = 0; i < NUM_AUTHS; ++i) { | ||
250 | if (ctsid->authority[i] != cwsid->authority[i]) { | ||
251 | if (ctsid->authority[i] > cwsid->authority[i]) | ||
252 | return 1; | ||
253 | else | ||
254 | return -1; | ||
255 | } | ||
256 | } | ||
257 | |||
258 | /* compare all of the subauth values if any */ | ||
259 | num_sat = ctsid->num_subauth; | ||
260 | num_saw = cwsid->num_subauth; | ||
261 | num_subauth = num_sat < num_saw ? num_sat : num_saw; | ||
262 | if (num_subauth) { | ||
263 | for (i = 0; i < num_subauth; ++i) { | ||
264 | if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) { | ||
265 | if (le32_to_cpu(ctsid->sub_auth[i]) > | ||
266 | le32_to_cpu(cwsid->sub_auth[i])) | ||
267 | return 1; | ||
268 | else | ||
269 | return -1; | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | |||
274 | return 0; /* sids compare/match */ | ||
275 | } | ||
276 | |||
227 | static void | 277 | static void |
228 | cifs_copy_sid(struct cifs_sid *dst, const struct cifs_sid *src) | 278 | cifs_copy_sid(struct cifs_sid *dst, const struct cifs_sid *src) |
229 | { | 279 | { |
@@ -630,54 +680,6 @@ cifs_destroy_idmaptrees(void) | |||
630 | spin_unlock(&gidsidlock); | 680 | spin_unlock(&gidsidlock); |
631 | } | 681 | } |
632 | 682 | ||
633 | /* if the two SIDs (roughly equivalent to a UUID for a user or group) are | ||
634 | the same returns 1, if they do not match returns 0 */ | ||
635 | int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) | ||
636 | { | ||
637 | int i; | ||
638 | int num_subauth, num_sat, num_saw; | ||
639 | |||
640 | if ((!ctsid) || (!cwsid)) | ||
641 | return 1; | ||
642 | |||
643 | /* compare the revision */ | ||
644 | if (ctsid->revision != cwsid->revision) { | ||
645 | if (ctsid->revision > cwsid->revision) | ||
646 | return 1; | ||
647 | else | ||
648 | return -1; | ||
649 | } | ||
650 | |||
651 | /* compare all of the six auth values */ | ||
652 | for (i = 0; i < NUM_AUTHS; ++i) { | ||
653 | if (ctsid->authority[i] != cwsid->authority[i]) { | ||
654 | if (ctsid->authority[i] > cwsid->authority[i]) | ||
655 | return 1; | ||
656 | else | ||
657 | return -1; | ||
658 | } | ||
659 | } | ||
660 | |||
661 | /* compare all of the subauth values if any */ | ||
662 | num_sat = ctsid->num_subauth; | ||
663 | num_saw = cwsid->num_subauth; | ||
664 | num_subauth = num_sat < num_saw ? num_sat : num_saw; | ||
665 | if (num_subauth) { | ||
666 | for (i = 0; i < num_subauth; ++i) { | ||
667 | if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) { | ||
668 | if (le32_to_cpu(ctsid->sub_auth[i]) > | ||
669 | le32_to_cpu(cwsid->sub_auth[i])) | ||
670 | return 1; | ||
671 | else | ||
672 | return -1; | ||
673 | } | ||
674 | } | ||
675 | } | ||
676 | |||
677 | return 0; /* sids compare/match */ | ||
678 | } | ||
679 | |||
680 | |||
681 | /* copy ntsd, owner sid, and group sid from a security descriptor to another */ | 683 | /* copy ntsd, owner sid, and group sid from a security descriptor to another */ |
682 | static void copy_sec_desc(const struct cifs_ntsd *pntsd, | 684 | static void copy_sec_desc(const struct cifs_ntsd *pntsd, |
683 | struct cifs_ntsd *pnntsd, __u32 sidsoffset) | 685 | struct cifs_ntsd *pnntsd, __u32 sidsoffset) |
diff --git a/fs/cifs/cifsacl.h b/fs/cifs/cifsacl.h index 80e0d66a403d..18c7521273a7 100644 --- a/fs/cifs/cifsacl.h +++ b/fs/cifs/cifsacl.h | |||
@@ -98,6 +98,4 @@ extern struct key_type cifs_idmap_key_type; | |||
98 | extern const struct cred *root_cred; | 98 | extern const struct cred *root_cred; |
99 | #endif /* KERNEL */ | 99 | #endif /* KERNEL */ |
100 | 100 | ||
101 | extern int compare_sids(const struct cifs_sid *, const struct cifs_sid *); | ||
102 | |||
103 | #endif /* _CIFSACL_H */ | 101 | #endif /* _CIFSACL_H */ |