[packages] libv4l: update to v0.6.1, don't ship dev shared lib sysmlinks
[packages.git] / libs / libv4l / patches / 001-no-shm_open-fix.patch
1 --- a/libv4lconvert/control/libv4lcontrol.c
2 +++ b/libv4lconvert/control/libv4lcontrol.c
3 @@ -338,7 +338,7 @@ static void v4lcontrol_init_flags(struct
4  
5  struct v4lcontrol_data *v4lcontrol_create(int fd, int always_needs_conversion)
6  {
7 -  int shm_fd;
8 +  int shm_fd, fdflags;
9    int i, rc, init = 0;
10    char *s, shm_name[256], pwd_buf[1024];
11    struct v4l2_capability cap;
12 @@ -392,25 +392,31 @@ struct v4lcontrol_data *v4lcontrol_creat
13    }
14  
15    if (getpwuid_r(geteuid(), &pwd, pwd_buf, sizeof(pwd_buf), &pwd_p) == 0) {
16 -    snprintf(shm_name, 256, "/libv4l-%s:%s:%s", pwd.pw_name,
17 +    snprintf(shm_name, 256, "/dev/shm/libv4l-%s:%s:%s", pwd.pw_name,
18              cap.bus_info, cap.card);
19    } else {
20      perror("libv4lcontrol: error getting username using uid instead");
21 -    snprintf(shm_name, 256, "/libv4l-%lu:%s:%s", (unsigned long)geteuid(),
22 +    snprintf(shm_name, 256, "/dev/shm/libv4l-%lu:%s:%s", (unsigned long)geteuid(),
23              cap.bus_info, cap.card);
24    }
25  
26    /* / is not allowed inside shm names */
27 -  for (i = 1; shm_name[i]; i++)
28 +  for (i = 9; shm_name[i]; i++) /* start after "/dev/shm", i = 9 */
29      if (shm_name[i] == '/')
30        shm_name[i] = '-';
31  
32    /* Open the shared memory object identified by shm_name */
33 -  if ((shm_fd = shm_open(shm_name, (O_CREAT | O_EXCL | O_RDWR),
34 +  if ((shm_fd = open(shm_name, (O_CREAT | O_EXCL | O_RDWR),
35                          (S_IREAD | S_IWRITE))) >= 0)
36      init = 1;
37    else
38 -    shm_fd = shm_open(shm_name, O_RDWR, (S_IREAD | S_IWRITE));
39 +    shm_fd = open(shm_name, O_RDWR, (S_IREAD | S_IWRITE));
40 +
41 +  /* This is all uClibc > 0.9.30 seems to do for shm_open() in librt/shm.c */
42 +  fdflags = fcntl(shm_fd, F_GETFD, 0);
43 +  
44 +  if (fdflags >= 0)
45 +    fdflags = fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
46  
47    if (shm_fd >= 0) {
48      /* Set the shared memory size */