tools/testing/selftests/bpf/progs/cgrp_ls_negative.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/cgrp_ls_negative.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/cgrp_ls_negative.c
Extension
.c
Size
633 bytes
Lines
27
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

char _license[] SEC("license") = "GPL";

struct {
	__uint(type, BPF_MAP_TYPE_CGRP_STORAGE);
	__uint(map_flags, BPF_F_NO_PREALLOC);
	__type(key, int);
	__type(value, long);
} map_a SEC(".maps");

SEC("tp_btf/sys_enter")
int BPF_PROG(on_enter, struct pt_regs *regs, long id)
{
	struct task_struct *task;

	task = bpf_get_current_task_btf();
	(void)bpf_cgrp_storage_get(&map_a, (struct cgroup *)task, 0,
				   BPF_LOCAL_STORAGE_GET_F_CREATE);
	return 0;
}

Annotation

Implementation Notes