]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
pluginlib: Add named pipe support for Metaplugin extend STAT: command.
authorRadosław Korzeniewski <radoslaw@korzeniewski.net>
Wed, 10 Nov 2021 19:12:35 +0000 (20:12 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:56 +0000 (13:56 +0200)
bacula/src/plugins/fd/pluginlib/metaplugin_attributes.cpp
bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c

index d19c495444da73418d078df5ff57f5c76d8f2964..f69d1a88dec4f590f7f513f4e4ae73df913f9c1e 100644 (file)
@@ -82,9 +82,11 @@ namespace attributes
             sp->type = FT_DIREND;
             sp->link = sp->fname;
             break;
+
          case S_IFREG:
             sp->type = FT_REG;
             break;
+
          case S_IFLNK:
             {
                sp->type = FT_LNK;
@@ -102,6 +104,11 @@ namespace attributes
                DMSG1(ctx, DDEBUG, "read_scan_stat_command():readlink:%s\n", sp->link);
             }
             break;
+
+         case S_IFIFO:
+            sp->type = FT_SPEC;
+            break;
+
          default:
             DMSG1(ctx, DERROR, "Unsupported file type: %o\n", sp->statp.st_mode & S_IFMT);
             return Invalid_Stat_Packet;
index a888e150c603dbdfdd24adbea8494aef571d842d..7291fd921e8af15e9557fb6640e6b18230fa14fd 100644 (file)
@@ -57,6 +57,7 @@ pid_t mypid;
 char *buf;
 char *buflog;
 char symlink_fname[32];
+char namedpipe_fname[32];
 
 bool regress_error_plugin_params = false;
 bool regress_error_start_job = false;
@@ -1195,15 +1196,20 @@ void perform_backup()
    write_plugin('C', buf);
    write_plugin('I', "TEST18S");
    signal_eod();
-   // here comes a file data contents
-   write_plugin('C', "DATA\n");
-   write_plugin('D', "/* here comes a file data contents */");
-   write_plugin('D', "/* here comes another file line    */");
-   write_plugin('D', "/* here comes another file line    */");
-   write_plugin('D', "/* here comes another file line    */");
-   write_plugin('D', "/* here comes another file line    */");
    signal_eod();
-   write_plugin('I', "TEST18S_Data");
+
+   // now test `STAT:/path/to/file` using named pipe
+   snprintf(namedpipe_fname, 32, "/tmp/namedpipe.%d", mypid);
+   mkfifo(namedpipe_fname, 0600);
+
+   // the file with external stat(2) packet
+   snprintf(buf, BIGBUFLEN, "FNAME:%s/java/%d/stat.namedpipe\n", PLUGINPREFIX, mypid);
+   write_plugin('C', buf);
+   snprintf(buf, BIGBUFLEN, "STAT:%s\n", namedpipe_fname);
+   write_plugin('C', buf);
+   write_plugin('I', "TEST18NP");
+   signal_eod();
+   signal_eod();
 
    // this plugin object should be the latest item to backup
    if (regress_backup_plugin_objects)
@@ -1793,8 +1799,10 @@ int main(int argc, char** argv) {
 
 Term:
    signal_term();
-   // LOG("#> Unlink symlink_fname.");
-   // unlink(symlink_fname);
+   LOG("#> Unlink symlink_fname.");
+   unlink(symlink_fname);
+   LOG("#> Unlink namedpipe_fname.");
+   unlink(namedpipe_fname);
    LOG("#> Terminating backend.");
    close(logfd);
    free(buf);