Lines Matching refs:buf

28 	struct tty_audit_buf *buf;
30 buf = kmalloc(sizeof(*buf), GFP_KERNEL);
31 if (!buf)
33 buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
34 if (!buf->data)
36 atomic_set(&buf->count, 1);
37 mutex_init(&buf->mutex);
38 buf->major = major;
39 buf->minor = minor;
40 buf->icanon = icanon;
41 buf->valid = 0;
42 return buf;
45 kfree(buf);
50 static void tty_audit_buf_free(struct tty_audit_buf *buf)
52 WARN_ON(buf->valid != 0);
53 kfree(buf->data);
54 kfree(buf);
57 static void tty_audit_buf_put(struct tty_audit_buf *buf)
59 if (atomic_dec_and_test(&buf->count))
60 tty_audit_buf_free(buf);
89 * Generate an audit message from the contents of @buf, which is owned by
90 * @tsk with @loginuid. @buf->mutex must be locked.
94 struct tty_audit_buf *buf)
96 if (buf->valid == 0)
99 buf->valid = 0;
102 tty_audit_log("tty", tsk, loginuid, sessionid, buf->major, buf->minor,
103 buf->data, buf->valid);
104 buf->valid = 0;
110 * Generate an audit message from the contents of @buf, which is owned by
111 * the current task. @buf->mutex must be locked.
113 static void tty_audit_buf_push_current(struct tty_audit_buf *buf)
117 tty_audit_buf_push(current, auid, sessionid, buf);
128 struct tty_audit_buf *buf;
131 buf = current->signal->tty_audit_buf;
134 if (!buf)
137 mutex_lock(&buf->mutex);
138 tty_audit_buf_push_current(buf);
139 mutex_unlock(&buf->mutex);
141 tty_audit_buf_put(buf);
161 struct tty_audit_buf *buf;
166 buf = current->signal->tty_audit_buf;
167 if (buf)
168 atomic_inc(&buf->count);
173 if (buf) {
174 mutex_lock(&buf->mutex);
175 if (buf->major == major && buf->minor == minor)
176 tty_audit_buf_push_current(buf);
177 mutex_unlock(&buf->mutex);
178 tty_audit_buf_put(buf);
204 struct tty_audit_buf *buf = ERR_PTR(-EPERM);
211 buf = tsk->signal->tty_audit_buf;
212 if (buf)
213 atomic_inc(&buf->count);
221 if (!buf || IS_ERR(buf))
222 return PTR_ERR(buf);
224 mutex_lock(&buf->mutex);
225 tty_audit_buf_push(tsk, loginuid, sessionid, buf);
226 mutex_unlock(&buf->mutex);
228 tty_audit_buf_put(buf);
241 struct tty_audit_buf *buf, *buf2;
243 buf = NULL;
248 buf = current->signal->tty_audit_buf;
249 if (buf) {
250 atomic_inc(&buf->count);
266 buf = current->signal->tty_audit_buf;
267 if (!buf) {
269 buf = buf2;
272 atomic_inc(&buf->count);
278 return buf;
289 struct tty_audit_buf *buf;
299 buf = tty_audit_buf_get(tty);
300 if (!buf)
303 mutex_lock(&buf->mutex);
306 if (buf->major != major || buf->minor != minor
307 || buf->icanon != tty->icanon) {
308 tty_audit_buf_push_current(buf);
309 buf->major = major;
310 buf->minor = minor;
311 buf->icanon = tty->icanon;
316 run = N_TTY_BUF_SIZE - buf->valid;
319 memcpy(buf->data + buf->valid, data, run);
320 buf->valid += run;
323 if (buf->valid == N_TTY_BUF_SIZE)
324 tty_audit_buf_push_current(buf);
326 mutex_unlock(&buf->mutex);
327 tty_audit_buf_put(buf);
337 struct tty_audit_buf *buf;
344 buf = current->signal->tty_audit_buf;
345 if (buf)
346 atomic_inc(&buf->count);
349 if (buf) {
354 mutex_lock(&buf->mutex);
355 if (buf->major == major && buf->minor == minor)
356 tty_audit_buf_push_current(buf);
357 mutex_unlock(&buf->mutex);
358 tty_audit_buf_put(buf);