| 1 | /* |
| 2 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; only version 2 |
| 7 | * of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | #ifndef _TRACEABLE_APP_H |
| 20 | #define _TRACEABLE_APP_H |
| 21 | |
| 22 | #include <stdint.h> |
| 23 | #include <urcu/list.h> |
| 24 | |
| 25 | #include "trace-ust.h" |
| 26 | |
| 27 | /* |
| 28 | * Application registration data structure. |
| 29 | */ |
| 30 | struct ust_register_msg { |
| 31 | uint32_t major; |
| 32 | uint32_t minor; |
| 33 | pid_t pid; |
| 34 | pid_t ppid; |
| 35 | uid_t uid; |
| 36 | gid_t gid; |
| 37 | char name[16]; |
| 38 | }; |
| 39 | |
| 40 | /* |
| 41 | * Traceable application list. |
| 42 | */ |
| 43 | struct ust_app_list { |
| 44 | /* |
| 45 | * This lock protects any read/write access to the list and count (which is |
| 46 | * basically the list size). All public functions in traceable-app.c |
| 47 | * acquire this lock and release it before returning. If none of those |
| 48 | * functions are used, the lock MUST be acquired in order to iterate or/and |
| 49 | * do any actions on that list. |
| 50 | */ |
| 51 | pthread_mutex_t lock; |
| 52 | |
| 53 | /* |
| 54 | * Number of element in the list. The session list lock MUST be acquired if |
| 55 | * this counter is used when iterating over the session list. |
| 56 | */ |
| 57 | unsigned int count; |
| 58 | |
| 59 | /* Linked list head */ |
| 60 | struct cds_list_head head; |
| 61 | }; |
| 62 | |
| 63 | /* Registered traceable applications. Libust registers to the session daemon |
| 64 | * and a linked list is kept of all running traceable app. |
| 65 | */ |
| 66 | struct ust_app { |
| 67 | int sock; /* Communication socket with the application */ |
| 68 | pid_t pid; |
| 69 | pid_t ppid; |
| 70 | uid_t uid; /* User ID that owns the apps */ |
| 71 | gid_t gid; /* Group ID that owns the apps */ |
| 72 | uint32_t v_major; /* Verion major number */ |
| 73 | uint32_t v_minor; /* Verion minor number */ |
| 74 | char name[17]; /* Process name (short) */ |
| 75 | struct ltt_ust_channel_list channels; |
| 76 | struct cds_list_head list; |
| 77 | }; |
| 78 | |
| 79 | #ifdef CONFIG_LTTNG_TOOLS_HAVE_UST |
| 80 | |
| 81 | int ust_app_register(struct ust_register_msg *msg, int sock); |
| 82 | void ust_app_unregister(int sock); |
| 83 | unsigned int ust_app_list_count(void); |
| 84 | |
| 85 | void ust_app_lock_list(void); |
| 86 | void ust_app_unlock_list(void); |
| 87 | void ust_app_clean_list(void); |
| 88 | struct ust_app_list *ust_app_get_list(void); |
| 89 | struct ust_app *ust_app_get_by_pid(pid_t pid); |
| 90 | |
| 91 | #else |
| 92 | |
| 93 | static inline |
| 94 | int ust_app_register(struct ust_register_msg *msg, int sock) |
| 95 | { |
| 96 | return -ENOSYS; |
| 97 | } |
| 98 | static inline |
| 99 | void ust_app_unregister(int sock) |
| 100 | { |
| 101 | } |
| 102 | static inline |
| 103 | unsigned int ust_app_list_count(void) |
| 104 | { |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | static inline |
| 109 | void ust_app_lock_list(void) |
| 110 | { |
| 111 | } |
| 112 | static inline |
| 113 | void ust_app_unlock_list(void) |
| 114 | { |
| 115 | } |
| 116 | static inline |
| 117 | void ust_app_clean_list(void) |
| 118 | { |
| 119 | } |
| 120 | static inline |
| 121 | struct ust_app_list *ust_app_get_list(void) |
| 122 | { |
| 123 | return NULL; |
| 124 | } |
| 125 | static inline |
| 126 | struct ust_app *ust_app_get_by_pid(pid_t pid) |
| 127 | { |
| 128 | return NULL; |
| 129 | } |
| 130 | |
| 131 | |
| 132 | |
| 133 | #endif |
| 134 | |
| 135 | #endif /* _TRACEABLE_APP_H */ |