scripts/ipe/polgen/polgen.c

Source file repositories/reference/linux-study-clean/scripts/ipe/polgen/polgen.c

File Facts

System
Linux kernel
Corpus path
scripts/ipe/polgen/polgen.c
Extension
.c
Size
2284 bytes
Lines
138
Domain
Support Tooling And Documentation
Bucket
scripts
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

switch (buf[i]) {
		case '"':
			fprintf(fd, "\\\"");
			break;
		case '\'':
			fprintf(fd, "'");
			break;
		case '\n':
			fprintf(fd, "\\n\"\n\t\"");
			break;
		case '\\':
			fprintf(fd, "\\\\");
			break;
		case '\t':
			fprintf(fd, "\\t");
			break;
		case '\?':
			fprintf(fd, "\\?");
			break;
		default:
			fprintf(fd, "%c", buf[i]);
		}
	}
	fprintf(fd, "\";\n");
	fclose(fd);

	return 0;
}

int main(int argc, const char *const argv[])
{
	char *policy = NULL;
	size_t len = 0;
	int rc = 0;

	if (argc < 2)
		usage(argv[0]);

	if (argc > 2) {
		rc = policy_to_buffer(argv[2], &policy, &len);
		if (rc != 0)
			goto cleanup;
	}

	rc = write_boot_policy(argv[1], policy, len);
cleanup:
	if (policy)
		free(policy);
	if (rc != 0)
		perror("An error occurred during policy conversion: ");
	return rc;
}

Annotation

Implementation Notes