Linux Audio

Check our new training course

Linux BSP upgrade and security maintenance

Need help to get security updates for your Linux BSP?
Loading...
v3.15
 
 1#include <stdio.h>
 2#include <stdint.h>
 3#include <stdlib.h>
 4#include <unistd.h>
 5#include <sys/types.h>
 6#include <sys/stat.h>
 7#include <fcntl.h>
 8#include <errno.h>
 9#include <string.h>
10
11int main(int argc, char **argv)
12{
13	const char *path;
14	char buf[4];
15	int fd, rc;
16
17	if (argc < 2) {
18		fprintf(stderr, "usage: %s <path>\n", argv[0]);
19		return EXIT_FAILURE;
20	}
21
22	path = argv[1];
23
24	/* create a test variable */
25	fd = open(path, O_RDWR | O_CREAT, 0600);
26	if (fd < 0) {
27		perror("open(O_WRONLY)");
28		return EXIT_FAILURE;
29	}
30
31	rc = read(fd, buf, sizeof(buf));
32	if (rc != 0) {
33		fprintf(stderr, "Reading a new var should return EOF\n");
 
34		return EXIT_FAILURE;
35	}
36
 
37	return EXIT_SUCCESS;
38}
v6.8
 1// SPDX-License-Identifier: GPL-2.0
 2#include <stdio.h>
 3#include <stdint.h>
 4#include <stdlib.h>
 5#include <unistd.h>
 6#include <sys/types.h>
 7#include <sys/stat.h>
 8#include <fcntl.h>
 9#include <errno.h>
10#include <string.h>
11
12int main(int argc, char **argv)
13{
14	const char *path;
15	char buf[4];
16	int fd, rc;
17
18	if (argc < 2) {
19		fprintf(stderr, "usage: %s <path>\n", argv[0]);
20		return EXIT_FAILURE;
21	}
22
23	path = argv[1];
24
25	/* create a test variable */
26	fd = open(path, O_RDWR | O_CREAT, 0600);
27	if (fd < 0) {
28		perror("open(O_WRONLY)");
29		return EXIT_FAILURE;
30	}
31
32	rc = read(fd, buf, sizeof(buf));
33	if (rc != 0) {
34		fprintf(stderr, "Reading a new var should return EOF\n");
35		close(fd);
36		return EXIT_FAILURE;
37	}
38
39	close(fd);
40	return EXIT_SUCCESS;
41}