]> andersk Git - moira.git/blobdiff - clients/moira/attach.c
install link for dcmmaint
[moira.git] / clients / moira / attach.c
index b84b6058a7b121f8fcaadcc9e1db70281f9c28e3..faa7f3da6f5b7d7dde15e7262d71008aa037be5e 100644 (file)
 #include <stdio.h>
 #include <strings.h>
 #include <sms.h>
+#include <sms_app.h>
 #include <menu.h>
 
 #include "mit-copyright.h"
 #include "defs.h"
 #include "f_defs.h"
 #include "globals.h"
-#include "infodefs.h"
 
 #define FS_ALIAS_TYPE "FILESYS"
 
 #define DEFAULT_MACHINE  DEFAULT_NONE
 #define DEFAULT_PACK     DEFAULT_NONE
 #define DEFAULT_M_POINT  DEFAULT_NONE
-#define DEFAULT_ACCESS   ("r")
+#define DEFAULT_ACCESS   ("w")
 #define DEFAULT_COMMENTS DEFAULT_COMMENT
 #define DEFAULT_OWNER    (user)
 #define DEFAULT_OWNERS   (user)
 #define DEFAULT_CREATE   DEFAULT_YES
-#define DEFAULT_L_TYPE   ("HOMEDIR")
+#define DEFAULT_L_TYPE   ("PROJECT")
 
 /*     Function Name: SetDefaults
  *     Description: sets the default values for filesystem additions.
@@ -94,22 +94,22 @@ char *name;
 
     switch (type) {
     case LABEL:
-       if ( (stat = sms_query("get_filesys_by_label", 1, &name,
-                              StoreInfo, (char *)&elem)) != 0) {
+       if ( (stat = do_sms_query("get_filesys_by_label", 1, &name,
+                                 StoreInfo, (char *)&elem)) != 0) {
            com_err(program_name, stat, NULL);
            return(NULL);
        }
        break;
     case MACHINE:
-       if ( (stat = sms_query("get_filesys_by_machine", 1, &name,
-                              StoreInfo, (char *)&elem)) != 0) {
+       if ( (stat = do_sms_query("get_filesys_by_machine", 1, &name,
+                                 StoreInfo, (char *)&elem)) != 0) {
            com_err(program_name, stat, NULL);
            return(NULL);
        }
        break;
     case GROUP:
-       if ( (stat = sms_query("get_filesys_by_group", 1, &name,
-                              StoreInfo, (char *)&elem)) != 0) {
+       if ( (stat = do_sms_query("get_filesys_by_group", 1, &name,
+                                 StoreInfo, (char *)&elem)) != 0) {
            com_err(program_name, stat, NULL);
            return(NULL);
        }
@@ -118,8 +118,8 @@ char *name;
        args[ALIAS_NAME] = name;
        args[ALIAS_TYPE] = FS_ALIAS_TYPE;
        args[ALIAS_TRANS] = "*";
-       if ( (stat = sms_query("get_alias", 3, args, StoreInfo, 
-                              (char *) &elem)) != 0) {
+       if ( (stat = do_sms_query("get_alias", 3, args, StoreInfo, 
+                                 (char *) &elem)) != 0) {
            com_err(program_name, stat, " in get_alias.");
            return(NULL);
        }
@@ -210,7 +210,7 @@ Bool name;
                         &newname);
     }
 
-    GetValueFromUser("Filesystem's Type", &info[FS_TYPE]);
+    GetTypeFromUser("Filesystem's Type", "filesys", &info[FS_TYPE]);
     GetValueFromUser("Filesystem's Machine", &info[FS_MACHINE]);
     strcpy(temp_buf, CanonicalizeHostname(info[FS_MACHINE]));
     free(info[FS_MACHINE]);
@@ -223,7 +223,7 @@ Bool name;
     GetValueFromUser("Filesystem's owners (group)", &info[FS_OWNERS]);
     GetYesNoValueFromUser("Automatically create this filesystem",
                     &info[FS_CREATE]);
-    GetValueFromUser("Filesystem's lockertype", &info[FS_L_TYPE]);
+    GetTypeFromUser("Filesystem's lockertype", "lockertype", &info[FS_L_TYPE]);
 
     FreeAndClear(&info[FS_MODTIME], TRUE);
     FreeAndClear(&info[FS_MODBY], TRUE);
@@ -280,8 +280,8 @@ Bool one_item;
     sprintf(temp_buf, "Are you sure that you want to delete filesystem %s",
            info[FS_NAME]);
     if(!one_item || Confirm(temp_buf)) {
-       if ( (stat = sms_query("delete_filesys", 1,
-                              &info[FS_NAME], Scream, NULL)) != 0)
+       if ( (stat = do_sms_query("delete_filesys", 1,
+                                 &info[FS_NAME], Scream, NULL)) != 0)
            com_err(program_name, stat, " filesystem not deleted.");
        else
            Put_message("Filesystem deleted.");
@@ -325,12 +325,29 @@ Bool junk;
 {
     int stat;
     char ** args = AskFSInfo(info, TRUE);
-
-    if ( (stat = sms_query("update_filesys", CountArgs(args), 
-                          args, NullFunc, NULL)) != 0)
-       com_err(program_name, stat, ", filesystem not updated");
-    else
-       Put_message("filesystem sucessfully updated.");
+    extern Menu nfsphys_menu;
+
+    stat = do_sms_query("update_filesys", CountArgs(args), args,
+                       NullFunc, NULL);
+    switch (stat) {
+    case SMS_NFS:
+       Put_message("That NFS filesystem is not exported.");
+       if (YesNoQuestion("Fix this now (Y/N)")) {
+           Do_menu(&nfsphys_menu, 0, NULL);
+           if (YesNoQuestion("Retry filesystem update now (Y/N)")) {
+               if (stat = do_sms_query("update_filesys", CountArgs(args), args,
+                                       NullFunc, NULL))
+                   com_err(program_name, stat, " filesystem not updated");
+               else
+                   Put_message("filesystem sucessfully updated.");
+           }
+       }
+       break;
+    case SMS_SUCCESS:
+       break;
+    default:
+       com_err(program_name, stat, " in UpdateFS");
+    }
 }
 
 /*     Function Name: ChangeFS
@@ -366,12 +383,13 @@ int argc;
 {
     char *info[MAX_ARGS_SIZE], **args;
     int stat;
+    extern Menu nfsphys_menu;
 
     if ( !ValidName(argv[1]) )
        return(DM_NORMAL);
 
-    if ( (stat = sms_query("get_filesys_by_label", 1, argv + 1,
-                          NullFunc, NULL)) == 0) {
+    if ( (stat = do_sms_query("get_filesys_by_label", 1, argv + 1,
+                             NullFunc, NULL)) == 0) {
        Put_message ("A Filesystem by that name already exists.");
        return(DM_NORMAL);
     } else if (stat != SMS_NO_MATCH) {
@@ -381,9 +399,26 @@ int argc;
 
     args = AskFSInfo(SetDefaults(info, argv[1]), FALSE );
 
-    if ( (stat = sms_query("add_filesys", CountArgs(args), args, 
-                        NullFunc, NULL)) != 0)
+    stat = do_sms_query("add_filesys", CountArgs(args), args, NullFunc, NULL);
+    switch (stat) {
+    case SMS_NFS:
+       Put_message("That NFS filesystem is not exported.");
+       if (YesNoQuestion("Fix this now (Y/N)")) {
+           Do_menu(&nfsphys_menu, 0, NULL);
+           if (YesNoQuestion("Retry filesystem creation now (Y/N)")) {
+               if (stat = do_sms_query("add_filesys", CountArgs(args), args,
+                                       NullFunc, NULL))
+                   com_err(program_name, stat, " in AddFS");
+               else
+                   Put_message("Created.");
+           }
+       }
+       break;
+    case SMS_SUCCESS:
+       break;
+    default:
        com_err(program_name, stat, " in AddFS");
+    }
 
     FreeInfo(info);
     return (DM_NORMAL);
@@ -446,8 +481,8 @@ char **argv;
  * print out values, free memory used and then exit.
  */
 
