@@ -431,13 +431,21 @@ impl FileData {
431431 let xattr_name = slice_to_string (
432432 & unsafe { extra_data. xattr } . name [ ..XATTR_NAME_MAX_LEN as usize ] ,
433433 ) ?;
434- FileData :: SetXattr ( XattrFileData { inner, xattr_name } )
434+ FileData :: SetXattr ( XattrFileData {
435+ inner,
436+ xattr_name,
437+ operation : XattrOperation :: Set ,
438+ } )
435439 }
436440 file_activity_type_t:: FILE_ACTIVITY_REMOVEXATTR => {
437441 let xattr_name = slice_to_string (
438442 & unsafe { extra_data. xattr } . name [ ..XATTR_NAME_MAX_LEN as usize ] ,
439443 ) ?;
440- FileData :: RemoveXattr ( XattrFileData { inner, xattr_name } )
444+ FileData :: RemoveXattr ( XattrFileData {
445+ inner,
446+ xattr_name,
447+ operation : XattrOperation :: Remove ,
448+ } )
441449 }
442450 invalid => unreachable ! ( "Invalid event type: {invalid:?}" ) ,
443451 } ;
@@ -465,11 +473,13 @@ impl From<FileData> for fact_api::file_activity::File {
465473 FileData :: RmDir ( _) => {
466474 unreachable ! ( "RmDir event reached protobuf conversion" ) ;
467475 }
468- FileData :: SetXattr ( _) => {
469- unreachable ! ( "SetXattr event reached protobuf conversion" ) ;
476+ FileData :: SetXattr ( event) => {
477+ let f_act = fact_api:: FileXattrChange :: from ( event) ;
478+ fact_api:: file_activity:: File :: Xattr ( f_act)
470479 }
471- FileData :: RemoveXattr ( _) => {
472- unreachable ! ( "RemoveXattr event reached protobuf conversion" ) ;
480+ FileData :: RemoveXattr ( event) => {
481+ let f_act = fact_api:: FileXattrChange :: from ( event) ;
482+ fact_api:: file_activity:: File :: Xattr ( f_act)
473483 }
474484 FileData :: Unlink ( event) => {
475485 let activity = Some ( fact_api:: FileActivityBase :: from ( event) ) ;
@@ -635,10 +645,32 @@ impl PartialEq for RenameFileData {
635645 }
636646}
637647
648+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Serialize ) ]
649+ pub enum XattrOperation {
650+ Set ,
651+ Remove ,
652+ }
653+
638654#[ derive( Debug , Clone , Serialize ) ]
639655pub struct XattrFileData {
640656 inner : BaseFileData ,
641657 xattr_name : String ,
658+ operation : XattrOperation ,
659+ }
660+
661+ impl From < XattrFileData > for fact_api:: FileXattrChange {
662+ fn from ( value : XattrFileData ) -> Self {
663+ let activity = fact_api:: FileActivityBase :: from ( value. inner ) ;
664+ let operation = match value. operation {
665+ XattrOperation :: Set => fact_api:: file_xattr_change:: Operation :: Set ,
666+ XattrOperation :: Remove => fact_api:: file_xattr_change:: Operation :: Remove ,
667+ } ;
668+ fact_api:: FileXattrChange {
669+ activity : Some ( activity) ,
670+ xattr_name : value. xattr_name ,
671+ operation : operation. into ( ) ,
672+ }
673+ }
642674}
643675
644676#[ cfg( test) ]
0 commit comments