File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l")
5656 set (CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -latomic" )
5757 set (CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -latomic" )
5858endif ()
59+ if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" )
60+ set (FLB_SYSTEM_FREEBSD On )
61+ add_definitions (-DFLB_SYSTEM_FREEBSD)
62+ set (CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -lutil" )
63+ set (CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -lutil" )
64+ endif ()
5965
6066include (GNUInstallDirs)
6167include (ExternalProject)
Original file line number Diff line number Diff line change 2121#include <sys/stat.h>
2222#include <fcntl.h>
2323#include <time.h>
24+ #ifdef FLB_SYSTEM_FREEBSD
25+ #include <sys/user.h>
26+ #include <libutil.h>
27+ #endif
2428
2529#include <fluent-bit/flb_compat.h>
2630#include <fluent-bit/flb_info.h>
@@ -1537,6 +1541,10 @@ char *flb_tail_file_name(struct flb_tail_file *file)
15371541 char path [PATH_MAX ];
15381542#elif defined(FLB_SYSTEM_WINDOWS )
15391543 HANDLE h ;
1544+ #elif defined(FLB_SYSTEM_FREEBSD )
1545+ struct kinfo_file * file_entries ;
1546+ int file_count ;
1547+ int file_index ;
15401548#endif
15411549
15421550 buf = flb_malloc (PATH_MAX );
@@ -1597,6 +1605,20 @@ char *flb_tail_file_name(struct flb_tail_file *file)
15971605 if (strstr (buf , "\\\\?\\" )) {
15981606 memmove (buf , buf + 4 , len + 1 );
15991607 }
1608+ #elif defined(FLB_SYSTEM_FREEBSD )
1609+ if ((file_entries = kinfo_getfile (getpid (), & file_count )) == NULL ) {
1610+ flb_free (buf );
1611+ return NULL ;
1612+ }
1613+
1614+ for (file_index = 0 ; file_index < file_count ; file_index ++ ) {
1615+ if (file_entries [file_index ].kf_fd == file -> fd ) {
1616+ strncpy (buf , file_entries [file_index ].kf_path , PATH_MAX - 1 );
1617+ buf [PATH_MAX - 1 ] = 0 ;
1618+ break ;
1619+ }
1620+ }
1621+ free (file_entries );
16001622#endif
16011623 return buf ;
16021624}
You can’t perform that action at this time.
0 commit comments