@@ -242,6 +242,8 @@ static void sigusr1_reload(int signo, siginfo_t *info, void *extra)
242242 need_reload = 1 ;
243243}
244244
245+ static void sig_noop_handler (int signo , siginfo_t * info , void * extra ) {}
246+
245247/* Functions to run the library methods */
246248
247249#define DEF_LIB_FS_OP (type , fsop ) \
@@ -276,8 +278,14 @@ DEF_LIB_FS_OP(sys , read)
276278 off_t offset, struct fuse_file_info *fi
277279#define LIB_FS_write_OP_ARGS path, buf, size, offset, fi
278280DEF_LIB_FS_OP (cg , write )
281+ DEF_LIB_FS_OP (proc , write )
279282DEF_LIB_FS_OP (sys , write )
280283
284+ #define LIB_FS_poll_OP_ARGS_TYPE const char *path, struct fuse_file_info *fi, \
285+ struct fuse_pollhandle *ph, unsigned *reventsp
286+ #define LIB_FS_poll_OP_ARGS path, fi, ph, reventsp
287+ DEF_LIB_FS_OP (proc , poll )
288+
281289#define LIB_FS_mkdir_OP_ARGS_TYPE const char *path, mode_t mode
282290#define LIB_FS_mkdir_OP_ARGS path, mode
283291DEF_LIB_FS_OP (cg , mkdir )
@@ -605,6 +613,13 @@ int lxcfs_write(const char *path, const char *buf, size_t size, off_t offset,
605613 return ret ;
606614 }
607615
616+ if (LXCFS_TYPE_PROC (type )) {
617+ up_users ();
618+ ret = do_proc_write (path , buf , size , offset , fi );
619+ down_users ();
620+ return ret ;
621+ }
622+
608623 if (LXCFS_TYPE_SYS (type )) {
609624 up_users ();
610625 ret = do_sys_write (path , buf , size , offset , fi );
@@ -615,6 +630,27 @@ int lxcfs_write(const char *path, const char *buf, size_t size, off_t offset,
615630 return - EINVAL ;
616631}
617632
633+ int lxcfs_poll (const char * path , struct fuse_file_info * fi ,
634+ struct fuse_pollhandle * ph , unsigned * reventsp )
635+ {
636+ int ret ;
637+ enum lxcfs_virt_t type ;
638+
639+ type = file_info_type (fi );
640+
641+ if (LXCFS_TYPE_PROC (type )) {
642+ up_users ();
643+ ret = do_proc_poll (path , fi , ph , reventsp );
644+ down_users ();
645+ return ret ;
646+ }
647+
648+ /* default f_op->poll() behavior when not supported */
649+ fuse_pollhandle_destroy (ph );
650+ * reventsp = DEFAULT_POLLMASK ;
651+ return 0 ;
652+ }
653+
618654int lxcfs_readlink (const char * path , char * buf , size_t size )
619655{
620656 int ret ;
@@ -842,6 +878,9 @@ const struct fuse_operations lxcfs_ops = {
842878 .truncate = lxcfs_truncate ,
843879 .write = lxcfs_write ,
844880 .readlink = lxcfs_readlink ,
881+ #if HAVE_FUSE3
882+ .poll = lxcfs_poll ,
883+ #endif
845884
846885 .create = NULL ,
847886 .destroy = NULL ,
@@ -937,6 +976,7 @@ static const struct option long_options[] = {
937976 {"enable-cfs" , no_argument , 0 , 0 },
938977 {"enable-pidfd" , no_argument , 0 , 0 },
939978 {"enable-cgroup" , no_argument , 0 , 0 },
979+ {"enable-psi-poll" , no_argument , 0 , 0 },
940980
941981 {"pidfile" , required_argument , 0 , 'p' },
942982 {"runtime-dir" , required_argument , 0 , 0 },
@@ -1011,7 +1051,8 @@ int main(int argc, char *argv[])
10111051 opts -> zswap_off = false;
10121052 opts -> use_pidfd = false;
10131053 opts -> use_cfs = false;
1014- opts -> version = 3 ;
1054+ opts -> psi_poll_on = false;
1055+ opts -> version = 4 ;
10151056
10161057 while ((c = getopt_long (argc , argv , "dulfhvso:p:" , long_options , & idx )) != -1 ) {
10171058 switch (c ) {
@@ -1022,6 +1063,8 @@ int main(int argc, char *argv[])
10221063 opts -> use_cfs = true;
10231064 else if (strcmp (long_options [idx ].name , "enable-cgroup" ) == 0 )
10241065 cgroup_is_enabled = true;
1066+ else if (strcmp (long_options [idx ].name , "enable-psi-poll" ) == 0 )
1067+ opts -> psi_poll_on = true;
10251068 else if (strcmp (long_options [idx ].name , "runtime-dir" ) == 0 )
10261069 runtime_path_arg = optarg ;
10271070 else
@@ -1189,6 +1232,11 @@ int main(int argc, char *argv[])
11891232 }
11901233#endif
11911234
1235+ if (install_signal_handler (SIG_NOTIFY_POLL_WAKEUP , sig_noop_handler )) {
1236+ lxcfs_error ("%s - Failed to install SIG_NOTIFY_POLL_WAKEUP signal handler" , strerror (errno ));
1237+ goto out ;
1238+ }
1239+
11921240 if (!pidfile ) {
11931241 snprintf (pidfile_buf , sizeof (pidfile_buf ), "%s%s" , runtime_path , PID_FILE );
11941242 pidfile = pidfile_buf ;
0 commit comments