@@ -178,7 +178,7 @@ def set_attr(self, group, attribute, value):
178178 try :
179179 with open (path , 'w' , encoding = "utf-8" ) as file_fd :
180180 file_fd .write (str (value ))
181- except Exception as e :
181+ except OSError as e :
182182 raise CFSError (f"Cannot set attribute { path } : { e } " ) from e
183183
184184 def get_attr (self , group , attribute ):
@@ -222,7 +222,7 @@ def set_enable(self, value):
222222 try :
223223 with open (path , 'w' , encoding = "utf-8" ) as file_fd :
224224 file_fd .write (str (value ))
225- except Exception as e :
225+ except OSError as e :
226226 raise CFSError (f"Cannot enable { self .path } : { e } ({ value } )" ) from e
227227 self ._enable = value
228228
@@ -304,7 +304,7 @@ def _modprobe(self, modname):
304304 try :
305305 kmod_ctypes .Kmod ().modprobe (modname )
306306 return
307- except Exception :
307+ except OSError :
308308 pass
309309
310310 # Try the binary specified in /proc
@@ -315,7 +315,7 @@ def _modprobe(self, modname):
315315 if modprobe_cmd :
316316 subprocess .run (shlex .split (modprobe_cmd ) + [modname ],
317317 check = False )
318- except Exception :
318+ except OSError :
319319 pass
320320
321321 def _list_subsystems (self ):
@@ -554,7 +554,7 @@ def add_allowed_host(self, nqn):
554554 try :
555555 os .symlink (f"{ self .configfs_dir } /hosts/{ nqn } " ,
556556 f"{ self ._path } /allowed_hosts/{ nqn } " )
557- except Exception as e :
557+ except OSError as e :
558558 raise CFSError (f"Could not symlink { nqn } in configFS: { e } " ) from e
559559
560560 def remove_allowed_host (self , nqn ):
@@ -563,7 +563,7 @@ def remove_allowed_host(self, nqn):
563563 '''
564564 try :
565565 os .unlink (f"{ self ._path } /allowed_hosts/{ nqn } " )
566- except Exception as e :
566+ except OSError as e :
567567 raise CFSError (f"Could not unlink { nqn } in configFS: { e } " ) from e
568568
569569 def has_passthru (self ):
@@ -895,7 +895,7 @@ def add_subsystem(self, nqn):
895895 try :
896896 os .symlink (f"{ self .configfs_dir } /subsystems/{ nqn } " ,
897897 f"{ self ._path } /subsystems/{ nqn } " )
898- except Exception as e :
898+ except OSError as e :
899899 raise CFSError (f"Could not symlink { nqn } in configFS: { e } " ) from e
900900
901901 def remove_subsystem (self , nqn ):
@@ -904,7 +904,7 @@ def remove_subsystem(self, nqn):
904904 '''
905905 try :
906906 os .unlink (f"{ self ._path } /subsystems/{ nqn } " )
907- except Exception as e :
907+ except OSError as e :
908908 raise CFSError (f"Could not unlink { nqn } in configFS: { e } " ) from e
909909
910910 def delete (self ):
0 commit comments