Update of /cvsroot/linux-decnet/dnprogs/dapfs
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17708
Modified Files:
dapfs.c dapfs.com dapfs_dap.cc filenames.c filenames.h
Log Message:
Fix reads & object proxy (properly this time)
add SETPROT command to the DAPFS.COM object so we can
set the protection on directories before renaming them.
Index: dapfs.c
===================================================================
RCS file: /cvsroot/linux-decnet/dnprogs/dapfs/dapfs.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** dapfs.c 26 Feb 2008 09:51:30 -0000 1.13
--- dapfs.c 26 Feb 2008 13:07:54 -0000 1.14
***************
*** 312,316 ****
char vmsname[VMSNAME_LEN];
! syslog(LOG_DEBUG, "open %s, flags=%x\n", path, fi->flags);
h = malloc(sizeof(struct dapfs_handle));
if (!h)
--- 312,318 ----
char vmsname[VMSNAME_LEN];
! if (debug&1)
! fprintf(stderr, "open %s, flags=%x\n", path, fi->flags);
!
h = malloc(sizeof(struct dapfs_handle));
if (!h)
***************
*** 327,330 ****
--- 329,335 ----
int saved_errno = errno;
free(h);
+
+ if (!saved_errno) // Catch all...TODO
+ saved_errno = -ENOENT;
return -saved_errno;
}
***************
*** 354,359 ****
if (!h) {
res = dapfs_open(path, fi);
! if (!res)
return res;
}
--- 359,365 ----
if (!h) {
res = dapfs_open(path, fi);
! if (res)
return res;
+ h = (struct dapfs_handle *)fi->fh;
}
***************
*** 385,390 ****
if (res == -1)
res = -errno;
! h->offset += res;
return res;
}
--- 391,399 ----
if (res == -1)
res = -errno;
+ else
+ h->offset += res;
! if (debug&1)
! fprintf(stderr, "dapfs_read: returning %d\n", res);
return res;
}
***************
*** 399,403 ****
if (!h) {
res = dapfs_open(path, fi);
! if (!res)
return res;
}
--- 408,412 ----
if (!h) {
res = dapfs_open(path, fi);
! if (res)
return res;
}
Index: dapfs.com
===================================================================
RCS file: /cvsroot/linux-decnet/dnprogs/dapfs/dapfs.com,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** dapfs.com 27 Oct 2005 08:50:21 -0000 1.3
--- dapfs.com 26 Feb 2008 13:07:55 -0000 1.4
***************
*** 39,45 ****
--- 39,47 ----
$ operation=f$edit(f$element(0, " ", command),"UPCASE")
$ dirname=f$element(1, " ", command)
+ $ prot=f$element(2, " ", command)
$!
$ if operation .eqs. "CREATE" then $goto create_op
$ if operation .eqs. "STATFS" then $goto statfs_op
+ $ if operation .eqs. "SETPROT" then $goto setprot_op
$ if operation .nes. "REMOVE" then $goto dir_error
$ set file/prot=(o:rwed) 'dirname'
***************
*** 65,68 ****
--- 67,77 ----
$ goto out
$!
+ $setprot_op:
+ $!
+ $ set prot='prot' 'dirname'
+ $ if $severity .ne. 1 then $goto dir_error
+ $ write dapfs "OK"
+ $ goto out
+ $!
$dir_error:
$ write dapfs "ERROR"
Index: dapfs_dap.cc
===================================================================
RCS file: /cvsroot/linux-decnet/dnprogs/dapfs/dapfs_dap.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** dapfs_dap.cc 26 Feb 2008 09:51:30 -0000 1.10
--- dapfs_dap.cc 26 Feb 2008 13:07:55 -0000 1.11
***************
*** 86,91 ****
return -1;
! strcpy((char *)accessdata.acc_acc, "ROOT");
! accessdata.acc_accl = 4;
np = getnodebyname(node);
--- 86,105 ----
return -1;
!
! // Try very hard to get the local username for proxy access.
! // This code copied from libdap for consistency
! char *local_user = cuserid(NULL);
! if (!local_user || local_user == (char *)0xffffffff)
! local_user = getenv("LOGNAME");
!
! if (!local_user) local_user = getenv("USER");
! if (local_user)
! {
! strcpy((char *)accessdata.acc_acc, local_user);
! accessdata.acc_accl = strlen((char *)accessdata.acc_acc);
! makeupper((char *)accessdata.acc_acc);
! }
! else
! accessdata.acc_acc[0] = '\0';
np = getnodebyname(node);
***************
*** 461,465 ****
return ret;
from = dirname;
- //TODO set prot=RWED on 'from' directory or we can't rename it!
}
--- 475,478 ----
***************
*** 467,472 ****
make_vms_filespec(to, vmsto, 0);
- /// TODO this does messes up directory grafts
if (from == dirname) {
if (vmsto[strlen(vmsto)-1] == '.')
strcat(vmsto, "DIR");
--- 480,499 ----
make_vms_filespec(to, vmsto, 0);
if (from == dirname) {
+
+ // Set prot=RWED on 'from' directory or we can't rename it.
+ // Don't regard this as fatal, subsequent calls will return -EPERM
+ // anyway if it's really wrong.
+ char setprot[BUFLEN];
+ char reply[BUFLEN];
+ int len;
+
+ sprintf(setprot, "SETPROT %s O:RWED", vmsfrom);
+ len = get_object_info(setprot, reply);
+ if (len != 2) // "OK"
+ syslog(LOG_WARNING, "dapfs: can't set protection on directory %s", vmsfrom);
+
+ // Fix the TO name too.
+ // TODO Odd dotting here, not sure why. just work around it for now
if (vmsto[strlen(vmsto)-1] == '.')
strcat(vmsto, "DIR");
Index: filenames.c
===================================================================
RCS file: /cvsroot/linux-decnet/dnprogs/dapfs/filenames.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** filenames.c 25 Feb 2008 17:20:28 -0000 1.6
--- filenames.c 26 Feb 2008 13:07:55 -0000 1.7
***************
*** 48,52 ****
}
! static void makeupper(char *s)
{
unsigned int i;
--- 48,52 ----
}
! void makeupper(char *s)
{
unsigned int i;
***************
*** 89,93 ****
if (slashes == 1)
{
! sprintf(vmsname, "[]%s", unixname+1);
return;
}
--- 89,93 ----
if (slashes == 1)
{
! sprintf(vmsname, "%s", unixname+1);
return;
}
Index: filenames.h
===================================================================
RCS file: /cvsroot/linux-decnet/dnprogs/dapfs/filenames.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** filenames.h 25 Feb 2008 17:20:28 -0000 1.3
--- filenames.h 26 Feb 2008 13:07:55 -0000 1.4
***************
*** 16,17 ****
--- 16,18 ----
void make_vms_filespec(const char *unixname, char *vmsname, int full);
void make_unix_filespec(char *unixname, char *vmsname);
+ void makeupper(char *s);
|