Exemplo n.º 1
0
void eRTSPStreamClient::process_pids(int op, const std::string &pid_str)
{
	eDebug("%s: operation %d, pid_str %s (len pids: %d)", __FUNCTION__, op, pid_str.c_str(), pids.size());

	if (op == _PIDS)
	{
		pids.clear();

		if (pid_str.find("all") != std::string::npos)
		{
			pids.insert(8192);
			update_service_list();
			return;
		}
	}

	std::stringstream ss(pid_str);
	std::string s;

	while (!ss.eof())
	{
		std::getline(ss, s, ',');
		if (s.empty())
			break;
		int p = atoi(s.c_str());
		if (p < 0 || p > 8191)
			continue;
		if (op == _PIDS || op == _ADD_PIDS)
			add_pid(p);
		if (op == _DEL_PIDS)
			del_pid(p);
	}
	update_service_list();
}
Exemplo n.º 2
0
static pid_list *scan_pid_maps(const char *fname, pid_t pid,
				inode_list *ilist, pid_list *plist)
{
	FILE *file;
	char line[MAX_LINE + 1];
	int major, minor;
	ino_t inode;
	long long uint64_inode;
	dev_t dev;

	file = fopen_for_read(fname);
	if (!file)
		return plist;
	while (fgets(line, MAX_LINE, file)) {
		if (sscanf(line, "%*s %*s %*s %x:%x %llu", &major, &minor, &uint64_inode) != 3)
			continue;
		inode = uint64_inode;
		if (major == 0 && minor == 0 && inode == 0)
			continue;
		dev = makedev(major, minor);
		if (search_dev_inode(ilist, dev, inode))
			plist = add_pid(plist, pid);
	}
	fclose(file);
	return plist;
}
Exemplo n.º 3
0
static void scan_link(const char *lname, pid_t pid)
{
	struct stat st;

	if (stat(lname, &st) >= 0) {
		if (search_dev_inode(&st))
			add_pid(pid);
	}
}
Exemplo n.º 4
0
static pid_list *scan_link(const char *lname, pid_t pid,
				inode_list *ilist, pid_list *plist)
{
	ino_t inode;
	dev_t dev;

	if (!file_to_dev_inode(lname, &dev, &inode))
		return plist;
	if (search_dev_inode(ilist, dev, inode))
		plist = add_pid(plist, pid);
	return plist;
}
void copy_fds(pid_t parent, pid_t child)
{
	struct pid_reg *pid_iter = *find_pid(parent);
	if (pid_iter)
	{
		struct fd_reg *fd_iter = pid_iter->fd_head;

		add_pid(child);
		struct fd_reg **nextfd = &pid_head->fd_head;

		while (fd_iter)
		{
			*nextfd = malloc(sizeof(struct fd_reg));
			**nextfd = *fd_iter;
			nextfd = &(*nextfd)->next;
			fd_iter = fd_iter->next;
		}
	}
}
void register_fd(int fd, const char *filename, struct status_t *status)
{
	struct pid_reg *pid_iter = *find_pid(getpid());
	if (pid_iter == 0)
	{
		add_pid(getpid());
		pid_iter = pid_head;
	}

	struct fd_reg *fd_iter = *find_fd(pid_iter, fd);
	if (fd_iter == 0)
	{
		add_fd(pid_iter, fd, filename, status);
	} else {
#  if DEBUG == 1
		if (debug) fprintf(stderr, "fl_wrapper.so debug [%d]: fd %d already registered (is %s, was %s).\n",
			getpid(), fd, filename, fd_iter->filename);
#  endif
		free(fd_iter->filename);
		fd_iter->filename = strdup(filename);
		fd_iter->status = *status;
	}
}
Exemplo n.º 7
0
static
struct thread *
thread_create(const char *name)
{
	struct thread *thread = kmalloc(sizeof(struct thread));
	if (thread==NULL) {
		return NULL;
	}
	thread->t_name = kstrdup(name);
	if (thread->t_name==NULL) {
		kfree(thread);
		return NULL;
	}
	thread->t_sleepaddr = NULL;
	thread->t_stack = NULL;
	thread->t_vmspace = NULL;
	thread->t_cwd = NULL;
	
	// If you add things to the thread structure, be sure to initialize
	// them here.
	// 8=================================================================D
	
	//Assume that the thread does not have a parent. If it remains 0 it is true, otherwise, it has a parent.
	thread->parent_pid=0;
	
	//Create a PID for the thread.
	lock_acquire(lock_addpid);
	thread->pid = add_pid(); //assign thread a pid
	//kprintf("CURTHREAD PID IS %d \n", thread->pid);
	lock_release(lock_addpid);
	if (thread->pid == -1){
		return NULL;
	}
	
	return thread;
}
Exemplo n.º 8
0
static void scan_pid_maps(const char *fname, pid_t pid)
{
	FILE *file;
	char line[MAX_LINE + 1];
	int major, minor;
	long long uint64_inode;
	struct stat st;

	file = fopen_for_read(fname);
	if (!file)
		return;

	while (fgets(line, MAX_LINE, file)) {
		if (sscanf(line, "%*s %*s %*s %x:%x %llu", &major, &minor, &uint64_inode) != 3)
			continue;
		st.st_ino = uint64_inode;
		if (major == 0 && minor == 0 && st.st_ino == 0)
			continue;
		st.st_dev = makedev(major, minor);
		if (search_dev_inode(&st))
			add_pid(pid);
	}
	fclose(file);
}