mkListxattr :: String -> a -> (a -> IO b) -> (b -> CString -> CSize -> IO CSsize) -> IO [AttrName]
mkListxattr funcName x iox cFunc = do
  x' <- iox x
  allocaBytes allocBufSize $ \mem -> do buflen <- cFunc x' mem allocCSize
                                        if buflen == -1
                                           then throwErrno funcName
                                           else fmap splitNull $ peekCStringLen (mem, fromIntegral buflen)

-- |Get a list of all of the attributes set on a path
mkListxattr :: String -> a -> (a -> IO b) -> (b -> CString -> CSize -> IO CSsize) -> IO [AttrName]
mkListxattr funcName x iox cFunc = do
  x' <- iox x
  allocaBytes allocBufSize $ \mem -> do buflen <- cFunc x' mem allocCSize
                                        if buflen == -1
                                           then throwErrno funcName
                                           else fmap splitNull $ peekCStringLen (mem, fromIntegral buflen)

-- |Get a list of all of the attributes set on a path
mkListxattr funcName x iox cFunc = do
  x' <- iox x
  allocaBytes allocBufSize $ \mem -> do buflen <- cFunc x' mem allocCSize
                                        if buflen == -1
                                           then throwErrno funcName
                                           else fmap splitNull $ peekCStringLen (mem, fromIntegral buflen)

-- |Get a list of all of the attributes set on a path