Skip to content

Commit 961e00d

Browse files
thisptr-hubdtrugman
authored andcommitted
add function to read task audit session id
1 parent 28256ed commit 961e00d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/pfs/task.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class task final
9696
std::vector<id_map> get_uid_map() const;
9797
std::vector<id_map> get_gid_map() const;
9898

99+
uint32_t get_sessionid() const;
100+
99101
private:
100102
friend class procfs;
101103
task(const std::string& procfs_root, int id);

src/task.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "pfs/parsers/mountinfo.hpp"
3434
#include "pfs/parsers/lines.hpp"
3535
#include "pfs/parsers/common.hpp"
36+
#include "pfs/parsers/number.hpp"
3637
#include "pfs/parsers/task_io.hpp"
3738
#include "pfs/parsers/task_status.hpp"
3839
#include "pfs/task.hpp"
@@ -489,4 +490,15 @@ std::vector<id_map> task::get_gid_map() const
489490
return output;
490491
}
491492

493+
uint32_t task::get_sessionid() const
494+
{
495+
static const std::string SESSION_ID_FILE("sessionid");
496+
auto path = _task_root + SESSION_ID_FILE;
497+
498+
auto line = utils::readline(path);
499+
uint32_t session_id;
500+
parsers::to_number(line, session_id);
501+
return session_id;
502+
}
503+
492504
} // namespace pfs

0 commit comments

Comments
 (0)