[PATCH v2 1/6] utils: Implement virFileIsNamedPipe

Purna Pavan Chandra Aekkaladevi posted 6 patches 1 year, 4 months ago
There is a newer version of this series
[PATCH v2 1/6] utils: Implement virFileIsNamedPipe
Posted by Purna Pavan Chandra Aekkaladevi 1 year, 4 months ago
virFileIsNamedPipe checks whether passed path is a FIFO file or not.

Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
Co-authored-by: Vineeth Pillai <viremana@linux.microsoft.com>
---
 src/libvirt_private.syms | 1 +
 src/util/virfile.c       | 8 ++++++++
 src/util/virfile.h       | 1 +
 3 files changed, 10 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 02dacea857..6bf6cfd20b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2357,6 +2357,7 @@ virFileIsDir;
 virFileIsExecutable;
 virFileIsLink;
 virFileIsMountPoint;
+virFileIsNamedPipe;
 virFileIsRegular;
 virFileIsSharedFS;
 virFileIsSharedFSType;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index d820172405..19b074ed8a 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -2023,6 +2023,14 @@ virFileIsDir(const char *path)
 }
 
 
+bool
+virFileIsNamedPipe(const char *path)
+{
+    struct stat s;
+    return (stat(path, &s) == 0) && S_ISFIFO(s.st_mode);
+}
+
+
 bool
 virFileIsRegular(const char *path)
 {
diff --git a/src/util/virfile.h b/src/util/virfile.h
index 7df3fcb840..4f7ff72483 100644
--- a/src/util/virfile.h
+++ b/src/util/virfile.h
@@ -215,6 +215,7 @@ void virFileActivateDirOverrideForLib(void);
 
 off_t virFileLength(const char *path, int fd) ATTRIBUTE_NONNULL(1);
 bool virFileIsDir (const char *file) ATTRIBUTE_NONNULL(1);
+bool virFileIsNamedPipe (const char *file) ATTRIBUTE_NONNULL(1);
 bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1) G_NO_INLINE;
 bool virFileIsExecutable(const char *file) ATTRIBUTE_NONNULL(1);
 bool virFileIsRegular(const char *file) ATTRIBUTE_NONNULL(1);
-- 
2.34.1
Re: [PATCH v2 1/6] utils: Implement virFileIsNamedPipe
Posted by Praveen K Paladugu 1 year, 4 months ago

On 10/1/2024 7:20 AM, Purna Pavan Chandra Aekkaladevi wrote:
> virFileIsNamedPipe checks whether passed path is a FIFO file or not.
> 
> Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
> Co-authored-by: Vineeth Pillai <viremana@linux.microsoft.com>
> ---
>   src/libvirt_private.syms | 1 +
>   src/util/virfile.c       | 8 ++++++++
>   src/util/virfile.h       | 1 +
>   3 files changed, 10 insertions(+)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 02dacea857..6bf6cfd20b 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -2357,6 +2357,7 @@ virFileIsDir;
>   virFileIsExecutable;
>   virFileIsLink;
>   virFileIsMountPoint;
> +virFileIsNamedPipe;
>   virFileIsRegular;
>   virFileIsSharedFS;
>   virFileIsSharedFSType;
> diff --git a/src/util/virfile.c b/src/util/virfile.c
> index d820172405..19b074ed8a 100644
> --- a/src/util/virfile.c
> +++ b/src/util/virfile.c
> @@ -2023,6 +2023,14 @@ virFileIsDir(const char *path)
>   }
>   
>   
> +bool
> +virFileIsNamedPipe(const char *path)
With v2, you are not using this method anywhere.
> +{
> +    struct stat s;
> +    return (stat(path, &s) == 0) && S_ISFIFO(s.st_mode);
> +}
> +
> +
>   bool
>   virFileIsRegular(const char *path)
>   {
> diff --git a/src/util/virfile.h b/src/util/virfile.h
> index 7df3fcb840..4f7ff72483 100644
> --- a/src/util/virfile.h
> +++ b/src/util/virfile.h
> @@ -215,6 +215,7 @@ void virFileActivateDirOverrideForLib(void);
>   
>   off_t virFileLength(const char *path, int fd) ATTRIBUTE_NONNULL(1);
>   bool virFileIsDir (const char *file) ATTRIBUTE_NONNULL(1);
> +bool virFileIsNamedPipe (const char *file) ATTRIBUTE_NONNULL(1);
>   bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1) G_NO_INLINE;
>   bool virFileIsExecutable(const char *file) ATTRIBUTE_NONNULL(1);
>   bool virFileIsRegular(const char *file) ATTRIBUTE_NONNULL(1);

