Add dummy override files
[lttng-modules.git] / ltt-debugfs-abi.c
1 /*
2 * ltt-debugfs-abi.c
3 *
4 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * LTTng debugfs ABI
7 *
8 * Mimic system calls for:
9 * - session creation, returns a file descriptor or failure.
10 * - channel creation, returns a file descriptor or failure.
11 * - Operates on a session file descriptor
12 * - Takes all channel options as parameters.
13 * - stream get, returns a file descriptor or failure.
14 * - Operates on a channel file descriptor.
15 * - stream notifier get, returns a file descriptor or failure.
16 * - Operates on a channel file descriptor.
17 * - event creation, returns a file descriptor or failure.
18 * - Operates on a channel file descriptor
19 * - Takes an event name as parameter
20 * - Takes an instrumentation source as parameter
21 * - e.g. tracepoints, dynamic_probes...
22 * - Takes instrumentation source specific arguments.
23 *
24 * Dual LGPL v2.1/GPL v2 license.
25 */
26
27 #include <linux/module.h>
28 #include <linux/debugfs.h>
29 #include <linux/proc_fs.h>
30 #include <linux/anon_inodes.h>
31 #include <linux/file.h>
32 #include <linux/uaccess.h>
33 #include <linux/slab.h>
34 #include "wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */
35 #include "wrapper/ringbuffer/vfs.h"
36 #include "wrapper/poll.h"
37 #include "ltt-debugfs-abi.h"
38 #include "ltt-events.h"
39 #include "ltt-tracer.h"
40
41 /*
42 * This is LTTng's own personal way to create a system call as an external
43 * module. We use ioctl() on /sys/kernel/debug/lttng.
44 */
45
46 static struct dentry *lttng_dentry;
47 static struct proc_dir_entry *lttng_proc_dentry;
48 static const struct file_operations lttng_fops;
49 static const struct file_operations lttng_session_fops;
50 static const struct file_operations lttng_channel_fops;
51 static const struct file_operations lttng_metadata_fops;
52 static const struct file_operations lttng_event_fops;
53
54 /*
55 * Teardown management: opened file descriptors keep a refcount on the module,
56 * so it can only exit when all file descriptors are closed.
57 */
58
59 enum channel_type {
60 PER_CPU_CHANNEL,
61 METADATA_CHANNEL,
62 };
63
64 static
65 int lttng_abi_create_session(void)
66 {
67 struct ltt_session *session;
68 struct file *session_file;
69 int session_fd, ret;
70
71 session = ltt_session_create();
72 if (!session)
73 return -ENOMEM;
74 session_fd = get_unused_fd();
75 if (session_fd < 0) {
76 ret = session_fd;
77 goto fd_error;
78 }
79 session_file = anon_inode_getfile("[lttng_session]",
80 &lttng_session_fops,
81 session, O_RDWR);
82 if (IS_ERR(session_file)) {
83 ret = PTR_ERR(session_file);
84 goto file_error;
85 }
86 session->file = session_file;
87 fd_install(session_fd, session_file);
88 return session_fd;
89
90 file_error:
91 put_unused_fd(session_fd);
92 fd_error:
93 ltt_session_destroy(session);
94 return ret;
95 }
96
97 static
98 int lttng_abi_tracepoint_list(void)
99 {
100 struct file *tracepoint_list_file;
101 int file_fd, ret;
102
103 file_fd = get_unused_fd();
104 if (file_fd < 0) {
105 ret = file_fd;
106 goto fd_error;
107 }
108
109 tracepoint_list_file = anon_inode_getfile("[lttng_session]",
110 &lttng_tracepoint_list_fops,
111 NULL, O_RDWR);
112 if (IS_ERR(tracepoint_list_file)) {
113 ret = PTR_ERR(tracepoint_list_file);
114 goto file_error;
115 }
116 ret = lttng_tracepoint_list_fops.open(NULL, tracepoint_list_file);
117 if (ret < 0)
118 goto open_error;
119 fd_install(file_fd, tracepoint_list_file);
120 if (file_fd < 0) {
121 ret = file_fd;
122 goto fd_error;
123 }
124 return file_fd;
125
126 open_error:
127 fput(tracepoint_list_file);
128 file_error:
129 put_unused_fd(file_fd);
130 fd_error:
131 return ret;
132 }
133
134 static
135 long lttng_abi_tracer_version(struct file *file,
136 struct lttng_kernel_tracer_version __user *uversion_param)
137 {
138 struct lttng_kernel_tracer_version v;
139
140 v.version = LTTNG_VERSION;
141 v.patchlevel = LTTNG_PATCHLEVEL;
142 v.sublevel = LTTNG_SUBLEVEL;
143
144 if (copy_to_user(uversion_param, &v, sizeof(v)))
145 return -EFAULT;
146 return 0;
147 }
148
149 static
150 long lttng_abi_add_context(struct file *file,
151 struct lttng_kernel_context __user *ucontext_param,
152 struct lttng_ctx **ctx, struct ltt_session *session)
153 {
154 struct lttng_kernel_context context_param;
155
156 if (session->been_active)
157 return -EPERM;
158
159 if (copy_from_user(&context_param, ucontext_param, sizeof(context_param)))
160 return -EFAULT;
161
162 switch (context_param.ctx) {
163 case LTTNG_KERNEL_CONTEXT_PID:
164 return lttng_add_pid_to_ctx(ctx);
165 case LTTNG_KERNEL_CONTEXT_PRIO:
166 return lttng_add_prio_to_ctx(ctx);
167 case LTTNG_KERNEL_CONTEXT_NICE:
168 return lttng_add_nice_to_ctx(ctx);
169 case LTTNG_KERNEL_CONTEXT_VPID:
170 return lttng_add_vpid_to_ctx(ctx);
171 case LTTNG_KERNEL_CONTEXT_TID:
172 return lttng_add_tid_to_ctx(ctx);
173 case LTTNG_KERNEL_CONTEXT_VTID:
174 return lttng_add_vtid_to_ctx(ctx);
175 case LTTNG_KERNEL_CONTEXT_PPID:
176 return lttng_add_ppid_to_ctx(ctx);
177 case LTTNG_KERNEL_CONTEXT_VPPID:
178 return lttng_add_vppid_to_ctx(ctx);
179 case LTTNG_KERNEL_CONTEXT_PERF_COUNTER:
180 context_param.u.perf_counter.name[LTTNG_SYM_NAME_LEN - 1] = '\0';
181 return lttng_add_perf_counter_to_ctx(context_param.u.perf_counter.type,
182 context_param.u.perf_counter.config,
183 context_param.u.perf_counter.name,
184 ctx);
185 case LTTNG_KERNEL_CONTEXT_COMM:
186 return lttng_add_comm_to_ctx(ctx);
187 default:
188 return -EINVAL;
189 }
190 }
191
192 /**
193 * lttng_ioctl - lttng syscall through ioctl
194 *
195 * @file: the file
196 * @cmd: the command
197 * @arg: command arg
198 *
199 * This ioctl implements lttng commands:
200 * LTTNG_KERNEL_SESSION
201 * Returns a LTTng trace session file descriptor
202 * LTTNG_KERNEL_TRACER_VERSION
203 * Returns the LTTng kernel tracer version
204 * LTTNG_KERNEL_TRACEPOINT_LIST
205 * Returns a file descriptor listing available tracepoints
206 * LTTNG_KERNEL_WAIT_QUIESCENT
207 * Returns after all previously running probes have completed
208 *
209 * The returned session will be deleted when its file descriptor is closed.
210 */
211 static
212 long lttng_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
213 {
214 switch (cmd) {
215 case LTTNG_KERNEL_SESSION:
216 return lttng_abi_create_session();
217 case LTTNG_KERNEL_TRACER_VERSION:
218 return lttng_abi_tracer_version(file,
219 (struct lttng_kernel_tracer_version __user *) arg);
220 case LTTNG_KERNEL_TRACEPOINT_LIST:
221 return lttng_abi_tracepoint_list();
222 case LTTNG_KERNEL_WAIT_QUIESCENT:
223 synchronize_trace();
224 return 0;
225 case LTTNG_KERNEL_CALIBRATE:
226 {
227 struct lttng_kernel_calibrate __user *ucalibrate =
228 (struct lttng_kernel_calibrate __user *) arg;
229 struct lttng_kernel_calibrate calibrate;
230 int ret;
231
232 if (copy_from_user(&calibrate, ucalibrate, sizeof(calibrate)))
233 return -EFAULT;
234 ret = lttng_calibrate(&calibrate);
235 if (copy_to_user(ucalibrate, &calibrate, sizeof(calibrate)))
236 return -EFAULT;
237 return ret;
238 }
239 default:
240 return -ENOIOCTLCMD;
241 }
242 }
243
244 static const struct file_operations lttng_fops = {
245 .owner = THIS_MODULE,
246 .unlocked_ioctl = lttng_ioctl,
247 #ifdef CONFIG_COMPAT
248 .compat_ioctl = lttng_ioctl,
249 #endif
250 };
251
252 /*
253 * We tolerate no failure in this function (if one happens, we print a dmesg
254 * error, but cannot return any error, because the channel information is
255 * invariant.
256 */
257 static
258 void lttng_metadata_create_events(struct file *channel_file)
259 {
260 struct ltt_channel *channel = channel_file->private_data;
261 static struct lttng_kernel_event metadata_params = {
262 .instrumentation = LTTNG_KERNEL_TRACEPOINT,
263 .name = "lttng_metadata",
264 };
265 struct ltt_event *event;
266
267 /*
268 * We tolerate no failure path after event creation. It will stay
269 * invariant for the rest of the session.
270 */
271 event = ltt_event_create(channel, &metadata_params, NULL, NULL);
272 if (!event) {
273 goto create_error;
274 }
275 return;
276
277 create_error:
278 WARN_ON(1);
279 return; /* not allowed to return error */
280 }
281
282 static
283 int lttng_abi_create_channel(struct file *session_file,
284 struct lttng_kernel_channel __user *uchan_param,
285 enum channel_type channel_type)
286 {
287 struct ltt_session *session = session_file->private_data;
288 const struct file_operations *fops = NULL;
289 const char *transport_name;
290 struct ltt_channel *chan;
291 struct file *chan_file;
292 struct lttng_kernel_channel chan_param;
293 int chan_fd;
294 int ret = 0;
295
296 if (copy_from_user(&chan_param, uchan_param, sizeof(chan_param)))
297 return -EFAULT;
298 chan_fd = get_unused_fd();
299 if (chan_fd < 0) {
300 ret = chan_fd;
301 goto fd_error;
302 }
303 switch (channel_type) {
304 case PER_CPU_CHANNEL:
305 fops = &lttng_channel_fops;
306 break;
307 case METADATA_CHANNEL:
308 fops = &lttng_metadata_fops;
309 break;
310 }
311
312 chan_file = anon_inode_getfile("[lttng_channel]",
313 fops,
314 NULL, O_RDWR);
315 if (IS_ERR(chan_file)) {
316 ret = PTR_ERR(chan_file);
317 goto file_error;
318 }
319 switch (channel_type) {
320 case PER_CPU_CHANNEL:
321 if (chan_param.output == LTTNG_KERNEL_SPLICE) {
322 transport_name = chan_param.overwrite ?
323 "relay-overwrite" : "relay-discard";
324 } else if (chan_param.output == LTTNG_KERNEL_MMAP) {
325 transport_name = chan_param.overwrite ?
326 "relay-overwrite-mmap" : "relay-discard-mmap";
327 } else {
328 return -EINVAL;
329 }
330 break;
331 case METADATA_CHANNEL:
332 if (chan_param.output == LTTNG_KERNEL_SPLICE)
333 transport_name = "relay-metadata";
334 else if (chan_param.output == LTTNG_KERNEL_MMAP)
335 transport_name = "relay-metadata-mmap";
336 else
337 return -EINVAL;
338 break;
339 default:
340 transport_name = "<unknown>";
341 break;
342 }
343 /*
344 * We tolerate no failure path after channel creation. It will stay
345 * invariant for the rest of the session.
346 */
347 chan = ltt_channel_create(session, transport_name, NULL,
348 chan_param.subbuf_size,
349 chan_param.num_subbuf,
350 chan_param.switch_timer_interval,
351 chan_param.read_timer_interval);
352 if (!chan) {
353 ret = -EINVAL;
354 goto chan_error;
355 }
356 chan->file = chan_file;
357 chan_file->private_data = chan;
358 fd_install(chan_fd, chan_file);
359 if (channel_type == METADATA_CHANNEL) {
360 session->metadata = chan;
361 lttng_metadata_create_events(chan_file);
362 }
363
364 /* The channel created holds a reference on the session */
365 atomic_long_inc(&session_file->f_count);
366
367 return chan_fd;
368
369 chan_error:
370 fput(chan_file);
371 file_error:
372 put_unused_fd(chan_fd);
373 fd_error:
374 return ret;
375 }
376
377 /**
378 * lttng_session_ioctl - lttng session fd ioctl
379 *
380 * @file: the file
381 * @cmd: the command
382 * @arg: command arg
383 *
384 * This ioctl implements lttng commands:
385 * LTTNG_KERNEL_CHANNEL
386 * Returns a LTTng channel file descriptor
387 * LTTNG_KERNEL_ENABLE
388 * Enables tracing for a session (weak enable)
389 * LTTNG_KERNEL_DISABLE
390 * Disables tracing for a session (strong disable)
391 * LTTNG_KERNEL_METADATA
392 * Returns a LTTng metadata file descriptor
393 *
394 * The returned channel will be deleted when its file descriptor is closed.
395 */
396 static
397 long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
398 {
399 struct ltt_session *session = file->private_data;
400
401 switch (cmd) {
402 case LTTNG_KERNEL_CHANNEL:
403 return lttng_abi_create_channel(file,
404 (struct lttng_kernel_channel __user *) arg,
405 PER_CPU_CHANNEL);
406 case LTTNG_KERNEL_SESSION_START:
407 case LTTNG_KERNEL_ENABLE:
408 return ltt_session_enable(session);
409 case LTTNG_KERNEL_SESSION_STOP:
410 case LTTNG_KERNEL_DISABLE:
411 return ltt_session_disable(session);
412 case LTTNG_KERNEL_METADATA:
413 return lttng_abi_create_channel(file,
414 (struct lttng_kernel_channel __user *) arg,
415 METADATA_CHANNEL);
416 default:
417 return -ENOIOCTLCMD;
418 }
419 }
420
421 /*
422 * Called when the last file reference is dropped.
423 *
424 * Big fat note: channels and events are invariant for the whole session after
425 * their creation. So this session destruction also destroys all channel and
426 * event structures specific to this session (they are not destroyed when their
427 * individual file is released).
428 */
429 static
430 int lttng_session_release(struct inode *inode, struct file *file)
431 {
432 struct ltt_session *session = file->private_data;
433
434 if (session)
435 ltt_session_destroy(session);
436 return 0;
437 }
438
439 static const struct file_operations lttng_session_fops = {
440 .owner = THIS_MODULE,
441 .release = lttng_session_release,
442 .unlocked_ioctl = lttng_session_ioctl,
443 #ifdef CONFIG_COMPAT
444 .compat_ioctl = lttng_session_ioctl,
445 #endif
446 };
447
448 static
449 int lttng_abi_open_stream(struct file *channel_file)
450 {
451 struct ltt_channel *channel = channel_file->private_data;
452 struct lib_ring_buffer *buf;
453 int stream_fd, ret;
454 struct file *stream_file;
455
456 buf = channel->ops->buffer_read_open(channel->chan);
457 if (!buf)
458 return -ENOENT;
459
460 stream_fd = get_unused_fd();
461 if (stream_fd < 0) {
462 ret = stream_fd;
463 goto fd_error;
464 }
465 stream_file = anon_inode_getfile("[lttng_stream]",
466 &lib_ring_buffer_file_operations,
467 buf, O_RDWR);
468 if (IS_ERR(stream_file)) {
469 ret = PTR_ERR(stream_file);
470 goto file_error;
471 }
472 /*
473 * OPEN_FMODE, called within anon_inode_getfile/alloc_file, don't honor
474 * FMODE_LSEEK, FMODE_PREAD nor FMODE_PWRITE. We need to read from this
475 * file descriptor, so we set FMODE_PREAD here.
476 */
477 stream_file->f_mode |= FMODE_PREAD;
478 fd_install(stream_fd, stream_file);
479 /*
480 * The stream holds a reference to the channel within the generic ring
481 * buffer library, so no need to hold a refcount on the channel and
482 * session files here.
483 */
484 return stream_fd;
485
486 file_error:
487 put_unused_fd(stream_fd);
488 fd_error:
489 channel->ops->buffer_read_close(buf);
490 return ret;
491 }
492
493 static
494 int lttng_abi_create_event(struct file *channel_file,
495 struct lttng_kernel_event __user *uevent_param)
496 {
497 struct ltt_channel *channel = channel_file->private_data;
498 struct ltt_event *event;
499 struct lttng_kernel_event event_param;
500 int event_fd, ret;
501 struct file *event_file;
502
503 if (copy_from_user(&event_param, uevent_param, sizeof(event_param)))
504 return -EFAULT;
505 event_param.name[LTTNG_SYM_NAME_LEN - 1] = '\0';
506 switch (event_param.instrumentation) {
507 case LTTNG_KERNEL_KRETPROBE:
508 event_param.u.kretprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
509 break;
510 case LTTNG_KERNEL_KPROBE:
511 event_param.u.kprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
512 break;
513 case LTTNG_KERNEL_FUNCTION:
514 event_param.u.ftrace.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
515 break;
516 default:
517 break;
518 }
519 switch (event_param.instrumentation) {
520 default:
521 event_fd = get_unused_fd();
522 if (event_fd < 0) {
523 ret = event_fd;
524 goto fd_error;
525 }
526 event_file = anon_inode_getfile("[lttng_event]",
527 &lttng_event_fops,
528 NULL, O_RDWR);
529 if (IS_ERR(event_file)) {
530 ret = PTR_ERR(event_file);
531 goto file_error;
532 }
533 /*
534 * We tolerate no failure path after event creation. It
535 * will stay invariant for the rest of the session.
536 */
537 event = ltt_event_create(channel, &event_param, NULL, NULL);
538 if (!event) {
539 ret = -EINVAL;
540 goto event_error;
541 }
542 event_file->private_data = event;
543 fd_install(event_fd, event_file);
544 /* The event holds a reference on the channel */
545 atomic_long_inc(&channel_file->f_count);
546 break;
547 case LTTNG_KERNEL_SYSCALLS:
548 ret = lttng_syscalls_register(channel, NULL);
549 if (ret)
550 goto fd_error;
551 event_fd = 0;
552 break;
553 }
554 return event_fd;
555
556 event_error:
557 fput(event_file);
558 file_error:
559 put_unused_fd(event_fd);
560 fd_error:
561 return ret;
562 }
563
564 /**
565 * lttng_channel_ioctl - lttng syscall through ioctl
566 *
567 * @file: the file
568 * @cmd: the command
569 * @arg: command arg
570 *
571 * This ioctl implements lttng commands:
572 * LTTNG_KERNEL_STREAM
573 * Returns an event stream file descriptor or failure.
574 * (typically, one event stream records events from one CPU)
575 * LTTNG_KERNEL_EVENT
576 * Returns an event file descriptor or failure.
577 * LTTNG_KERNEL_CONTEXT
578 * Prepend a context field to each event in the channel
579 * LTTNG_KERNEL_ENABLE
580 * Enable recording for events in this channel (weak enable)
581 * LTTNG_KERNEL_DISABLE
582 * Disable recording for events in this channel (strong disable)
583 *
584 * Channel and event file descriptors also hold a reference on the session.
585 */
586 static
587 long lttng_channel_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
588 {
589 struct ltt_channel *channel = file->private_data;
590
591 switch (cmd) {
592 case LTTNG_KERNEL_STREAM:
593 return lttng_abi_open_stream(file);
594 case LTTNG_KERNEL_EVENT:
595 return lttng_abi_create_event(file, (struct lttng_kernel_event __user *) arg);
596 case LTTNG_KERNEL_CONTEXT:
597 return lttng_abi_add_context(file,
598 (struct lttng_kernel_context __user *) arg,
599 &channel->ctx, channel->session);
600 case LTTNG_KERNEL_ENABLE:
601 return ltt_channel_enable(channel);
602 case LTTNG_KERNEL_DISABLE:
603 return ltt_channel_disable(channel);
604 default:
605 return -ENOIOCTLCMD;
606 }
607 }
608
609 /**
610 * lttng_metadata_ioctl - lttng syscall through ioctl
611 *
612 * @file: the file
613 * @cmd: the command
614 * @arg: command arg
615 *
616 * This ioctl implements lttng commands:
617 * LTTNG_KERNEL_STREAM
618 * Returns an event stream file descriptor or failure.
619 *
620 * Channel and event file descriptors also hold a reference on the session.
621 */
622 static
623 long lttng_metadata_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
624 {
625 switch (cmd) {
626 case LTTNG_KERNEL_STREAM:
627 return lttng_abi_open_stream(file);
628 default:
629 return -ENOIOCTLCMD;
630 }
631 }
632
633 /**
634 * lttng_channel_poll - lttng stream addition/removal monitoring
635 *
636 * @file: the file
637 * @wait: poll table
638 */
639 unsigned int lttng_channel_poll(struct file *file, poll_table *wait)
640 {
641 struct ltt_channel *channel = file->private_data;
642 unsigned int mask = 0;
643
644 if (file->f_mode & FMODE_READ) {
645 poll_wait_set_exclusive(wait);
646 poll_wait(file, channel->ops->get_hp_wait_queue(channel->chan),
647 wait);
648
649 if (channel->ops->is_disabled(channel->chan))
650 return POLLERR;
651 if (channel->ops->is_finalized(channel->chan))
652 return POLLHUP;
653 if (channel->ops->buffer_has_read_closed_stream(channel->chan))
654 return POLLIN | POLLRDNORM;
655 return 0;
656 }
657 return mask;
658
659 }
660
661 static
662 int lttng_channel_release(struct inode *inode, struct file *file)
663 {
664 struct ltt_channel *channel = file->private_data;
665
666 if (channel)
667 fput(channel->session->file);
668 return 0;
669 }
670
671 static const struct file_operations lttng_channel_fops = {
672 .owner = THIS_MODULE,
673 .release = lttng_channel_release,
674 .poll = lttng_channel_poll,
675 .unlocked_ioctl = lttng_channel_ioctl,
676 #ifdef CONFIG_COMPAT
677 .compat_ioctl = lttng_channel_ioctl,
678 #endif
679 };
680
681 static const struct file_operations lttng_metadata_fops = {
682 .owner = THIS_MODULE,
683 .release = lttng_channel_release,
684 .unlocked_ioctl = lttng_metadata_ioctl,
685 #ifdef CONFIG_COMPAT
686 .compat_ioctl = lttng_metadata_ioctl,
687 #endif
688 };
689
690 /**
691 * lttng_event_ioctl - lttng syscall through ioctl
692 *
693 * @file: the file
694 * @cmd: the command
695 * @arg: command arg
696 *
697 * This ioctl implements lttng commands:
698 * LTTNG_KERNEL_CONTEXT
699 * Prepend a context field to each record of this event
700 * LTTNG_KERNEL_ENABLE
701 * Enable recording for this event (weak enable)
702 * LTTNG_KERNEL_DISABLE
703 * Disable recording for this event (strong disable)
704 */
705 static
706 long lttng_event_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
707 {
708 struct ltt_event *event = file->private_data;
709
710 switch (cmd) {
711 case LTTNG_KERNEL_CONTEXT:
712 return lttng_abi_add_context(file,
713 (struct lttng_kernel_context __user *) arg,
714 &event->ctx, event->chan->session);
715 case LTTNG_KERNEL_ENABLE:
716 return ltt_event_enable(event);
717 case LTTNG_KERNEL_DISABLE:
718 return ltt_event_disable(event);
719 default:
720 return -ENOIOCTLCMD;
721 }
722 }
723
724 static
725 int lttng_event_release(struct inode *inode, struct file *file)
726 {
727 struct ltt_event *event = file->private_data;
728
729 if (event)
730 fput(event->chan->file);
731 return 0;
732 }
733
734 /* TODO: filter control ioctl */
735 static const struct file_operations lttng_event_fops = {
736 .owner = THIS_MODULE,
737 .release = lttng_event_release,
738 .unlocked_ioctl = lttng_event_ioctl,
739 #ifdef CONFIG_COMPAT
740 .compat_ioctl = lttng_event_ioctl,
741 #endif
742 };
743
744 int __init ltt_debugfs_abi_init(void)
745 {
746 int ret = 0;
747
748 wrapper_vmalloc_sync_all();
749 lttng_dentry = debugfs_create_file("lttng", S_IWUSR, NULL, NULL,
750 &lttng_fops);
751 if (IS_ERR(lttng_dentry))
752 lttng_dentry = NULL;
753
754 lttng_proc_dentry = proc_create_data("lttng", S_IWUSR, NULL,
755 &lttng_fops, NULL);
756
757 if (!lttng_dentry && !lttng_proc_dentry) {
758 printk(KERN_ERR "Error creating LTTng control file\n");
759 ret = -ENOMEM;
760 goto error;
761 }
762 error:
763 return ret;
764 }
765
766 void __exit ltt_debugfs_abi_exit(void)
767 {
768 if (lttng_dentry)
769 debugfs_remove(lttng_dentry);
770 if (lttng_proc_dentry)
771 remove_proc_entry("lttng", NULL);
772 }
This page took 0.060941 seconds and 4 git commands to generate.