Lines Matching defs:buf

25 	struct tty_audit_buf *buf;
27 buf = current->signal->tty_audit_buf;
28 WARN_ON(buf == ERR_PTR(-ESRCH));
29 return buf;
34 struct tty_audit_buf *buf;
36 buf = kzalloc(sizeof(*buf), GFP_KERNEL);
37 if (!buf)
40 buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
41 if (!buf->data)
44 mutex_init(&buf->mutex);
46 return buf;
49 kfree(buf);
54 static void tty_audit_buf_free(struct tty_audit_buf *buf)
56 WARN_ON(buf->valid != 0);
57 kfree(buf->data);
58 kfree(buf);
88 * Generate an audit message from the contents of @buf, which is owned by
89 * the current task. @buf->mutex must be locked.
91 static void tty_audit_buf_push(struct tty_audit_buf *buf)
93 if (buf->valid == 0)
96 buf->valid = 0;
99 tty_audit_log("tty", buf->dev, buf->data, buf->valid);
100 buf->valid = 0;
114 struct tty_audit_buf *buf;
116 buf = xchg(&current->signal->tty_audit_buf, ERR_PTR(-ESRCH));
117 if (!buf)
120 tty_audit_buf_push(buf);
121 tty_audit_buf_free(buf);
156 struct tty_audit_buf *buf;
161 buf = tty_audit_buf_ref();
162 if (!IS_ERR_OR_NULL(buf)) {
163 mutex_lock(&buf->mutex);
164 tty_audit_buf_push(buf);
165 mutex_unlock(&buf->mutex);
179 struct tty_audit_buf *buf;
181 buf = tty_audit_buf_ref();
182 if (buf)
183 return buf;
185 buf = tty_audit_buf_alloc();
186 if (buf == NULL) {
192 if (cmpxchg(&current->signal->tty_audit_buf, NULL, buf) != NULL)
193 tty_audit_buf_free(buf);
205 struct tty_audit_buf *buf;
224 buf = tty_audit_buf_get();
225 if (IS_ERR_OR_NULL(buf))
228 mutex_lock(&buf->mutex);
230 if (buf->dev != dev || buf->icanon != icanon) {
231 tty_audit_buf_push(buf);
232 buf->dev = dev;
233 buf->icanon = icanon;
238 run = N_TTY_BUF_SIZE - buf->valid;
241 memcpy(buf->data + buf->valid, data, run);
242 buf->valid += run;
245 if (buf->valid == N_TTY_BUF_SIZE)
246 tty_audit_buf_push(buf);
248 mutex_unlock(&buf->mutex);