source: trunk/athena/bin/xquota/main.c @ 5098

Revision 5098, 3.5 KB checked in by probe, 33 years ago (diff)
Handle AFS home directories.
Line 
1/*
2 * xquota -  X window system quota display program.
3 *
4 * $Athena: man.c,v 1.7 89/02/15 16:06:44 kit Exp $
5 *
6 * Copyright 1989 Massachusetts Institute of Technology
7 *
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation for any purpose and without fee is hereby granted, provided
10 * that the above copyright notice appear in all copies and that both that
11 * copyright notice and this permission notice appear in supporting
12 * documentation, and that the name of M.I.T. not be used in advertising or
13 * publicity pertaining to distribution of the software without specific,
14 * written prior permission.  M.I.T. makes no representations about the
15 * suitability of this software for any purpose.  It is provided "as is"
16 * without express or implied warranty.
17 *
18 * Author:    Chris D. Peterson, MIT Project Athena
19 * Created:   March 5, 1989
20 */
21
22#if ( !defined(lint) && !defined(SABER))
23  static char rcs_version[] = "$Athena: man.c,v 4.7 89/02/15 20:09:34 kit Locked $";
24#endif
25
26#include <stdio.h>
27#include <X11/Intrinsic.h>
28
29#include <pwd.h>
30#include <hesiod.h>
31#include <ctype.h>
32
33#include "xquota.h"
34
35#define FILSYS ("filsys")
36#define NFS    ("NFS")
37#define AFS    ("AFS")
38
39static void ParseHesiodInfo();
40static void GetUserFilsys();
41
42Info info;                      /* external for action proc only. */
43
44int homeIsAFS = 0;
45
46/*      Function Name: main
47 *      Description: main driver for the quota check program.
48 *      Arguments: argc, argv - you all know about these right?
49 *      Returns: none.
50 */
51
52void
53main(argc, argv)
54int argc;
55char ** argv;
56{
57  Widget top;
58
59  GetUserFilsys(&info);
60
61  top = InitializeWorld(&info, &argc, argv);
62  CreateWidgets(top, &info);
63
64  XtRealizeWidget(top);
65  XtAppMainLoop(info.appcon);
66}
67
68/*      Function Name: GetQuota
69 *      Description: Gets the quota for user who invoke this program.
70 *      Arguments: dqblk - the quota info ** RETURNED **
71 *      Returns: none.
72 */
73
74static void
75GetUserFilsys(info)
76Info * info;
77{
78  struct passwd *user_info;
79  char ** hesinfo;
80  char *type;
81
82/*
83 * Proceedure:
84 *
85 * o Get users filsys entries from hesiod.
86 * o Use first entry only.
87 * o If it is not an NFS or AFS filsys or hesiod failed the give up.
88 */
89
90  info->uid = getuid();
91  user_info = getpwuid(info->uid);
92  hesinfo = hes_resolve(user_info->pw_name, FILSYS);
93  if ( hesinfo != NULL ) {
94    ParseHesiodInfo(*hesinfo, &type, &(info->host), &(info->path) );
95    if ( !streq(type, NFS) && !streq(type, AFS) ) {
96      printf("Your home filesystem is not NFS or AFS, giving up.\n");
97      exit(0);
98    }
99    if (streq(type, AFS)) {
100        homeIsAFS = 1;
101        info->host = "AFS cell";
102    }
103  }
104  else {
105    printf("hesiod failure, giving up.\n");
106    hes_error();
107    exit(0);
108  }
109
110  hesinfo++;                    /* We are still using this space. */
111
112  if (*hesinfo != NULL) {
113    printf("You have more than one filesystem we will only provide a quota\n");
114    printf("graph for the filsys: %s on machine %s.\n",
115           info->path, info->host);
116    while (*hesinfo != NULL)    /* clean up. */
117      free(*hesinfo++);
118  }
119}
120
121/*      Function Name: ParseHesiodInfo
122 *      Description: Parses a hesiod filsys entry.
123 *      Arguments: string - string from hesiod.
124 *                 type - type of filsys ** RETURNED **
125 *                 host - host of filsys ** RETURNED **
126 *                 path - path to filsys ** RETURNED **
127 *      Returns: none
128 */
129
130static void
131ParseHesiodInfo(string, type, host, path)
132char * string;
133char **type, **host, **path;
134{
135  char * c = string;
136
137  *type = string;
138  while( !isspace(*c) ) c++;
139  *c = '\0';
140  *path = ++c;
141  while( !isspace(*c) ) c++;
142  *c = '\0';
143  *host = ++c;
144  while( !isspace(*c) ) c++;
145  *c = '\0';
146}
Note: See TracBrowser for help on using the repository browser.