You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.3 KiB

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