Revert "ide: skip probe if there are no devices on the port (v2)"
[linux-2.6/libata-dev.git] / fs / ceph / auth_none.c
blobb4ef6f0a6c856d42691ea55406ebfad824a6d763
2 #include "ceph_debug.h"
4 #include <linux/err.h>
5 #include <linux/module.h>
6 #include <linux/random.h>
8 #include "auth_none.h"
9 #include "auth.h"
10 #include "decode.h"
12 static void reset(struct ceph_auth_client *ac)
14 struct ceph_auth_none_info *xi = ac->private;
16 xi->starting = true;
17 xi->built_authorizer = false;
20 static void destroy(struct ceph_auth_client *ac)
22 kfree(ac->private);
23 ac->private = NULL;
26 static int is_authenticated(struct ceph_auth_client *ac)
28 struct ceph_auth_none_info *xi = ac->private;
30 return !xi->starting;
34 * the generic auth code decode the global_id, and we carry no actual
35 * authenticate state, so nothing happens here.
37 static int handle_reply(struct ceph_auth_client *ac, int result,
38 void *buf, void *end)
40 struct ceph_auth_none_info *xi = ac->private;
42 xi->starting = false;
43 return result;
47 * build an 'authorizer' with our entity_name and global_id. we can
48 * reuse a single static copy since it is identical for all services
49 * we connect to.
51 static int ceph_auth_none_create_authorizer(
52 struct ceph_auth_client *ac, int peer_type,
53 struct ceph_authorizer **a,
54 void **buf, size_t *len,
55 void **reply_buf, size_t *reply_len)
57 struct ceph_auth_none_info *ai = ac->private;
58 struct ceph_none_authorizer *au = &ai->au;
59 void *p, *end;
60 int ret;
62 if (!ai->built_authorizer) {
63 p = au->buf;
64 end = p + sizeof(au->buf);
65 ceph_encode_8(&p, 1);
66 ret = ceph_entity_name_encode(ac->name, &p, end - 8);
67 if (ret < 0)
68 goto bad;
69 ceph_decode_need(&p, end, sizeof(u64), bad2);
70 ceph_encode_64(&p, ac->global_id);
71 au->buf_len = p - (void *)au->buf;
72 ai->built_authorizer = true;
73 dout("built authorizer len %d\n", au->buf_len);
76 *a = (struct ceph_authorizer *)au;
77 *buf = au->buf;
78 *len = au->buf_len;
79 *reply_buf = au->reply_buf;
80 *reply_len = sizeof(au->reply_buf);
81 return 0;
83 bad2:
84 ret = -ERANGE;
85 bad:
86 return ret;
89 static void ceph_auth_none_destroy_authorizer(struct ceph_auth_client *ac,
90 struct ceph_authorizer *a)
92 /* nothing to do */
95 static const struct ceph_auth_client_ops ceph_auth_none_ops = {
96 .reset = reset,
97 .destroy = destroy,
98 .is_authenticated = is_authenticated,
99 .handle_reply = handle_reply,
100 .create_authorizer = ceph_auth_none_create_authorizer,
101 .destroy_authorizer = ceph_auth_none_destroy_authorizer,
104 int ceph_auth_none_init(struct ceph_auth_client *ac)
106 struct ceph_auth_none_info *xi;
108 dout("ceph_auth_none_init %p\n", ac);
109 xi = kzalloc(sizeof(*xi), GFP_NOFS);
110 if (!xi)
111 return -ENOMEM;
113 xi->starting = true;
114 xi->built_authorizer = false;
116 ac->protocol = CEPH_AUTH_NONE;
117 ac->private = xi;
118 ac->ops = &ceph_auth_none_ops;
119 return 0;