/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/stds.h>
-RCSID
- ("$Header$");
+#include <afs/procmgmt.h>
+#include <roken.h>
+#include <afs/opr.h>
-#include <afs/stds.h>
-#ifdef AFS_AIX32_ENV
-#include <signal.h>
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
#ifdef AFS_NT40_ENV
-#include <fcntl.h>
-#include <winsock2.h>
#include <WINNT/afsevent.h>
#include <sys/utime.h>
-#include <afs/dirent.h>
#include <direct.h>
-#include <process.h>
-#include <io.h>
-#include <afs/procmgmt.h>
-#else
-#include <sys/file.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/time.h>
-#include <dirent.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
#endif
+
+#ifdef AFS_AIX_ENV
+#include <sys/statfs.h>
#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <errno.h>
+
#include <rx/xdr.h>
#include <rx/rx.h>
#include <rx/rxkad.h>
#include <afs/cellconfig.h>
#include <afs/afsutil.h>
#include <afs/fileutil.h>
-#ifdef AFS_AIX_ENV
-#include <sys/statfs.h>
-#endif
+
#include "update.h"
#include "global.h"
+#include "update_internal.h"
char *whoami;
static int verbose;
afs_int32 atime, afs_int32 mtime);
static int RenameNewFiles(struct filestr *modFiles);
static int PathsAreEquivalent(char *path1, char *path2);
+int FetchFile(struct rx_call *, char *, char *, int);
+int IsCompatible(char *, afs_int32, afs_int32);
+int NotOnHost(char *, struct filestr *);
+int update_ReceiveFile(int, struct rx_call *, struct stat *);
afs_int32
GetServer(char *aname)
{
- register struct hostent *th;
+ struct hostent *th;
afs_int32 addr;
th = gethostbyname(aname);
int
-osi_audit()
+osi_audit(void)
{
/* this sucks but it works for now.
*/
afs_uint32 mode;
int error;
- char hostname[MAXSIZE];
+ char hostname[MAXFNSIZE];
FILE *stream;
afs_int32 time, length, atime;
struct filestr *df;
int a, cnt;
rxkad_level level;
- char dirbuf[MAXSIZE], filename[MAXSIZE];
+ char dirbuf[MAXFNSIZE], filename[MAXFNSIZE];
struct filestr *dirname, *ModFiles, *okhostfiles;
#ifdef AFS_AIX32_ENV
/*
- * The following signal action for AIX is necessary so that in case of a
- * crash (i.e. core is generated) we can include the user's data section
+ * The following signal action for AIX is necessary so that in case of a
+ * crash (i.e. core is generated) we can include the user's data section
* in the core dump. Unfortunately, by default, only a partial core is
* generated which, in many cases, isn't too useful.
*/
if (verbose >= 3)
printf(" checking %s\n", filename);
if (!IsCompatible(filename, time, length)) {
- /* if the file info has changed , record all the
+ /* if the file info has changed , record all the
*changed files in the ModFiles array*/
if (verbose >= 2)
printf(" getting %s\n", filename);
AddToList(&ModFiles, filename);
- /* now get the file from the server. The received
+ /* now get the file from the server. The received
* file is created under the name filename.NEW */
errcode =
GetFileFromUpServer(conn, filename, uid, gid, mode,
{ /*delete all the redundant files on the client */
DIR *dirp;
struct dirent *dp;
- char filename[MAXSIZE];
+ char filename[MAXFNSIZE];
dirp = opendir(curDir);
if (dirp == 0) {
/* returns 1 if the file is upto date else returns 0*/
/*check the dir case more carefully */
int
-IsCompatible(char *filename, afs_int32 time, afs_int32 length)
+IsCompatible(char *filename, afs_int32 time, afs_int32 length)
{
struct stat status;
afs_int32 error;
if (fstat(fd, &status) < 0) {
afs_com_err(whoami, errno, "Could not stat %s", localFile);
close(fd);
- printf("could not stast %s\n", localFile);
+ printf("could not stat %s\n", localFile);
return UPDATE_ERROR;
}
if (update_ReceiveFile(fd, call, &status))
int
-update_ReceiveFile(register int fd, register struct rx_call *call, register struct stat *status)
+update_ReceiveFile(int fd, struct rx_call *call, struct stat *status)
{
- register char *buffer = (char *)0;
+ char *buffer = (char *)0;
afs_int32 length;
- register int blockSize;
+ int blockSize;
afs_int32 error = 0, len;
#ifdef AFS_AIX_ENV
struct statfs tstatfs;
#endif
- len = rx_Read(call, &length, sizeof(afs_int32));
+ len = rx_Read(call, (char *)&length, sizeof(afs_int32));
length = ntohl(length);
if (len != sizeof(afs_int32))
return UPDATE_ERROR;
#else
blockSize = status->st_blksize;
#endif
- buffer = (char *)malloc(blockSize);
+ buffer = malloc(blockSize);
if (!buffer) {
printf("malloc failed\n");
return UPDATE_ERROR;
}
while (!error && length) {
- register int nbytes = (length > blockSize ? blockSize : length);
+ int nbytes = (length > blockSize ? blockSize : length);
nbytes = rx_Read(call, buffer, nbytes);
if (!nbytes)
error = UPDATE_ERROR;
static int
RenameNewFiles(struct filestr *modFiles)
{
- char newname[MAXSIZE];
+ char newname[MAXFNSIZE];
char *fname;
int errcode = 0;
struct filestr *tf;
/* GetFileFromUpServer() - Makes the FetchFile() call and gets the
- * file from the upserver.
+ * file from the upserver.
* Return Values:
* 0 - Alls well
* -1 - Serious error. Quit right away.
- * 1 - Error, but keep trying for the other files
- *
+ * 1 - Error, but keep trying for the other files
+ *
* The file obtained is written to the localized version of the filename.NEW
* and the uid, gid, file mode, access and modification times will be set to
* the passed in values.
#else
struct timeval tvp[2];
#endif
- char newfile[MAXSIZE];
+ char newfile[MAXFNSIZE];
/* construct local path from canonical (wire-format) path */
errcode = ConstructLocalPath(filename, "/", &lfile);
if (errcode) {
printf("failed to fetch file %s \n", filename);
afs_com_err(whoami, errcode, "fetching file");
+ unlink(newfile);
return 1;
}
(unsigned int)mode);
afs_com_err(whoami, errno, "could not change protection on %s to %u",
newfile, mode);
+ unlink(newfile);
return 1;
}
#ifdef AFS_NT40_ENV
afs_com_err(whoami, errno,
"could not change access and modify times on %s to %u %u",
newfile, atime, mtime);
+ unlink(newfile);
return 1;
}