-- 
Regards,
Praveen K Paladugu
Re: [PATCH v2 1/6] utils: Implement virFileIsNamedPipe
Posted by Purna Pavan Chandra Aekkaladevi 1 year, 3 months ago
On Tue, Oct 08, 2024 at 01:39:34PM -0500, Praveen K Paladugu wrote:
> 
> 
> On 10/1/2024 7:20 AM, Purna Pavan Chandra Aekkaladevi wrote:
> >virFileIsNamedPipe checks whether passed path is a FIFO file or not.
> >
> >Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@linux.microsoft.com>
> >Co-authored-by: Vineeth Pillai <viremana@linux.microsoft.com>
> >---
> >  src/libvirt_private.syms | 1 +
> >  src/util/virfile.c       | 8 ++++++++
> >  src/util/virfile.h       | 1 +
> >  3 files changed, 10 insertions(+)
> >
> >diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> >index 02dacea857..6bf6cfd20b 100644
> >--- a/src/libvirt_private.syms
> >+++ b/src/libvirt_private.syms
> >@@ -2357,6 +2357,7 @@ virFileIsDir;
> >  virFileIsExecutable;
> >  virFileIsLink;
> >  virFileIsMountPoint;
> >+virFileIsNamedPipe;
> >  virFileIsRegular;
> >  virFileIsSharedFS;
> >  virFileIsSharedFSType;
> >diff --git a/src/util/virfile.c b/src/util/virfile.c
> >index d820172405..19b074ed8a 100644
> >--- a/src/util/virfile.c
> >+++ b/src/util/virfile.c
> >@@ -2023,6 +2023,14 @@ virFileIsDir(const char *path)
> >  }
> >+bool
> >+virFileIsNamedPipe(const char *path)
> With v2, you are not using this method anywhere.

Sure, will remove it. Also, will take care of comments from other
patches as well in V3.

> >+{
> >+    struct stat s;
> >+    return (stat(path, &s) == 0) && S_ISFIFO(s.st_mode);
> >+}
> >+
> >+
> >  bool
> >  virFileIsRegular(const char *path)
> >  {
> >diff --git a/src/util/virfile.h b/src/util/virfile.h
> >index 7df3fcb840..4f7ff72483 100644
> >--- a/src/util/virfile.h
> >+++ b/src/util/virfile.h
> >@@ -215,6 +215,7 @@ void virFileActivateDirOverrideForLib(void);
> >  off_t virFileLength(const char *path, int fd) ATTRIBUTE_NONNULL(1);
> >  bool virFileIsDir (const char *file) ATTRIBUTE_NONNULL(1);
> >+bool virFileIsNamedPipe (const char *file) ATTRIBUTE_NONNULL(1);
> >  bool virFileExists(const char *file) ATTRIBUTE_NONNULL(1) G_NO_INLINE;
> >  bool virFileIsExecutable(const char *file) ATTRIBUTE_NONNULL(1);
> >  bool virFileIsRegular(const char *file) ATTRIBUTE_NONNULL(1);
> 
> -- 
> Regards,
> Praveen K Paladugu


Regards,
Pavan