quote on Fri, Jul 01, 2016 at 05:18:17PM +0200 (Richard Cochran): > On Fri, Jul 01, 2016 at 01:43:43PM +0300, Ivan Oleynikov wrote: > > This is simply icquired by using `realpath(3)` of value passed with -p > > parameter instead of its original value. > > Can you please explain what problem this patch fixes?
Imagine i have a symlink to my /dev/ptp0: ln -s /dev/ptp0 /dev/my_ptp If i try to syncronize that PHC over the network interface gbe0 i get: # ptp4l -p /dev/my_ptp -i gbe0 -m -s ptp4l[2117.975]: bad ptp device string failed to create a clock It seems strange that ptp4l expects path to ptp device to be in the form "/dev/ptp%d". This also forbids me to specify a relative path to PHC device. E.g: # ptp4l -p /dev/../dev/ptp0 -i gbe0 -m -s ptp4l[2268.015]: bad ptp device string failed to create a clock Working with PHC through a symlink instead of directly passing /dev/ptp0 to `ptl4l -p` can be useful when you have multiple PTP clocks in your system and the order in which they are registered is unpredictable (as well as name of your desired PHC file in /dev/). So you have to look at /sys/class/ptp/ptp*/{clock_name, device} to find the name of your device. Alternative solution would be to create udev rule matching ptp device with specific DRIVERS, KERNELS, etc. that will add a symlink (e.g. /dev/my_ptp in the first example) to your device. This patch makes ptp4l find full path to PHC using `realpath(3)` before doing anything else with it. Thus allowing me to: # ptp4l -p /dev/../dev/ptp0 -i gbe0 -m -s ptp4l[5346.225]: selected /dev/ptp0 as PTP clock And also to: # ptp4l -p /dev/my_ptp -i gbe0 -m -s ptp4l[5368.645]: selected /dev/ptp0 as PTP clock Better solution would be to determine phc_index by given PHC char device path without parsing its path (maybe by looking at sysfs or by some ioctl), but I couldn't find a way to do that. This would allow me to create char device with arbitrary name for my PHC (with mknod or by renaming it in udev). -- Ivan Oleynikov STC Metrotek St.Petersburg ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel