Hintergrund: Ich habe mehrere Server, die abwechselnd mal laufen und den Stream aufnehmen und suchte nach einer Automatik, die das Aufnahmeverzeichnis einem verfügbaren Server zuordnet. Irgendwie habe ich dafür kein normales Linux-Tool gefunden (Oder ich bin mal wieder an meinen Linux Kenntnissen gescheitert)
Code: Alles auswählen
--- stream2file.cpp.orig 2004-08-05 00:23:53.015625000 +0200
+++ stream2file.cpp 2004-08-05 00:34:24.859375000 +0200
@@ -34,6 +34,10 @@
#include <stream2file.h>
+#include <global.h>
+#include "../gui/nfs.h"
+#include <sys/mount.h>
+
#include <eventserver.h>
#include <neutrinoMessages.h>
@@ -430,16 +434,40 @@
// write stream information (should wakeup the disk from standby, too)
sprintf(buf, "%s.xml", filename);
- if ((fd = open(buf, O_SYNC | O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0)
- {
- write(fd, info, strlen(info));
- fdatasync(fd);
- close(fd);
- }
- else
+
+ for(int i = 0; i <= 4; i++)
{
- DEC_BUSY_COUNT
- return STREAM2FILE_INVALID_DIRECTORY;
+ if ((fd = open(buf, O_SYNC | O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0)
+ {
+ write(fd, info, strlen(info));
+ fdatasync(fd);
+ close(fd);
+ break;
+ }
+ else
+ printf("[record] %d. try failed: Can't write to directory\n", i);
+
+ if(i == 4)
+ {
+ DEC_BUSY_COUNT
+ return STREAM2FILE_INVALID_DIRECTORY;
+ }
+
+ if (strlen(g_settings.network_nfs_ip[i].c_str()) == 0 ||
+ strlen(g_settings.network_nfs_dir[i]) == 0 ||
+ strlen(g_settings.network_nfs_local_dir[i]) == 0)
+ continue;
+
+ if(strncmp(buf, g_settings.network_nfs_local_dir[i], strlen(g_settings.network_nfs_local_dir[i])) == 0)
+ {
+ printf("remount %s to %s:%s\n", g_settings.network_nfs_local_dir[i], g_settings.network_nfs_ip[i].c_str(), g_settings.network_nfs_dir[i]);
+
+ umount2(g_settings.network_nfs_local_dir[i],MNT_FORCE);
+
+ CNFSMountGui::mount(g_settings.network_nfs_ip[i].c_str(), g_settings.network_nfs_dir[i], g_settings.network_nfs_local_dir[i],
+ (CNFSMountGui::FSType) g_settings.network_nfs_type[i], g_settings.network_nfs_username[i],
+ g_settings.network_nfs_password[i], false);
+ }
}
if (splitsize < TS_SIZE)