@@ -422,26 +422,23 @@ int create_and_get_cgroup(const char *relative_path)
422
422
}
423
423
424
424
/**
425
- * get_cgroup_id() - Get cgroup id for a particular cgroup path
426
- * @relative_path : The cgroup path, relative to the workdir, to join
425
+ * get_cgroup_id_from_path - Get cgroup id for a particular cgroup path
426
+ * @cgroup_workdir : The absolute cgroup path
427
427
*
428
428
* On success, it returns the cgroup id. On failure it returns 0,
429
429
* which is an invalid cgroup id.
430
430
* If there is a failure, it prints the error to stderr.
431
431
*/
432
- unsigned long long get_cgroup_id (const char * relative_path )
432
+ unsigned long long get_cgroup_id_from_path (const char * cgroup_workdir )
433
433
{
434
434
int dirfd , err , flags , mount_id , fhsize ;
435
435
union {
436
436
unsigned long long cgid ;
437
437
unsigned char raw_bytes [8 ];
438
438
} id ;
439
- char cgroup_workdir [PATH_MAX + 1 ];
440
439
struct file_handle * fhp , * fhp2 ;
441
440
unsigned long long ret = 0 ;
442
441
443
- format_cgroup_path (cgroup_workdir , relative_path );
444
-
445
442
dirfd = AT_FDCWD ;
446
443
flags = 0 ;
447
444
fhsize = sizeof (* fhp );
@@ -477,6 +474,14 @@ unsigned long long get_cgroup_id(const char *relative_path)
477
474
return ret ;
478
475
}
479
476
477
+ unsigned long long get_cgroup_id (const char * relative_path )
478
+ {
479
+ char cgroup_workdir [PATH_MAX + 1 ];
480
+
481
+ format_cgroup_path (cgroup_workdir , relative_path );
482
+ return get_cgroup_id_from_path (cgroup_workdir );
483
+ }
484
+
480
485
int cgroup_setup_and_join (const char * path ) {
481
486
int cg_fd ;
482
487
@@ -621,3 +626,14 @@ void cleanup_classid_environment(void)
621
626
join_cgroup_from_top (NETCLS_MOUNT_PATH );
622
627
nftw (cgroup_workdir , nftwfunc , WALK_FD_LIMIT , FTW_DEPTH | FTW_MOUNT );
623
628
}
629
+
630
+ /**
631
+ * get_classid_cgroup_id - Get the cgroup id of a net_cls cgroup
632
+ */
633
+ unsigned long long get_classid_cgroup_id (void )
634
+ {
635
+ char cgroup_workdir [PATH_MAX + 1 ];
636
+
637
+ format_classid_path (cgroup_workdir );
638
+ return get_cgroup_id_from_path (cgroup_workdir );
639
+ }
0 commit comments