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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/bpf_iter_tasks.c
Extension
.c
Size
5686 bytes
Lines
199
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

if (i % 2 == 0) {
			if (big_str1[i] != 'b') {
				BPF_SEQ_PRINTF(seq, "%s\n", info);
				return 0;
			}
		} else {
			if (big_str1[i] != 'a') {
				BPF_SEQ_PRINTF(seq, "%s\n", info);
				return 0;
			}
		}
	}

	/* Longer length than the string that crosses a page boundary */
	ret = bpf_copy_from_user_task_str(big_str2, 5005, user_ptr_long, task, BPF_F_PAD_ZEROS);
	if (bpf_strncmp(big_str2, 4, "baba") != 0 || ret != 5000
	    || bpf_strncmp(big_str2 + 4996, 5, "bab\0\0") != 0) {
		BPF_SEQ_PRINTF(seq, "%s\n", info);
		return 0;
	}

	/* Shorter length than the string that crosses a page boundary */
	ret = bpf_copy_from_user_task_str(big_str3, 4996, user_ptr_long, task, 0);
	if (bpf_strncmp(big_str3, 4, "baba") != 0 || ret != 4996
	    || bpf_strncmp(big_str3 + 4992, 4, "bab\0") != 0) {
		BPF_SEQ_PRINTF(seq, "%s\n", info);
		return 0;
	}

	++num_success_copy_from_user_task_str;

	if (ctx->meta->seq_num == 0)
		BPF_SEQ_PRINTF(seq, "    tgid      gid     data\n");

	BPF_SEQ_PRINTF(seq, "%8d %8d %8d\n", task->tgid, task->pid, user_data);
	return 0;
}

Annotation

Implementation Notes