-    if ( (stat = sms_query("get_alias", 3, args, StoreInfo, 
-                          (char *)&elem)) == 0) {
+    if ( (stat = do_sms_query("get_alias", 3, args, StoreInfo, 
+                             (char *)&elem)) == 0) {
        top = elem = QueueTop(elem);
        while (elem != NULL) {
            info = (char **) elem->q_data;          
@@ -468,7 +503,7 @@ char **argv;
     GetValueFromUser("Which filesystem will this alias point to?",
                     &args[ALIAS_TRANS]);
 
-    if ( (stat = sms_query("add_alias", 3, args, NullFunc, NULL)) != 0)
+    if ( (stat = do_sms_query("add_alias", 3, args, NullFunc, NULL)) != 0)
        com_err(program_name, stat, " in CreateFSAlias.");
 
     FreeInfo(args);
@@ -499,8 +534,8 @@ Bool one_item;
            "Are you sure that you want to delete the filesystem alias %s",
            info[ALIAS_NAME]);
     if(!one_item || Confirm(temp_buf)) {
-       if ( (stat = sms_query("delete_alias", CountArgs(info),
-                              info, Scream, NULL)) != 0 )
+       if ( (stat = do_sms_query("delete_alias", CountArgs(info),
+                                 info, Scream, NULL)) != 0 )
            com_err(program_name, stat, " filesystem alias not deleted.");
        else
            Put_message("Filesystem alias deleted.");
@@ -554,14 +589,3 @@ AttachHelp()
 
     return(PrintHelp(message));
 }
-
-/* 
- * Local Variables:
- * mode: c
- * c-indent-level: 4
- * c-continued-statement-offset: 4
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * End:
- */
This page took 0.059004 seconds and 4 git commands to generate.