From 872bc94f8ce5d38f0a12e7cec455a2cb368b7427 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Wed, 16 Jul 2003 00:28:24 +0000 Subject: [PATCH] reindent-20030715 FIXES 1774 thanks to nneul@umr.edu for providing a script to do this. gnu indent 2.2.9 options: -npro -nbad -bap -nbc -bbo -br -ce -cdw -brs -ncdb -cp1 -ncs -di2 -ndj -nfc1 -nfca -i4 -lp -npcs -nprs -psl -sc -nsob -ts8 ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== FIXES 1774 fix subst mistake --- acconfig.h | 9 - src/JAVA/libjafs/ACL.c | 125 +- src/JAVA/libjafs/AdminToken.c | 398 +- src/JAVA/libjafs/Cell.c | 1619 ++-- src/JAVA/libjafs/Exceptions.h | 11 +- src/JAVA/libjafs/File.c | 582 +- src/JAVA/libjafs/FileInputStream.c | 131 +- src/JAVA/libjafs/FileOutputStream.c | 162 +- src/JAVA/libjafs/Group.c | 1013 ++- src/JAVA/libjafs/Internal.c | 1329 +-- src/JAVA/libjafs/Internal.h | 85 +- src/JAVA/libjafs/Key.c | 252 +- src/JAVA/libjafs/Partition.c | 465 +- src/JAVA/libjafs/Process.c | 653 +- src/JAVA/libjafs/Server.c | 1883 ++-- src/JAVA/libjafs/User.c | 2017 ++--- src/JAVA/libjafs/UserToken.c | 344 +- src/JAVA/libjafs/Volume.c | 965 ++- src/afs/AIX/osi_config.c | 376 +- src/afs/AIX/osi_file.c | 165 +- src/afs/AIX/osi_groups.c | 58 +- src/afs/AIX/osi_inode.c | 431 +- src/afs/AIX/osi_machdep.h | 2 +- src/afs/AIX/osi_misc.c | 57 +- src/afs/AIX/osi_sleep.c | 64 +- src/afs/AIX/osi_timeout.c | 545 +- src/afs/AIX/osi_vfs.h | 5 +- src/afs/AIX/osi_vfsops.c | 101 +- src/afs/AIX/osi_vm.c | 73 +- src/afs/AIX/osi_vnodeops.c | 2327 ++--- src/afs/DARWIN/osi_file.c | 228 +- src/afs/DARWIN/osi_groups.c | 76 +- src/afs/DARWIN/osi_inode.c | 200 +- src/afs/DARWIN/osi_inode.h | 4 +- src/afs/DARWIN/osi_machdep.h | 8 +- src/afs/DARWIN/osi_misc.c | 47 +- src/afs/DARWIN/osi_module.c | 79 +- src/afs/DARWIN/osi_prototypes.h | 2 +- src/afs/DARWIN/osi_sleep.c | 111 +- src/afs/DARWIN/osi_vfsops.c | 319 +- src/afs/DARWIN/osi_vm.c | 280 +- src/afs/DARWIN/osi_vnodeops.c | 1149 +-- src/afs/DUX/osi_file.c | 241 +- src/afs/DUX/osi_groups.c | 62 +- src/afs/DUX/osi_inode.c | 180 +- src/afs/DUX/osi_inode.h | 2 +- src/afs/DUX/osi_misc.c | 10 +- src/afs/DUX/osi_sleep.c | 65 +- src/afs/DUX/osi_vfsops.c | 178 +- src/afs/DUX/osi_vm.c | 41 +- src/afs/DUX/osi_vnodeops.c | 703 +- src/afs/FBSD/osi_file.c | 3 +- src/afs/FBSD/osi_groups.c | 71 +- src/afs/FBSD/osi_inode.c | 163 +- src/afs/FBSD/osi_inode.h | 2 +- src/afs/FBSD/osi_machdep.h | 4 +- src/afs/FBSD/osi_misc.c | 5 +- src/afs/FBSD/osi_module.c | 8 +- src/afs/FBSD/osi_prototypes.h | 2 +- src/afs/FBSD/osi_sleep.c | 3 +- src/afs/FBSD/osi_vfsops.c | 3 +- src/afs/FBSD/osi_vm.c | 66 +- src/afs/FBSD/osi_vnodeops.c | 803 +- src/afs/FBSD/vnode_if_4x.h | 2243 +++-- src/afs/FBSD/vnode_if_5x.h | 2473 +++--- src/afs/HPUX/osi_debug.c | 3 +- src/afs/HPUX/osi_file.c | 132 +- src/afs/HPUX/osi_groups.c | 124 +- src/afs/HPUX/osi_inode.c | 325 +- src/afs/HPUX/osi_inode.h | 3 +- src/afs/HPUX/osi_machdep.h | 6 +- src/afs/HPUX/osi_misc.c | 6 +- src/afs/HPUX/osi_sleep.c | 115 +- src/afs/HPUX/osi_vfs.h | 8 +- src/afs/HPUX/osi_vfsops.c | 106 +- src/afs/HPUX/osi_vm.c | 28 +- src/afs/HPUX/osi_vnodeops.c | 2721 +++--- src/afs/IRIX/osi_file.c | 146 +- src/afs/IRIX/osi_groups.c | 181 +- src/afs/IRIX/osi_idbg.c | 167 +- src/afs/IRIX/osi_inode.c | 775 +- src/afs/IRIX/osi_inode.h | 10 +- src/afs/IRIX/osi_machdep.h | 2 +- src/afs/IRIX/osi_misc.c | 33 +- src/afs/IRIX/osi_sleep.c | 64 +- src/afs/IRIX/osi_vfs.h | 110 +- src/afs/IRIX/osi_vfsops.c | 520 +- src/afs/IRIX/osi_vm.c | 65 +- src/afs/IRIX/osi_vnodeops.c | 1336 +-- src/afs/LINUX/osi_alloc.c | 222 +- src/afs/LINUX/osi_cred.c | 32 +- src/afs/LINUX/osi_file.c | 129 +- src/afs/LINUX/osi_groups.c | 87 +- src/afs/LINUX/osi_inode.c | 16 +- src/afs/LINUX/osi_machdep.h | 22 +- src/afs/LINUX/osi_misc.c | 195 +- src/afs/LINUX/osi_module.c | 389 +- src/afs/LINUX/osi_prototypes.h | 18 +- src/afs/LINUX/osi_sleep.c | 80 +- src/afs/LINUX/osi_sysctl.c | 65 +- src/afs/LINUX/osi_vfsops.c | 124 +- src/afs/LINUX/osi_vm.c | 21 +- src/afs/LINUX/osi_vnodeops.c | 853 +- src/afs/NBSD/osi_file.c | 135 +- src/afs/NBSD/osi_groups.c | 62 +- src/afs/NBSD/osi_inode.c | 164 +- src/afs/NBSD/osi_inode.h | 2 +- src/afs/NBSD/osi_misc.c | 10 +- src/afs/NBSD/osi_sleep.c | 67 +- src/afs/NBSD/osi_vfsops.c | 165 +- src/afs/NBSD/osi_vm.c | 42 +- src/afs/NBSD/osi_vnodeops.c | 673 +- src/afs/OBSD/osi_file.c | 57 +- src/afs/OBSD/osi_groups.c | 49 +- src/afs/OBSD/osi_machdep.h | 13 +- src/afs/OBSD/osi_misc.c | 15 +- src/afs/OBSD/osi_sleep.c | 23 +- src/afs/OBSD/osi_vfsops.c | 105 +- src/afs/OBSD/osi_vm.c | 20 +- src/afs/OBSD/osi_vnodeops.c | 541 +- src/afs/SOLARIS/osi_file.c | 193 +- src/afs/SOLARIS/osi_groups.c | 64 +- src/afs/SOLARIS/osi_inode.c | 121 +- src/afs/SOLARIS/osi_inode.h | 4 +- src/afs/SOLARIS/osi_machdep.h | 19 +- src/afs/SOLARIS/osi_prototypes.h | 10 +- src/afs/SOLARIS/osi_sleep.c | 59 +- src/afs/SOLARIS/osi_vfsops.c | 177 +- src/afs/SOLARIS/osi_vm.c | 60 +- src/afs/SOLARIS/osi_vnodeops.c | 1320 +-- src/afs/UKERNEL/afs_usrops.c | 1363 +-- src/afs/UKERNEL/afs_usrops.h | 18 +- src/afs/UKERNEL/osi_groups.c | 39 +- src/afs/UKERNEL/osi_machdep.h | 3 +- src/afs/UKERNEL/osi_vfsops.c | 63 +- src/afs/UKERNEL/osi_vm.c | 20 +- src/afs/UKERNEL/osi_vnodeops.c | 72 +- src/afs/UKERNEL/sysincludes.h | 447 +- src/afs/VNOPS/afs_vnop_access.c | 218 +- src/afs/VNOPS/afs_vnop_attrs.c | 323 +- src/afs/VNOPS/afs_vnop_create.c | 299 +- src/afs/VNOPS/afs_vnop_dirops.c | 204 +- src/afs/VNOPS/afs_vnop_fid.c | 45 +- src/afs/VNOPS/afs_vnop_flock.c | 584 +- src/afs/VNOPS/afs_vnop_link.c | 99 +- src/afs/VNOPS/afs_vnop_lookup.c | 1036 +-- src/afs/VNOPS/afs_vnop_open.c | 81 +- src/afs/VNOPS/afs_vnop_read.c | 492 +- src/afs/VNOPS/afs_vnop_readdir.c | 685 +- src/afs/VNOPS/afs_vnop_remove.c | 256 +- src/afs/VNOPS/afs_vnop_rename.c | 208 +- src/afs/VNOPS/afs_vnop_strategy.c | 53 +- src/afs/VNOPS/afs_vnop_symlink.c | 266 +- src/afs/VNOPS/afs_vnop_write.c | 478 +- src/afs/afs.h | 538 +- src/afs/afs_analyze.c | 680 +- src/afs/afs_axscache.c | 111 +- src/afs/afs_axscache.h | 7 +- src/afs/afs_buffer.c | 323 +- src/afs/afs_call.c | 1638 ++-- src/afs/afs_callback.c | 485 +- src/afs/afs_cbqueue.c | 360 +- src/afs/afs_cbqueue.h | 15 - src/afs/afs_cell.c | 245 +- src/afs/afs_chunk.c | 57 +- src/afs/afs_chunkops.h | 53 +- src/afs/afs_conn.c | 346 +- src/afs/afs_daemons.c | 843 +- src/afs/afs_dcache.c | 1541 ++-- src/afs/afs_dynroot.c | 187 +- src/afs/afs_exporter.c | 26 +- src/afs/afs_init.c | 415 +- src/afs/afs_lock.c | 232 +- src/afs/afs_mariner.c | 82 +- src/afs/afs_memcache.c | 864 +- src/afs/afs_nfsclnt.c | 167 +- src/afs/afs_nfsdisp.c | 1837 ++-- src/afs/afs_osi.c | 363 +- src/afs/afs_osi.h | 44 +- src/afs/afs_osi_alloc.c | 173 +- src/afs/afs_osi_pag.c | 125 +- src/afs/afs_osi_uio.c | 34 +- src/afs/afs_osi_vget.c | 14 +- src/afs/afs_osidnlc.c | 698 +- src/afs/afs_osidnlc.h | 22 +- src/afs/afs_pioctl.c | 2418 +++--- src/afs/afs_prototypes.h | 654 +- src/afs/afs_segments.c | 1188 +-- src/afs/afs_server.c | 1496 ++-- src/afs/afs_stat.c | 31 +- src/afs/afs_stats.h | 1322 +-- src/afs/afs_user.c | 278 +- src/afs/afs_util.c | 229 +- src/afs/afs_util.h | 2 +- src/afs/afs_vcache.c | 1313 +-- src/afs/afs_volume.c | 500 +- src/afs/exporter.h | 40 +- src/afs/lock.h | 48 +- src/afs/longc_procs.h | 54 +- src/afs/nfsclient.h | 13 +- src/afs/sysincludes.h | 40 +- src/afs/voldefs.h | 2 +- src/afs/volerrors.h | 24 +- src/afsd/afsd.c | 1803 ++-- src/afsd/vsys.c | 30 +- src/afsmonitor/afsmon-labels.h | 3420 ++++---- src/afsmonitor/afsmon-output.c | 955 +- src/afsmonitor/afsmon-parselog.c | 781 +- src/afsmonitor/afsmon-win.c | 3654 ++++---- src/afsmonitor/afsmonitor.c | 5411 ++++++------ src/afsmonitor/afsmonitor.h | 52 +- src/afsweb/apache_afs_cache.c | 429 +- src/afsweb/apache_afs_cache.h | 16 +- src/afsweb/apache_afs_client.c | 1390 +-- src/afsweb/apache_afs_module.c | 513 +- src/afsweb/apache_afs_plugin.c | 923 +- src/afsweb/apache_afs_utils.c | 337 +- src/afsweb/apache_afs_utils.h | 12 +- src/afsweb/apache_afs_weblog.c | 331 +- src/afsweb/apache_api.h | 2 +- src/afsweb/apache_includes/1.2/alloc.h | 90 +- src/afsweb/apache_includes/1.2/buff.h | 65 +- src/afsweb/apache_includes/1.2/conf.h | 140 +- .../apache_includes/1.2/http_conf_globals.h | 1 - src/afsweb/apache_includes/1.2/httpd.h | 375 +- src/afsweb/apache_includes/1.3.1/alloc.h | 225 +- src/afsweb/apache_includes/1.3.1/ap.h | 39 +- src/afsweb/apache_includes/1.3.1/ap_compat.h | 4 +- src/afsweb/apache_includes/1.3.1/ap_config.h | 243 +- src/afsweb/apache_includes/1.3.1/ap_ctype.h | 3 +- src/afsweb/apache_includes/1.3.1/buff.h | 161 +- .../apache_includes/1.3.1/http_conf_globals.h | 59 +- src/afsweb/apache_includes/1.3.1/httpd.h | 635 +- src/afsweb/apache_includes/1.3.1/os.h | 8 +- src/afsweb/apache_includes/1.3.1/util_uri.h | 71 +- src/afsweb/apache_includes/1.3.6/alloc.h | 234 +- src/afsweb/apache_includes/1.3.6/ap.h | 35 +- src/afsweb/apache_includes/1.3.6/ap_compat.h | 3 +- src/afsweb/apache_includes/1.3.6/ap_config.h | 251 +- src/afsweb/apache_includes/1.3.6/ap_ctype.h | 3 +- src/afsweb/apache_includes/1.3.6/ap_mmn.h | 4 +- src/afsweb/apache_includes/1.3.6/buff.h | 161 +- .../apache_includes/1.3.6/http_conf_globals.h | 61 +- src/afsweb/apache_includes/1.3.6/httpd.h | 671 +- src/afsweb/apache_includes/1.3.6/os-inline.c | 5 +- src/afsweb/apache_includes/1.3.6/os.h | 10 +- src/afsweb/apache_includes/1.3.6/util_uri.h | 71 +- src/afsweb/apache_includes/alloc.h | 90 +- src/afsweb/apache_includes/buff.h | 65 +- src/afsweb/apache_includes/conf.h | 140 +- .../apache_includes/http_conf_globals.h | 1 - src/afsweb/apache_includes/httpd.h | 375 +- src/afsweb/nsafs.c | 524 +- src/afsweb/nsafs.h | 21 +- src/afsweb/securehash.c | 54 +- src/afsweb/weblog.c | 1231 +-- src/afsweb/weblog_errors.h | 5 +- src/audit/audit.c | 640 +- src/audit/audit.h | 43 +- src/auth/auth.p.h | 37 +- src/auth/authcon.c | 102 +- src/auth/cellconfig.c | 658 +- src/auth/cellconfig.p.h | 84 +- src/auth/copyauth.c | 30 +- src/auth/ktc.c | 973 ++- src/auth/ktc_nt.c | 1142 ++- src/auth/setkey.c | 110 +- src/auth/test/ktctest.c | 61 +- src/auth/test/testcellconf.c | 46 +- src/auth/userok.c | 315 +- src/auth/writeconfig.c | 111 +- src/bozo/bnode.c | 479 +- src/bozo/bnode.p.h | 128 +- src/bozo/bos.c | 1397 +-- src/bozo/bos_util.c | 77 +- src/bozo/bosoprocs.c | 1182 +-- src/bozo/bosserver.c | 464 +- src/bozo/cronbnodeops.c | 165 +- src/bozo/ezbnodeops.c | 93 +- src/bozo/fsbnodeops.c | 434 +- src/bozo/smail-notifier.c | 132 +- src/bozo/test/testproc.c | 27 +- src/bu_utils/fms.c | 156 +- src/bubasics/bubasics.h | 134 +- src/bubasics/butm.p.h | 108 +- src/bubasics/tcdata.p.h | 120 +- src/bucoord/bc.p.h | 114 +- src/bucoord/bc_status.c | 301 +- src/bucoord/btest.c | 9 +- src/bucoord/commands.c | 3248 ++++--- src/bucoord/config.c | 107 +- src/bucoord/dlq.c | 107 +- src/bucoord/dsstub.c | 184 +- src/bucoord/dsvs.c | 373 +- src/bucoord/dump.c | 415 +- src/bucoord/dump_sched.c | 383 +- src/bucoord/error_macros.h | 1 - src/bucoord/expire.c | 367 +- src/bucoord/main.c | 733 +- src/bucoord/regex.c | 530 +- src/bucoord/restore.c | 740 +- src/bucoord/server.c | 12 +- src/bucoord/status.c | 77 +- src/bucoord/tape_hosts.c | 235 +- src/bucoord/ttest.c | 115 +- src/bucoord/ubik_db_if.c | 1055 ++- src/bucoord/vol_sets.c | 459 +- src/bucoord/volstub.c | 75 +- src/budb/budb_client.p.h | 42 +- src/budb/database.c | 176 +- src/budb/database.h | 241 +- src/budb/db_alloc.c | 197 +- src/budb/db_dump.c | 448 +- src/budb/db_hash.c | 1084 +-- src/budb/db_lock.c | 174 +- src/budb/db_lock.h | 19 +- src/budb/db_text.c | 323 +- src/budb/dbs_dump.c | 194 +- src/budb/globals.h | 72 +- src/budb/ol_verify.c | 1196 +-- src/budb/procs.c | 3971 +++++---- src/budb/server.c | 330 +- src/budb/struct_ops.c | 239 +- src/butc/butc_xbsa.c | 746 +- src/butc/butc_xbsa.h | 82 +- src/butc/common.h | 28 +- src/butc/dbentries.c | 559 +- src/butc/dump.c | 2251 ++--- src/butc/list.c | 108 +- src/butc/lwps.c | 2711 +++--- src/butc/read_tape.c | 937 +- src/butc/recoverDb.c | 690 +- src/butc/tcmain.c | 1015 ++- src/butc/tcprocs.c | 493 +- src/butc/tcstatus.c | 112 +- src/butc/tcudbprocs.c | 1262 +-- src/butc/tdump.c | 36 +- src/butc/test.c | 213 +- src/butc/test_budb.c | 463 +- src/butm/butm_test.c | 206 +- src/butm/error_macros.h | 1 - src/butm/file_tm.c | 1781 ++-- src/butm/test_ftm.c | 528 +- src/cmd/cmd.c | 691 +- src/cmd/cmd.p.h | 49 +- src/cmd/test/ctest.c | 33 +- src/cmd/test/dtest.c | 25 +- src/cmd/test/itest.c | 46 +- src/comerr/com_err.c | 28 +- src/comerr/com_err.h | 16 +- src/comerr/compile_et.c | 261 +- src/comerr/error_msg.c | 97 +- src/comerr/error_table.h | 2 +- src/comerr/error_table_nt.c | 1258 ++- src/comerr/error_table_nt.h | 10 +- src/comerr/et_name.c | 12 +- src/comerr/internal.h | 2 +- src/comerr/mit-sipb-cr.h | 1 - src/comerr/test/test.c | 76 +- src/config/afs_args.h | 18 +- src/config/afs_sysnames.h | 10 +- src/config/afsconfig-windows.h | 2 +- src/config/config.c | 12 +- src/config/debug.h | 15 +- src/config/icl.h | 24 +- src/config/mc.c | 86 +- src/config/mkvers.c | 100 +- src/config/param.alpha_dux40.h | 26 +- src/config/param.alpha_dux50.h | 28 +- src/config/param.alpha_dux51.h | 28 +- src/config/param.alpha_linux_22.h | 34 +- src/config/param.alpha_linux_24.h | 34 +- src/config/param.alpha_nbsd15.h | 10 +- src/config/param.alpha_nbsd16.h | 10 +- src/config/param.amd64_linux24.h | 18 +- src/config/param.hp_ux102.h | 24 +- src/config/param.hp_ux110.h | 26 +- src/config/param.hp_ux11i.h | 26 +- src/config/param.i386_djgpp.h | 12 +- src/config/param.i386_fbsd_42.h | 26 +- src/config/param.i386_fbsd_43.h | 28 +- src/config/param.i386_fbsd_44.h | 28 +- src/config/param.i386_fbsd_45.h | 28 +- src/config/param.i386_fbsd_46.h | 28 +- src/config/param.i386_fbsd_47.h | 28 +- src/config/param.i386_fbsd_50.h | 28 +- src/config/param.i386_linux22.h | 14 +- src/config/param.i386_linux24.h | 28 +- src/config/param.i386_nbsd15.h | 10 +- src/config/param.i386_nbsd16.h | 10 +- src/config/param.i386_nbsd20.h | 10 +- src/config/param.i386_nt40.h | 6 +- src/config/param.i386_obsd31.h | 8 +- src/config/param.i386_obsd32.h | 8 +- src/config/param.i386_obsd33.h | 8 +- src/config/param.i386_obsd34.h | 8 +- src/config/param.i386_umlinux22.h | 14 +- src/config/param.i386_umlinux24.h | 28 +- src/config/param.i386_win95.h | 6 +- src/config/param.ia64_hpux1122.h | 16 +- src/config/param.ia64_linux24.h | 18 +- src/config/param.nbsd15.h | 18 +- src/config/param.nbsd16.h | 18 +- src/config/param.nbsd20.h | 18 +- src/config/param.parisc_linux24.h | 28 +- src/config/param.ppc_darwin_12.h | 20 +- src/config/param.ppc_darwin_13.h | 20 +- src/config/param.ppc_darwin_14.h | 20 +- src/config/param.ppc_darwin_60.h | 20 +- src/config/param.ppc_linux22.h | 28 +- src/config/param.ppc_linux24.h | 28 +- src/config/param.ppc_nbsd16.h | 10 +- src/config/param.ppc_nbsd20.h | 10 +- src/config/param.rs_aix42.h | 26 +- src/config/param.rs_aix51.h | 24 +- src/config/param.s390_linux22.h | 14 +- src/config/param.s390_linux24.h | 14 +- src/config/param.sgi_62.h | 18 +- src/config/param.sgi_63.h | 16 +- src/config/param.sgi_64.h | 20 +- src/config/param.sgi_65.h | 24 +- src/config/param.sparc64_linux22.h | 14 +- src/config/param.sparc64_linux24.h | 14 +- src/config/param.sparc_linux22.h | 14 +- src/config/param.sparc_linux24.h | 14 +- src/config/param.sun4_413.h | 74 +- src/config/param.sun4x_55.h | 20 +- src/config/param.sun4x_56.h | 18 +- src/config/param.sun4x_57.h | 20 +- src/config/param.sun4x_58.h | 24 +- src/config/param.sun4x_59.h | 24 +- src/config/param.sunx86_54.h | 2 +- src/config/param.sunx86_57.h | 20 +- src/config/param.sunx86_58.h | 20 +- src/config/permit_xprt.h | 2 +- src/config/stds.h | 34 +- src/config/touch.c | 47 +- src/config/util_cr.c | 1214 ++- src/config/uvenus.h | 19 +- src/config/venus.h | 92 +- src/dauth/dlog.c | 421 +- src/dauth/dpass.c | 49 +- src/des/andrew-conf.h | 9 +- src/des/cbc_encrypt.c | 75 +- src/des/cksum.c | 35 +- src/des/conf-aix-ibm.h | 2 +- src/des/conf-alpha-bsd.h | 1 - src/des/conf-bsd-alpha.h | 1 - src/des/conf-ppc-darwin.h | 1 - src/des/conf.h | 7 +- src/des/crypt.c | 1016 +-- src/des/debug_decl.c | 5 +- src/des/des.c | 208 +- src/des/des.h | 4 +- src/des/des_conf.h | 16 +- src/des/des_internal.h | 14 +- src/des/des_prototypes.h | 44 +- src/des/enc.c | 93 +- src/des/key_parity.c | 23 +- src/des/key_sched.c | 218 +- src/des/main.c | 64 +- src/des/make_e.c | 20 +- src/des/make_fp.c | 35 +- src/des/make_ip.c | 32 +- src/des/make_keyperm.c | 251 +- src/des/make_odd.c | 43 +- src/des/make_p.c | 42 +- src/des/make_p_table.c | 36 +- src/des/make_s.c | 19 +- src/des/make_s_table.c | 83 +- src/des/misc.c | 194 +- src/des/new_rnd_key.c | 75 +- src/des/pcbc_encrypt.c | 87 +- src/des/quad_cksum.c | 32 +- src/des/read_pssword.c | 152 +- src/des/stats.h | 7 +- src/des/strng_to_key.c | 36 +- src/des/tables.h | 138 +- src/des/test/key_test.c | 132 +- src/des/test/testit.c | 162 +- src/des/test/verify.c | 145 +- src/des/util.c | 21 +- src/des/weak_key.c | 42 +- src/dir/buffer.c | 136 +- src/dir/dir.c | 382 +- src/dir/dir.h | 93 +- src/dir/salvage.c | 435 +- src/dir/test/dtest.c | 156 +- src/dir/test/physio.c | 122 +- src/dir/test/test-salvage.c | 66 +- src/export/cfgafs.c | 67 +- src/export/cfgexport.c | 864 +- src/export/export.c | 303 +- src/export/export.h | 22 +- src/export/sym.h | 42 +- src/export/symtab.c | 161 +- src/finale/translate_et.c | 25 +- src/finale/translate_et_nt.c | 17 +- src/fsint/afsaux.c | 118 +- src/fsprobe/fsprobe.c | 826 +- src/fsprobe/fsprobe.h | 130 +- src/fsprobe/fsprobe_callback.c | 413 +- src/fsprobe/fsprobe_test.c | 275 +- src/ftpd43+/ftp.h | 8 +- src/ftpd43+/ftpd.c | 2872 +++--- src/ftpd43+/getusershell.c | 125 +- src/ftpd43+/glob.c | 1480 ++-- src/ftpd43+/logwtmp.c | 48 +- src/ftpd43+/popen.c | 178 +- src/ftpd43+/telnet.h | 18 +- src/gtx/X11windows.c | 238 +- src/gtx/cb_test.c | 169 +- src/gtx/curses_test.c | 16 +- src/gtx/curseswindows.c | 381 +- src/gtx/dumbwindows.c | 272 +- src/gtx/frame.c | 405 +- src/gtx/gtxX11win.h | 114 +- src/gtx/gtxcurseswin.h | 122 +- src/gtx/gtxdumbwin.h | 114 +- src/gtx/gtxframe.h | 12 +- src/gtx/gtxkeymap.h | 24 +- src/gtx/gtxlightobj.h | 68 +- src/gtx/gtxobjdict.h | 26 +- src/gtx/gtxobjects.h | 76 +- src/gtx/gtxtest.c | 178 +- src/gtx/gtxtextcb.h | 68 +- src/gtx/gtxtextobj.h | 82 +- src/gtx/gtxwindows.h | 90 +- src/gtx/input.c | 45 +- src/gtx/keymap.c | 128 +- src/gtx/lightobject.c | 174 +- src/gtx/objdict.c | 75 +- src/gtx/object_test.c | 414 +- src/gtx/objects.c | 242 +- src/gtx/screen_test.c | 235 +- src/gtx/textcb.c | 625 +- src/gtx/textobject.c | 559 +- src/gtx/windows.c | 130 +- src/inetd/getenv.c | 29 +- src/inetd/inetd.c | 1849 ++-- src/inetd/setenv.c | 105 +- src/inetd/ta-rauth.c | 98 +- src/kauth/admin_tools.c | 2048 +++-- src/kauth/authclient.c | 740 +- src/kauth/client.c | 276 +- src/kauth/decode_ticket.c | 63 +- src/kauth/ka_util.c | 215 +- src/kauth/kaaux.c | 43 +- src/kauth/kaauxdb.c | 104 +- src/kauth/kadatabase.c | 993 ++- src/kauth/kalocalcell.c | 95 +- src/kauth/kalog.c | 83 +- src/kauth/kaopcodes.h | 22 +- src/kauth/kaprocs.c | 2613 +++--- src/kauth/kas.c | 53 +- src/kauth/kaserver.c | 252 +- src/kauth/kaserver.h | 137 +- src/kauth/kautils.c | 157 +- src/kauth/kautils.p.h | 436 +- src/kauth/kdb.c | 30 +- src/kauth/kkids.c | 539 +- src/kauth/klog.c | 264 +- src/kauth/klogin.c | 949 +- src/kauth/knfs.c | 196 +- src/kauth/kpasswd.c | 373 +- src/kauth/kpwvalid.c | 41 +- src/kauth/krb_tf.c | 65 +- src/kauth/krb_udp.c | 1098 +-- src/kauth/manyklog.c | 268 +- src/kauth/prot.h | 8 +- src/kauth/read_passwd.c | 144 +- src/kauth/rebuild.c | 899 +- src/kauth/test/background.c | 25 +- src/kauth/test/multiklog.c | 263 +- src/kauth/test/test_badtix.c | 729 +- src/kauth/test/test_date.c | 45 +- src/kauth/test/test_getticket.c | 488 +- src/kauth/test/test_interim_ktc.c | 792 +- src/kauth/test/test_rxkad_free.c | 354 +- src/kauth/token.c | 348 +- src/kauth/user.c | 273 +- src/kauth/user_nt.c | 742 +- src/libacl/acl.h | 16 +- src/libacl/aclprocs.c | 359 +- src/libacl/netprocs.c | 24 +- src/libacl/prs_fs.h | 14 +- src/libacl/test/acltest.c | 207 +- src/libadmin/adminutil/afs_AdminInternal.h | 88 +- src/libadmin/adminutil/afs_utilAdmin.c | 1517 ++-- src/libadmin/adminutil/afs_utilAdmin.h | 310 +- src/libadmin/afs_Admin.h | 36 +- src/libadmin/bos/afs_bosAdmin.c | 1199 ++- src/libadmin/bos/afs_bosAdmin.h | 598 +- src/libadmin/cfg/afs_cfgAdmin.h | 394 +- src/libadmin/cfg/cfgclient.c | 178 +- src/libadmin/cfg/cfgdb.c | 332 +- src/libadmin/cfg/cfghost.c | 293 +- src/libadmin/cfg/cfginternal.c | 177 +- src/libadmin/cfg/cfginternal.h | 96 +- src/libadmin/cfg/cfgservers.c | 709 +- src/libadmin/cfg/test/cfgtest.c | 231 +- src/libadmin/client/afs_clientAdmin.c | 868 +- src/libadmin/client/afs_clientAdmin.h | 329 +- src/libadmin/kas/afs_kasAdmin.c | 532 +- src/libadmin/kas/afs_kasAdmin.h | 227 +- src/libadmin/pts/afs_ptsAdmin.c | 912 +- src/libadmin/pts/afs_ptsAdmin.h | 333 +- src/libadmin/samples/cm_client_config.c | 25 +- src/libadmin/samples/cm_list_cells.c | 24 +- src/libadmin/samples/cm_local_cell.c | 22 +- src/libadmin/samples/cm_server_prefs.c | 25 +- src/libadmin/samples/rxdebug_basic_stats.c | 19 +- src/libadmin/samples/rxdebug_conns.c | 36 +- src/libadmin/samples/rxdebug_peers.c | 37 +- src/libadmin/samples/rxdebug_rx_stats.c | 92 +- .../samples/rxdebug_supported_stats.c | 19 +- src/libadmin/samples/rxdebug_version.c | 19 +- src/libadmin/samples/rxstat_clear_peer.c | 24 +- src/libadmin/samples/rxstat_clear_process.c | 24 +- src/libadmin/samples/rxstat_disable_peer.c | 24 +- src/libadmin/samples/rxstat_disable_process.c | 24 +- src/libadmin/samples/rxstat_enable_peer.c | 24 +- src/libadmin/samples/rxstat_enable_process.c | 24 +- src/libadmin/samples/rxstat_get_peer.c | 122 +- src/libadmin/samples/rxstat_get_process.c | 111 +- src/libadmin/samples/rxstat_get_version.c | 24 +- src/libadmin/samples/rxstat_query_peer.c | 30 +- src/libadmin/samples/rxstat_query_process.c | 33 +- src/libadmin/test/afscp.c | 44 +- src/libadmin/test/bos.c | 1592 ++-- src/libadmin/test/bos.h | 2 +- src/libadmin/test/client.c | 780 +- src/libadmin/test/client.h | 2 +- src/libadmin/test/common.h | 12 +- src/libadmin/test/kas.c | 558 +- src/libadmin/test/kas.h | 2 +- src/libadmin/test/pts.c | 357 +- src/libadmin/test/pts.h | 2 +- src/libadmin/test/util.c | 26 +- src/libadmin/test/util.h | 8 +- src/libadmin/test/vos.c | 1393 +-- src/libadmin/test/vos.h | 2 +- src/libadmin/vos/afs_vosAdmin.c | 1474 ++-- src/libadmin/vos/afs_vosAdmin.h | 749 +- src/libadmin/vos/lockprocs.c | 153 +- src/libadmin/vos/lockprocs.h | 75 +- src/libadmin/vos/vosutils.c | 322 +- src/libadmin/vos/vosutils.h | 102 +- src/libadmin/vos/vsprocs.c | 4063 ++++----- src/libadmin/vos/vsprocs.h | 258 +- src/libuafs/linktest.c | 11 +- src/log/kseal.c | 28 +- src/log/test/gettoktest.c | 61 +- src/log/test/testlog.c | 291 +- src/log/tokens.c | 81 +- src/log/unlog.c | 280 +- src/login/getenv.c | 37 +- src/login/login.c | 2443 +++--- src/login/setenv.c | 107 +- src/login/util_login.c | 31 +- src/login/util_logout.c | 44 +- src/login/util_logwtmp.c | 35 +- src/lwp/fasttime.c | 44 +- src/lwp/lock.c | 161 +- src/lwp/lock.h | 24 +- src/lwp/lwp.c | 934 +- src/lwp/lwp.h | 218 +- src/lwp/preempt.c | 99 +- src/lwp/preempt.h | 2 +- src/lwp/process.c | 211 +- src/lwp/rw.c | 93 +- src/lwp/test/selclient.c | 139 +- src/lwp/test/selserver.c | 162 +- src/lwp/test/selsubs.c | 72 +- src/lwp/test/seltest.h | 6 +- src/lwp/test/test.c | 40 +- src/lwp/test/test_key.c | 145 +- src/lwp/test/testtime.c | 43 +- src/lwp/threadname.c | 78 +- src/lwp/timer.c | 156 +- src/lwp/timer.h | 10 +- src/lwp/waitkey.c | 217 +- src/mpp/mpp.c | 592 +- src/ntp/mkntpconf.c | 237 +- src/ntp/ntp.c | 482 +- src/ntp/ntp.h | 238 +- src/ntp/ntp_adjust.c | 339 +- src/ntp/ntp_proto.c | 1743 ++-- src/ntp/ntp_sock.c | 411 +- src/ntp/ntpd.c | 2192 +++-- src/ntp/ntpdc.c | 557 +- src/ntp/ntpsubs.c | 276 +- src/ntp/read_local.c | 23 +- src/ntp/read_psti.c | 489 +- src/ntp/runntp.c | 252 +- src/ntp/test.c | 290 +- src/null/null.c | 11 +- src/package/check.c | 296 +- src/package/conftree.c | 536 +- src/package/fileops.c | 150 +- src/package/globals.h | 2 +- src/package/globfuncs.c | 68 +- src/package/messages.c | 374 +- src/package/misc.c | 9 +- src/package/package.c | 148 +- src/package/package.h | 73 +- src/package/test.c | 311 +- src/package/update.c | 432 +- src/package/validupdates.h | 76 +- src/pam/afs_account.c | 9 +- src/pam/afs_auth.c | 367 +- src/pam/afs_message.c | 118 +- src/pam/afs_message.h | 94 +- src/pam/afs_pam_msg.c | 25 +- src/pam/afs_pam_msg.h | 4 +- src/pam/afs_password.c | 196 +- src/pam/afs_session.c | 111 +- src/pam/afs_setcred.c | 261 +- src/pam/afs_util.c | 255 +- src/pam/afs_util.h | 19 +- src/pam/test_pam.c | 48 +- src/pinstall/install.c | 808 +- src/procmgmt/afskill.c | 65 +- src/procmgmt/procmgmt.h | 70 +- src/procmgmt/procmgmt_nt.c | 568 +- src/procmgmt/procmgmt_unix.c | 7 +- src/procmgmt/redirect_nt.c | 35 +- src/procmgmt/test/pmgttest.c | 305 +- src/ptserver/db_verify.c | 1502 ++-- src/ptserver/display.c | 153 +- src/ptserver/error_macros.h | 4 +- src/ptserver/map.c | 1230 ++- src/ptserver/pt_util.c | 289 +- src/ptserver/ptclient.c | 583 +- src/ptserver/ptprocs.c | 2357 ++--- src/ptserver/pts.c | 1030 ++- src/ptserver/ptserver.c | 233 +- src/ptserver/ptserver.h | 136 +- src/ptserver/ptuser.c | 604 +- src/ptserver/ptutils.c | 2303 ++--- src/ptserver/readgroup.c | 163 +- src/ptserver/readpwd.c | 49 +- src/ptserver/testpt.c | 1036 ++- src/ptserver/ubik.c | 124 +- src/ptserver/utils.c | 881 +- src/rcp/rcp.c | 1228 ++- src/rlogind/rexecd.c | 536 +- src/rlogind/rlogind.c | 2845 +++--- src/rsh/herror.c | 53 +- src/rsh/rcmd.c | 886 +- src/rsh/rlogin.c | 771 +- src/rsh/rsh.c | 624 +- src/rx/AIX/rx_kmutex.c | 3 +- src/rx/AIX/rx_kmutex.h | 5 +- src/rx/AIX/rx_knet.c | 325 +- src/rx/DARWIN/rx_kmutex.c | 3 +- src/rx/DARWIN/rx_kmutex.h | 3 +- src/rx/DARWIN/rx_knet.c | 45 +- src/rx/DUX/rx_kmutex.c | 3 +- src/rx/DUX/rx_kmutex.h | 5 +- src/rx/DUX/rx_knet.c | 249 +- src/rx/FBSD/rx_kmutex.c | 3 +- src/rx/FBSD/rx_kmutex.h | 3 +- src/rx/FBSD/rx_knet.c | 336 +- src/rx/HPUX/rx_kmutex.c | 3 +- src/rx/HPUX/rx_kmutex.h | 15 +- src/rx/HPUX/rx_knet.c | 185 +- src/rx/IRIX/rx_kmutex.c | 3 +- src/rx/IRIX/rx_kmutex.h | 3 +- src/rx/IRIX/rx_knet.c | 310 +- src/rx/LINUX/rx_kmutex.c | 42 +- src/rx/LINUX/rx_kmutex.h | 10 +- src/rx/LINUX/rx_knet.c | 65 +- src/rx/NBSD/rx_kmutex.h | 3 +- src/rx/NBSD/rx_knet.c | 112 +- src/rx/OBSD/rx_knet.c | 40 +- src/rx/SOLARIS/rx_kmutex.c | 41 +- src/rx/SOLARIS/rx_kmutex.h | 7 +- src/rx/SOLARIS/rx_knet.c | 180 +- src/rx/UKERNEL/rx_kmutex.c | 3 +- src/rx/UKERNEL/rx_kmutex.h | 3 +- src/rx/UKERNEL/rx_knet.c | 80 +- src/rx/bulk.example/bulk_client.c | 16 +- src/rx/bulk.example/bulk_io.c | 8 +- src/rx/bulktest/bulk_client.c | 150 +- src/rx/bulktest/bulk_io.c | 50 +- src/rx/bulktest/bulk_server.c | 78 +- src/rx/multi.example/sample_client.c | 73 +- src/rx/multi.example/sample_server.c | 52 +- src/rx/rx.c | 3764 ++++---- src/rx/rx.h | 593 +- src/rx/rx_clock.c | 21 +- src/rx/rx_clock.h | 8 +- src/rx/rx_clock_nt.c | 21 +- src/rx/rx_conncache.c | 169 +- src/rx/rx_event.c | 133 +- src/rx/rx_event.h | 20 +- src/rx/rx_getaddr.c | 617 +- src/rx/rx_globals.c | 3 +- src/rx/rx_globals.h | 81 +- src/rx/rx_kcommon.c | 730 +- src/rx/rx_kcommon.h | 13 +- src/rx/rx_kernel.h | 2 +- src/rx/rx_lwp.c | 285 +- src/rx/rx_lwp.h | 4 +- src/rx/rx_misc.c | 104 +- src/rx/rx_misc.h | 2 +- src/rx/rx_multi.c | 48 +- src/rx/rx_multi.h | 6 +- src/rx/rx_null.c | 11 +- src/rx/rx_packet.c | 1765 ++-- src/rx/rx_packet.h | 138 +- src/rx/rx_prototypes.h | 418 +- src/rx/rx_pthread.c | 181 +- src/rx/rx_pthread.h | 4 +- src/rx/rx_queue.h | 4 +- src/rx/rx_rdwr.c | 1025 +-- src/rx/rx_stream.c | 155 +- src/rx/rx_stream.h | 19 +- src/rx/rx_trace.c | 232 +- src/rx/rx_trace.h | 2 +- src/rx/rx_user.c | 460 +- src/rx/rx_user.h | 10 +- src/rx/rx_xmit_nt.c | 47 +- src/rx/rx_xmit_nt.h | 6 +- src/rx/rxdebug.c | 418 +- src/rx/rxperf.c | 434 +- src/rx/simple.example/sample_client.c | 29 +- src/rx/simple.example/sample_server.c | 46 +- src/rx/test/generator.c | 1066 +-- src/rx/test/generator.h | 16 +- src/rx/test/kctest.c | 92 +- src/rx/test/kstest.c | 51 +- src/rx/test/tableGen.c | 298 +- src/rx/test/testclient.c | 260 +- src/rx/test/testqueue.c | 42 +- src/rx/test/testserver.c | 188 +- src/rx/xdr.c | 601 +- src/rx/xdr.h | 58 +- src/rx/xdr_afsuuid.c | 44 +- src/rx/xdr_array.c | 107 +- src/rx/xdr_arrayn.c | 107 +- src/rx/xdr_float.c | 55 +- src/rx/xdr_int32.c | 37 +- src/rx/xdr_int64.c | 168 +- src/rx/xdr_mem.c | 164 +- src/rx/xdr_prototypes.h | 89 +- src/rx/xdr_rec.c | 694 +- src/rx/xdr_refernce.c | 49 +- src/rx/xdr_rx.c | 323 +- src/rx/xdr_stdio.c | 153 +- src/rx/xdr_update.c | 59 +- src/rxdebug/rxdebug.c | 431 +- src/rxgen/rpc_clntout.c | 122 +- src/rxgen/rpc_cout.c | 640 +- src/rxgen/rpc_errors.h | 1 - src/rxgen/rpc_hout.c | 622 +- src/rxgen/rpc_main.c | 976 ++- src/rxgen/rpc_parse.c | 1561 ++-- src/rxgen/rpc_parse.h | 148 +- src/rxgen/rpc_scan.c | 699 +- src/rxgen/rpc_scan.h | 106 +- src/rxgen/rpc_svcout.c | 327 +- src/rxgen/rpc_util.c | 500 +- src/rxgen/rpc_util.h | 63 +- src/rxkad/asn1_err.h | 28 +- src/rxkad/bg-fcrypt.c | 1110 +-- src/rxkad/crc.c | 12 +- src/rxkad/der.h | 193 +- src/rxkad/domestic/crypt_conn.c | 89 +- src/rxkad/domestic/fcrypt.c | 107 +- src/rxkad/domestic/fcrypt.h | 2 +- src/rxkad/domestic/sboxes.h | 196 +- src/rxkad/domestic/tcrypt.c | 176 +- src/rxkad/fc_test.c | 247 +- src/rxkad/lifetimes.h | 129 +- src/rxkad/private_data.h | 71 +- src/rxkad/rxkad.p.h | 20 +- src/rxkad/rxkad_client.c | 190 +- src/rxkad/rxkad_common.c | 389 +- src/rxkad/rxkad_prototypes.h | 168 +- src/rxkad/rxkad_server.c | 324 +- src/rxkad/test/stress.c | 267 +- src/rxkad/test/stress_c.c | 1009 ++- src/rxkad/test/stress_internal.h | 28 +- src/rxkad/test/stress_s.c | 217 +- src/rxkad/ticket.c | 272 +- src/rxkad/ticket5.c | 164 +- src/rxkad/v5der.c | 608 +- src/rxkad/v5gen-rewrite.h | 96 +- src/rxkad/v5gen.c | 4356 +++++----- src/rxkad/v5gen.h | 1078 +-- src/rxstat/rxstat.c | 136 +- src/scout/scout.c | 2282 +++-- src/sgistuff/sgi_auth.c | 73 +- src/sia/siad.c | 234 +- src/sia/test-reauth.c | 23 +- src/sys/afssyscalls.c | 171 +- src/sys/afssyscalls.h | 24 +- src/sys/fixit.c | 74 +- src/sys/icreate.c | 7 +- src/sys/idec.c | 15 +- src/sys/iinc.c | 15 +- src/sys/iopen.c | 24 +- src/sys/iread.c | 14 +- src/sys/istat.c | 12 +- src/sys/iwrite.c | 13 +- src/sys/pagsh.c | 74 +- src/sys/pioctl_nt.c | 556 +- src/sys/pioctl_nt.h | 11 +- src/sys/rmtsysc.c | 132 +- src/sys/rmtsysd.c | 23 +- src/sys/rmtsysnet.c | 683 +- src/sys/rmtsyss.c | 74 +- src/sys/xfsattrs.h | 20 +- src/tests/afscp.c | 906 +- src/tests/afscp_callback.c | 196 +- src/tests/afsdump_dirlist.c | 160 +- src/tests/afsdump_extract.c | 823 +- src/tests/afsdump_scan.c | 443 +- src/tests/afsdump_xsed.c | 525 +- src/tests/append-over-page.c | 1009 +-- src/tests/apwd.c | 229 +- src/tests/asu.c | 9 +- src/tests/backuphdr.c | 93 +- src/tests/blocks-new-file.c | 34 +- src/tests/create-dirs.c | 26 +- src/tests/create-files.c | 40 +- src/tests/create-remove.c | 58 +- src/tests/create-stat.c | 59 +- src/tests/create-symlinks.c | 63 +- src/tests/directory.c | 237 +- src/tests/dump.c | 400 +- src/tests/dumpfmt.h | 28 +- src/tests/dumpscan.h | 332 +- src/tests/dumptool.c | 3495 ++++---- src/tests/dup2-and-unlog.c | 18 +- src/tests/echo-n.c | 10 +- src/tests/err.c | 8 +- src/tests/err.h | 18 +- src/tests/errx.c | 8 +- src/tests/exit-wo-close.c | 58 +- src/tests/fchmod.c | 20 +- src/tests/fhbench.c | 184 +- src/tests/fs_lib.c | 379 +- src/tests/fsx.c | 1610 ++-- src/tests/ga-test.c | 182 +- src/tests/hardlink1.c | 87 +- src/tests/hardlink2.c | 12 +- src/tests/hardlink4.c | 40 +- src/tests/int64.c | 499 +- src/tests/intNN.h | 4 +- src/tests/internal.h | 20 +- src/tests/intr-read.c | 11 +- src/tests/invalidate-file.c | 130 +- src/tests/kill-softer.c | 100 +- src/tests/kill-softly.c | 69 +- src/tests/large-dir.c | 110 +- src/tests/large-dir2.c | 71 +- src/tests/large-dir3.c | 71 +- src/tests/make-page.c | 31 +- src/tests/mkdir2.c | 30 +- src/tests/mkdir3.c | 52 +- src/tests/mmap-and-read.c | 82 +- src/tests/mmap-cat.c | 44 +- src/tests/mmap-shared-write.c | 32 +- src/tests/mmap-vs-read.c | 82 +- src/tests/mmap-vs-read2.c | 82 +- src/tests/null-search.c | 239 +- src/tests/parsedump.c | 376 +- src/tests/parsetag.c | 253 +- src/tests/parsevnode.c | 760 +- src/tests/parsevol.c | 513 +- src/tests/pathname.c | 600 +- src/tests/pine.c | 36 +- src/tests/primitive.c | 182 +- src/tests/read-vs-mmap.c | 84 +- src/tests/read-vs-mmap2.c | 62 +- src/tests/read-write.c | 64 +- src/tests/readdir-vs-lstat.c | 34 +- src/tests/rename-under-feet.c | 94 +- src/tests/rename5.c | 38 +- src/tests/rename6.c | 10 +- src/tests/repair.c | 622 +- src/tests/rm-rf.c | 51 +- src/tests/snprintf.c | 886 +- src/tests/stagehdr.c | 190 +- src/tests/stagehdr.h | 40 +- src/tests/still-there-p.c | 10 +- src/tests/strange-characters-c.c | 32 +- src/tests/symlink.c | 14 +- src/tests/test-parallel1.c | 26 +- src/tests/test-parallel2.c | 92 +- src/tests/test-setgroups.c | 57 +- src/tests/test-setpag.c | 47 +- src/tests/truncate-files.c | 74 +- src/tests/truncate.c | 40 +- src/tests/util.c | 222 +- src/tests/utime-dir.c | 14 +- src/tests/utime-file.c | 39 +- src/tests/vwarnx.c | 1 - src/tests/warn.c | 8 +- src/tests/warnerr.c | 20 +- src/tests/warnx.c | 8 +- src/tests/write-closed.c | 32 +- src/tests/write-closed2.c | 50 +- src/tests/write-large.c | 22 +- src/tests/write-rand.c | 42 +- src/tests/write-ro-file.c | 34 +- src/tests/write-ucc.c | 48 +- src/tests/write3.c | 14 +- src/tests/xf_files.c | 206 +- src/tests/xf_printf.c | 690 +- src/tests/xf_profile.c | 200 +- src/tests/xf_rxcall.c | 353 +- src/tests/xfiles.c | 267 +- src/tests/xfiles.h | 58 +- src/tsm41/aix41_auth.c | 164 +- src/ubik/beacon.c | 556 +- src/ubik/disk.c | 585 +- src/ubik/lock.c | 170 +- src/ubik/phys.c | 125 +- src/ubik/recovery.c | 629 +- src/ubik/remote.c | 434 +- src/ubik/ubik.c | 578 +- src/ubik/ubik.p.h | 220 +- src/ubik/ubikclient.c | 532 +- src/ubik/ubikcmd.c | 38 +- src/ubik/udebug.c | 257 +- src/ubik/utst_client.c | 142 +- src/ubik/utst_server.c | 100 +- src/ubik/vote.c | 338 +- src/update/client.c | 540 +- src/update/server.c | 311 +- src/update/utils.c | 33 +- src/usd/test/usd_test.c | 429 +- src/usd/usd.h | 45 +- src/usd/usd_file.c | 204 +- src/usd/usd_nt.c | 461 +- src/uss/uss.c | 972 +-- src/uss/uss_acl.c | 407 +- src/uss/uss_acl.h | 22 +- src/uss/uss_common.c | 181 +- src/uss/uss_common.h | 118 +- src/uss/uss_fs.c | 350 +- src/uss/uss_fs.h | 84 +- src/uss/uss_kauth.c | 488 +- src/uss/uss_kauth.h | 24 +- src/uss/uss_procs.c | 576 +- src/uss/uss_procs.h | 94 +- src/uss/uss_ptserver.c | 166 +- src/uss/uss_ptserver.h | 28 +- src/uss/uss_vol.c | 766 +- src/uss/uss_vol.h | 68 +- src/util/afs_atomlist.c | 244 +- src/util/afs_atomlist.h | 25 +- src/util/afs_lhash.c | 729 +- src/util/afs_lhash.h | 77 +- src/util/afsutil.h | 46 +- src/util/afsutil_prototypes.h | 57 +- src/util/assert.c | 16 +- src/util/base32.c | 29 +- src/util/base64.c | 37 +- src/util/casestrcpy.c | 89 +- src/util/dirent_nt.h | 4 +- src/util/dirpath.c | 394 +- src/util/dirpath_nt.h | 140 +- src/util/errmap_nt.c | 51 +- src/util/errmap_nt.h | 2 +- src/util/errors.h | 34 +- src/util/fileutil.c | 24 +- src/util/fileutil.h | 13 +- src/util/flipbase64.c | 35 +- src/util/get_krbrlm.c | 20 +- src/util/hostparse.c | 274 +- src/util/hputil.c | 44 +- src/util/isathing.c | 8 +- src/util/itc.h | 2 +- src/util/kreltime.c | 197 +- src/util/ktime.c | 417 +- src/util/ktime.h | 10 +- src/util/netutils.c | 666 +- src/util/netutils.h | 2 +- src/util/packages.h | 26 +- src/util/potpourri.h | 8 +- src/util/pthread_glock.c | 27 +- src/util/pthread_glock.h | 2 +- src/util/pthread_nosigs.h | 38 +- src/util/readdir_nt.c | 75 +- src/util/regex.c | 541 +- src/util/remote.h | 126 +- src/util/secutil_nt.c | 86 +- src/util/secutil_nt.h | 10 +- src/util/serverLog.c | 183 +- src/util/snprintf.c | 683 +- src/util/softsig.c | 132 +- src/util/softsig.h | 4 +- src/util/strlcat.c | 7 +- src/util/strlcpy.c | 8 +- src/util/sys.c | 10 +- src/util/test/b32.c | 53 +- src/util/test/b64.c | 53 +- src/util/test/dirpath_test.c | 262 +- src/util/test/dtest.c | 14 +- src/util/test/fb64.c | 61 +- src/util/test/ktest.c | 8 +- src/util/test/test_ktime.c | 90 +- src/util/test/treaddir.c | 15 +- src/util/uuid.c | 202 +- src/util/vice.h | 15 +- src/util/volparse.c | 166 +- src/util/winsock_nt.c | 11 +- src/venus/cacheout.c | 319 +- src/venus/cmdebug.c | 216 +- src/venus/fs.c | 2083 +++-- src/venus/fstrace.c | 2487 +++--- src/venus/gcpags.c | 14 +- src/venus/kdump.c | 3954 +++++---- src/venus/livesys.c | 10 +- src/venus/test/fulltest.c | 179 +- src/venus/test/getinitparams.c | 25 +- src/venus/test/idtest.c | 7 +- src/venus/test/owntest.c | 21 +- src/venus/twiddle.c | 161 +- src/venus/up.c | 1038 +-- src/venus/whatfid.c | 77 +- src/vfsck/dir.c | 1024 ++- src/vfsck/dirutils.c | 32 +- src/vfsck/fsck.h | 184 +- src/vfsck/inode.c | 838 +- src/vfsck/main.c | 1694 ++-- src/vfsck/pass1.c | 642 +- src/vfsck/pass1b.c | 97 +- src/vfsck/pass2.c | 554 +- src/vfsck/pass3.c | 126 +- src/vfsck/pass4.c | 203 +- src/vfsck/pass5.c | 488 +- src/vfsck/proplist.c | 722 +- src/vfsck/setup.c | 1221 +-- src/vfsck/ufs_subr.c | 225 +- src/vfsck/ufs_tables.c | 137 +- src/vfsck/utilities.c | 1409 +-- src/vfsck/vprintf.c | 13 +- src/viced/afsfileprocs.c | 5851 ++++++------- src/viced/callback.c | 1623 ++-- src/viced/check_sysid.c | 148 +- src/viced/fs_stats.h | 174 +- src/viced/fsprobe.c | 490 +- src/viced/host.c | 1982 ++--- src/viced/host.h | 191 +- src/viced/physio.c | 103 +- src/viced/profile.c | 36 +- src/viced/viced.c | 1358 +-- src/viced/viced.h | 221 +- src/vlserver/cnvldb.c | 1168 +-- src/vlserver/cnvldb.h | 167 +- src/vlserver/sascnvldb.c | 528 +- src/vlserver/vlclient.c | 1439 +-- src/vlserver/vlclient.h | 1 - src/vlserver/vldb_check.c | 1641 ++-- src/vlserver/vlprocs.c | 3031 ++++--- src/vlserver/vlserver.c | 152 +- src/vlserver/vlserver.p.h | 90 +- src/vlserver/vlutils.c | 802 +- src/vol/clone.c | 495 +- src/vol/common.c | 14 +- src/vol/devname.c | 90 +- src/vol/fs_conv_411.c | 1367 +-- src/vol/fssync.c | 463 +- src/vol/fssync.h | 34 +- src/vol/gi.c | 101 +- src/vol/ihandle.c | 336 +- src/vol/ihandle.h | 78 +- src/vol/listinodes.c | 1537 ++-- src/vol/namei_ops.c | 852 +- src/vol/namei_ops.h | 39 +- src/vol/nfs.h | 2 +- src/vol/ntops.c | 537 +- src/vol/ntops.h | 43 +- src/vol/nuke.c | 81 +- src/vol/partition.c | 614 +- src/vol/partition.h | 63 +- src/vol/physio.c | 63 +- src/vol/purge.c | 85 +- src/vol/salvage.h | 5 +- src/vol/test/ilist_nt.c | 34 +- src/vol/test/listVicepx.c | 885 +- src/vol/test/listVicepx.h | 25 +- src/vol/test/ltlist.c | 29 +- src/vol/test/nicreate.c | 15 +- src/vol/test/nilist.c | 45 +- src/vol/test/nincdec.c | 35 +- src/vol/test/nino.c | 48 +- src/vol/test/nsubr.c | 11 +- src/vol/test/testpart.c | 23 +- src/vol/test/updateDirInode.c | 459 +- src/vol/test/utilities.c | 151 +- src/vol/viceinode.h | 36 +- src/vol/vnode.c | 480 +- src/vol/vnode.h | 135 +- src/vol/vol-info.c | 392 +- src/vol/vol-salvage.c | 2748 +++--- src/vol/voldefs.h | 2 +- src/vol/volinodes.h | 41 +- src/vol/volume.c | 1093 +-- src/vol/volume.h | 462 +- src/vol/vutil.c | 191 +- src/vol/xfs_size_check.c | 67 +- src/volser/common.c | 18 +- src/volser/dump.h | 2 +- src/volser/dumpstuff.c | 1223 +-- src/volser/lockdata.h | 4 +- src/volser/lockprocs.c | 136 +- src/volser/physio.c | 60 +- src/volser/restorevol.c | 1616 ++-- src/volser/vol.h | 10 +- src/volser/volmain.c | 239 +- src/volser/volprocs.c | 2498 +++--- src/volser/volser.p.h | 77 +- src/volser/volser_prototypes.h | 104 +- src/volser/voltrans.c | 78 +- src/volser/vos.c | 5716 ++++++------ src/volser/vsprocs.c | 7716 +++++++++-------- src/volser/vsutils.c | 485 +- src/xstat/xstat_cm.c | 355 +- src/xstat/xstat_cm.h | 84 +- src/xstat/xstat_cm_test.c | 1529 ++-- src/xstat/xstat_fs.c | 429 +- src/xstat/xstat_fs.h | 84 +- src/xstat/xstat_fs_callback.c | 391 +- src/xstat/xstat_fs_test.c | 532 +- 1231 files changed, 207782 insertions(+), 195386 deletions(-) diff --git a/acconfig.h b/acconfig.h index f31222d54..1e10c156d 100644 --- a/acconfig.h +++ b/acconfig.h @@ -1,16 +1,13 @@ @BOTTOM@ #undef PACKAGE #undef VERSION - #define RCSID(msg) \ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } - #undef HAVE_CONNECT #undef HAVE_GETHOSTBYNAME #undef HAVE_RES_SEARCH #undef HAVE_SOCKET #undef STRUCT_SOCKADDR_HAS_SA_LEN - #if ENDIANESS_IN_SYS_PARAM_H # ifndef KERNEL # include @@ -20,16 +17,13 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } # endif # endif #endif - #undef AFS_AFSDB_ENV #undef AFS_NAMEI_ENV - #undef BITMAP_LATER #undef BOS_RESTRICTED_MODE #undef BOS_NEW_CONFIG #undef FAST_RESTART #undef FULL_LISTVOL_SWITCH - #undef COMPLETION_H_EXISTS #undef DEFINED_FOR_EACH_PROCESS #undef DEFINED_PREV_TASK @@ -53,12 +47,9 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } #undef STRUCT_TASK_STRUCT_HAS_SIGHAND #undef STRUCT_TASK_STRUCT_HAS_SIGMASK_LOCK #undef ssize_t - #undef HAVE_STRUCT_BUF - /* glue for RedHat kernel bug */ #undef ENABLE_REDHAT_BUILDSYS - #if defined(ENABLE_REDHAT_BUILDSYS) && defined(KERNEL) && defined(REDHAT_FIX) #include "redhat-fix.h" #endif diff --git a/src/JAVA/libjafs/ACL.c b/src/JAVA/libjafs/ACL.c index d54887ca2..64b245f0a 100644 --- a/src/JAVA/libjafs/ACL.c +++ b/src/JAVA/libjafs/ACL.c @@ -40,8 +40,8 @@ #define OMAXHOSTS 8 #define MAXNAME 100 #define MAXSIZE 2048 -#define MAXINSIZE 1300 /* pioctl complains if data is larger than this */ -#define VMSGSIZE 128 /* size of msg buf in volume hdr */ +#define MAXINSIZE 1300 /* pioctl complains if data is larger than this */ +#define VMSGSIZE 128 /* size of msg buf in volume hdr */ static char space[MAXSIZE]; @@ -59,30 +59,32 @@ extern int errno; * path the directory path * returns NULL if an exception is encountered. */ -char* getACL(char *path) +char * +getACL(char *path) { struct ViceIoctl params; char *buffer; - params.in = NULL; + params.in = NULL; params.out = NULL; - params.in_size = 0; + params.in_size = 0; params.out_size = 0; - - buffer = (char*) malloc(ACL_LEN); + + buffer = (char *)malloc(ACL_LEN); if (!buffer) { - fprintf(stderr, "ERROR: ACL::getACL -> could not allocate buffer\n"); - return NULL; + fprintf(stderr, "ERROR: ACL::getACL -> could not allocate buffer\n"); + return NULL; } params.out = buffer; - params.out_size = ACL_LEN; + params.out_size = ACL_LEN; - if ( call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, ¶ms, 1, 0) ) { - fprintf(stderr, "ERROR: ACL::getACL -> VIOCGETAL failed: %d\n", errno); - free( buffer ); - return NULL; + if (call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, ¶ms, 1, 0)) { + fprintf(stderr, "ERROR: ACL::getACL -> VIOCGETAL failed: %d\n", + errno); + free(buffer); + return NULL; } return params.out; @@ -96,7 +98,8 @@ char* getACL(char *path) * aclString string representation of ACL to be set * returns TRUE if the operation succeeds; otherwise FALSE; */ -jboolean setACL(char *path, char *aclString) +jboolean +setACL(char *path, char *aclString) { struct ViceIoctl params; char *redirect, *parentURI, *cptr; @@ -106,9 +109,10 @@ jboolean setACL(char *path, char *aclString) params.out = NULL; params.out_size = 0; - if ( call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, ¶ms, 1) ) { - fprintf(stderr, "ERROR: ACL::setACL -> VIOCSETAL failed: %d\n", errno); - return JNI_FALSE; + if (call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, ¶ms, 1)) { + fprintf(stderr, "ERROR: ACL::setACL -> VIOCSETAL failed: %d\n", + errno); + return JNI_FALSE; } return JNI_TRUE; @@ -124,28 +128,29 @@ jboolean setACL(char *path, char *aclString) * path the directory path * returns NULL if an exception is encountered. */ -JNIEXPORT jstring JNICALL Java_org_openafs_jafs_ACL_getACLString - (JNIEnv *env, jobject obj, jstring pathUTF) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_ACL_getACLString(JNIEnv * env, jobject obj, + jstring pathUTF) { char *path, *acl; jstring answer = NULL; path = getNativeString(env, pathUTF); - if ( path == NULL ) { - fprintf(stderr, "ERROR: ACL::getACLString ->"); - fprintf(stderr, "path = NULL\n"); - throwAFSException( env, JAFSNULLPATH ); - return NULL; + if (path == NULL) { + fprintf(stderr, "ERROR: ACL::getACLString ->"); + fprintf(stderr, "path = NULL\n"); + throwAFSException(env, JAFSNULLPATH); + return NULL; } - acl = getACL( path ); - free( path ); + acl = getACL(path); + free(path); - if ( acl ) { - answer = (*env)->NewStringUTF( env, acl ); - free( acl ); + if (acl) { + answer = (*env)->NewStringUTF(env, acl); + free(acl); } else { - throwAFSException( env, errno ); + throwAFSException(env, errno); } return answer; @@ -163,50 +168,52 @@ JNIEXPORT jstring JNICALL Java_org_openafs_jafs_ACL_getACLString * aclString string representation of ACL to be set * throws an afsAdminExceptionName if an internal exception is encountered. */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_ACL_setACLString - (JNIEnv *env, jobject obj, jstring pathUTF, jstring aclStringUTF) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_ACL_setACLString(JNIEnv * env, jobject obj, + jstring pathUTF, jstring aclStringUTF) { char *path, *aclString; - if ( pathUTF == NULL ) { - fprintf(stderr, "ERROR: ACL::setACLString -> pathUTF == NULL\n"); - throwAFSException( env, JAFSNULLPATH ); - return; + if (pathUTF == NULL) { + fprintf(stderr, "ERROR: ACL::setACLString -> pathUTF == NULL\n"); + throwAFSException(env, JAFSNULLPATH); + return; } - if ( aclStringUTF == NULL ) { - fprintf(stderr, "ERROR: ACL::setACLString -> aclStringUTF == NULL\n"); - throwAFSException( env, JAFSNULLACL ); - return; + if (aclStringUTF == NULL) { + fprintf(stderr, "ERROR: ACL::setACLString -> aclStringUTF == NULL\n"); + throwAFSException(env, JAFSNULLACL); + return; } /* path = (char*) (*env)->GetStringUTFChars(env, pathUTF, 0); */ - path = getNativeString( env, pathUTF ); - if ( path == NULL ) { - fprintf(stderr, "ERROR: ACL::setACLString -> failed to get path\n"); - throwMessageException( env, "Failed to get path." ); - return; + path = getNativeString(env, pathUTF); + if (path == NULL) { + fprintf(stderr, "ERROR: ACL::setACLString -> failed to get path\n"); + throwMessageException(env, "Failed to get path."); + return; } /* aclString = (char*) (*env)->GetStringUTFChars(env, aclStringUTF, 0); */ - aclString = getNativeString( env, aclStringUTF ); - if ( aclString == NULL ) { - free( path ); - fprintf(stderr, "ERROR: ACL::setACLString -> failed to get aclString\n"); - throwMessageException( env, "Failed to get ACL string." ); - return; + aclString = getNativeString(env, aclStringUTF); + if (aclString == NULL) { + free(path); + fprintf(stderr, + "ERROR: ACL::setACLString -> failed to get aclString\n"); + throwMessageException(env, "Failed to get ACL string."); + return; } - if ( !setACL(path, aclString) ) { - throwAFSException( env, errno ); + if (!setACL(path, aclString)) { + throwAFSException(env, errno); } /* Clean up */ - free( path ); - free( aclString ); + free(path); + free(aclString); /* - (*env)->ReleaseStringUTFChars(env, pathUTF, path); - (*env)->ReleaseStringUTFChars(env, aclStringUTF, aclString); - */ + * (*env)->ReleaseStringUTFChars(env, pathUTF, path); + * (*env)->ReleaseStringUTFChars(env, aclStringUTF, aclString); + */ } diff --git a/src/JAVA/libjafs/AdminToken.c b/src/JAVA/libjafs/AdminToken.c index bc446dfd1..af543a33a 100644 --- a/src/JAVA/libjafs/AdminToken.c +++ b/src/JAVA/libjafs/AdminToken.c @@ -38,14 +38,14 @@ * env the Java environment * obj the current Java object */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Token_initializeAdminClient(JNIEnv *env, jclass cls) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Token_initializeAdminClient(JNIEnv * env, jclass cls) { - afs_status_t ast; - if ( !afsclient_Init( &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + if (!afsclient_Init(&ast)) { + throwAFSException(env, ast); + return; + } } @@ -60,67 +60,73 @@ Java_org_openafs_jafs_Token_initializeAdminClient(JNIEnv *env, jclass cls) * jpassword the password of the user * returns a token representing the authentication */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Token_getToken - (JNIEnv *env, jobject obj, jstring jcellName, jstring juserName, - jstring jpassword) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Token_getToken(JNIEnv * env, jobject obj, + jstring jcellName, jstring juserName, + jstring jpassword) { - afs_status_t ast; - char *cellName; - char *userName; - char *password; - void *tokenHandle; - int rc; - - // convert java strings - if ( jcellName != NULL ) { - cellName = getNativeString(env, jcellName); - if ( !cellName ) { - throwAFSException( env, JAFSADMNOMEM ); - return 0; + afs_status_t ast; + char *cellName; + char *userName; + char *password; + void *tokenHandle; + int rc; + + // convert java strings + if (jcellName != NULL) { + cellName = getNativeString(env, jcellName); + if (!cellName) { + throwAFSException(env, JAFSADMNOMEM); + return 0; + } + } else { + cellName = NULL; } - } else { - cellName = NULL; - } - - if ( juserName != NULL ) { - userName = getNativeString(env, juserName); - if ( !userName ) { - if ( cellName != NULL ) free( cellName ); - throwAFSException( env, JAFSADMNOMEM ); - return 0; + + if (juserName != NULL) { + userName = getNativeString(env, juserName); + if (!userName) { + if (cellName != NULL) + free(cellName); + throwAFSException(env, JAFSADMNOMEM); + return 0; + } + } else { + if (cellName != NULL) + free(cellName); + throwAFSException(env, JAFSNULLUSER); + return 0; } - } else { - if ( cellName != NULL ) free( cellName ); - throwAFSException( env, JAFSNULLUSER ); - return 0; - } - - if ( jpassword != NULL ) { - password = getNativeString(env, jpassword); - if ( !password ) { - if ( cellName != NULL ) free( cellName ); - free( userName ); - throwAFSException( env, JAFSADMNOMEM ); - return 0; + + if (jpassword != NULL) { + password = getNativeString(env, jpassword); + if (!password) { + if (cellName != NULL) + free(cellName); + free(userName); + throwAFSException(env, JAFSADMNOMEM); + return 0; + } + } else { + if (cellName != NULL) + free(cellName); + free(userName); + throwAFSException(env, JAFSNULLPASS); + return 0; + } + + if (! + (afsclient_TokenGetNew + (cellName, userName, password, &tokenHandle, &ast))) { + throwAFSException(env, ast); } - } else { - if ( cellName != NULL ) free( cellName ); - free( userName ); - throwAFSException( env, JAFSNULLPASS ); - return 0; - } - - if ( !(afsclient_TokenGetNew( cellName, userName, password, &tokenHandle, - &ast) ) ) { - throwAFSException( env, ast ); - } - - if ( cellName != NULL ) free( cellName ); - free( userName ); - free( password ); - - return (jint) tokenHandle; + + if (cellName != NULL) + free(cellName); + free(userName); + free(password); + + return (jint) tokenHandle; } /** @@ -130,16 +136,15 @@ Java_org_openafs_jafs_Token_getToken * obj the current Java object * tokenHandle the token to close */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Token_close - (JNIEnv *env, jobject obj, jint tokenHandle) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Token_close(JNIEnv * env, jobject obj, jint tokenHandle) { - afs_status_t ast; + afs_status_t ast; - if ( !afsclient_TokenClose( (void *) tokenHandle, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!afsclient_TokenClose((void *)tokenHandle, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -153,33 +158,32 @@ Java_org_openafs_jafs_Token_close * tokenHandle a token handle previously returned by a call to getToken * returns a handle to the open cell */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getCellHandle - (JNIEnv *env, jobject obj, jstring jcellName, jint tokenHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getCellHandle(JNIEnv * env, jobject obj, + jstring jcellName, jint tokenHandle) { - afs_status_t ast; - char *cellName; - void *cellHandle; - - if ( jcellName != NULL ) { - cellName = getNativeString(env, jcellName); - if ( !cellName ) { - throwAFSException( env, JAFSADMNOMEM ); + afs_status_t ast; + char *cellName; + void *cellHandle; + + if (jcellName != NULL) { + cellName = getNativeString(env, jcellName); + if (!cellName) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } + } else { + throwAFSException(env, JAFSNULLCELL); return -1; } - } else { - throwAFSException( env, JAFSNULLCELL ); - return -1; - } - if ( !afsclient_CellOpen( cellName, (void *) tokenHandle, - &cellHandle, &ast ) ) { - throwAFSException( env, ast ); - } + if (!afsclient_CellOpen(cellName, (void *)tokenHandle, &cellHandle, &ast)) { + throwAFSException(env, ast); + } - free( cellName ); + free(cellName); - return (jint) cellHandle; + return (jint) cellHandle; } /** @@ -189,16 +193,16 @@ Java_org_openafs_jafs_Cell_getCellHandle * obj the current Java object * cellHandle the cell handle to close */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_closeCell - (JNIEnv *env, jobject obj, jint cellHandle) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_closeCell(JNIEnv * env, jobject obj, + jint cellHandle) { - afs_status_t ast; + afs_status_t ast; - if ( !afsclient_CellClose( (void *) cellHandle, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!afsclient_CellClose((void *)cellHandle, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -214,34 +218,34 @@ Java_org_openafs_jafs_Cell_closeCell * a vos handle * returns a vos handle to the server */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getVosServerHandle - (JNIEnv *env, jobject obj, jint cellHandle, jstring jserverName) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getVosServerHandle(JNIEnv * env, jobject obj, + jint cellHandle, + jstring jserverName) { - afs_status_t ast; - void *serverHandle; - char *serverName; - - if ( jserverName != NULL ) { - serverName = getNativeString(env, jserverName); - if ( !serverName ) { - throwAFSException( env, JAFSADMNOMEM ); - return -1; + afs_status_t ast; + void *serverHandle; + char *serverName; + + if (jserverName != NULL) { + serverName = getNativeString(env, jserverName); + if (!serverName) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } + } else { + throwAFSException(env, JAFSNULLSERVER); + return -1; } - } else { - throwAFSException( env, JAFSNULLSERVER ); - return -1; - } - - if ( !vos_ServerOpen( (void *) cellHandle, serverName, - (void **) &serverHandle, &ast ) ) { - throwAFSException( env, ast ); - } - // release converted string - free( serverName ); + if (!vos_ServerOpen + ((void *)cellHandle, serverName, (void **)&serverHandle, &ast)) { + throwAFSException(env, ast); + } + // release converted string + free(serverName); - return (jint) serverHandle; + return (jint) serverHandle; } /** @@ -251,16 +255,16 @@ Java_org_openafs_jafs_Server_getVosServerHandle * obj the current Java object * vosServerHandle the vos server handle to close */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_closeVosServerHandle - (JNIEnv *env, jobject obj, jint vosServerHandle) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_closeVosServerHandle(JNIEnv * env, jobject obj, + jint vosServerHandle) { - afs_status_t ast; + afs_status_t ast; - if ( !vos_ServerClose( (void *) vosServerHandle, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!vos_ServerClose((void *)vosServerHandle, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -276,34 +280,34 @@ Java_org_openafs_jafs_Server_closeVosServerHandle * a bos handle * returns a bos handle to the server */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getBosServerHandle - (JNIEnv *env, jobject obj, jint cellHandle, jstring jserverName) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getBosServerHandle(JNIEnv * env, jobject obj, + jint cellHandle, + jstring jserverName) { - afs_status_t ast; - void *serverHandle; - char *serverName; - - if ( jserverName != NULL ) { - serverName = getNativeString(env, jserverName); - if ( !serverName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + afs_status_t ast; + void *serverHandle; + char *serverName; + + if (jserverName != NULL) { + serverName = getNativeString(env, jserverName); + if (!serverName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLSERVER); + return; } - } else { - throwAFSException( env, JAFSNULLSERVER ); - return; - } - - if ( !bos_ServerOpen( (void *) cellHandle, serverName, - (void **) &serverHandle, &ast ) ) { - throwAFSException( env, ast ); - } - // release converted string - free( serverName ); + if (!bos_ServerOpen + ((void *)cellHandle, serverName, (void **)&serverHandle, &ast)) { + throwAFSException(env, ast); + } + // release converted string + free(serverName); - return (jint) serverHandle; + return (jint) serverHandle; } /** @@ -313,16 +317,16 @@ Java_org_openafs_jafs_Server_getBosServerHandle * obj the current Java object * bosServerHandle the bos server handle to close */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_closeBosServerHandle - (JNIEnv *env, jobject obj, jint bosServerHandle) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_closeBosServerHandle(JNIEnv * env, jobject obj, + jint bosServerHandle) { - afs_status_t ast; + afs_status_t ast; - if ( !bos_ServerClose( (void *) bosServerHandle, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_ServerClose((void *)bosServerHandle, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -335,45 +339,45 @@ Java_org_openafs_jafs_Server_closeBosServerHandle * to getToken * returns a long representing the UTC time for the token expiration */ -JNIEXPORT jlong JNICALL -Java_org_openafs_jafs_Token_getExpiration - (JNIEnv *env, jobject obj, jint tokenHandle) +JNIEXPORT jlong JNICALL +Java_org_openafs_jafs_Token_getExpiration(JNIEnv * env, jobject obj, + jint tokenHandle) { - afs_status_t ast; - unsigned long expTime; - char *prince = malloc( sizeof(char)*KAS_MAX_NAME_LEN ); - char *inst = malloc( sizeof(char)*KAS_MAX_NAME_LEN ); - char *cell = malloc( sizeof(char)*AFS_MAX_SERVER_NAME_LEN ); - int hkt; - - if ( !prince || !inst || !cell ) { - if ( prince ) { - free( prince ); - } - if ( inst ) { - free( inst ); + afs_status_t ast; + unsigned long expTime; + char *prince = malloc(sizeof(char) * KAS_MAX_NAME_LEN); + char *inst = malloc(sizeof(char) * KAS_MAX_NAME_LEN); + char *cell = malloc(sizeof(char) * AFS_MAX_SERVER_NAME_LEN); + int hkt; + + if (!prince || !inst || !cell) { + if (prince) { + free(prince); + } + if (inst) { + free(inst); + } + if (cell) { + free(cell); + } + throwAFSException(env, JAFSADMNOMEM); + return; } - if ( cell ) { - free( cell ); - } - throwAFSException( env, JAFSADMNOMEM ); - return; - } - if ( !afsclient_TokenQuery( (void *) tokenHandle, &expTime, prince, inst, - cell, &hkt, &ast ) ) { - throwAFSException( env, ast ); - } + if (!afsclient_TokenQuery + ((void *)tokenHandle, &expTime, prince, inst, cell, &hkt, &ast)) { + throwAFSException(env, ast); + } - free( prince ); - free( inst ); - free( cell ); + free(prince); + free(inst); + free(cell); - return (jlong) expTime; + return (jlong) expTime; } // reclaim global memory used by this portion -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Token_reclaimAuthMemory (JNIEnv *env, jclass cls) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Token_reclaimAuthMemory(JNIEnv * env, jclass cls) { } diff --git a/src/JAVA/libjafs/Cell.c b/src/JAVA/libjafs/Cell.c index aafbfe6c6..f4c8e563c 100644 --- a/src/JAVA/libjafs/Cell.c +++ b/src/JAVA/libjafs/Cell.c @@ -53,20 +53,20 @@ extern jfieldID server_cachedInfoField; /*----------------------------------------------------------------------- * Definition in User.c */ -extern void getUserInfoChar (JNIEnv *env, int cellHandle, const char *name, - jobject user); +extern void getUserInfoChar(JNIEnv * env, int cellHandle, const char *name, + jobject user); /*----------------------------------------------------------------------- * Definition in Group.c */ -extern void getGroupInfoChar (JNIEnv *env, int cellHandle, const char *name, - jobject group); +extern void getGroupInfoChar(JNIEnv * env, int cellHandle, const char *name, + jobject group); /*----------------------------------------------------------------------- * Definition in Server.c */ -extern void fillServerInfo (JNIEnv *env, jint cellHandle, jobject server, - afs_serverEntry_t servEntry); +extern void fillServerInfo(JNIEnv * env, jint cellHandle, jobject server, + afs_serverEntry_t servEntry); /*-----------------------------------------------------------------------*/ @@ -80,29 +80,29 @@ extern void fillServerInfo (JNIEnv *env, jint cellHandle, jobject server, * cellHandle the handle of the cell to which the users belong * returns total count of KAS users */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getKasUserCount - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getKasUserCount(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - void *iterationId; - kas_identity_t who; - int i = 0; + afs_status_t ast; + void *iterationId; + kas_identity_t who; + int i = 0; - if ( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, - &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + if (!kas_PrincipalGetBegin((void *)cellHandle, NULL, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - while ( kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) i++; + while (kas_PrincipalGetNext((void *)iterationId, &who, &ast)) + i++; - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } @@ -117,20 +117,19 @@ Java_org_openafs_jafs_Cell_getKasUserCount * cellHandle the handle of the cell to which the users belong * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getKasUsersBegin - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getKasUsersBegin(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - void *iterationId; + afs_status_t ast; + void *iterationId; - if ( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, &iterationId, - &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!kas_PrincipalGetBegin((void *)cellHandle, NULL, &iterationId, &ast)) { + throwAFSException(env, ast); + return; + } - return (jint) iterationId; + return (jint) iterationId; } /** @@ -146,33 +145,33 @@ Java_org_openafs_jafs_Cell_getKasUsersBegin * startIndex the starting base-zero index * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getKasUsersBeginAt - (JNIEnv *env, jclass cls, jint cellHandle, jint startIndex) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getKasUsersBeginAt(JNIEnv * env, jclass cls, + jint cellHandle, + jint startIndex) { - afs_status_t ast; - void *iterationId; - kas_identity_t who; - int i; - - if ( !kas_PrincipalGetBegin( (void *) cellHandle, NULL, - &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } - - for ( i = 1; i < startIndex; i++) { - if ( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; - } - } - } - - return (jint) iterationId; + afs_status_t ast; + void *iterationId; + kas_identity_t who; + int i; + + if (!kas_PrincipalGetBegin((void *)cellHandle, NULL, &iterationId, &ast)) { + throwAFSException(env, ast); + return; + } + + for (i = 1; i < startIndex; i++) { + if (!kas_PrincipalGetNext((void *)iterationId, &who, &ast)) { + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } + } + } + + return (jint) iterationId; } /** @@ -185,43 +184,43 @@ Java_org_openafs_jafs_Cell_getKasUsersBeginAt * iterationId the iteration ID of this iteration * returns the name of the next user of the cell */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Cell_getKasUsersNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Cell_getKasUsersNextString(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; - kas_identity_t who; - jstring juser; + afs_status_t ast; + kas_identity_t who; + jstring juser; - if ( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return NULL; - // other + if (!kas_PrincipalGetNext((void *)iterationId, &who, &ast)) { + if (ast == ADMITERATORDONE) { + return NULL; + // other + } else { + throwAFSException(env, ast); + return; + } + } + + if (strcmp(who.instance, "")) { + char *fullName = (char *)malloc(sizeof(char) * (strlen(who.principal) + + strlen(who.instance) + + 2)); + if (!fullName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + *fullName = '\0'; + strcat(fullName, who.principal); + strcat(fullName, "."); + strcat(fullName, who.instance); + juser = (*env)->NewStringUTF(env, fullName); + free(fullName); } else { - throwAFSException( env, ast ); - return; - } - } - - if ( strcmp( who.instance, "" ) ) { - char *fullName = (char *) malloc( sizeof(char)*( strlen( who.principal ) - + strlen( who.instance ) - + 2 ) ); - if ( !fullName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - *fullName = '\0'; - strcat( fullName, who.principal ); - strcat( fullName, "." ); - strcat( fullName, who.instance ); - juser = (*env)->NewStringUTF(env, fullName ); - free( fullName ); - } else { - juser = (*env)->NewStringUTF(env, who.principal); - } - - return juser; + juser = (*env)->NewStringUTF(env, who.principal); + } + + return juser; } @@ -237,60 +236,61 @@ Java_org_openafs_jafs_Cell_getKasUsersNextString * the next kas user * returns 0 if there are no more users, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getKasUsersNext - (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId, - jobject juserObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getKasUsersNext(JNIEnv * env, jclass cls, + jint cellHandle, jint iterationId, + jobject juserObject) { - afs_status_t ast; - kas_identity_t who; - jstring juser; - char *fullName = NULL; + afs_status_t ast; + kas_identity_t who; + jstring juser; + char *fullName = NULL; - if ( !kas_PrincipalGetNext( (void *) iterationId, &who, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return 0; - // other + if (!kas_PrincipalGetNext((void *)iterationId, &who, &ast)) { + if (ast == ADMITERATORDONE) { + return 0; + // other + } else { + throwAFSException(env, ast); + return 0; + } + } + // take care of the instance stuff(by concatenating with a period in between) + if (strcmp(who.instance, "")) { + fullName = + (char *)malloc(sizeof(char) * + (strlen(who.principal) + strlen(who.instance) + + 2)); + if (!fullName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + *fullName = '\0'; + strcat(fullName, who.principal); + strcat(fullName, "."); + strcat(fullName, who.instance); + juser = (*env)->NewStringUTF(env, fullName); } else { - throwAFSException( env, ast ); - return 0; - } - } - - // take care of the instance stuff(by concatenating with a period in between) - if ( strcmp( who.instance, "" ) ) { - fullName = (char *) malloc( sizeof(char)*( strlen( who.principal ) + - strlen( who.instance ) + 2 ) ); - if ( !fullName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - *fullName = '\0'; - strcat( fullName, who.principal ); - strcat( fullName, "." ); - strcat( fullName, who.instance ); - juser = (*env)->NewStringUTF(env, fullName ); - } else { - juser = (*env)->NewStringUTF(env, who.principal); - } - - if ( userCls == 0 ) { - internal_getUserClass( env, juserObject ); - } - - (*env)->SetObjectField(env, juserObject, user_nameField, juser); - - if ( fullName != NULL ) { - getUserInfoChar( env, (int) cellHandle, fullName, juserObject ); - free( fullName ); - } else { - getUserInfoChar( env, (int) cellHandle, who.principal, juserObject ); - } - (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE ); - - return 1; + juser = (*env)->NewStringUTF(env, who.principal); + } + + if (userCls == 0) { + internal_getUserClass(env, juserObject); + } + + (*env)->SetObjectField(env, juserObject, user_nameField, juser); + + if (fullName != NULL) { + getUserInfoChar(env, (int)cellHandle, fullName, juserObject); + free(fullName); + } else { + getUserInfoChar(env, (int)cellHandle, who.principal, juserObject); + } + (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE); + + return 1; } @@ -301,16 +301,16 @@ Java_org_openafs_jafs_Cell_getKasUsersNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_getKasUsersDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_getKasUsersDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !kas_PrincipalGetDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!kas_PrincipalGetDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } @@ -322,23 +322,23 @@ Java_org_openafs_jafs_Cell_getKasUsersDone * cellHandle the handle of the cell to which the user belongs * returns the name of the cell */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Cell_getCellName - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Cell_getCellName(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - char *cellName; - jstring jcellName; + afs_status_t ast; + char *cellName; + jstring jcellName; + + if (!afsclient_CellNameGet + ((void *)cellHandle, (const char **)&cellName, &ast)) { + throwAFSException(env, ast); + return; + } - if ( !afsclient_CellNameGet( (void *) cellHandle, - (const char **) &cellName, &ast ) ) { - throwAFSException( env, ast ); - return; - } - - jcellName = (*env)->NewStringUTF(env, cellName); + jcellName = (*env)->NewStringUTF(env, cellName); - return jcellName; + return jcellName; } @@ -351,37 +351,38 @@ Java_org_openafs_jafs_Cell_getCellName * cellHandle the handle of the cell to which the users belong * returns total number of PTS users */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getPtsUserCount - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getPtsUserCount(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - void *iterationId; - char *userName; - int i = 0; + afs_status_t ast; + void *iterationId; + char *userName; + int i = 0; - if ( !pts_UserListBegin( (void *) cellHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + if (!pts_UserListBegin((void *)cellHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); - if ( !userName ) { - throwAFSException( env, JAFSADMNOMEM ); - return -1; - } + if (!userName) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } - while ( pts_UserListNext( (void *) iterationId, userName, &ast ) ) i++; + while (pts_UserListNext((void *)iterationId, userName, &ast)) + i++; - free( userName ); + free(userName); - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } /** @@ -393,61 +394,61 @@ Java_org_openafs_jafs_Cell_getPtsUserCount * cellHandle the handle of the cell to which the users belong * returns total number of users that are in PTS and not KAS */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getPtsOnlyUserCount - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getPtsOnlyUserCount(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - void *iterationId; - kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - kas_principalEntry_t kasEntry; - char *userName; - int i = 0; - - if ( who == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return -1; - } - - if ( !pts_UserListBegin( (void *) cellHandle, &iterationId, &ast ) ) { - free( who ); - throwAFSException( env, ast ); - return -1; - } - - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); - if ( !userName ) { - free( who ); - throwAFSException( env, JAFSADMNOMEM ); - return -1; - } - - while ( pts_UserListNext( (void *) iterationId, userName, &ast ) ) { - if ( strcmp( userName, "anonymous" ) != 0 ) { - // make sure the name is within the allowed bounds - if ( strlen( userName ) > KAS_MAX_NAME_LEN ) { - free( who ); - free( userName ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); - return -1; - } - - // if there is a kas entry, recurse - internal_makeKasIdentity( userName, who ); - if ( !kas_PrincipalGet( (void *) cellHandle, NULL, who, - &kasEntry, &ast ) ) i++; + afs_status_t ast; + void *iterationId; + kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t)); + kas_principalEntry_t kasEntry; + char *userName; + int i = 0; + + if (who == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } + + if (!pts_UserListBegin((void *)cellHandle, &iterationId, &ast)) { + free(who); + throwAFSException(env, ast); + return -1; + } + + userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); + if (!userName) { + free(who); + throwAFSException(env, JAFSADMNOMEM); + return -1; + } + + while (pts_UserListNext((void *)iterationId, userName, &ast)) { + if (strcmp(userName, "anonymous") != 0) { + // make sure the name is within the allowed bounds + if (strlen(userName) > KAS_MAX_NAME_LEN) { + free(who); + free(userName); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); + return -1; + } + // if there is a kas entry, recurse + internal_makeKasIdentity(userName, who); + if (!kas_PrincipalGet + ((void *)cellHandle, NULL, who, &kasEntry, &ast)) + i++; } - } + } - free( userName ); - free( who ); + free(userName); + free(who); - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } /** @@ -461,19 +462,19 @@ Java_org_openafs_jafs_Cell_getPtsOnlyUserCount * cellHandle the handle of the cell to which the users belong * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getPtsUsersBegin - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getPtsUsersBegin(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - void *iterationId; + afs_status_t ast; + void *iterationId; - if ( !pts_UserListBegin( (void *) cellHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + if (!pts_UserListBegin((void *)cellHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - return (jint) iterationId; + return (jint) iterationId; } @@ -486,40 +487,40 @@ Java_org_openafs_jafs_Cell_getPtsUsersBegin * iterationId the iteration ID of this iteration * returns the name of the next user of the cell */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Cell_getPtsUsersNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Cell_getPtsUsersNextString(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; - char *userName; - jstring juser; + afs_status_t ast; + char *userName; + jstring juser; - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); - if ( !userName ) { - throwAFSException( env, JAFSADMNOMEM ); - return NULL; - } + if (!userName) { + throwAFSException(env, JAFSADMNOMEM); + return NULL; + } - if ( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) { - free( userName ); - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return NULL; + if (!pts_UserListNext((void *)iterationId, userName, &ast)) { + free(userName); + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return NULL; + } } - } - if ( strcmp( userName, "anonymous" ) == 0 ) { - free( userName ); - return Java_org_openafs_jafs_Cell_getPtsUsersNextString( env, cls, - iterationId ); - } + if (strcmp(userName, "anonymous") == 0) { + free(userName); + return Java_org_openafs_jafs_Cell_getPtsUsersNextString(env, cls, + iterationId); + } - juser = (*env)->NewStringUTF(env, userName); - free( userName ); - return juser; + juser = (*env)->NewStringUTF(env, userName); + free(userName); + return juser; } @@ -533,64 +534,62 @@ Java_org_openafs_jafs_Cell_getPtsUsersNextString * cellHandle the cell handle to which these users will belong * returns the name of the next pts user (not kas user) of the cell */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Cell_getPtsOnlyUsersNextString - (JNIEnv *env, jclass cls, jint iterationId, jint cellHandle) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Cell_getPtsOnlyUsersNextString(JNIEnv * env, jclass cls, + jint iterationId, + jint cellHandle) { - kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) ); + kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t)); kas_principalEntry_t kasEntry; afs_status_t ast; char *userName; jstring juser; - if ( !who ) { - throwAFSException( env, JAFSADMNOMEM ); - return NULL; + if (!who) { + throwAFSException(env, JAFSADMNOMEM); + return NULL; } - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); - if ( !userName ) { - free( who ); - throwAFSException( env, JAFSADMNOMEM ); - return NULL; + if (!userName) { + free(who); + throwAFSException(env, JAFSADMNOMEM); + return NULL; } - while( 1 ) { + while (1) { - if ( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) { - free( userName ); - free( who ); - if ( ast == ADMITERATORDONE ) { + if (!pts_UserListNext((void *)iterationId, userName, &ast)) { + free(userName); + free(who); + if (ast == ADMITERATORDONE) { return NULL; } else { - throwAFSException( env, ast ); + throwAFSException(env, ast); return NULL; } } - if ( strcmp( userName, "anonymous" ) == 0 ) { + if (strcmp(userName, "anonymous") == 0) { continue; } - // make sure the name is within the allowed bounds - if ( strlen( userName ) > KAS_MAX_NAME_LEN ) { - free( who ); - free( userName ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); + if (strlen(userName) > KAS_MAX_NAME_LEN) { + free(who); + free(userName); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); return NULL; } - // if there is a kas entry, recurse - internal_makeKasIdentity( userName, who ); - if ( kas_PrincipalGet( (void *) cellHandle, NULL, who, - &kasEntry, &ast ) ) { + internal_makeKasIdentity(userName, who); + if (kas_PrincipalGet((void *)cellHandle, NULL, who, &kasEntry, &ast)) { continue; } - + juser = (*env)->NewStringUTF(env, userName); - free( userName ); - free( who ); + free(userName); + free(who); return juser; } @@ -608,54 +607,54 @@ Java_org_openafs_jafs_Cell_getPtsOnlyUsersNextString * the next pts user * returns 0 if there are no more users, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getPtsUsersNext - (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId, - jobject juserObject ) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getPtsUsersNext(JNIEnv * env, jclass cls, + jint cellHandle, jint iterationId, + jobject juserObject) { - - afs_status_t ast; - char *userName; - jstring juser; - - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); - - if ( !userName ) { - throwAFSException( env, JAFSADMNOMEM ); - return 0; - } - - if ( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) { - free( userName ); - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + + afs_status_t ast; + char *userName; + jstring juser; + + userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); + + if (!userName) { + throwAFSException(env, JAFSADMNOMEM); + return 0; } - } - if ( strcmp( userName, "anonymous" ) == 0 ) { - free( userName ); - return Java_org_openafs_jafs_Cell_getPtsUsersNext( env, cls, - cellHandle, - iterationId, - juserObject ); - } - - juser = (*env)->NewStringUTF(env, userName); + if (!pts_UserListNext((void *)iterationId, userName, &ast)) { + free(userName); + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } + } + + if (strcmp(userName, "anonymous") == 0) { + free(userName); + return Java_org_openafs_jafs_Cell_getPtsUsersNext(env, cls, + cellHandle, + iterationId, + juserObject); + } - if ( userCls == 0 ) { - internal_getUserClass( env, juserObject ); - } + juser = (*env)->NewStringUTF(env, userName); - (*env)->SetObjectField(env, juserObject, user_nameField, juser); + if (userCls == 0) { + internal_getUserClass(env, juserObject); + } - getUserInfoChar( env, (int) cellHandle, userName, juserObject ); - (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE ); + (*env)->SetObjectField(env, juserObject, user_nameField, juser); - free( userName ); - return 1; + getUserInfoChar(env, (int)cellHandle, userName, juserObject); + (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE); + + free(userName); + return 1; } /** @@ -670,78 +669,75 @@ Java_org_openafs_jafs_Cell_getPtsUsersNext * the next pts (with no kas) user * returns 0 if there are no more users, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getPtsOnlyUsersNext - (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId, - jobject juserObject ) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getPtsOnlyUsersNext(JNIEnv * env, jclass cls, + jint cellHandle, + jint iterationId, + jobject juserObject) { - kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - kas_principalEntry_t kasEntry; - afs_status_t ast; - char *userName; - jstring juser; - - if ( !who ) { - throwAFSException( env, JAFSADMNOMEM ); - return 0; - } - - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); - - if ( !userName ) { - free( who ); - throwAFSException( env, JAFSADMNOMEM ); - return 0; - } - - while( 1 ) { - - if ( !pts_UserListNext( (void *) iterationId, userName, &ast ) ) { - free( userName ); - free( who ); - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; - } - } - - if ( strcmp( userName, "anonymous" ) == 0 ) { - continue; - } - - // make sure the name is within the allowed bounds - if ( strlen( userName ) > KAS_MAX_NAME_LEN ) { - free( userName ); - free( who ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); - return 0; - } - - if ( userCls == 0 ) { - internal_getUserClass( env, juserObject ); - } - - - // if there is a kas entry, recurse - internal_makeKasIdentity( userName, who ); - if ( kas_PrincipalGet( (void *) cellHandle, NULL, who, - &kasEntry, &ast ) ) { - continue; - } - - juser = (*env)->NewStringUTF(env, userName); - - (*env)->SetObjectField(env, juserObject, user_nameField, juser); - getUserInfoChar( env, (int) cellHandle, userName, juserObject ); - (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE ); - - free( who ); - free( userName ); - return 1; - - } + kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t)); + kas_principalEntry_t kasEntry; + afs_status_t ast; + char *userName; + jstring juser; + + if (!who) { + throwAFSException(env, JAFSADMNOMEM); + return 0; + } + + userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); + + if (!userName) { + free(who); + throwAFSException(env, JAFSADMNOMEM); + return 0; + } + + while (1) { + + if (!pts_UserListNext((void *)iterationId, userName, &ast)) { + free(userName); + free(who); + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } + } + + if (strcmp(userName, "anonymous") == 0) { + continue; + } + // make sure the name is within the allowed bounds + if (strlen(userName) > KAS_MAX_NAME_LEN) { + free(userName); + free(who); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); + return 0; + } + + if (userCls == 0) { + internal_getUserClass(env, juserObject); + } + // if there is a kas entry, recurse + internal_makeKasIdentity(userName, who); + if (kas_PrincipalGet((void *)cellHandle, NULL, who, &kasEntry, &ast)) { + continue; + } + + juser = (*env)->NewStringUTF(env, userName); + + (*env)->SetObjectField(env, juserObject, user_nameField, juser); + getUserInfoChar(env, (int)cellHandle, userName, juserObject); + (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE); + + free(who); + free(userName); + return 1; + + } } @@ -752,17 +748,17 @@ Java_org_openafs_jafs_Cell_getPtsOnlyUsersNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_getPtsUsersDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_getPtsUsersDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; + + if (!pts_UserListDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } - if ( !pts_UserListDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } - } /** @@ -774,38 +770,39 @@ Java_org_openafs_jafs_Cell_getPtsUsersDone * cellHandle the handle of the cell to which the groups belong * returns total number of groups */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getGroupCount - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getGroupCount(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - void *iterationId; - char *groupName; - int i = 0; + afs_status_t ast; + void *iterationId; + char *groupName; + int i = 0; - if ( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + if (!pts_GroupListBegin((void *)cellHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); - if ( !groupName ) { - throwAFSException( env, JAFSADMNOMEM ); - return -1; - } + if (!groupName) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } - while ( pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) i++; + while (pts_GroupListNext((void *)iterationId, groupName, &ast)) + i++; - free( groupName ); + free(groupName); - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } /** @@ -819,19 +816,19 @@ Java_org_openafs_jafs_Cell_getGroupCount * cellHandle the handle of the cell to which the groups belong * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getGroupsBegin - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getGroupsBegin(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - void *iterationId; + afs_status_t ast; + void *iterationId; - if ( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!pts_GroupListBegin((void *)cellHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return; + } - return (jint) iterationId; + return (jint) iterationId; } /** @@ -846,36 +843,36 @@ Java_org_openafs_jafs_Cell_getGroupsBegin * startIndex the starting base-zero index * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getGroupsBeginAt - (JNIEnv *env, jclass cls, jint cellHandle, jint startIndex) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getGroupsBeginAt(JNIEnv * env, jclass cls, + jint cellHandle, jint startIndex) { - afs_status_t ast; - void *iterationId; - char *groupName; - int i; - - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); - - if ( !pts_GroupListBegin( (void *) cellHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return 0; - } - - for ( i = 1; i < startIndex; i++) { - if ( !pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) { - free( groupName ); - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; - } - } - } - - free( groupName ); - return (jint) iterationId; + afs_status_t ast; + void *iterationId; + char *groupName; + int i; + + groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); + + if (!pts_GroupListBegin((void *)cellHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return 0; + } + + for (i = 1; i < startIndex; i++) { + if (!pts_GroupListNext((void *)iterationId, groupName, &ast)) { + free(groupName); + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } + } + } + + free(groupName); + return (jint) iterationId; } /** @@ -887,34 +884,34 @@ Java_org_openafs_jafs_Cell_getGroupsBeginAt * iterationId the iteration ID of this iteration * returns the name of the next user of the cell */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Cell_getGroupsNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Cell_getGroupsNextString(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; - char *groupName; - jstring jgroup; + afs_status_t ast; + char *groupName; + jstring jgroup; - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); - if ( !groupName ) { - throwAFSException( env, JAFSADMNOMEM ); - return NULL; - } + if (!groupName) { + throwAFSException(env, JAFSADMNOMEM); + return NULL; + } - if ( !pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) { - free( groupName ); - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return NULL; + if (!pts_GroupListNext((void *)iterationId, groupName, &ast)) { + free(groupName); + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return NULL; + } } - } - jgroup = (*env)->NewStringUTF(env, groupName); - free( groupName ); - return jgroup; + jgroup = (*env)->NewStringUTF(env, groupName); + free(groupName); + return jgroup; } @@ -930,45 +927,45 @@ Java_org_openafs_jafs_Cell_getGroupsNextString * the next group * returns 0 if there are no more users, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getGroupsNext - (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId, - jobject jgroupObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getGroupsNext(JNIEnv * env, jclass cls, + jint cellHandle, jint iterationId, + jobject jgroupObject) { - afs_status_t ast; - char *groupName; - jstring jgroup; - - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN ); - - if ( !groupName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( !pts_GroupListNext( (void *) iterationId, groupName, &ast ) ) { - free( groupName ); - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + afs_status_t ast; + char *groupName; + jstring jgroup; + + groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); + + if (!groupName) { + throwAFSException(env, JAFSADMNOMEM); + return; } - } - jgroup = (*env)->NewStringUTF(env, groupName); + if (!pts_GroupListNext((void *)iterationId, groupName, &ast)) { + free(groupName); + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } + } - if ( groupCls == 0 ) { - internal_getGroupClass( env, jgroupObject ); - } + jgroup = (*env)->NewStringUTF(env, groupName); + + if (groupCls == 0) { + internal_getGroupClass(env, jgroupObject); + } - (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup); + (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup); - getGroupInfoChar( env, (int) cellHandle, groupName, jgroupObject ); - (*env)->SetBooleanField( env, jgroupObject, group_cachedInfoField, TRUE ); + getGroupInfoChar(env, (int)cellHandle, groupName, jgroupObject); + (*env)->SetBooleanField(env, jgroupObject, group_cachedInfoField, TRUE); - free( groupName ); - return 1; + free(groupName); + return 1; } /** @@ -978,17 +975,17 @@ Java_org_openafs_jafs_Cell_getGroupsNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_getGroupsDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_getGroupsDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; + + if (!pts_GroupListDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } - if ( !pts_GroupListDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } - } /** @@ -1001,19 +998,19 @@ Java_org_openafs_jafs_Cell_getGroupsDone * cellHandle the handle of the cell to which the group belongs * returns an integer reresenting the max group id in a cell */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getMaxGroupID - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getMaxGroupID(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - jint maxID; + afs_status_t ast; + jint maxID; - if ( !pts_GroupMaxGet( (void *) cellHandle, (int *) &maxID, &ast ) ) { - throwAFSException( env, ast ); - return 0; - } + if (!pts_GroupMaxGet((void *)cellHandle, (int *)&maxID, &ast)) { + throwAFSException(env, ast); + return 0; + } - return maxID; + return maxID; } /** @@ -1025,16 +1022,16 @@ Java_org_openafs_jafs_Cell_getMaxGroupID * cellHandle the handle of the cell to which the group belongs * maxID an integer reresenting the new max group id in a cell */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_setMaxGroupID - (JNIEnv *env, jclass cls, jint cellHandle, jint maxID) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_setMaxGroupID(JNIEnv * env, jclass cls, + jint cellHandle, jint maxID) { - afs_status_t ast; + afs_status_t ast; - if ( !pts_GroupMaxSet( (void *) cellHandle, (int) maxID, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!pts_GroupMaxSet((void *)cellHandle, (int)maxID, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -1047,19 +1044,19 @@ Java_org_openafs_jafs_Cell_setMaxGroupID * cellHandle the handle of the cell to which the user belongs * returns an integer reresenting the max user id in a cell */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getMaxUserID - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getMaxUserID(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - jint maxID; + afs_status_t ast; + jint maxID; - if ( !pts_UserMaxGet( (void *) cellHandle, (int *) &maxID, &ast ) ) { - throwAFSException( env, ast ); - return 0; - } + if (!pts_UserMaxGet((void *)cellHandle, (int *)&maxID, &ast)) { + throwAFSException(env, ast); + return 0; + } - return maxID; + return maxID; } /** @@ -1071,16 +1068,16 @@ Java_org_openafs_jafs_Cell_getMaxUserID * cellHandle the handle of the cell to which the user belongs * maxID an integer reresenting the new max user id in a cell */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_setMaxUserID - (JNIEnv *env, jclass cls, jint cellHandle, jint maxID) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_setMaxUserID(JNIEnv * env, jclass cls, + jint cellHandle, jint maxID) { - afs_status_t ast; + afs_status_t ast; - if ( !pts_UserMaxSet( (void *) cellHandle, (int) maxID, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!pts_UserMaxSet((void *)cellHandle, (int)maxID, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -1092,30 +1089,29 @@ Java_org_openafs_jafs_Cell_setMaxUserID * cellHandle the handle of the cell to which the servers belong * returns total number of servers */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getServerCount - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getServerCount(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - void *iterationId; - afs_serverEntry_t servEntry; - int i = 0; - - if ( !afsclient_AFSServerGetBegin( (void *) cellHandle, - &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } - - while ( afsclient_AFSServerGetNext( (void *) iterationId, - &servEntry, &ast ) ) i++; - - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } - - return i; + afs_status_t ast; + void *iterationId; + afs_serverEntry_t servEntry; + int i = 0; + + if (!afsclient_AFSServerGetBegin((void *)cellHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } + + while (afsclient_AFSServerGetNext((void *)iterationId, &servEntry, &ast)) + i++; + + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } + + return i; } /** @@ -1128,20 +1124,19 @@ Java_org_openafs_jafs_Cell_getServerCount * cellHandle the handle of the cell to which the servers belong * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getServersBegin - (JNIEnv *env, jclass cls, jint cellHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getServersBegin(JNIEnv * env, jclass cls, + jint cellHandle) { - afs_status_t ast; - void *iterationId; + afs_status_t ast; + void *iterationId; - if ( !afsclient_AFSServerGetBegin( (void *) cellHandle, - &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + if (!afsclient_AFSServerGetBegin((void *)cellHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - return (jint) iterationId; + return (jint) iterationId; } /** @@ -1153,23 +1148,23 @@ Java_org_openafs_jafs_Cell_getServersBegin * iterationId the iteration ID of this iteration * returns the name of the next server of the cell */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Cell_getServersNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Cell_getServersNextString(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; - jstring jserver; - afs_serverEntry_t servEntry; + afs_status_t ast; + jstring jserver; + afs_serverEntry_t servEntry; - if ( !afsclient_AFSServerGetNext( (void *) iterationId, &servEntry, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return NULL; + if (!afsclient_AFSServerGetNext((void *)iterationId, &servEntry, &ast)) { + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return NULL; + } } - } - return jserver; + return jserver; } /** @@ -1184,35 +1179,34 @@ Java_org_openafs_jafs_Cell_getServersNextString * of the next server * returns 0 if there are no more servers, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Cell_getServersNext - (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId, - jobject jserverObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Cell_getServersNext(JNIEnv * env, jclass cls, + jint cellHandle, jint iterationId, + jobject jserverObject) { - afs_status_t ast; - jstring jserver; - afs_serverEntry_t servEntry; - jintArray jaddress; - - if ( !afsclient_AFSServerGetNext( (void *) iterationId, &servEntry, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + afs_status_t ast; + jstring jserver; + afs_serverEntry_t servEntry; + jintArray jaddress; + + if (!afsclient_AFSServerGetNext((void *)iterationId, &servEntry, &ast)) { + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } + } + // get the class fields if need be + if (serverCls == 0) { + internal_getServerClass(env, jserverObject); } - } - - // get the class fields if need be - if ( serverCls == 0 ) { - internal_getServerClass( env, jserverObject ); - } - fillServerInfo( env, (int) cellHandle, jserverObject, servEntry ); + fillServerInfo(env, (int)cellHandle, jserverObject, servEntry); - (*env)->SetBooleanField( env, jserverObject, server_cachedInfoField, TRUE ); + (*env)->SetBooleanField(env, jserverObject, server_cachedInfoField, TRUE); - return 1; + return 1; } /** @@ -1222,16 +1216,16 @@ Java_org_openafs_jafs_Cell_getServersNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_getServersDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_getServersDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !afsclient_AFSServerGetDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!afsclient_AFSServerGetDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -1246,59 +1240,62 @@ Java_org_openafs_jafs_Cell_getServersDone * readWrite whether or not this is to be a readwrite mount point * forceCheck whether or not to check if this volume name exists */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_createMountPoint - (JNIEnv *env, jclass cls, jint cellHandle, jstring jdirectory, - jstring jvolumeName, jboolean readWrite, jboolean forceCheck) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_createMountPoint(JNIEnv * env, jclass cls, + jint cellHandle, + jstring jdirectory, + jstring jvolumeName, + jboolean readWrite, + jboolean forceCheck) { - afs_status_t ast; - char *directory; - char *volumeName; - vol_type_t type; - vol_check_t check; - - if ( jdirectory != NULL ) { - directory = getNativeString(env, jdirectory); - if ( !directory ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLPATH ); - return; - } - if ( jvolumeName != NULL ) { - volumeName = getNativeString(env, jvolumeName); - if ( volumeName == NULL ) { - free( directory ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( directory ); - throwAFSException( env, JAFSNULLVOLUME ); - return; - } - - if ( readWrite ) { - type = READ_WRITE; - } else { - type = READ_ONLY; - } - - if ( forceCheck ) { - check = CHECK_VOLUME; - } else { - check = DONT_CHECK_VOLUME; - } - - if ( !afsclient_MountPointCreate( (void *) cellHandle, directory, - volumeName, type, check, &ast ) ) { - throwAFSException( env, ast ); - } - - free( directory ); - free( volumeName ); + afs_status_t ast; + char *directory; + char *volumeName; + vol_type_t type; + vol_check_t check; + + if (jdirectory != NULL) { + directory = getNativeString(env, jdirectory); + if (!directory) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLPATH); + return; + } + if (jvolumeName != NULL) { + volumeName = getNativeString(env, jvolumeName); + if (volumeName == NULL) { + free(directory); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(directory); + throwAFSException(env, JAFSNULLVOLUME); + return; + } + + if (readWrite) { + type = READ_WRITE; + } else { + type = READ_ONLY; + } + + if (forceCheck) { + check = CHECK_VOLUME; + } else { + check = DONT_CHECK_VOLUME; + } + + if (!afsclient_MountPointCreate + ((void *)cellHandle, directory, volumeName, type, check, &ast)) { + throwAFSException(env, ast); + } + + free(directory); + free(volumeName); } /* @@ -1317,98 +1314,100 @@ Java_org_openafs_jafs_Cell_createMountPoint * lock whether or not to allow lock access to this user * admin whether or not to allow admin access to this user */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_setACL - (JNIEnv *env, jclass cls, jstring jdirectory, jstring juserName, - jboolean read, jboolean write, jboolean lookup, jboolean delete, - jboolean insert, jboolean lock, jboolean admin) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_setACL(JNIEnv * env, jclass cls, + jstring jdirectory, jstring juserName, + jboolean read, jboolean write, + jboolean lookup, jboolean delete, + jboolean insert, jboolean lock, + jboolean admin) { - afs_status_t ast; - char *directory; - char *userName; - acl_t acl; - - if ( !afsclient_Init( &ast ) ) { - throwAFSException( env, ast ); - return; - } - - if ( jdirectory != NULL ) { - directory = getNativeString(env, jdirectory); - if ( !directory ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLPATH ); - return; - } - - if ( juserName != NULL ) { - userName = getNativeString(env, juserName); - if ( !userName ) { - free( directory ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( directory ); - throwAFSException( env, JAFSNULLUSER ); - return; - } - - if ( read ) { - acl.read = READ; - } else { - acl.read = NO_READ; - } - - if ( write ) { - acl.write = WRITE; - } else { - acl.write = NO_WRITE; - } - - if ( lookup ) { - acl.lookup = LOOKUP; - } else { - acl.lookup = NO_LOOKUP; - } - - if ( delete ) { - acl.del = DELETE; - } else { - acl.del = NO_DELETE; - } - - if ( insert ) { - acl.insert = INSERT; - } else { - acl.insert = NO_INSERT; - } - - if ( lock ) { - acl.lock = LOCK; - } else { - acl.lock = NO_LOCK; - } - - if ( admin ) { - acl.admin = ADMIN; - } else { - acl.admin = NO_ADMIN; - } - - if ( !afsclient_ACLEntryAdd( directory, userName, &acl, &ast ) ) { - throwAFSException( env, ast ); - } - - free( userName ); - free( directory ); + afs_status_t ast; + char *directory; + char *userName; + acl_t acl; + + if (!afsclient_Init(&ast)) { + throwAFSException(env, ast); + return; + } + + if (jdirectory != NULL) { + directory = getNativeString(env, jdirectory); + if (!directory) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLPATH); + return; + } + + if (juserName != NULL) { + userName = getNativeString(env, juserName); + if (!userName) { + free(directory); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(directory); + throwAFSException(env, JAFSNULLUSER); + return; + } + + if (read) { + acl.read = READ; + } else { + acl.read = NO_READ; + } + + if (write) { + acl.write = WRITE; + } else { + acl.write = NO_WRITE; + } + + if (lookup) { + acl.lookup = LOOKUP; + } else { + acl.lookup = NO_LOOKUP; + } + + if (delete) { + acl.del = DELETE; + } else { + acl.del = NO_DELETE; + } + + if (insert) { + acl.insert = INSERT; + } else { + acl.insert = NO_INSERT; + } + + if (lock) { + acl.lock = LOCK; + } else { + acl.lock = NO_LOCK; + } + + if (admin) { + acl.admin = ADMIN; + } else { + acl.admin = NO_ADMIN; + } + + if (!afsclient_ACLEntryAdd(directory, userName, &acl, &ast)) { + throwAFSException(env, ast); + } + + free(userName); + free(directory); } // reclaim global memory used by this portion -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Cell_reclaimCellMemory (JNIEnv *env, jclass cls) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Cell_reclaimCellMemory(JNIEnv * env, jclass cls) { } diff --git a/src/JAVA/libjafs/Exceptions.h b/src/JAVA/libjafs/Exceptions.h index 1692cfdca..f657fa7d8 100644 --- a/src/JAVA/libjafs/Exceptions.h +++ b/src/JAVA/libjafs/Exceptions.h @@ -1,12 +1,9 @@ #ifndef _Jafsadm_Exceptions #define _Jafsadm_Exceptions -static char *afsExceptionName = "org/openafs/jafs/AFSException"; -static char *afsFileExceptionName = "org/openafs/jafs/AFSFileException"; -static char *afsSecurityExceptionName = "org/openafs/jafs/AFSSecurityException"; +static char *afsExceptionName = "org/openafs/jafs/AFSException"; +static char *afsFileExceptionName = "org/openafs/jafs/AFSFileException"; +static char *afsSecurityExceptionName = + "org/openafs/jafs/AFSSecurityException"; #endif - - - - diff --git a/src/JAVA/libjafs/File.c b/src/JAVA/libjafs/File.c index b2f563b86..4f6e6df42 100644 --- a/src/JAVA/libjafs/File.c +++ b/src/JAVA/libjafs/File.c @@ -49,7 +49,7 @@ #include "dmalloc.h" #endif -void setFileNotExistsAttributes(JNIEnv *env, jobject *obj); +void setFileNotExistsAttributes(JNIEnv * env, jobject * obj); typedef struct { char *fileName; @@ -58,15 +58,16 @@ typedef struct { /*static char compile_date[] = COMPILE_DATE;*/ -int sub_time(struct timeval *tv1, struct timeval *tv2) +int +sub_time(struct timeval *tv1, struct timeval *tv2) { - if (tv2->tv_usec > tv1->tv_usec) { - tv1->tv_usec += 1000000; - tv1->tv_usec -= 1; - } + if (tv2->tv_usec > tv1->tv_usec) { + tv1->tv_usec += 1000000; + tv1->tv_usec -= 1; + } - tv1->tv_usec -= tv2->tv_usec; - tv1->tv_sec -= tv2->tv_sec; + tv1->tv_usec -= tv2->tv_usec; + tv1->tv_sec -= tv2->tv_sec; } /** @@ -76,7 +77,8 @@ int sub_time(struct timeval *tv1, struct timeval *tv2) * env the Java environment * obj the current Java object */ -char* getAbsolutePath(JNIEnv *env, jobject *obj, char *dirName) +char * +getAbsolutePath(JNIEnv * env, jobject * obj, char *dirName) { jclass thisClass; jstring jDirName; @@ -85,30 +87,32 @@ char* getAbsolutePath(JNIEnv *env, jobject *obj, char *dirName) jfieldID fid; thisClass = (*env)->GetObjectClass(env, *obj); - if( thisClass == NULL ) { - fprintf(stderr, "File::getAbsolutePath(): GetObjectClass failed\n"); - return NULL; + if (thisClass == NULL) { + fprintf(stderr, "File::getAbsolutePath(): GetObjectClass failed\n"); + return NULL; } fid = (*env)->GetFieldID(env, thisClass, "path", "Ljava/lang/String;"); - if ( fid == NULL ) { - fprintf(stderr, "File::getAbsolutePath(): GetFieldID (path) failed\n"); - return NULL; + if (fid == NULL) { + fprintf(stderr, + "File::getAbsolutePath(): GetFieldID (path) failed\n"); + return NULL; } jDirName = (*env)->GetObjectField(env, *obj, fid); - if( jDirName == NULL ) { - fprintf(stderr, "File::getAbsolutePath(): failed to get file name\n"); - return NULL; + if (jDirName == NULL) { + fprintf(stderr, "File::getAbsolutePath(): failed to get file name\n"); + return NULL; } auxDirName = getNativeString(env, jDirName); - if ( auxDirName == NULL ) { - fprintf(stderr, "File::getAbsolutePath(): failed to get translated file name\n"); - return NULL; + if (auxDirName == NULL) { + fprintf(stderr, + "File::getAbsolutePath(): failed to get translated file name\n"); + return NULL; } strcpy(dirName, auxDirName); - free( auxDirName ); + free(auxDirName); } /** @@ -126,10 +130,10 @@ char* getAbsolutePath(JNIEnv *env, jobject *obj, char *dirName) * * throws AFSException */ -JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_setAttributes - (JNIEnv *env, jobject obj) +JNIEXPORT jboolean JNICALL +Java_org_openafs_jafs_File_setAttributes(JNIEnv * env, jobject obj) { - char target[FILENAME_MAX+1]; + char target[FILENAME_MAX + 1]; char dirName[FILENAME_MAX]; jclass thisClass; jfieldID fid; @@ -141,184 +145,187 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_setAttributes struct timeval tv0, tv1; struct timezone tz; - /*memset(target, 0, FILENAME_MAX);*/ + /*memset(target, 0, FILENAME_MAX); */ *dirName = '\0'; getAbsolutePath(env, &obj, dirName); - /*fprintf(stderr, "dirName=%s\n", dirName);*/ + /*fprintf(stderr, "dirName=%s\n", dirName); */ - if(*dirName == '\0') { - fprintf(stderr, "File::setAttributes(): failed to get dirName\n"); - return JNI_FALSE; + if (*dirName == '\0') { + fprintf(stderr, "File::setAttributes(): failed to get dirName\n"); + return JNI_FALSE; } - thisClass = (*env) -> GetObjectClass(env, obj); - if(thisClass == NULL) { - fprintf(stderr, "File::setAttributes(): GetObjectClass failed\n"); - return JNI_FALSE; + thisClass = (*env)->GetObjectClass(env, obj); + if (thisClass == NULL) { + fprintf(stderr, "File::setAttributes(): GetObjectClass failed\n"); + return JNI_FALSE; } gettimeofday(&tv0, &tz); if ((strcmp(dirName, "/afs") == 0) || (strcmp(dirName, "/afs/") == 0)) { - rc = 1; /* special case for /afs since statmountpoint fails on it */ + rc = 1; /* special case for /afs since statmountpoint fails on it */ } else { - rc = uafs_statmountpoint(dirName); - gettimeofday(&tv1, &tz); - sub_time(&tv1, &tv0); - /*printf("%s: statmountpoint %d.%06d\n", dirName, tv1.tv_sec, tv1.tv_usec);*/ - } - - if(rc < 0) { - setError(env, &obj, errno); - if(errno == ENOENT) { - setFileNotExistsAttributes(env, &obj); - return JNI_TRUE; /* not really an error */ - } else { - fprintf(stderr, "File::setAttributes(): uafs_statmountpoint failed " - "for %s (%s)\n", dirName, error_message(errno)); - return JNI_FALSE; - } + rc = uafs_statmountpoint(dirName); + gettimeofday(&tv1, &tz); + sub_time(&tv1, &tv0); + /*printf("%s: statmountpoint %d.%06d\n", dirName, tv1.tv_sec, tv1.tv_usec); */ + } + + if (rc < 0) { + setError(env, &obj, errno); + if (errno == ENOENT) { + setFileNotExistsAttributes(env, &obj); + return JNI_TRUE; /* not really an error */ + } else { + fprintf(stderr, + "File::setAttributes(): uafs_statmountpoint failed " + "for %s (%s)\n", dirName, error_message(errno)); + return JNI_FALSE; + } } if (rc == 1) { - /* this is an AFS mount point; we don't want to stat it */ - /* fake up a stat entry instead */ - mtpoint = 1; - st.st_mtime = 0; - st.st_size = 2048; - st.st_mode = 0; /* don't match anything */ + /* this is an AFS mount point; we don't want to stat it */ + /* fake up a stat entry instead */ + mtpoint = 1; + st.st_mtime = 0; + st.st_size = 2048; + st.st_mode = 0; /* don't match anything */ } else { - mtpoint = 0; - fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z"); - if (fid == 0) { - fprintf(stderr, "File::setAttributes(): GetFieldID (isLink) failed\n"); - setError(env, &obj, -1); - return JNI_FALSE; - } - islink = (*env)->GetBooleanField(env, obj, fid); - if (islink != JNI_TRUE) { - rc = uafs_lstat(dirName, &st); - } else { - /* Here we are being called on a link object for the second time, - so we want info on the object pointed to by the link. */ - fprintf(stderr, "islink = TRUE on file %s\n", dirName); - rc = uafs_stat(dirName, &st); - } - - if(rc < 0) { - setError(env, &obj, errno); - fprintf(stderr, "uafs_lstat failed for dir %s: error %d\n", - dirName, errno); - if(errno == ENOENT) { - setFileNotExistsAttributes(env, &obj); - return JNI_TRUE; - } - fprintf(stderr, - "File::setAttributes(): uafs_stat failed for %s (%s)\n", - dirName, error_message(errno)); - return JNI_FALSE; - } + mtpoint = 0; + fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z"); + if (fid == 0) { + fprintf(stderr, + "File::setAttributes(): GetFieldID (isLink) failed\n"); + setError(env, &obj, -1); + return JNI_FALSE; + } + islink = (*env)->GetBooleanField(env, obj, fid); + if (islink != JNI_TRUE) { + rc = uafs_lstat(dirName, &st); + } else { + /* Here we are being called on a link object for the second time, + * so we want info on the object pointed to by the link. */ + fprintf(stderr, "islink = TRUE on file %s\n", dirName); + rc = uafs_stat(dirName, &st); + } + + if (rc < 0) { + setError(env, &obj, errno); + fprintf(stderr, "uafs_lstat failed for dir %s: error %d\n", + dirName, errno); + if (errno == ENOENT) { + setFileNotExistsAttributes(env, &obj); + return JNI_TRUE; + } + fprintf(stderr, + "File::setAttributes(): uafs_stat failed for %s (%s)\n", + dirName, error_message(errno)); + return JNI_FALSE; + } } fid = (*env)->GetFieldID(env, thisClass, "exists", "Z"); if (fid == 0) { - fprintf(stderr, - "File::setAttributes(): GetFieldID (exists) failed\n"); - setError(env, &obj, -1); - return JNI_FALSE; + fprintf(stderr, + "File::setAttributes(): GetFieldID (exists) failed\n"); + setError(env, &obj, -1); + return JNI_FALSE; } (*env)->SetBooleanField(env, obj, fid, JNI_TRUE); fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z"); if (fid == 0) { - fprintf(stderr, - "File::setAttributes(): GetFieldID (isDirectory) failed\n"); - setError(env, &obj, -1); - return JNI_FALSE; + fprintf(stderr, + "File::setAttributes(): GetFieldID (isDirectory) failed\n"); + setError(env, &obj, -1); + return JNI_FALSE; } if ((st.st_mode & S_IFMT) == S_IFDIR && !mtpoint) { - (*env)->SetBooleanField(env, obj, fid, JNI_TRUE); + (*env)->SetBooleanField(env, obj, fid, JNI_TRUE); } else { - (*env)->SetBooleanField(env, obj, fid, JNI_FALSE); + (*env)->SetBooleanField(env, obj, fid, JNI_FALSE); } fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z"); if (fid == 0) { - fprintf(stderr, - "File::setAttributes(): GetFieldID (isFile) failed\n"); - setError(env, &obj, -1); - return JNI_FALSE; + fprintf(stderr, + "File::setAttributes(): GetFieldID (isFile) failed\n"); + setError(env, &obj, -1); + return JNI_FALSE; } if ((st.st_mode & S_IFMT) == S_IFREG) { - (*env)->SetBooleanField(env, obj, fid, JNI_TRUE); + (*env)->SetBooleanField(env, obj, fid, JNI_TRUE); } else { - (*env)->SetBooleanField(env, obj, fid, JNI_FALSE); + (*env)->SetBooleanField(env, obj, fid, JNI_FALSE); } fid = (*env)->GetFieldID(env, thisClass, "isLink", "Z"); if (fid == 0) { - fprintf(stderr, - "File::setAttributes(): GetFieldID (isLink) failed\n"); - setError(env, &obj, -1); - return JNI_FALSE; - } - - if (islink != JNI_TRUE) { /* don't re-process link */ - if ((st.st_mode & S_IFMT) == S_IFLNK) { - (*env)->SetBooleanField(env, obj, fid, JNI_TRUE); - - /* Find the target of the link */ - rc = uafs_readlink(dirName, target, FILENAME_MAX); - if (rc < 0) { - fprintf(stderr, "File::setAttributes(): uafs_readlink failed\n"); - setError(env, &obj, errno); - return JNI_FALSE; - } else { - target[rc] = 0; /* weird that we have to do this */ - /*fprintf(stderr, "readlink %s succeeded, target=%s, rc=%d\n", dirName, - target, rc);*/ - } - - rc = setString(env, &obj, "target", target); - if (rc < 0) { - fprintf(stderr, "setString dirName=%s target=%s failed\n", - dirName, target); - } - } else { - (*env)->SetBooleanField(env, obj, fid, JNI_FALSE); - } + fprintf(stderr, + "File::setAttributes(): GetFieldID (isLink) failed\n"); + setError(env, &obj, -1); + return JNI_FALSE; + } + + if (islink != JNI_TRUE) { /* don't re-process link */ + if ((st.st_mode & S_IFMT) == S_IFLNK) { + (*env)->SetBooleanField(env, obj, fid, JNI_TRUE); + + /* Find the target of the link */ + rc = uafs_readlink(dirName, target, FILENAME_MAX); + if (rc < 0) { + fprintf(stderr, + "File::setAttributes(): uafs_readlink failed\n"); + setError(env, &obj, errno); + return JNI_FALSE; + } else { + target[rc] = 0; /* weird that we have to do this */ + /*fprintf(stderr, "readlink %s succeeded, target=%s, rc=%d\n", dirName, + * target, rc); */ + } + + rc = setString(env, &obj, "target", target); + if (rc < 0) { + fprintf(stderr, "setString dirName=%s target=%s failed\n", + dirName, target); + } + } else { + (*env)->SetBooleanField(env, obj, fid, JNI_FALSE); + } } fid = (*env)->GetFieldID(env, thisClass, "isMountPoint", "Z"); if (fid == 0) { - fprintf(stderr, - "File::setAttributes(): GetFieldID (isMountPoint) failed\n"); - setError(env, &obj, -1); - return JNI_FALSE; + fprintf(stderr, + "File::setAttributes(): GetFieldID (isMountPoint) failed\n"); + setError(env, &obj, -1); + return JNI_FALSE; } if (mtpoint) { - (*env)->SetBooleanField(env, obj, fid, JNI_TRUE); + (*env)->SetBooleanField(env, obj, fid, JNI_TRUE); } else { - (*env)->SetBooleanField(env, obj, fid, JNI_FALSE); + (*env)->SetBooleanField(env, obj, fid, JNI_FALSE); } fid = (*env)->GetFieldID(env, thisClass, "lastModified", "J"); if (fid == 0) { - fprintf(stderr, - "File::setAttributes(): GetFieldID (lastModified) failed\n"); - setError(env, &obj, -1); - return JNI_FALSE; + fprintf(stderr, + "File::setAttributes(): GetFieldID (lastModified) failed\n"); + setError(env, &obj, -1); + return JNI_FALSE; } - (*env)->SetLongField(env, obj, fid, ((jlong) st.st_mtime)*1000); + (*env)->SetLongField(env, obj, fid, ((jlong) st.st_mtime) * 1000); fid = (*env)->GetFieldID(env, thisClass, "length", "J"); if (fid == 0) { - fprintf(stderr, - "File::setAttributes(): GetFieldID (length) failed\n"); - setError(env, &obj, -1); - return JNI_FALSE; + fprintf(stderr, + "File::setAttributes(): GetFieldID (length) failed\n"); + setError(env, &obj, -1); + return JNI_FALSE; } (*env)->SetLongField(env, obj, fid, st.st_size); @@ -335,8 +342,8 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_setAttributes * * return permission/ACL mask */ -JNIEXPORT jint JNICALL Java_org_openafs_jafs_File_getRights - (JNIEnv *env, jobject obj) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_File_getRights(JNIEnv * env, jobject obj) { char dirName[FILENAME_MAX]; jclass thisClass; @@ -348,10 +355,10 @@ JNIEXPORT jint JNICALL Java_org_openafs_jafs_File_getRights *dirName = '\0'; getAbsolutePath(env, &obj, dirName); - if(*dirName == '\0') { - fprintf(stderr, "File::getRights(): failed to get dirName\n"); - setError(env, &obj, -1); - return JNI_FALSE; + if (*dirName == '\0') { + fprintf(stderr, "File::getRights(): failed to get dirName\n"); + setError(env, &obj, -1); + return JNI_FALSE; } /*-Access Rights- @@ -367,25 +374,25 @@ JNIEXPORT jint JNICALL Java_org_openafs_jafs_File_getRights rights = 0; afs_rights = uafs_getRights(dirName); if (afs_rights < 0) { - setError(env, &obj, errno); - return -1; + setError(env, &obj, errno); + return -1; } - + if (afs_rights & PRSFS_READ) - rights |= UAFS_READ; + rights |= UAFS_READ; if (afs_rights & PRSFS_WRITE) - rights |= UAFS_WRITE; + rights |= UAFS_WRITE; if (afs_rights & PRSFS_INSERT) - rights |= UAFS_INSERT; + rights |= UAFS_INSERT; if (afs_rights & PRSFS_LOOKUP) - rights |= UAFS_LOOKUP; + rights |= UAFS_LOOKUP; if (afs_rights & PRSFS_DELETE) - rights |= UAFS_DELETE; + rights |= UAFS_DELETE; if (afs_rights & PRSFS_LOCK) - rights |= UAFS_LOCK; + rights |= UAFS_LOCK; if (afs_rights & PRSFS_ADMINISTER) - rights |= UAFS_ADMIN; - + rights |= UAFS_ADMIN; + return rights; } @@ -398,8 +405,9 @@ JNIEXPORT jint JNICALL Java_org_openafs_jafs_File_getRights * * return the directory handle */ -JNIEXPORT jlong JNICALL Java_org_openafs_jafs_File_listNative - (JNIEnv *env, jobject obj, jobject buffer) +JNIEXPORT jlong JNICALL +Java_org_openafs_jafs_File_listNative(JNIEnv * env, jobject obj, + jobject buffer) { char dirName[FILENAME_MAX]; jclass arrayListClass; @@ -409,48 +417,48 @@ JNIEXPORT jlong JNICALL Java_org_openafs_jafs_File_listNative struct usr_dirent *enp; int i, dirSize; - *dirName='\0'; + *dirName = '\0'; getAbsolutePath(env, &obj, dirName); - if(*dirName == '\0') { - fprintf(stderr, "File::listNative(): failed to get dirName\n"); - setError(env, &obj, -1); - return 0; + if (*dirName == '\0') { + fprintf(stderr, "File::listNative(): failed to get dirName\n"); + setError(env, &obj, -1); + return 0; } arrayListClass = (*env)->GetObjectClass(env, buffer); - if(arrayListClass == NULL) { - fprintf(stderr, "File::listNative(): GetObjectClass failed\n"); - setError(env, &obj, -1); - return 0; - } - addID = (*env) -> GetMethodID(env, arrayListClass, "add", - "(Ljava/lang/Object;)Z"); - if(addID == 0) { - fprintf(stderr, - "File::listNative(): failed to get addID\n"); - setError(env, &obj, -1); - return 0; + if (arrayListClass == NULL) { + fprintf(stderr, "File::listNative(): GetObjectClass failed\n"); + setError(env, &obj, -1); + return 0; + } + addID = + (*env)->GetMethodID(env, arrayListClass, "add", + "(Ljava/lang/Object;)Z"); + if (addID == 0) { + fprintf(stderr, "File::listNative(): failed to get addID\n"); + setError(env, &obj, -1); + return 0; } dirp = uafs_opendir(dirName); - if(dirp == NULL) { - fprintf(stderr, "File::listNative(): uafs_opendir(%s) failed(%s)\n", - dirName, error_message(errno)); - setError(env, &obj, errno); - //throwAFSSecurityException( env, errno ); - return 0; - } - while((enp = uafs_readdir(dirp)) != NULL) { - if(strcmp(enp->d_name, ".") == 0 || strcmp(enp->d_name, "..") == 0) { - continue; + if (dirp == NULL) { + fprintf(stderr, "File::listNative(): uafs_opendir(%s) failed(%s)\n", + dirName, error_message(errno)); + setError(env, &obj, errno); + //throwAFSSecurityException( env, errno ); + return 0; + } + while ((enp = uafs_readdir(dirp)) != NULL) { + if (strcmp(enp->d_name, ".") == 0 || strcmp(enp->d_name, "..") == 0) { + continue; } - entryJString = (*env) -> NewStringUTF(env, enp->d_name); - if(entryJString == NULL) { - fprintf(stderr, "File::listNative(): NewStringUTF failed\n"); - setError(env, &obj, -1); - return 0; - } - (*env) -> CallBooleanMethod(env, buffer, addID, entryJString); + entryJString = (*env)->NewStringUTF(env, enp->d_name); + if (entryJString == NULL) { + fprintf(stderr, "File::listNative(): NewStringUTF failed\n"); + setError(env, &obj, -1); + return 0; + } + (*env)->CallBooleanMethod(env, buffer, addID, entryJString); } - /*uafs_closedir(dirp);*/ + /*uafs_closedir(dirp); */ setError(env, &obj, 0); @@ -465,19 +473,19 @@ JNIEXPORT jlong JNICALL Java_org_openafs_jafs_File_listNative * * return true if the directory closes without error */ -JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_closeDir - (JNIEnv *env, jobject obj, jlong dp) +JNIEXPORT jboolean JNICALL +Java_org_openafs_jafs_File_closeDir(JNIEnv * env, jobject obj, jlong dp) { - usr_DIR *dirp = (usr_DIR *) dp; - int rc; - - rc = uafs_closedir(dirp); - if (rc < 0) { - setError(env, &obj, errno); - return JNI_FALSE; - } else { - return JNI_TRUE; - } + usr_DIR *dirp = (usr_DIR *) dp; + int rc; + + rc = uafs_closedir(dirp); + if (rc < 0) { + setError(env, &obj, errno); + return JNI_FALSE; + } else { + return JNI_TRUE; + } } @@ -489,24 +497,24 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_closeDir * * return true if the file is removed without error */ -JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmfile - (JNIEnv *env, jobject obj) +JNIEXPORT jboolean JNICALL +Java_org_openafs_jafs_File_rmfile(JNIEnv * env, jobject obj) { char dirName[FILENAME_MAX]; int rc; - *dirName='\0'; + *dirName = '\0'; getAbsolutePath(env, &obj, dirName); - if(*dirName == '\0') { - setError(env, &obj, EINVAL); - fprintf(stderr, "File::rmfile(): failed to get dirName\n"); - return JNI_FALSE; + if (*dirName == '\0') { + setError(env, &obj, EINVAL); + fprintf(stderr, "File::rmfile(): failed to get dirName\n"); + return JNI_FALSE; } rc = uafs_unlink(dirName); - if(rc < 0) { - setError(env, &obj, errno); - fprintf(stderr, "File::rmfile(): uafs_unlink failed\n"); - return JNI_FALSE; + if (rc < 0) { + setError(env, &obj, errno); + fprintf(stderr, "File::rmfile(): uafs_unlink failed\n"); + return JNI_FALSE; } setError(env, &obj, 0); return JNI_TRUE; @@ -520,24 +528,24 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmfile * * return true if the directory is removed without error */ -JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmdir - (JNIEnv *env, jobject obj) +JNIEXPORT jboolean JNICALL +Java_org_openafs_jafs_File_rmdir(JNIEnv * env, jobject obj) { char dirName[FILENAME_MAX]; int rc; - *dirName='\0'; + *dirName = '\0'; getAbsolutePath(env, &obj, dirName); - if(*dirName == '\0') { - setError(env, &obj, -1); - fprintf(stderr, "File::rmdir(): failed to get dirName\n"); - return JNI_FALSE; + if (*dirName == '\0') { + setError(env, &obj, -1); + fprintf(stderr, "File::rmdir(): failed to get dirName\n"); + return JNI_FALSE; } rc = uafs_rmdir(dirName); - if(rc < 0) { - setError(env, &obj, errno); - fprintf(stderr, "File::rmdir(): uafs_unlink failed\n"); - return JNI_FALSE; + if (rc < 0) { + setError(env, &obj, errno); + fprintf(stderr, "File::rmdir(): uafs_unlink failed\n"); + return JNI_FALSE; } setError(env, &obj, 0); return JNI_TRUE; @@ -552,24 +560,24 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_rmdir * return true if and only if the directory was * created; false otherwise */ -JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_mkdir - (JNIEnv *env, jobject obj) +JNIEXPORT jboolean JNICALL +Java_org_openafs_jafs_File_mkdir(JNIEnv * env, jobject obj) { char dirName[FILENAME_MAX]; int rc; - *dirName='\0'; + *dirName = '\0'; getAbsolutePath(env, &obj, dirName); - if(*dirName == '\0') { - setError(env, &obj, EINVAL); - fprintf(stderr, "File::mkdir(): failed to get dirName\n"); - return JNI_FALSE; + if (*dirName == '\0') { + setError(env, &obj, EINVAL); + fprintf(stderr, "File::mkdir(): failed to get dirName\n"); + return JNI_FALSE; } rc = uafs_mkdir(dirName, 0755); - if(rc < 0) { - setError(env, &obj, errno); - fprintf(stderr, "File::mkdir(): uafs_mkdir failed\n"); - return JNI_FALSE; + if (rc < 0) { + setError(env, &obj, errno); + fprintf(stderr, "File::mkdir(): uafs_mkdir failed\n"); + return JNI_FALSE; } setError(env, &obj, 0); return JNI_TRUE; @@ -588,31 +596,33 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_mkdir * throws NullPointerException * If parameter dest is null */ -JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_renameTo - (JNIEnv *env, jobject obj, jobject newFile) +JNIEXPORT jboolean JNICALL +Java_org_openafs_jafs_File_renameTo(JNIEnv * env, jobject obj, + jobject newFile) { char thisDirName[FILENAME_MAX], newDirName[FILENAME_MAX]; int rc; - *thisDirName='\0'; + *thisDirName = '\0'; getAbsolutePath(env, &obj, thisDirName); - if(*thisDirName == '\0') { - setError(env, &obj, -1); - fprintf(stderr, "File::renameTo(): failed to get dirName for this \n"); - return JNI_FALSE; + if (*thisDirName == '\0') { + setError(env, &obj, -1); + fprintf(stderr, + "File::renameTo(): failed to get dirName for this \n"); + return JNI_FALSE; } - *newDirName='\0'; + *newDirName = '\0'; getAbsolutePath(env, &newFile, newDirName); - if(*newDirName == '\0') { - setError(env, &obj, -1); - fprintf(stderr, "File::renameTo(): failed to get dirName for new \n"); - return JNI_FALSE; + if (*newDirName == '\0') { + setError(env, &obj, -1); + fprintf(stderr, "File::renameTo(): failed to get dirName for new \n"); + return JNI_FALSE; } rc = uafs_rename(thisDirName, newDirName); - if(rc < 0) { - setError(env, &obj, errno); - fprintf(stderr, "File::renameTo(): uafs_rename failed\n"); - return JNI_FALSE; + if (rc < 0) { + setError(env, &obj, errno); + fprintf(stderr, "File::renameTo(): uafs_rename failed\n"); + return JNI_FALSE; } return JNI_TRUE; } @@ -624,57 +634,57 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_renameTo * env the Java environment * obj the current Java object */ -void setFileNotExistsAttributes - (JNIEnv *env, jobject *obj) +void +setFileNotExistsAttributes(JNIEnv * env, jobject * obj) { jclass thisClass; jfieldID fid; - thisClass = (*env) -> GetObjectClass(env, *obj); - if(thisClass == NULL) { - fprintf(stderr, - "File::setFileNotExistsAttributes(): GetObjectClass failed\n"); - return; + thisClass = (*env)->GetObjectClass(env, *obj); + if (thisClass == NULL) { + fprintf(stderr, + "File::setFileNotExistsAttributes(): GetObjectClass failed\n"); + return; } fid = (*env)->GetFieldID(env, thisClass, "exists", "Z"); if (fid == 0) { - fprintf(stderr, - "File::setFileNotExistsAttributes(): GetFieldID (exists) failed\n"); - return; + fprintf(stderr, + "File::setFileNotExistsAttributes(): GetFieldID (exists) failed\n"); + return; } (*env)->SetBooleanField(env, *obj, fid, JNI_FALSE); fid = (*env)->GetFieldID(env, thisClass, "isDirectory", "Z"); if (fid == 0) { - fprintf(stderr, - "File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n"); - return; + fprintf(stderr, + "File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n"); + return; } (*env)->SetBooleanField(env, *obj, fid, JNI_FALSE); fid = (*env)->GetFieldID(env, thisClass, "isFile", "Z"); if (fid == 0) { - fprintf(stderr, - "File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n"); - return; + fprintf(stderr, + "File::setFileNotExistsAttributes(): GetFieldID (isDirectory) failed\n"); + return; } (*env)->SetBooleanField(env, *obj, fid, JNI_FALSE); fid = (*env)->GetFieldID(env, thisClass, "lastModified", "J"); if (fid == 0) { - fprintf(stderr, - "File::setFileNotExistsAttributes(): GetFieldID (lastModified) failed\n"); - return; + fprintf(stderr, + "File::setFileNotExistsAttributes(): GetFieldID (lastModified) failed\n"); + return; } (*env)->SetLongField(env, *obj, fid, 0); - + fid = (*env)->GetFieldID(env, thisClass, "length", "J"); if (fid == 0) { - fprintf(stderr, - "File::setFileNotExistsAttributes(): GetFieldID (length) failed\n"); - return; + fprintf(stderr, + "File::setFileNotExistsAttributes(): GetFieldID (length) failed\n"); + return; } (*env)->SetLongField(env, *obj, fid, 0); diff --git a/src/JAVA/libjafs/FileInputStream.c b/src/JAVA/libjafs/FileInputStream.c index 7c1b7fc87..de7dfd0b6 100644 --- a/src/JAVA/libjafs/FileInputStream.c +++ b/src/JAVA/libjafs/FileInputStream.c @@ -51,18 +51,19 @@ extern int errno; * @return file descriptor * @exception AFSFileException if an I/O or other file related error occurs. */ -JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_openReadOnly - (JNIEnv *env, jobject obj, jstring fileNameUTF) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_FileInputStream_openReadOnly(JNIEnv * env, jobject obj, + jstring fileNameUTF) { - int err; - int fd = -1; //file descriptor - - fd = openAFSFile(env, fileNameUTF, O_RDONLY, 0, &err); - if (fd < 0) { - fprintf(stderr, "FileInputStream::openReadOnly(): err=%d\n", err); - throwAFSFileException( env, err, NULL ); - } - return fd; + int err; + int fd = -1; //file descriptor + + fd = openAFSFile(env, fileNameUTF, O_RDONLY, 0, &err); + if (fd < 0) { + fprintf(stderr, "FileInputStream::openReadOnly(): err=%d\n", err); + throwAFSFileException(env, err, NULL); + } + return fd; } /** @@ -81,36 +82,40 @@ JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_openReadOnly * the file has been reached. * @exception AFSFileException if an I/O or other file related error occurs. */ -JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_read - (JNIEnv *env, jobject obj, jbyteArray jbytes, jint offset, jint length) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_FileInputStream_read(JNIEnv * env, jobject obj, + jbyteArray jbytes, jint offset, + jint length) { - int fd, bytesLen, bytesRead; - jclass thisClass; - jmethodID getFileDescriptorID; - jbyte *bytes; - jfieldID fid; - - /* If we have to read 0 bytes just return */ - if (length == 0) return 0; - - thisClass = (*env)->GetObjectClass(env, obj); - fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I"); - fd = (*env)->GetIntField(env, obj, fid); - - if (fd < 0) { - fprintf(stderr, "FileInputStream::read(): invalid file state\n"); - throwAFSFileException(env, 0, "Invalid file state"); - return -1; - } - - bytes = (*env) -> GetByteArrayElements(env, jbytes, 0); - bytesLen = (*env) -> GetArrayLength(env, jbytes); - bytesRead = uafs_read(fd, bytes, bytesLen); - - if (errno != 0) throwAFSFileException(env, errno, NULL); - - (*env) -> ReleaseByteArrayElements(env, jbytes, bytes, 0); - return (bytesRead > 0) ? bytesRead : -1; + int fd, bytesLen, bytesRead; + jclass thisClass; + jmethodID getFileDescriptorID; + jbyte *bytes; + jfieldID fid; + + /* If we have to read 0 bytes just return */ + if (length == 0) + return 0; + + thisClass = (*env)->GetObjectClass(env, obj); + fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I"); + fd = (*env)->GetIntField(env, obj, fid); + + if (fd < 0) { + fprintf(stderr, "FileInputStream::read(): invalid file state\n"); + throwAFSFileException(env, 0, "Invalid file state"); + return -1; + } + + bytes = (*env)->GetByteArrayElements(env, jbytes, 0); + bytesLen = (*env)->GetArrayLength(env, jbytes); + bytesRead = uafs_read(fd, bytes, bytesLen); + + if (errno != 0) + throwAFSFileException(env, errno, NULL); + + (*env)->ReleaseByteArrayElements(env, jbytes, bytes, 0); + return (bytesRead > 0) ? bytesRead : -1; } /** @@ -123,28 +128,28 @@ JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileInputStream_read * * @exception AFSFileException if an I/O or other file related error occurs. */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_FileInputStream_close - (JNIEnv *env, jobject obj) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_FileInputStream_close(JNIEnv * env, jobject obj) { - int fd, rc; - jclass thisClass; - jmethodID getFileDescriptorID; - jfieldID fid; - char *bytes; - - thisClass = (*env)->GetObjectClass(env, obj); - fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I"); - fd = (*env)->GetIntField(env, obj, fid); - - if (fd < 0) { - fprintf(stderr, "FileInputStream::close(): invalid file state\n"); - throwAFSFileException(env, 0, "Invalid file state"); - return; - } - - rc = uafs_close(fd); - - if (rc != 0) { - throwAFSFileException(env, errno, NULL); - } + int fd, rc; + jclass thisClass; + jmethodID getFileDescriptorID; + jfieldID fid; + char *bytes; + + thisClass = (*env)->GetObjectClass(env, obj); + fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I"); + fd = (*env)->GetIntField(env, obj, fid); + + if (fd < 0) { + fprintf(stderr, "FileInputStream::close(): invalid file state\n"); + throwAFSFileException(env, 0, "Invalid file state"); + return; + } + + rc = uafs_close(fd); + + if (rc != 0) { + throwAFSFileException(env, errno, NULL); + } } diff --git a/src/JAVA/libjafs/FileOutputStream.c b/src/JAVA/libjafs/FileOutputStream.c index effd82360..185297c90 100644 --- a/src/JAVA/libjafs/FileOutputStream.c +++ b/src/JAVA/libjafs/FileOutputStream.c @@ -54,18 +54,19 @@ * @returns file descriptor * @exception AFSFileException if an I/O or other file related error occurs. */ -JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileOutputStream_openWrite - (JNIEnv *env, jobject obj, jstring fileNameUTF) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_FileOutputStream_openWrite(JNIEnv * env, jobject obj, + jstring fileNameUTF) { - int err; - jint fd = -1; //file descriptor - - fd = openAFSFile(env, fileNameUTF, O_CREAT | O_TRUNC, 0644, &err); - if (fd < 0) { - fprintf(stderr, "FileOutputStream::openWrite(): err=%d\n", err); - throwAFSFileException(env, err, NULL); - } - return fd; + int err; + jint fd = -1; //file descriptor + + fd = openAFSFile(env, fileNameUTF, O_CREAT | O_TRUNC, 0644, &err); + if (fd < 0) { + fprintf(stderr, "FileOutputStream::openWrite(): err=%d\n", err); + throwAFSFileException(env, err, NULL); + } + return fd; } /** @@ -78,18 +79,19 @@ JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileOutputStream_openWrite * @return file descriptor * @exception AFSFileException if an I/O or other file related error occurs. */ -JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileOutputStream_openAppend - (JNIEnv *env, jobject obj, jstring fileNameUTF) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_FileOutputStream_openAppend(JNIEnv * env, jobject obj, + jstring fileNameUTF) { - int err; - jint fd = -1; //file descriptor - - fd = openAFSFile(env, fileNameUTF, O_CREAT | O_APPEND, 0644, &err); - if (fd < 0) { - fprintf(stderr, "FileOutputStream::openAppend(): err=%d\n", err); - throwAFSFileException(env, err, NULL); - } - return fd; + int err; + jint fd = -1; //file descriptor + + fd = openAFSFile(env, fileNameUTF, O_CREAT | O_APPEND, 0644, &err); + if (fd < 0) { + fprintf(stderr, "FileOutputStream::openAppend(): err=%d\n", err); + throwAFSFileException(env, err, NULL); + } + return fd; } /** @@ -104,46 +106,49 @@ JNIEXPORT jint JNICALL Java_org_openafs_jafs_FileOutputStream_openAppend * * @exception AFSFileException if an I/O or other file related error occurs. */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_write - (JNIEnv *env, jobject obj, jbyteArray jbytes, jint offset, jint length) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_FileOutputStream_write(JNIEnv * env, jobject obj, + jbyteArray jbytes, jint offset, + jint length) { - int fd, written, toWrite; - jint twritten; - jclass thisClass; - jmethodID getFileDescriptorID; - char *bytes; - jfieldID fid; - - thisClass = (*env)->GetObjectClass(env, obj); - fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I"); - fd = (*env)->GetIntField(env, obj, fid); - if(fd < 0) { - fprintf(stderr, "FileOutputStream::write(): failed to get file + int fd, written, toWrite; + jint twritten; + jclass thisClass; + jmethodID getFileDescriptorID; + char *bytes; + jfieldID fid; + + thisClass = (*env)->GetObjectClass(env, obj); + fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I"); + fd = (*env)->GetIntField(env, obj, fid); + if (fd < 0) { + fprintf(stderr, "FileOutputStream::write(): failed to get file descriptor\n"); - throwAFSFileException(env, 0, "Failed to get file descriptor!"); - } - - bytes = (char*) malloc(length); - if(bytes == NULL) { - fprintf(stderr, "FileOutputStream::write(): malloc failed of %d bytes\n", - length); - throwAFSFileException(env, 0, "Failed to allocate memory!"); - } - - (*env) -> GetByteArrayRegion(env, jbytes, offset, length, bytes); - toWrite = length; - twritten = 0; - - while( toWrite > 0 ) { - written = uafs_write(fd, bytes, length); - twritten += written; - if( written < 0 ) { - free(bytes); - throwAFSFileException(env, errno, NULL); + throwAFSFileException(env, 0, "Failed to get file descriptor!"); + } + + bytes = (char *)malloc(length); + if (bytes == NULL) { + fprintf(stderr, + "FileOutputStream::write(): malloc failed of %d bytes\n", + length); + throwAFSFileException(env, 0, "Failed to allocate memory!"); + } + + (*env)->GetByteArrayRegion(env, jbytes, offset, length, bytes); + toWrite = length; + twritten = 0; + + while (toWrite > 0) { + written = uafs_write(fd, bytes, length); + twritten += written; + if (written < 0) { + free(bytes); + throwAFSFileException(env, errno, NULL); + } + toWrite -= written; } - toWrite -= written; - } - free(bytes); + free(bytes); } /** @@ -156,24 +161,25 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_write * * @exception AFSFileException if an I/O or other file related error occurs. */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_FileOutputStream_close - (JNIEnv *env, jobject obj) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_FileOutputStream_close(JNIEnv * env, jobject obj) { - int fd, rc; - jclass thisClass; - jmethodID getFileDescriptorID; - char *bytes; - jfieldID fid; - - thisClass = (*env)->GetObjectClass(env, obj); - fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I"); - fd = (*env)->GetIntField(env, obj, fid); - if(fd < 0) { - fprintf(stderr, "FileOutputStream::close(): failed to get file descriptor\n"); - throwAFSFileException(env, 0, "Failed to get file descriptor!"); - } - rc = uafs_close(fd); - if (rc != 0) { - throwAFSFileException(env, rc, NULL); - } + int fd, rc; + jclass thisClass; + jmethodID getFileDescriptorID; + char *bytes; + jfieldID fid; + + thisClass = (*env)->GetObjectClass(env, obj); + fid = (*env)->GetFieldID(env, thisClass, "fileDescriptor", "I"); + fd = (*env)->GetIntField(env, obj, fid); + if (fd < 0) { + fprintf(stderr, + "FileOutputStream::close(): failed to get file descriptor\n"); + throwAFSFileException(env, 0, "Failed to get file descriptor!"); + } + rc = uafs_close(fd); + if (rc != 0) { + throwAFSFileException(env, rc, NULL); + } } diff --git a/src/JAVA/libjafs/Group.c b/src/JAVA/libjafs/Group.c index b314d920a..1dcb55749 100644 --- a/src/JAVA/libjafs/Group.c +++ b/src/JAVA/libjafs/Group.c @@ -65,61 +65,60 @@ extern jfieldID group_creatorField; * gid the group id to assign to the group (0 to have one * automatically assigned) */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_create - (JNIEnv *env, jclass cls, jint cellHandle, jstring jgroupName, - jstring jownerName, jint gid ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_create(JNIEnv * env, jclass cls, jint cellHandle, + jstring jgroupName, jstring jownerName, + jint gid) { - afs_status_t ast; - // convert java strings - char *groupName; - char *ownerName; - - if ( jgroupName != NULL ) { - groupName = getNativeString(env, jgroupName); - if ( groupName == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLGROUP ); - return; - } - - if ( jownerName != NULL ) { - ownerName = getNativeString(env, jownerName); - if ( ownerName == NULL ) { - free( groupName ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( groupName ); - throwAFSException( env, JAFSNULLOWNER ); - return; - } - - // make sure the name is within the allowed bounds - if ( strlen( groupName ) > PTS_MAX_NAME_LEN ) { - // release converted java strings - free( groupName ); - free( ownerName ); - throwAFSException( env, ADMPTSGROUPNAMETOOLONG ); - return; - } - - if ( !pts_GroupCreate( (void *) cellHandle, groupName, ownerName, - (int *) &gid, &ast ) ) { + afs_status_t ast; + // convert java strings + char *groupName; + char *ownerName; + + if (jgroupName != NULL) { + groupName = getNativeString(env, jgroupName); + if (groupName == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLGROUP); + return; + } + + if (jownerName != NULL) { + ownerName = getNativeString(env, jownerName); + if (ownerName == NULL) { + free(groupName); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(groupName); + throwAFSException(env, JAFSNULLOWNER); + return; + } + + // make sure the name is within the allowed bounds + if (strlen(groupName) > PTS_MAX_NAME_LEN) { + // release converted java strings + free(groupName); + free(ownerName); + throwAFSException(env, ADMPTSGROUPNAMETOOLONG); + return; + } + + if (!pts_GroupCreate + ((void *)cellHandle, groupName, ownerName, (int *)&gid, &ast)) { + // release converted java strings + free(groupName); + free(ownerName); + throwAFSException(env, ast); + return; + } // release converted java strings - free( groupName ); - free( ownerName ); - throwAFSException( env, ast ); - return; - } - - // release converted java strings - free( groupName ); - free( ownerName ); + free(groupName); + free(ownerName); } /** @@ -132,31 +131,30 @@ Java_org_openafs_jafs_Group_create * cellHandle the handle of the cell to which the group belongs * jgroupName the name of the group to delete */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_delete - (JNIEnv *env, jclass cls, jint cellHandle, jstring jgroupName ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_delete(JNIEnv * env, jclass cls, jint cellHandle, + jstring jgroupName) { - afs_status_t ast; - // convert java strings - char *groupName; - - if ( jgroupName != NULL ) { - groupName = getNativeString(env, jgroupName); - if ( !groupName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLGROUP ); - return; - } - - if ( !pts_GroupDelete( (void *) cellHandle, groupName, &ast ) ) { - throwAFSException( env, ast ); - } - - // release converted java strings - free( groupName ); + afs_status_t ast; + // convert java strings + char *groupName; + + if (jgroupName != NULL) { + groupName = getNativeString(env, jgroupName); + if (!groupName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLGROUP); + return; + } + + if (!pts_GroupDelete((void *)cellHandle, groupName, &ast)) { + throwAFSException(env, ast); + } + // release converted java strings + free(groupName); } /** @@ -168,91 +166,91 @@ Java_org_openafs_jafs_Group_delete * name the name of the group for which to get the info * group the Group object to populate with the info */ -void getGroupInfoChar - ( JNIEnv *env, jint cellHandle, const char *name, jobject group ) +void +getGroupInfoChar(JNIEnv * env, jint cellHandle, const char *name, + jobject group) { - jstring jowner; - jstring jcreator; - pts_GroupEntry_t entry; - afs_status_t ast; - // get the field ids if you haven't already - if ( groupCls == 0 ) { - internal_getGroupClass( env, group ); - } - - if ( !pts_GroupGet( (void *) cellHandle, name, &entry, &ast ) ) { - throwAFSException( env, ast ); - return; - } - - // set the fields - (*env)->SetIntField(env, group, group_nameUidField, entry.nameUid); - (*env)->SetIntField(env, group, group_ownerUidField, entry.ownerUid); - (*env)->SetIntField(env, group, group_creatorUidField, entry.creatorUid); - (*env)->SetIntField(env, group, group_membershipCountField, - entry.membershipCount); - - if ( entry.listStatus == PTS_GROUP_OWNER_ACCESS ) { - (*env)->SetIntField(env, group, group_listStatusField, - org_openafs_jafs_Group_GROUP_OWNER_ACCESS); - } else if ( entry.listStatus == PTS_GROUP_ACCESS ) { - (*env)->SetIntField(env, group, group_listStatusField, - org_openafs_jafs_Group_GROUP_GROUP_ACCESS); - } else { - (*env)->SetIntField(env, group, group_listStatusField, - org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); - } - - if ( entry.listGroupsOwned == PTS_GROUP_OWNER_ACCESS ) { - (*env)->SetIntField(env, group, group_listGroupsOwnedField, - org_openafs_jafs_Group_GROUP_OWNER_ACCESS); - } else if ( entry.listGroupsOwned == PTS_GROUP_ACCESS ) { - (*env)->SetIntField(env, group, group_listGroupsOwnedField, - org_openafs_jafs_Group_GROUP_GROUP_ACCESS); - } else { - (*env)->SetIntField(env, group, group_listGroupsOwnedField, - org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); - } - - if ( entry.listMembership == PTS_GROUP_OWNER_ACCESS ) { - (*env)->SetIntField(env, group, group_listMembershipField, - org_openafs_jafs_Group_GROUP_OWNER_ACCESS); - } else if ( entry.listMembership == PTS_GROUP_ACCESS ) { - (*env)->SetIntField(env, group, group_listMembershipField, - org_openafs_jafs_Group_GROUP_GROUP_ACCESS); - } else { - (*env)->SetIntField(env, group, group_listMembershipField, - org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); - } - - if ( entry.listAdd == PTS_GROUP_OWNER_ACCESS ) { - (*env)->SetIntField(env, group, group_listAddField, - org_openafs_jafs_Group_GROUP_OWNER_ACCESS); - } else if ( entry.listAdd == PTS_GROUP_ACCESS ) { - (*env)->SetIntField(env, group, group_listAddField, - org_openafs_jafs_Group_GROUP_GROUP_ACCESS); - } else { - (*env)->SetIntField(env, group, group_listAddField, - org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); - } - - if ( entry.listDelete == PTS_GROUP_OWNER_ACCESS ) { - (*env)->SetIntField(env, group, group_listDeleteField, - org_openafs_jafs_Group_GROUP_OWNER_ACCESS); - } else if ( entry.listDelete == PTS_GROUP_ACCESS ) { - (*env)->SetIntField(env, group, group_listDeleteField, - org_openafs_jafs_Group_GROUP_GROUP_ACCESS); - } else { - (*env)->SetIntField(env, group, group_listDeleteField, - org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); - } - - jowner = (*env)->NewStringUTF(env, entry.owner); - jcreator = (*env)->NewStringUTF(env, entry.creator); - - (*env)->SetObjectField(env, group, group_ownerField, jowner); - (*env)->SetObjectField(env, group, group_creatorField, jcreator); + jstring jowner; + jstring jcreator; + pts_GroupEntry_t entry; + afs_status_t ast; + // get the field ids if you haven't already + if (groupCls == 0) { + internal_getGroupClass(env, group); + } + + if (!pts_GroupGet((void *)cellHandle, name, &entry, &ast)) { + throwAFSException(env, ast); + return; + } + // set the fields + (*env)->SetIntField(env, group, group_nameUidField, entry.nameUid); + (*env)->SetIntField(env, group, group_ownerUidField, entry.ownerUid); + (*env)->SetIntField(env, group, group_creatorUidField, entry.creatorUid); + (*env)->SetIntField(env, group, group_membershipCountField, + entry.membershipCount); + + if (entry.listStatus == PTS_GROUP_OWNER_ACCESS) { + (*env)->SetIntField(env, group, group_listStatusField, + org_openafs_jafs_Group_GROUP_OWNER_ACCESS); + } else if (entry.listStatus == PTS_GROUP_ACCESS) { + (*env)->SetIntField(env, group, group_listStatusField, + org_openafs_jafs_Group_GROUP_GROUP_ACCESS); + } else { + (*env)->SetIntField(env, group, group_listStatusField, + org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); + } + + if (entry.listGroupsOwned == PTS_GROUP_OWNER_ACCESS) { + (*env)->SetIntField(env, group, group_listGroupsOwnedField, + org_openafs_jafs_Group_GROUP_OWNER_ACCESS); + } else if (entry.listGroupsOwned == PTS_GROUP_ACCESS) { + (*env)->SetIntField(env, group, group_listGroupsOwnedField, + org_openafs_jafs_Group_GROUP_GROUP_ACCESS); + } else { + (*env)->SetIntField(env, group, group_listGroupsOwnedField, + org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); + } + + if (entry.listMembership == PTS_GROUP_OWNER_ACCESS) { + (*env)->SetIntField(env, group, group_listMembershipField, + org_openafs_jafs_Group_GROUP_OWNER_ACCESS); + } else if (entry.listMembership == PTS_GROUP_ACCESS) { + (*env)->SetIntField(env, group, group_listMembershipField, + org_openafs_jafs_Group_GROUP_GROUP_ACCESS); + } else { + (*env)->SetIntField(env, group, group_listMembershipField, + org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); + } + + if (entry.listAdd == PTS_GROUP_OWNER_ACCESS) { + (*env)->SetIntField(env, group, group_listAddField, + org_openafs_jafs_Group_GROUP_OWNER_ACCESS); + } else if (entry.listAdd == PTS_GROUP_ACCESS) { + (*env)->SetIntField(env, group, group_listAddField, + org_openafs_jafs_Group_GROUP_GROUP_ACCESS); + } else { + (*env)->SetIntField(env, group, group_listAddField, + org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); + } + + if (entry.listDelete == PTS_GROUP_OWNER_ACCESS) { + (*env)->SetIntField(env, group, group_listDeleteField, + org_openafs_jafs_Group_GROUP_OWNER_ACCESS); + } else if (entry.listDelete == PTS_GROUP_ACCESS) { + (*env)->SetIntField(env, group, group_listDeleteField, + org_openafs_jafs_Group_GROUP_GROUP_ACCESS); + } else { + (*env)->SetIntField(env, group, group_listDeleteField, + org_openafs_jafs_Group_GROUP_ANYUSER_ACCESS); + } + + jowner = (*env)->NewStringUTF(env, entry.owner); + jcreator = (*env)->NewStringUTF(env, entry.creator); + + (*env)->SetObjectField(env, group, group_ownerField, jowner); + (*env)->SetObjectField(env, group, group_creatorField, jcreator); } /** @@ -266,33 +264,33 @@ void getGroupInfoChar * group the Group object in which to fill in the * information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_getGroupInfo - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname, jobject group) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_getGroupInfo(JNIEnv * env, jclass cls, + jint cellHandle, jstring jname, + jobject group) { - char *name; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( !name ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + char *name; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (!name) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLGROUP); + return; } - } else { - throwAFSException( env, JAFSNULLGROUP ); - return; - } - getGroupInfoChar( env, cellHandle, name, group ); + getGroupInfoChar(env, cellHandle, name, group); - // get class fields if need be - if ( groupCls == 0 ) { - internal_getGroupClass( env, group ); - } - - // set name in case blank object - (*env)->SetObjectField(env, group, group_nameField, jname); + // get class fields if need be + if (groupCls == 0) { + internal_getGroupClass(env, group); + } + // set name in case blank object + (*env)->SetObjectField(env, group, group_nameField, jname); - free( name ); + free(name); } /** @@ -304,86 +302,86 @@ Java_org_openafs_jafs_Group_getGroupInfo * name the name of the user for which to set the information * theGroup the group object containing the desired information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_setGroupInfo - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname, jobject group) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_setGroupInfo(JNIEnv * env, jclass cls, + jint cellHandle, jstring jname, + jobject group) { - char *name; - pts_GroupUpdateEntry_t ptsEntry; - afs_status_t ast; - - jint jlistStatus; - jint jlistGroupsOwned; - jint jlistMembership; - jint jlistAdd; - jint jlistDelete; - - // get the field ids if you haven't already - if ( groupCls == 0 ) { - internal_getGroupClass( env, group ); - } - - jlistStatus = (*env)->GetIntField(env, group, group_listStatusField); - jlistGroupsOwned = (*env)->GetIntField(env, group, - group_listGroupsOwnedField); - jlistMembership = (*env)->GetIntField(env, group, group_listMembershipField); - jlistAdd = (*env)->GetIntField(env, group, group_listAddField); - jlistDelete = (*env)->GetIntField(env, group, group_listDeleteField); - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( name == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLGROUP ); - return; - } - - if ( jlistStatus == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) { - ptsEntry.listStatus = PTS_GROUP_OWNER_ACCESS; - } else if ( jlistStatus == org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) { - ptsEntry.listStatus = PTS_GROUP_ACCESS; - } else { - ptsEntry.listStatus = PTS_GROUP_ANYUSER_ACCESS; - } - if ( jlistGroupsOwned == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) { - ptsEntry.listGroupsOwned = PTS_GROUP_OWNER_ACCESS; - } else if ( jlistGroupsOwned == - org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) { - ptsEntry.listGroupsOwned = PTS_GROUP_ACCESS; - } else { - ptsEntry.listGroupsOwned = PTS_GROUP_ANYUSER_ACCESS; - } - if ( jlistMembership == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) { - ptsEntry.listMembership = PTS_GROUP_OWNER_ACCESS; - } else if ( jlistMembership == - org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) { - ptsEntry.listMembership = PTS_GROUP_ACCESS; - } else { - ptsEntry.listMembership = PTS_GROUP_ANYUSER_ACCESS; - } - if ( jlistAdd == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) { - ptsEntry.listAdd = PTS_GROUP_OWNER_ACCESS; - } else if ( jlistAdd == org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) { - ptsEntry.listAdd = PTS_GROUP_ACCESS; - } else { - ptsEntry.listAdd = PTS_GROUP_ANYUSER_ACCESS; - } - if ( jlistDelete == org_openafs_jafs_Group_GROUP_OWNER_ACCESS ) { - ptsEntry.listDelete = PTS_GROUP_OWNER_ACCESS; - } else if ( jlistDelete == org_openafs_jafs_Group_GROUP_GROUP_ACCESS ) { - ptsEntry.listDelete = PTS_GROUP_ACCESS; - } else { - ptsEntry.listDelete = PTS_GROUP_ANYUSER_ACCESS; - } - - if ( !pts_GroupModify( (void *) cellHandle, name, &ptsEntry, &ast ) ) { - throwAFSException( env, ast ); - } - - free( name ); + char *name; + pts_GroupUpdateEntry_t ptsEntry; + afs_status_t ast; + + jint jlistStatus; + jint jlistGroupsOwned; + jint jlistMembership; + jint jlistAdd; + jint jlistDelete; + + // get the field ids if you haven't already + if (groupCls == 0) { + internal_getGroupClass(env, group); + } + + jlistStatus = (*env)->GetIntField(env, group, group_listStatusField); + jlistGroupsOwned = + (*env)->GetIntField(env, group, group_listGroupsOwnedField); + jlistMembership = + (*env)->GetIntField(env, group, group_listMembershipField); + jlistAdd = (*env)->GetIntField(env, group, group_listAddField); + jlistDelete = (*env)->GetIntField(env, group, group_listDeleteField); + + if (jname != NULL) { + name = getNativeString(env, jname); + if (name == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLGROUP); + return; + } + + if (jlistStatus == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) { + ptsEntry.listStatus = PTS_GROUP_OWNER_ACCESS; + } else if (jlistStatus == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) { + ptsEntry.listStatus = PTS_GROUP_ACCESS; + } else { + ptsEntry.listStatus = PTS_GROUP_ANYUSER_ACCESS; + } + if (jlistGroupsOwned == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) { + ptsEntry.listGroupsOwned = PTS_GROUP_OWNER_ACCESS; + } else if (jlistGroupsOwned == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) { + ptsEntry.listGroupsOwned = PTS_GROUP_ACCESS; + } else { + ptsEntry.listGroupsOwned = PTS_GROUP_ANYUSER_ACCESS; + } + if (jlistMembership == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) { + ptsEntry.listMembership = PTS_GROUP_OWNER_ACCESS; + } else if (jlistMembership == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) { + ptsEntry.listMembership = PTS_GROUP_ACCESS; + } else { + ptsEntry.listMembership = PTS_GROUP_ANYUSER_ACCESS; + } + if (jlistAdd == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) { + ptsEntry.listAdd = PTS_GROUP_OWNER_ACCESS; + } else if (jlistAdd == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) { + ptsEntry.listAdd = PTS_GROUP_ACCESS; + } else { + ptsEntry.listAdd = PTS_GROUP_ANYUSER_ACCESS; + } + if (jlistDelete == org_openafs_jafs_Group_GROUP_OWNER_ACCESS) { + ptsEntry.listDelete = PTS_GROUP_OWNER_ACCESS; + } else if (jlistDelete == org_openafs_jafs_Group_GROUP_GROUP_ACCESS) { + ptsEntry.listDelete = PTS_GROUP_ACCESS; + } else { + ptsEntry.listDelete = PTS_GROUP_ANYUSER_ACCESS; + } + + if (!pts_GroupModify((void *)cellHandle, name, &ptsEntry, &ast)) { + throwAFSException(env, ast); + } + + free(name); } /** @@ -397,33 +395,34 @@ Java_org_openafs_jafs_Group_setGroupInfo * jname the name of the group for which to get the members * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Group_getGroupMembersBegin - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Group_getGroupMembersBegin(JNIEnv * env, jclass cls, + jint cellHandle, + jstring jname) { - char *name; - afs_status_t ast; - void *iterationId; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( name == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return 0; + char *name; + afs_status_t ast; + void *iterationId; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (name == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return 0; + } + } else { + throwAFSException(env, JAFSNULLGROUP); + return 0; } - } else { - throwAFSException( env, JAFSNULLGROUP ); - return 0; - } - if ( !pts_GroupMemberListBegin( (void *) cellHandle, name, &iterationId, - &ast ) ) { - throwAFSException( env, ast ); - } + if (!pts_GroupMemberListBegin + ((void *)cellHandle, name, &iterationId, &ast)) { + throwAFSException(env, ast); + } - free( name ); + free(name); - return (jint) iterationId; + return (jint) iterationId; } /** @@ -435,32 +434,33 @@ Java_org_openafs_jafs_Group_getGroupMembersBegin * iterationId the iteration ID of this iteration * returns the name of the next member */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Group_getGroupMembersNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Group_getGroupMembersNextString(JNIEnv * env, + jclass cls, + jint iterationId) { - afs_status_t ast; - char *userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); - jstring juser; - - if ( !userName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) { - free( userName ); - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return; - } - } - - juser = (*env)->NewStringUTF(env, userName); - free( userName ); - return juser; + afs_status_t ast; + char *userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); + jstring juser; + + if (!userName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + + if (!pts_GroupMemberListNext((void *)iterationId, userName, &ast)) { + free(userName); + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return; + } + } + + juser = (*env)->NewStringUTF(env, userName); + free(userName); + return juser; } /** @@ -475,45 +475,46 @@ Java_org_openafs_jafs_Group_getGroupMembersNextString * next user * returns 0 if there are no more users, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Group_getGroupMembersNext - (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId, - jobject juserObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Group_getGroupMembersNext(JNIEnv * env, jclass cls, + jint cellHandle, + jint iterationId, + jobject juserObject) { - afs_status_t ast; - char *userName; - jstring juser; + afs_status_t ast; + char *userName; + jstring juser; - userName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + userName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); - if ( !userName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } + if (!userName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } - if ( !pts_GroupMemberListNext( (void *) iterationId, userName, &ast ) ) { - free( userName ); - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + if (!pts_GroupMemberListNext((void *)iterationId, userName, &ast)) { + free(userName); + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } } - } - juser = (*env)->NewStringUTF(env, userName); + juser = (*env)->NewStringUTF(env, userName); - if ( userCls == 0 ) { - internal_getUserClass( env, juserObject ); - } + if (userCls == 0) { + internal_getUserClass(env, juserObject); + } - (*env)->SetObjectField(env, juserObject, user_nameField, juser); + (*env)->SetObjectField(env, juserObject, user_nameField, juser); - getUserInfoChar( env, (void *) cellHandle, userName, juserObject ); - (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE ); + getUserInfoChar(env, (void *)cellHandle, userName, juserObject); + (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE); - free( userName ); - return 1; + free(userName); + return 1; } @@ -524,16 +525,16 @@ Java_org_openafs_jafs_Group_getGroupMembersNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_getGroupMembersDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_getGroupMembersDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !pts_GroupMemberListDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!pts_GroupMemberListDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -545,45 +546,45 @@ Java_org_openafs_jafs_Group_getGroupMembersDone * jgroupName the name of the group to which to add a member * juserName the name of the user to add */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_addMember - (JNIEnv *env, jclass cls, jint cellHandle, jstring jgroupName, - jstring juserName ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_addMember(JNIEnv * env, jclass cls, + jint cellHandle, jstring jgroupName, + jstring juserName) { - afs_status_t ast; - char *groupName; - char *userName; - - if ( jgroupName != NULL ) { - groupName = getNativeString(env, jgroupName); - if ( groupName == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLGROUP ); - return; - } - - if ( juserName != NULL ) { - userName = getNativeString(env, juserName); - if ( userName == NULL ) { - free( groupName ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( groupName ); - throwAFSException( env, JAFSNULLUSER ); - return; - } - - if ( !pts_GroupMemberAdd( (void *) cellHandle, userName, groupName, &ast ) ) { - throwAFSException( env, ast ); - } - - free( userName ); - free( groupName ); + afs_status_t ast; + char *groupName; + char *userName; + + if (jgroupName != NULL) { + groupName = getNativeString(env, jgroupName); + if (groupName == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLGROUP); + return; + } + + if (juserName != NULL) { + userName = getNativeString(env, juserName); + if (userName == NULL) { + free(groupName); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(groupName); + throwAFSException(env, JAFSNULLUSER); + return; + } + + if (!pts_GroupMemberAdd((void *)cellHandle, userName, groupName, &ast)) { + throwAFSException(env, ast); + } + + free(userName); + free(groupName); } /** @@ -596,46 +597,45 @@ Java_org_openafs_jafs_Group_addMember * member * juserName the name of the user to remove */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_removeMember - (JNIEnv *env, jclass cls, jint cellHandle, jstring jgroupName, - jstring juserName) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_removeMember(JNIEnv * env, jclass cls, + jint cellHandle, jstring jgroupName, + jstring juserName) { - afs_status_t ast; - char *groupName; - char *userName; - - if ( jgroupName != NULL ) { - groupName = getNativeString(env, jgroupName); - if ( groupName == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLGROUP ); - return; - } - - if ( juserName != NULL ) { - userName = getNativeString(env, juserName); - if ( userName == NULL ) { - free( groupName ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( groupName ); - throwAFSException( env, JAFSNULLUSER ); - return; - } - - if ( !pts_GroupMemberRemove( (void *)cellHandle, userName, - groupName, &ast ) ) { - throwAFSException( env, ast ); - } - - free( groupName ); - free( userName ); + afs_status_t ast; + char *groupName; + char *userName; + + if (jgroupName != NULL) { + groupName = getNativeString(env, jgroupName); + if (groupName == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLGROUP); + return; + } + + if (juserName != NULL) { + userName = getNativeString(env, juserName); + if (userName == NULL) { + free(groupName); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(groupName); + throwAFSException(env, JAFSNULLUSER); + return; + } + + if (!pts_GroupMemberRemove((void *)cellHandle, userName, groupName, &ast)) { + throwAFSException(env, ast); + } + + free(groupName); + free(userName); } /** @@ -648,46 +648,45 @@ Java_org_openafs_jafs_Group_removeMember * owner * jownerName the name of the new owner */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_changeOwner - (JNIEnv *env, jclass cls, jint cellHandle, jstring jgroupName, - jstring jownerName ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_changeOwner(JNIEnv * env, jclass cls, + jint cellHandle, jstring jgroupName, + jstring jownerName) { - afs_status_t ast; - char *groupName; - char *ownerName; - - if ( jgroupName != NULL ) { - groupName = getNativeString(env, jgroupName); - if ( groupName == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLGROUP ); - return; - } - - if ( jownerName != NULL ) { - ownerName = getNativeString(env, jownerName); - if ( ownerName == NULL ) { - free( groupName ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( groupName ); - throwAFSException( env, JAFSNULLOWNER ); - return; - } - - if ( !pts_GroupOwnerChange( (void *)cellHandle, groupName, - ownerName, &ast ) ) { - throwAFSException( env, ast ); - } - - free( groupName ); - free( ownerName ); + afs_status_t ast; + char *groupName; + char *ownerName; + + if (jgroupName != NULL) { + groupName = getNativeString(env, jgroupName); + if (groupName == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLGROUP); + return; + } + + if (jownerName != NULL) { + ownerName = getNativeString(env, jownerName); + if (ownerName == NULL) { + free(groupName); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(groupName); + throwAFSException(env, JAFSNULLOWNER); + return; + } + + if (!pts_GroupOwnerChange((void *)cellHandle, groupName, ownerName, &ast)) { + throwAFSException(env, ast); + } + + free(groupName); + free(ownerName); } /** @@ -699,54 +698,54 @@ Java_org_openafs_jafs_Group_changeOwner * joldGroupName the old name of the group * jnewGroupName the new name for the group */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_rename - (JNIEnv *env, jclass cls, jint cellHandle, jstring jgroupOldName, - jstring jgroupNewName ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_rename(JNIEnv * env, jclass cls, jint cellHandle, + jstring jgroupOldName, + jstring jgroupNewName) { - afs_status_t ast; - char *groupOldName; - char *groupNewName; - - if ( jgroupOldName != NULL ) { - groupOldName = getNativeString(env, jgroupOldName); - if ( groupOldName == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLGROUP ); - return; - } - - if ( jgroupNewName != NULL ) { - groupNewName = getNativeString(env, jgroupNewName); - if ( groupNewName == NULL ) { - free( groupOldName ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( groupOldName ); - throwAFSException( env, JAFSNULLGROUP ); - return; - } - - if ( !pts_GroupRename( (void *)cellHandle, groupOldName, - groupNewName, &ast ) ) { - throwAFSException( env, ast ); - } - - free( groupOldName ); - free( groupNewName ); + afs_status_t ast; + char *groupOldName; + char *groupNewName; + + if (jgroupOldName != NULL) { + groupOldName = getNativeString(env, jgroupOldName); + if (groupOldName == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLGROUP); + return; + } + + if (jgroupNewName != NULL) { + groupNewName = getNativeString(env, jgroupNewName); + if (groupNewName == NULL) { + free(groupOldName); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(groupOldName); + throwAFSException(env, JAFSNULLGROUP); + return; + } + + if (!pts_GroupRename + ((void *)cellHandle, groupOldName, groupNewName, &ast)) { + throwAFSException(env, ast); + } + + free(groupOldName); + free(groupNewName); } // reclaim global memory used by this portion -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Group_reclaimGroupMemory (JNIEnv *env, jclass cls) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Group_reclaimGroupMemory(JNIEnv * env, jclass cls) { - if ( groupCls ) { - (*env)->DeleteGlobalRef(env, groupCls); - groupCls = 0; - } + if (groupCls) { + (*env)->DeleteGlobalRef(env, groupCls); + groupCls = 0; + } } diff --git a/src/JAVA/libjafs/Internal.c b/src/JAVA/libjafs/Internal.c index e9bce8c73..ce0206044 100644 --- a/src/JAVA/libjafs/Internal.c +++ b/src/JAVA/libjafs/Internal.c @@ -27,11 +27,11 @@ extern int errno; -jmethodID MID_String_getBytes = 0; +jmethodID MID_String_getBytes = 0; #ifndef LIBJUAFS /* User Class and Fields */ -jclass userCls = 0; +jclass userCls = 0; jfieldID user_ptsField = 0; jfieldID user_kasField = 0; jfieldID user_nameField = 0; @@ -67,7 +67,7 @@ jfieldID user_lockTimeField = 0; jfieldID user_lockedUntilField = 0; /* Group Class and Fields */ -jclass groupCls = 0; +jclass groupCls = 0; jfieldID group_nameField = 0; jfieldID group_cachedInfoField = 0; jfieldID group_nameUidField = 0; @@ -83,7 +83,7 @@ jfieldID group_ownerField = 0; jfieldID group_creatorField = 0; /* Server Class and Fields */ -jclass serverCls = 0; +jclass serverCls = 0; jfieldID server_nameField = 0; jfieldID server_cachedInfoField = 0; jfieldID server_databaseField = 0; @@ -93,7 +93,7 @@ jfieldID server_badFileServerField = 0; jfieldID server_IPAddressField = 0; /* Executable Time Class and Fields */ -jclass exectimeCls = 0; +jclass exectimeCls = 0; jfieldID exectime_HourField = 0; jfieldID exectime_MinField = 0; jfieldID exectime_SecField = 0; @@ -102,7 +102,7 @@ jfieldID exectime_NowField = 0; jfieldID exectime_NeverField = 0; /* Partition Class and Fields */ -jclass partitionCls = 0; +jclass partitionCls = 0; jfieldID partition_nameField = 0; jfieldID partition_cachedInfoField = 0; jfieldID partition_idField = 0; @@ -112,7 +112,7 @@ jfieldID partition_totalSpaceField = 0; jfieldID partition_totalFreeSpaceField = 0; /* Volume Class and Fields */ -jclass volumeCls = 0; +jclass volumeCls = 0; jfieldID volume_nameField = 0; jfieldID volume_cachedInfoField = 0; jfieldID volume_idField = 0; @@ -133,7 +133,7 @@ jfieldID volume_dispositionField = 0; jfieldID volume_typeField = 0; /* Key Class and Fields */ -jclass keyCls = 0; +jclass keyCls = 0; jfieldID key_cachedInfoField = 0; jfieldID key_versionField = 0; jfieldID key_encryptionKeyField = 0; @@ -142,7 +142,7 @@ jfieldID key_lastModMsField = 0; jfieldID key_checkSumField = 0; /* Process Class and Fields */ -jclass processCls = 0; +jclass processCls = 0; jfieldID process_cachedInfoField = 0; jfieldID process_nameField = 0; jfieldID process_typeField = 0; @@ -165,31 +165,35 @@ jfieldID process_stateBadFileAccessField = 0; * for the exception. See Exceptions.h for the available * exceptions. */ -void throwException - (JNIEnv *env, jclass *excCls, char *excClsName, jmethodID *initID, int code) -{ - jobject exc; - if( *excCls == 0 ) { - *excCls = (*env)->NewGlobalRef(env, (*env)->FindClass(env, excClsName )); - if( !*excCls ) { - fprintf(stderr, "ERROR: Internal::throwException()\n Cannot find class: %s\n", excClsName); - return; +void throwException(JNIEnv * env, jclass * excCls, char *excClsName, + jmethodID * initID, int code) { + jobject exc; + if (*excCls == 0) { + *excCls = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, excClsName)); + if (!*excCls) { + fprintf(stderr, + "ERROR: Internal::throwException()\n Cannot find class: %s\n", + excClsName); + return; + } + *initID = (*env)->GetMethodID(env, *excCls, "", "(I)V"); + if (!*initID) { + fprintf(stderr, + "ERROR: Internal::throwException()\n Cannot find construction method: %s\n", + excClsName); + return; + } } - *initID = (*env)->GetMethodID( env, *excCls, "", "(I)V" ); - if( !*initID ) { - fprintf(stderr, "ERROR: Internal::throwException()\n Cannot find construction method: %s\n", - excClsName); + + exc = (*env)->NewObject(env, *excCls, *initID, code); + if (!exc) { + fprintf(stderr, + "ERROR: Internal::throwException()\n Cannot construct new exception object: %s\n", + excClsName); return; } - } - - exc = (*env)->NewObject( env, *excCls, *initID, code ); - if( !exc ) { - fprintf(stderr, "ERROR: Internal::throwException()\n Cannot construct new exception object: %s\n", - excClsName); - return; - } - (*env)->Throw(env, exc); + (*env)->Throw(env, exc); } /** @@ -198,14 +202,17 @@ void throwException * is unavailable and it is necessary to interrupt the Java call with an * exception. See Exceptions.h for the available exceptions. */ -void throwMessageException( JNIEnv *env, char *msg ) +void +throwMessageException(JNIEnv * env, char *msg) { - jclass excCls = (*env)->FindClass(env, afsExceptionName); - if(excCls == 0) { - fprintf(stderr, "ERROR: Internal::throwMessageException()\n Cannot find class: %s\n", afsExceptionName); - return; - } - (*env)->ThrowNew(env, excCls, msg); + jclass excCls = (*env)->FindClass(env, afsExceptionName); + if (excCls == 0) { + fprintf(stderr, + "ERROR: Internal::throwMessageException()\n Cannot find class: %s\n", + afsExceptionName); + return; + } + (*env)->ThrowNew(env, excCls, msg); } /** @@ -213,34 +220,39 @@ void throwMessageException( JNIEnv *env, char *msg ) * for the exception. See Exceptions.h for the available * exceptions. */ -void throwAFSException( JNIEnv *env, int code ) +void +throwAFSException(JNIEnv * env, int code) { - jclass afsExceptionCls; - jmethodID afsExceptionInit; - jthrowable exc; - - afsExceptionCls = (*env)->FindClass(env, afsExceptionName); - if( !afsExceptionCls ) { - fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot find class: %s\n", afsExceptionName); - return; - } - - afsExceptionInit = (*env)->GetMethodID( env, afsExceptionCls, - "", "(I)V" ); - if( !afsExceptionInit ) { - fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot find construction method: %s\n", - afsExceptionName); - return; - } - - exc = (*env)->NewObject( env, afsExceptionCls, afsExceptionInit, code ); - - if( !exc ) { - fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot construct new exception object: %s\n", - afsExceptionName); - return; - } - (*env)->Throw(env, exc); + jclass afsExceptionCls; + jmethodID afsExceptionInit; + jthrowable exc; + + afsExceptionCls = (*env)->FindClass(env, afsExceptionName); + if (!afsExceptionCls) { + fprintf(stderr, + "ERROR: Internal::throwAFSException()\n Cannot find class: %s\n", + afsExceptionName); + return; + } + + afsExceptionInit = + (*env)->GetMethodID(env, afsExceptionCls, "", "(I)V"); + if (!afsExceptionInit) { + fprintf(stderr, + "ERROR: Internal::throwAFSException()\n Cannot find construction method: %s\n", + afsExceptionName); + return; + } + + exc = (*env)->NewObject(env, afsExceptionCls, afsExceptionInit, code); + + if (!exc) { + fprintf(stderr, + "ERROR: Internal::throwAFSException()\n Cannot construct new exception object: %s\n", + afsExceptionName); + return; + } + (*env)->Throw(env, exc); } /** @@ -248,35 +260,42 @@ void throwAFSException( JNIEnv *env, int code ) * for the exception. See Exceptions.h for the available * exceptions. */ -void throwAFSFileException( JNIEnv *env, int code, char *msg ) +void +throwAFSFileException(JNIEnv * env, int code, char *msg) { - jclass afsFileExceptionCls; - jmethodID afsFileExceptionInit; - jthrowable exc; - - afsFileExceptionCls = (*env)->FindClass(env, afsFileExceptionName); - if( !afsFileExceptionCls ) { - fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot find class: %s\n", afsFileExceptionName); - return; - } - - afsFileExceptionInit = (*env)->GetMethodID( env, afsFileExceptionCls, - "", "(Ljava/lang/String;I)V" ); - - if( !afsFileExceptionInit ) { - fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot find construction method: %s\n", - afsFileExceptionName); - return; - } - - exc = (*env)->NewObject( env, afsFileExceptionCls, - afsFileExceptionInit, msg, code ); - if( !exc ) { - fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot construct new exception object: %s\n", - afsFileExceptionName); - return; - } - (*env)->Throw(env, exc); + jclass afsFileExceptionCls; + jmethodID afsFileExceptionInit; + jthrowable exc; + + afsFileExceptionCls = (*env)->FindClass(env, afsFileExceptionName); + if (!afsFileExceptionCls) { + fprintf(stderr, + "ERROR: Internal::throwAFSFileException()\n Cannot find class: %s\n", + afsFileExceptionName); + return; + } + + afsFileExceptionInit = + (*env)->GetMethodID(env, afsFileExceptionCls, "", + "(Ljava/lang/String;I)V"); + + if (!afsFileExceptionInit) { + fprintf(stderr, + "ERROR: Internal::throwAFSFileException()\n Cannot find construction method: %s\n", + afsFileExceptionName); + return; + } + + exc = + (*env)->NewObject(env, afsFileExceptionCls, afsFileExceptionInit, msg, + code); + if (!exc) { + fprintf(stderr, + "ERROR: Internal::throwAFSFileException()\n Cannot construct new exception object: %s\n", + afsFileExceptionName); + return; + } + (*env)->Throw(env, exc); } /** @@ -284,71 +303,79 @@ void throwAFSFileException( JNIEnv *env, int code, char *msg ) * for the exception. See Exceptions.h for the available * exceptions. */ -void throwAFSSecurityException( JNIEnv *env, int code ) +void +throwAFSSecurityException(JNIEnv * env, int code) { - jclass afsSecurityExceptionCls; - jmethodID afsSecurityExceptionInit; - jthrowable exc; - - afsSecurityExceptionCls = (*env)->FindClass(env, afsSecurityExceptionName); - if( !afsSecurityExceptionCls ) { - fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot find class: %s\n", afsSecurityExceptionName); - return; - } - - afsSecurityExceptionInit = (*env)->GetMethodID( env, afsSecurityExceptionCls, - "", "(I)V" ); - if( !afsSecurityExceptionInit ) { - fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot find construction method: %s\n", - afsSecurityExceptionName); - return; - } - - exc = (*env)->NewObject( env, afsSecurityExceptionCls, - afsSecurityExceptionInit, code ); - - if( !exc ) { - fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot construct new exception object: %s\n", - afsSecurityExceptionName); - return; - } - (*env)->Throw(env, exc); + jclass afsSecurityExceptionCls; + jmethodID afsSecurityExceptionInit; + jthrowable exc; + + afsSecurityExceptionCls = + (*env)->FindClass(env, afsSecurityExceptionName); + if (!afsSecurityExceptionCls) { + fprintf(stderr, + "ERROR: Internal::throwAFSSecurityException()\n Cannot find class: %s\n", + afsSecurityExceptionName); + return; + } + + afsSecurityExceptionInit = + (*env)->GetMethodID(env, afsSecurityExceptionCls, "", "(I)V"); + if (!afsSecurityExceptionInit) { + fprintf(stderr, + "ERROR: Internal::throwAFSSecurityException()\n Cannot find construction method: %s\n", + afsSecurityExceptionName); + return; + } + + exc = + (*env)->NewObject(env, afsSecurityExceptionCls, + afsSecurityExceptionInit, code); + + if (!exc) { + fprintf(stderr, + "ERROR: Internal::throwAFSSecurityException()\n Cannot construct new exception object: %s\n", + afsSecurityExceptionName); + return; + } + (*env)->Throw(env, exc); } -int setError(JNIEnv *env, jobject *obj, int code) +int +setError(JNIEnv * env, jobject * obj, int code) { - jfieldID fid; - jclass cls = (*env)->GetObjectClass(env, *obj); - if (cls != NULL) { - fid = (*env)->GetFieldID(env, cls, "errno", "I"); - if (fid) - { - (*env)->SetIntField(env, *obj, fid, code); - return 0; - } - } - return -1; + jfieldID fid; + jclass cls = (*env)->GetObjectClass(env, *obj); + if (cls != NULL) { + fid = (*env)->GetFieldID(env, cls, "errno", "I"); + if (fid) { + (*env)->SetIntField(env, *obj, fid, code); + return 0; + } + } + return -1; } -int setString(JNIEnv *env, jobject *obj, char *field, char *string) +int +setString(JNIEnv * env, jobject * obj, char *field, char *string) { - jclass cls; - jstring jstr; - jfieldID fid; - - cls = (*env)->GetObjectClass(env, *obj); - /*fprintf(stderr, "setString: env=0x%x, obj=0x%x, cls=0x%x\n", env, obj, cls);*/ - if (cls != NULL) { - fid = (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;"); - /*fprintf(stderr, "setString: field=%s, fid=0x%x\n", field, fid);*/ - if (fid) { - jstr = (*env)->NewStringUTF(env, (string)); - /*fprintf(stderr, "jstr = 0x%x\n", jstr);*/ - (*env)->SetObjectField(env, *obj, fid, jstr); - return 0; - } - } - return -1; + jclass cls; + jstring jstr; + jfieldID fid; + + cls = (*env)->GetObjectClass(env, *obj); + /*fprintf(stderr, "setString: env=0x%x, obj=0x%x, cls=0x%x\n", env, obj, cls); */ + if (cls != NULL) { + fid = (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;"); + /*fprintf(stderr, "setString: field=%s, fid=0x%x\n", field, fid); */ + if (fid) { + jstr = (*env)->NewStringUTF(env, (string)); + /*fprintf(stderr, "jstr = 0x%x\n", jstr); */ + (*env)->SetObjectField(env, *obj, fid, jstr); + return 0; + } + } + return -1; } /** @@ -369,57 +396,63 @@ int setString(JNIEnv *env, jobject *obj, char *field, char *string) * @returns native C string with the appropriate locale-specific * representation */ -char* getNativeString(JNIEnv *env, const jstring jstr) +char * +getNativeString(JNIEnv * env, const jstring jstr) { - jbyteArray bytes = 0; - char *result = NULL; - jint len = 0; - - if ((*env)->EnsureLocalCapacity(env, 2) < 0) { - // Out of memory error - fprintf(stderr, "Internal::getNativeString(): "); - fprintf(stderr, "EnsureLocalCapacity() failed: Most likely out of memory\n"); - return NULL; - } - - if ( !MID_String_getBytes ) { - jclass stringClass = (*env)->FindClass(env, "java/lang/String"); - if ( !stringClass ) { - fprintf(stderr, "Internal::getNativeString(): "); - fprintf(stderr, "Could not locate Java class: java.lang.String.\n"); - return NULL; - } - - MID_String_getBytes = (*env)->GetMethodID(env, stringClass, "getBytes","()[B"); - if ( !MID_String_getBytes ) { - fprintf(stderr, "Internal::getNativeString(): "); - fprintf(stderr, "Could not get Java method id for java.lang.String method \"getBytes()\".\n"); - return NULL; - } - } - - bytes = (*env)->CallObjectMethod(env, jstr, MID_String_getBytes); - if ( !bytes ) { - fprintf(stderr, "Internal::getNativeString(): "); - fprintf(stderr, "CallObjectMethod() failed for java.lang.String.getBytes().\n"); - fprintf(stderr, "\tMID_String_getBytes = %d\n", MID_String_getBytes); - return NULL; - } - - len = (*env)->GetArrayLength(env, bytes); - result = (char *)malloc(len + 1); - - if ( !result ) { - fprintf(stderr, "Internal::getNativeString(): "); - fprintf(stderr, "Could not allocate memory for byte array.\n"); - (*env)->DeleteLocalRef(env, bytes); - return NULL; - } - (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *)result); - result[len] = '\0'; // NULL-terminate + jbyteArray bytes = 0; + char *result = NULL; + jint len = 0; + + if ((*env)->EnsureLocalCapacity(env, 2) < 0) { + // Out of memory error + fprintf(stderr, "Internal::getNativeString(): "); + fprintf(stderr, + "EnsureLocalCapacity() failed: Most likely out of memory\n"); + return NULL; + } + + if (!MID_String_getBytes) { + jclass stringClass = (*env)->FindClass(env, "java/lang/String"); + if (!stringClass) { + fprintf(stderr, "Internal::getNativeString(): "); + fprintf(stderr, + "Could not locate Java class: java.lang.String.\n"); + return NULL; + } + + MID_String_getBytes = + (*env)->GetMethodID(env, stringClass, "getBytes", "()[B"); + if (!MID_String_getBytes) { + fprintf(stderr, "Internal::getNativeString(): "); + fprintf(stderr, + "Could not get Java method id for java.lang.String method \"getBytes()\".\n"); + return NULL; + } + } + + bytes = (*env)->CallObjectMethod(env, jstr, MID_String_getBytes); + if (!bytes) { + fprintf(stderr, "Internal::getNativeString(): "); + fprintf(stderr, + "CallObjectMethod() failed for java.lang.String.getBytes().\n"); + fprintf(stderr, "\tMID_String_getBytes = %d\n", MID_String_getBytes); + return NULL; + } - (*env)->DeleteLocalRef(env, bytes); - return result; + len = (*env)->GetArrayLength(env, bytes); + result = (char *)malloc(len + 1); + + if (!result) { + fprintf(stderr, "Internal::getNativeString(): "); + fprintf(stderr, "Could not allocate memory for byte array.\n"); + (*env)->DeleteLocalRef(env, bytes); + return NULL; + } + (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result); + result[len] = '\0'; // NULL-terminate + + (*env)->DeleteLocalRef(env, bytes); + return result; } #ifdef LIBJUAFS @@ -436,31 +469,30 @@ char* getNativeString(JNIEnv *env, const jstring jstr) * * @returns file descriptor */ -int openAFSFile - (JNIEnv *env, jstring filenameUTF, int flags, int mode, int *err) -{ +int openAFSFile(JNIEnv * env, jstring filenameUTF, int flags, int mode, + int *err) { char *filename; int fd = -1; *err = 0; errno = 0; filename = getNativeString(env, filenameUTF); - if(filename == NULL) { - fprintf(stderr, "Internal::openAFSFile(): failed to get filename\n"); - *err = -1; - return fd; + if (filename == NULL) { + fprintf(stderr, "Internal::openAFSFile(): failed to get filename\n"); + *err = -1; + return fd; } - fd = uafs_open(filename, flags, mode); - free( filename ); + fd = uafs_open(filename, flags, mode); + free(filename); *err = errno; if (errno != 0) { - fprintf(stderr, "Internal::openAFSFile(): errno=%d\n", errno); - fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd); + fprintf(stderr, "Internal::openAFSFile(): errno=%d\n", errno); + fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd); } if (fd < 0) { - fprintf(stderr, "Internal::openAFSFile(): failed to open filename\n"); - fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd); - return -1; + fprintf(stderr, "Internal::openAFSFile(): failed to open filename\n"); + fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd); + return -1; } return fd; } @@ -477,74 +509,80 @@ int openAFSFile * configuration directory (where to find ThisCell and CellServDB), * cache directory, debug and verbose options, and log file location. */ -int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir, - int *cacheBlocks, int *cacheFiles, int *cacheStatEntries, - int *dCacheSize, int *vCacheSize, int *chunkSize, - int *closeSynch, int *debug, int *nDaemons, int *cacheFlags, - char *logFile) +int +readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir, + int *cacheBlocks, int *cacheFiles, int *cacheStatEntries, + int *dCacheSize, int *vCacheSize, int *chunkSize, + int *closeSynch, int *debug, int *nDaemons, int *cacheFlags, + char *logFile) { - FILE *f; - char line[100]; - char *p; - int len1, len2, n; - char cacheConfigFile[100]; - - p = (char *)getenv("LIBJAFS_CACHE_CONFIG"); - if (p) { - strcpy(cacheConfigFile, p); - } else { - strcpy(cacheConfigFile, "/usr/afswsp/etc/CacheConfig"); - } - - f = fopen(cacheConfigFile, "r"); - if (!f) { - fprintf(stderr, "Could not open cache config file: %s\n", - cacheConfigFile); - return -1; - } - - while (1) { - fgets(line, 100, f); - if (feof(f)) break; - p = (char *)strchr(line, '\n'); - if (p) *p = '\0'; - if (strncmp(line, "#", 1) == 0) continue; /* comment */ - - p = (char *)strchr(line, ' '); - if (!p) continue; - len1 = p - line; - p++; len2 = strlen(p); - - if (strncmp(line, "MountPoint", len1) == 0) - strcpy(afsMountPoint, p); - else if (strncmp(line, "ConfDir", len1) == 0) - strcpy(afsConfDir, p); - else if (strncmp(line, "CacheDir", len1) == 0) - strcpy(afsCacheDir, p); - else if (strncmp(line, "CacheBlocks", len1) == 0) - *cacheBlocks = atoi(p); - else if (strncmp(line, "CacheFiles", len1) == 0) - *cacheFiles = atoi(p); - else if (strncmp(line, "CacheStatEntries", len1) == 0) - *cacheStatEntries = atoi(p); - else if (strncmp(line, "DCacheSize", len1) == 0) - *dCacheSize = atoi(p); - else if (strncmp(line, "VCacheSize", len1) == 0) - *vCacheSize = atoi(p); - else if (strncmp(line, "ChunkSize", len1) == 0) - *chunkSize = atoi(p); - else if (strncmp(line, "CloseSynch", len1) == 0) - *closeSynch = atoi(p); - else if (strncmp(line, "Debug", len1) == 0) - *debug = atoi(p); - else if (strncmp(line, "NDaemons", len1) == 0) - *nDaemons = atoi(p); - else if (strncmp(line, "CacheFlags", len1) == 0) - *cacheFlags = atoi(p); - else if (strncmp(line, "LogFile", len1) == 0) - strcpy(logFile, p); - } - return 0; + FILE *f; + char line[100]; + char *p; + int len1, len2, n; + char cacheConfigFile[100]; + + p = (char *)getenv("LIBJAFS_CACHE_CONFIG"); + if (p) { + strcpy(cacheConfigFile, p); + } else { + strcpy(cacheConfigFile, "/usr/afswsp/etc/CacheConfig"); + } + + f = fopen(cacheConfigFile, "r"); + if (!f) { + fprintf(stderr, "Could not open cache config file: %s\n", + cacheConfigFile); + return -1; + } + + while (1) { + fgets(line, 100, f); + if (feof(f)) + break; + p = (char *)strchr(line, '\n'); + if (p) + *p = '\0'; + if (strncmp(line, "#", 1) == 0) + continue; /* comment */ + + p = (char *)strchr(line, ' '); + if (!p) + continue; + len1 = p - line; + p++; + len2 = strlen(p); + + if (strncmp(line, "MountPoint", len1) == 0) + strcpy(afsMountPoint, p); + else if (strncmp(line, "ConfDir", len1) == 0) + strcpy(afsConfDir, p); + else if (strncmp(line, "CacheDir", len1) == 0) + strcpy(afsCacheDir, p); + else if (strncmp(line, "CacheBlocks", len1) == 0) + *cacheBlocks = atoi(p); + else if (strncmp(line, "CacheFiles", len1) == 0) + *cacheFiles = atoi(p); + else if (strncmp(line, "CacheStatEntries", len1) == 0) + *cacheStatEntries = atoi(p); + else if (strncmp(line, "DCacheSize", len1) == 0) + *dCacheSize = atoi(p); + else if (strncmp(line, "VCacheSize", len1) == 0) + *vCacheSize = atoi(p); + else if (strncmp(line, "ChunkSize", len1) == 0) + *chunkSize = atoi(p); + else if (strncmp(line, "CloseSynch", len1) == 0) + *closeSynch = atoi(p); + else if (strncmp(line, "Debug", len1) == 0) + *debug = atoi(p); + else if (strncmp(line, "NDaemons", len1) == 0) + *nDaemons = atoi(p); + else if (strncmp(line, "CacheFlags", len1) == 0) + *cacheFlags = atoi(p); + else if (strncmp(line, "LogFile", len1) == 0) + strcpy(logFile, p); + } + return 0; } #else @@ -556,203 +594,214 @@ int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir, * the instance is the empty string. The memory for who * that's passed in should be fully allocated in advance. */ -void internal_makeKasIdentity( const char *fullName, kas_identity_p who ) +void +internal_makeKasIdentity(const char *fullName, kas_identity_p who) { - char *period; - - if( (period = (char *) strchr( fullName, '.' )) != NULL ) { - strncpy( who->principal, fullName, period - fullName ); - who->principal[period - fullName] = '\0'; - strncpy( who->instance, period + 1, - strlen(fullName) - (period - fullName) ); - } else { - strcpy( who->principal, fullName); - strcpy( who->instance, "" ); - } + char *period; + + if ((period = (char *)strchr(fullName, '.')) != NULL) { + strncpy(who->principal, fullName, period - fullName); + who->principal[period - fullName] = '\0'; + strncpy(who->instance, period + 1, + strlen(fullName) - (period - fullName)); + } else { + strcpy(who->principal, fullName); + strcpy(who->instance, ""); + } } /** * Given a Java environment and an instance of a user, gets the object and * field information for the user object from the Java environment. */ -void internal_getUserClass( JNIEnv *env, jobject user ) +void +internal_getUserClass(JNIEnv * env, jobject user) { - if( userCls == 0 ) { - userCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, user) ); - if( !userCls ) { - throwAFSException( env, JAFSADMCLASSNOTFOUND ); - return; + if (userCls == 0) { + userCls = + (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, user)); + if (!userCls) { + throwAFSException(env, JAFSADMCLASSNOTFOUND); + return; + } + user_ptsField = (*env)->GetFieldID(env, userCls, "pts", "Z"); + user_kasField = (*env)->GetFieldID(env, userCls, "kas", "Z"); + user_nameField = + (*env)->GetFieldID(env, userCls, "name", "Ljava/lang/String;"); + user_cachedInfoField = + (*env)->GetFieldID(env, userCls, "cachedInfo", "Z"); + // pts fields + user_nameUidField = (*env)->GetFieldID(env, userCls, "nameUID", "I"); + user_ownerUidField = + (*env)->GetFieldID(env, userCls, "ownerUID", "I"); + user_creatorUidField = + (*env)->GetFieldID(env, userCls, "creatorUID", "I"); + user_listStatusField = + (*env)->GetFieldID(env, userCls, "listStatus", "I"); + user_listGroupsOwnedField = + (*env)->GetFieldID(env, userCls, "listGroupsOwned", "I"); + user_listMembershipField = + (*env)->GetFieldID(env, userCls, "listMembership", "I"); + user_groupCreationQuotaField = + (*env)->GetFieldID(env, userCls, "groupCreationQuota", "I"); + user_groupMembershipCountField = + (*env)->GetFieldID(env, userCls, "groupMembershipCount", "I"); + user_ownerField = + (*env)->GetFieldID(env, userCls, "owner", "Ljava/lang/String;"); + user_creatorField = + (*env)->GetFieldID(env, userCls, "creator", "Ljava/lang/String;"); + // kas fields + user_adminSettingField = + (*env)->GetFieldID(env, userCls, "adminSetting", "I"); + user_tgsSettingField = + (*env)->GetFieldID(env, userCls, "tgsSetting", "I"); + user_encSettingField = + (*env)->GetFieldID(env, userCls, "encSetting", "I"); + user_cpwSettingField = + (*env)->GetFieldID(env, userCls, "cpwSetting", "I"); + user_rpwSettingField = + (*env)->GetFieldID(env, userCls, "rpwSetting", "I"); + user_userExpirationField = + (*env)->GetFieldID(env, userCls, "userExpiration", "I"); + user_lastModTimeField = + (*env)->GetFieldID(env, userCls, "lastModTime", "I"); + user_lastModNameField = + (*env)->GetFieldID(env, userCls, "lastModName", + "Ljava/lang/String;"); + user_lastChangePasswordTimeField = + (*env)->GetFieldID(env, userCls, "lastChangePasswordTime", "I"); + user_maxTicketLifetimeField = + (*env)->GetFieldID(env, userCls, "maxTicketLifetime", "I"); + user_keyVersionField = + (*env)->GetFieldID(env, userCls, "keyVersion", "I"); + user_encryptionKeyField = + (*env)->GetFieldID(env, userCls, "encryptionKey", + "Ljava/lang/String;"); + user_keyCheckSumField = + (*env)->GetFieldID(env, userCls, "keyCheckSum", "J"); + user_daysToPasswordExpireField = + (*env)->GetFieldID(env, userCls, "daysToPasswordExpire", "I"); + user_failLoginCountField = + (*env)->GetFieldID(env, userCls, "failLoginCount", "I"); + user_lockTimeField = + (*env)->GetFieldID(env, userCls, "lockTime", "I"); + user_lockedUntilField = + (*env)->GetFieldID(env, userCls, "lockedUntil", "I"); + if (!user_ptsField || !user_kasField || !user_nameField + || !user_cachedInfoField || !user_nameUidField + || !user_ownerUidField || !user_creatorUidField + || !user_listStatusField || !user_listGroupsOwnedField + || !user_listMembershipField || !user_groupCreationQuotaField + || !user_groupMembershipCountField || !user_ownerField + || !user_creatorField || !user_adminSettingField + || !user_tgsSettingField || !user_encSettingField + || !user_cpwSettingField || !user_rpwSettingField + || !user_userExpirationField || !user_lastModTimeField + || !user_lastModNameField || !user_lastChangePasswordTimeField + || !user_maxTicketLifetimeField || !user_keyVersionField + || !user_encryptionKeyField || !user_keyCheckSumField + || !user_daysToPasswordExpireField || !user_failLoginCountField + || !user_lockTimeField || !user_lockedUntilField) { + + throwAFSException(env, JAFSADMFIELDNOTFOUND); + return; + } } - user_ptsField = (*env)->GetFieldID( env, userCls, "pts", "Z" ); - user_kasField = (*env)->GetFieldID( env, userCls, "kas", "Z" ); - user_nameField = (*env)->GetFieldID( env, userCls, "name", - "Ljava/lang/String;" ); - user_cachedInfoField = (*env)->GetFieldID( env, userCls, "cachedInfo", - "Z" ); - // pts fields - user_nameUidField = (*env)->GetFieldID( env, userCls, "nameUID", "I" ); - user_ownerUidField = (*env)->GetFieldID( env, userCls, "ownerUID", "I" ); - user_creatorUidField = (*env)->GetFieldID( env, userCls, "creatorUID", - "I" ); - user_listStatusField = (*env)->GetFieldID( env, userCls, "listStatus", - "I" ); - user_listGroupsOwnedField = (*env)->GetFieldID( env, userCls, - "listGroupsOwned", "I" ); - user_listMembershipField = (*env)->GetFieldID( env, userCls, - "listMembership", "I" ); - user_groupCreationQuotaField = (*env)->GetFieldID( env, userCls, - "groupCreationQuota", - "I" ); - user_groupMembershipCountField = (*env)->GetFieldID( env, userCls, - "groupMembershipCount", - "I" ); - user_ownerField = (*env)->GetFieldID( env, userCls, "owner", - "Ljava/lang/String;" ); - user_creatorField = (*env)->GetFieldID( env, userCls, "creator", - "Ljava/lang/String;" ); - // kas fields - user_adminSettingField = (*env)->GetFieldID( env, userCls, "adminSetting", - "I" ); - user_tgsSettingField = (*env)->GetFieldID( env, userCls, "tgsSetting", - "I" ); - user_encSettingField = (*env)->GetFieldID( env, userCls, "encSetting", - "I" ); - user_cpwSettingField = (*env)->GetFieldID( env, userCls, "cpwSetting", - "I" ); - user_rpwSettingField = (*env)->GetFieldID( env, userCls, "rpwSetting", - "I" ); - user_userExpirationField = (*env)->GetFieldID( env, userCls, - "userExpiration", "I" ); - user_lastModTimeField = (*env)->GetFieldID( env, userCls, "lastModTime", - "I" ); - user_lastModNameField = (*env)->GetFieldID( env, userCls, "lastModName", - "Ljava/lang/String;" ); - user_lastChangePasswordTimeField = (*env)->GetFieldID( env, userCls, - "lastChangePasswordTime", - "I" ); - user_maxTicketLifetimeField = (*env)->GetFieldID( env, userCls, - "maxTicketLifetime", - "I" ); - user_keyVersionField = (*env)->GetFieldID( env, userCls, "keyVersion", - "I" ); - user_encryptionKeyField = (*env)->GetFieldID( env, userCls, - "encryptionKey", - "Ljava/lang/String;" ); - user_keyCheckSumField = (*env)->GetFieldID( env, userCls, "keyCheckSum", - "J" ); - user_daysToPasswordExpireField = (*env)->GetFieldID( env, userCls, - "daysToPasswordExpire", - "I" ); - user_failLoginCountField = (*env)->GetFieldID( env, userCls, - "failLoginCount", "I" ); - user_lockTimeField = (*env)->GetFieldID( env, userCls, "lockTime", "I" ); - user_lockedUntilField = (*env)->GetFieldID( env, userCls, "lockedUntil", - "I" ); - if( !user_ptsField || !user_kasField || !user_nameField || - !user_cachedInfoField || !user_nameUidField || !user_ownerUidField || - !user_creatorUidField || !user_listStatusField || - !user_listGroupsOwnedField || !user_listMembershipField || - !user_groupCreationQuotaField || !user_groupMembershipCountField || - !user_ownerField || !user_creatorField || !user_adminSettingField || - !user_tgsSettingField || !user_encSettingField || - !user_cpwSettingField || !user_rpwSettingField || - !user_userExpirationField || !user_lastModTimeField || - !user_lastModNameField || !user_lastChangePasswordTimeField || - !user_maxTicketLifetimeField || !user_keyVersionField || - !user_encryptionKeyField || !user_keyCheckSumField || - !user_daysToPasswordExpireField || !user_failLoginCountField || - !user_lockTimeField || !user_lockedUntilField ) { - - throwAFSException( env, JAFSADMFIELDNOTFOUND ); - return; - } - } } /** * Given a Java environment and an instance of a group, gets the object and * field information for the group object from the Java environment. */ -void internal_getGroupClass( JNIEnv *env, jobject group ) +void +internal_getGroupClass(JNIEnv * env, jobject group) { - if( groupCls == 0 ) { - groupCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, group) ); - if( !groupCls ) { - throwAFSException( env, JAFSADMCLASSNOTFOUND ); - return; + if (groupCls == 0) { + groupCls = + (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, group)); + if (!groupCls) { + throwAFSException(env, JAFSADMCLASSNOTFOUND); + return; + } + group_nameField = + (*env)->GetFieldID(env, groupCls, "name", "Ljava/lang/String;"); + group_cachedInfoField = + (*env)->GetFieldID(env, groupCls, "cachedInfo", "Z"); + group_nameUidField = + (*env)->GetFieldID(env, groupCls, "nameUID", "I"); + group_ownerUidField = + (*env)->GetFieldID(env, groupCls, "ownerUID", "I"); + group_creatorUidField = + (*env)->GetFieldID(env, groupCls, "creatorUID", "I"); + group_listStatusField = + (*env)->GetFieldID(env, groupCls, "listStatus", "I"); + group_listGroupsOwnedField = + (*env)->GetFieldID(env, groupCls, "listGroupsOwned", "I"); + group_listMembershipField = + (*env)->GetFieldID(env, groupCls, "listMembership", "I"); + group_listAddField = + (*env)->GetFieldID(env, groupCls, "listAdd", "I"); + group_listDeleteField = + (*env)->GetFieldID(env, groupCls, "listDelete", "I"); + group_membershipCountField = + (*env)->GetFieldID(env, groupCls, "membershipCount", "I"); + group_ownerField = + (*env)->GetFieldID(env, groupCls, "owner", "Ljava/lang/String;"); + group_creatorField = + (*env)->GetFieldID(env, groupCls, "creator", + "Ljava/lang/String;"); + if (!group_nameField || !group_cachedInfoField || !group_nameUidField + || !group_ownerUidField || !group_creatorUidField + || !group_listStatusField || !group_listGroupsOwnedField + || !group_listMembershipField || !group_listAddField + || !group_listDeleteField || !group_membershipCountField + || !group_ownerField || !group_creatorField) { + + throwAFSException(env, JAFSADMFIELDNOTFOUND); + return; + } } - group_nameField = (*env)->GetFieldID( env, groupCls, "name", - "Ljava/lang/String;" ); - group_cachedInfoField = (*env)->GetFieldID( env, groupCls, "cachedInfo", - "Z" ); - group_nameUidField = (*env)->GetFieldID( env, groupCls, "nameUID", "I" ); - group_ownerUidField = (*env)->GetFieldID( env, groupCls, "ownerUID", "I" ); - group_creatorUidField = (*env)->GetFieldID( env, groupCls, "creatorUID", - "I" ); - group_listStatusField = (*env)->GetFieldID( env, groupCls, "listStatus", - "I" ); - group_listGroupsOwnedField = (*env)->GetFieldID( env, groupCls, - "listGroupsOwned", "I" ); - group_listMembershipField = (*env)->GetFieldID( env, groupCls, - "listMembership", "I" ); - group_listAddField = (*env)->GetFieldID( env, groupCls, "listAdd", "I" ); - group_listDeleteField = (*env)->GetFieldID( env, groupCls, "listDelete", - "I" ); - group_membershipCountField = (*env)->GetFieldID( env, groupCls, - "membershipCount", "I" ); - group_ownerField = (*env)->GetFieldID( env, groupCls, "owner", - "Ljava/lang/String;" ); - group_creatorField = (*env)->GetFieldID( env, groupCls, "creator", - "Ljava/lang/String;" ); - if( !group_nameField || !group_cachedInfoField || !group_nameUidField || - !group_ownerUidField || !group_creatorUidField || - !group_listStatusField || !group_listGroupsOwnedField || - !group_listMembershipField || !group_listAddField || - !group_listDeleteField || !group_membershipCountField || - !group_ownerField || !group_creatorField ) { - - throwAFSException( env, JAFSADMFIELDNOTFOUND ); - return; - } - } } /** * Given a Java environment and an instance of a server, gets the object and * field information for the server object from the Java environment. */ -void internal_getServerClass( JNIEnv *env, jobject server ) +void +internal_getServerClass(JNIEnv * env, jobject server) { - if( serverCls == 0 ) { - serverCls = (*env)->NewGlobalRef( env, - (*env)->GetObjectClass(env, server) ); - if( !serverCls ) { - throwAFSException( env, JAFSADMCLASSNOTFOUND ); - return; - } - server_nameField = (*env)->GetFieldID( env, serverCls, "name", - "Ljava/lang/String;" ); - server_cachedInfoField = (*env)->GetFieldID( env, serverCls, "cachedInfo", - "Z" ); - server_databaseField = (*env)->GetFieldID( env, serverCls, "database", - "Z" ); - server_fileServerField = (*env)->GetFieldID( env, serverCls, "fileServer", - "Z" ); - server_badDatabaseField = (*env)->GetFieldID( env, serverCls, - "badDatabase", "Z" ); - server_badFileServerField = (*env)->GetFieldID( env, serverCls, - "badFileServer", "Z" ); - server_IPAddressField = (*env)->GetFieldID( env, serverCls, "ipAddresses", - "[Ljava/lang/String;" ); - if( !server_nameField || !server_cachedInfoField || !server_databaseField - || !server_fileServerField || !server_badDatabaseField || - !server_badFileServerField || !server_IPAddressField ) { - - throwAFSException( env, JAFSADMFIELDNOTFOUND ); - return; - + if (serverCls == 0) { + serverCls = + (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, server)); + if (!serverCls) { + throwAFSException(env, JAFSADMCLASSNOTFOUND); + return; + } + server_nameField = + (*env)->GetFieldID(env, serverCls, "name", "Ljava/lang/String;"); + server_cachedInfoField = + (*env)->GetFieldID(env, serverCls, "cachedInfo", "Z"); + server_databaseField = + (*env)->GetFieldID(env, serverCls, "database", "Z"); + server_fileServerField = + (*env)->GetFieldID(env, serverCls, "fileServer", "Z"); + server_badDatabaseField = + (*env)->GetFieldID(env, serverCls, "badDatabase", "Z"); + server_badFileServerField = + (*env)->GetFieldID(env, serverCls, "badFileServer", "Z"); + server_IPAddressField = + (*env)->GetFieldID(env, serverCls, "ipAddresses", + "[Ljava/lang/String;"); + if (!server_nameField || !server_cachedInfoField + || !server_databaseField || !server_fileServerField + || !server_badDatabaseField || !server_badFileServerField + || !server_IPAddressField) { + + throwAFSException(env, JAFSADMFIELDNOTFOUND); + return; + + } } - } } /** @@ -760,223 +809,231 @@ void internal_getServerClass( JNIEnv *env, jobject server ) * object and field information for the executableTime object from the * Java environment. */ -void internal_getExecTimeClass( JNIEnv *env, jobject exectime ) +void +internal_getExecTimeClass(JNIEnv * env, jobject exectime) { - if( exectimeCls == 0 ) { - exectimeCls = (*env)->NewGlobalRef( env, - (*env)->GetObjectClass(env, exectime) ); - if( !exectimeCls ) { - throwAFSException( env, JAFSADMCLASSNOTFOUND ); - return; - } - exectime_HourField = (*env)->GetFieldID( env, exectimeCls, "hour", "S" ); - exectime_MinField = (*env)->GetFieldID( env, exectimeCls, "minute", - "S" ); - exectime_SecField = (*env)->GetFieldID( env, exectimeCls, "second", - "S" ); - exectime_DayField = (*env)->GetFieldID( env, exectimeCls, "day", "S" ); - exectime_NowField = (*env)->GetFieldID( env, exectimeCls, "now", "Z" ); - exectime_NeverField = (*env)->GetFieldID( env, exectimeCls, "never", "Z" ); - if( !exectime_HourField || !exectime_MinField || !exectime_SecField || - !exectime_DayField || !exectime_NowField || !exectime_NeverField ) { - - throwAFSException( env, JAFSADMFIELDNOTFOUND ); - return; - + if (exectimeCls == 0) { + exectimeCls = + (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, exectime)); + if (!exectimeCls) { + throwAFSException(env, JAFSADMCLASSNOTFOUND); + return; + } + exectime_HourField = + (*env)->GetFieldID(env, exectimeCls, "hour", "S"); + exectime_MinField = + (*env)->GetFieldID(env, exectimeCls, "minute", "S"); + exectime_SecField = + (*env)->GetFieldID(env, exectimeCls, "second", "S"); + exectime_DayField = (*env)->GetFieldID(env, exectimeCls, "day", "S"); + exectime_NowField = (*env)->GetFieldID(env, exectimeCls, "now", "Z"); + exectime_NeverField = + (*env)->GetFieldID(env, exectimeCls, "never", "Z"); + if (!exectime_HourField || !exectime_MinField || !exectime_SecField + || !exectime_DayField || !exectime_NowField + || !exectime_NeverField) { + + throwAFSException(env, JAFSADMFIELDNOTFOUND); + return; + + } } - } } /** * Given a Java environment and an instance of a partition, gets the object and * field information for the partition object from the Java environment. */ -void internal_getPartitionClass( JNIEnv *env, jobject partition ) +void +internal_getPartitionClass(JNIEnv * env, jobject partition) { - if( partitionCls == 0 ) { - partitionCls = (*env)->NewGlobalRef( env, - (*env)->GetObjectClass(env, partition) ); - if( !partitionCls ) { - throwAFSException( env, JAFSADMCLASSNOTFOUND ); - return; + if (partitionCls == 0) { + partitionCls = + (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, partition)); + if (!partitionCls) { + throwAFSException(env, JAFSADMCLASSNOTFOUND); + return; + } + partition_nameField = + (*env)->GetFieldID(env, partitionCls, "name", + "Ljava/lang/String;"); + partition_deviceNameField = + (*env)->GetFieldID(env, partitionCls, "deviceName", + "Ljava/lang/String;"); + partition_idField = (*env)->GetFieldID(env, partitionCls, "id", "I"); + partition_cachedInfoField = + (*env)->GetFieldID(env, partitionCls, "cachedInfo", "Z"); + partition_lockFileDescriptorField = + (*env)->GetFieldID(env, partitionCls, "lockFileDescriptor", "I"); + partition_totalSpaceField = + (*env)->GetFieldID(env, partitionCls, "totalSpace", "I"); + partition_totalFreeSpaceField = + (*env)->GetFieldID(env, partitionCls, "totalFreeSpace", "I"); + if (!partition_nameField || !partition_cachedInfoField + || !partition_idField || !partition_deviceNameField + || !partition_lockFileDescriptorField + || !partition_totalSpaceField || !partition_totalFreeSpaceField) { + + throwAFSException(env, JAFSADMFIELDNOTFOUND); + return; + + } } - partition_nameField = (*env)->GetFieldID( env, partitionCls, "name", - "Ljava/lang/String;" ); - partition_deviceNameField = (*env)->GetFieldID( env, partitionCls, - "deviceName", - "Ljava/lang/String;" ); - partition_idField = (*env)->GetFieldID( env, partitionCls, "id", "I" ); - partition_cachedInfoField = (*env)->GetFieldID( env, partitionCls, - "cachedInfo", "Z" ); - partition_lockFileDescriptorField = (*env)->GetFieldID( env, partitionCls, - "lockFileDescriptor", - "I" ); - partition_totalSpaceField = (*env)->GetFieldID( env, partitionCls, - "totalSpace", "I" ); - partition_totalFreeSpaceField = (*env)->GetFieldID( env, partitionCls, - "totalFreeSpace", "I"); - if( !partition_nameField || !partition_cachedInfoField || - !partition_idField || !partition_deviceNameField || - !partition_lockFileDescriptorField || !partition_totalSpaceField || - !partition_totalFreeSpaceField ) { - - throwAFSException( env, JAFSADMFIELDNOTFOUND ); - return; - - } - } } /** * Given a Java environment and an instance of a volume, gets the object and * field information for the volume object from the Java environment. */ -void internal_getVolumeClass( JNIEnv *env, jobject volume ) +void +internal_getVolumeClass(JNIEnv * env, jobject volume) { - if( volumeCls == 0 ) { - volumeCls = (*env)->NewGlobalRef( env, - (*env)->GetObjectClass(env, volume) ); - if( !volumeCls ) { - throwAFSException( env, JAFSADMCLASSNOTFOUND ); - return; + if (volumeCls == 0) { + volumeCls = + (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, volume)); + if (!volumeCls) { + throwAFSException(env, JAFSADMCLASSNOTFOUND); + return; + } + volume_nameField = + (*env)->GetFieldID(env, volumeCls, "name", "Ljava/lang/String;"); + volume_cachedInfoField = + (*env)->GetFieldID(env, volumeCls, "cachedInfo", "Z"); + volume_idField = (*env)->GetFieldID(env, volumeCls, "id", "I"); + volume_readWriteIdField = + (*env)->GetFieldID(env, volumeCls, "readWriteID", "I"); + volume_readOnlyIdField = + (*env)->GetFieldID(env, volumeCls, "readOnlyID", "I"); + volume_backupIdField = + (*env)->GetFieldID(env, volumeCls, "backupID", "I"); + volume_creationDateField = + (*env)->GetFieldID(env, volumeCls, "creationDate", "J"); + volume_lastAccessDateField = + (*env)->GetFieldID(env, volumeCls, "lastAccessDate", "J"); + volume_lastUpdateDateField = + (*env)->GetFieldID(env, volumeCls, "lastUpdateDate", "J"); + volume_lastBackupDateField = + (*env)->GetFieldID(env, volumeCls, "lastBackupDate", "J"); + volume_copyCreationDateField = + (*env)->GetFieldID(env, volumeCls, "copyCreationDate", "J"); + volume_accessesSinceMidnightField = + (*env)->GetFieldID(env, volumeCls, "accessesSinceMidnight", "I"); + volume_fileCountField = + (*env)->GetFieldID(env, volumeCls, "fileCount", "I"); + volume_maxQuotaField = + (*env)->GetFieldID(env, volumeCls, "maxQuota", "I"); + volume_currentSizeField = + (*env)->GetFieldID(env, volumeCls, "currentSize", "I"); + volume_statusField = + (*env)->GetFieldID(env, volumeCls, "status", "I"); + volume_dispositionField = + (*env)->GetFieldID(env, volumeCls, "disposition", "I"); + volume_typeField = (*env)->GetFieldID(env, volumeCls, "type", "I"); + if (!volume_nameField || !volume_cachedInfoField || !volume_idField + || !volume_readWriteIdField || !volume_readOnlyIdField + || !volume_backupIdField || !volume_creationDateField + || !volume_lastAccessDateField || !volume_lastUpdateDateField + || !volume_lastBackupDateField || !volume_copyCreationDateField + || !volume_accessesSinceMidnightField || !volume_fileCountField + || !volume_maxQuotaField || !volume_currentSizeField + || !volume_statusField || !volume_dispositionField + || !volume_typeField) { + + throwAFSException(env, JAFSADMFIELDNOTFOUND); + return; + + } } - volume_nameField = (*env)->GetFieldID( env, volumeCls, "name", - "Ljava/lang/String;" ); - volume_cachedInfoField = (*env)->GetFieldID( env, volumeCls, "cachedInfo", - "Z" ); - volume_idField = (*env)->GetFieldID( env, volumeCls, "id", "I" ); - volume_readWriteIdField = (*env)->GetFieldID( env, volumeCls, - "readWriteID", "I" ); - volume_readOnlyIdField = (*env)->GetFieldID( env, volumeCls, "readOnlyID", - "I" ); - volume_backupIdField = (*env)->GetFieldID( env, volumeCls, "backupID", - "I" ); - volume_creationDateField = (*env)->GetFieldID( env, volumeCls, - "creationDate", "J" ); - volume_lastAccessDateField = (*env)->GetFieldID( env, volumeCls, - "lastAccessDate", "J" ); - volume_lastUpdateDateField = (*env)->GetFieldID( env, volumeCls, - "lastUpdateDate", "J" ); - volume_lastBackupDateField = (*env)->GetFieldID( env, volumeCls, - "lastBackupDate", "J" ); - volume_copyCreationDateField = (*env)->GetFieldID( env, volumeCls, - "copyCreationDate", - "J" ); - volume_accessesSinceMidnightField = (*env)->GetFieldID( env, volumeCls, - "accessesSinceMidnight", - "I" ); - volume_fileCountField = (*env)->GetFieldID( env, volumeCls, "fileCount", - "I" ); - volume_maxQuotaField = (*env)->GetFieldID( env, volumeCls, "maxQuota", - "I" ); - volume_currentSizeField = (*env)->GetFieldID( env, volumeCls, - "currentSize", "I" ); - volume_statusField = (*env)->GetFieldID( env, volumeCls, "status", "I" ); - volume_dispositionField = (*env)->GetFieldID( env, volumeCls, - "disposition", "I" ); - volume_typeField = (*env)->GetFieldID( env, volumeCls, "type", "I" ); - if( !volume_nameField || !volume_cachedInfoField || !volume_idField || - !volume_readWriteIdField || !volume_readOnlyIdField || - !volume_backupIdField || !volume_creationDateField || - !volume_lastAccessDateField || !volume_lastUpdateDateField || - !volume_lastBackupDateField || !volume_copyCreationDateField || - !volume_accessesSinceMidnightField || !volume_fileCountField || - !volume_maxQuotaField || !volume_currentSizeField || - !volume_statusField || !volume_dispositionField || - !volume_typeField ) { - - throwAFSException( env, JAFSADMFIELDNOTFOUND ); - return; - - } - } } /** * Given a Java environment and an instance of a key, gets the object and * field information for the key object from the Java environment. */ -void internal_getKeyClass( JNIEnv *env, jobject key ) +void +internal_getKeyClass(JNIEnv * env, jobject key) { - if( keyCls == 0 ) { - keyCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, key) ); - if( !keyCls ) { - throwAFSException( env, JAFSADMCLASSNOTFOUND ); - return; - } - key_encryptionKeyField = (*env)->GetFieldID( env, keyCls, - "encryptionKey", - "Ljava/lang/String;" ); - key_cachedInfoField = (*env)->GetFieldID( env, keyCls, "cachedInfo", "Z" ); - key_versionField = (*env)->GetFieldID( env, keyCls, "version", "I" ); - key_lastModDateField = (*env)->GetFieldID( env, keyCls, "lastModDate", - "I" ); - key_lastModMsField = (*env)->GetFieldID( env, keyCls, "lastModMs", "I" ); - key_checkSumField = (*env)->GetFieldID( env, keyCls, "checkSum", "J" ); - if( !key_cachedInfoField || !key_versionField || !key_encryptionKeyField - || !key_lastModDateField || !key_lastModMsField || - !key_checkSumField ) { - - throwAFSException( env, JAFSADMFIELDNOTFOUND ); - return; - + if (keyCls == 0) { + keyCls = (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, key)); + if (!keyCls) { + throwAFSException(env, JAFSADMCLASSNOTFOUND); + return; + } + key_encryptionKeyField = + (*env)->GetFieldID(env, keyCls, "encryptionKey", + "Ljava/lang/String;"); + key_cachedInfoField = + (*env)->GetFieldID(env, keyCls, "cachedInfo", "Z"); + key_versionField = (*env)->GetFieldID(env, keyCls, "version", "I"); + key_lastModDateField = + (*env)->GetFieldID(env, keyCls, "lastModDate", "I"); + key_lastModMsField = + (*env)->GetFieldID(env, keyCls, "lastModMs", "I"); + key_checkSumField = (*env)->GetFieldID(env, keyCls, "checkSum", "J"); + if (!key_cachedInfoField || !key_versionField + || !key_encryptionKeyField || !key_lastModDateField + || !key_lastModMsField || !key_checkSumField) { + + throwAFSException(env, JAFSADMFIELDNOTFOUND); + return; + + } } - } } /** * Given a Java environment and an instance of a process, gets the object and * field information for the process object from the Java environment. */ -void internal_getProcessClass( JNIEnv *env, jobject process ) +void +internal_getProcessClass(JNIEnv * env, jobject process) { - if( processCls == 0 ) { - processCls = (*env)->NewGlobalRef( env, - (*env)->GetObjectClass(env, process) ); - if( !processCls ) { - throwAFSException( env, JAFSADMCLASSNOTFOUND ); - return; - } - process_cachedInfoField = (*env)->GetFieldID( env, processCls, - "cachedInfo", "Z" ); - process_nameField = (*env)->GetFieldID( env, processCls, "name", - "Ljava/lang/String;" ); - process_typeField = (*env)->GetFieldID( env, processCls, "type", "I" ); - process_stateField = (*env)->GetFieldID( env, processCls, "state", "I" ); - process_goalField = (*env)->GetFieldID( env, processCls, "goal", "I" ); - process_startTimeField = (*env)->GetFieldID( env, processCls, "startTime", - "J" ); - process_numberStartsField = (*env)->GetFieldID( env, processCls, - "numberStarts", "J" ); - process_exitTimeField = (*env)->GetFieldID( env, processCls, "exitTime", - "J" ); - process_exitErrorTimeField = (*env)->GetFieldID( env, processCls, - "exitErrorTime", "J" ); - process_errorCodeField = (*env)->GetFieldID( env, processCls, "errorCode", - "J" ); - process_errorSignalField = (*env)->GetFieldID( env, processCls, - "errorSignal", "J" ); - process_stateOkField = (*env)->GetFieldID( env, processCls, "stateOk", - "Z" ); - process_stateTooManyErrorsField = (*env)->GetFieldID( env, processCls, - "stateTooManyErrors", - "Z" ); - process_stateBadFileAccessField = (*env)->GetFieldID( env, processCls, - "stateBadFileAccess", - "Z" ); - if( !process_cachedInfoField || !process_nameField || !process_typeField - || !process_stateField || !process_goalField || - !process_startTimeField || !process_numberStartsField || - !process_exitTimeField || !process_exitErrorTimeField || - !process_errorCodeField || !process_errorSignalField || - !process_stateOkField || !process_stateTooManyErrorsField || - !process_stateBadFileAccessField ) { - - throwAFSException( env, JAFSADMFIELDNOTFOUND ); - return; - + if (processCls == 0) { + processCls = + (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, process)); + if (!processCls) { + throwAFSException(env, JAFSADMCLASSNOTFOUND); + return; + } + process_cachedInfoField = + (*env)->GetFieldID(env, processCls, "cachedInfo", "Z"); + process_nameField = + (*env)->GetFieldID(env, processCls, "name", "Ljava/lang/String;"); + process_typeField = (*env)->GetFieldID(env, processCls, "type", "I"); + process_stateField = + (*env)->GetFieldID(env, processCls, "state", "I"); + process_goalField = (*env)->GetFieldID(env, processCls, "goal", "I"); + process_startTimeField = + (*env)->GetFieldID(env, processCls, "startTime", "J"); + process_numberStartsField = + (*env)->GetFieldID(env, processCls, "numberStarts", "J"); + process_exitTimeField = + (*env)->GetFieldID(env, processCls, "exitTime", "J"); + process_exitErrorTimeField = + (*env)->GetFieldID(env, processCls, "exitErrorTime", "J"); + process_errorCodeField = + (*env)->GetFieldID(env, processCls, "errorCode", "J"); + process_errorSignalField = + (*env)->GetFieldID(env, processCls, "errorSignal", "J"); + process_stateOkField = + (*env)->GetFieldID(env, processCls, "stateOk", "Z"); + process_stateTooManyErrorsField = + (*env)->GetFieldID(env, processCls, "stateTooManyErrors", "Z"); + process_stateBadFileAccessField = + (*env)->GetFieldID(env, processCls, "stateBadFileAccess", "Z"); + if (!process_cachedInfoField || !process_nameField + || !process_typeField || !process_stateField || !process_goalField + || !process_startTimeField || !process_numberStartsField + || !process_exitTimeField || !process_exitErrorTimeField + || !process_errorCodeField || !process_errorSignalField + || !process_stateOkField || !process_stateTooManyErrorsField + || !process_stateBadFileAccessField) { + + throwAFSException(env, JAFSADMFIELDNOTFOUND); + return; + + } } - } } #endif /* LIBJUAFS */ diff --git a/src/JAVA/libjafs/Internal.h b/src/JAVA/libjafs/Internal.h index 14b91cd67..b08eea6cf 100644 --- a/src/JAVA/libjafs/Internal.h +++ b/src/JAVA/libjafs/Internal.h @@ -10,72 +10,71 @@ * Please add any internal error codes to the ErrorMessages.properties * file located in src/JAVA/classes/ */ -#define JAFSADMNOMEM 1050 // Memory problems -#define JAFSADMCLASSNOTFOUND 1051 // Trouble finding a Java class -#define JAFSADMMETHODNOTFOUND 1052 // Trouble finding a Java method -#define JAFSADMFIELDNOTFOUND 1053 // Trouble finding a Java field -#define JAFSNULLARG 1054 // Null argument (general) -#define JAFSNULLUSER 1055 // User argument null -#define JAFSNULLPASS 1056 // Password argument null -#define JAFSNULLGROUP 1057 // Group name argument null -#define JAFSNULLOWNER 1058 // Group owner name argument null -#define JAFSNULLVOLUME 1059 // Volume name argument null -#define JAFSNULLPART 1060 // Partition name argument null -#define JAFSNULLPROCESS 1061 // Process name argument null -#define JAFSNULLSERVER 1062 // Server name argument null -#define JAFSNULLCELL 1063 // Cell name argument null -#define JAFSNULLPATH 1064 // Path argument null -#define JAFSNULLACL 1065 // ACL string argument null +#define JAFSADMNOMEM 1050 // Memory problems +#define JAFSADMCLASSNOTFOUND 1051 // Trouble finding a Java class +#define JAFSADMMETHODNOTFOUND 1052 // Trouble finding a Java method +#define JAFSADMFIELDNOTFOUND 1053 // Trouble finding a Java field +#define JAFSNULLARG 1054 // Null argument (general) +#define JAFSNULLUSER 1055 // User argument null +#define JAFSNULLPASS 1056 // Password argument null +#define JAFSNULLGROUP 1057 // Group name argument null +#define JAFSNULLOWNER 1058 // Group owner name argument null +#define JAFSNULLVOLUME 1059 // Volume name argument null +#define JAFSNULLPART 1060 // Partition name argument null +#define JAFSNULLPROCESS 1061 // Process name argument null +#define JAFSNULLSERVER 1062 // Server name argument null +#define JAFSNULLCELL 1063 // Cell name argument null +#define JAFSNULLPATH 1064 // Path argument null +#define JAFSNULLACL 1065 // ACL string argument null #ifndef LIBJUAFS #include #include // make an identity out of a full name (possibly including an instance ) -void internal_makeKasIdentity( const char *fullName, kas_identity_p who ); - -void internal_getUserClass( JNIEnv *env, jobject user ); -void internal_getGroupClass( JNIEnv *env, jobject group ); -void internal_getServerClass( JNIEnv *env, jobject server ); -void internal_getPartitionClass( JNIEnv *env, jobject partition ); -void internal_getVolumeClass( JNIEnv *env, jobject volume ); -void internal_getKeyClass( JNIEnv *env, jobject key ); -void internal_getProcessClass( JNIEnv *env, jobject process ); +void internal_makeKasIdentity(const char *fullName, kas_identity_p who); + +void internal_getUserClass(JNIEnv * env, jobject user); +void internal_getGroupClass(JNIEnv * env, jobject group); +void internal_getServerClass(JNIEnv * env, jobject server); +void internal_getPartitionClass(JNIEnv * env, jobject partition); +void internal_getVolumeClass(JNIEnv * env, jobject volume); +void internal_getKeyClass(JNIEnv * env, jobject key); +void internal_getProcessClass(JNIEnv * env, jobject process); #else -int openAFSFile(JNIEnv *env, jstring fileNameUTF, int flags, int mode, int *err); +int openAFSFile(JNIEnv * env, jstring fileNameUTF, int flags, int mode, + int *err); int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir, - int *cacheBlocks, int *cacheFiles, int *cacheStatEntries, - int *dCacheSize, int *vCacheSize, int *chunkSize, - int *closeSynch, int *debug, int *nDaemons, int *cacheFlags, - char *logFile); + int *cacheBlocks, int *cacheFiles, int *cacheStatEntries, + int *dCacheSize, int *vCacheSize, int *chunkSize, + int *closeSynch, int *debug, int *nDaemons, + int *cacheFlags, char *logFile); #endif /* !LIBJUAFS */ // throw a non-AFS exception with a message -void throwMessageException( JNIEnv *env, char *msg ); +void throwMessageException(JNIEnv * env, char *msg); // throw an AFS exception with a message -void throwAFSException( JNIEnv *env, int code ); +void throwAFSException(JNIEnv * env, int code); // throw an AFS Admin exception with a message -void throwAFSException( JNIEnv *env, int code ); +void throwAFSException(JNIEnv * env, int code); // throw an AFS File or I/O related exception with a message -void throwFileAdminException( JNIEnv *env, int code, char *msg ); +void throwFileAdminException(JNIEnv * env, int code, char *msg); // throw an AFS Security exception with a message -void throwAFSSecurityException( JNIEnv *env, int code ); +void throwAFSSecurityException(JNIEnv * env, int code); // throw an exception with an error code -void throwException( JNIEnv *env, jclass *excCls, char *excClsName, jmethodID *initID, int code ); +void throwException(JNIEnv * env, jclass * excCls, char *excClsName, + jmethodID * initID, int code); // reclaim global memory used by exceptions -void reclaimExceptionMemory( JNIEnv *env, jclass cls ); +void reclaimExceptionMemory(JNIEnv * env, jclass cls); -int setError (JNIEnv *env, jobject *obj, int code); -int setString(JNIEnv *env, jobject *obj, char *field, char *string); -char* getNativeString(JNIEnv *env, jstring jstr); +int setError(JNIEnv * env, jobject * obj, int code); +int setString(JNIEnv * env, jobject * obj, char *field, char *string); +char *getNativeString(JNIEnv * env, jstring jstr); #endif - - - diff --git a/src/JAVA/libjafs/Key.c b/src/JAVA/libjafs/Key.c index 19486f82d..acde7bcc0 100644 --- a/src/JAVA/libjafs/Key.c +++ b/src/JAVA/libjafs/Key.c @@ -27,7 +27,7 @@ #include //// definitions in Internal.c ////////////////// -extern jclass keyCls; +extern jclass keyCls; extern jfieldID key_versionField; extern jfieldID key_encryptionKeyField; extern jfieldID key_lastModDateField; @@ -44,40 +44,41 @@ extern jfieldID key_checkSumField; * key the Key object to populate with the info * keyEntry the container of the key's information */ -void fillKeyInfo( JNIEnv *env, jobject key, bos_KeyInfo_t keyEntry ) +void +fillKeyInfo(JNIEnv * env, jobject key, bos_KeyInfo_t keyEntry) { - jstring jencryptionKey; - char *convertedKey; - int i; - - // get the class fields if need be - if ( keyCls == 0 ) { - internal_getKeyClass( env, key ); - } - - // set all the fields - (*env)->SetIntField( env, key, key_versionField, keyEntry.keyVersionNumber ); - - convertedKey = (char *) malloc( sizeof(char *)* - (sizeof(keyEntry.key.key)*4+1) ); - if ( !convertedKey ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - for( i = 0; i < sizeof(keyEntry.key.key); i++ ) { - sprintf( &(convertedKey[i*4]), "\\%0.3o", keyEntry.key.key[i] ); - } - jencryptionKey = (*env)->NewStringUTF(env, convertedKey); - (*env)->SetObjectField( env, key, key_encryptionKeyField, jencryptionKey ); - - (*env)->SetIntField( env, key, key_lastModDateField, - keyEntry.keyStatus.lastModificationDate ); - (*env)->SetIntField( env, key, key_lastModMsField, - keyEntry.keyStatus.lastModificationMicroSeconds ); - (*env)->SetLongField( env, key, key_checkSumField, - (unsigned int) keyEntry.keyStatus.checkSum ); - - free( convertedKey ); + jstring jencryptionKey; + char *convertedKey; + int i; + + // get the class fields if need be + if (keyCls == 0) { + internal_getKeyClass(env, key); + } + // set all the fields + (*env)->SetIntField(env, key, key_versionField, + keyEntry.keyVersionNumber); + + convertedKey = + (char *)malloc(sizeof(char *) * (sizeof(keyEntry.key.key) * 4 + 1)); + if (!convertedKey) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + for (i = 0; i < sizeof(keyEntry.key.key); i++) { + sprintf(&(convertedKey[i * 4]), "\\%0.3o", keyEntry.key.key[i]); + } + jencryptionKey = (*env)->NewStringUTF(env, convertedKey); + (*env)->SetObjectField(env, key, key_encryptionKeyField, jencryptionKey); + + (*env)->SetIntField(env, key, key_lastModDateField, + keyEntry.keyStatus.lastModificationDate); + (*env)->SetIntField(env, key, key_lastModMsField, + keyEntry.keyStatus.lastModificationMicroSeconds); + (*env)->SetLongField(env, key, key_checkSumField, + (unsigned int)keyEntry.keyStatus.checkSum); + + free(convertedKey); } /** @@ -91,55 +92,56 @@ void fillKeyInfo( JNIEnv *env, jobject key, bos_KeyInfo_t keyEntry ) * key the Key object in which to fill in the * information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Key_getKeyInfo - (JNIEnv *env, jclass cls, jint serverHandle, jint version, jobject key) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Key_getKeyInfo(JNIEnv * env, jclass cls, + jint serverHandle, jint version, + jobject key) { - afs_status_t ast; - bos_KeyInfo_t keyEntry; - void *iterationId; - int done; - - if ( !bos_KeyGetBegin( (void *) serverHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } - - done = FALSE; - - // there's no KeyGet function, so we must iterate and find the - // one with the matching version - while( !done ) { - - if ( !bos_KeyGetNext( iterationId, &keyEntry, &ast ) ) { - // no matching key - if ( ast == ADMITERATORDONE ) { - afs_status_t astnew; - if ( !bos_KeyGetDone( iterationId, &astnew ) ) { - throwAFSException( env, astnew ); - return; - } - throwAFSException( env, KAUNKNOWNKEY ); - return; - // other - } else { - throwAFSException( env, ast ); - return; - } - } + afs_status_t ast; + bos_KeyInfo_t keyEntry; + void *iterationId; + int done; - if ( keyEntry.keyVersionNumber == version ) { - done = TRUE; + if (!bos_KeyGetBegin((void *)serverHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return; } - } + done = FALSE; + + // there's no KeyGet function, so we must iterate and find the + // one with the matching version + while (!done) { + + if (!bos_KeyGetNext(iterationId, &keyEntry, &ast)) { + // no matching key + if (ast == ADMITERATORDONE) { + afs_status_t astnew; + if (!bos_KeyGetDone(iterationId, &astnew)) { + throwAFSException(env, astnew); + return; + } + throwAFSException(env, KAUNKNOWNKEY); + return; + // other + } else { + throwAFSException(env, ast); + return; + } + } + + if (keyEntry.keyVersionNumber == version) { + done = TRUE; + } + + } - fillKeyInfo( env, key, keyEntry ); + fillKeyInfo(env, key, keyEntry); - if ( !bos_KeyGetDone( iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_KeyGetDone(iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } @@ -155,56 +157,60 @@ Java_org_openafs_jafs_Key_getKeyInfo * jkeyString the String version of the key that will * be encrypted */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Key_create - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint version, - jstring jkeyString) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Key_create(JNIEnv * env, jclass cls, jint cellHandle, + jint serverHandle, jint version, + jstring jkeyString) { afs_status_t ast; char *keyString; char *cellName; - kas_encryptionKey_p key = - (kas_encryptionKey_p) malloc( sizeof(kas_encryptionKey_t) ); - - if ( !key ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + kas_encryptionKey_p key = + (kas_encryptionKey_p) malloc(sizeof(kas_encryptionKey_t)); + + if (!key) { + throwAFSException(env, JAFSADMNOMEM); + return; } - if ( jkeyString != NULL ) { - keyString = getNativeString(env, jkeyString); - if ( keyString == NULL ) { - free( key ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } + if (jkeyString != NULL) { + keyString = getNativeString(env, jkeyString); + if (keyString == NULL) { + free(key); + throwAFSException(env, JAFSADMNOMEM); + return; + } } else { - keyString = NULL; + keyString = NULL; } - if ( !afsclient_CellNameGet( (void *) cellHandle, &cellName, &ast ) ) { - free( key ); - if ( keyString != NULL ) free( keyString ); - throwAFSException( env, ast ); + if (!afsclient_CellNameGet((void *)cellHandle, &cellName, &ast)) { + free(key); + if (keyString != NULL) + free(keyString); + throwAFSException(env, ast); return; - } + } - if ( !kas_StringToKey( cellName, keyString, key, &ast ) ) { - free( key ); - if ( keyString != NULL ) free( keyString ); - throwAFSException( env, ast ); + if (!kas_StringToKey(cellName, keyString, key, &ast)) { + free(key); + if (keyString != NULL) + free(keyString); + throwAFSException(env, ast); return; } - if ( !bos_KeyCreate( (void *) serverHandle, version, key, &ast ) ) { - free( key ); - if ( keyString != NULL ) free( keyString ); - throwAFSException( env, ast ); + if (!bos_KeyCreate((void *)serverHandle, version, key, &ast)) { + free(key); + if (keyString != NULL) + free(keyString); + throwAFSException(env, ast); return; } - free( key ); - if ( keyString != NULL ) free( keyString ); + free(key); + if (keyString != NULL) + free(keyString); } /** @@ -215,24 +221,24 @@ Java_org_openafs_jafs_Key_create * serverHandle the bos handle of the server to which the key belongs * versionNumber the version number of the key to remove (0 to 255) */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Key_delete - (JNIEnv *env, jclass cls, jint serverHandle, jint version ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Key_delete(JNIEnv * env, jclass cls, jint serverHandle, + jint version) { - afs_status_t ast; + afs_status_t ast; - if ( !bos_KeyDelete( (void *) serverHandle, version, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_KeyDelete((void *)serverHandle, version, &ast)) { + throwAFSException(env, ast); + return; + } } // reclaim global memory being used by this portion JNIEXPORT void JNICALL -Java_org_openafs_jafs_Key_reclaimKeyMemory (JNIEnv *env, jclass cls) +Java_org_openafs_jafs_Key_reclaimKeyMemory(JNIEnv * env, jclass cls) { - if ( keyCls ) { - (*env)->DeleteGlobalRef(env, keyCls); - keyCls = 0; - } + if (keyCls) { + (*env)->DeleteGlobalRef(env, keyCls); + keyCls = 0; + } } diff --git a/src/JAVA/libjafs/Partition.c b/src/JAVA/libjafs/Partition.c index 14af75944..20823fca8 100644 --- a/src/JAVA/libjafs/Partition.c +++ b/src/JAVA/libjafs/Partition.c @@ -42,8 +42,8 @@ extern jfieldID volume_cachedInfoField; ///// Definition in jafs_Volume.c ///////////////// -extern void fillVolumeInfo - ( JNIEnv *env, jobject volume, vos_volumeEntry_t volEntry ); +extern void fillVolumeInfo(JNIEnv * env, jobject volume, + vos_volumeEntry_t volEntry); /////////////////////////////////////////////////// @@ -56,40 +56,40 @@ extern void fillVolumeInfo * partition the Partition object to populate with the info * partEntry the container of the partition's information */ -void fillPartitionInfo - (JNIEnv *env, jobject partition, vos_partitionEntry_t partEntry) +void +fillPartitionInfo(JNIEnv * env, jobject partition, + vos_partitionEntry_t partEntry) { - jstring jdeviceName; - jstring jpartition; - jint id; - afs_status_t ast; - - // get the class fields if need be - if ( partitionCls == 0 ) { - internal_getPartitionClass( env, partition ); - } - - // fill name and id in case it's a blank object - jpartition = (*env)->NewStringUTF(env, partEntry.name); - // get the id - if ( !vos_PartitionNameToId( partEntry.name, (int *) &id, &ast ) ) { - throwAFSException( env, ast ); - return; - } - (*env)->SetObjectField(env, partition, partition_nameField, jpartition); - (*env)->SetIntField(env, partition, partition_idField, id); - - jdeviceName = (*env)->NewStringUTF(env, partEntry.deviceName); - (*env)->SetObjectField(env, partition, partition_deviceNameField, - jdeviceName); - - (*env)->SetIntField(env, partition, partition_lockFileDescriptorField, - partEntry.lockFileDescriptor); - (*env)->SetIntField(env, partition, partition_totalSpaceField, - partEntry.totalSpace); - (*env)->SetIntField(env, partition, partition_totalFreeSpaceField, - partEntry.totalFreeSpace); - + jstring jdeviceName; + jstring jpartition; + jint id; + afs_status_t ast; + + // get the class fields if need be + if (partitionCls == 0) { + internal_getPartitionClass(env, partition); + } + // fill name and id in case it's a blank object + jpartition = (*env)->NewStringUTF(env, partEntry.name); + // get the id + if (!vos_PartitionNameToId(partEntry.name, (int *)&id, &ast)) { + throwAFSException(env, ast); + return; + } + (*env)->SetObjectField(env, partition, partition_nameField, jpartition); + (*env)->SetIntField(env, partition, partition_idField, id); + + jdeviceName = (*env)->NewStringUTF(env, partEntry.deviceName); + (*env)->SetObjectField(env, partition, partition_deviceNameField, + jdeviceName); + + (*env)->SetIntField(env, partition, partition_lockFileDescriptorField, + partEntry.lockFileDescriptor); + (*env)->SetIntField(env, partition, partition_totalSpaceField, + partEntry.totalSpace); + (*env)->SetIntField(env, partition, partition_totalFreeSpaceField, + partEntry.totalFreeSpace); + } /** @@ -105,22 +105,25 @@ void fillPartitionInfo * jpartitionObject the Partition object in which to * fill in the information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Partition_getPartitionInfo - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, - jint partition, jobject jpartitionObject) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Partition_getPartitionInfo(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle, + jint partition, + jobject jpartitionObject) { - afs_status_t ast; - vos_partitionEntry_t partEntry; - - // get the partition entry - if ( !vos_PartitionGet( (void *) cellHandle, (void *) serverHandle, NULL, - (unsigned int) partition, &partEntry, &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + vos_partitionEntry_t partEntry; + + // get the partition entry + if (!vos_PartitionGet + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, &partEntry, &ast)) { + throwAFSException(env, ast); + return; + } - fillPartitionInfo( env, jpartitionObject, partEntry ); + fillPartitionInfo(env, jpartitionObject, partEntry); } @@ -132,34 +135,34 @@ Java_org_openafs_jafs_Partition_getPartitionInfo * jname the name of the partition in question * returns the id of the partition in question */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Partition_translateNameToID - (JNIEnv *env, jclass cls, jstring jname) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Partition_translateNameToID(JNIEnv * env, jclass cls, + jstring jname) { - afs_status_t ast; - jint id; - char *name; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( name == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return -1; + afs_status_t ast; + jint id; + char *name; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (name == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } + } else { + throwAFSException(env, JAFSNULLPART); + return -1; } - } else { - throwAFSException( env, JAFSNULLPART ); - return -1; - } - // get the id - if ( !vos_PartitionNameToId( name, (unsigned int *) &id, &ast ) ) { - id = -1; - throwAFSException( env, ast ); - } + // get the id + if (!vos_PartitionNameToId(name, (unsigned int *)&id, &ast)) { + id = -1; + throwAFSException(env, ast); + } - free( name ); + free(name); - return id; + return id; } /** @@ -170,28 +173,27 @@ Java_org_openafs_jafs_Partition_translateNameToID * id the id of the partition in question * returns the name of the partition in question */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Partition_translateIDToName - (JNIEnv *env, jclass cls, jint id) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Partition_translateIDToName(JNIEnv * env, jclass cls, + jint id) { - afs_status_t ast; - char *name = (char *) malloc( sizeof(char)*VOS_MAX_PARTITION_NAME_LEN); - jstring jname = NULL; - - if ( name == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return NULL; - } - - // get the name - if ( vos_PartitionIdToName( (unsigned int) id, name, &ast ) ) { - jname = (*env)->NewStringUTF(env, name); - } else { - throwAFSException( env, ast ); - } - free( name ); - - return jname; + afs_status_t ast; + char *name = (char *)malloc(sizeof(char) * VOS_MAX_PARTITION_NAME_LEN); + jstring jname = NULL; + + if (name == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return NULL; + } + // get the name + if (vos_PartitionIdToName((unsigned int)id, name, &ast)) { + jname = (*env)->NewStringUTF(env, name); + } else { + throwAFSException(env, ast); + } + free(name); + + return jname; } /** @@ -206,29 +208,33 @@ Java_org_openafs_jafs_Partition_translateIDToName * reside * returns total number of volumes hosted by this partition */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Partition_getVolumeCount - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Partition_getVolumeCount(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle, + jint partition) { - afs_status_t ast; - void *iterationId; - vos_volumeEntry_t volEntry; - int i = 0; - - if ( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL, - (unsigned int) partition, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + afs_status_t ast; + void *iterationId; + vos_volumeEntry_t volEntry; + int i = 0; + + if (!vos_VolumeGetBegin + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - while ( vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) i++; + while (vos_VolumeGetNext((void *)iterationId, &volEntry, &ast)) + i++; - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } /** @@ -245,21 +251,24 @@ Java_org_openafs_jafs_Partition_getVolumeCount * reside * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Partition_getVolumesBegin - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Partition_getVolumesBegin(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle, + jint partition) { - afs_status_t ast; - void *iterationId; + afs_status_t ast; + void *iterationId; - if ( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL, - (unsigned int) partition, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + if (!vos_VolumeGetBegin + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - return (jint) iterationId; + return (jint) iterationId; } /** @@ -276,35 +285,37 @@ Java_org_openafs_jafs_Partition_getVolumesBegin * reside * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Partition_getVolumesBeginAt - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, - jint partition, jint index) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Partition_getVolumesBeginAt(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle, + jint partition, jint index) { - afs_status_t ast; - void *iterationId; - vos_volumeEntry_t volEntry; - int i; - - if ( !vos_VolumeGetBegin( (void *) cellHandle, (void *) serverHandle, NULL, - (unsigned int) partition, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } - - for ( i = 1; i < index; i++) { - if ( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; - } + afs_status_t ast; + void *iterationId; + vos_volumeEntry_t volEntry; + int i; + + if (!vos_VolumeGetBegin + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } + + for (i = 1; i < index; i++) { + if (!vos_VolumeGetNext((void *)iterationId, &volEntry, &ast)) { + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } + } } - } - return (jint) iterationId; + return (jint) iterationId; } @@ -317,25 +328,25 @@ Java_org_openafs_jafs_Partition_getVolumesBeginAt * iterationId the iteration ID of this iteration * returns the name of the next volume of the server */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Partition_getVolumesNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Partition_getVolumesNextString(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; - jstring jvolume; - vos_volumeEntry_t volEntry; - - if ( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return NULL; + afs_status_t ast; + jstring jvolume; + vos_volumeEntry_t volEntry; + + if (!vos_VolumeGetNext((void *)iterationId, &volEntry, &ast)) { + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return NULL; + } } - } - jvolume = (*env)->NewStringUTF(env, volEntry.name); - return jvolume; + jvolume = (*env)->NewStringUTF(env, volEntry.name); + return jvolume; } @@ -350,33 +361,34 @@ Java_org_openafs_jafs_Partition_getVolumesNextString * of the next volume * returns 0 if there are no more volumes, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Partition_getVolumesNext - (JNIEnv *env, jclass cls, jint iterationId, jobject jvolumeObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Partition_getVolumesNext(JNIEnv * env, jclass cls, + jint iterationId, + jobject jvolumeObject) { - afs_status_t ast; - jstring jvolume; - vos_volumeEntry_t volEntry; - - if ( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + afs_status_t ast; + jstring jvolume; + vos_volumeEntry_t volEntry; + + if (!vos_VolumeGetNext((void *)iterationId, &volEntry, &ast)) { + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } } - } - fillVolumeInfo( env, jvolumeObject, volEntry ); + fillVolumeInfo(env, jvolumeObject, volEntry); + + // get the class fields if need be + if (volumeCls == 0) { + internal_getVolumeClass(env, jvolumeObject); + } + (*env)->SetBooleanField(env, jvolumeObject, volume_cachedInfoField, TRUE); - // get the class fields if need be - if ( volumeCls == 0 ) { - internal_getVolumeClass( env, jvolumeObject ); - } - (*env)->SetBooleanField( env, jvolumeObject, volume_cachedInfoField, TRUE ); - - return 1; + return 1; } @@ -392,37 +404,38 @@ Java_org_openafs_jafs_Partition_getVolumesNext * advanceCount the number of volumes to advance past * returns 0 if there are no more volumes, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Partition_getVolumesAdvanceTo - (JNIEnv *env, jclass cls, jint iterationId, jobject jvolumeObject, - jint advanceCount) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Partition_getVolumesAdvanceTo(JNIEnv * env, jclass cls, + jint iterationId, + jobject jvolumeObject, + jint advanceCount) { - afs_status_t ast; - jstring jvolume; - vos_volumeEntry_t volEntry; - int i; - - for ( i = 0; i < advanceCount; i++) { - if ( !vos_VolumeGetNext( (void *) iterationId, &volEntry, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; - } + afs_status_t ast; + jstring jvolume; + vos_volumeEntry_t volEntry; + int i; + + for (i = 0; i < advanceCount; i++) { + if (!vos_VolumeGetNext((void *)iterationId, &volEntry, &ast)) { + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } + } } - } - fillVolumeInfo( env, jvolumeObject, volEntry ); + fillVolumeInfo(env, jvolumeObject, volEntry); + + // get the class fields if need be + if (volumeCls == 0) { + internal_getVolumeClass(env, jvolumeObject); + } + (*env)->SetBooleanField(env, jvolumeObject, volume_cachedInfoField, TRUE); - // get the class fields if need be - if ( volumeCls == 0 ) { - internal_getVolumeClass( env, jvolumeObject ); - } - (*env)->SetBooleanField( env, jvolumeObject, volume_cachedInfoField, TRUE ); - - return 1; + return 1; } /** @@ -432,25 +445,25 @@ Java_org_openafs_jafs_Partition_getVolumesAdvanceTo * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Partition_getVolumesDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Partition_getVolumesDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !vos_VolumeGetDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!vos_VolumeGetDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } // reclaim global memory being used by this portion JNIEXPORT void JNICALL -Java_org_openafs_jafs_Partition_reclaimPartitionMemory - (JNIEnv *env, jclass cls) +Java_org_openafs_jafs_Partition_reclaimPartitionMemory(JNIEnv * env, + jclass cls) { - if ( partitionCls ) { - (*env)->DeleteGlobalRef(env, partitionCls); - partitionCls = 0; - } + if (partitionCls) { + (*env)->DeleteGlobalRef(env, partitionCls); + partitionCls = 0; + } } diff --git a/src/JAVA/libjafs/Process.c b/src/JAVA/libjafs/Process.c index 3da7e6984..4d6b6a64d 100644 --- a/src/JAVA/libjafs/Process.c +++ b/src/JAVA/libjafs/Process.c @@ -26,7 +26,7 @@ ///// definitions in Internal.c //////////////////// -extern jclass processCls; +extern jclass processCls; extern jfieldID process_nameField; extern jfieldID process_typeField; extern jfieldID process_stateField; @@ -52,142 +52,142 @@ extern jfieldID process_stateBadFileAccessField; * processName the name of the process for which to get the info * process the Process object to populate with the info */ -void getProcessInfoChar - (JNIEnv *env, void *serverHandle, const char *processName, jobject process) +void +getProcessInfoChar(JNIEnv * env, void *serverHandle, const char *processName, + jobject process) { - afs_status_t ast; - bos_ProcessType_t type; - bos_ProcessInfo_t infoEntry; - bos_ProcessExecutionState_t state; - char *auxStatus; - - // get class fields if need be - if ( processCls == 0 ) { - internal_getProcessClass( env, process ); - } - - if ( !bos_ProcessInfoGet( serverHandle, processName, &type, - &infoEntry, &ast ) ) { - throwAFSException( env, ast ); - return; - } - - // set type variable - switch( type ) { - case BOS_PROCESS_SIMPLE : - (*env)->SetIntField(env, process, process_typeField, - org_openafs_jafs_Process_SIMPLE_PROCESS); - break; - case BOS_PROCESS_FS : - (*env)->SetIntField(env, process, process_typeField, - org_openafs_jafs_Process_FS_PROCESS); - break; - case BOS_PROCESS_CRON : - (*env)->SetIntField(env, process, process_typeField, - org_openafs_jafs_Process_CRON_PROCESS); - break; - default: - throwAFSException( env, type ); - return; - } - - // set goal variable - switch( infoEntry.processGoal ) { - case BOS_PROCESS_STOPPED : - (*env)->SetIntField(env, process, process_goalField, - org_openafs_jafs_Process_STOPPED); - break; - case BOS_PROCESS_RUNNING : - (*env)->SetIntField(env, process, process_goalField, - org_openafs_jafs_Process_RUNNING); - break; - case BOS_PROCESS_STOPPING : - (*env)->SetIntField(env, process, process_goalField, - org_openafs_jafs_Process_STOPPING); - break; - case BOS_PROCESS_STARTING : - (*env)->SetIntField(env, process, process_goalField, - org_openafs_jafs_Process_STARTING); - break; - default: - throwAFSException( env, infoEntry.processGoal ); - return; - } - - // set state variable - auxStatus = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); - if ( !auxStatus ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - if ( !bos_ProcessExecutionStateGet( (void *) serverHandle, processName, - &state, auxStatus, &ast ) ) { - free( auxStatus ); - throwAFSException( env, ast ); - return; - } - free( auxStatus ); - - switch( state ) { - case BOS_PROCESS_STOPPED : - (*env)->SetIntField(env, process, process_stateField, - org_openafs_jafs_Process_STOPPED); - break; - case BOS_PROCESS_RUNNING : - (*env)->SetIntField(env, process, process_stateField, - org_openafs_jafs_Process_RUNNING); - break; - case BOS_PROCESS_STOPPING : - (*env)->SetIntField(env, process, process_stateField, - org_openafs_jafs_Process_STOPPING); - break; - case BOS_PROCESS_STARTING : - (*env)->SetIntField(env, process, process_stateField, - org_openafs_jafs_Process_STARTING); - break; - default: - throwAFSException( env, state ); - return; - } - - // set longs - (*env)->SetLongField(env, process, process_startTimeField, - infoEntry.processStartTime ); - (*env)->SetLongField(env, process, process_numberStartsField, - infoEntry.numberProcessStarts ); - (*env)->SetLongField(env, process, process_exitTimeField, - infoEntry.processExitTime ); - (*env)->SetLongField(env, process, process_exitErrorTimeField, - infoEntry.processExitErrorTime ); - (*env)->SetLongField(env, process, process_errorCodeField, - infoEntry.processErrorCode ); - (*env)->SetLongField(env, process, process_errorSignalField, - infoEntry.processErrorSignal ); - - // set stateOk to true if no core dump - if ( infoEntry.state & BOS_PROCESS_CORE_DUMPED ) { - (*env)->SetBooleanField(env, process, process_stateOkField, FALSE ); - } else { - (*env)->SetBooleanField(env, process, process_stateOkField, TRUE ); - } - - // set stateTooManyErrors - if ( infoEntry.state & BOS_PROCESS_TOO_MANY_ERRORS ) { - (*env)->SetBooleanField(env, process, - process_stateTooManyErrorsField, TRUE ); - } else { - (*env)->SetBooleanField(env, process, - process_stateTooManyErrorsField, FALSE ); - } - - // set stateBadFileAccess - if ( infoEntry.state & BOS_PROCESS_BAD_FILE_ACCESS ) { - (*env)->SetBooleanField(env, process, - process_stateBadFileAccessField, TRUE ); - } else { - (*env)->SetBooleanField(env, process, - process_stateBadFileAccessField, FALSE ); - } + afs_status_t ast; + bos_ProcessType_t type; + bos_ProcessInfo_t infoEntry; + bos_ProcessExecutionState_t state; + char *auxStatus; + + // get class fields if need be + if (processCls == 0) { + internal_getProcessClass(env, process); + } + + if (!bos_ProcessInfoGet + (serverHandle, processName, &type, &infoEntry, &ast)) { + throwAFSException(env, ast); + return; + } + // set type variable + switch (type) { + case BOS_PROCESS_SIMPLE: + (*env)->SetIntField(env, process, process_typeField, + org_openafs_jafs_Process_SIMPLE_PROCESS); + break; + case BOS_PROCESS_FS: + (*env)->SetIntField(env, process, process_typeField, + org_openafs_jafs_Process_FS_PROCESS); + break; + case BOS_PROCESS_CRON: + (*env)->SetIntField(env, process, process_typeField, + org_openafs_jafs_Process_CRON_PROCESS); + break; + default: + throwAFSException(env, type); + return; + } + + // set goal variable + switch (infoEntry.processGoal) { + case BOS_PROCESS_STOPPED: + (*env)->SetIntField(env, process, process_goalField, + org_openafs_jafs_Process_STOPPED); + break; + case BOS_PROCESS_RUNNING: + (*env)->SetIntField(env, process, process_goalField, + org_openafs_jafs_Process_RUNNING); + break; + case BOS_PROCESS_STOPPING: + (*env)->SetIntField(env, process, process_goalField, + org_openafs_jafs_Process_STOPPING); + break; + case BOS_PROCESS_STARTING: + (*env)->SetIntField(env, process, process_goalField, + org_openafs_jafs_Process_STARTING); + break; + default: + throwAFSException(env, infoEntry.processGoal); + return; + } + + // set state variable + auxStatus = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN); + if (!auxStatus) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + if (!bos_ProcessExecutionStateGet + ((void *)serverHandle, processName, &state, auxStatus, &ast)) { + free(auxStatus); + throwAFSException(env, ast); + return; + } + free(auxStatus); + + switch (state) { + case BOS_PROCESS_STOPPED: + (*env)->SetIntField(env, process, process_stateField, + org_openafs_jafs_Process_STOPPED); + break; + case BOS_PROCESS_RUNNING: + (*env)->SetIntField(env, process, process_stateField, + org_openafs_jafs_Process_RUNNING); + break; + case BOS_PROCESS_STOPPING: + (*env)->SetIntField(env, process, process_stateField, + org_openafs_jafs_Process_STOPPING); + break; + case BOS_PROCESS_STARTING: + (*env)->SetIntField(env, process, process_stateField, + org_openafs_jafs_Process_STARTING); + break; + default: + throwAFSException(env, state); + return; + } + + // set longs + (*env)->SetLongField(env, process, process_startTimeField, + infoEntry.processStartTime); + (*env)->SetLongField(env, process, process_numberStartsField, + infoEntry.numberProcessStarts); + (*env)->SetLongField(env, process, process_exitTimeField, + infoEntry.processExitTime); + (*env)->SetLongField(env, process, process_exitErrorTimeField, + infoEntry.processExitErrorTime); + (*env)->SetLongField(env, process, process_errorCodeField, + infoEntry.processErrorCode); + (*env)->SetLongField(env, process, process_errorSignalField, + infoEntry.processErrorSignal); + + // set stateOk to true if no core dump + if (infoEntry.state & BOS_PROCESS_CORE_DUMPED) { + (*env)->SetBooleanField(env, process, process_stateOkField, FALSE); + } else { + (*env)->SetBooleanField(env, process, process_stateOkField, TRUE); + } + + // set stateTooManyErrors + if (infoEntry.state & BOS_PROCESS_TOO_MANY_ERRORS) { + (*env)->SetBooleanField(env, process, process_stateTooManyErrorsField, + TRUE); + } else { + (*env)->SetBooleanField(env, process, process_stateTooManyErrorsField, + FALSE); + } + + // set stateBadFileAccess + if (infoEntry.state & BOS_PROCESS_BAD_FILE_ACCESS) { + (*env)->SetBooleanField(env, process, process_stateBadFileAccessField, + TRUE); + } else { + (*env)->SetBooleanField(env, process, process_stateBadFileAccessField, + FALSE); + } } @@ -202,31 +202,32 @@ void getProcessInfoChar * process the Process object in which to fill * in the information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Process_getProcessInfo - (JNIEnv *env, jclass cls, jint serverHandle, jstring jname, jobject process) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Process_getProcessInfo(JNIEnv * env, jclass cls, + jint serverHandle, jstring jname, + jobject process) { - char *name; + char *name; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (name == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLPROCESS); + return; + } - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( name == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + getProcessInfoChar(env, (void *)serverHandle, name, process); + + // set name in case blank object + if (processCls == NULL) { + internal_getProcessClass(env, process); } - } else { - throwAFSException( env, JAFSNULLPROCESS ); - return; - } - - getProcessInfoChar( env, (void *) serverHandle, name, process ); - - // set name in case blank object - if ( processCls == NULL ) { - internal_getProcessClass( env, process ); - } - (*env)->SetObjectField(env, process, process_nameField, jname); - free( name ); + (*env)->SetObjectField(env, process, process_nameField, jname); + free(name); } /** @@ -254,92 +255,99 @@ Java_org_openafs_jafs_Process_getProcessInfo * be called when the process terminates. Can be * null */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Process_create - (JNIEnv *env, jclass cls, jint serverHandle, jstring jname, jint jtype, - jstring jpath, jstring jcronTime, jstring jnotifier) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Process_create(JNIEnv * env, jclass cls, + jint serverHandle, jstring jname, + jint jtype, jstring jpath, + jstring jcronTime, jstring jnotifier) { - afs_status_t ast; - bos_ProcessType_t type; - char *name; - char *path; - char *cronTime; - char *notifier; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( name == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + afs_status_t ast; + bos_ProcessType_t type; + char *name; + char *path; + char *cronTime; + char *notifier; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (name == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLPROCESS); + return; } - } else { - throwAFSException( env, JAFSNULLPROCESS ); - return; - } - - if ( jpath != NULL ) { - path = getNativeString(env, jpath); - if ( path == NULL ) { - free( name ); - throwAFSException( env, JAFSADMNOMEM ); - return; + + if (jpath != NULL) { + path = getNativeString(env, jpath); + if (path == NULL) { + free(name); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + path = NULL; } - } else { - path = NULL; - } - - switch( jtype ) { - case org_openafs_jafs_Process_SIMPLE_PROCESS: - type = BOS_PROCESS_SIMPLE; - break; - case org_openafs_jafs_Process_FS_PROCESS: - type = BOS_PROCESS_FS; - break; - case org_openafs_jafs_Process_CRON_PROCESS: - type = BOS_PROCESS_CRON; - break; - default: - free( name ); - if ( path != NULL ) free( path ); - throwAFSException( env, jtype ); - return; - } - - if ( jcronTime != NULL ) { - cronTime = getNativeString(env, jcronTime); - if ( !cronTime ) { - free( name ); - if ( path != NULL ) free( path ); - throwAFSException( env, JAFSADMNOMEM ); - return; + + switch (jtype) { + case org_openafs_jafs_Process_SIMPLE_PROCESS: + type = BOS_PROCESS_SIMPLE; + break; + case org_openafs_jafs_Process_FS_PROCESS: + type = BOS_PROCESS_FS; + break; + case org_openafs_jafs_Process_CRON_PROCESS: + type = BOS_PROCESS_CRON; + break; + default: + free(name); + if (path != NULL) + free(path); + throwAFSException(env, jtype); + return; } - } else { - cronTime = NULL; - } - - if ( jnotifier != NULL ) { - notifier = getNativeString(env, jnotifier); - if ( !notifier ) { - free( name ); - if ( path != NULL ) free( path ); - if ( cronTime != NULL ) free( cronTime ); - throwAFSException( env, JAFSADMNOMEM ); - return; + + if (jcronTime != NULL) { + cronTime = getNativeString(env, jcronTime); + if (!cronTime) { + free(name); + if (path != NULL) + free(path); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + cronTime = NULL; + } + + if (jnotifier != NULL) { + notifier = getNativeString(env, jnotifier); + if (!notifier) { + free(name); + if (path != NULL) + free(path); + if (cronTime != NULL) + free(cronTime); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + notifier = NULL; + } + + if (!bos_ProcessCreate + ((void *)serverHandle, name, type, path, cronTime, notifier, &ast)) { + throwAFSException(env, ast); } - } else { - notifier = NULL; - } - - if ( !bos_ProcessCreate( (void *) serverHandle, name, type, path, - cronTime, notifier, &ast ) ) { - throwAFSException( env, ast ); - } - - // release strings - free( name ); - if ( path != NULL ) free( path ); - if ( cronTime != NULL ) free( cronTime ); - if ( notifier != NULL ) free( notifier ); + // release strings + free(name); + if (path != NULL) + free(path); + if (cronTime != NULL) + free(cronTime); + if (notifier != NULL) + free(notifier); } /** @@ -351,29 +359,29 @@ Java_org_openafs_jafs_Process_create * belongs * jname the name of the process to remove */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Process_delete - (JNIEnv *env, jclass cls, jint serverHandle, jstring jname) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Process_delete(JNIEnv * env, jclass cls, + jint serverHandle, jstring jname) { - afs_status_t ast; - char *name; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( !name ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + afs_status_t ast; + char *name; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (!name) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLPROCESS); + return; } - } else { - throwAFSException( env, JAFSNULLPROCESS ); - return; - } - if ( !bos_ProcessDelete( (void *) serverHandle, name, &ast ) ) { - throwAFSException( env, ast ); - } + if (!bos_ProcessDelete((void *)serverHandle, name, &ast)) { + throwAFSException(env, ast); + } - free( name ); + free(name); } /** @@ -385,30 +393,30 @@ Java_org_openafs_jafs_Process_delete * belongs * jname the name of the process to stop */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Process_stop - (JNIEnv *env, jclass cls, jint serverHandle, jstring jname) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Process_stop(JNIEnv * env, jclass cls, + jint serverHandle, jstring jname) { - afs_status_t ast; - char *name; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( !name ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + afs_status_t ast; + char *name; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (!name) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLPROCESS); + return; } - } else { - throwAFSException( env, JAFSNULLPROCESS ); - return; - } - if ( !bos_ProcessExecutionStateSet( (void *) serverHandle, name, - BOS_PROCESS_STOPPED, &ast ) ) { - throwAFSException( env, ast ); - } + if (!bos_ProcessExecutionStateSet + ((void *)serverHandle, name, BOS_PROCESS_STOPPED, &ast)) { + throwAFSException(env, ast); + } - free( name ); + free(name); } /** @@ -420,30 +428,30 @@ Java_org_openafs_jafs_Process_stop * belongs * jname the name of the process to start */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Process_start - (JNIEnv *env, jclass cls, jint serverHandle, jstring jname) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Process_start(JNIEnv * env, jclass cls, + jint serverHandle, jstring jname) { - afs_status_t ast; - char *name; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( !name ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + afs_status_t ast; + char *name; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (!name) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLPROCESS); + return; } - } else { - throwAFSException( env, JAFSNULLPROCESS ); - return; - } - if ( !bos_ProcessExecutionStateSet( (void *) serverHandle, name, - BOS_PROCESS_RUNNING, &ast ) ) { - throwAFSException( env, ast ); - } + if (!bos_ProcessExecutionStateSet + ((void *)serverHandle, name, BOS_PROCESS_RUNNING, &ast)) { + throwAFSException(env, ast); + } - free( name ); + free(name); } /** @@ -455,38 +463,37 @@ Java_org_openafs_jafs_Process_start * belongs * jname the name of the process to restart */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Process_restart - (JNIEnv *env, jclass cls, jint serverHandle, jstring jname) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Process_restart(JNIEnv * env, jclass cls, + jint serverHandle, jstring jname) { - afs_status_t ast; - char *name; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( !name ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + afs_status_t ast; + char *name; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (!name) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLPROCESS); + return; } - } else { - throwAFSException( env, JAFSNULLPROCESS ); - return; - } - if ( !bos_ProcessRestart( (void *) serverHandle, name, &ast ) ) { - throwAFSException( env, ast ); - } + if (!bos_ProcessRestart((void *)serverHandle, name, &ast)) { + throwAFSException(env, ast); + } - free( name ); + free(name); } // reclaim global memory being used by this portion JNIEXPORT void JNICALL -Java_org_openafs_jafs_Process_reclaimProcessMemory - (JNIEnv *env, jclass cls) +Java_org_openafs_jafs_Process_reclaimProcessMemory(JNIEnv * env, jclass cls) { - if ( processCls ) { - (*env)->DeleteGlobalRef(env, processCls); - processCls = 0; - } + if (processCls) { + (*env)->DeleteGlobalRef(env, processCls); + processCls = 0; + } } diff --git a/src/JAVA/libjafs/Server.c b/src/JAVA/libjafs/Server.c index 24bb89427..70adce6dc 100644 --- a/src/JAVA/libjafs/Server.c +++ b/src/JAVA/libjafs/Server.c @@ -66,21 +66,21 @@ extern jfieldID user_cachedInfoField; ///// definition in jafs_Partition.c ///////////////// -extern void fillPartitionInfo( JNIEnv *env, jobject partition, - vos_partitionEntry_t partEntry ); +extern void fillPartitionInfo(JNIEnv * env, jobject partition, + vos_partitionEntry_t partEntry); /////////////////////////////////////////////////// ///// definition in jafs_Key.c ///////////////// -extern void fillKeyInfo( JNIEnv *env, jobject key, bos_KeyInfo_t keyEntry ); +extern void fillKeyInfo(JNIEnv * env, jobject key, bos_KeyInfo_t keyEntry); /////////////////////////////////////////////////// ///// definition in jafs_Process.c ///////////////// -extern void getProcessInfoChar( JNIEnv *env, void *serverHandle, - const char *processName, jobject process ); +extern void getProcessInfoChar(JNIEnv * env, void *serverHandle, + const char *processName, jobject process); /////////////////////////////////////////////////// @@ -93,90 +93,97 @@ extern void getProcessInfoChar( JNIEnv *env, void *serverHandle, * server the Server object to populate with the info * servEntry the container of the server's information */ -void fillServerInfo - ( JNIEnv *env, jint cellHandle, jobject server, afs_serverEntry_t servEntry ) +void +fillServerInfo(JNIEnv * env, jint cellHandle, jobject server, + afs_serverEntry_t servEntry) { - jstring jip; - jobjectArray jaddresses; - jstring jserver; - int i = 0; - - // get the class fields if need be - if ( serverCls == 0 ) { - internal_getServerClass( env, server ); - } - - // in case it's blank - jserver = (*env)->NewStringUTF(env, servEntry.serverName); - (*env)->SetObjectField(env, server, server_nameField, jserver); - - // let's convert just the addresses in the address array into an IP - jaddresses = (jobjectArray) (*env)->GetObjectField( env, server, - server_IPAddressField ); - for (i = 0; i < 16; i++) { - if (servEntry.serverAddress[i] != 0) { - jip = (*env)->NewStringUTF(env, (char *) - inet_ntoa(htonl(servEntry.serverAddress[i]))); - (*env)->SetObjectArrayElement(env, jaddresses, i, jip); + jstring jip; + jobjectArray jaddresses; + jstring jserver; + int i = 0; + + // get the class fields if need be + if (serverCls == 0) { + internal_getServerClass(env, server); + } + // in case it's blank + jserver = (*env)->NewStringUTF(env, servEntry.serverName); + (*env)->SetObjectField(env, server, server_nameField, jserver); + + // let's convert just the addresses in the address array into an IP + jaddresses = + (jobjectArray) (*env)->GetObjectField(env, server, + server_IPAddressField); + for (i = 0; i < 16; i++) { + if (servEntry.serverAddress[i] != 0) { + jip = (*env)->NewStringUTF(env, (char *) + inet_ntoa(htonl + (servEntry. + serverAddress[i]))); + (*env)->SetObjectArrayElement(env, jaddresses, i, jip); + } else { + break; + } + } + + // let's check if this is really a database server + (*env)->SetBooleanField(env, server, server_databaseField, + servEntry.serverType & DATABASE_SERVER); + if (servEntry.serverType & DATABASE_SERVER) { + // for now, if it thinks it's a database server than it is + // later, add checks for database configuration, and actual + // on-ness of the machine + (*env)->SetBooleanField(env, server, server_badDatabaseField, FALSE); } else { - break; - } - } - - // let's check if this is really a database server - (*env)->SetBooleanField(env, server, server_databaseField, - servEntry.serverType & DATABASE_SERVER); - if ( servEntry.serverType & DATABASE_SERVER ) { - // for now, if it thinks it's a database server than it is - // later, add checks for database configuration, and actual - // on-ness of the machine - (*env)->SetBooleanField(env, server, server_badDatabaseField, FALSE); - } else { - (*env)->SetBooleanField(env, server, server_badDatabaseField, FALSE); - } - - // we should check to see if this is truly a file server or not - // it could just be an old remnant, left over inside the vldb that - // should be removed. - // if it is a file server, mark it as such. If not, mark it as faulty. - (*env)->SetBooleanField(env, server, server_fileServerField, - servEntry.serverType & FILE_SERVER); - if ( servEntry.serverType & FILE_SERVER ) { - - // to see if it's really a file server, make sure the - // "fs" process is running - void *bosHandle; - afs_status_t ast; - bos_ProcessType_t processTypeT; - bos_ProcessInfo_t processInfoT; - char *fileServerProcessName = "fs"; - - // set the file server to true (it thinks it's a file server) - (*env)->SetBooleanField(env, server, server_fileServerField, TRUE); - - if ( !bos_ServerOpen( (void *) cellHandle, servEntry.serverName, - &bosHandle, &ast ) ) { - throwAFSException( env, ast ); - return; - } - if ( !bos_ProcessInfoGet( bosHandle, fileServerProcessName, &processTypeT, - &processInfoT, &ast ) ) { - // if the machine does not have a fs process or is not responding - // or is part of another cell - if ( ast == BZNOENT || ast == -1 || ast == RXKADBADTICKET ) { - (*env)->SetBooleanField(env, server, server_badFileServerField, TRUE); - // otherwise - } else { - throwAFSException( env, ast ); - return; - } + (*env)->SetBooleanField(env, server, server_badDatabaseField, FALSE); + } + + // we should check to see if this is truly a file server or not + // it could just be an old remnant, left over inside the vldb that + // should be removed. + // if it is a file server, mark it as such. If not, mark it as faulty. + (*env)->SetBooleanField(env, server, server_fileServerField, + servEntry.serverType & FILE_SERVER); + if (servEntry.serverType & FILE_SERVER) { + + // to see if it's really a file server, make sure the + // "fs" process is running + void *bosHandle; + afs_status_t ast; + bos_ProcessType_t processTypeT; + bos_ProcessInfo_t processInfoT; + char *fileServerProcessName = "fs"; + + // set the file server to true (it thinks it's a file server) + (*env)->SetBooleanField(env, server, server_fileServerField, TRUE); + + if (!bos_ServerOpen + ((void *)cellHandle, servEntry.serverName, &bosHandle, &ast)) { + throwAFSException(env, ast); + return; + } + if (!bos_ProcessInfoGet + (bosHandle, fileServerProcessName, &processTypeT, &processInfoT, + &ast)) { + // if the machine does not have a fs process or is not responding + // or is part of another cell + if (ast == BZNOENT || ast == -1 || ast == RXKADBADTICKET) { + (*env)->SetBooleanField(env, server, + server_badFileServerField, TRUE); + // otherwise + } else { + throwAFSException(env, ast); + return; + } + } else { + // it's good + (*env)->SetBooleanField(env, server, server_badFileServerField, + FALSE); + } } else { - // it's good - (*env)->SetBooleanField(env, server, server_badFileServerField, FALSE); + (*env)->SetBooleanField(env, server, server_badFileServerField, + FALSE); } - } else { - (*env)->SetBooleanField(env, server, server_badFileServerField, FALSE); - } } @@ -190,34 +197,34 @@ void fillServerInfo * server the Server object in which to fill in * the information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_getServerInfo - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname, jobject server) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_getServerInfo(JNIEnv * env, jclass cls, + jint cellHandle, jstring jname, + jobject server) { - char *name; - afs_status_t ast; - afs_serverEntry_t servEntry; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( name == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLSERVER ); - return; - } - - // get the server entry - if ( !afsclient_AFSServerGet( (void *) cellHandle, name, - &servEntry, &ast ) ) { - throwAFSException( env, ast ); - } - - fillServerInfo( env, cellHandle, server, servEntry ); - - free( name ); + char *name; + afs_status_t ast; + afs_serverEntry_t servEntry; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (name == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLSERVER); + return; + } + + // get the server entry + if (!afsclient_AFSServerGet((void *)cellHandle, name, &servEntry, &ast)) { + throwAFSException(env, ast); + } + + fillServerInfo(env, cellHandle, server, servEntry); + + free(name); } /** @@ -231,29 +238,32 @@ Java_org_openafs_jafs_Server_getServerInfo * partitions belong * returns total number of partitions */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getPartitionCount - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getPartitionCount(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle) { - afs_status_t ast; - void *iterationId; - vos_partitionEntry_t partEntry; - int i = 0; - - if ( !vos_PartitionGetBegin( (void *) cellHandle, (void *) serverHandle, - NULL, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + afs_status_t ast; + void *iterationId; + vos_partitionEntry_t partEntry; + int i = 0; + + if (!vos_PartitionGetBegin + ((void *)cellHandle, (void *)serverHandle, NULL, &iterationId, + &ast)) { + throwAFSException(env, ast); + return -1; + } - while ( vos_PartitionGetNext( (void *) iterationId, &partEntry, &ast ) ) i++; + while (vos_PartitionGetNext((void *)iterationId, &partEntry, &ast)) + i++; - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } /** @@ -268,20 +278,22 @@ Java_org_openafs_jafs_Server_getPartitionCount * partitions belong * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getPartitionsBegin - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getPartitionsBegin(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle) { - afs_status_t ast; - void *iterationId; + afs_status_t ast; + void *iterationId; - if ( !vos_PartitionGetBegin( (void *) cellHandle, (void *) serverHandle, - NULL, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!vos_PartitionGetBegin + ((void *)cellHandle, (void *)serverHandle, NULL, &iterationId, + &ast)) { + throwAFSException(env, ast); + return; + } - return (jint) iterationId; + return (jint) iterationId; } @@ -294,25 +306,25 @@ Java_org_openafs_jafs_Server_getPartitionsBegin * iterationId the iteration ID of this iteration * returns the name of the next partition of the server */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Server_getPartitionsNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Server_getPartitionsNextString(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; - jstring jpartition; - vos_partitionEntry_t partEntry; - - if ( !vos_PartitionGetNext( (void *) iterationId, &partEntry, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return; + afs_status_t ast; + jstring jpartition; + vos_partitionEntry_t partEntry; + + if (!vos_PartitionGetNext((void *)iterationId, &partEntry, &ast)) { + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return; + } } - } - jpartition = (*env)->NewStringUTF(env, partEntry.name); - return jpartition; + jpartition = (*env)->NewStringUTF(env, partEntry.name); + return jpartition; } @@ -327,33 +339,34 @@ Java_org_openafs_jafs_Server_getPartitionsNextString * values of the next partition * returns 0 if there are no more servers, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getPartitionsNext - (JNIEnv *env, jclass cls, jint iterationId, jobject jpartitionObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getPartitionsNext(JNIEnv * env, jclass cls, + jint iterationId, + jobject jpartitionObject) { - afs_status_t ast; - vos_partitionEntry_t partEntry; - - if ( !vos_PartitionGetNext( (void *) iterationId, &partEntry, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + afs_status_t ast; + vos_partitionEntry_t partEntry; + + if (!vos_PartitionGetNext((void *)iterationId, &partEntry, &ast)) { + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } } - } - fillPartitionInfo( env, jpartitionObject, partEntry ); + fillPartitionInfo(env, jpartitionObject, partEntry); + + // get the class fields if need be + if (partitionCls == 0) { + internal_getPartitionClass(env, jpartitionObject); + } + (*env)->SetBooleanField(env, jpartitionObject, partition_cachedInfoField, + TRUE); - // get the class fields if need be - if ( partitionCls == 0 ) { - internal_getPartitionClass( env, jpartitionObject ); - } - (*env)->SetBooleanField( env, jpartitionObject, partition_cachedInfoField, - TRUE ); - - return 1; + return 1; } @@ -364,16 +377,16 @@ Java_org_openafs_jafs_Server_getPartitionsNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_getPartitionsDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_getPartitionsDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !vos_PartitionGetDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!vos_PartitionGetDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } @@ -386,29 +399,29 @@ Java_org_openafs_jafs_Server_getPartitionsDone * partitions belong * jnewAdmin the name of the admin to add to the list */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_addBosAdmin - (JNIEnv *env, jclass cls, jint serverHandle, jstring jnewAdmin) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_addBosAdmin(JNIEnv * env, jclass cls, + jint serverHandle, jstring jnewAdmin) { - afs_status_t ast; - char *newAdmin; - - if ( jnewAdmin != NULL ) { - newAdmin = getNativeString(env, jnewAdmin); - if ( newAdmin == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + afs_status_t ast; + char *newAdmin; + + if (jnewAdmin != NULL) { + newAdmin = getNativeString(env, jnewAdmin); + if (newAdmin == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLUSER); + return; } - } else { - throwAFSException( env, JAFSNULLUSER ); - return; - } - if ( !bos_AdminCreate( (void *) serverHandle, newAdmin, &ast ) ) { - throwAFSException( env, ast ); - } + if (!bos_AdminCreate((void *)serverHandle, newAdmin, &ast)) { + throwAFSException(env, ast); + } - free( newAdmin ); + free(newAdmin); } @@ -422,29 +435,30 @@ Java_org_openafs_jafs_Server_addBosAdmin * partitions belong * joldAdmin the name of the admin to remove from the list */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_removeBosAdmin - (JNIEnv *env, jclass cls, jint serverHandle, jstring joldAdmin) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_removeBosAdmin(JNIEnv * env, jclass cls, + jint serverHandle, + jstring joldAdmin) { - afs_status_t ast; - char *oldAdmin; - - if ( joldAdmin != NULL ) { - oldAdmin = getNativeString(env, joldAdmin); - if ( oldAdmin == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + afs_status_t ast; + char *oldAdmin; + + if (joldAdmin != NULL) { + oldAdmin = getNativeString(env, joldAdmin); + if (oldAdmin == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLUSER); + return; } - } else { - throwAFSException( env, JAFSNULLUSER ); - return; - } - if ( !bos_AdminDelete( (void *) serverHandle, oldAdmin, &ast ) ) { - throwAFSException( env, ast ); - } + if (!bos_AdminDelete((void *)serverHandle, oldAdmin, &ast)) { + throwAFSException(env, ast); + } - free( oldAdmin ); + free(oldAdmin); } /** @@ -457,38 +471,39 @@ Java_org_openafs_jafs_Server_removeBosAdmin * BOS admins belong * returns total number of BOS administrators */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getBosAdminCount - (JNIEnv *env, jclass cls, jint serverHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getBosAdminCount(JNIEnv * env, jclass cls, + jint serverHandle) { - afs_status_t ast; - void *iterationId; - char *admin; - jstring jadmin; - int i = 0; - - if ( !bos_AdminGetBegin( (void *) serverHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + afs_status_t ast; + void *iterationId; + char *admin; + jstring jadmin; + int i = 0; + + if (!bos_AdminGetBegin((void *)serverHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - admin = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN); + admin = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN); - if ( !admin ) { - throwAFSException( env, JAFSADMNOMEM ); - return -1; - } + if (!admin) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } - while ( bos_AdminGetNext( (void *) iterationId, admin, &ast ) ) i++; + while (bos_AdminGetNext((void *)iterationId, admin, &ast)) + i++; - free( admin ); + free(admin); - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } /** @@ -502,19 +517,19 @@ Java_org_openafs_jafs_Server_getBosAdminCount * partitions belong * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getBosAdminsBegin - (JNIEnv *env, jclass cls, jint serverHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getBosAdminsBegin(JNIEnv * env, jclass cls, + jint serverHandle) { - afs_status_t ast; - void *iterationId; + afs_status_t ast; + void *iterationId; - if ( !bos_AdminGetBegin( (void *) serverHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_AdminGetBegin((void *)serverHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return; + } - return (jint) iterationId; + return (jint) iterationId; } /** @@ -526,32 +541,33 @@ Java_org_openafs_jafs_Server_getBosAdminsBegin * iterationId the iteration ID of this iteration * returns the name of the next admin of the server */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Server_getBosAdminsNextString - (JNIEnv *env, jclass cls, jint iterationId) { - - afs_status_t ast; - jstring jadmin; - char *admin = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); - - if ( !admin ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( !bos_AdminGetNext( (void *) iterationId, admin, &ast ) ) { - free( admin ); - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return; +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Server_getBosAdminsNextString(JNIEnv * env, jclass cls, + jint iterationId) +{ + + afs_status_t ast; + jstring jadmin; + char *admin = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN); + + if (!admin) { + throwAFSException(env, JAFSADMNOMEM); + return; } - } - jadmin = (*env)->NewStringUTF(env, admin); - free( admin ); - return jadmin; + if (!bos_AdminGetNext((void *)iterationId, admin, &ast)) { + free(admin); + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return; + } + } + + jadmin = (*env)->NewStringUTF(env, admin); + free(admin); + return jadmin; } @@ -566,45 +582,46 @@ Java_org_openafs_jafs_Server_getBosAdminsNextString * juserObject the user object in which to fill the values of this admin * returns 0 if no more admins, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getBosAdminsNext - (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId, - jobject juserObject ) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getBosAdminsNext(JNIEnv * env, jclass cls, + jint cellHandle, + jint iterationId, + jobject juserObject) { - afs_status_t ast; - char *admin; - jstring jadmin; + afs_status_t ast; + char *admin; + jstring jadmin; - admin = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN); + admin = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN); - if ( !admin ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } + if (!admin) { + throwAFSException(env, JAFSADMNOMEM); + return; + } - if ( !bos_AdminGetNext( (void *) iterationId, admin, &ast ) ) { - free( admin ); - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + if (!bos_AdminGetNext((void *)iterationId, admin, &ast)) { + free(admin); + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } } - } - jadmin = (*env)->NewStringUTF(env, admin); + jadmin = (*env)->NewStringUTF(env, admin); - if ( userCls == 0 ) { - internal_getUserClass( env, juserObject ); - } + if (userCls == 0) { + internal_getUserClass(env, juserObject); + } - (*env)->SetObjectField(env, juserObject, user_nameField, jadmin); + (*env)->SetObjectField(env, juserObject, user_nameField, jadmin); - getUserInfoChar( env, cellHandle, admin, juserObject ); - (*env)->SetBooleanField( env, juserObject, user_cachedInfoField, TRUE ); + getUserInfoChar(env, cellHandle, admin, juserObject); + (*env)->SetBooleanField(env, juserObject, user_cachedInfoField, TRUE); - free( admin ); - return 1; + free(admin); + return 1; } @@ -615,16 +632,16 @@ Java_org_openafs_jafs_Server_getBosAdminsNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_getBosAdminsDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_getBosAdminsDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !bos_AdminGetDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_AdminGetDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -637,28 +654,29 @@ Java_org_openafs_jafs_Server_getBosAdminsDone * keys belong * returns total number of keys */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getKeyCount - (JNIEnv *env, jclass cls, jint serverHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getKeyCount(JNIEnv * env, jclass cls, + jint serverHandle) { - afs_status_t ast; - void *iterationId; - bos_KeyInfo_t keyEntry; - int i = 0; + afs_status_t ast; + void *iterationId; + bos_KeyInfo_t keyEntry; + int i = 0; - if ( !bos_KeyGetBegin( (void *) serverHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + if (!bos_KeyGetBegin((void *)serverHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - while ( bos_KeyGetNext( (void *) iterationId, &keyEntry, &ast ) ) i++; + while (bos_KeyGetNext((void *)iterationId, &keyEntry, &ast)) + i++; - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } /** @@ -671,19 +689,19 @@ Java_org_openafs_jafs_Server_getKeyCount * serverHandle the bos handle of the server to which the keys belong * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getKeysBegin - (JNIEnv *env, jclass cls, jint serverHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getKeysBegin(JNIEnv * env, jclass cls, + jint serverHandle) { - afs_status_t ast; - void *iterationId; + afs_status_t ast; + void *iterationId; - if ( !bos_KeyGetBegin( (void *) serverHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_KeyGetBegin((void *)serverHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return; + } - return (jint) iterationId; + return (jint) iterationId; } /** @@ -697,33 +715,33 @@ Java_org_openafs_jafs_Server_getKeysBegin * properties of the next key. * returns 0 if there are no more keys, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getKeysNext - (JNIEnv *env, jclass cls, jint iterationId, jobject jkeyObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getKeysNext(JNIEnv * env, jclass cls, + jint iterationId, jobject jkeyObject) { - - afs_status_t ast; - bos_KeyInfo_t keyEntry; - if ( !bos_KeyGetNext( (void *) iterationId, &keyEntry, &ast ) ) { - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + afs_status_t ast; + bos_KeyInfo_t keyEntry; + + if (!bos_KeyGetNext((void *)iterationId, &keyEntry, &ast)) { + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } } - } - fillKeyInfo( env, jkeyObject, keyEntry ); + fillKeyInfo(env, jkeyObject, keyEntry); - // get the class fields if need be - if ( keyCls == 0 ) { - internal_getKeyClass( env, jkeyObject ); - } + // get the class fields if need be + if (keyCls == 0) { + internal_getKeyClass(env, jkeyObject); + } - (*env)->SetBooleanField( env, jkeyObject, key_cachedInfoField, TRUE ); + (*env)->SetBooleanField(env, jkeyObject, key_cachedInfoField, TRUE); - return 1; + return 1; } /** @@ -733,16 +751,16 @@ Java_org_openafs_jafs_Server_getKeysNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_getKeysDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_getKeysDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !bos_KeyGetDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_KeyGetDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -755,38 +773,39 @@ Java_org_openafs_jafs_Server_getKeysDone * processes belong * returns total number of processes */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getProcessCount - (JNIEnv *env, jclass cls, jint serverHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getProcessCount(JNIEnv * env, jclass cls, + jint serverHandle) { - afs_status_t ast; - void *iterationId; - char *process; - jstring jprocess; - int i = 0; - - if ( !bos_ProcessNameGetBegin( (void *) serverHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return -1; - } + afs_status_t ast; + void *iterationId; + char *process; + jstring jprocess; + int i = 0; + + if (!bos_ProcessNameGetBegin((void *)serverHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return -1; + } - process = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); + process = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN); - if ( !process ) { - throwAFSException( env, JAFSADMNOMEM ); - return -1; - } + if (!process) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } - while ( bos_ProcessNameGetNext( (void *) iterationId, process, &ast ) ) i++; + while (bos_ProcessNameGetNext((void *)iterationId, process, &ast)) + i++; - free( process ); + free(process); - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } /** @@ -800,19 +819,19 @@ Java_org_openafs_jafs_Server_getProcessCount * processes belong * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getProcessesBegin - (JNIEnv *env, jclass cls, jint serverHandle) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getProcessesBegin(JNIEnv * env, jclass cls, + jint serverHandle) { - afs_status_t ast; - void *iterationId; + afs_status_t ast; + void *iterationId; - if ( !bos_ProcessNameGetBegin( (void *) serverHandle, &iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_ProcessNameGetBegin((void *)serverHandle, &iterationId, &ast)) { + throwAFSException(env, ast); + return; + } - return (jint) iterationId; + return (jint) iterationId; } /** @@ -824,32 +843,32 @@ Java_org_openafs_jafs_Server_getProcessesBegin * iterationId the iteration ID of this iteration * returns the name of the next process of the cell */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Server_getProcessesNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Server_getProcessesNextString(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; - jstring jprocess; - char *process = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); - - if ( !process ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( !bos_ProcessNameGetNext( (void *) iterationId, process, &ast ) ) { - free( process ); - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return; + afs_status_t ast; + jstring jprocess; + char *process = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN); + + if (!process) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + + if (!bos_ProcessNameGetNext((void *)iterationId, process, &ast)) { + free(process); + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return; + } } - } - jprocess = (*env)->NewStringUTF(env, process); - free( process ); - return jprocess; + jprocess = (*env)->NewStringUTF(env, process); + free(process); + return jprocess; } /** @@ -864,45 +883,45 @@ Java_org_openafs_jafs_Server_getProcessesNextString * values of the next process * returns 0 if there are no more processes, != otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Server_getProcessesNext - (JNIEnv *env, jclass cls, jint serverHandle, jint iterationId, - jobject jprocessObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Server_getProcessesNext(JNIEnv * env, jclass cls, + jint serverHandle, + jint iterationId, + jobject jprocessObject) { - afs_status_t ast; - char *process = (char *) malloc( sizeof(char)*BOS_MAX_NAME_LEN ); - jstring jprocess; - - if ( !process ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( !bos_ProcessNameGetNext( (void *) iterationId, process, &ast ) ) { - free( process ); - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + afs_status_t ast; + char *process = (char *)malloc(sizeof(char) * BOS_MAX_NAME_LEN); + jstring jprocess; + + if (!process) { + throwAFSException(env, JAFSADMNOMEM); + return; } - } - // get the class fields if need be - if ( processCls == 0 ) { - internal_getProcessClass( env, jprocessObject ); - } + if (!bos_ProcessNameGetNext((void *)iterationId, process, &ast)) { + free(process); + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } + } + // get the class fields if need be + if (processCls == 0) { + internal_getProcessClass(env, jprocessObject); + } - jprocess = (*env)->NewStringUTF(env, process); - (*env)->SetObjectField(env, jprocessObject, process_nameField, jprocess); + jprocess = (*env)->NewStringUTF(env, process); + (*env)->SetObjectField(env, jprocessObject, process_nameField, jprocess); - getProcessInfoChar( env, (void *) serverHandle, process, jprocessObject ); + getProcessInfoChar(env, (void *)serverHandle, process, jprocessObject); - (*env)->SetBooleanField( env, jprocessObject, - process_cachedInfoField, TRUE ); + (*env)->SetBooleanField(env, jprocessObject, process_cachedInfoField, + TRUE); - free( process ); - return 1; + free(process); + return 1; } /** @@ -912,16 +931,16 @@ Java_org_openafs_jafs_Server_getProcessesNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_getProcessesDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_getProcessesDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !bos_ProcessNameGetDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_ProcessNameGetDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -956,126 +975,132 @@ Java_org_openafs_jafs_Server_getProcessesDone * one block at a time and skip badly damaged * blocks. Use if partition has disk errors */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_salvage - (JNIEnv *env, jclass cls, - jint cellHandle, - jint serverHandle, - jstring jpartName, - jstring jvolName, - jint numSalvagers, - jstring jtempDir, - jstring jlogFile, - jboolean inspectAllVolumes, - jboolean removeBadlyDamaged, - jboolean writeInodes, - jboolean writeRootInodes, - jboolean forceDirectory, - jboolean forceBlockReads) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_salvage(JNIEnv * env, jclass cls, + jint cellHandle, jint serverHandle, + jstring jpartName, jstring jvolName, + jint numSalvagers, jstring jtempDir, + jstring jlogFile, + jboolean inspectAllVolumes, + jboolean removeBadlyDamaged, + jboolean writeInodes, + jboolean writeRootInodes, + jboolean forceDirectory, + jboolean forceBlockReads) { - afs_status_t ast; - char *partName; - char *volName; - char *tempDir; - char *logFile; - vos_force_t force; - bos_SalvageDamagedVolumes_t sdv; - bos_WriteInodes_t wi; - bos_WriteRootInodes_t wri; - bos_ForceDirectory_t forceD; - bos_ForceBlockRead_t forceBR; - - // convert strings - if ( jpartName != NULL ) { - partName = getNativeString(env, jpartName); - if ( !partName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - partName = NULL; - } - - if ( jvolName != NULL ) { - volName = getNativeString(env, jvolName); - if ( !volName ) { - if ( partName != NULL ) free( partName ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - volName = NULL; - } - - if ( jtempDir != NULL ) { - tempDir = getNativeString(env, jtempDir); - if ( !tempDir ) { - if ( partName != NULL ) free( partName ); - if ( volName != NULL ) free( volName ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - tempDir = NULL; - } - - if ( jlogFile != NULL ) { - logFile = getNativeString(env, jlogFile); - if ( !logFile ) { - if ( partName != NULL ) free( partName ); - if ( volName != NULL ) free( volName ); - if ( tempDir != NULL ) free( tempDir ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - logFile = NULL; - } - - // deal with booleans - if ( inspectAllVolumes ) { - force = VOS_FORCE; - } else { - force = VOS_NORMAL; - } - if ( removeBadlyDamaged ) { - sdv = BOS_DONT_SALVAGE_DAMAGED_VOLUMES; - } else { - sdv = BOS_SALVAGE_DAMAGED_VOLUMES; - } - if ( writeInodes ) { - wi = BOS_SALVAGE_WRITE_INODES; - } else { - wi = BOS_SALVAGE_DONT_WRITE_INODES; - } - if ( writeRootInodes ) { - wri = BOS_SALVAGE_WRITE_ROOT_INODES; - } else { - wri = BOS_SALVAGE_DONT_WRITE_ROOT_INODES; - } - if ( forceDirectory ) { - forceD = BOS_SALVAGE_FORCE_DIRECTORIES; - } else { - forceD = BOS_SALVAGE_DONT_FORCE_DIRECTORIES; - } - if ( forceBlockReads ) { - forceBR = BOS_SALVAGE_FORCE_BLOCK_READS; - } else { - forceBR = BOS_SALVAGE_DONT_FORCE_BLOCK_READS; - } - - //salvage! - if ( !bos_Salvage( (void *) cellHandle, (void *) serverHandle, partName, - volName, (int) numSalvagers, tempDir, logFile, force, sdv, - wi, wri, forceD, forceBR, &ast ) ) { - throwAFSException( env, ast ); - } - - // release strings - if ( partName != NULL ) free( partName ); - if ( volName != NULL ) free( volName ); - if ( tempDir != NULL ) free( tempDir ); - if ( logFile != NULL ) free( logFile ); + afs_status_t ast; + char *partName; + char *volName; + char *tempDir; + char *logFile; + vos_force_t force; + bos_SalvageDamagedVolumes_t sdv; + bos_WriteInodes_t wi; + bos_WriteRootInodes_t wri; + bos_ForceDirectory_t forceD; + bos_ForceBlockRead_t forceBR; + + // convert strings + if (jpartName != NULL) { + partName = getNativeString(env, jpartName); + if (!partName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + partName = NULL; + } + + if (jvolName != NULL) { + volName = getNativeString(env, jvolName); + if (!volName) { + if (partName != NULL) + free(partName); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + volName = NULL; + } + + if (jtempDir != NULL) { + tempDir = getNativeString(env, jtempDir); + if (!tempDir) { + if (partName != NULL) + free(partName); + if (volName != NULL) + free(volName); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + tempDir = NULL; + } + + if (jlogFile != NULL) { + logFile = getNativeString(env, jlogFile); + if (!logFile) { + if (partName != NULL) + free(partName); + if (volName != NULL) + free(volName); + if (tempDir != NULL) + free(tempDir); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + logFile = NULL; + } + + // deal with booleans + if (inspectAllVolumes) { + force = VOS_FORCE; + } else { + force = VOS_NORMAL; + } + if (removeBadlyDamaged) { + sdv = BOS_DONT_SALVAGE_DAMAGED_VOLUMES; + } else { + sdv = BOS_SALVAGE_DAMAGED_VOLUMES; + } + if (writeInodes) { + wi = BOS_SALVAGE_WRITE_INODES; + } else { + wi = BOS_SALVAGE_DONT_WRITE_INODES; + } + if (writeRootInodes) { + wri = BOS_SALVAGE_WRITE_ROOT_INODES; + } else { + wri = BOS_SALVAGE_DONT_WRITE_ROOT_INODES; + } + if (forceDirectory) { + forceD = BOS_SALVAGE_FORCE_DIRECTORIES; + } else { + forceD = BOS_SALVAGE_DONT_FORCE_DIRECTORIES; + } + if (forceBlockReads) { + forceBR = BOS_SALVAGE_FORCE_BLOCK_READS; + } else { + forceBR = BOS_SALVAGE_DONT_FORCE_BLOCK_READS; + } + + //salvage! + if (!bos_Salvage + ((void *)cellHandle, (void *)serverHandle, partName, volName, + (int)numSalvagers, tempDir, logFile, force, sdv, wi, wri, forceD, + forceBR, &ast)) { + throwAFSException(env, ast); + } + // release strings + if (partName != NULL) + free(partName); + if (volName != NULL) + free(volName); + if (tempDir != NULL) + free(tempDir); + if (logFile != NULL) + free(logFile); } @@ -1093,67 +1118,67 @@ Java_org_openafs_jafs_Server_salvage * execTime the ExecutableTime object, in which * to fill the restart time fields */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_getRestartTime - (JNIEnv *env, jclass cls, jint serverHandle, jint jtype, jobject exectime) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_getRestartTime(JNIEnv * env, jclass cls, + jint serverHandle, jint jtype, + jobject exectime) { - afs_status_t ast; - bos_Restart_t type; - bos_RestartTime_t time; - jfieldID hourField; - jfieldID minField; - jfieldID secField; - jfieldID dayField; - jfieldID neverField; - jfieldID nowField; - - // get the class fields if need be - if ( exectimeCls == 0 ) { - internal_getExecTimeClass( env, exectime ); - } - - if ( jtype == org_openafs_jafs_Server_RESTART_BINARY ) { - type = BOS_RESTART_DAILY; - } else { - type = BOS_RESTART_WEEKLY; - } - - hourField = exectime_HourField; - minField = exectime_MinField; - secField = exectime_SecField; - dayField = exectime_DayField; - neverField = exectime_NeverField; - nowField = exectime_NowField; - - if ( !bos_ExecutableRestartTimeGet( (void *) serverHandle, type, - &time, &ast ) ) { - throwAFSException( env, ast ); - return; - } - - // set now - (*env)->SetBooleanField(env, exectime, nowField, - (time.mask & BOS_RESTART_TIME_NOW) ); - - // set never - (*env)->SetBooleanField(env, exectime, neverField, - (time.mask & BOS_RESTART_TIME_NEVER) ); - - // set hour - (*env)->SetShortField(env, exectime, hourField, time.hour ); - - // set minute - (*env)->SetShortField(env, exectime, minField, time.min ); - - // set second - (*env)->SetShortField(env, exectime, secField, time.sec ); - - // set day - if ( time.mask & BOS_RESTART_TIME_DAY ) { - (*env)->SetShortField(env, exectime, dayField, time.day ); - } else { - (*env)->SetShortField(env, exectime, dayField, (jshort) -1 ); - } + afs_status_t ast; + bos_Restart_t type; + bos_RestartTime_t time; + jfieldID hourField; + jfieldID minField; + jfieldID secField; + jfieldID dayField; + jfieldID neverField; + jfieldID nowField; + + // get the class fields if need be + if (exectimeCls == 0) { + internal_getExecTimeClass(env, exectime); + } + + if (jtype == org_openafs_jafs_Server_RESTART_BINARY) { + type = BOS_RESTART_DAILY; + } else { + type = BOS_RESTART_WEEKLY; + } + + hourField = exectime_HourField; + minField = exectime_MinField; + secField = exectime_SecField; + dayField = exectime_DayField; + neverField = exectime_NeverField; + nowField = exectime_NowField; + + if (!bos_ExecutableRestartTimeGet + ((void *)serverHandle, type, &time, &ast)) { + throwAFSException(env, ast); + return; + } + // set now + (*env)->SetBooleanField(env, exectime, nowField, + (time.mask & BOS_RESTART_TIME_NOW)); + + // set never + (*env)->SetBooleanField(env, exectime, neverField, + (time.mask & BOS_RESTART_TIME_NEVER)); + + // set hour + (*env)->SetShortField(env, exectime, hourField, time.hour); + + // set minute + (*env)->SetShortField(env, exectime, minField, time.min); + + // set second + (*env)->SetShortField(env, exectime, secField, time.sec); + + // set day + if (time.mask & BOS_RESTART_TIME_DAY) { + (*env)->SetShortField(env, exectime, dayField, time.day); + } else { + (*env)->SetShortField(env, exectime, dayField, (jshort) - 1); + } } @@ -1170,111 +1195,111 @@ Java_org_openafs_jafs_Server_getRestartTime * executableTime the ExecutableTime object containing the * desired information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_setRestartTime - (JNIEnv *env, jclass cls, jint serverHandle, jint jtype, jobject exectime ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_setRestartTime(JNIEnv * env, jclass cls, + jint serverHandle, jint jtype, + jobject exectime) { - afs_status_t ast; - bos_Restart_t type; - bos_RestartTime_t time; - jboolean doHour; - jboolean doMinute; - jboolean doSecond; - jboolean doDay; - jboolean doNever; - jboolean doNow; - jshort hour; - jshort minute; - jshort second; - jshort day; - jfieldID hourField; - jfieldID minField; - jfieldID secField; - jfieldID dayField; - jfieldID neverField; - jfieldID nowField; - - // get the class fields if need be - if ( exectimeCls == 0 ) { - internal_getExecTimeClass( env, exectime ); - } - - if ( jtype == org_openafs_jafs_Server_RESTART_BINARY ) { - type = BOS_RESTART_DAILY; - } else { - type = BOS_RESTART_WEEKLY; - } - - hourField = exectime_HourField; - minField = exectime_MinField; - secField = exectime_SecField; - dayField = exectime_DayField; - neverField = exectime_NeverField; - nowField = exectime_NowField; - - hour = (*env)->GetShortField(env, exectime, hourField ); - if ( hour != 0 ) { - doHour = TRUE; - } else { - doHour = FALSE; - } - minute = (*env)->GetShortField(env, exectime, minField ); - if ( minute != 0 ) { - doMinute = TRUE; - } else { - doMinute = FALSE; - } - second = (*env)->GetShortField(env, exectime, secField ); - if ( second != 0 ) { - doSecond = TRUE; - } else { - doSecond = FALSE; - } - day = (*env)->GetShortField(env, exectime, dayField ); - if ( day != -1 ) { - doDay = TRUE; - } else { - doDay = FALSE; - } - doNever = (*env)->GetBooleanField(env, exectime, neverField ); - doNow = (*env)->GetBooleanField(env, exectime, nowField ); - - bzero(&time, sizeof(time)); - - if ( jtype == org_openafs_jafs_Server_RESTART_BINARY ) { - type = BOS_RESTART_DAILY; - } else { - type = BOS_RESTART_WEEKLY; - } - - if ( doHour ) { - time.mask |= BOS_RESTART_TIME_HOUR; - } - if ( doMinute ) { - time.mask |= BOS_RESTART_TIME_MINUTE; - } - if ( doSecond ) { - time.mask |= BOS_RESTART_TIME_SECOND; - } - if ( doDay ) { - time.mask |= BOS_RESTART_TIME_DAY; - } - if ( doNever ) { - time.mask |= BOS_RESTART_TIME_NEVER; - } - if ( doNow ) { - time.mask |= BOS_RESTART_TIME_NOW; - } - - time.hour = hour; - time.min = minute; - time.sec = second; - time.day = day; - - if ( !bos_ExecutableRestartTimeSet( (void *) serverHandle, type, - time, &ast ) ) { - throwAFSException( env, ast ); - } + afs_status_t ast; + bos_Restart_t type; + bos_RestartTime_t time; + jboolean doHour; + jboolean doMinute; + jboolean doSecond; + jboolean doDay; + jboolean doNever; + jboolean doNow; + jshort hour; + jshort minute; + jshort second; + jshort day; + jfieldID hourField; + jfieldID minField; + jfieldID secField; + jfieldID dayField; + jfieldID neverField; + jfieldID nowField; + + // get the class fields if need be + if (exectimeCls == 0) { + internal_getExecTimeClass(env, exectime); + } + + if (jtype == org_openafs_jafs_Server_RESTART_BINARY) { + type = BOS_RESTART_DAILY; + } else { + type = BOS_RESTART_WEEKLY; + } + + hourField = exectime_HourField; + minField = exectime_MinField; + secField = exectime_SecField; + dayField = exectime_DayField; + neverField = exectime_NeverField; + nowField = exectime_NowField; + + hour = (*env)->GetShortField(env, exectime, hourField); + if (hour != 0) { + doHour = TRUE; + } else { + doHour = FALSE; + } + minute = (*env)->GetShortField(env, exectime, minField); + if (minute != 0) { + doMinute = TRUE; + } else { + doMinute = FALSE; + } + second = (*env)->GetShortField(env, exectime, secField); + if (second != 0) { + doSecond = TRUE; + } else { + doSecond = FALSE; + } + day = (*env)->GetShortField(env, exectime, dayField); + if (day != -1) { + doDay = TRUE; + } else { + doDay = FALSE; + } + doNever = (*env)->GetBooleanField(env, exectime, neverField); + doNow = (*env)->GetBooleanField(env, exectime, nowField); + + bzero(&time, sizeof(time)); + + if (jtype == org_openafs_jafs_Server_RESTART_BINARY) { + type = BOS_RESTART_DAILY; + } else { + type = BOS_RESTART_WEEKLY; + } + + if (doHour) { + time.mask |= BOS_RESTART_TIME_HOUR; + } + if (doMinute) { + time.mask |= BOS_RESTART_TIME_MINUTE; + } + if (doSecond) { + time.mask |= BOS_RESTART_TIME_SECOND; + } + if (doDay) { + time.mask |= BOS_RESTART_TIME_DAY; + } + if (doNever) { + time.mask |= BOS_RESTART_TIME_NEVER; + } + if (doNow) { + time.mask |= BOS_RESTART_TIME_NOW; + } + + time.hour = hour; + time.min = minute; + time.sec = second; + time.day = day; + + if (!bos_ExecutableRestartTimeSet((void *)serverHandle, type, time, &ast)) { + throwAFSException(env, ast); + } } /** @@ -1286,23 +1311,25 @@ Java_org_openafs_jafs_Server_setRestartTime * serverHandle the vos handle of the server * partition the id of the partition to sync, can be -1 to ignore */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_syncServerWithVLDB - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_syncServerWithVLDB(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle, + jint partition) { - afs_status_t ast; - int *part; - - if ( partition == -1 ) { - part = NULL; - } else { - part = (int *) &partition; - } - - if ( !vos_ServerSync( (void *) cellHandle, (void *) serverHandle, - NULL, part, &ast ) ) { - throwAFSException( env, ast ); - } + afs_status_t ast; + int *part; + + if (partition == -1) { + part = NULL; + } else { + part = (int *)&partition; + } + + if (!vos_ServerSync + ((void *)cellHandle, (void *)serverHandle, NULL, part, &ast)) { + throwAFSException(env, ast); + } } /** @@ -1315,31 +1342,33 @@ Java_org_openafs_jafs_Server_syncServerWithVLDB * partition the id of the partition to sync, can be -1 to ignore * forceDeletion whether or not to force the deletion of bad volumes */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_syncVLDBWithServer - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition, - jboolean forceDeletion) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_syncVLDBWithServer(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle, + jint partition, + jboolean forceDeletion) { - afs_status_t ast; - int *part; - vos_force_t force; - - if ( partition == -1 ) { - part = NULL; - } else { - part = (int *) &partition; - } - - if ( forceDeletion ) { - force = VOS_FORCE; - } else { - force = VOS_NORMAL; - } - - if ( !vos_VLDBSync( (void *) cellHandle, (void *) serverHandle, NULL, part, - force, &ast ) ) { - throwAFSException( env, ast ); - } + afs_status_t ast; + int *part; + vos_force_t force; + + if (partition == -1) { + part = NULL; + } else { + part = (int *)&partition; + } + + if (forceDeletion) { + force = VOS_FORCE; + } else { + force = VOS_NORMAL; + } + + if (!vos_VLDBSync + ((void *)cellHandle, (void *)serverHandle, NULL, part, force, &ast)) { + throwAFSException(env, ast); + } } /** @@ -1350,16 +1379,16 @@ Java_org_openafs_jafs_Server_syncVLDBWithServer * serverHandle the bos handle of the server to which the * processes belong */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_startAllProcesses - (JNIEnv *env, jclass cls, jint serverHandle) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_startAllProcesses(JNIEnv * env, jclass cls, + jint serverHandle) { - afs_status_t ast; + afs_status_t ast; - if ( !bos_ProcessAllStart( (void *) serverHandle, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_ProcessAllStart((void *)serverHandle, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -1370,16 +1399,16 @@ Java_org_openafs_jafs_Server_startAllProcesses * serverHandle the bos handle of the server to which the * processes belong */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_stopAllProcesses - (JNIEnv *env, jclass cls, jint serverHandle) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_stopAllProcesses(JNIEnv * env, jclass cls, + jint serverHandle) { - afs_status_t ast; + afs_status_t ast; - if ( !bos_ProcessAllStop( (void *) serverHandle, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!bos_ProcessAllStop((void *)serverHandle, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -1391,23 +1420,24 @@ Java_org_openafs_jafs_Server_stopAllProcesses * processes belong * restartBosServer whether or not to restart the bos server as well */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_restartAllProcesses - (JNIEnv *env, jclass cls, jint serverHandle, jboolean restartBosServer) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_restartAllProcesses(JNIEnv * env, jclass cls, + jint serverHandle, + jboolean restartBosServer) { - afs_status_t ast; - bos_RestartBosServer_t rbs; - - if ( restartBosServer ) { - rbs = BOS_RESTART_BOS_SERVER; - } else { - rbs = BOS_DONT_RESTART_BOS_SERVER; - } - - if ( !bos_ProcessAllStopAndRestart( (void *) serverHandle, rbs, &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + bos_RestartBosServer_t rbs; + + if (restartBosServer) { + rbs = BOS_RESTART_BOS_SERVER; + } else { + rbs = BOS_DONT_RESTART_BOS_SERVER; + } + + if (!bos_ProcessAllStopAndRestart((void *)serverHandle, rbs, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -1420,80 +1450,77 @@ Java_org_openafs_jafs_Server_restartAllProcesses * serverHandle the bos handle of the server to which the key belongs * jlogFile the full path and name of the desired bos log */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_Server_getLog - (JNIEnv *env, jclass cls, jint serverHandle, jstring jlogFile) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_Server_getLog(JNIEnv * env, jclass cls, + jint serverHandle, jstring jlogFile) { - afs_status_t ast; - char *logFile; - char *logData; - unsigned long currInLogSize = 1; - unsigned long currOutLogSize = 0; - jstring logOut; - - logData = (char *) malloc( sizeof(char)*currInLogSize ); - if ( logData == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return NULL; - } - - if ( jlogFile != NULL ) { - logFile = getNativeString(env, jlogFile); - if ( logFile == NULL ) { - free( logData ); - throwAFSException( env, JAFSADMNOMEM ); - return NULL; - } - } else { - free( logData ); - throwAFSException( env, JAFSNULLARG ); - return NULL; - } - - // check how big the log is . . . - if ( !bos_LogGet( (void *) serverHandle, logFile, - &currOutLogSize, logData, &ast ) ) { - // anything but not enough room in buffer - if ( ast != ADMMOREDATA ) { - free( logData ); - free( logFile ); - throwAFSException( env, ast ); - return NULL; - } - } - - // free previous allocation - free( logData ); - - // increase log size (plus one for terminator) - currInLogSize = currOutLogSize + 1; - - // allocate buffer - logData = (char *) malloc( sizeof(char)*currInLogSize ); - if ( logData == NULL ) { - free( logFile ); - throwAFSException( env, JAFSADMNOMEM ); - return NULL; - } - - // get the log for real - if ( !bos_LogGet( (void *) serverHandle, logFile, &currOutLogSize, - logData, &ast ) ) { - free( logData ); - free( logFile ); - throwAFSException( env, ast ); - return NULL; - } - - // NULL-terminate - logData[currOutLogSize] == '\0'; - - logOut = (*env)->NewStringUTF(env, logData); - - free( logData ); - free( logFile ); - - return logOut; + afs_status_t ast; + char *logFile; + char *logData; + unsigned long currInLogSize = 1; + unsigned long currOutLogSize = 0; + jstring logOut; + + logData = (char *)malloc(sizeof(char) * currInLogSize); + if (logData == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return NULL; + } + + if (jlogFile != NULL) { + logFile = getNativeString(env, jlogFile); + if (logFile == NULL) { + free(logData); + throwAFSException(env, JAFSADMNOMEM); + return NULL; + } + } else { + free(logData); + throwAFSException(env, JAFSNULLARG); + return NULL; + } + + // check how big the log is . . . + if (!bos_LogGet + ((void *)serverHandle, logFile, &currOutLogSize, logData, &ast)) { + // anything but not enough room in buffer + if (ast != ADMMOREDATA) { + free(logData); + free(logFile); + throwAFSException(env, ast); + return NULL; + } + } + // free previous allocation + free(logData); + + // increase log size (plus one for terminator) + currInLogSize = currOutLogSize + 1; + + // allocate buffer + logData = (char *)malloc(sizeof(char) * currInLogSize); + if (logData == NULL) { + free(logFile); + throwAFSException(env, JAFSADMNOMEM); + return NULL; + } + // get the log for real + if (!bos_LogGet + ((void *)serverHandle, logFile, &currOutLogSize, logData, &ast)) { + free(logData); + free(logFile); + throwAFSException(env, ast); + return NULL; + } + // NULL-terminate + logData[currOutLogSize] == '\0'; + + logOut = (*env)->NewStringUTF(env, logData); + + free(logData); + free(logFile); + + return logOut; } @@ -1505,38 +1532,38 @@ Java_org_openafs_jafs_Server_getLog * serverHandle the bos handle of the server to which the key belongs * jcommand the text of the commmand to execute */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_executeCommand - (JNIEnv *env, jclass cls, jint serverHandle, jstring jcommand) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Server_executeCommand(JNIEnv * env, jclass cls, + jint serverHandle, + jstring jcommand) { - afs_status_t ast; - char *command; - - if ( jcommand != NULL ) { - command = getNativeString(env, jcommand); - if ( command == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + afs_status_t ast; + char *command; + + if (jcommand != NULL) { + command = getNativeString(env, jcommand); + if (command == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLARG); + return; } - } else { - throwAFSException( env, JAFSNULLARG ); - return; - } - if ( !bos_CommandExecute( (void *) serverHandle, command, &ast ) ) { - throwAFSException( env, ast ); - } + if (!bos_CommandExecute((void *)serverHandle, command, &ast)) { + throwAFSException(env, ast); + } - free( command ); + free(command); } // reclaim global memory being used by this portion JNIEXPORT void JNICALL -Java_org_openafs_jafs_Server_reclaimServerMemory - (JNIEnv *env, jclass cls) +Java_org_openafs_jafs_Server_reclaimServerMemory(JNIEnv * env, jclass cls) { - if ( serverCls ) { - (*env)->DeleteGlobalRef(env, serverCls); - serverCls = 0; - } + if (serverCls) { + (*env)->DeleteGlobalRef(env, serverCls); + serverCls = 0; + } } diff --git a/src/JAVA/libjafs/User.c b/src/JAVA/libjafs/User.c index 7a32bb65f..a58194830 100644 --- a/src/JAVA/libjafs/User.c +++ b/src/JAVA/libjafs/User.c @@ -85,108 +85,102 @@ extern jfieldID group_cachedInfoField; * uid the user id to assign to the user (0 to have one * automatically assigned) */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_create - (JNIEnv *env, jclass cls, jint cellHandle, jstring jusername, - jstring jpassword, jint uid ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_User_create(JNIEnv * env, jclass cls, jint cellHandle, + jstring jusername, jstring jpassword, + jint uid) { - afs_status_t ast; - char *username; - char *password; - kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - - if ( !who ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - // convert java strings - if ( jusername != NULL ) { - username = getNativeString(env, jusername); - if ( username == NULL ) { - free( who ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( who ); - throwAFSException( env, JAFSNULLUSER ); - return; - } - - if ( jpassword != NULL ) { - password = getNativeString(env, jpassword); - if ( password == NULL ) { - free( who ); - free( username ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( who ); - free( username ); - throwAFSException( env, JAFSNULLPASS ); - return; - } - - // make sure the name is within the allowed bounds - if ( strlen( username ) > KAS_MAX_NAME_LEN ) { - free( who ); - free( username ); - free( password ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); - return; - } - - // make sure name doesn't have ":" in it - if ( strchr( username, ':' ) != (int) NULL ) { - free( who ); - free( username ); - free( password ); - throwAFSException( env, PRBADNAM ); - return; - } - - // make sure the id isn't negative - if ( uid < 0 ) { - free( who ); - free( username ); - free( password ); - // use the "bad arg" error code even though it's an ID exception. - // There isn't a bad user ID error code - throwAFSException( env, PRBADARG ); - return; - } - - if ( username != NULL ) { - internal_makeKasIdentity( username, who ); - } - - // create the kas entry - if (!kas_PrincipalCreate( (void *) cellHandle, NULL, who, - password, &ast ) ) { - free( who ); - free( username ); - free( password ); - throwAFSException( env, ast ); - return; - } - - // create the pts entry - if there's an error, make sure to delete - // the kas entry - if ( !pts_UserCreate( (void *) cellHandle, username, (int *) &uid, &ast ) ) { - afs_status_t ast_kd; - kas_PrincipalDelete( (void *) cellHandle, NULL, who, &ast_kd ); - free( who ); - free( username ); - free( password ); - throwAFSException( env, ast ); - return; - } - - free( who ); - free( username ); - free( password ); + afs_status_t ast; + char *username; + char *password; + kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t)); + + if (!who) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + // convert java strings + if (jusername != NULL) { + username = getNativeString(env, jusername); + if (username == NULL) { + free(who); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(who); + throwAFSException(env, JAFSNULLUSER); + return; + } + + if (jpassword != NULL) { + password = getNativeString(env, jpassword); + if (password == NULL) { + free(who); + free(username); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(who); + free(username); + throwAFSException(env, JAFSNULLPASS); + return; + } + + // make sure the name is within the allowed bounds + if (strlen(username) > KAS_MAX_NAME_LEN) { + free(who); + free(username); + free(password); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); + return; + } + // make sure name doesn't have ":" in it + if (strchr(username, ':') != (int)NULL) { + free(who); + free(username); + free(password); + throwAFSException(env, PRBADNAM); + return; + } + // make sure the id isn't negative + if (uid < 0) { + free(who); + free(username); + free(password); + // use the "bad arg" error code even though it's an ID exception. + // There isn't a bad user ID error code + throwAFSException(env, PRBADARG); + return; + } + + if (username != NULL) { + internal_makeKasIdentity(username, who); + } + // create the kas entry + if (!kas_PrincipalCreate((void *)cellHandle, NULL, who, password, &ast)) { + free(who); + free(username); + free(password); + throwAFSException(env, ast); + return; + } + // create the pts entry - if there's an error, make sure to delete + // the kas entry + if (!pts_UserCreate((void *)cellHandle, username, (int *)&uid, &ast)) { + afs_status_t ast_kd; + kas_PrincipalDelete((void *)cellHandle, NULL, who, &ast_kd); + free(who); + free(username); + free(password); + throwAFSException(env, ast); + return; + } + + free(who); + free(username); + free(password); } /** @@ -199,70 +193,69 @@ Java_org_openafs_jafs_User_create * cellHandle the handle of the cell to which the user belongs * jusername the name of the user to delete */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_delete - (JNIEnv *env, jclass cls, jint cellHandle, jstring jusername ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_User_delete(JNIEnv * env, jclass cls, jint cellHandle, + jstring jusername) { - afs_status_t ast; - char *username; - kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - int kas; - - if ( !who ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( jusername != NULL ) { - username = getNativeString(env, jusername); - if ( username == NULL ) { - free( who ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( who ); - throwAFSException( env, JAFSNULLUSER ); - return; - } - - // make sure the name is within the allowed bounds - if ( strlen( username ) > KAS_MAX_NAME_LEN ) { - free( who ); - free( username ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); - return; - } - - internal_makeKasIdentity( username, who ); - - // delete the kas entry - if ( !kas_PrincipalDelete( (void *) cellHandle, NULL, who, &ast ) ) { - if ( ast != KANOENT ) { - free(who); - free( username ); - throwAFSException( env, ast ); - return; + afs_status_t ast; + char *username; + kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t)); + int kas; + + if (!who) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + + if (jusername != NULL) { + username = getNativeString(env, jusername); + if (username == NULL) { + free(who); + throwAFSException(env, JAFSADMNOMEM); + return; + } } else { - kas = FALSE; + free(who); + throwAFSException(env, JAFSNULLUSER); + return; + } + + // make sure the name is within the allowed bounds + if (strlen(username) > KAS_MAX_NAME_LEN) { + free(who); + free(username); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); + return; } - } - //delete the pts entry - if ( !pts_UserDelete( (void *) cellHandle, username, &ast ) ) { - // throw exception if there was no such pts user only if there was - // also no such kas user - if ( (ast == ADMPTSFAILEDNAMETRANSLATE && !kas ) || - ast != ADMPTSFAILEDNAMETRANSLATE ) { - free( who ); - free( username ); - throwAFSException( env, ast ); - return; + internal_makeKasIdentity(username, who); + + // delete the kas entry + if (!kas_PrincipalDelete((void *)cellHandle, NULL, who, &ast)) { + if (ast != KANOENT) { + free(who); + free(username); + throwAFSException(env, ast); + return; + } else { + kas = FALSE; + } + } + //delete the pts entry + if (!pts_UserDelete((void *)cellHandle, username, &ast)) { + // throw exception if there was no such pts user only if there was + // also no such kas user + if ((ast == ADMPTSFAILEDNAMETRANSLATE && !kas) + || ast != ADMPTSFAILEDNAMETRANSLATE) { + free(who); + free(username); + throwAFSException(env, ast); + return; + } } - } - free( who ); - free( username ); + free(who); + free(username); } /** @@ -273,52 +266,51 @@ Java_org_openafs_jafs_User_delete * cellHandle the handle of the cell to which the user belongs * jusername the name of the user to unlock */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_unlock - (JNIEnv *env, jclass cls, jint cellHandle, jstring jusername ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_User_unlock(JNIEnv * env, jclass cls, jint cellHandle, + jstring jusername) { - afs_status_t ast; - char *username; - kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - - if ( !who ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - // convert java strings - if ( jusername != NULL ) { - username = getNativeString(env, jusername); - if ( username == NULL ) { - free( who ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( who ); - throwAFSException( env, JAFSNULLUSER ); - return; - } - - // make sure the name is within the allowed bounds - if ( strlen( username ) > KAS_MAX_NAME_LEN ) { - free( who ); - free( username ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); - return; - } - - internal_makeKasIdentity( username, who ); - - if ( !kas_PrincipalUnlock( (void *) cellHandle, NULL, who, &ast ) ) { - free( who ); - free( username ); - throwAFSException( env, ast ); - return; - } - - free( who ); - free( username ); + afs_status_t ast; + char *username; + kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t)); + + if (!who) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + // convert java strings + if (jusername != NULL) { + username = getNativeString(env, jusername); + if (username == NULL) { + free(who); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(who); + throwAFSException(env, JAFSNULLUSER); + return; + } + + // make sure the name is within the allowed bounds + if (strlen(username) > KAS_MAX_NAME_LEN) { + free(who); + free(username); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); + return; + } + + internal_makeKasIdentity(username, who); + + if (!kas_PrincipalUnlock((void *)cellHandle, NULL, who, &ast)) { + free(who); + free(username); + throwAFSException(env, ast); + return; + } + + free(who); + free(username); } /** @@ -330,208 +322,207 @@ Java_org_openafs_jafs_User_unlock * name the name of the user for which to get the info * user the User object to populate with the info */ -void getUserInfoChar - (JNIEnv *env, int cellHandle, const char *name, jobject user) +void +getUserInfoChar(JNIEnv * env, int cellHandle, const char *name, jobject user) { - jstring jowner; - jstring jcreator; - jstring jlastModName; - jstring jencryptionKey; - jboolean pts; - jboolean kas; - pts_UserEntry_t ptsEntry; - afs_status_t ast; - kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - kas_principalEntry_t kasEntry; - unsigned int lockedUntil; - - if ( !who ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - // make sure the name is within the allowed bounds - if ( name != NULL && strlen( name ) > KAS_MAX_NAME_LEN ) { - free( who ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); - return; - } - - if ( name != NULL ) { - internal_makeKasIdentity( name, who ); - } - - // get all the field ids, if you haven't done so already - if ( userCls == 0 ) { - internal_getUserClass( env, user ); - } - - // get the pts entry - if ( !pts_UserGet( (void *) cellHandle, name, &ptsEntry, &ast ) ) { - // if the user has no pts ptsEntry - if ( ast == ADMPTSFAILEDNAMETRANSLATE ) { - pts = FALSE; - } else { - free( who ); - throwAFSException( env, ast ); + jstring jowner; + jstring jcreator; + jstring jlastModName; + jstring jencryptionKey; + jboolean pts; + jboolean kas; + pts_UserEntry_t ptsEntry; + afs_status_t ast; + kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t)); + kas_principalEntry_t kasEntry; + unsigned int lockedUntil; + + if (!who) { + throwAFSException(env, JAFSADMNOMEM); return; } - } else { - pts = TRUE; - } - - - // get the kas entry - if ( !kas_PrincipalGet( (void *) cellHandle, NULL, who, &kasEntry, &ast ) ) { - // no kas entry - if ( ast == KANOENT ) { - if ( !pts ) { - free( who ); - throwAFSException( env, ast ); - return; + // make sure the name is within the allowed bounds + if (name != NULL && strlen(name) > KAS_MAX_NAME_LEN) { + free(who); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); + return; + } + + if (name != NULL) { + internal_makeKasIdentity(name, who); + } + // get all the field ids, if you haven't done so already + if (userCls == 0) { + internal_getUserClass(env, user); + } + // get the pts entry + if (!pts_UserGet((void *)cellHandle, name, &ptsEntry, &ast)) { + // if the user has no pts ptsEntry + if (ast == ADMPTSFAILEDNAMETRANSLATE) { + pts = FALSE; + } else { + free(who); + throwAFSException(env, ast); + return; + } + } else { + pts = TRUE; + } + + + // get the kas entry + if (!kas_PrincipalGet((void *)cellHandle, NULL, who, &kasEntry, &ast)) { + // no kas entry + if (ast == KANOENT) { + if (!pts) { + free(who); + throwAFSException(env, ast); + return; + } else { + kas = FALSE; + } + // other } else { - kas = FALSE; + free(who); + throwAFSException(env, ast); + return; } - // other } else { - free( who ); - throwAFSException( env, ast ); + kas = TRUE; + } + + // get the lock status + if (kas + && !kas_PrincipalLockStatusGet((void *)cellHandle, NULL, who, + &lockedUntil, &ast)) { + free(who); + throwAFSException(env, ast); return; } - } else { - kas = TRUE; - } - - // get the lock status - if ( kas && !kas_PrincipalLockStatusGet( (void *) cellHandle, NULL, who, - &lockedUntil, &ast ) ) { - free( who ); - throwAFSException( env, ast ); - return; - } - - (*env)->SetBooleanField(env, user, user_ptsField, pts); - (*env)->SetBooleanField(env, user, user_kasField, kas); - - // set the pts fields - if ( pts ) { - (*env)->SetIntField(env, user, user_nameUidField, ptsEntry.nameUid); - (*env)->SetIntField(env, user, user_ownerUidField, ptsEntry.ownerUid); - (*env)->SetIntField(env, user, user_creatorUidField, - ptsEntry.creatorUid); - (*env)->SetIntField(env, user, user_groupCreationQuotaField, - ptsEntry.groupCreationQuota); - (*env)->SetIntField(env, user, user_groupMembershipCountField, - ptsEntry.groupMembershipCount); - - if ( ptsEntry.listStatus == PTS_USER_OWNER_ACCESS ) { - (*env)->SetIntField(env, user, user_listStatusField, - org_openafs_jafs_User_USER_OWNER_ACCESS); - } else { - (*env)->SetIntField(env, user, user_listStatusField, - org_openafs_jafs_User_USER_ANYUSER_ACCESS); - } - if ( ptsEntry.listGroupsOwned == PTS_USER_OWNER_ACCESS ) { - (*env)->SetIntField(env, user, user_listGroupsOwnedField, - org_openafs_jafs_User_USER_OWNER_ACCESS); - } else { - (*env)->SetIntField(env, user, user_listGroupsOwnedField, - org_openafs_jafs_User_USER_ANYUSER_ACCESS); - } - if ( ptsEntry.listMembership == PTS_USER_OWNER_ACCESS ) { - (*env)->SetIntField(env, user, user_listMembershipField, - org_openafs_jafs_User_USER_OWNER_ACCESS); - } else { - (*env)->SetIntField(env, user, user_listMembershipField, - org_openafs_jafs_User_USER_ANYUSER_ACCESS); - } - - jowner = (*env)->NewStringUTF(env, ptsEntry.owner); - jcreator = (*env)->NewStringUTF(env, ptsEntry.creator); - - (*env)->SetObjectField(env, user, user_ownerField, jowner); - (*env)->SetObjectField(env, user, user_creatorField, jcreator); - - } - - // set the kas fields - if ( kas ) { - char *convertedKey; - int i; - if ( kasEntry.adminSetting == KAS_ADMIN ) { - (*env)->SetIntField(env, user, user_adminSettingField, - org_openafs_jafs_User_ADMIN); - } else { - (*env)->SetIntField(env, user, user_adminSettingField, - org_openafs_jafs_User_NO_ADMIN); - } - if ( kasEntry.tgsSetting == TGS ) { - (*env)->SetIntField(env, user, user_tgsSettingField, - org_openafs_jafs_User_GRANT_TICKETS); - } else { - (*env)->SetIntField(env, user, user_tgsSettingField, - org_openafs_jafs_User_NO_GRANT_TICKETS); - } - if ( kasEntry.encSetting != NO_ENCRYPT ) { - (*env)->SetIntField(env, user, user_encSettingField, - org_openafs_jafs_User_ENCRYPT); - } else { - (*env)->SetIntField(env, user, user_encSettingField, - org_openafs_jafs_User_NO_ENCRYPT); - } - if ( kasEntry.cpwSetting == CHANGE_PASSWORD ) { - (*env)->SetIntField(env, user, user_cpwSettingField, - org_openafs_jafs_User_CHANGE_PASSWORD); - } else { - (*env)->SetIntField(env, user, user_cpwSettingField, - org_openafs_jafs_User_NO_CHANGE_PASSWORD); - } - if ( kasEntry.rpwSetting == REUSE_PASSWORD ) { - (*env)->SetIntField(env, user, user_rpwSettingField, - org_openafs_jafs_User_REUSE_PASSWORD); - } else { - (*env)->SetIntField(env, user, user_rpwSettingField, - org_openafs_jafs_User_NO_REUSE_PASSWORD); - } - (*env)->SetIntField(env, user, user_userExpirationField, - kasEntry.userExpiration); - (*env)->SetIntField(env, user, user_lastModTimeField, - kasEntry.lastModTime); - (*env)->SetIntField(env, user, user_lastChangePasswordTimeField, - kasEntry.lastChangePasswordTime); - (*env)->SetIntField(env, user, user_maxTicketLifetimeField, - kasEntry.maxTicketLifetime); - (*env)->SetIntField(env, user, user_keyVersionField, - kasEntry.keyVersion); - (*env)->SetLongField(env, user, user_keyCheckSumField, - (unsigned int) kasEntry.keyCheckSum); - (*env)->SetIntField(env, user, user_daysToPasswordExpireField, - kasEntry.daysToPasswordExpire); - (*env)->SetIntField(env, user, user_failLoginCountField, - kasEntry.failLoginCount); - (*env)->SetIntField(env, user, user_lockTimeField, kasEntry.lockTime); - (*env)->SetIntField(env, user, user_lockedUntilField, lockedUntil); - - jlastModName = (*env)->NewStringUTF(env, - kasEntry.lastModPrincipal.principal); - (*env)->SetObjectField(env, user, user_lastModNameField, jlastModName); - - convertedKey = (char *) malloc( sizeof(char *)* - (sizeof(kasEntry.key.key)*4+1) ); - if ( !convertedKey ) { - free( who ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - for( i = 0; i < sizeof(kasEntry.key.key); i++ ) { - sprintf( &(convertedKey[i*4]), "\\%0.3o", kasEntry.key.key[i] ); - } - jencryptionKey = (*env)->NewStringUTF(env, convertedKey); - (*env)->SetObjectField(env, user, user_encryptionKeyField, - jencryptionKey); - free( convertedKey ); - } - free( who ); + + (*env)->SetBooleanField(env, user, user_ptsField, pts); + (*env)->SetBooleanField(env, user, user_kasField, kas); + + // set the pts fields + if (pts) { + (*env)->SetIntField(env, user, user_nameUidField, ptsEntry.nameUid); + (*env)->SetIntField(env, user, user_ownerUidField, ptsEntry.ownerUid); + (*env)->SetIntField(env, user, user_creatorUidField, + ptsEntry.creatorUid); + (*env)->SetIntField(env, user, user_groupCreationQuotaField, + ptsEntry.groupCreationQuota); + (*env)->SetIntField(env, user, user_groupMembershipCountField, + ptsEntry.groupMembershipCount); + + if (ptsEntry.listStatus == PTS_USER_OWNER_ACCESS) { + (*env)->SetIntField(env, user, user_listStatusField, + org_openafs_jafs_User_USER_OWNER_ACCESS); + } else { + (*env)->SetIntField(env, user, user_listStatusField, + org_openafs_jafs_User_USER_ANYUSER_ACCESS); + } + if (ptsEntry.listGroupsOwned == PTS_USER_OWNER_ACCESS) { + (*env)->SetIntField(env, user, user_listGroupsOwnedField, + org_openafs_jafs_User_USER_OWNER_ACCESS); + } else { + (*env)->SetIntField(env, user, user_listGroupsOwnedField, + org_openafs_jafs_User_USER_ANYUSER_ACCESS); + } + if (ptsEntry.listMembership == PTS_USER_OWNER_ACCESS) { + (*env)->SetIntField(env, user, user_listMembershipField, + org_openafs_jafs_User_USER_OWNER_ACCESS); + } else { + (*env)->SetIntField(env, user, user_listMembershipField, + org_openafs_jafs_User_USER_ANYUSER_ACCESS); + } + + jowner = (*env)->NewStringUTF(env, ptsEntry.owner); + jcreator = (*env)->NewStringUTF(env, ptsEntry.creator); + + (*env)->SetObjectField(env, user, user_ownerField, jowner); + (*env)->SetObjectField(env, user, user_creatorField, jcreator); + + } + // set the kas fields + if (kas) { + char *convertedKey; + int i; + if (kasEntry.adminSetting == KAS_ADMIN) { + (*env)->SetIntField(env, user, user_adminSettingField, + org_openafs_jafs_User_ADMIN); + } else { + (*env)->SetIntField(env, user, user_adminSettingField, + org_openafs_jafs_User_NO_ADMIN); + } + if (kasEntry.tgsSetting == TGS) { + (*env)->SetIntField(env, user, user_tgsSettingField, + org_openafs_jafs_User_GRANT_TICKETS); + } else { + (*env)->SetIntField(env, user, user_tgsSettingField, + org_openafs_jafs_User_NO_GRANT_TICKETS); + } + if (kasEntry.encSetting != NO_ENCRYPT) { + (*env)->SetIntField(env, user, user_encSettingField, + org_openafs_jafs_User_ENCRYPT); + } else { + (*env)->SetIntField(env, user, user_encSettingField, + org_openafs_jafs_User_NO_ENCRYPT); + } + if (kasEntry.cpwSetting == CHANGE_PASSWORD) { + (*env)->SetIntField(env, user, user_cpwSettingField, + org_openafs_jafs_User_CHANGE_PASSWORD); + } else { + (*env)->SetIntField(env, user, user_cpwSettingField, + org_openafs_jafs_User_NO_CHANGE_PASSWORD); + } + if (kasEntry.rpwSetting == REUSE_PASSWORD) { + (*env)->SetIntField(env, user, user_rpwSettingField, + org_openafs_jafs_User_REUSE_PASSWORD); + } else { + (*env)->SetIntField(env, user, user_rpwSettingField, + org_openafs_jafs_User_NO_REUSE_PASSWORD); + } + (*env)->SetIntField(env, user, user_userExpirationField, + kasEntry.userExpiration); + (*env)->SetIntField(env, user, user_lastModTimeField, + kasEntry.lastModTime); + (*env)->SetIntField(env, user, user_lastChangePasswordTimeField, + kasEntry.lastChangePasswordTime); + (*env)->SetIntField(env, user, user_maxTicketLifetimeField, + kasEntry.maxTicketLifetime); + (*env)->SetIntField(env, user, user_keyVersionField, + kasEntry.keyVersion); + (*env)->SetLongField(env, user, user_keyCheckSumField, + (unsigned int)kasEntry.keyCheckSum); + (*env)->SetIntField(env, user, user_daysToPasswordExpireField, + kasEntry.daysToPasswordExpire); + (*env)->SetIntField(env, user, user_failLoginCountField, + kasEntry.failLoginCount); + (*env)->SetIntField(env, user, user_lockTimeField, kasEntry.lockTime); + (*env)->SetIntField(env, user, user_lockedUntilField, lockedUntil); + + jlastModName = + (*env)->NewStringUTF(env, kasEntry.lastModPrincipal.principal); + (*env)->SetObjectField(env, user, user_lastModNameField, + jlastModName); + + convertedKey = + (char *)malloc(sizeof(char *) * + (sizeof(kasEntry.key.key) * 4 + 1)); + if (!convertedKey) { + free(who); + throwAFSException(env, JAFSADMNOMEM); + return; + } + for (i = 0; i < sizeof(kasEntry.key.key); i++) { + sprintf(&(convertedKey[i * 4]), "\\%0.3o", kasEntry.key.key[i]); + } + jencryptionKey = (*env)->NewStringUTF(env, convertedKey); + (*env)->SetObjectField(env, user, user_encryptionKeyField, + jencryptionKey); + free(convertedKey); + } + free(who); } /** @@ -545,34 +536,34 @@ void getUserInfoChar * user the User object in which to fill in the * information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_getUserInfo - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname, jobject user) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_User_getUserInfo(JNIEnv * env, jclass cls, + jint cellHandle, jstring jname, + jobject user) { - char *name; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( !name ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLUSER ); - return; - } - - getUserInfoChar( env, cellHandle, name, user ); - - // get class fields if need be - if ( userCls == 0 ) { - internal_getUserClass( env, user ); - } - - // set name in case blank object - (*env)->SetObjectField(env, user, user_nameField, jname); - - free( name ); + char *name; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (!name) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLUSER); + return; + } + + getUserInfoChar(env, cellHandle, name, user); + + // get class fields if need be + if (userCls == 0) { + internal_getUserClass(env, user); + } + // set name in case blank object + (*env)->SetObjectField(env, user, user_nameField, jname); + + free(name); } /** @@ -586,151 +577,151 @@ Java_org_openafs_jafs_User_getUserInfo * user the User object containing the desired * information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_setUserInfo - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname, jobject user ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_User_setUserInfo(JNIEnv * env, jclass cls, + jint cellHandle, jstring jname, + jobject user) { - char *name; - kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - pts_UserUpdateEntry_t ptsEntry; - afs_status_t ast; - kas_admin_t isAdmin; - kas_tgs_t grantTickets; - kas_enc_t canEncrypt; - kas_cpw_t canChangePassword; - kas_rpw_t passwordReuse; - unsigned int expirationDate; - unsigned int maxTicketLifetime; - unsigned int passwordExpires; - unsigned int failedPasswordAttempts; - unsigned int failedPasswordLockTime; - int kas; - int pts; - - if ( !who ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( name == NULL ) { - free( who ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( who ); - throwAFSException( env, JAFSNULLUSER ); - return; - } - - // make sure the name is within the allowed bounds - if ( strlen( name ) > KAS_MAX_NAME_LEN ) { - free( who ); - free( name ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); - return; - } - - internal_makeKasIdentity( name, who ); - - // get class fields if need be - if ( userCls == 0 ) { - internal_getUserClass( env, user ); - } - - kas = (*env)->GetBooleanField(env, user, user_kasField); - pts = (*env)->GetBooleanField(env, user, user_ptsField); - - if ( pts ) { - // set the pts fields: - ptsEntry.flag = PTS_USER_UPDATE_GROUP_CREATE_QUOTA | - PTS_USER_UPDATE_PERMISSIONS; - ptsEntry.groupCreationQuota = - (*env)->GetIntField(env, user, user_groupCreationQuotaField); - if ( (*env)->GetIntField(env, user, user_listStatusField) == - org_openafs_jafs_User_USER_OWNER_ACCESS ) { - ptsEntry.listStatus = PTS_USER_OWNER_ACCESS; - } else { - ptsEntry.listStatus = PTS_USER_ANYUSER_ACCESS; - } - if ( (*env)->GetIntField(env, user, user_listGroupsOwnedField) == - org_openafs_jafs_User_USER_OWNER_ACCESS ) { - ptsEntry.listGroupsOwned = PTS_USER_OWNER_ACCESS; - } else { - ptsEntry.listGroupsOwned = PTS_USER_ANYUSER_ACCESS; + char *name; + kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t)); + pts_UserUpdateEntry_t ptsEntry; + afs_status_t ast; + kas_admin_t isAdmin; + kas_tgs_t grantTickets; + kas_enc_t canEncrypt; + kas_cpw_t canChangePassword; + kas_rpw_t passwordReuse; + unsigned int expirationDate; + unsigned int maxTicketLifetime; + unsigned int passwordExpires; + unsigned int failedPasswordAttempts; + unsigned int failedPasswordLockTime; + int kas; + int pts; + + if (!who) { + throwAFSException(env, JAFSADMNOMEM); + return; } - if ( (*env)->GetIntField(env, user, user_listMembershipField) == - org_openafs_jafs_User_USER_OWNER_ACCESS ) { - ptsEntry.listMembership = PTS_USER_OWNER_ACCESS; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (name == NULL) { + free(who); + throwAFSException(env, JAFSADMNOMEM); + return; + } } else { - ptsEntry.listMembership = PTS_USER_ANYUSER_ACCESS; - } - if ( !pts_UserModify( (void *) cellHandle, name, &ptsEntry, &ast ) ) { - free( who ); - free( name ); - throwAFSException( env, ast ); - return; + free(who); + throwAFSException(env, JAFSNULLUSER); + return; } - } - if ( kas ) { - // set the kas fields: - if ( (*env)->GetIntField(env, user, user_adminSettingField) == - org_openafs_jafs_User_ADMIN ) { - isAdmin = KAS_ADMIN; - } else { - isAdmin = NO_KAS_ADMIN; + // make sure the name is within the allowed bounds + if (strlen(name) > KAS_MAX_NAME_LEN) { + free(who); + free(name); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); + return; } - if ( (*env)->GetIntField(env, user, user_tgsSettingField) == - org_openafs_jafs_User_GRANT_TICKETS ) { - grantTickets = TGS; - } else { - grantTickets = NO_TGS; + + internal_makeKasIdentity(name, who); + + // get class fields if need be + if (userCls == 0) { + internal_getUserClass(env, user); } - if ( (*env)->GetIntField(env, user, user_encSettingField) == - org_openafs_jafs_User_ENCRYPT ) { - canEncrypt = 0; - } else { - canEncrypt = NO_ENCRYPT; + + kas = (*env)->GetBooleanField(env, user, user_kasField); + pts = (*env)->GetBooleanField(env, user, user_ptsField); + + if (pts) { + // set the pts fields: + ptsEntry.flag = + PTS_USER_UPDATE_GROUP_CREATE_QUOTA | PTS_USER_UPDATE_PERMISSIONS; + ptsEntry.groupCreationQuota = + (*env)->GetIntField(env, user, user_groupCreationQuotaField); + if ((*env)->GetIntField(env, user, user_listStatusField) == + org_openafs_jafs_User_USER_OWNER_ACCESS) { + ptsEntry.listStatus = PTS_USER_OWNER_ACCESS; + } else { + ptsEntry.listStatus = PTS_USER_ANYUSER_ACCESS; + } + if ((*env)->GetIntField(env, user, user_listGroupsOwnedField) == + org_openafs_jafs_User_USER_OWNER_ACCESS) { + ptsEntry.listGroupsOwned = PTS_USER_OWNER_ACCESS; + } else { + ptsEntry.listGroupsOwned = PTS_USER_ANYUSER_ACCESS; + } + if ((*env)->GetIntField(env, user, user_listMembershipField) == + org_openafs_jafs_User_USER_OWNER_ACCESS) { + ptsEntry.listMembership = PTS_USER_OWNER_ACCESS; + } else { + ptsEntry.listMembership = PTS_USER_ANYUSER_ACCESS; + } + if (!pts_UserModify((void *)cellHandle, name, &ptsEntry, &ast)) { + free(who); + free(name); + throwAFSException(env, ast); + return; + } } - if ( (*env)->GetIntField(env, user, user_cpwSettingField) == - org_openafs_jafs_User_CHANGE_PASSWORD ) { - canChangePassword = CHANGE_PASSWORD; - } else { - canChangePassword = NO_CHANGE_PASSWORD; + + if (kas) { + // set the kas fields: + if ((*env)->GetIntField(env, user, user_adminSettingField) == + org_openafs_jafs_User_ADMIN) { + isAdmin = KAS_ADMIN; + } else { + isAdmin = NO_KAS_ADMIN; + } + if ((*env)->GetIntField(env, user, user_tgsSettingField) == + org_openafs_jafs_User_GRANT_TICKETS) { + grantTickets = TGS; + } else { + grantTickets = NO_TGS; + } + if ((*env)->GetIntField(env, user, user_encSettingField) == + org_openafs_jafs_User_ENCRYPT) { + canEncrypt = 0; + } else { + canEncrypt = NO_ENCRYPT; + } + if ((*env)->GetIntField(env, user, user_cpwSettingField) == + org_openafs_jafs_User_CHANGE_PASSWORD) { + canChangePassword = CHANGE_PASSWORD; + } else { + canChangePassword = NO_CHANGE_PASSWORD; + } + if ((*env)->GetIntField(env, user, user_rpwSettingField) == + org_openafs_jafs_User_REUSE_PASSWORD) { + passwordReuse = REUSE_PASSWORD; + } else { + passwordReuse = NO_REUSE_PASSWORD; + } + expirationDate = + (*env)->GetIntField(env, user, user_userExpirationField); + maxTicketLifetime = + (*env)->GetIntField(env, user, user_maxTicketLifetimeField); + passwordExpires = + (*env)->GetIntField(env, user, user_daysToPasswordExpireField); + failedPasswordAttempts = + (*env)->GetIntField(env, user, user_failLoginCountField); + failedPasswordLockTime = + (*env)->GetIntField(env, user, user_lockTimeField); + + + if (!kas_PrincipalFieldsSet + ((void *)cellHandle, NULL, who, &isAdmin, &grantTickets, + &canEncrypt, &canChangePassword, &expirationDate, + &maxTicketLifetime, &passwordExpires, &passwordReuse, + &failedPasswordAttempts, &failedPasswordLockTime, &ast)) { + throwAFSException(env, ast); + } } - if ( (*env)->GetIntField(env, user, user_rpwSettingField) == - org_openafs_jafs_User_REUSE_PASSWORD ) { - passwordReuse = REUSE_PASSWORD; - } else { - passwordReuse = NO_REUSE_PASSWORD; - } - expirationDate = (*env)->GetIntField(env, user, - user_userExpirationField); - maxTicketLifetime = (*env)->GetIntField(env, user, - user_maxTicketLifetimeField); - passwordExpires = (*env)->GetIntField(env, user, - user_daysToPasswordExpireField); - failedPasswordAttempts = (*env)->GetIntField(env, user, - user_failLoginCountField); - failedPasswordLockTime = (*env)->GetIntField(env, user, - user_lockTimeField); - - - if ( !kas_PrincipalFieldsSet( (void *) cellHandle, NULL, who, &isAdmin, - &grantTickets, &canEncrypt, - &canChangePassword, &expirationDate, - &maxTicketLifetime, &passwordExpires, - &passwordReuse, &failedPasswordAttempts, - &failedPasswordLockTime, &ast ) ) { - throwAFSException( env, ast ); - } - } - - free( who ); - free( name ); + + free(who); + free(name); } /** @@ -743,158 +734,169 @@ Java_org_openafs_jafs_User_setUserInfo * joldName the name of the user to rename * jnewName the new name for the user */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_rename - (JNIEnv *env, jclass cls, jint cellHandle, jstring joldName, jstring jnewName) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_User_rename(JNIEnv * env, jclass cls, jint cellHandle, + jstring joldName, jstring jnewName) { - char *oldName; - char *newName; - kas_identity_p whoOld = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - kas_identity_p whoNew = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - kas_principalEntry_t kasEntry; - pts_UserEntry_t ptsEntry; - afs_status_t ast; - int kas; - - if ( !whoOld || !whoNew ) { - if ( whoOld ) { - free( whoOld ); - } - if ( whoNew ) { - free( whoNew ); - } - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( joldName != NULL ) { - oldName = getNativeString(env, joldName); - if ( oldName == NULL ) { - free( whoOld ); - free( whoNew ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - oldName = NULL; - } - if ( jnewName != NULL ) { - newName = getNativeString(env, jnewName); - if ( newName == NULL ) { - free( whoOld ); - free( whoNew ); - if ( oldName != NULL ) free ( oldName ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - newName = NULL; - } - - // make sure the names are within the allowed bounds - if ( (oldName != NULL && strlen( oldName ) > KAS_MAX_NAME_LEN) || - (newName != NULL && strlen( newName ) > KAS_MAX_NAME_LEN) ) - { - free( whoOld ); - free( whoNew ); - if ( oldName != NULL ) free( oldName ); - if ( newName != NULL ) free( newName ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); - return; - } - - if ( oldName != NULL ) { - internal_makeKasIdentity( oldName, whoOld ); - } - if ( newName != NULL ) { - internal_makeKasIdentity( newName, whoNew ); - } - - // retrieve the old kas info - if ( !kas_PrincipalGet( (void *) cellHandle, NULL, whoOld, - &kasEntry, &ast ) ) { - if ( ast != KANOENT ) { - free( whoOld ); - free( whoNew ); - if ( oldName != NULL ) free( oldName ); - if ( newName != NULL ) free( newName ); - throwAFSException( env, ast ); - return; + char *oldName; + char *newName; + kas_identity_p whoOld = (kas_identity_p) malloc(sizeof(kas_identity_t)); + kas_identity_p whoNew = (kas_identity_p) malloc(sizeof(kas_identity_t)); + kas_principalEntry_t kasEntry; + pts_UserEntry_t ptsEntry; + afs_status_t ast; + int kas; + + if (!whoOld || !whoNew) { + if (whoOld) { + free(whoOld); + } + if (whoNew) { + free(whoNew); + } + throwAFSException(env, JAFSADMNOMEM); + return; + } + + if (joldName != NULL) { + oldName = getNativeString(env, joldName); + if (oldName == NULL) { + free(whoOld); + free(whoNew); + throwAFSException(env, JAFSADMNOMEM); + return; + } } else { - kas = FALSE; - } - } else { - kas = TRUE; - } - - if ( kas ) { - // create a new kas entry - // temporarily set the password equal to the new name - if (!kas_PrincipalCreate( (void *) cellHandle, NULL, whoNew, - newName, &ast ) ) { - free( whoOld ); - free( whoNew ); - if ( oldName != NULL ) free( oldName ); - if ( newName != NULL ) free( newName ); - throwAFSException( env, ast ); - return; - } - - // set the password - ast = 0; - // For some reason kas_PrincipalKeySet doesn't set the return code - // correctly. It always returns 0. - // So instead of checking the return code, we see if there's an - // error in the status variable. - kas_PrincipalKeySet( (void *) cellHandle, NULL, whoNew, 0, - &(kasEntry.key), &ast ); - if ( ast ) { - afs_status_t ast_kd; - kas_PrincipalDelete( (void *) cellHandle, NULL, whoNew, &ast_kd ); - free( whoOld ); - free( whoNew ); - if ( oldName != NULL ) free( oldName ); - if ( newName != NULL ) free( newName ); - throwAFSException( env, ast ); - return; - } - } - - // rename the pts entry - if ( !pts_UserRename( (void *) cellHandle, oldName, newName, &ast ) ) { - // throw exception if there was no such pts user only if - // there was also no such kas user - if ( (ast == ADMPTSFAILEDNAMETRANSLATE && !kas ) || - ast != ADMPTSFAILEDNAMETRANSLATE ) { - afs_status_t ast_kd; - if ( kas ) { - kas_PrincipalDelete( (void *) cellHandle, NULL, whoNew, &ast_kd ); - } - free( whoOld ); - free( whoNew ); - if ( oldName != NULL ) free( oldName ); - if ( newName != NULL ) free( newName ); - throwAFSException( env, ast ); - return; - } - } - - if ( kas ) { - // delete the old kas entry - if ( !kas_PrincipalDelete( (void *) cellHandle, NULL, whoOld, &ast ) ) { - free( whoOld ); - free( whoNew ); - if ( oldName != NULL ) free( oldName ); - if ( newName != NULL ) free( newName ); - throwAFSException( env, ast ); - return; - } - } - - free( whoOld ); - free( whoNew ); - if ( oldName != NULL ) free( oldName ); - if ( newName != NULL ) free( newName ); + oldName = NULL; + } + if (jnewName != NULL) { + newName = getNativeString(env, jnewName); + if (newName == NULL) { + free(whoOld); + free(whoNew); + if (oldName != NULL) + free(oldName); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + newName = NULL; + } + + // make sure the names are within the allowed bounds + if ((oldName != NULL && strlen(oldName) > KAS_MAX_NAME_LEN) + || (newName != NULL && strlen(newName) > KAS_MAX_NAME_LEN)) { + free(whoOld); + free(whoNew); + if (oldName != NULL) + free(oldName); + if (newName != NULL) + free(newName); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); + return; + } + + if (oldName != NULL) { + internal_makeKasIdentity(oldName, whoOld); + } + if (newName != NULL) { + internal_makeKasIdentity(newName, whoNew); + } + // retrieve the old kas info + if (!kas_PrincipalGet((void *)cellHandle, NULL, whoOld, &kasEntry, &ast)) { + if (ast != KANOENT) { + free(whoOld); + free(whoNew); + if (oldName != NULL) + free(oldName); + if (newName != NULL) + free(newName); + throwAFSException(env, ast); + return; + } else { + kas = FALSE; + } + } else { + kas = TRUE; + } + + if (kas) { + // create a new kas entry + // temporarily set the password equal to the new name + if (!kas_PrincipalCreate + ((void *)cellHandle, NULL, whoNew, newName, &ast)) { + free(whoOld); + free(whoNew); + if (oldName != NULL) + free(oldName); + if (newName != NULL) + free(newName); + throwAFSException(env, ast); + return; + } + // set the password + ast = 0; + // For some reason kas_PrincipalKeySet doesn't set the return code + // correctly. It always returns 0. + // So instead of checking the return code, we see if there's an + // error in the status variable. + kas_PrincipalKeySet((void *)cellHandle, NULL, whoNew, 0, + &(kasEntry.key), &ast); + if (ast) { + afs_status_t ast_kd; + kas_PrincipalDelete((void *)cellHandle, NULL, whoNew, &ast_kd); + free(whoOld); + free(whoNew); + if (oldName != NULL) + free(oldName); + if (newName != NULL) + free(newName); + throwAFSException(env, ast); + return; + } + } + // rename the pts entry + if (!pts_UserRename((void *)cellHandle, oldName, newName, &ast)) { + // throw exception if there was no such pts user only if + // there was also no such kas user + if ((ast == ADMPTSFAILEDNAMETRANSLATE && !kas) + || ast != ADMPTSFAILEDNAMETRANSLATE) { + afs_status_t ast_kd; + if (kas) { + kas_PrincipalDelete((void *)cellHandle, NULL, whoNew, + &ast_kd); + } + free(whoOld); + free(whoNew); + if (oldName != NULL) + free(oldName); + if (newName != NULL) + free(newName); + throwAFSException(env, ast); + return; + } + } + + if (kas) { + // delete the old kas entry + if (!kas_PrincipalDelete((void *)cellHandle, NULL, whoOld, &ast)) { + free(whoOld); + free(whoNew); + if (oldName != NULL) + free(oldName); + if (newName != NULL) + free(newName); + throwAFSException(env, ast); + return; + } + } + + free(whoOld); + free(whoNew); + if (oldName != NULL) + free(oldName); + if (newName != NULL) + free(newName); } /** @@ -906,106 +908,106 @@ Java_org_openafs_jafs_User_rename * jusername the name of the user for which to set the password * jnewPassword the new password for the user */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_setPassword - (JNIEnv *env, jclass cls, jint cellHandle, jstring jusername, - jstring jnewPassword) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_User_setPassword(JNIEnv * env, jclass cls, + jint cellHandle, jstring jusername, + jstring jnewPassword) { - afs_status_t ast; - char *cellName; - char *username; - char *newPassword; - kas_encryptionKey_p newKey = - (kas_encryptionKey_p) malloc( sizeof(kas_encryptionKey_t) ); - kas_identity_p who = (kas_identity_p) malloc( sizeof(kas_identity_t) ); - - if ( !who || !newKey ) { - if ( who ) { - free( who ); - } - if ( newKey ) { - free( newKey ); - } - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( jusername != NULL ) { - username = getNativeString(env, jusername); - if ( username == NULL ) { - free( who ); - free( newKey ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( who ); - free( newKey ); - throwAFSException( env, JAFSNULLUSER ); - return; - } - - if ( jnewPassword != NULL ) { - newPassword = getNativeString(env, jnewPassword); - if ( newPassword == NULL ) { - free( who ); - free( newKey ); - free( username ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - free( who ); - free( newKey ); - free( username ); - throwAFSException( env, JAFSNULLPASS ); - return; - } - - // make sure the name is within the allowed bounds - if ( strlen( username ) > KAS_MAX_NAME_LEN ) { - free( who ); - free( newKey ); - free( username ); - free( newPassword ); - throwAFSException( env, ADMPTSUSERNAMETOOLONG ); - return; - } - - if ( !afsclient_CellNameGet( (void *) cellHandle, &cellName, &ast ) ) { - free( who ); - free( newKey ); - free( username ); - free( newPassword ); - throwAFSException( env, ast ); - return; - } - - if ( !kas_StringToKey( cellName, newPassword, newKey, &ast ) ) { - free( who ); - free( newKey ); - free( username ); - free( newPassword ); - throwAFSException( env, ast ); - return; - } - - internal_makeKasIdentity( username, who ); - - ast = 0; - // For some reason kas_PrincipalKeySet doesn't set the return code correctly. - // It always returns 0. - // So instead of checking the return code, we see if there's an error - // in the status variable. - kas_PrincipalKeySet( (void *) cellHandle, NULL, who, 0, newKey, &ast ); - if ( ast ) { - throwAFSException( env, ast ); - } - - free( who ); - free( newKey ); - free( username ); - free( newPassword ); + afs_status_t ast; + char *cellName; + char *username; + char *newPassword; + kas_encryptionKey_p newKey = + (kas_encryptionKey_p) malloc(sizeof(kas_encryptionKey_t)); + kas_identity_p who = (kas_identity_p) malloc(sizeof(kas_identity_t)); + + if (!who || !newKey) { + if (who) { + free(who); + } + if (newKey) { + free(newKey); + } + throwAFSException(env, JAFSADMNOMEM); + return; + } + + if (jusername != NULL) { + username = getNativeString(env, jusername); + if (username == NULL) { + free(who); + free(newKey); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(who); + free(newKey); + throwAFSException(env, JAFSNULLUSER); + return; + } + + if (jnewPassword != NULL) { + newPassword = getNativeString(env, jnewPassword); + if (newPassword == NULL) { + free(who); + free(newKey); + free(username); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + free(who); + free(newKey); + free(username); + throwAFSException(env, JAFSNULLPASS); + return; + } + + // make sure the name is within the allowed bounds + if (strlen(username) > KAS_MAX_NAME_LEN) { + free(who); + free(newKey); + free(username); + free(newPassword); + throwAFSException(env, ADMPTSUSERNAMETOOLONG); + return; + } + + if (!afsclient_CellNameGet((void *)cellHandle, &cellName, &ast)) { + free(who); + free(newKey); + free(username); + free(newPassword); + throwAFSException(env, ast); + return; + } + + if (!kas_StringToKey(cellName, newPassword, newKey, &ast)) { + free(who); + free(newKey); + free(username); + free(newPassword); + throwAFSException(env, ast); + return; + } + + internal_makeKasIdentity(username, who); + + ast = 0; + // For some reason kas_PrincipalKeySet doesn't set the return code correctly. + // It always returns 0. + // So instead of checking the return code, we see if there's an error + // in the status variable. + kas_PrincipalKeySet((void *)cellHandle, NULL, who, 0, newKey, &ast); + if (ast) { + throwAFSException(env, ast); + } + + free(who); + free(newKey); + free(username); + free(newPassword); } /** @@ -1019,33 +1021,33 @@ Java_org_openafs_jafs_User_setPassword * jname the name of the user for which to get the groups * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_User_getUserGroupsBegin - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_User_getUserGroupsBegin(JNIEnv * env, jclass cls, + jint cellHandle, jstring jname) { - char *name; - afs_status_t ast; - void *iterationId; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( name == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return; + char *name; + afs_status_t ast; + void *iterationId; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (name == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLUSER); + return; } - } else { - throwAFSException( env, JAFSNULLUSER ); - return; - } - if ( !pts_UserMemberListBegin( (void *) cellHandle, name, &iterationId, - &ast ) ) { - throwAFSException( env, ast ); - } + if (!pts_UserMemberListBegin + ((void *)cellHandle, name, &iterationId, &ast)) { + throwAFSException(env, ast); + } - free( name ); + free(name); - return (jint) iterationId; + return (jint) iterationId; } /** @@ -1057,32 +1059,32 @@ Java_org_openafs_jafs_User_getUserGroupsBegin * iterationId the iteration ID of this iteration * returns the name of the next group */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_User_getUserGroupsNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_User_getUserGroupsNextString(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; - char *groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); - jstring jgroup; - - if ( !groupName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( !pts_UserMemberListNext( (void *) iterationId, groupName, &ast ) ) { - free( groupName ); - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return; - } - } - - jgroup = (*env)->NewStringUTF(env, groupName); - free( groupName ); - return jgroup; + afs_status_t ast; + char *groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); + jstring jgroup; + + if (!groupName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + + if (!pts_UserMemberListNext((void *)iterationId, groupName, &ast)) { + free(groupName); + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return; + } + } + + jgroup = (*env)->NewStringUTF(env, groupName); + free(groupName); + return jgroup; } /** @@ -1097,45 +1099,46 @@ Java_org_openafs_jafs_User_getUserGroupsNextString * next group * returns 0 if there are no more users, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_User_getUserGroupsNext - (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId, - jobject jgroupObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_User_getUserGroupsNext(JNIEnv * env, jclass cls, + jint cellHandle, + jint iterationId, + jobject jgroupObject) { - afs_status_t ast; - char *groupName; - jstring jgroup; + afs_status_t ast; + char *groupName; + jstring jgroup; - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); - if ( !groupName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } + if (!groupName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } - if ( !pts_UserMemberListNext( (void *) iterationId, groupName, &ast ) ) { - free( groupName ); - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + if (!pts_UserMemberListNext((void *)iterationId, groupName, &ast)) { + free(groupName); + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } } - } - jgroup = (*env)->NewStringUTF(env, groupName); + jgroup = (*env)->NewStringUTF(env, groupName); - if ( groupCls == 0 ) { - internal_getGroupClass( env, jgroupObject ); - } + if (groupCls == 0) { + internal_getGroupClass(env, jgroupObject); + } - (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup); + (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup); - getGroupInfoChar( env, (void *) cellHandle, groupName, jgroupObject ); - (*env)->SetBooleanField( env, jgroupObject, group_cachedInfoField, TRUE ); + getGroupInfoChar(env, (void *)cellHandle, groupName, jgroupObject); + (*env)->SetBooleanField(env, jgroupObject, group_cachedInfoField, TRUE); - free( groupName ); - return 1; + free(groupName); + return 1; } @@ -1146,16 +1149,16 @@ Java_org_openafs_jafs_User_getUserGroupsNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_getUserGroupsDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_User_getUserGroupsDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !pts_UserMemberListDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!pts_UserMemberListDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -1167,38 +1170,38 @@ Java_org_openafs_jafs_User_getUserGroupsDone * jname the name of the user for which to get the groups * returns total number of groups owned by the user */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_User_getGroupsOwnedCount - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_User_getGroupsOwnedCount(JNIEnv * env, jclass cls, + jint cellHandle, jstring jname) { - afs_status_t ast; - void *iterationId; - char *groupName; - int i = 0; + afs_status_t ast; + void *iterationId; + char *groupName; + int i = 0; - iterationId = - (void *) Java_org_openafs_jafs_User_getGroupsOwnedBegin( env, cls, - cellHandle, - jname ); + iterationId = + (void *)Java_org_openafs_jafs_User_getGroupsOwnedBegin(env, cls, + cellHandle, + jname); - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); - if ( !groupName ) { - throwAFSException( env, JAFSADMNOMEM ); - return -1; - } + if (!groupName) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } - while ( pts_OwnedGroupListNext( (void *) iterationId, groupName, &ast ) ) - i++; + while (pts_OwnedGroupListNext((void *)iterationId, groupName, &ast)) + i++; - free( groupName ); + free(groupName); - if ( ast != ADMITERATORDONE ) { - throwAFSException( env, ast ); - return -1; - } + if (ast != ADMITERATORDONE) { + throwAFSException(env, ast); + return -1; + } - return i; + return i; } /** @@ -1212,33 +1215,33 @@ Java_org_openafs_jafs_User_getGroupsOwnedCount * jname the name of the user or group for which to get the groups * returns an iteration ID */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_User_getGroupsOwnedBegin - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_User_getGroupsOwnedBegin(JNIEnv * env, jclass cls, + jint cellHandle, jstring jname) { - char *name; - afs_status_t ast; - void *iterationId; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( name == NULL ) { - throwAFSException( env, JAFSADMNOMEM ); - return -1; + char *name; + afs_status_t ast; + void *iterationId; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (name == NULL) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } + } else { + throwAFSException(env, JAFSNULLUSER); + return -1; } - } else { - throwAFSException( env, JAFSNULLUSER ); - return -1; - } - if ( !pts_OwnedGroupListBegin( (void *) cellHandle, name, - &iterationId, &ast ) ) { - throwAFSException( env, ast ); - } + if (!pts_OwnedGroupListBegin + ((void *)cellHandle, name, &iterationId, &ast)) { + throwAFSException(env, ast); + } - free( name ); + free(name); - return (jint) iterationId; + return (jint) iterationId; } /** @@ -1250,32 +1253,32 @@ Java_org_openafs_jafs_User_getGroupsOwnedBegin * iterationId the iteration ID of this iteration * returns the name of the next group */ -JNIEXPORT jstring JNICALL -Java_org_openafs_jafs_User_getGroupsOwnedNextString - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT jstring JNICALL +Java_org_openafs_jafs_User_getGroupsOwnedNextString(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; - char *groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); - jstring jgroup; - - if ( !groupName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - - if ( !pts_OwnedGroupListNext( (void *) iterationId, groupName, &ast ) ) { - free( groupName ); - if ( ast == ADMITERATORDONE ) { - return NULL; - } else { - throwAFSException( env, ast ); - return NULL; + afs_status_t ast; + char *groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); + jstring jgroup; + + if (!groupName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + + if (!pts_OwnedGroupListNext((void *)iterationId, groupName, &ast)) { + free(groupName); + if (ast == ADMITERATORDONE) { + return NULL; + } else { + throwAFSException(env, ast); + return NULL; + } } - } - - jgroup = (*env)->NewStringUTF(env, groupName); - free( groupName ); - return jgroup; + + jgroup = (*env)->NewStringUTF(env, groupName); + free(groupName); + return jgroup; } @@ -1291,45 +1294,46 @@ Java_org_openafs_jafs_User_getGroupsOwnedNextString * next group * returns 0 if there are no more users, != 0 otherwise */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_User_getGroupsOwnedNext - (JNIEnv *env, jclass cls, jint cellHandle, jint iterationId, - jobject jgroupObject) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_User_getGroupsOwnedNext(JNIEnv * env, jclass cls, + jint cellHandle, + jint iterationId, + jobject jgroupObject) { - afs_status_t ast; - char *groupName; - jstring jgroup; + afs_status_t ast; + char *groupName; + jstring jgroup; - groupName = (char *) malloc( sizeof(char)*PTS_MAX_NAME_LEN); + groupName = (char *)malloc(sizeof(char) * PTS_MAX_NAME_LEN); - if ( !groupName ) { - throwAFSException( env, JAFSADMNOMEM ); - return 0; - } + if (!groupName) { + throwAFSException(env, JAFSADMNOMEM); + return 0; + } - if ( !pts_OwnedGroupListNext( (void *) iterationId, groupName, &ast ) ) { - free( groupName ); - if ( ast == ADMITERATORDONE ) { - return 0; - } else { - throwAFSException( env, ast ); - return 0; + if (!pts_OwnedGroupListNext((void *)iterationId, groupName, &ast)) { + free(groupName); + if (ast == ADMITERATORDONE) { + return 0; + } else { + throwAFSException(env, ast); + return 0; + } } - } - jgroup = (*env)->NewStringUTF(env, groupName); + jgroup = (*env)->NewStringUTF(env, groupName); - if ( groupCls == 0 ) { - internal_getGroupClass( env, jgroupObject ); - } + if (groupCls == 0) { + internal_getGroupClass(env, jgroupObject); + } - (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup); + (*env)->SetObjectField(env, jgroupObject, group_nameField, jgroup); - getGroupInfoChar( env, (void *) cellHandle, groupName, jgroupObject ); - (*env)->SetBooleanField( env, jgroupObject, group_cachedInfoField, TRUE ); + getGroupInfoChar(env, (void *)cellHandle, groupName, jgroupObject); + (*env)->SetBooleanField(env, jgroupObject, group_cachedInfoField, TRUE); - free( groupName ); - return 1; + free(groupName); + return 1; } @@ -1340,25 +1344,24 @@ Java_org_openafs_jafs_User_getGroupsOwnedNext * cls the current Java class * iterationId the iteration ID of this iteration */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_getGroupsOwnedDone - (JNIEnv *env, jclass cls, jint iterationId) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_User_getGroupsOwnedDone(JNIEnv * env, jclass cls, + jint iterationId) { - afs_status_t ast; + afs_status_t ast; - if ( !pts_OwnedGroupListDone( (void *) iterationId, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!pts_OwnedGroupListDone((void *)iterationId, &ast)) { + throwAFSException(env, ast); + return; + } } // reclaim global memory being used by this portion JNIEXPORT void JNICALL -Java_org_openafs_jafs_User_reclaimUserMemory - (JNIEnv *env, jclass cls) +Java_org_openafs_jafs_User_reclaimUserMemory(JNIEnv * env, jclass cls) { - if ( userCls ) { - (*env)->DeleteGlobalRef(env, userCls); - userCls = 0; - } + if (userCls) { + (*env)->DeleteGlobalRef(env, userCls); + userCls = 0; + } } diff --git a/src/JAVA/libjafs/UserToken.c b/src/JAVA/libjafs/UserToken.c index e8395a4ec..1bd597fd5 100644 --- a/src/JAVA/libjafs/UserToken.c +++ b/src/JAVA/libjafs/UserToken.c @@ -42,11 +42,11 @@ pthread_mutex_t jafs_init_lock; extern pthread_mutex_t jafs_login_lock; extern int readCacheParms(char *afsMountPoint, char *afsConfDir, - char *afsCacheDir, int *cacheBlocks, - int *cacheFiles, int *cacheStatEntries, - int *dCacheSize, int *vCacheSize, int *chunkSize, - int *closeSynch, int *debug, int *nDaemons, - int *cacheFlags, char *logFile); + char *afsCacheDir, int *cacheBlocks, + int *cacheFiles, int *cacheStatEntries, + int *dCacheSize, int *vCacheSize, int *chunkSize, + int *closeSynch, int *debug, int *nDaemons, + int *cacheFlags, char *logFile); /** * Be carefull with the memory management: @@ -57,13 +57,14 @@ extern int readCacheParms(char *afsMountPoint, char *afsConfDir, * - For every malloc call the corresponding free. */ -int osi_audit(void) +int +osi_audit(void) { - return 0; + return 0; } -JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_callDebugger - (JNIEnv *env, jobject obj) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Token_callDebugger(JNIEnv * env, jobject obj) { fprintf(stderr, "callDebugger called\n"); __asm__("int $0x3"); @@ -81,72 +82,67 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_callDebugger * * throws AFSException */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_initUserSpace - (JNIEnv *env, jclass cls) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Token_initUserSpace(JNIEnv * env, jclass cls) { - char afsMountPoint[100], afsConfDir[100], afsCacheDir[100], logFile[100]; - jfieldID fid; - int pagval; - - /* Initialize each init parameter with its associated default value */ - int cacheBlocks = 100000; - int cacheFiles = 12500; - int cacheStatEntries = 8192; - int dCacheSize = 11398; - int vCacheSize = 128; - int chunkSize = 0; - int closeSynch = 0; - int debug = 0; - int nDaemons = 3; - int cacheFlags = -1; - - /* Initialize each init parameter with its associated default value */ - strcpy(afsMountPoint, "/afs"); - strcpy(afsConfDir, "/usr/afswsp/etc"); - strcpy(afsCacheDir, "/usr/afswsp/cache"); - strcpy(logFile, "/usr/afswsp/log/libjafs.log"); - - pthread_mutex_init(&jafs_init_lock, NULL); - pthread_mutex_lock(&jafs_init_lock); - - readCacheParms(afsMountPoint, afsConfDir, afsCacheDir, - &cacheBlocks, &cacheFiles, &cacheStatEntries, - &dCacheSize, &vCacheSize, &chunkSize, - &closeSynch, &debug, &nDaemons, &cacheFlags, - logFile); - - /* See cache.tune for configuration details */ - if (debug) { - fprintf(stderr, "uafs_Init(\"init_native\", \"%s\", \"%s\", \"%s\", + char afsMountPoint[100], afsConfDir[100], afsCacheDir[100], logFile[100]; + jfieldID fid; + int pagval; + + /* Initialize each init parameter with its associated default value */ + int cacheBlocks = 100000; + int cacheFiles = 12500; + int cacheStatEntries = 8192; + int dCacheSize = 11398; + int vCacheSize = 128; + int chunkSize = 0; + int closeSynch = 0; + int debug = 0; + int nDaemons = 3; + int cacheFlags = -1; + + /* Initialize each init parameter with its associated default value */ + strcpy(afsMountPoint, "/afs"); + strcpy(afsConfDir, "/usr/afswsp/etc"); + strcpy(afsCacheDir, "/usr/afswsp/cache"); + strcpy(logFile, "/usr/afswsp/log/libjafs.log"); + + pthread_mutex_init(&jafs_init_lock, NULL); + pthread_mutex_lock(&jafs_init_lock); + + readCacheParms(afsMountPoint, afsConfDir, afsCacheDir, &cacheBlocks, + &cacheFiles, &cacheStatEntries, &dCacheSize, &vCacheSize, + &chunkSize, &closeSynch, &debug, &nDaemons, &cacheFlags, + logFile); + + /* See cache.tune for configuration details */ + if (debug) { + fprintf(stderr, "uafs_Init(\"init_native\", \"%s\", \"%s\", \"%s\", %d, %d, %d, %d, %d, %d, - %d, %d, %d, %d, \"%s\");\n", - afsMountPoint, afsConfDir, afsCacheDir, - cacheBlocks, cacheFiles, cacheStatEntries, - dCacheSize, vCacheSize, chunkSize, - closeSynch, debug, nDaemons, cacheFlags, logFile); - } - uafs_Init("init_native", afsMountPoint, afsConfDir, afsCacheDir, - cacheBlocks, cacheFiles, cacheStatEntries, - dCacheSize, vCacheSize, chunkSize, - closeSynch, debug, nDaemons, cacheFlags, logFile); - - - /* make the initial pag the unauthenticated pag */ - afs_setpag(); - uafs_unlog(); - pagval = afs_getpag_val(); - - fid = (*env)->GetStaticFieldID(env, cls, "ANYUSER_PAG_ID", "I"); - if (fid == 0) { - fprintf(stderr, - "UserToken::init(): GetFieldID (ANYUSER_PAG_ID) failed\n"); - return; - } - - (*env)->SetStaticIntField(env, cls, fid, pagval); - - pthread_mutex_unlock(&jafs_init_lock); + %d, %d, %d, %d, \"%s\");\n", afsMountPoint, afsConfDir, afsCacheDir, cacheBlocks, cacheFiles, cacheStatEntries, dCacheSize, vCacheSize, chunkSize, closeSynch, debug, nDaemons, cacheFlags, logFile); + } + uafs_Init("init_native", afsMountPoint, afsConfDir, afsCacheDir, + cacheBlocks, cacheFiles, cacheStatEntries, dCacheSize, + vCacheSize, chunkSize, closeSynch, debug, nDaemons, cacheFlags, + logFile); + + + /* make the initial pag the unauthenticated pag */ + afs_setpag(); + uafs_unlog(); + pagval = afs_getpag_val(); + + fid = (*env)->GetStaticFieldID(env, cls, "ANYUSER_PAG_ID", "I"); + if (fid == 0) { + fprintf(stderr, + "UserToken::init(): GetFieldID (ANYUSER_PAG_ID) failed\n"); + return; + } + + (*env)->SetStaticIntField(env, cls, fid, pagval); + + pthread_mutex_unlock(&jafs_init_lock); } /** @@ -164,87 +160,103 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_initUserSpace * throws AFSException */ JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Token_klog (JNIEnv *env, jobject obj, - jstring jusername, jstring jpassword, jstring jcell, jint id) +Java_org_openafs_jafs_Token_klog(JNIEnv * env, jobject obj, jstring jusername, + jstring jpassword, jstring jcell, jint id) { - char *username; - char *password; - char *cell; - char *reason; - int code; - jint rc = -1; - - if ( jcell != NULL ) { - cell = getNativeString(env, jcell); - if ( !cell ) { - fprintf(stderr, "UserToken::klog(): failed to get cell name\n"); - throwMessageException( env, "Internal error, failed to translate cell name." ); - return -1; + char *username; + char *password; + char *cell; + char *reason; + int code; + jint rc = -1; + + if (jcell != NULL) { + cell = getNativeString(env, jcell); + if (!cell) { + fprintf(stderr, "UserToken::klog(): failed to get cell name\n"); + throwMessageException(env, + "Internal error, failed to translate cell name."); + return -1; + } + } else { + cell = NULL; } - } else { - cell = NULL; - } - - if ( jusername != NULL ) { - username = getNativeString(env, jusername); - if ( !username ) { - if ( cell != NULL ) free( cell ); - fprintf(stderr, "UserToken::klog(): failed to get username\n"); - throwMessageException( env, "Internal error, failed to translate username." ); - return -1; + + if (jusername != NULL) { + username = getNativeString(env, jusername); + if (!username) { + if (cell != NULL) + free(cell); + fprintf(stderr, "UserToken::klog(): failed to get username\n"); + throwMessageException(env, + "Internal error, failed to translate username."); + return -1; + } + } else { + if (cell != NULL) + free(cell); + throwAFSException(env, JAFSNULLUSER); + return -1; + } + + if (jpassword != NULL) { + password = getNativeString(env, jpassword); + if (!password) { + if (cell != NULL) + free(cell); + free(username); + fprintf(stderr, "UserToken::klog(): failed to get password\n"); + throwMessageException(env, + "Internal error, failed to translate password."); + return -1; + } + } else { + if (cell != NULL) + free(cell); + free(username); + throwAFSException(env, JAFSNULLPASS); + return -1; } - } else { - if ( cell != NULL ) free( cell ); - throwAFSException( env, JAFSNULLUSER ); - return -1; - } - - if ( jpassword != NULL ) { - password = getNativeString(env, jpassword); - if ( !password ) { - if ( cell != NULL ) free( cell ); - free( username ); - fprintf(stderr, "UserToken::klog(): failed to get password\n"); - throwMessageException( env, "Internal error, failed to translate password." ); - return -1; + + if (id == 0) { + code = uafs_klog(username, cell, password, &reason); + } else { + /* Use existing PAG for this thread */ + code = afs_setpag_val(id); + if (code != 0) + code = 180492L; /* KABADARGUMENT */ + if (!code) + code = uafs_klog_nopag(username, cell, password, &reason); } - } else { - if ( cell != NULL ) free( cell ); - free( username ); - throwAFSException( env, JAFSNULLPASS ); - return -1; - } - - if (id == 0) { - code = uafs_klog(username, cell, password, &reason); - } else { - /* Use existing PAG for this thread */ - code = afs_setpag_val(id); - if (code != 0) code = 180492L; /* KABADARGUMENT */ - if (!code) code = uafs_klog_nopag(username, cell, password, &reason); - } - - if (code != 0) { - if ( cell != NULL ) free( cell ); - if ( username != NULL ) free( username ); - if ( password != NULL ) free( password ); - fprintf(stderr, "UserToken::klog(): uafs_klog failed to cell %s: %s\n", - cell, reason); - fprintf(stderr, "code = %d\n", code); - throwAFSException( env, code ); - return -1; - } - - /* Get the PAG we were assigned as the return value */ - rc = afs_getpag_val(); - - /* clean up */ - if ( cell != NULL ) free( cell ); - if ( username != NULL ) free( username ); - if ( password != NULL ) free( password ); - - /* return PAG ID */ - return rc; + + if (code != 0) { + if (cell != NULL) + free(cell); + if (username != NULL) + free(username); + if (password != NULL) + free(password); + fprintf(stderr, + "UserToken::klog(): uafs_klog failed to cell %s: %s\n", cell, + reason); + fprintf(stderr, "code = %d\n", code); + throwAFSException(env, code); + return -1; + } + + /* Get the PAG we were assigned as the return value */ + rc = afs_getpag_val(); + + /* clean up */ + if (cell != NULL) + free(cell); + if (username != NULL) + free(username); + if (password != NULL) + free(password); + + /* return PAG ID */ + return rc; } /** @@ -261,16 +273,16 @@ Java_org_openafs_jafs_Token_klog (JNIEnv *env, jobject obj, * * throws AFSException */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_relog - (JNIEnv *env, jobject obj, jint id) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Token_relog(JNIEnv * env, jobject obj, jint id) { - int rc; + int rc; - rc = afs_setpag_val(id); + rc = afs_setpag_val(id); - if (rc != 0) { - throwAFSException( env, rc ); - } + if (rc != 0) { + throwAFSException(env, rc); + } } /** @@ -282,16 +294,16 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_relog * * throws AFSException */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_unlog - (JNIEnv *env, jobject obj) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Token_unlog(JNIEnv * env, jobject obj) { - int rc; + int rc; - rc = uafs_unlog(); + rc = uafs_unlog(); - if (rc != 0) { - throwAFSException( env, rc ); - } + if (rc != 0) { + throwAFSException(env, rc); + } } /** @@ -306,8 +318,8 @@ JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_unlog * * throws AFSException */ -JNIEXPORT void JNICALL Java_org_openafs_jafs_Token_shutdown - (JNIEnv *env, jobject obj) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Token_shutdown(JNIEnv * env, jobject obj) { - uafs_Shutdown(); + uafs_Shutdown(); } diff --git a/src/JAVA/libjafs/Volume.c b/src/JAVA/libjafs/Volume.c index 4cf74af54..ef2f3c432 100644 --- a/src/JAVA/libjafs/Volume.c +++ b/src/JAVA/libjafs/Volume.c @@ -56,168 +56,168 @@ extern jfieldID volume_typeField; * volume the Volume object to populate with the info * volEntry the container of the volume's information */ -extern void fillVolumeInfo - ( JNIEnv *env, jobject volume, vos_volumeEntry_t volEntry ) +extern void +fillVolumeInfo(JNIEnv * env, jobject volume, vos_volumeEntry_t volEntry) { - jstring jvolume; - - // get the class fields if need be - if ( volumeCls == 0 ) { - internal_getVolumeClass( env, volume ); - } - - // set name, just in case it was a completely blank object - jvolume = (*env)->NewStringUTF(env, volEntry.name); - (*env)->SetObjectField(env, volume, volume_nameField, jvolume); - - (*env)->SetIntField(env, volume, volume_idField, volEntry.id); - (*env)->SetIntField(env, volume, volume_readWriteIdField, - volEntry.readWriteId); - (*env)->SetIntField(env, volume, volume_readOnlyIdField, - volEntry.readOnlyId); - (*env)->SetIntField(env, volume, volume_backupIdField, volEntry.backupId); - (*env)->SetLongField(env, volume, volume_creationDateField, - volEntry.creationDate); - (*env)->SetLongField(env, volume, volume_lastAccessDateField, - volEntry.lastAccessDate); - (*env)->SetLongField(env, volume, volume_lastUpdateDateField, - volEntry.lastUpdateDate); - (*env)->SetLongField(env, volume, volume_lastBackupDateField, - volEntry.lastBackupDate); - (*env)->SetLongField(env, volume, volume_copyCreationDateField, - volEntry.copyCreationDate); - (*env)->SetIntField(env, volume, volume_accessesSinceMidnightField, - volEntry.accessesSinceMidnight); - (*env)->SetIntField(env, volume, volume_fileCountField, volEntry.fileCount); - (*env)->SetIntField(env, volume, volume_maxQuotaField, volEntry.maxQuota); - (*env)->SetIntField(env, volume, volume_currentSizeField, - volEntry.currentSize); - - // set status variable - switch( volEntry.status ) { - case VOS_OK : - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_OK); - break; - case VOS_SALVAGE : - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_SALVAGE); - break; - case VOS_NO_VNODE: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_NO_VNODE); - break; - case VOS_NO_VOL: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_NO_VOL); - break; - case VOS_VOL_EXISTS: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_VOL_EXISTS); - break; - case VOS_NO_SERVICE: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_NO_SERVICE); - break; - case VOS_OFFLINE: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_OFFLINE); - break; - case VOS_ONLINE: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_ONLINE); - break; - case VOS_DISK_FULL: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_DISK_FULL); - break; - case VOS_OVER_QUOTA: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_OVER_QUOTA); - break; - case VOS_BUSY: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_BUSY); - break; - case VOS_MOVED: - (*env)->SetIntField(env, volume, volume_statusField, - org_openafs_jafs_Volume_VOLUME_MOVED); - break; - default: - throwAFSException( env, volEntry.status ); - } - - // set disposition variable - switch( volEntry.volumeDisposition ) { - case VOS_OK : - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_OK); - break; - case VOS_SALVAGE : - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_SALVAGE); - break; - case VOS_NO_VNODE: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_NO_VNODE); - break; - case VOS_NO_VOL: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_NO_VOL); - break; - case VOS_VOL_EXISTS: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_VOL_EXISTS); - break; - case VOS_NO_SERVICE: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_NO_SERVICE); - break; - case VOS_OFFLINE: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_OFFLINE); - break; - case VOS_ONLINE: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_ONLINE); - break; - case VOS_DISK_FULL: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_DISK_FULL); - break; - case VOS_OVER_QUOTA: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_OVER_QUOTA); - break; - case VOS_BUSY: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_BUSY); - break; - case VOS_MOVED: - (*env)->SetIntField(env, volume, volume_dispositionField, - org_openafs_jafs_Volume_VOLUME_MOVED); - break; - default: - throwAFSException( env, volEntry.volumeDisposition ); - } - - // set type variable - switch( volEntry.type ) { - case VOS_READ_WRITE_VOLUME: - (*env)->SetIntField(env, volume, volume_typeField, - org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE); - break; - case VOS_READ_ONLY_VOLUME: - (*env)->SetIntField(env, volume, volume_typeField, - org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY); - break; - case VOS_BACKUP_VOLUME: - (*env)->SetIntField(env, volume, volume_typeField, - org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP); - break; - default: - throwAFSException( env, volEntry.type ); - } + jstring jvolume; + + // get the class fields if need be + if (volumeCls == 0) { + internal_getVolumeClass(env, volume); + } + // set name, just in case it was a completely blank object + jvolume = (*env)->NewStringUTF(env, volEntry.name); + (*env)->SetObjectField(env, volume, volume_nameField, jvolume); + + (*env)->SetIntField(env, volume, volume_idField, volEntry.id); + (*env)->SetIntField(env, volume, volume_readWriteIdField, + volEntry.readWriteId); + (*env)->SetIntField(env, volume, volume_readOnlyIdField, + volEntry.readOnlyId); + (*env)->SetIntField(env, volume, volume_backupIdField, volEntry.backupId); + (*env)->SetLongField(env, volume, volume_creationDateField, + volEntry.creationDate); + (*env)->SetLongField(env, volume, volume_lastAccessDateField, + volEntry.lastAccessDate); + (*env)->SetLongField(env, volume, volume_lastUpdateDateField, + volEntry.lastUpdateDate); + (*env)->SetLongField(env, volume, volume_lastBackupDateField, + volEntry.lastBackupDate); + (*env)->SetLongField(env, volume, volume_copyCreationDateField, + volEntry.copyCreationDate); + (*env)->SetIntField(env, volume, volume_accessesSinceMidnightField, + volEntry.accessesSinceMidnight); + (*env)->SetIntField(env, volume, volume_fileCountField, + volEntry.fileCount); + (*env)->SetIntField(env, volume, volume_maxQuotaField, volEntry.maxQuota); + (*env)->SetIntField(env, volume, volume_currentSizeField, + volEntry.currentSize); + + // set status variable + switch (volEntry.status) { + case VOS_OK: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_OK); + break; + case VOS_SALVAGE: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_SALVAGE); + break; + case VOS_NO_VNODE: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_NO_VNODE); + break; + case VOS_NO_VOL: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_NO_VOL); + break; + case VOS_VOL_EXISTS: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_VOL_EXISTS); + break; + case VOS_NO_SERVICE: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_NO_SERVICE); + break; + case VOS_OFFLINE: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_OFFLINE); + break; + case VOS_ONLINE: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_ONLINE); + break; + case VOS_DISK_FULL: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_DISK_FULL); + break; + case VOS_OVER_QUOTA: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_OVER_QUOTA); + break; + case VOS_BUSY: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_BUSY); + break; + case VOS_MOVED: + (*env)->SetIntField(env, volume, volume_statusField, + org_openafs_jafs_Volume_VOLUME_MOVED); + break; + default: + throwAFSException(env, volEntry.status); + } + + // set disposition variable + switch (volEntry.volumeDisposition) { + case VOS_OK: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_OK); + break; + case VOS_SALVAGE: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_SALVAGE); + break; + case VOS_NO_VNODE: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_NO_VNODE); + break; + case VOS_NO_VOL: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_NO_VOL); + break; + case VOS_VOL_EXISTS: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_VOL_EXISTS); + break; + case VOS_NO_SERVICE: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_NO_SERVICE); + break; + case VOS_OFFLINE: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_OFFLINE); + break; + case VOS_ONLINE: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_ONLINE); + break; + case VOS_DISK_FULL: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_DISK_FULL); + break; + case VOS_OVER_QUOTA: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_OVER_QUOTA); + break; + case VOS_BUSY: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_BUSY); + break; + case VOS_MOVED: + (*env)->SetIntField(env, volume, volume_dispositionField, + org_openafs_jafs_Volume_VOLUME_MOVED); + break; + default: + throwAFSException(env, volEntry.volumeDisposition); + } + + // set type variable + switch (volEntry.type) { + case VOS_READ_WRITE_VOLUME: + (*env)->SetIntField(env, volume, volume_typeField, + org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE); + break; + case VOS_READ_ONLY_VOLUME: + (*env)->SetIntField(env, volume, volume_typeField, + org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY); + break; + case VOS_BACKUP_VOLUME: + (*env)->SetIntField(env, volume, volume_typeField, + org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP); + break; + default: + throwAFSException(env, volEntry.type); + } } @@ -235,23 +235,24 @@ extern void fillVolumeInfo * jvolumeObject the Volume object in which to fill in * the information */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_getVolumeInfo - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition, - jint volID, jobject jvolumeObject) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_getVolumeInfo(JNIEnv * env, jclass cls, + jint cellHandle, jint serverHandle, + jint partition, jint volID, + jobject jvolumeObject) { - afs_status_t ast; - vos_volumeEntry_t volEntry; - - // get the volume entry - if ( !vos_VolumeGet( (void *) cellHandle, (void *) serverHandle, NULL, - (unsigned int) partition, (unsigned int) volID, - &volEntry, &ast ) ) { - throwAFSException( env, ast ); - return; - } - - fillVolumeInfo( env, jvolumeObject, volEntry ); + afs_status_t ast; + vos_volumeEntry_t volEntry; + + // get the volume entry + if (!vos_VolumeGet + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, (unsigned int)volID, &volEntry, &ast)) { + throwAFSException(env, ast); + return; + } + + fillVolumeInfo(env, jvolumeObject, volEntry); } /** @@ -268,35 +269,35 @@ Java_org_openafs_jafs_Volume_getVolumeInfo * quota the amount of space (in KB) to set as this volume's quota * returns the numeric ID assigned to the volume */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Volume_create - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, - jint partition, jstring jvolName, jint quota) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Volume_create(JNIEnv * env, jclass cls, jint cellHandle, + jint serverHandle, jint partition, + jstring jvolName, jint quota) { - afs_status_t ast; - char *volName; - int id; - - if ( jvolName != NULL ) { - volName = getNativeString(env, jvolName); - if ( !volName ) { - throwAFSException( env, JAFSADMNOMEM ); + afs_status_t ast; + char *volName; + int id; + + if (jvolName != NULL) { + volName = getNativeString(env, jvolName); + if (!volName) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } + } else { + throwAFSException(env, JAFSNULLVOLUME); return -1; } - } else { - throwAFSException( env, JAFSNULLVOLUME ); - return -1; - } - if ( !vos_VolumeCreate( (void *) cellHandle, (void *) serverHandle, NULL, - (unsigned int) partition, volName, - (unsigned int) quota, &id, &ast ) ) { - throwAFSException( env, ast ); - } + if (!vos_VolumeCreate + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, volName, (unsigned int)quota, &id, &ast)) { + throwAFSException(env, ast); + } - free( volName ); + free(volName); - return (jint) id; + return (jint) id; } /** @@ -311,19 +312,19 @@ Java_org_openafs_jafs_Volume_create * the volume * volId the numeric id of the volume to delete */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_delete - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, - jint partition, jint volID) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_delete(JNIEnv * env, jclass cls, jint cellHandle, + jint serverHandle, jint partition, + jint volID) { - afs_status_t ast; - - if ( !vos_VolumeDelete( (void *) cellHandle, (void *) serverHandle, NULL, - (unsigned int) partition, - (unsigned int) volID, &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + + if (!vos_VolumeDelete + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, (unsigned int)volID, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -335,17 +336,17 @@ Java_org_openafs_jafs_Volume_delete * volId the numeric id of the volume for which to create a backup * volume */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_createBackupVolume - (JNIEnv *env, jclass cls, jint cellHandle, jint volID) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_createBackupVolume(JNIEnv * env, jclass cls, + jint cellHandle, jint volID) { - afs_status_t ast; + afs_status_t ast; - if ( !vos_BackupVolumeCreate( (void *) cellHandle, NULL, - (unsigned int) volID, &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!vos_BackupVolumeCreate + ((void *)cellHandle, NULL, (unsigned int)volID, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -361,19 +362,20 @@ Java_org_openafs_jafs_Volume_createBackupVolume * volId the numeric id of the volume for which to * create a read-only volume */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_createReadOnlyVolume - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition, - jint volID) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_createReadOnlyVolume(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle, + jint partition, jint volID) { - afs_status_t ast; - - if ( !vos_VLDBReadOnlySiteCreate( (void *) cellHandle, (void *) serverHandle, - NULL, (unsigned int) partition, - (unsigned int) volID, &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + + if (!vos_VLDBReadOnlySiteCreate + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, (unsigned int)volID, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -389,19 +391,20 @@ Java_org_openafs_jafs_Volume_createReadOnlyVolume * volId the numeric read-write id of the volume for which to * delete the read-only volume */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_deleteReadOnlyVolume - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition, - jint volID) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_deleteReadOnlyVolume(JNIEnv * env, jclass cls, + jint cellHandle, + jint serverHandle, + jint partition, jint volID) { - afs_status_t ast; - - if ( !vos_VLDBReadOnlySiteDelete( (void *) cellHandle, (void *) serverHandle, - NULL, (unsigned int) partition, - (unsigned int) volID, &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + + if (!vos_VLDBReadOnlySiteDelete + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, (unsigned int)volID, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -417,20 +420,21 @@ Java_org_openafs_jafs_Volume_deleteReadOnlyVolume * volId the numeric id of the volume for which to change the quota * newQuota the new quota (in KB) to assign the volume */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_changeQuota - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition, - jint volID, jint newQuota) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_changeQuota(JNIEnv * env, jclass cls, + jint cellHandle, jint serverHandle, + jint partition, jint volID, + jint newQuota) { - afs_status_t ast; - - if ( !vos_VolumeQuotaChange( (void *) cellHandle, (void *) serverHandle, - NULL, (unsigned int) partition, - (unsigned int) volID, (unsigned int) newQuota, - &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + + if (!vos_VolumeQuotaChange + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, (unsigned int)volID, (unsigned int)newQuota, + &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -449,20 +453,21 @@ Java_org_openafs_jafs_Volume_changeQuota * should be moved * volId the numeric id of the volume to move */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_move - (JNIEnv *env, jclass cls, jint cellHandle, jint fromServerHandle, - jint fromPartition, jint toServerHandle, jint toPartition, jint volID) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_move(JNIEnv * env, jclass cls, jint cellHandle, + jint fromServerHandle, jint fromPartition, + jint toServerHandle, jint toPartition, + jint volID) { - afs_status_t ast; - - if ( !vos_VolumeMove( (void *) cellHandle, NULL, (unsigned int) volID, - (void *) fromServerHandle, (unsigned int) fromPartition, - (void *) toServerHandle, (unsigned int) toPartition, - &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + + if (!vos_VolumeMove + ((void *)cellHandle, NULL, (unsigned int)volID, + (void *)fromServerHandle, (unsigned int)fromPartition, + (void *)toServerHandle, (unsigned int)toPartition, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -474,24 +479,25 @@ Java_org_openafs_jafs_Volume_move * volId the numeric id of the volume to release * forceComplete whether or not to force a complete release */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_release - (JNIEnv *env, jclass cls, jint cellHandle, jint volID, jboolean forceComplete) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_release(JNIEnv * env, jclass cls, + jint cellHandle, jint volID, + jboolean forceComplete) { - afs_status_t ast; - vos_force_t force; - - if ( forceComplete ) { - force = VOS_FORCE; - } else { - force = VOS_NORMAL; - } - - if ( !vos_VolumeRelease( (void *) cellHandle, NULL, (unsigned int) volID, - force, &ast )) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + vos_force_t force; + + if (forceComplete) { + force = VOS_FORCE; + } else { + force = VOS_NORMAL; + } + + if (!vos_VolumeRelease + ((void *)cellHandle, NULL, (unsigned int)volID, force, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -509,32 +515,34 @@ Java_org_openafs_jafs_Volume_release * be dumped * jdumpFile the full path of the file to which to dump */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_dump - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition, - jint volID, jint startTime, jstring jdumpFile) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_dump(JNIEnv * env, jclass cls, jint cellHandle, + jint serverHandle, jint partition, + jint volID, jint startTime, + jstring jdumpFile) { - afs_status_t ast; - char *dumpFile; - - if ( jdumpFile != NULL ) { - dumpFile = getNativeString(env, jdumpFile); - if ( !dumpFile ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLARG ); - return; - } - - if ( !vos_VolumeDump( (void *) cellHandle, (void *) serverHandle, NULL, - (unsigned int *) &partition, (unsigned int) volID, - (unsigned int) startTime, dumpFile, &ast ) ) { - throwAFSException( env, ast ); - } - - free( dumpFile ); + afs_status_t ast; + char *dumpFile; + + if (jdumpFile != NULL) { + dumpFile = getNativeString(env, jdumpFile); + if (!dumpFile) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLARG); + return; + } + + if (!vos_VolumeDump + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int *)&partition, (unsigned int)volID, + (unsigned int)startTime, dumpFile, &ast)) { + throwAFSException(env, ast); + } + + free(dumpFile); } /** @@ -555,59 +563,63 @@ Java_org_openafs_jafs_Volume_dump * indicate the current position of the existing volume), * otherwise restores a full dump */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_restore - (JNIEnv *env, jclass cls, jint cellHandle, jint serverHandle, jint partition, - jint volID, jstring jvolName, jstring jdumpFile, jboolean incremental) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_restore(JNIEnv * env, jclass cls, + jint cellHandle, jint serverHandle, + jint partition, jint volID, + jstring jvolName, jstring jdumpFile, + jboolean incremental) { - afs_status_t ast; - char *volName; - char *dumpFile; - int *volumeIDp; - vos_volumeRestoreType_t vrt; - - if ( jvolName != NULL ) { - volName = getNativeString(env, jvolName); - if ( !volName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLVOLUME ); - return; - } - - if ( jdumpFile != NULL ) { - dumpFile = getNativeString(env, jdumpFile); - if ( !dumpFile ) { - free( volName ); - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - dumpFile = NULL; - } - - if ( volID == 0 ) { - volumeIDp = NULL; - } else { - volumeIDp = (int *) &volID; - } - - if ( incremental ) { - vrt = VOS_RESTORE_INCREMENTAL; - } else { - vrt = VOS_RESTORE_FULL; - } - - if ( !vos_VolumeRestore( (void *) cellHandle, (void *) serverHandle, NULL, - (unsigned int) partition, (unsigned int *) volumeIDp, - volName, dumpFile, vrt, &ast ) ) { - throwAFSException( env, ast ); - } - - if ( dumpFile != NULL ) free( dumpFile ); - free( volName ); + afs_status_t ast; + char *volName; + char *dumpFile; + int *volumeIDp; + vos_volumeRestoreType_t vrt; + + if (jvolName != NULL) { + volName = getNativeString(env, jvolName); + if (!volName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLVOLUME); + return; + } + + if (jdumpFile != NULL) { + dumpFile = getNativeString(env, jdumpFile); + if (!dumpFile) { + free(volName); + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + dumpFile = NULL; + } + + if (volID == 0) { + volumeIDp = NULL; + } else { + volumeIDp = (int *)&volID; + } + + if (incremental) { + vrt = VOS_RESTORE_INCREMENTAL; + } else { + vrt = VOS_RESTORE_FULL; + } + + if (!vos_VolumeRestore + ((void *)cellHandle, (void *)serverHandle, NULL, + (unsigned int)partition, (unsigned int *)volumeIDp, volName, + dumpFile, vrt, &ast)) { + throwAFSException(env, ast); + } + + if (dumpFile != NULL) + free(dumpFile); + free(volName); } /** @@ -619,30 +631,30 @@ Java_org_openafs_jafs_Volume_restore * volId the numeric id of the read-write volume to rename * jnewName the new name for the volume */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_rename - (JNIEnv *env, jclass cls, jint cellHandle, jint volID, jstring jnewName) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_rename(JNIEnv * env, jclass cls, jint cellHandle, + jint volID, jstring jnewName) { - afs_status_t ast; - char *newName; - - if ( jnewName != NULL ) { - newName = getNativeString(env, jnewName); - if ( !newName ) { - throwAFSException( env, JAFSADMNOMEM ); - return; - } - } else { - throwAFSException( env, JAFSNULLVOLUME ); - return; - } - - if ( !vos_VolumeRename( (void *) cellHandle, NULL, (unsigned int) volID, - newName, &ast ) ) { - throwAFSException( env, ast ); - } - - free( newName ); + afs_status_t ast; + char *newName; + + if (jnewName != NULL) { + newName = getNativeString(env, jnewName); + if (!newName) { + throwAFSException(env, JAFSADMNOMEM); + return; + } + } else { + throwAFSException(env, JAFSNULLVOLUME); + return; + } + + if (!vos_VolumeRename + ((void *)cellHandle, NULL, (unsigned int)volID, newName, &ast)) { + throwAFSException(env, ast); + } + + free(newName); } /** @@ -660,26 +672,27 @@ Java_org_openafs_jafs_Volume_rename * offline ? (not sure what this is either, probably the current * status of the volume -- busy or offline) */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_mount - (JNIEnv *env, jclass cls, jint serverHandle, jint partition, jint volID, - jint sleepTime, jboolean offline) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_mount(JNIEnv * env, jclass cls, + jint serverHandle, jint partition, + jint volID, jint sleepTime, + jboolean offline) { - afs_status_t ast; - vos_volumeOnlineType_t volumeStatus; - - if ( offline ) { - volumeStatus = VOS_ONLINE_OFFLINE; - } else { - volumeStatus = VOS_ONLINE_BUSY; - } - - if ( !vos_VolumeOnline( (void *) serverHandle, NULL, (unsigned int) partition, - (unsigned int) volID, (unsigned int) sleepTime, - volumeStatus, &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + vos_volumeOnlineType_t volumeStatus; + + if (offline) { + volumeStatus = VOS_ONLINE_OFFLINE; + } else { + volumeStatus = VOS_ONLINE_BUSY; + } + + if (!vos_VolumeOnline + ((void *)serverHandle, NULL, (unsigned int)partition, + (unsigned int)volID, (unsigned int)sleepTime, volumeStatus, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -693,18 +706,19 @@ Java_org_openafs_jafs_Volume_mount * resides * volId the numeric id of the volume to bring offline */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_unmount - (JNIEnv *env, jclass cls, jint serverHandle, jint partition, jint volID) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_unmount(JNIEnv * env, jclass cls, + jint serverHandle, jint partition, + jint volID) { - afs_status_t ast; - - if ( !vos_VolumeOffline( (void *) serverHandle, NULL, - (unsigned int) partition, (unsigned int) volID, - &ast ) ) { - throwAFSException( env, ast ); - return; - } + afs_status_t ast; + + if (!vos_VolumeOffline + ((void *)serverHandle, NULL, (unsigned int)partition, + (unsigned int)volID, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -715,17 +729,17 @@ Java_org_openafs_jafs_Volume_unmount * cellHandle the handle of the cell on which the volume resides * volId the numeric id of the volume to lock */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_lock - (JNIEnv *env, jclass cls, jint cellHandle, jint volID ) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_lock(JNIEnv * env, jclass cls, jint cellHandle, + jint volID) { - afs_status_t ast; + afs_status_t ast; - if ( !vos_VLDBEntryLock( (void *) cellHandle, NULL, (unsigned int) volID, - &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!vos_VLDBEntryLock + ((void *)cellHandle, NULL, (unsigned int)volID, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -736,17 +750,17 @@ Java_org_openafs_jafs_Volume_lock * cellHandle the handle of the cell on which the volume resides * volId the numeric id of the volume to unlock */ -JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_unlock - (JNIEnv *env, jclass cls, jint cellHandle, jint volID) +JNIEXPORT void JNICALL +Java_org_openafs_jafs_Volume_unlock(JNIEnv * env, jclass cls, jint cellHandle, + jint volID) { - afs_status_t ast; + afs_status_t ast; - if ( !vos_VLDBEntryUnlock( (void *) cellHandle, NULL, (unsigned int) volID, - &ast ) ) { - throwAFSException( env, ast ); - return; - } + if (!vos_VLDBEntryUnlock + ((void *)cellHandle, NULL, (unsigned int)volID, &ast)) { + throwAFSException(env, ast); + return; + } } /** @@ -764,53 +778,52 @@ Java_org_openafs_jafs_Volume_unlock * org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP * returns the id of the volume in question */ -JNIEXPORT jint JNICALL -Java_org_openafs_jafs_Volume_translateNameToID - (JNIEnv *env, jclass cls, jint cellHandle, jstring jname, jint type) +JNIEXPORT jint JNICALL +Java_org_openafs_jafs_Volume_translateNameToID(JNIEnv * env, jclass cls, + jint cellHandle, jstring jname, + jint type) { - afs_status_t ast; - char *name; - vos_vldbEntry_t vldbEntry; - - if ( jname != NULL ) { - name = getNativeString(env, jname); - if ( !name ) { - throwAFSException( env, JAFSADMNOMEM ); + afs_status_t ast; + char *name; + vos_vldbEntry_t vldbEntry; + + if (jname != NULL) { + name = getNativeString(env, jname); + if (!name) { + throwAFSException(env, JAFSADMNOMEM); + return -1; + } + } else { + throwAFSException(env, JAFSNULLVOLUME); return -1; - } - } else { - throwAFSException( env, JAFSNULLVOLUME ); - return -1; - } - - // get the id - if ( !vos_VLDBGet( (void *) cellHandle, NULL, NULL, name, - &vldbEntry, &ast ) ) { - free( name ); - throwAFSException( env, ast ); - return -1; - } - - free( name ); - - if ( type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE ) { - return vldbEntry.volumeId[VOS_READ_WRITE_VOLUME]; - } else if ( type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY ) { - return vldbEntry.volumeId[VOS_READ_ONLY_VOLUME]; - } else { - return vldbEntry.volumeId[VOS_BACKUP_VOLUME]; - } + } + + // get the id + if (!vos_VLDBGet((void *)cellHandle, NULL, NULL, name, &vldbEntry, &ast)) { + free(name); + throwAFSException(env, ast); + return -1; + } + + free(name); + + if (type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE) { + return vldbEntry.volumeId[VOS_READ_WRITE_VOLUME]; + } else if (type == org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY) { + return vldbEntry.volumeId[VOS_READ_ONLY_VOLUME]; + } else { + return vldbEntry.volumeId[VOS_BACKUP_VOLUME]; + } } // reclaim global memory being used by this portion JNIEXPORT void JNICALL -Java_org_openafs_jafs_Volume_reclaimVolumeMemory - (JNIEnv *env, jclass cls) +Java_org_openafs_jafs_Volume_reclaimVolumeMemory(JNIEnv * env, jclass cls) { - if ( volumeCls ) { - (*env)->DeleteGlobalRef(env, volumeCls); - volumeCls = 0; - } + if (volumeCls) { + (*env)->DeleteGlobalRef(env, volumeCls); + volumeCls = 0; + } } diff --git a/src/afs/AIX/osi_config.c b/src/afs/AIX/osi_config.c index 4fd353361..c1ebc3fca 100644 --- a/src/afs/AIX/osi_config.c +++ b/src/afs/AIX/osi_config.c @@ -36,7 +36,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "sys/limits.h" #include "sys/types.h" @@ -50,14 +51,14 @@ RCSID("$Header$"); #include "sys/gfs.h" #include "sys/uio.h" #include "sys/pri.h" -#include "sys/priv.h" /* XXX */ +#include "sys/priv.h" /* XXX */ #include "sys/lockl.h" #include "sys/malloc.h" -#include /* to define the assert and ASSERT macros */ -#include /* For the timer related defines */ -#include /* for the serialization defines */ -#include /* for the parameters to xmalloc() */ -#include "afs/afs_osi.h" /* pick up osi_timeval_t for afs_stats.h */ +#include /* to define the assert and ASSERT macros */ +#include /* For the timer related defines */ +#include /* for the serialization defines */ +#include /* for the parameters to xmalloc() */ +#include "afs/afs_osi.h" /* pick up osi_timeval_t for afs_stats.h */ #include "afs/afs_stats.h" #include "export.h" @@ -66,9 +67,12 @@ RCSID("$Header$"); #else #define KOFF_PRESENT 0 #endif - + #if !KOFF_PRESENT -_db_trace() { ; } +_db_trace() +{; +} + long db_tflags = 0; #endif @@ -94,69 +98,70 @@ extern Simple_lock afs_callout_lock; * uiop - uio vector describing any config params */ afs_config(cmd, uiop) -struct uio *uiop; { - int err; - extern struct vnodeops *afs_ops; - - AFS_STATCNT(afs_config); - - err = 0; - AFS_GLOCK(); - if (cmd == CFG_INIT) { /* add AFS gfs */ - /* - * init any vrmix mandated kluges - */ - if (err = kluge_init()) - goto out; - /* - * make sure that we pin everything - */ - if (err = pincode(afs_config)) - goto out; - err = gfsadd(AFS_MOUNT_AFS, &afs_gfs); - /* - * ok, if already installed - */ - if (err == EBUSY) - err = 0; - if (!err) { - pin(&afs_callout_lock, sizeof(afs_callout_lock)); - lock_alloc(&afs_callout_lock, LOCK_ALLOC_PIN, 0, 5); - simple_lock_init(&afs_callout_lock); - afs_ops = &locked_afs_gn_vnodeops; - timeoutcf(AFS_CALLOUT_TBL_SIZE); - } else { - unpincode(afs_config); - goto out; - } - if (KOFF_PRESENT) { - extern void *db_syms[]; - extern db_nsyms; - - koff_addsyms(db_syms, db_nsyms); - } - } else if (cmd == CFG_TERM) { /* delete AFS gfs */ - err = gfsdel(AFS_MOUNT_AFS); - /* - * ok, if already deleted - */ - if (err == ENOENT) - err = 0; - else if (!err) { - if (err = unpincode(afs_config)) - err = 0; - - timeoutcf(-AFS_CALLOUT_TBL_SIZE); - } - } else /* unknown command */ - err = EINVAL; - - out: - AFS_GUNLOCK(); - if ( !err && (cmd == CFG_INIT) ) - osi_Init(); - - return err; + struct uio *uiop; +{ + int err; + extern struct vnodeops *afs_ops; + + AFS_STATCNT(afs_config); + + err = 0; + AFS_GLOCK(); + if (cmd == CFG_INIT) { /* add AFS gfs */ + /* + * init any vrmix mandated kluges + */ + if (err = kluge_init()) + goto out; + /* + * make sure that we pin everything + */ + if (err = pincode(afs_config)) + goto out; + err = gfsadd(AFS_MOUNT_AFS, &afs_gfs); + /* + * ok, if already installed + */ + if (err == EBUSY) + err = 0; + if (!err) { + pin(&afs_callout_lock, sizeof(afs_callout_lock)); + lock_alloc(&afs_callout_lock, LOCK_ALLOC_PIN, 0, 5); + simple_lock_init(&afs_callout_lock); + afs_ops = &locked_afs_gn_vnodeops; + timeoutcf(AFS_CALLOUT_TBL_SIZE); + } else { + unpincode(afs_config); + goto out; + } + if (KOFF_PRESENT) { + extern void *db_syms[]; + extern db_nsyms; + + koff_addsyms(db_syms, db_nsyms); + } + } else if (cmd == CFG_TERM) { /* delete AFS gfs */ + err = gfsdel(AFS_MOUNT_AFS); + /* + * ok, if already deleted + */ + if (err == ENOENT) + err = 0; + else if (!err) { + if (err = unpincode(afs_config)) + err = 0; + + timeoutcf(-AFS_CALLOUT_TBL_SIZE); + } + } else /* unknown command */ + err = EINVAL; + + out: + AFS_GUNLOCK(); + if (!err && (cmd == CFG_INIT)) + osi_Init(); + + return err; } /* @@ -170,7 +175,8 @@ struct uio *uiop; { * Seems we can't make up our mind what to call these */ char * -mem_getbytes(size) { +mem_getbytes(size) +{ return malloc(size); } @@ -179,33 +185,38 @@ mem_getbytes(size) { * mem_freebytes - memory deallocator */ mem_freebytes(p, size) -char *p; { + char *p; +{ free(p); } char * -kmem_alloc(size) { +kmem_alloc(size) +{ - return malloc(size); + return malloc(size); } kmem_free(p, size) -char *p; { + char *p; +{ - free(p); + free(p); } VN_RELE(vp) -register struct vnode *vp; { + register struct vnode *vp; +{ - VNOP_RELE(vp); + VNOP_RELE(vp); } VN_HOLD(vp) -register struct vnode *vp; { + register struct vnode *vp; +{ - VNOP_HOLD(vp); + VNOP_HOLD(vp); } /* @@ -213,48 +224,48 @@ register struct vnode *vp; { * from the kernel isn't, so we must be devious. */ -int (*kluge_ufdalloc)(); -int (*kluge_fpalloc)(); -void *(*kluge_ufdfree)(); -void *(*kluge_ffree)(); -int (*kluge_iptovp)(); -int (*kluge_dev_ialloc)(); -int (*kluge_iget)(); -int (*kluge_iput)(); -int (*kluge_commit)(); -void *(*kluge_ksettimer)(); -void *(*kluge_fsSimpleLock)(); -void *(*kluge_fsSimpleUnlock)(); -void *(*kluge_fsReadLock)(); -void *(*kluge_fsWriteLock)(); -void *(*kluge_fsCxUnlock)(); +int (*kluge_ufdalloc) (); +int (*kluge_fpalloc) (); +void *(*kluge_ufdfree) (); +void *(*kluge_ffree) (); +int (*kluge_iptovp) (); +int (*kluge_dev_ialloc) (); +int (*kluge_iget) (); +int (*kluge_iput) (); +int (*kluge_commit) (); +void *(*kluge_ksettimer) (); +void *(*kluge_fsSimpleLock) (); +void *(*kluge_fsSimpleUnlock) (); +void *(*kluge_fsReadLock) (); +void *(*kluge_fsWriteLock) (); +void *(*kluge_fsCxUnlock) (); /* * kernel function import list */ struct k_func kfuncs[] = { - { (void *(**)()) &kluge_ufdalloc, ".ufdalloc" }, - { (void *(**)()) &kluge_fpalloc, ".fpalloc" }, - { &kluge_ufdfree, ".ufdfree" }, - { &kluge_ffree, ".ffree" }, - { (void *(**)()) &kluge_iptovp, ".iptovp" }, - { (void *(**)()) &kluge_dev_ialloc, ".dev_ialloc" }, - { (void *(**)()) &kluge_iget, ".iget" }, - { (void *(**)()) &kluge_iput, ".iput" }, - { (void *(**)()) &kluge_commit, ".commit" }, - { &kluge_ksettimer, ".ksettimer" }, + {(void *(**)())&kluge_ufdalloc, ".ufdalloc"}, + {(void *(**)())&kluge_fpalloc, ".fpalloc"}, + {&kluge_ufdfree, ".ufdfree"}, + {&kluge_ffree, ".ffree"}, + {(void *(**)())&kluge_iptovp, ".iptovp"}, + {(void *(**)())&kluge_dev_ialloc, ".dev_ialloc"}, + {(void *(**)())&kluge_iget, ".iget"}, + {(void *(**)())&kluge_iput, ".iput"}, + {(void *(**)())&kluge_commit, ".commit"}, + {&kluge_ksettimer, ".ksettimer"}, #ifdef _FSDEBUG - { &kluge_fsSimpleLock, ".fs_simple_lock" }, - { &kluge_fsSimpleUnlock, ".fs_simple_unlock" }, - { &kluge_fsReadLock, ".fs_read_lock" }, - { &kluge_fsWriteLock, ".fs_write_lock" }, - { &kluge_fsCxUnlock, ".fs_complex_unlock" }, + {&kluge_fsSimpleLock, ".fs_simple_lock"}, + {&kluge_fsSimpleUnlock, ".fs_simple_unlock"}, + {&kluge_fsReadLock, ".fs_read_lock"}, + {&kluge_fsWriteLock, ".fs_write_lock"}, + {&kluge_fsCxUnlock, ".fs_complex_unlock"}, #endif - { 0, 0 }, + {0, 0}, }; -void *vnodefops; /* dummy vnodeops */ +void *vnodefops; /* dummy vnodeops */ struct ifnet *ifnet; Simple_lock jfs_icache_lock; Simple_lock proc_tbl_lock; @@ -263,135 +274,148 @@ Simple_lock proc_tbl_lock; * kernel variable import list */ struct k_var kvars[] = { - { (void *) &vnodefops, "vnodefops" }, - { (void *) &ifnet, "ifnet" }, - { (void *) &jfs_icache_lock, "jfs_icache_lock" }, + {(void *)&vnodefops, "vnodefops"}, + {(void *)&ifnet, "ifnet"}, + {(void *)&jfs_icache_lock, "jfs_icache_lock"}, #ifndef AFS_AIX51_ENV - { (void *) &proc_tbl_lock, "proc_tbl_lock" }, + {(void *)&proc_tbl_lock, "proc_tbl_lock"}, #endif - { 0, 0 }, + {0, 0}, }; /* * kluge_init - initialise the kernel imports kluge */ -kluge_init() { - register struct k_func *kf; - register struct k_var *kv; +kluge_init() +{ + register struct k_func *kf; + register struct k_var *kv; #ifdef __64BIT__ - register afs_uint64 toc; + register afs_uint64 toc; #else - register afs_uint32 toc; + register afs_uint32 toc; #endif - register err = 0; + register err = 0; - toc = get_toc(); - for (kf = kfuncs; !err && kf->name; ++kf) { - err = import_kfunc(kf); - } - for (kv = kvars; !err && kv->name; ++kv) { - err = import_kvar(kv, toc); - } + toc = get_toc(); + for (kf = kfuncs; !err && kf->name; ++kf) { + err = import_kfunc(kf); + } + for (kv = kvars; !err && kv->name; ++kv) { + err = import_kvar(kv, toc); + } - return err; + return err; } ufdalloc(i, fdp) -int *fdp; { + int *fdp; +{ - return (*kluge_ufdalloc)(i, fdp); + return (*kluge_ufdalloc) (i, fdp); } fpalloc(vp, flag, type, ops, fpp) -struct vnode *vp; -struct fileops *ops; -struct file **fpp; { + struct vnode *vp; + struct fileops *ops; + struct file **fpp; +{ - return (*kluge_fpalloc)(vp, flag, type, ops, fpp); + return (*kluge_fpalloc) (vp, flag, type, ops, fpp); } void -ufdfree(fd) { +ufdfree(fd) +{ - (void) (*kluge_ufdfree)(fd); + (void)(*kluge_ufdfree) (fd); } void ffree(fp) -struct file *fp; { + struct file *fp; +{ - (void) (*kluge_ffree)(fp); + (void)(*kluge_ffree) (fp); } iptovp(vfsp, ip, vpp) -struct vfs *vfsp; -struct inode *ip, **vpp; { + struct vfs *vfsp; + struct inode *ip, **vpp; +{ - return (*kluge_iptovp)(vfsp, ip, vpp); + return (*kluge_iptovp) (vfsp, ip, vpp); } dev_ialloc(pip, ino, mode, vfsp, ipp) -struct inode *pip; -ino_t ino; -mode_t mode; -struct vfs *vfsp; -struct inode **ipp; { + struct inode *pip; + ino_t ino; + mode_t mode; + struct vfs *vfsp; + struct inode **ipp; +{ - return (*kluge_dev_ialloc)(pip, ino, mode, vfsp, ipp); + return (*kluge_dev_ialloc) (pip, ino, mode, vfsp, ipp); } iget(dev, ino, ipp, doscan, vfsp) -dev_t dev; -ino_t ino; + dev_t dev; + ino_t ino; #ifdef __64BIT__ -afs_size_t doscan; + afs_size_t doscan; #endif -struct vfs *vfsp; -struct inode **ipp; { + struct vfs *vfsp; + struct inode **ipp; +{ #ifdef __64BIT__ afs_int64 dummy[10]; dummy[0] = doscan; - return (*kluge_iget)(dev, ino, ipp, (afs_size_t) doscan, vfsp, &dummy); + return (*kluge_iget) (dev, ino, ipp, (afs_size_t) doscan, vfsp, &dummy); #else - return (*kluge_iget)(dev, ino, ipp, doscan, vfsp); + return (*kluge_iget) (dev, ino, ipp, doscan, vfsp); #endif } iput(ip, vfsp) -struct vfs *vfsp; -struct inode *ip; { - return (*kluge_iput)(ip, vfsp); + struct vfs *vfsp; + struct inode *ip; +{ + return (*kluge_iput) (ip, vfsp); } commit(n, i0, i1, i2) -struct inode *i0, *i1, *i2; { + struct inode *i0, *i1, *i2; +{ - return (*kluge_commit)(n, i0, i1, i2); + return (*kluge_commit) (n, i0, i1, i2); } #ifdef _FSDEBUG -fs_simple_lock(void *lp, int type) { - return (*kluge_fsSimpleLock)(lp, type); +fs_simple_lock(void *lp, int type) +{ + return (*kluge_fsSimpleLock) (lp, type); } -fs_simple_unlock(void *lp, int type) { - return (*kluge_fsSimpleUnlock)(lp, type); +fs_simple_unlock(void *lp, int type) +{ + return (*kluge_fsSimpleUnlock) (lp, type); } -fs_read_lock(complex_lock_t lp, int type) { - return (*kluge_fsReadLock)(lp, type); +fs_read_lock(complex_lock_t lp, int type) +{ + return (*kluge_fsReadLock) (lp, type); } -fs_write_lock(complex_lock_t lp, int type) { - return (*kluge_fsWriteLock)(lp, type); +fs_write_lock(complex_lock_t lp, int type) +{ + return (*kluge_fsWriteLock) (lp, type); } -fs_complex_unlock(complex_lock_t lp, int type) { - return (*kluge_fsCxUnlock)(lp, type); +fs_complex_unlock(complex_lock_t lp, int type) +{ + return (*kluge_fsCxUnlock) (lp, type); } #endif - - diff --git a/src/afs/AIX/osi_file.c b/src/afs/AIX/osi_file.c index 63f29e105..2c5c9af50 100644 --- a/src/afs/AIX/osi_file.c +++ b/src/afs/AIX/osi_file.c @@ -10,21 +10,23 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ -int afs_osicred_initialized=0; -struct AFS_UCRED afs_osi_cred; +int afs_osicred_initialized = 0; +struct AFS_UCRED afs_osi_cred; afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct vfs *afs_cacheVfsp; -void *osi_UFSOpen(afs_int32 ainode) +void * +osi_UFSOpen(afs_int32 ainode) { struct inode *ip; register struct osi_file *afile = NULL; @@ -34,7 +36,7 @@ void *osi_UFSOpen(afs_int32 ainode) afs_int32 code = 0; int dummy; AFS_STATCNT(osi_UFSOpen); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) { + if (cacheDiskType != AFS_FCACHE_TYPE_UFS) { osi_Panic("UFSOpen called for non-UFS cache\n"); } if (!afs_osicred_initialized) { @@ -43,29 +45,31 @@ void *osi_UFSOpen(afs_int32 ainode) crhold(&afs_osi_cred); /* don't let it evaporate, since it is static */ afs_osicred_initialized = 1; } - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); setuerror(0); AFS_GUNLOCK(); - ip = (struct inode *) igetinode((dev_t) cacheDev.dev, rootvfs, (ino_t)ainode, &vp,&dummy); + ip = (struct inode *)igetinode((dev_t) cacheDev.dev, rootvfs, + (ino_t) ainode, &vp, &dummy); AFS_GLOCK(); if (getuerror()) { osi_FreeSmallSpace(afile); osi_Panic("UFSOpen: igetinode failed"); } - afile->vnode = vp; /* Save the vnode pointer for the inode ip; also ip is already prele'ed in igetinode */ + afile->vnode = vp; /* Save the vnode pointer for the inode ip; also ip is already prele'ed in igetinode */ afile->size = VTOI(afile->vnode)->i_size; afile->offset = 0; - afile->proc = (int (*)()) 0; - afile->inum = ainode; /* for hint validity checking */ + afile->proc = (int (*)())0; + afile->inum = ainode; /* for hint validity checking */ return (void *)afile; } -int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) +int +afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) { register afs_int32 code; struct vattr tvattr; AFS_STATCNT(osi_Stat); - MObtainWriteLock(&afs_xosi,320); + MObtainWriteLock(&afs_xosi, 320); AFS_GUNLOCK(); code = VNOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred); AFS_GLOCK(); @@ -79,10 +83,11 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta return code; } -int osi_UFSClose(register struct osi_file *afile) - { - AFS_STATCNT(osi_Close); - if(afile->vnode) { +int +osi_UFSClose(register struct osi_file *afile) +{ + AFS_STATCNT(osi_Close); + if (afile->vnode) { /* AIX writes entire data regions at a time when dumping core. We've * seen a 26M write go through the system. When this happens, we run * out of available pages. So, we'll flush the vnode's vm if we're short @@ -98,19 +103,20 @@ int osi_UFSClose(register struct osi_file *afile) } } AFS_RELE(afile->vnode); - } - - osi_FreeSmallSpace(afile); - return 0; - } + } -int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) + osi_FreeSmallSpace(afile); + return 0; +} + +int +osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) { struct AFS_UCRED *oldCred; struct vattr tvattr; register afs_int32 code; struct osi_stat tstat; - afs_int32 mode=FWRITE|FSYNC; + afs_int32 mode = FWRITE | FSYNC; AFS_STATCNT(osi_Truncate); /* This routine only shrinks files, and most systems @@ -118,70 +124,76 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) * small enough. Check now and save some time. */ code = afs_osi_Stat(afile, &tstat); - if (code || tstat.size <= asize) return code; - MObtainWriteLock(&afs_xosi,321); + if (code || tstat.size <= asize) + return code; + MObtainWriteLock(&afs_xosi, 321); /* * If we're truncating an unopened file to a non-zero length, * we need to bind it to a vm segment * Note that that the binding will actually happen inside * jfs by xix_ftrunc; setting mode to 0 will enable that. */ - if (asize && !VTOGP(afile->vnode)->gn_seg) + if (asize && !VTOGP(afile->vnode)->gn_seg) mode = 0; AFS_GUNLOCK(); - code = VNOP_FTRUNC(afile->vnode, mode, asize, (caddr_t)0, &afs_osi_cred); + code = VNOP_FTRUNC(afile->vnode, mode, asize, (caddr_t) 0, &afs_osi_cred); AFS_GLOCK(); MReleaseWriteLock(&afs_xosi); return code; } -void osi_DisableAtimes(struct vnode *avp) +void +osi_DisableAtimes(struct vnode *avp) { - struct inode *ip = VTOIP(avp); - ip->i_flag &= ~IACC; + struct inode *ip = VTOIP(avp); + ip->i_flag &= ~IACC; } /* Generic read interface */ -int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize) +int +afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; unsigned int resid; register afs_int32 code; - register afs_int32 cnt1=0; + register afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); - + /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ - if ( !afile ) { - if ( !afs_shuttingdown ) + if (!afile) { + if (!afs_shuttingdown) osi_Panic("osi_Read called with null param"); else return EIO; } - if (offset != -1) afile->offset = offset; -retry_IO: + if (offset != -1) + afile->offset = offset; + retry_IO: /* Note the difference in the way the afile->offset is passed (see comments in gop_rdwr() in afs_aix_subr.c for comments) */ AFS_GUNLOCK(); #ifdef AFS_64BIT_KERNEL - code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, - &afile->offset, AFS_UIOSYS, NULL, &resid); + code = + gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, + &afile->offset, AFS_UIOSYS, NULL, &resid); #else - code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, - (off_t)&afile->offset, AFS_UIOSYS, NULL, &resid); + code = + gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, + (off_t) & afile->offset, AFS_UIOSYS, NULL, &resid); #endif AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); - } - else { + } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, - ICL_TYPE_INT32, code); + ICL_TYPE_INT32, code); /* * To handle periodic low-level EFAULT failures that we've seen with the * Weitek chip; in all observed failed cases a second read succeeded. @@ -190,52 +202,54 @@ retry_IO: afs_stats_cmperf.osiread_efaults++; goto retry_IO; } - setuerror(code); + setuerror(code); code = -1; } return code; } /* Generic write interface */ -int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) +int +afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; unsigned int resid; register afs_int32 code; AFS_STATCNT(osi_Write); - if ( !afile ) - osi_Panic("afs_osi_Write called with null param"); - if (offset != -1) afile->offset = offset; + if (!afile) + osi_Panic("afs_osi_Write called with null param"); + if (offset != -1) + afile->offset = offset; /* Note the difference in the way the afile->offset is passed (see comments in gop_rdwr() in afs_aix_subr.c for comments) */ AFS_GUNLOCK(); #ifdef AFS_64BIT_KERNEL - code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, - &afile->offset, AFS_UIOSYS, NULL, &resid); + code = + gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, + &afile->offset, AFS_UIOSYS, NULL, &resid); #else - code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, - (off_t)&afile->offset, AFS_UIOSYS, NULL, &resid); + code = + gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, + (off_t) & afile->offset, AFS_UIOSYS, NULL, &resid); #endif AFS_GLOCK(); if (code == 0) { - if (resid) - afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED, - ICL_TYPE_INT32, asize, - ICL_TYPE_INT32, resid, - ICL_TYPE_INT32, code); + if (resid) + afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED, ICL_TYPE_INT32, + asize, ICL_TYPE_INT32, resid, ICL_TYPE_INT32, code); code = asize - resid; afile->offset += code; - } - else { - afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED, - ICL_TYPE_INT32, asize, - ICL_TYPE_INT32, resid, - ICL_TYPE_INT32, code); - if (code == ENOSPC) afs_warnuser("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); + } else { + afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED, ICL_TYPE_INT32, asize, + ICL_TYPE_INT32, resid, ICL_TYPE_INT32, code); + if (code == ENOSPC) + afs_warnuser + ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); setuerror(code); code = -1; } if (afile->proc) { - (*afile->proc)(afile, code); + (*afile->proc) (afile, code); } return code; } @@ -244,7 +258,8 @@ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, /* This work should be handled by physstrat in ca/machdep.c. This routine written from the RT NFS port strategy routine. It has been generalized a bit, but should still be pretty clear. */ -int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) +int +afs_osi_MapStrategy(int (*aproc) (), register struct buf *bp) { afs_int32 returnCode; @@ -256,13 +271,13 @@ int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) -void shutdown_osifile(void) +void +shutdown_osifile(void) { - extern int afs_cold_shutdown; + extern int afs_cold_shutdown; - AFS_STATCNT(shutdown_osifile); - if (afs_cold_shutdown) { - afs_osicred_initialized = 0; - } + AFS_STATCNT(shutdown_osifile); + if (afs_cold_shutdown) { + afs_osicred_initialized = 0; + } } - diff --git a/src/afs/AIX/osi_groups.c b/src/afs/AIX/osi_groups.c index 3fd8539d1..358b796ef 100644 --- a/src/afs/AIX/osi_groups.c +++ b/src/afs/AIX/osi_groups.c @@ -16,31 +16,26 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset); + afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset); static int -afs_setgroups( - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent); + afs_setgroups(struct ucred **cred, int ngroups, gid_t * gidset, + int change_parent); #ifndef AFS_AIX51_ENV int setgroups(ngroups, gidset) - int ngroups; - gid_t *gidset; + int ngroups; + gid_t *gidset; { int code = 0; struct vrequest treq; @@ -54,7 +49,8 @@ setgroups(ngroups, gidset) code = afs_InitReq(&treq, credp); AFS_GUNLOCK(); crfree(credp); - if (code) return code; + if (code) + return code; code = osetgroups(ngroups, gidset); @@ -82,10 +78,10 @@ setgroups(ngroups, gidset) int setpag(cred, pagvalue, newpag, change_parent) - struct ucred **cred; - afs_uint32 pagvalue; - afs_uint32 *newpag; - afs_uint32 change_parent; + struct ucred **cred; + afs_uint32 pagvalue; + afs_uint32 *newpag; + afs_uint32 change_parent; { gid_t gidset[NGROUPS]; int ngroups, code; @@ -99,13 +95,13 @@ setpag(cred, pagvalue, newpag, change_parent) if (ngroups + 2 > NGROUPS) { return (setuerror(E2BIG), E2BIG); } - for (j = ngroups -1; j >= 0; j--) { - gidset[j+2] = gidset[j]; - } + for (j = ngroups - 1; j >= 0; j--) { + gidset[j + 2] = gidset[j]; + } ngroups += 2; } #endif - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); #ifdef AFS_AIX51_ENV if (change_parent) { code = kcred_setpag(*cred, PAG_AFS, *newpag); @@ -128,10 +124,7 @@ setpag(cred, pagvalue, newpag, change_parent) #ifndef AFS_AIX51_ENV static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset) +afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset) { int ngrps, savengrps; gid_t *gp; @@ -150,9 +143,9 @@ afs_getgroups( static void copy_to_cred(newcr, ngroups, gidset) - struct ucred *newcr; - int ngroups; - gid_t *gidset; + struct ucred *newcr; + int ngroups; + gid_t *gidset; { gid_t *gp; int newngroups; @@ -178,11 +171,8 @@ copy_to_cred(newcr, ngroups, gidset) */ static int -afs_setgroups( - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct ucred **cred, int ngroups, gid_t * gidset, + int change_parent) { AFS_STATCNT(afs_setgroups); diff --git a/src/afs/AIX/osi_inode.c b/src/afs/AIX/osi_inode.c index 6236e5c08..921802d28 100644 --- a/src/afs/AIX/osi_inode.c +++ b/src/afs/AIX/osi_inode.c @@ -16,19 +16,20 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ #include "afs/osi_inode.h" -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include "sys/syspest.h" #if !defined(offsetof) -#include /* for definition of offsetof() */ +#include /* for definition of offsetof() */ #endif -extern Simple_lock jfs_icache_lock; +extern Simple_lock jfs_icache_lock; #define ICACHE_LOCK() simple_lock(&jfs_icache_lock) #define ICACHE_UNLOCK() simple_unlock(&jfs_icache_lock) @@ -57,11 +58,11 @@ extern Simple_lock jfs_icache_lock; * is at an expected offset. */ -#if IACTIVITY == 0x0020 /* in on AIX 4.2.0 */ +#if IACTIVITY == 0x0020 /* in on AIX 4.2.0 */ #define afs_inode_lock i_rdwrlock #endif -#if IACTIVITY == 0x0010 /* in on AIX 4.2.1 and later */ +#if IACTIVITY == 0x0010 /* in on AIX 4.2.1 and later */ #define afs_inode_lock i_nodelock #endif @@ -115,7 +116,8 @@ struct devtovfs_args { * (Returning nonzero causes vfs_search() to terminate the search.) */ -static int devtovfs_func(struct vfs *vfsp, struct devtovfs_args *rock) +static int +devtovfs_func(struct vfs *vfsp, struct devtovfs_args *rock) { if (vfsp->vfs_mntd != NULL && vfsp->vfs_type == MNT_JFS && (vfsp->vfs_flag & VFS_DEVMOUNT)) { @@ -158,91 +160,91 @@ int IGI_mode; extern int iget(); extern struct vnode *filevp; struct inode * -igetinode(dev, vfsp, inode, vpp,perror) - struct vfs *vfsp; - struct vnode **vpp; /* vnode associated with the inode */ - dev_t dev; - ino_t inode; - int *perror; +igetinode(dev, vfsp, inode, vpp, perror) + struct vfs *vfsp; + struct vnode **vpp; /* vnode associated with the inode */ + dev_t dev; + ino_t inode; + int *perror; { - struct inode *ip; - register was_locked; - struct vfs *nvfsp = NULL; - int code; - *perror = 0; - *vpp = NULL; - AFS_STATCNT(igetinode); - - /* - * Double check that the inode lock is at a known offset. - * - * If it isn't, then we need to reexamine our code to make - * sure that it is still okay. - */ + struct inode *ip; + register was_locked; + struct vfs *nvfsp = NULL; + int code; + *perror = 0; + *vpp = NULL; + AFS_STATCNT(igetinode); + + /* + * Double check that the inode lock is at a known offset. + * + * If it isn't, then we need to reexamine our code to make + * sure that it is still okay. + */ #ifdef __64BIT__ /* osi_Assert(offsetof(struct inode, afs_inode_lock) == 208); */ #else - osi_Assert(offsetof(struct inode, afs_inode_lock) == 128); + osi_Assert(offsetof(struct inode, afs_inode_lock) == 128); #endif - if (!vfsp && !(vfsp = devtovfs((dev_t)dev))) { - afs_warn("Dev=%d not mounted!!; quitting\n", dev); - setuerror(ENODEV); - ip = 0; - goto out; - } - if (vfsp->vfs_flag & VFS_DEVMOUNT) - nvfsp = vfsp; - - /* Check if inode 0. This is the mount inode for the device - * and will panic the aix system if removed: defect 11434. - * No file should ever point to this inode. - */ - if (inode == 0) { - afs_warn("Dev=%d zero inode.\n", dev); - setuerror(ENOENT); - ip = 0; - goto out; - } + if (!vfsp && !(vfsp = devtovfs((dev_t) dev))) { + afs_warn("Dev=%d not mounted!!; quitting\n", dev); + setuerror(ENODEV); + ip = 0; + goto out; + } + if (vfsp->vfs_flag & VFS_DEVMOUNT) + nvfsp = vfsp; + + /* Check if inode 0. This is the mount inode for the device + * and will panic the aix system if removed: defect 11434. + * No file should ever point to this inode. + */ + if (inode == 0) { + afs_warn("Dev=%d zero inode.\n", dev); + setuerror(ENOENT); + ip = 0; + goto out; + } - ICACHE_LOCK(); + ICACHE_LOCK(); #ifdef __64BIT__ - if ((code = iget(dev, inode, &ip, (afs_size_t) 1, nvfsp))) { + if ((code = iget(dev, inode, &ip, (afs_size_t) 1, nvfsp))) { #else - if ((code = iget(dev, inode, &ip, 1, nvfsp))) { + if ((code = iget(dev, inode, &ip, 1, nvfsp))) { #endif - IGI_error = code; - IGI_inode = inode; - *perror = BAD_IGET; - ICACHE_UNLOCK(); - setuerror(ENOENT); /* Well... */ - ip = 0; - goto out; - } + IGI_error = code; + IGI_inode = inode; + *perror = BAD_IGET; ICACHE_UNLOCK(); - IREAD_LOCK(ip); - if (ip->i_nlink == 0 || (ip->i_mode&IFMT) != IFREG) { - IGI_error = 0; - IGI_inode = inode; - IGI_nlink = ip->i_nlink; - IGI_mode = ip->i_mode; - IREAD_UNLOCK(ip); - ICACHE_LOCK(); - iput(ip, NULL); - ICACHE_UNLOCK(); - setuerror(ENOENT); - ip = 0; - goto out; - } + setuerror(ENOENT); /* Well... */ + ip = 0; + goto out; + } + ICACHE_UNLOCK(); + IREAD_LOCK(ip); + if (ip->i_nlink == 0 || (ip->i_mode & IFMT) != IFREG) { + IGI_error = 0; + IGI_inode = inode; + IGI_nlink = ip->i_nlink; + IGI_mode = ip->i_mode; IREAD_UNLOCK(ip); - if (vpp) { - if (nvfsp) - *vpp = ip->i_gnode.gn_vnode; - else - setuerror(iptovp(vfsp, ip, vpp)); - } -out: - return ip; + ICACHE_LOCK(); + iput(ip, NULL); + ICACHE_UNLOCK(); + setuerror(ENOENT); + ip = 0; + goto out; + } + IREAD_UNLOCK(ip); + if (vpp) { + if (nvfsp) + *vpp = ip->i_gnode.gn_vnode; + else + setuerror(iptovp(vfsp, ip, vpp)); + } + out: + return ip; } @@ -252,113 +254,117 @@ out: * marked as journalled. We would also like to journal inodes corresponding * to directory information... */ -#define INODESPECIAL 0xffffffff /* ... from ../vol/viceonode.h */ +#define INODESPECIAL 0xffffffff /* ... from ../vol/viceonode.h */ #endif -SYSENT(icreate, (dev, near_inode, param1, param2, param3, param4), ) { - struct inode *ip, *newip, *pip; - register int err, rval1, rc=0; - struct vnode *vp = NULL; - extern struct vfs *rootvfs; - register struct vfs *vfsp; - struct vfs *nvfsp = NULL; - char error; - ino_t ino = near_inode; - - AFS_STATCNT(afs_syscall_icreate); - if (!suser(&error)) { - setuerror(error); - return -1; - } +SYSENT(icreate, (dev, near_inode, param1, param2, param3, param4),) +{ + struct inode *ip, *newip, *pip; + register int err, rval1, rc = 0; + struct vnode *vp = NULL; + extern struct vfs *rootvfs; + register struct vfs *vfsp; + struct vfs *nvfsp = NULL; + char error; + ino_t ino = near_inode; + + AFS_STATCNT(afs_syscall_icreate); + if (!suser(&error)) { + setuerror(error); + return -1; + } - if ((vfsp = devtovfs((dev_t)dev)) == 0) { - afs_warn("Dev=%d not mounted!!; quitting\n", dev); - setuerror(ENODEV); - return -1; - } - if (vfsp->vfs_flag & VFS_DEVMOUNT) - nvfsp = vfsp; - ICACHE_LOCK(); - rc = iget(dev, 0, &pip, 1, nvfsp); - if (!rc) { - /* - * this is the mount inode, and thus we should be - * safe putting it back. - */ - iput(pip, nvfsp); - } - ICACHE_UNLOCK(); + if ((vfsp = devtovfs((dev_t) dev)) == 0) { + afs_warn("Dev=%d not mounted!!; quitting\n", dev); + setuerror(ENODEV); + return -1; + } + if (vfsp->vfs_flag & VFS_DEVMOUNT) + nvfsp = vfsp; + ICACHE_LOCK(); + rc = iget(dev, 0, &pip, 1, nvfsp); + if (!rc) { + /* + * this is the mount inode, and thus we should be + * safe putting it back. + */ + iput(pip, nvfsp); + } + ICACHE_UNLOCK(); - if (rc) { - setuerror(EINVAL); - return -1; - } + if (rc) { + setuerror(EINVAL); + return -1; + } - if (setuerror(dev_ialloc(pip, ino, IFREG, nvfsp, &newip))) - return -1; - newip->i_flag |= IACC|IUPD|ICHG; - newip->i_gid = -2; /* Put special gid flag */ - newip->i_vicemagic = VICEMAGIC; - newip->i_vicep1 = param1; - newip->i_vicep2 = param2; - newip->i_vicep3 = param3; - newip->i_vicep4 = param4; - IWRITE_UNLOCK(newip); - if (nvfsp) { - vp = newip->i_gnode.gn_vnode; - } else { - rc = iptovp(vfsp, newip, &vp); - } - setuerror(rc); - - rval1 = newip->i_number; - if (vp) { - VNOP_RELE(vp); - } - return getuerror() ? -1 : rval1; + if (setuerror(dev_ialloc(pip, ino, IFREG, nvfsp, &newip))) + return -1; + newip->i_flag |= IACC | IUPD | ICHG; + newip->i_gid = -2; /* Put special gid flag */ + newip->i_vicemagic = VICEMAGIC; + newip->i_vicep1 = param1; + newip->i_vicep2 = param2; + newip->i_vicep3 = param3; + newip->i_vicep4 = param4; + IWRITE_UNLOCK(newip); + if (nvfsp) { + vp = newip->i_gnode.gn_vnode; + } else { + rc = iptovp(vfsp, newip, &vp); + } + setuerror(rc); + + rval1 = newip->i_number; + if (vp) { + VNOP_RELE(vp); + } + return getuerror()? -1 : rval1; } -SYSENT(iopen, (dev, inode, usrmod), ) { - struct file *fp; - register struct inode *ip; - struct vnode *vp = NULL; - extern struct fileops vnodefops; - register struct vfs *vfsp; - int fd; - char error; - struct ucred *credp; - int dummy; - - AFS_STATCNT(afs_syscall_iopen); - if (!suser(&error)) { - setuerror(error); - return -1; - } +SYSENT(iopen, (dev, inode, usrmod),) +{ + struct file *fp; + register struct inode *ip; + struct vnode *vp = NULL; + extern struct fileops vnodefops; + register struct vfs *vfsp; + int fd; + char error; + struct ucred *credp; + int dummy; + + AFS_STATCNT(afs_syscall_iopen); + if (!suser(&error)) { + setuerror(error); + return -1; + } - if ((vfsp = devtovfs((dev_t)dev)) == 0) { - afs_warn("Dev=%d not mounted!!; quitting\n", dev); - setuerror(ENODEV); - return -1; - } - ip = igetinode((dev_t)dev, vfsp, (ino_t)inode, &vp,&dummy); - if (getuerror()) - return -1; - - credp = crref(); - if (setuerror(ufdcreate((usrmod-FOPEN)&FMASK, &vnodefops, vp - , DTYPE_VNODE, &fd, credp))) { - crfree(credp); - VNOP_RELE(vp); - return -1; - } - - if (setuerror(VNOP_OPEN(vp, (usrmod-FOPEN)&FMASK, 0, 0, credp))) { - close(fd); - crfree(credp); - return -1; - } + if ((vfsp = devtovfs((dev_t) dev)) == 0) { + afs_warn("Dev=%d not mounted!!; quitting\n", dev); + setuerror(ENODEV); + return -1; + } + ip = igetinode((dev_t) dev, vfsp, (ino_t) inode, &vp, &dummy); + if (getuerror()) + return -1; + + credp = crref(); + if (setuerror + (ufdcreate + ((usrmod - FOPEN) & FMASK, &vnodefops, vp, DTYPE_VNODE, &fd, + credp))) { crfree(credp); - return fd; + VNOP_RELE(vp); + return -1; + } + + if (setuerror(VNOP_OPEN(vp, (usrmod - FOPEN) & FMASK, 0, 0, credp))) { + close(fd); + crfree(credp); + return -1; + } + crfree(credp); + return fd; } @@ -368,55 +374,58 @@ SYSENT(iopen, (dev, inode, usrmod), ) { * Restricted to super user. * Only VICEMAGIC type inodes. */ -iinc(dev, inode, inode_p1) { +iinc(dev, inode, inode_p1) +{ AFS_STATCNT(iinc); return iincdec(dev, inode, inode_p1, 1); } -idec(dev, inode, inode_p1) { +idec(dev, inode, inode_p1) +{ AFS_STATCNT(idec); return iincdec(dev, inode, inode_p1, -1); } -SYSENT(iincdec, (dev, inode, inode_p1, amount), ) { - register struct inode *ip; - char error; - struct vnode *vp = NULL; - int dummy; - - AFS_STATCNT(afs_syscall_iincdec); - if (!suser(&error)) { - setuerror(error); - return -1; - } +SYSENT(iincdec, (dev, inode, inode_p1, amount),) +{ + register struct inode *ip; + char error; + struct vnode *vp = NULL; + int dummy; + + AFS_STATCNT(afs_syscall_iincdec); + if (!suser(&error)) { + setuerror(error); + return -1; + } - ip = igetinode((dev_t)dev, 0, (ino_t)inode, &vp, &dummy); - if (getuerror()) { - return -1; - } - IWRITE_LOCK(ip); - if (ip->i_vicemagic != VICEMAGIC) - setuerror(EPERM); - else if (ip->i_vicep1 != inode_p1) - setuerror(ENXIO); - else { - ip->i_nlink += amount; - if (ip->i_nlink == 0) { - ip->i_vicemagic = 0; - ip->i_cflag &= ~CMNEW; - } - ip->i_flag |= ICHG; - commit(1, ip); /* always commit */ + ip = igetinode((dev_t) dev, 0, (ino_t) inode, &vp, &dummy); + if (getuerror()) { + return -1; + } + IWRITE_LOCK(ip); + if (ip->i_vicemagic != VICEMAGIC) + setuerror(EPERM); + else if (ip->i_vicep1 != inode_p1) + setuerror(ENXIO); + else { + ip->i_nlink += amount; + if (ip->i_nlink == 0) { + ip->i_vicemagic = 0; + ip->i_cflag &= ~CMNEW; } - IWRITE_UNLOCK(ip); - VNOP_RELE(vp); + ip->i_flag |= ICHG; + commit(1, ip); /* always commit */ + } + IWRITE_UNLOCK(ip); + VNOP_RELE(vp); /* ICACHE_LOCK(); iput(ip, 0); ICACHE_UNLOCK(); */ - return getuerror() ? -1 : 0; + return getuerror()? -1 : 0; } diff --git a/src/afs/AIX/osi_machdep.h b/src/afs/AIX/osi_machdep.h index 110ef7c4c..f52c4c11b 100644 --- a/src/afs/AIX/osi_machdep.h +++ b/src/afs/AIX/osi_machdep.h @@ -70,7 +70,7 @@ extern simple_lock_data afs_global_lock; } while(0) #define ISAFS_GLOCK() lock_mine((void *)&afs_global_lock) -#define AFS_RXGLOCK() +#define AFS_RXGLOCK() #define AFS_RXGUNLOCK() #define ISAFS_RXGLOCK() 1 #endif diff --git a/src/afs/AIX/osi_misc.c b/src/afs/AIX/osi_misc.c index 9e86a7f60..4fd610c10 100644 --- a/src/afs/AIX/osi_misc.c +++ b/src/afs/AIX/osi_misc.c @@ -19,7 +19,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "h/systm.h" #include "h/types.h" @@ -57,7 +58,7 @@ RCSID("$Header$"); * initialization of all gfs; one day we might need to actual do somehing here. */ Afs_init(gfsp) -char *gfsp; /* this is really struct gfs *, but we do not use it */ + char *gfsp; /* this is really struct gfs *, but we do not use it */ { extern int afs_gn_strategy(); #define AFS_VM_BUFS 50 @@ -65,7 +66,7 @@ char *gfsp; /* this is really struct gfs *, but we do not use it */ /* For now nothing special is required during AFS initialization. */ AFS_STATCNT(afs_init); - (void) vm_mount(D_REMOTE, afs_gn_strategy, AFS_VM_BUFS); + (void)vm_mount(D_REMOTE, afs_gn_strategy, AFS_VM_BUFS); return 0; } @@ -82,19 +83,19 @@ char *gfsp; /* this is really struct gfs *, but we do not use it */ */ int gop_rdwr(rw, vp, base, len, offset, segflg, unit, aresid) -enum uio_rw rw; -struct vnode *vp; -caddr_t base; + enum uio_rw rw; + struct vnode *vp; + caddr_t base; #ifdef AFS_64BIT_KERNEL -offset_t *offset; + offset_t *offset; #else -off_t *offset; + off_t *offset; #endif -int len, segflg; -int *aresid; -int unit; /* Ignored */ + int len, segflg; + int *aresid; + int unit; /* Ignored */ { - struct uio uio_struct; + struct uio uio_struct; struct iovec uiovector; register int code; @@ -111,12 +112,14 @@ int unit; /* Ignored */ uio_struct.uio_fmode = (rw == UIO_READ ? FREAD : FWRITE); #ifdef AFS_64BIT_KERNEL - code = VNOP_RDWR(vp, rw, - (int32long64_t)(rw == UIO_READ ? FREAD : FWRITE), &uio_struct, - (ext_t) 0, (caddr_t) 0, (struct vattr *)0, &afs_osi_cred); + code = + VNOP_RDWR(vp, rw, (int32long64_t) (rw == UIO_READ ? FREAD : FWRITE), + &uio_struct, (ext_t) 0, (caddr_t) 0, (struct vattr *)0, + &afs_osi_cred); #else - code = VNOP_RDWR(vp, rw, (rw == UIO_READ ? FREAD : FWRITE), &uio_struct, - NULL, NULL, NULL, &afs_osi_cred); + code = + VNOP_RDWR(vp, rw, (rw == UIO_READ ? FREAD : FWRITE), &uio_struct, + NULL, NULL, NULL, &afs_osi_cred); #endif *aresid = uio_struct.uio_resid; return code; @@ -134,7 +137,7 @@ int unit; /* Ignored */ * no linked list of gnodes to remove this element from. */ aix_gnode_rele(vp) -struct vnode *vp; + struct vnode *vp; { register struct vnode *tvp; register struct vfs *vfsp = vp->v_vfsp; @@ -148,12 +151,12 @@ struct vnode *vp; if (vp->v_vfsprev != NULL) vp->v_vfsprev->v_vfsnext = vp->v_vfsnext; - endgnode: - /* Free the allocated gnode that was accompanying the vcache's vnode */ - if (vp->v_gnode) { - osi_FreeSmallSpace(vp->v_gnode); - vp->v_gnode = 0; - } + endgnode: + /* Free the allocated gnode that was accompanying the vcache's vnode */ + if (vp->v_gnode) { + osi_FreeSmallSpace(vp->v_gnode); + vp->v_gnode = 0; + } return 0; } @@ -164,11 +167,11 @@ struct vnode *vp; * Note that it must NOT set errno. */ -afs_suser() { +afs_suser() +{ register rc; char err; - + rc = suser(&err); return rc; } - diff --git a/src/afs/AIX/osi_sleep.c b/src/afs/AIX/osi_sleep.c index 337947897..1e4c50b6f 100644 --- a/src/afs/AIX/osi_sleep.c +++ b/src/afs/AIX/osi_sleep.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ @@ -22,28 +23,32 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok); static char waitV; -static void AfsWaitHack(struct trb *trb) +static void +AfsWaitHack(struct trb *trb) { AFS_STATCNT(WaitHack); e_clear_wait(trb->func_data, THREAD_TIMED_OUT); } -void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) +void +afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) { AFS_STATCNT(osi_InitWaitHandle); achandle->proc = (caddr_t) 0; } /* cancel osi_Wait */ -void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) { caddr_t proc; AFS_STATCNT(osi_CancelWait); proc = achandle->proc; - if (proc == 0) return; - achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ + if (proc == 0) + return; + achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ afs_osi_Wakeup(&waitV); } @@ -51,13 +56,14 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) * Waits for data on ahandle, or ams ms later. ahandle may be null. * Returns 0 if timeout and EINTR if signalled. */ -int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) +int +afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int code; afs_int32 endTime, tid; AFS_STATCNT(osi_Wait); - endTime = osi_Time() + (ams/1000); + endTime = osi_Time() + (ams / 1000); if (ahandle) ahandle->proc = (caddr_t) thread_self(); do { @@ -65,7 +71,8 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) code = 0; code = osi_TimedSleep(&waitV, ams, aintok); - if (code) break; /* if something happened, quit now */ + if (code) + break; /* if something happened, quit now */ /* if we we're cancelled, quit now */ if (ahandle && (ahandle->proc == (caddr_t) 0)) { /* we've been signalled */ @@ -83,19 +90,20 @@ typedef struct afs_event { char *event; /* lwp event: an address */ int refcount; /* Is it in use? */ int seq; /* Sequence number: this is incremented - by wakeup calls; wait will not return until - it changes */ + * by wakeup calls; wait will not return until + * it changes */ tid_t cond; } afs_event_t; #define HASHSIZE 128 -afs_event_t *afs_evhasht[HASHSIZE];/* Hash table for events */ +afs_event_t *afs_evhasht[HASHSIZE]; /* Hash table for events */ #define afs_evhash(event) (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1)); int afs_evhashcnt = 0; /* Get and initialize event structure corresponding to lwp event (i.e. address) * */ -static afs_event_t *afs_getevent(char *event) +static afs_event_t * +afs_getevent(char *event) { afs_event_t *evp, *newp = 0; int hashcode; @@ -113,7 +121,7 @@ static afs_event_t *afs_getevent(char *event) evp = evp->next; } if (!newp) { - newp = (afs_event_t *) osi_AllocSmallSpace(sizeof (afs_event_t)); + newp = (afs_event_t *) osi_AllocSmallSpace(sizeof(afs_event_t)); afs_evhashcnt++; newp->next = afs_evhasht[hashcode]; afs_evhasht[hashcode] = newp; @@ -129,7 +137,8 @@ static afs_event_t *afs_getevent(char *event) #define relevent(evp) ((evp)->refcount--) -void afs_osi_Sleep(void *event) +void +afs_osi_Sleep(void *event) { struct afs_event *evp; int seq; @@ -146,7 +155,8 @@ void afs_osi_Sleep(void *event) relevent(evp); } -int afs_osi_SleepSig(void *event) +int +afs_osi_SleepSig(void *event) { afs_osi_Sleep(event); return 0; @@ -161,7 +171,8 @@ int afs_osi_SleepSig(void *event) * * Returns 0 if timeout and EINTR if signalled. */ -static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) +static int +osi_TimedSleep(char *event, afs_int32 ams, int aintok) { int code = 0; struct afs_event *evp; @@ -170,7 +181,7 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) int rc; ticks.tv_sec = ams / 1000; - ticks.tv_nsec = (ams - (ticks.tv_sec * 1000) ) * 1000000; + ticks.tv_nsec = (ams - (ticks.tv_sec * 1000)) * 1000000; evp = afs_getevent(event); @@ -179,7 +190,7 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) if (trb == NULL) osi_Panic("talloc returned NULL"); trb->flags = 0; - trb->func = AfsWaitHack; + trb->func = AfsWaitHack; trb->eventlist = EVENT_NULL; trb->ipri = INTTIMER; trb->func_data = thread_self(); @@ -189,27 +200,28 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) AFS_GUNLOCK(); tstart(trb); rc = e_block_thread(); - while(tstop(trb)); + while (tstop(trb)); if (rc == THREAD_INTERRUPTED) code = EINTR; tfree(trb); AFS_GLOCK(); - + relevent(evp); return code; } -int afs_osi_Wakeup(void *event) +int +afs_osi_Wakeup(void *event) { - int ret=1; + int ret = 1; struct afs_event *evp; evp = afs_getevent(event); if (evp->refcount > 1) { - evp->seq++; + evp->seq++; e_wakeup(&evp->cond); - ret=0; + ret = 0; } relevent(evp); return ret; diff --git a/src/afs/AIX/osi_timeout.c b/src/afs/AIX/osi_timeout.c index 9b904257c..6f9f588cf 100644 --- a/src/afs/AIX/osi_timeout.c +++ b/src/afs/AIX/osi_timeout.c @@ -15,19 +15,20 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /* Standard vendor system headers */ -#include "afsincludes.h" /* Afs-based standard headers */ +#include "afs/sysincludes.h" /* Standard vendor system headers */ +#include "afsincludes.h" /* Afs-based standard headers */ #include "sys/limits.h" #include "sys/types.h" #include "sys/user.h" #include "sys/pri.h" -#include "sys/priv.h" /* XXX */ +#include "sys/priv.h" /* XXX */ #include "sys/lockl.h" #include "sys/malloc.h" -#include /* For the timer related defines */ -#include /* for the serialization defines */ +#include /* For the timer related defines */ +#include /* for the serialization defines */ /* NOTE: This lock makes the callout table MP-safe. timeout itself could * be subject to deadlocks if used for anything more complex than we are @@ -39,320 +40,306 @@ Simple_lock afs_callout_lock; #define AFS_UNLOCK_ENABLE(_pri, _lock) unlock_enable((_pri), (_lock)) -struct tos { - struct tos *toprev; /* previous tos in callout table*/ - struct tos *tonext; /* next tos in callout table */ - struct trb *trb; /* this timer request block */ - afs_int32 type; - long p1; +struct tos { + struct tos *toprev; /* previous tos in callout table */ + struct tos *tonext; /* next tos in callout table */ + struct trb *trb; /* this timer request block */ + afs_int32 type; + long p1; }; -struct callo { - int ncallo; /* number of callout table elements */ - struct tos *head; /* callout table head element */ +struct callo { + int ncallo; /* number of callout table elements */ + struct tos *head; /* callout table head element */ }; -struct callo afs_callo = {0, NULL};/* callout table anchor */ +struct callo afs_callo = { 0, NULL }; /* callout table anchor */ -static void timeout_end(struct trb *); /* timeout()'s timeout function */ -extern void tstart(struct trb *); -extern void i_enable(int); +static void timeout_end(struct trb *); /* timeout()'s timeout function */ +extern void tstart(struct trb *); +extern void i_enable(int); -void timeout( - register void (*func)(), /* function to call at timeout*/ - register caddr_t arg, /* It's argument. */ - register int ticks, /* when to set timeout for */ - register int type, - register char *p1) +void +timeout(register void (*func) (), /* function to call at timeout */ + register caddr_t arg, /* It's argument. */ + register int ticks, /* when to set timeout for */ + register int type, register char *p1) { - register int ipri; /* caller's interrupt priority */ - register struct tos *tos; /* tos to use for timeout */ - register struct trb *trb; /* trb in the tos being used */ - struct itimerstruc_t tv; /* timeout interval */ - - tv.it_value.tv_sec = ticks / HZ; - tv.it_value.tv_nsec = (ticks % HZ) * (NS_PER_SEC / HZ); - - osi_Assert(afs_callo.ncallo != 0); - -timeout_retry: - - ipri = AFS_DISABLE_LOCK(INTMAX, &afs_callout_lock); - /* - * Run the callout table chain to see if there is already a pending - * timeout for the specified function. If so, that timeout will - * be cancelled and the tos re-used. - */ - for(tos = afs_callo.head; tos != NULL; tos = tos->tonext) { - if((tos->trb->tof == func) && (tos->trb->func_data == (ulong) arg)) { - break; - } + register int ipri; /* caller's interrupt priority */ + register struct tos *tos; /* tos to use for timeout */ + register struct trb *trb; /* trb in the tos being used */ + struct itimerstruc_t tv; /* timeout interval */ + + tv.it_value.tv_sec = ticks / HZ; + tv.it_value.tv_nsec = (ticks % HZ) * (NS_PER_SEC / HZ); + + osi_Assert(afs_callo.ncallo != 0); + + timeout_retry: + + ipri = AFS_DISABLE_LOCK(INTMAX, &afs_callout_lock); + /* + * Run the callout table chain to see if there is already a pending + * timeout for the specified function. If so, that timeout will + * be cancelled and the tos re-used. + */ + for (tos = afs_callo.head; tos != NULL; tos = tos->tonext) { + if ((tos->trb->tof == func) && (tos->trb->func_data == (ulong) arg)) { + break; + } + } + + /* + * If a pending timeout for the specified function was NOT found, + * then the callout table chain will have to be run to find an + * unused tos. + */ + if (tos == NULL) { + for (tos = afs_callo.head; tos != NULL; tos = tos->tonext) { + if (tos->trb->tof == NULL) { + break; + } } /* - * If a pending timeout for the specified function was NOT found, - * then the callout table chain will have to be run to find an - * unused tos. + * If there isn't an available tos, then there is no error + * recovery. This means that either the caller has not + * correctly registered the number of callout table entries + * that would be needed or is incorrectly using the ones that + * were registered. Either way, panic is the only recourse. */ - if(tos == NULL) { - for(tos = afs_callo.head; tos != NULL; tos = tos->tonext) { - if(tos->trb->tof == NULL) { - break; - } - } - - /* - * If there isn't an available tos, then there is no error - * recovery. This means that either the caller has not - * correctly registered the number of callout table entries - * that would be needed or is incorrectly using the ones that - * were registered. Either way, panic is the only recourse. - */ - osi_Assert(tos != NULL); - } - /* - * A pending timeout for the specified function WAS found. - * If the request is still active, stop it. - */ - while (tstop(tos->trb)) { - AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); - goto timeout_retry; - } - - tos->type = type; /* Temp */ - tos->p1 = (long)p1; /* Temp */ - tos->trb->knext = NULL; - tos->trb->kprev = NULL; - tos->trb->flags = 0; - tos->trb->timeout = tv; - tos->trb->tof = func; - tos->trb->func = timeout_end; - tos->trb->func_data = (ulong) arg; - tos->trb->ipri = INTTIMER; - tos->trb->id = -1; - tstart(tos->trb); - + osi_Assert(tos != NULL); + } + /* + * A pending timeout for the specified function WAS found. + * If the request is still active, stop it. + */ + while (tstop(tos->trb)) { AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); + goto timeout_retry; + } + + tos->type = type; /* Temp */ + tos->p1 = (long)p1; /* Temp */ + tos->trb->knext = NULL; + tos->trb->kprev = NULL; + tos->trb->flags = 0; + tos->trb->timeout = tv; + tos->trb->tof = func; + tos->trb->func = timeout_end; + tos->trb->func_data = (ulong) arg; + tos->trb->ipri = INTTIMER; + tos->trb->id = -1; + tstart(tos->trb); + + AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); } -void untimeout( -register void (*func)(), -register ulong arg) +void +untimeout(register void (*func) (), register ulong arg) { - register int ipri; /* caller's interrupt priority */ - register struct tos *tos; /* tos to walk callout table */ - register struct trb *trb; /* trb for this tos */ + register int ipri; /* caller's interrupt priority */ + register struct tos *tos; /* tos to walk callout table */ + register struct trb *trb; /* trb for this tos */ - untimeout_retry: + untimeout_retry: - ipri = AFS_DISABLE_LOCK(INTMAX, &afs_callout_lock); - /* Run the callout table chain looking for the timeout. */ - for(tos = afs_callo.head; tos != NULL; tos = tos->tonext) { - if(tos->trb->tof == func && tos->trb->func_data == arg) { - break; - } + ipri = AFS_DISABLE_LOCK(INTMAX, &afs_callout_lock); + /* Run the callout table chain looking for the timeout. */ + for (tos = afs_callo.head; tos != NULL; tos = tos->tonext) { + if (tos->trb->tof == func && tos->trb->func_data == arg) { + break; } + } - if(tos) { - /* - * Found it on the timeout list - stop the pending timeout - * if it is active. - */ - while(tstop(tos->trb)) { - AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); - goto untimeout_retry; - } - - /* Mark this callout table entry as free. */ - tos->trb->knext = NULL; - tos->trb->kprev = NULL; - tos->trb->tof = NULL; + if (tos) { + /* + * Found it on the timeout list - stop the pending timeout + * if it is active. + */ + while (tstop(tos->trb)) { + AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); + goto untimeout_retry; } - AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); + + /* Mark this callout table entry as free. */ + tos->trb->knext = NULL; + tos->trb->kprev = NULL; + tos->trb->tof = NULL; + } + AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); } -static void timeout_end( -struct trb *trb) /* trb of the current timeout */ -{ - register void (*func)(); /* function to call at timeout */ - int ipri; - ipri = AFS_DISABLE_LOCK(INTMAX, &afs_callout_lock); +static void +timeout_end(struct trb *trb) +{ /* trb of the current timeout */ + register void (*func) (); /* function to call at timeout */ + int ipri; + ipri = AFS_DISABLE_LOCK(INTMAX, &afs_callout_lock); - func = trb->tof; - trb->func = NULL; - trb->tof = NULL; /* Zero out pointer to user function */ + func = trb->tof; + trb->func = NULL; + trb->tof = NULL; /* Zero out pointer to user function */ - AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); + AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); - (* func)(trb->func_data); - /* for compatibility with untimeout() */ + (*func) (trb->func_data); + /* for compatibility with untimeout() */ } -int timeoutcf( - register int cocnt) /* # entries to change callout table by */ -{ - register int ipri; /* caller's interrupt priority */ - register int rv; /* return value to the caller */ - register struct tos *tos; /* tos to add to/remove from table */ - register struct trb *trb; /* trb in the tos to be added/removed */ +int +timeoutcf(register int cocnt) +{ /* # entries to change callout table by */ + register int ipri; /* caller's interrupt priority */ + register int rv; /* return value to the caller */ + register struct tos *tos; /* tos to add to/remove from table */ + register struct trb *trb; /* trb in the tos to be added/removed */ - rv = 0; + rv = 0; - if(cocnt > 0) { - /* - * Callout table is being enlarged - keep working until the - * right number of elements have been added. - */ - while(cocnt > 0) { - /* Allocate a timer request block. */ - trb = (struct trb *) talloc(); - - /* - * If the low-level timer service could not provide - * a trb, the callout table can't be expanded any - * more so get out. - */ - if(trb == NULL) { - rv = -1; - break; - } - - /* Allocate memory for the callout table structure. */ - tos = (struct tos *) - xmalloc((uint)sizeof(struct tos), (uint)0, pinned_heap); - - /* - * If memory couldn't be allocated for the tos, the - * callout table can't be expanded any more so get out. - */ - if(tos == NULL) { - rv = -1; - break; - } - else { - memset(tos, 0, sizeof(struct tos)); - } - - /* The trb and the tos were both allocated. */ - tos->trb = trb; + if (cocnt > 0) { + /* + * Callout table is being enlarged - keep working until the + * right number of elements have been added. + */ + while (cocnt > 0) { + /* Allocate a timer request block. */ + trb = (struct trb *)talloc(); + + /* + * If the low-level timer service could not provide + * a trb, the callout table can't be expanded any + * more so get out. + */ + if (trb == NULL) { + rv = -1; + break; + } + + /* Allocate memory for the callout table structure. */ + tos = (struct tos *) + xmalloc((uint) sizeof(struct tos), (uint) 0, pinned_heap); + + /* + * If memory couldn't be allocated for the tos, the + * callout table can't be expanded any more so get out. + */ + if (tos == NULL) { + rv = -1; + break; + } else { + memset(tos, 0, sizeof(struct tos)); + } + + /* The trb and the tos were both allocated. */ + tos->trb = trb; #ifdef DEBUG - /* - * Debug code to ensure that the low-level timer - * service talloc() clears out the pointers. - */ - osi_Assert(trb->knext == NULL); - osi_Assert(trb->kprev == NULL); + /* + * Debug code to ensure that the low-level timer + * service talloc() clears out the pointers. + */ + osi_Assert(trb->knext == NULL); + osi_Assert(trb->kprev == NULL); #endif /* DEBUG */ - ipri = AFS_DISABLE_LOCK(INTMAX, &afs_callout_lock); - if(afs_callo.head == NULL) { - /* - * The callout table is currently empty. This - * is the easy case, just set the head of the - * callout chain to this tos. - */ - afs_callo.head = tos; - } - else { - /* - * The callout table is not empty. Chain this - * trb to the head of the callout chain. - */ - tos->tonext = afs_callo.head; - afs_callo.head->toprev = tos; - afs_callo.head = tos; - } - - /* Just finished adding a trb to the callout table. */ - afs_callo.ncallo++; - cocnt--; - AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); - } - } - else { + ipri = AFS_DISABLE_LOCK(INTMAX, &afs_callout_lock); + if (afs_callo.head == NULL) { /* - * Callout table is being shrunk - keep working until the - * right number of elements have been removed being careful - * only to remove elements which do not belong to timeout - * requests that are currently active. + * The callout table is currently empty. This + * is the easy case, just set the head of the + * callout chain to this tos. */ - if(cocnt < 0) { - - /* - * There had better be at least as many tos's in - * the callout table as the size by which the caller - * wants to decrease the size of the table. - */ - osi_Assert(afs_callo.ncallo >= -cocnt); - - while(cocnt < 0) { - - /* - * Start from the head of the callout chain, - * making sure that there is a tos at the - * head (i.e. that there is a callout chain). - */ - ipri = AFS_DISABLE_LOCK(INTMAX, - &afs_callout_lock); - tos = afs_callo.head; - osi_Assert(tos != NULL); - - /* - * Keep walking down the callout chain until - * a tos is found which is not currently - * active. - */ - while((tos != NULL) && - (tos->trb->tof != NULL)) { - tos = tos->tonext; - } - - /* - * If trb is not NULL, then there was not a - * callout table entry that wasn't set to - * timeout. Panic. - */ - osi_Assert(tos != NULL); - - /* - * Found a free callout table element, free - * it and remove it from the callout table. - */ - tfree(tos->trb); - if(afs_callo.head == tos) { - afs_callo.head = tos->tonext; - if(afs_callo.head != NULL) { - afs_callo.head->toprev = NULL; - } - } - else { - osi_Assert(tos->toprev != NULL); - tos->toprev->tonext = tos->tonext; - if(tos->tonext != NULL) { - tos->tonext->toprev = - tos->toprev; - } - } - /* - * Just finished removing a trb from the - * callout table. - */ - afs_callo.ncallo--; - cocnt++; - AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); - xmfree((void *)tos, pinned_heap); - - } - } + afs_callo.head = tos; + } else { + /* + * The callout table is not empty. Chain this + * trb to the head of the callout chain. + */ + tos->tonext = afs_callo.head; + afs_callo.head->toprev = tos; + afs_callo.head = tos; + } + + /* Just finished adding a trb to the callout table. */ + afs_callo.ncallo++; + cocnt--; + AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); } + } else { + /* + * Callout table is being shrunk - keep working until the + * right number of elements have been removed being careful + * only to remove elements which do not belong to timeout + * requests that are currently active. + */ + if (cocnt < 0) { - return(rv); -} + /* + * There had better be at least as many tos's in + * the callout table as the size by which the caller + * wants to decrease the size of the table. + */ + osi_Assert(afs_callo.ncallo >= -cocnt); + + while (cocnt < 0) { + + /* + * Start from the head of the callout chain, + * making sure that there is a tos at the + * head (i.e. that there is a callout chain). + */ + ipri = AFS_DISABLE_LOCK(INTMAX, &afs_callout_lock); + tos = afs_callo.head; + osi_Assert(tos != NULL); + /* + * Keep walking down the callout chain until + * a tos is found which is not currently + * active. + */ + while ((tos != NULL) && (tos->trb->tof != NULL)) { + tos = tos->tonext; + } + /* + * If trb is not NULL, then there was not a + * callout table entry that wasn't set to + * timeout. Panic. + */ + osi_Assert(tos != NULL); + /* + * Found a free callout table element, free + * it and remove it from the callout table. + */ + tfree(tos->trb); + if (afs_callo.head == tos) { + afs_callo.head = tos->tonext; + if (afs_callo.head != NULL) { + afs_callo.head->toprev = NULL; + } + } else { + osi_Assert(tos->toprev != NULL); + tos->toprev->tonext = tos->tonext; + if (tos->tonext != NULL) { + tos->tonext->toprev = tos->toprev; + } + } + /* + * Just finished removing a trb from the + * callout table. + */ + afs_callo.ncallo--; + cocnt++; + AFS_UNLOCK_ENABLE(ipri, &afs_callout_lock); + xmfree((void *)tos, pinned_heap); + } + } + } + return (rv); +} diff --git a/src/afs/AIX/osi_vfs.h b/src/afs/AIX/osi_vfs.h index 4b98e8b70..3e2842ccf 100644 --- a/src/afs/AIX/osi_vfs.h +++ b/src/afs/AIX/osi_vfs.h @@ -34,10 +34,9 @@ * if _SUN is defined, this is in vnode.h (at least today... who knows where * they will hide it tomorrow) */ -enum vcexcl {NONEXCL, EXCL}; /* (non)exclusive create */ +enum vcexcl { NONEXCL, EXCL }; /* (non)exclusive create */ #endif -struct buf *getblk(), *geteblk(), *breada(), *bread(); +struct buf *getblk(), *geteblk(), *breada(), *bread(); #define b_actf av_forw #define dbtob(db) ((unsigned)(db) << 9) /* (db * 512) */ - diff --git a/src/afs/AIX/osi_vfsops.c b/src/afs/AIX/osi_vfsops.c index edf30756f..10a7edfe0 100644 --- a/src/afs/AIX/osi_vfsops.c +++ b/src/afs/AIX/osi_vfsops.c @@ -13,17 +13,18 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #ifdef AFS_AIX_IAUTH_ENV #include "afs/nfsclient.h" #include "afs/exporter.h" -extern struct afs_exporter *afs_nfsexporter; +extern struct afs_exporter *afs_nfsexporter; #endif #define AFS_VFSLOCK_DECL register int glockOwner = ISAFS_GLOCK() @@ -34,12 +35,13 @@ struct vfs *afs_globalVFS = 0; struct vcache *afs_globalVp = 0; -static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp); +static int afs_root_nolock(struct vfs *afsp, struct vnode **avpp); -static int afs_mount(afsp, path, data) - char *path; - caddr_t data; - struct vfs *afsp; +static int +afs_mount(afsp, path, data) + char *path; + caddr_t data; + struct vfs *afsp; { struct vnode *afsrootvp = NULL; int error; @@ -52,7 +54,7 @@ static int afs_mount(afsp, path, data) * it well. */ AFS_VFSUNLOCK(); - return (setuerror(EBUSY)); + return (setuerror(EBUSY)); } @@ -63,31 +65,32 @@ static int afs_mount(afsp, path, data) afsp->vfs_flag |= VFS_DEVMOUNT; #endif /* AFS_64BIT_CLIENT */ - afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ - afsp->vfs_fsid.val[1] = AFS_VFSFSID; + afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ + afsp->vfs_fsid.val[1] = AFS_VFSFSID; /* For AFS, we don't allow file over file mounts. */ - if (afsp->vfs_mntdover->v_type != VDIR) - return(ENOTDIR); - /* try to get the root vnode, but don't worry if you don't. The actual - * setting of the root vnode (vfs_mntd) is done in afs_root, so that it - * get re-eval'd at the right time if things aren't working when we - * first try the mount. - */ + if (afsp->vfs_mntdover->v_type != VDIR) + return (ENOTDIR); + /* try to get the root vnode, but don't worry if you don't. The actual + * setting of the root vnode (vfs_mntd) is done in afs_root, so that it + * get re-eval'd at the right time if things aren't working when we + * first try the mount. + */ afs_root_nolock(afsp, &afsrootvp); afsp->vfs_mntdover->v_mvfsp = afsp; afsp->vfs_mdata->vmt_flags |= MNT_REMOTE; #ifdef AFS_AIX_IAUTH_ENV - if (afs_iauth_register()<0) + if (afs_iauth_register() < 0) afs_warn("Can't register AFS iauth interface.\n"); #endif AFS_VFSUNLOCK(); return 0; } -static int afs_unmount (struct vfs *afsp, int flag) +static int +afs_unmount(struct vfs *afsp, int flag) { AFS_VFSLOCK_DECL; AFS_VFSLOCK(); @@ -100,11 +103,12 @@ static int afs_unmount (struct vfs *afsp, int flag) return 0; } -static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp) +static int +afs_root_nolock(struct vfs *afsp, struct vnode **avpp) { register afs_int32 code = 0; struct vrequest treq; - register struct vcache *tvp=0; + register struct vcache *tvp = 0; AFS_STATCNT(afs_root); if (afs_globalVp && (afs_globalVp->states & CStatd)) { @@ -116,8 +120,7 @@ static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp) afs_globalVp = NULL; } credp = crref(); - if (!(code = afs_InitReq(&treq, credp)) && - !(code = afs_CheckInit())) { + if (!(code = afs_InitReq(&treq, credp)) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); /* we really want this to stay around */ if (tvp) { @@ -131,12 +134,12 @@ static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp) VN_HOLD(AFSTOV(tvp)); VN_LOCK(AFSTOV(tvp)); - AFSTOV(tvp)->v_flag |= VROOT; /* No-op on Ultrix 2.2 */ + AFSTOV(tvp)->v_flag |= VROOT; /* No-op on Ultrix 2.2 */ VN_UNLOCK(AFSTOV(tvp)); afs_globalVFS = afsp; *avpp = AFSTOV(tvp); - afsp->vfs_mntd = *avpp; + afsp->vfs_mntd = *avpp; } afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp, @@ -145,7 +148,8 @@ static int afs_root_nolock (struct vfs *afsp, struct vnode **avpp) } -static int afs_root (struct vfs *afsp, struct vnode **avpp) +static int +afs_root(struct vfs *afsp, struct vnode **avpp) { int code; AFS_VFSLOCK_DECL; @@ -155,8 +159,8 @@ static int afs_root (struct vfs *afsp, struct vnode **avpp) return code; } -static int afs_statfs(struct vfs *afsp, struct statfs *abp, - struct ucred *credp) +static int +afs_statfs(struct vfs *afsp, struct statfs *abp, struct ucred *credp) { AFS_VFSLOCK_DECL; AFS_VFSLOCK(); @@ -170,17 +174,18 @@ static int afs_statfs(struct vfs *afsp, struct statfs *abp, abp->f_vfstype = AFS_VFSFSID; abp->f_vfsnumber = afsp->vfs_number; abp->f_vfsoff = abp->f_vfslen = abp->f_vfsvers = -1; - abp->f_fsize = 4096; /* fundamental filesystem block size */ + abp->f_fsize = 4096; /* fundamental filesystem block size */ abp->f_fsid = afsp->vfs_fsid; - (void) strcpy(abp->f_fname, "/afs"); - (void) strcpy(abp->f_fpack, "AFS"); + (void)strcpy(abp->f_fname, "/afs"); + (void)strcpy(abp->f_fpack, "AFS"); abp->f_name_max = 256; AFS_VFSUNLOCK(); return 0; } -static int afs_sync() +static int +afs_sync() { AFS_VFSLOCK_DECL; AFS_VFSLOCK(); @@ -192,7 +197,8 @@ static int afs_sync() /* Note that the cred is only for AIX 4.1.5+ and AIX 4.2+ */ -static int afs_vget(struct vfs *vfsp, struct vnode **avcp, struct fileid *fidp, +static int +afs_vget(struct vfs *vfsp, struct vnode **avcp, struct fileid *fidp, struct ucred *credp) { int code; @@ -210,8 +216,8 @@ static int afs_vget(struct vfs *vfsp, struct vnode **avcp, struct fileid *fidp, } #endif - if ((code = afs_InitReq(&treq, credp))==0) { - code = afs_osi_vget((struct vcache**)avcp, fidp, &treq); + if ((code = afs_InitReq(&treq, credp)) == 0) { + code = afs_osi_vget((struct vcache **)avcp, fidp, &treq); } afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp, @@ -221,24 +227,25 @@ static int afs_vget(struct vfs *vfsp, struct vnode **avcp, struct fileid *fidp, AFS_VFSUNLOCK(); return code; } - -static int afs_badop() + +static int +afs_badop() { return EOPNOTSUPP; } struct vfsops Afs_vfsops = { - afs_mount, - afs_unmount, - afs_root, - afs_statfs, - afs_sync, - afs_vget, - afs_badop, /* vfs_cntl */ - afs_badop /* vfs_quotactl */ + afs_mount, + afs_unmount, + afs_root, + afs_statfs, + afs_sync, + afs_vget, + afs_badop, /* vfs_cntl */ + afs_badop /* vfs_quotactl */ #ifdef AFS_AIX51_ENV - ,afs_badop /* vfs_syncvfs */ + , afs_badop /* vfs_syncvfs */ #endif }; diff --git a/src/afs/AIX/osi_vm.c b/src/afs/AIX/osi_vm.c index d4b616950..336db196e 100644 --- a/src/afs/AIX/osi_vm.c +++ b/src/afs/AIX/osi_vm.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ /* Try to discard pages, in order to recycle a vcache entry. * @@ -30,7 +31,8 @@ RCSID("$Header$"); * is not dropped and re-acquired for any platform. It may be that *slept is * therefore obsolescent. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { if (avc->vrefCount != 0) return EBUSY; @@ -66,7 +68,8 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { if (avc->segid) { /* @@ -74,36 +77,36 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * the vm_writep call below. We only initiate a pageout of the * dirty vm pages on the last store... * this is strictly a pragmatic decision, and _does_ break the - * advertised AFS consistency semantics. Without this hack, - * AIX systems panic under heavy load. I consider the current - * behavior a bug introduced to hack around a worse bug. XXX + * advertised AFS consistency semantics. Without this hack, + * AIX systems panic under heavy load. I consider the current + * behavior a bug introduced to hack around a worse bug. XXX * * Removed do_writep governing sync'ing behavior. - */ - ReleaseWriteLock(&avc->lock); /* XXX */ + */ + ReleaseWriteLock(&avc->lock); /* XXX */ AFS_GUNLOCK(); - vm_writep(avc->segid, 0, MAXFSIZE/PAGESIZE -1 ); + vm_writep(avc->segid, 0, MAXFSIZE / PAGESIZE - 1); vms_iowait(avc->segid); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,93); /* XXX */ + ObtainWriteLock(&avc->lock, 93); /* XXX */ /* * The following is necessary because of the following * asynchronicity: We open a file, write to it and - * close the file + * close the file * if CCore flag is set, we clear it and do the extra - * decrement ourselves now. - * If we're called by the CCore clearer, the CCore flag - * will already be clear, so we don't have to worry about - * clearing it twice. + * decrement ourselves now. + * If we're called by the CCore clearer, the CCore flag + * will already be clear, so we don't have to worry about + * clearing it twice. * avc was "VN_HELD" and "crheld" when CCore was set in * afs_FakeClose - */ + */ if (avc->states & CCore) { avc->states &= ~CCore; avc->opens--; avc->execsOrWriters--; - AFS_RELE(AFSTOV(avc)); - crfree((struct ucred *)avc->linkData); + AFS_RELE(AFSTOV(avc)); + crfree((struct ucred *)avc->linkData); avc->linkData = NULL; } } @@ -118,16 +121,16 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * Since we drop and re-obtain the lock, we can't guarantee that there won't * be some pages around when we return, newly created by concurrent activity. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, - int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { if (avc->segid) { ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); - vm_flushp(avc->segid, 0, MAXFSIZE/PAGESIZE - 1); - vms_iowait(avc->segid); /* XXX Wait?? XXX */ + vm_flushp(avc->segid, 0, MAXFSIZE / PAGESIZE - 1); + vms_iowait(avc->segid); /* XXX Wait?? XXX */ AFS_GLOCK(); - ObtainWriteLock(&avc->lock,60); + ObtainWriteLock(&avc->lock, 60); } } @@ -135,14 +138,15 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, * * Locking: No lock is held, not even the global lock. */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { if (avc->segid) { - vm_flushp(avc->segid, 0, MAXFSIZE/PAGESIZE - 1); - /* - * XXX We probably don't need to wait but better be safe XXX - */ - vms_iowait(avc->segid); + vm_flushp(avc->segid, 0, MAXFSIZE / PAGESIZE - 1); + /* + * XXX We probably don't need to wait but better be safe XXX + */ + vms_iowait(avc->segid); } } @@ -152,11 +156,12 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * activeV is raised. This is supposed to block pageins, but at present * it only works on Solaris. */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { if (avc->segid) { - int firstpage = (alen + PAGESIZE-1)/PAGESIZE; - vm_releasep(avc->segid, firstpage, MAXFSIZE/PAGESIZE - firstpage); - vms_iowait(avc->segid); /* Do we need this? */ + int firstpage = (alen + PAGESIZE - 1) / PAGESIZE; + vm_releasep(avc->segid, firstpage, MAXFSIZE / PAGESIZE - firstpage); + vms_iowait(avc->segid); /* Do we need this? */ } } diff --git a/src/afs/AIX/osi_vnodeops.c b/src/afs/AIX/osi_vnodeops.c index 1952cf6e2..9cf454a4f 100644 --- a/src/afs/AIX/osi_vnodeops.c +++ b/src/afs/AIX/osi_vnodeops.c @@ -10,7 +10,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "h/systm.h" #include "h/types.h" @@ -106,71 +107,71 @@ int afs_gn_enosys(); * declare a struct vnodeops and initialize it with ptrs to all functions */ struct vnodeops afs_gn_vnodeops = { - /* creation/naming/deletion */ - afs_gn_link, - afs_gn_mkdir, - afs_gn_mknod, - afs_gn_remove, - afs_gn_rename, - afs_gn_rmdir, - /* lookup, file handle stuff */ - afs_gn_lookup, - afs_gn_fid, - /* access to files */ - afs_gn_open, - afs_gn_create, - afs_gn_hold, - afs_gn_rele, - afs_gn_close, - afs_gn_map, - afs_gn_unmap, - /* manipulate attributes of files */ - afs_gn_access, - afs_gn_getattr, - afs_gn_setattr, - /* data update operations */ - afs_gn_fclear, - afs_gn_fsync, - afs_gn_ftrunc, - afs_gn_rdwr, - afs_gn_lockctl, - /* extensions */ - afs_gn_ioctl, - afs_gn_readlink, - afs_gn_select, - afs_gn_symlink, - afs_gn_readdir, - /* buffer ops */ - afs_gn_strategy, - /* security things */ - afs_gn_revoke, - afs_gn_getacl, - afs_gn_setacl, - afs_gn_getpcl, - afs_gn_setpcl, - afs_gn_enosys, /* vn_seek */ - afs_gn_enosys, /* vn_fsync_range */ - afs_gn_enosys, /* vn_create_attr */ - afs_gn_enosys, /* vn_finfo */ - afs_gn_enosys, /* vn_map_lloff */ - afs_gn_enosys, /* vn_readdir_eofp */ - afs_gn_enosys, /* vn_rdwr_attr */ - afs_gn_enosys, /* vn_memcntl */ - afs_gn_enosys, /* vn_spare7 */ - afs_gn_enosys, /* vn_spare8 */ - afs_gn_enosys, /* vn_spare9 */ - afs_gn_enosys, /* vn_spareA */ - afs_gn_enosys, /* vn_spareB */ - afs_gn_enosys, /* vn_spareC */ - afs_gn_enosys, /* vn_spareD */ - afs_gn_enosys, /* vn_spareE */ - afs_gn_enosys /* vn_spareF */ + /* creation/naming/deletion */ + afs_gn_link, + afs_gn_mkdir, + afs_gn_mknod, + afs_gn_remove, + afs_gn_rename, + afs_gn_rmdir, + /* lookup, file handle stuff */ + afs_gn_lookup, + afs_gn_fid, + /* access to files */ + afs_gn_open, + afs_gn_create, + afs_gn_hold, + afs_gn_rele, + afs_gn_close, + afs_gn_map, + afs_gn_unmap, + /* manipulate attributes of files */ + afs_gn_access, + afs_gn_getattr, + afs_gn_setattr, + /* data update operations */ + afs_gn_fclear, + afs_gn_fsync, + afs_gn_ftrunc, + afs_gn_rdwr, + afs_gn_lockctl, + /* extensions */ + afs_gn_ioctl, + afs_gn_readlink, + afs_gn_select, + afs_gn_symlink, + afs_gn_readdir, + /* buffer ops */ + afs_gn_strategy, + /* security things */ + afs_gn_revoke, + afs_gn_getacl, + afs_gn_setacl, + afs_gn_getpcl, + afs_gn_setpcl, + afs_gn_enosys, /* vn_seek */ + afs_gn_enosys, /* vn_fsync_range */ + afs_gn_enosys, /* vn_create_attr */ + afs_gn_enosys, /* vn_finfo */ + afs_gn_enosys, /* vn_map_lloff */ + afs_gn_enosys, /* vn_readdir_eofp */ + afs_gn_enosys, /* vn_rdwr_attr */ + afs_gn_enosys, /* vn_memcntl */ + afs_gn_enosys, /* vn_spare7 */ + afs_gn_enosys, /* vn_spare8 */ + afs_gn_enosys, /* vn_spare9 */ + afs_gn_enosys, /* vn_spareA */ + afs_gn_enosys, /* vn_spareB */ + afs_gn_enosys, /* vn_spareC */ + afs_gn_enosys, /* vn_spareD */ + afs_gn_enosys, /* vn_spareE */ + afs_gn_enosys /* vn_spareF */ #ifdef AFS_AIX51_ENV - ,afs_gn_enosys, /* pagerBackRange */ - afs_gn_enosys, /* pagerGetFileSize */ - afs_gn_enosys, /* pagerReadAhead */ - afs_gn_enosys, /* pagerWriteBehind */ - afs_gn_enosys /* pagerEndCopy */ + , afs_gn_enosys, /* pagerBackRange */ + afs_gn_enosys, /* pagerGetFileSize */ + afs_gn_enosys, /* pagerReadAhead */ + afs_gn_enosys, /* pagerWriteBehind */ + afs_gn_enosys /* pagerEndCopy */ #endif }; struct vnodeops *afs_ops = &afs_gn_vnodeops; @@ -178,67 +179,68 @@ struct vnodeops *afs_ops = &afs_gn_vnodeops; int afs_gn_link(vp, dp, name, cred) -struct vnode *vp; -struct vnode *dp; -char *name; -struct ucred *cred; + struct vnode *vp; + struct vnode *dp; + char *name; + struct ucred *cred; { - int error; + int error; AFS_STATCNT(afs_gn_link); error = afs_link(vp, dp, name, cred); afs_Trace3(afs_iclSetp, CM_TRACE_GNLINK, ICL_TYPE_POINTER, vp, ICL_TYPE_STRING, name, ICL_TYPE_LONG, error); - return(error); + return (error); } int afs_gn_mkdir(dp, name, Mode, cred) -struct vnode *dp; -char *name; + struct vnode *dp; + char *name; #ifdef AFS_AIX51_ENV -int32long64_t Mode; + int32long64_t Mode; #else -int Mode; + int Mode; #endif -struct ucred *cred; + struct ucred *cred; { - struct vattr va; - struct vnode *vp; - int error; - int mode = Mode; + struct vattr va; + struct vnode *vp; + int error; + int mode = Mode; AFS_STATCNT(afs_gn_mkdir); VATTR_NULL(&va); va.va_type = VDIR; va.va_mode = (mode & 07777) & ~get_umask(); error = afs_mkdir(dp, name, &va, &vp, cred); - if (! error) { + if (!error) { AFS_RELE(vp); } afs_Trace4(afs_iclSetp, CM_TRACE_GMKDIR, ICL_TYPE_POINTER, vp, - ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG, error); - return(error); + ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG, + error); + return (error); } int afs_gn_mknod(dp, name, Mode, dev, cred) -struct vnode *dp; -char *name; + struct vnode *dp; + char *name; #ifdef AFS_AIX51_ENV -int Mode; + int Mode; #else -int Mode; + int Mode; #endif -dev_t dev; -struct ucred *cred; + dev_t dev; + struct ucred *cred; { - struct vattr va; - struct vnode *vp; - int error; - int mode = Mode; + struct vattr va; + struct vnode *vp; + int error; + int mode = Mode; AFS_STATCNT(afs_gn_mknod); VATTR_NULL(&va); @@ -247,166 +249,171 @@ struct ucred *cred; /**** I'm not sure if suser() should stay here since it makes no sense in AFS; however the documentation says that one "should be super-user unless making a FIFO file. Others systems such as SUN do this checking in the early stages of mknod (before the abstraction), so it's equivalently the same! *****/ if (va.va_type != VFIFO && !suser(&error)) - return(EPERM); + return (EPERM); switch (va.va_type) { - case VDIR: - error = afs_mkdir(dp, name, &va, &vp, cred); - break; - case VNON: - error = EINVAL; - break; - case VBAD: - case VCHR: - case VBLK: - va.va_rdev = dev; - default: - error = afs_create(dp, name, &va, NONEXCL, mode, &vp, cred); + case VDIR: + error = afs_mkdir(dp, name, &va, &vp, cred); + break; + case VNON: + error = EINVAL; + break; + case VBAD: + case VCHR: + case VBLK: + va.va_rdev = dev; + default: + error = afs_create(dp, name, &va, NONEXCL, mode, &vp, cred); } - if (! error) { + if (!error) { AFS_RELE(vp); } - afs_Trace4(afs_iclSetp, CM_TRACE_GMKNOD, ICL_TYPE_POINTER, (afs_int32)vp, - ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG, error); - return(error); + afs_Trace4(afs_iclSetp, CM_TRACE_GMKNOD, ICL_TYPE_POINTER, (afs_int32) vp, + ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG, + error); + return (error); } int afs_gn_remove(vp, dp, name, cred) -struct vnode *vp; /* Ignored in AFS */ -struct vnode *dp; -char *name; -struct ucred *cred; + struct vnode *vp; /* Ignored in AFS */ + struct vnode *dp; + char *name; + struct ucred *cred; { - int error; + int error; - AFS_STATCNT(afs_gn_remove); - error = afs_remove(dp, name, cred); - afs_Trace3(afs_iclSetp, CM_TRACE_GREMOVE, ICL_TYPE_POINTER, dp, - ICL_TYPE_STRING, name, ICL_TYPE_LONG, error); - return(error); + AFS_STATCNT(afs_gn_remove); + error = afs_remove(dp, name, cred); + afs_Trace3(afs_iclSetp, CM_TRACE_GREMOVE, ICL_TYPE_POINTER, dp, + ICL_TYPE_STRING, name, ICL_TYPE_LONG, error); + return (error); } int afs_gn_rename(vp, dp, name, tp, tdp, tname, cred) -struct vnode *dp; -char *name; -struct vnode *vp; /* Ignored in AFS */ -struct vnode *tp; /* Ignored in AFS */ -struct vnode *tdp; -char *tname; -struct ucred *cred; + struct vnode *dp; + char *name; + struct vnode *vp; /* Ignored in AFS */ + struct vnode *tp; /* Ignored in AFS */ + struct vnode *tdp; + char *tname; + struct ucred *cred; { - int error; + int error; - AFS_STATCNT(afs_gn_rename); + AFS_STATCNT(afs_gn_rename); error = afs_rename(dp, name, tdp, tname, cred); afs_Trace4(afs_iclSetp, CM_TRACE_GRENAME, ICL_TYPE_POINTER, dp, - ICL_TYPE_STRING, name, ICL_TYPE_STRING, tname, ICL_TYPE_LONG, error); - return(error); + ICL_TYPE_STRING, name, ICL_TYPE_STRING, tname, ICL_TYPE_LONG, + error); + return (error); } int afs_gn_rmdir(vp, dp, name, cred) -struct vnode *vp; /* Ignored in AFS */ -struct vnode *dp; -char *name; -struct ucred *cred; + struct vnode *vp; /* Ignored in AFS */ + struct vnode *dp; + char *name; + struct ucred *cred; { - int error; + int error; - AFS_STATCNT(afs_gn_rmdir); + AFS_STATCNT(afs_gn_rmdir); error = afs_rmdir(dp, name, cred); if (error) { - if (error == 66 /* 4.3's ENOTEMPTY */) - error = EEXIST; /* AIX returns EEXIST where 4.3 used ENOTEMPTY */ + if (error == 66 /* 4.3's ENOTEMPTY */ ) + error = EEXIST; /* AIX returns EEXIST where 4.3 used ENOTEMPTY */ } afs_Trace3(afs_iclSetp, CM_TRACE_GRMDIR, ICL_TYPE_POINTER, dp, ICL_TYPE_STRING, name, ICL_TYPE_LONG, error); - return(error); + return (error); } int afs_gn_lookup(dp, vpp, name, Flags, vattrp, cred) -struct vattr *vattrp; -struct vnode *dp; -struct vnode **vpp; -char *name; + struct vattr *vattrp; + struct vnode *dp; + struct vnode **vpp; + char *name; #ifdef AFS_AIX51_ENV -int32long64_t Flags; /* includes FOLLOW... */ + int32long64_t Flags; /* includes FOLLOW... */ #else -afs_uint32 Flags; /* includes FOLLOW... */ + afs_uint32 Flags; /* includes FOLLOW... */ #endif -struct ucred *cred; + struct ucred *cred; { - int error; - int flags = Flags; + int error; + int flags = Flags; - AFS_STATCNT(afs_gn_lookup); + AFS_STATCNT(afs_gn_lookup); error = afs_lookup(dp, name, vpp, cred); afs_Trace3(afs_iclSetp, CM_TRACE_GLOOKUP, ICL_TYPE_POINTER, dp, ICL_TYPE_STRING, name, ICL_TYPE_LONG, error); - if (vattrp != NULL && error == 0) - afs_gn_getattr(*vpp, vattrp, cred); - return(error); + if (vattrp != NULL && error == 0) + afs_gn_getattr(*vpp, vattrp, cred); + return (error); } int afs_gn_fid(vp, fidp, cred) -struct vnode *vp; -struct fid *fidp; -struct ucred *cred; + struct vnode *vp; + struct fid *fidp; + struct ucred *cred; { - int error; + int error; AFS_STATCNT(afs_gn_fid); - error = afs_fid(vp, fidp); + error = afs_fid(vp, fidp); afs_Trace3(afs_iclSetp, CM_TRACE_GFID, ICL_TYPE_POINTER, vp, - ICL_TYPE_LONG, (afs_int32)fidp, ICL_TYPE_LONG, error); - return(error); + ICL_TYPE_LONG, (afs_int32) fidp, ICL_TYPE_LONG, error); + return (error); } int afs_gn_open(vp, Flags, ext, vinfop, cred) -struct vnode *vp; + struct vnode *vp; #ifdef AFS_AIX51_ENV -int32long64_t Flags; -ext_t ext; /* Ignored in AFS */ + int32long64_t Flags; + ext_t ext; /* Ignored in AFS */ #else -int Flags; -int ext; /* Ignored in AFS */ + int Flags; + int ext; /* Ignored in AFS */ #endif -struct ucred **vinfop; /* return ptr for fp->f_vinfo, used as fp->f_cred */ -struct ucred *cred; + struct ucred **vinfop; /* return ptr for fp->f_vinfo, used as fp->f_cred */ + struct ucred *cred; { - int error; - struct vattr va; + int error; + struct vattr va; struct vcache *tvp = VTOAFS(vp); afs_int32 modes; - int flags = Flags; + int flags = Flags; AFS_STATCNT(afs_gn_open); modes = 0; - if ((flags & FREAD)) modes |= R_ACC; - if ((flags & FEXEC)) modes |= X_ACC; - if ((flags & FWRITE) || (flags & FTRUNC)) modes |= W_ACC; + if ((flags & FREAD)) + modes |= R_ACC; + if ((flags & FEXEC)) + modes |= X_ACC; + if ((flags & FWRITE) || (flags & FTRUNC)) + modes |= W_ACC; while ((flags & FNSHARE) && tvp->opens) { if (!(flags & FDELAY)) { - error = ETXTBSY; - goto abort; + error = ETXTBSY; + goto abort; } afs_osi_Sleep(&tvp->opens); } error = afs_access(vp, modes, cred); if (error) { - goto abort; + goto abort; } error = afs_open(&vp, flags, cred); @@ -420,58 +427,60 @@ struct ucred *cred; if (flags & FNSHARE) tvp->states |= CNSHARE; - if (! error) { - *vinfop = cred; /* fp->f_vinfo is like fp->f_cred in suns */ - } - else { + if (!error) { + *vinfop = cred; /* fp->f_vinfo is like fp->f_cred in suns */ + } else { /* an error occurred; we've told CM that the file - * is open, so close it now so that open and - * writer counts are correct. Ignore error code, - * as it is likely to fail (the setattr just did). - */ + * is open, so close it now so that open and + * writer counts are correct. Ignore error code, + * as it is likely to fail (the setattr just did). + */ afs_close(vp, flags, cred); } } -abort: + abort: afs_Trace3(afs_iclSetp, CM_TRACE_GOPEN, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, flags, ICL_TYPE_LONG, error); - return(error); + return (error); } int afs_gn_create(dp, vpp, Flags, name, Mode, vinfop, cred) -struct vnode *dp; -struct vnode **vpp; -char *name; + struct vnode *dp; + struct vnode **vpp; + char *name; #ifdef AFS_AIX51_ENV -int32long64_t Flags; -int32long64_t Mode; + int32long64_t Flags; + int32long64_t Mode; #else -int Flags; -int Mode; + int Flags; + int Mode; #endif -struct ucred **vinfop; /* return ptr for fp->f_vinfo, used as fp->f_cred */ -struct ucred *cred; + struct ucred **vinfop; /* return ptr for fp->f_vinfo, used as fp->f_cred */ + struct ucred *cred; { - struct vattr va; - enum vcexcl exclusive; - int error, modes=0; - int flags = Flags; - int mode = Mode; + struct vattr va; + enum vcexcl exclusive; + int error, modes = 0; + int flags = Flags; + int mode = Mode; AFS_STATCNT(afs_gn_create); - if ((flags & (O_EXCL|O_CREAT)) == (O_EXCL|O_CREAT)) + if ((flags & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) exclusive = EXCL; - else + else exclusive = NONEXCL; VATTR_NULL(&va); va.va_type = VREG; va.va_mode = (mode & 07777) & ~get_umask(); - if ((flags & FREAD)) modes |= R_ACC; - if ((flags & FEXEC)) modes |= X_ACC; - if ((flags & FWRITE) || (flags & FTRUNC)) modes |= W_ACC; + if ((flags & FREAD)) + modes |= R_ACC; + if ((flags & FEXEC)) + modes |= X_ACC; + if ((flags & FWRITE) || (flags & FTRUNC)) + modes |= W_ACC; error = afs_create(dp, name, &va, exclusive, modes, vpp, cred); if (error) { return error; @@ -492,61 +501,62 @@ struct ucred *cred; * are stuff in afs_open that we need. For example advance the * execsOrWriters flag (else we'll be treated as the sun's "core" * case). */ - *vinfop = cred; /* save user creds in fp->f_vinfo */ + *vinfop = cred; /* save user creds in fp->f_vinfo */ error = afs_open(vpp, flags, cred); } afs_Trace4(afs_iclSetp, CM_TRACE_GCREATE, ICL_TYPE_POINTER, dp, - ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG, error); + ICL_TYPE_STRING, name, ICL_TYPE_LONG, mode, ICL_TYPE_LONG, + error); return error; } int afs_gn_hold(vp) -struct vnode *vp; + struct vnode *vp; { AFS_STATCNT(afs_gn_hold); ++(vp->v_count); - return(0); + return (0); } int vmPageHog = 0; int afs_gn_rele(vp) -struct vnode *vp; + struct vnode *vp; { - struct vcache *vcp = VTOAFS(vp); - int error = 0; + struct vcache *vcp = VTOAFS(vp); + int error = 0; AFS_STATCNT(afs_gn_rele); if (vp->v_count == 0) osi_Panic("afs_rele: zero v_count"); if (--(vp->v_count) == 0) { if (vcp->states & CPageHog) { - vmPageHog --; + vmPageHog--; vcp->states &= ~CPageHog; } error = afs_inactive(vp, 0); } - return(error); + return (error); } int afs_gn_close(vp, Flags, vinfo, cred) -struct vnode *vp; + struct vnode *vp; #ifdef AFS_AIX51_ENV -int32long64_t Flags; + int32long64_t Flags; #else -int Flags; + int Flags; #endif -caddr_t vinfo; /* Ignored in AFS */ -struct ucred *cred; + caddr_t vinfo; /* Ignored in AFS */ + struct ucred *cred; { - int error; + int error; struct vcache *tvp = VTOAFS(vp); - int flags = Flags; + int flags = Flags; AFS_STATCNT(afs_gn_close); @@ -556,22 +566,22 @@ struct ucred *cred; } error = afs_close(vp, flags, cred); - afs_Trace3(afs_iclSetp, CM_TRACE_GCLOSE, ICL_TYPE_POINTER, (afs_int32)vp, + afs_Trace3(afs_iclSetp, CM_TRACE_GCLOSE, ICL_TYPE_POINTER, (afs_int32) vp, ICL_TYPE_LONG, flags, ICL_TYPE_LONG, error); - return(error); + return (error); } int afs_gn_map(vp, addr, Len, Off, Flag, cred) -struct vnode *vp; -caddr_t addr; + struct vnode *vp; + caddr_t addr; #ifdef AFS_AIX51_ENV -uint32long64_t Len, Off, Flag; + uint32long64_t Len, Off, Flag; #else -u_int Len, Off, Flag; + u_int Len, Off, Flag; #endif -struct ucred *cred; + struct ucred *cred; { struct vcache *vcp = VTOAFS(vp); struct vrequest treq; @@ -582,39 +592,40 @@ struct ucred *cred; AFS_STATCNT(afs_gn_map); #ifdef notdef - if (error = afs_InitReq(&treq, cred)) return error; + if (error = afs_InitReq(&treq, cred)) + return error; error = afs_VerifyVCache(vcp, &treq); if (error) return afs_CheckCode(error, &treq, 49); #endif - osi_FlushPages(vcp, cred); /* XXX ensure old pages are gone XXX */ + osi_FlushPages(vcp, cred); /* XXX ensure old pages are gone XXX */ ObtainWriteLock(&vcp->lock, 401); - vcp->states |= CMAPPED; /* flag cleared at afs_inactive */ + vcp->states |= CMAPPED; /* flag cleared at afs_inactive */ /* * We map the segment into our address space using the handle returned by vm_create. */ if (!vcp->segid) { - afs_uint32 tlen = vcp->m.Length; + afs_uint32 tlen = vcp->m.Length; #ifdef AFS_64BIT_CLIENT - if (vcp->m.Length > afs_vmMappingEnd) - tlen = afs_vmMappingEnd; + if (vcp->m.Length > afs_vmMappingEnd) + tlen = afs_vmMappingEnd; #endif /* Consider V_INTRSEG too for interrupts */ - if (error = vms_create(&vcp->segid, V_CLIENT, vcp->v.v_gnode, tlen, 0, 0)) { + if (error = + vms_create(&vcp->segid, V_CLIENT, vcp->v.v_gnode, tlen, 0, 0)) { ReleaseWriteLock(&vcp->lock); - return(EOPNOTSUPP); + return (EOPNOTSUPP); } #ifdef AFS_64BIT_KERNEL - vcp->vmh = vm_handle(vcp->segid, (int32long64_t) 0); + vcp->vmh = vm_handle(vcp->segid, (int32long64_t) 0); #else vcp->vmh = SRVAL(vcp->segid, 0, 0); #endif } - vcp->v.v_gnode->gn_seg = vcp->segid; /* XXX Important XXX */ + vcp->v.v_gnode->gn_seg = vcp->segid; /* XXX Important XXX */ if (flag & SHM_RDONLY) { vp->v_gnode->gn_mrdcnt++; - } - else { + } else { vp->v_gnode->gn_mwrcnt++; } /* @@ -634,30 +645,31 @@ struct ucred *cred; VN_HOLD(vp); afs_Trace4(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, addr, ICL_TYPE_LONG, len, ICL_TYPE_LONG, off); - return(0); + return (0); } int afs_gn_unmap(vp, flag, cred) -struct vnode *vp; + struct vnode *vp; #ifdef AFS_AIX51_ENV -int32long64_t flag; + int32long64_t flag; #else -int flag; + int flag; #endif -struct ucred *cred; + struct ucred *cred; { struct vcache *vcp = VTOAFS(vp); AFS_STATCNT(afs_gn_unmap); ObtainWriteLock(&vcp->lock, 402); if (flag & SHM_RDONLY) { vp->v_gnode->gn_mrdcnt--; - if (vp->v_gnode->gn_mrdcnt <=0) vp->v_gnode->gn_mrdcnt = 0; - } - else { + if (vp->v_gnode->gn_mrdcnt <= 0) + vp->v_gnode->gn_mrdcnt = 0; + } else { vp->v_gnode->gn_mwrcnt--; - if (vp->v_gnode->gn_mwrcnt <=0) vp->v_gnode->gn_mwrcnt = 0; + if (vp->v_gnode->gn_mwrcnt <= 0) + vp->v_gnode->gn_mwrcnt = 0; } ReleaseWriteLock(&vcp->lock); @@ -668,17 +680,17 @@ struct ucred *cred; int afs_gn_access(vp, Mode, Who, cred) -struct vnode *vp; + struct vnode *vp; #ifdef AFS_AIX51_ENV -int32long64_t Mode; -int32long64_t Who; + int32long64_t Mode; + int32long64_t Who; #else -int Mode; -int Who; + int Mode; + int Who; #endif -struct ucred *cred; + struct ucred *cred; { - int error; + int error; struct vattr vattr; int mode = Mode; int who = Who; @@ -697,130 +709,131 @@ struct ucred *cred; if (!error) { if (who == ACC_ANY) { if (((vattr.va_mode >> 6) & mode) == mode) { - error = 0; + error = 0; goto out; } } if (((vattr.va_mode >> 3) & mode) == mode) - error = 0; + error = 0; else error = EACCES; } } else if (who == ACC_ALL) { error = afs_getattr(vp, &vattr, cred); if (!error) { - if ((!((vattr.va_mode >> 6) & mode)) || (!((vattr.va_mode >> 3) & mode)) || - (!(vattr.va_mode & mode))) + if ((!((vattr.va_mode >> 6) & mode)) + || (!((vattr.va_mode >> 3) & mode)) + || (!(vattr.va_mode & mode))) error = EACCES; else error = 0; } } - + } -out: + out: afs_Trace3(afs_iclSetp, CM_TRACE_GACCESS, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, mode, ICL_TYPE_LONG, error); - return(error); + return (error); } int afs_gn_getattr(vp, vattrp, cred) -struct vnode *vp; -struct vattr *vattrp; -struct ucred *cred; + struct vnode *vp; + struct vattr *vattrp; + struct ucred *cred; { - int error; + int error; - AFS_STATCNT(afs_gn_getattr); + AFS_STATCNT(afs_gn_getattr); error = afs_getattr(vp, vattrp, cred); afs_Trace2(afs_iclSetp, CM_TRACE_GGETATTR, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, error); - return(error); + return (error); } int afs_gn_setattr(vp, op, arg1, arg2, arg3, cred) -struct vnode *vp; + struct vnode *vp; #ifdef AFS_AIX51_ENV -int32long64_t op; -int32long64_t arg1; -int32long64_t arg2; -int32long64_t arg3; + int32long64_t op; + int32long64_t arg1; + int32long64_t arg2; + int32long64_t arg3; #else -int op; -int arg1; -int arg2; -int arg3; + int op; + int arg1; + int arg2; + int arg3; #endif -struct ucred *cred; + struct ucred *cred; { - struct vattr va; - int error = 0; + struct vattr va; + int error = 0; - AFS_STATCNT(afs_gn_setattr); + AFS_STATCNT(afs_gn_setattr); VATTR_NULL(&va); - switch(op) { + switch (op) { /* change mode */ - case V_MODE: - va.va_mode = arg1; - break; - case V_OWN: - if ((arg1 & T_OWNER_AS_IS) == 0) - va.va_uid = arg2; - if ((arg1 & T_GROUP_AS_IS) == 0) - va.va_gid = arg3; - break; - case V_UTIME: + case V_MODE: + va.va_mode = arg1; + break; + case V_OWN: + if ((arg1 & T_OWNER_AS_IS) == 0) + va.va_uid = arg2; + if ((arg1 & T_GROUP_AS_IS) == 0) + va.va_gid = arg3; + break; + case V_UTIME: #ifdef notdef - error = afs_access(vp, VWRITE, cred); - if (error) - goto out; -#endif - if (arg1 & T_SETTIME) { - va.va_atime.tv_sec = time; - va.va_mtime.tv_sec = time; - } else { - va.va_atime = *(struct timestruc_t *) arg2; - va.va_mtime = *(struct timestruc_t *) arg3; - } - break; - default: - error = EINVAL; + error = afs_access(vp, VWRITE, cred); + if (error) goto out; +#endif + if (arg1 & T_SETTIME) { + va.va_atime.tv_sec = time; + va.va_mtime.tv_sec = time; + } else { + va.va_atime = *(struct timestruc_t *)arg2; + va.va_mtime = *(struct timestruc_t *)arg3; + } + break; + default: + error = EINVAL; + goto out; } error = afs_setattr(vp, &va, cred); -out: + out: afs_Trace2(afs_iclSetp, CM_TRACE_GSETATTR, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, error); - return(error); + return (error); } char zero_buffer[PAGESIZE]; int -afs_gn_fclear(vp, flags, offset, length, vinfo, cred) -struct vnode *vp; +afs_gn_fclear(vp, flags, offset, length, vinfo, cred) + struct vnode *vp; #ifdef AFS_AIX51_ENV -int32long64_t flags; + int32long64_t flags; #else -int flags; + int flags; #endif -offset_t offset; -offset_t length; -caddr_t vinfo; -struct ucred *cred; + offset_t offset; + offset_t length; + caddr_t vinfo; + struct ucred *cred; { int i, len, error = 0; struct iovec iov; struct uio uio; - static int fclear_init =0; + static int fclear_init = 0; register struct vcache *avc = VTOAFS(vp); - AFS_STATCNT(afs_gn_fclear); + AFS_STATCNT(afs_gn_fclear); if (!fclear_init) { memset(zero_buffer, 0, PAGESIZE); fclear_init = 1; @@ -829,19 +842,19 @@ struct ucred *cred; * Don't clear past ulimit */ if (offset + length > get_ulimit()) - return(EFBIG); + return (EFBIG); /* Flush all pages first */ if (avc->segid) { AFS_GUNLOCK(); - vm_flushp(avc->segid, 0, MAXFSIZE/PAGESIZE - 1); - vms_iowait(avc->segid); + vm_flushp(avc->segid, 0, MAXFSIZE / PAGESIZE - 1); + vms_iowait(avc->segid); AFS_GLOCK(); - } + } uio.afsio_offset = offset; for (i = offset; i < offset + length; i = uio.afsio_offset) { len = offset + length - i; - iov.iov_len = (len > PAGESIZE) ? PAGESIZE : len; + iov.iov_len = (len > PAGESIZE) ? PAGESIZE : len; iov.iov_base = zero_buffer; uio.afsio_iov = &iov; uio.afsio_iovcnt = 1; @@ -851,80 +864,81 @@ struct ucred *cred; break; } afs_Trace4(afs_iclSetp, CM_TRACE_GFCLEAR, ICL_TYPE_POINTER, vp, - ICL_TYPE_LONG, offset, ICL_TYPE_LONG, length, ICL_TYPE_LONG, error); + ICL_TYPE_LONG, offset, ICL_TYPE_LONG, length, ICL_TYPE_LONG, + error); return (error); } int afs_gn_fsync(vp, flags, vinfo, cred) -struct vnode *vp; + struct vnode *vp; #ifdef AFS_AIX51_ENV -int32long64_t flags; /* Not used by AFS */ -int32long64_t vinfo; /* Not used by AFS */ + int32long64_t flags; /* Not used by AFS */ + int32long64_t vinfo; /* Not used by AFS */ #else -int flags; /* Not used by AFS */ -caddr_t vinfo; /* Not used by AFS */ + int flags; /* Not used by AFS */ + caddr_t vinfo; /* Not used by AFS */ #endif -struct ucred *cred; + struct ucred *cred; { - int error; + int error; - AFS_STATCNT(afs_gn_fsync); + AFS_STATCNT(afs_gn_fsync); error = afs_fsync(vp, cred); afs_Trace3(afs_iclSetp, CM_TRACE_GFSYNC, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, flags, ICL_TYPE_LONG, error); - return(error); + return (error); } int afs_gn_ftrunc(vp, flags, length, vinfo, cred) -struct vnode *vp; + struct vnode *vp; #ifdef AFS_AIX51_ENV -int32long64_t flags; /* Ignored in AFS */ + int32long64_t flags; /* Ignored in AFS */ #else -int flags; /* Ignored in AFS */ + int flags; /* Ignored in AFS */ #endif -offset_t length; -caddr_t vinfo; /* Ignored in AFS */ -struct ucred *cred; + offset_t length; + caddr_t vinfo; /* Ignored in AFS */ + struct ucred *cred; { - struct vattr va; - int error; + struct vattr va; + int error; AFS_STATCNT(afs_gn_ftrunc); VATTR_NULL(&va); va.va_size = length; error = afs_setattr(vp, &va, cred); afs_Trace4(afs_iclSetp, CM_TRACE_GFTRUNC, ICL_TYPE_POINTER, vp, - ICL_TYPE_LONG, flags, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(length), - ICL_TYPE_LONG, error); - return(error); + ICL_TYPE_LONG, flags, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(length), ICL_TYPE_LONG, error); + return (error); } /* Min size of a file which is dumping core before we declare it a page hog. */ #define MIN_PAGE_HOG_SIZE 8388608 -int afs_gn_rdwr(vp, op, Flags, ubuf, ext, vinfo, vattrp, cred) -struct vnode *vp; -enum uio_rw op; +int +afs_gn_rdwr(vp, op, Flags, ubuf, ext, vinfo, vattrp, cred) + struct vnode *vp; + enum uio_rw op; #ifdef AFS_AIX51_ENV -int32long64_t Flags; -ext_t ext; /* Ignored in AFS */ + int32long64_t Flags; + ext_t ext; /* Ignored in AFS */ #else -int Flags; -int ext; /* Ignored in AFS */ + int Flags; + int ext; /* Ignored in AFS */ #endif -struct uio *ubuf; -caddr_t vinfo; /* Ignored in AFS */ -struct vattr *vattrp; -struct ucred *cred; + struct uio *ubuf; + caddr_t vinfo; /* Ignored in AFS */ + struct vattr *vattrp; + struct ucred *cred; { - register struct vcache *vcp = VTOAFS(vp); + register struct vcache *vcp = VTOAFS(vp); struct vrequest treq; - int error=0; + int error = 0; int free_cred = 0; int flags = Flags; @@ -932,12 +946,11 @@ struct ucred *cred; if (vcp->vc_error) { if (op == UIO_WRITE) { - afs_Trace2(afs_iclSetp, CM_TRACE_GRDWR1, - ICL_TYPE_POINTER, vp, - ICL_TYPE_LONG, vcp->vc_error); + afs_Trace2(afs_iclSetp, CM_TRACE_GRDWR1, ICL_TYPE_POINTER, vp, + ICL_TYPE_LONG, vcp->vc_error); return vcp->vc_error; } else - return EIO; + return EIO; } ObtainSharedLock(&vcp->lock, 507); @@ -957,7 +970,7 @@ struct ucred *cred; free_cred = 1; } #endif - crhold(cred); /* Bump refcount for reference in vcache */ + crhold(cred); /* Bump refcount for reference in vcache */ if (vcp->credp) { struct ucred *crp; @@ -967,27 +980,29 @@ struct ucred *cred; ConvertWToSLock(&vcp->lock); crfree(crp); } - vcp->credp = cred; + vcp->credp = cred; } ReleaseSharedLock(&vcp->lock); /* * XXX Is the following really required?? XXX */ - if (error = afs_InitReq(&treq, cred)) return error; + if (error = afs_InitReq(&treq, cred)) + return error; if (error = afs_VerifyVCache(vcp, &treq)) return afs_CheckCode(error, &treq, 50); - osi_FlushPages(vcp, cred); /* Flush old pages */ + osi_FlushPages(vcp, cred); /* Flush old pages */ if (AFS_NFSXLATORREQ(cred)) { if (flags & FSYNC) flags &= ~FSYNC; if (op == UIO_READ) { - if (!afs_AccessOK(vcp, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) { - if (free_cred) - crfree(cred); - return EACCES; + if (!afs_AccessOK + (vcp, PRSFS_READ, &treq, + CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) { + if (free_cred) + crfree(cred); + return EACCES; } } } @@ -999,14 +1014,14 @@ struct ucred *cred; */ if (op == UIO_WRITE) { #ifdef AFS_64BIT_CLIENT - if (ubuf->afsio_offset < afs_vmMappingEnd) { + if (ubuf->afsio_offset < afs_vmMappingEnd) { #endif /* AFS_64BIT_ENV */ - ObtainWriteLock(&vcp->lock,240); - vcp->states |= CDirty; /* Set the dirty bit */ - afs_FakeOpen(vcp); - ReleaseWriteLock(&vcp->lock); + ObtainWriteLock(&vcp->lock, 240); + vcp->states |= CDirty; /* Set the dirty bit */ + afs_FakeOpen(vcp); + ReleaseWriteLock(&vcp->lock); #ifdef AFS_64BIT_CLIENT - } + } #endif /* AFS_64BIT_ENV */ } @@ -1014,13 +1029,13 @@ struct ucred *cred; if (op == UIO_WRITE) { #ifdef AFS_64BIT_CLIENT - if (ubuf->afsio_offset < afs_vmMappingEnd) { + if (ubuf->afsio_offset < afs_vmMappingEnd) { #endif /* AFS_64BIT_ENV */ - ObtainWriteLock(&vcp->lock,241); - afs_FakeClose(vcp, cred); /* XXXX For nfs trans and cores XXXX */ - ReleaseWriteLock(&vcp->lock); + ObtainWriteLock(&vcp->lock, 241); + afs_FakeClose(vcp, cred); /* XXXX For nfs trans and cores XXXX */ + ReleaseWriteLock(&vcp->lock); #ifdef AFS_64BIT_CLIENT - } + } #endif /* AFS_64BIT_ENV */ } if (vattrp != NULL && error == 0) @@ -1030,17 +1045,17 @@ struct ucred *cred; ICL_TYPE_LONG, flags, ICL_TYPE_LONG, op, ICL_TYPE_LONG, error); if (free_cred) - crfree(cred); - return(error); + crfree(cred); + return (error); } #define AFS_MAX_VM_CHUNKS 10 afs_vm_rdwr(vp, uiop, rw, ioflag, credp) - register struct vnode *vp; - struct uio *uiop; - enum uio_rw rw; - int ioflag; - struct ucred *credp; + register struct vnode *vp; + struct uio *uiop; + enum uio_rw rw; + int ioflag; + struct ucred *credp; { register afs_int32 code = 0; register int i; @@ -1061,14 +1076,16 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) int counter = 0; struct vrequest treq; - if (code = afs_InitReq(&treq, credp)) return code; + if (code = afs_InitReq(&treq, credp)) + return code; /* special case easy transfer; apparently a lot are done */ - if ((xfrSize=uiop->afsio_resid) == 0) return 0; + if ((xfrSize = uiop->afsio_resid) == 0) + return 0; ObtainReadLock(&vcp->lock); fileSize = vcp->m.Length; - if (rw == UIO_WRITE && (ioflag & IO_APPEND)) { /* handle IO_APPEND mode */ + if (rw == UIO_WRITE && (ioflag & IO_APPEND)) { /* handle IO_APPEND mode */ uiop->afsio_offset = fileSize; } /* compute xfrOffset now, and do some checks */ @@ -1077,7 +1094,6 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) code = EINVAL; goto fail; } - #ifndef AFS_64BIT_CLIENT /* check for "file too big" error, which should really be done above us */ if (rw == UIO_WRITE && xfrSize + fileSize > get_ulimit()) { @@ -1091,69 +1107,70 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) if (xfrOffset < afs_vmMappingEnd) { /* special case of a buffer crossing the VM mapping line */ struct uio tuio; - struct iovec tvec[16]; /* Should have access to #define */ - afs_int32 tsize; + struct iovec tvec[16]; /* Should have access to #define */ + afs_int32 tsize; mixed = 1; finalOffset = xfrOffset + xfrSize; - tsize = (afs_size_t) (xfrOffset + xfrSize - afs_vmMappingEnd); + tsize = (afs_size_t) (xfrOffset + xfrSize - afs_vmMappingEnd); txfrSize = xfrSize; afsio_copy(uiop, &tuio, tvec); afsio_skip(&tuio, txfrSize - tsize); afsio_trim(&tuio, tsize); tuio.afsio_offset = afs_vmMappingEnd; ReleaseReadLock(&vcp->lock); - ObtainWriteLock(&vcp->lock,243); + ObtainWriteLock(&vcp->lock, 243); afs_FakeClose(vcp, credp); /* XXXX For nfs trans and cores XXXX */ ReleaseWriteLock(&vcp->lock); code = afs_direct_rdwr(vp, &tuio, rw, ioflag, credp); - ObtainWriteLock(&vcp->lock,244); - afs_FakeOpen(vcp); /* XXXX For nfs trans and cores XXXX */ + ObtainWriteLock(&vcp->lock, 244); + afs_FakeOpen(vcp); /* XXXX For nfs trans and cores XXXX */ ReleaseWriteLock(&vcp->lock); ObtainReadLock(&vcp->lock); - if (code) goto fail; - xfrSize = afs_vmMappingEnd - xfrOffset; + if (code) + goto fail; + xfrSize = afs_vmMappingEnd - xfrOffset; txfrSize = xfrSize; afsio_trim(uiop, txfrSize); } else { ReleaseReadLock(&vcp->lock); - code = afs_direct_rdwr(vp, uiop, rw, ioflag, credp); + code = afs_direct_rdwr(vp, uiop, rw, ioflag, credp); return code; } } #endif /* AFS_64BIT_CLIENT */ if (!vcp->segid) { - afs_uint32 tlen = vcp->m.Length; + afs_uint32 tlen = vcp->m.Length; #ifdef AFS_64BIT_CLIENT - if (vcp->m.Length > afs_vmMappingEnd) - tlen = afs_vmMappingEnd; + if (vcp->m.Length > afs_vmMappingEnd) + tlen = afs_vmMappingEnd; #endif /* Consider V_INTRSEG too for interrupts */ - if (code = vms_create(&vcp->segid, V_CLIENT, vcp->v.v_gnode, - tlen, 0, 0)) { + if (code = + vms_create(&vcp->segid, V_CLIENT, vcp->v.v_gnode, tlen, 0, 0)) { goto fail; } #ifdef AFS_64BIT_KERNEL - vcp->vmh = vm_handle(vcp->segid, (int32long64_t) 0); + vcp->vmh = vm_handle(vcp->segid, (int32long64_t) 0); #else - vcp->vmh = SRVAL(vcp->segid, 0, 0); + vcp->vmh = SRVAL(vcp->segid, 0, 0); #endif } vcp->v.v_gnode->gn_seg = vcp->segid; if (rw == UIO_READ) { /* don't read past EOF */ - if (xfrSize+xfrOffset > fileSize) + if (xfrSize + xfrOffset > fileSize) xfrSize = fileSize - xfrOffset; - if (xfrSize <= 0) goto fail; + if (xfrSize <= 0) + goto fail; ReleaseReadLock(&vcp->lock); #ifdef AFS_64BIT_CLIENT toffset = xfrOffset; uiop->afsio_offset = xfrOffset; - afs_Trace3(afs_iclSetp, CM_TRACE_VMWRITE, - ICL_TYPE_POINTER, vcp, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(xfrOffset), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(xfrSize)); + afs_Trace3(afs_iclSetp, CM_TRACE_VMWRITE, ICL_TYPE_POINTER, vcp, + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(xfrOffset), + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(xfrSize)); AFS_GUNLOCK(); txfrSize = xfrSize; code = vm_move(vcp->segid, toffset, txfrSize, rw, uiop); @@ -1168,13 +1185,13 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) */ if (counter == 0 || AFS_CHUNKOFFSET(xfrOffset) == 0 && xfrSize <= AFS_CHUNKSIZE(xfrOffset)) { - ObtainWriteLock(&vcp->lock,407); + ObtainWriteLock(&vcp->lock, 407); tdc = afs_FindDCache(vcp, xfrOffset); - if (tdc) { + if (tdc) { if (!(tdc->mflags & DFNextStarted)) - afs_PrefetchChunk(vcp, tdc, credp, &treq); - afs_PutDCache(tdc); - } + afs_PrefetchChunk(vcp, tdc, credp, &treq); + afs_PutDCache(tdc); + } ReleaseWriteLock(&vcp->lock); } #ifdef AFS_64BIT_CLIENT @@ -1187,30 +1204,29 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) /* UIO_WRITE */ start_offset = uiop->afsio_offset; - afs_Trace3(afs_iclSetp, CM_TRACE_VMWRITE, - ICL_TYPE_POINTER, vcp, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(start_offset), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(xfrSize)); + afs_Trace3(afs_iclSetp, CM_TRACE_VMWRITE, ICL_TYPE_POINTER, vcp, + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(start_offset), + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(xfrSize)); ReleaseReadLock(&vcp->lock); - ObtainWriteLock(&vcp->lock,400); + ObtainWriteLock(&vcp->lock, 400); vcp->m.Date = osi_Time(); /* Set file date (for ranlib) */ /* extend file */ /* un-protect last page. */ - last_page = vcp->m.Length/PAGESIZE; + last_page = vcp->m.Length / PAGESIZE; #ifdef AFS_64BIT_CLIENT if (vcp->m.Length > afs_vmMappingEnd) - last_page = afs_vmMappingEnd/PAGESIZE; + last_page = afs_vmMappingEnd / PAGESIZE; #endif vm_protectp(vcp->segid, last_page, 1, FILEKEY); if (xfrSize + xfrOffset > fileSize) { - vcp->m.Length = xfrSize+xfrOffset; - } + vcp->m.Length = xfrSize + xfrOffset; + } if ((!(vcp->states & CPageHog)) && (xfrSize >= MIN_PAGE_HOG_SIZE)) { - vmPageHog ++; + vmPageHog++; vcp->states |= CPageHog; } ReleaseWriteLock(&vcp->lock); - + /* If the write will fit into a single chunk we'll write all of it * at once. Otherwise, we'll write one chunk at a time, flushing * some of it to disk. @@ -1221,19 +1237,20 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) * small file which is either new or completely overwrites the * existing file. */ - if ((xfrOffset == 0) && (xfrSize < PAGESIZE) && (xfrSize >= fileSize) && - (vcp->v.v_gnode->gn_mwrcnt == 0) && - (vcp->v.v_gnode->gn_mrdcnt == 0)) { - (void) vm_makep(vcp->segid, 0); + if ((xfrOffset == 0) && (xfrSize < PAGESIZE) && (xfrSize >= fileSize) + && (vcp->v.v_gnode->gn_mwrcnt == 0) + && (vcp->v.v_gnode->gn_mrdcnt == 0)) { + (void)vm_makep(vcp->segid, 0); } - + while (xfrSize > 0) { offset = AFS_CHUNKBASE(xfrOffset); len = xfrSize; - + if (AFS_CHUNKSIZE(xfrOffset) <= len) - len = (afs_size_t)AFS_CHUNKSIZE(xfrOffset) - (xfrOffset - offset); - + len = + (afs_size_t) AFS_CHUNKSIZE(xfrOffset) - (xfrOffset - offset); + if (len == xfrSize) { /* All data goes to this one chunk. */ AFS_GUNLOCK(); @@ -1249,30 +1266,29 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) AFS_GLOCK(); xfrOffset += len; xfrSize = 0; - } - else { + } else { /* Write just one chunk's worth of data. */ struct uio tuio; - struct iovec tvec[16]; /* Should have access to #define */ + struct iovec tvec[16]; /* Should have access to #define */ /* Purge dirty chunks of file if there are too many dirty chunks. * Inside the write loop, we only do this at a chunk boundary. * Clean up partial chunk if necessary at end of loop. */ if (counter > 0 && code == 0 && xfrOffset == offset) { - ObtainWriteLock(&vcp->lock,403); + ObtainWriteLock(&vcp->lock, 403); if (xfrOffset > vcp->m.Length) vcp->m.Length = xfrOffset; - code = afs_DoPartialWrite(vcp, &treq); + code = afs_DoPartialWrite(vcp, &treq); vcp->states |= CDirty; ReleaseWriteLock(&vcp->lock); } counter++; - + afsio_copy(uiop, &tuio, tvec); afsio_trim(&tuio, len); tuio.afsio_offset = xfrOffset; - + AFS_GUNLOCK(); old_offset = uiop->afsio_offset; #ifdef AFS_64BIT_CLIENT @@ -1287,13 +1303,13 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) xfrSize -= len; xfrOffset += len; } - - first_page = (afs_size_t)old_offset >> PGSHIFT; - pages = 1 + (((afs_size_t)old_offset + (len - 1)) >> PGSHIFT) - first_page; - afs_Trace3(afs_iclSetp, CM_TRACE_VMWRITE2, - ICL_TYPE_POINTER, vcp, - ICL_TYPE_INT32, first_page, - ICL_TYPE_INT32, pages); + + first_page = (afs_size_t) old_offset >> PGSHIFT; + pages = + 1 + (((afs_size_t) old_offset + (len - 1)) >> PGSHIFT) - + first_page; + afs_Trace3(afs_iclSetp, CM_TRACE_VMWRITE2, ICL_TYPE_POINTER, vcp, + ICL_TYPE_INT32, first_page, ICL_TYPE_INT32, pages); AFS_GUNLOCK(); code = vm_writep(vcp->segid, first_page, pages); if (++count > AFS_MAX_VM_CHUNKS) { @@ -1301,7 +1317,7 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) vms_iowait(vcp->segid); } AFS_GLOCK(); - + } if (count) { @@ -1310,17 +1326,17 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) AFS_GLOCK(); } - ObtainWriteLock(&vcp->lock,242); + ObtainWriteLock(&vcp->lock, 242); if (code == 0 && (vcp->states & CDirty)) { code = afs_DoPartialWrite(vcp, &treq); } vm_protectp(vcp->segid, last_page, 1, RDONLY); ReleaseWriteLock(&vcp->lock); - + /* If requested, fsync the file after every write */ if (ioflag & FSYNC) afs_fsync(vp, credp); - + ObtainReadLock(&vcp->lock); if (vcp->vc_error) { /* Pretend we didn't write anything. We need to get the error back to @@ -1331,7 +1347,7 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) */ code = vcp->vc_error; if (code == EDQUOT || code == ENOSPC) - uiop->afsio_resid = save_resid; + uiop->afsio_resid = save_resid; } #ifdef AFS_64BIT_CLIENT if (mixed) { @@ -1341,41 +1357,42 @@ afs_vm_rdwr(vp, uiop, rw, ioflag, credp) fail: ReleaseReadLock(&vcp->lock); - afs_Trace2(afs_iclSetp, CM_TRACE_VMWRITE3, - ICL_TYPE_POINTER, vcp, - ICL_TYPE_INT32, code); + afs_Trace2(afs_iclSetp, CM_TRACE_VMWRITE3, ICL_TYPE_POINTER, vcp, + ICL_TYPE_INT32, code); return code; } afs_direct_rdwr(vp, uiop, rw, ioflag, credp) - register struct vnode *vp; - struct uio *uiop; - enum uio_rw rw; - int ioflag; - struct ucred *credp; -{ + register struct vnode *vp; + struct uio *uiop; + enum uio_rw rw; + int ioflag; + struct ucred *credp; +{ register afs_int32 code = 0; afs_size_t fileSize, xfrOffset, offset, old_offset, xfrSize; struct vcache *vcp = VTOAFS(vp); afs_int32 save_resid = uiop->afsio_resid; struct vrequest treq; - if (code = afs_InitReq(&treq, credp)) return code; + if (code = afs_InitReq(&treq, credp)) + return code; /* special case easy transfer; apparently a lot are done */ - if ((xfrSize=uiop->afsio_resid) == 0) return 0; + if ((xfrSize = uiop->afsio_resid) == 0) + return 0; ObtainReadLock(&vcp->lock); fileSize = vcp->m.Length; - if (rw == UIO_WRITE && (ioflag & IO_APPEND)) { /* handle IO_APPEND mode */ + if (rw == UIO_WRITE && (ioflag & IO_APPEND)) { /* handle IO_APPEND mode */ uiop->afsio_offset = fileSize; } /* compute xfrOffset now, and do some checks */ xfrOffset = uiop->afsio_offset; if (xfrOffset < 0 || xfrOffset + xfrSize < 0) { code = EINVAL; - ReleaseReadLock(&vcp->lock); + ReleaseReadLock(&vcp->lock); goto fail; } @@ -1383,29 +1400,28 @@ afs_direct_rdwr(vp, uiop, rw, ioflag, credp) #ifdef notdef if (rw == UIO_WRITE && xfrSize + fileSize > get_ulimit()) { code = EFBIG; - ReleaseReadLock(&vcp->lock); + ReleaseReadLock(&vcp->lock); goto fail; } #endif ReleaseReadLock(&vcp->lock); if (rw == UIO_WRITE) { - ObtainWriteLock(&vcp->lock,400); - vcp->m.Date = osi_Time(); /* Set file date (for ranlib) */ - /* extend file */ - if (xfrSize + xfrOffset > fileSize) + ObtainWriteLock(&vcp->lock, 400); + vcp->m.Date = osi_Time(); /* Set file date (for ranlib) */ + /* extend file */ + if (xfrSize + xfrOffset > fileSize) vcp->m.Length = xfrSize + xfrOffset; - ReleaseWriteLock(&vcp->lock); - } - afs_Trace3(afs_iclSetp, CM_TRACE_DIRECTRDWR, - ICL_TYPE_POINTER, vp, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(uiop->afsio_offset), - ICL_TYPE_LONG, uiop->afsio_resid); + ReleaseWriteLock(&vcp->lock); + } + afs_Trace3(afs_iclSetp, CM_TRACE_DIRECTRDWR, ICL_TYPE_POINTER, vp, + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(uiop->afsio_offset), + ICL_TYPE_LONG, uiop->afsio_resid); code = afs_rdwr(vp, uiop, rw, ioflag, credp); if (code != 0) { uiop->afsio_resid = save_resid; } else { uiop->afsio_offset = xfrOffset + xfrSize; - if (uiop->afsio_resid > 0) { + if (uiop->afsio_resid > 0) { /* should zero here the remaining buffer */ uiop->afsio_resid = 0; } @@ -1414,7 +1430,7 @@ afs_direct_rdwr(vp, uiop, rw, ioflag, credp) * Clean up partial chunk if necessary at end of loop. */ if (AFS_CHUNKBASE(uiop->afsio_offset) != AFS_CHUNKBASE(xfrOffset)) { - ObtainWriteLock(&vcp->lock,402); + ObtainWriteLock(&vcp->lock, 402); code = afs_DoPartialWrite(vcp, &treq); vcp->states |= CDirty; ReleaseWriteLock(&vcp->lock); @@ -1426,28 +1442,30 @@ afs_direct_rdwr(vp, uiop, rw, ioflag, credp) } -static int lock_normalize(vp, lckdat, offset, cred) - struct vnode *vp; - struct eflock *lckdat; - offset_t offset; - struct ucred *cred; +static int +lock_normalize(vp, lckdat, offset, cred) + struct vnode *vp; + struct eflock *lckdat; + offset_t offset; + struct ucred *cred; { struct vattr vattr; int code; - switch(lckdat->l_whence) { - case 0: - return 0; - case 1: - lckdat->l_start += (off_t) offset; - break; - case 2: - code = afs_getattr(vp, &vattr, cred); - if (code != 0) return code; - lckdat->l_start += (off_t) vattr.va_size; - break; - default: - return EINVAL; + switch (lckdat->l_whence) { + case 0: + return 0; + case 1: + lckdat->l_start += (off_t) offset; + break; + case 2: + code = afs_getattr(vp, &vattr, cred); + if (code != 0) + return code; + lckdat->l_start += (off_t) vattr.va_size; + break; + default: + return EINVAL; } lckdat->l_whence = 0; return 0; @@ -1456,142 +1474,144 @@ static int lock_normalize(vp, lckdat, offset, cred) afs_gn_lockctl(vp, offset, lckdat, cmd, ignored_fcn, ignored_id, cred) -void (*ignored_fcn)(); -void *ignored_id; -struct vnode *vp; -offset_t offset; -struct eflock *lckdat; -struct ucred *cred; + void (*ignored_fcn) (); + void *ignored_id; + struct vnode *vp; + offset_t offset; + struct eflock *lckdat; + struct ucred *cred; #ifdef AFS_AIX51_ENV -int32long64_t cmd; + int32long64_t cmd; #else -int cmd; + int cmd; #endif { - int error, ncmd=0; - struct flock flkd; - struct vattr *attrs; - - AFS_STATCNT(afs_gn_lockctl); - /* Convert from AIX's cmd to standard lockctl lock types... */ - if (cmd == 0) - ncmd = F_GETLK; - else if (cmd & SETFLCK) { - ncmd = F_SETLK; - if (cmd & SLPFLCK) - ncmd = F_SETLKW; - } - flkd.l_type = lckdat->l_type; - flkd.l_whence = lckdat->l_whence; - flkd.l_start = lckdat->l_start; - flkd.l_len = lckdat->l_len; - flkd.l_pid = lckdat->l_pid; - flkd.l_sysid = lckdat->l_sysid; - - if (flkd.l_start != lckdat->l_start || flkd.l_len != lckdat->l_len) - return EINVAL; + int error, ncmd = 0; + struct flock flkd; + struct vattr *attrs; + + AFS_STATCNT(afs_gn_lockctl); + /* Convert from AIX's cmd to standard lockctl lock types... */ + if (cmd == 0) + ncmd = F_GETLK; + else if (cmd & SETFLCK) { + ncmd = F_SETLK; + if (cmd & SLPFLCK) + ncmd = F_SETLKW; + } + flkd.l_type = lckdat->l_type; + flkd.l_whence = lckdat->l_whence; + flkd.l_start = lckdat->l_start; + flkd.l_len = lckdat->l_len; + flkd.l_pid = lckdat->l_pid; + flkd.l_sysid = lckdat->l_sysid; + + if (flkd.l_start != lckdat->l_start || flkd.l_len != lckdat->l_len) + return EINVAL; if (error = lock_normalize(vp, &flkd, offset, cred)) - return(error); + return (error); error = afs_lockctl(vp, &flkd, ncmd, cred); - lckdat->l_type = flkd.l_type; - lckdat->l_whence = flkd.l_whence; - lckdat->l_start = flkd.l_start; - lckdat->l_len = flkd.l_len; - lckdat->l_pid = flkd.l_pid; - lckdat->l_sysid = flkd.l_sysid; + lckdat->l_type = flkd.l_type; + lckdat->l_whence = flkd.l_whence; + lckdat->l_start = flkd.l_start; + lckdat->l_len = flkd.l_len; + lckdat->l_pid = flkd.l_pid; + lckdat->l_sysid = flkd.l_sysid; afs_Trace3(afs_iclSetp, CM_TRACE_GLOCKCTL, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, ncmd, ICL_TYPE_LONG, error); - return(error); + return (error); } /* NOTE: In the nfs glue routine (nfs_gn2sun.c) the order was wrong (vp, flags, cmd, arg, ext); was that another typo? */ -int afs_gn_ioctl(vp, Cmd, arg, flags, channel, ext) -struct vnode *vp; +int +afs_gn_ioctl(vp, Cmd, arg, flags, channel, ext) + struct vnode *vp; #ifdef AFS_AIX51_ENV -int32long64_t Cmd; + int32long64_t Cmd; #else -int Cmd; + int Cmd; #endif -int arg; -int flags; /* Ignored in AFS */ -int channel; /* Ignored in AFS */ -int ext; /* Ignored in AFS */ + int arg; + int flags; /* Ignored in AFS */ + int channel; /* Ignored in AFS */ + int ext; /* Ignored in AFS */ { - int error; + int error; int cmd = Cmd; AFS_STATCNT(afs_gn_ioctl); - /* This seems to be a perfect fit for our ioctl redirection (afs_xioctl hack); thus the ioctl(2) entry in sysent.c is unaffected in the aix/afs port. */ + /* This seems to be a perfect fit for our ioctl redirection (afs_xioctl hack); thus the ioctl(2) entry in sysent.c is unaffected in the aix/afs port. */ error = afs_ioctl(vp, cmd, arg); afs_Trace3(afs_iclSetp, CM_TRACE_GIOCTL, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, cmd, ICL_TYPE_LONG, error); - return(error); + return (error); } int -afs_gn_readlink(vp, uiop, cred) -struct vnode *vp; -struct uio *uiop; -struct ucred *cred; +afs_gn_readlink(vp, uiop, cred) + struct vnode *vp; + struct uio *uiop; + struct ucred *cred; { - int error; + int error; - AFS_STATCNT(afs_gn_readlink); + AFS_STATCNT(afs_gn_readlink); error = afs_readlink(vp, uiop, cred); afs_Trace2(afs_iclSetp, CM_TRACE_GREADLINK, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, error); - return(error); + return (error); } int afs_gn_select(vp, which, vinfo, mpx) -struct vnode *vp; -int which; -caddr_t *vinfo; -caddr_t *mpx; + struct vnode *vp; + int which; + caddr_t *vinfo; + caddr_t *mpx; { - AFS_STATCNT(afs_gn_select); + AFS_STATCNT(afs_gn_select); /* NO SUPPORT for this in afs YET! */ - return(EOPNOTSUPP); + return (EOPNOTSUPP); } int afs_gn_symlink(vp, link, target, cred) -struct vnode *vp; -char *target; -char *link; -struct ucred *cred; + struct vnode *vp; + char *target; + char *link; + struct ucred *cred; { - struct vattr va; - int error; + struct vattr va; + int error; AFS_STATCNT(afs_gn_symlink); VATTR_NULL(&va); va.va_mode = 0777; error = afs_symlink(vp, link, &va, target, cred); afs_Trace4(afs_iclSetp, CM_TRACE_GSYMLINK, ICL_TYPE_POINTER, vp, - ICL_TYPE_STRING, link, ICL_TYPE_STRING, target, ICL_TYPE_LONG, error); - return(error); + ICL_TYPE_STRING, link, ICL_TYPE_STRING, target, ICL_TYPE_LONG, + error); + return (error); } int afs_gn_readdir(vp, uiop, cred) -struct vnode *vp; -struct uio *uiop; -struct ucred *cred; + struct vnode *vp; + struct uio *uiop; + struct ucred *cred; { - int error; + int error; - AFS_STATCNT(afs_gn_readdir); + AFS_STATCNT(afs_gn_readdir); error = afs_readdir(vp, uiop, cred); afs_Trace2(afs_iclSetp, CM_TRACE_GREADDIR, ICL_TYPE_POINTER, vp, ICL_TYPE_LONG, error); - return(error); + return (error); } @@ -1615,14 +1635,14 @@ extern int afs_asyncbuf_cv; */ #define AIX_VM_BLKSIZE 8192 afs_gn_strategy(abp, cred) -struct ucred *cred; -register struct buf *abp; + struct ucred *cred; + register struct buf *abp; { register struct buf **lbp, *tbp; #ifdef AFS_64BIT_KERNEL - afs_int64 *lwbp; /* last quy in work chain */ + afs_int64 *lwbp; /* last quy in work chain */ #else - int *lwbp; /* last guy in work chain */ + int *lwbp; /* last guy in work chain */ #endif struct buf *nbp, *qbp, *qnbp, *firstComparable; int doMerge; @@ -1635,10 +1655,10 @@ register struct buf *abp; && !((y)->b_flags & B_PFPROT)) oldPriority = disable_lock(INTMAX, &afs_asyncbuf_lock); - for(tbp = abp; tbp; tbp=nbp) { + for (tbp = abp; tbp; tbp = nbp) { nbp = tbp->av_forw; /* remember for later */ tbp->b_work = 0; - tbp->av_back = (struct buf *) afs_biotime++; + tbp->av_back = (struct buf *)afs_biotime++; /* first insert the buffer into the afs_async queue. Insert buffer * sorted within its disk position within a set of comparable buffers. @@ -1647,9 +1667,10 @@ register struct buf *abp; */ firstComparable = NULL; lbp = &afs_asyncbuf; - for(qbp = *lbp; qbp; lbp = &qbp->av_forw, qbp = *lbp) { + for (qbp = *lbp; qbp; lbp = &qbp->av_forw, qbp = *lbp) { if (EFS_COMPARABLE(tbp, qbp)) { - if (!firstComparable) firstComparable = qbp; + if (!firstComparable) + firstComparable = qbp; /* this buffer is comparable, so see if the next buffer * is farther in the file; if it is insert before next buffer. */ @@ -1701,31 +1722,34 @@ register struct buf *abp; * the file system block size, then we know that such blocks are also * on block boundaries. */ - - doMerge = 1; /* start the loop */ - while(doMerge) { /* loop until an iteration doesn't - * make any more changes */ + + doMerge = 1; /* start the loop */ + while (doMerge) { /* loop until an iteration doesn't + * make any more changes */ doMerge = 0; - for (qbp = firstComparable; ; qbp = qnbp) { + for (qbp = firstComparable;; qbp = qnbp) { qnbp = qbp->av_forw; - if (!qnbp) break; /* we're done */ - if (!EFS_COMPARABLE(qbp, qnbp)) break; + if (!qnbp) + break; /* we're done */ + if (!EFS_COMPARABLE(qbp, qnbp)) + break; /* try to merge qbp and qnbp */ /* first check if both not adjacent go on to next region */ - if ((dbtob(qbp->b_blkno) + qbp->b_bcount) != dbtob(qnbp->b_blkno)) + if ((dbtob(qbp->b_blkno) + qbp->b_bcount) != + dbtob(qnbp->b_blkno)) continue; /* note if both in the same block, the first byte of leftmost guy * and last byte of rightmost guy are in the same block. */ - if ((dbtob(qbp->b_blkno) & ~(AIX_VM_BLKSIZE-1)) == - ((dbtob(qnbp->b_blkno)+qnbp->b_bcount-1) & ~(AIX_VM_BLKSIZE-1))) { + if ((dbtob(qbp->b_blkno) & ~(AIX_VM_BLKSIZE - 1)) == + ((dbtob(qnbp->b_blkno) + qnbp->b_bcount - + 1) & ~(AIX_VM_BLKSIZE - 1))) { doMerge = 1; /* both in same block */ - } - else if ((qbp->b_bcount & (AIX_VM_BLKSIZE-1)) == 0 - && (qnbp->b_bcount & (AIX_VM_BLKSIZE-1)) == 0) { + } else if ((qbp->b_bcount & (AIX_VM_BLKSIZE - 1)) == 0 + && (qnbp->b_bcount & (AIX_VM_BLKSIZE - 1)) == 0) { doMerge = 1; /* both integral #s of blocks */ } if (doMerge) { @@ -1734,100 +1758,106 @@ register struct buf *abp; /* merge both of these blocks together */ /* first set age to the older of the two */ #ifdef AFS_64BIT_KERNEL - if ((afs_int64) qnbp->av_back - (afs_int64) qbp->av_back < 0) + if ((afs_int64) qnbp->av_back - (afs_int64) qbp->av_back < + 0) #else - if ((int) qnbp->av_back - (int) qbp->av_back < 0) + if ((int)qnbp->av_back - (int)qbp->av_back < 0) #endif qbp->av_back = qnbp->av_back; lwbp = &qbp->b_work; /* find end of qbp's work queue */ - for(xbp = (struct buf *)(*lwbp); xbp; - lwbp = &xbp->b_work, xbp = (struct buf *) (*lwbp)); + for (xbp = (struct buf *)(*lwbp); xbp; + lwbp = &xbp->b_work, xbp = (struct buf *)(*lwbp)); /* * now setting *lwbp will change the last ptr in the qbp's * work chain */ - qbp->av_forw = qnbp->av_forw; /* splice out qnbp */ - qbp->b_bcount += qnbp->b_bcount; /* fix count */ + qbp->av_forw = qnbp->av_forw; /* splice out qnbp */ + qbp->b_bcount += qnbp->b_bcount; /* fix count */ #ifdef AFS_64BIT_KERNEL - *lwbp = (afs_int64) qnbp; /* append qnbp to end */ + *lwbp = (afs_int64) qnbp; /* append qnbp to end */ #else - *lwbp = (int) qnbp; /* append qnbp to end */ + *lwbp = (int)qnbp; /* append qnbp to end */ #endif /* * note that qnbp is bogus, but it doesn't matter because * we're going to restart the for loop now. */ - break; /* out of the for loop */ + break; /* out of the for loop */ } } } - } /* for loop for all interrupt data */ + } /* for loop for all interrupt data */ /* at this point, all I/O has been queued. Wakeup the daemon */ - e_wakeup_one((int*) &afs_asyncbuf_cv); + e_wakeup_one((int *)&afs_asyncbuf_cv); unlock_enable(oldPriority, &afs_asyncbuf_lock); return 0; } afs_inactive(avc, acred) - register struct vcache *avc; - struct AFS_UCRED *acred; + register struct vcache *avc; + struct AFS_UCRED *acred; { afs_InactiveVCache(avc, acred); } int afs_gn_revoke(vp) -struct vnode *vp; + struct vnode *vp; { AFS_STATCNT(afs_gn_revoke); /* NO SUPPORT for this in afs YET! */ - return(EOPNOTSUPP); + return (EOPNOTSUPP); } -int afs_gn_getacl(vp, uiop, cred) - struct vnode *vp; - struct uio *uiop; - struct ucred *cred; -{ +int +afs_gn_getacl(vp, uiop, cred) + struct vnode *vp; + struct uio *uiop; + struct ucred *cred; +{ return ENOSYS; }; -int afs_gn_setacl(vp, uiop, cred) - struct vnode *vp; - struct uio *uiop; - struct ucred *cred; -{ +int +afs_gn_setacl(vp, uiop, cred) + struct vnode *vp; + struct uio *uiop; + struct ucred *cred; +{ return ENOSYS; }; -int afs_gn_getpcl(vp, uiop, cred) - struct vnode *vp; - struct uio *uiop; - struct ucred *cred; -{ +int +afs_gn_getpcl(vp, uiop, cred) + struct vnode *vp; + struct uio *uiop; + struct ucred *cred; +{ return ENOSYS; }; -int afs_gn_setpcl(vp, uiop, cred) - struct vnode *vp; - struct uio *uiop; - struct ucred *cred; -{ +int +afs_gn_setpcl(vp, uiop, cred) + struct vnode *vp; + struct uio *uiop; + struct ucred *cred; +{ return ENOSYS; }; -int afs_gn_enosys() +int +afs_gn_enosys() { return ENOSYS; } - -extern struct vfsops Afs_vfsops; -extern struct vnodeops afs_gn_vnodeops; -extern int Afs_init(); + +extern struct vfsops Afs_vfsops; +extern struct vnodeops afs_gn_vnodeops; +extern int Afs_init(); #define AFS_CALLOUT_TBL_SIZE 256 @@ -1838,764 +1868,825 @@ extern int Afs_init(); */ static -vfs_mount(struct vfs *a, struct ucred *b) { - register glockOwner, ret; +vfs_mount(struct vfs *a, struct ucred *b) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*Afs_vfsops.vfs_mount)(a, b); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*Afs_vfsops.vfs_mount) (a, b); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vfs_unmount(struct vfs *a, int b, struct ucred *c) { - register glockOwner, ret; +vfs_unmount(struct vfs *a, int b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*Afs_vfsops.vfs_unmount)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*Afs_vfsops.vfs_unmount) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vfs_root(struct vfs *a, struct vnode **b, struct ucred *c) { - register glockOwner, ret; +vfs_root(struct vfs *a, struct vnode **b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*Afs_vfsops.vfs_root)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*Afs_vfsops.vfs_root) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vfs_statfs(struct vfs *a, struct statfs *b, struct ucred *c) { - register glockOwner, ret; +vfs_statfs(struct vfs *a, struct statfs *b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*Afs_vfsops.vfs_statfs)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*Afs_vfsops.vfs_statfs) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vfs_sync(struct gfs *a) { - register glockOwner, ret; +vfs_sync(struct gfs *a) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*Afs_vfsops.vfs_sync)(a); - if (!glockOwner) - AFS_GUNLOCK(); - return ret; + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*Afs_vfsops.vfs_sync) (a); + if (!glockOwner) + AFS_GUNLOCK(); + return ret; } static -vfs_vget(struct vfs *a, struct vnode **b, struct fileid *c - , struct ucred *d) { - register glockOwner, ret; +vfs_vget(struct vfs *a, struct vnode **b, struct fileid *c, struct ucred *d) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*Afs_vfsops.vfs_vget)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*Afs_vfsops.vfs_vget) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vfs_cntl(struct vfs *a, int b, caddr_t c, size_t d, struct ucred *e) { - register glockOwner, ret; +vfs_cntl(struct vfs *a, int b, caddr_t c, size_t d, struct ucred *e) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*Afs_vfsops.vfs_cntl)(a, b, c, d, e); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*Afs_vfsops.vfs_cntl) (a, b, c, d, e); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vfs_quotactl(struct vfs *a, int b, uid_t c, caddr_t d - , struct ucred *e) { - register glockOwner, ret; +vfs_quotactl(struct vfs *a, int b, uid_t c, caddr_t d, struct ucred *e) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*Afs_vfsops.vfs_quotactl)(a, b, c, d, e); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*Afs_vfsops.vfs_quotactl) (a, b, c, d, e); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } #ifdef AFS_AIX51_ENV static vfs_syncvfs(struct gfs *a, struct vfs *b, int c, struct ucred *d) { - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*Afs_vfsops.vfs_syncvfs)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*Afs_vfsops.vfs_syncvfs) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } #endif struct vfsops locked_Afs_vfsops = { - vfs_mount, - vfs_unmount, - vfs_root, - vfs_statfs, - vfs_sync, - vfs_vget, - vfs_cntl, - vfs_quotactl, + vfs_mount, + vfs_unmount, + vfs_root, + vfs_statfs, + vfs_sync, + vfs_vget, + vfs_cntl, + vfs_quotactl, #ifdef AFS_AIX51_ENV - vfs_syncvfs + vfs_syncvfs #endif }; static -vn_link(struct vnode *a, struct vnode *b, char *c, struct ucred *d) { - register glockOwner, ret; +vn_link(struct vnode *a, struct vnode *b, char *c, struct ucred *d) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_link)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_link) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_mkdir(struct vnode *a, char *b, int32long64_t c, struct ucred *d) { +vn_mkdir(struct vnode *a, char *b, int32long64_t c, struct ucred *d) +{ #else -vn_mkdir(struct vnode *a, char *b, int c, struct ucred *d) { +vn_mkdir(struct vnode *a, char *b, int c, struct ucred *d) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_mkdir)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_mkdir) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_mknod(struct vnode *a, caddr_t b, int32long64_t c, dev_t d, struct ucred *e) { +vn_mknod(struct vnode *a, caddr_t b, int32long64_t c, dev_t d, + struct ucred *e) +{ #else -vn_mknod(struct vnode *a, caddr_t b, int c, dev_t d, struct ucred *e) { +vn_mknod(struct vnode *a, caddr_t b, int c, dev_t d, struct ucred *e) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_mknod)(a, b, c, d, e); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_mknod) (a, b, c, d, e); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_remove(struct vnode *a, struct vnode *b, char *c, struct ucred *d) { - register glockOwner, ret; +vn_remove(struct vnode *a, struct vnode *b, char *c, struct ucred *d) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_remove)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_remove) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_rename(struct vnode *a, struct vnode *b, caddr_t c - , struct vnode *d, struct vnode *e, caddr_t f, struct ucred *g) { - register glockOwner, ret; +vn_rename(struct vnode *a, struct vnode *b, caddr_t c, struct vnode *d, + struct vnode *e, caddr_t f, struct ucred *g) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_rename)(a, b, c, d, e, f, g); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_rename) (a, b, c, d, e, f, g); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_rmdir(struct vnode *a, struct vnode *b, char *c, struct ucred *d) { - register glockOwner, ret; +vn_rmdir(struct vnode *a, struct vnode *b, char *c, struct ucred *d) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_rmdir)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_rmdir) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_lookup(struct vnode *a, struct vnode **b, char *c, int32long64_t d, + vn_lookup(struct vnode *a, struct vnode **b, char *c, int32long64_t d, #else vn_lookup(struct vnode *a, struct vnode **b, char *c, int d, #endif - struct vattr *v, struct ucred *e) { - register glockOwner, ret; + struct vattr *v, struct ucred *e) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_lookup)(a, b, c, d, v, e); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_lookup) (a, b, c, d, v, e); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_fid(struct vnode *a, struct fileid *b, struct ucred *c) { - register glockOwner, ret; +vn_fid(struct vnode *a, struct fileid *b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_fid)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_fid) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_open(struct vnode *a, int b, int c, caddr_t *d, struct ucred *e) { +vn_open(struct vnode *a, int b, int c, caddr_t * d, struct ucred *e) +{ #else -vn_open(struct vnode *a, int32long64_t b, ext_t c, caddr_t *d, struct ucred *e) { +vn_open(struct vnode *a, int32long64_t b, ext_t c, caddr_t * d, + struct ucred *e) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_open)(a, b, c, d, e); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_open) (a, b, c, d, e); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_create(struct vnode *a, struct vnode **b, int32long64_t c, caddr_t d - , int32long64_t e, caddr_t *f, struct ucred *g) { +vn_create(struct vnode *a, struct vnode **b, int32long64_t c, caddr_t d, + int32long64_t e, caddr_t * f, struct ucred *g) +{ #else -vn_create(struct vnode *a, struct vnode **b, int c, caddr_t d - , int e, caddr_t *f, struct ucred *g) { +vn_create(struct vnode *a, struct vnode **b, int c, caddr_t d, int e, + caddr_t * f, struct ucred *g) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_create)(a, b, c, d, e, f, g); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_create) (a, b, c, d, e, f, g); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_hold(struct vnode *a) { - register glockOwner, ret; +vn_hold(struct vnode *a) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_hold)(a); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_hold) (a); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_rele(struct vnode *a) { - register glockOwner, ret; +vn_rele(struct vnode *a) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_rele)(a); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_rele) (a); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_close(struct vnode *a, int32long64_t b, caddr_t c, struct ucred *d) { +vn_close(struct vnode *a, int32long64_t b, caddr_t c, struct ucred *d) +{ #else -vn_close(struct vnode *a, int b, caddr_t c, struct ucred *d) { +vn_close(struct vnode *a, int b, caddr_t c, struct ucred *d) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_close)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_close) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_map(struct vnode *a, caddr_t b, uint32long64_t c, uint32long64_t d, uint32long64_t e, struct ucred *f) { +vn_map(struct vnode *a, caddr_t b, uint32long64_t c, uint32long64_t d, + uint32long64_t e, struct ucred *f) +{ #else -vn_map(struct vnode *a, caddr_t b, uint c, uint d, uint e, struct ucred *f) { +vn_map(struct vnode *a, caddr_t b, uint c, uint d, uint e, struct ucred *f) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_map)(a, b, c, d, e, f); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_map) (a, b, c, d, e, f); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_unmap(struct vnode *a, int32long64_t b, struct ucred *c) { +vn_unmap(struct vnode *a, int32long64_t b, struct ucred *c) +{ #else -vn_unmap(struct vnode *a, int b, struct ucred *c) { +vn_unmap(struct vnode *a, int b, struct ucred *c) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_unmap)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_unmap) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_access(struct vnode *a, int32long64_t b, int32long64_t c, struct ucred *d) { +vn_access(struct vnode *a, int32long64_t b, int32long64_t c, struct ucred *d) +{ #else -vn_access(struct vnode *a, int b, int c, struct ucred *d) { +vn_access(struct vnode *a, int b, int c, struct ucred *d) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_access)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_access) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_getattr(struct vnode *a, struct vattr *b, struct ucred *c) { - register glockOwner, ret; +vn_getattr(struct vnode *a, struct vattr *b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_getattr)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_getattr) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_setattr(struct vnode *a, int32long64_t b, int32long64_t c, int32long64_t d, int32long64_t e, struct ucred *f) { +vn_setattr(struct vnode *a, int32long64_t b, int32long64_t c, int32long64_t d, + int32long64_t e, struct ucred *f) +{ #else -vn_setattr(struct vnode *a, int b, int c, int d, int e, struct ucred *f) { +vn_setattr(struct vnode *a, int b, int c, int d, int e, struct ucred *f) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_setattr)(a, b, c, d, e, f); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_setattr) (a, b, c, d, e, f); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_fclear(struct vnode *a, int32long64_t b, offset_t c, offset_t d + vn_fclear(struct vnode *a, int32long64_t b, offset_t c, offset_t d #else vn_fclear(struct vnode *a, int b, offset_t c, offset_t d #endif - , caddr_t e, struct ucred *f) { - register glockOwner, ret; + , caddr_t e, struct ucred *f) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_fclear)(a, b, c, d, e, f); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_fclear) (a, b, c, d, e, f); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_fsync(struct vnode *a, int32long64_t b, int32long64_t c, struct ucred *d) { +vn_fsync(struct vnode *a, int32long64_t b, int32long64_t c, struct ucred *d) +{ #else -vn_fsync(struct vnode *a, int b, int c, struct ucred *d) { +vn_fsync(struct vnode *a, int b, int c, struct ucred *d) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_fsync)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_fsync) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_ftrunc(struct vnode *a, int32long64_t b, offset_t c, caddr_t d, struct ucred *e) { +vn_ftrunc(struct vnode *a, int32long64_t b, offset_t c, caddr_t d, + struct ucred *e) +{ #else -vn_ftrunc(struct vnode *a, int b, offset_t c, caddr_t d, struct ucred *e) { +vn_ftrunc(struct vnode *a, int b, offset_t c, caddr_t d, struct ucred *e) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_ftrunc)(a, b, c, d, e); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_ftrunc) (a, b, c, d, e); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_rdwr(struct vnode *a, enum uio_rw b, int32long64_t c, struct uio *d - , ext_t e, caddr_t f, struct vattr *v, struct ucred *g) { +vn_rdwr(struct vnode *a, enum uio_rw b, int32long64_t c, struct uio *d, + ext_t e, caddr_t f, struct vattr *v, struct ucred *g) +{ #else -vn_rdwr(struct vnode *a, enum uio_rw b, int c, struct uio *d - , int e, caddr_t f, struct vattr *v, struct ucred *g) { +vn_rdwr(struct vnode *a, enum uio_rw b, int c, struct uio *d, int e, + caddr_t f, struct vattr *v, struct ucred *g) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_rdwr)(a, b, c, d, e, f, v, g); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_rdwr) (a, b, c, d, e, f, v, g); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_lockctl(struct vnode *a, offset_t b, struct eflock *c, int32long64_t d - , int (*e)(), ulong32int64_t *f, struct ucred *g) { +vn_lockctl(struct vnode *a, offset_t b, struct eflock *c, int32long64_t d, + int (*e) (), ulong32int64_t * f, struct ucred *g) +{ #else -vn_lockctl(struct vnode *a, offset_t b, struct eflock *c, int d - , int (*e)(), ulong *f, struct ucred *g) { +vn_lockctl(struct vnode *a, offset_t b, struct eflock *c, int d, int (*e) (), + ulong * f, struct ucred *g) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_lockctl)(a, b, c, d, e, f, g); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_lockctl) (a, b, c, d, e, f, g); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_ioctl(struct vnode *a, int32long64_t b, caddr_t c, size_t d, ext_t e, struct ucred *f) { +vn_ioctl(struct vnode *a, int32long64_t b, caddr_t c, size_t d, ext_t e, + struct ucred *f) +{ #else -vn_ioctl(struct vnode *a, int b, caddr_t c, size_t d, int e, struct ucred *f) { +vn_ioctl(struct vnode *a, int b, caddr_t c, size_t d, int e, struct ucred *f) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_ioctl)(a, b, c, d, e, f); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_ioctl) (a, b, c, d, e, f); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_readlink(struct vnode *a, struct uio *b, struct ucred *c) { - register glockOwner, ret; +vn_readlink(struct vnode *a, struct uio *b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_readlink)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_readlink) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_select(struct vnode *a, int32long64_t b, ushort c, ushort *d, void (*e)() + vn_select(struct vnode *a, int32long64_t b, ushort c, ushort * d, + void (*e) () #else -vn_select(struct vnode *a, int b, ushort c, ushort *d, void (*e)() +vn_select(struct vnode *a, int b, ushort c, ushort * d, void (*e) () #endif - , caddr_t f, struct ucred *g) { - register glockOwner, ret; + , caddr_t f, struct ucred *g) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_select)(a, b, c, d, e, f, g); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_select) (a, b, c, d, e, f, g); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_symlink(struct vnode *a, char *b, char *c, struct ucred *d) { - register glockOwner, ret; +vn_symlink(struct vnode *a, char *b, char *c, struct ucred *d) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_symlink)(a, b, c, d); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_symlink) (a, b, c, d); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_readdir(struct vnode *a, struct uio *b, struct ucred *c) { - register glockOwner, ret; +vn_readdir(struct vnode *a, struct uio *b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_readdir)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_readdir) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static #ifdef AFS_AIX51_ENV -vn_revoke(struct vnode *a, int32long64_t b, int32long64_t c, struct vattr *d, struct ucred *e) { +vn_revoke(struct vnode *a, int32long64_t b, int32long64_t c, struct vattr *d, + struct ucred *e) +{ #else -vn_revoke(struct vnode *a, int b, int c, struct vattr *d, struct ucred *e) { +vn_revoke(struct vnode *a, int b, int c, struct vattr *d, struct ucred *e) +{ #endif - register glockOwner, ret; + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_revoke)(a, b, c, d, e); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_revoke) (a, b, c, d, e); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_getacl(struct vnode *a, struct uio *b, struct ucred *c) { - register glockOwner, ret; +vn_getacl(struct vnode *a, struct uio *b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_getacl)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_getacl) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_setacl(struct vnode *a, struct uio *b, struct ucred *c) { - register glockOwner, ret; +vn_setacl(struct vnode *a, struct uio *b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_setacl)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_setacl) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_getpcl(struct vnode *a, struct uio *b, struct ucred *c) { - register glockOwner, ret; +vn_getpcl(struct vnode *a, struct uio *b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_getpcl)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_getpcl) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } static -vn_setpcl(struct vnode *a, struct uio *b, struct ucred *c) { - register glockOwner, ret; +vn_setpcl(struct vnode *a, struct uio *b, struct ucred *c) +{ + register glockOwner, ret; - glockOwner = ISAFS_GLOCK(); - if (!glockOwner) - AFS_GLOCK(); - ret = (*afs_gn_vnodeops.vn_setpcl)(a, b, c); - if (!glockOwner) - AFS_GUNLOCK(); + glockOwner = ISAFS_GLOCK(); + if (!glockOwner) + AFS_GLOCK(); + ret = (*afs_gn_vnodeops.vn_setpcl) (a, b, c); + if (!glockOwner) + AFS_GUNLOCK(); - return ret; + return ret; } extern int afs_gn_strategy(); struct vnodeops locked_afs_gn_vnodeops = { - vn_link, - vn_mkdir, - vn_mknod, - vn_remove, - vn_rename, - vn_rmdir, - vn_lookup, - vn_fid, - vn_open, - vn_create, - vn_hold, - vn_rele, - vn_close, - vn_map, - vn_unmap, - vn_access, - vn_getattr, - vn_setattr, - vn_fclear, - vn_fsync, - vn_ftrunc, - vn_rdwr, - vn_lockctl, - vn_ioctl, - vn_readlink, - vn_select, - vn_symlink, - vn_readdir, - afs_gn_strategy, /* no locking!!! (discovered the hard way) */ - vn_revoke, - vn_getacl, - vn_setacl, - vn_getpcl, - vn_setpcl, - afs_gn_enosys, /* vn_seek */ - afs_gn_enosys, /* vn_fsync_range */ - afs_gn_enosys, /* vn_create_attr */ - afs_gn_enosys, /* vn_finfo */ - afs_gn_enosys, /* vn_map_lloff */ - afs_gn_enosys, /* vn_readdir_eofp */ - afs_gn_enosys, /* vn_rdwr_attr */ - afs_gn_enosys, /* vn_memcntl */ - afs_gn_enosys, /* vn_spare7 */ - afs_gn_enosys, /* vn_spare8 */ - afs_gn_enosys, /* vn_spare9 */ - afs_gn_enosys, /* vn_spareA */ - afs_gn_enosys, /* vn_spareB */ - afs_gn_enosys, /* vn_spareC */ - afs_gn_enosys, /* vn_spareD */ - afs_gn_enosys, /* vn_spareE */ - afs_gn_enosys /* vn_spareF */ + vn_link, + vn_mkdir, + vn_mknod, + vn_remove, + vn_rename, + vn_rmdir, + vn_lookup, + vn_fid, + vn_open, + vn_create, + vn_hold, + vn_rele, + vn_close, + vn_map, + vn_unmap, + vn_access, + vn_getattr, + vn_setattr, + vn_fclear, + vn_fsync, + vn_ftrunc, + vn_rdwr, + vn_lockctl, + vn_ioctl, + vn_readlink, + vn_select, + vn_symlink, + vn_readdir, + afs_gn_strategy, /* no locking!!! (discovered the hard way) */ + vn_revoke, + vn_getacl, + vn_setacl, + vn_getpcl, + vn_setpcl, + afs_gn_enosys, /* vn_seek */ + afs_gn_enosys, /* vn_fsync_range */ + afs_gn_enosys, /* vn_create_attr */ + afs_gn_enosys, /* vn_finfo */ + afs_gn_enosys, /* vn_map_lloff */ + afs_gn_enosys, /* vn_readdir_eofp */ + afs_gn_enosys, /* vn_rdwr_attr */ + afs_gn_enosys, /* vn_memcntl */ + afs_gn_enosys, /* vn_spare7 */ + afs_gn_enosys, /* vn_spare8 */ + afs_gn_enosys, /* vn_spare9 */ + afs_gn_enosys, /* vn_spareA */ + afs_gn_enosys, /* vn_spareB */ + afs_gn_enosys, /* vn_spareC */ + afs_gn_enosys, /* vn_spareD */ + afs_gn_enosys, /* vn_spareE */ + afs_gn_enosys /* vn_spareF */ #ifdef AFS_AIX51_ENV - ,afs_gn_enosys, /* pagerBackRange */ - afs_gn_enosys, /* pagerGetFileSize */ - afs_gn_enosys, /* pagerReadAhead */ - afs_gn_enosys, /* pagerWriteBehind */ - afs_gn_enosys /* pagerEndCopy */ + , afs_gn_enosys, /* pagerBackRange */ + afs_gn_enosys, /* pagerGetFileSize */ + afs_gn_enosys, /* pagerReadAhead */ + afs_gn_enosys, /* pagerWriteBehind */ + afs_gn_enosys /* pagerEndCopy */ #endif }; struct gfs afs_gfs = { - &locked_Afs_vfsops, - &locked_afs_gn_vnodeops, - AFS_MOUNT_AFS, - "afs", - Afs_init, - GFS_VERSION4 | GFS_REMOTE, - NULL + &locked_Afs_vfsops, + &locked_afs_gn_vnodeops, + AFS_MOUNT_AFS, + "afs", + Afs_init, + GFS_VERSION4 | GFS_REMOTE, + NULL }; - diff --git a/src/afs/DARWIN/osi_file.c b/src/afs/DARWIN/osi_file.c index f3ff494e0..478541476 100644 --- a/src/afs/DARWIN/osi_file.c +++ b/src/afs/DARWIN/osi_file.c @@ -10,88 +10,91 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /* Standard vendor system headers */ -#include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/sysincludes.h" /* Standard vendor system headers */ +#include "afsincludes.h" /* Afs-based standard headers */ +#include "afs/afs_stats.h" /* afs statistics */ #include "afs/osi_inode.h" -int afs_osicred_initialized=0; -struct AFS_UCRED afs_osi_cred; -afs_lock_t afs_xosi; /* lock is for tvattr */ +int afs_osicred_initialized = 0; +struct AFS_UCRED afs_osi_cred; +afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct mount *afs_cacheVfsp; int afs_CacheFSType = -1; /* Initialize the cache operations. Called while initializing cache files. */ -void afs_InitDualFSCacheOps(struct vnode *vp) +void +afs_InitDualFSCacheOps(struct vnode *vp) { int code; static int inited = 0; if (inited) - return; + return; inited = 1; if (vp == NULL) - return; + return; if (strncmp("hfs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0) - afs_CacheFSType = AFS_APPL_HFS_CACHE; - else - if (strncmp("ufs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0) - afs_CacheFSType = AFS_APPL_UFS_CACHE; + afs_CacheFSType = AFS_APPL_HFS_CACHE; + else if (strncmp("ufs", vp->v_mount->mnt_vfc->vfc_name, 3) == 0) + afs_CacheFSType = AFS_APPL_UFS_CACHE; else - osi_Panic("Unknown cache vnode type\n"); + osi_Panic("Unknown cache vnode type\n"); } -ino_t VnodeToIno(vnode_t *avp) +ino_t +VnodeToIno(vnode_t * avp) { - unsigned long ret; + unsigned long ret; - if (afs_CacheFSType == AFS_APPL_UFS_CACHE) { - struct inode *ip = VTOI(avp); - ret=ip->i_number; - } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) { + if (afs_CacheFSType == AFS_APPL_UFS_CACHE) { + struct inode *ip = VTOI(avp); + ret = ip->i_number; + } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) { #ifndef VTOH - struct vattr va; - if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc())) - osi_Panic("VOP_GETATTR failed in VnodeToIno\n"); - ret=va.va_fileid; + struct vattr va; + if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc())) + osi_Panic("VOP_GETATTR failed in VnodeToIno\n"); + ret = va.va_fileid; #else - struct hfsnode *hp = VTOH(avp); - ret=H_FILEID(hp); + struct hfsnode *hp = VTOH(avp); + ret = H_FILEID(hp); #endif - } else - osi_Panic("VnodeToIno called before cacheops initialized\n"); - return ret; + } else + osi_Panic("VnodeToIno called before cacheops initialized\n"); + return ret; } -dev_t VnodeToDev(vnode_t *avp) +dev_t +VnodeToDev(vnode_t * avp) { - - if (afs_CacheFSType == AFS_APPL_UFS_CACHE) { - struct inode *ip = VTOI(avp); - return ip->i_dev; - } else - if (afs_CacheFSType == AFS_APPL_HFS_CACHE) { -#ifndef VTOH /* slow, but works */ - struct vattr va; - if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc())) - osi_Panic("VOP_GETATTR failed in VnodeToDev\n"); - return va.va_fsid; /* XXX they say it's the dev.... */ + + if (afs_CacheFSType == AFS_APPL_UFS_CACHE) { + struct inode *ip = VTOI(avp); + return ip->i_dev; + } else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) { +#ifndef VTOH /* slow, but works */ + struct vattr va; + if (VOP_GETATTR(avp, &va, &afs_osi_cred, current_proc())) + osi_Panic("VOP_GETATTR failed in VnodeToDev\n"); + return va.va_fsid; /* XXX they say it's the dev.... */ #else - struct hfsnode *hp = VTOH(avp); - return H_DEV(hp); + struct hfsnode *hp = VTOH(avp); + return H_DEV(hp); #endif - } else - osi_Panic("VnodeToDev called before cacheops initialized\n"); + } else + osi_Panic("VnodeToDev called before cacheops initialized\n"); } -void *osi_UFSOpen(afs_int32 ainode) +void * +osi_UFSOpen(afs_int32 ainode) { struct vnode *vp; struct vattr va; @@ -100,25 +103,26 @@ void *osi_UFSOpen(afs_int32 ainode) afs_int32 code = 0; int dummy; AFS_STATCNT(osi_UFSOpen); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) { + if (cacheDiskType != AFS_FCACHE_TYPE_UFS) { osi_Panic("UFSOpen called for non-UFS cache\n"); } if (!afs_osicred_initialized) { /* valid for alpha_osf, SunOS, Ultrix */ memset((char *)&afs_osi_cred, 0, sizeof(struct AFS_UCRED)); afs_osi_cred.cr_ref++; - afs_osi_cred.cr_ngroups=1; + afs_osi_cred.cr_ngroups = 1; afs_osicred_initialized = 1; } - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); - if (afs_CacheFSType == AFS_APPL_HFS_CACHE) - code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, &ainode, &vp, &va, &dummy); /* XXX hfs is broken */ + if (afs_CacheFSType == AFS_APPL_HFS_CACHE) + code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, &ainode, &vp, &va, &dummy); /* XXX hfs is broken */ + else if (afs_CacheFSType == AFS_APPL_UFS_CACHE) + code = + igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode, + &vp, &va, &dummy); else - if (afs_CacheFSType == AFS_APPL_UFS_CACHE) - code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode, &vp, &va, &dummy); - else - panic("osi_UFSOpen called before cacheops initialized\n"); + panic("osi_UFSOpen called before cacheops initialized\n"); AFS_GLOCK(); if (code) { osi_FreeSmallSpace(afile); @@ -127,19 +131,20 @@ void *osi_UFSOpen(afs_int32 ainode) afile->vnode = vp; afile->size = va.va_size; afile->offset = 0; - afile->proc = (int (*)()) 0; - afile->inum = ainode; /* for hint validity checking */ + afile->proc = (int (*)())0; + afile->inum = ainode; /* for hint validity checking */ return (void *)afile; } -int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) +int +afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) { register afs_int32 code; struct vattr tvattr; AFS_STATCNT(osi_Stat); - MObtainWriteLock(&afs_xosi,320); + MObtainWriteLock(&afs_xosi, 320); AFS_GUNLOCK(); - code=VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc()); + code = VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc()); AFS_GLOCK(); if (code == 0) { astat->size = tvattr.va_size; @@ -151,18 +156,20 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta return code; } -int osi_UFSClose(register struct osi_file *afile) +int +osi_UFSClose(register struct osi_file *afile) { - AFS_STATCNT(osi_Close); - if(afile->vnode) { + AFS_STATCNT(osi_Close); + if (afile->vnode) { AFS_RELE(afile->vnode); - } - - osi_FreeSmallSpace(afile); - return 0; + } + + osi_FreeSmallSpace(afile); + return 0; } -int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) +int +osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) { struct AFS_UCRED *oldCred; struct vattr tvattr; @@ -175,36 +182,40 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) * small enough. Check now and save some time. */ code = afs_osi_Stat(afile, &tstat); - if (code || tstat.size <= asize) return code; - MObtainWriteLock(&afs_xosi,321); + if (code || tstat.size <= asize) + return code; + MObtainWriteLock(&afs_xosi, 321); VATTR_NULL(&tvattr); tvattr.va_size = asize; AFS_GUNLOCK(); - code=VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc()); + code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc()); AFS_GLOCK(); MReleaseWriteLock(&afs_xosi); return code; } -void osi_DisableAtimes(struct vnode *avp) +void +osi_DisableAtimes(struct vnode *avp) { - if (afs_CacheFSType == AFS_APPL_UFS_CACHE) { - struct inode *ip = VTOI(avp); - ip->i_flag &= ~IN_ACCESS; - } -#ifdef VTOH /* can't do this without internals */ - else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) { - struct hfsnode *hp = VTOH(avp); - hp->h_nodeflags &= ~IN_ACCESS; - } + if (afs_CacheFSType == AFS_APPL_UFS_CACHE) { + struct inode *ip = VTOI(avp); + ip->i_flag &= ~IN_ACCESS; + } +#ifdef VTOH /* can't do this without internals */ + else if (afs_CacheFSType == AFS_APPL_HFS_CACHE) { + struct hfsnode *hp = VTOH(avp); + hp->h_nodeflags &= ~IN_ACCESS; + } #endif } /* Generic read interface */ -int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize) +int +afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; unsigned int resid; @@ -215,56 +226,61 @@ int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_in * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ - if ( !afile ) { - if ( !afs_shuttingdown ) + if (!afile) { + if (!afs_shuttingdown) osi_Panic("osi_Read called with null param"); else return EIO; } - if (offset != -1) afile->offset = offset; + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); - code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, + AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); - } - else { + } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, - ICL_TYPE_INT32, code); + ICL_TYPE_INT32, code); code = -1; } return code; } /* Generic write interface */ -int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) +int +afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; unsigned int resid; register afs_int32 code; AFS_STATCNT(osi_Write); - if ( !afile ) + if (!afile) osi_Panic("afs_osi_Write called with null param"); - if (offset != -1) afile->offset = offset; + if (offset != -1) + afile->offset = offset; { AFS_GUNLOCK(); - code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, + afile->offset, AFS_UIOSYS, IO_UNIT, &afs_osi_cred, + &resid); AFS_GLOCK(); } if (code == 0) { code = asize - resid; afile->offset += code; - } - else { + } else { code = -1; } if (afile->proc) { - (*afile->proc)(afile, code); + (*afile->proc) (afile, code); } return code; } @@ -273,13 +289,13 @@ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, -void shutdown_osifile(void) +void +shutdown_osifile(void) { - extern int afs_cold_shutdown; + extern int afs_cold_shutdown; - AFS_STATCNT(shutdown_osifile); - if (afs_cold_shutdown) { - afs_osicred_initialized = 0; - } + AFS_STATCNT(shutdown_osifile); + if (afs_cold_shutdown) { + afs_osicred_initialized = 0; + } } - diff --git a/src/afs/DARWIN/osi_groups.c b/src/afs/DARWIN/osi_groups.c index cba32ddfd..d5703b51e 100644 --- a/src/afs/DARWIN/osi_groups.c +++ b/src/afs/DARWIN/osi_groups.c @@ -17,61 +17,56 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset); + afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset); static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent); + afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent); int Afs_xsetgroups(p, args, retval) - struct proc *p; - void *args; - int *retval; + struct proc *p; + void *args; + int *retval; { int code = 0; struct vrequest treq; struct ucred *cr; pcred_readlock(p); - cr=crdup(p->p_cred->pc_ucred); + cr = crdup(p->p_cred->pc_ucred); pcred_unlock(p); AFS_STATCNT(afs_xsetgroups); AFS_GLOCK(); - + code = afs_InitReq(&treq, cr); AFS_GUNLOCK(); crfree(cr); - if (code) return setgroups(p, args, retval); /* afs has shut down */ + if (code) + return setgroups(p, args, retval); /* afs has shut down */ code = setgroups(p, args, retval); /* Note that if there is a pag already in the new groups we don't * overwrite it with the old pag. */ pcred_readlock(p); - cr=crdup(p->p_cred->pc_ucred); + cr = crdup(p->p_cred->pc_ucred); pcred_unlock(p); if (PagInCred(cr) == NOPAG) { if (((treq.uid >> 24) & 0xff) == 'A') { AFS_GLOCK(); /* we've already done a setpag, so now we redo it */ - AddPag(p, treq.uid, &cr ); + AddPag(p, treq.uid, &cr); AFS_GUNLOCK(); } } @@ -82,11 +77,11 @@ Afs_xsetgroups(p, args, retval) int setpag(proc, cred, pagvalue, newpag, change_parent) - struct proc *proc; - struct ucred **cred; - afs_uint32 pagvalue; - afs_uint32 *newpag; - afs_uint32 change_parent; + struct proc *proc; + struct ucred **cred; + afs_uint32 pagvalue; + afs_uint32 *newpag; + afs_uint32 change_parent; { gid_t gidset[NGROUPS]; int ngroups, code; @@ -99,12 +94,12 @@ setpag(proc, cred, pagvalue, newpag, change_parent) if (ngroups + 2 > NGROUPS) { return (E2BIG); } - for (j = ngroups -1; j >= 1; j--) { - gidset[j+2] = gidset[j]; + for (j = ngroups - 1; j >= 1; j--) { + gidset[j + 2] = gidset[j]; } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]); code = afs_setgroups(proc, cred, ngroups, gidset, change_parent); return code; @@ -112,10 +107,7 @@ setpag(proc, cred, pagvalue, newpag, change_parent) static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset) +afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset) { int ngrps, savengrps; gid_t *gp; @@ -124,19 +116,15 @@ afs_getgroups( savengrps = ngrps = MIN(ngroups, cred->cr_ngroups); gp = cred->cr_groups; while (ngrps--) - *gidset++ = *gp++; + *gidset++ = *gp++; return savengrps; } static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent) { int ngrps; int i; @@ -158,16 +146,16 @@ afs_setgroups( if (change_parent) { crhold(cr); pcred_writelock(proc->p_pptr); - oldcr=proc->p_pptr->p_cred->pc_ucred; - proc->p_pptr->p_cred->pc_ucred=cr; + oldcr = proc->p_pptr->p_cred->pc_ucred; + proc->p_pptr->p_cred->pc_ucred = cr; pcred_unlock(proc->p_pptr); crfree(oldcr); } crhold(cr); pcred_writelock(proc); - oldcr=proc->p_cred->pc_ucred; - proc->p_cred->pc_ucred=cr; + oldcr = proc->p_cred->pc_ucred; + proc->p_cred->pc_ucred = cr; pcred_unlock(proc); crfree(oldcr); - return(0); + return (0); } diff --git a/src/afs/DARWIN/osi_inode.c b/src/afs/DARWIN/osi_inode.c index b59507753..a6bbeda95 100644 --- a/src/afs/DARWIN/osi_inode.c +++ b/src/afs/DARWIN/osi_inode.c @@ -15,12 +15,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /* Standard vendor system headers */ -#include "afsincludes.h" /* Afs-based standard headers */ +#include "afs/sysincludes.h" /* Standard vendor system headers */ +#include "afsincludes.h" /* Afs-based standard headers */ #include "afs/osi_inode.h" -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include extern struct ucred afs_osi_cred; @@ -44,43 +45,44 @@ getinode(fs, dev, inode, vpp, perror) register struct vnode *vp; register struct mount *mp; extern struct mount *rootfs; - if (mp = rootfs) do { - /* - * XXX Also do the test for MFS - */ - if (!strcmp(mp->mnt_vfc->vfc_name, "ufs")) { - ump = VFSTOUFS(mp); - if (ump->um_fs == NULL) - break; - if (ump->um_dev == dev) { - fs = ump->um_mountp; - } - } + if (mp = rootfs) + do { + /* + * XXX Also do the test for MFS + */ + if (!strcmp(mp->mnt_vfc->vfc_name, "ufs")) { + ump = VFSTOUFS(mp); + if (ump->um_fs == NULL) + break; + if (ump->um_dev == dev) { + fs = ump->um_mountp; + } + } #ifdef VFSTOHFS - if (!strcmp(mp->mnt_vfc->vfc_name, "hfs")) { - hmp = VFSTOHFS(mp); + if (!strcmp(mp->mnt_vfc->vfc_name, "hfs")) { + hmp = VFSTOHFS(mp); #if 0 - if (hmp->hfs_mp == NULL) - break; + if (hmp->hfs_mp == NULL) + break; #endif - if (hmp->hfs_raw_dev == dev) { - fs = hmp->hfs_mp; - } - } + if (hmp->hfs_raw_dev == dev) { + fs = hmp->hfs_mp; + } + } #endif - mp = CIRCLEQ_NEXT(mp, mnt_list); - } while (mp != rootfs); + mp = CIRCLEQ_NEXT(mp, mnt_list); + } while (mp != rootfs); if (!fs) - return(ENXIO); + return (ENXIO); } - code=VFS_VGET(fs, (void *)inode, &vp); + code = VFS_VGET(fs, (void *)inode, &vp); if (code) { *perror = BAD_IGET; return code; - } else { + } else { *vpp = vp; - return(0); + return (0); } } extern int afs_CacheFSType; @@ -100,34 +102,34 @@ igetinode(vfsp, dev, inode, vpp, va, perror) AFS_STATCNT(igetinode); if ((code = getinode(vfsp, dev, inode, &vp, perror)) != 0) { - return(code); + return (code); } if (vp->v_type != VREG && vp->v_type != VDIR && vp->v_type != VLNK) { - printf("igetinode: bad type %d\n", vp->v_type); - iforget(vp); - return(ENOENT); + printf("igetinode: bad type %d\n", vp->v_type); + iforget(vp); + return (ENOENT); } VOP_GETATTR(vp, va, &afs_osi_cred, current_proc()); if (va->va_mode == 0) { /* Not an allocated inode */ - iforget(vp); - return(ENOENT); + iforget(vp); + return (ENOENT); } if (vfsp && afs_CacheFSType == AFS_APPL_HFS_CACHE && va->va_nlink == 0) { - printf("igetinode: hfs nlink 0\n"); + printf("igetinode: hfs nlink 0\n"); } if (va->va_nlink == 0) { vput(vp); - return(ENOENT); + return (ENOENT); } VOP_UNLOCK(vp, 0, current_proc()); *vpp = vp; - return(0); + return (0); } iforget(vp) -struct vnode *vp; + struct vnode *vp; { AFS_STATCNT(iforget); @@ -135,8 +137,8 @@ struct vnode *vp; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, current_proc()); /* this whole thing is too wierd. Why??? XXX */ if (vp->v_usecount == 1) { - vp->v_usecount=0; - VOP_UNLOCK(vp,0, current_proc()); + vp->v_usecount = 0; + VOP_UNLOCK(vp, 0, current_proc()); #if 0 simple_lock(&vnode_free_list_slock); TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); @@ -158,72 +160,70 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval) long *retval; long dev, near_inode, param1, param2, param3, param4; { - int dummy, err=0; + int dummy, err = 0; struct inode *ip, *newip; register int code; struct vnode *vp; - + AFS_STATCNT(afs_syscall_icreate); - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = getinode(0, (dev_t)dev, 2, &ip, &dummy); + code = getinode(0, (dev_t) dev, 2, &ip, &dummy); if (code) { - return(ENOENT); + return (ENOENT); } - code = ialloc(ip, (ino_t)near_inode, 0, &newip); + code = ialloc(ip, (ino_t) near_inode, 0, &newip); iput(ip); if (code) { - return(code); + return (code); } IN_LOCK(newip); - newip->i_flag |= IACC|IUPD|ICHG; - + newip->i_flag |= IACC | IUPD | ICHG; + newip->i_nlink = 1; newip->i_mode = IFREG; - + IN_UNLOCK(newip); vp = ITOV(newip); VN_LOCK(vp); vp->v_type = VREG; VN_UNLOCK(vp); - - if ( !vp->v_object) - { - extern struct vfs_ubcops ufs_ubcops; - extern struct vm_ubc_object* ubc_object_allocate(); - struct vm_ubc_object* vop; - vop = ubc_object_allocate(&vp, &ufs_ubcops, - vp->v_mount->m_funnel); - VN_LOCK(vp); - vp->v_object = vop; - VN_UNLOCK(vp); - } - - + + if (!vp->v_object) { + extern struct vfs_ubcops ufs_ubcops; + extern struct vm_ubc_object *ubc_object_allocate(); + struct vm_ubc_object *vop; + vop = ubc_object_allocate(&vp, &ufs_ubcops, vp->v_mount->m_funnel); + VN_LOCK(vp); + vp->v_object = vop; + VN_UNLOCK(vp); + } + + IN_LOCK(newip); - newip->i_flags |= IC_XUID|IC_XGID; + newip->i_flags |= IC_XUID | IC_XGID; newip->i_flags &= ~IC_PROPLIST; newip->i_vicep1 = param1; - if (param2 == 0x1fffffff/*INODESPECIAL*/) { + if (param2 == 0x1fffffff /*INODESPECIAL*/) { newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3)); - newip->i_vicep3a = (u_short)(param3 >> 16); - newip->i_vicep3b = (u_short)param3; + newip->i_vicep3a = (u_short) (param3 >> 16); + newip->i_vicep3b = (u_short) param3; } else { - newip->i_vicep2 = (((param2 >> 16) & 0x1f) << 27) + - (((param4 >> 16) & 0x1f) << 22) + - (param3 & 0x3fffff); - newip->i_vicep3a = (u_short)param4; - newip->i_vicep3b = (u_short)param2; + newip->i_vicep2 = + (((param2 >> 16) & 0x1f) << 27) + + (((param4 >> 16) & 0x1f) << 22) + (param3 & 0x3fffff); + newip->i_vicep3a = (u_short) param4; + newip->i_vicep3b = (u_short) param2; } newip->i_vicemagic = VICEMAGIC; - + *retval = newip->i_number; IN_UNLOCK(newip); iput(newip); - return(code); + return (code); } @@ -238,32 +238,32 @@ afs_syscall_iopen(dev, inode, usrmod, retval) int fd; extern struct fileops vnops; register int code; - + AFS_STATCNT(afs_syscall_iopen); - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy); + code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy); if (code) { - return(code); + return (code); } if ((code = falloc(&fp, &fd)) != 0) { iput(ip); - return(code); + return (code); } IN_UNLOCK(ip); - + FP_LOCK(fp); - fp->f_flag = (usrmod-FOPEN) & FMASK; + fp->f_flag = (usrmod - FOPEN) & FMASK; fp->f_type = DTYPE_VNODE; fp->f_ops = &vnops; - fp->f_data = (caddr_t)ITOV(ip); - + fp->f_data = (caddr_t) ITOV(ip); + FP_UNLOCK(fp); U_FD_SET(fd, fp, &u.u_file_state); *retval = fd; - return(0); + return (0); } @@ -279,18 +279,18 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount) int dummy; struct inode *ip; register int code; - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy); + code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy); if (code) { - return(code); + return (code); } if (!IS_VICEMAGIC(ip)) { - return(EPERM); + return (EPERM); } else if (ip->i_vicep1 != inode_p1) { - return(ENXIO); + return (ENXIO); } ip->i_nlink += amount; if (ip->i_nlink == 0) { @@ -298,24 +298,26 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount) } ip->i_flag |= ICHG; iput(ip); - return(0); + return (0); } #else afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval) long *retval; long dev, near_inode, param1, param2, param3, param4; { - return EOPNOTSUPP; + return EOPNOTSUPP; } + afs_syscall_iopen(dev, inode, usrmod, retval) long *retval; int dev, inode, usrmod; { - return EOPNOTSUPP; + return EOPNOTSUPP; } + afs_syscall_iincdec(dev, inode, inode_p1, amount) int dev, inode, inode_p1, amount; { - return EOPNOTSUPP; + return EOPNOTSUPP; } #endif diff --git a/src/afs/DARWIN/osi_inode.h b/src/afs/DARWIN/osi_inode.h index f392a2666..c1b48fb84 100644 --- a/src/afs/DARWIN/osi_inode.h +++ b/src/afs/DARWIN/osi_inode.h @@ -25,13 +25,13 @@ #define i_vicep1 i_din.di_gen #define i_vicep2 i_din.di_uid #define i_vicep3 i_din.di_gid -#define i_vicep4 i_din.di_spare[0] /* not used */ +#define i_vicep4 i_din.di_spare[0] /* not used */ #define di_vicemagic di_flags #define di_vicep1 di_gen #define di_vicep2 di_uid #define di_vicep3 di_gid -#define di_vicep4 di_spare[0] /* not used */ +#define di_vicep4 di_spare[0] /* not used */ #define IS_VICEMAGIC(ip) ((ip)->i_vicemagic == VICEMAGIC) #define IS_DVICEMAGIC(dp) ((dp)->di_vicemagic == VICEMAGIC) diff --git a/src/afs/DARWIN/osi_machdep.h b/src/afs/DARWIN/osi_machdep.h index 9feda0345..c7eeaf652 100644 --- a/src/afs/DARWIN/osi_machdep.h +++ b/src/afs/DARWIN/osi_machdep.h @@ -21,7 +21,7 @@ #ifdef XAFS_DARWIN_ENV #ifndef _MACH_ETAP_H_ #define _MACH_ETAP_H_ -typedef unsigned short etap_event_t; +typedef unsigned short etap_event_t; #endif #endif @@ -37,7 +37,7 @@ typedef unsigned short etap_event_t; #define FTRUNC 0 /* vcexcl - used only by afs_create */ -enum vcexcl { EXCL, NONEXCL } ; +enum vcexcl { EXCL, NONEXCL }; /* * Time related macros @@ -103,8 +103,8 @@ extern struct lock__bsd__ afs_global_lock; #define AFS_APPL_UFS_CACHE 1 #define AFS_APPL_HFS_CACHE 2 -extern ino_t VnodeToIno(vnode_t *vp); -extern dev_t VnodeToDev(vnode_t *vp); +extern ino_t VnodeToIno(vnode_t * vp); +extern dev_t VnodeToDev(vnode_t * vp); #endif /* KERNEL */ diff --git a/src/afs/DARWIN/osi_misc.c b/src/afs/DARWIN/osi_misc.c index c106f8fc3..e8323f80f 100644 --- a/src/afs/DARWIN/osi_misc.c +++ b/src/afs/DARWIN/osi_misc.c @@ -10,35 +10,37 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" #include -int osi_lookupname(char *aname, enum uio_seg seg, int followlink, - struct vnode **dirvpp, struct vnode **vpp) +int +osi_lookupname(char *aname, enum uio_seg seg, int followlink, + struct vnode **dirvpp, struct vnode **vpp) { - struct nameidata n; - int flags,error; - flags=0; - flags=LOCKLEAF; - if (followlink) - flags|=FOLLOW; - else - flags|=NOFOLLOW; -/* if (dirvpp) flags|=WANTPARENT;*/ /* XXX LOCKPARENT? */ - NDINIT(&n, LOOKUP, flags, seg, aname, current_proc()); - if (error=namei(&n)) - return error; - *vpp=n.ni_vp; + struct nameidata n; + int flags, error; + flags = 0; + flags = LOCKLEAF; + if (followlink) + flags |= FOLLOW; + else + flags |= NOFOLLOW; + /* if (dirvpp) flags|=WANTPARENT; *//* XXX LOCKPARENT? */ + NDINIT(&n, LOOKUP, flags, seg, aname, current_proc()); + if (error = namei(&n)) + return error; + *vpp = n.ni_vp; /* if (dirvpp) *dirvpp = n.ni_dvp; #/ /* should we do this? */ - VOP_UNLOCK(n.ni_vp, 0, current_proc()); - return 0; + VOP_UNLOCK(n.ni_vp, 0, current_proc()); + return 0; } /* @@ -47,12 +49,13 @@ int osi_lookupname(char *aname, enum uio_seg seg, int followlink, * Note that it must NOT set errno. */ -afs_suser() { +afs_suser() +{ int error; - struct proc *p=current_proc(); + struct proc *p = current_proc(); if ((error = suser(p->p_ucred, &p->p_acflag)) == 0) { - return(1); + return (1); } - return(0); + return (0); } diff --git a/src/afs/DARWIN/osi_module.c b/src/afs/DARWIN/osi_module.c index 67ab99b2d..e880764d0 100644 --- a/src/afs/DARWIN/osi_module.c +++ b/src/afs/DARWIN/osi_module.c @@ -1,11 +1,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#ifdef AFS_DARWIN60_ENV /* not in Kernel.framework anymore !?! */ +#ifdef AFS_DARWIN60_ENV /* not in Kernel.framework anymore !?! */ #include #else #include "sys/syscall.h" @@ -22,44 +23,48 @@ extern int afs3_syscall(); extern int ioctl(); extern int setgroups(); extern int maxvfsconf; -kern_return_t afs_modload(struct kmod_info *ki, void *data) +kern_return_t +afs_modload(struct kmod_info *ki, void *data) { - if (sysent[AFS_SYSCALL].sy_call != nosys) { - printf("AFS_SYSCALL in use. aborting\n"); - return KERN_FAILURE; - } - memset(&afs_vfsconf, 0, sizeof(struct vfsconf)); - strcpy(afs_vfsconf.vfc_name, "afs"); - afs_vfsconf.vfc_vfsops=&afs_vfsops; - afs_vfsconf.vfc_typenum=maxvfsconf++;/* oddly not VT_AFS */ - afs_vfsconf.vfc_flags=MNT_NODEV; - if (vfsconf_add(&afs_vfsconf)) { - printf("AFS: vfsconf_add failed. aborting\n"); - return KERN_FAILURE; - } - sysent[SYS_setgroups].sy_call=Afs_xsetgroups; - sysent[SYS_ioctl].sy_call=afs_xioctl; - sysent[AFS_SYSCALL].sy_call=afs3_syscall; - sysent[AFS_SYSCALL].sy_narg = 5; - sysent[AFS_SYSCALL].sy_parallel = 0; + if (sysent[AFS_SYSCALL].sy_call != nosys) { + printf("AFS_SYSCALL in use. aborting\n"); + return KERN_FAILURE; + } + memset(&afs_vfsconf, 0, sizeof(struct vfsconf)); + strcpy(afs_vfsconf.vfc_name, "afs"); + afs_vfsconf.vfc_vfsops = &afs_vfsops; + afs_vfsconf.vfc_typenum = maxvfsconf++; /* oddly not VT_AFS */ + afs_vfsconf.vfc_flags = MNT_NODEV; + if (vfsconf_add(&afs_vfsconf)) { + printf("AFS: vfsconf_add failed. aborting\n"); + return KERN_FAILURE; + } + sysent[SYS_setgroups].sy_call = Afs_xsetgroups; + sysent[SYS_ioctl].sy_call = afs_xioctl; + sysent[AFS_SYSCALL].sy_call = afs3_syscall; + sysent[AFS_SYSCALL].sy_narg = 5; + sysent[AFS_SYSCALL].sy_parallel = 0; #ifdef KERNEL_FUNNEL - sysent[AFS_SYSCALL].sy_funnel=KERNEL_FUNNEL; + sysent[AFS_SYSCALL].sy_funnel = KERNEL_FUNNEL; #endif - return KERN_SUCCESS; + return KERN_SUCCESS; } -kern_return_t afs_modunload(struct kmod_info *ki, void *data) + +kern_return_t +afs_modunload(struct kmod_info * ki, void *data) { - if (afs_globalVFS) - return KERN_FAILURE; - if (vfsconf_del("afs")) - return KERN_FAILURE; - /* give up syscall entries for ioctl & setgroups, which we've stolen */ - sysent[SYS_ioctl].sy_call = ioctl; - sysent[SYS_setgroups].sy_call = setgroups; - /* give up the stolen syscall entry */ - sysent[AFS_SYSCALL].sy_narg = 0; - sysent[AFS_SYSCALL].sy_call = nosys; - return KERN_SUCCESS; - } + if (afs_globalVFS) + return KERN_FAILURE; + if (vfsconf_del("afs")) + return KERN_FAILURE; + /* give up syscall entries for ioctl & setgroups, which we've stolen */ + sysent[SYS_ioctl].sy_call = ioctl; + sysent[SYS_setgroups].sy_call = setgroups; + /* give up the stolen syscall entry */ + sysent[AFS_SYSCALL].sy_narg = 0; + sysent[AFS_SYSCALL].sy_call = nosys; + return KERN_SUCCESS; +} -KMOD_EXPLICIT_DECL(org.openafs.filesystems.afs, VERSION, afs_modload, afs_modunload) +KMOD_EXPLICIT_DECL(org.openafs.filesystems.afs, VERSION, afs_modload, + afs_modunload) diff --git a/src/afs/DARWIN/osi_prototypes.h b/src/afs/DARWIN/osi_prototypes.h index 874a71b12..012036e4d 100644 --- a/src/afs/DARWIN/osi_prototypes.h +++ b/src/afs/DARWIN/osi_prototypes.h @@ -19,7 +19,7 @@ extern afs_rwlock_t afs_xosi; /* osi_misc.c */ extern int osi_lookupname(char *aname, enum uio_seg seg, int followlink, - struct vnode **dirvpp, struct vnode **vpp); + struct vnode **dirvpp, struct vnode **vpp); /* osi_vm.c */ extern void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size); extern int osi_VM_Setup(struct vcache *avc, int force); diff --git a/src/afs/DARWIN/osi_sleep.c b/src/afs/DARWIN/osi_sleep.c index 666b6e0ee..8bfc4127c 100644 --- a/src/afs/DARWIN/osi_sleep.c +++ b/src/afs/DARWIN/osi_sleep.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /* Standard vendor system headers */ -#include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/sysincludes.h" /* Standard vendor system headers */ +#include "afsincludes.h" /* Afs-based standard headers */ +#include "afs/afs_stats.h" /* afs statistics */ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok); @@ -22,21 +23,24 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok); static char waitV; -void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) +void +afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) { AFS_STATCNT(osi_InitWaitHandle); achandle->proc = (caddr_t) 0; } /* cancel osi_Wait */ -void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) { caddr_t proc; AFS_STATCNT(osi_CancelWait); proc = achandle->proc; - if (proc == 0) return; - achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ + if (proc == 0) + return; + achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ afs_osi_Wakeup(&waitV); } @@ -44,22 +48,24 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) * Waits for data on ahandle, or ams ms later. ahandle may be null. * Returns 0 if timeout and EINTR if signalled. */ -int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) +int +afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int code; afs_int32 endTime, tid; - struct proc *p=current_proc(); + struct proc *p = current_proc(); AFS_STATCNT(osi_Wait); - endTime = osi_Time() + (ams/1000); + endTime = osi_Time() + (ams / 1000); if (ahandle) - ahandle->proc = (caddr_t)p; + ahandle->proc = (caddr_t) p; do { AFS_ASSERT_GLOCK(); code = 0; code = osi_TimedSleep(&waitV, ams, aintok); - if (code) break; /* if something happened, quit now */ + if (code) + break; /* if something happened, quit now */ /* if we we're cancelled, quit now */ if (ahandle && (ahandle->proc == (caddr_t) 0)) { /* we've been signalled */ @@ -72,22 +78,23 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) typedef struct afs_event { - struct afs_event *next; /* next in hash chain */ - char *event; /* lwp event: an address */ - int refcount; /* Is it in use? */ - int seq; /* Sequence number: this is incremented - by wakeup calls; wait will not return until - it changes */ + struct afs_event *next; /* next in hash chain */ + char *event; /* lwp event: an address */ + int refcount; /* Is it in use? */ + int seq; /* Sequence number: this is incremented + * by wakeup calls; wait will not return until + * it changes */ } afs_event_t; #define HASHSIZE 128 -afs_event_t *afs_evhasht[HASHSIZE];/* Hash table for events */ +afs_event_t *afs_evhasht[HASHSIZE]; /* Hash table for events */ #define afs_evhash(event) (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1)); int afs_evhashcnt = 0; /* Get and initialize event structure corresponding to lwp event (i.e. address) * */ -static afs_event_t *afs_getevent(char *event) +static afs_event_t * +afs_getevent(char *event) { afs_event_t *evp, *newp = 0; int hashcode; @@ -105,7 +112,7 @@ static afs_event_t *afs_getevent(char *event) evp = evp->next; } if (!newp) { - newp = (afs_event_t *) osi_AllocSmallSpace(sizeof (afs_event_t)); + newp = (afs_event_t *) osi_AllocSmallSpace(sizeof(afs_event_t)); afs_evhashcnt++; newp->next = afs_evhasht[hashcode]; afs_evhasht[hashcode] = newp; @@ -120,7 +127,8 @@ static afs_event_t *afs_getevent(char *event) #define relevent(evp) ((evp)->refcount--) -void afs_osi_Sleep(void *event) +void +afs_osi_Sleep(void *event) { struct afs_event *evp; int seq; @@ -131,10 +139,10 @@ void afs_osi_Sleep(void *event) AFS_ASSERT_GLOCK(); AFS_GUNLOCK(); #ifdef AFS_DARWIN14_ENV - /* this is probably safe for all versions, but testing is hard */ - sleep(event, PVFS); + /* this is probably safe for all versions, but testing is hard */ + sleep(event, PVFS); #else - assert_wait((event_t)event, 0); + assert_wait((event_t) event, 0); thread_block(0); #endif AFS_GLOCK(); @@ -142,7 +150,8 @@ void afs_osi_Sleep(void *event) relevent(evp); } -int afs_osi_SleepSig(void *event) +int +afs_osi_SleepSig(void *event) { afs_osi_Sleep(event); return 0; @@ -157,63 +166,65 @@ int afs_osi_SleepSig(void *event) * * Returns 0 if timeout and EINTR if signalled. */ -static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) +static int +osi_TimedSleep(char *event, afs_int32 ams, int aintok) { int code = 0; struct afs_event *evp; - int ticks,seq; + int ticks, seq; int prio; - ticks = ( ams * afs_hz )/1000; + ticks = (ams * afs_hz) / 1000; evp = afs_getevent(event); - seq=evp->seq; + seq = evp->seq; AFS_GUNLOCK(); #ifdef AFS_DARWIN14_ENV /* this is probably safe for all versions, but testing is hard. */ /* using tsleep instead of assert_wait/thread_set_timer/thread_block - allows shutdown to work in 1.4 */ + * allows shutdown to work in 1.4 */ /* lack of PCATCH does *not* prevent signal delivery, neither does - a low priority. We would need to deal with ERESTART here if we - wanted to mess with p->p_sigmask, and messing with p_sigignore is - not the way to go.... (someone correct me if I'm wrong) - */ + * a low priority. We would need to deal with ERESTART here if we + * wanted to mess with p->p_sigmask, and messing with p_sigignore is + * not the way to go.... (someone correct me if I'm wrong) + */ if (aintok) - prio=PCATCH|PPAUSE; + prio = PCATCH | PPAUSE; else - prio=PVFS; - code=tsleep(event, prio, "afs_osi_TimedSleep", ticks); -#else - assert_wait((event_t)event, aintok ? THREAD_ABORTSAFE : THREAD_UNINT); + prio = PVFS; + code = tsleep(event, prio, "afs_osi_TimedSleep", ticks); +#else + assert_wait((event_t) event, aintok ? THREAD_ABORTSAFE : THREAD_UNINT); thread_set_timer(ticks, NSEC_PER_SEC / hz); thread_block(0); - code=0; + code = 0; #endif AFS_GLOCK(); if (seq == evp->seq) code = EINTR; - + relevent(evp); return code; } -int afs_osi_Wakeup(void *event) +int +afs_osi_Wakeup(void *event) { struct afs_event *evp; - int ret=1; + int ret = 1; evp = afs_getevent(event); if (evp->refcount > 1) { - evp->seq++; + evp->seq++; #ifdef AFS_DARWIN14_ENV - /* this is probably safe for all versions, but testing is hard. */ - wakeup(event); + /* this is probably safe for all versions, but testing is hard. */ + wakeup(event); #else - thread_wakeup((event_t)event); + thread_wakeup((event_t) event); #endif - ret=0; + ret = 0; } relevent(evp); return ret; diff --git a/src/afs/DARWIN/osi_vfsops.c b/src/afs/DARWIN/osi_vfsops.c index 705cc42c1..69f27e0fa 100644 --- a/src/afs/DARWIN/osi_vfsops.c +++ b/src/afs/DARWIN/osi_vfsops.c @@ -1,11 +1,12 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); -#include /* Standard vendor system headers */ -#include /* Afs-based standard headers */ -#include /* statistics */ +#include /* Standard vendor system headers */ +#include /* Afs-based standard headers */ +#include /* statistics */ #include #include #include @@ -17,47 +18,47 @@ struct mount *afs_globalVFS = 0; int afs_quotactl() { - return EOPNOTSUPP; + return EOPNOTSUPP; } int afs_fhtovp(mp, fhp, vpp) -struct mount *mp; -struct fid *fhp; -struct vnode **vpp; + struct mount *mp; + struct fid *fhp; + struct vnode **vpp; { - return (EINVAL); + return (EINVAL); } int afs_vptofh(vp, fhp) -struct vnode *vp; -struct fid *fhp; + struct vnode *vp; + struct fid *fhp; { - return (EINVAL); + return (EINVAL); } int afs_start(mp, flags, p) -struct mount *mp; -int flags; -struct proc *p; + struct mount *mp; + int flags; + struct proc *p; { - return (0); /* nothing to do. ? */ + return (0); /* nothing to do. ? */ } int afs_mount(mp, path, data, ndp, p) -register struct mount *mp; -char *path; -caddr_t data; -struct nameidata *ndp; -struct proc *p; + register struct mount *mp; + char *path; + caddr_t data; + struct nameidata *ndp; + struct proc *p; { /* ndp contains the mounted-from device. Just ignore it. - we also don't care about our proc struct. */ + * we also don't care about our proc struct. */ size_t size; int error; @@ -67,7 +68,7 @@ struct proc *p; AFS_GLOCK(); AFS_STATCNT(afs_mount); - if (data == NULL && afs_globalVFS) { /* Don't allow remounts. */ + if (data == NULL && afs_globalVFS) { /* Don't allow remounts. */ AFS_GUNLOCK(); return (EBUSY); } @@ -75,27 +76,27 @@ struct proc *p; afs_globalVFS = mp; mp->vfs_bsize = 8192; vfs_getnewfsid(mp); - mp->mnt_stat.f_iosize=8192; - - (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN-1, &size); + mp->mnt_stat.f_iosize = 8192; + + (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size); memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN); if (data == NULL) { strcpy(mp->mnt_stat.f_mntfromname, "AFS"); /* null terminated string "AFS" will fit, just leave it be. */ - mp->mnt_data = (qaddr_t)NULL; + mp->mnt_data = (qaddr_t) NULL; } else { struct VenusFid *rootFid = NULL; struct volume *tvp; char volName[MNAMELEN]; - (void) copyinstr((char *)data, volName, MNAMELEN-1, &size); + (void)copyinstr((char *)data, volName, MNAMELEN - 1, &size); memset(volName + size, 0, MNAMELEN - size); if (volName[0] == 0) { strcpy(mp->mnt_stat.f_mntfromname, "AFS"); - mp->mnt_data = (qaddr_t)&afs_rootFid; + mp->mnt_data = (qaddr_t) & afs_rootFid; } else { struct cell *localcell = afs_GetPrimaryCell(READ_LOCK); if (localcell == NULL) { @@ -104,15 +105,16 @@ struct proc *p; } /* Set the volume identifier to "AFS:volume.name" */ - snprintf(mp->mnt_stat.f_mntfromname, MNAMELEN-1, "AFS:%s", + snprintf(mp->mnt_stat.f_mntfromname, MNAMELEN - 1, "AFS:%s", volName); - tvp = afs_GetVolumeByName(volName, localcell->cellNum, 1, - (struct vrequest *)0, READ_LOCK); - + tvp = + afs_GetVolumeByName(volName, localcell->cellNum, 1, + (struct vrequest *)0, READ_LOCK); + if (tvp) { int volid = (tvp->roVol ? tvp->roVol : tvp->volume); - MALLOC(rootFid, struct VenusFid *, sizeof(*rootFid), - M_UFSMNT, M_WAITOK); + MALLOC(rootFid, struct VenusFid *, sizeof(*rootFid), M_UFSMNT, + M_WAITOK); rootFid->Cell = localcell->cellNum; rootFid->Fid.Volume = volid; rootFid->Fid.Vnode = 1; @@ -121,30 +123,30 @@ struct proc *p; AFS_GUNLOCK(); return ENODEV; } - - mp->mnt_data = (qaddr_t)rootFid; + + mp->mnt_data = (qaddr_t) rootFid; } } strcpy(mp->mnt_stat.f_fstypename, "afs"); AFS_GUNLOCK(); - (void) afs_statfs(mp, &mp->mnt_stat, p); + (void)afs_statfs(mp, &mp->mnt_stat, p); return 0; } int afs_unmount(mp, flags, p) -struct mount *mp; -int flags; -struct proc *p; + struct mount *mp; + int flags; + struct proc *p; { - + AFS_GLOCK(); AFS_STATCNT(afs_unmount); - if (mp->mnt_data != (qaddr_t)-1) { + if (mp->mnt_data != (qaddr_t) - 1) { if (mp->mnt_data != NULL) { FREE(mp->mnt_data, M_UFSMNT); - mp->mnt_data = (qaddr_t)-1; + mp->mnt_data = (qaddr_t) - 1; } else { if (flags & MNT_FORCE) { afs_globalVFS = 0; @@ -163,25 +165,24 @@ struct proc *p; } int -afs_root(struct mount *mp, - struct vnode **vpp) +afs_root(struct mount *mp, struct vnode **vpp) { int error; struct vrequest treq; - register struct vcache *tvp=0; - struct proc *p=current_proc(); + register struct vcache *tvp = 0; + struct proc *p = current_proc(); struct ucred cr; pcred_readlock(p); - cr=*p->p_cred->pc_ucred; + cr = *p->p_cred->pc_ucred; pcred_unlock(p); AFS_GLOCK(); AFS_STATCNT(afs_root); - if (mp->mnt_data == NULL - && afs_globalVp && (afs_globalVp->states & CStatd)) { + if (mp->mnt_data == NULL && afs_globalVp + && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; - error=0; - } else if (mp->mnt_data == (qaddr_t)-1) { + error = 0; + } else if (mp->mnt_data == (qaddr_t) - 1) { error = ENOENT; } else { struct VenusFid *rootFid = (mp->mnt_data == NULL) @@ -192,27 +193,26 @@ afs_root(struct mount *mp, afs_globalVp = NULL; } - if (!(error = afs_InitReq(&treq, &cr)) && - !(error = afs_CheckInit())) { + if (!(error = afs_InitReq(&treq, &cr)) && !(error = afs_CheckInit())) { tvp = afs_GetVCache(rootFid, &treq, NULL, NULL); /* we really want this to stay around */ if (tvp) { if (mp->mnt_data == NULL) afs_globalVp = tvp; } else - error = ENOENT; + error = ENOENT; } } if (tvp) { - osi_vnhold(tvp,0); - AFS_GUNLOCK(); - vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, p); - AFS_GLOCK(); - if (mp->mnt_data == NULL) { + osi_vnhold(tvp, 0); + AFS_GUNLOCK(); + vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, p); + AFS_GLOCK(); + if (mp->mnt_data == NULL) { afs_globalVFS = mp; - } + } *vpp = AFSTOV(tvp); - AFSTOV(tvp)->v_flag |= VROOT; + AFSTOV(tvp)->v_flag |= VROOT; AFSTOV(tvp)->v_vfsp = mp; } @@ -224,9 +224,9 @@ afs_root(struct mount *mp, int afs_vget(mp, lfl, vp) -struct mount *mp; -struct vnode *vp; -int lfl; + struct mount *mp; + struct vnode *vp; + int lfl; { int error; printf("vget called. help!\n"); @@ -236,11 +236,12 @@ int lfl; } error = vget(vp, lfl, current_proc()); if (!error) - insmntque(vp, mp); /* take off free list */ + insmntque(vp, mp); /* take off free list */ return error; } -int afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p) +int +afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p) { AFS_GLOCK(); AFS_STATCNT(afs_statfs); @@ -256,113 +257,119 @@ int afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p) * storing something there. */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 2000000; + abp->f_ffree = 2000000; abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0]; abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1]; if (abp != &mp->mnt_stat) { abp->f_type = mp->mnt_vfc->vfc_typenum; - memcpy((caddr_t)&abp->f_mntonname[0], (caddr_t)mp->mnt_stat.f_mntonname, MNAMELEN); - memcpy((caddr_t)&abp->f_mntfromname[0], (caddr_t)mp->mnt_stat.f_mntfromname, MNAMELEN); + memcpy((caddr_t) & abp->f_mntonname[0], + (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN); + memcpy((caddr_t) & abp->f_mntfromname[0], + (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN); } AFS_GUNLOCK(); return 0; } -int afs_sync(mp, waitfor, cred, p) -struct mount *mp; -int waitfor; -struct ucred *cred; -struct prioc *p; +int +afs_sync(mp, waitfor, cred, p) + struct mount *mp; + int waitfor; + struct ucred *cred; + struct prioc *p; { -return 0; + return 0; } -int afs_sysctl() { - return EOPNOTSUPP; +int +afs_sysctl() +{ + return EOPNOTSUPP; } -typedef (*PFI)(); -extern int vfs_opv_numops; /* The total number of defined vnode operations */ +typedef (*PFI) (); +extern int vfs_opv_numops; /* The total number of defined vnode operations */ extern struct vnodeopv_desc afs_vnodeop_opv_desc; -int afs_init(struct vfsconf *vfc) { - int j; - int (**opv_desc_vector)(); - struct vnodeopv_entry_desc *opve_descp; - - - - MALLOC(afs_vnodeop_p, PFI *, vfs_opv_numops*sizeof(PFI), M_TEMP, M_WAITOK); - - memset(afs_vnodeop_p, 0, vfs_opv_numops*sizeof(PFI)); - - opv_desc_vector = afs_vnodeop_p; - for (j=0; afs_vnodeop_opv_desc.opv_desc_ops[j].opve_op; j++) { - opve_descp = &(afs_vnodeop_opv_desc.opv_desc_ops[j]); - - /* - * Sanity check: is this operation listed - * in the list of operations? We check this - * by seeing if its offest is zero. Since - * the default routine should always be listed - * first, it should be the only one with a zero - * offset. Any other operation with a zero - * offset is probably not listed in - * vfs_op_descs, and so is probably an error. - * - * A panic here means the layer programmer - * has committed the all-too common bug - * of adding a new operation to the layer's - * list of vnode operations but - * not adding the operation to the system-wide - * list of supported operations. - */ - if (opve_descp->opve_op->vdesc_offset == 0 && - opve_descp->opve_op->vdesc_offset != VOFFSET(vop_default)) { - printf("afs_init: operation %s not listed in %s.\n", - opve_descp->opve_op->vdesc_name, - "vfs_op_descs"); - panic ("load_afs: bad operation"); - } - /* - * Fill in this entry. - */ - opv_desc_vector[opve_descp->opve_op->vdesc_offset] = - opve_descp->opve_impl; - } - - /* - * Finally, go back and replace unfilled routines - * with their default. (Sigh, an O(n^3) algorithm. I - * could make it better, but that'd be work, and n is small.) - */ - - /* - * Force every operations vector to have a default routine. - */ - opv_desc_vector = afs_vnodeop_p; - if (opv_desc_vector[VOFFSET(vop_default)]==NULL) { - panic("afs_init: operation vector without default routine."); - } - for (j = 0;jopve_op->vdesc_offset == 0 + && opve_descp->opve_op->vdesc_offset != VOFFSET(vop_default)) { + printf("afs_init: operation %s not listed in %s.\n", + opve_descp->opve_op->vdesc_name, "vfs_op_descs"); + panic("load_afs: bad operation"); + } + /* + * Fill in this entry. + */ + opv_desc_vector[opve_descp->opve_op->vdesc_offset] = + opve_descp->opve_impl; + } + + /* + * Finally, go back and replace unfilled routines + * with their default. (Sigh, an O(n^3) algorithm. I + * could make it better, but that'd be work, and n is small.) + */ + + /* + * Force every operations vector to have a default routine. + */ + opv_desc_vector = afs_vnodeop_p; + if (opv_desc_vector[VOFFSET(vop_default)] == NULL) { + panic("afs_init: operation vector without default routine."); + } + for (j = 0; j < vfs_opv_numops; j++) + if (opv_desc_vector[j] == NULL) + opv_desc_vector[j] = opv_desc_vector[VOFFSET(vop_default)]; } struct vfsops afs_vfsops = { - afs_mount, - afs_start, - afs_unmount, - afs_root, - afs_quotactl, - afs_statfs, - afs_sync, - afs_vget, - afs_fhtovp, - afs_vptofh, - afs_init, - afs_sysctl + afs_mount, + afs_start, + afs_unmount, + afs_root, + afs_quotactl, + afs_statfs, + afs_sync, + afs_vget, + afs_fhtovp, + afs_vptofh, + afs_init, + afs_sysctl }; diff --git a/src/afs/DARWIN/osi_vm.c b/src/afs/DARWIN/osi_vm.c index 70792bbf8..df1f8e543 100644 --- a/src/afs/DARWIN/osi_vm.c +++ b/src/afs/DARWIN/osi_vm.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /* Standard vendor system headers */ -#include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/sysincludes.h" /* Standard vendor system headers */ +#include "afsincludes.h" /* Afs-based standard headers */ +#include "afs/afs_stats.h" /* statistics */ #include /* Try to discard pages, in order to recycle a vcache entry. @@ -33,9 +34,10 @@ RCSID("$Header$"); * * OSF/1 Locking: VN_LOCK has been called. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { - struct vnode *vp=AFSTOV(avc); + struct vnode *vp = AFSTOV(avc); #ifdef AFS_DARWIN14_ENV if (UBCINFOEXISTS(vp)) return EBUSY; @@ -53,13 +55,12 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) AFS_GUNLOCK(); cache_purge(vp); #ifndef AFS_DARWIN14_ENV - if (UBCINFOEXISTS(vp)) - { - ubc_clean(vp, 1); - ubc_uncache(vp); - ubc_release(vp); - ubc_info_free(vp); - } + if (UBCINFOEXISTS(vp)) { + ubc_clean(vp, 1); + ubc_uncache(vp); + ubc_release(vp); + ubc_info_free(vp); + } #endif AFS_GLOCK(); @@ -73,16 +74,17 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { - struct vnode *vp=AFSTOV(avc); + struct vnode *vp = AFSTOV(avc); ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); if (UBCINFOEXISTS(vp)) { ubc_pushdirty(vp); } AFS_GLOCK(); - ObtainWriteLock(&avc->lock,94); + ObtainWriteLock(&avc->lock, 94); } /* Try to invalidate pages, for "fs flush" or "fs flushv"; or @@ -94,24 +96,24 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * Since we drop and re-obtain the lock, we can't guarantee that there won't * be some pages around when we return, newly created by concurrent activity. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, - int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { - struct vnode *vp=AFSTOV(avc); + struct vnode *vp = AFSTOV(avc); void *object; kern_return_t kret; off_t size, lastpg; - + ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); - if (UBCINFOEXISTS(vp)) { - size=ubc_getsize(vp); - kret=ubc_invalidate(vp,0,size); - if (kret != 1) /* should be KERN_SUCCESS */ - printf("TryToSmush: invalidate failed (error = %d)\n", kret); + if (UBCINFOEXISTS(vp)) { + size = ubc_getsize(vp); + kret = ubc_invalidate(vp, 0, size); + if (kret != 1) /* should be KERN_SUCCESS */ + printf("TryToSmush: invalidate failed (error = %d)\n", kret); } AFS_GLOCK(); - ObtainWriteLock(&avc->lock,59); + ObtainWriteLock(&avc->lock, 59); } /* Purge VM for a file when its callback is revoked. @@ -121,20 +123,21 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, /* XXX this seems to not be referenced anywhere. *somebody* ought to be calling this, and also making sure that ubc's idea of the filesize is right more often */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { - struct vnode *vp=AFSTOV(avc); + struct vnode *vp = AFSTOV(avc); void *object; kern_return_t kret; off_t size; - if (UBCINFOEXISTS(vp)) { - size=ubc_getsize(vp); - kret=ubc_invalidate(vp,0,size); - if (kret != 1) /* Should be KERN_SUCCESS */ - printf("VMFlushPages: invalidate failed (error = %d)\n", kret); - /* XXX what about when not CStatd */ - if (avc->states & CStatd && size != avc->m.Length) - ubc_setsize(vp, avc->m.Length); + if (UBCINFOEXISTS(vp)) { + size = ubc_getsize(vp); + kret = ubc_invalidate(vp, 0, size); + if (kret != 1) /* Should be KERN_SUCCESS */ + printf("VMFlushPages: invalidate failed (error = %d)\n", kret); + /* XXX what about when not CStatd */ + if (avc->states & CStatd && size != avc->m.Length) + ubc_setsize(vp, avc->m.Length); } } @@ -144,10 +147,11 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * activeV is raised. This is supposed to block pageins, but at present * it only works on Solaris. */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { - struct vnode *vp=AFSTOV(avc); - if (UBCINFOEXISTS(vp)) { + struct vnode *vp = AFSTOV(avc); + if (UBCINFOEXISTS(vp)) { ubc_setsize(vp, alen); } } @@ -155,164 +159,167 @@ void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) /* vnreclaim and vinactive are probably not aggressive enough to keep enough afs vcaches free, so we try to do some of it ourselves */ /* XXX there's probably not nearly enough locking here */ -void osi_VM_TryReclaim(struct vcache *avc, int *slept) +void +osi_VM_TryReclaim(struct vcache *avc, int *slept) { - struct proc *p=current_proc(); - struct vnode *vp=AFSTOV(avc); + struct proc *p = current_proc(); + struct vnode *vp = AFSTOV(avc); void *obj; if (slept) - *slept=0; - VN_HOLD(vp); /* remove from inactive list */ + *slept = 0; + VN_HOLD(vp); /* remove from inactive list */ if (!simple_lock_try(&vp->v_interlock)) { - AFS_RELE(vp); - return; + AFS_RELE(vp); + return; } if (!UBCINFOEXISTS(vp) || vp->v_count != 2) { - simple_unlock(&vp->v_interlock); - AFS_RELE(vp); - return; + simple_unlock(&vp->v_interlock); + AFS_RELE(vp); + return; } #ifdef AFS_DARWIN14_ENV if (vp->v_ubcinfo->ui_refcount > 1 || vp->v_ubcinfo->ui_mapped) { - simple_unlock(&vp->v_interlock); - AFS_RELE(vp); - return; + simple_unlock(&vp->v_interlock); + AFS_RELE(vp); + return; } #else if (vp->v_ubcinfo->ui_holdcnt) { - simple_unlock(&vp->v_interlock); - AFS_RELE(vp); - return; + simple_unlock(&vp->v_interlock); + AFS_RELE(vp); + return; } #endif if (slept && ubc_issetflags(vp, UI_WASMAPPED)) { - /* We can't possibly release this in time for this NewVCache to get it */ - simple_unlock(&vp->v_interlock); - AFS_RELE(vp); - return; + /* We can't possibly release this in time for this NewVCache to get it */ + simple_unlock(&vp->v_interlock); + AFS_RELE(vp); + return; } - vp->v_usecount--; /* we want the usecount to be 1 */ + vp->v_usecount--; /* we want the usecount to be 1 */ if (slept) { - ReleaseWriteLock(&afs_xvcache); - *slept=1; + ReleaseWriteLock(&afs_xvcache); + *slept = 1; } else - ReleaseReadLock(&afs_xvcache); + ReleaseReadLock(&afs_xvcache); AFS_GUNLOCK(); - obj=0; + obj = 0; if (ubc_issetflags(vp, UI_WASMAPPED)) { - simple_unlock(&vp->v_interlock); + simple_unlock(&vp->v_interlock); #ifdef AFS_DARWIN14_ENV - ubc_release_named(vp); + ubc_release_named(vp); #else - ubc_release(vp); + ubc_release(vp); #endif - if (ubc_issetflags(vp, UI_HASOBJREF)) - printf("ubc_release didn't release the reference?!\n"); - } else if (!vn_lock(vp, LK_EXCLUSIVE|LK_INTERLOCK,current_proc())) { + if (ubc_issetflags(vp, UI_HASOBJREF)) + printf("ubc_release didn't release the reference?!\n"); + } else if (!vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK, current_proc())) { #ifdef AFS_DARWIN14_ENV - obj = ubc_getobject(vp,UBC_HOLDOBJECT); + obj = ubc_getobject(vp, UBC_HOLDOBJECT); #else #ifdef AFS_DARWIN13_ENV - obj = ubc_getobject(vp,(UBC_NOREACTIVATE|UBC_HOLDOBJECT)); + obj = ubc_getobject(vp, (UBC_NOREACTIVATE | UBC_HOLDOBJECT)); #else - obj = ubc_getobject(vp); + obj = ubc_getobject(vp); #endif #endif - (void)ubc_clean(vp, 1); - vinvalbuf(vp, V_SAVE, &afs_osi_cred, p, 0, 0); - if (vp->v_usecount == 1) - VOP_INACTIVE(vp, p); - else - VOP_UNLOCK(vp, 0, p); - if (obj) { - if (ISSET(vp->v_flag, VTERMINATE)) - panic("afs_vnreclaim: already teminating"); - SET(vp->v_flag, VTERMINATE); - memory_object_destroy(obj, 0); - while (ISSET(vp->v_flag, VTERMINATE)) { - SET(vp->v_flag, VTERMWANT); - tsleep((caddr_t)&vp->v_ubcinfo, PINOD, "afs_vnreclaim", 0); - } - } - } else { - if (simple_lock_try(&vp->v_interlock)) - panic("afs_vnreclaim: slept, but did no work :("); - if (UBCINFOEXISTS(vp) && vp->v_count == 1) { - vp->v_usecount++; - simple_unlock(&vp->v_interlock); - VN_RELE(vp); - } else - simple_unlock(&vp->v_interlock); - } - AFS_GLOCK(); - if (slept) - ObtainWriteLock(&afs_xvcache,175); - else - ObtainReadLock(&afs_xvcache); + (void)ubc_clean(vp, 1); + vinvalbuf(vp, V_SAVE, &afs_osi_cred, p, 0, 0); + if (vp->v_usecount == 1) + VOP_INACTIVE(vp, p); + else + VOP_UNLOCK(vp, 0, p); + if (obj) { + if (ISSET(vp->v_flag, VTERMINATE)) + panic("afs_vnreclaim: already teminating"); + SET(vp->v_flag, VTERMINATE); + memory_object_destroy(obj, 0); + while (ISSET(vp->v_flag, VTERMINATE)) { + SET(vp->v_flag, VTERMWANT); + tsleep((caddr_t) & vp->v_ubcinfo, PINOD, "afs_vnreclaim", 0); + } + } + } else { + if (simple_lock_try(&vp->v_interlock)) + panic("afs_vnreclaim: slept, but did no work :("); + if (UBCINFOEXISTS(vp) && vp->v_count == 1) { + vp->v_usecount++; + simple_unlock(&vp->v_interlock); + VN_RELE(vp); + } else + simple_unlock(&vp->v_interlock); + } + AFS_GLOCK(); + if (slept) + ObtainWriteLock(&afs_xvcache, 175); + else + ObtainReadLock(&afs_xvcache); } -void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size) +void +osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size) { void *object; struct vcache *avc = VTOAFS(vp); #ifdef AFS_DARWIN14_ENV - offset=trunc_page(offset); - size=round_page(size+1); + offset = trunc_page(offset); + size = round_page(size + 1); while (size) { - ubc_page_op(vp, (vm_offset_t)offset, - UPL_POP_SET | UPL_POP_BUSY | UPL_POP_DUMP, - 0, 0); - size-=PAGE_SIZE; - offset+=PAGE_SIZE; + ubc_page_op(vp, (vm_offset_t) offset, + UPL_POP_SET | UPL_POP_BUSY | UPL_POP_DUMP, 0, 0); + size -= PAGE_SIZE; + offset += PAGE_SIZE; } #else - object=NULL; + object = NULL; #ifdef AFS_DARWIN13_ENV if (UBCINFOEXISTS(vp)) - object = ubc_getobject(vp, UBC_NOREACTIVATE); + object = ubc_getobject(vp, UBC_NOREACTIVATE); #else if (UBCINFOEXISTS(vp)) - object = ubc_getobject(vp); + object = ubc_getobject(vp); #endif if (!object) - return; + return; - offset=trunc_page(offset); - size=round_page(size+1); + offset = trunc_page(offset); + size = round_page(size + 1); #ifdef AFS_DARWIN13_ENV while (size) { - memory_object_page_op(object, (vm_offset_t)offset, - UPL_POP_SET | UPL_POP_BUSY | UPL_POP_DUMP, - 0, 0); - size-=PAGE_SIZE; - offset+=PAGE_SIZE; + memory_object_page_op(object, (vm_offset_t) offset, + UPL_POP_SET | UPL_POP_BUSY | UPL_POP_DUMP, 0, + 0); + size -= PAGE_SIZE; + offset += PAGE_SIZE; } -#else +#else /* This is all we can do, and it's not enough. sucks to be us */ ubc_setsize(vp, offset); - size=(offset + size > avc->m.Length) ? offset + size : avc->m.Length; + size = (offset + size > avc->m.Length) ? offset + size : avc->m.Length; ubc_setsize(vp, size); #endif #endif } -int osi_VM_Setup(struct vcache *avc, int force) { +int +osi_VM_Setup(struct vcache *avc, int force) +{ int error; - struct vnode *vp=AFSTOV(avc); - + struct vnode *vp = AFSTOV(avc); + if (UBCISVALID(vp) && ((avc->states & CStatd) || force)) { - if (!UBCINFOEXISTS(vp) && !ISSET(vp->v_flag, VTERMINATE)) { - osi_vnhold(avc,0); - avc->states |= CUBCinit; + if (!UBCINFOEXISTS(vp) && !ISSET(vp->v_flag, VTERMINATE)) { + osi_vnhold(avc, 0); + avc->states |= CUBCinit; AFS_GUNLOCK(); - if ((error=ubc_info_init(&avc->v))) { + if ((error = ubc_info_init(&avc->v))) { AFS_GLOCK(); - avc->states &= ~CUBCinit; + avc->states &= ~CUBCinit; AFS_RELE(avc); return error; } @@ -320,15 +327,16 @@ int osi_VM_Setup(struct vcache *avc, int force) { simple_lock(&avc->v.v_interlock); if (!ubc_issetflags(&avc->v, UI_HASOBJREF)) #ifdef AFS_DARWIN13_ENV - if (ubc_getobject(&avc->v, (UBC_NOREACTIVATE|UBC_HOLDOBJECT))) + if (ubc_getobject + (&avc->v, (UBC_NOREACTIVATE | UBC_HOLDOBJECT))) panic("VM_Setup: null object"); #else - (void)_ubc_getobject(&avc->v, 1); /* return value not used */ + (void)_ubc_getobject(&avc->v, 1); /* return value not used */ #endif simple_unlock(&avc->v.v_interlock); #endif AFS_GLOCK(); - avc->states &= ~CUBCinit; + avc->states &= ~CUBCinit; AFS_RELE(avc); } if (UBCINFOEXISTS(&avc->v)) diff --git a/src/afs/DARWIN/osi_vnodeops.c b/src/afs/DARWIN/osi_vnodeops.c index 0e583c7f5..b9389ec1c 100644 --- a/src/afs/DARWIN/osi_vnodeops.c +++ b/src/afs/DARWIN/osi_vnodeops.c @@ -1,11 +1,12 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); -#include /* Standard vendor system headers */ -#include /* Afs-based standard headers */ -#include /* statistics */ +#include /* Standard vendor system headers */ +#include /* Afs-based standard headers */ +#include /* statistics */ #include #include #include @@ -61,61 +62,61 @@ int afs_vop_cmap __P((struct vop_cmap_args *)); #define afs_vop_reallocblks afs_vop_opnotsupp /* Global vfs data structures for AFS. */ -int (**afs_vnodeop_p)(); +int (**afs_vnodeop_p) (); struct vnodeopv_entry_desc afs_vnodeop_entries[] = { - { &vop_default_desc, vn_default_error }, - { &vop_lookup_desc, afs_vop_lookup }, /* lookup */ - { &vop_create_desc, afs_vop_create }, /* create */ - { &vop_mknod_desc, afs_vop_mknod }, /* mknod */ - { &vop_open_desc, afs_vop_open }, /* open */ - { &vop_close_desc, afs_vop_close }, /* close */ - { &vop_access_desc, afs_vop_access }, /* access */ - { &vop_getattr_desc, afs_vop_getattr }, /* getattr */ - { &vop_setattr_desc, afs_vop_setattr }, /* setattr */ - { &vop_read_desc, afs_vop_read }, /* read */ - { &vop_write_desc, afs_vop_write }, /* write */ - { &vop_pagein_desc, afs_vop_pagein }, /* read */ - { &vop_pageout_desc, afs_vop_pageout }, /* write */ - { &vop_ioctl_desc, afs_vop_ioctl }, /* XXX ioctl */ - { &vop_select_desc, afs_vop_select }, /* select */ - { &vop_mmap_desc, afs_vop_mmap }, /* mmap */ - { &vop_fsync_desc, afs_vop_fsync }, /* fsync */ - { &vop_seek_desc, afs_vop_seek }, /* seek */ - { &vop_remove_desc, afs_vop_remove }, /* remove */ - { &vop_link_desc, afs_vop_link }, /* link */ - { &vop_rename_desc, afs_vop_rename }, /* rename */ - { &vop_mkdir_desc, afs_vop_mkdir }, /* mkdir */ - { &vop_rmdir_desc, afs_vop_rmdir }, /* rmdir */ - { &vop_symlink_desc, afs_vop_symlink }, /* symlink */ - { &vop_readdir_desc, afs_vop_readdir }, /* readdir */ - { &vop_readlink_desc, afs_vop_readlink }, /* readlink */ - /* Yes, we use the ufs_abortop call. It just releases the namei - buffer stuff */ - { &vop_abortop_desc, ufs_abortop }, /* abortop */ - { &vop_inactive_desc, afs_vop_inactive }, /* inactive */ - { &vop_reclaim_desc, afs_vop_reclaim }, /* reclaim */ - { &vop_lock_desc, afs_vop_lock }, /* lock */ - { &vop_unlock_desc, afs_vop_unlock }, /* unlock */ - { &vop_bmap_desc, afs_vop_bmap }, /* bmap */ - { &vop_strategy_desc, afs_vop_strategy }, /* strategy */ - { &vop_print_desc, afs_vop_print }, /* print */ - { &vop_islocked_desc, afs_vop_islocked }, /* islocked */ - { &vop_pathconf_desc, afs_vop_pathconf }, /* pathconf */ - { &vop_advlock_desc, afs_vop_advlock }, /* advlock */ - { &vop_blkatoff_desc, afs_vop_blkatoff }, /* blkatoff */ - { &vop_valloc_desc, afs_vop_valloc }, /* valloc */ - { &vop_reallocblks_desc, afs_vop_reallocblks }, /* reallocblks */ - { &vop_vfree_desc, afs_vop_vfree }, /* vfree */ - { &vop_truncate_desc, afs_vop_truncate }, /* truncate */ - { &vop_update_desc, afs_vop_update }, /* update */ - { &vop_blktooff_desc, afs_vop_blktooff }, /* blktooff */ - { &vop_offtoblk_desc, afs_vop_offtoblk }, /* offtoblk */ - { &vop_cmap_desc, afs_vop_cmap }, /* cmap */ - { &vop_bwrite_desc, vn_bwrite }, - { (struct vnodeop_desc*)NULL, (int(*)())NULL } + {&vop_default_desc, vn_default_error}, + {&vop_lookup_desc, afs_vop_lookup}, /* lookup */ + {&vop_create_desc, afs_vop_create}, /* create */ + {&vop_mknod_desc, afs_vop_mknod}, /* mknod */ + {&vop_open_desc, afs_vop_open}, /* open */ + {&vop_close_desc, afs_vop_close}, /* close */ + {&vop_access_desc, afs_vop_access}, /* access */ + {&vop_getattr_desc, afs_vop_getattr}, /* getattr */ + {&vop_setattr_desc, afs_vop_setattr}, /* setattr */ + {&vop_read_desc, afs_vop_read}, /* read */ + {&vop_write_desc, afs_vop_write}, /* write */ + {&vop_pagein_desc, afs_vop_pagein}, /* read */ + {&vop_pageout_desc, afs_vop_pageout}, /* write */ + {&vop_ioctl_desc, afs_vop_ioctl}, /* XXX ioctl */ + {&vop_select_desc, afs_vop_select}, /* select */ + {&vop_mmap_desc, afs_vop_mmap}, /* mmap */ + {&vop_fsync_desc, afs_vop_fsync}, /* fsync */ + {&vop_seek_desc, afs_vop_seek}, /* seek */ + {&vop_remove_desc, afs_vop_remove}, /* remove */ + {&vop_link_desc, afs_vop_link}, /* link */ + {&vop_rename_desc, afs_vop_rename}, /* rename */ + {&vop_mkdir_desc, afs_vop_mkdir}, /* mkdir */ + {&vop_rmdir_desc, afs_vop_rmdir}, /* rmdir */ + {&vop_symlink_desc, afs_vop_symlink}, /* symlink */ + {&vop_readdir_desc, afs_vop_readdir}, /* readdir */ + {&vop_readlink_desc, afs_vop_readlink}, /* readlink */ + /* Yes, we use the ufs_abortop call. It just releases the namei + * buffer stuff */ + {&vop_abortop_desc, ufs_abortop}, /* abortop */ + {&vop_inactive_desc, afs_vop_inactive}, /* inactive */ + {&vop_reclaim_desc, afs_vop_reclaim}, /* reclaim */ + {&vop_lock_desc, afs_vop_lock}, /* lock */ + {&vop_unlock_desc, afs_vop_unlock}, /* unlock */ + {&vop_bmap_desc, afs_vop_bmap}, /* bmap */ + {&vop_strategy_desc, afs_vop_strategy}, /* strategy */ + {&vop_print_desc, afs_vop_print}, /* print */ + {&vop_islocked_desc, afs_vop_islocked}, /* islocked */ + {&vop_pathconf_desc, afs_vop_pathconf}, /* pathconf */ + {&vop_advlock_desc, afs_vop_advlock}, /* advlock */ + {&vop_blkatoff_desc, afs_vop_blkatoff}, /* blkatoff */ + {&vop_valloc_desc, afs_vop_valloc}, /* valloc */ + {&vop_reallocblks_desc, afs_vop_reallocblks}, /* reallocblks */ + {&vop_vfree_desc, afs_vop_vfree}, /* vfree */ + {&vop_truncate_desc, afs_vop_truncate}, /* truncate */ + {&vop_update_desc, afs_vop_update}, /* update */ + {&vop_blktooff_desc, afs_vop_blktooff}, /* blktooff */ + {&vop_offtoblk_desc, afs_vop_offtoblk}, /* offtoblk */ + {&vop_cmap_desc, afs_vop_cmap}, /* cmap */ + {&vop_bwrite_desc, vn_bwrite}, + {(struct vnodeop_desc *)NULL, (int (*)())NULL} }; struct vnodeopv_desc afs_vnodeop_opv_desc = - { &afs_vnodeop_p, afs_vnodeop_entries }; + { &afs_vnodeop_p, afs_vnodeop_entries }; #define GETNAME() \ struct componentname *cnp = ap->a_cnp; \ @@ -125,29 +126,29 @@ struct vnodeopv_desc afs_vnodeop_opv_desc = name[cnp->cn_namelen] = '\0' #define DROPNAME() FREE(name, M_TEMP) - + int afs_vop_lookup(ap) -struct vop_lookup_args /* { - struct vnodeop_desc * a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - } */ *ap; + struct vop_lookup_args /* { + * struct vnodeop_desc * a_desc; + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * } */ *ap; { int error; struct vcache *vcp; struct vnode *vp, *dvp; register int flags = ap->a_cnp->cn_flags; - int lockparent; /* 1 => lockparent flag is set */ - int wantparent; /* 1 => wantparent or lockparent flag */ + int lockparent; /* 1 => lockparent flag is set */ + int wantparent; /* 1 => wantparent or lockparent flag */ struct proc *p; GETNAME(); - p=cnp->cn_proc; + p = cnp->cn_proc; lockparent = flags & LOCKPARENT; - wantparent = flags & (LOCKPARENT|WANTPARENT); + wantparent = flags & (LOCKPARENT | WANTPARENT); if (ap->a_dvp->v_type != VDIR) { *ap->a_vpp = 0; @@ -155,16 +156,16 @@ struct vop_lookup_args /* { return ENOTDIR; } dvp = ap->a_dvp; - if (flags & ISDOTDOT) - VOP_UNLOCK(dvp, 0, p); + if (flags & ISDOTDOT) + VOP_UNLOCK(dvp, 0, p); AFS_GLOCK(); error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred); AFS_GUNLOCK(); if (error) { - if (flags & ISDOTDOT) - VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p); - if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) && - (flags & ISLASTCN) && error == ENOENT) + if (flags & ISDOTDOT) + VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p); + if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) + && (flags & ISLASTCN) && error == ENOENT) error = EJUSTRETURN; if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN)) cnp->cn_flags |= SAVENAME; @@ -172,35 +173,35 @@ struct vop_lookup_args /* { *ap->a_vpp = 0; return (error); } - vp = AFSTOV(vcp); /* always get a node if no error */ + vp = AFSTOV(vcp); /* always get a node if no error */ vp->v_vfsp = dvp->v_vfsp; /* The parent directory comes in locked. We unlock it on return - unless the caller wants it left locked. - we also always return the vnode locked. */ + * unless the caller wants it left locked. + * we also always return the vnode locked. */ if (flags & ISDOTDOT) { vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - /* always return the child locked */ - if (lockparent && (flags & ISLASTCN) && - (error = vn_lock(dvp, LK_EXCLUSIVE, p))) { - vput(vp); - DROPNAME(); - return (error); - } + /* always return the child locked */ + if (lockparent && (flags & ISLASTCN) + && (error = vn_lock(dvp, LK_EXCLUSIVE, p))) { + vput(vp); + DROPNAME(); + return (error); + } } else if (vp == dvp) { /* they're the same; afs_lookup() already ref'ed the leaf. - It came in locked, so we don't need to ref OR lock it */ + * It came in locked, so we don't need to ref OR lock it */ } else { if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(dvp, 0, p); /* done with parent. */ + VOP_UNLOCK(dvp, 0, p); /* done with parent. */ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - /* always return the child locked */ + /* always return the child locked */ } *ap->a_vpp = vp; - if ((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN) || - (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN)))) + if ((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN) + || (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN)))) cnp->cn_flags |= SAVENAME; DROPNAME(); @@ -209,42 +210,41 @@ struct vop_lookup_args /* { int afs_vop_create(ap) - struct vop_create_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap; + struct vop_create_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * } */ *ap; { int error = 0; struct vcache *vcp; register struct vnode *dvp = ap->a_dvp; struct proc *p; GETNAME(); - p=cnp->cn_proc; + p = cnp->cn_proc; /* vnode layer handles excl/nonexcl */ AFS_GLOCK(); - error = afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL, - ap->a_vap->va_mode, &vcp, - cnp->cn_cred); + error = + afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL, ap->a_vap->va_mode, + &vcp, cnp->cn_cred); AFS_GUNLOCK(); if (error) { VOP_ABORTOP(dvp, cnp); vput(dvp); DROPNAME(); - return(error); + return (error); } if (vcp) { *ap->a_vpp = AFSTOV(vcp); (*ap->a_vpp)->v_vfsp = dvp->v_vfsp; - vn_lock(*ap->a_vpp, LK_EXCLUSIVE| LK_RETRY, p); - if (UBCINFOMISSING(*ap->a_vpp) || - UBCINFORECLAIMED(*ap->a_vpp)) - ubc_info_init(*ap->a_vpp); - } - else *ap->a_vpp = 0; + vn_lock(*ap->a_vpp, LK_EXCLUSIVE | LK_RETRY, p); + if (UBCINFOMISSING(*ap->a_vpp) || UBCINFORECLAIMED(*ap->a_vpp)) + ubc_info_init(*ap->a_vpp); + } else + *ap->a_vpp = 0; if ((cnp->cn_flags & SAVESTART) == 0) FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI); @@ -255,26 +255,26 @@ afs_vop_create(ap) int afs_vop_mknod(ap) - struct vop_mknod_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap; + struct vop_mknod_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * } */ *ap; { FREE_ZONE(ap->a_cnp->cn_pnbuf, ap->a_cnp->cn_pnlen, M_NAMEI); vput(ap->a_dvp); - return(ENODEV); + return (ENODEV); } int afs_vop_open(ap) - struct vop_open_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_open_args /* { + * struct vnode *a_vp; + * int a_mode; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int error; struct vcache *vc = VTOAFS(ap->a_vp); @@ -293,32 +293,32 @@ afs_vop_open(ap) int afs_vop_close(ap) - struct vop_close_args /* { - struct vnode *a_vp; - int a_fflag; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_close_args /* { + * struct vnode *a_vp; + * int a_fflag; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; - struct vcache *avc=ap->a_vp; + struct vcache *avc = ap->a_vp; AFS_GLOCK(); - if (ap->a_cred) - code=afs_close(avc, ap->a_fflag, ap->a_cred, ap->a_p); + if (ap->a_cred) + code = afs_close(avc, ap->a_fflag, ap->a_cred, ap->a_p); else - code=afs_close(avc, ap->a_fflag, &afs_osi_cred, ap->a_p); + code = afs_close(avc, ap->a_fflag, &afs_osi_cred, ap->a_p); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ afs_BozonUnlock(&avc->pvnLock, avc); AFS_GUNLOCK(); #ifdef AFS_DARWIN14_ENV if (UBCINFOEXISTS(ap->a_vp) && ap->a_vp->v_ubcinfo->ui_refcount < 2) { - ubc_hold(ap->a_vp); - if (ap->a_vp->v_ubcinfo->ui_refcount < 2) { - printf("afs: Imminent ui_refcount panic\n"); - } else { - printf("afs: WARNING: ui_refcount panic averted\n"); - } + ubc_hold(ap->a_vp); + if (ap->a_vp->v_ubcinfo->ui_refcount < 2) { + printf("afs: Imminent ui_refcount panic\n"); + } else { + printf("afs: WARNING: ui_refcount panic averted\n"); + } } #endif @@ -327,126 +327,130 @@ afs_vop_close(ap) int afs_vop_access(ap) - struct vop_access_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_access_args /* { + * struct vnode *a_vp; + * int a_mode; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; AFS_GLOCK(); - code=afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred); + code = afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred); AFS_GUNLOCK(); return code; } + int afs_vop_getattr(ap) - struct vop_getattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_getattr_args /* { + * struct vnode *a_vp; + * struct vattr *a_vap; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; AFS_GLOCK(); - code=afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred); + code = afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred); AFS_GUNLOCK(); return code; } + int afs_vop_setattr(ap) - struct vop_setattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_setattr_args /* { + * struct vnode *a_vp; + * struct vattr *a_vap; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; AFS_GLOCK(); - code=afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred); + code = afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred); AFS_GUNLOCK(); return code; } + int afs_vop_read(ap) - struct vop_read_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap; + struct vop_read_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * int a_ioflag; + * struct ucred *a_cred; + * } */ *ap; { int code; - struct vcache *avc=VTOAFS(ap->a_vp); + struct vcache *avc = VTOAFS(ap->a_vp); AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ - code=afs_read(avc, ap->a_uio, ap->a_cred, 0, 0, 0); + osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ + code = afs_read(avc, ap->a_uio, ap->a_cred, 0, 0, 0); afs_BozonUnlock(&avc->pvnLock, avc); AFS_GUNLOCK(); return code; } + int afs_vop_pagein(ap) - struct vop_pagein_args /* { - struct vnode *a_vp; - upl_t a_pl; - vm_offset_t a_pl_offset; - off_t a_f_offset; - size_t a_size; - struct ucred *a_cred; - int a_flags; - } */ *ap; + struct vop_pagein_args /* { + * struct vnode *a_vp; + * upl_t a_pl; + * vm_offset_t a_pl_offset; + * off_t a_f_offset; + * size_t a_size; + * struct ucred *a_cred; + * int a_flags; + * } */ *ap; { register struct vnode *vp = ap->a_vp; upl_t pl = ap->a_pl; - size_t size= ap->a_size; + size_t size = ap->a_size; off_t f_offset = ap->a_f_offset; vm_offset_t pl_offset = ap->a_pl_offset; - int flags = ap->a_flags; + int flags = ap->a_flags; struct ucred *cred; vm_offset_t ioaddr; - struct uio auio; - struct iovec aiov; - struct uio * uio = &auio; + struct uio auio; + struct iovec aiov; + struct uio *uio = &auio; int nocommit = flags & UPL_NOCOMMIT; int code; - struct vcache *tvc=VTOAFS(vp); + struct vcache *tvc = VTOAFS(vp); if (UBCINVALID(vp)) { #if DIAGNOSTIC - panic("afs_vop_pagein: invalid vp"); + panic("afs_vop_pagein: invalid vp"); #endif /* DIAGNOSTIC */ - return (EPERM); + return (EPERM); } UBCINFOCHECK("afs_vop_pagein", vp); - if(pl == (upl_t)NULL) { - panic("afs_vop_pagein: no upl"); + if (pl == (upl_t) NULL) { + panic("afs_vop_pagein: no upl"); } cred = ubc_getcred(vp); if (cred == NOCRED) - cred = ap->a_cred; + cred = ap->a_cred; if (size == 0) { - if (!nocommit) - kernel_upl_abort_range(pl, pl_offset, size, - UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY); - return (0); + if (!nocommit) + kernel_upl_abort_range(pl, pl_offset, size, + UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY); + return (0); } if (f_offset < 0) { - if (!nocommit) - kernel_upl_abort_range(pl, pl_offset, size, - UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY); - return (EINVAL); + if (!nocommit) + kernel_upl_abort_range(pl, pl_offset, size, + UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY); + return (EINVAL); } if (f_offset & PAGE_MASK) - panic("afs_vop_pagein: offset not page aligned"); + panic("afs_vop_pagein: offset not page aligned"); auio.uio_iov = &aiov; auio.uio_iovcnt = 1; @@ -457,15 +461,15 @@ afs_vop_pagein(ap) kernel_upl_map(kernel_map, pl, &ioaddr); ioaddr += pl_offset; auio.uio_resid = aiov.iov_len = size; - aiov.iov_base = (caddr_t)ioaddr; + aiov.iov_base = (caddr_t) ioaddr; AFS_GLOCK(); afs_BozonLock(&tvc->pvnLock, tvc); - osi_FlushPages(tvc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ - code=afs_read(tvc, uio, cred, 0, 0, 0); + osi_FlushPages(tvc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ + code = afs_read(tvc, uio, cred, 0, 0, 0); if (code == 0) { - ObtainWriteLock(&tvc->lock, 2); - tvc->states |= CMAPPED; - ReleaseWriteLock(&tvc->lock); + ObtainWriteLock(&tvc->lock, 2); + tvc->states |= CMAPPED; + ReleaseWriteLock(&tvc->lock); } afs_BozonUnlock(&tvc->pvnLock, tvc); AFS_GUNLOCK(); @@ -476,37 +480,41 @@ afs_vop_pagein(ap) kernel_upl_unmap(kernel_map, pl); if (!nocommit) { - if (code) - kernel_upl_abort_range(pl, pl_offset, size, - UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY); - else - kernel_upl_commit_range(pl, pl_offset, size, - UPL_COMMIT_CLEAR_DIRTY | UPL_COMMIT_FREE_ON_EMPTY, - UPL_GET_INTERNAL_PAGE_LIST(pl), MAX_UPL_TRANSFER); + if (code) + kernel_upl_abort_range(pl, pl_offset, size, + UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY); + else + kernel_upl_commit_range(pl, pl_offset, size, + UPL_COMMIT_CLEAR_DIRTY | + UPL_COMMIT_FREE_ON_EMPTY, + UPL_GET_INTERNAL_PAGE_LIST(pl), + MAX_UPL_TRANSFER); } return code; } int afs_vop_write(ap) - struct vop_write_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap; + struct vop_write_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * int a_ioflag; + * struct ucred *a_cred; + * } */ *ap; { int code; - struct vcache *avc=VTOAFS(ap->a_vp); + struct vcache *avc = VTOAFS(ap->a_vp); void *object; AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ if (UBCINFOEXISTS(ap->a_vp)) - ubc_clean(ap->a_vp, 1); + ubc_clean(ap->a_vp, 1); if (UBCINFOEXISTS(ap->a_vp)) - osi_VM_NukePages(ap->a_vp, ap->a_uio->uio_offset, ap->a_uio->uio_resid); - code=afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0); + osi_VM_NukePages(ap->a_vp, ap->a_uio->uio_offset, + ap->a_uio->uio_resid); + code = + afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0); afs_BozonUnlock(&avc->pvnLock, avc); AFS_GUNLOCK(); return code; @@ -514,93 +522,93 @@ afs_vop_write(ap) int afs_vop_pageout(ap) - struct vop_pageout_args /* { - struct vnode *a_vp; - upl_t a_pl, - vm_offset_t a_pl_offset, - off_t a_f_offset, - size_t a_size, - struct ucred *a_cred, - int a_flags - } */ *ap; + struct vop_pageout_args /* { + * struct vnode *a_vp; + * upl_t a_pl, + * vm_offset_t a_pl_offset, + * off_t a_f_offset, + * size_t a_size, + * struct ucred *a_cred, + * int a_flags + * } */ *ap; { register struct vnode *vp = ap->a_vp; upl_t pl = ap->a_pl; - size_t size= ap->a_size; + size_t size = ap->a_size; off_t f_offset = ap->a_f_offset; vm_offset_t pl_offset = ap->a_pl_offset; - int flags = ap->a_flags; + int flags = ap->a_flags; struct ucred *cred; vm_offset_t ioaddr; - struct uio auio; - struct iovec aiov; - struct uio * uio = &auio; + struct uio auio; + struct iovec aiov; + struct uio *uio = &auio; int nocommit = flags & UPL_NOCOMMIT; int code; - struct vcache *tvc=VTOAFS(vp); + struct vcache *tvc = VTOAFS(vp); if (UBCINVALID(vp)) { #if DIAGNOSTIC - panic("afs_vop_pageout: invalid vp"); + panic("afs_vop_pageout: invalid vp"); #endif /* DIAGNOSTIC */ - return (EPERM); + return (EPERM); } UBCINFOCHECK("afs_vop_pageout", vp); - if(pl == (upl_t)NULL) { - panic("afs_vop_pageout: no upl"); + if (pl == (upl_t) NULL) { + panic("afs_vop_pageout: no upl"); } #if 1 - { int lbn, iosize, s; - struct buf *bp; - int biosize = DEV_BSIZE; - - lbn = f_offset / DEV_BSIZE; - - for (iosize = size; iosize > 0; iosize -= biosize, lbn++) { - - s = splbio(); - if (bp = incore(vp, lbn)) { - if (ISSET(bp->b_flags, B_BUSY)) - panic("nfs_pageout: found BUSY buffer incore\n") -; - - bremfree(bp); - SET(bp->b_flags, (B_BUSY | B_INVAL)); - brelse(bp); - } - splx(s); - } + { + int lbn, iosize, s; + struct buf *bp; + int biosize = DEV_BSIZE; + + lbn = f_offset / DEV_BSIZE; + + for (iosize = size; iosize > 0; iosize -= biosize, lbn++) { + + s = splbio(); + if (bp = incore(vp, lbn)) { + if (ISSET(bp->b_flags, B_BUSY)) + panic("nfs_pageout: found BUSY buffer incore\n"); + + bremfree(bp); + SET(bp->b_flags, (B_BUSY | B_INVAL)); + brelse(bp); + } + splx(s); + } } #endif cred = ubc_getcred(vp); if (cred == NOCRED) - cred = ap->a_cred; + cred = ap->a_cred; if (size == 0) { - if (!nocommit) - kernel_upl_abort_range(pl, pl_offset, size, - UPL_ABORT_FREE_ON_EMPTY); - return (0); + if (!nocommit) + kernel_upl_abort_range(pl, pl_offset, size, + UPL_ABORT_FREE_ON_EMPTY); + return (0); } if (flags & (IO_APPEND | IO_SYNC)) - panic("nfs_pageout: (IO_APPEND | IO_SYNC)"); + panic("nfs_pageout: (IO_APPEND | IO_SYNC)"); if (f_offset < 0) { - if (!nocommit) - kernel_upl_abort_range(pl, pl_offset, size, - UPL_ABORT_FREE_ON_EMPTY); - return (EINVAL); + if (!nocommit) + kernel_upl_abort_range(pl, pl_offset, size, + UPL_ABORT_FREE_ON_EMPTY); + return (EINVAL); } if (f_offset >= tvc->m.Length) { - if (!nocommit) - kernel_upl_abort_range(pl, pl_offset, size, - UPL_ABORT_FREE_ON_EMPTY); - return (EINVAL); + if (!nocommit) + kernel_upl_abort_range(pl, pl_offset, size, + UPL_ABORT_FREE_ON_EMPTY); + return (EINVAL); } if (f_offset & PAGE_MASK) - panic("afs_vop_pageout: offset not page aligned"); + panic("afs_vop_pageout: offset not page aligned"); auio.uio_iov = &aiov; auio.uio_iovcnt = 1; @@ -611,30 +619,30 @@ afs_vop_pageout(ap) kernel_upl_map(kernel_map, pl, &ioaddr); ioaddr += pl_offset; auio.uio_resid = aiov.iov_len = size; - aiov.iov_base = (caddr_t)ioaddr; -#if 1 /* USV [ */ - { - /* - * check for partial page and clear the - * contents past end of the file before - * releasing it in the VM page cache - */ - if ((f_offset < tvc->m.Length) && (f_offset + size) > tvc->m.Length) { - size_t io = tvc->m.Length - f_offset; - - memset((caddr_t)(ioaddr + pl_offset + io), 0, size - io); - } - } + aiov.iov_base = (caddr_t) ioaddr; +#if 1 /* USV [ */ + { + /* + * check for partial page and clear the + * contents past end of the file before + * releasing it in the VM page cache + */ + if ((f_offset < tvc->m.Length) && (f_offset + size) > tvc->m.Length) { + size_t io = tvc->m.Length - f_offset; + + memset((caddr_t) (ioaddr + pl_offset + io), 0, size - io); + } + } #endif /* ] USV */ AFS_GLOCK(); afs_BozonLock(&tvc->pvnLock, tvc); - osi_FlushPages(tvc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(tvc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ ObtainWriteLock(&tvc->lock, 1); afs_FakeOpen(tvc); ReleaseWriteLock(&tvc->lock); - code=afs_write(tvc, uio, flags, cred, 0); + code = afs_write(tvc, uio, flags, cred, 0); ObtainWriteLock(&tvc->lock, 1); afs_FakeClose(tvc, cred); @@ -643,64 +651,68 @@ afs_vop_pageout(ap) AFS_GUNLOCK(); kernel_upl_unmap(kernel_map, pl); if (!nocommit) { - if(code) - kernel_upl_abort_range(pl, pl_offset, size, - UPL_ABORT_FREE_ON_EMPTY); - else - kernel_upl_commit_range(pl, pl_offset, size, - UPL_COMMIT_CLEAR_DIRTY | UPL_COMMIT_FREE_ON_EMPTY, - UPL_GET_INTERNAL_PAGE_LIST(pl), MAX_UPL_TRANSFER); + if (code) + kernel_upl_abort_range(pl, pl_offset, size, + UPL_ABORT_FREE_ON_EMPTY); + else + kernel_upl_commit_range(pl, pl_offset, size, + UPL_COMMIT_CLEAR_DIRTY | + UPL_COMMIT_FREE_ON_EMPTY, + UPL_GET_INTERNAL_PAGE_LIST(pl), + MAX_UPL_TRANSFER); } return code; } + int afs_vop_ioctl(ap) - struct vop_ioctl_args /* { - struct vnode *a_vp; - int a_command; - caddr_t a_data; - int a_fflag; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_ioctl_args /* { + * struct vnode *a_vp; + * int a_command; + * caddr_t a_data; + * int a_fflag; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { struct vcache *tvc = VTOAFS(ap->a_vp); struct afs_ioctl data; int error = 0; - + /* in case we ever get in here... */ AFS_STATCNT(afs_ioctl); if (((ap->a_command >> 8) & 0xff) == 'V') { /* This is a VICEIOCTL call */ - AFS_GLOCK(); - error = HandleIoctl(tvc, (struct file *)0/*Not used*/, - ap->a_command, ap->a_data); - AFS_GUNLOCK(); - return(error); + AFS_GLOCK(); + error = HandleIoctl(tvc, (struct file *)0 /*Not used */ , + ap->a_command, ap->a_data); + AFS_GUNLOCK(); + return (error); } else { /* No-op call; just return. */ - return(ENOTTY); + return (ENOTTY); } } /* ARGSUSED */ int afs_vop_select(ap) - struct vop_select_args /* { - struct vnode *a_vp; - int a_which; - int a_fflags; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_select_args /* { + * struct vnode *a_vp; + * int a_which; + * int a_fflags; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { - /* - * We should really check to see if I/O is possible. - */ - return (1); + /* + * We should really check to see if I/O is possible. + */ + return (1); } + /* * Mmap a file * @@ -709,60 +721,60 @@ afs_vop_select(ap) /* ARGSUSED */ int afs_vop_mmap(ap) - struct vop_mmap_args /* { - struct vnode *a_vp; - int a_fflags; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_mmap_args /* { + * struct vnode *a_vp; + * int a_fflags; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { - return (EINVAL); + return (EINVAL); } int afs_vop_fsync(ap) - struct vop_fsync_args /* { - struct vnode *a_vp; - struct ucred *a_cred; - int a_waitfor; - struct proc *a_p; - } */ *ap; + struct vop_fsync_args /* { + * struct vnode *a_vp; + * struct ucred *a_cred; + * int a_waitfor; + * struct proc *a_p; + * } */ *ap; { int wait = ap->a_waitfor == MNT_WAIT; int error; register struct vnode *vp = ap->a_vp; AFS_GLOCK(); - /*vflushbuf(vp, wait);*/ + /*vflushbuf(vp, wait); */ if (ap->a_cred) - error=afs_fsync(VTOAFS(vp), ap->a_cred); + error = afs_fsync(VTOAFS(vp), ap->a_cred); else - error=afs_fsync(VTOAFS(vp), &afs_osi_cred); + error = afs_fsync(VTOAFS(vp), &afs_osi_cred); AFS_GUNLOCK(); return error; } int afs_vop_seek(ap) - struct vop_seek_args /* { - struct vnode *a_vp; - off_t a_oldoff; - off_t a_newoff; - struct ucred *a_cred; - } */ *ap; + struct vop_seek_args /* { + * struct vnode *a_vp; + * off_t a_oldoff; + * off_t a_newoff; + * struct ucred *a_cred; + * } */ *ap; { - if (ap->a_newoff > ULONG_MAX) /* AFS doesn't support 64-bit offsets */ + if (ap->a_newoff > ULONG_MAX) /* AFS doesn't support 64-bit offsets */ return EINVAL; return (0); } int afs_vop_remove(ap) - struct vop_remove_args /* { - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; - } */ *ap; + struct vop_remove_args /* { + * struct vnode *a_dvp; + * struct vnode *a_vp; + * struct componentname *a_cnp; + * } */ *ap; { int error = 0; register struct vnode *vp = ap->a_vp; @@ -770,20 +782,20 @@ afs_vop_remove(ap) GETNAME(); AFS_GLOCK(); - error = afs_remove(VTOAFS(dvp), name, cnp->cn_cred); + error = afs_remove(VTOAFS(dvp), name, cnp->cn_cred); AFS_GUNLOCK(); cache_purge(vp); if (!error && UBCINFOEXISTS(vp)) { #ifdef AFS_DARWIN14_ENV - (void) ubc_uncache(vp); + (void)ubc_uncache(vp); #else - int wasmapped=ubc_issetflags(vp, UI_WASMAPPED); - int hasobjref=ubc_issetflags(vp, UI_HASOBJREF); - if (wasmapped) - (void) ubc_uncache(vp); - if (hasobjref) - ubc_release(vp); - /* WARNING vp may not be valid after this */ + int wasmapped = ubc_issetflags(vp, UI_WASMAPPED); + int hasobjref = ubc_issetflags(vp, UI_HASOBJREF); + if (wasmapped) + (void)ubc_uncache(vp); + if (hasobjref) + ubc_release(vp); + /* WARNING vp may not be valid after this */ #endif } if (dvp == vp) @@ -799,11 +811,11 @@ afs_vop_remove(ap) int afs_vop_link(ap) - struct vop_link_args /* { - struct vnode *a_vp; - struct vnode *a_tdvp; - struct componentname *a_cnp; - } */ *ap; + struct vop_link_args /* { + * struct vnode *a_vp; + * struct vnode *a_tdvp; + * struct componentname *a_cnp; + * } */ *ap; { int error = 0; register struct vnode *dvp = ap->a_tdvp; @@ -811,7 +823,7 @@ afs_vop_link(ap) struct proc *p; GETNAME(); - p=cnp->cn_proc; + p = cnp->cn_proc; if (vp->v_type == VDIR) { VOP_ABORTOP(vp, cnp); error = EISDIR; @@ -826,8 +838,8 @@ afs_vop_link(ap) AFS_GUNLOCK(); FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI); if (dvp != vp) - VOP_UNLOCK(vp,0, p); -out: + VOP_UNLOCK(vp, 0, p); + out: vput(dvp); DROPNAME(); return error; @@ -835,14 +847,14 @@ out: int afs_vop_rename(ap) - struct vop_rename_args /* { - struct vnode *a_fdvp; - struct vnode *a_fvp; - struct componentname *a_fcnp; - struct vnode *a_tdvp; - struct vnode *a_tvp; - struct componentname *a_tcnp; - } */ *ap; + struct vop_rename_args /* { + * struct vnode *a_fdvp; + * struct vnode *a_fvp; + * struct componentname *a_fcnp; + * struct vnode *a_tdvp; + * struct vnode *a_tvp; + * struct componentname *a_tcnp; + * } */ *ap; { int error = 0; struct componentname *fcnp = ap->a_fcnp; @@ -853,7 +865,7 @@ afs_vop_rename(ap) register struct vnode *tdvp = ap->a_tdvp; struct vnode *fvp = ap->a_fvp; register struct vnode *fdvp = ap->a_fdvp; - struct proc *p=fcnp->cn_proc; + struct proc *p = fcnp->cn_proc; /* * if fvp == tvp, we're just removing one name of a pair of @@ -863,15 +875,15 @@ afs_vop_rename(ap) if (fvp == tvp) { if (fvp->v_type == VDIR) { error = EINVAL; - abortit: - VOP_ABORTOP(tdvp, tcnp); /* XXX, why not in NFS? */ + abortit: + VOP_ABORTOP(tdvp, tcnp); /* XXX, why not in NFS? */ if (tdvp == tvp) vrele(tdvp); else vput(tdvp); if (tvp) vput(tvp); - VOP_ABORTOP(fdvp, fcnp); /* XXX, why not in NFS? */ + VOP_ABORTOP(fdvp, fcnp); /* XXX, why not in NFS? */ vrele(fdvp); vrele(fvp); return (error); @@ -890,30 +902,31 @@ afs_vop_rename(ap) if ((fcnp->cn_flags & SAVESTART) == 0) panic("afs_rename: lost from startdir"); fcnp->cn_nameiop = DELETE; - (void) relookup(fdvp, &fvp, fcnp); + (void)relookup(fdvp, &fvp, fcnp); return (VOP_REMOVE(fdvp, fvp, fcnp)); } if (error = vn_lock(fvp, LK_EXCLUSIVE, p)) goto abortit; - MALLOC(fname, char *, fcnp->cn_namelen+1, M_TEMP, M_WAITOK); + MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK); memcpy(fname, fcnp->cn_nameptr, fcnp->cn_namelen); fname[fcnp->cn_namelen] = '\0'; - MALLOC(tname, char *, tcnp->cn_namelen+1, M_TEMP, M_WAITOK); + MALLOC(tname, char *, tcnp->cn_namelen + 1, M_TEMP, M_WAITOK); memcpy(tname, tcnp->cn_nameptr, tcnp->cn_namelen); tname[tcnp->cn_namelen] = '\0'; AFS_GLOCK(); /* XXX use "from" or "to" creds? NFS uses "to" creds */ - error = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred); + error = + afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred); AFS_GUNLOCK(); VOP_UNLOCK(fvp, 0, p); FREE(fname, M_TEMP); FREE(tname, M_TEMP); if (error) - goto abortit; /* XXX */ + goto abortit; /* XXX */ if (tdvp == tvp) vrele(tdvp); else @@ -927,12 +940,12 @@ afs_vop_rename(ap) int afs_vop_mkdir(ap) - struct vop_mkdir_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap; + struct vop_mkdir_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * } */ *ap; { register struct vnode *dvp = ap->a_dvp; register struct vattr *vap = ap->a_vap; @@ -941,7 +954,7 @@ afs_vop_mkdir(ap) struct proc *p; GETNAME(); - p=cnp->cn_proc; + p = cnp->cn_proc; #ifdef DIAGNOSTIC if ((cnp->cn_flags & HASBUF) == 0) panic("afs_vop_mkdir: no name"); @@ -953,12 +966,12 @@ afs_vop_mkdir(ap) VOP_ABORTOP(dvp, cnp); vput(dvp); DROPNAME(); - return(error); + return (error); } if (vcp) { *ap->a_vpp = AFSTOV(vcp); (*ap->a_vpp)->v_vfsp = dvp->v_vfsp; - vn_lock(*ap->a_vpp, LK_EXCLUSIVE|LK_RETRY, p); + vn_lock(*ap->a_vpp, LK_EXCLUSIVE | LK_RETRY, p); } else *ap->a_vpp = 0; DROPNAME(); @@ -969,11 +982,11 @@ afs_vop_mkdir(ap) int afs_vop_rmdir(ap) - struct vop_rmdir_args /* { - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; - } */ *ap; + struct vop_rmdir_args /* { + * struct vnode *a_dvp; + * struct vnode *a_vp; + * struct componentname *a_cnp; + * } */ *ap; { int error = 0; register struct vnode *vp = ap->a_vp; @@ -999,13 +1012,13 @@ afs_vop_rmdir(ap) int afs_vop_symlink(ap) - struct vop_symlink_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - char *a_target; - } */ *ap; + struct vop_symlink_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * char *a_target; + * } */ *ap; { register struct vnode *dvp = ap->a_dvp; int error = 0; @@ -1013,8 +1026,8 @@ afs_vop_symlink(ap) GETNAME(); AFS_GLOCK(); - error = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, - cnp->cn_cred); + error = + afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, cnp->cn_cred); AFS_GUNLOCK(); DROPNAME(); FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI); @@ -1024,23 +1037,23 @@ afs_vop_symlink(ap) int afs_vop_readdir(ap) - struct vop_readdir_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - int *a_eofflag; - u_long *a_cookies; - int ncookies; - } */ *ap; + struct vop_readdir_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * struct ucred *a_cred; + * int *a_eofflag; + * u_long *a_cookies; + * int ncookies; + * } */ *ap; { int error; off_t off; /* printf("readdir %x cookies %x ncookies %d\n", ap->a_vp, ap->a_cookies, ap->a_ncookies); */ - off=ap->a_uio->uio_offset; + off = ap->a_uio->uio_offset; AFS_GLOCK(); - error= afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, - ap->a_eofflag); + error = + afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag); AFS_GUNLOCK(); if (!error && ap->a_ncookies != NULL) { struct uio *uio = ap->a_uio; @@ -1053,17 +1066,15 @@ afs_vop_readdir(ap) dp = (const struct dirent *) ((const char *)uio->uio_iov->iov_base - (uio->uio_offset - off)); - dp_end = (const struct dirent *) uio->uio_iov->iov_base; - for (dp_start = dp, ncookies = 0; - dp < dp_end; - dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) + dp_end = (const struct dirent *)uio->uio_iov->iov_base; + for (dp_start = dp, ncookies = 0; dp < dp_end; + dp = (const struct dirent *)((const char *)dp + dp->d_reclen)) ncookies++; - MALLOC(cookies, u_long *, ncookies * sizeof(u_long), - M_TEMP, M_WAITOK); - for (dp = dp_start, cookiep = cookies; - dp < dp_end; - dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) { + MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP, + M_WAITOK); + for (dp = dp_start, cookiep = cookies; dp < dp_end; + dp = (const struct dirent *)((const char *)dp + dp->d_reclen)) { off += dp->d_reclen; *cookiep++ = off; } @@ -1076,16 +1087,16 @@ afs_vop_readdir(ap) int afs_vop_readlink(ap) - struct vop_readlink_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - } */ *ap; + struct vop_readlink_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * struct ucred *a_cred; + * } */ *ap; { int error; /* printf("readlink %x\n", ap->a_vp);*/ AFS_GLOCK(); - error= afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred); + error = afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred); AFS_GUNLOCK(); return error; } @@ -1094,10 +1105,10 @@ extern int prtactive; int afs_vop_inactive(ap) - struct vop_inactive_args /* { - struct vnode *a_vp; - struct proc *a_p; - } */ *ap; + struct vop_inactive_args /* { + * struct vnode *a_vp; + * struct proc *a_p; + * } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -1105,7 +1116,7 @@ afs_vop_inactive(ap) vprint("afs_vop_inactive(): pushing active", vp); AFS_GLOCK(); - afs_InactiveVCache(VTOAFS(vp), 0); /* decrs ref counts */ + afs_InactiveVCache(VTOAFS(vp), 0); /* decrs ref counts */ AFS_GUNLOCK(); VOP_UNLOCK(vp, 0, ap->a_p); return 0; @@ -1113,74 +1124,74 @@ afs_vop_inactive(ap) int afs_vop_reclaim(ap) - struct vop_reclaim_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_reclaim_args /* { + * struct vnode *a_vp; + * } */ *ap; { int error; int sl; register struct vnode *vp = ap->a_vp; - cache_purge(vp); /* just in case... */ + cache_purge(vp); /* just in case... */ -#if 0 +#if 0 AFS_GLOCK(); - error = afs_FlushVCache(VTOAFS(vp), &sl); /* tosses our stuff from vnode */ + error = afs_FlushVCache(VTOAFS(vp), &sl); /* tosses our stuff from vnode */ AFS_GUNLOCK(); ubc_unlink(vp); if (!error && vp->v_data) panic("afs_reclaim: vnode not cleaned"); return error; #else - if (vp->v_usecount == 2) { - vprint("reclaim count==2", vp); - } else if (vp->v_usecount == 1) { - vprint("reclaim count==1", vp); - } else - vprint("reclaim bad count", vp); - - return 0; + if (vp->v_usecount == 2) { + vprint("reclaim count==2", vp); + } else if (vp->v_usecount == 1) { + vprint("reclaim count==1", vp); + } else + vprint("reclaim bad count", vp); + + return 0; #endif } int afs_vop_lock(ap) - struct vop_lock_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_lock_args /* { + * struct vnode *a_vp; + * } */ *ap; { - register struct vnode *vp = ap->a_vp; - register struct vcache *avc = VTOAFS(vp); + register struct vnode *vp = ap->a_vp; + register struct vcache *avc = VTOAFS(vp); - if (vp->v_tag == VT_NON) - return (ENOENT); - return (lockmgr(&avc->rwlock, ap->a_flags, &vp->v_interlock, - ap->a_p)); + if (vp->v_tag == VT_NON) + return (ENOENT); + return (lockmgr(&avc->rwlock, ap->a_flags, &vp->v_interlock, ap->a_p)); } int afs_vop_unlock(ap) - struct vop_unlock_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_unlock_args /* { + * struct vnode *a_vp; + * } */ *ap; { struct vnode *vp = ap->a_vp; struct vcache *avc = VTOAFS(vp); - return (lockmgr(&avc->rwlock, ap->a_flags | LK_RELEASE, - &vp->v_interlock, ap->a_p)); + return (lockmgr + (&avc->rwlock, ap->a_flags | LK_RELEASE, &vp->v_interlock, + ap->a_p)); } int afs_vop_bmap(ap) - struct vop_bmap_args /* { - struct vnode *a_vp; - daddr_t a_bn; - struct vnode **a_vpp; - daddr_t *a_bnp; - int *a_runp; - int *a_runb; - } */ *ap; + struct vop_bmap_args /* { + * struct vnode *a_vp; + * daddr_t a_bn; + * struct vnode **a_vpp; + * daddr_t *a_bnp; + * int *a_runp; + * int *a_runb; + * } */ *ap; { struct vcache *vcp; int error; @@ -1190,52 +1201,58 @@ afs_vop_bmap(ap) if (ap->a_vpp) { *ap->a_vpp = ap->a_vp; } - if (ap->a_runp != NULL) - *ap->a_runp = 0; + if (ap->a_runp != NULL) + *ap->a_runp = 0; #ifdef notyet - if (ap->a_runb != NULL) - *ap->a_runb = 0; + if (ap->a_runb != NULL) + *ap->a_runb = 0; #endif - + return 0; } + int afs_vop_strategy(ap) - struct vop_strategy_args /* { - struct buf *a_bp; - } */ *ap; + struct vop_strategy_args /* { + * struct buf *a_bp; + * } */ *ap; { int error; AFS_GLOCK(); - error= afs_ustrategy(ap->a_bp); + error = afs_ustrategy(ap->a_bp); AFS_GUNLOCK(); return error; } + int afs_vop_print(ap) - struct vop_print_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_print_args /* { + * struct vnode *a_vp; + * } */ *ap; { register struct vnode *vp = ap->a_vp; register struct vcache *vc = VTOAFS(ap->a_vp); int s = vc->states; - printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, vc->fid.Cell, - vc->fid.Fid.Volume, vc->fid.Fid.Vnode, vc->fid.Fid.Unique, vc->opens, - vc->execsOrWriters); - printf("\n states%s%s%s%s%s", (s&CStatd) ? " statd" : "", (s&CRO) ? " readonly" : "",(s&CDirty) ? " dirty" : "",(s&CMAPPED) ? " mapped" : "", (s&CVFlushed) ? " flush in progress" : ""); + printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, + vc->fid.Cell, vc->fid.Fid.Volume, vc->fid.Fid.Vnode, + vc->fid.Fid.Unique, vc->opens, vc->execsOrWriters); + printf("\n states%s%s%s%s%s", (s & CStatd) ? " statd" : "", + (s & CRO) ? " readonly" : "", (s & CDirty) ? " dirty" : "", + (s & CMAPPED) ? " mapped" : "", + (s & CVFlushed) ? " flush in progress" : ""); if (UBCISVALID(vp)) { - printf("\n UBC: "); - if (UBCINFOEXISTS(vp)) { - printf("exists, ") ; + printf("\n UBC: "); + if (UBCINFOEXISTS(vp)) { + printf("exists, "); #ifdef AFS_DARWIN14_ENV - printf("refs %d%s%s", vp->v_ubcinfo->ui_refcount, - ubc_issetflags(vp, UI_HASOBJREF) ? " HASOBJREF" : "", - ubc_issetflags(vp, UI_WASMAPPED) ? " WASMAPPED" : ""); + printf("refs %d%s%s", vp->v_ubcinfo->ui_refcount, + ubc_issetflags(vp, UI_HASOBJREF) ? " HASOBJREF" : "", + ubc_issetflags(vp, UI_WASMAPPED) ? " WASMAPPED" : ""); #else - printf("holdcnt %d", vp->v_ubcinfo->ui_holdcnt); + printf("holdcnt %d", vp->v_ubcinfo->ui_holdcnt); #endif - } else printf("does not exist"); + } else + printf("does not exist"); } printf("\n"); return 0; @@ -1243,9 +1260,9 @@ afs_vop_print(ap) int afs_vop_islocked(ap) - struct vop_islocked_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_islocked_args /* { + * struct vnode *a_vp; + * } */ *ap; { struct vcache *vc = VTOAFS(ap->a_vp); return lockstatus(&vc->rwlock); @@ -1255,33 +1272,33 @@ afs_vop_islocked(ap) * Return POSIX pathconf information applicable to ufs filesystems. */ afs_vop_pathconf(ap) - struct vop_pathconf_args /* { - struct vnode *a_vp; - int a_name; - int *a_retval; - } */ *ap; + struct vop_pathconf_args /* { + * struct vnode *a_vp; + * int a_name; + * int *a_retval; + * } */ *ap; { AFS_STATCNT(afs_cntl); switch (ap->a_name) { - case _PC_LINK_MAX: + case _PC_LINK_MAX: *ap->a_retval = LINK_MAX; break; - case _PC_NAME_MAX: + case _PC_NAME_MAX: *ap->a_retval = NAME_MAX; break; - case _PC_PATH_MAX: + case _PC_PATH_MAX: *ap->a_retval = PATH_MAX; break; - case _PC_CHOWN_RESTRICTED: + case _PC_CHOWN_RESTRICTED: *ap->a_retval = 1; break; - case _PC_NO_TRUNC: + case _PC_NO_TRUNC: *ap->a_retval = 1; break; - case _PC_PIPE_BUF: + case _PC_PIPE_BUF: return EINVAL; break; - default: + default: return EINVAL; } return 0; @@ -1292,36 +1309,36 @@ afs_vop_pathconf(ap) */ int afs_vop_advlock(ap) - struct vop_advlock_args /* { - struct vnode *a_vp; - caddr_t a_id; - int a_op; - struct flock *a_fl; - int a_flags; - } */ *ap; + struct vop_advlock_args /* { + * struct vnode *a_vp; + * caddr_t a_id; + * int a_op; + * struct flock *a_fl; + * int a_flags; + * } */ *ap; { int error; - struct proc *p=current_proc(); + struct proc *p = current_proc(); struct ucred cr; pcred_readlock(p); - cr=*p->p_cred->pc_ucred; + cr = *p->p_cred->pc_ucred; pcred_unlock(p); AFS_GLOCK(); - error= afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr, - (int) ap->a_id); + error = + afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr, (int)ap->a_id); AFS_GUNLOCK(); return error; } int afs_vop_truncate(ap) - struct vop_truncate_args /* { - struct vnode *a_vp; - off_t a_length; - int a_flags; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_truncate_args /* { + * struct vnode *a_vp; + * off_t a_length; + * int a_flags; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { printf("stray afs_vop_truncate\n"); return EOPNOTSUPP; @@ -1329,52 +1346,54 @@ afs_vop_truncate(ap) int afs_vop_update(ap) - struct vop_update_args /* { - struct vnode *a_vp; - struct timeval *a_access; - struct timeval *a_modify; - int a_waitfor; - } */ *ap; + struct vop_update_args /* { + * struct vnode *a_vp; + * struct timeval *a_access; + * struct timeval *a_modify; + * int a_waitfor; + * } */ *ap; { printf("stray afs_vop_update\n"); return EOPNOTSUPP; } -int afs_vop_blktooff(ap) - struct vop_blktooff_args /* { - struct vnode *a_vp; - daddr_t a_lblkno; - off_t *a_offset; - } */ *ap; +int +afs_vop_blktooff(ap) + struct vop_blktooff_args /* { + * struct vnode *a_vp; + * daddr_t a_lblkno; + * off_t *a_offset; + * } */ *ap; { - *ap->a_offset = (off_t)(ap->a_lblkno * DEV_BSIZE); - return 0; + *ap->a_offset = (off_t) (ap->a_lblkno * DEV_BSIZE); + return 0; } -int afs_vop_offtoblk(ap) - struct vop_offtoblk_args /* { - struct vnode *a_vp; - off_t a_offset; - daddr_t *a_lblkno; - } */ *ap; +int +afs_vop_offtoblk(ap) + struct vop_offtoblk_args /* { + * struct vnode *a_vp; + * off_t a_offset; + * daddr_t *a_lblkno; + * } */ *ap; { - *ap->a_lblkno = (daddr_t)(ap->a_offset / DEV_BSIZE); + *ap->a_lblkno = (daddr_t) (ap->a_offset / DEV_BSIZE); - return (0); + return (0); } -int afs_vop_cmap(ap) - struct vop_cmap_args /* { - struct vnode *a_vp; - off_t a_foffset; - size_t a_size; - daddr_t *a_bpn; - size_t *a_run; - void *a_poff; - } */ *ap; +int +afs_vop_cmap(ap) + struct vop_cmap_args /* { + * struct vnode *a_vp; + * off_t a_foffset; + * size_t a_size; + * daddr_t *a_bpn; + * size_t *a_run; + * void *a_poff; + * } */ *ap; { - *ap->a_bpn = (daddr_t)(ap->a_foffset / DEV_BSIZE); - *ap->a_run= MAX(ap->a_size, AFS_CHUNKSIZE(ap->a_foffset)); - return 0; + *ap->a_bpn = (daddr_t) (ap->a_foffset / DEV_BSIZE); + *ap->a_run = MAX(ap->a_size, AFS_CHUNKSIZE(ap->a_foffset)); + return 0; } - diff --git a/src/afs/DUX/osi_file.c b/src/afs/DUX/osi_file.c index 2ba492f47..450312ec1 100644 --- a/src/afs/DUX/osi_file.c +++ b/src/afs/DUX/osi_file.c @@ -10,21 +10,23 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ -int afs_osicred_initialized=0; -struct AFS_UCRED afs_osi_cred; +int afs_osicred_initialized = 0; +struct AFS_UCRED afs_osi_cred; afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct mount *afs_cacheVfsp; -void *osi_UFSOpen(afs_int32 ainode) +void * +osi_UFSOpen(afs_int32 ainode) { static struct vnode *tags_vnode = NULL; struct inode *ip; @@ -33,70 +35,72 @@ void *osi_UFSOpen(afs_int32 ainode) afs_int32 code = 0; int dummy; AFS_STATCNT(osi_UFSOpen); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) + if (cacheDiskType != AFS_FCACHE_TYPE_UFS) osi_Panic("UFSOpen called for non-UFS cache\n"); - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); - switch(afs_cacheVfsp->m_stat.f_type) { + switch (afs_cacheVfsp->m_stat.f_type) { case MOUNT_UFS: - code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode, &ip, &dummy); - if (code) { - osi_FreeSmallSpace(afile); - osi_Panic("UFSOpen: igetinode failed"); - } - IN_UNLOCK(ip); - afile->vnode = ITOV(ip); - afile->size = VTOI(afile->vnode)->i_size; - afile->offset = 0; - afile->proc = NULL; - afile->inum = ainode; /* for hint validity checking */ - break; - case MOUNT_MSFS: { - char path[1024]; - struct nameidata nd, *ndp = &nd; - struct utask_nd utnd = { NULL, NULL }; - struct vattr attr; - - memset(&nd, 0, sizeof(nd)); - ndp->ni_utnd = &utnd; - ndp->ni_nameiop = LOOKUP; - ndp->ni_cred = &afs_osi_cred; - ndp->ni_segflg = UIO_SYSSPACE; - - /* get hold of a vnode for the .tags directory, so we can - lookup files relative to it */ - if(tags_vnode == NULL) { - ndp->ni_cdir = afs_cacheVfsp->m_vnodecovered; - strcpy(path, afs_cacheVfsp->m_stat.f_mntonname); - strcat(path, "/.tags"); - ndp->ni_dirp = path; - if((code = namei(ndp))) - osi_Panic("failed to lookup %s (%d)", path, code); - tags_vnode = ndp->ni_vp; - } - sprintf(path, "%d", ainode); - ndp->ni_dirp = path; - ndp->ni_cdir = tags_vnode; - if((code = namei(ndp))) - osi_Panic("failed to lookup %s (%d)", path, code); - - /* XXX this sucks, chances are we're going to do this again right - away, but apparently we can't just set the size to 0 */ - VOP_GETATTR(ndp->ni_vp, &attr, &afs_osi_cred, code); - if(code) - osi_Panic("failed to stat %s (%d)", path, code); - - afile->vnode = ndp->ni_vp; - afile->size = attr.va_size; - afile->offset = 0; - afile->proc = NULL; - afile->inum = ainode; /* for hint validity checking */ - break; - } + code = + igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode, + &ip, &dummy); + if (code) { + osi_FreeSmallSpace(afile); + osi_Panic("UFSOpen: igetinode failed"); + } + IN_UNLOCK(ip); + afile->vnode = ITOV(ip); + afile->size = VTOI(afile->vnode)->i_size; + afile->offset = 0; + afile->proc = NULL; + afile->inum = ainode; /* for hint validity checking */ + break; + case MOUNT_MSFS:{ + char path[1024]; + struct nameidata nd, *ndp = &nd; + struct utask_nd utnd = { NULL, NULL }; + struct vattr attr; + + memset(&nd, 0, sizeof(nd)); + ndp->ni_utnd = &utnd; + ndp->ni_nameiop = LOOKUP; + ndp->ni_cred = &afs_osi_cred; + ndp->ni_segflg = UIO_SYSSPACE; + + /* get hold of a vnode for the .tags directory, so we can + * lookup files relative to it */ + if (tags_vnode == NULL) { + ndp->ni_cdir = afs_cacheVfsp->m_vnodecovered; + strcpy(path, afs_cacheVfsp->m_stat.f_mntonname); + strcat(path, "/.tags"); + ndp->ni_dirp = path; + if ((code = namei(ndp))) + osi_Panic("failed to lookup %s (%d)", path, code); + tags_vnode = ndp->ni_vp; + } + sprintf(path, "%d", ainode); + ndp->ni_dirp = path; + ndp->ni_cdir = tags_vnode; + if ((code = namei(ndp))) + osi_Panic("failed to lookup %s (%d)", path, code); + + /* XXX this sucks, chances are we're going to do this again right + * away, but apparently we can't just set the size to 0 */ + VOP_GETATTR(ndp->ni_vp, &attr, &afs_osi_cred, code); + if (code) + osi_Panic("failed to stat %s (%d)", path, code); + + afile->vnode = ndp->ni_vp; + afile->size = attr.va_size; + afile->offset = 0; + afile->proc = NULL; + afile->inum = ainode; /* for hint validity checking */ + break; + } default: - osi_Panic("UFSOpen called for unknown cache-type (%d)", + osi_Panic("UFSOpen called for unknown cache-type (%d)", afs_cacheVfsp->m_stat.f_type); } @@ -104,12 +108,13 @@ void *osi_UFSOpen(afs_int32 ainode) return afile; } -int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) +int +afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) { register afs_int32 code; struct vattr tvattr; AFS_STATCNT(osi_Stat); - MObtainWriteLock(&afs_xosi,320); + MObtainWriteLock(&afs_xosi, 320); AFS_GUNLOCK(); VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, code); AFS_GLOCK(); @@ -123,18 +128,20 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta return code; } -int osi_UFSClose(register struct osi_file *afile) +int +osi_UFSClose(register struct osi_file *afile) { - AFS_STATCNT(osi_Close); - if(afile->vnode) { + AFS_STATCNT(osi_Close); + if (afile->vnode) { AFS_RELE(afile->vnode); - } - - osi_FreeSmallSpace(afile); - return 0; + } + + osi_FreeSmallSpace(afile); + return 0; } -int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) +int +osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) { struct AFS_UCRED *oldCred; struct vattr tvattr; @@ -147,98 +154,107 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) * small enough. Check now and save some time. */ code = afs_osi_Stat(afile, &tstat); - if (code || tstat.size <= asize) return code; - MObtainWriteLock(&afs_xosi,321); + if (code || tstat.size <= asize) + return code; + MObtainWriteLock(&afs_xosi, 321); VATTR_NULL(&tvattr); /* note that this credential swapping stuff is only necessary because - of ufs's references directly to u.u_cred instead of to - credentials parameter. Probably should fix ufs some day. */ - oldCred = u.u_cred; /* remember old credentials pointer */ - u.u_cred = &afs_osi_cred; /* temporarily use superuser credentials */ + * of ufs's references directly to u.u_cred instead of to + * credentials parameter. Probably should fix ufs some day. */ + oldCred = u.u_cred; /* remember old credentials pointer */ + u.u_cred = &afs_osi_cred; /* temporarily use superuser credentials */ tvattr.va_size = asize; AFS_GUNLOCK(); VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, code); AFS_GLOCK(); - u.u_cred = oldCred; /* restore */ + u.u_cred = oldCred; /* restore */ MReleaseWriteLock(&afs_xosi); return code; } -void osi_DisableAtimes(struct vnode *avp) +void +osi_DisableAtimes(struct vnode *avp) { - struct inode *ip; - assert(avp->v_tag == VT_UFS); - ip = VTOI(avp); - ip->i_flag &= ~IACC; + struct inode *ip; + assert(avp->v_tag == VT_UFS); + ip = VTOI(avp); + ip->i_flag &= ~IACC; } /* Generic read interface */ -int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize) +int +afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; unsigned int resid; register afs_int32 code; - register afs_int32 cnt1=0; + register afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ - if ( !afile ) { - if ( !afs_shuttingdown ) + if (!afile) { + if (!afs_shuttingdown) osi_Panic("osi_Read called with null param"); else return EIO; } - if (offset != -1) afile->offset = offset; + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); - code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, + AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); - } - else { + } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, - ICL_TYPE_INT32, code); + ICL_TYPE_INT32, code); code = -1; } return code; } /* Generic write interface */ -int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) +int +afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; unsigned int resid; register afs_int32 code; AFS_STATCNT(osi_Write); - if ( !afile ) - osi_Panic("afs_osi_Write called with null param"); - if (offset != -1) afile->offset = offset; + if (!afile) + osi_Panic("afs_osi_Write called with null param"); + if (offset != -1) + afile->offset = offset; { struct ucred *tmpcred = u.u_cred; u.u_cred = &afs_osi_cred; AFS_GUNLOCK(); - code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, + afile->offset, AFS_UIOSYS, IO_UNIT, &afs_osi_cred, + &resid); AFS_GLOCK(); u.u_cred = tmpcred; } if (code == 0) { code = asize - resid; afile->offset += code; - } - else { + } else { code = -1; } if (afile->proc) { - (*afile->proc)(afile, code); + (*afile->proc) (afile, code); } return code; } @@ -247,7 +263,8 @@ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, /* This work should be handled by physstrat in ca/machdep.c. This routine written from the RT NFS port strategy routine. It has been generalized a bit, but should still be pretty clear. */ -int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) +int +afs_osi_MapStrategy(int (*aproc) (), register struct buf *bp) { afs_int32 returnCode; @@ -259,13 +276,13 @@ int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) -void shutdown_osifile(void) +void +shutdown_osifile(void) { - extern int afs_cold_shutdown; + extern int afs_cold_shutdown; - AFS_STATCNT(shutdown_osifile); - if (afs_cold_shutdown) { - afs_osicred_initialized = 0; - } + AFS_STATCNT(shutdown_osifile); + if (afs_cold_shutdown) { + afs_osicred_initialized = 0; + } } - diff --git a/src/afs/DUX/osi_groups.c b/src/afs/DUX/osi_groups.c index d39aeb611..daed60c37 100644 --- a/src/afs/DUX/osi_groups.c +++ b/src/afs/DUX/osi_groups.c @@ -16,31 +16,25 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset); + afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset); static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent); + afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent); int Afs_xsetgroups(p, args, retval) - struct proc *p; - void *args; - int *retval; + struct proc *p; + void *args; + int *retval; { int code = 0; struct vrequest treq; @@ -50,7 +44,8 @@ Afs_xsetgroups(p, args, retval) code = afs_InitReq(&treq, u.u_cred); AFS_GUNLOCK(); - if (code) return code; + if (code) + return code; code = setgroups(p, args, retval); /* Note that if there is a pag already in the new groups we don't @@ -70,11 +65,11 @@ Afs_xsetgroups(p, args, retval) int setpag(proc, cred, pagvalue, newpag, change_parent) - struct proc *proc; - struct ucred **cred; - afs_uint32 pagvalue; - afs_uint32 *newpag; - afs_uint32 change_parent; + struct proc *proc; + struct ucred **cred; + afs_uint32 pagvalue; + afs_uint32 *newpag; + afs_uint32 change_parent; { gid_t gidset[NGROUPS]; int ngroups, code; @@ -87,12 +82,12 @@ setpag(proc, cred, pagvalue, newpag, change_parent) if (ngroups + 2 > NGROUPS) { return (E2BIG); } - for (j = ngroups -1; j >= 0; j--) { - gidset[j+2] = gidset[j]; - } + for (j = ngroups - 1; j >= 0; j--) { + gidset[j + 2] = gidset[j]; + } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]); code = afs_setgroups(proc, cred, ngroups, gidset, change_parent); return code; @@ -100,10 +95,7 @@ setpag(proc, cred, pagvalue, newpag, change_parent) static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset) +afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset) { int ngrps, savengrps; gid_t *gp; @@ -112,19 +104,15 @@ afs_getgroups( savengrps = ngrps = MIN(ngroups, cred->cr_ngroups); gp = cred->cr_groups; while (ngrps--) - *gidset++ = *gp++; + *gidset++ = *gp++; return savengrps; } static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent) { int ngrps; int i; @@ -152,5 +140,5 @@ afs_setgroups( substitute_real_creds(proc, NOUID, NOUID, NOGID, NOGID, newcr); } *cred = newcr; - return(0); + return (0); } diff --git a/src/afs/DUX/osi_inode.c b/src/afs/DUX/osi_inode.c index 970895e36..bdf960af4 100644 --- a/src/afs/DUX/osi_inode.c +++ b/src/afs/DUX/osi_inode.c @@ -16,12 +16,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ #include "afs/osi_inode.h" -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include /* given a vnode, return the `inode number'; if it's a UFS vnode just @@ -34,28 +35,28 @@ osi_vnodeToInumber(struct vnode *vnode) struct vattr attr; /* use faster version with UFS */ - if(vnode->v_tag == VT_UFS) + if (vnode->v_tag == VT_UFS) return VTOI(vnode)->i_number; /* otherwise stat the file */ VOP_GETATTR(vnode, &attr, NULL, error); - if(error) + if (error) osi_Panic("VOP_GETATTR = %d", error); return attr.va_fileid; } /* return the id of the device containing the file */ afs_uint32 -osi_vnodeToDev(struct vnode *vnode) +osi_vnodeToDev(struct vnode * vnode) { int error; struct vattr attr; /* use faster version with UFS */ - if(vnode->v_tag == VT_UFS) + if (vnode->v_tag == VT_UFS) return VTOI(vnode)->i_dev; /* otherwise stat the file */ VOP_GETATTR(vnode, &attr, NULL, error); - if(error) + if (error) osi_Panic("VOP_GETATTR = %d", error); return attr.va_rdev; } @@ -78,43 +79,44 @@ getinode(fs, dev, inode, ipp, perror) register struct ufsmount *ump; register struct vnode *vp; register struct mount *mp; - + MOUNTLIST_LOCK(); - if (mp = rootfs) do { - /* - * XXX Also do the test for MFS - */ + if (mp = rootfs) + do { + /* + * XXX Also do the test for MFS + */ #undef m_data #undef m_next - if (mp->m_stat.f_type == MOUNT_UFS) { - MOUNTLIST_UNLOCK(); - ump = VFSTOUFS(mp); - if (ump->um_fs == NULL) - break; - if (ump->um_dev == dev) { - fs = ump->um_mountp; + if (mp->m_stat.f_type == MOUNT_UFS) { + MOUNTLIST_UNLOCK(); + ump = VFSTOUFS(mp); + if (ump->um_fs == NULL) + break; + if (ump->um_dev == dev) { + fs = ump->um_mountp; + } + MOUNTLIST_LOCK(); } - MOUNTLIST_LOCK(); - } #ifdef AFS_DUX50_ENV #define m_next m_nxt #endif - mp = mp->m_next; - } while (mp != rootfs); + mp = mp->m_next; + } while (mp != rootfs); MOUNTLIST_UNLOCK(); if (!fs) - return(ENXIO); + return (ENXIO); } - vp = (struct vnode *) fake_vnode; + vp = (struct vnode *)fake_vnode; fake_inode_init(vp, fs); assert(vp->v_tag == VT_UFS); code = iget(VTOI(vp), inode, &ip, 0); if (code != 0) { *perror = BAD_IGET; - return code; + return code; } else { *ipp = ip; - return(0); + return (0); } } @@ -134,26 +136,26 @@ igetinode(vfsp, dev, inode, ipp, perror) AFS_STATCNT(igetinode); if ((code = getinode(vfsp, dev, inode, &ip, perror)) != 0) { - return(code); + return (code); } if (ip->i_mode == 0) { /* Not an allocated inode */ - iforget(ip); - return(ENOENT); + iforget(ip); + return (ENOENT); } - if (ip->i_nlink == 0 || (ip->i_mode&IFMT) != IFREG) { + if (ip->i_nlink == 0 || (ip->i_mode & IFMT) != IFREG) { iput(ip); - return(ENOENT); + return (ENOENT); } *ipp = ip; - return(0); + return (0); } iforget(ip) -struct inode *ip; + struct inode *ip; { struct vnode *vp = ITOV(ip); @@ -176,72 +178,70 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval) long *retval; long dev, near_inode, param1, param2, param3, param4; { - int dummy, err=0; + int dummy, err = 0; struct inode *ip, *newip; register int code; struct vnode *vp; - + AFS_STATCNT(afs_syscall_icreate); - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = getinode(0, (dev_t)dev, 2, &ip, &dummy); + code = getinode(0, (dev_t) dev, 2, &ip, &dummy); if (code) { - return(ENOENT); + return (ENOENT); } - code = ialloc(ip, (ino_t)near_inode, 0, &newip); + code = ialloc(ip, (ino_t) near_inode, 0, &newip); iput(ip); if (code) { - return(code); + return (code); } IN_LOCK(newip); - newip->i_flag |= IACC|IUPD|ICHG; - + newip->i_flag |= IACC | IUPD | ICHG; + newip->i_nlink = 1; newip->i_mode = IFREG; - + IN_UNLOCK(newip); vp = ITOV(newip); VN_LOCK(vp); vp->v_type = VREG; VN_UNLOCK(vp); - - if ( !vp->v_object) - { - extern struct vfs_ubcops ufs_ubcops; - extern struct vm_ubc_object* ubc_object_allocate(); - struct vm_ubc_object* vop; - vop = ubc_object_allocate(&vp, &ufs_ubcops, - vp->v_mount->m_funnel); - VN_LOCK(vp); - vp->v_object = vop; - VN_UNLOCK(vp); - } - - + + if (!vp->v_object) { + extern struct vfs_ubcops ufs_ubcops; + extern struct vm_ubc_object *ubc_object_allocate(); + struct vm_ubc_object *vop; + vop = ubc_object_allocate(&vp, &ufs_ubcops, vp->v_mount->m_funnel); + VN_LOCK(vp); + vp->v_object = vop; + VN_UNLOCK(vp); + } + + IN_LOCK(newip); - newip->i_flags |= IC_XUID|IC_XGID; + newip->i_flags |= IC_XUID | IC_XGID; newip->i_flags &= ~IC_PROPLIST; newip->i_vicep1 = param1; - if (param2 == 0x1fffffff/*INODESPECIAL*/) { + if (param2 == 0x1fffffff /*INODESPECIAL*/) { newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3)); - newip->i_vicep3a = (u_short)(param3 >> 16); - newip->i_vicep3b = (u_short)param3; + newip->i_vicep3a = (u_short) (param3 >> 16); + newip->i_vicep3b = (u_short) param3; } else { - newip->i_vicep2 = (((param2 >> 16) & 0x1f) << 27) + - (((param4 >> 16) & 0x1f) << 22) + - (param3 & 0x3fffff); - newip->i_vicep3a = (u_short)param4; - newip->i_vicep3b = (u_short)param2; + newip->i_vicep2 = + (((param2 >> 16) & 0x1f) << 27) + + (((param4 >> 16) & 0x1f) << 22) + (param3 & 0x3fffff); + newip->i_vicep3a = (u_short) param4; + newip->i_vicep3b = (u_short) param2; } newip->i_vicemagic = VICEMAGIC; - + *retval = newip->i_number; IN_UNLOCK(newip); iput(newip); - return(code); + return (code); } @@ -259,35 +259,35 @@ afs_syscall_iopen(dev, inode, usrmod, retval) #ifdef AFS_DUX50_ENV struct ufile_entry *fe; #endif - + AFS_STATCNT(afs_syscall_iopen); - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy); + code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy); if (code) { - return(code); + return (code); } #ifdef AFS_DUX50_ENV if ((code = falloc(&fp, &fd, &fe)) != 0) { - iput(ip); - return(code); + iput(ip); + return (code); } #else if ((code = falloc(&fp, &fd)) != 0) { iput(ip); - return(code); + return (code); } #endif IN_UNLOCK(ip); - + FP_LOCK(fp); - fp->f_flag = (usrmod-FOPEN) & FMASK; + fp->f_flag = (usrmod - FOPEN) & FMASK; fp->f_type = DTYPE_VNODE; fp->f_ops = &vnops; - fp->f_data = (caddr_t)ITOV(ip); - + fp->f_data = (caddr_t) ITOV(ip); + FP_UNLOCK(fp); #ifdef AFS_DUX50_ENV u_set_fe(fd, fe, fp, &u.u_file_state); @@ -295,7 +295,7 @@ afs_syscall_iopen(dev, inode, usrmod, retval) U_FD_SET(fd, fp, &u.u_file_state); #endif *retval = fd; - return(0); + return (0); } @@ -311,18 +311,18 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount) int dummy; struct inode *ip; register int code; - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy); + code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy); if (code) { - return(code); + return (code); } if (!IS_VICEMAGIC(ip)) { - return(EPERM); + return (EPERM); } else if (ip->i_vicep1 != inode_p1) { - return(ENXIO); + return (ENXIO); } ip->i_nlink += amount; if (ip->i_nlink == 0) { @@ -330,5 +330,5 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount) } ip->i_flag |= ICHG; iput(ip); - return(0); + return (0); } diff --git a/src/afs/DUX/osi_inode.h b/src/afs/DUX/osi_inode.h index ea16d3350..505528292 100644 --- a/src/afs/DUX/osi_inode.h +++ b/src/afs/DUX/osi_inode.h @@ -34,7 +34,7 @@ #define di_vicep2 di_gid #define di_vicep3a di_bcuid #define di_vicep3b di_bcgid -#define di_vicep4 di_spare[0] /* not used */ +#define di_vicep4 di_spare[0] /* not used */ #define IS_VICEMAGIC(ip) ((ip)->i_vicemagic == VICEMAGIC) #define IS_DVICEMAGIC(dp) ((dp)->di_vicemagic == VICEMAGIC) diff --git a/src/afs/DUX/osi_misc.c b/src/afs/DUX/osi_misc.c index 6035f9fbf..b484cb210 100644 --- a/src/afs/DUX/osi_misc.c +++ b/src/afs/DUX/osi_misc.c @@ -15,7 +15,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ @@ -26,11 +27,12 @@ RCSID("$Header$"); * Note that it must NOT set errno. */ -afs_suser() { +afs_suser() +{ int error; if ((error = suser(u.u_cred, &u.u_acflag)) == 0) { - return(1); + return (1); } - return(0); + return (0); } diff --git a/src/afs/DUX/osi_sleep.c b/src/afs/DUX/osi_sleep.c index 0e452a1af..12fa8020d 100644 --- a/src/afs/DUX/osi_sleep.c +++ b/src/afs/DUX/osi_sleep.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ @@ -23,21 +24,24 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok); static char waitV; -void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) +void +afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) { AFS_STATCNT(osi_InitWaitHandle); achandle->proc = (caddr_t) 0; } /* cancel osi_Wait */ -void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) { caddr_t proc; AFS_STATCNT(osi_CancelWait); proc = achandle->proc; - if (proc == 0) return; - achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ + if (proc == 0) + return; + achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ afs_osi_Wakeup(&waitV); } @@ -45,13 +49,14 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) * Waits for data on ahandle, or ams ms later. ahandle may be null. * Returns 0 if timeout and EINTR if signalled. */ -int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) +int +afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int code; afs_int32 endTime, tid; AFS_STATCNT(osi_Wait); - endTime = osi_Time() + (ams/1000); + endTime = osi_Time() + (ams / 1000); if (ahandle) ahandle->proc = (caddr_t) u.u_procp; do { @@ -59,7 +64,8 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) code = 0; code = osi_TimedSleep(&waitV, ams, aintok); - if (code) break; /* if something happened, quit now */ + if (code) + break; /* if something happened, quit now */ /* if we we're cancelled, quit now */ if (ahandle && (ahandle->proc == (caddr_t) 0)) { /* we've been signalled */ @@ -77,19 +83,20 @@ typedef struct afs_event { char *event; /* lwp event: an address */ int refcount; /* Is it in use? */ int seq; /* Sequence number: this is incremented - by wakeup calls; wait will not return until - it changes */ + * by wakeup calls; wait will not return until + * it changes */ int cond; } afs_event_t; #define HASHSIZE 128 -afs_event_t *afs_evhasht[HASHSIZE];/* Hash table for events */ +afs_event_t *afs_evhasht[HASHSIZE]; /* Hash table for events */ #define afs_evhash(event) (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1)); int afs_evhashcnt = 0; /* Get and initialize event structure corresponding to lwp event (i.e. address) * */ -static afs_event_t *afs_getevent(char *event) +static afs_event_t * +afs_getevent(char *event) { afs_event_t *evp, *newp = 0; int hashcode; @@ -107,7 +114,7 @@ static afs_event_t *afs_getevent(char *event) evp = evp->next; } if (!newp) { - newp = (afs_event_t *) osi_AllocSmallSpace(sizeof (afs_event_t)); + newp = (afs_event_t *) osi_AllocSmallSpace(sizeof(afs_event_t)); afs_evhashcnt++; newp->next = afs_evhasht[hashcode]; afs_evhasht[hashcode] = newp; @@ -122,7 +129,8 @@ static afs_event_t *afs_getevent(char *event) #define relevent(evp) ((evp)->refcount--) -void afs_osi_Sleep(void *event) +void +afs_osi_Sleep(void *event) { struct afs_event *evp; int seq; @@ -131,7 +139,7 @@ void afs_osi_Sleep(void *event) seq = evp->seq; while (seq == evp->seq) { AFS_ASSERT_GLOCK(); - assert_wait((vm_offset_t)(&evp->cond), 0); + assert_wait((vm_offset_t) (&evp->cond), 0); AFS_GUNLOCK(); thread_block(); AFS_GLOCK(); @@ -139,7 +147,8 @@ void afs_osi_Sleep(void *event) relevent(evp); } -int afs_osi_SleepSig(void *event) +int +afs_osi_SleepSig(void *event) { afs_osi_Sleep(event); return 0; @@ -154,40 +163,42 @@ int afs_osi_SleepSig(void *event) * * Returns 0 if timeout and EINTR if signalled. */ -static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) +static int +osi_TimedSleep(char *event, afs_int32 ams, int aintok) { int code = 0; struct afs_event *evp; int ticks; - ticks = ( ams * afs_hz )/1000; + ticks = (ams * afs_hz) / 1000; evp = afs_getevent(event); - assert_wait((vm_offset_t)(&evp->cond), aintok); + assert_wait((vm_offset_t) (&evp->cond), aintok); AFS_GUNLOCK(); thread_set_timeout(ticks); thread_block(); AFS_GLOCK(); if (current_thread()->wait_result != THREAD_AWAKENED) code = EINTR; - + relevent(evp); return code; } -int afs_osi_Wakeup(void *event) +int +afs_osi_Wakeup(void *event) { - int ret=1; + int ret = 1; struct afs_event *evp; - + evp = afs_getevent(event); if (evp->refcount > 1) { - evp->seq++; - thread_wakeup((vm_offset_t)(&evp->cond)); - ret=0; + evp->seq++; + thread_wakeup((vm_offset_t) (&evp->cond)); + ret = 0; } relevent(evp); return ret; diff --git a/src/afs/DUX/osi_vfsops.c b/src/afs/DUX/osi_vfsops.c index 4063b6c5a..a70d2c91d 100644 --- a/src/afs/DUX/osi_vfsops.c +++ b/src/afs/DUX/osi_vfsops.c @@ -13,11 +13,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include #include #include @@ -37,10 +38,8 @@ udecl_simple_lock_data(, afsmntid_lock) #define AFSMNTID_LOCK() usimple_lock(&afsmntid_lock) #define AFSMNTID_UNLOCK() usimple_unlock(&afsmntid_lock) #define AFSMNTID_LOCK_INIT() usimple_lock_init(&afsmntid_lock) - - -int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, - struct nameidata *ndp) + int mp_afs_mount(struct mount *afsp, char *path, caddr_t data, + struct nameidata *ndp) { u_int size; @@ -51,7 +50,7 @@ int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, AFS_GLOCK(); AFS_STATCNT(afs_mount); - if (afs_globalVFS) { /* Don't allow remounts. */ + if (afs_globalVFS) { /* Don't allow remounts. */ AFS_GUNLOCK(); return (EBUSY); } @@ -65,7 +64,7 @@ int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, afsp->m_stat.f_fsid.val[1] = MOUNT_AFS; AFSMNTID_LOCK(); if (++afs_mntid == 0) - ++afs_mntid; + ++afs_mntid; AFSMNTID_UNLOCK(); BM(AFSMNTID_LOCK()); tfsid.val[0] = makedev(130, afs_mntid); @@ -73,29 +72,30 @@ int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, BM(AFSMNTID_UNLOCK()); while (xmp = getvfs(&tfsid)) { - UNMOUNT_READ_UNLOCK(xmp); - tfsid.val[0]++; - AFSMNTID_LOCK(); - afs_mntid++; - AFSMNTID_UNLOCK(); + UNMOUNT_READ_UNLOCK(xmp); + tfsid.val[0]++; + AFSMNTID_LOCK(); + afs_mntid++; + AFSMNTID_UNLOCK(); } if (major(tfsid.val[0]) != 130) { AFS_GUNLOCK(); - return (ENOENT); + return (ENOENT); } afsp->m_stat.f_fsid.val[0] = tfsid.val[0]; afsp->m_stat.f_mntonname = AFS_KALLOC(MNAMELEN); - afsp->m_stat.f_mntfromname = AFS_KALLOC(MNAMELEN); - if ( !afsp->m_stat.f_mntonname || !afsp->m_stat.f_mntfromname) + afsp->m_stat.f_mntfromname = AFS_KALLOC(MNAMELEN); + if (!afsp->m_stat.f_mntonname || !afsp->m_stat.f_mntfromname) panic("malloc failure in afs_mount\n"); memset(afsp->m_stat.f_mntonname, 0, MNAMELEN); memset(afsp->m_stat.f_mntfromname, 0, MNAMELEN); - AFS_COPYINSTR(path, (caddr_t)afsp->m_stat.f_mntonname, MNAMELEN, &size, code); + AFS_COPYINSTR(path, (caddr_t) afsp->m_stat.f_mntonname, MNAMELEN, &size, + code); memcpy(afsp->m_stat.f_mntfromname, "AFS", 4); AFS_GUNLOCK(); - (void) mp_afs_statfs(afsp); + (void)mp_afs_statfs(afsp); AFS_GLOCK(); afs_vfsdev = afsp->m_stat.f_fsid.val[0]; @@ -109,7 +109,8 @@ int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, } -int mp_afs_unmount (struct mount *afsp, int flag) +int +mp_afs_unmount(struct mount *afsp, int flag) { AFS_GLOCK(); AFS_STATCNT(afs_unmount); @@ -120,16 +121,18 @@ int mp_afs_unmount (struct mount *afsp, int flag) } -int mp_afs_start(struct mount *mp, int flags) +int +mp_afs_start(struct mount *mp, int flags) { - return(0); + return (0); } -int mp_afs_root (struct mount *afsp, struct vnode **avpp) +int +mp_afs_root(struct mount *afsp, struct vnode **avpp) { register afs_int32 code = 0; struct vrequest treq; - register struct vcache *tvp=0; + register struct vcache *tvp = 0; AFS_GLOCK(); AFS_STATCNT(afs_root); @@ -141,8 +144,8 @@ int mp_afs_root (struct mount *afsp, struct vnode **avpp) afs_globalVp = NULL; } - if (!(code = afs_InitReq(&treq, u.u_cred)) && - !(code = afs_CheckInit())) { + if (!(code = afs_InitReq(&treq, u.u_cred)) + && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); /* we really want this to stay around */ if (tvp) { @@ -156,7 +159,7 @@ int mp_afs_root (struct mount *afsp, struct vnode **avpp) AFS_GUNLOCK(); VN_HOLD(vp); VN_LOCK(vp); - vp->v_flag |= VROOT; /* No-op on Ultrix 2.2 */ + vp->v_flag |= VROOT; /* No-op on Ultrix 2.2 */ VN_UNLOCK(vp); AFS_GLOCK(); @@ -171,12 +174,13 @@ int mp_afs_root (struct mount *afsp, struct vnode **avpp) } -mp_afs_quotactl(struct mount *mp, int cmd, uid_t uid, caddr_t arg) +mp_afs_quotactl(struct mount * mp, int cmd, uid_t uid, caddr_t arg) { return EOPNOTSUPP; } -int mp_afs_statfs(struct mount *afsp) +int +mp_afs_statfs(struct mount *afsp) { struct nstatfs *abp = &afsp->m_stat; @@ -191,7 +195,7 @@ int mp_afs_statfs(struct mount *afsp) * storing something there. */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 2000000; + abp->f_ffree = 2000000; abp->f_fsize = 1024; abp->f_fsid.val[0] = afsp->m_stat.f_fsid.val[0]; @@ -202,7 +206,8 @@ int mp_afs_statfs(struct mount *afsp) } -int mp_afs_sync(struct mount *mp, int flags) +int +mp_afs_sync(struct mount *mp, int flags) { AFS_STATCNT(afs_sync); return 0; @@ -210,14 +215,16 @@ int mp_afs_sync(struct mount *mp, int flags) #ifdef AFS_DUX50_ENV -int mp_afs_smoothsync(struct mount *mp, u_int age, u_int smsync_flag) +int +mp_afs_smoothsync(struct mount *mp, u_int age, u_int smsync_flag) { AFS_STATCNT(afs_sync); return 0; } #endif -int mp_afs_fhtovp(struct mount *afsp, struct fid *fidp, struct vnode **avcp) +int +mp_afs_fhtovp(struct mount *afsp, struct fid *fidp, struct vnode **avcp) { struct vrequest treq; register code = 0; @@ -228,7 +235,7 @@ int mp_afs_fhtovp(struct mount *afsp, struct fid *fidp, struct vnode **avcp) *avcp = NULL; if ((code = afs_InitReq(&treq, u.u_cred)) == 0) { - code = afs_osi_vget((struct vcache**)avcp, fidp, &treq); + code = afs_osi_vget((struct vcache **)avcp, fidp, &treq); } afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp, @@ -268,11 +275,12 @@ int mp_afs_fhtovp(struct mount *afsp, struct fid *fidp, struct vnode **avcp) */ #define AFS_FIDDATASIZE 8 -#define AFS_SIZEOFSMALLFID 12 /* full size of fid, including len field */ -extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */ -int afs_fid_vnodeoverflow=0, afs_fid_uniqueoverflow=0; +#define AFS_SIZEOFSMALLFID 12 /* full size of fid, including len field */ +extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */ +int afs_fid_vnodeoverflow = 0, afs_fid_uniqueoverflow = 0; -int mp_afs_vptofh(struct vnode *avn, struct fid *fidp) +int +mp_afs_vptofh(struct vnode *avn, struct fid *fidp) { struct SmallFid Sfid; long addr[2]; @@ -288,13 +296,14 @@ int mp_afs_vptofh(struct vnode *avn, struct fid *fidp) return EIO; } - if (afs_NFSRootOnly && (avc == afs_globalVp)) rootvp = 1; + if (afs_NFSRootOnly && (avc == afs_globalVp)) + rootvp = 1; if (!afs_NFSRootOnly || rootvp) { tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); Sfid.Volume = avc->fid.Fid.Volume; fidp->fid_reserved = avc->fid.Fid.Vnode; - Sfid.CellAndUnique = ((tcell->cellIndex << 24) + - (avc->fid.Fid.Unique & 0xffffff)); + Sfid.CellAndUnique = + ((tcell->cellIndex << 24) + (avc->fid.Fid.Unique & 0xffffff)); afs_PutCell(tcell, READ_LOCK); if (avc->fid.Fid.Vnode > 0xffff) afs_fid_vnodeoverflow++; @@ -312,26 +321,27 @@ int mp_afs_vptofh(struct vnode *avn, struct fid *fidp) fidp->fid_len = AFS_SIZEOFSMALLFID; if (afs_NFSRootOnly) { if (rootvp) { - memcpy(fidp->fid_data, (caddr_t)&Sfid, AFS_FIDDATASIZE); + memcpy(fidp->fid_data, (caddr_t) & Sfid, AFS_FIDDATASIZE); } else { - memcpy(fidp->fid_data, (caddr_t)addr, AFS_FIDDATASIZE); + memcpy(fidp->fid_data, (caddr_t) addr, AFS_FIDDATASIZE); } } else { - memcpy(fidp->fid_data, (caddr_t)&Sfid, AFS_FIDDATASIZE); + memcpy(fidp->fid_data, (caddr_t) & Sfid, AFS_FIDDATASIZE); } AFS_GUNLOCK(); return 0; } -int mp_Afs_init(void); /* vfs_init - defined below */ +int mp_Afs_init(void); /* vfs_init - defined below */ /* This is only called by vfs_mount when afs is going to be mounted as root. * Since we don't support diskless clients we shouldn't come here. */ -int afsmountroot=0; -int mp_afs_mountroot(struct mount *afsp, struct vnode **vp) +int afsmountroot = 0; +int +mp_afs_mountroot(struct mount *afsp, struct vnode **vp) { AFS_GLOCK(); AFS_STATCNT(afs_mountroot); @@ -344,8 +354,9 @@ int mp_afs_mountroot(struct mount *afsp, struct vnode **vp) /* It's called to setup swapping over the net for diskless clients; again * not for us. */ -int afsswapvp=0; -int mp_afs_swapvp(void) +int afsswapvp = 0; +int +mp_afs_swapvp(void) { AFS_GLOCK(); AFS_STATCNT(afs_swapvp); @@ -363,7 +374,7 @@ struct vfsops afs_vfsops = { mp_afs_quotactl, mp_afs_statfs, mp_afs_sync, - mp_afs_fhtovp, /* afs_vget */ + mp_afs_fhtovp, /* afs_vget */ mp_afs_vptofh, mp_Afs_init, mp_afs_mountroot, @@ -379,16 +390,16 @@ struct vfsops afs_vfsops = { */ #define NULL_FUNC (int (*)(int))0 -int (*afs_syscall_func)() = NULL_FUNC; -int (*afs_xsetgroups_func)() = NULL_FUNC; -int (*afs_xioctl_func)() = NULL_FUNC; +int (*afs_syscall_func) () = NULL_FUNC; +int (*afs_xsetgroups_func) () = NULL_FUNC; +int (*afs_xioctl_func) () = NULL_FUNC; afssyscall(p, args, retval) - struct proc *p; - void *args; - long *retval; + struct proc *p; + void *args; + long *retval; { - int (*func)(); + int (*func) (); int code; AFS_GLOCK(); @@ -396,18 +407,18 @@ afssyscall(p, args, retval) if (func == NULL_FUNC) { code = nosys(p, args, retval); } else { - code = (*func)(p, args, retval); + code = (*func) (p, args, retval); } AFS_GUNLOCK(); return code; } afsxsetgroups(p, args, retval) - struct proc *p; - void *args; - long *retval; + struct proc *p; + void *args; + long *retval; { - int (*func)(); + int (*func) (); int code; AFS_GLOCK(); @@ -415,18 +426,18 @@ afsxsetgroups(p, args, retval) if (func == NULL_FUNC) { code = nosys(p, args, retval); } else { - code = (*func)(p, args, retval); + code = (*func) (p, args, retval); } AFS_GUNLOCK(); return code; } afsxioctl(p, args, retval) - struct proc *p; - void *args; - long *retval; + struct proc *p; + void *args; + long *retval; { - int (*func)(); + int (*func) (); int code; AFS_GLOCK(); @@ -434,7 +445,7 @@ afsxioctl(p, args, retval) if (func == NULL_FUNC) { code = nosys(p, args, retval); } else { - code = (*func)(p, args, retval); + code = (*func) (p, args, retval); } AFS_GUNLOCK(); return code; @@ -451,15 +462,16 @@ afs_unconfig() } -cfg_subsys_attr_t afs_attributes[] = { +cfg_subsys_attr_t afs_attributes[] = { {"", 0, 0, 0, 0, 0, 0} /* must be the last element */ }; -afs_configure(cfg_op_t op, caddr_t indata, size_t indata_size, caddr_t outdata, size_t outdata_size) +afs_configure(cfg_op_t op, caddr_t indata, size_t indata_size, + caddr_t outdata, size_t outdata_size) { - cfg_attr_t *attributes; - int ret = ESUCCESS; - int i, j, size; + cfg_attr_t *attributes; + int ret = ESUCCESS; + int i, j, size; caddr_t p; switch (op) { @@ -469,11 +481,11 @@ afs_configure(cfg_op_t op, caddr_t indata, size_t indata_size, caddr_t outdata, * indata_size is the count of attributes. */ if ((ret = vfssw_add_fsname(MOUNT_AFS, &afs_vfsops, "afs")) != 0) - return(ret); + return (ret); break; case CFG_OP_UNCONFIGURE: if ((ret = afs_unconfig()) != 0) - return(ret); + return (ret); break; default: ret = EINVAL; @@ -483,22 +495,22 @@ afs_configure(cfg_op_t op, caddr_t indata, size_t indata_size, caddr_t outdata, } -int mp_Afs_init(void) +int +mp_Afs_init(void) { extern int Afs_xsetgroups(), afs_xioctl(), afs3_syscall(); - + AFS_GLOCK(); - ((struct sysent *) (&sysent[AFS_SYSCALL]))->sy_call = afs3_syscall; + ((struct sysent *)(&sysent[AFS_SYSCALL]))->sy_call = afs3_syscall; #ifdef SY_NARG - ((struct sysent *) (&sysent[AFS_SYSCALL]))->sy_info = 6; + ((struct sysent *)(&sysent[AFS_SYSCALL]))->sy_info = 6; #else - ((struct sysent *) (&sysent[AFS_SYSCALL]))->sy_parallel = 0; - ((struct sysent *) (&sysent[AFS_SYSCALL]))->sy_narg = 6; + ((struct sysent *)(&sysent[AFS_SYSCALL]))->sy_parallel = 0; + ((struct sysent *)(&sysent[AFS_SYSCALL]))->sy_narg = 6; #endif - ((struct sysent *) (&sysent[SYS_setgroups]))->sy_call = - Afs_xsetgroups; - afs_xioctl_func = afsxioctl; + ((struct sysent *)(&sysent[SYS_setgroups]))->sy_call = Afs_xsetgroups; + afs_xioctl_func = afsxioctl; afs_xsetgroups_func = afsxsetgroups; afs_syscall_func = afssyscall; AFS_GUNLOCK(); diff --git a/src/afs/DUX/osi_vm.c b/src/afs/DUX/osi_vm.c index f6a8b92f8..853d5e6fe 100644 --- a/src/afs/DUX/osi_vm.c +++ b/src/afs/DUX/osi_vm.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include #include @@ -34,7 +35,8 @@ RCSID("$Header$"); * * OSF/1 Locking: VN_LOCK has been called. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { if (avc->vrefCount > 1) return EBUSY; @@ -79,16 +81,17 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * * Called with the global lock NOT held. */ -static void osi_ubc_flush_dirty_and_wait(struct vnode *vp, int flags) +static void +osi_ubc_flush_dirty_and_wait(struct vnode *vp, int flags) { int retry; vm_page_t pp; int first; do { - struct vm_ubc_object* vop; - vop = (struct vm_ubc_object*)(vp->v_object); - ubc_flush_dirty(vop, flags); + struct vm_ubc_object *vop; + vop = (struct vm_ubc_object *)(vp->v_object); + ubc_flush_dirty(vop, flags); vm_object_lock(vop); if (vop->vu_dirtypl) @@ -103,14 +106,15 @@ static void osi_ubc_flush_dirty_and_wait(struct vnode *vp, int flags) if (pp->pg_busy) { retry = 1; pp->pg_wait = 1; - assert_wait_mesg((vm_offset_t)pp, FALSE, "pg_wait"); + assert_wait_mesg((vm_offset_t) pp, FALSE, "pg_wait"); vm_object_unlock(vop); thread_block(); break; } } } - if (retry) continue; + if (retry) + continue; } vm_object_unlock(vop); } while (retry); @@ -121,13 +125,14 @@ static void osi_ubc_flush_dirty_and_wait(struct vnode *vp, int flags) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); osi_ubc_flush_dirty_and_wait(AFSTOV(avc), 0); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,94); + ObtainWriteLock(&avc->lock, 94); } /* Try to invalidate pages, for "fs flush" or "fs flushv"; or @@ -139,21 +144,23 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * Since we drop and re-obtain the lock, we can't guarantee that there won't * be some pages around when we return, newly created by concurrent activity. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); osi_ubc_flush_dirty_and_wait(AFSTOV(avc), 0); ubc_invalidate(AFSTOV(avc)->v_object, 0, 0, B_INVAL); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,59); + ObtainWriteLock(&avc->lock, 59); } /* Purge VM for a file when its callback is revoked. * * Locking: No lock is held, not even the global lock. */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { ubc_flush_dirty(AFSTOV(avc)->v_object, 0); ubc_invalidate(AFSTOV(avc)->v_object, 0, 0, B_INVAL); @@ -165,8 +172,8 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * activeV is raised. This is supposed to block pageins, but at present * it only works on Solaris. */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { - ubc_invalidate(AFSTOV(avc)->v_object, alen, - MAXINT - alen, B_INVAL); + ubc_invalidate(AFSTOV(avc)->v_object, alen, MAXINT - alen, B_INVAL); } diff --git a/src/afs/DUX/osi_vnodeops.c b/src/afs/DUX/osi_vnodeops.c index d874ee11e..48089a94c 100644 --- a/src/afs/DUX/osi_vnodeops.c +++ b/src/afs/DUX/osi_vnodeops.c @@ -14,12 +14,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include #include #include "afs/afs_cbqueue.h" @@ -48,48 +49,48 @@ int mp_afs_ioctl(); /* AFS vnodeops */ struct vnodeops Afs_vnodeops = { - mp_afs_lookup, - mp_afs_create, - afs_noop, /* vn_mknod */ - mp_afs_open, - mp_afs_close, - mp_afs_access, - mp_afs_getattr, - mp_afs_setattr, - mp_afs_ubcrdwr, - mp_afs_ubcrdwr, - mp_afs_ioctl, /* vn_ioctl */ - seltrue, /* vn_select */ - mp_afs_mmap, - mp_afs_fsync, - mp_afs_seek, - mp_afs_remove, - mp_afs_link, - mp_afs_rename, - mp_afs_mkdir, - mp_afs_rmdir, - mp_afs_symlink, - mp_afs_readdir, - mp_afs_readlink, - mp_afs_abortop, - mp_afs_inactive, - mp_afs_reclaim, - mp_afs_bmap, - mp_afs_strategy, - mp_afs_print, - mp_afs_page_read, - mp_afs_page_write, - mp_afs_swap, - mp_afs_bread, - mp_afs_brelse, - mp_afs_lockctl, - mp_afs_syncdata, - afs_noop, /* Lock */ - afs_noop, /* unLock */ - afs_noop, /* get ext attrs */ - afs_noop, /* set ext attrs */ - afs_noop, /* del ext attrs */ - vn_pathconf_default, + mp_afs_lookup, + mp_afs_create, + afs_noop, /* vn_mknod */ + mp_afs_open, + mp_afs_close, + mp_afs_access, + mp_afs_getattr, + mp_afs_setattr, + mp_afs_ubcrdwr, + mp_afs_ubcrdwr, + mp_afs_ioctl, /* vn_ioctl */ + seltrue, /* vn_select */ + mp_afs_mmap, + mp_afs_fsync, + mp_afs_seek, + mp_afs_remove, + mp_afs_link, + mp_afs_rename, + mp_afs_mkdir, + mp_afs_rmdir, + mp_afs_symlink, + mp_afs_readdir, + mp_afs_readlink, + mp_afs_abortop, + mp_afs_inactive, + mp_afs_reclaim, + mp_afs_bmap, + mp_afs_strategy, + mp_afs_print, + mp_afs_page_read, + mp_afs_page_write, + mp_afs_swap, + mp_afs_bread, + mp_afs_brelse, + mp_afs_lockctl, + mp_afs_syncdata, + afs_noop, /* Lock */ + afs_noop, /* unLock */ + afs_noop, /* get ext attrs */ + afs_noop, /* set ext attrs */ + afs_noop, /* del ext attrs */ + vn_pathconf_default, }; struct vnodeops *afs_ops = &Afs_vnodeops; @@ -109,8 +110,8 @@ struct fileops afs_fileops = { }; mp_afs_lookup(adp, ndp) - struct vcache *adp; - struct nameidata *ndp; + struct vcache *adp; + struct nameidata *ndp; { int code; AFS_GLOCK(); @@ -120,8 +121,8 @@ mp_afs_lookup(adp, ndp) } mp_afs_create(ndp, attrs) - struct nameidata *ndp; - struct vattr *attrs; + struct nameidata *ndp; + struct vattr *attrs; { int code; AFS_GLOCK(); @@ -131,9 +132,9 @@ mp_afs_create(ndp, attrs) } mp_afs_open(avcp, aflags, acred) - struct vcache **avcp; - afs_int32 aflags; - struct AFS_UCRED *acred; + struct vcache **avcp; + afs_int32 aflags; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -143,9 +144,9 @@ mp_afs_open(avcp, aflags, acred) } mp_afs_access(avc, amode, acred) - struct vcache *avc; - afs_int32 amode; - struct AFS_UCRED *acred; + struct vcache *avc; + afs_int32 amode; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -155,9 +156,9 @@ mp_afs_access(avc, amode, acred) } mp_afs_close(avc, flags, cred) - struct vnode *avc; - int flags; - struct ucred *cred; + struct vnode *avc; + int flags; + struct ucred *cred; { int code; AFS_GLOCK(); @@ -167,9 +168,9 @@ mp_afs_close(avc, flags, cred) } mp_afs_getattr(avc, attrs, acred) - struct vcache *avc; - struct vattr *attrs; - struct AFS_UCRED *acred; + struct vcache *avc; + struct vattr *attrs; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -179,9 +180,9 @@ mp_afs_getattr(avc, attrs, acred) } mp_afs_setattr(avc, attrs, acred) - struct vcache *avc; - struct vattr *attrs; - struct AFS_UCRED *acred; + struct vcache *avc; + struct vattr *attrs; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -191,10 +192,10 @@ mp_afs_setattr(avc, attrs, acred) } mp_afs_fsync(avc, fflags, acred, waitfor) - struct vcache *avc; - int fflags; - struct AFS_UCRED *acred; - int waitfor; + struct vcache *avc; + int fflags; + struct AFS_UCRED *acred; + int waitfor; { int code; AFS_GLOCK(); @@ -204,7 +205,7 @@ mp_afs_fsync(avc, fflags, acred, waitfor) } mp_afs_remove(ndp) - struct nameidata *ndp; + struct nameidata *ndp; { int code; AFS_GLOCK(); @@ -214,8 +215,8 @@ mp_afs_remove(ndp) } mp_afs_link(avc, ndp) - struct vcache *avc; - struct nameidata *ndp; + struct vcache *avc; + struct nameidata *ndp; { int code; AFS_GLOCK(); @@ -225,7 +226,7 @@ mp_afs_link(avc, ndp) } mp_afs_rename(fndp, tndp) - struct nameidata *fndp, *tndp; + struct nameidata *fndp, *tndp; { int code; AFS_GLOCK(); @@ -235,8 +236,8 @@ mp_afs_rename(fndp, tndp) } mp_afs_mkdir(ndp, attrs) - struct nameidata *ndp; - struct vattr *attrs; + struct nameidata *ndp; + struct vattr *attrs; { int code; AFS_GLOCK(); @@ -246,7 +247,7 @@ mp_afs_mkdir(ndp, attrs) } mp_afs_rmdir(ndp) - struct nameidata *ndp; + struct nameidata *ndp; { int code; AFS_GLOCK(); @@ -256,9 +257,9 @@ mp_afs_rmdir(ndp) } mp_afs_symlink(ndp, attrs, atargetName) - struct nameidata *ndp; - struct vattr *attrs; - register char *atargetName; + struct nameidata *ndp; + struct vattr *attrs; + register char *atargetName; { int code; AFS_GLOCK(); @@ -268,10 +269,10 @@ mp_afs_symlink(ndp, attrs, atargetName) } mp_afs_readdir(avc, auio, acred, eofp) - struct vcache *avc; - struct uio *auio; - struct AFS_UCRED *acred; - int *eofp; + struct vcache *avc; + struct uio *auio; + struct AFS_UCRED *acred; + int *eofp; { int code; AFS_GLOCK(); @@ -281,9 +282,9 @@ mp_afs_readdir(avc, auio, acred, eofp) } mp_afs_readlink(avc, auio, acred) - struct vcache *avc; - struct uio *auio; - struct AFS_UCRED *acred; + struct vcache *avc; + struct uio *auio; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -293,12 +294,12 @@ mp_afs_readlink(avc, auio, acred) } mp_afs_lockctl(avc, af, flag, acred, clid, offset) - struct vcache *avc; - struct eflock *af; - struct AFS_UCRED *acred; - int flag; - pid_t clid; - off_t offset; + struct vcache *avc; + struct eflock *af; + struct AFS_UCRED *acred; + int flag; + pid_t clid; + off_t offset; { int code; AFS_GLOCK(); @@ -308,7 +309,7 @@ mp_afs_lockctl(avc, af, flag, acred, clid, offset) } mp_afs_closex(afd) - struct file *afd; + struct file *afd; { int code; AFS_GLOCK(); @@ -318,25 +319,25 @@ mp_afs_closex(afd) } mp_afs_seek(avc, oldoff, newoff, cred) - struct vcache *avc; - off_t oldoff, newoff; - struct ucred *cred; + struct vcache *avc; + off_t oldoff, newoff; + struct ucred *cred; { - if ((int) newoff < 0) - return(EINVAL); + if ((int)newoff < 0) + return (EINVAL); else - return(0); + return (0); } mp_afs_abortop(ndp) - struct nameidata *ndp; + struct nameidata *ndp; { - return(0); + return (0); } mp_afs_inactive(avc, acred) - register struct vcache *avc; - struct AFS_UCRED *acred; + register struct vcache *avc; + struct AFS_UCRED *acred; { AFS_GLOCK(); afs_InactiveVCache(avc, acred); @@ -345,21 +346,21 @@ mp_afs_inactive(avc, acred) mp_afs_reclaim(avc) - struct vcache *avc; + struct vcache *avc; { - return(0); + return (0); } mp_afs_print(avc) - struct vcache *avc; + struct vcache *avc; { - return(0); + return (0); } mp_afs_page_read(avc, uio, acred) - struct vcache *avc; - struct uio *uio; - struct ucred *acred; + struct vcache *avc; + struct uio *uio; + struct ucred *acred; { int error; struct vrequest treq; @@ -367,26 +368,26 @@ mp_afs_page_read(avc, uio, acred) AFS_GLOCK(); error = afs_rdwr(avc, uio, UIO_READ, 0, acred); afs_Trace3(afs_iclSetp, CM_TRACE_PAGE_READ, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, error, ICL_TYPE_INT32, avc->states); + ICL_TYPE_INT32, error, ICL_TYPE_INT32, avc->states); if (error) { error = EIO; } else if ((avc->states & CWired) == 0) { afs_InitReq(&treq, acred); - ObtainWriteLock(&avc->lock,161); + ObtainWriteLock(&avc->lock, 161); afs_Wire(avc, &treq); ReleaseWriteLock(&avc->lock); } AFS_GUNLOCK(); - return(error); + return (error); } mp_afs_page_write(avc, uio, acred, pager, offset) - struct vcache *avc; - struct uio *uio; - struct ucred *acred; - memory_object_t pager; - vm_offset_t offset; + struct vcache *avc; + struct uio *uio; + struct ucred *acred; + memory_object_t pager; + vm_offset_t offset; { int error; @@ -398,20 +399,20 @@ mp_afs_page_write(avc, uio, acred, pager, offset) error = EIO; } AFS_GUNLOCK(); - return(error); + return (error); } -int DO_FLUSH=1; +int DO_FLUSH = 1; mp_afs_ubcrdwr(avc, uio, ioflag, cred) - struct vcache *avc; - struct uio *uio; - int ioflag; - struct ucred *cred; + struct vcache *avc; + struct uio *uio; + int ioflag; + struct ucred *cred; { register afs_int32 code; register char *data; - afs_int32 fileBase, size, cnt=0; + afs_int32 fileBase, size, cnt = 0; afs_int32 pageBase; register afs_int32 tsize; register afs_int32 pageOffset; @@ -419,26 +420,26 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) struct vrequest treq; int rw = uio->uio_rw; int rv, flags; - int newpage=0; + int newpage = 0; vm_page_t page; afs_int32 save_resid; struct dcache *tdc; - int didFakeOpen=0; - int counter=0; + int didFakeOpen = 0; + int counter = 0; AFS_GLOCK(); afs_InitReq(&treq, cred); if (AFS_NFSXLATORREQ(cred) && rw == UIO_READ) { - if (!afs_AccessOK(avc, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) { + if (!afs_AccessOK + (avc, PRSFS_READ, &treq, + CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) { AFS_GUNLOCK(); return EACCES; } } afs_Trace4(afs_iclSetp, CM_TRACE_VMRW, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, (rw==UIO_WRITE? 1 : 0), - ICL_TYPE_LONG, uio->uio_offset, - ICL_TYPE_LONG, uio->uio_resid); + ICL_TYPE_INT32, (rw == UIO_WRITE ? 1 : 0), ICL_TYPE_LONG, + uio->uio_offset, ICL_TYPE_LONG, uio->uio_resid); code = afs_VerifyVCache(avc, &treq); if (code) { code = afs_CheckCode(code, &treq, 35); @@ -447,25 +448,26 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) } if (vType(avc) != VREG) { AFS_GUNLOCK(); - return EISDIR; /* can't read or write other things */ + return EISDIR; /* can't read or write other things */ } afs_BozonLock(&avc->pvnLock, avc); osi_FlushPages(avc, cred); /* hold bozon lock, but not basic vnode lock */ - ObtainWriteLock(&avc->lock,162); + ObtainWriteLock(&avc->lock, 162); /* adjust parameters when appending files */ if ((ioflag & IO_APPEND) && uio->uio_rw == UIO_WRITE) uio->uio_offset = avc->m.Length; /* write at EOF position */ if (uio->uio_rw == UIO_WRITE) { avc->states |= CDirty; afs_FakeOpen(avc); - didFakeOpen=1; + didFakeOpen = 1; /* * before starting any I/O, we must ensure that the file is big enough * to hold the results (since afs_putpage will be called to force * the I/O. */ size = uio->afsio_resid + uio->afsio_offset; /* new file size */ - if (size > avc->m.Length) avc->m.Length = size; /* file grew */ + if (size > avc->m.Length) + avc->m.Length = size; /* file grew */ avc->m.Date = osi_Time(); /* Set file date (for ranlib) */ if (uio->afsio_resid > PAGE_SIZE) cnt = uio->afsio_resid / PAGE_SIZE; @@ -477,26 +479,29 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) * compute the amount of data to move into this block, * based on uio->afsio_resid. */ - size = uio->afsio_resid; /* transfer size */ - fileBase = uio->afsio_offset; /* start file position */ - pageBase = fileBase & ~(PAGE_SIZE-1); /* file position of the page */ - pageOffset = fileBase & (PAGE_SIZE-1); /* start offset within page */ - tsize = PAGE_SIZE-pageOffset; /* amount left in this page */ + size = uio->afsio_resid; /* transfer size */ + fileBase = uio->afsio_offset; /* start file position */ + pageBase = fileBase & ~(PAGE_SIZE - 1); /* file position of the page */ + pageOffset = fileBase & (PAGE_SIZE - 1); /* start offset within page */ + tsize = PAGE_SIZE - pageOffset; /* amount left in this page */ /* * we'll read tsize bytes, * but first must make sure tsize isn't too big */ - if (tsize > size) tsize = size; /* don't read past end of request */ - eof = 0; /* flag telling us if we hit the EOF on the read */ + if (tsize > size) + tsize = size; /* don't read past end of request */ + eof = 0; /* flag telling us if we hit the EOF on the read */ if (uio->uio_rw == UIO_READ) { /* we're doing a read operation */ /* don't read past EOF */ if (tsize + fileBase > avc->m.Length) { tsize = avc->m.Length - fileBase; eof = 1; /* we did hit the EOF */ - if (tsize < 0) tsize = 0; /* better safe than sorry */ + if (tsize < 0) + tsize = 0; /* better safe than sorry */ } } - if (tsize <= 0) break; /* nothing to transfer, we're done */ + if (tsize <= 0) + break; /* nothing to transfer, we're done */ /* Purge dirty chunks of file if there are too many dirty chunks. * Inside the write loop, we only do this at a chunk boundary. @@ -516,28 +521,32 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); #ifdef AFS_DUX50_ENV - code = ubc_lookup(AFSTOV(avc)->v_object, pageBase, - PAGE_SIZE, PAGE_SIZE, &page, &flags, NULL); + code = + ubc_lookup(AFSTOV(avc)->v_object, pageBase, PAGE_SIZE, PAGE_SIZE, + &page, &flags, NULL); #else - code = ubc_lookup(AFSTOV(avc)->v_object, pageBase, - PAGE_SIZE, PAGE_SIZE, &page, &flags); + code = + ubc_lookup(AFSTOV(avc)->v_object, pageBase, PAGE_SIZE, PAGE_SIZE, + &page, &flags); #endif AFS_GLOCK(); - ObtainWriteLock(&avc->lock,163); + ObtainWriteLock(&avc->lock, 163); if (code) { break; } if (flags & B_NOCACHE) { /* - No page found. We should not read the page in if - 1. the write starts on a page edge (ie, pageoffset == 0) - and either - 1. we will fill the page (ie, size == PAGESIZE), or - 2. we are writing past eof + * No page found. We should not read the page in if + * 1. the write starts on a page edge (ie, pageoffset == 0) + * and either + * 1. we will fill the page (ie, size == PAGESIZE), or + * 2. we are writing past eof */ - if ((uio->uio_rw == UIO_WRITE) && - ((pageOffset == 0 && (size == PAGE_SIZE || fileBase >= avc->m.Length)))) { + if ((uio->uio_rw == UIO_WRITE) + && + ((pageOffset == 0 + && (size == PAGE_SIZE || fileBase >= avc->m.Length)))) { struct vnode *vp = AFSTOV(avc); /* we're doing a write operation past eof; no need to read it */ newpage = 1; @@ -557,13 +566,13 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) bp->b_blkno = btodb(pageBase); ReleaseWriteLock(&avc->lock); code = afs_ustrategy(bp, cred); /* do the I/O */ - ObtainWriteLock(&avc->lock,164); + ObtainWriteLock(&avc->lock, 164); AFS_GUNLOCK(); ubc_sync_iodone(bp); AFS_GLOCK(); if (code) { AFS_GUNLOCK(); - ubc_page_release(page, 0); + ubc_page_release(page, 0); AFS_GLOCK(); break; } @@ -571,53 +580,53 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) } AFS_GUNLOCK(); ubc_page_wait(page); - data = ubc_load(page, pageOffset, page_size); + data = ubc_load(page, pageOffset, page_size); AFS_GLOCK(); ReleaseWriteLock(&avc->lock); /* uiomove may page fault */ AFS_GUNLOCK(); - code = uiomove(data+pageOffset, tsize, uio); + code = uiomove(data + pageOffset, tsize, uio); ubc_unload(page, pageOffset, page_size); if (uio->uio_rw == UIO_WRITE) { - vm_offset_t toffset; - - /* Mark the page dirty and release it to avoid a deadlock - * in ubc_dirty_kluster when more than one process writes - * this page at the same time. */ - toffset = page->pg_offset; - flags |= B_DIRTY; - ubc_page_release(page, flags); - - if (cnt > 10) { - vm_page_t pl; - int kpcnt; - struct buf *bp; - - /* We released the page, so we can get a null page - * list if another thread calls the strategy routine. - */ - pl = ubc_dirty_kluster(AFSTOV(avc)->v_object, - NULL, toffset, 0, B_WANTED, FALSE, &kpcnt); - if (pl) { - bp = ubc_bufalloc(pl, 1, PAGE_SIZE, 1, B_WRITE); - bp->b_dev = 0; - bp->b_vp = AFSTOV(avc); - bp->b_blkno = btodb(pageBase); + vm_offset_t toffset; + + /* Mark the page dirty and release it to avoid a deadlock + * in ubc_dirty_kluster when more than one process writes + * this page at the same time. */ + toffset = page->pg_offset; + flags |= B_DIRTY; + ubc_page_release(page, flags); + + if (cnt > 10) { + vm_page_t pl; + int kpcnt; + struct buf *bp; + + /* We released the page, so we can get a null page + * list if another thread calls the strategy routine. + */ + pl = ubc_dirty_kluster(AFSTOV(avc)->v_object, NULL, toffset, + 0, B_WANTED, FALSE, &kpcnt); + if (pl) { + bp = ubc_bufalloc(pl, 1, PAGE_SIZE, 1, B_WRITE); + bp->b_dev = 0; + bp->b_vp = AFSTOV(avc); + bp->b_blkno = btodb(pageBase); + AFS_GLOCK(); + code = afs_ustrategy(bp, cred); /* do the I/O */ + AFS_GUNLOCK(); + ubc_sync_iodone(bp); + if (code) { AFS_GLOCK(); - code = afs_ustrategy(bp, cred); /* do the I/O */ - AFS_GUNLOCK(); - ubc_sync_iodone(bp); - if (code) { - AFS_GLOCK(); - ObtainWriteLock(&avc->lock,415); - break; - } + ObtainWriteLock(&avc->lock, 415); + break; } } + } } else { ubc_page_release(page, flags); } AFS_GLOCK(); - ObtainWriteLock(&avc->lock,165); + ObtainWriteLock(&avc->lock, 165); /* * If reading at a chunk boundary, start prefetch of next chunk. */ @@ -631,7 +640,8 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) } } counter++; - if (code) break; + if (code) + break; } if (didFakeOpen) afs_FakeClose(avc, cred); @@ -642,7 +652,7 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) afs_BozonUnlock(&avc->pvnLock, avc); if (DO_FLUSH || (!newpage && (cnt < 10))) { AFS_GUNLOCK(); - ubc_flush_dirty(AFSTOV(avc)->v_object, flags); + ubc_flush_dirty(AFSTOV(avc)->v_object, flags); AFS_GLOCK(); } @@ -668,7 +678,7 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) && !AFS_NFSXLATORREQ(cred)) { code = afs_fsync(avc, 0, cred, 0); } -out: + out: code = afs_CheckCode(code, &treq, 36); AFS_GUNLOCK(); return code; @@ -678,7 +688,7 @@ int mp_afs_ioctl(struct vnode *vp, int com, caddr_t data, int fflag, struct ucred *cred, int *retval) { - return ENOSYS; + return ENOSYS; } /* @@ -690,15 +700,15 @@ mp_afs_ioctl(struct vnode *vp, int com, caddr_t data, int fflag, */ mp_afs_mmap(avc, offset, map, addrp, len, prot, maxprot, flags, cred) - register struct vcache *avc; - vm_offset_t offset; - vm_map_t map; - vm_offset_t *addrp; - vm_size_t len; - vm_prot_t prot; - vm_prot_t maxprot; - int flags; - struct ucred *cred; + register struct vcache *avc; + vm_offset_t offset; + vm_map_t map; + vm_offset_t *addrp; + vm_size_t len; + vm_prot_t prot; + vm_prot_t maxprot; + int flags; + struct ucred *cred; { struct vp_mmap_args args; register struct vp_mmap_args *ap = &args; @@ -713,21 +723,20 @@ mp_afs_mmap(avc, offset, map, addrp, len, prot, maxprot, flags, cred) afs_InitReq(&treq, cred); code = afs_VerifyVCache(avc, &treq); if (code) { - code = afs_CheckCode(code, &treq, 37); - AFS_GUNLOCK(); - return code; + code = afs_CheckCode(code, &treq, 37); + AFS_GUNLOCK(); + return code; } afs_BozonLock(&avc->pvnLock, avc); osi_FlushPages(avc, cred); /* ensure old pages are gone */ afs_BozonUnlock(&avc->pvnLock, avc); - ObtainWriteLock(&avc->lock,166); + ObtainWriteLock(&avc->lock, 166); avc->states |= CMAPPED; ReleaseWriteLock(&avc->lock); ap->a_offset = offset; ap->a_vaddr = addrp; ap->a_size = len; - ap->a_prot = prot, - ap->a_maxprot = maxprot; + ap->a_prot = prot, ap->a_maxprot = maxprot; ap->a_flags = flags; AFS_GUNLOCK(); code = u_vp_create(map, vp->v_object, (vm_offset_t) ap); @@ -738,27 +747,28 @@ mp_afs_mmap(avc, offset, map, addrp, len, prot, maxprot, flags, cred) } -int mp_afs_getpage(vop, offset, len, protp, pl, plsz, +int +mp_afs_getpage(vop, offset, len, protp, pl, plsz, #ifdef AFS_DUX50_ENV - policy, + policy, #else - mape, addr, + mape, addr, #endif - rw, cred) - vm_ubc_object_t vop; - vm_offset_t offset; - vm_size_t len; - vm_prot_t *protp; - vm_page_t *pl; - int plsz; + rw, cred) + vm_ubc_object_t vop; + vm_offset_t offset; + vm_size_t len; + vm_prot_t *protp; + vm_page_t *pl; + int plsz; #ifdef AFS_DUX50_ENV - struct vm_policy *policy; + struct vm_policy *policy; #else - vm_map_entry_t mape; - vm_offset_t addr; + vm_map_entry_t mape; + vm_offset_t addr; #endif - int rw; - struct ucred *cred; + int rw; + struct ucred *cred; { register afs_int32 code; struct vrequest treq; @@ -767,7 +777,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz, vm_page_t *pagep; vm_offset_t off; - struct vcache *avc = VTOAFS(vop->vu_vp); + struct vcache *avc = VTOAFS(vop->vu_vp); /* first, obtain the proper lock for the VM system */ @@ -776,42 +786,45 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz, code = afs_VerifyVCache(avc, &treq); if (code) { *pl = VM_PAGE_NULL; - code = afs_CheckCode(code, &treq, 39); /* failed to get it */ + code = afs_CheckCode(code, &treq, 39); /* failed to get it */ AFS_GUNLOCK(); return code; } - + /* clean all dirty pages for this vnode */ AFS_GUNLOCK(); - ubc_flush_dirty(vop,0); + ubc_flush_dirty(vop, 0); AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); - ObtainWriteLock(&avc->lock,167); + ObtainWriteLock(&avc->lock, 167); afs_Trace4(afs_iclSetp, CM_TRACE_PAGEIN, ICL_TYPE_POINTER, avc, - ICL_TYPE_LONG, offset, ICL_TYPE_LONG, len, - ICL_TYPE_INT32, (int) rw); + ICL_TYPE_LONG, offset, ICL_TYPE_LONG, len, ICL_TYPE_INT32, + (int)rw); for (i = 0; i < pages; i++) { pagep = &pl[i]; off = offset + PAGE_SIZE * i; - if (protp) protp[i] = 0; + if (protp) + protp[i] = 0; flags = 0; ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); #ifdef AFS_DUX50_ENV - code = ubc_lookup(AFSTOV(avc)->v_object, off, - PAGE_SIZE, PAGE_SIZE, pagep, &flags, NULL); + code = + ubc_lookup(AFSTOV(avc)->v_object, off, PAGE_SIZE, PAGE_SIZE, + pagep, &flags, NULL); #else - code = ubc_lookup(AFSTOV(avc)->v_object, off, - PAGE_SIZE, PAGE_SIZE, pagep, &flags); + code = + ubc_lookup(AFSTOV(avc)->v_object, off, PAGE_SIZE, PAGE_SIZE, + pagep, &flags); #endif AFS_GLOCK(); - ObtainWriteLock(&avc->lock,168); + ObtainWriteLock(&avc->lock, 168); if (code) { goto out; } - if(flags & B_NOCACHE) { /* if (page) */ - if ((rw & B_WRITE) && (offset+len >= avc->m.Length)) { + if (flags & B_NOCACHE) { /* if (page) */ + if ((rw & B_WRITE) && (offset + len >= avc->m.Length)) { struct vnode *vp = AFSTOV(avc); /* we're doing a write operation past eof; no need to read it */ AFS_GUNLOCK(); @@ -830,7 +843,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz, bp->b_blkno = btodb(off); ReleaseWriteLock(&avc->lock); code = afs_ustrategy(bp, cred); /* do the I/O */ - ObtainWriteLock(&avc->lock,169); + ObtainWriteLock(&avc->lock, 169); AFS_GUNLOCK(); ubc_sync_iodone(bp); AFS_GLOCK(); @@ -856,7 +869,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz, } } } -out: + out: pl[i] = VM_PAGE_NULL; ReleaseWriteLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); @@ -868,14 +881,15 @@ out: } -int mp_afs_putpage(vop, pl, pcnt, flags, cred) - vm_ubc_object_t vop; - vm_page_t *pl; - int pcnt; - int flags; - struct ucred *cred; +int +mp_afs_putpage(vop, pl, pcnt, flags, cred) + vm_ubc_object_t vop; + vm_page_t *pl; + int pcnt; + int flags; + struct ucred *cred; { - register afs_int32 code=0; + register afs_int32 code = 0; struct vnode *vp = vop->vu_vp; struct vcache *avc = VTOAFS(vp); int i; @@ -890,10 +904,10 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred) if (vp->v_flag & VXLOCK) { VN_UNLOCK(vp); for (i = 0; i < pcnt; i++) { - ubc_page_release(pl[i], B_DONE|B_DIRTY); + ubc_page_release(pl[i], B_DONE | B_DIRTY); pl[i] = VM_PAGE_NULL; } - return(0); + return (0); } else { VN_UNLOCK(vp); } @@ -902,7 +916,7 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred) /* first, obtain the proper lock for the VM system */ afs_BozonLock(&avc->pvnLock, avc); - ObtainWriteLock(&avc->lock,170); + ObtainWriteLock(&avc->lock, 170); for (i = 0; i < pcnt; i++) { vm_page_t page = pl[i]; struct buf *bp; @@ -916,7 +930,7 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred) bp->b_blkno = btodb(page->pg_offset); ReleaseWriteLock(&avc->lock); code = afs_ustrategy(bp, cred); /* do the I/O */ - ObtainWriteLock(&avc->lock,171); + ObtainWriteLock(&avc->lock, 171); AFS_GUNLOCK(); ubc_sync_iodone(bp); AFS_GLOCK(); @@ -926,7 +940,7 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred) pl[i] = VM_PAGE_NULL; } } -done: + done: ReleaseWriteLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); afs_Trace2(afs_iclSetp, CM_TRACE_PAGEOUTDONE, ICL_TYPE_INT32, code, @@ -936,20 +950,22 @@ done: } -int mp_afs_swap(avc, swapop, argp) - struct vcache *avc; - vp_swap_op_t swapop; - vm_offset_t argp; +int +mp_afs_swap(avc, swapop, argp) + struct vcache *avc; + vp_swap_op_t swapop; + vm_offset_t argp; { return EIO; } -int mp_afs_syncdata(avc, flag, offset, length, cred) - struct vcache *avc; - int flag; - vm_offset_t offset; - vm_size_t length; - struct ucred *cred; +int +mp_afs_syncdata(avc, flag, offset, length, cred) + struct vcache *avc; + int flag; + vm_offset_t offset; + vm_size_t length; + struct ucred *cred; { /* NFS V3 makes this call, ignore it. We'll sync the data in afs_fsync. */ if (AFS_NFSXLATORREQ(cred)) @@ -966,90 +982,90 @@ struct buf *afs_bread_freebp = 0; * Thus we can use fake bufs (ie not from the real buffer pool). */ mp_afs_bread(vp, lbn, bpp, cred) - struct ucred *cred; - struct vnode *vp; - daddr_t lbn; - struct buf **bpp; + struct ucred *cred; + struct vnode *vp; + daddr_t lbn; + struct buf **bpp; { - int offset, fsbsize, error; - struct buf *bp; - struct iovec iov; - struct uio uio; + int offset, fsbsize, error; + struct buf *bp; + struct iovec iov; + struct uio uio; - AFS_GLOCK(); - AFS_STATCNT(afs_bread); - fsbsize = vp->v_vfsp->vfs_bsize; - offset = lbn * fsbsize; - if (afs_bread_freebp) { - bp = afs_bread_freebp; - afs_bread_freebp = 0; - } else { - bp = (struct buf *) AFS_KALLOC(sizeof(*bp)); - bp->b_un.b_addr = (caddr_t) AFS_KALLOC(fsbsize); - } + AFS_GLOCK(); + AFS_STATCNT(afs_bread); + fsbsize = vp->v_vfsp->vfs_bsize; + offset = lbn * fsbsize; + if (afs_bread_freebp) { + bp = afs_bread_freebp; + afs_bread_freebp = 0; + } else { + bp = (struct buf *)AFS_KALLOC(sizeof(*bp)); + bp->b_un.b_addr = (caddr_t) AFS_KALLOC(fsbsize); + } - iov.iov_base = bp->b_un.b_addr; - iov.iov_len = fsbsize; - uio.afsio_iov = &iov; - uio.afsio_iovcnt = 1; - uio.afsio_seg = AFS_UIOSYS; - uio.afsio_offset = offset; - uio.afsio_resid = fsbsize; - *bpp = 0; - error = afs_read(VTOAFS(vp), &uio, cred, lbn, bpp, 0); - if (error) { - afs_bread_freebp = bp; - AFS_GUNLOCK(); - return error; - } - if (*bpp) { - afs_bread_freebp = bp; - } else { - *(struct buf **)&bp->b_vp = bp; /* mark as fake */ - *bpp = bp; - } + iov.iov_base = bp->b_un.b_addr; + iov.iov_len = fsbsize; + uio.afsio_iov = &iov; + uio.afsio_iovcnt = 1; + uio.afsio_seg = AFS_UIOSYS; + uio.afsio_offset = offset; + uio.afsio_resid = fsbsize; + *bpp = 0; + error = afs_read(VTOAFS(vp), &uio, cred, lbn, bpp, 0); + if (error) { + afs_bread_freebp = bp; AFS_GUNLOCK(); - return 0; + return error; + } + if (*bpp) { + afs_bread_freebp = bp; + } else { + *(struct buf **)&bp->b_vp = bp; /* mark as fake */ + *bpp = bp; + } + AFS_GUNLOCK(); + return 0; } mp_afs_brelse(vp, bp) -struct vnode *vp; -struct buf *bp; + struct vnode *vp; + struct buf *bp; { AFS_GLOCK(); AFS_STATCNT(afs_brelse); - if ((struct buf *)bp->b_vp != bp) { /* not fake */ - brelse(bp); - } else if (afs_bread_freebp) { - AFS_KFREE(bp->b_un.b_addr, vp->v_vfsp->vfs_bsize); - AFS_KFREE(bp, sizeof(*bp)); - } else { - afs_bread_freebp = bp; - } + if ((struct buf *)bp->b_vp != bp) { /* not fake */ + brelse(bp); + } else if (afs_bread_freebp) { + AFS_KFREE(bp->b_un.b_addr, vp->v_vfsp->vfs_bsize); + AFS_KFREE(bp, sizeof(*bp)); + } else { + afs_bread_freebp = bp; + } AFS_GUNLOCK(); } mp_afs_bmap(avc, abn, anvp, anbn) - register struct vcache *avc; - afs_int32 abn, *anbn; - struct vcache **anvp; + register struct vcache *avc; + afs_int32 abn, *anbn; + struct vcache **anvp; { AFS_GLOCK(); AFS_STATCNT(afs_bmap); if (anvp) *anvp = avc; if (anbn) - *anbn = abn * (8192 / DEV_BSIZE); /* in 512 byte units */ + *anbn = abn * (8192 / DEV_BSIZE); /* in 512 byte units */ AFS_GUNLOCK(); return 0; } /* real strategy */ -mp_afs_strategy (abp) - register struct buf *abp; +mp_afs_strategy(abp) + register struct buf *abp; { register afs_int32 code; @@ -1063,47 +1079,47 @@ mp_afs_strategy (abp) mp_afs_refer(vm_ubc_object_t vop) { - VREF(vop->vu_vp); + VREF(vop->vu_vp); } mp_afs_release(vm_ubc_object_t vop) { - vrele(vop->vu_vp); + vrele(vop->vu_vp); } mp_afs_write_check(vm_ubc_object_t vop, vm_page_t pp) { - return TRUE; + return TRUE; } #ifdef AFS_DUX50_ENV int mp_afs_objtovp(vm_ubc_object_t vop, struct vnode **vp) { - *vp = vop->vu_vp; - return 0; + *vp = vop->vu_vp; + return 0; } int mp_afs_setpgstamp(vm_page_t pp, unsigned int tick) { - pp->pg_stamp = tick; - return 0; + pp->pg_stamp = tick; + return 0; } #endif struct vfs_ubcops afs_ubcops = { - mp_afs_refer, /* refer vnode */ - mp_afs_release, /* release vnode */ - mp_afs_getpage, /* get page */ - mp_afs_putpage, /* put page */ - mp_afs_write_check, /* check writablity */ + mp_afs_refer, /* refer vnode */ + mp_afs_release, /* release vnode */ + mp_afs_getpage, /* get page */ + mp_afs_putpage, /* put page */ + mp_afs_write_check, /* check writablity */ #ifdef AFS_DUX50_ENV - mp_afs_objtovp, /* get vnode pointer */ - mp_afs_setpgstamp /* set page stamp */ + mp_afs_objtovp, /* get vnode pointer */ + mp_afs_setpgstamp /* set page stamp */ #endif }; @@ -1115,17 +1131,17 @@ struct vfs_ubcops afs_ubcops = { * locked after return. */ lookupname(namep, seg, follow, dvpp, cvpp) - char *namep; /* path name */ - int seg; /* address space containing name */ - int follow; /* follow symbolic links */ - struct vnode **dvpp; /* result, containing parent vnode */ - struct vnode **cvpp; /* result, containing final component vnode */ + char *namep; /* path name */ + int seg; /* address space containing name */ + int follow; /* follow symbolic links */ + struct vnode **dvpp; /* result, containing parent vnode */ + struct vnode **cvpp; /* result, containing final component vnode */ { /* Should I use free-bee in u-area? */ struct nameidata *ndp = &u.u_nd; int error; - ndp->ni_nameiop = ((follow) ? (LOOKUP|FOLLOW) : (LOOKUP)); + ndp->ni_nameiop = ((follow) ? (LOOKUP | FOLLOW) : (LOOKUP)); ndp->ni_segflg = seg; ndp->ni_dirp = namep; error = namei(ndp); @@ -1133,6 +1149,5 @@ lookupname(namep, seg, follow, dvpp, cvpp) *dvpp = ndp->ni_dvp; if (cvpp != NULL) *cvpp = ndp->ni_vp; - return(error); + return (error); } - diff --git a/src/afs/FBSD/osi_file.c b/src/afs/FBSD/osi_file.c index 629f7f736..4ce371fde 100644 --- a/src/afs/FBSD/osi_file.c +++ b/src/afs/FBSD/osi_file.c @@ -10,7 +10,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ diff --git a/src/afs/FBSD/osi_groups.c b/src/afs/FBSD/osi_groups.c index a18da3d5c..6c6db9e9f 100644 --- a/src/afs/FBSD/osi_groups.c +++ b/src/afs/FBSD/osi_groups.c @@ -21,25 +21,19 @@ #include #endif -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset); + afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset); static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent); + afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent); #ifdef AFS_FBSD50_ENV /* @@ -67,7 +61,8 @@ Afs_xsetgroups(struct thread *td, struct setgroups_args *uap) code = afs_InitReq(&treq, cr); AFS_GUNLOCK(); crfree(cr); - if (code) return setgroups(td, uap); /* afs has shut down */ + if (code) + return setgroups(td, uap); /* afs has shut down */ code = setgroups(td, uap); /* Note that if there is a pag already in the new groups we don't @@ -89,35 +84,36 @@ Afs_xsetgroups(struct thread *td, struct setgroups_args *uap) #else /* FBSD50 */ int Afs_xsetgroups(p, args, retval) - struct proc *p; - void *args; - int *retval; + struct proc *p; + void *args; + int *retval; { int code = 0; struct vrequest treq; struct ucred *cr; - cr=crdup(p->p_cred->pc_ucred); + cr = crdup(p->p_cred->pc_ucred); AFS_STATCNT(afs_xsetgroups); AFS_GLOCK(); - + code = afs_InitReq(&treq, cr); AFS_GUNLOCK(); crfree(cr); - if (code) return setgroups(p, args, retval); /* afs has shut down */ + if (code) + return setgroups(p, args, retval); /* afs has shut down */ code = setgroups(p, args, retval); /* Note that if there is a pag already in the new groups we don't * overwrite it with the old pag. */ - cr=crdup(p->p_cred->pc_ucred); + cr = crdup(p->p_cred->pc_ucred); if (PagInCred(cr) == NOPAG) { if (((treq.uid >> 24) & 0xff) == 'A') { AFS_GLOCK(); /* we've already done a setpag, so now we redo it */ - AddPag(p, treq.uid, &cr ); + AddPag(p, treq.uid, &cr); AFS_GUNLOCK(); } } @@ -129,7 +125,7 @@ Afs_xsetgroups(p, args, retval) int setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue, - afs_uint32 *newpag, int change_parent) + afs_uint32 * newpag, int change_parent) { gid_t gidset[NGROUPS]; int ngroups, code; @@ -142,12 +138,12 @@ setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue, if (ngroups + 2 > NGROUPS) { return (E2BIG); } - for (j = ngroups -1; j >= 1; j--) { - gidset[j+2] = gidset[j]; + for (j = ngroups - 1; j >= 1; j--) { + gidset[j + 2] = gidset[j]; } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]); code = afs_setgroups(proc, cred, ngroups, gidset, change_parent); return code; @@ -155,10 +151,7 @@ setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue, static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset) +afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset) { int ngrps, savengrps; gid_t *gp; @@ -167,18 +160,14 @@ afs_getgroups( savengrps = ngrps = MIN(ngroups, cred->cr_ngroups); gp = cred->cr_groups; while (ngrps--) - *gidset++ = *gp++; + *gidset++ = *gp++; return savengrps; } static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent) { #ifndef AFS_FBSD50_ENV int ngrps; @@ -200,14 +189,14 @@ afs_setgroups( *gp++ = *gidset++; if (change_parent) { crhold(cr); - oldcr=proc->p_pptr->p_cred->pc_ucred; - proc->p_pptr->p_cred->pc_ucred=cr; + oldcr = proc->p_pptr->p_cred->pc_ucred; + proc->p_pptr->p_cred->pc_ucred = cr; crfree(oldcr); } crhold(cr); - oldcr=proc->p_cred->pc_ucred; - proc->p_cred->pc_ucred=cr; + oldcr = proc->p_cred->pc_ucred; + proc->p_cred->pc_ucred = cr; crfree(oldcr); #endif - return(0); + return (0); } diff --git a/src/afs/FBSD/osi_inode.c b/src/afs/FBSD/osi_inode.c index d57a822d3..8e97f120b 100644 --- a/src/afs/FBSD/osi_inode.c +++ b/src/afs/FBSD/osi_inode.c @@ -16,12 +16,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ #include "afs/osi_inode.h" -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include #include #include @@ -52,29 +53,30 @@ getinode(fs, dev, inode, ipp, perror) #else simple_lock(&mountlist_slock); #endif - if (mp = TAILQ_FIRST(&mountlist)) do { - /* - * XXX Also do the test for MFS - */ + if (mp = TAILQ_FIRST(&mountlist)) + do { + /* + * XXX Also do the test for MFS + */ #undef m_data #undef m_next - if (mp->mnt_stat.f_type == MOUNT_UFS) { - ump = VFSTOUFS(mp); - if (ump->um_fs == NULL) - break; - if (ump->um_dev == dev) { - fs = ump->um_mountp; + if (mp->mnt_stat.f_type == MOUNT_UFS) { + ump = VFSTOUFS(mp); + if (ump->um_fs == NULL) + break; + if (ump->um_dev == dev) { + fs = ump->um_mountp; + } } - } - mp = TAILQ_NEXT(mp, mnt_list); - } while (mp != TAILQ_FIRST(&mountlist)); + mp = TAILQ_NEXT(mp, mnt_list); + } while (mp != TAILQ_FIRST(&mountlist)); #if defined(AFS_FBSD50_ENV) - mtx_unlock(&mountlist_mtx); + mtx_unlock(&mountlist_mtx); #else - simple_unlock(&mountlist_slock); + simple_unlock(&mountlist_slock); #endif if (!fs) - return(ENXIO); + return (ENXIO); } #if defined(AFS_FBSD50_ENV) code = VFS_VGET(fs, inode, 0, &vp); @@ -83,10 +85,10 @@ getinode(fs, dev, inode, ipp, perror) #endif if (code != 0) { *perror = BAD_IGET; - return code; + return code; } else { *ipp = VTOI(vp); - return(0); + return (0); } } @@ -106,22 +108,22 @@ igetinode(vfsp, dev, inode, ipp, perror) AFS_STATCNT(igetinode); if ((code = getinode(vfsp, dev, inode, &ip, perror)) != 0) { - return(code); + return (code); } if (ip->i_mode == 0) { /* Not an allocated inode */ vput(ITOV(ip)); - return(ENOENT); + return (ENOENT); } - if (ip->i_nlink == 0 || (ip->i_mode&IFMT) != IFREG) { + if (ip->i_nlink == 0 || (ip->i_mode & IFMT) != IFREG) { vput(ITOV(ip)); - return(ENOENT); + return (ENOENT); } *ipp = ip; - return(0); + return (0); } #if 0 @@ -132,73 +134,73 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval) long *retval; long dev, near_inode, param1, param2, param3, param4; { - int dummy, err=0; + int dummy, err = 0; struct inode *ip, *newip; register int code; struct vnode *vp; - + AFS_STATCNT(afs_syscall_icreate); - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = getinode(0, (dev_t)dev, 2, &ip, &dummy); + code = getinode(0, (dev_t) dev, 2, &ip, &dummy); if (code) { - return(ENOENT); + return (ENOENT); } - code = ialloc(ip, (ino_t)near_inode, 0, &newip); + code = ialloc(ip, (ino_t) near_inode, 0, &newip); iput(ip); if (code) { - return(code); + return (code); } IN_LOCK(newip); - newip->i_flag |= IACC|IUPD|ICHG; - + newip->i_flag |= IACC | IUPD | ICHG; + newip->i_nlink = 1; newip->i_mode = IFREG; - + IN_UNLOCK(newip); vp = ITOV(newip); VN_LOCK(vp); vp->v_type = VREG; VN_UNLOCK(vp); - + /* - if ( !vp->v_object) - { - extern struct vfs_ubcops ufs_ubcops; - extern struct vm_ubc_object* ubc_object_allocate(); - struct vm_ubc_object* vop; - vop = ubc_object_allocate(&vp, &ufs_ubcops, - vp->v_mount->m_funnel); - VN_LOCK(vp); - vp->v_object = vop; - VN_UNLOCK(vp); - } - */ - + * if ( !vp->v_object) + * { + * extern struct vfs_ubcops ufs_ubcops; + * extern struct vm_ubc_object* ubc_object_allocate(); + * struct vm_ubc_object* vop; + * vop = ubc_object_allocate(&vp, &ufs_ubcops, + * vp->v_mount->m_funnel); + * VN_LOCK(vp); + * vp->v_object = vop; + * VN_UNLOCK(vp); + * } + */ + IN_LOCK(newip); /* newip->i_flags |= IC_XUID|IC_XGID; */ /* newip->i_flags &= ~IC_PROPLIST; */ newip->i_vicep1 = param1; - if (param2 == 0x1fffffff/*INODESPECIAL*/) { + if (param2 == 0x1fffffff /*INODESPECIAL*/) { newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3)); - newip->i_vicep3a = (u_short)(param3 >> 16); - newip->i_vicep3b = (u_short)param3; + newip->i_vicep3a = (u_short) (param3 >> 16); + newip->i_vicep3b = (u_short) param3; } else { - newip->i_vicep2 = (((param2 >> 16) & 0x1f) << 27) + - (((param4 >> 16) & 0x1f) << 22) + - (param3 & 0x3fffff); - newip->i_vicep3a = (u_short)param4; - newip->i_vicep3b = (u_short)param2; + newip->i_vicep2 = + (((param2 >> 16) & 0x1f) << 27) + + (((param4 >> 16) & 0x1f) << 22) + (param3 & 0x3fffff); + newip->i_vicep3a = (u_short) param4; + newip->i_vicep3b = (u_short) param2; } newip->i_vicemagic = VICEMAGIC; - + *retval = newip->i_number; IN_UNLOCK(newip); iput(newip); - return(code); + return (code); } @@ -214,31 +216,31 @@ afs_syscall_iopen(dev, inode, usrmod, retval) int fd; extern struct fileops vnops; register int code; - + AFS_STATCNT(afs_syscall_iopen); - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy); + code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy); if (code) { - return(code); + return (code); } if ((code = falloc(curproc, &fp, &fd)) != 0) { iput(ip); - return(code); + return (code); } IN_UNLOCK(ip); - + /* FreeBSD doesn't do much mp stuff yet :( */ /* FP_LOCK(fp); */ fp->f_flag = (usrmod) & FMASK; fp->f_type = DTYPE_VNODE; fp->f_ops = &vnops; - fp->f_data = (caddr_t)ITOV(ip); - + fp->f_data = (caddr_t) ITOV(ip); + /* FP_UNLOCK(fp); */ - return(0); + return (0); } @@ -255,18 +257,18 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount) int dummy; struct inode *ip; register int code; - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy); + code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy); if (code) { - return(code); + return (code); } if (!IS_VICEMAGIC(ip)) { - return(EPERM); + return (EPERM); } else if (ip->i_vicep1 != inode_p1) { - return(ENXIO); + return (ENXIO); } ip->i_nlink += amount; if (ip->i_nlink == 0) { @@ -274,7 +276,7 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount) } ip->i_flag |= ICHG; iput(ip); - return(0); + return (0); } #else int @@ -282,7 +284,7 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval) long *retval; long dev, near_inode, param1, param2, param3, param4; { - return EOPNOTSUPP; + return EOPNOTSUPP; } int @@ -290,14 +292,13 @@ afs_syscall_iopen(dev, inode, usrmod, retval) long *retval; int dev, inode, usrmod; { - return EOPNOTSUPP; + return EOPNOTSUPP; } int afs_syscall_iincdec(dev, inode, inode_p1, amount) int dev, inode, inode_p1, amount; { - return EOPNOTSUPP; + return EOPNOTSUPP; } #endif - diff --git a/src/afs/FBSD/osi_inode.h b/src/afs/FBSD/osi_inode.h index 39c706fa1..d63526c95 100644 --- a/src/afs/FBSD/osi_inode.h +++ b/src/afs/FBSD/osi_inode.h @@ -46,7 +46,7 @@ #define di_vicep2 di_gid #define di_vicep3a di_u.oldids[0] #define di_vicep3b di_u.oldids[1] -#define di_vicep4 di_spare[1] /* not used */ +#define di_vicep4 di_spare[1] /* not used */ /* * Macros for handling inode numbers: diff --git a/src/afs/FBSD/osi_machdep.h b/src/afs/FBSD/osi_machdep.h index 694f0e583..d4f6be916 100644 --- a/src/afs/FBSD/osi_machdep.h +++ b/src/afs/FBSD/osi_machdep.h @@ -64,7 +64,7 @@ extern struct lock afs_global_lock; #define simple_unlock(x) mtx_unlock(x) #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \ vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(cred),(aresid), curthread) -extern struct thread * afs_global_owner; +extern struct thread *afs_global_owner; #define AFS_GLOCK() \ do { \ osi_Assert(curthread); \ @@ -87,7 +87,7 @@ extern struct thread * afs_global_owner; #define getpid() curproc #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \ vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc) -extern struct proc * afs_global_owner; +extern struct proc *afs_global_owner; #define AFS_GLOCK() \ do { \ osi_Assert(curproc); \ diff --git a/src/afs/FBSD/osi_misc.c b/src/afs/FBSD/osi_misc.c index 21a996779..0df25e517 100644 --- a/src/afs/FBSD/osi_misc.c +++ b/src/afs/FBSD/osi_misc.c @@ -17,7 +17,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ @@ -59,7 +60,7 @@ osi_lookupname(char *aname, enum uio_seg seg, int followlink, flags |= FOLLOW; else flags |= NOFOLLOW; - /* if (dirvpp) flags|=WANTPARENT;*//* XXX LOCKPARENT? */ + /* if (dirvpp) flags|=WANTPARENT; *//* XXX LOCKPARENT? */ NDINIT(&n, LOOKUP, flags, seg, aname, curproc); if (error = namei(&n)) return error; diff --git a/src/afs/FBSD/osi_module.c b/src/afs/FBSD/osi_module.c index f12dc22a9..ecc17a620 100644 --- a/src/afs/FBSD/osi_module.c +++ b/src/afs/FBSD/osi_module.c @@ -11,7 +11,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -45,8 +46,8 @@ afs_module_handler(module_t mod, int what, void *arg) error = -1; break; } - if (sysent[AFS_SYSCALL].sy_call != nosys && - sysent[AFS_SYSCALL].sy_call != lkmnosys) { + if (sysent[AFS_SYSCALL].sy_call != nosys + && sysent[AFS_SYSCALL].sy_call != lkmnosys) { printf("AFS_SYSCALL in use. aborting\n"); error = -1; break; @@ -101,4 +102,5 @@ static moduledata_t afs_mod = { afs_module_handler, &afs_mod }; + DECLARE_MODULE(afs, afs_mod, SI_SUB_VFS, SI_ORDER_MIDDLE); diff --git a/src/afs/FBSD/osi_prototypes.h b/src/afs/FBSD/osi_prototypes.h index d2b303613..a798d2f5b 100644 --- a/src/afs/FBSD/osi_prototypes.h +++ b/src/afs/FBSD/osi_prototypes.h @@ -19,7 +19,7 @@ extern afs_rwlock_t afs_xosi; /* osi_misc.c */ extern int osi_lookupname(char *aname, enum uio_seg seg, int followlink, - struct vnode **dirvpp, struct vnode **vpp); + struct vnode **dirvpp, struct vnode **vpp); /* osi_vfsops.c */ extern int afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p); diff --git a/src/afs/FBSD/osi_sleep.c b/src/afs/FBSD/osi_sleep.c index f4d8ba5fa..97d270727 100644 --- a/src/afs/FBSD/osi_sleep.c +++ b/src/afs/FBSD/osi_sleep.c @@ -11,7 +11,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ diff --git a/src/afs/FBSD/osi_vfsops.c b/src/afs/FBSD/osi_vfsops.c index 03cc594c8..249e9fc03 100644 --- a/src/afs/FBSD/osi_vfsops.c +++ b/src/afs/FBSD/osi_vfsops.c @@ -1,7 +1,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include /* Standard vendor system headers */ #include /* Afs-based standard headers */ diff --git a/src/afs/FBSD/osi_vm.c b/src/afs/FBSD/osi_vm.c index 5d7440633..e645e0996 100644 --- a/src/afs/FBSD/osi_vm.c +++ b/src/afs/FBSD/osi_vm.c @@ -21,11 +21,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include #include #include @@ -47,7 +48,8 @@ RCSID("$Header$"); * * OSF/1 Locking: VN_LOCK has been called. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { struct vm_object *obj; struct vnode *vp; @@ -65,16 +67,16 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) vp = AFSTOV(avc); simple_lock(&vp->v_interlock); if (VOP_GETVOBJECT(vp, &obj) == 0) { - vm_object_page_remove(obj, 0, 0, FALSE); + vm_object_page_remove(obj, 0, 0, FALSE); #if 0 - if (obj->ref_count == 0) { - vgonel(vp,curproc); - simple_lock(&vp->v_interlock); - vp->v_tag=VT_AFS; - SetAfsVnode(vp); - } + if (obj->ref_count == 0) { + vgonel(vp, curproc); + simple_lock(&vp->v_interlock); + vp->v_tag = VT_AFS; + SetAfsVnode(vp); + } #endif - } + } simple_unlock(&vp->v_interlock); AFS_GLOCK(); @@ -86,25 +88,27 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { struct vnode *vp; struct vm_object *obj; - int anyio,tries; + int anyio, tries; ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); - tries=5; + tries = 5; vp = AFSTOV(avc); do { - anyio=0; + anyio = 0; simple_lock(&vp->v_interlock); - if (VOP_GETVOBJECT(vp, &obj) == 0 && - (obj->flags & OBJ_MIGHTBEDIRTY)) { + if (VOP_GETVOBJECT(vp, &obj) == 0 && (obj->flags & OBJ_MIGHTBEDIRTY)) { #ifdef AFS_FBSD50_ENV if (!vget(vp, LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY, curthread)) { #else - if (!vget(vp, LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curproc)) { + if (!vget + (vp, LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, + curproc)) { #endif if (VOP_GETVOBJECT(vp, &obj) == 0) { vm_object_page_clean(obj, 0, 0, OBJPC_SYNC); @@ -116,7 +120,7 @@ void osi_VM_StoreAllSegments(struct vcache *avc) simple_unlock(&vp->v_interlock); } while (anyio && (--tries > 0)); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,94); + ObtainWriteLock(&avc->lock, 94); } /* Try to invalidate pages, for "fs flush" or "fs flushv"; or @@ -128,7 +132,8 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * Since we drop and re-obtain the lock, we can't guarantee that there won't * be some pages around when we return, newly created by concurrent activity. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { struct vnode *vp; struct vm_object *obj; @@ -139,14 +144,15 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) tries = 5; vp = AFSTOV(avc); do { - anyio=0; + anyio = 0; simple_lock(&vp->v_interlock); - if (VOP_GETVOBJECT(vp, &obj) == 0 && - (obj->flags & OBJ_MIGHTBEDIRTY)) { + if (VOP_GETVOBJECT(vp, &obj) == 0 && (obj->flags & OBJ_MIGHTBEDIRTY)) { #ifdef AFS_FBSD50_ENV if (!vget(vp, LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY, curthread)) { #else - if (!vget(vp, LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curproc)) { + if (!vget + (vp, LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, + curproc)) { #endif if (VOP_GETVOBJECT(vp, &obj) == 0) { vm_object_page_clean(obj, 0, 0, OBJPC_SYNC); @@ -162,16 +168,17 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) vm_object_page_remove(obj, 0, 0, FALSE); } simple_unlock(&vp->v_interlock); - /*vinvalbuf(AFSTOV(avc),0, NOCRED, curproc, 0,0);*/ + /*vinvalbuf(AFSTOV(avc),0, NOCRED, curproc, 0,0); */ AFS_GLOCK(); - ObtainWriteLock(&avc->lock,59); + ObtainWriteLock(&avc->lock, 59); } /* Purge VM for a file when its callback is revoked. * * Locking: No lock is held, not even the global lock. */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { struct vnode *vp; struct vm_object *obj; @@ -182,7 +189,7 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) vm_object_page_remove(obj, 0, 0, FALSE); } simple_unlock(&vp->v_interlock); - /*vinvalbuf(AFSTOV(avc),0, NOCRED, curproc, 0,0);*/ + /*vinvalbuf(AFSTOV(avc),0, NOCRED, curproc, 0,0); */ } /* Purge pages beyond end-of-file, when truncating a file. @@ -191,7 +198,8 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * activeV is raised. This is supposed to block pageins, but at present * it only works on Solaris. */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { vnode_pager_setsize(AFSTOV(avc), alen); } diff --git a/src/afs/FBSD/osi_vnodeops.c b/src/afs/FBSD/osi_vnodeops.c index 737f2cc96..45186a19a 100644 --- a/src/afs/FBSD/osi_vnodeops.c +++ b/src/afs/FBSD/osi_vnodeops.c @@ -1,11 +1,12 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); -#include /* Standard vendor system headers */ -#include /* Afs-based standard headers */ -#include /* statistics */ +#include /* Standard vendor system headers */ +#include /* Afs-based standard headers */ +#include /* statistics */ #include #include #ifndef AFS_FBSD50_ENV @@ -58,54 +59,54 @@ int afs_vop_advlock(struct vop_advlock_args *); /* Global vfs data structures for AFS. */ vop_t **afs_vnodeop_p; struct vnodeopv_entry_desc afs_vnodeop_entries[] = { - { &vop_default_desc, (vop_t *) vop_eopnotsupp }, - { &vop_access_desc, (vop_t *) afs_vop_access }, /* access */ - { &vop_advlock_desc, (vop_t *) afs_vop_advlock }, /* advlock */ - { &vop_bmap_desc, (vop_t *) afs_vop_bmap }, /* bmap */ + {&vop_default_desc, (vop_t *) vop_eopnotsupp}, + {&vop_access_desc, (vop_t *) afs_vop_access}, /* access */ + {&vop_advlock_desc, (vop_t *) afs_vop_advlock}, /* advlock */ + {&vop_bmap_desc, (vop_t *) afs_vop_bmap}, /* bmap */ #ifndef AFS_FBSD50_ENV - { &vop_bwrite_desc, (vop_t *) vop_stdbwrite }, + {&vop_bwrite_desc, (vop_t *) vop_stdbwrite}, #endif - { &vop_close_desc, (vop_t *) afs_vop_close }, /* close */ - { &vop_createvobject_desc, (vop_t *) vop_stdcreatevobject }, - { &vop_destroyvobject_desc, (vop_t *) vop_stddestroyvobject }, - { &vop_create_desc, (vop_t *) afs_vop_create }, /* create */ - { &vop_fsync_desc, (vop_t *) afs_vop_fsync }, /* fsync */ - { &vop_getattr_desc, (vop_t *) afs_vop_getattr }, /* getattr */ - { &vop_getpages_desc, (vop_t *) afs_vop_getpages }, /* read */ - { &vop_getvobject_desc, (vop_t *) vop_stdgetvobject }, - { &vop_putpages_desc, (vop_t *) afs_vop_putpages }, /* write */ - { &vop_inactive_desc, (vop_t *) afs_vop_inactive }, /* inactive */ - { &vop_islocked_desc, (vop_t *) afs_vop_islocked }, /* islocked */ - { &vop_lease_desc, (vop_t *) vop_null }, - { &vop_link_desc, (vop_t *) afs_vop_link }, /* link */ - { &vop_lock_desc, (vop_t *) afs_vop_lock }, /* lock */ - { &vop_lookup_desc, (vop_t *) afs_vop_lookup }, /* lookup */ - { &vop_mkdir_desc, (vop_t *) afs_vop_mkdir }, /* mkdir */ - { &vop_mknod_desc, (vop_t *) afs_vop_mknod }, /* mknod */ + {&vop_close_desc, (vop_t *) afs_vop_close}, /* close */ + {&vop_createvobject_desc, (vop_t *) vop_stdcreatevobject}, + {&vop_destroyvobject_desc, (vop_t *) vop_stddestroyvobject}, + {&vop_create_desc, (vop_t *) afs_vop_create}, /* create */ + {&vop_fsync_desc, (vop_t *) afs_vop_fsync}, /* fsync */ + {&vop_getattr_desc, (vop_t *) afs_vop_getattr}, /* getattr */ + {&vop_getpages_desc, (vop_t *) afs_vop_getpages}, /* read */ + {&vop_getvobject_desc, (vop_t *) vop_stdgetvobject}, + {&vop_putpages_desc, (vop_t *) afs_vop_putpages}, /* write */ + {&vop_inactive_desc, (vop_t *) afs_vop_inactive}, /* inactive */ + {&vop_islocked_desc, (vop_t *) afs_vop_islocked}, /* islocked */ + {&vop_lease_desc, (vop_t *) vop_null}, + {&vop_link_desc, (vop_t *) afs_vop_link}, /* link */ + {&vop_lock_desc, (vop_t *) afs_vop_lock}, /* lock */ + {&vop_lookup_desc, (vop_t *) afs_vop_lookup}, /* lookup */ + {&vop_mkdir_desc, (vop_t *) afs_vop_mkdir}, /* mkdir */ + {&vop_mknod_desc, (vop_t *) afs_vop_mknod}, /* mknod */ #ifndef AFS_FBSD50_ENV - { &vop_mmap_desc, (vop_t *) afs_vop_mmap }, /* mmap */ + {&vop_mmap_desc, (vop_t *) afs_vop_mmap}, /* mmap */ #endif - { &vop_open_desc, (vop_t *) afs_vop_open }, /* open */ - { &vop_poll_desc, (vop_t *) afs_vop_poll }, /* select */ - { &vop_print_desc, (vop_t *) afs_vop_print }, /* print */ - { &vop_read_desc, (vop_t *) afs_vop_read }, /* read */ - { &vop_readdir_desc, (vop_t *) afs_vop_readdir }, /* readdir */ - { &vop_readlink_desc, (vop_t *) afs_vop_readlink }, /* readlink */ - { &vop_reclaim_desc, (vop_t *) afs_vop_reclaim }, /* reclaim */ - { &vop_remove_desc, (vop_t *) afs_vop_remove }, /* remove */ - { &vop_rename_desc, (vop_t *) afs_vop_rename }, /* rename */ - { &vop_rmdir_desc, (vop_t *) afs_vop_rmdir }, /* rmdir */ - { &vop_setattr_desc, (vop_t *) afs_vop_setattr }, /* setattr */ - { &vop_strategy_desc, (vop_t *) afs_vop_strategy }, /* strategy */ - { &vop_symlink_desc, (vop_t *) afs_vop_symlink }, /* symlink */ - { &vop_unlock_desc, (vop_t *) afs_vop_unlock }, /* unlock */ - { &vop_write_desc, (vop_t *) afs_vop_write }, /* write */ - { &vop_ioctl_desc, (vop_t *) afs_vop_ioctl }, /* XXX ioctl */ - /*{ &vop_seek_desc, afs_vop_seek },*/ /* seek */ - { NULL, NULL } + {&vop_open_desc, (vop_t *) afs_vop_open}, /* open */ + {&vop_poll_desc, (vop_t *) afs_vop_poll}, /* select */ + {&vop_print_desc, (vop_t *) afs_vop_print}, /* print */ + {&vop_read_desc, (vop_t *) afs_vop_read}, /* read */ + {&vop_readdir_desc, (vop_t *) afs_vop_readdir}, /* readdir */ + {&vop_readlink_desc, (vop_t *) afs_vop_readlink}, /* readlink */ + {&vop_reclaim_desc, (vop_t *) afs_vop_reclaim}, /* reclaim */ + {&vop_remove_desc, (vop_t *) afs_vop_remove}, /* remove */ + {&vop_rename_desc, (vop_t *) afs_vop_rename}, /* rename */ + {&vop_rmdir_desc, (vop_t *) afs_vop_rmdir}, /* rmdir */ + {&vop_setattr_desc, (vop_t *) afs_vop_setattr}, /* setattr */ + {&vop_strategy_desc, (vop_t *) afs_vop_strategy}, /* strategy */ + {&vop_symlink_desc, (vop_t *) afs_vop_symlink}, /* symlink */ + {&vop_unlock_desc, (vop_t *) afs_vop_unlock}, /* unlock */ + {&vop_write_desc, (vop_t *) afs_vop_write}, /* write */ + {&vop_ioctl_desc, (vop_t *) afs_vop_ioctl}, /* XXX ioctl */ + /*{ &vop_seek_desc, afs_vop_seek }, *//* seek */ + {NULL, NULL} }; struct vnodeopv_desc afs_vnodeop_opv_desc = - { &afs_vnodeop_p, afs_vnodeop_entries }; + { &afs_vnodeop_p, afs_vnodeop_entries }; #define GETNAME() \ struct componentname *cnp = ap->a_cnp; \ @@ -120,24 +121,24 @@ struct vnodeopv_desc afs_vnodeop_opv_desc = #ifdef AFS_FBSD50_ENV #define a_p a_td #endif - + int afs_vop_lookup(ap) - struct vop_lookup_args /* { - struct vnodeop_desc * a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - } */ *ap; + struct vop_lookup_args /* { + * struct vnodeop_desc * a_desc; + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * } */ *ap; { int error; struct vcache *vcp; struct vnode *vp, *dvp; register int flags = ap->a_cnp->cn_flags; - int lockparent; /* 1 => lockparent flag is set */ - int wantparent; /* 1 => wantparent or lockparent flag */ + int lockparent; /* 1 => lockparent flag is set */ + int wantparent; /* 1 => wantparent or lockparent flag */ #ifdef AFS_FBSD50_ENV struct thread *p = ap->a_cnp->cn_thread; #else @@ -146,7 +147,7 @@ afs_vop_lookup(ap) GETNAME(); lockparent = flags & LOCKPARENT; - wantparent = flags & (LOCKPARENT|WANTPARENT); + wantparent = flags & (LOCKPARENT | WANTPARENT); if (ap->a_dvp->v_type != VDIR) { *ap->a_vpp = 0; @@ -154,16 +155,16 @@ afs_vop_lookup(ap) return ENOTDIR; } dvp = ap->a_dvp; - if (flags & ISDOTDOT) - VOP_UNLOCK(dvp, 0, p); + if (flags & ISDOTDOT) + VOP_UNLOCK(dvp, 0, p); AFS_GLOCK(); error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred); AFS_GUNLOCK(); if (error) { - if (flags & ISDOTDOT) - VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p); - if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) && - (flags & ISLASTCN) && error == ENOENT) + if (flags & ISDOTDOT) + VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p); + if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) + && (flags & ISLASTCN) && error == ENOENT) error = EJUSTRETURN; if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN)) cnp->cn_flags |= SAVENAME; @@ -171,34 +172,34 @@ afs_vop_lookup(ap) *ap->a_vpp = 0; return (error); } - vp = AFSTOV(vcp); /* always get a node if no error */ + vp = AFSTOV(vcp); /* always get a node if no error */ /* The parent directory comes in locked. We unlock it on return - unless the caller wants it left locked. - we also always return the vnode locked. */ + * unless the caller wants it left locked. + * we also always return the vnode locked. */ if (flags & ISDOTDOT) { vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - /* always return the child locked */ - if (lockparent && (flags & ISLASTCN) && - (error = vn_lock(dvp, LK_EXCLUSIVE, p))) { - vput(vp); - DROPNAME(); - return (error); - } + /* always return the child locked */ + if (lockparent && (flags & ISLASTCN) + && (error = vn_lock(dvp, LK_EXCLUSIVE, p))) { + vput(vp); + DROPNAME(); + return (error); + } } else if (vp == dvp) { /* they're the same; afs_lookup() already ref'ed the leaf. - It came in locked, so we don't need to ref OR lock it */ + * It came in locked, so we don't need to ref OR lock it */ } else { if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(dvp, 0, p); /* done with parent. */ + VOP_UNLOCK(dvp, 0, p); /* done with parent. */ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); - /* always return the child locked */ + /* always return the child locked */ } *ap->a_vpp = vp; - if ((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN)) || - (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))) + if ((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN)) + || (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))) cnp->cn_flags |= SAVENAME; DROPNAME(); @@ -207,12 +208,12 @@ afs_vop_lookup(ap) int afs_vop_create(ap) - struct vop_create_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap; + struct vop_create_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * } */ *ap; { int error = 0; struct vcache *vcp; @@ -225,20 +226,21 @@ afs_vop_create(ap) GETNAME(); AFS_GLOCK(); - error = afs_create(VTOAFS(dvp), name, ap->a_vap, ap->a_vap->va_vaflags & VA_EXCLUSIVE? EXCL : NONEXCL, - ap->a_vap->va_mode, &vcp, - cnp->cn_cred); + error = + afs_create(VTOAFS(dvp), name, ap->a_vap, + ap->a_vap->va_vaflags & VA_EXCLUSIVE ? EXCL : NONEXCL, + ap->a_vap->va_mode, &vcp, cnp->cn_cred); AFS_GUNLOCK(); if (error) { DROPNAME(); - return(error); + return (error); } if (vcp) { *ap->a_vpp = AFSTOV(vcp); - vn_lock(AFSTOV(vcp), LK_EXCLUSIVE| LK_RETRY, p); - } - else *ap->a_vpp = 0; + vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, p); + } else + *ap->a_vpp = 0; DROPNAME(); return error; @@ -246,49 +248,50 @@ afs_vop_create(ap) int afs_vop_mknod(ap) - struct vop_mknod_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap; + struct vop_mknod_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * } */ *ap; { - return(ENODEV); + return (ENODEV); } #if 0 -static int validate_vops(struct vnode *vp, int after) +static int +validate_vops(struct vnode *vp, int after) { - int ret=0; - struct vnodeopv_entry_desc *this; - for (this=afs_vnodeop_entries; this->opve_op; this++) { + int ret = 0; + struct vnodeopv_entry_desc *this; + for (this = afs_vnodeop_entries; this->opve_op; this++) { if (vp->v_op[this->opve_op->vdesc_offset] != this->opve_impl) { - if (!ret) { - printf("v_op %d ", after); - vprint("check", vp); - } - ret=1; - printf("For oper %d (%s), func is %p, not %p", - this->opve_op->vdesc_offset, this->opve_op->vdesc_name, - vp->v_op[this->opve_op->vdesc_offset], this->opve_impl); - } - } - return ret; -} + if (!ret) { + printf("v_op %d ", after); + vprint("check", vp); + } + ret = 1; + printf("For oper %d (%s), func is %p, not %p", + this->opve_op->vdesc_offset, this->opve_op->vdesc_name, + vp->v_op[this->opve_op->vdesc_offset], this->opve_impl); + } + } + return ret; +} #endif int afs_vop_open(ap) - struct vop_open_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_open_args /* { + * struct vnode *a_vp; + * int a_mode; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int error; int bad; struct vcache *vc = VTOAFS(ap->a_vp); - bad=0; + bad = 0; AFS_GLOCK(); error = afs_open(&vc, ap->a_mode, ap->a_cred); #ifdef DIAGNOSTIC @@ -304,22 +307,22 @@ afs_vop_open(ap) int afs_vop_close(ap) - struct vop_close_args /* { - struct vnode *a_vp; - int a_fflag; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_close_args /* { + * struct vnode *a_vp; + * int a_fflag; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; struct vcache *avc = VTOAFS(ap->a_vp); AFS_GLOCK(); - if (ap->a_cred) - code = afs_close(avc, ap->a_fflag, ap->a_cred); + if (ap->a_cred) + code = afs_close(avc, ap->a_fflag, ap->a_cred); else - code = afs_close(avc, ap->a_fflag, &afs_osi_cred); + code = afs_close(avc, ap->a_fflag, &afs_osi_cred); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ afs_BozonUnlock(&avc->pvnLock, avc); AFS_GUNLOCK(); return code; @@ -327,12 +330,12 @@ afs_vop_close(ap) int afs_vop_access(ap) - struct vop_access_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_access_args /* { + * struct vnode *a_vp; + * int a_mode; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; AFS_GLOCK(); @@ -340,14 +343,15 @@ afs_vop_access(ap) AFS_GUNLOCK(); return code; } + int afs_vop_getattr(ap) - struct vop_getattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_getattr_args /* { + * struct vnode *a_vp; + * struct vattr *a_vap; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; AFS_GLOCK(); @@ -355,49 +359,53 @@ afs_vop_getattr(ap) AFS_GUNLOCK(); return code; } + int afs_vop_setattr(ap) - struct vop_setattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_setattr_args /* { + * struct vnode *a_vp; + * struct vattr *a_vap; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; AFS_GLOCK(); code = afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred); AFS_GUNLOCK(); return code; -}int +} + +int afs_vop_read(ap) - struct vop_read_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - -} */ *ap; + struct vop_read_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * int a_ioflag; + * struct ucred *a_cred; + * + * } */ *ap; { int code; - struct vcache *avc=VTOAFS(ap->a_vp); + struct vcache *avc = VTOAFS(ap->a_vp); AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ code = afs_read(avc, ap->a_uio, ap->a_cred, 0, 0, 0); afs_BozonUnlock(&avc->pvnLock, avc); AFS_GUNLOCK(); return code; } + int afs_vop_getpages(ap) - struct vop_getpages_args /* { - struct vnode *a_vp; - vm_page_t *a_m; - int a_count; - int a_reqpage; - vm_oofset_t a_offset; - } */ *ap; + struct vop_getpages_args /* { + * struct vnode *a_vp; + * vm_page_t *a_m; + * int a_count; + * int a_reqpage; + * vm_oofset_t a_offset; + * } */ *ap; { int code; int i, nextoff, size, toff, npages; @@ -405,13 +413,13 @@ afs_vop_getpages(ap) struct iovec iov; struct buf *bp; vm_offset_t kva; - struct vcache *avc=VTOAFS(ap->a_vp); + struct vcache *avc = VTOAFS(ap->a_vp); if (avc->v.v_object == NULL) { - printf("afs_getpages: called with non-merged cache vnode??\n"); - return VM_PAGER_ERROR; + printf("afs_getpages: called with non-merged cache vnode??\n"); + return VM_PAGER_ERROR; } - npages=btoc(ap->a_count); + npages = btoc(ap->a_count); /* * If the requested page is partially valid, just return it and * allow the pager to zero-out the blanks. Partially valid pages @@ -428,13 +436,13 @@ afs_vop_getpages(ap) if (i != ap->a_reqpage) vm_page_free(ap->a_m[i]); } - return(0); + return (0); } } bp = getpbuf(&afs_pbuf_freecnt); kva = (vm_offset_t) bp->b_data; pmap_qenter(kva, ap->a_m, npages); - iov.iov_base = (caddr_t)kva; + iov.iov_base = (caddr_t) kva; iov.iov_len = ap->a_count; uio.uio_iov = &iov; uio.uio_iovcnt = 1; @@ -449,7 +457,7 @@ afs_vop_getpages(ap) #endif AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc, osi_curcred()); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(avc, osi_curcred()); /* hold bozon lock, but not basic vnode lock */ code = afs_read(avc, &uio, osi_curcred(), 0, 0, 0); afs_BozonUnlock(&avc->pvnLock, avc); AFS_GUNLOCK(); @@ -465,19 +473,19 @@ afs_vop_getpages(ap) } size = ap->a_count - uio.uio_resid; for (i = 0, toff = 0; i < npages; i++, toff = nextoff) { - vm_page_t m; - nextoff = toff + PAGE_SIZE; - m = ap->a_m[i]; + vm_page_t m; + nextoff = toff + PAGE_SIZE; + m = ap->a_m[i]; - m->flags &= ~PG_ZERO; + m->flags &= ~PG_ZERO; - if (nextoff <= size) { + if (nextoff <= size) { /* * Read operation filled an entire page */ m->valid = VM_PAGE_BITS_ALL; vm_page_undirty(m); - } else if (size > toff) { + } else if (size > toff) { /* * Read operation filled a partial page. */ @@ -485,9 +493,9 @@ afs_vop_getpages(ap) vm_page_set_validclean(m, 0, size - toff); /* handled by vm_fault now */ /* vm_page_zero_invalid(m, TRUE); */ - } - - if (i != ap->a_reqpage) { + } + + if (i != ap->a_reqpage) { /* * Whether or not to leave the page activated is up in * the air, but we should put the page on a page queue @@ -509,26 +517,27 @@ afs_vop_getpages(ap) } else { vm_page_free(m); } - } + } } return 0; } - + int afs_vop_write(ap) - struct vop_write_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap; + struct vop_write_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * int a_ioflag; + * struct ucred *a_cred; + * } */ *ap; { int code; struct vcache *avc = VTOAFS(ap->a_vp); AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ - code = afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0); + osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ + code = + afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0); afs_BozonUnlock(&avc->pvnLock, avc); AFS_GUNLOCK(); return code; @@ -536,14 +545,14 @@ afs_vop_write(ap) int afs_vop_putpages(ap) - struct vop_putpages_args /* { - struct vnode *a_vp; - vm_page_t *a_m; - int a_count; - int a_sync; - int *a_rtvals; - vm_oofset_t a_offset; - } */ *ap; + struct vop_putpages_args /* { + * struct vnode *a_vp; + * vm_page_t *a_m; + * int a_count; + * int a_sync; + * int *a_rtvals; + * vm_oofset_t a_offset; + * } */ *ap; { int code; int i, size, npages, sync; @@ -551,22 +560,23 @@ afs_vop_putpages(ap) struct iovec iov; struct buf *bp; vm_offset_t kva; - struct vcache *avc=VTOAFS(ap->a_vp); + struct vcache *avc = VTOAFS(ap->a_vp); if (avc->v.v_object == NULL) { - printf("afs_putpages: called with non-merged cache vnode??\n"); - return VM_PAGER_ERROR; + printf("afs_putpages: called with non-merged cache vnode??\n"); + return VM_PAGER_ERROR; } if (vType(avc) != VREG) { - printf("afs_putpages: not VREG"); - return VM_PAGER_ERROR; + printf("afs_putpages: not VREG"); + return VM_PAGER_ERROR; } - npages=btoc(ap->a_count); - for (i=0; i < npages; i++ ) ap->a_rtvals[i]=VM_PAGER_AGAIN; + npages = btoc(ap->a_count); + for (i = 0; i < npages; i++) + ap->a_rtvals[i] = VM_PAGER_AGAIN; bp = getpbuf(&afs_pbuf_freecnt); kva = (vm_offset_t) bp->b_data; pmap_qenter(kva, ap->a_m, npages); - iov.iov_base = (caddr_t)kva; + iov.iov_base = (caddr_t) kva; iov.iov_len = ap->a_count; uio.uio_iov = &iov; uio.uio_iovcnt = 1; @@ -581,9 +591,9 @@ afs_vop_putpages(ap) #endif sync = IO_VMIO; if (ap->a_sync & VM_PAGER_PUT_SYNC) - sync |= IO_SYNC; + sync |= IO_SYNC; /*if (ap->a_sync & VM_PAGER_PUT_INVAL) - sync |= IO_INVAL;*/ + * sync |= IO_INVAL; */ AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); @@ -596,8 +606,8 @@ afs_vop_putpages(ap) if (!code) { size = ap->a_count - uio.uio_resid; for (i = 0; i < round_page(size) / PAGE_SIZE; i++) { - ap->a_rtvals[i]=VM_PAGER_OK; - ap->a_m[i]->dirty=0; + ap->a_rtvals[i] = VM_PAGER_OK; + ap->a_m[i]->dirty = 0; } return VM_PAGER_ERROR; } @@ -606,49 +616,50 @@ afs_vop_putpages(ap) int afs_vop_ioctl(ap) - struct vop_ioctl_args /* { - struct vnode *a_vp; - int a_command; - caddr_t a_data; - int a_fflag; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_ioctl_args /* { + * struct vnode *a_vp; + * int a_command; + * caddr_t a_data; + * int a_fflag; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { struct vcache *tvc = VTOAFS(ap->a_vp); int error = 0; - + /* in case we ever get in here... */ AFS_STATCNT(afs_ioctl); if (((ap->a_command >> 8) & 0xff) == 'V') { /* This is a VICEIOCTL call */ AFS_GLOCK(); - error = HandleIoctl(tvc, NULL /*Not used*/, - ap->a_command, ap->a_data); + error = HandleIoctl(tvc, NULL /*Not used */ , + ap->a_command, ap->a_data); AFS_GUNLOCK(); - return(error); + return (error); } else { /* No-op call; just return. */ - return(ENOTTY); + return (ENOTTY); } } /* ARGSUSED */ int afs_vop_poll(ap) - struct vop_poll_args /* { - struct vnode *a_vp; - int a_events; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_poll_args /* { + * struct vnode *a_vp; + * int a_events; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { /* * We should really check to see if I/O is possible. */ return (1); } + /* * Mmap a file * @@ -657,30 +668,30 @@ afs_vop_poll(ap) /* ARGSUSED */ int afs_vop_mmap(ap) - struct vop_mmap_args /* { - struct vnode *a_vp; - int a_fflags; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_mmap_args /* { + * struct vnode *a_vp; + * int a_fflags; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { - return (EINVAL); + return (EINVAL); } int afs_vop_fsync(ap) - struct vop_fsync_args /* { - struct vnode *a_vp; - struct ucred *a_cred; - int a_waitfor; - struct proc *a_p; - } */ *ap; + struct vop_fsync_args /* { + * struct vnode *a_vp; + * struct ucred *a_cred; + * int a_waitfor; + * struct proc *a_p; + * } */ *ap; { int error; register struct vnode *vp = ap->a_vp; AFS_GLOCK(); - /*vflushbuf(vp, wait);*/ + /*vflushbuf(vp, wait); */ if (ap->a_cred) error = afs_fsync(VTOAFS(vp), ap->a_cred); else @@ -691,11 +702,11 @@ afs_vop_fsync(ap) int afs_vop_remove(ap) - struct vop_remove_args /* { - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; - } */ *ap; + struct vop_remove_args /* { + * struct vnode *a_dvp; + * struct vnode *a_vp; + * struct componentname *a_cnp; + * } */ *ap; { int error = 0; register struct vnode *vp = ap->a_vp; @@ -703,7 +714,7 @@ afs_vop_remove(ap) GETNAME(); AFS_GLOCK(); - error = afs_remove(VTOAFS(dvp), name, cnp->cn_cred); + error = afs_remove(VTOAFS(dvp), name, cnp->cn_cred); AFS_GUNLOCK(); cache_purge(vp); DROPNAME(); @@ -712,11 +723,11 @@ afs_vop_remove(ap) int afs_vop_link(ap) - struct vop_link_args /* { - struct vnode *a_vp; - struct vnode *a_tdvp; - struct componentname *a_cnp; - } */ *ap; + struct vop_link_args /* { + * struct vnode *a_vp; + * struct vnode *a_tdvp; + * struct componentname *a_cnp; + * } */ *ap; { int error = 0; register struct vnode *dvp = ap->a_tdvp; @@ -743,22 +754,22 @@ afs_vop_link(ap) error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred); AFS_GUNLOCK(); if (dvp != vp) - VOP_UNLOCK(vp,0, p); -out: + VOP_UNLOCK(vp, 0, p); + out: DROPNAME(); return error; } int afs_vop_rename(ap) - struct vop_rename_args /* { - struct vnode *a_fdvp; - struct vnode *a_fvp; - struct componentname *a_fcnp; - struct vnode *a_tdvp; - struct vnode *a_tvp; - struct componentname *a_tcnp; - } */ *ap; + struct vop_rename_args /* { + * struct vnode *a_fdvp; + * struct vnode *a_fvp; + * struct componentname *a_fcnp; + * struct vnode *a_tdvp; + * struct vnode *a_tvp; + * struct componentname *a_tcnp; + * } */ *ap; { int error = 0; struct componentname *fcnp = ap->a_fcnp; @@ -778,10 +789,10 @@ afs_vop_rename(ap) /* * Check for cross-device rename. */ - if ((fvp->v_mount != tdvp->v_mount) || - (tvp && (fvp->v_mount != tvp->v_mount))) { + if ((fvp->v_mount != tdvp->v_mount) + || (tvp && (fvp->v_mount != tvp->v_mount))) { error = EXDEV; -abortit: + abortit: if (tdvp == tvp) vrele(tdvp); else @@ -796,7 +807,7 @@ abortit: * if fvp == tvp, we're just removing one name of a pair of * directory entries for the same element. convert call into rename. ( (pinched from FreeBSD 4.4's ufs_rename()) - + */ if (fvp == tvp) { if (fvp->v_type == VDIR) { @@ -816,36 +827,37 @@ abortit: if ((fcnp->cn_flags & SAVESTART) == 0) panic("afs_rename: lost from startdir"); fcnp->cn_nameiop = DELETE; - VREF(fdvp); - error=relookup(fdvp, &fvp, fcnp); - if (error == 0) - vrele(fdvp); - if (fvp == NULL) { - return (ENOENT); - } - - error=VOP_REMOVE(fdvp, fvp, fcnp); - if (fdvp == fvp) - vrele(fdvp); - else - vput(fdvp); - vput(fvp); - return (error); + VREF(fdvp); + error = relookup(fdvp, &fvp, fcnp); + if (error == 0) + vrele(fdvp); + if (fvp == NULL) { + return (ENOENT); + } + + error = VOP_REMOVE(fdvp, fvp, fcnp); + if (fdvp == fvp) + vrele(fdvp); + else + vput(fdvp); + vput(fvp); + return (error); } if ((error = vn_lock(fvp, LK_EXCLUSIVE, p)) != 0) goto abortit; - MALLOC(fname, char *, fcnp->cn_namelen+1, M_TEMP, M_WAITOK); + MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK); memcpy(fname, fcnp->cn_nameptr, fcnp->cn_namelen); fname[fcnp->cn_namelen] = '\0'; - MALLOC(tname, char *, tcnp->cn_namelen+1, M_TEMP, M_WAITOK); + MALLOC(tname, char *, tcnp->cn_namelen + 1, M_TEMP, M_WAITOK); memcpy(tname, tcnp->cn_nameptr, tcnp->cn_namelen); tname[tcnp->cn_namelen] = '\0'; AFS_GLOCK(); /* XXX use "from" or "to" creds? NFS uses "to" creds */ - error = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred); + error = + afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred); AFS_GUNLOCK(); FREE(fname, M_TEMP); @@ -863,12 +875,12 @@ abortit: int afs_vop_mkdir(ap) - struct vop_mkdir_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap; + struct vop_mkdir_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * } */ *ap; { register struct vnode *dvp = ap->a_dvp; register struct vattr *vap = ap->a_vap; @@ -891,11 +903,11 @@ afs_vop_mkdir(ap) if (error) { vput(dvp); DROPNAME(); - return(error); + return (error); } if (vcp) { *ap->a_vpp = AFSTOV(vcp); - vn_lock(AFSTOV(vcp), LK_EXCLUSIVE|LK_RETRY, p); + vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, p); } else *ap->a_vpp = 0; DROPNAME(); @@ -904,11 +916,11 @@ afs_vop_mkdir(ap) int afs_vop_rmdir(ap) - struct vop_rmdir_args /* { - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; - } */ *ap; + struct vop_rmdir_args /* { + * struct vnode *a_dvp; + * struct vnode *a_vp; + * struct componentname *a_cnp; + * } */ *ap; { int error = 0; register struct vnode *dvp = ap->a_dvp; @@ -923,13 +935,13 @@ afs_vop_rmdir(ap) int afs_vop_symlink(ap) - struct vop_symlink_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - char *a_target; - } */ *ap; + struct vop_symlink_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * char *a_target; + * } */ *ap; { register struct vnode *dvp = ap->a_dvp; int error = 0; @@ -937,8 +949,8 @@ afs_vop_symlink(ap) GETNAME(); AFS_GLOCK(); - error = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, - cnp->cn_cred); + error = + afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, cnp->cn_cred); AFS_GUNLOCK(); DROPNAME(); return error; @@ -946,23 +958,23 @@ afs_vop_symlink(ap) int afs_vop_readdir(ap) - struct vop_readdir_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - int *a_eofflag; - u_long *a_cookies; - int ncookies; - } */ *ap; + struct vop_readdir_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * struct ucred *a_cred; + * int *a_eofflag; + * u_long *a_cookies; + * int ncookies; + * } */ *ap; { int error; off_t off; /* printf("readdir %x cookies %x ncookies %d\n", ap->a_vp, ap->a_cookies, ap->a_ncookies); */ - off=ap->a_uio->uio_offset; + off = ap->a_uio->uio_offset; AFS_GLOCK(); - error= afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, - ap->a_eofflag); + error = + afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag); AFS_GUNLOCK(); if (!error && ap->a_ncookies != NULL) { struct uio *uio = ap->a_uio; @@ -975,17 +987,15 @@ afs_vop_readdir(ap) dp = (const struct dirent *) ((const char *)uio->uio_iov->iov_base - (uio->uio_offset - off)); - dp_end = (const struct dirent *) uio->uio_iov->iov_base; - for (dp_start = dp, ncookies = 0; - dp < dp_end; - dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) + dp_end = (const struct dirent *)uio->uio_iov->iov_base; + for (dp_start = dp, ncookies = 0; dp < dp_end; + dp = (const struct dirent *)((const char *)dp + dp->d_reclen)) ncookies++; - MALLOC(cookies, u_long *, ncookies * sizeof(u_long), - M_TEMP, M_WAITOK); - for (dp = dp_start, cookiep = cookies; - dp < dp_end; - dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) { + MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP, + M_WAITOK); + for (dp = dp_start, cookiep = cookies; dp < dp_end; + dp = (const struct dirent *)((const char *)dp + dp->d_reclen)) { off += dp->d_reclen; *cookiep++ = off; } @@ -998,16 +1008,16 @@ afs_vop_readdir(ap) int afs_vop_readlink(ap) - struct vop_readlink_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - } */ *ap; + struct vop_readlink_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * struct ucred *a_cred; + * } */ *ap; { int error; /* printf("readlink %x\n", ap->a_vp);*/ AFS_GLOCK(); - error= afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred); + error = afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred); AFS_GUNLOCK(); return error; } @@ -1016,10 +1026,10 @@ extern int prtactive; int afs_vop_inactive(ap) - struct vop_inactive_args /* { - struct vnode *a_vp; - struct proc *a_p; - } */ *ap; + struct vop_inactive_args /* { + * struct vnode *a_vp; + * struct proc *a_p; + * } */ *ap; { register struct vnode *vp = ap->a_vp; @@ -1027,7 +1037,7 @@ afs_vop_inactive(ap) vprint("afs_vop_inactive(): pushing active", vp); AFS_GLOCK(); - afs_InactiveVCache(VTOAFS(vp), 0); /* decrs ref counts */ + afs_InactiveVCache(VTOAFS(vp), 0); /* decrs ref counts */ AFS_GUNLOCK(); VOP_UNLOCK(vp, 0, ap->a_p); return 0; @@ -1035,20 +1045,20 @@ afs_vop_inactive(ap) int afs_vop_reclaim(ap) - struct vop_reclaim_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_reclaim_args /* { + * struct vnode *a_vp; + * } */ *ap; { #ifdef AFS_DO_FLUSH_IN_RECLAIM int error, sl; #endif register struct vnode *vp = ap->a_vp; - cache_purge(vp); /* just in case... */ + cache_purge(vp); /* just in case... */ #ifdef AFS_DO_FLUSH_IN_RECLAIM AFS_GLOCK(); - error = afs_FlushVCache(VTOAFS(vp), &sl); /* tosses our stuff from vnode */ + error = afs_FlushVCache(VTOAFS(vp), &sl); /* tosses our stuff from vnode */ AFS_GUNLOCK(); ubc_unlink(vp); if (!error && vp->v_data) @@ -1056,11 +1066,11 @@ afs_vop_reclaim(ap) return error; #else if (vp->v_usecount == 2) { - vprint("reclaim count==2", vp); + vprint("reclaim count==2", vp); } else if (vp->v_usecount == 1) { - vprint("reclaim count==1", vp); - } else - vprint("reclaim bad count", vp); + vprint("reclaim count==1", vp); + } else + vprint("reclaim bad count", vp); return 0; #endif @@ -1068,9 +1078,9 @@ afs_vop_reclaim(ap) int afs_vop_lock(ap) - struct vop_lock_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_lock_args /* { + * struct vnode *a_vp; + * } */ *ap; { register struct vnode *vp = ap->a_vp; register struct vcache *avc = VTOAFS(vp); @@ -1081,33 +1091,33 @@ afs_vop_lock(ap) if (vp->v_tag == VT_NON) #endif return (ENOENT); - return (lockmgr(&avc->rwlock, ap->a_flags, &vp->v_interlock, - ap->a_p)); + return (lockmgr(&avc->rwlock, ap->a_flags, &vp->v_interlock, ap->a_p)); } int afs_vop_unlock(ap) - struct vop_unlock_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_unlock_args /* { + * struct vnode *a_vp; + * } */ *ap; { struct vnode *vp = ap->a_vp; struct vcache *avc = VTOAFS(vp); - return (lockmgr(&avc->rwlock, ap->a_flags | LK_RELEASE, - &vp->v_interlock, ap->a_p)); + return (lockmgr + (&avc->rwlock, ap->a_flags | LK_RELEASE, &vp->v_interlock, + ap->a_p)); } int afs_vop_bmap(ap) - struct vop_bmap_args /* { - struct vnode *a_vp; - daddr_t a_bn; - struct vnode **a_vpp; - daddr_t *a_bnp; - int *a_runp; - int *a_runb; - } */ *ap; + struct vop_bmap_args /* { + * struct vnode *a_vp; + * daddr_t a_bn; + * struct vnode **a_vpp; + * daddr_t *a_bnp; + * int *a_runp; + * int *a_runb; + * } */ *ap; { if (ap->a_bnp) { *ap->a_bnp = ap->a_bn * (PAGE_SIZE / DEV_BSIZE); @@ -1119,52 +1129,57 @@ afs_vop_bmap(ap) *ap->a_runp = 0; if (ap->a_runb != NULL) *ap->a_runb = 0; - + return 0; } int afs_vop_strategy(ap) - struct vop_strategy_args /* { - struct buf *a_bp; - } */ *ap; + struct vop_strategy_args /* { + * struct buf *a_bp; + * } */ *ap; { int error; AFS_GLOCK(); - error= afs_ustrategy(ap->a_bp); + error = afs_ustrategy(ap->a_bp); AFS_GUNLOCK(); return error; } int afs_vop_print(ap) - struct vop_print_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_print_args /* { + * struct vnode *a_vp; + * } */ *ap; { register struct vnode *vp = ap->a_vp; register struct vcache *vc = VTOAFS(ap->a_vp); int s = vc->states; #ifdef AFS_FBSD50_ENV - printf("tag %s, fid: %d.%x.%x.%x, opens %d, writers %d", vp->v_tag, (int) vc->fid.Cell, - (u_int) vc->fid.Fid.Volume, (u_int) vc->fid.Fid.Vnode, (u_int) vc->fid.Fid.Unique, - vc->opens, vc->execsOrWriters); + printf("tag %s, fid: %d.%x.%x.%x, opens %d, writers %d", vp->v_tag, + (int)vc->fid.Cell, (u_int) vc->fid.Fid.Volume, + (u_int) vc->fid.Fid.Vnode, (u_int) vc->fid.Fid.Unique, vc->opens, + vc->execsOrWriters); #else - printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, vc->fid.Cell, - (u_int) vc->fid.Fid.Volume, (u_int) vc->fid.Fid.Vnode, (u_int) vc->fid.Fid.Unique, - vc->opens, vc->execsOrWriters); + printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, + vc->fid.Cell, (u_int) vc->fid.Fid.Volume, + (u_int) vc->fid.Fid.Vnode, (u_int) vc->fid.Fid.Unique, vc->opens, + vc->execsOrWriters); #endif - printf("\n states%s%s%s%s%s", (s&CStatd) ? " statd" : "", (s&CRO) ? " readonly" : "",(s&CDirty) ? " dirty" : "",(s&CMAPPED) ? " mapped" : "", (s&CVFlushed) ? " flush in progress" : ""); + printf("\n states%s%s%s%s%s", (s & CStatd) ? " statd" : "", + (s & CRO) ? " readonly" : "", (s & CDirty) ? " dirty" : "", + (s & CMAPPED) ? " mapped" : "", + (s & CVFlushed) ? " flush in progress" : ""); printf("\n"); return 0; } int afs_vop_islocked(ap) - struct vop_islocked_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_islocked_args /* { + * struct vnode *a_vp; + * } */ *ap; { struct vcache *vc = VTOAFS(ap->a_vp); return lockstatus(&vc->rwlock, ap->a_p); @@ -1175,20 +1190,20 @@ afs_vop_islocked(ap) */ int afs_vop_advlock(ap) - struct vop_advlock_args /* { - struct vnode *a_vp; - caddr_t a_id; - int a_op; - struct flock *a_fl; - int a_flags; - } */ *ap; + struct vop_advlock_args /* { + * struct vnode *a_vp; + * caddr_t a_id; + * int a_op; + * struct flock *a_fl; + * int a_flags; + * } */ *ap; { int error; struct ucred cr = *osi_curcred(); AFS_GLOCK(); - error= afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr, - (int) ap->a_id); + error = + afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr, (int)ap->a_id); AFS_GUNLOCK(); return error; } diff --git a/src/afs/FBSD/vnode_if_4x.h b/src/afs/FBSD/vnode_if_4x.h index ded87a16d..7ff290e42 100644 --- a/src/afs/FBSD/vnode_if_4x.h +++ b/src/afs/FBSD/vnode_if_4x.h @@ -7,1417 +7,1340 @@ extern struct vnodeop_desc vop_default_desc; struct vop_islocked_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct proc *a_p; }; extern struct vnodeop_desc vop_islocked_desc; -static __inline int VOP_ISLOCKED __P(( - struct vnode *vp, - struct proc *p)); -static __inline int VOP_ISLOCKED(vp, p) - struct vnode *vp; - struct proc *p; +static __inline int VOP_ISLOCKED __P((struct vnode * vp, struct proc * p)); +static __inline int +VOP_ISLOCKED(vp, p) + struct vnode *vp; + struct proc *p; { - struct vop_islocked_args a; - int rc; - a.a_desc = VDESC(vop_islocked); - a.a_vp = vp; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_islocked), &a); - return (rc); + struct vop_islocked_args a; + int rc; + a.a_desc = VDESC(vop_islocked); + a.a_vp = vp; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_islocked), &a); + return (rc); } struct vop_lookup_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_lookup_desc; -static __inline int VOP_LOOKUP __P(( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp)); -static __inline int VOP_LOOKUP(dvp, vpp, cnp) - struct vnode *dvp; - struct vnode **vpp; - struct componentname *cnp; +static __inline int VOP_LOOKUP +__P((struct vnode * dvp, struct vnode ** vpp, struct componentname * cnp)); +static __inline int +VOP_LOOKUP(dvp, vpp, cnp) + struct vnode *dvp; + struct vnode **vpp; + struct componentname *cnp; { - struct vop_lookup_args a; - int rc; - a.a_desc = VDESC(vop_lookup); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - rc = VCALL(dvp, VOFFSET(vop_lookup), &a); - return (rc); + struct vop_lookup_args a; + int rc; + a.a_desc = VDESC(vop_lookup); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + rc = VCALL(dvp, VOFFSET(vop_lookup), &a); + return (rc); } struct vop_cachedlookup_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_cachedlookup_desc; -static __inline int VOP_CACHEDLOOKUP __P(( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp)); -static __inline int VOP_CACHEDLOOKUP(dvp, vpp, cnp) - struct vnode *dvp; - struct vnode **vpp; - struct componentname *cnp; +static __inline int VOP_CACHEDLOOKUP +__P((struct vnode * dvp, struct vnode ** vpp, struct componentname * cnp)); +static __inline int +VOP_CACHEDLOOKUP(dvp, vpp, cnp) + struct vnode *dvp; + struct vnode **vpp; + struct componentname *cnp; { - struct vop_cachedlookup_args a; - int rc; - a.a_desc = VDESC(vop_cachedlookup); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - rc = VCALL(dvp, VOFFSET(vop_cachedlookup), &a); - return (rc); + struct vop_cachedlookup_args a; + int rc; + a.a_desc = VDESC(vop_cachedlookup); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + rc = VCALL(dvp, VOFFSET(vop_cachedlookup), &a); + return (rc); } struct vop_create_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; }; extern struct vnodeop_desc vop_create_desc; -static __inline int VOP_CREATE __P(( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp, - struct vattr *vap)); -static __inline int VOP_CREATE(dvp, vpp, cnp, vap) - struct vnode *dvp; - struct vnode **vpp; - struct componentname *cnp; - struct vattr *vap; +static __inline int VOP_CREATE +__P((struct vnode * dvp, struct vnode ** vpp, struct componentname * cnp, + struct vattr * vap)); +static __inline int +VOP_CREATE(dvp, vpp, cnp, vap) + struct vnode *dvp; + struct vnode **vpp; + struct componentname *cnp; + struct vattr *vap; { - struct vop_create_args a; - int rc; - a.a_desc = VDESC(vop_create); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - a.a_vap = vap; - rc = VCALL(dvp, VOFFSET(vop_create), &a); - return (rc); + struct vop_create_args a; + int rc; + a.a_desc = VDESC(vop_create); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + a.a_vap = vap; + rc = VCALL(dvp, VOFFSET(vop_create), &a); + return (rc); } struct vop_whiteout_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct componentname *a_cnp; - int a_flags; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct componentname *a_cnp; + int a_flags; }; extern struct vnodeop_desc vop_whiteout_desc; -static __inline int VOP_WHITEOUT __P(( - struct vnode *dvp, - struct componentname *cnp, - int flags)); -static __inline int VOP_WHITEOUT(dvp, cnp, flags) - struct vnode *dvp; - struct componentname *cnp; - int flags; +static __inline int VOP_WHITEOUT +__P((struct vnode * dvp, struct componentname * cnp, int flags)); +static __inline int +VOP_WHITEOUT(dvp, cnp, flags) + struct vnode *dvp; + struct componentname *cnp; + int flags; { - struct vop_whiteout_args a; - int rc; - a.a_desc = VDESC(vop_whiteout); - a.a_dvp = dvp; - a.a_cnp = cnp; - a.a_flags = flags; - rc = VCALL(dvp, VOFFSET(vop_whiteout), &a); - return (rc); + struct vop_whiteout_args a; + int rc; + a.a_desc = VDESC(vop_whiteout); + a.a_dvp = dvp; + a.a_cnp = cnp; + a.a_flags = flags; + rc = VCALL(dvp, VOFFSET(vop_whiteout), &a); + return (rc); } struct vop_mknod_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; }; extern struct vnodeop_desc vop_mknod_desc; -static __inline int VOP_MKNOD __P(( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp, - struct vattr *vap)); -static __inline int VOP_MKNOD(dvp, vpp, cnp, vap) - struct vnode *dvp; - struct vnode **vpp; - struct componentname *cnp; - struct vattr *vap; +static __inline int VOP_MKNOD +__P((struct vnode * dvp, struct vnode ** vpp, struct componentname * cnp, + struct vattr * vap)); +static __inline int +VOP_MKNOD(dvp, vpp, cnp, vap) + struct vnode *dvp; + struct vnode **vpp; + struct componentname *cnp; + struct vattr *vap; { - struct vop_mknod_args a; - int rc; - a.a_desc = VDESC(vop_mknod); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - a.a_vap = vap; - rc = VCALL(dvp, VOFFSET(vop_mknod), &a); - return (rc); + struct vop_mknod_args a; + int rc; + a.a_desc = VDESC(vop_mknod); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + a.a_vap = vap; + rc = VCALL(dvp, VOFFSET(vop_mknod), &a); + return (rc); } struct vop_open_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_mode; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_open_desc; -static __inline int VOP_OPEN __P(( - struct vnode *vp, - int mode, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_OPEN(vp, mode, cred, p) - struct vnode *vp; - int mode; - struct ucred *cred; - struct proc *p; +static __inline int VOP_OPEN +__P((struct vnode * vp, int mode, struct ucred * cred, struct proc * p)); +static __inline int +VOP_OPEN(vp, mode, cred, p) + struct vnode *vp; + int mode; + struct ucred *cred; + struct proc *p; { - struct vop_open_args a; - int rc; - a.a_desc = VDESC(vop_open); - a.a_vp = vp; - a.a_mode = mode; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_open), &a); - return (rc); + struct vop_open_args a; + int rc; + a.a_desc = VDESC(vop_open); + a.a_vp = vp; + a.a_mode = mode; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_open), &a); + return (rc); } struct vop_close_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_fflag; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_fflag; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_close_desc; -static __inline int VOP_CLOSE __P(( - struct vnode *vp, - int fflag, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_CLOSE(vp, fflag, cred, p) - struct vnode *vp; - int fflag; - struct ucred *cred; - struct proc *p; +static __inline int VOP_CLOSE +__P((struct vnode * vp, int fflag, struct ucred * cred, struct proc * p)); +static __inline int +VOP_CLOSE(vp, fflag, cred, p) + struct vnode *vp; + int fflag; + struct ucred *cred; + struct proc *p; { - struct vop_close_args a; - int rc; - a.a_desc = VDESC(vop_close); - a.a_vp = vp; - a.a_fflag = fflag; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_close), &a); - return (rc); + struct vop_close_args a; + int rc; + a.a_desc = VDESC(vop_close); + a.a_vp = vp; + a.a_fflag = fflag; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_close), &a); + return (rc); } struct vop_access_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_mode; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_access_desc; -static __inline int VOP_ACCESS __P(( - struct vnode *vp, - int mode, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_ACCESS(vp, mode, cred, p) - struct vnode *vp; - int mode; - struct ucred *cred; - struct proc *p; +static __inline int VOP_ACCESS +__P((struct vnode * vp, int mode, struct ucred * cred, struct proc * p)); +static __inline int +VOP_ACCESS(vp, mode, cred, p) + struct vnode *vp; + int mode; + struct ucred *cred; + struct proc *p; { - struct vop_access_args a; - int rc; - a.a_desc = VDESC(vop_access); - a.a_vp = vp; - a.a_mode = mode; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_access), &a); - return (rc); + struct vop_access_args a; + int rc; + a.a_desc = VDESC(vop_access); + a.a_vp = vp; + a.a_mode = mode; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_access), &a); + return (rc); } struct vop_getattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct vattr *a_vap; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_getattr_desc; -static __inline int VOP_GETATTR __P(( - struct vnode *vp, - struct vattr *vap, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_GETATTR(vp, vap, cred, p) - struct vnode *vp; - struct vattr *vap; - struct ucred *cred; - struct proc *p; +static __inline int VOP_GETATTR +__P((struct vnode * vp, struct vattr * vap, struct ucred * cred, + struct proc * p)); +static __inline int +VOP_GETATTR(vp, vap, cred, p) + struct vnode *vp; + struct vattr *vap; + struct ucred *cred; + struct proc *p; { - struct vop_getattr_args a; - int rc; - a.a_desc = VDESC(vop_getattr); - a.a_vp = vp; - a.a_vap = vap; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_getattr), &a); - return (rc); + struct vop_getattr_args a; + int rc; + a.a_desc = VDESC(vop_getattr); + a.a_vp = vp; + a.a_vap = vap; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_getattr), &a); + return (rc); } struct vop_setattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct vattr *a_vap; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_setattr_desc; -static __inline int VOP_SETATTR __P(( - struct vnode *vp, - struct vattr *vap, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_SETATTR(vp, vap, cred, p) - struct vnode *vp; - struct vattr *vap; - struct ucred *cred; - struct proc *p; +static __inline int VOP_SETATTR +__P((struct vnode * vp, struct vattr * vap, struct ucred * cred, + struct proc * p)); +static __inline int +VOP_SETATTR(vp, vap, cred, p) + struct vnode *vp; + struct vattr *vap; + struct ucred *cred; + struct proc *p; { - struct vop_setattr_args a; - int rc; - a.a_desc = VDESC(vop_setattr); - a.a_vp = vp; - a.a_vap = vap; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_setattr), &a); - return (rc); + struct vop_setattr_args a; + int rc; + a.a_desc = VDESC(vop_setattr); + a.a_vp = vp; + a.a_vap = vap; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_setattr), &a); + return (rc); } struct vop_read_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + int a_ioflag; + struct ucred *a_cred; }; extern struct vnodeop_desc vop_read_desc; -static __inline int VOP_READ __P(( - struct vnode *vp, - struct uio *uio, - int ioflag, - struct ucred *cred)); -static __inline int VOP_READ(vp, uio, ioflag, cred) - struct vnode *vp; - struct uio *uio; - int ioflag; - struct ucred *cred; +static __inline int VOP_READ +__P((struct vnode * vp, struct uio * uio, int ioflag, struct ucred * cred)); +static __inline int +VOP_READ(vp, uio, ioflag, cred) + struct vnode *vp; + struct uio *uio; + int ioflag; + struct ucred *cred; { - struct vop_read_args a; - int rc; - a.a_desc = VDESC(vop_read); - a.a_vp = vp; - a.a_uio = uio; - a.a_ioflag = ioflag; - a.a_cred = cred; - rc = VCALL(vp, VOFFSET(vop_read), &a); - return (rc); + struct vop_read_args a; + int rc; + a.a_desc = VDESC(vop_read); + a.a_vp = vp; + a.a_uio = uio; + a.a_ioflag = ioflag; + a.a_cred = cred; + rc = VCALL(vp, VOFFSET(vop_read), &a); + return (rc); } struct vop_write_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + int a_ioflag; + struct ucred *a_cred; }; extern struct vnodeop_desc vop_write_desc; -static __inline int VOP_WRITE __P(( - struct vnode *vp, - struct uio *uio, - int ioflag, - struct ucred *cred)); -static __inline int VOP_WRITE(vp, uio, ioflag, cred) - struct vnode *vp; - struct uio *uio; - int ioflag; - struct ucred *cred; +static __inline int VOP_WRITE +__P((struct vnode * vp, struct uio * uio, int ioflag, struct ucred * cred)); +static __inline int +VOP_WRITE(vp, uio, ioflag, cred) + struct vnode *vp; + struct uio *uio; + int ioflag; + struct ucred *cred; { - struct vop_write_args a; - int rc; - a.a_desc = VDESC(vop_write); - a.a_vp = vp; - a.a_uio = uio; - a.a_ioflag = ioflag; - a.a_cred = cred; - rc = VCALL(vp, VOFFSET(vop_write), &a); - return (rc); + struct vop_write_args a; + int rc; + a.a_desc = VDESC(vop_write); + a.a_vp = vp; + a.a_uio = uio; + a.a_ioflag = ioflag; + a.a_cred = cred; + rc = VCALL(vp, VOFFSET(vop_write), &a); + return (rc); } struct vop_lease_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct proc *a_p; - struct ucred *a_cred; - int a_flag; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct proc *a_p; + struct ucred *a_cred; + int a_flag; }; extern struct vnodeop_desc vop_lease_desc; -static __inline int VOP_LEASE __P(( - struct vnode *vp, - struct proc *p, - struct ucred *cred, - int flag)); -static __inline int VOP_LEASE(vp, p, cred, flag) - struct vnode *vp; - struct proc *p; - struct ucred *cred; - int flag; +static __inline int VOP_LEASE +__P((struct vnode * vp, struct proc * p, struct ucred * cred, int flag)); +static __inline int +VOP_LEASE(vp, p, cred, flag) + struct vnode *vp; + struct proc *p; + struct ucred *cred; + int flag; { - struct vop_lease_args a; - int rc; - a.a_desc = VDESC(vop_lease); - a.a_vp = vp; - a.a_p = p; - a.a_cred = cred; - a.a_flag = flag; - rc = VCALL(vp, VOFFSET(vop_lease), &a); - return (rc); + struct vop_lease_args a; + int rc; + a.a_desc = VDESC(vop_lease); + a.a_vp = vp; + a.a_p = p; + a.a_cred = cred; + a.a_flag = flag; + rc = VCALL(vp, VOFFSET(vop_lease), &a); + return (rc); } struct vop_ioctl_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - u_long a_command; - caddr_t a_data; - int a_fflag; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + u_long a_command; + caddr_t a_data; + int a_fflag; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_ioctl_desc; -static __inline int VOP_IOCTL __P(( - struct vnode *vp, - u_long command, - caddr_t data, - int fflag, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_IOCTL(vp, command, data, fflag, cred, p) - struct vnode *vp; - u_long command; - caddr_t data; - int fflag; - struct ucred *cred; - struct proc *p; +static __inline int VOP_IOCTL +__P((struct vnode * vp, u_long command, caddr_t data, int fflag, + struct ucred * cred, struct proc * p)); +static __inline int +VOP_IOCTL(vp, command, data, fflag, cred, p) + struct vnode *vp; + u_long command; + caddr_t data; + int fflag; + struct ucred *cred; + struct proc *p; { - struct vop_ioctl_args a; - int rc; - a.a_desc = VDESC(vop_ioctl); - a.a_vp = vp; - a.a_command = command; - a.a_data = data; - a.a_fflag = fflag; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_ioctl), &a); - return (rc); + struct vop_ioctl_args a; + int rc; + a.a_desc = VDESC(vop_ioctl); + a.a_vp = vp; + a.a_command = command; + a.a_data = data; + a.a_fflag = fflag; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_ioctl), &a); + return (rc); } struct vop_poll_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_events; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_events; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_poll_desc; -static __inline int VOP_POLL __P(( - struct vnode *vp, - int events, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_POLL(vp, events, cred, p) - struct vnode *vp; - int events; - struct ucred *cred; - struct proc *p; +static __inline int VOP_POLL +__P((struct vnode * vp, int events, struct ucred * cred, struct proc * p)); +static __inline int +VOP_POLL(vp, events, cred, p) + struct vnode *vp; + int events; + struct ucred *cred; + struct proc *p; { - struct vop_poll_args a; - int rc; - a.a_desc = VDESC(vop_poll); - a.a_vp = vp; - a.a_events = events; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_poll), &a); - return (rc); + struct vop_poll_args a; + int rc; + a.a_desc = VDESC(vop_poll); + a.a_vp = vp; + a.a_events = events; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_poll), &a); + return (rc); } struct vop_kqfilter_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct knote *a_kn; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct knote *a_kn; }; extern struct vnodeop_desc vop_kqfilter_desc; -static __inline int VOP_KQFILTER __P(( - struct vnode *vp, - struct knote *kn)); -static __inline int VOP_KQFILTER(vp, kn) - struct vnode *vp; - struct knote *kn; +static __inline int VOP_KQFILTER __P((struct vnode * vp, struct knote * kn)); +static __inline int +VOP_KQFILTER(vp, kn) + struct vnode *vp; + struct knote *kn; { - struct vop_kqfilter_args a; - int rc; - a.a_desc = VDESC(vop_kqfilter); - a.a_vp = vp; - a.a_kn = kn; - rc = VCALL(vp, VOFFSET(vop_kqfilter), &a); - return (rc); + struct vop_kqfilter_args a; + int rc; + a.a_desc = VDESC(vop_kqfilter); + a.a_vp = vp; + a.a_kn = kn; + rc = VCALL(vp, VOFFSET(vop_kqfilter), &a); + return (rc); } struct vop_revoke_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_flags; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_flags; }; extern struct vnodeop_desc vop_revoke_desc; -static __inline int VOP_REVOKE __P(( - struct vnode *vp, - int flags)); -static __inline int VOP_REVOKE(vp, flags) - struct vnode *vp; - int flags; +static __inline int VOP_REVOKE __P((struct vnode * vp, int flags)); +static __inline int +VOP_REVOKE(vp, flags) + struct vnode *vp; + int flags; { - struct vop_revoke_args a; - int rc; - a.a_desc = VDESC(vop_revoke); - a.a_vp = vp; - a.a_flags = flags; - rc = VCALL(vp, VOFFSET(vop_revoke), &a); - return (rc); + struct vop_revoke_args a; + int rc; + a.a_desc = VDESC(vop_revoke); + a.a_vp = vp; + a.a_flags = flags; + rc = VCALL(vp, VOFFSET(vop_revoke), &a); + return (rc); } struct vop_mmap_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_fflags; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_fflags; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_mmap_desc; -static __inline int VOP_MMAP __P(( - struct vnode *vp, - int fflags, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_MMAP(vp, fflags, cred, p) - struct vnode *vp; - int fflags; - struct ucred *cred; - struct proc *p; +static __inline int VOP_MMAP +__P((struct vnode * vp, int fflags, struct ucred * cred, struct proc * p)); +static __inline int +VOP_MMAP(vp, fflags, cred, p) + struct vnode *vp; + int fflags; + struct ucred *cred; + struct proc *p; { - struct vop_mmap_args a; - int rc; - a.a_desc = VDESC(vop_mmap); - a.a_vp = vp; - a.a_fflags = fflags; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_mmap), &a); - return (rc); + struct vop_mmap_args a; + int rc; + a.a_desc = VDESC(vop_mmap); + a.a_vp = vp; + a.a_fflags = fflags; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_mmap), &a); + return (rc); } struct vop_fsync_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct ucred *a_cred; - int a_waitfor; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct ucred *a_cred; + int a_waitfor; + struct proc *a_p; }; extern struct vnodeop_desc vop_fsync_desc; -static __inline int VOP_FSYNC __P(( - struct vnode *vp, - struct ucred *cred, - int waitfor, - struct proc *p)); -static __inline int VOP_FSYNC(vp, cred, waitfor, p) - struct vnode *vp; - struct ucred *cred; - int waitfor; - struct proc *p; +static __inline int VOP_FSYNC +__P((struct vnode * vp, struct ucred * cred, int waitfor, struct proc * p)); +static __inline int +VOP_FSYNC(vp, cred, waitfor, p) + struct vnode *vp; + struct ucred *cred; + int waitfor; + struct proc *p; { - struct vop_fsync_args a; - int rc; - a.a_desc = VDESC(vop_fsync); - a.a_vp = vp; - a.a_cred = cred; - a.a_waitfor = waitfor; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_fsync), &a); - return (rc); + struct vop_fsync_args a; + int rc; + a.a_desc = VDESC(vop_fsync); + a.a_vp = vp; + a.a_cred = cred; + a.a_waitfor = waitfor; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_fsync), &a); + return (rc); } struct vop_remove_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode *a_vp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_remove_desc; -static __inline int VOP_REMOVE __P(( - struct vnode *dvp, - struct vnode *vp, - struct componentname *cnp)); -static __inline int VOP_REMOVE(dvp, vp, cnp) - struct vnode *dvp; - struct vnode *vp; - struct componentname *cnp; +static __inline int VOP_REMOVE +__P((struct vnode * dvp, struct vnode * vp, struct componentname * cnp)); +static __inline int +VOP_REMOVE(dvp, vp, cnp) + struct vnode *dvp; + struct vnode *vp; + struct componentname *cnp; { - struct vop_remove_args a; - int rc; - a.a_desc = VDESC(vop_remove); - a.a_dvp = dvp; - a.a_vp = vp; - a.a_cnp = cnp; - rc = VCALL(dvp, VOFFSET(vop_remove), &a); - return (rc); + struct vop_remove_args a; + int rc; + a.a_desc = VDESC(vop_remove); + a.a_dvp = dvp; + a.a_vp = vp; + a.a_cnp = cnp; + rc = VCALL(dvp, VOFFSET(vop_remove), &a); + return (rc); } struct vop_link_args { - struct vnodeop_desc *a_desc; - struct vnode *a_tdvp; - struct vnode *a_vp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_tdvp; + struct vnode *a_vp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_link_desc; -static __inline int VOP_LINK __P(( - struct vnode *tdvp, - struct vnode *vp, - struct componentname *cnp)); -static __inline int VOP_LINK(tdvp, vp, cnp) - struct vnode *tdvp; - struct vnode *vp; - struct componentname *cnp; +static __inline int VOP_LINK +__P((struct vnode * tdvp, struct vnode * vp, struct componentname * cnp)); +static __inline int +VOP_LINK(tdvp, vp, cnp) + struct vnode *tdvp; + struct vnode *vp; + struct componentname *cnp; { - struct vop_link_args a; - int rc; - a.a_desc = VDESC(vop_link); - a.a_tdvp = tdvp; - a.a_vp = vp; - a.a_cnp = cnp; - rc = VCALL(tdvp, VOFFSET(vop_link), &a); - return (rc); + struct vop_link_args a; + int rc; + a.a_desc = VDESC(vop_link); + a.a_tdvp = tdvp; + a.a_vp = vp; + a.a_cnp = cnp; + rc = VCALL(tdvp, VOFFSET(vop_link), &a); + return (rc); } struct vop_rename_args { - struct vnodeop_desc *a_desc; - struct vnode *a_fdvp; - struct vnode *a_fvp; - struct componentname *a_fcnp; - struct vnode *a_tdvp; - struct vnode *a_tvp; - struct componentname *a_tcnp; + struct vnodeop_desc *a_desc; + struct vnode *a_fdvp; + struct vnode *a_fvp; + struct componentname *a_fcnp; + struct vnode *a_tdvp; + struct vnode *a_tvp; + struct componentname *a_tcnp; }; extern struct vnodeop_desc vop_rename_desc; -static __inline int VOP_RENAME __P(( - struct vnode *fdvp, - struct vnode *fvp, - struct componentname *fcnp, - struct vnode *tdvp, - struct vnode *tvp, - struct componentname *tcnp)); -static __inline int VOP_RENAME(fdvp, fvp, fcnp, tdvp, tvp, tcnp) - struct vnode *fdvp; - struct vnode *fvp; - struct componentname *fcnp; - struct vnode *tdvp; - struct vnode *tvp; - struct componentname *tcnp; +static __inline int VOP_RENAME +__P((struct vnode * fdvp, struct vnode * fvp, struct componentname * fcnp, + struct vnode * tdvp, struct vnode * tvp, struct componentname * tcnp)); +static __inline int +VOP_RENAME(fdvp, fvp, fcnp, tdvp, tvp, tcnp) + struct vnode *fdvp; + struct vnode *fvp; + struct componentname *fcnp; + struct vnode *tdvp; + struct vnode *tvp; + struct componentname *tcnp; { - struct vop_rename_args a; - int rc; - a.a_desc = VDESC(vop_rename); - a.a_fdvp = fdvp; - a.a_fvp = fvp; - a.a_fcnp = fcnp; - a.a_tdvp = tdvp; - a.a_tvp = tvp; - a.a_tcnp = tcnp; - rc = VCALL(fdvp, VOFFSET(vop_rename), &a); - return (rc); + struct vop_rename_args a; + int rc; + a.a_desc = VDESC(vop_rename); + a.a_fdvp = fdvp; + a.a_fvp = fvp; + a.a_fcnp = fcnp; + a.a_tdvp = tdvp; + a.a_tvp = tvp; + a.a_tcnp = tcnp; + rc = VCALL(fdvp, VOFFSET(vop_rename), &a); + return (rc); } struct vop_mkdir_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; }; extern struct vnodeop_desc vop_mkdir_desc; -static __inline int VOP_MKDIR __P(( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp, - struct vattr *vap)); -static __inline int VOP_MKDIR(dvp, vpp, cnp, vap) - struct vnode *dvp; - struct vnode **vpp; - struct componentname *cnp; - struct vattr *vap; +static __inline int VOP_MKDIR +__P((struct vnode * dvp, struct vnode ** vpp, struct componentname * cnp, + struct vattr * vap)); +static __inline int +VOP_MKDIR(dvp, vpp, cnp, vap) + struct vnode *dvp; + struct vnode **vpp; + struct componentname *cnp; + struct vattr *vap; { - struct vop_mkdir_args a; - int rc; - a.a_desc = VDESC(vop_mkdir); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - a.a_vap = vap; - rc = VCALL(dvp, VOFFSET(vop_mkdir), &a); - return (rc); + struct vop_mkdir_args a; + int rc; + a.a_desc = VDESC(vop_mkdir); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + a.a_vap = vap; + rc = VCALL(dvp, VOFFSET(vop_mkdir), &a); + return (rc); } struct vop_rmdir_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode *a_vp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_rmdir_desc; -static __inline int VOP_RMDIR __P(( - struct vnode *dvp, - struct vnode *vp, - struct componentname *cnp)); -static __inline int VOP_RMDIR(dvp, vp, cnp) - struct vnode *dvp; - struct vnode *vp; - struct componentname *cnp; +static __inline int VOP_RMDIR +__P((struct vnode * dvp, struct vnode * vp, struct componentname * cnp)); +static __inline int +VOP_RMDIR(dvp, vp, cnp) + struct vnode *dvp; + struct vnode *vp; + struct componentname *cnp; { - struct vop_rmdir_args a; - int rc; - a.a_desc = VDESC(vop_rmdir); - a.a_dvp = dvp; - a.a_vp = vp; - a.a_cnp = cnp; - rc = VCALL(dvp, VOFFSET(vop_rmdir), &a); - return (rc); + struct vop_rmdir_args a; + int rc; + a.a_desc = VDESC(vop_rmdir); + a.a_dvp = dvp; + a.a_vp = vp; + a.a_cnp = cnp; + rc = VCALL(dvp, VOFFSET(vop_rmdir), &a); + return (rc); } struct vop_symlink_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - char *a_target; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; + char *a_target; }; extern struct vnodeop_desc vop_symlink_desc; -static __inline int VOP_SYMLINK __P(( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp, - struct vattr *vap, - char *target)); -static __inline int VOP_SYMLINK(dvp, vpp, cnp, vap, target) - struct vnode *dvp; - struct vnode **vpp; - struct componentname *cnp; - struct vattr *vap; - char *target; +static __inline int VOP_SYMLINK +__P((struct vnode * dvp, struct vnode ** vpp, struct componentname * cnp, + struct vattr * vap, char *target)); +static __inline int +VOP_SYMLINK(dvp, vpp, cnp, vap, target) + struct vnode *dvp; + struct vnode **vpp; + struct componentname *cnp; + struct vattr *vap; + char *target; { - struct vop_symlink_args a; - int rc; - a.a_desc = VDESC(vop_symlink); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - a.a_vap = vap; - a.a_target = target; - rc = VCALL(dvp, VOFFSET(vop_symlink), &a); - return (rc); + struct vop_symlink_args a; + int rc; + a.a_desc = VDESC(vop_symlink); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + a.a_vap = vap; + a.a_target = target; + rc = VCALL(dvp, VOFFSET(vop_symlink), &a); + return (rc); } struct vop_readdir_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - int *a_eofflag; - int *a_ncookies; - u_long **a_cookies; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + struct ucred *a_cred; + int *a_eofflag; + int *a_ncookies; + u_long **a_cookies; }; extern struct vnodeop_desc vop_readdir_desc; -static __inline int VOP_READDIR __P(( - struct vnode *vp, - struct uio *uio, - struct ucred *cred, - int *eofflag, - int *ncookies, - u_long **cookies)); -static __inline int VOP_READDIR(vp, uio, cred, eofflag, ncookies, cookies) - struct vnode *vp; - struct uio *uio; - struct ucred *cred; - int *eofflag; - int *ncookies; - u_long **cookies; +static __inline int VOP_READDIR +__P((struct vnode * vp, struct uio * uio, struct ucred * cred, int *eofflag, + int *ncookies, u_long ** cookies)); +static __inline int +VOP_READDIR(vp, uio, cred, eofflag, ncookies, cookies) + struct vnode *vp; + struct uio *uio; + struct ucred *cred; + int *eofflag; + int *ncookies; + u_long **cookies; { - struct vop_readdir_args a; - int rc; - a.a_desc = VDESC(vop_readdir); - a.a_vp = vp; - a.a_uio = uio; - a.a_cred = cred; - a.a_eofflag = eofflag; - a.a_ncookies = ncookies; - a.a_cookies = cookies; - rc = VCALL(vp, VOFFSET(vop_readdir), &a); - return (rc); + struct vop_readdir_args a; + int rc; + a.a_desc = VDESC(vop_readdir); + a.a_vp = vp; + a.a_uio = uio; + a.a_cred = cred; + a.a_eofflag = eofflag; + a.a_ncookies = ncookies; + a.a_cookies = cookies; + rc = VCALL(vp, VOFFSET(vop_readdir), &a); + return (rc); } struct vop_readlink_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + struct ucred *a_cred; }; extern struct vnodeop_desc vop_readlink_desc; -static __inline int VOP_READLINK __P(( - struct vnode *vp, - struct uio *uio, - struct ucred *cred)); -static __inline int VOP_READLINK(vp, uio, cred) - struct vnode *vp; - struct uio *uio; - struct ucred *cred; +static __inline int VOP_READLINK +__P((struct vnode * vp, struct uio * uio, struct ucred * cred)); +static __inline int +VOP_READLINK(vp, uio, cred) + struct vnode *vp; + struct uio *uio; + struct ucred *cred; { - struct vop_readlink_args a; - int rc; - a.a_desc = VDESC(vop_readlink); - a.a_vp = vp; - a.a_uio = uio; - a.a_cred = cred; - rc = VCALL(vp, VOFFSET(vop_readlink), &a); - return (rc); + struct vop_readlink_args a; + int rc; + a.a_desc = VDESC(vop_readlink); + a.a_vp = vp; + a.a_uio = uio; + a.a_cred = cred; + rc = VCALL(vp, VOFFSET(vop_readlink), &a); + return (rc); } struct vop_inactive_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct proc *a_p; }; extern struct vnodeop_desc vop_inactive_desc; -static __inline int VOP_INACTIVE __P(( - struct vnode *vp, - struct proc *p)); -static __inline int VOP_INACTIVE(vp, p) - struct vnode *vp; - struct proc *p; +static __inline int VOP_INACTIVE __P((struct vnode * vp, struct proc * p)); +static __inline int +VOP_INACTIVE(vp, p) + struct vnode *vp; + struct proc *p; { - struct vop_inactive_args a; - int rc; - a.a_desc = VDESC(vop_inactive); - a.a_vp = vp; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_inactive), &a); - return (rc); + struct vop_inactive_args a; + int rc; + a.a_desc = VDESC(vop_inactive); + a.a_vp = vp; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_inactive), &a); + return (rc); } struct vop_reclaim_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct proc *a_p; }; extern struct vnodeop_desc vop_reclaim_desc; -static __inline int VOP_RECLAIM __P(( - struct vnode *vp, - struct proc *p)); -static __inline int VOP_RECLAIM(vp, p) - struct vnode *vp; - struct proc *p; +static __inline int VOP_RECLAIM __P((struct vnode * vp, struct proc * p)); +static __inline int +VOP_RECLAIM(vp, p) + struct vnode *vp; + struct proc *p; { - struct vop_reclaim_args a; - int rc; - a.a_desc = VDESC(vop_reclaim); - a.a_vp = vp; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_reclaim), &a); - return (rc); + struct vop_reclaim_args a; + int rc; + a.a_desc = VDESC(vop_reclaim); + a.a_vp = vp; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_reclaim), &a); + return (rc); } struct vop_lock_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_flags; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_flags; + struct proc *a_p; }; extern struct vnodeop_desc vop_lock_desc; -static __inline int VOP_LOCK __P(( - struct vnode *vp, - int flags, - struct proc *p)); -static __inline int VOP_LOCK(vp, flags, p) - struct vnode *vp; - int flags; - struct proc *p; +static __inline int VOP_LOCK +__P((struct vnode * vp, int flags, struct proc * p)); +static __inline int +VOP_LOCK(vp, flags, p) + struct vnode *vp; + int flags; + struct proc *p; { - struct vop_lock_args a; - int rc; - a.a_desc = VDESC(vop_lock); - a.a_vp = vp; - a.a_flags = flags; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_lock), &a); - return (rc); + struct vop_lock_args a; + int rc; + a.a_desc = VDESC(vop_lock); + a.a_vp = vp; + a.a_flags = flags; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_lock), &a); + return (rc); } struct vop_unlock_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_flags; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_flags; + struct proc *a_p; }; extern struct vnodeop_desc vop_unlock_desc; -static __inline int VOP_UNLOCK __P(( - struct vnode *vp, - int flags, - struct proc *p)); -static __inline int VOP_UNLOCK(vp, flags, p) - struct vnode *vp; - int flags; - struct proc *p; +static __inline int VOP_UNLOCK +__P((struct vnode * vp, int flags, struct proc * p)); +static __inline int +VOP_UNLOCK(vp, flags, p) + struct vnode *vp; + int flags; + struct proc *p; { - struct vop_unlock_args a; - int rc; - a.a_desc = VDESC(vop_unlock); - a.a_vp = vp; - a.a_flags = flags; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_unlock), &a); - return (rc); + struct vop_unlock_args a; + int rc; + a.a_desc = VDESC(vop_unlock); + a.a_vp = vp; + a.a_flags = flags; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_unlock), &a); + return (rc); } struct vop_bmap_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - daddr_t a_bn; - struct vnode **a_vpp; - daddr_t *a_bnp; - int *a_runp; - int *a_runb; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + daddr_t a_bn; + struct vnode **a_vpp; + daddr_t *a_bnp; + int *a_runp; + int *a_runb; }; extern struct vnodeop_desc vop_bmap_desc; -static __inline int VOP_BMAP __P(( - struct vnode *vp, - daddr_t bn, - struct vnode **vpp, - daddr_t *bnp, - int *runp, - int *runb)); -static __inline int VOP_BMAP(vp, bn, vpp, bnp, runp, runb) - struct vnode *vp; - daddr_t bn; - struct vnode **vpp; - daddr_t *bnp; - int *runp; - int *runb; +static __inline int VOP_BMAP +__P((struct vnode * vp, daddr_t bn, struct vnode ** vpp, daddr_t * bnp, + int *runp, int *runb)); +static __inline int +VOP_BMAP(vp, bn, vpp, bnp, runp, runb) + struct vnode *vp; + daddr_t bn; + struct vnode **vpp; + daddr_t *bnp; + int *runp; + int *runb; { - struct vop_bmap_args a; - int rc; - a.a_desc = VDESC(vop_bmap); - a.a_vp = vp; - a.a_bn = bn; - a.a_vpp = vpp; - a.a_bnp = bnp; - a.a_runp = runp; - a.a_runb = runb; - rc = VCALL(vp, VOFFSET(vop_bmap), &a); - return (rc); + struct vop_bmap_args a; + int rc; + a.a_desc = VDESC(vop_bmap); + a.a_vp = vp; + a.a_bn = bn; + a.a_vpp = vpp; + a.a_bnp = bnp; + a.a_runp = runp; + a.a_runb = runb; + rc = VCALL(vp, VOFFSET(vop_bmap), &a); + return (rc); } struct vop_strategy_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct buf *a_bp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct buf *a_bp; }; extern struct vnodeop_desc vop_strategy_desc; -static __inline int VOP_STRATEGY __P(( - struct vnode *vp, - struct buf *bp)); -static __inline int VOP_STRATEGY(vp, bp) - struct vnode *vp; - struct buf *bp; +static __inline int VOP_STRATEGY __P((struct vnode * vp, struct buf * bp)); +static __inline int +VOP_STRATEGY(vp, bp) + struct vnode *vp; + struct buf *bp; { - struct vop_strategy_args a; - int rc; - a.a_desc = VDESC(vop_strategy); - a.a_vp = vp; - a.a_bp = bp; - rc = VCALL(vp, VOFFSET(vop_strategy), &a); - return (rc); + struct vop_strategy_args a; + int rc; + a.a_desc = VDESC(vop_strategy); + a.a_vp = vp; + a.a_bp = bp; + rc = VCALL(vp, VOFFSET(vop_strategy), &a); + return (rc); } struct vop_print_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; }; extern struct vnodeop_desc vop_print_desc; -static __inline int VOP_PRINT __P(( - struct vnode *vp)); -static __inline int VOP_PRINT(vp) - struct vnode *vp; +static __inline int VOP_PRINT __P((struct vnode * vp)); +static __inline int +VOP_PRINT(vp) + struct vnode *vp; { - struct vop_print_args a; - int rc; - a.a_desc = VDESC(vop_print); - a.a_vp = vp; - rc = VCALL(vp, VOFFSET(vop_print), &a); - return (rc); + struct vop_print_args a; + int rc; + a.a_desc = VDESC(vop_print); + a.a_vp = vp; + rc = VCALL(vp, VOFFSET(vop_print), &a); + return (rc); } struct vop_pathconf_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_name; - register_t *a_retval; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_name; + register_t *a_retval; }; extern struct vnodeop_desc vop_pathconf_desc; -static __inline int VOP_PATHCONF __P(( - struct vnode *vp, - int name, - register_t *retval)); -static __inline int VOP_PATHCONF(vp, name, retval) - struct vnode *vp; - int name; - register_t *retval; +static __inline int VOP_PATHCONF +__P((struct vnode * vp, int name, register_t * retval)); +static __inline int +VOP_PATHCONF(vp, name, retval) + struct vnode *vp; + int name; + register_t *retval; { - struct vop_pathconf_args a; - int rc; - a.a_desc = VDESC(vop_pathconf); - a.a_vp = vp; - a.a_name = name; - a.a_retval = retval; - rc = VCALL(vp, VOFFSET(vop_pathconf), &a); - return (rc); + struct vop_pathconf_args a; + int rc; + a.a_desc = VDESC(vop_pathconf); + a.a_vp = vp; + a.a_name = name; + a.a_retval = retval; + rc = VCALL(vp, VOFFSET(vop_pathconf), &a); + return (rc); } struct vop_advlock_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - caddr_t a_id; - int a_op; - struct flock *a_fl; - int a_flags; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + caddr_t a_id; + int a_op; + struct flock *a_fl; + int a_flags; }; extern struct vnodeop_desc vop_advlock_desc; -static __inline int VOP_ADVLOCK __P(( - struct vnode *vp, - caddr_t id, - int op, - struct flock *fl, - int flags)); -static __inline int VOP_ADVLOCK(vp, id, op, fl, flags) - struct vnode *vp; - caddr_t id; - int op; - struct flock *fl; - int flags; +static __inline int VOP_ADVLOCK +__P((struct vnode * vp, caddr_t id, int op, struct flock * fl, int flags)); +static __inline int +VOP_ADVLOCK(vp, id, op, fl, flags) + struct vnode *vp; + caddr_t id; + int op; + struct flock *fl; + int flags; { - struct vop_advlock_args a; - int rc; - a.a_desc = VDESC(vop_advlock); - a.a_vp = vp; - a.a_id = id; - a.a_op = op; - a.a_fl = fl; - a.a_flags = flags; - rc = VCALL(vp, VOFFSET(vop_advlock), &a); - return (rc); + struct vop_advlock_args a; + int rc; + a.a_desc = VDESC(vop_advlock); + a.a_vp = vp; + a.a_id = id; + a.a_op = op; + a.a_fl = fl; + a.a_flags = flags; + rc = VCALL(vp, VOFFSET(vop_advlock), &a); + return (rc); } struct vop_balloc_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - off_t a_startoffset; - int a_size; - struct ucred *a_cred; - int a_flags; - struct buf **a_bpp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + off_t a_startoffset; + int a_size; + struct ucred *a_cred; + int a_flags; + struct buf **a_bpp; }; extern struct vnodeop_desc vop_balloc_desc; -static __inline int VOP_BALLOC __P(( - struct vnode *vp, - off_t startoffset, - int size, - struct ucred *cred, - int flags, - struct buf **bpp)); -static __inline int VOP_BALLOC(vp, startoffset, size, cred, flags, bpp) - struct vnode *vp; - off_t startoffset; - int size; - struct ucred *cred; - int flags; - struct buf **bpp; +static __inline int VOP_BALLOC +__P((struct vnode * vp, off_t startoffset, int size, struct ucred * cred, + int flags, struct buf ** bpp)); +static __inline int +VOP_BALLOC(vp, startoffset, size, cred, flags, bpp) + struct vnode *vp; + off_t startoffset; + int size; + struct ucred *cred; + int flags; + struct buf **bpp; { - struct vop_balloc_args a; - int rc; - a.a_desc = VDESC(vop_balloc); - a.a_vp = vp; - a.a_startoffset = startoffset; - a.a_size = size; - a.a_cred = cred; - a.a_flags = flags; - a.a_bpp = bpp; - rc = VCALL(vp, VOFFSET(vop_balloc), &a); - return (rc); + struct vop_balloc_args a; + int rc; + a.a_desc = VDESC(vop_balloc); + a.a_vp = vp; + a.a_startoffset = startoffset; + a.a_size = size; + a.a_cred = cred; + a.a_flags = flags; + a.a_bpp = bpp; + rc = VCALL(vp, VOFFSET(vop_balloc), &a); + return (rc); } struct vop_reallocblks_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct cluster_save *a_buflist; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct cluster_save *a_buflist; }; extern struct vnodeop_desc vop_reallocblks_desc; -static __inline int VOP_REALLOCBLKS __P(( - struct vnode *vp, - struct cluster_save *buflist)); -static __inline int VOP_REALLOCBLKS(vp, buflist) - struct vnode *vp; - struct cluster_save *buflist; +static __inline int VOP_REALLOCBLKS +__P((struct vnode * vp, struct cluster_save * buflist)); +static __inline int +VOP_REALLOCBLKS(vp, buflist) + struct vnode *vp; + struct cluster_save *buflist; { - struct vop_reallocblks_args a; - int rc; - a.a_desc = VDESC(vop_reallocblks); - a.a_vp = vp; - a.a_buflist = buflist; - rc = VCALL(vp, VOFFSET(vop_reallocblks), &a); - return (rc); + struct vop_reallocblks_args a; + int rc; + a.a_desc = VDESC(vop_reallocblks); + a.a_vp = vp; + a.a_buflist = buflist; + rc = VCALL(vp, VOFFSET(vop_reallocblks), &a); + return (rc); } struct vop_getpages_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - vm_page_t *a_m; - int a_count; - int a_reqpage; - vm_ooffset_t a_offset; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + vm_page_t *a_m; + int a_count; + int a_reqpage; + vm_ooffset_t a_offset; }; extern struct vnodeop_desc vop_getpages_desc; -static __inline int VOP_GETPAGES __P(( - struct vnode *vp, - vm_page_t *m, - int count, - int reqpage, - vm_ooffset_t offset)); -static __inline int VOP_GETPAGES(vp, m, count, reqpage, offset) - struct vnode *vp; - vm_page_t *m; - int count; - int reqpage; - vm_ooffset_t offset; +static __inline int VOP_GETPAGES +__P((struct vnode * vp, vm_page_t * m, int count, int reqpage, + vm_ooffset_t offset)); +static __inline int +VOP_GETPAGES(vp, m, count, reqpage, offset) + struct vnode *vp; + vm_page_t *m; + int count; + int reqpage; + vm_ooffset_t offset; { - struct vop_getpages_args a; - int rc; - a.a_desc = VDESC(vop_getpages); - a.a_vp = vp; - a.a_m = m; - a.a_count = count; - a.a_reqpage = reqpage; - a.a_offset = offset; - rc = VCALL(vp, VOFFSET(vop_getpages), &a); - return (rc); + struct vop_getpages_args a; + int rc; + a.a_desc = VDESC(vop_getpages); + a.a_vp = vp; + a.a_m = m; + a.a_count = count; + a.a_reqpage = reqpage; + a.a_offset = offset; + rc = VCALL(vp, VOFFSET(vop_getpages), &a); + return (rc); } struct vop_putpages_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - vm_page_t *a_m; - int a_count; - int a_sync; - int *a_rtvals; - vm_ooffset_t a_offset; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + vm_page_t *a_m; + int a_count; + int a_sync; + int *a_rtvals; + vm_ooffset_t a_offset; }; extern struct vnodeop_desc vop_putpages_desc; -static __inline int VOP_PUTPAGES __P(( - struct vnode *vp, - vm_page_t *m, - int count, - int sync, - int *rtvals, - vm_ooffset_t offset)); -static __inline int VOP_PUTPAGES(vp, m, count, sync, rtvals, offset) - struct vnode *vp; - vm_page_t *m; - int count; - int sync; - int *rtvals; - vm_ooffset_t offset; +static __inline int VOP_PUTPAGES +__P((struct vnode * vp, vm_page_t * m, int count, int sync, int *rtvals, + vm_ooffset_t offset)); +static __inline int +VOP_PUTPAGES(vp, m, count, sync, rtvals, offset) + struct vnode *vp; + vm_page_t *m; + int count; + int sync; + int *rtvals; + vm_ooffset_t offset; { - struct vop_putpages_args a; - int rc; - a.a_desc = VDESC(vop_putpages); - a.a_vp = vp; - a.a_m = m; - a.a_count = count; - a.a_sync = sync; - a.a_rtvals = rtvals; - a.a_offset = offset; - rc = VCALL(vp, VOFFSET(vop_putpages), &a); - return (rc); + struct vop_putpages_args a; + int rc; + a.a_desc = VDESC(vop_putpages); + a.a_vp = vp; + a.a_m = m; + a.a_count = count; + a.a_sync = sync; + a.a_rtvals = rtvals; + a.a_offset = offset; + rc = VCALL(vp, VOFFSET(vop_putpages), &a); + return (rc); } struct vop_freeblks_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - daddr_t a_addr; - daddr_t a_length; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + daddr_t a_addr; + daddr_t a_length; }; extern struct vnodeop_desc vop_freeblks_desc; -static __inline int VOP_FREEBLKS __P(( - struct vnode *vp, - daddr_t addr, - daddr_t length)); -static __inline int VOP_FREEBLKS(vp, addr, length) - struct vnode *vp; - daddr_t addr; - daddr_t length; +static __inline int VOP_FREEBLKS +__P((struct vnode * vp, daddr_t addr, daddr_t length)); +static __inline int +VOP_FREEBLKS(vp, addr, length) + struct vnode *vp; + daddr_t addr; + daddr_t length; { - struct vop_freeblks_args a; - int rc; - a.a_desc = VDESC(vop_freeblks); - a.a_vp = vp; - a.a_addr = addr; - a.a_length = length; - rc = VCALL(vp, VOFFSET(vop_freeblks), &a); - return (rc); + struct vop_freeblks_args a; + int rc; + a.a_desc = VDESC(vop_freeblks); + a.a_vp = vp; + a.a_addr = addr; + a.a_length = length; + rc = VCALL(vp, VOFFSET(vop_freeblks), &a); + return (rc); } struct vop_bwrite_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct buf *a_bp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct buf *a_bp; }; extern struct vnodeop_desc vop_bwrite_desc; -static __inline int VOP_BWRITE __P(( - struct vnode *vp, - struct buf *bp)); -static __inline int VOP_BWRITE(vp, bp) - struct vnode *vp; - struct buf *bp; +static __inline int VOP_BWRITE __P((struct vnode * vp, struct buf * bp)); +static __inline int +VOP_BWRITE(vp, bp) + struct vnode *vp; + struct buf *bp; { - struct vop_bwrite_args a; - int rc; - a.a_desc = VDESC(vop_bwrite); - a.a_vp = vp; - a.a_bp = bp; - rc = VCALL(vp, VOFFSET(vop_bwrite), &a); - return (rc); + struct vop_bwrite_args a; + int rc; + a.a_desc = VDESC(vop_bwrite); + a.a_vp = vp; + a.a_bp = bp; + rc = VCALL(vp, VOFFSET(vop_bwrite), &a); + return (rc); } struct vop_getacl_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - acl_type_t a_type; - struct acl *a_aclp; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_getacl_desc; -static __inline int VOP_GETACL __P(( - struct vnode *vp, - acl_type_t type, - struct acl *aclp, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_GETACL(vp, type, aclp, cred, p) - struct vnode *vp; - acl_type_t type; - struct acl *aclp; - struct ucred *cred; - struct proc *p; +static __inline int VOP_GETACL +__P((struct vnode * vp, acl_type_t type, struct acl * aclp, + struct ucred * cred, struct proc * p)); +static __inline int +VOP_GETACL(vp, type, aclp, cred, p) + struct vnode *vp; + acl_type_t type; + struct acl *aclp; + struct ucred *cred; + struct proc *p; { - struct vop_getacl_args a; - int rc; - a.a_desc = VDESC(vop_getacl); - a.a_vp = vp; - a.a_type = type; - a.a_aclp = aclp; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_getacl), &a); - return (rc); + struct vop_getacl_args a; + int rc; + a.a_desc = VDESC(vop_getacl); + a.a_vp = vp; + a.a_type = type; + a.a_aclp = aclp; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_getacl), &a); + return (rc); } struct vop_setacl_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - acl_type_t a_type; - struct acl *a_aclp; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_setacl_desc; -static __inline int VOP_SETACL __P(( - struct vnode *vp, - acl_type_t type, - struct acl *aclp, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_SETACL(vp, type, aclp, cred, p) - struct vnode *vp; - acl_type_t type; - struct acl *aclp; - struct ucred *cred; - struct proc *p; +static __inline int VOP_SETACL +__P((struct vnode * vp, acl_type_t type, struct acl * aclp, + struct ucred * cred, struct proc * p)); +static __inline int +VOP_SETACL(vp, type, aclp, cred, p) + struct vnode *vp; + acl_type_t type; + struct acl *aclp; + struct ucred *cred; + struct proc *p; { - struct vop_setacl_args a; - int rc; - a.a_desc = VDESC(vop_setacl); - a.a_vp = vp; - a.a_type = type; - a.a_aclp = aclp; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_setacl), &a); - return (rc); + struct vop_setacl_args a; + int rc; + a.a_desc = VDESC(vop_setacl); + a.a_vp = vp; + a.a_type = type; + a.a_aclp = aclp; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_setacl), &a); + return (rc); } struct vop_aclcheck_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - acl_type_t a_type; - struct acl *a_aclp; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_aclcheck_desc; -static __inline int VOP_ACLCHECK __P(( - struct vnode *vp, - acl_type_t type, - struct acl *aclp, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_ACLCHECK(vp, type, aclp, cred, p) - struct vnode *vp; - acl_type_t type; - struct acl *aclp; - struct ucred *cred; - struct proc *p; +static __inline int VOP_ACLCHECK +__P((struct vnode * vp, acl_type_t type, struct acl * aclp, + struct ucred * cred, struct proc * p)); +static __inline int +VOP_ACLCHECK(vp, type, aclp, cred, p) + struct vnode *vp; + acl_type_t type; + struct acl *aclp; + struct ucred *cred; + struct proc *p; { - struct vop_aclcheck_args a; - int rc; - a.a_desc = VDESC(vop_aclcheck); - a.a_vp = vp; - a.a_type = type; - a.a_aclp = aclp; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_aclcheck), &a); - return (rc); + struct vop_aclcheck_args a; + int rc; + a.a_desc = VDESC(vop_aclcheck); + a.a_vp = vp; + a.a_type = type; + a.a_aclp = aclp; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_aclcheck), &a); + return (rc); } struct vop_getextattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - char *a_name; - struct uio *a_uio; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + char *a_name; + struct uio *a_uio; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_getextattr_desc; -static __inline int VOP_GETEXTATTR __P(( - struct vnode *vp, - char *name, - struct uio *uio, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_GETEXTATTR(vp, name, uio, cred, p) - struct vnode *vp; - char *name; - struct uio *uio; - struct ucred *cred; - struct proc *p; +static __inline int VOP_GETEXTATTR +__P((struct vnode * vp, char *name, struct uio * uio, struct ucred * cred, + struct proc * p)); +static __inline int +VOP_GETEXTATTR(vp, name, uio, cred, p) + struct vnode *vp; + char *name; + struct uio *uio; + struct ucred *cred; + struct proc *p; { - struct vop_getextattr_args a; - int rc; - a.a_desc = VDESC(vop_getextattr); - a.a_vp = vp; - a.a_name = name; - a.a_uio = uio; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_getextattr), &a); - return (rc); + struct vop_getextattr_args a; + int rc; + a.a_desc = VDESC(vop_getextattr); + a.a_vp = vp; + a.a_name = name; + a.a_uio = uio; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_getextattr), &a); + return (rc); } struct vop_setextattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - char *a_name; - struct uio *a_uio; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + char *a_name; + struct uio *a_uio; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_setextattr_desc; -static __inline int VOP_SETEXTATTR __P(( - struct vnode *vp, - char *name, - struct uio *uio, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_SETEXTATTR(vp, name, uio, cred, p) - struct vnode *vp; - char *name; - struct uio *uio; - struct ucred *cred; - struct proc *p; +static __inline int VOP_SETEXTATTR +__P((struct vnode * vp, char *name, struct uio * uio, struct ucred * cred, + struct proc * p)); +static __inline int +VOP_SETEXTATTR(vp, name, uio, cred, p) + struct vnode *vp; + char *name; + struct uio *uio; + struct ucred *cred; + struct proc *p; { - struct vop_setextattr_args a; - int rc; - a.a_desc = VDESC(vop_setextattr); - a.a_vp = vp; - a.a_name = name; - a.a_uio = uio; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_setextattr), &a); - return (rc); + struct vop_setextattr_args a; + int rc; + a.a_desc = VDESC(vop_setextattr); + a.a_vp = vp; + a.a_name = name; + a.a_uio = uio; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_setextattr), &a); + return (rc); } struct vop_createvobject_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct ucred *a_cred; - struct proc *a_p; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct ucred *a_cred; + struct proc *a_p; }; extern struct vnodeop_desc vop_createvobject_desc; -static __inline int VOP_CREATEVOBJECT __P(( - struct vnode *vp, - struct ucred *cred, - struct proc *p)); -static __inline int VOP_CREATEVOBJECT(vp, cred, p) - struct vnode *vp; - struct ucred *cred; - struct proc *p; +static __inline int VOP_CREATEVOBJECT +__P((struct vnode * vp, struct ucred * cred, struct proc * p)); +static __inline int +VOP_CREATEVOBJECT(vp, cred, p) + struct vnode *vp; + struct ucred *cred; + struct proc *p; { - struct vop_createvobject_args a; - int rc; - a.a_desc = VDESC(vop_createvobject); - a.a_vp = vp; - a.a_cred = cred; - a.a_p = p; - rc = VCALL(vp, VOFFSET(vop_createvobject), &a); - return (rc); + struct vop_createvobject_args a; + int rc; + a.a_desc = VDESC(vop_createvobject); + a.a_vp = vp; + a.a_cred = cred; + a.a_p = p; + rc = VCALL(vp, VOFFSET(vop_createvobject), &a); + return (rc); } struct vop_destroyvobject_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; }; extern struct vnodeop_desc vop_destroyvobject_desc; -static __inline int VOP_DESTROYVOBJECT __P(( - struct vnode *vp)); -static __inline int VOP_DESTROYVOBJECT(vp) - struct vnode *vp; +static __inline int VOP_DESTROYVOBJECT __P((struct vnode * vp)); +static __inline int +VOP_DESTROYVOBJECT(vp) + struct vnode *vp; { - struct vop_destroyvobject_args a; - int rc; - a.a_desc = VDESC(vop_destroyvobject); - a.a_vp = vp; - rc = VCALL(vp, VOFFSET(vop_destroyvobject), &a); - return (rc); + struct vop_destroyvobject_args a; + int rc; + a.a_desc = VDESC(vop_destroyvobject); + a.a_vp = vp; + rc = VCALL(vp, VOFFSET(vop_destroyvobject), &a); + return (rc); } struct vop_getvobject_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct vm_object **a_objpp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct vm_object **a_objpp; }; extern struct vnodeop_desc vop_getvobject_desc; -static __inline int VOP_GETVOBJECT __P(( - struct vnode *vp, - struct vm_object **objpp)); -static __inline int VOP_GETVOBJECT(vp, objpp) - struct vnode *vp; - struct vm_object **objpp; +static __inline int VOP_GETVOBJECT +__P((struct vnode * vp, struct vm_object ** objpp)); +static __inline int +VOP_GETVOBJECT(vp, objpp) + struct vnode *vp; + struct vm_object **objpp; { - struct vop_getvobject_args a; - int rc; - a.a_desc = VDESC(vop_getvobject); - a.a_vp = vp; - a.a_objpp = objpp; - rc = VCALL(vp, VOFFSET(vop_getvobject), &a); - return (rc); + struct vop_getvobject_args a; + int rc; + a.a_desc = VDESC(vop_getvobject); + a.a_vp = vp; + a.a_objpp = objpp; + rc = VCALL(vp, VOFFSET(vop_getvobject), &a); + return (rc); } diff --git a/src/afs/FBSD/vnode_if_5x.h b/src/afs/FBSD/vnode_if_5x.h index ebc731378..b70ef0c3d 100644 --- a/src/afs/FBSD/vnode_if_5x.h +++ b/src/afs/FBSD/vnode_if_5x.h @@ -7,1742 +7,1673 @@ extern struct vnodeop_desc vop_default_desc; struct vop_islocked_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct thread *a_td; }; extern struct vnodeop_desc vop_islocked_desc; -static __inline int VOP_ISLOCKED( - struct vnode *vp, - struct thread *td) +static __inline int +VOP_ISLOCKED(struct vnode *vp, struct thread *td) { - struct vop_islocked_args a; - int rc; - a.a_desc = VDESC(vop_islocked); - a.a_vp = vp; - a.a_td = td; - rc = VCALL(vp, VOFFSET(vop_islocked), &a); - CTR2(KTR_VOP, "VOP_ISLOCKED(vp 0x%lX, td 0x%lX)", vp, td); -if (rc == 0) { -} else { -} - return (rc); + struct vop_islocked_args a; + int rc; + a.a_desc = VDESC(vop_islocked); + a.a_vp = vp; + a.a_td = td; + rc = VCALL(vp, VOFFSET(vop_islocked), &a); + CTR2(KTR_VOP, "VOP_ISLOCKED(vp 0x%lX, td 0x%lX)", vp, td); + if (rc == 0) { + } else { + } + return (rc); } struct vop_lookup_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_lookup_desc; -static __inline int VOP_LOOKUP( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp) +static __inline int +VOP_LOOKUP(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) { - struct vop_lookup_args a; - int rc; - a.a_desc = VDESC(vop_lookup); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; + struct vop_lookup_args a; + int rc; + a.a_desc = VDESC(vop_lookup); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; #ifdef DEBUG_VFS_LOCKS - vop_lookup_pre(&a); + vop_lookup_pre(&a); #endif - rc = VCALL(dvp, VOFFSET(vop_lookup), &a); - CTR3(KTR_VOP, "VOP_LOOKUP(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX)", dvp, vpp, cnp); -if (rc == 0) { -} else { -} + rc = VCALL(dvp, VOFFSET(vop_lookup), &a); + CTR3(KTR_VOP, "VOP_LOOKUP(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX)", dvp, vpp, + cnp); + if (rc == 0) { + } else { + } #ifdef DEBUG_VFS_LOCKS - vop_lookup_post(&a, rc); + vop_lookup_post(&a, rc); #endif - return (rc); + return (rc); } struct vop_cachedlookup_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_cachedlookup_desc; -static __inline int VOP_CACHEDLOOKUP( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp) +static __inline int +VOP_CACHEDLOOKUP(struct vnode *dvp, struct vnode **vpp, + struct componentname *cnp) { - struct vop_cachedlookup_args a; - int rc; - a.a_desc = VDESC(vop_cachedlookup); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - ASSERT_VI_UNLOCKED(dvp, "VOP_CACHEDLOOKUP"); - ASSERT_VOP_LOCKED(dvp, "VOP_CACHEDLOOKUP"); - rc = VCALL(dvp, VOFFSET(vop_cachedlookup), &a); - CTR3(KTR_VOP, "VOP_CACHEDLOOKUP(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX)", dvp, vpp, cnp); -if (rc == 0) { + struct vop_cachedlookup_args a; + int rc; + a.a_desc = VDESC(vop_cachedlookup); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + ASSERT_VI_UNLOCKED(dvp, "VOP_CACHEDLOOKUP"); + ASSERT_VOP_LOCKED(dvp, "VOP_CACHEDLOOKUP"); + rc = VCALL(dvp, VOFFSET(vop_cachedlookup), &a); + CTR3(KTR_VOP, "VOP_CACHEDLOOKUP(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX)", dvp, + vpp, cnp); + if (rc == 0) { ASSERT_VI_UNLOCKED(dvp, "VOP_CACHEDLOOKUP"); -} else { + } else { ASSERT_VI_UNLOCKED(dvp, "VOP_CACHEDLOOKUP"); -} - return (rc); + } + return (rc); } struct vop_create_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; }; extern struct vnodeop_desc vop_create_desc; -static __inline int VOP_CREATE( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp, - struct vattr *vap) +static __inline int +VOP_CREATE(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, + struct vattr *vap) { - struct vop_create_args a; - int rc; - a.a_desc = VDESC(vop_create); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - a.a_vap = vap; - ASSERT_VI_UNLOCKED(dvp, "VOP_CREATE"); - ASSERT_VOP_LOCKED(dvp, "VOP_CREATE"); - rc = VCALL(dvp, VOFFSET(vop_create), &a); - CTR4(KTR_VOP, "VOP_CREATE(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX, vap 0x%lX)", dvp, vpp, cnp, vap); -if (rc == 0) { + struct vop_create_args a; + int rc; + a.a_desc = VDESC(vop_create); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + a.a_vap = vap; + ASSERT_VI_UNLOCKED(dvp, "VOP_CREATE"); + ASSERT_VOP_LOCKED(dvp, "VOP_CREATE"); + rc = VCALL(dvp, VOFFSET(vop_create), &a); + CTR4(KTR_VOP, "VOP_CREATE(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX, vap 0x%lX)", + dvp, vpp, cnp, vap); + if (rc == 0) { ASSERT_VI_UNLOCKED(dvp, "VOP_CREATE"); ASSERT_VOP_LOCKED(dvp, "VOP_CREATE"); -} else { + } else { ASSERT_VI_UNLOCKED(dvp, "VOP_CREATE"); ASSERT_VOP_LOCKED(dvp, "VOP_CREATE"); -} - return (rc); + } + return (rc); } struct vop_whiteout_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct componentname *a_cnp; - int a_flags; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct componentname *a_cnp; + int a_flags; }; extern struct vnodeop_desc vop_whiteout_desc; -static __inline int VOP_WHITEOUT( - struct vnode *dvp, - struct componentname *cnp, - int flags) +static __inline int +VOP_WHITEOUT(struct vnode *dvp, struct componentname *cnp, int flags) { - struct vop_whiteout_args a; - int rc; - a.a_desc = VDESC(vop_whiteout); - a.a_dvp = dvp; - a.a_cnp = cnp; - a.a_flags = flags; + struct vop_whiteout_args a; + int rc; + a.a_desc = VDESC(vop_whiteout); + a.a_dvp = dvp; + a.a_cnp = cnp; + a.a_flags = flags; + ASSERT_VI_UNLOCKED(dvp, "VOP_WHITEOUT"); + ASSERT_VOP_LOCKED(dvp, "VOP_WHITEOUT"); + rc = VCALL(dvp, VOFFSET(vop_whiteout), &a); + CTR3(KTR_VOP, "VOP_WHITEOUT(dvp 0x%lX, cnp 0x%lX, flags %ld)", dvp, cnp, + flags); + if (rc == 0) { ASSERT_VI_UNLOCKED(dvp, "VOP_WHITEOUT"); ASSERT_VOP_LOCKED(dvp, "VOP_WHITEOUT"); - rc = VCALL(dvp, VOFFSET(vop_whiteout), &a); - CTR3(KTR_VOP, "VOP_WHITEOUT(dvp 0x%lX, cnp 0x%lX, flags %ld)", dvp, cnp, flags); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(dvp, "VOP_WHITEOUT"); ASSERT_VOP_LOCKED(dvp, "VOP_WHITEOUT"); -} else { - ASSERT_VI_UNLOCKED(dvp, "VOP_WHITEOUT"); - ASSERT_VOP_LOCKED(dvp, "VOP_WHITEOUT"); -} - return (rc); + } + return (rc); } struct vop_mknod_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; }; extern struct vnodeop_desc vop_mknod_desc; -static __inline int VOP_MKNOD( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp, - struct vattr *vap) +static __inline int +VOP_MKNOD(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, + struct vattr *vap) { - struct vop_mknod_args a; - int rc; - a.a_desc = VDESC(vop_mknod); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - a.a_vap = vap; + struct vop_mknod_args a; + int rc; + a.a_desc = VDESC(vop_mknod); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + a.a_vap = vap; + ASSERT_VI_UNLOCKED(dvp, "VOP_MKNOD"); + ASSERT_VOP_LOCKED(dvp, "VOP_MKNOD"); + rc = VCALL(dvp, VOFFSET(vop_mknod), &a); + CTR4(KTR_VOP, "VOP_MKNOD(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX, vap 0x%lX)", + dvp, vpp, cnp, vap); + if (rc == 0) { ASSERT_VI_UNLOCKED(dvp, "VOP_MKNOD"); ASSERT_VOP_LOCKED(dvp, "VOP_MKNOD"); - rc = VCALL(dvp, VOFFSET(vop_mknod), &a); - CTR4(KTR_VOP, "VOP_MKNOD(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX, vap 0x%lX)", dvp, vpp, cnp, vap); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(dvp, "VOP_MKNOD"); ASSERT_VOP_LOCKED(dvp, "VOP_MKNOD"); -} else { - ASSERT_VI_UNLOCKED(dvp, "VOP_MKNOD"); - ASSERT_VOP_LOCKED(dvp, "VOP_MKNOD"); -} - return (rc); + } + return (rc); } struct vop_open_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_mode; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_open_desc; -static __inline int VOP_OPEN( - struct vnode *vp, - int mode, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_OPEN(struct vnode *vp, int mode, struct ucred *cred, struct thread *td) { - struct vop_open_args a; - int rc; - a.a_desc = VDESC(vop_open); - a.a_vp = vp; - a.a_mode = mode; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_OPEN"); - ASSERT_VOP_LOCKED(vp, "VOP_OPEN"); - rc = VCALL(vp, VOFFSET(vop_open), &a); - CTR4(KTR_VOP, "VOP_OPEN(vp 0x%lX, mode %ld, cred 0x%lX, td 0x%lX)", vp, mode, cred, td); -if (rc == 0) { + struct vop_open_args a; + int rc; + a.a_desc = VDESC(vop_open); + a.a_vp = vp; + a.a_mode = mode; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_OPEN"); + ASSERT_VOP_LOCKED(vp, "VOP_OPEN"); + rc = VCALL(vp, VOFFSET(vop_open), &a); + CTR4(KTR_VOP, "VOP_OPEN(vp 0x%lX, mode %ld, cred 0x%lX, td 0x%lX)", vp, + mode, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_OPEN"); ASSERT_VOP_LOCKED(vp, "VOP_OPEN"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_OPEN"); ASSERT_VOP_LOCKED(vp, "VOP_OPEN"); -} - return (rc); + } + return (rc); } struct vop_close_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_fflag; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_fflag; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_close_desc; -static __inline int VOP_CLOSE( - struct vnode *vp, - int fflag, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_CLOSE(struct vnode *vp, int fflag, struct ucred *cred, struct thread *td) { - struct vop_close_args a; - int rc; - a.a_desc = VDESC(vop_close); - a.a_vp = vp; - a.a_fflag = fflag; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_CLOSE"); - ASSERT_VOP_UNLOCKED(vp, "VOP_CLOSE"); - rc = VCALL(vp, VOFFSET(vop_close), &a); - CTR4(KTR_VOP, "VOP_CLOSE(vp 0x%lX, fflag %ld, cred 0x%lX, td 0x%lX)", vp, fflag, cred, td); -if (rc == 0) { + struct vop_close_args a; + int rc; + a.a_desc = VDESC(vop_close); + a.a_vp = vp; + a.a_fflag = fflag; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_CLOSE"); + ASSERT_VOP_UNLOCKED(vp, "VOP_CLOSE"); + rc = VCALL(vp, VOFFSET(vop_close), &a); + CTR4(KTR_VOP, "VOP_CLOSE(vp 0x%lX, fflag %ld, cred 0x%lX, td 0x%lX)", vp, + fflag, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_CLOSE"); ASSERT_VOP_UNLOCKED(vp, "VOP_CLOSE"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_CLOSE"); ASSERT_VOP_UNLOCKED(vp, "VOP_CLOSE"); -} - return (rc); + } + return (rc); } struct vop_access_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_mode; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_access_desc; -static __inline int VOP_ACCESS( - struct vnode *vp, - int mode, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_ACCESS(struct vnode *vp, int mode, struct ucred *cred, struct thread *td) { - struct vop_access_args a; - int rc; - a.a_desc = VDESC(vop_access); - a.a_vp = vp; - a.a_mode = mode; - a.a_cred = cred; - a.a_td = td; + struct vop_access_args a; + int rc; + a.a_desc = VDESC(vop_access); + a.a_vp = vp; + a.a_mode = mode; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_ACCESS"); + ASSERT_VOP_LOCKED(vp, "VOP_ACCESS"); + rc = VCALL(vp, VOFFSET(vop_access), &a); + CTR4(KTR_VOP, "VOP_ACCESS(vp 0x%lX, mode %ld, cred 0x%lX, td 0x%lX)", vp, + mode, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_ACCESS"); ASSERT_VOP_LOCKED(vp, "VOP_ACCESS"); - rc = VCALL(vp, VOFFSET(vop_access), &a); - CTR4(KTR_VOP, "VOP_ACCESS(vp 0x%lX, mode %ld, cred 0x%lX, td 0x%lX)", vp, mode, cred, td); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_ACCESS"); ASSERT_VOP_LOCKED(vp, "VOP_ACCESS"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_ACCESS"); - ASSERT_VOP_LOCKED(vp, "VOP_ACCESS"); -} - return (rc); + } + return (rc); } struct vop_getattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct vattr *a_vap; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_getattr_desc; -static __inline int VOP_GETATTR( - struct vnode *vp, - struct vattr *vap, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_GETATTR(struct vnode *vp, struct vattr *vap, struct ucred *cred, + struct thread *td) { - struct vop_getattr_args a; - int rc; - a.a_desc = VDESC(vop_getattr); - a.a_vp = vp; - a.a_vap = vap; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_GETATTR"); - ASSERT_VOP_LOCKED(vp, "VOP_GETATTR"); - rc = VCALL(vp, VOFFSET(vop_getattr), &a); - CTR4(KTR_VOP, "VOP_GETATTR(vp 0x%lX, vap 0x%lX, cred 0x%lX, td 0x%lX)", vp, vap, cred, td); -if (rc == 0) { + struct vop_getattr_args a; + int rc; + a.a_desc = VDESC(vop_getattr); + a.a_vp = vp; + a.a_vap = vap; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_GETATTR"); + ASSERT_VOP_LOCKED(vp, "VOP_GETATTR"); + rc = VCALL(vp, VOFFSET(vop_getattr), &a); + CTR4(KTR_VOP, "VOP_GETATTR(vp 0x%lX, vap 0x%lX, cred 0x%lX, td 0x%lX)", + vp, vap, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_GETATTR"); ASSERT_VOP_LOCKED(vp, "VOP_GETATTR"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_GETATTR"); ASSERT_VOP_LOCKED(vp, "VOP_GETATTR"); -} - return (rc); + } + return (rc); } struct vop_setattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct vattr *a_vap; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_setattr_desc; -static __inline int VOP_SETATTR( - struct vnode *vp, - struct vattr *vap, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_SETATTR(struct vnode *vp, struct vattr *vap, struct ucred *cred, + struct thread *td) { - struct vop_setattr_args a; - int rc; - a.a_desc = VDESC(vop_setattr); - a.a_vp = vp; - a.a_vap = vap; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_SETATTR"); - ASSERT_VOP_LOCKED(vp, "VOP_SETATTR"); - rc = VCALL(vp, VOFFSET(vop_setattr), &a); - CTR4(KTR_VOP, "VOP_SETATTR(vp 0x%lX, vap 0x%lX, cred 0x%lX, td 0x%lX)", vp, vap, cred, td); -if (rc == 0) { + struct vop_setattr_args a; + int rc; + a.a_desc = VDESC(vop_setattr); + a.a_vp = vp; + a.a_vap = vap; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_SETATTR"); + ASSERT_VOP_LOCKED(vp, "VOP_SETATTR"); + rc = VCALL(vp, VOFFSET(vop_setattr), &a); + CTR4(KTR_VOP, "VOP_SETATTR(vp 0x%lX, vap 0x%lX, cred 0x%lX, td 0x%lX)", + vp, vap, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_SETATTR"); ASSERT_VOP_LOCKED(vp, "VOP_SETATTR"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_SETATTR"); ASSERT_VOP_LOCKED(vp, "VOP_SETATTR"); -} - return (rc); + } + return (rc); } struct vop_read_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + int a_ioflag; + struct ucred *a_cred; }; extern struct vnodeop_desc vop_read_desc; -static __inline int VOP_READ( - struct vnode *vp, - struct uio *uio, - int ioflag, - struct ucred *cred) +static __inline int +VOP_READ(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) { - struct vop_read_args a; - int rc; - a.a_desc = VDESC(vop_read); - a.a_vp = vp; - a.a_uio = uio; - a.a_ioflag = ioflag; - a.a_cred = cred; + struct vop_read_args a; + int rc; + a.a_desc = VDESC(vop_read); + a.a_vp = vp; + a.a_uio = uio; + a.a_ioflag = ioflag; + a.a_cred = cred; + ASSERT_VI_UNLOCKED(vp, "VOP_READ"); + ASSERT_VOP_LOCKED(vp, "VOP_READ"); + rc = VCALL(vp, VOFFSET(vop_read), &a); + CTR4(KTR_VOP, "VOP_READ(vp 0x%lX, uio 0x%lX, ioflag %ld, cred 0x%lX)", vp, + uio, ioflag, cred); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_READ"); ASSERT_VOP_LOCKED(vp, "VOP_READ"); - rc = VCALL(vp, VOFFSET(vop_read), &a); - CTR4(KTR_VOP, "VOP_READ(vp 0x%lX, uio 0x%lX, ioflag %ld, cred 0x%lX)", vp, uio, ioflag, cred); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_READ"); ASSERT_VOP_LOCKED(vp, "VOP_READ"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_READ"); - ASSERT_VOP_LOCKED(vp, "VOP_READ"); -} - return (rc); + } + return (rc); } struct vop_write_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + int a_ioflag; + struct ucred *a_cred; }; extern struct vnodeop_desc vop_write_desc; -static __inline int VOP_WRITE( - struct vnode *vp, - struct uio *uio, - int ioflag, - struct ucred *cred) +static __inline int +VOP_WRITE(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred) { - struct vop_write_args a; - int rc; - a.a_desc = VDESC(vop_write); - a.a_vp = vp; - a.a_uio = uio; - a.a_ioflag = ioflag; - a.a_cred = cred; - ASSERT_VI_UNLOCKED(vp, "VOP_WRITE"); - ASSERT_VOP_LOCKED(vp, "VOP_WRITE"); - rc = VCALL(vp, VOFFSET(vop_write), &a); - CTR4(KTR_VOP, "VOP_WRITE(vp 0x%lX, uio 0x%lX, ioflag %ld, cred 0x%lX)", vp, uio, ioflag, cred); -if (rc == 0) { + struct vop_write_args a; + int rc; + a.a_desc = VDESC(vop_write); + a.a_vp = vp; + a.a_uio = uio; + a.a_ioflag = ioflag; + a.a_cred = cred; + ASSERT_VI_UNLOCKED(vp, "VOP_WRITE"); + ASSERT_VOP_LOCKED(vp, "VOP_WRITE"); + rc = VCALL(vp, VOFFSET(vop_write), &a); + CTR4(KTR_VOP, "VOP_WRITE(vp 0x%lX, uio 0x%lX, ioflag %ld, cred 0x%lX)", + vp, uio, ioflag, cred); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_WRITE"); ASSERT_VOP_LOCKED(vp, "VOP_WRITE"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_WRITE"); ASSERT_VOP_LOCKED(vp, "VOP_WRITE"); -} - return (rc); + } + return (rc); } struct vop_lease_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct thread *a_td; - struct ucred *a_cred; - int a_flag; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct thread *a_td; + struct ucred *a_cred; + int a_flag; }; extern struct vnodeop_desc vop_lease_desc; -static __inline int VOP_LEASE( - struct vnode *vp, - struct thread *td, - struct ucred *cred, - int flag) +static __inline int +VOP_LEASE(struct vnode *vp, struct thread *td, struct ucred *cred, int flag) { - struct vop_lease_args a; - int rc; - a.a_desc = VDESC(vop_lease); - a.a_vp = vp; - a.a_td = td; - a.a_cred = cred; - a.a_flag = flag; - ASSERT_VI_UNLOCKED(vp, "VOP_LEASE"); - rc = VCALL(vp, VOFFSET(vop_lease), &a); - CTR4(KTR_VOP, "VOP_LEASE(vp 0x%lX, td 0x%lX, cred 0x%lX, flag %ld)", vp, td, cred, flag); -if (rc == 0) { + struct vop_lease_args a; + int rc; + a.a_desc = VDESC(vop_lease); + a.a_vp = vp; + a.a_td = td; + a.a_cred = cred; + a.a_flag = flag; + ASSERT_VI_UNLOCKED(vp, "VOP_LEASE"); + rc = VCALL(vp, VOFFSET(vop_lease), &a); + CTR4(KTR_VOP, "VOP_LEASE(vp 0x%lX, td 0x%lX, cred 0x%lX, flag %ld)", vp, + td, cred, flag); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_LEASE"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_LEASE"); -} - return (rc); + } + return (rc); } struct vop_ioctl_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - u_long a_command; - caddr_t a_data; - int a_fflag; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + u_long a_command; + caddr_t a_data; + int a_fflag; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_ioctl_desc; -static __inline int VOP_IOCTL( - struct vnode *vp, - u_long command, - caddr_t data, - int fflag, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_IOCTL(struct vnode *vp, u_long command, caddr_t data, int fflag, + struct ucred *cred, struct thread *td) { - struct vop_ioctl_args a; - int rc; - a.a_desc = VDESC(vop_ioctl); - a.a_vp = vp; - a.a_command = command; - a.a_data = data; - a.a_fflag = fflag; - a.a_cred = cred; - a.a_td = td; + struct vop_ioctl_args a; + int rc; + a.a_desc = VDESC(vop_ioctl); + a.a_vp = vp; + a.a_command = command; + a.a_data = data; + a.a_fflag = fflag; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_IOCTL"); + ASSERT_VOP_UNLOCKED(vp, "VOP_IOCTL"); + rc = VCALL(vp, VOFFSET(vop_ioctl), &a); + CTR6(KTR_VOP, + "VOP_IOCTL(vp 0x%lX, command %ld, data %ld, fflag %ld, cred 0x%lX, td 0x%lX)", + vp, command, data, fflag, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_IOCTL"); ASSERT_VOP_UNLOCKED(vp, "VOP_IOCTL"); - rc = VCALL(vp, VOFFSET(vop_ioctl), &a); - CTR6(KTR_VOP, "VOP_IOCTL(vp 0x%lX, command %ld, data %ld, fflag %ld, cred 0x%lX, td 0x%lX)", vp, command, data, fflag, cred, td); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_IOCTL"); ASSERT_VOP_UNLOCKED(vp, "VOP_IOCTL"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_IOCTL"); - ASSERT_VOP_UNLOCKED(vp, "VOP_IOCTL"); -} - return (rc); + } + return (rc); } struct vop_poll_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_events; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_events; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_poll_desc; -static __inline int VOP_POLL( - struct vnode *vp, - int events, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_POLL(struct vnode *vp, int events, struct ucred *cred, struct thread *td) { - struct vop_poll_args a; - int rc; - a.a_desc = VDESC(vop_poll); - a.a_vp = vp; - a.a_events = events; - a.a_cred = cred; - a.a_td = td; + struct vop_poll_args a; + int rc; + a.a_desc = VDESC(vop_poll); + a.a_vp = vp; + a.a_events = events; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_POLL"); + ASSERT_VOP_UNLOCKED(vp, "VOP_POLL"); + rc = VCALL(vp, VOFFSET(vop_poll), &a); + CTR4(KTR_VOP, "VOP_POLL(vp 0x%lX, events %ld, cred 0x%lX, td 0x%lX)", vp, + events, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_POLL"); ASSERT_VOP_UNLOCKED(vp, "VOP_POLL"); - rc = VCALL(vp, VOFFSET(vop_poll), &a); - CTR4(KTR_VOP, "VOP_POLL(vp 0x%lX, events %ld, cred 0x%lX, td 0x%lX)", vp, events, cred, td); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_POLL"); ASSERT_VOP_UNLOCKED(vp, "VOP_POLL"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_POLL"); - ASSERT_VOP_UNLOCKED(vp, "VOP_POLL"); -} - return (rc); + } + return (rc); } struct vop_kqfilter_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct knote *a_kn; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct knote *a_kn; }; extern struct vnodeop_desc vop_kqfilter_desc; -static __inline int VOP_KQFILTER( - struct vnode *vp, - struct knote *kn) +static __inline int +VOP_KQFILTER(struct vnode *vp, struct knote *kn) { - struct vop_kqfilter_args a; - int rc; - a.a_desc = VDESC(vop_kqfilter); - a.a_vp = vp; - a.a_kn = kn; + struct vop_kqfilter_args a; + int rc; + a.a_desc = VDESC(vop_kqfilter); + a.a_vp = vp; + a.a_kn = kn; + ASSERT_VI_UNLOCKED(vp, "VOP_KQFILTER"); + ASSERT_VOP_UNLOCKED(vp, "VOP_KQFILTER"); + rc = VCALL(vp, VOFFSET(vop_kqfilter), &a); + CTR2(KTR_VOP, "VOP_KQFILTER(vp 0x%lX, kn 0x%lX)", vp, kn); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_KQFILTER"); ASSERT_VOP_UNLOCKED(vp, "VOP_KQFILTER"); - rc = VCALL(vp, VOFFSET(vop_kqfilter), &a); - CTR2(KTR_VOP, "VOP_KQFILTER(vp 0x%lX, kn 0x%lX)", vp, kn); -if (rc == 0) { - ASSERT_VI_UNLOCKED(vp, "VOP_KQFILTER"); - ASSERT_VOP_UNLOCKED(vp, "VOP_KQFILTER"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_KQFILTER"); ASSERT_VOP_UNLOCKED(vp, "VOP_KQFILTER"); -} - return (rc); + } + return (rc); } struct vop_revoke_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_flags; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_flags; }; extern struct vnodeop_desc vop_revoke_desc; -static __inline int VOP_REVOKE( - struct vnode *vp, - int flags) +static __inline int +VOP_REVOKE(struct vnode *vp, int flags) { - struct vop_revoke_args a; - int rc; - a.a_desc = VDESC(vop_revoke); - a.a_vp = vp; - a.a_flags = flags; - ASSERT_VI_UNLOCKED(vp, "VOP_REVOKE"); - ASSERT_VOP_UNLOCKED(vp, "VOP_REVOKE"); - rc = VCALL(vp, VOFFSET(vop_revoke), &a); - CTR2(KTR_VOP, "VOP_REVOKE(vp 0x%lX, flags %ld)", vp, flags); -if (rc == 0) { + struct vop_revoke_args a; + int rc; + a.a_desc = VDESC(vop_revoke); + a.a_vp = vp; + a.a_flags = flags; + ASSERT_VI_UNLOCKED(vp, "VOP_REVOKE"); + ASSERT_VOP_UNLOCKED(vp, "VOP_REVOKE"); + rc = VCALL(vp, VOFFSET(vop_revoke), &a); + CTR2(KTR_VOP, "VOP_REVOKE(vp 0x%lX, flags %ld)", vp, flags); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_REVOKE"); ASSERT_VOP_UNLOCKED(vp, "VOP_REVOKE"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_REVOKE"); ASSERT_VOP_UNLOCKED(vp, "VOP_REVOKE"); -} - return (rc); + } + return (rc); } struct vop_fsync_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct ucred *a_cred; - int a_waitfor; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct ucred *a_cred; + int a_waitfor; + struct thread *a_td; }; extern struct vnodeop_desc vop_fsync_desc; -static __inline int VOP_FSYNC( - struct vnode *vp, - struct ucred *cred, - int waitfor, - struct thread *td) +static __inline int +VOP_FSYNC(struct vnode *vp, struct ucred *cred, int waitfor, + struct thread *td) { - struct vop_fsync_args a; - int rc; - a.a_desc = VDESC(vop_fsync); - a.a_vp = vp; - a.a_cred = cred; - a.a_waitfor = waitfor; - a.a_td = td; + struct vop_fsync_args a; + int rc; + a.a_desc = VDESC(vop_fsync); + a.a_vp = vp; + a.a_cred = cred; + a.a_waitfor = waitfor; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_FSYNC"); + ASSERT_VOP_LOCKED(vp, "VOP_FSYNC"); + rc = VCALL(vp, VOFFSET(vop_fsync), &a); + CTR4(KTR_VOP, "VOP_FSYNC(vp 0x%lX, cred 0x%lX, waitfor %ld, td 0x%lX)", + vp, cred, waitfor, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_FSYNC"); ASSERT_VOP_LOCKED(vp, "VOP_FSYNC"); - rc = VCALL(vp, VOFFSET(vop_fsync), &a); - CTR4(KTR_VOP, "VOP_FSYNC(vp 0x%lX, cred 0x%lX, waitfor %ld, td 0x%lX)", vp, cred, waitfor, td); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_FSYNC"); ASSERT_VOP_LOCKED(vp, "VOP_FSYNC"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_FSYNC"); - ASSERT_VOP_LOCKED(vp, "VOP_FSYNC"); -} - return (rc); + } + return (rc); } struct vop_remove_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode *a_vp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_remove_desc; -static __inline int VOP_REMOVE( - struct vnode *dvp, - struct vnode *vp, - struct componentname *cnp) +static __inline int +VOP_REMOVE(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) { - struct vop_remove_args a; - int rc; - a.a_desc = VDESC(vop_remove); - a.a_dvp = dvp; - a.a_vp = vp; - a.a_cnp = cnp; - ASSERT_VI_UNLOCKED(dvp, "VOP_REMOVE"); - ASSERT_VOP_LOCKED(dvp, "VOP_REMOVE"); - ASSERT_VI_UNLOCKED(vp, "VOP_REMOVE"); - ASSERT_VOP_LOCKED(vp, "VOP_REMOVE"); - rc = VCALL(dvp, VOFFSET(vop_remove), &a); - CTR3(KTR_VOP, "VOP_REMOVE(dvp 0x%lX, vp 0x%lX, cnp 0x%lX)", dvp, vp, cnp); -if (rc == 0) { + struct vop_remove_args a; + int rc; + a.a_desc = VDESC(vop_remove); + a.a_dvp = dvp; + a.a_vp = vp; + a.a_cnp = cnp; + ASSERT_VI_UNLOCKED(dvp, "VOP_REMOVE"); + ASSERT_VOP_LOCKED(dvp, "VOP_REMOVE"); + ASSERT_VI_UNLOCKED(vp, "VOP_REMOVE"); + ASSERT_VOP_LOCKED(vp, "VOP_REMOVE"); + rc = VCALL(dvp, VOFFSET(vop_remove), &a); + CTR3(KTR_VOP, "VOP_REMOVE(dvp 0x%lX, vp 0x%lX, cnp 0x%lX)", dvp, vp, cnp); + if (rc == 0) { ASSERT_VI_UNLOCKED(dvp, "VOP_REMOVE"); ASSERT_VOP_LOCKED(dvp, "VOP_REMOVE"); ASSERT_VI_UNLOCKED(vp, "VOP_REMOVE"); ASSERT_VOP_LOCKED(vp, "VOP_REMOVE"); -} else { + } else { ASSERT_VI_UNLOCKED(dvp, "VOP_REMOVE"); ASSERT_VOP_LOCKED(dvp, "VOP_REMOVE"); ASSERT_VI_UNLOCKED(vp, "VOP_REMOVE"); ASSERT_VOP_LOCKED(vp, "VOP_REMOVE"); -} - return (rc); + } + return (rc); } struct vop_link_args { - struct vnodeop_desc *a_desc; - struct vnode *a_tdvp; - struct vnode *a_vp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_tdvp; + struct vnode *a_vp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_link_desc; -static __inline int VOP_LINK( - struct vnode *tdvp, - struct vnode *vp, - struct componentname *cnp) +static __inline int +VOP_LINK(struct vnode *tdvp, struct vnode *vp, struct componentname *cnp) { - struct vop_link_args a; - int rc; - a.a_desc = VDESC(vop_link); - a.a_tdvp = tdvp; - a.a_vp = vp; - a.a_cnp = cnp; - ASSERT_VI_UNLOCKED(tdvp, "VOP_LINK"); - ASSERT_VOP_LOCKED(tdvp, "VOP_LINK"); - ASSERT_VI_UNLOCKED(vp, "VOP_LINK"); - ASSERT_VOP_LOCKED(vp, "VOP_LINK"); - rc = VCALL(tdvp, VOFFSET(vop_link), &a); - CTR3(KTR_VOP, "VOP_LINK(tdvp 0x%lX, vp 0x%lX, cnp 0x%lX)", tdvp, vp, cnp); -if (rc == 0) { + struct vop_link_args a; + int rc; + a.a_desc = VDESC(vop_link); + a.a_tdvp = tdvp; + a.a_vp = vp; + a.a_cnp = cnp; + ASSERT_VI_UNLOCKED(tdvp, "VOP_LINK"); + ASSERT_VOP_LOCKED(tdvp, "VOP_LINK"); + ASSERT_VI_UNLOCKED(vp, "VOP_LINK"); + ASSERT_VOP_LOCKED(vp, "VOP_LINK"); + rc = VCALL(tdvp, VOFFSET(vop_link), &a); + CTR3(KTR_VOP, "VOP_LINK(tdvp 0x%lX, vp 0x%lX, cnp 0x%lX)", tdvp, vp, cnp); + if (rc == 0) { ASSERT_VI_UNLOCKED(tdvp, "VOP_LINK"); ASSERT_VOP_LOCKED(tdvp, "VOP_LINK"); ASSERT_VI_UNLOCKED(vp, "VOP_LINK"); ASSERT_VOP_LOCKED(vp, "VOP_LINK"); -} else { + } else { ASSERT_VI_UNLOCKED(tdvp, "VOP_LINK"); ASSERT_VOP_LOCKED(tdvp, "VOP_LINK"); ASSERT_VI_UNLOCKED(vp, "VOP_LINK"); ASSERT_VOP_LOCKED(vp, "VOP_LINK"); -} - return (rc); + } + return (rc); } struct vop_rename_args { - struct vnodeop_desc *a_desc; - struct vnode *a_fdvp; - struct vnode *a_fvp; - struct componentname *a_fcnp; - struct vnode *a_tdvp; - struct vnode *a_tvp; - struct componentname *a_tcnp; + struct vnodeop_desc *a_desc; + struct vnode *a_fdvp; + struct vnode *a_fvp; + struct componentname *a_fcnp; + struct vnode *a_tdvp; + struct vnode *a_tvp; + struct componentname *a_tcnp; }; extern struct vnodeop_desc vop_rename_desc; -static __inline int VOP_RENAME( - struct vnode *fdvp, - struct vnode *fvp, - struct componentname *fcnp, - struct vnode *tdvp, - struct vnode *tvp, - struct componentname *tcnp) +static __inline int +VOP_RENAME(struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp, + struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp) { - struct vop_rename_args a; - int rc; - a.a_desc = VDESC(vop_rename); - a.a_fdvp = fdvp; - a.a_fvp = fvp; - a.a_fcnp = fcnp; - a.a_tdvp = tdvp; - a.a_tvp = tvp; - a.a_tcnp = tcnp; + struct vop_rename_args a; + int rc; + a.a_desc = VDESC(vop_rename); + a.a_fdvp = fdvp; + a.a_fvp = fvp; + a.a_fcnp = fcnp; + a.a_tdvp = tdvp; + a.a_tvp = tvp; + a.a_tcnp = tcnp; #ifdef DEBUG_VFS_LOCKS - vop_rename_pre(&a); + vop_rename_pre(&a); #endif - rc = VCALL(fdvp, VOFFSET(vop_rename), &a); - CTR6(KTR_VOP, "VOP_RENAME(fdvp 0x%lX, fvp 0x%lX, fcnp 0x%lX, tdvp 0x%lX, tvp 0x%lX, tcnp 0x%lX)", fdvp, fvp, fcnp, tdvp, tvp, tcnp); -if (rc == 0) { -} else { -} - return (rc); + rc = VCALL(fdvp, VOFFSET(vop_rename), &a); + CTR6(KTR_VOP, + "VOP_RENAME(fdvp 0x%lX, fvp 0x%lX, fcnp 0x%lX, tdvp 0x%lX, tvp 0x%lX, tcnp 0x%lX)", + fdvp, fvp, fcnp, tdvp, tvp, tcnp); + if (rc == 0) { + } else { + } + return (rc); } struct vop_mkdir_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; }; extern struct vnodeop_desc vop_mkdir_desc; -static __inline int VOP_MKDIR( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp, - struct vattr *vap) +static __inline int +VOP_MKDIR(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, + struct vattr *vap) { - struct vop_mkdir_args a; - int rc; - a.a_desc = VDESC(vop_mkdir); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - a.a_vap = vap; - ASSERT_VI_UNLOCKED(dvp, "VOP_MKDIR"); - ASSERT_VOP_LOCKED(dvp, "VOP_MKDIR"); - rc = VCALL(dvp, VOFFSET(vop_mkdir), &a); - CTR4(KTR_VOP, "VOP_MKDIR(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX, vap 0x%lX)", dvp, vpp, cnp, vap); -if (rc == 0) { + struct vop_mkdir_args a; + int rc; + a.a_desc = VDESC(vop_mkdir); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + a.a_vap = vap; + ASSERT_VI_UNLOCKED(dvp, "VOP_MKDIR"); + ASSERT_VOP_LOCKED(dvp, "VOP_MKDIR"); + rc = VCALL(dvp, VOFFSET(vop_mkdir), &a); + CTR4(KTR_VOP, "VOP_MKDIR(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX, vap 0x%lX)", + dvp, vpp, cnp, vap); + if (rc == 0) { ASSERT_VI_UNLOCKED(dvp, "VOP_MKDIR"); ASSERT_VOP_LOCKED(dvp, "VOP_MKDIR"); -} else { + } else { ASSERT_VI_UNLOCKED(dvp, "VOP_MKDIR"); ASSERT_VOP_LOCKED(dvp, "VOP_MKDIR"); -} - return (rc); + } + return (rc); } struct vop_rmdir_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode *a_vp; + struct componentname *a_cnp; }; extern struct vnodeop_desc vop_rmdir_desc; -static __inline int VOP_RMDIR( - struct vnode *dvp, - struct vnode *vp, - struct componentname *cnp) +static __inline int +VOP_RMDIR(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) { - struct vop_rmdir_args a; - int rc; - a.a_desc = VDESC(vop_rmdir); - a.a_dvp = dvp; - a.a_vp = vp; - a.a_cnp = cnp; - ASSERT_VI_UNLOCKED(dvp, "VOP_RMDIR"); - ASSERT_VOP_LOCKED(dvp, "VOP_RMDIR"); - ASSERT_VI_UNLOCKED(vp, "VOP_RMDIR"); - ASSERT_VOP_LOCKED(vp, "VOP_RMDIR"); - rc = VCALL(dvp, VOFFSET(vop_rmdir), &a); - CTR3(KTR_VOP, "VOP_RMDIR(dvp 0x%lX, vp 0x%lX, cnp 0x%lX)", dvp, vp, cnp); -if (rc == 0) { + struct vop_rmdir_args a; + int rc; + a.a_desc = VDESC(vop_rmdir); + a.a_dvp = dvp; + a.a_vp = vp; + a.a_cnp = cnp; + ASSERT_VI_UNLOCKED(dvp, "VOP_RMDIR"); + ASSERT_VOP_LOCKED(dvp, "VOP_RMDIR"); + ASSERT_VI_UNLOCKED(vp, "VOP_RMDIR"); + ASSERT_VOP_LOCKED(vp, "VOP_RMDIR"); + rc = VCALL(dvp, VOFFSET(vop_rmdir), &a); + CTR3(KTR_VOP, "VOP_RMDIR(dvp 0x%lX, vp 0x%lX, cnp 0x%lX)", dvp, vp, cnp); + if (rc == 0) { ASSERT_VI_UNLOCKED(dvp, "VOP_RMDIR"); ASSERT_VOP_LOCKED(dvp, "VOP_RMDIR"); ASSERT_VI_UNLOCKED(vp, "VOP_RMDIR"); ASSERT_VOP_LOCKED(vp, "VOP_RMDIR"); -} else { + } else { ASSERT_VI_UNLOCKED(dvp, "VOP_RMDIR"); ASSERT_VOP_LOCKED(dvp, "VOP_RMDIR"); ASSERT_VI_UNLOCKED(vp, "VOP_RMDIR"); ASSERT_VOP_LOCKED(vp, "VOP_RMDIR"); -} - return (rc); + } + return (rc); } struct vop_symlink_args { - struct vnodeop_desc *a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - char *a_target; + struct vnodeop_desc *a_desc; + struct vnode *a_dvp; + struct vnode **a_vpp; + struct componentname *a_cnp; + struct vattr *a_vap; + char *a_target; }; extern struct vnodeop_desc vop_symlink_desc; -static __inline int VOP_SYMLINK( - struct vnode *dvp, - struct vnode **vpp, - struct componentname *cnp, - struct vattr *vap, - char *target) +static __inline int +VOP_SYMLINK(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, + struct vattr *vap, char *target) { - struct vop_symlink_args a; - int rc; - a.a_desc = VDESC(vop_symlink); - a.a_dvp = dvp; - a.a_vpp = vpp; - a.a_cnp = cnp; - a.a_vap = vap; - a.a_target = target; - ASSERT_VI_UNLOCKED(dvp, "VOP_SYMLINK"); - ASSERT_VOP_LOCKED(dvp, "VOP_SYMLINK"); - rc = VCALL(dvp, VOFFSET(vop_symlink), &a); - CTR5(KTR_VOP, "VOP_SYMLINK(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX, vap 0x%lX, target 0x%lX)", dvp, vpp, cnp, vap, target); -if (rc == 0) { + struct vop_symlink_args a; + int rc; + a.a_desc = VDESC(vop_symlink); + a.a_dvp = dvp; + a.a_vpp = vpp; + a.a_cnp = cnp; + a.a_vap = vap; + a.a_target = target; + ASSERT_VI_UNLOCKED(dvp, "VOP_SYMLINK"); + ASSERT_VOP_LOCKED(dvp, "VOP_SYMLINK"); + rc = VCALL(dvp, VOFFSET(vop_symlink), &a); + CTR5(KTR_VOP, + "VOP_SYMLINK(dvp 0x%lX, vpp 0x%lX, cnp 0x%lX, vap 0x%lX, target 0x%lX)", + dvp, vpp, cnp, vap, target); + if (rc == 0) { ASSERT_VI_UNLOCKED(dvp, "VOP_SYMLINK"); ASSERT_VOP_LOCKED(dvp, "VOP_SYMLINK"); -} else { + } else { ASSERT_VI_UNLOCKED(dvp, "VOP_SYMLINK"); ASSERT_VOP_LOCKED(dvp, "VOP_SYMLINK"); -} - return (rc); + } + return (rc); } struct vop_readdir_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - int *a_eofflag; - int *a_ncookies; - u_long **a_cookies; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + struct ucred *a_cred; + int *a_eofflag; + int *a_ncookies; + u_long **a_cookies; }; extern struct vnodeop_desc vop_readdir_desc; -static __inline int VOP_READDIR( - struct vnode *vp, - struct uio *uio, - struct ucred *cred, - int *eofflag, - int *ncookies, - u_long **cookies) +static __inline int +VOP_READDIR(struct vnode *vp, struct uio *uio, struct ucred *cred, + int *eofflag, int *ncookies, u_long ** cookies) { - struct vop_readdir_args a; - int rc; - a.a_desc = VDESC(vop_readdir); - a.a_vp = vp; - a.a_uio = uio; - a.a_cred = cred; - a.a_eofflag = eofflag; - a.a_ncookies = ncookies; - a.a_cookies = cookies; + struct vop_readdir_args a; + int rc; + a.a_desc = VDESC(vop_readdir); + a.a_vp = vp; + a.a_uio = uio; + a.a_cred = cred; + a.a_eofflag = eofflag; + a.a_ncookies = ncookies; + a.a_cookies = cookies; + ASSERT_VI_UNLOCKED(vp, "VOP_READDIR"); + ASSERT_VOP_LOCKED(vp, "VOP_READDIR"); + rc = VCALL(vp, VOFFSET(vop_readdir), &a); + CTR6(KTR_VOP, + "VOP_READDIR(vp 0x%lX, uio 0x%lX, cred 0x%lX, eofflag 0x%lX, ncookies 0x%lX, cookies 0x%lX)", + vp, uio, cred, eofflag, ncookies, cookies); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_READDIR"); ASSERT_VOP_LOCKED(vp, "VOP_READDIR"); - rc = VCALL(vp, VOFFSET(vop_readdir), &a); - CTR6(KTR_VOP, "VOP_READDIR(vp 0x%lX, uio 0x%lX, cred 0x%lX, eofflag 0x%lX, ncookies 0x%lX, cookies 0x%lX)", vp, uio, cred, eofflag, ncookies, cookies); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_READDIR"); ASSERT_VOP_LOCKED(vp, "VOP_READDIR"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_READDIR"); - ASSERT_VOP_LOCKED(vp, "VOP_READDIR"); -} - return (rc); + } + return (rc); } struct vop_readlink_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct uio *a_uio; + struct ucred *a_cred; }; extern struct vnodeop_desc vop_readlink_desc; -static __inline int VOP_READLINK( - struct vnode *vp, - struct uio *uio, - struct ucred *cred) +static __inline int +VOP_READLINK(struct vnode *vp, struct uio *uio, struct ucred *cred) { - struct vop_readlink_args a; - int rc; - a.a_desc = VDESC(vop_readlink); - a.a_vp = vp; - a.a_uio = uio; - a.a_cred = cred; - ASSERT_VI_UNLOCKED(vp, "VOP_READLINK"); - ASSERT_VOP_LOCKED(vp, "VOP_READLINK"); - rc = VCALL(vp, VOFFSET(vop_readlink), &a); - CTR3(KTR_VOP, "VOP_READLINK(vp 0x%lX, uio 0x%lX, cred 0x%lX)", vp, uio, cred); -if (rc == 0) { + struct vop_readlink_args a; + int rc; + a.a_desc = VDESC(vop_readlink); + a.a_vp = vp; + a.a_uio = uio; + a.a_cred = cred; + ASSERT_VI_UNLOCKED(vp, "VOP_READLINK"); + ASSERT_VOP_LOCKED(vp, "VOP_READLINK"); + rc = VCALL(vp, VOFFSET(vop_readlink), &a); + CTR3(KTR_VOP, "VOP_READLINK(vp 0x%lX, uio 0x%lX, cred 0x%lX)", vp, uio, + cred); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_READLINK"); ASSERT_VOP_LOCKED(vp, "VOP_READLINK"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_READLINK"); ASSERT_VOP_LOCKED(vp, "VOP_READLINK"); -} - return (rc); + } + return (rc); } struct vop_inactive_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct thread *a_td; }; extern struct vnodeop_desc vop_inactive_desc; -static __inline int VOP_INACTIVE( - struct vnode *vp, - struct thread *td) +static __inline int +VOP_INACTIVE(struct vnode *vp, struct thread *td) { - struct vop_inactive_args a; - int rc; - a.a_desc = VDESC(vop_inactive); - a.a_vp = vp; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_INACTIVE"); - ASSERT_VOP_LOCKED(vp, "VOP_INACTIVE"); - rc = VCALL(vp, VOFFSET(vop_inactive), &a); - CTR2(KTR_VOP, "VOP_INACTIVE(vp 0x%lX, td 0x%lX)", vp, td); -if (rc == 0) { + struct vop_inactive_args a; + int rc; + a.a_desc = VDESC(vop_inactive); + a.a_vp = vp; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_INACTIVE"); + ASSERT_VOP_LOCKED(vp, "VOP_INACTIVE"); + rc = VCALL(vp, VOFFSET(vop_inactive), &a); + CTR2(KTR_VOP, "VOP_INACTIVE(vp 0x%lX, td 0x%lX)", vp, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_INACTIVE"); ASSERT_VOP_UNLOCKED(vp, "VOP_INACTIVE"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_INACTIVE"); ASSERT_VOP_UNLOCKED(vp, "VOP_INACTIVE"); -} - return (rc); + } + return (rc); } struct vop_reclaim_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct thread *a_td; }; extern struct vnodeop_desc vop_reclaim_desc; -static __inline int VOP_RECLAIM( - struct vnode *vp, - struct thread *td) +static __inline int +VOP_RECLAIM(struct vnode *vp, struct thread *td) { - struct vop_reclaim_args a; - int rc; - a.a_desc = VDESC(vop_reclaim); - a.a_vp = vp; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_RECLAIM"); - ASSERT_VOP_UNLOCKED(vp, "VOP_RECLAIM"); - rc = VCALL(vp, VOFFSET(vop_reclaim), &a); - CTR2(KTR_VOP, "VOP_RECLAIM(vp 0x%lX, td 0x%lX)", vp, td); -if (rc == 0) { + struct vop_reclaim_args a; + int rc; + a.a_desc = VDESC(vop_reclaim); + a.a_vp = vp; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_RECLAIM"); + ASSERT_VOP_UNLOCKED(vp, "VOP_RECLAIM"); + rc = VCALL(vp, VOFFSET(vop_reclaim), &a); + CTR2(KTR_VOP, "VOP_RECLAIM(vp 0x%lX, td 0x%lX)", vp, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_RECLAIM"); ASSERT_VOP_UNLOCKED(vp, "VOP_RECLAIM"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_RECLAIM"); ASSERT_VOP_UNLOCKED(vp, "VOP_RECLAIM"); -} - return (rc); + } + return (rc); } struct vop_lock_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_flags; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_flags; + struct thread *a_td; }; extern struct vnodeop_desc vop_lock_desc; -static __inline int VOP_LOCK( - struct vnode *vp, - int flags, - struct thread *td) +static __inline int +VOP_LOCK(struct vnode *vp, int flags, struct thread *td) { - struct vop_lock_args a; - int rc; - a.a_desc = VDESC(vop_lock); - a.a_vp = vp; - a.a_flags = flags; - a.a_td = td; + struct vop_lock_args a; + int rc; + a.a_desc = VDESC(vop_lock); + a.a_vp = vp; + a.a_flags = flags; + a.a_td = td; #ifdef DEBUG_VFS_LOCKS - vop_lock_pre(&a); + vop_lock_pre(&a); #endif - rc = VCALL(vp, VOFFSET(vop_lock), &a); - CTR3(KTR_VOP, "VOP_LOCK(vp 0x%lX, flags %ld, td 0x%lX)", vp, flags, td); -if (rc == 0) { -} else { -} + rc = VCALL(vp, VOFFSET(vop_lock), &a); + CTR3(KTR_VOP, "VOP_LOCK(vp 0x%lX, flags %ld, td 0x%lX)", vp, flags, td); + if (rc == 0) { + } else { + } #ifdef DEBUG_VFS_LOCKS - vop_lock_post(&a, rc); + vop_lock_post(&a, rc); #endif - return (rc); + return (rc); } struct vop_unlock_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_flags; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_flags; + struct thread *a_td; }; extern struct vnodeop_desc vop_unlock_desc; -static __inline int VOP_UNLOCK( - struct vnode *vp, - int flags, - struct thread *td) +static __inline int +VOP_UNLOCK(struct vnode *vp, int flags, struct thread *td) { - struct vop_unlock_args a; - int rc; - a.a_desc = VDESC(vop_unlock); - a.a_vp = vp; - a.a_flags = flags; - a.a_td = td; + struct vop_unlock_args a; + int rc; + a.a_desc = VDESC(vop_unlock); + a.a_vp = vp; + a.a_flags = flags; + a.a_td = td; #ifdef DEBUG_VFS_LOCKS - vop_unlock_pre(&a); + vop_unlock_pre(&a); #endif - rc = VCALL(vp, VOFFSET(vop_unlock), &a); - CTR3(KTR_VOP, "VOP_UNLOCK(vp 0x%lX, flags %ld, td 0x%lX)", vp, flags, td); -if (rc == 0) { -} else { -} + rc = VCALL(vp, VOFFSET(vop_unlock), &a); + CTR3(KTR_VOP, "VOP_UNLOCK(vp 0x%lX, flags %ld, td 0x%lX)", vp, flags, td); + if (rc == 0) { + } else { + } #ifdef DEBUG_VFS_LOCKS - vop_unlock_post(&a, rc); + vop_unlock_post(&a, rc); #endif - return (rc); + return (rc); } struct vop_bmap_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - daddr_t a_bn; - struct vnode **a_vpp; - daddr_t *a_bnp; - int *a_runp; - int *a_runb; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + daddr_t a_bn; + struct vnode **a_vpp; + daddr_t *a_bnp; + int *a_runp; + int *a_runb; }; extern struct vnodeop_desc vop_bmap_desc; -static __inline int VOP_BMAP( - struct vnode *vp, - daddr_t bn, - struct vnode **vpp, - daddr_t *bnp, - int *runp, - int *runb) +static __inline int +VOP_BMAP(struct vnode *vp, daddr_t bn, struct vnode **vpp, daddr_t * bnp, + int *runp, int *runb) { - struct vop_bmap_args a; - int rc; - a.a_desc = VDESC(vop_bmap); - a.a_vp = vp; - a.a_bn = bn; - a.a_vpp = vpp; - a.a_bnp = bnp; - a.a_runp = runp; - a.a_runb = runb; - ASSERT_VI_UNLOCKED(vp, "VOP_BMAP"); - ASSERT_VOP_LOCKED(vp, "VOP_BMAP"); - rc = VCALL(vp, VOFFSET(vop_bmap), &a); - CTR6(KTR_VOP, "VOP_BMAP(vp 0x%lX, bn %ld, vpp 0x%lX, bnp 0x%lX, runp 0x%lX, runb 0x%lX)", vp, bn, vpp, bnp, runp, runb); -if (rc == 0) { + struct vop_bmap_args a; + int rc; + a.a_desc = VDESC(vop_bmap); + a.a_vp = vp; + a.a_bn = bn; + a.a_vpp = vpp; + a.a_bnp = bnp; + a.a_runp = runp; + a.a_runb = runb; + ASSERT_VI_UNLOCKED(vp, "VOP_BMAP"); + ASSERT_VOP_LOCKED(vp, "VOP_BMAP"); + rc = VCALL(vp, VOFFSET(vop_bmap), &a); + CTR6(KTR_VOP, + "VOP_BMAP(vp 0x%lX, bn %ld, vpp 0x%lX, bnp 0x%lX, runp 0x%lX, runb 0x%lX)", + vp, bn, vpp, bnp, runp, runb); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_BMAP"); ASSERT_VOP_LOCKED(vp, "VOP_BMAP"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_BMAP"); ASSERT_VOP_LOCKED(vp, "VOP_BMAP"); -} - return (rc); + } + return (rc); } struct vop_strategy_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct buf *a_bp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct buf *a_bp; }; extern struct vnodeop_desc vop_strategy_desc; -static __inline int VOP_STRATEGY( - struct vnode *vp, - struct buf *bp) +static __inline int +VOP_STRATEGY(struct vnode *vp, struct buf *bp) { - struct vop_strategy_args a; - int rc; - a.a_desc = VDESC(vop_strategy); - a.a_vp = vp; - a.a_bp = bp; + struct vop_strategy_args a; + int rc; + a.a_desc = VDESC(vop_strategy); + a.a_vp = vp; + a.a_bp = bp; #ifdef DEBUG_VFS_LOCKS - vop_strategy_pre(&a); + vop_strategy_pre(&a); #endif - rc = VCALL(vp, VOFFSET(vop_strategy), &a); - CTR2(KTR_VOP, "VOP_STRATEGY(vp 0x%lX, bp 0x%lX)", vp, bp); -if (rc == 0) { -} else { -} - return (rc); + rc = VCALL(vp, VOFFSET(vop_strategy), &a); + CTR2(KTR_VOP, "VOP_STRATEGY(vp 0x%lX, bp 0x%lX)", vp, bp); + if (rc == 0) { + } else { + } + return (rc); } struct vop_getwritemount_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct mount **a_mpp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct mount **a_mpp; }; extern struct vnodeop_desc vop_getwritemount_desc; -static __inline int VOP_GETWRITEMOUNT( - struct vnode *vp, - struct mount **mpp) +static __inline int +VOP_GETWRITEMOUNT(struct vnode *vp, struct mount **mpp) { - struct vop_getwritemount_args a; - int rc; - a.a_desc = VDESC(vop_getwritemount); - a.a_vp = vp; - a.a_mpp = mpp; + struct vop_getwritemount_args a; + int rc; + a.a_desc = VDESC(vop_getwritemount); + a.a_vp = vp; + a.a_mpp = mpp; + ASSERT_VI_UNLOCKED(vp, "VOP_GETWRITEMOUNT"); + rc = VCALL(vp, VOFFSET(vop_getwritemount), &a); + CTR2(KTR_VOP, "VOP_GETWRITEMOUNT(vp 0x%lX, mpp 0x%lX)", vp, mpp); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_GETWRITEMOUNT"); - rc = VCALL(vp, VOFFSET(vop_getwritemount), &a); - CTR2(KTR_VOP, "VOP_GETWRITEMOUNT(vp 0x%lX, mpp 0x%lX)", vp, mpp); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_GETWRITEMOUNT"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_GETWRITEMOUNT"); -} - return (rc); + } + return (rc); } struct vop_print_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; }; extern struct vnodeop_desc vop_print_desc; -static __inline int VOP_PRINT( - struct vnode *vp) +static __inline int +VOP_PRINT(struct vnode *vp) { - struct vop_print_args a; - int rc; - a.a_desc = VDESC(vop_print); - a.a_vp = vp; + struct vop_print_args a; + int rc; + a.a_desc = VDESC(vop_print); + a.a_vp = vp; + ASSERT_VI_UNLOCKED(vp, "VOP_PRINT"); + rc = VCALL(vp, VOFFSET(vop_print), &a); + CTR1(KTR_VOP, "VOP_PRINT(vp 0x%lX)", vp); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_PRINT"); - rc = VCALL(vp, VOFFSET(vop_print), &a); - CTR1(KTR_VOP, "VOP_PRINT(vp 0x%lX)", vp); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_PRINT"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_PRINT"); -} - return (rc); + } + return (rc); } struct vop_pathconf_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_name; - register_t *a_retval; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_name; + register_t *a_retval; }; extern struct vnodeop_desc vop_pathconf_desc; -static __inline int VOP_PATHCONF( - struct vnode *vp, - int name, - register_t *retval) +static __inline int +VOP_PATHCONF(struct vnode *vp, int name, register_t * retval) { - struct vop_pathconf_args a; - int rc; - a.a_desc = VDESC(vop_pathconf); - a.a_vp = vp; - a.a_name = name; - a.a_retval = retval; + struct vop_pathconf_args a; + int rc; + a.a_desc = VDESC(vop_pathconf); + a.a_vp = vp; + a.a_name = name; + a.a_retval = retval; + ASSERT_VI_UNLOCKED(vp, "VOP_PATHCONF"); + ASSERT_VOP_LOCKED(vp, "VOP_PATHCONF"); + rc = VCALL(vp, VOFFSET(vop_pathconf), &a); + CTR3(KTR_VOP, "VOP_PATHCONF(vp 0x%lX, name %ld, retval 0x%lX)", vp, name, + retval); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_PATHCONF"); ASSERT_VOP_LOCKED(vp, "VOP_PATHCONF"); - rc = VCALL(vp, VOFFSET(vop_pathconf), &a); - CTR3(KTR_VOP, "VOP_PATHCONF(vp 0x%lX, name %ld, retval 0x%lX)", vp, name, retval); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_PATHCONF"); ASSERT_VOP_LOCKED(vp, "VOP_PATHCONF"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_PATHCONF"); - ASSERT_VOP_LOCKED(vp, "VOP_PATHCONF"); -} - return (rc); + } + return (rc); } struct vop_advlock_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - caddr_t a_id; - int a_op; - struct flock *a_fl; - int a_flags; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + caddr_t a_id; + int a_op; + struct flock *a_fl; + int a_flags; }; extern struct vnodeop_desc vop_advlock_desc; -static __inline int VOP_ADVLOCK( - struct vnode *vp, - caddr_t id, - int op, - struct flock *fl, - int flags) +static __inline int +VOP_ADVLOCK(struct vnode *vp, caddr_t id, int op, struct flock *fl, int flags) { - struct vop_advlock_args a; - int rc; - a.a_desc = VDESC(vop_advlock); - a.a_vp = vp; - a.a_id = id; - a.a_op = op; - a.a_fl = fl; - a.a_flags = flags; + struct vop_advlock_args a; + int rc; + a.a_desc = VDESC(vop_advlock); + a.a_vp = vp; + a.a_id = id; + a.a_op = op; + a.a_fl = fl; + a.a_flags = flags; + ASSERT_VI_UNLOCKED(vp, "VOP_ADVLOCK"); + ASSERT_VOP_UNLOCKED(vp, "VOP_ADVLOCK"); + rc = VCALL(vp, VOFFSET(vop_advlock), &a); + CTR5(KTR_VOP, + "VOP_ADVLOCK(vp 0x%lX, id %ld, op %ld, fl 0x%lX, flags %ld)", vp, id, + op, fl, flags); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_ADVLOCK"); ASSERT_VOP_UNLOCKED(vp, "VOP_ADVLOCK"); - rc = VCALL(vp, VOFFSET(vop_advlock), &a); - CTR5(KTR_VOP, "VOP_ADVLOCK(vp 0x%lX, id %ld, op %ld, fl 0x%lX, flags %ld)", vp, id, op, fl, flags); -if (rc == 0) { - ASSERT_VI_UNLOCKED(vp, "VOP_ADVLOCK"); - ASSERT_VOP_UNLOCKED(vp, "VOP_ADVLOCK"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_ADVLOCK"); ASSERT_VOP_UNLOCKED(vp, "VOP_ADVLOCK"); -} - return (rc); + } + return (rc); } struct vop_reallocblks_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct cluster_save *a_buflist; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct cluster_save *a_buflist; }; extern struct vnodeop_desc vop_reallocblks_desc; -static __inline int VOP_REALLOCBLKS( - struct vnode *vp, - struct cluster_save *buflist) +static __inline int +VOP_REALLOCBLKS(struct vnode *vp, struct cluster_save *buflist) { - struct vop_reallocblks_args a; - int rc; - a.a_desc = VDESC(vop_reallocblks); - a.a_vp = vp; - a.a_buflist = buflist; - ASSERT_VI_UNLOCKED(vp, "VOP_REALLOCBLKS"); - ASSERT_VOP_LOCKED(vp, "VOP_REALLOCBLKS"); - rc = VCALL(vp, VOFFSET(vop_reallocblks), &a); - CTR2(KTR_VOP, "VOP_REALLOCBLKS(vp 0x%lX, buflist 0x%lX)", vp, buflist); -if (rc == 0) { + struct vop_reallocblks_args a; + int rc; + a.a_desc = VDESC(vop_reallocblks); + a.a_vp = vp; + a.a_buflist = buflist; + ASSERT_VI_UNLOCKED(vp, "VOP_REALLOCBLKS"); + ASSERT_VOP_LOCKED(vp, "VOP_REALLOCBLKS"); + rc = VCALL(vp, VOFFSET(vop_reallocblks), &a); + CTR2(KTR_VOP, "VOP_REALLOCBLKS(vp 0x%lX, buflist 0x%lX)", vp, buflist); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_REALLOCBLKS"); ASSERT_VOP_LOCKED(vp, "VOP_REALLOCBLKS"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_REALLOCBLKS"); ASSERT_VOP_LOCKED(vp, "VOP_REALLOCBLKS"); -} - return (rc); + } + return (rc); } struct vop_getpages_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - vm_page_t *a_m; - int a_count; - int a_reqpage; - vm_ooffset_t a_offset; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + vm_page_t *a_m; + int a_count; + int a_reqpage; + vm_ooffset_t a_offset; }; extern struct vnodeop_desc vop_getpages_desc; -static __inline int VOP_GETPAGES( - struct vnode *vp, - vm_page_t *m, - int count, - int reqpage, - vm_ooffset_t offset) +static __inline int +VOP_GETPAGES(struct vnode *vp, vm_page_t * m, int count, int reqpage, + vm_ooffset_t offset) { - struct vop_getpages_args a; - int rc; - a.a_desc = VDESC(vop_getpages); - a.a_vp = vp; - a.a_m = m; - a.a_count = count; - a.a_reqpage = reqpage; - a.a_offset = offset; + struct vop_getpages_args a; + int rc; + a.a_desc = VDESC(vop_getpages); + a.a_vp = vp; + a.a_m = m; + a.a_count = count; + a.a_reqpage = reqpage; + a.a_offset = offset; + ASSERT_VI_UNLOCKED(vp, "VOP_GETPAGES"); + ASSERT_VOP_LOCKED(vp, "VOP_GETPAGES"); + rc = VCALL(vp, VOFFSET(vop_getpages), &a); + CTR5(KTR_VOP, + "VOP_GETPAGES(vp 0x%lX, m 0x%lX, count %ld, reqpage %ld, offset %ld)", + vp, m, count, reqpage, offset); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_GETPAGES"); ASSERT_VOP_LOCKED(vp, "VOP_GETPAGES"); - rc = VCALL(vp, VOFFSET(vop_getpages), &a); - CTR5(KTR_VOP, "VOP_GETPAGES(vp 0x%lX, m 0x%lX, count %ld, reqpage %ld, offset %ld)", vp, m, count, reqpage, offset); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_GETPAGES"); ASSERT_VOP_LOCKED(vp, "VOP_GETPAGES"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_GETPAGES"); - ASSERT_VOP_LOCKED(vp, "VOP_GETPAGES"); -} - return (rc); + } + return (rc); } struct vop_putpages_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - vm_page_t *a_m; - int a_count; - int a_sync; - int *a_rtvals; - vm_ooffset_t a_offset; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + vm_page_t *a_m; + int a_count; + int a_sync; + int *a_rtvals; + vm_ooffset_t a_offset; }; extern struct vnodeop_desc vop_putpages_desc; -static __inline int VOP_PUTPAGES( - struct vnode *vp, - vm_page_t *m, - int count, - int sync, - int *rtvals, - vm_ooffset_t offset) +static __inline int +VOP_PUTPAGES(struct vnode *vp, vm_page_t * m, int count, int sync, + int *rtvals, vm_ooffset_t offset) { - struct vop_putpages_args a; - int rc; - a.a_desc = VDESC(vop_putpages); - a.a_vp = vp; - a.a_m = m; - a.a_count = count; - a.a_sync = sync; - a.a_rtvals = rtvals; - a.a_offset = offset; + struct vop_putpages_args a; + int rc; + a.a_desc = VDESC(vop_putpages); + a.a_vp = vp; + a.a_m = m; + a.a_count = count; + a.a_sync = sync; + a.a_rtvals = rtvals; + a.a_offset = offset; + ASSERT_VI_UNLOCKED(vp, "VOP_PUTPAGES"); + ASSERT_VOP_LOCKED(vp, "VOP_PUTPAGES"); + rc = VCALL(vp, VOFFSET(vop_putpages), &a); + CTR6(KTR_VOP, + "VOP_PUTPAGES(vp 0x%lX, m 0x%lX, count %ld, sync %ld, rtvals 0x%lX, offset %ld)", + vp, m, count, sync, rtvals, offset); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_PUTPAGES"); ASSERT_VOP_LOCKED(vp, "VOP_PUTPAGES"); - rc = VCALL(vp, VOFFSET(vop_putpages), &a); - CTR6(KTR_VOP, "VOP_PUTPAGES(vp 0x%lX, m 0x%lX, count %ld, sync %ld, rtvals 0x%lX, offset %ld)", vp, m, count, sync, rtvals, offset); -if (rc == 0) { - ASSERT_VI_UNLOCKED(vp, "VOP_PUTPAGES"); - ASSERT_VOP_LOCKED(vp, "VOP_PUTPAGES"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_PUTPAGES"); ASSERT_VOP_LOCKED(vp, "VOP_PUTPAGES"); -} - return (rc); + } + return (rc); } struct vop_freeblks_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - daddr_t a_addr; - daddr_t a_length; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + daddr_t a_addr; + daddr_t a_length; }; extern struct vnodeop_desc vop_freeblks_desc; -static __inline int VOP_FREEBLKS( - struct vnode *vp, - daddr_t addr, - daddr_t length) +static __inline int +VOP_FREEBLKS(struct vnode *vp, daddr_t addr, daddr_t length) { - struct vop_freeblks_args a; - int rc; - a.a_desc = VDESC(vop_freeblks); - a.a_vp = vp; - a.a_addr = addr; - a.a_length = length; - ASSERT_VI_UNLOCKED(vp, "VOP_FREEBLKS"); - rc = VCALL(vp, VOFFSET(vop_freeblks), &a); - CTR3(KTR_VOP, "VOP_FREEBLKS(vp 0x%lX, addr %ld, length %ld)", vp, addr, length); -if (rc == 0) { + struct vop_freeblks_args a; + int rc; + a.a_desc = VDESC(vop_freeblks); + a.a_vp = vp; + a.a_addr = addr; + a.a_length = length; + ASSERT_VI_UNLOCKED(vp, "VOP_FREEBLKS"); + rc = VCALL(vp, VOFFSET(vop_freeblks), &a); + CTR3(KTR_VOP, "VOP_FREEBLKS(vp 0x%lX, addr %ld, length %ld)", vp, addr, + length); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_FREEBLKS"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_FREEBLKS"); -} - return (rc); + } + return (rc); } struct vop_getacl_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - acl_type_t a_type; - struct acl *a_aclp; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_getacl_desc; -static __inline int VOP_GETACL( - struct vnode *vp, - acl_type_t type, - struct acl *aclp, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_GETACL(struct vnode *vp, acl_type_t type, struct acl *aclp, + struct ucred *cred, struct thread *td) { - struct vop_getacl_args a; - int rc; - a.a_desc = VDESC(vop_getacl); - a.a_vp = vp; - a.a_type = type; - a.a_aclp = aclp; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_GETACL"); - ASSERT_VOP_LOCKED(vp, "VOP_GETACL"); - rc = VCALL(vp, VOFFSET(vop_getacl), &a); - CTR5(KTR_VOP, "VOP_GETACL(vp 0x%lX, type %ld, aclp 0x%lX, cred 0x%lX, td 0x%lX)", vp, type, aclp, cred, td); -if (rc == 0) { + struct vop_getacl_args a; + int rc; + a.a_desc = VDESC(vop_getacl); + a.a_vp = vp; + a.a_type = type; + a.a_aclp = aclp; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_GETACL"); + ASSERT_VOP_LOCKED(vp, "VOP_GETACL"); + rc = VCALL(vp, VOFFSET(vop_getacl), &a); + CTR5(KTR_VOP, + "VOP_GETACL(vp 0x%lX, type %ld, aclp 0x%lX, cred 0x%lX, td 0x%lX)", + vp, type, aclp, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_GETACL"); ASSERT_VOP_LOCKED(vp, "VOP_GETACL"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_GETACL"); ASSERT_VOP_LOCKED(vp, "VOP_GETACL"); -} - return (rc); + } + return (rc); } struct vop_setacl_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - acl_type_t a_type; - struct acl *a_aclp; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_setacl_desc; -static __inline int VOP_SETACL( - struct vnode *vp, - acl_type_t type, - struct acl *aclp, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_SETACL(struct vnode *vp, acl_type_t type, struct acl *aclp, + struct ucred *cred, struct thread *td) { - struct vop_setacl_args a; - int rc; - a.a_desc = VDESC(vop_setacl); - a.a_vp = vp; - a.a_type = type; - a.a_aclp = aclp; - a.a_cred = cred; - a.a_td = td; + struct vop_setacl_args a; + int rc; + a.a_desc = VDESC(vop_setacl); + a.a_vp = vp; + a.a_type = type; + a.a_aclp = aclp; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_SETACL"); + ASSERT_VOP_LOCKED(vp, "VOP_SETACL"); + rc = VCALL(vp, VOFFSET(vop_setacl), &a); + CTR5(KTR_VOP, + "VOP_SETACL(vp 0x%lX, type %ld, aclp 0x%lX, cred 0x%lX, td 0x%lX)", + vp, type, aclp, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_SETACL"); ASSERT_VOP_LOCKED(vp, "VOP_SETACL"); - rc = VCALL(vp, VOFFSET(vop_setacl), &a); - CTR5(KTR_VOP, "VOP_SETACL(vp 0x%lX, type %ld, aclp 0x%lX, cred 0x%lX, td 0x%lX)", vp, type, aclp, cred, td); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_SETACL"); ASSERT_VOP_LOCKED(vp, "VOP_SETACL"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_SETACL"); - ASSERT_VOP_LOCKED(vp, "VOP_SETACL"); -} - return (rc); + } + return (rc); } struct vop_aclcheck_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - acl_type_t a_type; - struct acl *a_aclp; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_aclcheck_desc; -static __inline int VOP_ACLCHECK( - struct vnode *vp, - acl_type_t type, - struct acl *aclp, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_ACLCHECK(struct vnode *vp, acl_type_t type, struct acl *aclp, + struct ucred *cred, struct thread *td) { - struct vop_aclcheck_args a; - int rc; - a.a_desc = VDESC(vop_aclcheck); - a.a_vp = vp; - a.a_type = type; - a.a_aclp = aclp; - a.a_cred = cred; - a.a_td = td; + struct vop_aclcheck_args a; + int rc; + a.a_desc = VDESC(vop_aclcheck); + a.a_vp = vp; + a.a_type = type; + a.a_aclp = aclp; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_ACLCHECK"); + rc = VCALL(vp, VOFFSET(vop_aclcheck), &a); + CTR5(KTR_VOP, + "VOP_ACLCHECK(vp 0x%lX, type %ld, aclp 0x%lX, cred 0x%lX, td 0x%lX)", + vp, type, aclp, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_ACLCHECK"); - rc = VCALL(vp, VOFFSET(vop_aclcheck), &a); - CTR5(KTR_VOP, "VOP_ACLCHECK(vp 0x%lX, type %ld, aclp 0x%lX, cred 0x%lX, td 0x%lX)", vp, type, aclp, cred, td); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_ACLCHECK"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_ACLCHECK"); -} - return (rc); + } + return (rc); } struct vop_closeextattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_commit; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_commit; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_closeextattr_desc; -static __inline int VOP_CLOSEEXTATTR( - struct vnode *vp, - int commit, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_CLOSEEXTATTR(struct vnode *vp, int commit, struct ucred *cred, + struct thread *td) { - struct vop_closeextattr_args a; - int rc; - a.a_desc = VDESC(vop_closeextattr); - a.a_vp = vp; - a.a_commit = commit; - a.a_cred = cred; - a.a_td = td; + struct vop_closeextattr_args a; + int rc; + a.a_desc = VDESC(vop_closeextattr); + a.a_vp = vp; + a.a_commit = commit; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_CLOSEEXTATTR"); + ASSERT_VOP_LOCKED(vp, "VOP_CLOSEEXTATTR"); + rc = VCALL(vp, VOFFSET(vop_closeextattr), &a); + CTR4(KTR_VOP, + "VOP_CLOSEEXTATTR(vp 0x%lX, commit %ld, cred 0x%lX, td 0x%lX)", vp, + commit, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_CLOSEEXTATTR"); ASSERT_VOP_LOCKED(vp, "VOP_CLOSEEXTATTR"); - rc = VCALL(vp, VOFFSET(vop_closeextattr), &a); - CTR4(KTR_VOP, "VOP_CLOSEEXTATTR(vp 0x%lX, commit %ld, cred 0x%lX, td 0x%lX)", vp, commit, cred, td); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_CLOSEEXTATTR"); ASSERT_VOP_LOCKED(vp, "VOP_CLOSEEXTATTR"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_CLOSEEXTATTR"); - ASSERT_VOP_LOCKED(vp, "VOP_CLOSEEXTATTR"); -} - return (rc); + } + return (rc); } struct vop_getextattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_attrnamespace; - const char *a_name; - struct uio *a_uio; - size_t *a_size; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_attrnamespace; + const char *a_name; + struct uio *a_uio; + size_t *a_size; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_getextattr_desc; -static __inline int VOP_GETEXTATTR( - struct vnode *vp, - int attrnamespace, - const char *name, - struct uio *uio, - size_t *size, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_GETEXTATTR(struct vnode *vp, int attrnamespace, const char *name, + struct uio *uio, size_t * size, struct ucred *cred, + struct thread *td) { - struct vop_getextattr_args a; - int rc; - a.a_desc = VDESC(vop_getextattr); - a.a_vp = vp; - a.a_attrnamespace = attrnamespace; - a.a_name = name; - a.a_uio = uio; - a.a_size = size; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_GETEXTATTR"); - ASSERT_VOP_LOCKED(vp, "VOP_GETEXTATTR"); - rc = VCALL(vp, VOFFSET(vop_getextattr), &a); - CTR6(KTR_VOP, "VOP_GETEXTATTR(vp 0x%lX, attrnamespace %ld, name 0x%lX, uio 0x%lX, size 0x%lX, cred 0x%lX, td 0x%lX)", vp, attrnamespace, name, uio, size, cred); -if (rc == 0) { + struct vop_getextattr_args a; + int rc; + a.a_desc = VDESC(vop_getextattr); + a.a_vp = vp; + a.a_attrnamespace = attrnamespace; + a.a_name = name; + a.a_uio = uio; + a.a_size = size; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_GETEXTATTR"); + ASSERT_VOP_LOCKED(vp, "VOP_GETEXTATTR"); + rc = VCALL(vp, VOFFSET(vop_getextattr), &a); + CTR6(KTR_VOP, + "VOP_GETEXTATTR(vp 0x%lX, attrnamespace %ld, name 0x%lX, uio 0x%lX, size 0x%lX, cred 0x%lX, td 0x%lX)", + vp, attrnamespace, name, uio, size, cred); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_GETEXTATTR"); ASSERT_VOP_LOCKED(vp, "VOP_GETEXTATTR"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_GETEXTATTR"); ASSERT_VOP_LOCKED(vp, "VOP_GETEXTATTR"); -} - return (rc); + } + return (rc); } struct vop_openextattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_openextattr_desc; -static __inline int VOP_OPENEXTATTR( - struct vnode *vp, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_OPENEXTATTR(struct vnode *vp, struct ucred *cred, struct thread *td) { - struct vop_openextattr_args a; - int rc; - a.a_desc = VDESC(vop_openextattr); - a.a_vp = vp; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_OPENEXTATTR"); - ASSERT_VOP_LOCKED(vp, "VOP_OPENEXTATTR"); - rc = VCALL(vp, VOFFSET(vop_openextattr), &a); - CTR3(KTR_VOP, "VOP_OPENEXTATTR(vp 0x%lX, cred 0x%lX, td 0x%lX)", vp, cred, td); -if (rc == 0) { + struct vop_openextattr_args a; + int rc; + a.a_desc = VDESC(vop_openextattr); + a.a_vp = vp; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_OPENEXTATTR"); + ASSERT_VOP_LOCKED(vp, "VOP_OPENEXTATTR"); + rc = VCALL(vp, VOFFSET(vop_openextattr), &a); + CTR3(KTR_VOP, "VOP_OPENEXTATTR(vp 0x%lX, cred 0x%lX, td 0x%lX)", vp, cred, + td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_OPENEXTATTR"); ASSERT_VOP_LOCKED(vp, "VOP_OPENEXTATTR"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_OPENEXTATTR"); ASSERT_VOP_LOCKED(vp, "VOP_OPENEXTATTR"); -} - return (rc); + } + return (rc); } struct vop_setextattr_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - int a_attrnamespace; - const char *a_name; - struct uio *a_uio; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_attrnamespace; + const char *a_name; + struct uio *a_uio; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_setextattr_desc; -static __inline int VOP_SETEXTATTR( - struct vnode *vp, - int attrnamespace, - const char *name, - struct uio *uio, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_SETEXTATTR(struct vnode *vp, int attrnamespace, const char *name, + struct uio *uio, struct ucred *cred, struct thread *td) { - struct vop_setextattr_args a; - int rc; - a.a_desc = VDESC(vop_setextattr); - a.a_vp = vp; - a.a_attrnamespace = attrnamespace; - a.a_name = name; - a.a_uio = uio; - a.a_cred = cred; - a.a_td = td; + struct vop_setextattr_args a; + int rc; + a.a_desc = VDESC(vop_setextattr); + a.a_vp = vp; + a.a_attrnamespace = attrnamespace; + a.a_name = name; + a.a_uio = uio; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_SETEXTATTR"); + ASSERT_VOP_LOCKED(vp, "VOP_SETEXTATTR"); + rc = VCALL(vp, VOFFSET(vop_setextattr), &a); + CTR6(KTR_VOP, + "VOP_SETEXTATTR(vp 0x%lX, attrnamespace %ld, name 0x%lX, uio 0x%lX, cred 0x%lX, td 0x%lX)", + vp, attrnamespace, name, uio, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_SETEXTATTR"); ASSERT_VOP_LOCKED(vp, "VOP_SETEXTATTR"); - rc = VCALL(vp, VOFFSET(vop_setextattr), &a); - CTR6(KTR_VOP, "VOP_SETEXTATTR(vp 0x%lX, attrnamespace %ld, name 0x%lX, uio 0x%lX, cred 0x%lX, td 0x%lX)", vp, attrnamespace, name, uio, cred, td); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_SETEXTATTR"); ASSERT_VOP_LOCKED(vp, "VOP_SETEXTATTR"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_SETEXTATTR"); - ASSERT_VOP_LOCKED(vp, "VOP_SETEXTATTR"); -} - return (rc); + } + return (rc); } struct vop_createvobject_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_createvobject_desc; -static __inline int VOP_CREATEVOBJECT( - struct vnode *vp, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_CREATEVOBJECT(struct vnode *vp, struct ucred *cred, struct thread *td) { - struct vop_createvobject_args a; - int rc; - a.a_desc = VDESC(vop_createvobject); - a.a_vp = vp; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_CREATEVOBJECT"); - ASSERT_VOP_LOCKED(vp, "VOP_CREATEVOBJECT"); - rc = VCALL(vp, VOFFSET(vop_createvobject), &a); - CTR3(KTR_VOP, "VOP_CREATEVOBJECT(vp 0x%lX, cred 0x%lX, td 0x%lX)", vp, cred, td); -if (rc == 0) { + struct vop_createvobject_args a; + int rc; + a.a_desc = VDESC(vop_createvobject); + a.a_vp = vp; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_CREATEVOBJECT"); + ASSERT_VOP_LOCKED(vp, "VOP_CREATEVOBJECT"); + rc = VCALL(vp, VOFFSET(vop_createvobject), &a); + CTR3(KTR_VOP, "VOP_CREATEVOBJECT(vp 0x%lX, cred 0x%lX, td 0x%lX)", vp, + cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_CREATEVOBJECT"); ASSERT_VOP_LOCKED(vp, "VOP_CREATEVOBJECT"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_CREATEVOBJECT"); ASSERT_VOP_LOCKED(vp, "VOP_CREATEVOBJECT"); -} - return (rc); + } + return (rc); } struct vop_destroyvobject_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; }; extern struct vnodeop_desc vop_destroyvobject_desc; -static __inline int VOP_DESTROYVOBJECT( - struct vnode *vp) +static __inline int +VOP_DESTROYVOBJECT(struct vnode *vp) { - struct vop_destroyvobject_args a; - int rc; - a.a_desc = VDESC(vop_destroyvobject); - a.a_vp = vp; - ASSERT_VI_UNLOCKED(vp, "VOP_DESTROYVOBJECT"); - ASSERT_VOP_LOCKED(vp, "VOP_DESTROYVOBJECT"); - rc = VCALL(vp, VOFFSET(vop_destroyvobject), &a); - CTR1(KTR_VOP, "VOP_DESTROYVOBJECT(vp 0x%lX)", vp); -if (rc == 0) { + struct vop_destroyvobject_args a; + int rc; + a.a_desc = VDESC(vop_destroyvobject); + a.a_vp = vp; + ASSERT_VI_UNLOCKED(vp, "VOP_DESTROYVOBJECT"); + ASSERT_VOP_LOCKED(vp, "VOP_DESTROYVOBJECT"); + rc = VCALL(vp, VOFFSET(vop_destroyvobject), &a); + CTR1(KTR_VOP, "VOP_DESTROYVOBJECT(vp 0x%lX)", vp); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_DESTROYVOBJECT"); ASSERT_VOP_LOCKED(vp, "VOP_DESTROYVOBJECT"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_DESTROYVOBJECT"); ASSERT_VOP_LOCKED(vp, "VOP_DESTROYVOBJECT"); -} - return (rc); + } + return (rc); } struct vop_getvobject_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct vm_object **a_objpp; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct vm_object **a_objpp; }; extern struct vnodeop_desc vop_getvobject_desc; -static __inline int VOP_GETVOBJECT( - struct vnode *vp, - struct vm_object **objpp) +static __inline int +VOP_GETVOBJECT(struct vnode *vp, struct vm_object **objpp) { - struct vop_getvobject_args a; - int rc; - a.a_desc = VDESC(vop_getvobject); - a.a_vp = vp; - a.a_objpp = objpp; + struct vop_getvobject_args a; + int rc; + a.a_desc = VDESC(vop_getvobject); + a.a_vp = vp; + a.a_objpp = objpp; + ASSERT_VI_UNLOCKED(vp, "VOP_GETVOBJECT"); + ASSERT_VOP_LOCKED(vp, "VOP_GETVOBJECT"); + rc = VCALL(vp, VOFFSET(vop_getvobject), &a); + CTR2(KTR_VOP, "VOP_GETVOBJECT(vp 0x%lX, objpp 0x%lX)", vp, objpp); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_GETVOBJECT"); ASSERT_VOP_LOCKED(vp, "VOP_GETVOBJECT"); - rc = VCALL(vp, VOFFSET(vop_getvobject), &a); - CTR2(KTR_VOP, "VOP_GETVOBJECT(vp 0x%lX, objpp 0x%lX)", vp, objpp); -if (rc == 0) { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_GETVOBJECT"); ASSERT_VOP_LOCKED(vp, "VOP_GETVOBJECT"); -} else { - ASSERT_VI_UNLOCKED(vp, "VOP_GETVOBJECT"); - ASSERT_VOP_LOCKED(vp, "VOP_GETVOBJECT"); -} - return (rc); + } + return (rc); } struct vop_refreshlabel_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_refreshlabel_desc; -static __inline int VOP_REFRESHLABEL( - struct vnode *vp, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_REFRESHLABEL(struct vnode *vp, struct ucred *cred, struct thread *td) { - struct vop_refreshlabel_args a; - int rc; - a.a_desc = VDESC(vop_refreshlabel); - a.a_vp = vp; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_REFRESHLABEL"); - ASSERT_VOP_LOCKED(vp, "VOP_REFRESHLABEL"); - rc = VCALL(vp, VOFFSET(vop_refreshlabel), &a); - CTR3(KTR_VOP, "VOP_REFRESHLABEL(vp 0x%lX, cred 0x%lX, td 0x%lX)", vp, cred, td); -if (rc == 0) { + struct vop_refreshlabel_args a; + int rc; + a.a_desc = VDESC(vop_refreshlabel); + a.a_vp = vp; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_REFRESHLABEL"); + ASSERT_VOP_LOCKED(vp, "VOP_REFRESHLABEL"); + rc = VCALL(vp, VOFFSET(vop_refreshlabel), &a); + CTR3(KTR_VOP, "VOP_REFRESHLABEL(vp 0x%lX, cred 0x%lX, td 0x%lX)", vp, + cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_REFRESHLABEL"); ASSERT_VOP_LOCKED(vp, "VOP_REFRESHLABEL"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_REFRESHLABEL"); ASSERT_VOP_LOCKED(vp, "VOP_REFRESHLABEL"); -} - return (rc); + } + return (rc); } struct vop_setlabel_args { - struct vnodeop_desc *a_desc; - struct vnode *a_vp; - struct label *a_label; - struct ucred *a_cred; - struct thread *a_td; + struct vnodeop_desc *a_desc; + struct vnode *a_vp; + struct label *a_label; + struct ucred *a_cred; + struct thread *a_td; }; extern struct vnodeop_desc vop_setlabel_desc; -static __inline int VOP_SETLABEL( - struct vnode *vp, - struct label *label, - struct ucred *cred, - struct thread *td) +static __inline int +VOP_SETLABEL(struct vnode *vp, struct label *label, struct ucred *cred, + struct thread *td) { - struct vop_setlabel_args a; - int rc; - a.a_desc = VDESC(vop_setlabel); - a.a_vp = vp; - a.a_label = label; - a.a_cred = cred; - a.a_td = td; - ASSERT_VI_UNLOCKED(vp, "VOP_SETLABEL"); - ASSERT_VOP_LOCKED(vp, "VOP_SETLABEL"); - rc = VCALL(vp, VOFFSET(vop_setlabel), &a); - CTR4(KTR_VOP, "VOP_SETLABEL(vp 0x%lX, label 0x%lX, cred 0x%lX, td 0x%lX)", vp, label, cred, td); -if (rc == 0) { + struct vop_setlabel_args a; + int rc; + a.a_desc = VDESC(vop_setlabel); + a.a_vp = vp; + a.a_label = label; + a.a_cred = cred; + a.a_td = td; + ASSERT_VI_UNLOCKED(vp, "VOP_SETLABEL"); + ASSERT_VOP_LOCKED(vp, "VOP_SETLABEL"); + rc = VCALL(vp, VOFFSET(vop_setlabel), &a); + CTR4(KTR_VOP, "VOP_SETLABEL(vp 0x%lX, label 0x%lX, cred 0x%lX, td 0x%lX)", + vp, label, cred, td); + if (rc == 0) { ASSERT_VI_UNLOCKED(vp, "VOP_SETLABEL"); ASSERT_VOP_LOCKED(vp, "VOP_SETLABEL"); -} else { + } else { ASSERT_VI_UNLOCKED(vp, "VOP_SETLABEL"); ASSERT_VOP_LOCKED(vp, "VOP_SETLABEL"); -} - return (rc); + } + return (rc); } diff --git a/src/afs/HPUX/osi_debug.c b/src/afs/HPUX/osi_debug.c index 964a358b4..12d86df49 100644 --- a/src/afs/HPUX/osi_debug.c +++ b/src/afs/HPUX/osi_debug.c @@ -10,7 +10,8 @@ #include #include "param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "sysincludes.h" #include "afsincludes.h" diff --git a/src/afs/HPUX/osi_file.c b/src/afs/HPUX/osi_file.c index accd3de5f..81c7c8e42 100644 --- a/src/afs/HPUX/osi_file.c +++ b/src/afs/HPUX/osi_file.c @@ -10,22 +10,24 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #include "afs/osi_inode.h" /* igetinode() */ -int afs_osicred_initialized=0; -struct AFS_UCRED afs_osi_cred; +int afs_osicred_initialized = 0; +struct AFS_UCRED afs_osi_cred; afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct vfs *afs_cacheVfsp; -void *osi_UFSOpen(afs_int32 ainode) +void * +osi_UFSOpen(afs_int32 ainode) { struct inode *ip; register struct osi_file *afile = NULL; @@ -33,7 +35,7 @@ void *osi_UFSOpen(afs_int32 ainode) afs_int32 code = 0; int dummy; AFS_STATCNT(osi_UFSOpen); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) { + if (cacheDiskType != AFS_FCACHE_TYPE_UFS) { osi_Panic("UFSOpen called for non-UFS cache\n"); } if (!afs_osicred_initialized) { @@ -42,10 +44,11 @@ void *osi_UFSOpen(afs_int32 ainode) crhold(&afs_osi_cred); /* don't let it evaporate, since it is static */ afs_osicred_initialized = 1; } - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); setuerror(0); AFS_GUNLOCK(); - ip = (struct inode *) igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode,&dummy); + ip = (struct inode *)igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, + (ino_t) ainode, &dummy); AFS_GLOCK(); if (getuerror()) { osi_FreeSmallSpace(afile); @@ -55,17 +58,18 @@ void *osi_UFSOpen(afs_int32 ainode) afile->vnode = ITOV(ip); afile->size = VTOI(afile->vnode)->i_size; afile->offset = 0; - afile->proc = (int (*)()) 0; - afile->inum = ainode; /* for hint validity checking */ + afile->proc = (int (*)())0; + afile->inum = ainode; /* for hint validity checking */ return (void *)afile; } -int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) +int +afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) { register afs_int32 code; struct vattr tvattr; AFS_STATCNT(osi_Stat); - MObtainWriteLock(&afs_xosi,320); + MObtainWriteLock(&afs_xosi, 320); AFS_GUNLOCK(); code = VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, VSYNC); AFS_GLOCK(); @@ -79,18 +83,20 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta return code; } -int osi_UFSClose(register struct osi_file *afile) +int +osi_UFSClose(register struct osi_file *afile) { - AFS_STATCNT(osi_Close); - if(afile->vnode) { + AFS_STATCNT(osi_Close); + if (afile->vnode) { AFS_RELE(afile->vnode); - } - - osi_FreeSmallSpace(afile); - return 0; + } + + osi_FreeSmallSpace(afile); + return 0; } -int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) +int +osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) { struct AFS_UCRED *oldCred; struct vattr tvattr; @@ -103,64 +109,69 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) * small enough. Check now and save some time. */ code = afs_osi_Stat(afile, &tstat); - if (code || tstat.size <= asize) return code; - MObtainWriteLock(&afs_xosi,321); + if (code || tstat.size <= asize) + return code; + MObtainWriteLock(&afs_xosi, 321); VATTR_NULL(&tvattr); /* note that this credential swapping stuff is only necessary because - of ufs's references directly to u.u_cred instead of to - credentials parameter. Probably should fix ufs some day. */ + * of ufs's references directly to u.u_cred instead of to + * credentials parameter. Probably should fix ufs some day. */ oldCred = p_cred(u.u_procp); set_p_cred(u.u_procp, &afs_osi_cred); tvattr.va_size = asize; AFS_GUNLOCK(); code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, 0); AFS_GLOCK(); - set_p_cred(u.u_procp, oldCred); /* restore */ + set_p_cred(u.u_procp, oldCred); /* restore */ MReleaseWriteLock(&afs_xosi); return code; } -void osi_DisableAtimes(struct vnode *avp) +void +osi_DisableAtimes(struct vnode *avp) { - struct inode *ip = VTOI(avp); - ip->i_flag &= ~IACC; + struct inode *ip = VTOI(avp); + ip->i_flag &= ~IACC; } /* Generic read interface */ -int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize) +int +afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; long resid; register afs_int32 code; - register afs_int32 cnt1=0; + register afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ - if ( !afile ) { - if ( !afs_shuttingdown ) + if (!afile) { + if (!afs_shuttingdown) osi_Panic("osi_Read called with null param"); else return EIO; } - if (offset != -1) afile->offset = offset; -retry_IO: + if (offset != -1) + afile->offset = offset; + retry_IO: AFS_GUNLOCK(); - code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &resid); + code = + gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, + AFS_UIOSYS, IO_UNIT, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); - } - else { - afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, (afs_int32) resid, - ICL_TYPE_INT32, code); + } else { + afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, + (afs_int32) resid, ICL_TYPE_INT32, code); /* * To handle periodic low-level EFAULT failures that we've seen with the * Weitek chip; in all observed failed cases a second read succeeded. @@ -169,49 +180,54 @@ retry_IO: afs_stats_cmperf.osiread_efaults++; goto retry_IO; } - setuerror(code); + setuerror(code); code = -1; } return code; } /* Generic write interface */ -int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) +int +afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; long resid; register afs_int32 code; AFS_STATCNT(osi_Write); - if ( !afile ) - osi_Panic("afs_osi_Write called with null param"); - if (offset != -1) afile->offset = offset; + if (!afile) + osi_Panic("afs_osi_Write called with null param"); + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); - code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &resid); + code = + gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, + afile->offset, AFS_UIOSYS, IO_UNIT, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; - } - else { - if (code == ENOSPC) afs_warnuser("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); + } else { + if (code == ENOSPC) + afs_warnuser + ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); setuerror(code); code = -1; } if (afile->proc) { - (*afile->proc)(afile, code); + (*afile->proc) (afile, code); } return code; } -void shutdown_osifile(void) +void +shutdown_osifile(void) { - extern int afs_cold_shutdown; + extern int afs_cold_shutdown; - AFS_STATCNT(shutdown_osifile); - if (afs_cold_shutdown) { - afs_osicred_initialized = 0; - } + AFS_STATCNT(shutdown_osifile); + if (afs_cold_shutdown) { + afs_osicred_initialized = 0; + } } - diff --git a/src/afs/HPUX/osi_groups.c b/src/afs/HPUX/osi_groups.c index 762321818..aec2f4e6b 100644 --- a/src/afs/HPUX/osi_groups.c +++ b/src/afs/HPUX/osi_groups.c @@ -16,27 +16,22 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset); + afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset); static int -afs_setgroups( - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent); + afs_setgroups(struct ucred **cred, int ngroups, gid_t * gidset, + int change_parent); int -Afs_xsetgroups() +Afs_xsetgroups() { int code = 0; struct vrequest treq; @@ -45,7 +40,8 @@ Afs_xsetgroups() AFS_GLOCK(); code = afs_InitReq(&treq, p_cred(u.u_procp)); AFS_GUNLOCK(); - if (code) return code; + if (code) + return code; setgroups(); /* Note that if there is a pag already in the new groups we don't @@ -66,10 +62,10 @@ Afs_xsetgroups() int setpag(cred, pagvalue, newpag, change_parent) - struct ucred **cred; - afs_uint32 pagvalue; - afs_uint32 *newpag; - afs_uint32 change_parent; + struct ucred **cred; + afs_uint32 pagvalue; + afs_uint32 *newpag; + afs_uint32 change_parent; { gid_t gidset[NGROUPS]; int ngroups, code; @@ -82,12 +78,12 @@ setpag(cred, pagvalue, newpag, change_parent) if (ngroups + 2 > NGROUPS) { return (setuerror(E2BIG), E2BIG); } - for (j = ngroups -1; j >= 0; j--) { - gidset[j+2] = gidset[j]; - } + for (j = ngroups - 1; j >= 0; j--) { + gidset[j + 2] = gidset[j]; + } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]); if (code = afs_setgroups(cred, ngroups, gidset, change_parent)) { @@ -98,10 +94,7 @@ setpag(cred, pagvalue, newpag, change_parent) static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset) +afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset) { int ngrps, savengrps; int *gp; @@ -111,10 +104,10 @@ afs_getgroups( for (gp = &cred->cr_groups[NGROUPS]; gp > cred->cr_groups; gp--) { if (gp[-1] != NOGROUP) - break; + break; } savengrps = ngrps = MIN(ngroups, gp - cred->cr_groups); - for (gp = cred->cr_groups; ngrps--; ) + for (gp = cred->cr_groups; ngrps--;) *gidset++ = *gp++; return savengrps; } @@ -122,11 +115,8 @@ afs_getgroups( static int -afs_setgroups( - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct ucred **cred, int ngroups, gid_t * gidset, + int change_parent) { int ngrps; int i; @@ -134,57 +124,51 @@ afs_setgroups( struct ucred *newcr; ulong_t s; #if defined(AFS_HPUX110_ENV) - register ulong_t context; + register ulong_t context; #endif AFS_STATCNT(afs_setgroups); - - if (!change_parent) - { - newcr = (struct ucred *)crdup(*cred); - /* nobody else has the pointer to newcr because we - ** just allocated it, so no need for locking */ - } - else - { - /* somebody else might have a pointer to this structure. - ** make sure we do not have a race condition */ - newcr = *cred; + + if (!change_parent) { + newcr = (struct ucred *)crdup(*cred); + /* nobody else has the pointer to newcr because we + ** just allocated it, so no need for locking */ + } else { + /* somebody else might have a pointer to this structure. + ** make sure we do not have a race condition */ + newcr = *cred; #if defined(AFS_HPUX110_ENV) - /* all of the uniprocessor spinlocks are not defined. */ - /* I assume the UP and MP are now handled together */ - MP_SPINLOCK_USAV(cred_lock, context); + /* all of the uniprocessor spinlocks are not defined. */ + /* I assume the UP and MP are now handled together */ + MP_SPINLOCK_USAV(cred_lock, context); #else - s = UP_SPL6(); - SPINLOCK(cred_lock); + s = UP_SPL6(); + SPINLOCK(cred_lock); #endif - } - - + } + + /* copy the group info */ gp = newcr->cr_groups; while (ngroups--) *gp++ = *gidset++; - for ( ; gp < &(newcr)->cr_groups[NGROUPS]; gp++) - *gp = ((gid_t) -1); - - if ( !change_parent) - { - /* replace the new cred structure in the proc area */ - struct ucred* tmp; - tmp = *cred; - set_p_cred(u.u_procp, newcr); - crfree(tmp); - } - else - { + for (; gp < &(newcr)->cr_groups[NGROUPS]; gp++) + *gp = ((gid_t) - 1); + + if (!change_parent) { + /* replace the new cred structure in the proc area */ + struct ucred *tmp; + tmp = *cred; + set_p_cred(u.u_procp, newcr); + crfree(tmp); + } else { #if defined(AFS_HPUX110_ENV) - MP_SPINUNLOCK_USAV(cred_lock, context); + MP_SPINUNLOCK_USAV(cred_lock, context); #else - (void) UP_SPLX(s); - SPINUNLOCK(cred_lock); + (void)UP_SPLX(s); + SPINUNLOCK(cred_lock); #endif - } + } return (setuerror(0), 0); } diff --git a/src/afs/HPUX/osi_inode.c b/src/afs/HPUX/osi_inode.c index a549fa810..ccf4661fc 100644 --- a/src/afs/HPUX/osi_inode.c +++ b/src/afs/HPUX/osi_inode.c @@ -16,203 +16,204 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ #include "afs/osi_inode.h" -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include static struct inode * getinode(struct vfs *vfsp, dev_t dev, ino_t inode, int *perror) { - struct mount *mp = (vfsp ? VFSTOM(vfsp) : 0); - struct inode *pip; - *perror = 0; - - if (!mp && !(mp = getmp(dev))) { - u.u_error = ENXIO; - return(NULL); - } - pip=iget(dev,mp,inode); - if(!pip) + struct mount *mp = (vfsp ? VFSTOM(vfsp) : 0); + struct inode *pip; + *perror = 0; + + if (!mp && !(mp = getmp(dev))) { + u.u_error = ENXIO; + return (NULL); + } + pip = iget(dev, mp, inode); + if (!pip) *perror = BAD_IGET; - return(pip); + return (pip); } struct inode * igetinode(struct vfs *vfsp, dev_t dev, ino_t inode, int *perror) { - struct inode *pip, *ip; - extern struct osi_dev cacheDev; - register int code = 0; - - *perror = 0; - AFS_STATCNT(igetinode); - ip = getinode(vfsp, dev, inode,perror); - if (ip == NULL) { - *perror = BAD_IGET; - u.u_error = ENOENT; /* Well... */ - return; - } - if (ip->i_mode == 0) { - /* Not an allocated inode */ - iforget(ip); - u.u_error = ENOENT; - return; - } - if (ip->i_nlink == 0 || (ip->i_mode&IFMT) != IFREG) { - iput(ip); - u.u_error = ENOENT; - return; - } - return ip; + struct inode *pip, *ip; + extern struct osi_dev cacheDev; + register int code = 0; + + *perror = 0; + AFS_STATCNT(igetinode); + ip = getinode(vfsp, dev, inode, perror); + if (ip == NULL) { + *perror = BAD_IGET; + u.u_error = ENOENT; /* Well... */ + return; + } + if (ip->i_mode == 0) { + /* Not an allocated inode */ + iforget(ip); + u.u_error = ENOENT; + return; + } + if (ip->i_nlink == 0 || (ip->i_mode & IFMT) != IFREG) { + iput(ip); + u.u_error = ENOENT; + return; + } + return ip; } iforget(ip) struct inode *ip; { - idrop(ip); + idrop(ip); } afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4) -long dev, near_inode, param1, param2, param3, param4; + long dev, near_inode, param1, param2, param3, param4; { - int dummy, err=0; - struct inode *ip, *newip; - - AFS_STATCNT(afs_syscall_icreate); - - if (!afs_suser()) { - u.u_error = EPERM; - goto out; - } - - ip = getinode(0, (dev_t)dev, 2,&dummy); - if (ip == NULL) { - u.u_error = ENOENT; /* Well... */ - goto out; - } - - newip = (struct inode *)ialloc(ip, near_inode, 0); - iput(ip); - if (newip == NULL) - goto out; - - newip->i_flag |= IACC|IUPD|ICHG; - newip->i_nlink = 1; - newip->i_mode = IFREG; - newip->i_vnode.v_type = VREG; - newip->i_vicemagic = VICEMAGIC; - newip->i_vicep1 = param1; - newip->i_vicep2 = param2; - I_VICE3(newip) = param3; - newip->i_vicep4 = param4; - u.u_r.r_val1 = newip->i_number; - - iput(newip); - -out: - return err; + int dummy, err = 0; + struct inode *ip, *newip; + + AFS_STATCNT(afs_syscall_icreate); + + if (!afs_suser()) { + u.u_error = EPERM; + goto out; + } + + ip = getinode(0, (dev_t) dev, 2, &dummy); + if (ip == NULL) { + u.u_error = ENOENT; /* Well... */ + goto out; + } + + newip = (struct inode *)ialloc(ip, near_inode, 0); + iput(ip); + if (newip == NULL) + goto out; + + newip->i_flag |= IACC | IUPD | ICHG; + newip->i_nlink = 1; + newip->i_mode = IFREG; + newip->i_vnode.v_type = VREG; + newip->i_vicemagic = VICEMAGIC; + newip->i_vicep1 = param1; + newip->i_vicep2 = param2; + I_VICE3(newip) = param3; + newip->i_vicep4 = param4; + u.u_r.r_val1 = newip->i_number; + + iput(newip); + + out: + return err; } afs_syscall_iopen(dev, inode, usrmod) -int dev, inode, usrmod; + int dev, inode, usrmod; { - struct file *fp; - struct inode *ip; - struct vnode *vp = NULL; - int dummy; - extern struct fileops vnodefops; - register int code; - - AFS_STATCNT(afs_syscall_iopen); - - if (!afs_suser()) { - u.u_error = EPERM; - goto out; - } - - ip = igetinode(0, (dev_t)dev, (ino_t)inode,&dummy); - if (u.u_error) - goto out; - fp = falloc(); - if (!fp) { - iput(ip); - goto out; - } - iunlock(ip); - - fp->f_ops = &vnodefops; - vp = ITOV(ip); - fp->f_data = (char *)vp; - fp->f_type = DTYPE_VNODE; - fp->f_flag = (usrmod+1) & (FMASK); - - /* Obtained from hp kernel sys/vfs_scalls.c: copen(). - * Otherwise we panic because the v_writecount - * goes less than 0 during close. - */ - if ((vp->v_type == VREG) && (fp->f_flag & FWRITE)) { - VN_INC_WRITECOUNT(vp); - } - - /* fp->f_count, f_msgcount are set by falloc */ - /* fp->f_offset zeroed by falloc */ - /* f_cred set by falloc */ - - /* - * Obtained from hp kernel sys/vfs_scalls.c: copen() does - * a PUTF() (defined earlier in the file) before returning, - * so we parrot what it does. If this is not done, then - * threaded processes will get EBADF errors when they try - * to use the resulting file descriptor (e.g. with lseek()). - * - * Note: u.u_r.r_val1 is set by ufalloc(), which is - * called by falloc(), which is called above. - */ - if (is_multithreaded(u.u_procp)) { - int fd = (int)u.u_r.r_val1; - putf(fd); - } - -out: - return; + struct file *fp; + struct inode *ip; + struct vnode *vp = NULL; + int dummy; + extern struct fileops vnodefops; + register int code; + + AFS_STATCNT(afs_syscall_iopen); + + if (!afs_suser()) { + u.u_error = EPERM; + goto out; + } + + ip = igetinode(0, (dev_t) dev, (ino_t) inode, &dummy); + if (u.u_error) + goto out; + fp = falloc(); + if (!fp) { + iput(ip); + goto out; + } + iunlock(ip); + + fp->f_ops = &vnodefops; + vp = ITOV(ip); + fp->f_data = (char *)vp; + fp->f_type = DTYPE_VNODE; + fp->f_flag = (usrmod + 1) & (FMASK); + + /* Obtained from hp kernel sys/vfs_scalls.c: copen(). + * Otherwise we panic because the v_writecount + * goes less than 0 during close. + */ + if ((vp->v_type == VREG) && (fp->f_flag & FWRITE)) { + VN_INC_WRITECOUNT(vp); + } + + /* fp->f_count, f_msgcount are set by falloc */ + /* fp->f_offset zeroed by falloc */ + /* f_cred set by falloc */ + + /* + * Obtained from hp kernel sys/vfs_scalls.c: copen() does + * a PUTF() (defined earlier in the file) before returning, + * so we parrot what it does. If this is not done, then + * threaded processes will get EBADF errors when they try + * to use the resulting file descriptor (e.g. with lseek()). + * + * Note: u.u_r.r_val1 is set by ufalloc(), which is + * called by falloc(), which is called above. + */ + if (is_multithreaded(u.u_procp)) { + int fd = (int)u.u_r.r_val1; + putf(fd); + } + + out: + return; } afs_syscall_iincdec(dev, inode, inode_p1, amount) -int dev, inode, inode_p1, amount; + int dev, inode, inode_p1, amount; { - int dummy; - struct inode *ip; - register afs_int32 code; - - if (!afs_suser()) { - u.u_error = EPERM; - goto out; - } - - ip = igetinode(0, (dev_t)dev, (ino_t)inode,&dummy); - if (u.u_error) { - goto out; + int dummy; + struct inode *ip; + register afs_int32 code; + + if (!afs_suser()) { + u.u_error = EPERM; + goto out; + } + + ip = igetinode(0, (dev_t) dev, (ino_t) inode, &dummy); + if (u.u_error) { + goto out; + } + + if (!IS_VICEMAGIC(ip)) + u.u_error = EPERM; + else if (ip->i_vicep1 != inode_p1) + u.u_error = ENXIO; + else { + ip->i_nlink += amount; + if (ip->i_nlink == 0) { + CLEAR_VICEMAGIC(ip); } + ip->i_flag |= ICHG; + } - if (!IS_VICEMAGIC(ip)) - u.u_error = EPERM; - else if (ip->i_vicep1 != inode_p1) - u.u_error = ENXIO; - else { - ip->i_nlink += amount; - if (ip->i_nlink == 0) { - CLEAR_VICEMAGIC(ip); - } - ip->i_flag |= ICHG; - } - - iput(ip); + iput(ip); -out: + out: return; } diff --git a/src/afs/HPUX/osi_inode.h b/src/afs/HPUX/osi_inode.h index d7f69a9d7..cdd3bac45 100644 --- a/src/afs/HPUX/osi_inode.h +++ b/src/afs/HPUX/osi_inode.h @@ -47,6 +47,7 @@ #define CLEAR_VICEMAGIC(ip) (ip)->i_vicemagic = 0 #define CLEAR_DVICEMAGIC(dp) (dp)->di_vicemagic = 0 -struct inode *igetinode(struct vfs *vfsp, dev_t dev, ino_t inode, int *perror); +struct inode *igetinode(struct vfs *vfsp, dev_t dev, ino_t inode, + int *perror); #endif /* _OSI_INODE_H_ */ diff --git a/src/afs/HPUX/osi_machdep.h b/src/afs/HPUX/osi_machdep.h index 1035bad3f..b13f6e461 100644 --- a/src/afs/HPUX/osi_machdep.h +++ b/src/afs/HPUX/osi_machdep.h @@ -60,10 +60,10 @@ extern b_sema_t afs_global_sema; extern void osi_InitGlock(void); #if !defined(AFS_HPUX110_ENV) -extern void afsHash(int nbuckets); +extern void afsHash(int nbuckets); extern sv_sema_t *afsHashInsertFind(tid_t key); extern sv_sema_t *afsHashFind(tid_t key); -extern void afsHashRelease(tid_t key); +extern void afsHashRelease(tid_t key); #define AFS_GLOCK_PID kt_tid(u.u_kthreadp) #define AFS_SAVE_SEMA afsHashInsertFind(AFS_GLOCK_PID) @@ -74,7 +74,7 @@ extern void afsHashRelease(tid_t key); #define ISAFS_GLOCK() (!uniprocessor ? owns_sema(&afs_global_sema):1) #else -#define AFS_GLOCK() b_psema(&afs_global_sema) +#define AFS_GLOCK() b_psema(&afs_global_sema) #define AFS_GUNLOCK() b_vsema(&afs_global_sema) #define ISAFS_GLOCK() b_owns_sema(&afs_global_sema) diff --git a/src/afs/HPUX/osi_misc.c b/src/afs/HPUX/osi_misc.c index b3c7a9e37..7bc49561a 100644 --- a/src/afs/HPUX/osi_misc.c +++ b/src/afs/HPUX/osi_misc.c @@ -15,7 +15,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ @@ -28,7 +29,8 @@ RCSID("$Header$"); * Here we have to save and restore errno since the HP-UX suser() sets errno. */ -afs_suser() { +afs_suser() +{ int save_errno; int code; diff --git a/src/afs/HPUX/osi_sleep.c b/src/afs/HPUX/osi_sleep.c index fa36325ea..de72e84cd 100644 --- a/src/afs/HPUX/osi_sleep.c +++ b/src/afs/HPUX/osi_sleep.c @@ -10,21 +10,23 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #if !defined(AFS_HPUX110_ENV) static char waitV; #endif /* call procedure aproc with arock as an argument, in ams milliseconds */ -static int afs_osi_CallProc(aproc, arock, ams) - register void (*aproc)(); - register char *arock; - afs_int32 ams; +static int +afs_osi_CallProc(aproc, arock, ams) + register void (*aproc) (); + register char *arock; + afs_int32 ams; { int code; @@ -33,7 +35,7 @@ static int afs_osi_CallProc(aproc, arock, ams) AFS_GUNLOCK(); #endif /* hz is in cycles/second, and timeout's 3rd parm is in cycles */ - code = timeout(aproc, arock, (ams * afs_hz)/1000 + 1); + code = timeout(aproc, arock, (ams * afs_hz) / 1000 + 1); #if !defined(AFS_HPUX110_ENV) AFS_GLOCK(); #endif @@ -41,9 +43,10 @@ static int afs_osi_CallProc(aproc, arock, ams) } /* cancel a timeout, whether or not it has already occurred */ -static int afs_osi_CancelProc(aproc, arock) - register void (*aproc)(); - register char *arock; +static int +afs_osi_CancelProc(aproc, arock) + register void (*aproc) (); + register char *arock; { int code = 0; AFS_STATCNT(osi_CancelProc); @@ -59,41 +62,46 @@ static int afs_osi_CancelProc(aproc, arock) } #if defined(AFS_HPUX110_ENV) -static void AfsWaitHack(char * event) +static void +AfsWaitHack(char *event) { - lock_t * sleep_lock; + lock_t *sleep_lock; AFS_STATCNT(WaitHack); - sleep_lock = get_sleep_lock(event); + sleep_lock = get_sleep_lock(event); wakeup(event); - spinunlock(sleep_lock); + spinunlock(sleep_lock); } #else -static void AfsWaitHack() +static void +AfsWaitHack() { AFS_STATCNT(WaitHack); wakeup(&waitV); } #endif -void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) +void +afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) { AFS_STATCNT(osi_InitWaitHandle); achandle->proc = (caddr_t) 0; } /* cancel osi_Wait */ -void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) { caddr_t proc; AFS_STATCNT(osi_CancelWait); proc = achandle->proc; - if (proc == 0) return; - achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ + if (proc == 0) + return; + achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ #if defined(AFS_HPUX110_ENV) - afs_osi_Wakeup((char *)achandle); + afs_osi_Wakeup((char *)achandle); #else afs_osi_Wakeup(&waitV); #endif @@ -104,17 +112,18 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) * Waits for data on ahandle, or ams ms later. ahandle may be null. * Returns 0 if timeout and EINTR if signalled. */ -int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) +int +afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int code; afs_int32 endTime, tid; #if defined(AFS_HPUX110_ENV) - char localwait; - char * event; + char localwait; + char *event; #endif AFS_STATCNT(osi_Wait); - endTime = osi_Time() + (ams/1000); + endTime = osi_Time() + (ams / 1000); if (ahandle) ahandle->proc = (caddr_t) u.u_procp; do { @@ -122,22 +131,22 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) code = 0; /* do not do anything for solaris, digital, AIX, and SGI MP */ #if defined(AFS_HPUX110_ENV) - if (ahandle) { - event = (char *) ahandle; - } - else { - event = &localwait; - } + if (ahandle) { + event = (char *)ahandle; + } else { + event = &localwait; + } afs_osi_CallProc(AfsWaitHack, event, ams); afs_osi_Sleep(event); afs_osi_CancelProc(AfsWaitHack, event); #else - afs_osi_CallProc(AfsWaitHack, (char *) u.u_procp, ams); - afs_osi_Sleep(&waitV); /* for HP 10.0 */ + afs_osi_CallProc(AfsWaitHack, (char *)u.u_procp, ams); + afs_osi_Sleep(&waitV); /* for HP 10.0 */ /* do not do anything for solaris, digital, and SGI MP */ - afs_osi_CancelProc(AfsWaitHack, (char *) u.u_procp); - if (code) break; /* if something happened, quit now */ + afs_osi_CancelProc(AfsWaitHack, (char *)u.u_procp); + if (code) + break; /* if something happened, quit now */ #endif /* if we we're cancelled, quit now */ if (ahandle && (ahandle->proc == (caddr_t) 0)) { @@ -148,35 +157,39 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) return code; } -int afs_osi_SleepSig(void *event) +int +afs_osi_SleepSig(void *event) { afs_osi_Sleep(event); return 0; } #if defined(AFS_HPUX110_ENV) -void afs_osi_Sleep(void *event) +void +afs_osi_Sleep(void *event) { - lock_t * sleep_lock; - - AFS_ASSERT_GLOCK(); - get_sleep_lock(event); - AFS_GUNLOCK(); - sleep((caddr_t) event, PZERO-2); - AFS_GLOCK(); + lock_t *sleep_lock; + + AFS_ASSERT_GLOCK(); + get_sleep_lock(event); + AFS_GUNLOCK(); + sleep((caddr_t) event, PZERO - 2); + AFS_GLOCK(); } - -int afs_osi_Wakeup(void *event) + +int +afs_osi_Wakeup(void *event) { - lock_t * sleep_lock; + lock_t *sleep_lock; - sleep_lock = get_sleep_lock(event); - wakeup((caddr_t) event); - spinunlock(sleep_lock); - return 0; + sleep_lock = get_sleep_lock(event); + wakeup((caddr_t) event); + spinunlock(sleep_lock); + return 0; } #else -int afs_osi_Wakeup(void *event) +int +afs_osi_Wakeup(void *event) { wakeup((caddr_t) event); return 0; diff --git a/src/afs/HPUX/osi_vfs.h b/src/afs/HPUX/osi_vfs.h index 43b9f2519..bfcb3bd15 100644 --- a/src/afs/HPUX/osi_vfs.h +++ b/src/afs/HPUX/osi_vfs.h @@ -6,10 +6,10 @@ /* * Flock(3) call. (from sys/file.h) */ -#define LOCK_SH 1 /* shared lock */ -#define LOCK_EX 2 /* exclusive lock */ -#define LOCK_NB 4 /* don't block when locking */ -#define LOCK_UN 8 /* unlock */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* don't block when locking */ +#define LOCK_UN 8 /* unlock */ #define d_fileno d_ino diff --git a/src/afs/HPUX/osi_vfsops.c b/src/afs/HPUX/osi_vfsops.c index 99ddfea7a..fc1eb5abe 100644 --- a/src/afs/HPUX/osi_vfsops.c +++ b/src/afs/HPUX/osi_vfsops.c @@ -13,11 +13,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include @@ -25,20 +26,21 @@ static char afs_mountpath[512]; struct vfs *afs_globalVFS = 0; struct vcache *afs_globalVp = 0; -int afs_mount(struct vfs *afsp, char *path, smountargs_t *data) +int +afs_mount(struct vfs *afsp, char *path, smountargs_t * data) { AFS_GLOCK(); AFS_STATCNT(afs_mount); - if (afs_globalVFS) { /* Don't allow remounts. */ + if (afs_globalVFS) { /* Don't allow remounts. */ AFS_GUNLOCK(); - return (setuerror(EBUSY)); + return (setuerror(EBUSY)); } afs_globalVFS = afsp; afsp->vfs_bsize = 8192; - afsp->vfs_fsid[0] = AFS_VFSMAGIC; /* magic */ - afsp->vfs_fsid[1] = AFS_VFSFSID; + afsp->vfs_fsid[0] = AFS_VFSMAGIC; /* magic */ + afsp->vfs_fsid[1] = AFS_VFSFSID; strcpy(afsp->vfs_name, "AFS"); afsp->vfs_name[3] = '\0'; @@ -47,7 +49,7 @@ int afs_mount(struct vfs *afsp, char *path, smountargs_t *data) #ifndef AFS_NONFSTRANS /* Set up the xlator in case it wasn't done elsewhere */ - afs_xlatorinit_v2(); + afs_xlatorinit_v2(); #endif AFS_GUNLOCK(); @@ -55,7 +57,8 @@ int afs_mount(struct vfs *afsp, char *path, smountargs_t *data) } -int afs_unmount(struct vfs *afsp) +int +afs_unmount(struct vfs *afsp) { AFS_GLOCK(); AFS_STATCNT(afs_unmount); @@ -65,13 +68,14 @@ int afs_unmount(struct vfs *afsp) AFS_GUNLOCK(); return 0; -} +} -int afs_root (struct vfs *afsp, struct vnode **avpp, char *unused1) +int +afs_root(struct vfs *afsp, struct vnode **avpp, char *unused1) { int code = 0; struct vrequest treq; - register struct vcache *tvp=0; + register struct vcache *tvp = 0; AFS_GLOCK(); AFS_STATCNT(afs_root); @@ -83,8 +87,8 @@ int afs_root (struct vfs *afsp, struct vnode **avpp, char *unused1) afs_globalVp = NULL; } - if (!(code = afs_InitReq(&treq, p_cred(u.u_procp))) && - !(code = afs_CheckInit())) { + if (!(code = afs_InitReq(&treq, p_cred(u.u_procp))) + && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); /* we really want this to stay around */ if (tvp) { @@ -106,9 +110,10 @@ int afs_root (struct vfs *afsp, struct vnode **avpp, char *unused1) AFS_GUNLOCK(); return code; -} +} -int afs_statfs(register struct vfs *afsp, struct k_statvfs *abp) +int +afs_statfs(register struct vfs *afsp, struct k_statvfs *abp) { AFS_GLOCK(); AFS_STATCNT(afs_statfs); @@ -126,25 +131,27 @@ int afs_statfs(register struct vfs *afsp, struct k_statvfs *abp) AFS_GUNLOCK(); return 0; -} +} -int afs_sync(struct vfs *unused1, int unused2) +int +afs_sync(struct vfs *unused1, int unused2) { AFS_STATCNT(afs_sync); return 0; } -int afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp) +int +afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp) { int code; struct vrequest treq; AFS_GLOCK(); AFS_STATCNT(afs_vget); - * avcp = NULL; + *avcp = NULL; - if ((code = afs_InitReq(&treq, p_cred(u.u_procp)))==0) { - code = afs_osi_vget((struct vcache**)avcp, fidp, &treq); + if ((code = afs_InitReq(&treq, p_cred(u.u_procp))) == 0) { + code = afs_osi_vget((struct vcache **)avcp, fidp, &treq); } afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp, @@ -153,16 +160,19 @@ int afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp) AFS_GUNLOCK(); return code; -} +} -int afs_getmount(struct vfs *vfsp, char *fsmntdir, struct mount_data *mdp, char *unused1) +int +afs_getmount(struct vfs *vfsp, char *fsmntdir, struct mount_data *mdp, + char *unused1) { int l; mdp->md_msite = 0; mdp->md_dev = 0; mdp->md_rdev = 0; - return(copyoutstr(afs_mountpath, fsmntdir, strlen(afs_mountpath)+1, &l)); + return (copyoutstr + (afs_mountpath, fsmntdir, strlen(afs_mountpath) + 1, &l)); } @@ -174,13 +184,13 @@ struct vfsops Afs_vfsops = { afs_sync, afs_vget, afs_getmount, - (vfs_freeze_t *)0, /* vfs_freeze */ - (vfs_thaw_t *)0, /* vfs_thaw */ - (vfs_quota_t *)0, /* vfs_quota */ - (vfs_mountroot_t *)0, /* vfs_mountroot. Note: afs_mountroot_nullop in this - * position panicked HP 11.00+ - */ - (vfs_size_t *)0 /* vfs_size */ + (vfs_freeze_t *) 0, /* vfs_freeze */ + (vfs_thaw_t *) 0, /* vfs_thaw */ + (vfs_quota_t *) 0, /* vfs_quota */ + (vfs_mountroot_t *) 0, /* vfs_mountroot. Note: afs_mountroot_nullop in this + * position panicked HP 11.00+ + */ + (vfs_size_t *) 0 /* vfs_size */ }; static int afs_Starting = 0; @@ -188,15 +198,15 @@ static int afs_Starting = 0; #pragma align 64 #if !defined(AFS_HPUX110_ENV) sema_t afs_global_sema = { - NULL, 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, /* sa_type */ - 0, 0, 0, 0, 0, 0, 0, NULL, /* sa_link */ - NULL, NULL + NULL, 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, /* sa_type */ + 0, 0, 0, 0, 0, 0, 0, NULL, /* sa_link */ + NULL, NULL #ifdef SEMA_COUNTING - , 0, 0, 0, NULL + , 0, 0, 0, NULL #endif - }; +}; #else -b_sema_t afs_global_sema = {0}; +b_sema_t afs_global_sema = { 0 }; #endif void @@ -205,15 +215,15 @@ osi_InitGlock() register ulong_t context; SPINLOCK_USAV(sched_lock, context); - if ( !afs_Starting ) { + if (!afs_Starting) { afs_Starting = 1; SPINUNLOCK_USAV(sched_lock, context); #if defined(AFS_HPUX110_ENV) - b_initsema(&afs_global_sema, 1, NFS_LOCK_ORDER2, "AFS GLOCK"); - /* afsHash(64); */ /* 64 buckets */ + b_initsema(&afs_global_sema, 1, NFS_LOCK_ORDER2, "AFS GLOCK"); + /* afsHash(64); *//* 64 buckets */ #else - initsema(&afs_global_sema, 1, FILESYS_SEMA_PRI, FILESYS_SEMA_ORDER); - afsHash(64); /* 64 buckets */ + initsema(&afs_global_sema, 1, FILESYS_SEMA_PRI, FILESYS_SEMA_ORDER); + afsHash(64); /* 64 buckets */ #endif } else { SPINUNLOCK_USAV(sched_lock, context); @@ -226,7 +236,7 @@ osi_InitGlock() /* * afsc_link - Initialize VFS */ -int afs_vfs_slot=-1; +int afs_vfs_slot = -1; afsc_link() @@ -235,10 +245,11 @@ afsc_link() /* For now nothing special is required during AFS initialization. */ AFS_STATCNT(afsc_link); - osi_Init(); - if ( (afs_vfs_slot=add_vfs_type("afs", &Afs_vfsops)) < 0 ) + osi_Init(); + if ((afs_vfs_slot = add_vfs_type("afs", &Afs_vfsops)) < 0) return; - sysent_assign_function(AFS_SYSCALL, 7, (void (*)())Afs_syscall, "Afs_syscall"); + sysent_assign_function(AFS_SYSCALL, 7, (void (*)())Afs_syscall, + "Afs_syscall"); sysent_define_arg(AFS_SYSCALL, 0, longArg); sysent_define_arg(AFS_SYSCALL, 1, longArg); sysent_define_arg(AFS_SYSCALL, 2, longArg); @@ -255,4 +266,3 @@ afsc_link() sysent_returns_long(80); return 0; } - diff --git a/src/afs/HPUX/osi_vm.c b/src/afs/HPUX/osi_vm.c index 11aa3f7c6..17f2e7aff 100644 --- a/src/afs/HPUX/osi_vm.c +++ b/src/afs/HPUX/osi_vm.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ /* Try to discard pages, in order to recycle a vcache entry. * @@ -30,7 +31,8 @@ RCSID("$Header$"); * is not dropped and re-acquired for any platform. It may be that *slept is * therefore obsolescent. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { if (avc->vrefCount > 1) return EBUSY; @@ -46,9 +48,10 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { - ; /* Nothing here yet */ + ; /* Nothing here yet */ } /* Try to invalidate pages, for "fs flush" or "fs flushv"; or @@ -57,7 +60,8 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * Locking: the vcache entry's lock is held. It may be dropped and * re-obtained. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { struct vnode *vp = AFSTOV(avc); @@ -65,7 +69,7 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) * from the buffer cache */ if ((vp->v_flag & VTEXT) == 0) { - mpurge(vp); + mpurge(vp); } /* Mark the cached blocks on the free list as invalid; it invalidates blocks * associated with vp which are on the freelist. @@ -78,9 +82,10 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) * * Locking: No lock is held, not even the global lock. */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { - ; /* Nothing here yet */ + ; /* Nothing here yet */ } /* Purge pages beyond end-of-file, when truncating a file. @@ -89,7 +94,8 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * activeV is raised. This is supposed to block pageins, but at present * it only works on Solaris. */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { - ; /* Nothing here yet */ + ; /* Nothing here yet */ } diff --git a/src/afs/HPUX/osi_vnodeops.c b/src/afs/HPUX/osi_vnodeops.c index 6a9580ae8..714128c92 100644 --- a/src/afs/HPUX/osi_vnodeops.c +++ b/src/afs/HPUX/osi_vnodeops.c @@ -12,11 +12,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include #include @@ -70,39 +71,39 @@ extern int afs_close(); */ int m_cpytoc(m, off, len, cp) - register struct mbuf *m; - register int off, len; - register caddr_t cp; + register struct mbuf *m; + register int off, len; + register caddr_t cp; { - register int ml; - - if (m == NULL || off < 0 || len < 0 || cp == NULL) - osi_Panic("m_cpytoc"); - while (off && m) - if (m->m_len <= off) { - off -= m->m_len; - m = m->m_next; - continue; - } else - break; - if (m == NULL) - return (len); - - ml = MIN(len, m->m_len - off); - memcpy(cp, mtod(m, caddr_t)+off, (u_int)ml); + register int ml; + + if (m == NULL || off < 0 || len < 0 || cp == NULL) + osi_Panic("m_cpytoc"); + while (off && m) + if (m->m_len <= off) { + off -= m->m_len; + m = m->m_next; + continue; + } else + break; + if (m == NULL) + return (len); + + ml = MIN(len, m->m_len - off); + memcpy(cp, mtod(m, caddr_t) + off, (u_int) ml); + cp += ml; + len -= ml; + m = m->m_next; + + while (len && m) { + ml = m->m_len; + memcpy(cp, mtod(m, caddr_t), (u_int) ml); cp += ml; len -= ml; m = m->m_next; + } - while (len && m) { - ml = m->m_len; - memcpy(cp, mtod(m, caddr_t), (u_int)ml); - cp += ml; - len -= ml; - m = m->m_next; - } - - return (len); + return (len); } #endif @@ -114,14 +115,14 @@ m_cpytoc(m, off, len, cp) * fcntl() looking request, and then translate the results back if necessary. * we call afs_lockctl() directly . */ -afs_lockf( vp, flag, len, cred, fp, LB, UB ) - struct vnode *vp; - int flag; - struct AFS_UCRED *cred; - struct file *fp; - k_off_t len, LB, UB; +afs_lockf(vp, flag, len, cred, fp, LB, UB) + struct vnode *vp; + int flag; + struct AFS_UCRED *cred; + struct file *fp; + k_off_t len, LB, UB; { - /*for now, just pretend it works*/ + /*for now, just pretend it works */ struct k_flock flock; int cmd, code; @@ -133,7 +134,7 @@ afs_lockf( vp, flag, len, cred, fp, LB, UB ) flock.l_len = len; flock.l_start = fp->f_offset; /* convert negative lengths to positive */ - if (flock.l_len < 0 ) { + if (flock.l_len < 0) { flock.l_start += flock.l_len; flock.l_len = -(flock.l_len); } @@ -146,19 +147,19 @@ afs_lockf( vp, flag, len, cred, fp, LB, UB ) flock.l_type = F_WRLCK; cmd = F_SETLK; switch (flag) { - case F_ULOCK: + case F_ULOCK: flock.l_type = F_UNLCK; break; - case F_LOCK: + case F_LOCK: cmd = F_SETLKW; break; - case F_TEST: + case F_TEST: cmd = F_GETLK; break; } - u.u_error = mp_afs_lockctl(vp, &flock, cmd, fp->f_cred); + u.u_error = mp_afs_lockctl(vp, &flock, cmd, fp->f_cred); if (u.u_error) { - return(u.u_error); /* some other error code */ + return (u.u_error); /* some other error code */ } /* * if request is F_TEST, and GETLK changed @@ -176,7 +177,7 @@ afs_lockf( vp, flag, len, cred, fp, LB, UB ) #if defined(AFS_HPUX1122_ENV) #include "machine/vm/vmparam.h" #else -#include "../machine/vmparam.h" /* For KERNELSPACE */ +#include "../machine/vmparam.h" /* For KERNELSPACE */ #endif #include "h/debug.h" #include "h/types.h" @@ -205,58 +206,57 @@ struct buf *afs_bread_freebp = 0; * Thus we can use fake bufs (ie not from the real buffer pool). */ afs_bread(vp, lbn, bpp) - struct vnode *vp; - daddr_t lbn; - struct buf **bpp; + struct vnode *vp; + daddr_t lbn; + struct buf **bpp; { - int offset, fsbsize, error; - struct buf *bp; - struct iovec iov; - struct uio uio; - - AFS_STATCNT(afs_bread); - fsbsize = vp->v_vfsp->vfs_bsize; - offset = lbn * fsbsize; - if (afs_bread_freebp) { - bp = afs_bread_freebp; - afs_bread_freebp = 0; - } else { - bp = (struct buf *) AFS_KALLOC(sizeof(*bp)); - bp->b_un.b_addr = (caddr_t) AFS_KALLOC(fsbsize); - } + int offset, fsbsize, error; + struct buf *bp; + struct iovec iov; + struct uio uio; + + AFS_STATCNT(afs_bread); + fsbsize = vp->v_vfsp->vfs_bsize; + offset = lbn * fsbsize; + if (afs_bread_freebp) { + bp = afs_bread_freebp; + afs_bread_freebp = 0; + } else { + bp = (struct buf *)AFS_KALLOC(sizeof(*bp)); + bp->b_un.b_addr = (caddr_t) AFS_KALLOC(fsbsize); + } - iov.iov_base = bp->b_un.b_addr; - iov.iov_len = fsbsize; - uio.afsio_iov = &iov; - uio.afsio_iovcnt = 1; - uio.afsio_seg = AFS_UIOSYS; - uio.afsio_offset = offset; - uio.afsio_resid = fsbsize; - uio.uio_fpflags = 0; - *bpp = 0; - - error = afs_read(VTOAFS(vp), &uio, p_cred(u.u_procp), - lbn, bpp, 0); - if (error) { - afs_bread_freebp = bp; - return error; - } - if (*bpp) { - afs_bread_freebp = bp; - } else { - *(struct buf **)&bp->b_vp = bp; /* mark as fake */ - *bpp = bp; - } - return 0; + iov.iov_base = bp->b_un.b_addr; + iov.iov_len = fsbsize; + uio.afsio_iov = &iov; + uio.afsio_iovcnt = 1; + uio.afsio_seg = AFS_UIOSYS; + uio.afsio_offset = offset; + uio.afsio_resid = fsbsize; + uio.uio_fpflags = 0; + *bpp = 0; + + error = afs_read(VTOAFS(vp), &uio, p_cred(u.u_procp), lbn, bpp, 0); + if (error) { + afs_bread_freebp = bp; + return error; + } + if (*bpp) { + afs_bread_freebp = bp; + } else { + *(struct buf **)&bp->b_vp = bp; /* mark as fake */ + *bpp = bp; + } + return 0; } afs_brelse(vp, bp) -struct vnode *vp; -struct buf *bp; + struct vnode *vp; + struct buf *bp; { AFS_STATCNT(afs_brelse); - if ((struct buf *)bp->b_vp != bp) { /* not fake */ + if ((struct buf *)bp->b_vp != bp) { /* not fake */ ufs_brelse(bp->b_vp, bp); } else if (afs_bread_freebp) { AFS_KFREE(bp->b_un.b_addr, vp->v_vfsp->vfs_bsize); @@ -268,42 +268,45 @@ struct buf *bp; afs_bmap(avc, abn, anvp, anbn) - register struct vcache *avc; - afs_int32 abn, *anbn; - struct vcache **anvp; { + register struct vcache *avc; + afs_int32 abn, *anbn; + struct vcache **anvp; +{ AFS_STATCNT(afs_bmap); if (anvp) *anvp = avc; if (anbn) - *anbn = abn * (8192 / DEV_BSIZE); /* in 512 byte units */ + *anbn = abn * (8192 / DEV_BSIZE); /* in 512 byte units */ return 0; } afs_inactive(avc, acred) - register struct vcache *avc; - struct AFS_UCRED *acred; + register struct vcache *avc; + struct AFS_UCRED *acred; { struct vnode *vp = AFSTOV(avc); ulong_t context; lock_t *sv_lock; - if (afs_shuttingdown) return ; + if (afs_shuttingdown) + return; /* * In Solaris and HPUX s800 and HP-UX10.0 they actually call us with * v_count 1 on last reference! */ - MP_H_SPINLOCK_USAV(vn_h_sl_pool,vp,&sv_lock,&context); - if (avc->vrefCount < 1) osi_Panic("afs_inactive : v_count < 1\n"); + MP_H_SPINLOCK_USAV(vn_h_sl_pool, vp, &sv_lock, &context); + if (avc->vrefCount < 1) + osi_Panic("afs_inactive : v_count < 1\n"); /* * If more than 1 don't unmap the vnode but do decrement the ref count */ vp->v_count--; if (vp->v_count > 0) { - MP_SPINUNLOCK_USAV(sv_lock,context); + MP_SPINUNLOCK_USAV(sv_lock, context); return 0; } - MP_SPINUNLOCK_USAV(sv_lock,context); + MP_SPINUNLOCK_USAV(sv_lock, context); afs_InactiveVCache(avc, acred); return 0; } @@ -332,7 +335,8 @@ mp_afs_close(register struct vnode *avcp, int aflags, struct AFS_UCRED *acred) } int -mp_afs_rdwr(register struct vnode *avcp, struct uio *uio, enum uio_rw arw, int aio, struct AFS_UCRED *acred) +mp_afs_rdwr(register struct vnode *avcp, struct uio *uio, enum uio_rw arw, + int aio, struct AFS_UCRED *acred) { register int code; long save_resid; @@ -349,7 +353,8 @@ mp_afs_rdwr(register struct vnode *avcp, struct uio *uio, enum uio_rw arw, int a } int -mp_afs_getattr(register struct vnode *avcp, struct vattr *attrs, struct AFS_UCRED *acred, enum vsync unused1) +mp_afs_getattr(register struct vnode *avcp, struct vattr *attrs, + struct AFS_UCRED *acred, enum vsync unused1) { register int code; @@ -360,7 +365,8 @@ mp_afs_getattr(register struct vnode *avcp, struct vattr *attrs, struct AFS_UCRE } int -mp_afs_setattr(register struct vnode *avcp, register struct vattr *attrs, struct AFS_UCRED *acred, int unused1) +mp_afs_setattr(register struct vnode *avcp, register struct vattr *attrs, + struct AFS_UCRED *acred, int unused1) { register int code; @@ -382,7 +388,9 @@ mp_afs_access(register struct vnode *avcp, int mode, struct AFS_UCRED *acred) } int -mp_afs_lookup(register struct vnode *adp, char *aname, register struct vnode **avcp, struct AFS_UCRED *acred, struct vnode *unused1) +mp_afs_lookup(register struct vnode *adp, char *aname, + register struct vnode **avcp, struct AFS_UCRED *acred, + struct vnode *unused1) { register int code; @@ -393,7 +401,9 @@ mp_afs_lookup(register struct vnode *adp, char *aname, register struct vnode **a } int -mp_afs_create(register struct vnode *adp, char *aname, struct vattr *attrs, enum vcexcl aexcl, int amode, struct vnode **avcp, struct AFS_UCRED *acred) +mp_afs_create(register struct vnode *adp, char *aname, struct vattr *attrs, + enum vcexcl aexcl, int amode, struct vnode **avcp, + struct AFS_UCRED *acred) { register int code; @@ -405,7 +415,8 @@ mp_afs_create(register struct vnode *adp, char *aname, struct vattr *attrs, enum int -mp_afs_remove(register struct vnode *adp, char *aname, struct AFS_UCRED *acred) +mp_afs_remove(register struct vnode *adp, char *aname, + struct AFS_UCRED *acred) { register int code; @@ -416,7 +427,8 @@ mp_afs_remove(register struct vnode *adp, char *aname, struct AFS_UCRED *acred) } int -mp_afs_link(register struct vnode *avc, register struct vnode *adp, char *aname, struct AFS_UCRED *acred) +mp_afs_link(register struct vnode *avc, register struct vnode *adp, + char *aname, struct AFS_UCRED *acred) { register int code; @@ -427,7 +439,9 @@ mp_afs_link(register struct vnode *avc, register struct vnode *adp, char *aname, } int -mp_afs_rename(register struct vnode *aodp, char *aname1, register struct vnode *andp, char *aname2, struct AFS_UCRED *acred) +mp_afs_rename(register struct vnode *aodp, char *aname1, + register struct vnode *andp, char *aname2, + struct AFS_UCRED *acred) { register int code; @@ -438,7 +452,8 @@ mp_afs_rename(register struct vnode *aodp, char *aname1, register struct vnode * } int -mp_afs_mkdir(register struct vnode *adp, char *aname, struct vattr *attrs, register struct vnode **avcp, struct AFS_UCRED *acred) +mp_afs_mkdir(register struct vnode *adp, char *aname, struct vattr *attrs, + register struct vnode **avcp, struct AFS_UCRED *acred) { register int code; @@ -462,18 +477,20 @@ mp_afs_rmdir(register struct vnode *adp, char *aname, struct AFS_UCRED *acred) int -mp_afs_readdir(register struct vnode *avc, struct uio *auio, struct AFS_UCRED *acred) +mp_afs_readdir(register struct vnode *avc, struct uio *auio, + struct AFS_UCRED *acred) { register int code; AFS_GLOCK(); code = afs_readdir(avc, auio, acred); AFS_GUNLOCK(); - return (code); + return (code); } int -mp_afs_symlink(register struct vnode *adp, char *aname, struct vattr *attrs, char *atargetName, struct AFS_UCRED *acred) +mp_afs_symlink(register struct vnode *adp, char *aname, struct vattr *attrs, + char *atargetName, struct AFS_UCRED *acred) { register int code; @@ -485,7 +502,8 @@ mp_afs_symlink(register struct vnode *adp, char *aname, struct vattr *attrs, cha int -mp_afs_readlink(register struct vnode *avc, struct uio *auio, struct AFS_UCRED *acred) +mp_afs_readlink(register struct vnode *avc, struct uio *auio, + struct AFS_UCRED *acred) { register int code; @@ -507,7 +525,8 @@ mp_afs_fsync(register struct vnode *avc, struct AFS_UCRED *acred, int unused1) } int -mp_afs_bread(register struct vnode *avc, daddr_t lbn, struct buf **bpp, struct vattr *unused1, struct ucred *unused2) +mp_afs_bread(register struct vnode *avc, daddr_t lbn, struct buf **bpp, + struct vattr *unused1, struct ucred *unused2) { register int code; @@ -541,7 +560,9 @@ mp_afs_inactive(register struct vnode *avc, struct AFS_UCRED *acred) } int -mp_afs_lockctl(struct vnode *avc, struct flock *af, int cmd, struct AFS_UCRED *acred, struct file *unused1, off_t unused2, off_t unused3) +mp_afs_lockctl(struct vnode *avc, struct flock *af, int cmd, + struct AFS_UCRED *acred, struct file *unused1, off_t unused2, + off_t unused3) { register int code; @@ -561,8 +582,10 @@ mp_afs_fid(struct vnode *avc, struct fid **fidpp) AFS_GUNLOCK(); return (code); } + int -mp_afs_readdir2(register struct vnode *avc, struct uio *auio, struct AFS_UCRED *acred) +mp_afs_readdir2(register struct vnode *avc, struct uio *auio, + struct AFS_UCRED *acred) { register int code; @@ -574,66 +597,66 @@ mp_afs_readdir2(register struct vnode *avc, struct uio *auio, struct AFS_UCRED * struct vnodeops Afs_vnodeops = { - mp_afs_open, - mp_afs_close, - mp_afs_rdwr, - afs_ioctl, - afs_noop, - mp_afs_getattr, - mp_afs_setattr, - mp_afs_access, - mp_afs_lookup, - mp_afs_create, - mp_afs_remove, - mp_afs_link, - mp_afs_rename, - mp_afs_mkdir, - mp_afs_rmdir, - afs_readdir, - mp_afs_symlink, - mp_afs_readlink, - mp_afs_fsync, - mp_afs_inactive, - afs_bmap, - afs_hp_strategy, + mp_afs_open, + mp_afs_close, + mp_afs_rdwr, + afs_ioctl, + afs_noop, + mp_afs_getattr, + mp_afs_setattr, + mp_afs_access, + mp_afs_lookup, + mp_afs_create, + mp_afs_remove, + mp_afs_link, + mp_afs_rename, + mp_afs_mkdir, + mp_afs_rmdir, + afs_readdir, + mp_afs_symlink, + mp_afs_readlink, + mp_afs_fsync, + mp_afs_inactive, + afs_bmap, + afs_hp_strategy, #if !defined(AFS_NONFSTRANS) - /* on HPUX102 the nfs translator calls afs_bread but does - * not call afs_brelse. Hence we see a memory leak. If the - * VOP_BREAD() call fails, then nfs does VOP_RDWR() to get - * the same data : this is the path we follow now. */ - afs_noop, - afs_noop, + /* on HPUX102 the nfs translator calls afs_bread but does + * not call afs_brelse. Hence we see a memory leak. If the + * VOP_BREAD() call fails, then nfs does VOP_RDWR() to get + * the same data : this is the path we follow now. */ + afs_noop, + afs_noop, #else - mp_afs_bread, - mp_afs_brelse, + mp_afs_bread, + mp_afs_brelse, #endif - afs_badop, /* pathsend */ - afs_noop, /* setacl */ - afs_noop, /* getacl */ - afs_pathconf, - afs_pathconf, - mp_afs_lockctl, - afs_lockf, /* lockf */ - mp_afs_fid, - afs_noop, /*fsctl */ - afs_badop, - afs_pagein, - afs_pageout, - NULL, - NULL, - afs_prealloc, - afs_mapdbd, - afs_mmap, - afs_cachelimit, - afs_vm_checkpage, - afs_vm_fscontiguous, - afs_vm_stopio, - afs_read_ahead , - afs_release, - afs_unmap, - afs_swapfs_len, - mp_afs_readdir2, - afs_readdir3, + afs_badop, /* pathsend */ + afs_noop, /* setacl */ + afs_noop, /* getacl */ + afs_pathconf, + afs_pathconf, + mp_afs_lockctl, + afs_lockf, /* lockf */ + mp_afs_fid, + afs_noop, /*fsctl */ + afs_badop, + afs_pagein, + afs_pageout, + NULL, + NULL, + afs_prealloc, + afs_mapdbd, + afs_mmap, + afs_cachelimit, + afs_vm_checkpage, + afs_vm_fscontiguous, + afs_vm_stopio, + afs_read_ahead, + afs_release, + afs_unmap, + afs_swapfs_len, + mp_afs_readdir2, + afs_readdir3, }; struct vnodeops *afs_ops = &Afs_vnodeops; @@ -661,133 +684,130 @@ struct fileops afs_fileops = { ******************************************************************** */ pgcnt_t -afspgin_setup_io_ranges( - vfspage_t *vm_info, - pgcnt_t bpages, - k_off_t isize, - pgcnt_t startindex) +afspgin_setup_io_ranges(vfspage_t * vm_info, pgcnt_t bpages, k_off_t isize, + pgcnt_t startindex) { - pgcnt_t file_offset = VM_FILE_OFFSET(vm_info); - pgcnt_t minpage; /* first page to bring in */ - pgcnt_t maxpage; /* one past last page to bring in */ - pgcnt_t maxpagein; - pgcnt_t multio_maxpage; - daddr_t start_blk; - dbd_t *dbd; - expnd_flags_t up_reason, down_reason; - int count = 1; - int indx = 0; - int max_num_io; - int dbdtype; - preg_t *prp; - - VM_GET_IO_INFO(vm_info, maxpagein, max_num_io); - - /* - * We do not go past the end of the current pregion nor past the end - * of the current file. - */ - - maxpage = startindex + (bpages - (startindex+file_offset) % bpages); - maxpage = vm_reset_maxpage(vm_info, maxpage); - maxpage = MIN(maxpage, (pgcnt_t)btorp(isize) - file_offset); - maxpage = MIN(maxpage, startindex + maxpagein); - multio_maxpage = maxpage = vm_maxpage(vm_info, maxpage); - - if (!maxpage) - return (0); - - VASSERT(maxpage >= startindex); - - /* - * Expanding the fault will create calls to FINDENTRY() for new - * pages, which will obsolete "dbd", so copy what it points to - * and clear it to prevent using stale data. - */ - - prp = VM_PRP(vm_info); - dbdtype = DBD_TYPE(vm_info); - start_blk = DBD_DATA(vm_info); - vm_info->dbd = NULL; - vm_info->vfd = NULL; - VASSERT(dbdtype != DBD_NONE); - - if (max_num_io == 1) { - /* - * We need to set up one I/O: First we attempt to expand the - * I/O forward. Then we expand the I/O backwards. - */ - count = expand_faultin_up(vm_info, dbdtype, (int)bpages, - maxpage, count, startindex, - start_blk, &up_reason); - maxpage = startindex + count; - VASSERT(maxpage <= startindex + maxpagein); - minpage = startindex - (startindex+file_offset) % bpages; - minpage = MAX(minpage, maxpage - maxpagein); - VASSERT(startindex >= VM_BASE_OFFSET(vm_info)); - minpage = vm_minpage(vm_info, minpage); - VASSERT(minpage <= startindex); - count = expand_faultin_down(vm_info, dbdtype, (int)bpages, - minpage, count, &startindex, - &start_blk, &down_reason); - VM_SET_IO_STARTINDX(vm_info, 0, startindex); - VM_SET_IO_STARTBLK(vm_info, 0, start_blk); - VM_SET_IO_COUNT(vm_info, 0, count); - VM_SET_NUM_IO(vm_info, 1); - } - - if (max_num_io > 1) { - /* - * We need to set up multiple I/O information; beginning - * with the startindex, we will expand upwards. The expansion - * could stop for one of 2 reasons; we take the appropriate - * action in each of these cases: - * o VM reasons: abort setting up the multiple I/O - * information and return to our caller indicating - * that "retry" is required. - * o pagelimit: set up the next I/O info [we may have - * reached multio_maxpage at this point]. - * Note that expansion involves no more than a block at a time; - * hence it could never stop due to "discontiguous block" - * reason. - */ - startindex = minpage = vm_minpage(vm_info, 0); - for (indx = 0; - (indx < max_num_io) && (startindex < multio_maxpage); - indx++, startindex +=count) { - dbd = FINDDBD(prp->p_reg, startindex); - start_blk = dbd->dbd_data; - maxpage = startindex + - (bpages - (startindex+file_offset) % bpages); - maxpage = min(maxpage, multio_maxpage); - count = expand_faultin_up(vm_info, dbdtype, - bpages, maxpage, 1 /* count */, - startindex, start_blk, &up_reason); - VM_SET_IO_STARTINDX(vm_info, indx, startindex); - VM_SET_IO_STARTBLK(vm_info, indx, start_blk); - VM_SET_IO_COUNT(vm_info, indx, count); - if (up_reason & VM_REASONS) - break; - VASSERT(!(up_reason&NONCONTIGUOUS_BLOCK)); - VASSERT(up_reason & PAGELIMIT); - } - if (startindex < multio_maxpage) { - VM_MULT_IO_FAILURE(vm_info); - VM_REINIT_FAULT_DBDVFD(vm_info); - return (0); /* retry */ - } - count = maxpagein; - VM_SET_NUM_IO(vm_info, indx); - } - - /* - * Tell VM where the I/O intends to start. This may be different - * from the faulting point. - */ - - VM_SET_STARTINDX(vm_info, VM_GET_IO_STARTINDX(vm_info, 0)); - - return(count); + pgcnt_t file_offset = VM_FILE_OFFSET(vm_info); + pgcnt_t minpage; /* first page to bring in */ + pgcnt_t maxpage; /* one past last page to bring in */ + pgcnt_t maxpagein; + pgcnt_t multio_maxpage; + daddr_t start_blk; + dbd_t *dbd; + expnd_flags_t up_reason, down_reason; + int count = 1; + int indx = 0; + int max_num_io; + int dbdtype; + preg_t *prp; + + VM_GET_IO_INFO(vm_info, maxpagein, max_num_io); + + /* + * We do not go past the end of the current pregion nor past the end + * of the current file. + */ + + maxpage = startindex + (bpages - (startindex + file_offset) % bpages); + maxpage = vm_reset_maxpage(vm_info, maxpage); + maxpage = MIN(maxpage, (pgcnt_t) btorp(isize) - file_offset); + maxpage = MIN(maxpage, startindex + maxpagein); + multio_maxpage = maxpage = vm_maxpage(vm_info, maxpage); + + if (!maxpage) + return (0); + + VASSERT(maxpage >= startindex); + + /* + * Expanding the fault will create calls to FINDENTRY() for new + * pages, which will obsolete "dbd", so copy what it points to + * and clear it to prevent using stale data. + */ + + prp = VM_PRP(vm_info); + dbdtype = DBD_TYPE(vm_info); + start_blk = DBD_DATA(vm_info); + vm_info->dbd = NULL; + vm_info->vfd = NULL; + VASSERT(dbdtype != DBD_NONE); + + if (max_num_io == 1) { + /* + * We need to set up one I/O: First we attempt to expand the + * I/O forward. Then we expand the I/O backwards. + */ + count = + expand_faultin_up(vm_info, dbdtype, (int)bpages, maxpage, count, + startindex, start_blk, &up_reason); + maxpage = startindex + count; + VASSERT(maxpage <= startindex + maxpagein); + minpage = startindex - (startindex + file_offset) % bpages; + minpage = MAX(minpage, maxpage - maxpagein); + VASSERT(startindex >= VM_BASE_OFFSET(vm_info)); + minpage = vm_minpage(vm_info, minpage); + VASSERT(minpage <= startindex); + count = + expand_faultin_down(vm_info, dbdtype, (int)bpages, minpage, count, + &startindex, &start_blk, &down_reason); + VM_SET_IO_STARTINDX(vm_info, 0, startindex); + VM_SET_IO_STARTBLK(vm_info, 0, start_blk); + VM_SET_IO_COUNT(vm_info, 0, count); + VM_SET_NUM_IO(vm_info, 1); + } + + if (max_num_io > 1) { + /* + * We need to set up multiple I/O information; beginning + * with the startindex, we will expand upwards. The expansion + * could stop for one of 2 reasons; we take the appropriate + * action in each of these cases: + * o VM reasons: abort setting up the multiple I/O + * information and return to our caller indicating + * that "retry" is required. + * o pagelimit: set up the next I/O info [we may have + * reached multio_maxpage at this point]. + * Note that expansion involves no more than a block at a time; + * hence it could never stop due to "discontiguous block" + * reason. + */ + startindex = minpage = vm_minpage(vm_info, 0); + for (indx = 0; (indx < max_num_io) && (startindex < multio_maxpage); + indx++, startindex += count) { + dbd = FINDDBD(prp->p_reg, startindex); + start_blk = dbd->dbd_data; + maxpage = + startindex + (bpages - (startindex + file_offset) % bpages); + maxpage = min(maxpage, multio_maxpage); + count = + expand_faultin_up(vm_info, dbdtype, bpages, maxpage, + 1 /* count */ , + startindex, start_blk, &up_reason); + VM_SET_IO_STARTINDX(vm_info, indx, startindex); + VM_SET_IO_STARTBLK(vm_info, indx, start_blk); + VM_SET_IO_COUNT(vm_info, indx, count); + if (up_reason & VM_REASONS) + break; + VASSERT(!(up_reason & NONCONTIGUOUS_BLOCK)); + VASSERT(up_reason & PAGELIMIT); + } + if (startindex < multio_maxpage) { + VM_MULT_IO_FAILURE(vm_info); + VM_REINIT_FAULT_DBDVFD(vm_info); + return (0); /* retry */ + } + count = maxpagein; + VM_SET_NUM_IO(vm_info, indx); + } + + /* + * Tell VM where the I/O intends to start. This may be different + * from the faulting point. + */ + + VM_SET_STARTINDX(vm_info, VM_GET_IO_STARTINDX(vm_info, 0)); + + return (count); } @@ -799,39 +819,36 @@ afspgin_setup_io_ranges( ******************************************************************** */ retval_t -afspgin_blkflsh ( - vfspage_t *vm_info, - struct vnode *devvp, - pgcnt_t *num_4k) +afspgin_blkflsh(vfspage_t * vm_info, struct vnode * devvp, pgcnt_t * num_4k) { - int flush_reslt = 0; - pgcnt_t count = *num_4k; - pgcnt_t page_count; - int indx = 0; - int num_io = VM_GET_NUM_IO(vm_info); - - /* - * On this blkflush() we don't want to purge the buffer cache and we do - * want to wait, so the flags are '0'. - */ - - for (indx = 0; indx < num_io; indx++) { - flush_reslt = blkflush(devvp, - (daddr_t)VM_GET_IO_STARTBLK(vm_info, indx), - ptob(VM_GET_IO_COUNT(vm_info, indx)), - 0, VM_REGION(vm_info)); - if (flush_reslt) { - vm_lock(vm_info); - if (vm_page_now_valid(vm_info, &page_count)) { - vm_release_memory(vm_info); - vm_release_structs(vm_info); - *num_4k = page_count; - return(VM_PAGE_PRESENT); - } - return (VM_RETRY); - } - } - return (VM_DONE); + int flush_reslt = 0; + pgcnt_t count = *num_4k; + pgcnt_t page_count; + int indx = 0; + int num_io = VM_GET_NUM_IO(vm_info); + + /* + * On this blkflush() we don't want to purge the buffer cache and we do + * want to wait, so the flags are '0'. + */ + + for (indx = 0; indx < num_io; indx++) { + flush_reslt = + blkflush(devvp, (daddr_t) VM_GET_IO_STARTBLK(vm_info, indx), + ptob(VM_GET_IO_COUNT(vm_info, indx)), 0, + VM_REGION(vm_info)); + if (flush_reslt) { + vm_lock(vm_info); + if (vm_page_now_valid(vm_info, &page_count)) { + vm_release_memory(vm_info); + vm_release_structs(vm_info); + *num_4k = page_count; + return (VM_PAGE_PRESENT); + } + return (VM_RETRY); + } + } + return (VM_DONE); } /* @@ -842,104 +859,96 @@ afspgin_blkflsh ( ******************************************************************** */ int -afspgin_io( - vfspage_t *vm_info, - struct vnode *devvp, - pgcnt_t bpages, - pgcnt_t maxpagein, - pgcnt_t count) +afspgin_io(vfspage_t * vm_info, struct vnode *devvp, pgcnt_t bpages, + pgcnt_t maxpagein, pgcnt_t count) { - int i; - int error = 0; - caddr_t vaddr = VM_ADDR(vm_info); - caddr_t virt_addr = VM_MAPPED_ADDR(vm_info); - pagein_info_t *io = VM_PAGEIN_INFO(vm_info); - preg_t *prp = VM_PRP(vm_info); - int wrt = VM_WRT(vm_info); - space_t space = VM_SPACE(vm_info); - int num_io = VM_GET_NUM_IO(vm_info); - -#ifdef notdef /* Not used in AFS */ - /* - * With VM_READ_AHEAD_ALLOWED() macro, check if read-ahead should - * be used in this case. - * - * Unlike UFS, NFS does not start the faulting page I/O - * asynchronously. Why? Asynchronous requests are handled by the - * biod's. It doesn't make sense to queue up the faulting request - * behind other asynchrnous requests. This is not true for UFS - * where the asynchrnous request is immediately handled. - */ - - if ((VM_READ_AHEAD_ALLOWED(vm_info)) && - (nfs_read_ahead_on) && - (NFS_DO_READ_AHEAD) && - (should_do_read_ahead(prp, vaddr))) { - - pgcnt_t max_rhead_io; - caddr_t rhead_vaddr; - pgcnt_t total_rheads_allowed; - - /* - * Determine the maximum amount of read-ahead I/O. - */ - total_rheads_allowed = maxpagein - count ; - - /* - * If the count is less than a block, raise it to one. - */ - if (total_rheads_allowed < bpages) - total_rheads_allowed = bpages; - - max_rhead_io = total_rheads_allowed; - rhead_vaddr = VM_MAPPED_ADDR(vm_info) + (count*NBPG); - error = nfs_read_ahead(vm_info->vp, prp, wrt, space, - rhead_vaddr, &max_rhead_io); - - /* - * Set the next fault location. If read_ahead launches any - * I/O it will adjust it accordingly. - */ - vm_info->prp->p_nextfault = vm_info->startindex + count; - - /* - * Now perform the faulting I/O synchronously. - */ - vm_unlock(vm_info); - - error = syncpageio((swblk_t)VM_GET_IO_STARTBLK(vm_info, 0), - VM_MAPPED_SPACE(vm_info), - VM_MAPPED_ADDR(vm_info), - (int)ptob(count), B_READ, devvp, - B_vfs_pagein|B_pagebf, VM_REGION(vm_info)); - } else + int i; + int error = 0; + caddr_t vaddr = VM_ADDR(vm_info); + caddr_t virt_addr = VM_MAPPED_ADDR(vm_info); + pagein_info_t *io = VM_PAGEIN_INFO(vm_info); + preg_t *prp = VM_PRP(vm_info); + int wrt = VM_WRT(vm_info); + space_t space = VM_SPACE(vm_info); + int num_io = VM_GET_NUM_IO(vm_info); + +#ifdef notdef /* Not used in AFS */ + /* + * With VM_READ_AHEAD_ALLOWED() macro, check if read-ahead should + * be used in this case. + * + * Unlike UFS, NFS does not start the faulting page I/O + * asynchronously. Why? Asynchronous requests are handled by the + * biod's. It doesn't make sense to queue up the faulting request + * behind other asynchrnous requests. This is not true for UFS + * where the asynchrnous request is immediately handled. + */ + + if ((VM_READ_AHEAD_ALLOWED(vm_info)) && (nfs_read_ahead_on) + && (NFS_DO_READ_AHEAD) && (should_do_read_ahead(prp, vaddr))) { + + pgcnt_t max_rhead_io; + caddr_t rhead_vaddr; + pgcnt_t total_rheads_allowed; + + /* + * Determine the maximum amount of read-ahead I/O. + */ + total_rheads_allowed = maxpagein - count; + + /* + * If the count is less than a block, raise it to one. + */ + if (total_rheads_allowed < bpages) + total_rheads_allowed = bpages; + + max_rhead_io = total_rheads_allowed; + rhead_vaddr = VM_MAPPED_ADDR(vm_info) + (count * NBPG); + error = + nfs_read_ahead(vm_info->vp, prp, wrt, space, rhead_vaddr, + &max_rhead_io); + + /* + * Set the next fault location. If read_ahead launches any + * I/O it will adjust it accordingly. + */ + vm_info->prp->p_nextfault = vm_info->startindex + count; + + /* + * Now perform the faulting I/O synchronously. + */ + vm_unlock(vm_info); + + error = + syncpageio((swblk_t) VM_GET_IO_STARTBLK(vm_info, 0), + VM_MAPPED_SPACE(vm_info), VM_MAPPED_ADDR(vm_info), + (int)ptob(count), B_READ, devvp, + B_vfs_pagein | B_pagebf, VM_REGION(vm_info)); + } else #endif - { - virt_addr = VM_MAPPED_ADDR(vm_info); - vm_unlock(vm_info); - for (i = 0; i < num_io; i++) { - /* - * REVISIT -- investigate doing asyncpageio(). - */ - error |= (io[i].error = - syncpageio( - (swblk_t)VM_GET_IO_STARTBLK(vm_info, i), - VM_MAPPED_SPACE(vm_info), - virt_addr, - (int)ptob(VM_GET_IO_COUNT(vm_info, i)), - B_READ, devvp, - B_vfs_pagein|B_pagebf, - VM_REGION(vm_info))); - virt_addr += ptob(VM_GET_IO_COUNT(vm_info, i)); - } - /* - * Set the next fault location. If read_ahead launches any - * I/O it will adjust it accordingly. - */ - vm_info->prp->p_nextfault = vm_info->startindex + count; - } - - return (error); + { + virt_addr = VM_MAPPED_ADDR(vm_info); + vm_unlock(vm_info); + for (i = 0; i < num_io; i++) { + /* + * REVISIT -- investigate doing asyncpageio(). + */ + error |= (io[i].error = + syncpageio((swblk_t) VM_GET_IO_STARTBLK(vm_info, i), + VM_MAPPED_SPACE(vm_info), virt_addr, + (int)ptob(VM_GET_IO_COUNT(vm_info, i)), + B_READ, devvp, B_vfs_pagein | B_pagebf, + VM_REGION(vm_info))); + virt_addr += ptob(VM_GET_IO_COUNT(vm_info, i)); + } + /* + * Set the next fault location. If read_ahead launches any + * I/O it will adjust it accordingly. + */ + vm_info->prp->p_nextfault = vm_info->startindex + count; + } + + return (error); } /* @@ -950,91 +959,90 @@ afspgin_io( ******************************************************************** */ void -afspgin_update_dbd( - vfspage_t *vm_info, - int bsize) +afspgin_update_dbd(vfspage_t * vm_info, int bsize) { - k_off_t off; - pgcnt_t count = bsize / NBPG; - k_off_t rem; - pgcnt_t m; - pgcnt_t pgindx; - daddr_t blkno; - int num_io = VM_GET_NUM_IO(vm_info); - int i; - - for (i = 0; i < num_io; i++) { - - pgindx = VM_GET_IO_STARTINDX(vm_info, i); - off = vnodindx(VM_REGION(vm_info), pgindx); - rem = off % bsize; - blkno = VM_GET_IO_STARTBLK(vm_info, i); - - VASSERT(bsize % NBPG == 0); - VASSERT(rem % NBPG == 0); - - pgindx -= (pgcnt_t)btop(rem); - blkno -= (daddr_t)btodb(rem); - - /* - * This region could start in mid-block. If so, pgindx - * could be less than 0, so we adjust pgindx and blkno back - * up so that pgindx is 0. - */ - - if (pgindx < 0) { - pgcnt_t prem; - prem = 0 - pgindx; - pgindx = 0; - count -= prem; - blkno += btodb(ptob(prem)); - } - - for (m = 0; m < count && pgindx < VM_REGION_SIZE(vm_info); - m++, pgindx++, blkno += btodb(NBPG)) { - /* - * Note: since this only changes one block, it - * assumes only one block was faulted in. Currently - * this is always true for remote files, and we only - * get here for remote files, so everything is ok. - */ - vm_mark_dbd(vm_info, pgindx, blkno); - } - } + k_off_t off; + pgcnt_t count = bsize / NBPG; + k_off_t rem; + pgcnt_t m; + pgcnt_t pgindx; + daddr_t blkno; + int num_io = VM_GET_NUM_IO(vm_info); + int i; + + for (i = 0; i < num_io; i++) { + + pgindx = VM_GET_IO_STARTINDX(vm_info, i); + off = vnodindx(VM_REGION(vm_info), pgindx); + rem = off % bsize; + blkno = VM_GET_IO_STARTBLK(vm_info, i); + + VASSERT(bsize % NBPG == 0); + VASSERT(rem % NBPG == 0); + + pgindx -= (pgcnt_t) btop(rem); + blkno -= (daddr_t) btodb(rem); + + /* + * This region could start in mid-block. If so, pgindx + * could be less than 0, so we adjust pgindx and blkno back + * up so that pgindx is 0. + */ + + if (pgindx < 0) { + pgcnt_t prem; + prem = 0 - pgindx; + pgindx = 0; + count -= prem; + blkno += btodb(ptob(prem)); + } + + for (m = 0; m < count && pgindx < VM_REGION_SIZE(vm_info); + m++, pgindx++, blkno += btodb(NBPG)) { + /* + * Note: since this only changes one block, it + * assumes only one block was faulted in. Currently + * this is always true for remote files, and we only + * get here for remote files, so everything is ok. + */ + vm_mark_dbd(vm_info, pgindx, blkno); + } + } } -int afs_pagein(vp, prp, wrt, space, vaddr, ret_startindex) - struct vnode *vp; - preg_t *prp; - int wrt; - space_t space; - caddr_t vaddr; - pgcnt_t *ret_startindex; +int +afs_pagein(vp, prp, wrt, space, vaddr, ret_startindex) + struct vnode *vp; + preg_t *prp; + int wrt; + space_t space; + caddr_t vaddr; + pgcnt_t *ret_startindex; { - pgcnt_t startindex; - pgcnt_t pgindx = *ret_startindex; - pgcnt_t maxpagein; - struct vnode *devvp; - pgcnt_t count; - daddr_t start_blk=0; - int bsize; - int error; - k_off_t isize; - int shared; /* writable memory mapped file */ - retval_t retval = 0; - pgcnt_t ok_dbd_limit = 0; /* last dbd that we can trust */ - pgcnt_t bpages; /* number of pages per block */ - pgcnt_t page_count; - vfspage_t* vm_info=NULL; - int done; + pgcnt_t startindex; + pgcnt_t pgindx = *ret_startindex; + pgcnt_t maxpagein; + struct vnode *devvp; + pgcnt_t count; + daddr_t start_blk = 0; + int bsize; + int error; + k_off_t isize; + int shared; /* writable memory mapped file */ + retval_t retval = 0; + pgcnt_t ok_dbd_limit = 0; /* last dbd that we can trust */ + pgcnt_t bpages; /* number of pages per block */ + pgcnt_t page_count; + vfspage_t *vm_info = NULL; + int done; struct vattr va; - caddr_t nvaddr; - space_t nspace; - int change_to_fstore = 0; /* need to change dbds to DBD_FSTORE */ - int flush_start_blk = 0; - int flush_end_blk = 0; + caddr_t nvaddr; + space_t nspace; + int change_to_fstore = 0; /* need to change dbds to DBD_FSTORE */ + int flush_start_blk = 0; + int flush_end_blk = 0; int i, j; @@ -1042,13 +1050,14 @@ int afs_pagein(vp, prp, wrt, space, vaddr, ret_startindex) vmemp_lockx(); /* lock down VM empire */ /* Initialize the VM info structure */ - done = vm_pagein_init(&vm_info, prp, pgindx, space, vaddr, wrt, 0, - LGPG_ENABLE); + done = + vm_pagein_init(&vm_info, prp, pgindx, space, vaddr, wrt, 0, + LGPG_ENABLE); /* Check to see if we slept and the page was falted in. */ if (done) { - vm_release_structs(vm_info); - vmemp_returnx(1); + vm_release_structs(vm_info); + vmemp_returnx(1); } vp = VM_GET_PAGEIN_VNODE(vm_info); @@ -1064,22 +1073,22 @@ int afs_pagein(vp, prp, wrt, space, vaddr, ret_startindex) if (bsize <= 0 || (bsize & (DEV_BSIZE - 1))) osi_Panic("afs_pagein: bsize is zero or not a multiple of DEV_BSIZE"); - bpages = (pgcnt_t)btop(bsize); + bpages = (pgcnt_t) btop(bsize); VASSERT(bpages > 0); VM_SET_FS_MAX_PAGES(vm_info, bpages); /* this trace cannot be here because the afs_global lock might not be - held at this point. We hold the vm global lock throughout - this procedure ( and not the AFS global lock ) - afs_Trace4(afs_iclSetp, CM_TRACE_HPPAGEIN, ICL_TYPE_POINTER, (afs_int32) vp, - ICL_TYPE_LONG, DBD_TYPE(vm_info), ICL_TYPE_LONG, bpages, - ICL_TYPE_LONG, shared); - */ + * held at this point. We hold the vm global lock throughout + * this procedure ( and not the AFS global lock ) + * afs_Trace4(afs_iclSetp, CM_TRACE_HPPAGEIN, ICL_TYPE_POINTER, (afs_int32) vp, + * ICL_TYPE_LONG, DBD_TYPE(vm_info), ICL_TYPE_LONG, bpages, + * ICL_TYPE_LONG, shared); + */ /* Come here if we have to release the region lock before * locking pages. This can happen in memreserve() and * blkflush(). */ -retry: + retry: /* * For remote files like ours, we want to check to see if the file has shrunk. * If so, we should invalidate any pages past the end. In the name @@ -1087,47 +1096,46 @@ retry: * past the end of the file. */ { - if (VOP_GETATTR(vp, &va, kt_cred(u.u_kthreadp), VIFSYNC) != 0) { - VM_ZOMBIE_OBJECT(vm_info); - vm_release_memory(vm_info); - vm_release_structs(vm_info); - vmemp_returnx(0); - } - isize = va.va_size; - if (vnodindx(VM_REGION(vm_info), pgindx) >= isize) { - /* - * The file has shrunk and someone is trying to access a - * page past the end of the object. Shrink the object back - * to its currrent size, send a SIGBUS to the faulting - * process and return. - * - * We must release the region lock before calling mtrunc(), - * since mtrunc() locks all the regions that are using this - * file. - */ - vm_release_memory(vm_info); - vm_truncate_region(vm_info, isize); - vm_release_structs(vm_info); - vmemp_returnx(-SIGBUS); - } + if (VOP_GETATTR(vp, &va, kt_cred(u.u_kthreadp), VIFSYNC) != 0) { + VM_ZOMBIE_OBJECT(vm_info); + vm_release_memory(vm_info); + vm_release_structs(vm_info); + vmemp_returnx(0); + } + isize = va.va_size; + if (vnodindx(VM_REGION(vm_info), pgindx) >= isize) { + /* + * The file has shrunk and someone is trying to access a + * page past the end of the object. Shrink the object back + * to its currrent size, send a SIGBUS to the faulting + * process and return. + * + * We must release the region lock before calling mtrunc(), + * since mtrunc() locks all the regions that are using this + * file. + */ + vm_release_memory(vm_info); + vm_truncate_region(vm_info, isize); + vm_release_structs(vm_info); + vmemp_returnx(-SIGBUS); + } } maxpagein = vm_pick_maxpagein(vm_info); if (vm_wait_for_memory(vm_info, maxpagein, 1)) { - /* Check to see if we should continue faulting. */ - if (vm_page_now_valid(vm_info, &page_count)) { - vm_release_memory(vm_info); - vm_release_structs(vm_info); - vmemp_returnx(page_count); - } + /* Check to see if we should continue faulting. */ + if (vm_page_now_valid(vm_info, &page_count)) { + vm_release_memory(vm_info); + vm_release_structs(vm_info); + vmemp_returnx(page_count); + } } if (count = vm_no_io_required(vm_info)) { - /* Release any excess memory. */ - vm_release_memory(vm_info); - vm_release_structs(vm_info); - vmemp_returnx(count); + /* Release any excess memory. */ + vm_release_memory(vm_info); + vm_release_structs(vm_info); + vmemp_returnx(count); } - #ifdef OSDEBUG /* * We should never have DBD_HOLE pages in a non-MMF region. @@ -1135,51 +1143,51 @@ retry: if (!shared) VASSERT(dbd->dbd_type != DBD_HOLE); #endif - VASSERT( DBD_TYPE(vm_info) != DBD_NONE); + VASSERT(DBD_TYPE(vm_info) != DBD_NONE); startindex = *ret_startindex; /* * If the page we want is in memory already, take it */ - if (VM_MEMORY_RESERVED(vm_info) < maxpagein) - { - /* pick up the rest of memory now. */ - if (vm_wait_for_memory(vm_info, maxpagein, 0)) { - if (vm_page_now_valid(vm_info, &page_count)) { - vm_release_memory(vm_info); - vm_release_structs(vm_info); - vmemp_returnx(page_count); - } - goto retry; - } + if (VM_MEMORY_RESERVED(vm_info) < maxpagein) { + /* pick up the rest of memory now. */ + if (vm_wait_for_memory(vm_info, maxpagein, 0)) { + if (vm_page_now_valid(vm_info, &page_count)) { + vm_release_memory(vm_info); + vm_release_structs(vm_info); + vmemp_returnx(page_count); + } + goto retry; + } } - if (!(count = afspgin_setup_io_ranges(vm_info, bpages, isize, - startindex))) { - goto retry; + if (! + (count = + afspgin_setup_io_ranges(vm_info, bpages, isize, startindex))) { + goto retry; } startindex = VM_GET_STARTINDX(vm_info); VASSERT(maxpagein >= count); - + /* * Release the memory we won't need. */ if (count < maxpagein) { - vm_release_excess_memory(vm_info, - (VM_MEMORY_RESERVED(vm_info) - count)); - } + vm_release_excess_memory(vm_info, + (VM_MEMORY_RESERVED(vm_info) - count)); + } retval = afspgin_blkflsh(vm_info, devvp, &count); - + if (retval == VM_RETRY) { - goto retry; + goto retry; } if (retval == VM_PAGE_PRESENT) - return (count); + return (count); #if 0 /* @@ -1191,9 +1199,9 @@ retry: /* It's a real fault, not a reclaim */ { - krusage_cntr_t *temp; - temp = kt_cntrp(u.u_kthreadp); - temp->krc_majflt++; + krusage_cntr_t *temp; + temp = kt_cntrp(u.u_kthreadp); + temp->krc_majflt++; } #endif @@ -1212,26 +1220,26 @@ retry: * Count may have been adjusted, check to make sure it's non-zero. */ if (count == 0) { - if (vm_retry(vm_info)) { - goto retry; - } - - /* - * Release resources and retry the fault. Release any excess - * memory. - */ - - vm_release_memory(vm_info); - vm_release_structs(vm_info); - vmemp_returnx(0); + if (vm_retry(vm_info)) { + goto retry; + } + + /* + * Release resources and retry the fault. Release any excess + * memory. + */ + + vm_release_memory(vm_info); + vm_release_structs(vm_info); + vmemp_returnx(0); } error = afspgin_io(vm_info, devvp, bpages, maxpagein, count); if ((VM_IS_ZOMBIE(vm_info)) || (error)) { - retval = -SIGBUS; - VM_ZOMBIE_OBJECT(vm_info); - goto backout; + retval = -SIGBUS; + VM_ZOMBIE_OBJECT(vm_info); + goto backout; } /* * For a writable memory mapped file that is remote we must @@ -1240,63 +1248,63 @@ retry: * no easy way to do this, so this gets a little ugly. */ if (shared && wrt) { - /* - * See if The user wants to write to this page. Write some - * minimal amount of data back to the remote file to - * force allocation of file space. We only need to - * write a small amount, since holes are always at - * least one filesystem block in size. - */ - error = vm_alloc_hole(vm_info); - - /* - * If some sort of I/O error occurred we generate a - * SIGBUS for the process that caused the write, - * undo our page locks, etc and return. - */ - if ((VM_IS_ZOMBIE(vm_info)) || (error)) { - VM_ZOMBIE_OBJECT(vm_info); - retval = -SIGBUS; - goto backout; - } - - /* - * Change these dbds to DBD_FSTORE. We cannot do it here, - * since the region must be locked, and it is not locked - * at the moment. We cannot lock the region yet, as we - * first have to release the page locks. - */ - change_to_fstore = 1; + /* + * See if The user wants to write to this page. Write some + * minimal amount of data back to the remote file to + * force allocation of file space. We only need to + * write a small amount, since holes are always at + * least one filesystem block in size. + */ + error = vm_alloc_hole(vm_info); + + /* + * If some sort of I/O error occurred we generate a + * SIGBUS for the process that caused the write, + * undo our page locks, etc and return. + */ + if ((VM_IS_ZOMBIE(vm_info)) || (error)) { + VM_ZOMBIE_OBJECT(vm_info); + retval = -SIGBUS; + goto backout; + } + + /* + * Change these dbds to DBD_FSTORE. We cannot do it here, + * since the region must be locked, and it is not locked + * at the moment. We cannot lock the region yet, as we + * first have to release the page locks. + */ + change_to_fstore = 1; } vm_finish_io(vm_info, count); - + /* * Acquire the lock before we play around with changing the vfd's. */ vm_lock(vm_info); if (change_to_fstore) - afspgin_update_dbd(vm_info, bsize); - -#if defined(AFS_HPUX110_ENV) - getppdp()->cnt.v_exfod += count; + afspgin_update_dbd(vm_info, bsize); + +#if defined(AFS_HPUX110_ENV) + getppdp()->cnt.v_exfod += count; #else mpproc_info[getprocindex()].cnt.v_exfod += count; #endif - vmemp_unlockx(); /* free up VM empire */ + vmemp_unlockx(); /* free up VM empire */ *ret_startindex = startindex; - + /* * In case we have any excess memory... */ if (VM_MEMORY_RESERVED(vm_info)) - vm_release_memory(vm_info); + vm_release_memory(vm_info); vm_release_structs(vm_info); - + return count; -backout: + backout: vm_finish_io_failed(vm_info, count); @@ -1308,20 +1316,20 @@ backout: * In case we have any excess memory... */ if (VM_MEMORY_RESERVED(vm_info)) - vm_release_memory(vm_info); + vm_release_memory(vm_info); vm_release_structs(vm_info); - vmemp_unlockx(); /* free up VM empire */ + vmemp_unlockx(); /* free up VM empire */ return retval; } int -afs_pageout(vp,prp, start, end, flags) - struct vnode *vp; /* not used */ - preg_t *prp; - pgcnt_t start; - pgcnt_t end; - int flags; +afs_pageout(vp, prp, start, end, flags) + struct vnode *vp; /* not used */ + preg_t *prp; + pgcnt_t start; + pgcnt_t end; + int flags; { struct vnode *filevp; struct vnode *devvp; @@ -1329,7 +1337,7 @@ afs_pageout(vp,prp, start, end, flags) int steal; int vhand; int hard; - int *piocnt; /* wakeup counter used if PAGEOUT_WAIT */ + int *piocnt; /* wakeup counter used if PAGEOUT_WAIT */ struct ucred *old_cred; vfspage_t vm_info; fsdata_t args; @@ -1339,10 +1347,10 @@ afs_pageout(vp,prp, start, end, flags) struct inode *ip; AFS_STATCNT(afs_pageout); - + steal = (flags & PAGEOUT_FREE); vhand = (flags & PAGEOUT_VHAND); - hard = (flags & PAGEOUT_HARD); + hard = (flags & PAGEOUT_HARD); vmemp_lockx(); @@ -1356,7 +1364,7 @@ afs_pageout(vp,prp, start, end, flags) */ if (vm_no_pageout(&vm_info)) { vmemp_unlockx(); - return(0); + return (0); } /* @@ -1364,10 +1372,10 @@ afs_pageout(vp,prp, start, end, flags) */ vm_setup_wait_for_io(&vm_info); - filevp = VM_GET_PAGEOUT_VNODE(&vm_info); /* always page out to back store */ + filevp = VM_GET_PAGEOUT_VNODE(&vm_info); /* always page out to back store */ VASSERT(filevp != NULL); - memset((caddr_t)&args, 0, sizeof(fsdata_t)); + memset((caddr_t) & args, 0, sizeof(fsdata_t)); args.remote_down = 0; /* assume remote file servers are up */ args.remote = 1; /* we are remote */ args.bsize = 0; /* filled up later by afs_vm_checkpage() */ @@ -1376,8 +1384,7 @@ afs_pageout(vp,prp, start, end, flags) ip = VTOI(filevp); devvp = ip->i_devvp; file_is_remote = 0; - } - else { + } else { file_is_remote = 1; devvp = filevp; @@ -1388,8 +1395,8 @@ afs_pageout(vp,prp, start, end, flags) * of dirty NFS pages until a future time. */ #ifdef notdef - if (vhand && filevp->v_fstype == VNFS && - vtomi(filevp)->mi_down && vtomi(filevp)->mi_hard) { + if (vhand && filevp->v_fstype == VNFS && vtomi(filevp)->mi_down + && vtomi(filevp)->mi_hard) { extern afs_int32 vhand_nfs_retry; /* * If there is still time left on our timer, we will @@ -1406,14 +1413,14 @@ afs_pageout(vp,prp, start, end, flags) * it must get the file size and other attributes if it comes across * a dirty page. */ - vm_info.fs_data = (caddr_t)&args; + vm_info.fs_data = (caddr_t) & args; /* this trace cannot be here because the afs_global lock might not be - held at this point. We hold the vm global lock throughout - this procedure ( and not the AFS global lock ) - afs_Trace4(afs_iclSetp, CM_TRACE_HPPAGEOUT, ICL_TYPE_POINTER, (afs_int32) filevp, - ICL_TYPE_LONG, start, ICL_TYPE_LONG, end, ICL_TYPE_LONG, flags); - */ + * held at this point. We hold the vm global lock throughout + * this procedure ( and not the AFS global lock ) + * afs_Trace4(afs_iclSetp, CM_TRACE_HPPAGEOUT, ICL_TYPE_POINTER, (afs_int32) filevp, + * ICL_TYPE_LONG, start, ICL_TYPE_LONG, end, ICL_TYPE_LONG, flags); + */ i = start; @@ -1428,37 +1435,37 @@ afs_pageout(vp,prp, start, end, flags) space_t nspace; caddr_t nvaddr; - /* - * Ask the VM system to find the next run of pages. - */ - vm_find_next_range(&vm_info, i, end); - - /* - * It's possible that the remote file shrunk in size. Check the flags - * to see if the request was beyond the end of the file. If it was, - * truncate the region to the file size and continue. We could be on a - * run so after trunction continue, there may be some I/O to write - * out. - */ - if (VM_FS_FLAGS(&vm_info) & PAGEOUT_TRUNCATE) { - pgcnt_t pglen = (pgcnt_t)btorp(args.isize); - - /* - * This page is past the end of the file. Unlock this page - * (region_trunc will throw it away) and then call - * region_trunc() to invalidate all pages past the new end of - * the file. - */ - region_trunc(VM_REGION(&vm_info), pglen, pglen + 1); - - /* - * remove the truncation flag. - */ - VM_UNSETFS_FLAGS(&vm_info, PAGEOUT_TRUNCATE); - } - - if (VM_NO_PAGEOUT_RUN(&vm_info)) - break; + /* + * Ask the VM system to find the next run of pages. + */ + vm_find_next_range(&vm_info, i, end); + + /* + * It's possible that the remote file shrunk in size. Check the flags + * to see if the request was beyond the end of the file. If it was, + * truncate the region to the file size and continue. We could be on a + * run so after trunction continue, there may be some I/O to write + * out. + */ + if (VM_FS_FLAGS(&vm_info) & PAGEOUT_TRUNCATE) { + pgcnt_t pglen = (pgcnt_t) btorp(args.isize); + + /* + * This page is past the end of the file. Unlock this page + * (region_trunc will throw it away) and then call + * region_trunc() to invalidate all pages past the new end of + * the file. + */ + region_trunc(VM_REGION(&vm_info), pglen, pglen + 1); + + /* + * remove the truncation flag. + */ + VM_UNSETFS_FLAGS(&vm_info, PAGEOUT_TRUNCATE); + } + + if (VM_NO_PAGEOUT_RUN(&vm_info)) + break; /* * We have a run of dirty pages [args.start...args.end]. @@ -1467,31 +1474,32 @@ afs_pageout(vp,prp, start, end, flags) VASSERT((filevp->v_vfsp->vfs_flag & VFS_RDONLY) == 0); VASSERT(VM_GET_NUM_IO(&vm_info) == 1); - /* - * We will be doing an I/O on the region, let the VM system know. - */ - (void)vm_up_physio_count(&vm_info); + /* + * We will be doing an I/O on the region, let the VM system know. + */ + (void)vm_up_physio_count(&vm_info); /* * Okay, get set to perform the I/O. */ inode_changed = 1; - npages = (VM_END_PAGEOUT_INDX(&vm_info) + 1) - - VM_START_PAGEOUT_INDX(&vm_info); + npages = + (VM_END_PAGEOUT_INDX(&vm_info) + 1) - + VM_START_PAGEOUT_INDX(&vm_info); /* * Allocate and initialize an I/O buffer. */ bp = bswalloc(); - vm_init_bp(&vm_info, bp); /* Let the VM system initialize */ + vm_init_bp(&vm_info, bp); /* Let the VM system initialize */ - /* Identify this buffer for KI */ - bp->b_bptype = B_vfs_pageout|B_pagebf; + /* Identify this buffer for KI */ + bp->b_bptype = B_vfs_pageout | B_pagebf; if (steal) - bp->b_flags = B_CALL|B_BUSY|B_PAGEOUT; /* steal pages */ + bp->b_flags = B_CALL | B_BUSY | B_PAGEOUT; /* steal pages */ else - bp->b_flags = B_CALL|B_BUSY; /* keep pages */ + bp->b_flags = B_CALL | B_BUSY; /* keep pages */ /* * If we are vhand paging over NFS, we will wait for the I/O @@ -1534,32 +1542,31 @@ afs_pageout(vp,prp, start, end, flags) nbytes = roundup(args.isize - start, DEV_BSIZE); } - /* - * Now get ready to perform the I/O - */ - if (!vm_protect_pageout(&vm_info, npages)) - { - VASSERT(vhand); - vm_undo_invalidation(&vm_info, vm_info.start, vm_info.end); - vm_finish_io_failed(&vm_info, npages); - bswfree(bp); - break; - } - /* - * If this is an NFS write by vhand(), we will not be calling - * pageiodone(). asyncpageio() increments parolemem for us - * if bp->b_iodone is pageiodone, so we must do it manually - * if pageiodone() will not be called automatically. - */ - if (!(bp->b_flags & B_CALL) && steal) { - register ulong_t context; - - SPINLOCK_USAV(pfdat_lock, context); - parolemem += btorp(nbytes); - SPINUNLOCK_USAV(pfdat_lock, context); - } - blkflush(devvp, VM_START_PAGEOUT_BLK(&vm_info), (long)nbytes, - (BX_NOBUFWAIT|BX_PURGE), VM_REGION(&vm_info)); + /* + * Now get ready to perform the I/O + */ + if (!vm_protect_pageout(&vm_info, npages)) { + VASSERT(vhand); + vm_undo_invalidation(&vm_info, vm_info.start, vm_info.end); + vm_finish_io_failed(&vm_info, npages); + bswfree(bp); + break; + } + /* + * If this is an NFS write by vhand(), we will not be calling + * pageiodone(). asyncpageio() increments parolemem for us + * if bp->b_iodone is pageiodone, so we must do it manually + * if pageiodone() will not be called automatically. + */ + if (!(bp->b_flags & B_CALL) && steal) { + register ulong_t context; + + SPINLOCK_USAV(pfdat_lock, context); + parolemem += btorp(nbytes); + SPINUNLOCK_USAV(pfdat_lock, context); + } + blkflush(devvp, VM_START_PAGEOUT_BLK(&vm_info), (long)nbytes, + (BX_NOBUFWAIT | BX_PURGE), VM_REGION(&vm_info)); /* * If vhand is the one paging things out, and this is an NFS @@ -1572,64 +1579,65 @@ afs_pageout(vp,prp, start, end, flags) * value in the vas (this should be fixed in 10.0). */ old_cred = kt_cred(u.u_kthreadp); - if (vhand) { - set_kt_cred(u.u_kthreadp, filevp->v_vas->va_cred); - - /* - * If root was the one who opened the mmf for write, - * va_cred will be NULL. So reset kt_cred(u.u_kthreadp) to what it - * was. We will page out as root, but that is the - * correct thing to do in this case anyway. - */ - if (kt_cred(u.u_kthreadp) == NULL) - set_kt_cred(u.u_kthreadp, old_cred); - } + if (vhand) { + set_kt_cred(u.u_kthreadp, filevp->v_vas->va_cred); + + /* + * If root was the one who opened the mmf for write, + * va_cred will be NULL. So reset kt_cred(u.u_kthreadp) to what it + * was. We will page out as root, but that is the + * correct thing to do in this case anyway. + */ + if (kt_cred(u.u_kthreadp) == NULL) + set_kt_cred(u.u_kthreadp, old_cred); + } /* * Really do the I/O. */ - error = asyncpageio(bp, VM_START_PAGEOUT_BLK(&vm_info), - VM_MAPPED_SPACE(&vm_info), VM_MAPPED_ADDR(&vm_info), + error = + asyncpageio(bp, VM_START_PAGEOUT_BLK(&vm_info), + VM_MAPPED_SPACE(&vm_info), VM_MAPPED_ADDR(&vm_info), (int)nbytes, B_WRITE, devvp); VASSERT(error == 0); #ifdef notdef - /* - * If we are vhand paging over NFS we want to wait for the - * I/O to complete and take the appropriate actions if an - * error is encountered. - */ - if (vhand) { - if (waitforpageio(bp) && nfs_mi_harddown(filevp)) { - /* - * The server is down, ignore this failure, and - * try again later. (rfscall() has set our retry - * timer). - */ - fsdata.remote_down = 1; - pageiocleanup(bp, 0); - - /* - * vm_vfdcheck() has cleared the valid bit on the - * vfds for these pages. We must go back and set the - * valid bit, as the pages are really not gone. - * - * NOTE: we can do this because we still hold (and have - * not released) the region lock. - */ - if (steal) - vm_undo_invalidation(&vm_info, vm_info.start, vm_info.end); - } - else { - /* - * The I/O succeeded, or we had an error that we do - * not want to defer until later. Call pageidone() - * to handle things. - */ - pageiodone(bp); - } - } + /* + * If we are vhand paging over NFS we want to wait for the + * I/O to complete and take the appropriate actions if an + * error is encountered. + */ + if (vhand) { + if (waitforpageio(bp) && nfs_mi_harddown(filevp)) { + /* + * The server is down, ignore this failure, and + * try again later. (rfscall() has set our retry + * timer). + */ + fsdata.remote_down = 1; + pageiocleanup(bp, 0); + + /* + * vm_vfdcheck() has cleared the valid bit on the + * vfds for these pages. We must go back and set the + * valid bit, as the pages are really not gone. + * + * NOTE: we can do this because we still hold (and have + * not released) the region lock. + */ + if (steal) + vm_undo_invalidation(&vm_info, vm_info.start, + vm_info.end); + } else { + /* + * The I/O succeeded, or we had an error that we do + * not want to defer until later. Call pageidone() + * to handle things. + */ + pageiodone(bp); + } + } #endif /* @@ -1657,8 +1665,7 @@ afs_pageout(vp,prp, start, end, flags) mpproc_info[getprocindex()].cnt.v_pswpout += npages; #endif /* sar_bswapout += ptod(npages);*/ - } - else if (vhand) { + } else if (vhand) { #if defined(AFS_HPUX110_ENV) getppdp()->cnt.v_pgout++; getppdp()->cnt.v_pgpgout += npages; @@ -1673,13 +1680,13 @@ afs_pageout(vp,prp, start, end, flags) * If time and patience have delivered enough * pages, then quit now while we are ahead. */ - if (VM_STOP_PAGING(&vm_info)) - break; + if (VM_STOP_PAGING(&vm_info)) + break; i = VM_END_PAGEOUT_INDX(&vm_info) - VM_BASE_OFFSET(&vm_info) + 1; } - vm_finish_pageout(&vm_info); /* update vhand's stealscan */ + vm_finish_pageout(&vm_info); /* update vhand's stealscan */ vmemp_unlockx(); @@ -1691,7 +1698,7 @@ afs_pageout(vp,prp, start, end, flags) vm_wait_for_io(&vm_info); if (inode_changed && !file_is_remote) { - imark(ip, IUPD|ICHG); + imark(ip, IUPD | ICHG); iupdat(ip, 0, 0); } return 0; @@ -1700,42 +1707,42 @@ afs_pageout(vp,prp, start, end, flags) int afs_mapdbd(filevp, offset, bn, flags, hole, startidx, endidx) struct vnode *filevp; - off_t offset; - daddr_t *bn; /* Block number. */ - int flags; /* B_READ or B_WRITE */ - int *hole; /* To be used for read-ahead. */ - pgcnt_t *startidx; /* To be used for read-ahead. */ - pgcnt_t *endidx; /* To be used for read-ahead. */ + off_t offset; + daddr_t *bn; /* Block number. */ + int flags; /* B_READ or B_WRITE */ + int *hole; /* To be used for read-ahead. */ + pgcnt_t *startidx; /* To be used for read-ahead. */ + pgcnt_t *endidx; /* To be used for read-ahead. */ { - daddr_t lbn, local_bn; - int on; - int err; - long bsize = vtoblksz(filevp) & ~(DEV_BSIZE - 1); - - if (startidx) - *startidx = (pgcnt_t)(offset/NBPG); - if (endidx) - *endidx = (pgcnt_t)(offset/NBPG); - if (hole) - *hole = 0; /* Can't have holes. */ - if (bsize <= 0 ) - osi_Panic("afs_mapdbd: zero size"); - - lbn = (daddr_t)(offset / bsize); - on = offset % bsize; - - err = VOP_BMAP(filevp, lbn, NULL, &local_bn, flags); - VASSERT(err == 0); - - /* - * We can never get a bn less than zero on remote files. - */ - VASSERT(local_bn >= 0); - - local_bn = local_bn + btodb(on); - *bn = local_bn; - - return(0); + daddr_t lbn, local_bn; + int on; + int err; + long bsize = vtoblksz(filevp) & ~(DEV_BSIZE - 1); + + if (startidx) + *startidx = (pgcnt_t) (offset / NBPG); + if (endidx) + *endidx = (pgcnt_t) (offset / NBPG); + if (hole) + *hole = 0; /* Can't have holes. */ + if (bsize <= 0) + osi_Panic("afs_mapdbd: zero size"); + + lbn = (daddr_t) (offset / bsize); + on = offset % bsize; + + err = VOP_BMAP(filevp, lbn, NULL, &local_bn, flags); + VASSERT(err == 0); + + /* + * We can never get a bn less than zero on remote files. + */ + VASSERT(local_bn >= 0); + + local_bn = local_bn + btodb(on); + *bn = local_bn; + + return (0); } /* @@ -1746,14 +1753,14 @@ afs_mapdbd(filevp, offset, bn, flags, hole, startidx, endidx) int afs_vm_fscontiguous(vp, args, cur_data) struct vnode *vp; - vfspage_t *args; - u_int cur_data; + vfspage_t *args; + u_int cur_data; { - if (cur_data == (VM_END_PAGEOUT_BLK(args) + btodb(NBPG))) { - return(1); - } else { - return(0); - } + if (cur_data == (VM_END_PAGEOUT_BLK(args) + btodb(NBPG))) { + return (1); + } else { + return (0); + } } /* @@ -1764,15 +1771,15 @@ afs_vm_fscontiguous(vp, args, cur_data) */ afs_vm_stopio(vp, args) struct vnode *vp; - vfspage_t *args; + vfspage_t *args; { - fsdata_t *fsdata = (fsdata_t *)args->fs_data; + fsdata_t *fsdata = (fsdata_t *) args->fs_data; - if ((dbtob(VM_END_PAGEOUT_BLK(args)) + NBPG) % (fsdata->bsize) == 0) { - return(1); - } else { - return(0); - } + if ((dbtob(VM_END_PAGEOUT_BLK(args)) + NBPG) % (fsdata->bsize) == 0) { + return (1); + } else { + return (0); + } } /* @@ -1782,18 +1789,18 @@ afs_vm_stopio(vp, args) */ afs_vm_checkpage(vp, args, pgindx, cur_data) struct vnode *vp; - vfspage_t *args; - pgcnt_t pgindx; - int cur_data; + vfspage_t *args; + pgcnt_t pgindx; + int cur_data; { - fsdata_t *fsdata = (fsdata_t *)args->fs_data; - - if (fsdata->remote_down) { /* never happens for AFS */ - /* - * The remote system is down. - */ - VASSERT(args->run == 0); - return 1; + fsdata_t *fsdata = (fsdata_t *) args->fs_data; + + if (fsdata->remote_down) { /* never happens for AFS */ + /* + * The remote system is down. + */ + VASSERT(args->run == 0); + return 1; } /* * A dirty page. If we have not yet determined the file size and @@ -1802,137 +1809,136 @@ afs_vm_checkpage(vp, args, pgindx, cur_data) */ if (fsdata->bsize == 0) { k_off_t isize; - long bsize; - struct vattr va; - struct vnode *filevp; - /* - * Get the various attributes about the file. Store them - * in args for the next time around. - */ - filevp = args->vp; - - bsize = vtoblksz(filevp); - args->maxpgs = (pgcnt_t)btop(bsize); + long bsize; + struct vattr va; + struct vnode *filevp; + /* + * Get the various attributes about the file. Store them + * in args for the next time around. + */ + filevp = args->vp; + + bsize = vtoblksz(filevp); + args->maxpgs = (pgcnt_t) btop(bsize); if (VOP_GETATTR(filevp, &va, kt_cred(u.u_kthreadp), VIFSYNC) != 0) { - /* - * The VOP_GETATTR() failed. - * we are vhand, and this is a hard mount, we will - * skip dirty pages for a while and try again later. - */ - if (args->vm_flags & PAGEOUT_VHAND) - { - VASSERT(args->run == 0); - return 1; - } - /* - * This is a "soft" mount, or some other error was - * returned from the server. Mark this region - * as a zombie, and free this dirty page. - */ - VM_ZOMBIE_OBJECT(args); - - /* - * The caller will see r_zomb and remove the page - * appropriately. - */ - return(1); - } - isize = va.va_size; - fsdata->isize = isize; - fsdata->bsize = bsize; - fsdata->remote = 1; + /* + * The VOP_GETATTR() failed. + * we are vhand, and this is a hard mount, we will + * skip dirty pages for a while and try again later. + */ + if (args->vm_flags & PAGEOUT_VHAND) { + VASSERT(args->run == 0); + return 1; + } + /* + * This is a "soft" mount, or some other error was + * returned from the server. Mark this region + * as a zombie, and free this dirty page. + */ + VM_ZOMBIE_OBJECT(args); + + /* + * The caller will see r_zomb and remove the page + * appropriately. + */ + return (1); + } + isize = va.va_size; + fsdata->isize = isize; + fsdata->bsize = bsize; + fsdata->remote = 1; } /* - * See if the file has shrunk (this could have happened - * asynchronously because of NFS or DUX). If so, invalidate - * all of the pages past the end of the file. This is only - * needed for remote files, as local files are truncated - * synchronously. - */ + * See if the file has shrunk (this could have happened + * asynchronously because of NFS or DUX). If so, invalidate + * all of the pages past the end of the file. This is only + * needed for remote files, as local files are truncated + * synchronously. + */ if (vnodindx(VM_REGION(args), pgindx) > fsdata->isize) { - /* - * This page is past the end of the file. Unlock this page - * (region_trunc will throw it away) and then call region_trunc() - * to invalidate all pages past the new end of the file. - */ - VM_SETFS_FLAGS(args, PAGEOUT_TRUNCATE); - return(1); + /* + * This page is past the end of the file. Unlock this page + * (region_trunc will throw it away) and then call region_trunc() + * to invalidate all pages past the new end of the file. + */ + VM_SETFS_FLAGS(args, PAGEOUT_TRUNCATE); + return (1); } #ifdef notdef - if ((args->vm_flags & PAGEOUT_VHAND) && - (!(args->vm_flags & PAGEOUT_RESERVED)) && - (!(VM_IS_ZOMBIE(args)))) { - VASSERT(args->run == 0); - if (vm_reserve_malloc_memory(NFS_PAGEOUT_MEM)) { - /* - * Got enough memory to pageout. Mark the fact that we did - * a sysprocmemreserve(), so that we can sysprocmemunreserve() it - * later (in remote_pageout()). - */ - args->vm_flags |= PAGEOUT_RESERVED; - } else { - /* - * We do not have enough memory to do this pageout. By - * definition, we do not yet have a run, so we just unlock - * this page and tell foreach_valid() to continue scanning. - * If we come across another dirty page, we will try to - * reserve memory again. That is okay, in fact some memory - * may have freed up (as earlier pageouts complete under - * interrupt). - */ - return 1; - } + if ((args->vm_flags & PAGEOUT_VHAND) + && (!(args->vm_flags & PAGEOUT_RESERVED)) + && (!(VM_IS_ZOMBIE(args)))) { + VASSERT(args->run == 0); + if (vm_reserve_malloc_memory(NFS_PAGEOUT_MEM)) { + /* + * Got enough memory to pageout. Mark the fact that we did + * a sysprocmemreserve(), so that we can sysprocmemunreserve() it + * later (in remote_pageout()). + */ + args->vm_flags |= PAGEOUT_RESERVED; + } else { + /* + * We do not have enough memory to do this pageout. By + * definition, we do not yet have a run, so we just unlock + * this page and tell foreach_valid() to continue scanning. + * If we come across another dirty page, we will try to + * reserve memory again. That is okay, in fact some memory + * may have freed up (as earlier pageouts complete under + * interrupt). + */ + return 1; + } } #endif - return(0); + return (0); } afs_swapfs_len(bp) struct buf *bp; { - long fs_bsize; - long max_size; - long bnrem; - - fs_bsize = vtoblksz(bp->b_vp); - /* - * Check to see if we are starting mid block. If so, then - * we must return the remainder of the block or less depending - * on the length. - */ - bnrem = bp->b_offset % fs_bsize; - if (bnrem) { - max_size = fs_bsize - bnrem; - } else { - max_size = fs_bsize; - } - - if (bp->b_bcount > max_size) { - return(max_size); - } else { - return(bp->b_bcount); - } + long fs_bsize; + long max_size; + long bnrem; + + fs_bsize = vtoblksz(bp->b_vp); + /* + * Check to see if we are starting mid block. If so, then + * we must return the remainder of the block or less depending + * on the length. + */ + bnrem = bp->b_offset % fs_bsize; + if (bnrem) { + max_size = fs_bsize - bnrem; + } else { + max_size = fs_bsize; + } + + if (bp->b_bcount > max_size) { + return (max_size); + } else { + return (bp->b_bcount); + } } afs_mmap(vp, off, size_bytes, access) struct vnode *vp; u_int off; #if defined(AFS_HPUX1111_ENV) - u_long size_bytes; + u_long size_bytes; #else u_int size_bytes; #endif int access; { - long bsize = vtoblksz(vp); + long bsize = vtoblksz(vp); - if (bsize % NBPG != 0) { - return(EINVAL); - } + if (bsize % NBPG != 0) { + return (EINVAL); + } - return(0); + return (0); } afs_cachelimit(vp, len, location) @@ -1940,31 +1946,31 @@ afs_cachelimit(vp, len, location) k_off_t len; int *location; { - /* - * Disk addresses are logical, not physical, so fragments are - * transparent. - */ - *location = btorp(len) + 1; + /* + * Disk addresses are logical, not physical, so fragments are + * transparent. + */ + *location = btorp(len) + 1; } afs_release(vp) struct vnode *vp; { - return(0); + return (0); } int -afs_unmap(vp,off, size_bytes,access) +afs_unmap(vp, off, size_bytes, access) struct vnode *vp; u_int off; #if defined(AFS_HPUX1111_ENV) - u_long size_bytes; + u_long size_bytes; #else u_int size_bytes; #endif int access; { - return 0; + return 0; } int @@ -1976,51 +1982,52 @@ afs_read_ahead(vp, prp, wrt, space, vaddr, rhead_cnt) caddr_t vaddr; pgcnt_t *rhead_cnt; { - printf("afs_read_ahead returning 0 \n"); - return 0; + printf("afs_read_ahead returning 0 \n"); + return 0; } int afs_prealloc(vp, size, ignore_minfree, reserved) - struct vnode *vp; + struct vnode *vp; /* DEE on 11.22 following is off_t */ - size_t size; - int ignore_minfree; - int reserved; + size_t size; + int ignore_minfree; + int reserved; { - printf("afs_prealloc returning ENOSPC\n"); - return ENOSPC; + printf("afs_prealloc returning ENOSPC\n"); + return ENOSPC; } int afs_ioctl(vp, com, data, flag, cred) - struct vnode *vp; - int com; - caddr_t data; - int flag; - struct ucred *cred; + struct vnode *vp; + int com; + caddr_t data; + int flag; + struct ucred *cred; { - int error; - struct afs_ioctl afsioctl, *ai; + int error; + struct afs_ioctl afsioctl, *ai; - AFS_STATCNT(afs_ioctl); + AFS_STATCNT(afs_ioctl); - /* The call must be a VICEIOCTL call */ - if (((com >> 8) & 0xff) == 'V') { -#ifdef notdef - /* AFS_COPYIN returns error 14. Copy data in instead */ - AFS_COPYIN(data, (caddr_t) &afsioctl, sizeof(afsioctl), error); - if (error) return(error); + /* The call must be a VICEIOCTL call */ + if (((com >> 8) & 0xff) == 'V') { +#ifdef notdef + /* AFS_COPYIN returns error 14. Copy data in instead */ + AFS_COPYIN(data, (caddr_t) & afsioctl, sizeof(afsioctl), error); + if (error) + return (error); #endif - ai = (struct afs_ioctl *) data; - afsioctl.in = ai->in; - afsioctl.out = ai->out; - afsioctl.in_size = ai->in_size; - afsioctl.out_size = ai->out_size; - error = HandleIoctl(VTOAFS(vp), com, &afsioctl); - return(error); - } - return(ENOTTY); + ai = (struct afs_ioctl *)data; + afsioctl.in = ai->in; + afsioctl.out = ai->out; + afsioctl.in_size = ai->in_size; + afsioctl.out_size = ai->out_size; + error = HandleIoctl(VTOAFS(vp), com, &afsioctl); + return (error); + } + return (ENOTTY); } #if defined(AFS_HPUX1111_ENV) @@ -2043,60 +2050,60 @@ afs_readdir(vp, uiop, cred) struct uio *uiop; struct ucred *cred; { - struct uio auio; - struct iovec aiov; - caddr_t ibuf, obuf, ibufend, obufend; - struct __dirent32 *idp; - struct dirent *odp; - int count, outcount; - dir_off_t offset; - uint64_t tmp_offset; - - count = uiop->uio_resid; - /* Allocate temporary space for format conversion */ - ibuf = kmem_alloc(2*count); /* overkill - fix later */ - obuf = kmem_alloc(count + sizeof (struct dirent)); - aiov.iov_base = ibuf; - aiov.iov_len = count; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - offset = auio.uio_offset = uiop->uio_offset; - auio.uio_seg = UIOSEG_KERNEL; - auio.uio_resid = count; - auio.uio_fpflags = 0; - - u.u_error = mp_afs_readdir2(vp, &auio, cred); - if (u.u_error) - goto out; - - /* Convert entries from __dirent32 to dirent format */ - - for (idp = (struct __dirent32 *) ibuf, odp = (struct dirent *) obuf, - ibufend = ibuf + (count - auio.uio_resid), - obufend = obuf + count; - (caddr_t)idp < ibufend; - idp = (struct __dirent32 *) ((caddr_t) idp + idp->__d_reclen), - odp = (struct dirent *) ((caddr_t) odp + odp->d_reclen)) { - odp->d_ino = idp->__d_ino; - odp->d_namlen = idp->__d_namlen; - (void) strcpy(odp->d_name, idp->__d_name); - odp->d_reclen = reclen(odp); - if ((caddr_t) odp + odp->d_reclen > obufend) - break; - /* record offset *after* we're sure to use this entry */ - memcpy((char *)&tmp_offset, (char *)&idp->__d_off, sizeof tmp_offset); - offset = tmp_offset; - } - - outcount = (caddr_t) odp - obuf; - AFS_UIOMOVE(obuf, outcount, UIO_READ, uiop, u.u_error); - if (u.u_error) - goto out; - uiop->uio_offset = offset; -out: - kmem_free(ibuf, count); - kmem_free(obuf, count + sizeof (struct dirent)); - return u.u_error; + struct uio auio; + struct iovec aiov; + caddr_t ibuf, obuf, ibufend, obufend; + struct __dirent32 *idp; + struct dirent *odp; + int count, outcount; + dir_off_t offset; + uint64_t tmp_offset; + + count = uiop->uio_resid; + /* Allocate temporary space for format conversion */ + ibuf = kmem_alloc(2 * count); /* overkill - fix later */ + obuf = kmem_alloc(count + sizeof(struct dirent)); + aiov.iov_base = ibuf; + aiov.iov_len = count; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + offset = auio.uio_offset = uiop->uio_offset; + auio.uio_seg = UIOSEG_KERNEL; + auio.uio_resid = count; + auio.uio_fpflags = 0; + + u.u_error = mp_afs_readdir2(vp, &auio, cred); + if (u.u_error) + goto out; + + /* Convert entries from __dirent32 to dirent format */ + + for (idp = (struct __dirent32 *)ibuf, odp = + (struct dirent *)obuf, ibufend = + ibuf + (count - auio.uio_resid), obufend = obuf + count; + (caddr_t) idp < ibufend; + idp = (struct __dirent32 *)((caddr_t) idp + idp->__d_reclen), odp = + (struct dirent *)((caddr_t) odp + odp->d_reclen)) { + odp->d_ino = idp->__d_ino; + odp->d_namlen = idp->__d_namlen; + (void)strcpy(odp->d_name, idp->__d_name); + odp->d_reclen = reclen(odp); + if ((caddr_t) odp + odp->d_reclen > obufend) + break; + /* record offset *after* we're sure to use this entry */ + memcpy((char *)&tmp_offset, (char *)&idp->__d_off, sizeof tmp_offset); + offset = tmp_offset; + } + + outcount = (caddr_t) odp - obuf; + AFS_UIOMOVE(obuf, outcount, UIO_READ, uiop, u.u_error); + if (u.u_error) + goto out; + uiop->uio_offset = offset; + out: + kmem_free(ibuf, count); + kmem_free(obuf, count + sizeof(struct dirent)); + return u.u_error; } @@ -2110,59 +2117,60 @@ afs_readdir3(vp, uiop, cred) struct uio *uiop; struct ucred *cred; { - struct uio auio; - struct iovec aiov; - caddr_t ibuf, obuf, ibufend, obufend; - struct __dirent32 *idp; - struct __dirent64 *odp; - int count, outcount; - dir_off_t offset; - - count = uiop->uio_resid; - /* Allocate temporary space for format conversion */ - ibuf = kmem_alloc(2*count); /* overkill - fix later */ - obuf = kmem_alloc(count + sizeof (struct __dirent64)); - aiov.iov_base = ibuf; - aiov.iov_len = count; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - offset = auio.uio_offset = uiop->uio_offset; - auio.uio_seg = UIOSEG_KERNEL; - auio.uio_resid = count; - auio.uio_fpflags = 0; - - u.u_error = mp_afs_readdir2(vp, &auio, cred); - if (u.u_error) - goto out; - - /* Convert entries from __dirent32 to __dirent64 format */ - - for (idp = (struct __dirent32 *) ibuf, odp = (struct __dirent64 *) obuf, - ibufend = ibuf + (count - auio.uio_resid), - obufend = obuf + count; - (caddr_t)idp < ibufend; - idp = (struct __dirent32 *) ((caddr_t) idp + idp->__d_reclen), - odp = (struct __dirent64 *) ((caddr_t) odp + odp->__d_reclen)) { - memcpy((char *)&odp->__d_off, (char *)&idp->__d_off, sizeof odp->__d_off); - odp->__d_ino = idp->__d_ino; - odp->__d_namlen = idp->__d_namlen; - (void) strcpy(odp->__d_name, idp->__d_name); - odp->__d_reclen = reclen_dirent64(odp); - if ((caddr_t) odp + odp->__d_reclen > obufend) - break; - /* record offset *after* we're sure to use this entry */ - offset = odp->__d_off; - } - - outcount = (caddr_t) odp - obuf; - AFS_UIOMOVE(obuf, outcount, UIO_READ, uiop, u.u_error); - if (u.u_error) - goto out; - uiop->uio_offset = offset; -out: - kmem_free(ibuf, count); - kmem_free(obuf, count + sizeof (struct __dirent64)); - return u.u_error; + struct uio auio; + struct iovec aiov; + caddr_t ibuf, obuf, ibufend, obufend; + struct __dirent32 *idp; + struct __dirent64 *odp; + int count, outcount; + dir_off_t offset; + + count = uiop->uio_resid; + /* Allocate temporary space for format conversion */ + ibuf = kmem_alloc(2 * count); /* overkill - fix later */ + obuf = kmem_alloc(count + sizeof(struct __dirent64)); + aiov.iov_base = ibuf; + aiov.iov_len = count; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + offset = auio.uio_offset = uiop->uio_offset; + auio.uio_seg = UIOSEG_KERNEL; + auio.uio_resid = count; + auio.uio_fpflags = 0; + + u.u_error = mp_afs_readdir2(vp, &auio, cred); + if (u.u_error) + goto out; + + /* Convert entries from __dirent32 to __dirent64 format */ + + for (idp = (struct __dirent32 *)ibuf, odp = + (struct __dirent64 *)obuf, ibufend = + ibuf + (count - auio.uio_resid), obufend = obuf + count; + (caddr_t) idp < ibufend; + idp = (struct __dirent32 *)((caddr_t) idp + idp->__d_reclen), odp = + (struct __dirent64 *)((caddr_t) odp + odp->__d_reclen)) { + memcpy((char *)&odp->__d_off, (char *)&idp->__d_off, + sizeof odp->__d_off); + odp->__d_ino = idp->__d_ino; + odp->__d_namlen = idp->__d_namlen; + (void)strcpy(odp->__d_name, idp->__d_name); + odp->__d_reclen = reclen_dirent64(odp); + if ((caddr_t) odp + odp->__d_reclen > obufend) + break; + /* record offset *after* we're sure to use this entry */ + offset = odp->__d_off; + } + + outcount = (caddr_t) odp - obuf; + AFS_UIOMOVE(obuf, outcount, UIO_READ, uiop, u.u_error); + if (u.u_error) + goto out; + uiop->uio_offset = offset; + out: + kmem_free(ibuf, count); + kmem_free(obuf, count + sizeof(struct __dirent64)); + return u.u_error; } #define AFS_SV_SEMA_HASH 1 @@ -2214,28 +2222,26 @@ out: #define hashLock(xx) MP_PSEMA(&xx) #define hashUnlock(xx) MP_VSEMA(&xx) -typedef struct elem -{ - struct elem* next; - ELEMENT element; - KEY key; - int refCnt; +typedef struct elem { + struct elem *next; + ELEMENT element; + KEY key; + int refCnt; } Element; -typedef struct bucket -{ - sema_t lock; - Element* element; +typedef struct bucket { + sema_t lock; + Element *element; } Bucket; -static int sizeOfHashTable; -static Bucket* hashTable; +static int sizeOfHashTable; +static Bucket *hashTable; -static int currentSize=0; -static Element* freeList; /* free list */ +static int currentSize = 0; +static Element *freeList; /* free list */ #pragma align 64 -static sema_t afsHashLock = { 0 }; /* global lock for hash table */ +static sema_t afsHashLock = { 0 }; /* global lock for hash table */ static void afsHashGarbageCollect(); @@ -2249,232 +2255,231 @@ static void afsHashGarbageCollect(); void -afsHash(int nbuckets) /* allocate the hash table */ -{ - int i; +afsHash(int nbuckets) +{ /* allocate the hash table */ + int i; #if AFS_SV_SEMA_HASH_DEBUG -printf("afsHash: enter\n"); + printf("afsHash: enter\n"); #endif - sizeOfHashTable = nbuckets; - currentSize = nbuckets * sizeof(Bucket); + sizeOfHashTable = nbuckets; + currentSize = nbuckets * sizeof(Bucket); - if ( hashTable ) - osi_Panic("afs: SEMA Hashtable already created\n"); + if (hashTable) + osi_Panic("afs: SEMA Hashtable already created\n"); - hashTable = (Bucket *)AFS_KALLOC(sizeOfHashTable * sizeof(Bucket)); - if ( ! hashTable ) - osi_Panic("afs: cannot create SEMA Hashtable\n"); + hashTable = (Bucket *) AFS_KALLOC(sizeOfHashTable * sizeof(Bucket)); + if (!hashTable) + osi_Panic("afs: cannot create SEMA Hashtable\n"); - /* initialize the hash table and associated locks */ - memset((char *)hashTable, 0, sizeOfHashTable * sizeof(Bucket )); - for ( i=0;i < sizeOfHashTable; i ++) - hashLockInit( hashTable[i].lock); - hashLockInit(afsHashLock); + /* initialize the hash table and associated locks */ + memset((char *)hashTable, 0, sizeOfHashTable * sizeof(Bucket)); + for (i = 0; i < sizeOfHashTable; i++) + hashLockInit(hashTable[i].lock); + hashLockInit(afsHashLock); #if AFS_SV_SEMA_HASH_DEBUG -printf("afsHash: exit\n"); + printf("afsHash: exit\n"); #endif } -ELEMENT* +ELEMENT * afsHashInsertFind(KEY key) { - int index; - Element* ptr; + int index; + Element *ptr; #if AFS_SV_SEMA_HASH_DEBUG -printf("afsHashInsertFind: %d\n", key); + printf("afsHashInsertFind: %d\n", key); #endif - if ( ! hashTable ) - osi_Panic("afs: afsHashInsertFind: no hashTable\n"); - - index = Hash(key); /* get bucket number */ - hashLock(hashTable[index].lock); /* lock this bucket */ - ptr = hashTable[index].element; - - /* if it is already there */ - while ( ptr ) { - if ( ptr->key == key ) { - ptr->refCnt++; /* hold it */ - hashUnlock(hashTable[index].lock); + if (!hashTable) + osi_Panic("afs: afsHashInsertFind: no hashTable\n"); + + index = Hash(key); /* get bucket number */ + hashLock(hashTable[index].lock); /* lock this bucket */ + ptr = hashTable[index].element; + + /* if it is already there */ + while (ptr) { + if (ptr->key == key) { + ptr->refCnt++; /* hold it */ + hashUnlock(hashTable[index].lock); #if AFS_SV_SEMA_HASH_DEBUG -printf("afsHashInsertFind: %d FOUND\n", key); + printf("afsHashInsertFind: %d FOUND\n", key); #endif - return &(ptr->element); - } else { - ptr = ptr->next; - } + return &(ptr->element); + } else { + ptr = ptr->next; } + } - hashUnlock(hashTable[index].lock); + hashUnlock(hashTable[index].lock); - /* if something exists in the freeList, take it from there */ - ptr = NULL; - hashLock(afsHashLock); + /* if something exists in the freeList, take it from there */ + ptr = NULL; + hashLock(afsHashLock); - if ( freeList ) { - ptr = freeList; /* reuse entry */ - freeList = freeList->next; + if (freeList) { + ptr = freeList; /* reuse entry */ + freeList = freeList->next; + } else { + afsHashGarbageCollect(); /* afsHashLock locked */ + if (freeList) { + ptr = freeList; /* reuse entry */ + freeList = freeList->next; } else { - afsHashGarbageCollect(); /* afsHashLock locked */ - if ( freeList ) { - ptr = freeList; /* reuse entry */ - freeList = freeList->next; - } else { - ptr = (Element *)AFS_KALLOC(sizeof(Element)); - } + ptr = (Element *) AFS_KALLOC(sizeof(Element)); } + } - currentSize += sizeof(Element); /* update memory used */ - hashUnlock(afsHashLock); - - if ( ! ptr ) - osi_Panic("afs: SEMA Hashtable cannot create new entry\n"); - /* create new entry */ - ptr->key = key; - memset((char *)&ptr->element, 0, sizeof(ptr->element)); - ptr->refCnt = 1; /* this guy */ - - /* insert new entry in bucket */ - hashLock(hashTable[index].lock); /* lock this bucket */ - ptr->next = hashTable[index].element; - hashTable[index].element = ptr; - hashUnlock(hashTable[index].lock); + currentSize += sizeof(Element); /* update memory used */ + hashUnlock(afsHashLock); + + if (!ptr) + osi_Panic("afs: SEMA Hashtable cannot create new entry\n"); + /* create new entry */ + ptr->key = key; + memset((char *)&ptr->element, 0, sizeof(ptr->element)); + ptr->refCnt = 1; /* this guy */ + + /* insert new entry in bucket */ + hashLock(hashTable[index].lock); /* lock this bucket */ + ptr->next = hashTable[index].element; + hashTable[index].element = ptr; + hashUnlock(hashTable[index].lock); #if AFS_SV_SEMA_HASH_DEBUG -printf("afsHashInsertFind: %d MADE\n", key); + printf("afsHashInsertFind: %d MADE\n", key); #endif - return &(ptr->element); + return &(ptr->element); } -ELEMENT* +ELEMENT * afsHashFind(KEY key) { - int index; - Element* ptr; + int index; + Element *ptr; #if AFS_SV_SEMA_HASH_DEBUG -printf("afsHashFind: %d\n", key); + printf("afsHashFind: %d\n", key); #endif - if ( ! hashTable ) - osi_Panic("afs: afsHashFind: no hashTable\n"); - - index = Hash(key); /* get bucket number */ - hashLock(hashTable[index].lock); /* lock this bucket */ - ptr = hashTable[index].element; - - /* it should be in the hash table */ - while ( ptr ) { - if ( ptr->key == key ) - { - if(ptr->refCnt <= 0 ) - osi_Panic("afs: SEMA HashTable entry already released\n"); - hashUnlock(hashTable[index].lock); + if (!hashTable) + osi_Panic("afs: afsHashFind: no hashTable\n"); + + index = Hash(key); /* get bucket number */ + hashLock(hashTable[index].lock); /* lock this bucket */ + ptr = hashTable[index].element; + + /* it should be in the hash table */ + while (ptr) { + if (ptr->key == key) { + if (ptr->refCnt <= 0) + osi_Panic("afs: SEMA HashTable entry already released\n"); + hashUnlock(hashTable[index].lock); #if AFS_SV_SEMA_HASH_DEBUG -printf("afsHashFind: %d FOUND\n", key); + printf("afsHashFind: %d FOUND\n", key); #endif - return &(ptr->element); - } else { - ptr = ptr->next; - } + return &(ptr->element); + } else { + ptr = ptr->next; } + } - hashUnlock(hashTable[index].lock); - /* it better be in the hash table */ - osi_Panic("afs: SEMA HashTable wants non-existent entry \n"); - return 0; + hashUnlock(hashTable[index].lock); + /* it better be in the hash table */ + osi_Panic("afs: SEMA HashTable wants non-existent entry \n"); + return 0; } void afsHashRelease(KEY key) { - int index; - Element* ptr; + int index; + Element *ptr; #if AFS_SV_SEMA_HASH_DEBUG -printf("afsHashRelease: %d\n", key); + printf("afsHashRelease: %d\n", key); #endif - if ( ! hashTable ) - osi_Panic("afs: afsHashRelease: no hashTable\n"); - - index = Hash(key); /* get bucket number */ - hashLock(hashTable[index].lock); /* lock this bucket */ - ptr = hashTable[index].element; - - /* it should be in the hash table */ - while ( ptr ) { - if ( ptr->key == key ) { - if(ptr->refCnt <= 0 ) - osi_Panic("afs: SEMA HashTable entry already released\n"); - ptr->refCnt--; /* release this guy */ - hashUnlock(hashTable[index].lock); + if (!hashTable) + osi_Panic("afs: afsHashRelease: no hashTable\n"); + + index = Hash(key); /* get bucket number */ + hashLock(hashTable[index].lock); /* lock this bucket */ + ptr = hashTable[index].element; + + /* it should be in the hash table */ + while (ptr) { + if (ptr->key == key) { + if (ptr->refCnt <= 0) + osi_Panic("afs: SEMA HashTable entry already released\n"); + ptr->refCnt--; /* release this guy */ + hashUnlock(hashTable[index].lock); #if AFS_SV_SEMA_HASH_DEBUG -printf("afsHashRelease: %d FOUND\n", key); + printf("afsHashRelease: %d FOUND\n", key); #endif - return; - } else { - ptr = ptr->next; - } + return; + } else { + ptr = ptr->next; } + } - hashUnlock(hashTable[index].lock); - /* it better be in the hash table */ - osi_Panic("afs: SEMA HashTable deleting non-existent entry \n"); + hashUnlock(hashTable[index].lock); + /* it better be in the hash table */ + osi_Panic("afs: SEMA HashTable deleting non-existent entry \n"); } /* this should be called with afsHashLock WRITE locked */ static void afsHashGarbageCollect() { - int index; - Element* ptr; - int foundFlag=0; - - if ( ! hashTable ) - osi_Panic("afs: afsHashGarbageCollect: no hashTable\n"); - - for ( index = 0; index < sizeOfHashTable; index++) { - hashLock(hashTable[index].lock); - ptr = hashTable[index].element; /* pick up bucket */ - - while ( ptr && !ptr->refCnt ) { - /* insert this element into free list */ - Element* temp; - temp = ptr->next; - ptr->next = freeList; - freeList = ptr; - - foundFlag = 1; /* found at least one */ - currentSize -= sizeof(Element); - ptr = temp; + int index; + Element *ptr; + int foundFlag = 0; + + if (!hashTable) + osi_Panic("afs: afsHashGarbageCollect: no hashTable\n"); + + for (index = 0; index < sizeOfHashTable; index++) { + hashLock(hashTable[index].lock); + ptr = hashTable[index].element; /* pick up bucket */ + + while (ptr && !ptr->refCnt) { + /* insert this element into free list */ + Element *temp; + temp = ptr->next; + ptr->next = freeList; + freeList = ptr; + + foundFlag = 1; /* found at least one */ + currentSize -= sizeof(Element); + ptr = temp; + } + hashTable[index].element = ptr; + + /* scan thru the remaining list */ + if (ptr) { + while (ptr->next) { + if (ptr->next->refCnt == 0) { + /* collect this element */ + Element *temp; + temp = ptr->next; + ptr->next = ptr->next->next; + temp->next = freeList; + freeList = temp; + foundFlag = 1; + currentSize -= sizeof(Element); + } else { + ptr = ptr->next; } - hashTable[index].element = ptr; - - /* scan thru the remaining list */ - if ( ptr ) { - while ( ptr->next ) { - if ( ptr->next->refCnt == 0 ) { - /* collect this element */ - Element* temp; - temp = ptr->next; - ptr->next = ptr->next->next; - temp->next = freeList; - freeList = temp; - foundFlag = 1; - currentSize -= sizeof(Element); - } else { - ptr = ptr->next; - } - } - } - hashUnlock(hashTable[index].lock); + } } + hashUnlock(hashTable[index].lock); + } #if 0 - if(!foundFlag) - osi_Panic("afs: SEMA HashTable full\n"); + if (!foundFlag) + osi_Panic("afs: SEMA HashTable full\n"); #endif } @@ -2482,7 +2487,7 @@ afsHashGarbageCollect() afs_hp_strategy(bp) - register struct buf *bp; + register struct buf *bp; { register afs_int32 code; struct uio tuio; @@ -2501,40 +2506,37 @@ afs_hp_strategy(bp) hdl_kmap_bp(bp); AFS_GLOCK(); - afs_Trace4(afs_iclSetp, CM_TRACE_HPSTRAT, ICL_TYPE_POINTER, - bp->b_vp, ICL_TYPE_LONG, - (int)bp->b_blkno*DEV_BSIZE, ICL_TYPE_LONG, bp->b_bcount, - ICL_TYPE_LONG,0); - - /* Set up the uio structure */ - tuio.afsio_iov = tiovec; - tuio.afsio_iovcnt = 1; - tuio.afsio_offset = DEV_BSIZE * bp->b_blkno; - tuio.afsio_seg = AFS_UIOSYS; - tuio.afsio_resid = bp->b_bcount; - tuio.uio_fpflags = 0; - tiovec[0].iov_base = bp->b_un.b_addr; - tiovec[0].iov_len = bp->b_bcount; - - /* Do the I/O */ - if ((bp->b_flags & B_READ) == B_READ) - { - /* read b_bcount bytes into kernel address b_un.b_addr - starting at byte DEV_BSIZE * b_blkno. Bzero anything - we can't read, and finally call iodone(bp). File is - in bp->b_vp. Credentials are from u area?? - */ - code = afs_rdwr(VTOAFS(bp->b_vp),&tuio,UIO_READ,0,kt_cred(t)); - if (code == 0) - if (tuio.afsio_resid > 0) - { - privlbzero(bvtospace(bp, bp->b_un.b_addr), - bp->b_un.b_addr + bp->b_bcount - tuio.afsio_resid, - (size_t) tuio.afsio_resid); - - } - } else - code = afs_rdwr(VTOAFS(bp->b_vp),&tuio,UIO_WRITE,0,kt_cred(t)); + afs_Trace4(afs_iclSetp, CM_TRACE_HPSTRAT, ICL_TYPE_POINTER, bp->b_vp, + ICL_TYPE_LONG, (int)bp->b_blkno * DEV_BSIZE, ICL_TYPE_LONG, + bp->b_bcount, ICL_TYPE_LONG, 0); + + /* Set up the uio structure */ + tuio.afsio_iov = tiovec; + tuio.afsio_iovcnt = 1; + tuio.afsio_offset = DEV_BSIZE * bp->b_blkno; + tuio.afsio_seg = AFS_UIOSYS; + tuio.afsio_resid = bp->b_bcount; + tuio.uio_fpflags = 0; + tiovec[0].iov_base = bp->b_un.b_addr; + tiovec[0].iov_len = bp->b_bcount; + + /* Do the I/O */ + if ((bp->b_flags & B_READ) == B_READ) { + /* read b_bcount bytes into kernel address b_un.b_addr + * starting at byte DEV_BSIZE * b_blkno. Bzero anything + * we can't read, and finally call iodone(bp). File is + * in bp->b_vp. Credentials are from u area?? + */ + code = afs_rdwr(VTOAFS(bp->b_vp), &tuio, UIO_READ, 0, kt_cred(t)); + if (code == 0) + if (tuio.afsio_resid > 0) { + privlbzero(bvtospace(bp, bp->b_un.b_addr), + bp->b_un.b_addr + bp->b_bcount - tuio.afsio_resid, + (size_t) tuio.afsio_resid); + + } + } else + code = afs_rdwr(VTOAFS(bp->b_vp), &tuio, UIO_WRITE, 0, kt_cred(t)); /* Remap back to the user's space */ hdl_remap_bp(bp); @@ -2546,76 +2548,75 @@ afs_hp_strategy(bp) } afs_pathconf(vp, name, resultp, cred) -struct vnode *vp; -int name; -int *resultp; -struct ucred *cred; /* unused */ + struct vnode *vp; + int name; + int *resultp; + struct ucred *cred; /* unused */ { - switch(name) - { - case _PC_LINK_MAX: /* Maximum number of links to a file */ - *resultp = 255; /* an unsigned short on the fileserver*/ - break; /* a unsigned char in the client.... */ - - case _PC_NAME_MAX: /* Max length of file name */ - *resultp = 255; - break; + switch (name) { + case _PC_LINK_MAX: /* Maximum number of links to a file */ + *resultp = 255; /* an unsigned short on the fileserver */ + break; /* a unsigned char in the client.... */ - case _PC_PATH_MAX: /* Maximum length of Path Name */ - *resultp = 1024; - break; + case _PC_NAME_MAX: /* Max length of file name */ + *resultp = 255; + break; - case _PC_PIPE_BUF: /* Max atomic write to pipe. See fifo_vnops */ - case _PC_CHOWN_RESTRICTED: /* Anybody can chown? */ - case _PC_NO_TRUNC: /* No file name truncation on overflow? */ - u.u_error = EOPNOTSUPP; - return(EOPNOTSUPP); - break; + case _PC_PATH_MAX: /* Maximum length of Path Name */ + *resultp = 1024; + break; - case _PC_MAX_CANON: /* TTY buffer size for canonical input */ - /* need more work here for pty, ite buffer size, if differ */ - if (vp->v_type != VCHR) { - u.u_error = EINVAL; - return(EINVAL); - } - *resultp = CANBSIZ; /*for tty*/ - break; + case _PC_PIPE_BUF: /* Max atomic write to pipe. See fifo_vnops */ + case _PC_CHOWN_RESTRICTED: /* Anybody can chown? */ + case _PC_NO_TRUNC: /* No file name truncation on overflow? */ + u.u_error = EOPNOTSUPP; + return (EOPNOTSUPP); + break; - case _PC_MAX_INPUT: - /* need more work here for pty, ite buffer size, if differ */ - if (vp->v_type != VCHR) { /* TTY buffer size */ - u.u_error = EINVAL; - return(EINVAL); - } - *resultp = TTYHOG; /*for tty*/ - break; + case _PC_MAX_CANON: /* TTY buffer size for canonical input */ + /* need more work here for pty, ite buffer size, if differ */ + if (vp->v_type != VCHR) { + u.u_error = EINVAL; + return (EINVAL); + } + *resultp = CANBSIZ; /*for tty */ + break; - case _PC_VDISABLE: - /* Terminal special characters can be disabled? */ - if (vp->v_type != VCHR) { - u.u_error = EINVAL; - return(EINVAL); - } - *resultp = 1; - break; + case _PC_MAX_INPUT: + /* need more work here for pty, ite buffer size, if differ */ + if (vp->v_type != VCHR) { /* TTY buffer size */ + u.u_error = EINVAL; + return (EINVAL); + } + *resultp = TTYHOG; /*for tty */ + break; - case _PC_SYNC_IO: - if ((vp->v_type != VREG) && (vp->v_type != VBLK)) { - *resultp = -1; - return EINVAL; - } - *resultp = 1; /* Synchronized IO supported for this file */ - break; - - case _PC_FILESIZEBITS: - if (vp->v_type != VDIR) - return(EINVAL); - *resultp = MAX_SMALL_FILE_BITS; - break; + case _PC_VDISABLE: + /* Terminal special characters can be disabled? */ + if (vp->v_type != VCHR) { + u.u_error = EINVAL; + return (EINVAL); + } + *resultp = 1; + break; - default: - return(EINVAL); + case _PC_SYNC_IO: + if ((vp->v_type != VREG) && (vp->v_type != VBLK)) { + *resultp = -1; + return EINVAL; } + *resultp = 1; /* Synchronized IO supported for this file */ + break; - return(0); + case _PC_FILESIZEBITS: + if (vp->v_type != VDIR) + return (EINVAL); + *resultp = MAX_SMALL_FILE_BITS; + break; + + default: + return (EINVAL); + } + + return (0); } diff --git a/src/afs/IRIX/osi_file.c b/src/afs/IRIX/osi_file.c index 9542c5376..df4c759e3 100644 --- a/src/afs/IRIX/osi_file.c +++ b/src/afs/IRIX/osi_file.c @@ -10,13 +10,14 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ -int afs_osicred_initialized=0; +int afs_osicred_initialized = 0; afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct vfs *afs_cacheVfsp; @@ -27,32 +28,34 @@ extern struct vfs *afs_cacheVfsp; * added which accesses the inode, that will also need EFS/XFS variants. */ #ifdef AFS_SGI_EFS_IOPS_ENV -vnode_t *afs_EFSIGetVnode(ino_t ainode) +vnode_t * +afs_EFSIGetVnode(ino_t ainode) { struct inode *ip; int error; - if ((error = igetinode(afs_cacheVfsp, (dev_t)cacheDev.dev, ainode, &ip))) { + if ((error = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, ainode, &ip))) { osi_Panic("afs_EFSIGetVnode: igetinode failed, error=%d", error); } /* We don't care about atimes on the cache files, so disable them. I'm not * sure that this is the right place to do this: it should be *after* readi * and getattr and stuff. */ - ip->i_flags &= ~(ISYN|IACC); + ip->i_flags &= ~(ISYN | IACC); iunlock(ip); return (EFS_ITOV(ip)); -} +} #endif /* AFS_SGI_EFS_IOPS_ENV */ -vnode_t *afs_XFSIGetVnode(ino_t ainode) +vnode_t * +afs_XFSIGetVnode(ino_t ainode) { struct xfs_inode *ip; int error; vnode_t *vp; if ((error = - xfs_igetinode(afs_cacheVfsp, (dev_t)cacheDev.dev, ainode, &ip))) { + xfs_igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, ainode, &ip))) { osi_Panic("afs_XFSIGetVnode: xfs_igetinode failed, error=%d", error); } vp = XFS_ITOV(ip); @@ -60,7 +63,8 @@ vnode_t *afs_XFSIGetVnode(ino_t ainode) } /* Force to 64 bits, even for EFS filesystems. */ -void *osi_UFSOpen(ino_t ainode) +void * +osi_UFSOpen(ino_t ainode) { struct inode *ip; register struct osi_file *afile = NULL; @@ -68,7 +72,7 @@ void *osi_UFSOpen(ino_t ainode) afs_int32 code = 0; int dummy; AFS_STATCNT(osi_UFSOpen); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) { + if (cacheDiskType != AFS_FCACHE_TYPE_UFS) { osi_Panic("UFSOpen called for non-UFS cache\n"); } if (!afs_osicred_initialized) { @@ -77,25 +81,26 @@ void *osi_UFSOpen(ino_t ainode) crhold(&afs_osi_cred); /* don't let it evaporate, since it is static */ afs_osicred_initialized = 1; } - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); afile->vnode = AFS_SGI_IGETVNODE(ainode); AFS_GLOCK(); afile->size = VnodeToSize(afile->vnode); afile->offset = 0; - afile->proc = (int (*)()) 0; - afile->inum = ainode; /* for hint validity checking */ + afile->proc = (int (*)())0; + afile->inum = ainode; /* for hint validity checking */ return (void *)afile; } -int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) +int +afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) { register afs_int32 code; struct vattr tvattr; AFS_STATCNT(osi_Stat); - MObtainWriteLock(&afs_xosi,320); + MObtainWriteLock(&afs_xosi, 320); AFS_GUNLOCK(); - tvattr.va_mask = AT_SIZE|AT_BLKSIZE|AT_MTIME|AT_ATIME; + tvattr.va_mask = AT_SIZE | AT_BLKSIZE | AT_MTIME | AT_ATIME; AFS_VOP_GETATTR(afile->vnode, &tvattr, 0, &afs_osi_cred, code); AFS_GLOCK(); if (code == 0) { @@ -108,18 +113,20 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta return code; } -int osi_UFSClose(register struct osi_file *afile) +int +osi_UFSClose(register struct osi_file *afile) { - AFS_STATCNT(osi_Close); - if(afile->vnode) { + AFS_STATCNT(osi_Close); + if (afile->vnode) { VN_RELE(afile->vnode); - } - - osi_FreeSmallSpace(afile); - return 0; + } + + osi_FreeSmallSpace(afile); + return 0; } -int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) +int +osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) { struct AFS_UCRED *oldCred; struct vattr tvattr; @@ -133,8 +140,9 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) * small enough. Check now and save some time. */ code = afs_osi_Stat(afile, &tstat); - if (code || tstat.size <= asize) return code; - MObtainWriteLock(&afs_xosi,321); + if (code || tstat.size <= asize) + return code; + MObtainWriteLock(&afs_xosi, 321); AFS_GUNLOCK(); tvattr.va_mask = AT_SIZE; tvattr.va_size = asize; @@ -145,42 +153,46 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) } #ifdef AFS_SGI_EFS_IOPS_ENV -void osi_DisableAtimes(struct vnode *avp) +void +osi_DisableAtimes(struct vnode *avp) { - if (afs_CacheFSType == AFS_SGI_EFS_CACHE) - { - struct inode *ip = EFS_VTOI(avp); - ip->i_flags &= ~IACC; - } + if (afs_CacheFSType == AFS_SGI_EFS_CACHE) { + struct inode *ip = EFS_VTOI(avp); + ip->i_flags &= ~IACC; + } } #endif /* AFS_SGI_EFS_IOPS_ENV */ /* Generic read interface */ -int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize) +int +afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; ssize_t resid; register afs_int32 code; - register afs_int32 cnt1=0; + register afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); - + /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ - if ( !afile ) { - if ( !afs_shuttingdown ) + if (!afile) { + if (!afs_shuttingdown) osi_Panic("osi_Read called with null param"); else - return EIO; + return EIO; } - - if (offset != -1) afile->offset = offset; + + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); - code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, 0, 0x7fffffff, &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, + AFS_UIOSYS, 0, 0x7fffffff, &afs_osi_cred, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; @@ -188,39 +200,44 @@ int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_in #ifdef AFS_SGI_EFS_IOPS_ENV osi_DisableAtimes(afile->vnode); #endif /* AFS_SGI_EFS_IOPS_ENV */ - } - else { + } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, - ICL_TYPE_INT32, code); + ICL_TYPE_INT32, code); code = -1; } return code; } /* Generic write interface */ -int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) +int +afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; ssize_t resid; register afs_int32 code; AFS_STATCNT(osi_Write); - if ( !afile ) - osi_Panic("afs_osi_Write called with null param"); - if (offset != -1) afile->offset = offset; + if (!afile) + osi_Panic("afs_osi_Write called with null param"); + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); - code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, 0, 0x7fffffff, &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, + afile->offset, AFS_UIOSYS, 0, 0x7fffffff, &afs_osi_cred, + &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; - } - else { - if (code == ENOSPC) afs_warnuser("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); + } else { + if (code == ENOSPC) + afs_warnuser + ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); code = -1; } if (afile->proc) { - (*afile->proc)(afile, code); + (*afile->proc) (afile, code); } return code; } @@ -229,7 +246,8 @@ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, /* This work should be handled by physstrat in ca/machdep.c. This routine written from the RT NFS port strategy routine. It has been generalized a bit, but should still be pretty clear. */ -int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) +int +afs_osi_MapStrategy(int (*aproc) (), register struct buf *bp) { afs_int32 returnCode; @@ -241,13 +259,13 @@ int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) -void shutdown_osifile(void) +void +shutdown_osifile(void) { - extern int afs_cold_shutdown; + extern int afs_cold_shutdown; - AFS_STATCNT(shutdown_osifile); - if (afs_cold_shutdown) { - afs_osicred_initialized = 0; - } + AFS_STATCNT(shutdown_osifile); + if (afs_cold_shutdown) { + afs_osicred_initialized = 0; + } } - diff --git a/src/afs/IRIX/osi_groups.c b/src/afs/IRIX/osi_groups.c index 4b773f351..6b6cc8055 100644 --- a/src/afs/IRIX/osi_groups.c +++ b/src/afs/IRIX/osi_groups.c @@ -18,25 +18,20 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset); + afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset); static int -afs_setgroups( - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent); + afs_setgroups(struct ucred **cred, int ngroups, gid_t * gidset, + int change_parent); /* This is common code between SGI's DFS and our AFS. Do *not* alter it's @@ -47,8 +42,9 @@ afs_setgroups( * Sets up the cred for the call to estgroups. This is pretty convoluted * in order to avoid including the private proc.h header file. */ -int fixup_pags(int **credpp, int ngroups, gid_t *gidset, int old_afs_pag, - int old_dfs_pag) +int +fixup_pags(int **credpp, int ngroups, gid_t * gidset, int old_afs_pag, + int old_dfs_pag) { int new_afs_pag = 0; int new_dfs_pag = 0; @@ -67,45 +63,46 @@ int fixup_pags(int **credpp, int ngroups, gid_t *gidset, int old_afs_pag, return EFAULT; } - if (ngroups >= 2) { /* possibly an AFS PAG */ - new_afs_pag = (afs_get_pag_from_groups(groups[0], groups[1]) != NOPAG); + if (ngroups >= 2) { /* possibly an AFS PAG */ + new_afs_pag = + (afs_get_pag_from_groups(groups[0], groups[1]) != NOPAG); } - if (ngroups >= 1) { /* possibly a DFS PAG */ - new_dfs_pag = (int) groups[ngroups-1]; + if (ngroups >= 1) { /* possibly a DFS PAG */ + new_dfs_pag = (int)groups[ngroups - 1]; if (((new_dfs_pag >> 24) & 0xff) == 'A') - new_dfs_pag = (int) groups[ngroups-1]; + new_dfs_pag = (int)groups[ngroups - 1]; else new_dfs_pag = 0; } /* Now compute the number of groups we will need. */ new = ngroups; - if (old_afs_pag && !new_afs_pag) /* prepend old AFS pag */ + if (old_afs_pag && !new_afs_pag) /* prepend old AFS pag */ new += 2; - if (old_dfs_pag && !new_dfs_pag) /* append old DFS pag */ - new ++; + if (old_dfs_pag && !new_dfs_pag) /* append old DFS pag */ + new++; if (new > ngroups_max) - return EINVAL; /* sorry */ + return EINVAL; /* sorry */ - cr = crdup(OSI_GET_CURRENT_CRED()); /* we will replace all the groups. */ - memset((char*)&cr->cr_groups, 0, ngroups_max * sizeof(gid_t)); + cr = crdup(OSI_GET_CURRENT_CRED()); /* we will replace all the groups. */ + memset((char *)&cr->cr_groups, 0, ngroups_max * sizeof(gid_t)); /* Now cobble the new groups list together. */ new = 0; old = 0; - if (old_afs_pag && !new_afs_pag) { /* prepend old AFS pag */ + if (old_afs_pag && !new_afs_pag) { /* prepend old AFS pag */ gid_t g0, g1; changed = 1; afs_get_groups_from_pag(old_afs_pag, &g0, &g1); cr->cr_groups[new++] = g0; cr->cr_groups[new++] = g1; } - + for (old = 0; old < ngroups; old++) cr->cr_groups[new++] = groups[old]; - if (old_dfs_pag && !new_dfs_pag) { /* append old DFS pag */ + if (old_dfs_pag && !new_dfs_pag) { /* append old DFS pag */ changed = 1; cr->cr_groups[new++] = old_dfs_pag; } @@ -114,8 +111,7 @@ int fixup_pags(int **credpp, int ngroups, gid_t *gidset, int old_afs_pag, if (changed) { cr->cr_ngroups = new; *credpp = cr; - } - else { + } else { crfree(cr); *credpp = NULL; } @@ -127,7 +123,8 @@ int fixup_pags(int **credpp, int ngroups, gid_t *gidset, int old_afs_pag, * If flag = 0 this is a DFS pag held in one group. * If flag = 1 this is a AFS pag held in two group entries */ -static int afsDFS_SetPagInCred(struct ucred *credp, int pag, int flag) +static int +afsDFS_SetPagInCred(struct ucred *credp, int pag, int flag) { int *gidset; int i, ngrps; @@ -138,31 +135,31 @@ static int afsDFS_SetPagInCred(struct ucred *credp, int pag, int flag) ngrps = credp->cr_ngroups + groups_taken; if (ngrps >= ngroups_max) - return E2BIG; + return E2BIG; + - if (flag) { - /* Break out the AFS pag into two groups */ - afs_get_groups_from_pag(pag, &g0, &g1); + /* Break out the AFS pag into two groups */ + afs_get_groups_from_pag(pag, &g0, &g1); } newcredp = crdup(credp); newcredp->cr_ngroups = ngrps; if (flag) { - /* AFS case */ - newcredp->cr_groups[0] = g0; - newcredp->cr_groups[1] = g1; + /* AFS case */ + newcredp->cr_groups[0] = g0; + newcredp->cr_groups[1] = g1; } else { - /* DFS case */ - if (PagInCred(newcredp) != NOPAG){ - /* found an AFS PAG is set in this cred */ - n = 2; - } - newcredp->cr_groups[n] = pag; + /* DFS case */ + if (PagInCred(newcredp) != NOPAG) { + /* found an AFS PAG is set in this cred */ + n = 2; + } + newcredp->cr_groups[n] = pag; } - for (i=n; icr_ngroups; i++) - newcredp->cr_groups[i+groups_taken] = credp->cr_groups[i]; + for (i = n; i < credp->cr_ngroups; i++) + newcredp->cr_groups[i + groups_taken] = credp->cr_groups[i]; /* estgroups sets current threads cred from newcredp and crfree's credp */ estgroups(credp, newcredp); @@ -172,11 +169,12 @@ static int afsDFS_SetPagInCred(struct ucred *credp, int pag, int flag) #endif /* AFS_SGI65_ENV */ /* SGI's osi_GetPagFromCred - They return a long. */ -int osi_DFSGetPagFromCred(struct ucred *credp) +int +osi_DFSGetPagFromCred(struct ucred *credp) { int pag; int ngroups; - + /* * For IRIX, the PAG is stored in the first entry * of the gruop list in the cred structure. gid_t's @@ -185,47 +183,47 @@ int osi_DFSGetPagFromCred(struct ucred *credp) */ ngroups = credp->cr_ngroups; if (ngroups < 1) - return NOPAG; + return NOPAG; /* * Keep in mind that we might be living with AFS here. * This means we don't really know if our DFS PAG is in * the first or third group entry. */ #ifdef AFS_SGI65_ENV - pag = credp->cr_groups[ngroups-1]; + pag = credp->cr_groups[ngroups - 1]; #else pag = credp->cr_groups[0]; - if (PagInCred(credp) != NOPAG ){ - /* AFS has a PAG value in the first two group entries */ - if (ngroups < 3) - return NOPAG; - pag = credp->cr_groups[2]; + if (PagInCred(credp) != NOPAG) { + /* AFS has a PAG value in the first two group entries */ + if (ngroups < 3) + return NOPAG; + pag = credp->cr_groups[2]; } #endif if (((pag >> 24) & 0xff) == 'A') - return pag; + return pag; else - return NOPAG; + return NOPAG; } - + int -Afs_xsetgroups(int ngroups, gid_t *gidset) +Afs_xsetgroups(int ngroups, gid_t * gidset) { int old_afs_pag = NOPAG; int old_dfs_pag = NOPAG; int code = 0; struct ucred *credp = OSI_GET_CURRENT_CRED(); struct ucred *modcredp; - + credp = OSI_GET_CURRENT_CRED(); /* First get any old PAG's */ old_afs_pag = PagInCred(credp); old_dfs_pag = osi_DFSGetPagFromCred(credp); - + /* Set the passed in group list. */ if (code = setgroups(ngroups, gidset)) - return code; + return code; #ifdef AFS_SGI65_ENV if (old_afs_pag == NOPAG && old_dfs_pag == NOPAG) @@ -236,42 +234,43 @@ Afs_xsetgroups(int ngroups, gid_t *gidset) * the uthread until we return to user space. So, we examine the passed * in groups in fixup_pags. */ - code = fixup_pags(&modcredp, ngroups, gidset, - (old_afs_pag == NOPAG) ? 0 : old_afs_pag, - (old_dfs_pag == NOPAG) ? 0 : old_dfs_pag); + code = + fixup_pags(&modcredp, ngroups, gidset, + (old_afs_pag == NOPAG) ? 0 : old_afs_pag, + (old_dfs_pag == NOPAG) ? 0 : old_dfs_pag); if (!code && modcredp) estgroups(OSI_GET_CURRENT_PROCP(), modcredp); #else - + /* * The setgroups gave our curent thread a new cred pointer * Get the value again */ credp = OSI_GET_CURRENT_CRED(); if ((PagInCred(credp) == NOPAG) && (old_afs_pag != NOPAG)) { - /* reset the AFS PAG */ - code = afsDFS_SetPagInCred(credp, old_afs_pag, 1); + /* reset the AFS PAG */ + code = afsDFS_SetPagInCred(credp, old_afs_pag, 1); } /* * Once again get the credp because the afsDFS_SetPagInCred might have * assigned a new one. */ credp = OSI_GET_CURRENT_CRED(); - if ((osi_DFSGetPagFromCred(credp)==NOPAG) + if ((osi_DFSGetPagFromCred(credp) == NOPAG) && (old_dfs_pag != NOPAG)) { - code = afsDFS_SetPagInCred(credp, old_dfs_pag, 0); + code = afsDFS_SetPagInCred(credp, old_dfs_pag, 0); } -#endif /* AFS_SGI65_ENV */ +#endif /* AFS_SGI65_ENV */ return code; } int setpag(cred, pagvalue, newpag, change_parent) - struct ucred **cred; - afs_uint32 pagvalue; - afs_uint32 *newpag; - afs_uint32 change_parent; + struct ucred **cred; + afs_uint32 pagvalue; + afs_uint32 *newpag; + afs_uint32 change_parent; { gid_t gidset[NGROUPS]; int ngroups, code; @@ -289,18 +288,18 @@ setpag(cred, pagvalue, newpag, change_parent) return (E2BIG); #endif } - for (j = ngroups -1; j >= 0; j--) { - gidset[j+2] = gidset[j]; - } + for (j = ngroups - 1; j >= 0; j--) { + gidset[j + 2] = gidset[j]; + } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]); if (code = afs_setgroups(cred, ngroups, gidset, change_parent)) { #if defined(KERNEL_HAVE_UERROR) return (setuerror(code), code); #else - return code; + return code; #endif } return code; @@ -308,10 +307,7 @@ setpag(cred, pagvalue, newpag, change_parent) static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset) +afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset) { int ngrps, savengrps; gid_t *gp; @@ -321,18 +317,15 @@ afs_getgroups( savengrps = ngrps = MIN(ngroups, cred->cr_ngroups); gp = cred->cr_groups; while (ngrps--) - *gidset++ = *gp++; + *gidset++ = *gp++; return savengrps; } static int -afs_setgroups( - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct ucred **cred, int ngroups, gid_t * gidset, + int change_parent) { gid_t *gp; cred_t *cr, *newcr; @@ -340,21 +333,21 @@ afs_setgroups( AFS_STATCNT(afs_setgroups); if (ngroups > ngroups_max) - return EINVAL; + return EINVAL; cr = *cred; if (!change_parent) - newcr = crdup(cr); + newcr = crdup(cr); else - newcr = cr; + newcr = cr; newcr->cr_ngroups = ngroups; gp = newcr->cr_groups; while (ngroups--) - *gp++ = *gidset++; + *gp++ = *gidset++; if (!change_parent) { #ifdef AFS_SGI65_ENV estgroups(OSI_GET_CURRENT_PROCP(), newcr); #else - estgroups(cr, newcr); + estgroups(cr, newcr); #endif } *cred = newcr; diff --git a/src/afs/IRIX/osi_idbg.c b/src/afs/IRIX/osi_idbg.c index 3e176f471..126d67421 100644 --- a/src/afs/IRIX/osi_idbg.c +++ b/src/afs/IRIX/osi_idbg.c @@ -13,12 +13,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_SGI62_ENV #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ /* @@ -40,15 +41,15 @@ printflags(register unsigned int flags, register char **strings) } char *tab_vcache[] = { - "CStatd", /* 1 */ - "CBackup", /* 2 */ - "CRO", /* 4 */ - "CMValid", /* 8 */ - "CCore", /* 0x10 */ - "CDirty", /* 0x20 */ - "CSafeStore", /* 0x40 */ - "CMAPPED", /* 0x80 */ - "CNSHARE", /* 0x100 */ + "CStatd", /* 1 */ + "CBackup", /* 2 */ + "CRO", /* 4 */ + "CMValid", /* 8 */ + "CCore", /* 0x10 */ + "CDirty", /* 0x20 */ + "CSafeStore", /* 0x40 */ + "CMAPPED", /* 0x80 */ + "CNSHARE", /* 0x100 */ }; int @@ -56,119 +57,115 @@ idbg_prafsnode(OSI_VC_DECL(avc)) { OSI_VC_CONVERT(avc) - AFS_GLOCK(); + AFS_GLOCK(); qprintf(" Len %d DV %d Date %d Own %d Grp %d Mode 0%o Lnk %d\n", - avc->m.Length, avc->m.DataVersion, avc->m.Date, - avc->m.Owner, avc->m.Group, avc->m.Mode, avc->m.LinkCount); + avc->m.Length, avc->m.DataVersion, avc->m.Date, avc->m.Owner, + avc->m.Group, avc->m.Mode, avc->m.LinkCount); qprintf(" flushDV %d mapDV %d truncpos 0x%x cb 0x%x cbE 0x%x\n", - avc->flushDV, avc->mapDV, avc->truncPos, - avc->callback, avc->cbExpires); - qprintf(" opens %d ex/wr %d flckcnt %d state 0x%x ", - avc->opens, avc->execsOrWriters, avc->flockCount, - avc->states); + avc->flushDV, avc->mapDV, avc->truncPos, avc->callback, + avc->cbExpires); + qprintf(" opens %d ex/wr %d flckcnt %d state 0x%x ", avc->opens, + avc->execsOrWriters, avc->flockCount, avc->states); printflags(avc->states, tab_vcache); qprintf("\n"); #ifdef AFS_SGI64_ENV qprintf(" mapcnt %llu, mvstat %d anyAcc 0x%x Access 0x%x\n", avc->mapcnt, avc->mvstat, avc->anyAccess, avc->Access); - qprintf(" mvid 0x%x &lock 0x%x cred 0x%x\n", - avc->mvid, &avc->lock, avc->cred); - qprintf(" rwlock 0x%x (%d) id %llu trips %d\n", - &avc->vc_rwlock, valusema(&avc->vc_rwlock), avc->vc_rwlockid, - avc->vc_locktrips); + qprintf(" mvid 0x%x &lock 0x%x cred 0x%x\n", avc->mvid, &avc->lock, + avc->cred); + qprintf(" rwlock 0x%x (%d) id %llu trips %d\n", &avc->vc_rwlock, + valusema(&avc->vc_rwlock), avc->vc_rwlockid, avc->vc_locktrips); #else - qprintf(" mapcnt %d mvstat %d anyAcc 0x%x Access 0x%x\n", - avc->mapcnt, avc->mvstat, avc->anyAccess, avc->Access); - qprintf(" mvid 0x%x &lock 0x%x cred 0x%x\n", - avc->mvid, &avc->lock, avc->cred); - qprintf(" rwlock 0x%x (%d) id %d trips %d\n", - &avc->vc_rwlock, valusema(&avc->vc_rwlock), avc->vc_rwlockid, - avc->vc_locktrips); + qprintf(" mapcnt %d mvstat %d anyAcc 0x%x Access 0x%x\n", avc->mapcnt, + avc->mvstat, avc->anyAccess, avc->Access); + qprintf(" mvid 0x%x &lock 0x%x cred 0x%x\n", avc->mvid, &avc->lock, + avc->cred); + qprintf(" rwlock 0x%x (%d) id %d trips %d\n", &avc->vc_rwlock, + valusema(&avc->vc_rwlock), avc->vc_rwlockid, avc->vc_locktrips); #endif AFS_GUNLOCK(); return 0; } -extern struct afs_q VLRU; /*vcache LRU*/ +extern struct afs_q VLRU; /*vcache LRU */ static char *tab_vtypes[] = { - "VNON", - "VREG", - "VDIR", - "VBLK", - "VCHR", - "VLNK", - "VFIFO", - "VXNAM", - "VBAD", - "VSOCK", - 0 + "VNON", + "VREG", + "VDIR", + "VBLK", + "VCHR", + "VLNK", + "VFIFO", + "VXNAM", + "VBAD", + "VSOCK", + 0 }; int idbg_afsvfslist() { - struct vcache *tvc; - register struct afs_q *tq; - struct afs_q *uq; - afs_int32 nodeid; /* what ls prints as 'inode' */ + struct vcache *tvc; + register struct afs_q *tq; + struct afs_q *uq; + afs_int32 nodeid; /* what ls prints as 'inode' */ - AFS_GLOCK(); - for(tq = VLRU.prev; tq != &VLRU; tq = uq) { - tvc = QTOV(tq); - uq = QPrev(tq); - nodeid = tvc->fid.Fid.Vnode + (tvc->fid.Fid.Volume << 16); - nodeid &= 0x7fffffff; - qprintf("avp 0x%x type %s cnt %d pg %d map %d nodeid %d(0x%x)\n", - tvc, tab_vtypes[((vnode_t *)tvc)->v_type], - ((vnode_t *)tvc)->v_count, - (int) VN_GET_PGCNT((vnode_t *)tvc), - (int)tvc->mapcnt, nodeid, nodeid); - } - AFS_GUNLOCK(); - return 0; + AFS_GLOCK(); + for (tq = VLRU.prev; tq != &VLRU; tq = uq) { + tvc = QTOV(tq); + uq = QPrev(tq); + nodeid = tvc->fid.Fid.Vnode + (tvc->fid.Fid.Volume << 16); + nodeid &= 0x7fffffff; + qprintf("avp 0x%x type %s cnt %d pg %d map %d nodeid %d(0x%x)\n", tvc, + tab_vtypes[((vnode_t *) tvc)->v_type], + ((vnode_t *) tvc)->v_count, + (int)VN_GET_PGCNT((vnode_t *) tvc), (int)tvc->mapcnt, nodeid, + nodeid); + } + AFS_GUNLOCK(); + return 0; } static char *tab_userstates[] = { - "UHasTokens", - "UTokensBad", - "UPrimary", - "UNeedsReset", - "UPAGcounted", - "UNK", + "UHasTokens", + "UTokensBad", + "UPrimary", + "UNeedsReset", + "UPAGcounted", + "UNK", }; static void idbg_pruser(struct unixuser *tu) { - qprintf("@0x%x nxt 0x%x uid %d (0x%x) cell 0x%x vid 0x%x ref %d\n", - tu, tu->next, tu->uid, tu->uid, tu->cell, - tu->vid, tu->refCount); - qprintf("time %d stLen %d stp 0x%x exp 0x%x ", - tu->tokenTime, tu->stLen, tu->stp, tu->exporter); + qprintf("@0x%x nxt 0x%x uid %d (0x%x) cell 0x%x vid 0x%x ref %d\n", tu, + tu->next, tu->uid, tu->uid, tu->cell, tu->vid, tu->refCount); + qprintf("time %d stLen %d stp 0x%x exp 0x%x ", tu->tokenTime, tu->stLen, + tu->stp, tu->exporter); printflags(tu->states, tab_userstates); qprintf("\n"); qprintf("ClearToken: handle 0x%x ViceID 0x%x Btime %d Etime %d\n", - tu->ct.AuthHandle, tu->ct.ViceId, tu->ct.BeginTimestamp, - tu->ct.EndTimestamp); + tu->ct.AuthHandle, tu->ct.ViceId, tu->ct.BeginTimestamp, + tu->ct.EndTimestamp); } extern struct unixuser *afs_users[NUSERS]; int idbg_afsuser(void *x) { - struct unixuser *tu; - int i; - AFS_GLOCK(); + struct unixuser *tu; + int i; + AFS_GLOCK(); - if (x == (void *)-1L) { - for (i = 0; i < NUSERS; i++) - for (tu = afs_users[i]; tu; tu = tu->next) - idbg_pruser(tu); - } else - idbg_pruser((struct unixuser *)x); + if (x == (void *)-1L) { + for (i = 0; i < NUSERS; i++) + for (tu = afs_users[i]; tu; tu = tu->next) + idbg_pruser(tu); + } else + idbg_pruser((struct unixuser *)x); - AFS_GUNLOCK(); - return 0; + AFS_GUNLOCK(); + return 0; } #endif /* AFS_SGI62_ENV */ diff --git a/src/afs/IRIX/osi_inode.c b/src/afs/IRIX/osi_inode.c index b1efb1ef5..3610b7bc5 100644 --- a/src/afs/IRIX/osi_inode.c +++ b/src/afs/IRIX/osi_inode.c @@ -42,12 +42,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ #include "afs/osi_inode.h" -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #define BAD_IGET -1000 @@ -58,7 +59,7 @@ RCSID("$Header$"); /* * `INODESPECIAL' type inodes are ones that describe volumes. */ -#define INODESPECIAL 0xffffffff /* ... from ../vol/viceinode.h */ +#define INODESPECIAL 0xffffffff /* ... from ../vol/viceinode.h */ #endif /* * copy disk inode to incore inode and vice-versa @@ -66,82 +67,84 @@ RCSID("$Header$"); void afsdptoip(struct efs_dinode *dp, struct inode *ip) { - struct afsparms *ap; - - ip->i_afs = kmem_alloc(sizeof(struct afsparms), KM_SLEEP); - osi_Assert(ip->i_version == EFS_IVER_AFSSPEC - || ip->i_version == EFS_IVER_AFSINO); - ap = (struct afsparms *)ip->i_afs; - /* vicep1 is VOLid */ - ap->vicep1 = dmag(dp, 0) << 24 | dmag(dp, 1) << 16 | - dmag(dp, 2) << 8 | dmag(dp, 3) << 0; - - if (ip->i_version == EFS_IVER_AFSSPEC) { - ap->vicep3 = dmag(dp, 8); /* Type */ - ap->vicep4 = dmag(dp, 4) << 24 | dmag(dp, 5) << 16 | - dmag(dp, 6) << 8 | dmag(dp, 7) << 0; - - } else { - /* vnode number */ - ap->vicep2 = dmag(dp, 4) << 16 | - dmag(dp, 5) << 8 | dmag(dp, 6) << 0; - /* disk uniqifier */ - ap->vicep3 = dmag(dp, 7) << 16 | - dmag(dp, 8) << 8 | dmag(dp, 9) << 0; - /* data version */ - ap->vicep4 = dmag(dp, 10) << 16 | - dmag(dp, 11) << 8 | (dp)->di_spare; - } + struct afsparms *ap; + + ip->i_afs = kmem_alloc(sizeof(struct afsparms), KM_SLEEP); + osi_Assert(ip->i_version == EFS_IVER_AFSSPEC + || ip->i_version == EFS_IVER_AFSINO); + ap = (struct afsparms *)ip->i_afs; + /* vicep1 is VOLid */ + ap->vicep1 = + dmag(dp, 0) << 24 | dmag(dp, 1) << 16 | dmag(dp, 2) << 8 | dmag(dp, + 3) << + 0; + + if (ip->i_version == EFS_IVER_AFSSPEC) { + ap->vicep3 = dmag(dp, 8); /* Type */ + ap->vicep4 = + dmag(dp, 4) << 24 | dmag(dp, 5) << 16 | dmag(dp, + 6) << 8 | dmag(dp, + 7) << + 0; + + } else { + /* vnode number */ + ap->vicep2 = dmag(dp, 4) << 16 | dmag(dp, 5) << 8 | dmag(dp, 6) << 0; + /* disk uniqifier */ + ap->vicep3 = dmag(dp, 7) << 16 | dmag(dp, 8) << 8 | dmag(dp, 9) << 0; + /* data version */ + ap->vicep4 = dmag(dp, 10) << 16 | dmag(dp, 11) << 8 | (dp)->di_spare; + } } void afsiptodp(struct inode *ip, struct efs_dinode *dp) { - struct afsparms *ap; - - if (ip->i_afs == NULL) - return; - - osi_Assert(ip->i_version == EFS_IVER_AFSSPEC - || ip->i_version == EFS_IVER_AFSINO); - ap = (struct afsparms *)ip->i_afs; - /* vicep1 is VOLid */ - dmag(dp, 0) = ap->vicep1 >> 24; - dmag(dp, 1) = ap->vicep1 >> 16; - dmag(dp, 2) = ap->vicep1 >> 8; - dmag(dp, 3) = ap->vicep1 >> 0; - - if (ip->i_version == EFS_IVER_AFSSPEC) { - /* Type */ - dmag(dp, 8) = ap->vicep3; - /* ParentId */ - dmag(dp, 4) = ap->vicep4 >> 24; - dmag(dp, 5) = ap->vicep4 >> 16; - dmag(dp, 6) = ap->vicep4 >> 8; - dmag(dp, 7) = ap->vicep4 >> 0; - } else { - /* vnode number */ - dmag(dp, 4) = ap->vicep2 >> 16; - dmag(dp, 5) = ap->vicep2 >> 8; - dmag(dp, 6) = ap->vicep2 >> 0; - /* disk uniqifier */ - dmag(dp, 7) = ap->vicep3 >> 16; - dmag(dp, 8) = ap->vicep3 >> 8; - dmag(dp, 9) = ap->vicep3 >> 0; - /* data version */ - dmag(dp, 10) = ap->vicep4 >> 16; - dmag(dp, 11) = ap->vicep4 >> 8; - dp->di_spare = ap->vicep4 >> 0; - } + struct afsparms *ap; + + if (ip->i_afs == NULL) + return; + + osi_Assert(ip->i_version == EFS_IVER_AFSSPEC + || ip->i_version == EFS_IVER_AFSINO); + ap = (struct afsparms *)ip->i_afs; + /* vicep1 is VOLid */ + dmag(dp, 0) = ap->vicep1 >> 24; + dmag(dp, 1) = ap->vicep1 >> 16; + dmag(dp, 2) = ap->vicep1 >> 8; + dmag(dp, 3) = ap->vicep1 >> 0; + + if (ip->i_version == EFS_IVER_AFSSPEC) { + /* Type */ + dmag(dp, 8) = ap->vicep3; + /* ParentId */ + dmag(dp, 4) = ap->vicep4 >> 24; + dmag(dp, 5) = ap->vicep4 >> 16; + dmag(dp, 6) = ap->vicep4 >> 8; + dmag(dp, 7) = ap->vicep4 >> 0; + } else { + /* vnode number */ + dmag(dp, 4) = ap->vicep2 >> 16; + dmag(dp, 5) = ap->vicep2 >> 8; + dmag(dp, 6) = ap->vicep2 >> 0; + /* disk uniqifier */ + dmag(dp, 7) = ap->vicep3 >> 16; + dmag(dp, 8) = ap->vicep3 >> 8; + dmag(dp, 9) = ap->vicep3 >> 0; + /* data version */ + dmag(dp, 10) = ap->vicep4 >> 16; + dmag(dp, 11) = ap->vicep4 >> 8; + dp->di_spare = ap->vicep4 >> 0; + } } void afsidestroy(struct inode *ip) { - if (ip->i_afs) { - kmem_free(ip->i_afs, sizeof(struct afsparms)); - ip->i_afs = NULL; - } + if (ip->i_afs) { + kmem_free(ip->i_afs, sizeof(struct afsparms)); + ip->i_afs = NULL; + } } extern int efs_fstype; @@ -170,8 +173,9 @@ getinode(struct vfs *vfsp, dev_t dev, ino_t inode, struct inode **ipp) return ENOSYS; #endif - if (error = iget((((struct mount *)((vfsp)->vfs_bh.bh_first)->bd_pdata)), - (unsigned int)(inode&0xffffffff), &ip)) { + if (error = + iget((((struct mount *)((vfsp)->vfs_bh.bh_first)->bd_pdata)), + (unsigned int)(inode & 0xffffffff), &ip)) { return error; } *ipp = ip; @@ -197,8 +201,8 @@ dev_t XFS_IGET_DEV; #define SET_XFS_ERROR(POS, DEV, INO) \ XFS_IGET_EPOS = (POS), XFS_IGET_DEV = (DEV), XFS_IGET_INO = (INO) -int xfs_getinode(struct vfs *vfsp, dev_t dev, ino_t inode, - struct xfs_inode **ipp) +int +xfs_getinode(struct vfs *vfsp, dev_t dev, ino_t inode, struct xfs_inode **ipp) { struct xfs_inode *ip; int error; @@ -222,9 +226,9 @@ int xfs_getinode(struct vfs *vfsp, dev_t dev, ino_t inode, #endif if (error = xfs_iget((((struct mount *) - ((vfsp)->vfs_bh.bh_first)->bd_pdata)), - (void*)0, (xfs_ino_t)inode, - XFS_ILOCK_SHARED, &ip, (daddr_t)0)) { + ((vfsp)->vfs_bh.bh_first)->bd_pdata)), (void *)0, + (xfs_ino_t) inode, XFS_ILOCK_SHARED, &ip, + (daddr_t) 0)) { SET_XFS_ERROR(3, vfsp->vfs_dev, inode); return error; } @@ -236,8 +240,9 @@ int xfs_getinode(struct vfs *vfsp, dev_t dev, ino_t inode, /* xfs_igetinode now returns an unlocked inode. This is fine, since we * have a refcount on the holding vnode. */ -int xfs_igetinode(struct vfs *vfsp, dev_t dev, ino_t inode, - struct xfs_inode **ipp) +int +xfs_igetinode(struct vfs *vfsp, dev_t dev, ino_t inode, + struct xfs_inode **ipp) { struct xfs_inode *ip; vnode_t *vp; @@ -275,22 +280,23 @@ int xfs_igetinode(struct vfs *vfsp, dev_t dev, ino_t inode, * ***************************************************************************/ struct icreateargs { - sysarg_t dev; - sysarg_t near_inode; - sysarg_t param1; - sysarg_t param2; - sysarg_t param3; - sysarg_t param4; + sysarg_t dev; + sysarg_t near_inode; + sysarg_t param1; + sysarg_t param2; + sysarg_t param3; + sysarg_t param4; }; /* EFS only fs suite uses this entry point - icreate in afssyscalls.c. */ int -icreate(struct icreateargs *uap, rval_t *rvp) +icreate(struct icreateargs *uap, rval_t * rvp) { #ifdef AFS_SGI_EFS_IOPS_ENV AFS_STATCNT(icreate); - return(afs_syscall_icreate(uap->dev, uap->near_inode, uap->param1, - uap->param2, uap->param3, uap->param4, rvp)); + return (afs_syscall_icreate + (uap->dev, uap->near_inode, uap->param1, uap->param2, uap->param3, + uap->param4, rvp)); #else return ENOSYS; #endif @@ -299,51 +305,51 @@ icreate(struct icreateargs *uap, rval_t *rvp) #ifdef AFS_SGI_EFS_IOPS_ENV int afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp) -afs_uint32 dev, near_inode, param1, param2, param3, param4; -rval_t *rvp; + afs_uint32 dev, near_inode, param1, param2, param3, param4; + rval_t *rvp; { - struct inode *ip, *newip; - struct afsparms *ap; - struct cred cr; - int error; + struct inode *ip, *newip; + struct afsparms *ap; + struct cred cr; + int error; - AFS_STATCNT(afs_syscall_icreate); - if (!afs_suser()) - return EPERM; + AFS_STATCNT(afs_syscall_icreate); + if (!afs_suser()) + return EPERM; - if (error = getinode(0, (dev_t)dev, 2, &ip)) - return error; + if (error = getinode(0, (dev_t) dev, 2, &ip)) + return error; - cr.cr_uid = 0; - cr.cr_gid = -2; - if (error = efs_ialloc(ip, IFREG, 1, NODEV, &newip, &cr)) { - iput(ip); - return error; - } + cr.cr_uid = 0; + cr.cr_gid = -2; + if (error = efs_ialloc(ip, IFREG, 1, NODEV, &newip, &cr)) { iput(ip); - osi_Assert(newip); - newip->i_flags |= IACC|IUPD|ICHG; - - osi_Assert(newip->i_afs == NULL); - newip->i_afs = kmem_alloc(sizeof(struct afsparms), KM_SLEEP); - if (param2 == INODESPECIAL) - newip->i_version = EFS_IVER_AFSSPEC; - else - newip->i_version = EFS_IVER_AFSINO; - ap = (struct afsparms *)newip->i_afs; - ap->vicep1 = param1; /* VOLid */ - ap->vicep2 = param2; /* Vnode # */ - ap->vicep3 = param3; /* SPEC:type INO:vnode uniq */ - ap->vicep4 = param4; /* SPEC:parentId INO:data version */ - rvp->r_val1 = newip->i_number; - iput(newip); - return 0; + return error; + } + iput(ip); + osi_Assert(newip); + newip->i_flags |= IACC | IUPD | ICHG; + + osi_Assert(newip->i_afs == NULL); + newip->i_afs = kmem_alloc(sizeof(struct afsparms), KM_SLEEP); + if (param2 == INODESPECIAL) + newip->i_version = EFS_IVER_AFSSPEC; + else + newip->i_version = EFS_IVER_AFSINO; + ap = (struct afsparms *)newip->i_afs; + ap->vicep1 = param1; /* VOLid */ + ap->vicep2 = param2; /* Vnode # */ + ap->vicep3 = param3; /* SPEC:type INO:vnode uniq */ + ap->vicep4 = param4; /* SPEC:parentId INO:data version */ + rvp->r_val1 = newip->i_number; + iput(newip); + return 0; } #else /* !AFS_SGI_EFS_IOPS_ENV */ int afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp) -afs_uint32 dev, near_inode, param1, param2, param3, param4; -rval_t *rvp; + afs_uint32 dev, near_inode, param1, param2, param3, param4; + rval_t *rvp; { return ENOSYS; } @@ -388,7 +394,7 @@ int afs_vol_create_lock_inited = 0; */ int xfs_icreatename64(struct vfs *vfsp, int datap, int datalen, - afs_inode_params_t params, ino_t *inop) + afs_inode_params_t params, ino_t * inop) { #define AFS_PNAME_SIZE 16 char path[64]; @@ -400,7 +406,7 @@ xfs_icreatename64(struct vfs *vfsp, int datap, int datalen, int code = 0, unused; struct vnode *vp; struct vnode *dvp; - int rw_vno; /* volume ID of parent volume */ + int rw_vno; /* volume ID of parent volume */ int i; int createdDir = 0; size_t junk; @@ -411,7 +417,7 @@ xfs_icreatename64(struct vfs *vfsp, int datap, int datalen, if (datalen >= AFS_PNAME_SIZE) return E2BIG; - AFS_COPYINSTR((char*)datap, path, AFS_PNAME_SIZE-1, &junk, unused); + AFS_COPYINSTR((char *)datap, path, AFS_PNAME_SIZE - 1, &junk, unused); if (*path != '/') { return EINVAL; } @@ -429,11 +435,10 @@ xfs_icreatename64(struct vfs *vfsp, int datap, int datalen, code = gop_lookupname(path, AFS_UIOSYS, FOLLOW, NULL, &dvp); if (code == ENOENT) { /* Maybe it's an old directory name format. */ - AFS_COPYINSTR((char*)datap, name, AFS_PNAME_SIZE-1, &junk, unused); + AFS_COPYINSTR((char *)datap, name, AFS_PNAME_SIZE - 1, &junk, unused); strcat(name, "/."); strcat(name, int_to_base64(stmp1, rw_vno)); - code = gop_lookupname(name, AFS_UIOSYS, FOLLOW, NULL, - &dvp); + code = gop_lookupname(name, AFS_UIOSYS, FOLLOW, NULL, &dvp); if (!code) { /* Use old name format. */ strcpy(path, name); @@ -444,78 +449,78 @@ xfs_icreatename64(struct vfs *vfsp, int datap, int datalen, if (code == ENOENT) { afs_xfs_dattr_t dattr; /* make directory. */ - - code = AFS_VN_OPEN(path, UIO_SYSSPACE, FCREAT|FEXCL, 0700, &dvp, - CRMKDIR); + + code = + AFS_VN_OPEN(path, UIO_SYSSPACE, FCREAT | FEXCL, 0700, &dvp, + CRMKDIR); if (code) { if (code == EEXIST) { /* someone beat us to it? */ - code = gop_lookupname(path, AFS_UIOSYS, 0, NULL, - &dvp); + code = gop_lookupname(path, AFS_UIOSYS, 0, NULL, &dvp); } if (code) { AFS_UNLOCK_VOL_CREATE(); return code; } - } - else + } else createdDir = 1; - memset((char*)&dattr, 0, sizeof(dattr)); + memset((char *)&dattr, 0, sizeof(dattr)); dattr.atd_version = AFS_XFS_ATD_VERS; dattr.atd_volume = rw_vno; - AFS_VOP_ATTR_SET(dvp, AFS_XFS_DATTR, (char*)&dattr, - SIZEOF_XFS_DATTR_T, - ATTR_ROOT|ATTR_CREATE, OSI_GET_CURRENT_CRED(), code); + AFS_VOP_ATTR_SET(dvp, AFS_XFS_DATTR, (char *)&dattr, + SIZEOF_XFS_DATTR_T, ATTR_ROOT | ATTR_CREATE, + OSI_GET_CURRENT_CRED(), code); if (code) { VN_RELE(dvp); if (createdDir) - (void) vn_remove(path, UIO_SYSSPACE, RMDIRECTORY); + (void)vn_remove(path, UIO_SYSSPACE, RMDIRECTORY); AFS_UNLOCK_VOL_CREATE(); return code; } } - vattr.va_mask = AT_FSID|AT_NODEID; /* gets a guick return using FSID*/ + vattr.va_mask = AT_FSID | AT_NODEID; /* gets a guick return using FSID */ AFS_VOP_GETATTR(dvp, &vattr, 0, OSI_GET_CURRENT_CRED(), code); if (code) { VN_RELE(dvp); return code; } - memset((char*)&attrs, 0, sizeof(attrs)); + memset((char *)&attrs, 0, sizeof(attrs)); attrs.at_pino = vattr.va_nodeid; VN_RELE(dvp); - + /* Create the desired file. Use up to ten tries to create a unique name. */ - (void) strcpy(name, path); - (void) strcat(name, "/."); - (void) strcat(name, int_to_base64(stmp2, params[2])); + (void)strcpy(name, path); + (void)strcat(name, "/."); + (void)strcat(name, int_to_base64(stmp2, params[2])); s = &name[strlen(name)]; - attrs.at_tag = 0; /* Initial guess at a unique tag. */ - for (i=0; i<10; i++) { - *s = '\0'; - strcat(s, "."); - strcat(s, int_to_base64(stmp1, attrs.at_tag)); - code = AFS_VN_OPEN(name, UIO_SYSSPACE, FCREAT|FEXCL, 0600, &vp, - CRCREAT); + attrs.at_tag = 0; /* Initial guess at a unique tag. */ + for (i = 0; i < 10; i++) { + *s = '\0'; + strcat(s, "."); + strcat(s, int_to_base64(stmp1, attrs.at_tag)); + code = + AFS_VN_OPEN(name, UIO_SYSSPACE, FCREAT | FEXCL, 0600, &vp, + CRCREAT); if (!code || code != EEXIST) break; - attrs.at_tag ++ ; + attrs.at_tag++; } - /* Unlock the creation process since the directory now has a file in it.*/ + /* Unlock the creation process since the directory now has a file in it. */ if (params[1] == INODESPECIAL) AFS_UNLOCK_VOL_CREATE(); - + if (!code) { /* Set attributes. */ - memcpy((char*)attrs.at_param, (char*)params, sizeof(afs_inode_params_t)); + memcpy((char *)attrs.at_param, (char *)params, + sizeof(afs_inode_params_t)); attrs.at_attr_version = AFS_XFS_ATTR_VERS; attrs.at_name_version = name_version; - AFS_VOP_ATTR_SET(vp, AFS_XFS_ATTR, (char*)&attrs, - SIZEOF_XFS_ATTR_T, - ATTR_ROOT|ATTR_CREATE, OSI_GET_CURRENT_CRED(), + AFS_VOP_ATTR_SET(vp, AFS_XFS_ATTR, (char *)&attrs, SIZEOF_XFS_ATTR_T, + ATTR_ROOT | ATTR_CREATE, OSI_GET_CURRENT_CRED(), code); if (!code) { vattr.va_mode = 1; @@ -535,12 +540,12 @@ xfs_icreatename64(struct vfs *vfsp, int datap, int datalen, if (code) { /* remove partially created file. */ - (void) vn_remove(name, UIO_SYSSPACE, RMFILE); - + (void)vn_remove(name, UIO_SYSSPACE, RMFILE); + /* and directory if volume special file. */ if (createdDir) { AFS_LOCK_VOL_CREATE(); - (void) vn_remove(path, UIO_SYSSPACE, RMDIRECTORY); + (void)vn_remove(path, UIO_SYSSPACE, RMDIRECTORY); AFS_UNLOCK_VOL_CREATE(); } } @@ -574,24 +579,25 @@ afs_syscall_icreatename64(int dev, int datap, int datalen, int paramp, return ENXIO; } - AFS_COPYIN((char*)paramp, (char*)param, sizeof(afs_inode_params_t), code); + AFS_COPYIN((char *)paramp, (char *)param, sizeof(afs_inode_params_t), + code); if (vfsp->vfs_fstype == xfs_fstype) { - code = xfs_icreatename64(vfsp, datap, datalen, param, &ino); + code = xfs_icreatename64(vfsp, datap, datalen, param, &ino); if (code) return code; else { - AFS_COPYOUT((char*)&ino, (char*)inop, sizeof(ino_t), code); + AFS_COPYOUT((char *)&ino, (char *)inop, sizeof(ino_t), code); return code; } - } - else if (vfsp->vfs_fstype == efs_fstype) { - code = afs_syscall_icreate(dev, 0, param[0], param[1], param[2], - param[3], &rval); + } else if (vfsp->vfs_fstype == efs_fstype) { + code = + afs_syscall_icreate(dev, 0, param[0], param[1], param[2], + param[3], &rval); if (code) return code; else { - ino = (ino_t)rval.r_val1; - AFS_COPYOUT((char*)&ino, (char*)inop, sizeof(ino_t), code); + ino = (ino_t) rval.r_val1; + AFS_COPYOUT((char *)&ino, (char *)inop, sizeof(ino_t), code); return code; } } @@ -608,69 +614,66 @@ afs_syscall_icreatename64(int dev, int datap, int datalen, int paramp, * still in use. */ struct iopenargs { - sysarg_t dev; - sysarg_t inode; - sysarg_t usrmod; + sysarg_t dev; + sysarg_t inode; + sysarg_t usrmod; }; #ifdef AFS_SGI_XFS_IOPS_ENV struct iopenargs64 { - sysarg_t dev; - sysarg_t inode_hi; - sysarg_t inode_lo; - sysarg_t usrmod; + sysarg_t dev; + sysarg_t inode_hi; + sysarg_t inode_lo; + sysarg_t usrmod; }; #ifdef AFS_SGI65_ENV int -afs_syscall_iopen(int dev, ino_t inode, int usrmod, rval_t *rvp) +afs_syscall_iopen(int dev, ino_t inode, int usrmod, rval_t * rvp) { - struct file *fp; - int fd; - int error; - struct vfs* vfsp; - struct vnode *vp; + struct file *fp; + int fd; + int error; + struct vfs *vfsp; + struct vnode *vp; - AFS_STATCNT(afs_syscall_iopen); - if (!afs_suser()) - return EPERM; - vfsp = vfs_devsearch(dev, xfs_fstype); - if (!vfsp) - vfsp = vfs_devsearch(dev, efs_fstype); - if (!vfsp) - return ENXIO; + AFS_STATCNT(afs_syscall_iopen); + if (!afs_suser()) + return EPERM; + vfsp = vfs_devsearch(dev, xfs_fstype); + if (!vfsp) + vfsp = vfs_devsearch(dev, efs_fstype); + if (!vfsp) + return ENXIO; #ifdef AFS_SGI_EFS_IOPS_ENV - if (vfsp->vfs_fstype == efs_fstype) { - struct inode *ip; - if (error = igetinode(vfsp, (dev_t)dev, inode, &ip)) - return error; - vp = EFS_ITOV(ip); - if (error = vfile_alloc((usrmod+1) & (FMASK), &fp, &fd)) { - iput(ip); - return error; - } - iunlock(ip); + if (vfsp->vfs_fstype == efs_fstype) { + struct inode *ip; + if (error = igetinode(vfsp, (dev_t) dev, inode, &ip)) + return error; + vp = EFS_ITOV(ip); + if (error = vfile_alloc((usrmod + 1) & (FMASK), &fp, &fd)) { + iput(ip); + return error; } - else + iunlock(ip); + } else #endif /* AFS_SGI_EFS_IOPS_ENV */ - if (vfsp->vfs_fstype == xfs_fstype) { - struct xfs_inode *xip; - if (error = xfs_igetinode(vfsp, (dev_t)dev, inode, &xip)) - return error; - vp = XFS_ITOV(xip); - if (error = vfile_alloc((usrmod+1) & (FMASK), &fp, &fd)) { - VN_RELE(vp); - return error; - } - } - else { - osi_Panic("afs_syscall_iopen: bad fstype = %d\n", - vfsp->vfs_fstype); - } - vfile_ready(fp, vp); - rvp->r_val1 = fd; - return 0; + if (vfsp->vfs_fstype == xfs_fstype) { + struct xfs_inode *xip; + if (error = xfs_igetinode(vfsp, (dev_t) dev, inode, &xip)) + return error; + vp = XFS_ITOV(xip); + if (error = vfile_alloc((usrmod + 1) & (FMASK), &fp, &fd)) { + VN_RELE(vp); + return error; + } + } else { + osi_Panic("afs_syscall_iopen: bad fstype = %d\n", vfsp->vfs_fstype); + } + vfile_ready(fp, vp); + rvp->r_val1 = fd; + return 0; } #else /* afs_syscall_iopen @@ -678,67 +681,64 @@ afs_syscall_iopen(int dev, ino_t inode, int usrmod, rval_t *rvp) * 64 bit inode number. */ int -afs_syscall_iopen(int dev, ino_t inode, int usrmod, rval_t *rvp) +afs_syscall_iopen(int dev, ino_t inode, int usrmod, rval_t * rvp) { - struct file *fp; - int fd; - int error; - struct vfs* vfsp; - - AFS_STATCNT(afs_syscall_iopen); - if (!afs_suser()) - return EPERM; - vfsp = vfs_devsearch(dev); - if (!vfsp) { - return ENXIO; - } + struct file *fp; + int fd; + int error; + struct vfs *vfsp; - if (vfsp->vfs_fstype == xfs_fstype) { - struct xfs_inode *xip; - struct vnode *vp; - if (error = xfs_igetinode(vfsp, (dev_t)dev, inode, &xip)) - return error; - vp = XFS_ITOV(xip); - if (error = falloc(vp, (usrmod+1) & (FMASK), &fp, &fd)) { - VN_RELE(vp); - return error; - } - } - else if (vfsp->vfs_fstype == efs_fstype) { - struct inode *ip; - if (error = igetinode(vfsp, (dev_t)dev, inode, &ip)) - return error; - if (error = falloc(EFS_ITOV(ip), (usrmod+1) & (FMASK), &fp, &fd)) { - iput(ip); - return error; - } - iunlock(ip); + AFS_STATCNT(afs_syscall_iopen); + if (!afs_suser()) + return EPERM; + vfsp = vfs_devsearch(dev); + if (!vfsp) { + return ENXIO; + } + + if (vfsp->vfs_fstype == xfs_fstype) { + struct xfs_inode *xip; + struct vnode *vp; + if (error = xfs_igetinode(vfsp, (dev_t) dev, inode, &xip)) + return error; + vp = XFS_ITOV(xip); + if (error = falloc(vp, (usrmod + 1) & (FMASK), &fp, &fd)) { + VN_RELE(vp); + return error; } - else { - osi_Panic("afs_syscall_iopen: bad fstype = %d\n", - vfsp->vfs_fstype); + } else if (vfsp->vfs_fstype == efs_fstype) { + struct inode *ip; + if (error = igetinode(vfsp, (dev_t) dev, inode, &ip)) + return error; + if (error = falloc(EFS_ITOV(ip), (usrmod + 1) & (FMASK), &fp, &fd)) { + iput(ip); + return error; } - fready(fp); - rvp->r_val1 = fd; - return 0; + iunlock(ip); + } else { + osi_Panic("afs_syscall_iopen: bad fstype = %d\n", vfsp->vfs_fstype); + } + fready(fp); + rvp->r_val1 = fd; + return 0; } #endif /* AFS_SGI65_ENV */ int -iopen(struct iopenargs *uap, rval_t *rvp) +iopen(struct iopenargs *uap, rval_t * rvp) { - AFS_STATCNT(iopen); - return (afs_syscall_iopen(uap->dev, (ino_t)uap->inode, uap->usrmod, - rvp)); + AFS_STATCNT(iopen); + return (afs_syscall_iopen + (uap->dev, (ino_t) uap->inode, uap->usrmod, rvp)); } int -iopen64(struct iopenargs64 *uap, rval_t *rvp) +iopen64(struct iopenargs64 *uap, rval_t * rvp) { - AFS_STATCNT(iopen); - return (afs_syscall_iopen(uap->dev, - (ino_t)((uap->inode_hi<<32) | uap->inode_lo), - uap->usrmod, rvp)); + AFS_STATCNT(iopen); + return (afs_syscall_iopen + (uap->dev, (ino_t) ((uap->inode_hi << 32) | uap->inode_lo), + uap->usrmod, rvp)); } #else /* AFS_SGI_XFS_IOPS_ENV */ @@ -747,37 +747,37 @@ iopen64(struct iopenargs64 *uap, rval_t *rvp) * Original EFS only 32 bit iopen call. */ int -iopen(struct iopenargs *uap, rval_t *rvp) +iopen(struct iopenargs *uap, rval_t * rvp) { - AFS_STATCNT(iopen); - return (afs_syscall_iopen(uap->dev, uap->inode, uap->usrmod, rvp)); + AFS_STATCNT(iopen); + return (afs_syscall_iopen(uap->dev, uap->inode, uap->usrmod, rvp)); } int afs_syscall_iopen(dev, inode, usrmod, rvp) -int dev, inode, usrmod; -rval_t *rvp; + int dev, inode, usrmod; + rval_t *rvp; { - struct file *fp; - struct inode *ip; - int fd; - int error; - - AFS_STATCNT(afs_syscall_iopen); - if (!afs_suser()) - return EPERM; - if (error = igetinode(0, (dev_t)dev, inode, &ip)) - return error; - if (error = falloc(EFS_ITOV(ip), (usrmod+1) & (FMASK), &fp, &fd)) { - iput(ip); - return error; - } - iunlock(ip); - rvp->r_val1 = fd; + struct file *fp; + struct inode *ip; + int fd; + int error; + + AFS_STATCNT(afs_syscall_iopen); + if (!afs_suser()) + return EPERM; + if (error = igetinode(0, (dev_t) dev, inode, &ip)) + return error; + if (error = falloc(EFS_ITOV(ip), (usrmod + 1) & (FMASK), &fp, &fd)) { + iput(ip); + return error; + } + iunlock(ip); + rvp->r_val1 = fd; #ifdef AFS_SGI53_ENV - fready(fp); + fready(fp); #endif - return 0; + return 0; } #endif /* AFS_SGI_XFS_IOPS_ENV */ @@ -793,16 +793,17 @@ rval_t *rvp; * * XFS/EFS iinc/idec code for EFS. Uses 32 bit inode numbers. */ -static int efs_iincdec(vfsp, inode, inode_p1, amount) -struct vfs *vfsp; -int inode, inode_p1, amount; +static int +efs_iincdec(vfsp, inode, inode_p1, amount) + struct vfs *vfsp; + int inode, inode_p1, amount; { struct inode *ip; int error; if (error = igetinode(vfsp, NULL, inode, &ip)) return error; - + if (!IS_VICEMAGIC(ip)) error = EPERM; else if (((struct afsparms *)ip->i_afs)->vicep1 != inode_p1) @@ -826,8 +827,8 @@ int inode, inode_p1, amount; * * XFS/EFS iinc/idec code for EFS. Uses 64 bit inode numbers. */ -static int xfs_iincdec64(struct vfs *vfsp, ino_t inode, int inode_p1, - int amount) +static int +xfs_iincdec64(struct vfs *vfsp, ino_t inode, int inode_p1, int amount) { vnode_t *vp; xfs_inode_t *ip; @@ -838,24 +839,25 @@ static int xfs_iincdec64(struct vfs *vfsp, ino_t inode, int inode_p1, struct vattr vattr; int nlink; int vol; - - code = xfs_iget((((struct mount *)((vfsp)->vfs_bh.bh_first)->bd_pdata)), - (void*)0, (xfs_ino_t)inode, XFS_ILOCK_SHARED, &ip, - (daddr_t)0); + + code = + xfs_iget((((struct mount *)((vfsp)->vfs_bh.bh_first)->bd_pdata)), + (void *)0, (xfs_ino_t) inode, XFS_ILOCK_SHARED, &ip, + (daddr_t) 0); if (code) return code; vp = XFS_ITOV(ip); xfs_iunlock(ip, XFS_ILOCK_SHARED); - + vattr.va_mask = AT_GID | AT_UID | AT_MODE; AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code); - if (code) + if (code) code = EPERM; if (!code && (vattr.va_gid != XFS_VICEMAGIC)) code = EPERM; - + if (!code && (AFS_XFS_VNO_CLIP(inode_p1) != vattr.va_uid)) code = ENXIO; @@ -876,16 +878,15 @@ static int xfs_iincdec64(struct vfs *vfsp, ino_t inode, int inode_p1, AFS_VOP_SETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code); VN_RELE(vp); return code; - } - else { + } else { char path[64]; b64_string_t stmp1, stmp2; vnode_t *dvp; xfs_inode_t *ip; - + length = SIZEOF_XFS_ATTR_T; - AFS_VOP_ATTR_GET(vp, AFS_XFS_ATTR, (char*)&attrs, &length, - ATTR_ROOT, OSI_GET_CURRENT_CRED(), code); + AFS_VOP_ATTR_GET(vp, AFS_XFS_ATTR, (char *)&attrs, &length, ATTR_ROOT, + OSI_GET_CURRENT_CRED(), code); VN_RELE(vp); if (!code) { if (length != SIZEOF_XFS_ATTR_T @@ -905,7 +906,7 @@ static int xfs_iincdec64(struct vfs *vfsp, ino_t inode, int inode_p1, /* Verify directory attributes. */ length = SIZEOF_XFS_DATTR_T; - AFS_VOP_ATTR_GET(dvp, AFS_XFS_DATTR , (char*)&dattr, &length, + AFS_VOP_ATTR_GET(dvp, AFS_XFS_DATTR, (char *)&dattr, &length, ATTR_ROOT, OSI_GET_CURRENT_CRED(), code); if (!code) { if (length != SIZEOF_XFS_DATTR_T @@ -921,35 +922,34 @@ static int xfs_iincdec64(struct vfs *vfsp, ino_t inode, int inode_p1, strcat(path, int_to_base64(stmp1, attrs.at_param[2])); strcat(path, "."); strcat(path, int_to_base64(stmp1, attrs.at_tag)); - + AFS_VOP_REMOVE(dvp, path, OSI_GET_CURRENT_CRED(), code); - + if (!code) { int code2; vattr.va_mask = AT_NLINK; - AFS_VOP_GETATTR(dvp, &vattr, 0, OSI_GET_CURRENT_CRED(), - code2); + AFS_VOP_GETATTR(dvp, &vattr, 0, OSI_GET_CURRENT_CRED(), code2); if (!code2) { if (vattr.va_nlink == 2) { - vnode_t *ddvp; /* parent of volume directory. */ + vnode_t *ddvp; /* parent of volume directory. */ /* Try to remove the directory if this is a volume * special file. It's ok to fail. */ - AFS_VOP_LOOKUP(dvp, "..", &ddvp, - (struct pathname *)NULL, + AFS_VOP_LOOKUP(dvp, "..", &ddvp, (struct pathname *)NULL, 0, OSI_GET_CURRENT_RDIR(), OSI_GET_CURRENT_CRED(), code2); if (!code2) { VN_RELE(dvp); - dvp = (vnode_t*)0; + dvp = (vnode_t *) 0; strcpy(path, "."); if (attrs.at_name_version == AFS_XFS_NAME_VERS2) strcpy(path, AFS_INODE_DIR_NAME); - else + else strcpy(path, "."); int_to_base64(stmp1, - (attrs.at_param[1] == INODESPECIAL) ? - attrs.at_param[3] : attrs.at_param[0]); + (attrs.at_param[1] == + INODESPECIAL) ? attrs. + at_param[3] : attrs.at_param[0]); strcat(path, stmp1); AFS_LOCK_VOL_CREATE(); AFS_VOP_RMDIR(ddvp, path, OSI_GET_CURRENT_CDIR(), @@ -1013,17 +1013,22 @@ afs_syscall_iinc64(int dev, int inode_hi, int inode_lo, int inode_p1) struct iincargs { - sysarg_t dev; - sysarg_t inode; - sysarg_t inode_p1; + sysarg_t dev; + sysarg_t inode; + sysarg_t inode_p1; }; #ifdef AFS_SGI65_ENV -int iinc(struct iincargs *uap, rval_t *rvp) { +int +iinc(struct iincargs *uap, rval_t * rvp) +{ AFS_STATCNT(iinc); return ENOTSUP; } -int idec(struct iincargs *uap, rval_t *rvp) { + +int +idec(struct iincargs *uap, rval_t * rvp) +{ AFS_STATCNT(idec); return ENOTSUP; } @@ -1035,10 +1040,10 @@ int idec(struct iincargs *uap, rval_t *rvp) { */ int iincdec(dev, inode, inode_p1, amount) -int dev, inode, inode_p1, amount; + int dev, inode, inode_p1, amount; { struct vfs *vfsp; - + if (!afs_suser()) return EPERM; vfsp = vfs_devsearch(dev); @@ -1050,14 +1055,17 @@ int dev, inode, inode_p1, amount; return efs_iincdec(vfsp, inode, inode_p1, amount); } + int -iinc(struct iincargs *uap, rval_t *rvp) { +iinc(struct iincargs *uap, rval_t * rvp) +{ AFS_STATCNT(iinc); return (iincdec(uap->dev, uap->inode, uap->inode_p1, 1)); } int -idec(struct iincargs *uap, rval_t *rvp) { +idec(struct iincargs *uap, rval_t * rvp) +{ AFS_STATCNT(idec); return (iincdec(uap->dev, uap->inode, uap->inode_p1, -1)); } @@ -1070,48 +1078,50 @@ idec(struct iincargs *uap, rval_t *rvp) { */ int afs_syscall_iincdec(dev, inode, inode_p1, amount) -int dev, inode, inode_p1, amount; + int dev, inode, inode_p1, amount; { - struct inode *ip; - int error = 0; + struct inode *ip; + int error = 0; - if (!afs_suser()) - return EPERM; - if (error = igetinode(0, (dev_t)dev, inode, &ip)) - return error; + if (!afs_suser()) + return EPERM; + if (error = igetinode(0, (dev_t) dev, inode, &ip)) + return error; - if (!IS_VICEMAGIC(ip)) - error = EPERM; - else if (((struct afsparms *)ip->i_afs)->vicep1 != inode_p1) - error = ENXIO; - else { - ip->i_nlink += amount; - osi_Assert(ip->i_nlink >= 0); - if (ip->i_nlink == 0) { - CLEAR_VICEMAGIC(ip); - afsidestroy(ip); - } - ip->i_flags |= ICHG; + if (!IS_VICEMAGIC(ip)) + error = EPERM; + else if (((struct afsparms *)ip->i_afs)->vicep1 != inode_p1) + error = ENXIO; + else { + ip->i_nlink += amount; + osi_Assert(ip->i_nlink >= 0); + if (ip->i_nlink == 0) { + CLEAR_VICEMAGIC(ip); + afsidestroy(ip); } - /* XXX sync write?? */ - iput(ip); - return error; + ip->i_flags |= ICHG; + } + /* XXX sync write?? */ + iput(ip); + return error; } struct iincargs { - sysarg_t dev; - sysarg_t inode; - sysarg_t inode_p1; + sysarg_t dev; + sysarg_t inode; + sysarg_t inode_p1; }; int -iinc(struct iincargs *uap, rval_t *rvp) { +iinc(struct iincargs *uap, rval_t * rvp) +{ AFS_STATCNT(iinc); return (afs_syscall_iincdec(uap->dev, uap->inode, uap->inode_p1, 1)); } int -idec(struct iincargs *uap, rval_t *rvp) { +idec(struct iincargs *uap, rval_t * rvp) +{ AFS_STATCNT(idec); return (afs_syscall_iincdec(uap->dev, uap->inode, uap->inode_p1, -1)); } @@ -1122,8 +1132,8 @@ idec(struct iincargs *uap, rval_t *rvp) { * Gathers up all required info for ListViceInodes in one system call. */ int -afs_syscall_ilistinode64(int dev, int inode_hi, int inode_lo, - int datap, int datalenp) +afs_syscall_ilistinode64(int dev, int inode_hi, int inode_lo, int datap, + int datalenp) { int code = 0; ino_t inode; @@ -1151,40 +1161,42 @@ afs_syscall_ilistinode64(int dev, int inode_hi, int inode_lo, return ENOSYS; #endif - AFS_COPYIN((char*)datalenp, &idatalen, sizeof(int), code); + AFS_COPYIN((char *)datalenp, &idatalen, sizeof(int), code); if (idatalen < sizeof(i_list_inode_t)) { idatalen = sizeof(i_list_inode_t); - AFS_COPYOUT((char*)datalenp, (char*)&idatalen, sizeof(int), code); + AFS_COPYOUT((char *)datalenp, (char *)&idatalen, sizeof(int), code); return E2BIG; } idatalen = sizeof(i_list_inode_t); - AFS_COPYOUT((char*)datalenp, (char*)&idatalen, sizeof(int), code); + AFS_COPYOUT((char *)datalenp, (char *)&idatalen, sizeof(int), code); - AFS_COPYIN((char*)datap, (char*)&data, sizeof(i_list_inode_t), code); + AFS_COPYIN((char *)datap, (char *)&data, sizeof(i_list_inode_t), code); if (data.ili_version != AFS_XFS_ILI_VERSION) { data.ili_version = AFS_XFS_ILI_VERSION; - AFS_COPYOUT((char*)&data, (char*)datap, sizeof(i_list_inode_t), code); + AFS_COPYOUT((char *)&data, (char *)datap, sizeof(i_list_inode_t), + code); return EINVAL; } - - + + inode = inode_hi; inode <<= 32; inode |= inode_lo; - code = xfs_iget((((struct mount *)((vfsp)->vfs_bh.bh_first)->bd_pdata)), - (void*)0, (xfs_ino_t)inode, - XFS_ILOCK_SHARED, &ip, (daddr_t)0); + code = + xfs_iget((((struct mount *)((vfsp)->vfs_bh.bh_first)->bd_pdata)), + (void *)0, (xfs_ino_t) inode, XFS_ILOCK_SHARED, &ip, + (daddr_t) 0); if (code) return code; - + vp = XFS_ITOV(ip); xfs_iunlock(ip, XFS_ILOCK_SHARED); - + length = SIZEOF_XFS_ATTR_T; - AFS_VOP_ATTR_GET(vp, AFS_XFS_ATTR, (char*)&attrs, &length, - ATTR_ROOT, OSI_GET_CURRENT_CRED(), code); - if (code) { + AFS_VOP_ATTR_GET(vp, AFS_XFS_ATTR, (char *)&attrs, &length, ATTR_ROOT, + OSI_GET_CURRENT_CRED(), code); + if (code) { code = EPERM; } @@ -1192,25 +1204,26 @@ afs_syscall_ilistinode64(int dev, int inode_hi, int inode_lo, if (attrs.at_attr_version != AFS_XFS_ATTR_VERS) code = EINVAL; } - + if (!code) { vattr.va_mask = AT_STAT; AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code); } - + if (!code) { - memset((char*)&data, 0, sizeof(data)); + memset((char *)&data, 0, sizeof(data)); data.ili_info.inodeNumber = inode; data.ili_info.byteCount = vattr.va_size; data.ili_info.linkCount = (vattr.va_mode & AFS_XFS_MODE_LINK_MASK); - memcpy((char*)data.ili_info.param, (char*)attrs.at_param, sizeof(data.ili_info.param)); + memcpy((char *)data.ili_info.param, (char *)attrs.at_param, + sizeof(data.ili_info.param)); data.ili_attr_version = attrs.at_attr_version; data.ili_name_version = attrs.at_name_version; data.ili_tag = attrs.at_tag; data.ili_pino = attrs.at_pino; data.ili_vno = vattr.va_uid; data.ili_magic = vattr.va_gid; - AFS_COPYOUT((char*)&data, (char*)datap, sizeof(data), code); + AFS_COPYOUT((char *)&data, (char *)datap, sizeof(data), code); } VN_RELE(vp); return code; diff --git a/src/afs/IRIX/osi_inode.h b/src/afs/IRIX/osi_inode.h index 56a533647..0340062f2 100644 --- a/src/afs/IRIX/osi_inode.h +++ b/src/afs/IRIX/osi_inode.h @@ -47,11 +47,11 @@ /* we hang this struct off of the incore inode */ struct afsparms { - afs_int32 vicep1; - afs_int32 vicep2; - afs_int32 vicep3; - afs_int32 vicep4; - }; + afs_int32 vicep1; + afs_int32 vicep2; + afs_int32 vicep3; + afs_int32 vicep4; +}; #define dmag(p,n) ((p)->di_u.di_extents[n].ex_magic) diff --git a/src/afs/IRIX/osi_machdep.h b/src/afs/IRIX/osi_machdep.h index 94704289a..06ceea238 100644 --- a/src/afs/IRIX/osi_machdep.h +++ b/src/afs/IRIX/osi_machdep.h @@ -129,7 +129,7 @@ extern flid_t osi_flid; #if defined(KERNEL) #if defined(MP) -#define _MP_NETLOCKS /* to get sblock to work right */ +#define _MP_NETLOCKS /* to get sblock to work right */ /* On SGI mutex_owned doesn't work, so simulate this by remembering the owning * thread explicitly. This is only used for debugging so could be disabled for diff --git a/src/afs/IRIX/osi_misc.c b/src/afs/IRIX/osi_misc.c index 70806613b..636137a86 100644 --- a/src/afs/IRIX/osi_misc.c +++ b/src/afs/IRIX/osi_misc.c @@ -13,12 +13,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_SGI62_ENV #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ @@ -26,7 +27,10 @@ RCSID("$Header$"); /* * various special purpose routines */ -void afs_mpservice(void *a) {} +void +afs_mpservice(void *a) +{ +} #ifdef AFS_SGI_VNODE_GLUE #include @@ -38,31 +42,32 @@ extern mutex_t afs_init_kern_lock; * Argument: flag * 0 = no numa, 1 = has numa, -1 = test for numa. */ -int afs_init_kernel_config(int flag) +int +afs_init_kernel_config(int flag) { static int afs_kern_inited = 0; int code = 0; - + mutex_enter(&afs_init_kern_lock); if (!afs_kern_inited) { afs_kern_inited = 1; - + if (flag == -1) { inventory_t *pinv; /* test for numa arch. */ /* Determine if thisis a NUMA platform. Currently, this is true * only if it's an IP27 or IP35. */ - pinv = find_inventory((inventory_t*)NULL, INV_PROCESSOR, - INV_CPUBOARD, -1, -1, -1); + pinv = + find_inventory((inventory_t *) NULL, INV_PROCESSOR, + INV_CPUBOARD, -1, -1, -1); if (!pinv) code = ENODEV; - else - afs_is_numa_arch = ((pinv->inv_state == INV_IP27BOARD) || - (pinv->inv_state == INV_IP35BOARD)) - ? 1 : 0; - } - else + else + afs_is_numa_arch = ((pinv->inv_state == INV_IP27BOARD) + || (pinv->inv_state == INV_IP35BOARD)) + ? 1 : 0; + } else afs_is_numa_arch = flag; } mutex_exit(&afs_init_kern_lock); diff --git a/src/afs/IRIX/osi_sleep.c b/src/afs/IRIX/osi_sleep.c index 3674bafd0..d69823507 100644 --- a/src/afs/IRIX/osi_sleep.c +++ b/src/afs/IRIX/osi_sleep.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ @@ -23,21 +24,24 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok); static char waitV; -void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) +void +afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) { AFS_STATCNT(osi_InitWaitHandle); achandle->proc = (caddr_t) 0; } /* cancel osi_Wait */ -void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) { caddr_t proc; AFS_STATCNT(osi_CancelWait); proc = achandle->proc; - if (proc == 0) return; - achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ + if (proc == 0) + return; + achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ afs_osi_Wakeup(&waitV); } @@ -45,13 +49,14 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) * Waits for data on ahandle, or ams ms later. ahandle may be null. * Returns 0 if timeout and EINTR if signalled. */ -int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) +int +afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int code; afs_int32 endTime, tid; AFS_STATCNT(osi_Wait); - endTime = osi_Time() + (ams/1000); + endTime = osi_Time() + (ams / 1000); if (ahandle) ahandle->proc = (caddr_t) curthreadp; do { @@ -59,7 +64,8 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) code = 0; code = osi_TimedSleep(&waitV, ams, aintok); - if (code) break; /* if something happened, quit now */ + if (code) + break; /* if something happened, quit now */ /* if we we're cancelled, quit now */ if (ahandle && (ahandle->proc == (caddr_t) 0)) { /* we've been signalled */ @@ -77,13 +83,13 @@ typedef struct afs_event { char *event; /* lwp event: an address */ int refcount; /* Is it in use? */ int seq; /* Sequence number: this is incremented - by wakeup calls; wait will not return until - it changes */ + * by wakeup calls; wait will not return until + * it changes */ kcondvar_t cond; /* Currently associated condition variable */ } afs_event_t; #define HASHSIZE 128 -afs_event_t *afs_evhasht[HASHSIZE];/* Hash table for events */ +afs_event_t *afs_evhasht[HASHSIZE]; /* Hash table for events */ #if (_MIPS_SZPTR == 64) #define afs_evhash(event) (afs_uint32) ((((long)event)>>3) & (HASHSIZE-1)); #else @@ -93,7 +99,8 @@ int afs_evhashcnt = 0; /* Get and initialize event structure corresponding to lwp event (i.e. address) * */ -static afs_event_t *afs_getevent(char *event) +static afs_event_t * +afs_getevent(char *event) { afs_event_t *evp, *newp = 0; int hashcode; @@ -111,7 +118,7 @@ static afs_event_t *afs_getevent(char *event) evp = evp->next; } if (!newp) { - newp = (afs_event_t *) osi_AllocSmallSpace(sizeof (afs_event_t)); + newp = (afs_event_t *) osi_AllocSmallSpace(sizeof(afs_event_t)); afs_evhashcnt++; newp->next = afs_evhasht[hashcode]; afs_evhasht[hashcode] = newp; @@ -127,7 +134,8 @@ static afs_event_t *afs_getevent(char *event) #define relevent(evp) ((evp)->refcount--) -void afs_osi_Sleep(void *event) +void +afs_osi_Sleep(void *event) { struct afs_event *evp; int seq; @@ -141,7 +149,8 @@ void afs_osi_Sleep(void *event) relevent(evp); } -int afs_osi_SleepSig(void *event) +int +afs_osi_SleepSig(void *event) { afs_osi_Sleep(event); return 0; @@ -156,43 +165,46 @@ int afs_osi_SleepSig(void *event) * * Returns 0 if timeout and EINTR if signalled. */ -static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) +static int +osi_TimedSleep(char *event, afs_int32 ams, int aintok) { int code = 0; struct afs_event *evp; struct timespec ticks; ticks.tv_sec = ams / 1000; - ticks.tv_nsec = (ams - (ticks.tv_sec * 1000) ) * 1000000; + ticks.tv_nsec = (ams - (ticks.tv_sec * 1000)) * 1000000; evp = afs_getevent(event); AFS_ASSERT_GLOCK(); if (aintok) { - if (sv_timedwait_sig(&evp->cond, AFSD_PRI(), &afs_global_lock, - 0, 0, &ticks, (struct timespec*)0)) + if (sv_timedwait_sig + (&evp->cond, AFSD_PRI(), &afs_global_lock, 0, 0, &ticks, + (struct timespec *)0)) code = EINTR; - AFS_MUTEX_ENTER(&afs_global_lock); + AFS_MUTEX_ENTER(&afs_global_lock); } else { cv_timedwait(&evp->cond, &afs_global_lock, ticks); } - + relevent(evp); return code; } -int afs_osi_Wakeup(void *event) +int +afs_osi_Wakeup(void *event) { - int ret=1; + int ret = 1; struct afs_event *evp; evp = afs_getevent(event); if (evp->refcount > 1) { - evp->seq++; + evp->seq++; cv_broadcast(&evp->cond); - ret=0; + ret = 0; } relevent(evp); return ret; diff --git a/src/afs/IRIX/osi_vfs.h b/src/afs/IRIX/osi_vfs.h index d0225ed4e..1f2460a8b 100644 --- a/src/afs/IRIX/osi_vfs.h +++ b/src/afs/IRIX/osi_vfs.h @@ -47,8 +47,8 @@ typedef struct xfs_inode xfs_inode_t; #define XFS_ILOCK_SHARED 0x08 struct xfs_trans; struct xfs_mount; -extern int xfs_iget(struct mount *, struct xfs_trans *, xfs_ino_t, - uint, xfs_inode_t **, daddr_t); +extern int xfs_iget(struct mount *, struct xfs_trans *, xfs_ino_t, uint, + xfs_inode_t **, daddr_t); #ifdef AFS_SGI64_ENV #define XFS_ITOV(ip) BHV_TO_VNODE((struct bhv_desc *)(((char*)(ip)) + 6*sizeof(void*))) @@ -63,15 +63,15 @@ extern int xfs_iget(struct mount *, struct xfs_trans *, xfs_ino_t, #define AFS_SGI_EFS_CACHE 0 #define AFS_SGI_XFS_CACHE 1 extern int afs_CacheFSType; -extern vnode_t * (*afs_IGetVnode)(ino_t); +extern vnode_t *(*afs_IGetVnode) (ino_t); extern struct vnodeops *afs_efs_vnodeopsp; extern struct vnodeops *afs_xfs_vnodeopsp; #define AFS_SGI_IGETVNODE(INO) (*afs_IGetVnode)(INO) /* These need to be functions to wrap the vnode op calls. */ -extern ino_t VnodeToIno(vnode_t *vp); -extern dev_t VnodeToDev(vnode_t *vp); -extern off_t VnodeToSize(vnode_t *vp); +extern ino_t VnodeToIno(vnode_t * vp); +extern dev_t VnodeToDev(vnode_t * vp); +extern off_t VnodeToSize(vnode_t * vp); #else /* Just the EFS variants exist for now. */ #define VnodeToIno(vp) ((ino_t)(EFS_VTOI((vp))->i_number)) @@ -241,65 +241,65 @@ extern int afs_is_numa_arch; #ifdef AFS_SGI_VNODE_GLUE extern int afs_is_numa_arch; typedef struct bhv_head1 { - struct bhv_desc *bh_first; /* first behavior in chain */ + struct bhv_desc *bh_first; /* first behavior in chain */ #ifdef notdef - /* This is not present in the non NUMA machines. */ - mrlock_t bh_mrlock; /* lock for ops-in-progress synch. */ + /* This is not present in the non NUMA machines. */ + mrlock_t bh_mrlock; /* lock for ops-in-progress synch. */ #endif } bhv_head1_t; typedef struct vnode1 { - struct vnlist v_list; /* freelist linkage */ - uint v_flag; /* vnode flags (see below) */ - cnt_t v_count; /* reference count */ - u_short v_namecap; /* name cache capability */ - enum vtype v_type; /* vnode type */ - dev_t v_rdev; /* device (VCHR, VBLK) */ - struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */ - struct vfs *v_vfsp; /* ptr to containing VFS */ - struct stdata *v_stream; /* associated stream */ - struct filock *v_filocks; /* ptr to filock list */ - mutex_t *v_filocksem; /* ptr to mutex for list */ - vnumber_t v_number; /* in-core vnode number */ - short v_listid; /* free list id */ - cnt_t v_intpcount; /* interp. refcount for imon */ - bhv_head1_t v_bh; /* behavior head */ + struct vnlist v_list; /* freelist linkage */ + uint v_flag; /* vnode flags (see below) */ + cnt_t v_count; /* reference count */ + u_short v_namecap; /* name cache capability */ + enum vtype v_type; /* vnode type */ + dev_t v_rdev; /* device (VCHR, VBLK) */ + struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */ + struct vfs *v_vfsp; /* ptr to containing VFS */ + struct stdata *v_stream; /* associated stream */ + struct filock *v_filocks; /* ptr to filock list */ + mutex_t *v_filocksem; /* ptr to mutex for list */ + vnumber_t v_number; /* in-core vnode number */ + short v_listid; /* free list id */ + cnt_t v_intpcount; /* interp. refcount for imon */ + bhv_head1_t v_bh; /* behavior head */ - /* - * Used only by global cache. - */ - struct vnode *v_hashp; /* hash list for lookup */ - struct vnode *v_hashn; /* hash list for lookup */ + /* + * Used only by global cache. + */ + struct vnode *v_hashp; /* hash list for lookup */ + struct vnode *v_hashn; /* hash list for lookup */ - /* - * Values manipulated only by VM and - * the page/buffer caches. - */ - struct pregion *v_mreg; /* mapped file region pointer */ - int v_dbuf; /* delwri buffer count */ - pgno_t v_pgcnt; /* pages hashed to vnode */ - struct pfdat *v_dpages; /* delwri pages */ - struct buf *v_buf; /* vnode buffer tree head */ - unsigned int v_bufgen; /* buf list generation number */ - mutex_t v_buf_lock; /* mutex for buffer tree */ + /* + * Values manipulated only by VM and + * the page/buffer caches. + */ + struct pregion *v_mreg; /* mapped file region pointer */ + int v_dbuf; /* delwri buffer count */ + pgno_t v_pgcnt; /* pages hashed to vnode */ + struct pfdat *v_dpages; /* delwri pages */ + struct buf *v_buf; /* vnode buffer tree head */ + unsigned int v_bufgen; /* buf list generation number */ + mutex_t v_buf_lock; /* mutex for buffer tree */ - vnode_pcache_t v_pc; /* Page cache structure. - * per vnode. Refer to - * vnode_pcache.h - * for details. - */ + vnode_pcache_t v_pc; /* Page cache structure. + * per vnode. Refer to + * vnode_pcache.h + * for details. + */ #ifdef VNODE_TRACING - struct ktrace *v_trace; /* trace header structure */ + struct ktrace *v_trace; /* trace header structure */ #endif #ifdef CKPT - ckpt_handle_t v_ckpt; /* ckpt lookup info */ + ckpt_handle_t v_ckpt; /* ckpt lookup info */ #endif } vnode1_t; -extern struct pfdat *vnode_get_dpages(vnode_t*); -extern int vnode_get_dbuf(vnode_t*); -extern pgno_t vnode_get_pgcnt(vnode_t*); -extern struct pregion *vnode_get_mreg(vnode_t*); +extern struct pfdat *vnode_get_dpages(vnode_t *); +extern int vnode_get_dbuf(vnode_t *); +extern pgno_t vnode_get_pgcnt(vnode_t *); +extern struct pregion *vnode_get_mreg(vnode_t *); #define VN_GET_DPAGES(V) (afs_is_numa_arch ? \ ((V)->v_dpages) : \ (((vnode1_t*)(V))->v_dpages)) @@ -351,10 +351,10 @@ extern struct pregion *vnode_get_mreg(vnode_t*); /* * Flock(3) call. (from sys/file.h) */ -#define LOCK_SH 1 /* shared lock */ -#define LOCK_EX 2 /* exclusive lock */ -#define LOCK_NB 4 /* don't block when locking */ -#define LOCK_UN 8 /* unlock */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* don't block when locking */ +#define LOCK_UN 8 /* unlock */ #endif diff --git a/src/afs/IRIX/osi_vfsops.c b/src/afs/IRIX/osi_vfsops.c index 2f922c550..6ddae6609 100644 --- a/src/afs/IRIX/osi_vfsops.c +++ b/src/afs/IRIX/osi_vfsops.c @@ -13,11 +13,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include "sys/syssgi.h" @@ -33,7 +34,7 @@ mutex_t afs_init_kern_lock; #define SYS_setgroups SGI_SETGROUPS -int (*nfs_rfsdisptab_v2)() = NULL; +int (*nfs_rfsdisptab_v2) () = NULL; int afs_fstype; lock_t afs_rxlock; @@ -41,7 +42,7 @@ lock_t afs_rxlock; #include "sys/mload.h" char *Afs_mversion = M_VERSION; -extern int (*setgroupsp)(int, gid_t *); +extern int (*setgroupsp) (int, gid_t *); extern struct afs_lock afs_xvcache; extern int idbg_afsuser(); extern void afs_mpservice(void *); @@ -55,14 +56,14 @@ extern void afs_mpservice(void *); syscallsw[ABI_IRIX5].sc_sysent[(n)-1000].sy_flags = 0; extern struct vfsops Afs_vfsops, *afs_vfsopsp; extern struct vnodeops Afs_vnodeops, *afs_vnodeopsp; -extern void (*afsidestroyp)(struct inode *); -extern void (*afsdptoipp)(struct efs_dinode *, struct inode *); -extern void (*afsiptodpp)(struct inode *, struct efs_dinode *); +extern void (*afsidestroyp) (struct inode *); +extern void (*afsdptoipp) (struct efs_dinode *, struct inode *); +extern void (*afsiptodpp) (struct inode *, struct efs_dinode *); extern void afsidestroy(struct inode *); extern void afsdptoip(struct efs_dinode *, struct inode *); extern void afsiptodp(struct inode *, struct efs_dinode *); -extern int (*idbg_prafsnodep)(vnode_t *); -extern int (*idbg_afsvfslistp)(void); +extern int (*idbg_prafsnodep) (vnode_t *); +extern int (*idbg_afsvfslistp) (void); extern int idbg_prafsnode(vnode_t *); extern int idbg_afsvfslist(void); @@ -96,18 +97,18 @@ Afs_init(struct vfssw *vswp, int fstype) afsdptoipp = afsdptoip; idbg_prafsnodep = idbg_prafsnode; idbg_afsvfslistp = idbg_afsvfslist; - NewSystemCall (AFS_SYSCALL, Afs_syscall, 6); - NewSystemCall (AFS_PIOCTL, afs_pioctl, 4); - NewSystemCall (AFS_SETPAG, afs_setpag, 0); - NewSystemCall (AFS_IOPEN, iopen, 3); - NewSystemCall (AFS_ICREATE, icreate, 6); - NewSystemCall (AFS_IINC, iinc, 3); - NewSystemCall (AFS_IDEC, idec, 3); + NewSystemCall(AFS_SYSCALL, Afs_syscall, 6); + NewSystemCall(AFS_PIOCTL, afs_pioctl, 4); + NewSystemCall(AFS_SETPAG, afs_setpag, 0); + NewSystemCall(AFS_IOPEN, iopen, 3); + NewSystemCall(AFS_ICREATE, icreate, 6); + NewSystemCall(AFS_IINC, iinc, 3); + NewSystemCall(AFS_IDEC, idec, 3); #ifdef AFS_SGI_XFS_IOPS_ENV - NewSystemCall (AFS_IOPEN64, iopen64, 4); + NewSystemCall(AFS_IOPEN64, iopen64, 4); #else - NewSystemCall (AFS_IREAD, iread, 6); - NewSystemCall (AFS_IWRITE, iwrite, 6); + NewSystemCall(AFS_IREAD, iread, 6); + NewSystemCall(AFS_IWRITE, iwrite, 6); #endif /* last replace these */ @@ -124,7 +125,7 @@ extern int afs_sync(OSI_VFS_DECL(afsp), int flags, struct cred *cr); #else extern int afs_sync(OSI_VFS_DECL(afsp), short flags, struct cred *cr); #endif -extern int afs_vget(OSI_VFS_DECL(afsp), vnode_t **vpp, struct fid *afidp); +extern int afs_vget(OSI_VFS_DECL(afsp), vnode_t ** vpp, struct fid *afidp); #ifdef MP struct vfsops afs_lockedvfsops = #else @@ -140,8 +141,8 @@ struct vfsops Afs_vfsops = #endif afs_mount, #ifdef AFS_SGI64_ENV - fs_nosys, /* rootinit */ - fs_nosys, /* mntupdate */ + fs_nosys, /* rootinit */ + fs_nosys, /* mntupdate */ fs_dounmount, #endif afs_unmount, @@ -149,25 +150,25 @@ struct vfsops Afs_vfsops = afs_statfs, afs_sync, afs_vget, - fs_nosys, /* mountroot */ + fs_nosys, /* mountroot */ #ifdef AFS_SGI65_ENV - fs_nosys, /* realvfsops */ - fs_import, /* import */ - fs_nosys, /* quotactl */ + fs_nosys, /* realvfsops */ + fs_import, /* import */ + fs_nosys, /* quotactl */ #else - fs_nosys, /* swapvp */ + fs_nosys, /* swapvp */ #endif }; -extern struct afs_q VLRU; /*vcache LRU*/ +extern struct afs_q VLRU; /*vcache LRU */ #ifdef AFS_SGI64_ENV static bhv_desc_t afs_vfs_bhv; #endif -afs_mount(struct vfs *afsp, vnode_t *mvp, struct mounta *uap, +afs_mount(struct vfs *afsp, vnode_t * mvp, struct mounta *uap, #ifdef AFS_SGI65_ENV char *attrs, #endif - cred_t *cr) + cred_t * cr) { AFS_STATCNT(afs_mount); @@ -177,21 +178,21 @@ afs_mount(struct vfs *afsp, vnode_t *mvp, struct mounta *uap, if (mvp->v_type != VDIR) return ENOTDIR; - if (afs_globalVFS) { /* Don't allow remounts. */ + if (afs_globalVFS) { /* Don't allow remounts. */ return EBUSY; } afs_globalVFS = afsp; afsp->vfs_bsize = 8192; - afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ - afsp->vfs_fsid.val[1] = afs_fstype; + afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ + afsp->vfs_fsid.val[1] = afs_fstype; #ifdef AFS_SGI64_ENV vfs_insertbhv(afsp, &afs_vfs_bhv, &Afs_vfsops, &afs_vfs_bhv); #else afsp->vfs_data = NULL; #endif afsp->vfs_fstype = afs_fstype; - afsp->vfs_dev = 0xbabebabe; /* XXX this should be unique */ + afsp->vfs_dev = 0xbabebabe; /* XXX this should be unique */ #ifndef AFS_NONFSTRANS if (nfs_rfsdisptab_v2) @@ -202,9 +203,9 @@ afs_mount(struct vfs *afsp, vnode_t *mvp, struct mounta *uap, } afs_unmount(OSI_VFS_ARG(afsp), flags, cr) -OSI_VFS_DECL(afsp); -int flags; -cred_t *cr; + OSI_VFS_DECL(afsp); + int flags; + cred_t *cr; { extern int afs_afs_cold_shutdown; struct vcache *tvc; @@ -214,7 +215,7 @@ cred_t *cr; int error, fv_slept; OSI_VFS_CONVERT(afsp) - AFS_STATCNT(afs_unmount); + AFS_STATCNT(afs_unmount); if (!suser()) return EPERM; @@ -223,19 +224,19 @@ cred_t *cr; * flush all pages from inactive vnodes - return * EBUSY if any still in use */ - ObtainWriteLock(&afs_xvcache,172); + ObtainWriteLock(&afs_xvcache, 172); for (tq = VLRU.prev; tq != &VLRU; tq = uq) { tvc = QTOV(tq); uq = QPrev(tq); - vp = (vnode_t *)tvc; + vp = (vnode_t *) tvc; if (error = afs_FlushVCache(tvc, &fv_slept)) - if (vp->v_flag & VROOT) { - rootvp = vp; - continue; - } else { - ReleaseWriteLock(&afs_xvcache); - return error; - } + if (vp->v_flag & VROOT) { + rootvp = vp; + continue; + } else { + ReleaseWriteLock(&afs_xvcache); + return error; + } } /* @@ -243,14 +244,14 @@ cred_t *cr; */ if (rootvp) { tvc = VTOAFS(rootvp); - if (tvc->opens || CheckLock(&tvc->lock) || LockWaiters(&tvc->lock)) { + if (tvc->opens || CheckLock(&tvc->lock) || LockWaiters(&tvc->lock)) { ReleaseWriteLock(&afs_xvcache); return EBUSY; } - ReleaseWriteLock(&afs_xvcache); + ReleaseWriteLock(&afs_xvcache); rootvp->v_count = 1; AFS_RELE(rootvp); - ObtainWriteLock(&afs_xvcache,173); + ObtainWriteLock(&afs_xvcache, 173); afs_FlushVCache(tvc, &fv_slept); } ReleaseWriteLock(&afs_xvcache); @@ -264,16 +265,16 @@ cred_t *cr; -afs_root (OSI_VFS_ARG(afsp), avpp) +afs_root(OSI_VFS_ARG(afsp), avpp) OSI_VFS_DECL(afsp); - struct vnode **avpp; + struct vnode **avpp; { register afs_int32 code = 0; struct vrequest treq; - register struct vcache *tvp=0; + register struct vcache *tvp = 0; OSI_VFS_CONVERT(afsp) - AFS_STATCNT(afs_root); + AFS_STATCNT(afs_root); if (afs_globalVp && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; } else { @@ -282,8 +283,8 @@ afs_root (OSI_VFS_ARG(afsp), avpp) afs_globalVp = NULL; } - if (!(code = afs_InitReq(&treq, OSI_GET_CURRENT_CRED())) && - !(code = afs_CheckInit())) { + if (!(code = afs_InitReq(&treq, OSI_GET_CURRENT_CRED())) + && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); /* we really want this to stay around */ if (tvp) { @@ -296,7 +297,7 @@ afs_root (OSI_VFS_ARG(afsp), avpp) int s; VN_HOLD(AFSTOV(tvp)); s = VN_LOCK(AFSTOV(tvp)); - AFSTOV(tvp)->v_flag |= VROOT; + AFSTOV(tvp)->v_flag |= VROOT; VN_UNLOCK(AFSTOV(tvp), s); afs_globalVFS = afsp; @@ -309,27 +310,27 @@ afs_root (OSI_VFS_ARG(afsp), avpp) } afs_statfs(OSI_VFS_ARG(afsp), abp, avp) -OSI_VFS_DECL(afsp); -struct statvfs *abp; -struct vnode *avp; /* unused */ + OSI_VFS_DECL(afsp); + struct statvfs *abp; + struct vnode *avp; /* unused */ { OSI_VFS_CONVERT(afsp) AFS_STATCNT(afs_statfs); - abp->f_bsize = afsp->vfs_bsize; - abp->f_frsize = afsp->vfs_bsize; - /* Fake a high number below to satisfy programs that use the statfs - * call to make sure that there's enough space in the device partition - * before storing something there. - */ - abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = abp->f_favail = 900000; - - abp->f_fsid = AFS_VFSMAGIC; /* magic */ - strcpy(abp->f_basetype, AFS_MOUNT_AFS); - abp->f_flag = 0; - abp->f_namemax = 256; - return 0; + abp->f_bsize = afsp->vfs_bsize; + abp->f_frsize = afsp->vfs_bsize; + /* Fake a high number below to satisfy programs that use the statfs + * call to make sure that there's enough space in the device partition + * before storing something there. + */ + abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = + abp->f_ffree = abp->f_favail = 900000; + + abp->f_fsid = AFS_VFSMAGIC; /* magic */ + strcpy(abp->f_basetype, AFS_MOUNT_AFS); + abp->f_flag = 0; + abp->f_namemax = 256; + return 0; } @@ -371,154 +372,151 @@ afs_sync(OSI_VFS_DECL(afsp), struct cred *cr) { /* Why enable the vfs sync operation?? */ - int error, lasterr, preempt; - struct vcache *tvc; - struct vnode *vp; - afs_uint32 lvcachegen; - register struct afs_q *tq; - struct afs_q *uq; - int s; - OSI_VFS_CONVERT(afsp) + int error, lasterr, preempt; + struct vcache *tvc; + struct vnode *vp; + afs_uint32 lvcachegen; + register struct afs_q *tq; + struct afs_q *uq; + int s; + OSI_VFS_CONVERT(afsp) error = lasterr = 0; - /* - * if not interested in vnodes, skip all this - */ + /* + * if not interested in vnodes, skip all this + */ #ifdef AFS_SGI61_ENV - if ((flags & (SYNC_CLOSE|SYNC_DELWRI|SYNC_PDFLUSH)) == 0) - goto end; + if ((flags & (SYNC_CLOSE | SYNC_DELWRI | SYNC_PDFLUSH)) == 0) + goto end; #else /* AFS_SGI61_ENV */ - if ((flags & (SYNC_CLOSE|SYNC_DELWRI|SYNC_ATTR)) == 0) - goto end; + if ((flags & (SYNC_CLOSE | SYNC_DELWRI | SYNC_ATTR)) == 0) + goto end; #endif /* AFS_SGI61_ENV */ -loop: - ObtainReadLock(&afs_xvcache); - for (tq = VLRU.prev; tq != &VLRU; tq = uq) { - tvc = QTOV(tq); - uq = QPrev(tq); - vp = (vnode_t *)tvc; - /* - * Since we push all dirty pages on last close/VOP_INACTIVE - * we are only concerned with vnodes with - * active reference counts. - */ - s = VN_LOCK(vp); - if (vp->v_count == 0) { - VN_UNLOCK(vp, s); - continue; - } - if ((flags & SYNC_CLOSE) == 0 && !AFS_VN_DIRTY(vp)) { - VN_UNLOCK(vp, s); - continue; - } - - /* - * ignore vnodes which need no flushing - */ - if (flags & SYNC_DELWRI) { - if (!AFS_VN_DIRTY(vp)) { - VN_UNLOCK(vp, s); - continue; - } - } + loop: + ObtainReadLock(&afs_xvcache); + for (tq = VLRU.prev; tq != &VLRU; tq = uq) { + tvc = QTOV(tq); + uq = QPrev(tq); + vp = (vnode_t *) tvc; + /* + * Since we push all dirty pages on last close/VOP_INACTIVE + * we are only concerned with vnodes with + * active reference counts. + */ + s = VN_LOCK(vp); + if (vp->v_count == 0) { + VN_UNLOCK(vp, s); + continue; + } + if ((flags & SYNC_CLOSE) == 0 && !AFS_VN_DIRTY(vp)) { + VN_UNLOCK(vp, s); + continue; + } + + /* + * ignore vnodes which need no flushing + */ + if (flags & SYNC_DELWRI) { + if (!AFS_VN_DIRTY(vp)) { + VN_UNLOCK(vp, s); + continue; + } + } #ifdef AFS_SGI61_ENV - else if (flags & SYNC_PDFLUSH) { - if (!VN_GET_DPAGES(vp)) { - VN_UNLOCK(vp, s); - continue; - } - } + else if (flags & SYNC_PDFLUSH) { + if (!VN_GET_DPAGES(vp)) { + VN_UNLOCK(vp, s); + continue; + } + } #endif /* AFS_SGI61_ENV */ - vp->v_count++; - VN_UNLOCK(vp, s); - lvcachegen = vcachegen; - ReleaseReadLock(&afs_xvcache); - - /* - * Try to lock rwlock without sleeping. If we can't, we must - * sleep for rwlock. - */ - if (afs_rwlock_nowait(vp, 1) == 0) { + vp->v_count++; + VN_UNLOCK(vp, s); + lvcachegen = vcachegen; + ReleaseReadLock(&afs_xvcache); + + /* + * Try to lock rwlock without sleeping. If we can't, we must + * sleep for rwlock. + */ + if (afs_rwlock_nowait(vp, 1) == 0) { #ifdef AFS_SGI61_ENV - if (flags & (SYNC_BDFLUSH | SYNC_PDFLUSH)) + if (flags & (SYNC_BDFLUSH | SYNC_PDFLUSH)) #else /* AFS_SGI61_ENV */ - if (flags & SYNC_BDFLUSH) + if (flags & SYNC_BDFLUSH) #endif /* AFS_SGI61_ENV */ - { - AFS_RELE(vp); - ObtainReadLock(&afs_xvcache); - if (vcachegen != lvcachegen) { - ReleaseReadLock(&afs_xvcache); - goto loop; - } - continue; - } - AFS_RWLOCK(vp, VRWLOCK_WRITE); + { + AFS_RELE(vp); + ObtainReadLock(&afs_xvcache); + if (vcachegen != lvcachegen) { + ReleaseReadLock(&afs_xvcache); + goto loop; } + continue; + } + AFS_RWLOCK(vp, VRWLOCK_WRITE); + } - AFS_GUNLOCK(); - if (flags & SYNC_CLOSE) { - PFLUSHINVALVP(vp, (off_t)0, (off_t)tvc->m.Length); - } + AFS_GUNLOCK(); + if (flags & SYNC_CLOSE) { + PFLUSHINVALVP(vp, (off_t) 0, (off_t) tvc->m.Length); + } #ifdef AFS_SGI61_ENV - else if (flags & SYNC_PDFLUSH) { - if (VN_GET_DPAGES(vp)) { - pdflush(vp, B_ASYNC); - } - } + else if (flags & SYNC_PDFLUSH) { + if (VN_GET_DPAGES(vp)) { + pdflush(vp, B_ASYNC); + } + } #endif /* AFS_SGI61_ENV */ - if ((flags & SYNC_DELWRI) && AFS_VN_DIRTY(vp)) { + if ((flags & SYNC_DELWRI) && AFS_VN_DIRTY(vp)) { #ifdef AFS_SGI61_ENV - PFLUSHVP(vp, (off_t)tvc->m.Length, - (flags & SYNC_WAIT) ? 0 : B_ASYNC, error); + PFLUSHVP(vp, (off_t) tvc->m.Length, + (flags & SYNC_WAIT) ? 0 : B_ASYNC, error); #else /* AFS_SGI61_ENV */ - if (flags & SYNC_WAIT) - /* push all and wait */ - PFLUSHVP(vp, (off_t)tvc->m.Length, - (off_t)0, error); - else if (flags & SYNC_BDFLUSH) { - /* push oldest */ - error = pdflush(vp, B_ASYNC); - } - else { - /* push all but don't wait */ - PFLUSHVP(vp, (off_t)tvc->m.Length, - (off_t)B_ASYNC, error); - } + if (flags & SYNC_WAIT) + /* push all and wait */ + PFLUSHVP(vp, (off_t) tvc->m.Length, (off_t) 0, error); + else if (flags & SYNC_BDFLUSH) { + /* push oldest */ + error = pdflush(vp, B_ASYNC); + } else { + /* push all but don't wait */ + PFLUSHVP(vp, (off_t) tvc->m.Length, (off_t) B_ASYNC, error); + } #endif /* AFS_SGI61_ENV */ - } + } - /* - * Release vp, check error and whether to preempt, and if - * we let go of xvcache lock and someone has changed the - * VLRU, restart the loop - */ - AFS_GLOCK(); - AFS_RWUNLOCK(vp, VRWLOCK_WRITE); - AFS_RELE(vp); - if (error) - lasterr = error; - if ((++preempt & PREEMPT_MASK) == 0) { - AFS_GUNLOCK(); - PREEMPT(); - AFS_GLOCK(); - } - ObtainReadLock(&afs_xvcache); - if (vcachegen != lvcachegen) { - ReleaseReadLock(&afs_xvcache); - goto loop; - } + /* + * Release vp, check error and whether to preempt, and if + * we let go of xvcache lock and someone has changed the + * VLRU, restart the loop + */ + AFS_GLOCK(); + AFS_RWUNLOCK(vp, VRWLOCK_WRITE); + AFS_RELE(vp); + if (error) + lasterr = error; + if ((++preempt & PREEMPT_MASK) == 0) { + AFS_GUNLOCK(); + PREEMPT(); + AFS_GLOCK(); } - ReleaseReadLock(&afs_xvcache); -end: - return lasterr; + ObtainReadLock(&afs_xvcache); + if (vcachegen != lvcachegen) { + ReleaseReadLock(&afs_xvcache); + goto loop; + } + } + ReleaseReadLock(&afs_xvcache); + end: + return lasterr; } -afs_vget(OSI_VFS_DECL(afsp), vnode_t **avcp, struct fid *fidp) +afs_vget(OSI_VFS_DECL(afsp), vnode_t ** avcp, struct fid * fidp) { struct VenusFid vfid; struct vrequest treq; @@ -528,16 +526,16 @@ afs_vget(OSI_VFS_DECL(afsp), vnode_t **avcp, struct fid *fidp) #if defined(AFS_SGI64_ENV) && defined(CKPT) && !defined(_R5000_CVT_WAR) afs_fid2_t *afid2; -#endif +#endif OSI_VFS_CONVERT(afsp) - AFS_STATCNT(afs_vget); + AFS_STATCNT(afs_vget); *avcp = NULL; #if defined(AFS_SGI64_ENV) && defined(CKPT) && !defined(_R5000_CVT_WAR) - afid2 = (afs_fid2_t*)fidp; + afid2 = (afs_fid2_t *) fidp; if (afid2->af_len == sizeof(afs_fid2_t) - sizeof(afid2->af_len)) { /* It's a checkpoint restart fid. */ tcell = afs_GetCellByIndex(afid2->af_cell, READ_LOCK); @@ -553,18 +551,20 @@ afs_vget(OSI_VFS_DECL(afsp), vnode_t **avcp, struct fid *fidp) if (code = afs_InitReq(&treq, OSI_GET_CURRENT_CRED())) goto out; - *avcp = (vnode_t*) afs_GetVCache(&vfid, &treq, NULL, (struct vcache*)0); - if (! *avcp) { + *avcp = + (vnode_t *) afs_GetVCache(&vfid, &treq, NULL, (struct vcache *)0); + if (!*avcp) { code = ENOENT; } goto out; } #endif - if (code = afs_InitReq(&treq, OSI_GET_CURRENT_CRED())) goto out; - code = afs_osi_vget((struct vcache**)avcp, fidp, &treq); + if (code = afs_InitReq(&treq, OSI_GET_CURRENT_CRED())) + goto out; + code = afs_osi_vget((struct vcache **)avcp, fidp, &treq); - out: + out: afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp, ICL_TYPE_INT32, treq.uid, ICL_TYPE_FID, &vfid); code = afs_CheckCode(code, &treq, 42); @@ -572,7 +572,7 @@ afs_vget(OSI_VFS_DECL(afsp), vnode_t **avcp, struct fid *fidp) } -#ifdef MP /* locked versions of vfs operations. */ +#ifdef MP /* locked versions of vfs operations. */ /* wrappers for vfs calls */ #ifdef AFS_SGI64_ENV @@ -581,70 +581,78 @@ afs_vget(OSI_VFS_DECL(afsp), vnode_t **avcp, struct fid *fidp) #define AFS_MP_VFS_ARG(A) struct vfs A #endif -int mp_afs_mount(struct vfs *a, struct vnode *b, struct mounta *c, +int +mp_afs_mount(struct vfs *a, struct vnode *b, struct mounta *c, #ifdef AFS_SGI65_ENV - char *d, + char *d, #endif - struct cred *e) + struct cred *e) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvfsops.vfs_mount(a, b, c, d + int rv; + AFS_GLOCK(); + rv = afs_lockedvfsops.vfs_mount(a, b, c, d #ifdef AFS_SGI65_ENV - , e + , e #endif - ); - AFS_GUNLOCK(); - return rv; + ); + AFS_GUNLOCK(); + return rv; } -int mp_afs_unmount(AFS_MP_VFS_ARG(*a), int b, struct cred *c) +int +mp_afs_unmount(AFS_MP_VFS_ARG(*a), int b, struct cred *c) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvfsops.vfs_unmount(a, b, c); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvfsops.vfs_unmount(a, b, c); + AFS_GUNLOCK(); + return rv; } -int mp_afs_root(AFS_MP_VFS_ARG(*a), struct vnode **b) +int +mp_afs_root(AFS_MP_VFS_ARG(*a), struct vnode **b) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvfsops.vfs_root(a, b); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvfsops.vfs_root(a, b); + AFS_GUNLOCK(); + return rv; } -int mp_afs_statvfs(AFS_MP_VFS_ARG(*a), struct statvfs *b, struct vnode *c) +int +mp_afs_statvfs(AFS_MP_VFS_ARG(*a), struct statvfs *b, struct vnode *c) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvfsops.vfs_statvfs(a, b, c); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvfsops.vfs_statvfs(a, b, c); + AFS_GUNLOCK(); + return rv; } -int mp_afs_sync(AFS_MP_VFS_ARG(*a), + +int +mp_afs_sync(AFS_MP_VFS_ARG(*a), #ifdef AFS_SGI65_ENV - int b, + int b, #else - short b, + short b, #endif - struct cred *c) + struct cred *c) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvfsops.vfs_sync(a, b, c); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvfsops.vfs_sync(a, b, c); + AFS_GUNLOCK(); + return rv; } -int mp_afs_vget(AFS_MP_VFS_ARG(*a), struct vnode **b, struct fid *c) + +int +mp_afs_vget(AFS_MP_VFS_ARG(*a), struct vnode **b, struct fid *c) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvfsops.vfs_vget(a, b, c); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvfsops.vfs_vget(a, b, c); + AFS_GUNLOCK(); + return rv; } struct vfsops Afs_vfsops = { @@ -657,8 +665,8 @@ struct vfsops Afs_vfsops = { #endif mp_afs_mount, #ifdef AFS_SGI64_ENV - fs_nosys, /* rootinit */ - fs_nosys, /* mntupdate */ + fs_nosys, /* rootinit */ + fs_nosys, /* mntupdate */ fs_dounmount, #endif mp_afs_unmount, @@ -666,13 +674,13 @@ struct vfsops Afs_vfsops = { mp_afs_statvfs, mp_afs_sync, mp_afs_vget, - fs_nosys, /* mountroot */ + fs_nosys, /* mountroot */ #ifdef AFS_SGI65_ENV - fs_nosys, /* realvfsops */ - fs_import, /* import */ - fs_nosys, /* quotactl */ + fs_nosys, /* realvfsops */ + fs_import, /* import */ + fs_nosys, /* quotactl */ #else - fs_nosys, /* swapvp */ + fs_nosys, /* swapvp */ #endif }; diff --git a/src/afs/IRIX/osi_vm.c b/src/afs/IRIX/osi_vm.c index 3d44051d3..93a29abab 100644 --- a/src/afs/IRIX/osi_vm.c +++ b/src/afs/IRIX/osi_vm.c @@ -10,7 +10,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ @@ -33,7 +34,8 @@ extern struct vnodeops Afs_vnodeops; * is not dropped and re-acquired for any platform. It may be that *slept is * therefore obsolescent. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { int s, code; vnode_t *vp = &avc->v; @@ -60,7 +62,7 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Note that although we checked vcount above, we didn't have the lock */ if (vp->v_count > 0 || (vp->v_flag & VINACT)) { - VN_UNLOCK(vp, s); + VN_UNLOCK(vp, s); return EBUSY; } VN_UNLOCK(vp, s); @@ -71,7 +73,7 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Note that we hold the xvcache lock the entire time. */ AFS_GUNLOCK(); - PTOSSVP(vp, (off_t)0, (off_t)MAXLONG); + PTOSSVP(vp, (off_t) 0, (off_t) MAXLONG); AFS_GLOCK(); /* afs_chkpgoob will drop and re-acquire the global lock. */ @@ -88,9 +90,9 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) if (vp->v_filocksem) { if (vp->v_filocks) #ifdef AFS_SGI64_ENV - cleanlocks(vp, &curprocp->p_flid); + cleanlocks(vp, &curprocp->p_flid); #else - cleanlocks(vp, IGN_PID, 0); + cleanlocks(vp, IGN_PID, 0); #endif osi_Assert(vp->v_filocks == NULL); mutex_destroy(vp->v_filocksem); @@ -99,10 +101,11 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) } #endif /* AFS_SGI65_ENV */ - if (avc->vrefCount) osi_Panic("flushVcache: vm race"); + if (avc->vrefCount) + osi_Panic("flushVcache: vm race"); #ifdef AFS_SGI64_ENV AFS_GUNLOCK(); - vnode_pcache_reclaim(vp); /* this can sleep */ + vnode_pcache_reclaim(vp); /* this can sleep */ vnode_pcache_free(vp); if (vp->v_op != &Afs_vnodeops) { VOP_RECLAIM(vp, FSYNC_WAIT, code); @@ -120,7 +123,7 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) bhv_remove(VN_BHV_HEAD(vp), &(avc->vc_bhv_desc)); bhv_head_destroy(&(vp->v_bh)); #endif - vp->v_flag = 0; /* debug */ + vp->v_flag = 0; /* debug */ #if defined(DEBUG) && defined(VNODE_INIT_BITLOCK) destroy_bitlock(&vp->v_flag); #endif @@ -141,27 +144,29 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Since we drop and re-obtain the lock, we can't guarantee that there won't * be some pages around when we return, newly created by concurrent activity. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); /* current remapf restriction - cannot have VOP_RWLOCK */ osi_Assert(OSI_GET_LOCKID() != avc->vc_rwlockid); - if (((vnode_t *)avc)->v_type == VREG && AFS_VN_MAPPED(((vnode_t *)avc))) - remapf(((vnode_t *)avc), 0, 0); - PTOSSVP(AFSTOV(avc), (off_t)0, (off_t)MAXLONG); + if (((vnode_t *) avc)->v_type == VREG && AFS_VN_MAPPED(((vnode_t *) avc))) + remapf(((vnode_t *) avc), 0, 0); + PTOSSVP(AFSTOV(avc), (off_t) 0, (off_t) MAXLONG); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,62); + ObtainWriteLock(&avc->lock, 62); } /* Flush and invalidate pages, for fsync() with INVAL flag * * Locking: only the global lock is held. */ -void osi_VM_FSyncInval(struct vcache *avc) +void +osi_VM_FSyncInval(struct vcache *avc) { AFS_GUNLOCK(); - PFLUSHINVALVP((vnode_t *)avc, (off_t)0, (off_t)avc->m.Length); + PFLUSHINVALVP((vnode_t *) avc, (off_t) 0, (off_t) avc->m.Length); AFS_GLOCK(); } @@ -170,7 +175,8 @@ void osi_VM_FSyncInval(struct vcache *avc) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { int error; osi_Assert(valusema(&avc->vc_rwlock) <= 0); @@ -183,11 +189,11 @@ void osi_VM_StoreAllSegments(struct vcache *avc) AFS_GUNLOCK(); /* Write out dirty pages list to avoid B_DELWRI buffers. */ - while (VN_GET_DPAGES((vnode_t*)avc)) { + while (VN_GET_DPAGES((vnode_t *) avc)) { pdflush(AFSTOV(avc), 0); } - PFLUSHVP(AFSTOV(avc), (off_t)avc->m.Length, (off_t)0, error); + PFLUSHVP(AFSTOV(avc), (off_t) avc->m.Length, (off_t) 0, error); AFS_GLOCK(); if (error) { /* @@ -198,11 +204,12 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * does what we want (we don't use this normally since * it also unhashes pages ..) */ - PINVALFREE((vnode_t *)avc, avc->m.Length); + PINVALFREE((vnode_t *) avc, avc->m.Length); } - ObtainWriteLock(&avc->lock,121); + ObtainWriteLock(&avc->lock, 121); if (error && avc->m.LinkCount) - cmn_err(CE_WARN, "AFS:Failed to push back pages for vnode 0x%x error %d (from afs_StoreOnLastReference)", + cmn_err(CE_WARN, + "AFS:Failed to push back pages for vnode 0x%x error %d (from afs_StoreOnLastReference)", avc, error); } @@ -210,11 +217,12 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * * Locking: No lock is held, not even the global lock. */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { - vnode_t *vp = (vnode_t *)avc; + vnode_t *vp = (vnode_t *) avc; - remapf(vp, /*avc->m.Length*/ 0, 0); + remapf(vp, /*avc->m.Length */ 0, 0); /* Used to grab locks and recheck avc->m.DataVersion and * avc->execsOrWriters here, but we have to drop locks before calling @@ -225,7 +233,7 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * ptossvp tosses all pages associated with this vnode * All in-use pages are marked BAD */ - PTOSSVP(vp, (off_t)0, (off_t)MAXLONG); + PTOSSVP(vp, (off_t) 0, (off_t) MAXLONG); } /* Purge pages beyond end-of-file, when truncating a file. @@ -234,7 +242,8 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * activeV is raised. This is supposed to block pageins, but at present * it only works on Solaris. */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { - PTOSSVP(&avc->v, (off_t)alen, (off_t)MAXLONG); + PTOSSVP(&avc->v, (off_t) alen, (off_t) MAXLONG); } diff --git a/src/afs/IRIX/osi_vnodeops.c b/src/afs/IRIX/osi_vnodeops.c index 51e4be7b7..d7722bf14 100644 --- a/src/afs/IRIX/osi_vnodeops.c +++ b/src/afs/IRIX/osi_vnodeops.c @@ -13,14 +13,15 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_SGI62_ENV #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ -#include "sys/flock.h" -#include "afs/nfsclient.h" +#include "afs/afs_stats.h" /* statistics */ +#include "sys/flock.h" +#include "afs/nfsclient.h" /* AFSBSIZE must be at least the size of a page, else the client will hang. * For 64 bit platforms, the page size is more than 8K. @@ -33,14 +34,15 @@ static void afs_strategy(); static int afs_xread(), afs_xwrite(); static int afs_xbmap(), afs_map(), afs_reclaim(); #ifndef AFS_SGI65_ENV -static int afs_addmap(), afs_delmap(); +static int afs_addmap(), afs_delmap(); #endif extern int afs_open(), afs_close(), afs_ioctl(), afs_getattr(), afs_setattr(); extern int afs_access(), afs_lookup(); extern int afs_create(), afs_remove(), afs_link(), afs_rename(); extern int afs_mkdir(), afs_rmdir(), afs_readdir(); -extern int afs_symlink(), afs_readlink(), afs_fsync(), afs_fid(), afs_frlock(); -static int afs_seek(OSI_VC_DECL(a), off_t b, off_t *c); +extern int afs_symlink(), afs_readlink(), afs_fsync(), afs_fid(), +afs_frlock(); +static int afs_seek(OSI_VC_DECL(a), off_t b, off_t * c); #ifdef AFS_SGI64_ENV extern int afs_xinactive(); #else @@ -48,17 +50,14 @@ extern void afs_xinactive(); #endif extern void afs_rwlock(OSI_VN_DECL(vp), AFS_RWLOCK_T b); -extern void afs_rwunlock(OSI_VN_DECL(vp), AFS_RWLOCK_T b); +extern void afs_rwunlock(OSI_VN_DECL(vp), AFS_RWLOCK_T b); extern int afs_fid2(); -static int afsrwvp(register struct vcache *avc, - register struct uio *uio, - enum uio_rw rw, - int ioflag, +static int afsrwvp(register struct vcache *avc, register struct uio *uio, + enum uio_rw rw, int ioflag, #ifdef AFS_SGI64_ENV - struct cred *cr, - struct flid *flp); + struct cred *cr, struct flid *flp); #else struct cred *cr); #endif @@ -72,89 +71,91 @@ struct vnodeops Afs_vnodeops = { #ifdef AFS_SGI64_ENV #ifdef AFS_SGI65_ENV - BHV_IDENTITY_INIT_POSITION(VNODE_POSITION_BASE), + BHV_IDENTITY_INIT_POSITION(VNODE_POSITION_BASE), #else - VNODE_POSITION_BASE, -#endif -#endif - afs_open, - afs_close, - afs_xread, - afs_xwrite, - afs_ioctl, - fs_setfl, - afs_getattr, - afs_setattr, - afs_access, - afs_lookup, - afs_create, - afs_remove, - afs_link, - afs_rename, - afs_mkdir, - afs_rmdir, - afs_readdir, - afs_symlink, - afs_readlink, - afs_fsync, - afs_xinactive, - afs_fid, - afs_fid2, - afs_rwlock, - afs_rwunlock, - afs_seek, - fs_cmp, - afs_frlock, - fs_nosys, /* realvp */ - afs_xbmap, - afs_strategy, - afs_map, + VNODE_POSITION_BASE, +#endif +#endif + afs_open, + afs_close, + afs_xread, + afs_xwrite, + afs_ioctl, + fs_setfl, + afs_getattr, + afs_setattr, + afs_access, + afs_lookup, + afs_create, + afs_remove, + afs_link, + afs_rename, + afs_mkdir, + afs_rmdir, + afs_readdir, + afs_symlink, + afs_readlink, + afs_fsync, + afs_xinactive, + afs_fid, + afs_fid2, + afs_rwlock, + afs_rwunlock, + afs_seek, + fs_cmp, + afs_frlock, + fs_nosys, /* realvp */ + afs_xbmap, + afs_strategy, + afs_map, #ifdef AFS_SGI65_ENV - fs_noerr, /* addmap - devices only */ - fs_noerr, /* delmap - devices only */ + fs_noerr, /* addmap - devices only */ + fs_noerr, /* delmap - devices only */ #else - afs_addmap, - afs_delmap, -#endif - fs_poll, /* poll */ - fs_nosys, /* dump */ - fs_pathconf, - fs_nosys, /* allocstore */ - fs_nosys, /* fcntl */ - afs_reclaim, /* reclaim */ - fs_nosys, /* attr_get */ - fs_nosys, /* attr_set */ - fs_nosys, /* attr_remove */ - fs_nosys, /* attr_list */ + afs_addmap, + afs_delmap, +#endif + fs_poll, /* poll */ + fs_nosys, /* dump */ + fs_pathconf, + fs_nosys, /* allocstore */ + fs_nosys, /* fcntl */ + afs_reclaim, /* reclaim */ + fs_nosys, /* attr_get */ + fs_nosys, /* attr_set */ + fs_nosys, /* attr_remove */ + fs_nosys, /* attr_list */ #ifdef AFS_SGI64_ENV #ifdef AFS_SGI65_ENV - fs_cover, - (vop_link_removed_t)fs_noval, - fs_vnode_change, - fs_tosspages, - fs_flushinval_pages, - fs_flush_pages, - fs_invalfree_pages, - fs_pages_sethole, - (vop_commit_t)fs_nosys, - (vop_readbuf_t)fs_nosys, - fs_strgetmsg, - fs_strputmsg, + fs_cover, + (vop_link_removed_t) fs_noval, + fs_vnode_change, + fs_tosspages, + fs_flushinval_pages, + fs_flush_pages, + fs_invalfree_pages, + fs_pages_sethole, + (vop_commit_t) fs_nosys, + (vop_readbuf_t) fs_nosys, + fs_strgetmsg, + fs_strputmsg, #else - fs_mount, + fs_mount, #endif #endif }; + #ifndef MP struct vnodeops *afs_ops = &Afs_vnodeops; #endif -int afs_frlock(OSI_VN_DECL(vp), int cmd, struct flock *lfp, int flag, - off_t offset, +int +afs_frlock(OSI_VN_DECL(vp), int cmd, struct flock *lfp, int flag, + off_t offset, #ifdef AFS_SGI65_ENV - vrwlock_t vrwlock, + vrwlock_t vrwlock, #endif - cred_t *cr) + cred_t * cr) { int error; OSI_VN_CONVERT(vp) @@ -177,13 +178,13 @@ int afs_frlock(OSI_VN_DECL(vp), int cmd, struct flock *lfp, int flag, * For GETLK we do a bit more - we first check any byte-wise * locks - if none then check for full AFS file locks */ - if (cmd == F_GETLK || lfp->l_whence != 0 || lfp->l_start != 0 || - (lfp->l_len != MAXEND && lfp->l_len != 0)) { + if (cmd == F_GETLK || lfp->l_whence != 0 || lfp->l_start != 0 + || (lfp->l_len != MAXEND && lfp->l_len != 0)) { AFS_RWLOCK(vp, VRWLOCK_WRITE); AFS_GUNLOCK(); #ifdef AFS_SGI65_ENV - error = fs_frlock(OSI_VN_ARG(vp), cmd, lfp, flag, offset, - vrwlock, cr); + error = + fs_frlock(OSI_VN_ARG(vp), cmd, lfp, flag, offset, vrwlock, cr); #else error = fs_frlock(vp, cmd, lfp, flag, offset, cr); #endif @@ -197,37 +198,36 @@ int afs_frlock(OSI_VN_DECL(vp), int cmd, struct flock *lfp, int flag, /* fall through to check for full AFS file locks */ } - /* map BSD style to plain - we don't call reclock() + /* map BSD style to plain - we don't call reclock() * and its only there that the difference is important */ switch (cmd) { - case F_GETLK: - case F_RGETLK: - break; - case F_SETLK: - case F_RSETLK: - break; - case F_SETBSDLK: - cmd = F_SETLK; - break; - case F_SETLKW: - case F_RSETLKW: - break; - case F_SETBSDLKW: - cmd = F_SETLKW; - break; - default: - return EINVAL; + case F_GETLK: + case F_RGETLK: + break; + case F_SETLK: + case F_RSETLK: + break; + case F_SETBSDLK: + cmd = F_SETLK; + break; + case F_SETLKW: + case F_RSETLKW: + break; + case F_SETBSDLKW: + cmd = F_SETLKW; + break; + default: + return EINVAL; } AFS_GUNLOCK(); - error = convoff(vp, lfp, 0, offset - , SEEKLIMIT + error = convoff(vp, lfp, 0, offset, SEEKLIMIT #ifdef AFS_SGI64_ENV , OSI_GET_CURRENT_CRED() #endif /* AFS_SGI64_ENV */ - ); + ); AFS_GLOCK(); if (!error) { @@ -263,32 +263,34 @@ int afs_frlock(OSI_VN_DECL(vp), int cmd, struct flock *lfp, int flag, */ /* ARGSUSED */ #ifdef AFS_SGI64_ENV -static int afs_xread(OSI_VC_ARG(avc), uiop, ioflag, cr, flp) -struct flid *flp; +static int +afs_xread(OSI_VC_ARG(avc), uiop, ioflag, cr, flp) + struct flid *flp; #else -static int afs_xread(OSI_VC_ARG(avc), uiop, ioflag, cr) +static int +afs_xread(OSI_VC_ARG(avc), uiop, ioflag, cr) #endif - OSI_VC_DECL(avc); - struct uio *uiop; - int ioflag; - struct cred *cr; +OSI_VC_DECL(avc); + struct uio *uiop; + int ioflag; + struct cred *cr; { int code; OSI_VC_CONVERT(avc) - osi_Assert(avc->v.v_count > 0); + osi_Assert(avc->v.v_count > 0); if (avc->v.v_type != VREG) return EISDIR; #ifdef AFS_SGI64_ENV #ifdef AFS_SGI65_ENV if (!(ioflag & IO_ISLOCKED)) - AFS_RWLOCK((vnode_t*)avc, VRWLOCK_READ); + AFS_RWLOCK((vnode_t *) avc, VRWLOCK_READ); #endif code = afsrwvp(avc, uiop, UIO_READ, ioflag, cr, flp); #ifdef AFS_SGI65_ENV if (!(ioflag & IO_ISLOCKED)) - AFS_RWUNLOCK((vnode_t*)avc, VRWLOCK_READ); + AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_READ); #endif #else code = afsrwvp(avc, uiop, UIO_READ, ioflag, cr); @@ -298,20 +300,22 @@ static int afs_xread(OSI_VC_ARG(avc), uiop, ioflag, cr) /* ARGSUSED */ #ifdef AFS_SGI64_ENV -static int afs_xwrite(OSI_VC_ARG(avc), uiop, ioflag, cr, flp) -struct flid *flp; +static int +afs_xwrite(OSI_VC_ARG(avc), uiop, ioflag, cr, flp) + struct flid *flp; #else -static int afs_xwrite(OSI_VC_ARG(avc), uiop, ioflag, cr) +static int +afs_xwrite(OSI_VC_ARG(avc), uiop, ioflag, cr) #endif - OSI_VC_DECL(avc); - struct uio *uiop; - int ioflag; - struct cred *cr; +OSI_VC_DECL(avc); + struct uio *uiop; + int ioflag; + struct cred *cr; { int code; OSI_VC_CONVERT(avc) - osi_Assert(avc->v.v_count > 0); + osi_Assert(avc->v.v_count > 0); if (avc->v.v_type != VREG) return EISDIR; @@ -320,12 +324,12 @@ static int afs_xwrite(OSI_VC_ARG(avc), uiop, ioflag, cr) #ifdef AFS_SGI64_ENV #ifdef AFS_SGI65_ENV if (!(ioflag & IO_ISLOCKED)) - AFS_RWLOCK(((vnode_t*)avc), VRWLOCK_WRITE); + AFS_RWLOCK(((vnode_t *) avc), VRWLOCK_WRITE); #endif code = afsrwvp(avc, uiop, UIO_WRITE, ioflag, cr, flp); #ifdef AFS_SGI65_ENV if (!(ioflag & IO_ISLOCKED)) - AFS_RWUNLOCK((vnode_t*)avc, VRWLOCK_WRITE); + AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE); #endif #else code = afsrwvp(avc, uiop, UIO_WRITE, ioflag, cr); @@ -338,15 +342,13 @@ static int prnra = 0; static int acchk = 0; static int acdrop = 0; -static int afsrwvp(register struct vcache *avc, - register struct uio *uio, - enum uio_rw rw, - int ioflag, +static int +afsrwvp(register struct vcache *avc, register struct uio *uio, enum uio_rw rw, + int ioflag, #ifdef AFS_SGI64_ENV - struct cred *cr, - struct flid *flp) + struct cred *cr, struct flid *flp) #else - struct cred *cr) + struct cred *cr) #endif { register struct vnode *vp = AFSTOV(avc); @@ -362,34 +364,32 @@ static int afsrwvp(register struct vcache *avc, struct dcache *tdc; int counter = 0; - osi_Assert((valusema(&avc->vc_rwlock) <= 0) && - (OSI_GET_LOCKID() == avc->vc_rwlockid)); + osi_Assert((valusema(&avc->vc_rwlock) <= 0) + && (OSI_GET_LOCKID() == avc->vc_rwlockid)); newoff = uio->uio_resid + uio->uio_offset; if (uio->uio_resid <= 0) { return (0); } - if (uio->uio_offset < 0 - || (signed long)newoff < 0) { + if (uio->uio_offset < 0 || (signed long)newoff < 0) { return (EINVAL); } if (ioflag & IO_DIRECT) return EINVAL; - if (rw == UIO_WRITE && vp->v_type == VREG - && newoff > uio->uio_limit) { + if (rw == UIO_WRITE && vp->v_type == VREG && newoff > uio->uio_limit) { return (EFBIG); } afs_Trace4(afs_iclSetp, CM_TRACE_GRDWR, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, ioflag, - ICL_TYPE_INT32, rw, ICL_TYPE_INT32, 0); + ICL_TYPE_INT32, ioflag, ICL_TYPE_INT32, rw, ICL_TYPE_INT32, 0); /* get a validated vcache entry */ afs_InitReq(&treq, cr); error = afs_VerifyVCache(avc, &treq); - if (error) return afs_CheckCode(error, &treq, 51); + if (error) + return afs_CheckCode(error, &treq, 51); /* * flush any stale pages - this will unmap @@ -398,8 +398,9 @@ static int afsrwvp(register struct vcache *avc, osi_FlushPages(avc, cr); if (cr && AFS_NFSXLATORREQ(cr) && rw == UIO_READ) { - if (!afs_AccessOK(avc, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) + if (!afs_AccessOK + (avc, PRSFS_READ, &treq, + CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) return EACCES; } /* @@ -408,7 +409,7 @@ static int afsrwvp(register struct vcache *avc, * the last writers credentials */ if (rw == UIO_WRITE || (rw == UIO_READ && avc->cred == NULL)) { - ObtainWriteLock(&avc->lock,92); + ObtainWriteLock(&avc->lock, 92); if (avc->cred) crfree(avc->cred); crhold(cr); @@ -422,7 +423,7 @@ static int afsrwvp(register struct vcache *avc, * because there're no open/close nfs rpc's to call our afs_open/close. */ if (root_exported && rw == UIO_WRITE) { - ObtainWriteLock(&avc->lock,234); + ObtainWriteLock(&avc->lock, 234); if (root_exported) { didFakeOpen = 1; afs_FakeOpen(avc); @@ -432,7 +433,7 @@ static int afsrwvp(register struct vcache *avc, error = 0; if (rw == UIO_WRITE) { - ObtainWriteLock(&avc->lock,330); + ObtainWriteLock(&avc->lock, 330); avc->states |= CDirty; ReleaseWriteLock(&avc->lock); } @@ -453,7 +454,7 @@ static int afsrwvp(register struct vcache *avc, error = avc->vc_error; break; } - bsize = AFSBSIZE; /* why not?? */ + bsize = AFSBSIZE; /* why not?? */ off = uio->uio_offset % bsize; bn = BTOBBT(uio->uio_offset - off); /* @@ -472,7 +473,7 @@ static int afsrwvp(register struct vcache *avc, /* * read/paging in a normal file */ - rem = avc->m.Length - (afs_int32)uio->uio_offset; + rem = avc->m.Length - (afs_int32) uio->uio_offset; if (rem <= 0) /* EOF */ break; @@ -503,8 +504,8 @@ static int afsrwvp(register struct vcache *avc, * do read-ahead on any file that has potentially * dirty mmap pages. */ - if ((avc->lastr + BTOBB(AFSBSIZE) == bn || - uio->uio_resid > AFSBSIZE) + if ((avc->lastr + BTOBB(AFSBSIZE) == bn + || uio->uio_resid > AFSBSIZE) #ifdef AFS_SGI61_ENV && (!AFS_VN_MAPPED(vp)) #else /* AFS_SGI61_ENV */ @@ -533,10 +534,10 @@ static int afsrwvp(register struct vcache *avc, } #ifdef DEBUG else if (prnra) - printf("NRA:vp 0x%x lastr %d bn %d len %d cnt %d bsize %d rem %d resid %d\n", - vp, avc->lastr, bn, - len, cnt, bsize, rem, - uio->uio_resid); + printf + ("NRA:vp 0x%x lastr %d bn %d len %d cnt %d bsize %d rem %d resid %d\n", + vp, avc->lastr, bn, len, cnt, bsize, rem, + uio->uio_resid); #endif avc->lastr = bn; @@ -546,13 +547,13 @@ static int afsrwvp(register struct vcache *avc, */ if (counter == 0 || AFS_CHUNKOFFSET(off) == 0) { AFS_GLOCK(); - ObtainWriteLock(&avc->lock,562); + ObtainWriteLock(&avc->lock, 562); tdc = afs_FindDCache(avc, off); - if (tdc) { - if (!(tdc->mflags & DFNextStarted)) - afs_PrefetchChunk(avc, tdc, cr, &treq); + if (tdc) { + if (!(tdc->mflags & DFNextStarted)) + afs_PrefetchChunk(avc, tdc, cr, &treq); afs_PutDCache(tdc); - } + } ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); } @@ -568,13 +569,14 @@ static int afsrwvp(register struct vcache *avc, */ if (counter > 0 && AFS_CHUNKOFFSET(uio->uio_offset) == 0) { AFS_GLOCK(); - ObtainWriteLock(&avc->lock,90); + ObtainWriteLock(&avc->lock, 90); error = afs_DoPartialWrite(avc, &treq); if (error == 0) avc->states |= CDirty; ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); - if (error) break; + if (error) + break; } counter++; @@ -623,7 +625,7 @@ static int afsrwvp(register struct vcache *avc, osi_Assert(bp->b_error == 0); if (uio->uio_segflg != UIO_NOSPACE) - (void) bp_mapin(bp); + (void)bp_mapin(bp); AFS_UIOMOVE(bp->b_un.b_addr + bmv[0].pboff, cnt, rw, uio, error); if (rw == UIO_READ || error) { if (bp->b_flags & B_DELWRI) { @@ -635,12 +637,12 @@ static int afsrwvp(register struct vcache *avc, * m.Length is the maximum number of bytes known to be in the file. * Make sure it is at least as high as the last byte we just wrote * into the buffer. - */ - if (avc->m.Length < (afs_int32)uio->uio_offset) { + */ + if (avc->m.Length < (afs_int32) uio->uio_offset) { AFS_GLOCK(); - ObtainWriteLock(&avc->lock,235); + ObtainWriteLock(&avc->lock, 235); avc->m.Length = uio->uio_offset; - ReleaseWriteLock(&avc->lock); + ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); } if (uio->uio_fmode & FSYNC) { @@ -654,10 +656,11 @@ static int afsrwvp(register struct vcache *avc, /* * Since EIO on an unlinked file is non-intuitive - give some * explanation - */ + */ if (error) { if (avc->m.LinkCount == 0) - cmn_err(CE_WARN,"AFS: Process pid %d write error %d writing to unlinked file.", + cmn_err(CE_WARN, + "AFS: Process pid %d write error %d writing to unlinked file.", OSI_GET_CURRENT_PID(), error); } } @@ -674,8 +677,8 @@ static int afsrwvp(register struct vcache *avc, if (!error) { #ifdef AFS_SGI61_ENV - if (((ioflag & IO_SYNC) || (ioflag & IO_DSYNC)) && (rw == UIO_WRITE) && - !AFS_NFSXLATORREQ(cr)) { + if (((ioflag & IO_SYNC) || (ioflag & IO_DSYNC)) && (rw == UIO_WRITE) + && !AFS_NFSXLATORREQ(cr)) { error = afs_fsync(avc, 0, cr); } #else /* AFS_SGI61_ENV */ @@ -685,42 +688,43 @@ static int afsrwvp(register struct vcache *avc, #endif /* AFS_SGI61_ENV */ } if (didFakeOpen) { - ObtainWriteLock(&avc->lock,236); + ObtainWriteLock(&avc->lock, 236); afs_FakeClose(avc, cr); /* XXXX For nfs trans XXXX */ ReleaseWriteLock(&avc->lock); } afs_Trace4(afs_iclSetp, CM_TRACE_GRDWR, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, ioflag, - ICL_TYPE_INT32, rw, ICL_TYPE_INT32, error); + ICL_TYPE_INT32, ioflag, ICL_TYPE_INT32, rw, ICL_TYPE_INT32, + error); return (error); } -int afs_xbmap(OSI_VC_ARG(avc), offset, count, flag, cr, bmv, nbmv) - OSI_VC_DECL(avc); - off_t offset; - ssize_t count; - int flag; - struct cred *cr; - struct bmapval *bmv; - int *nbmv; +int +afs_xbmap(OSI_VC_ARG(avc), offset, count, flag, cr, bmv, nbmv) +OSI_VC_DECL(avc); + off_t offset; + ssize_t count; + int flag; + struct cred *cr; + struct bmapval *bmv; + int *nbmv; { - int bsize; /* server's block size in bytes */ + int bsize; /* server's block size in bytes */ off_t off; size_t rem, cnt; OSI_VC_CONVERT(avc) - bsize = AFSBSIZE; + bsize = AFSBSIZE; off = offset % bsize; /* offset into block */ bmv->bn = BTOBBT(offset - off); bmv->offset = bmv->bn; bmv->pboff = off; rem = avc->m.Length - offset; if (rem <= 0) - cnt = 0; /* EOF */ + cnt = 0; /* EOF */ else cnt = MIN(bsize - off, rem); - + /* * It is benign to ignore *nbmv > 1, since it is only for requesting * readahead. @@ -753,7 +757,7 @@ int afs_xbmap(OSI_VC_ARG(avc), offset, count, flag, cr, bmv, nbmv) */ static void afs_strategy(OSI_VC_ARG(avc), bp) - OSI_VC_DECL(avc); +OSI_VC_DECL(avc); struct buf *bp; { uio_t auio; @@ -762,31 +766,31 @@ afs_strategy(OSI_VC_ARG(avc), bp) int error; struct cred *cr; OSI_VC_CONVERT(avc) - vnode_t *vp = (vnode_t *)avc; + vnode_t *vp = (vnode_t *) avc; /* * We can't afford DELWRI buffers for 2 reasons: * 1) Since we can call underlying EFS, we can require a - * buffer to flush a buffer. This leads to 2 potential - * recursions/deadlocks - * a) if all buffers are DELWRI afs buffers, then - * ngeteblk -> bwrite -> afs_strategy -> afs_write -> - * UFS_Write -> efs_write -> ngeteblk .... could - * recurse a long ways! - * b) brelse -> chunkhold which can call dchunkpush - * will look for any DELWRI buffers and call strategy - * on them. This can then end up via UFS_Write - * recursing + * buffer to flush a buffer. This leads to 2 potential + * recursions/deadlocks + * a) if all buffers are DELWRI afs buffers, then + * ngeteblk -> bwrite -> afs_strategy -> afs_write -> + * UFS_Write -> efs_write -> ngeteblk .... could + * recurse a long ways! + * b) brelse -> chunkhold which can call dchunkpush + * will look for any DELWRI buffers and call strategy + * on them. This can then end up via UFS_Write + * recursing * Current hack: - * a) We never do bdwrite(s) on AFS buffers. - * b) We call pdflush with B_ASYNC - * c) in chunkhold where it can set a buffer DELWRI - * we immediatly do a clusterwrite for AFS vp's + * a) We never do bdwrite(s) on AFS buffers. + * b) We call pdflush with B_ASYNC + * c) in chunkhold where it can set a buffer DELWRI + * we immediatly do a clusterwrite for AFS vp's * XXX Alas, 'c' got dropped in 5.1 so its possible to get DELWRI - * buffers if someone has mmaped the file and dirtied it then - * reads/faults it again. - * Instead - wherever we call chunkread/getchunk we check for a - * returned bp with DELWRI set, and write it out immediately + * buffers if someone has mmaped the file and dirtied it then + * reads/faults it again. + * Instead - wherever we call chunkread/getchunk we check for a + * returned bp with DELWRI set, and write it out immediately */ if (CheckLock(&avc->lock) && VN_GET_DBUF(vp)) { printf("WARN: afs_strategy vp=%x, v_dbuf=%x bp=%x\n", vp, @@ -796,8 +800,9 @@ afs_strategy(OSI_VC_ARG(avc), bp) iodone(bp); return; } - if (bp->b_error != 0) - printf("WARNING: afs_strategy3 vp=%x, bp=%x, err=%x\n", vp, bp, bp->b_error); + if (bp->b_error != 0) + printf("WARNING: afs_strategy3 vp=%x, bp=%x, err=%x\n", vp, bp, + bp->b_error); /* * To get credentials somewhat correct (we may be called from bdflush/ @@ -815,7 +820,7 @@ afs_strategy(OSI_VC_ARG(avc), bp) ReleaseReadLock(&avc->lock); return; } - } else if ((avc->states & CWritingUFS) && (bp->b_flags & B_DELWRI)) { + } else if ((avc->states & CWritingUFS) && (bp->b_flags & B_DELWRI)) { bp->b_ref = 3; ReleaseReadLock(&avc->lock); iodone(bp); @@ -864,27 +869,28 @@ afs_strategy(OSI_VC_ARG(avc), bp) } /* ARGSUSED */ -static int afs_seek(OSI_VC_ARG(avc), ooff, noffp) - OSI_VC_DECL(avc); - off_t ooff; - off_t *noffp; +static int +afs_seek(OSI_VC_ARG(avc), ooff, noffp) +OSI_VC_DECL(avc); + off_t ooff; + off_t *noffp; { - return *noffp < 0 ? EINVAL : 0; + return *noffp < 0 ? EINVAL : 0; } #if !defined(AFS_SGI65_ENV) /* Irix 6.5 uses addmap/delmap only for devices. */ /* ARGSUSED */ -static int afs_addmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, - flags, cr) - off_t off; - OSI_VC_DECL(avc); - struct pregion *prp; - addr_t addr; - size_t len; - u_int prot, maxprot; - u_int flags; - struct cred *cr; +static int +afs_addmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, flags, cr) + off_t off; +OSI_VC_DECL(avc); + struct pregion *prp; + addr_t addr; + size_t len; + u_int prot, maxprot; + u_int flags; + struct cred *cr; { OSI_VC_CONVERT(avc) struct vnode *vp = AFSTOV(avc); @@ -896,7 +902,7 @@ static int afs_addmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, AFS_RWLOCK(vp, VRWLOCK_WRITE); if (avc->mapcnt == 0) { /* on first mapping add a open reference */ - ObtainWriteLock(&avc->lock,237); + ObtainWriteLock(&avc->lock, 237); avc->execsOrWriters++; avc->opens++; ReleaseWriteLock(&avc->lock); @@ -906,17 +912,16 @@ static int afs_addmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, return 0; } -/*ARGSUSED*/ -static int afs_delmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, - flags, acred) - off_t off; - OSI_VC_DECL(avc); - struct pregion *prp; - addr_t addr; - size_t len; - u_int prot, maxprot; - u_int flags; - struct cred *acred; + /*ARGSUSED*/ static int +afs_delmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, flags, acred) + off_t off; +OSI_VC_DECL(avc); + struct pregion *prp; + addr_t addr; + size_t len; + u_int prot, maxprot; + u_int flags; + struct cred *acred; { OSI_VC_CONVERT(avc) struct vnode *vp = AFSTOV(avc); @@ -937,9 +942,9 @@ static int afs_delmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, osi_Assert(avc->execsOrWriters > 0); osi_Assert(avc->opens > 0); if (avc->m.LinkCount == 0) { - ObtainWriteLock(&avc->lock,238); + ObtainWriteLock(&avc->lock, 238); AFS_GUNLOCK(); - PTOSSVP(vp, (off_t)0, (off_t)MAXLONG); + PTOSSVP(vp, (off_t) 0, (off_t) MAXLONG); AFS_GLOCK(); ReleaseWriteLock(&avc->lock); } @@ -949,17 +954,18 @@ static int afs_delmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, afs_InitReq(&treq, acred); if (afs_BBusy()) { /* do it yourself if daemons are all busy */ - ObtainWriteLock(&avc->lock,239); + ObtainWriteLock(&avc->lock, 239); code = afs_StoreOnLastReference(avc, &treq); ReleaseWriteLock(&avc->lock); /* BStore does CheckCode so we should also */ /* VNOVNODE is "acceptable" error code from close, since - may happen when deleting a file on another machine while - it is open here. */ + * may happen when deleting a file on another machine while + * it is open here. */ if (code == VNOVNODE) code = 0; if (code) { - afs_StoreWarn(code, avc->fid.Fid.Volume, /* /dev/console */ 1); + afs_StoreWarn(code, avc->fid.Fid.Volume, /* /dev/console */ + 1); } code = afs_CheckCode(code, &treq, 52); AFS_RWUNLOCK(vp, VRWLOCK_WRITE); @@ -968,7 +974,7 @@ static int afs_delmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, /* at least one daemon is idle, so ask it to do the store. * Also, note that we don't lock it any more... */ tb = afs_BQueue(BOP_STORE, avc, 0, 1, acred, - (afs_size_t) acred->cr_uid, 0L, (void *) 0); + (afs_size_t) acred->cr_uid, 0L, (void *)0); /* sleep waiting for the store to start, then retrieve error code */ while ((tb->flags & BUVALID) == 0) { tb->flags |= BUWAIT; @@ -991,25 +997,26 @@ static int afs_delmap(OSI_VC_ARG(avc), off, prp, addr, len, prot, maxprot, * ever having been 'opened' */ #ifdef AFS_SGI65_ENV -static int afs_map(OSI_VC_ARG(avc), off, len, prot, flags, cr, vpp) +static int +afs_map(OSI_VC_ARG(avc), off, len, prot, flags, cr, vpp) off_t off; - OSI_VC_DECL(avc); +OSI_VC_DECL(avc); size_t len; mprot_t prot; u_int flags; struct cred *cr; vnode_t **vpp; #else -static int afs_map(OSI_VC_ARG(avc), off, prp, addrp, len, prot, maxprot, - flags, cr) - off_t off; - OSI_VC_DECL(avc); - struct pregion *prp; - addr_t *addrp; - size_t len; - u_int prot, maxprot; - u_int flags; - struct cred *cr; +static int +afs_map(OSI_VC_ARG(avc), off, prp, addrp, len, prot, maxprot, flags, cr) + off_t off; +OSI_VC_DECL(avc); + struct pregion *prp; + addr_t *addrp; + size_t len; + u_int prot, maxprot; + u_int flags; + struct cred *cr; #endif { OSI_VC_CONVERT(avc) @@ -1020,7 +1027,8 @@ static int afs_map(OSI_VC_ARG(avc), off, prp, addrp, len, prot, maxprot, /* get a validated vcache entry */ afs_InitReq(&treq, cr); error = afs_VerifyVCache(avc, &treq); - if (error) return afs_CheckCode(error, &treq, 53); + if (error) + return afs_CheckCode(error, &treq, 53); osi_FlushPages(avc, cr); /* ensure old pages are gone */ #ifdef AFS_SGI65_ENV @@ -1031,17 +1039,18 @@ static int afs_map(OSI_VC_ARG(avc), off, prp, addrp, len, prot, maxprot, AFS_RWLOCK(vp, VRWLOCK_WRITE); ObtainWriteLock(&avc->lock, 501); if (avc->execsOrWriters > 0) { - avc->execsOrWriters ++; - avc->opens ++; - avc->mapcnt ++; /* count eow's due to mappings. */ + avc->execsOrWriters++; + avc->opens++; + avc->mapcnt++; /* count eow's due to mappings. */ } ReleaseWriteLock(&avc->lock); AFS_RWUNLOCK(vp, VRWLOCK_WRITE); #else AFS_RWLOCK(vp, VRWLOCK_WRITE); AFS_GUNLOCK(); - error = fs_map_subr(vp, (off_t) avc->m.Length, (u_int)avc->m.Mode, off, prp, - *addrp, len, prot, maxprot, flags, cr); + error = + fs_map_subr(vp, (off_t) avc->m.Length, (u_int) avc->m.Mode, off, prp, + *addrp, len, prot, maxprot, flags, cr); AFS_GLOCK(); AFS_RWUNLOCK(vp, VRWLOCK_WRITE); #endif /* AFS_SGI65_ENV */ @@ -1061,17 +1070,17 @@ extern afs_lock_t afs_xdcache; #ifdef AFS_SGI64_ENV int #else -void +void #endif afs_xinactive(OSI_VC_ARG(avc), acred) - OSI_VC_DECL(avc); - struct ucred *acred; +OSI_VC_DECL(avc); + struct ucred *acred; { int s; OSI_VC_CONVERT(avc) - vnode_t *vp = (vnode_t *)avc; - int mapcnt = avc->mapcnt; /* We just clear off this many. */ - + vnode_t *vp = (vnode_t *) avc; + int mapcnt = avc->mapcnt; /* We just clear off this many. */ + AFS_STATCNT(afs_inactive); s = VN_LOCK(vp); @@ -1096,7 +1105,7 @@ afs_xinactive(OSI_VC_ARG(avc), acred) /* In Irix 6.5, the last unmap of a dirty mmap'd file does not * get an explicit vnode op. Instead we only find out at VOP_INACTIVE. */ - if (!afs_rwlock_nowait((vnode_t*)avc, VRWLOCK_WRITE)) { + if (!afs_rwlock_nowait((vnode_t *) avc, VRWLOCK_WRITE)) { return VN_INACTIVE_CACHE; } if (NBObtainWriteLock(&avc->lock, 502)) { @@ -1104,7 +1113,7 @@ afs_xinactive(OSI_VC_ARG(avc), acred) return VN_INACTIVE_CACHE; } if (avc->states & CUnlinked) { - if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) { + if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) { avc->states |= CUnlinkedDel; ReleaseWriteLock(&avc->lock); AFS_RWUNLOCK(vp, VRWLOCK_WRITE); @@ -1136,16 +1145,16 @@ afs_xinactive(OSI_VC_ARG(avc), acred) code = 0; if (code) { if (mapcnt) { - cmn_err(CE_WARN, "AFS: Failed to store FID (%x:%lu.%lu.%lu) in VOP_INACTIVE, error = %d\n", + cmn_err(CE_WARN, + "AFS: Failed to store FID (%x:%lu.%lu.%lu) in VOP_INACTIVE, error = %d\n", (int)(avc->fid.Cell) & 0xffffffff, - avc->fid.Fid.Volume, - avc->fid.Fid.Vnode, avc->fid.Fid.Unique, - code); + avc->fid.Fid.Volume, avc->fid.Fid.Vnode, + avc->fid.Fid.Unique, code); } afs_InvalidateAllSegments(avc); } s = VN_LOCK(vp); - vp->v_count --; + vp->v_count--; code = (vp->v_count == 0); VN_UNLOCK(vp, s); /* If the vnode is now in use by someone else, return early. */ @@ -1158,7 +1167,7 @@ afs_xinactive(OSI_VC_ARG(avc), acred) } #endif - osi_Assert((avc->states & (CCore|CMAPPED)) == 0); + osi_Assert((avc->states & (CCore | CMAPPED)) == 0); if (avc->cred) { crfree(avc->cred); @@ -1173,17 +1182,16 @@ afs_xinactive(OSI_VC_ARG(avc), acred) */ if (avc->m.LinkCount == 0) { AFS_GUNLOCK(); - PTOSSVP(vp, (off_t)0, (off_t)MAXLONG); + PTOSSVP(vp, (off_t) 0, (off_t) MAXLONG); AFS_GLOCK(); } - #ifndef AFS_SGI65_ENV osi_Assert(avc->mapcnt == 0); afs_chkpgoob(&avc->v, btoc(avc->m.Length)); - avc->states &= ~CDirty; /* Give up on store-backs */ + avc->states &= ~CDirty; /* Give up on store-backs */ if (avc->states & CUnlinked) { - if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) { + if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) { avc->states |= CUnlinkedDel; } else { afs_remunlink(avc, 1); /* ignore any return code */ @@ -1199,14 +1207,15 @@ static int afs_reclaim(OSI_VC_DECL(avc), int flag) { #ifdef AFS_SGI64_ENV - /* Get's called via VOP_RELCAIM in afs_FlushVCache to clear repl_vnodeops*/ + /* Get's called via VOP_RELCAIM in afs_FlushVCache to clear repl_vnodeops */ return 0; #else panic("afs_reclaim"); #endif } -void afs_rwlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag) +void +afs_rwlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag) { OSI_VN_CONVERT(vp) struct vcache *avc = VTOAFS(vp); @@ -1221,7 +1230,8 @@ void afs_rwlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag) avc->vc_rwlockid = OSI_GET_LOCKID(); } -void afs_rwunlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag) +void +afs_rwunlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag) { OSI_VN_CONVERT(vp) struct vcache *avc = VTOAFS(vp); @@ -1242,7 +1252,8 @@ void afs_rwunlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag) * does not match the corresponding lock flag. But they may start using this * flag for a real rw lock at some time. */ -int afs_rwlock_nowait(vnode_t *vp, AFS_RWLOCK_T flag) +int +afs_rwlock_nowait(vnode_t * vp, AFS_RWLOCK_T flag) { struct vcache *avc = VTOAFS(vp); @@ -1253,25 +1264,26 @@ int afs_rwlock_nowait(vnode_t *vp, AFS_RWLOCK_T flag) } if (cpsema(&avc->vc_rwlock)) { avc->vc_rwlockid = OSI_GET_LOCKID(); - return 1; + return 1; } return 0; } #if defined(AFS_SGI64_ENV) && defined(CKPT) && !defined(_R5000_CVT_WAR) -int afs_fid2(OSI_VC_DECL(avc), struct fid *fidp) +int +afs_fid2(OSI_VC_DECL(avc), struct fid *fidp) { struct cell *tcell; - afs_fid2_t *afid = (afs_fid2_t*)fidp; + afs_fid2_t *afid = (afs_fid2_t *) fidp; OSI_VC_CONVERT(avc) - osi_Assert(sizeof(fid_t) >= sizeof(afs_fid2_t)); + osi_Assert(sizeof(fid_t) >= sizeof(afs_fid2_t)); afid->af_len = sizeof(afs_fid2_t) - sizeof(afid->af_len); tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); afid->af_cell = tcell->cellIndex & 0xffff; afs_PutCell(tcell, READ_LOCK); - + afid->af_volid = avc->fid.Fid.Volume; afid->af_vno = avc->fid.Fid.Vnode; afid->af_uniq = avc->fid.Fid.Unique; @@ -1286,7 +1298,8 @@ int afs_fid2(OSI_VC_DECL(avc), struct fid *fidp) * * afs_fid2 is used to support the R5000 workarounds (_R5000_CVT_WAR) */ -int afs_fid2(OSI_VC_DECL(avc), struct fid *fidp) +int +afs_fid2(OSI_VC_DECL(avc), struct fid *fidp) { #if defined(_R5000_CVT_WAR) extern int R5000_cvt_war; @@ -1308,7 +1321,7 @@ int afs_fid2(OSI_VC_DECL(avc), struct fid *fidp) * Drop the global lock here, since we may not actually do the call. */ void -afs_chkpgoob(vnode_t *vp, pgno_t pgno) +afs_chkpgoob(vnode_t * vp, pgno_t pgno) { #undef PGDEBUG #ifdef PGDEBUG @@ -1328,485 +1341,542 @@ afs_chkpgoob(vnode_t *vp, pgno_t pgno) #endif #ifdef AFS_SGI64_ENV -int mp_afs_open(bhv_desc_t *bhp, vnode_t **a, mode_t b, struct cred *c) +int +mp_afs_open(bhv_desc_t * bhp, vnode_t ** a, mode_t b, struct cred *c) #else -int mp_afs_open(vnode_t **a, mode_t b, struct cred *c) +int +mp_afs_open(vnode_t ** a, mode_t b, struct cred *c) #endif { - int rv; - AFS_GLOCK(); + int rv; + AFS_GLOCK(); #ifdef AFS_SGI64_ENV - rv = afs_lockedvnodeops.vop_open(bhp, a, b, c); + rv = afs_lockedvnodeops.vop_open(bhp, a, b, c); #else - rv = afs_lockedvnodeops.vop_open(a, b, c); + rv = afs_lockedvnodeops.vop_open(a, b, c); #endif - AFS_GUNLOCK(); - return rv; + AFS_GUNLOCK(); + return rv; } #if defined(AFS_SGI64_ENV) #if defined(AFS_SGI65_ENV) -int mp_afs_close(AFS_MP_VC_ARG (*a), int b, lastclose_t c, struct cred *d) +int +mp_afs_close(AFS_MP_VC_ARG(*a), int b, lastclose_t c, struct cred *d) #else -int mp_afs_close(AFS_MP_VC_ARG (*a), int b, lastclose_t c, off_t d, - struct cred *e, struct flid *f) +int +mp_afs_close(AFS_MP_VC_ARG(*a), int b, lastclose_t c, off_t d, struct cred *e, + struct flid *f) #endif #else -int mp_afs_close(AFS_MP_VC_ARG (*a), int b, lastclose_t c, off_t d, - struct cred *e) +int +mp_afs_close(AFS_MP_VC_ARG(*a), int b, lastclose_t c, off_t d, struct cred *e) #endif { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_close(a, b, c, d + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_close(a, b, c, d #if !defined(AFS_SGI65_ENV) - , e + , e #if defined(AFS_SGI64_ENV) - , f + , f #endif #endif - ); - - AFS_GUNLOCK(); - return rv; + ); + + AFS_GUNLOCK(); + return rv; } #ifdef AFS_SGI64_ENV -int mp_afs_read(AFS_MP_VC_ARG(*a), struct uio *b, int c, struct cred *d, - struct flid *f) +int +mp_afs_read(AFS_MP_VC_ARG(*a), struct uio *b, int c, struct cred *d, + struct flid *f) #else -int mp_afs_read(AFS_MP_VC_ARG(*a), struct uio *b, int c, struct cred *d) +int +mp_afs_read(AFS_MP_VC_ARG(*a), struct uio *b, int c, struct cred *d) #endif { - int rv; - AFS_GLOCK(); + int rv; + AFS_GLOCK(); #ifdef AFS_SGI64_ENV - rv = afs_lockedvnodeops.vop_read(a, b, c, d, f); + rv = afs_lockedvnodeops.vop_read(a, b, c, d, f); #else - rv = afs_lockedvnodeops.vop_read(a, b, c, d); + rv = afs_lockedvnodeops.vop_read(a, b, c, d); #endif - AFS_GUNLOCK(); - return rv; + AFS_GUNLOCK(); + return rv; } #ifdef AFS_SGI64_ENV -int mp_afs_write(AFS_MP_VC_ARG(*a), struct uio *b, int c, struct cred *d, - struct flid *f) +int +mp_afs_write(AFS_MP_VC_ARG(*a), struct uio *b, int c, struct cred *d, + struct flid *f) #else -int mp_afs_write(AFS_MP_VC_ARG(*a), struct uio *b, int c, struct cred *d) +int +mp_afs_write(AFS_MP_VC_ARG(*a), struct uio *b, int c, struct cred *d) #endif { - int rv; - AFS_GLOCK(); + int rv; + AFS_GLOCK(); #ifdef AFS_SGI64_ENV - rv = afs_lockedvnodeops.vop_write(a, b, c, d, f); + rv = afs_lockedvnodeops.vop_write(a, b, c, d, f); #else - rv = afs_lockedvnodeops.vop_write(a, b, c, d); + rv = afs_lockedvnodeops.vop_write(a, b, c, d); #endif - AFS_GUNLOCK(); - return rv; + AFS_GUNLOCK(); + return rv; } -int mp_afs_ioctl(AFS_MP_VC_ARG(*a), int b, void *c, int d, struct cred *e, - int *f +int +mp_afs_ioctl(AFS_MP_VC_ARG(*a), int b, void *c, int d, struct cred *e, int *f #ifdef AFS_SGI65_ENV - , struct vopbd *vbds + , struct vopbd *vbds #endif - ) + ) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_ioctl(a, b, c, d, e, f + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_ioctl(a, b, c, d, e, f #ifdef AFS_SGI65_ENV - , vbds + , vbds #endif - ); - AFS_GUNLOCK(); - return rv; + ); + AFS_GUNLOCK(); + return rv; } -int mp_fs_setfl(AFS_MP_VC_ARG(*a), int b, int c, struct cred *d) +int +mp_fs_setfl(AFS_MP_VC_ARG(*a), int b, int c, struct cred *d) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_setfl(a, b, c, d); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_setfl(a, b, c, d); + AFS_GUNLOCK(); + return rv; } -int mp_afs_getattr(AFS_MP_VC_ARG(*a), struct vattr *b, int c, struct cred *d) + +int +mp_afs_getattr(AFS_MP_VC_ARG(*a), struct vattr *b, int c, struct cred *d) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_getattr(a, b, c, d); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_getattr(a, b, c, d); + AFS_GUNLOCK(); + return rv; } -int mp_afs_setattr(AFS_MP_VC_ARG(*a), struct vattr *b, int c, struct cred *d) + +int +mp_afs_setattr(AFS_MP_VC_ARG(*a), struct vattr *b, int c, struct cred *d) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_setattr(a, b, c, d); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_setattr(a, b, c, d); + AFS_GUNLOCK(); + return rv; } -int mp_afs_access(AFS_MP_VC_ARG(*a), int b, +int +mp_afs_access(AFS_MP_VC_ARG(*a), int b, #ifndef AFS_SGI65_ENV - int c, + int c, #endif - struct cred *d) + struct cred *d) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_access(a, b, + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_access(a, b, #ifndef AFS_SGI65_ENV - c, + c, #endif - d); - AFS_GUNLOCK(); - return rv; + d); + AFS_GUNLOCK(); + return rv; } -int mp_afs_lookup(AFS_MP_VC_ARG(*a), char *b, vnode_t **c, struct pathname *d, - int e, vnode_t *f, struct cred *g) +int +mp_afs_lookup(AFS_MP_VC_ARG(*a), char *b, vnode_t ** c, struct pathname *d, + int e, vnode_t * f, struct cred *g) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_lookup(a, b, c, d, e, f, g); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_lookup(a, b, c, d, e, f, g); + AFS_GUNLOCK(); + return rv; } + #ifdef AFS_SGI64_ENV -int mp_afs_create(AFS_MP_VC_ARG(*a), char *b, struct vattr *c, int d, int e, - vnode_t **f, struct cred *g) +int +mp_afs_create(AFS_MP_VC_ARG(*a), char *b, struct vattr *c, int d, int e, + vnode_t ** f, struct cred *g) #else -int mp_afs_create(AFS_MP_VC_ARG(*a), char *b, struct vattr *c, enum vcexcl d, - int e, vnode_t **f, struct cred *g) +int +mp_afs_create(AFS_MP_VC_ARG(*a), char *b, struct vattr *c, enum vcexcl d, + int e, vnode_t ** f, struct cred *g) #endif { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_create(a, b, c, d, e, f, g); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_create(a, b, c, d, e, f, g); + AFS_GUNLOCK(); + return rv; } -int mp_afs_remove(AFS_MP_VC_ARG(*a), char *b, struct cred *c) + +int +mp_afs_remove(AFS_MP_VC_ARG(*a), char *b, struct cred *c) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_remove(a, b, c); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_remove(a, b, c); + AFS_GUNLOCK(); + return rv; } -int mp_afs_link(AFS_MP_VC_ARG(*a), vnode_t *b, char *c, struct cred *d) + +int +mp_afs_link(AFS_MP_VC_ARG(*a), vnode_t * b, char *c, struct cred *d) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_link(a, b, c, d); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_link(a, b, c, d); + AFS_GUNLOCK(); + return rv; } -int mp_afs_rename(AFS_MP_VC_ARG(*a), char *b, vnode_t *c, char *d, - struct pathname *e, struct cred *f) + +int +mp_afs_rename(AFS_MP_VC_ARG(*a), char *b, vnode_t * c, char *d, + struct pathname *e, struct cred *f) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_rename(a, b, c, d, e, f); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_rename(a, b, c, d, e, f); + AFS_GUNLOCK(); + return rv; } -int mp_afs_mkdir(AFS_MP_VC_ARG(*a), char *b, struct vattr *c, vnode_t **d, - struct cred *e) + +int +mp_afs_mkdir(AFS_MP_VC_ARG(*a), char *b, struct vattr *c, vnode_t ** d, + struct cred *e) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_mkdir(a, b, c, d, e); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_mkdir(a, b, c, d, e); + AFS_GUNLOCK(); + return rv; } -int mp_afs_rmdir(AFS_MP_VC_ARG(*a), char *b, vnode_t *c, struct cred *d) + +int +mp_afs_rmdir(AFS_MP_VC_ARG(*a), char *b, vnode_t * c, struct cred *d) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_rmdir(a, b, c, d); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_rmdir(a, b, c, d); + AFS_GUNLOCK(); + return rv; } -int mp_afs_readdir(AFS_MP_VC_ARG(*a), struct uio *b, struct cred *c, int *d) + +int +mp_afs_readdir(AFS_MP_VC_ARG(*a), struct uio *b, struct cred *c, int *d) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_readdir(a, b, c, d); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_readdir(a, b, c, d); + AFS_GUNLOCK(); + return rv; } -int mp_afs_symlink(AFS_MP_VC_ARG(*a), char *b, struct vattr *c, char *d, - struct cred *e) + +int +mp_afs_symlink(AFS_MP_VC_ARG(*a), char *b, struct vattr *c, char *d, + struct cred *e) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_symlink(a, b, c, d, e); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_symlink(a, b, c, d, e); + AFS_GUNLOCK(); + return rv; } -int mp_afs_readlink(AFS_MP_VC_ARG(*a), struct uio *b, struct cred *c) + +int +mp_afs_readlink(AFS_MP_VC_ARG(*a), struct uio *b, struct cred *c) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_readlink(a, b, c); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_readlink(a, b, c); + AFS_GUNLOCK(); + return rv; } -int mp_afs_fsync(AFS_MP_VC_ARG(*a), int b, struct cred *c +int +mp_afs_fsync(AFS_MP_VC_ARG(*a), int b, struct cred *c #ifdef AFS_SGI65_ENV - , off_t start, off_t stop + , off_t start, off_t stop #endif - ) + ) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_fsync(a, b, c + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_fsync(a, b, c #ifdef AFS_SGI65_ENV - , start, stop + , start, stop #endif - ); - AFS_GUNLOCK(); - return rv; + ); + AFS_GUNLOCK(); + return rv; } -void mp_afs_inactive(AFS_MP_VC_ARG(*a), struct cred *b) +void +mp_afs_inactive(AFS_MP_VC_ARG(*a), struct cred *b) { - AFS_GLOCK(); - afs_lockedvnodeops.vop_inactive(a, b); - AFS_GUNLOCK(); - return; + AFS_GLOCK(); + afs_lockedvnodeops.vop_inactive(a, b); + AFS_GUNLOCK(); + return; } -int mp_afs_fid(AFS_MP_VC_ARG(*a), struct fid **b) + +int +mp_afs_fid(AFS_MP_VC_ARG(*a), struct fid **b) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_fid(a, b); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_fid(a, b); + AFS_GUNLOCK(); + return rv; } -int mp_afs_fid2(AFS_MP_VC_ARG(*a), struct fid *b) + +int +mp_afs_fid2(AFS_MP_VC_ARG(*a), struct fid *b) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_fid2(a, b); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_fid2(a, b); + AFS_GUNLOCK(); + return rv; } -void mp_afs_rwlock(AFS_MP_VC_ARG(*a), AFS_RWLOCK_T b) + +void +mp_afs_rwlock(AFS_MP_VC_ARG(*a), AFS_RWLOCK_T b) { - AFS_GLOCK(); - afs_rwlock(a, VRWLOCK_WRITE); - AFS_GUNLOCK(); + AFS_GLOCK(); + afs_rwlock(a, VRWLOCK_WRITE); + AFS_GUNLOCK(); } -void mp_afs_rwunlock(AFS_MP_VC_ARG(*a), AFS_RWLOCK_T b) + +void +mp_afs_rwunlock(AFS_MP_VC_ARG(*a), AFS_RWLOCK_T b) { - AFS_GLOCK(); - afs_rwunlock(a, VRWLOCK_WRITE); - AFS_GUNLOCK(); + AFS_GLOCK(); + afs_rwunlock(a, VRWLOCK_WRITE); + AFS_GUNLOCK(); } -int mp_afs_seek(AFS_MP_VC_ARG(*a), off_t b, off_t*c) + +int +mp_afs_seek(AFS_MP_VC_ARG(*a), off_t b, off_t * c) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_seek(a, b, c); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_seek(a, b, c); + AFS_GUNLOCK(); + return rv; } -int mp_fs_cmp(AFS_MP_VC_ARG(*a), vnode_t *b) + +int +mp_fs_cmp(AFS_MP_VC_ARG(*a), vnode_t * b) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_cmp(a, b); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_cmp(a, b); + AFS_GUNLOCK(); + return rv; } -int mp_afs_frlock(AFS_MP_VC_ARG(*a), int b, struct flock *c, int d, off_t e, +int +mp_afs_frlock(AFS_MP_VC_ARG(*a), int b, struct flock *c, int d, off_t e, #ifdef AFS_SGI65_ENV - vrwlock_t vrwlock, + vrwlock_t vrwlock, #endif - struct cred *f) + struct cred *f) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_frlock(a, b, c, d, e, + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_frlock(a, b, c, d, e, #ifdef AFS_SGI65_ENV - vrwlock, + vrwlock, #endif - f); - AFS_GUNLOCK(); - return rv; + f); + AFS_GUNLOCK(); + return rv; } -int mp_afs_realvp(AFS_MP_VC_ARG(*a), vnode_t **b) +int +mp_afs_realvp(AFS_MP_VC_ARG(*a), vnode_t ** b) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_realvp(a, b); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_realvp(a, b); + AFS_GUNLOCK(); + return rv; } -int mp_afs_bmap(AFS_MP_VC_ARG(*a), off_t b, ssize_t c, int d, struct cred *e, - struct bmapval *f, int *g) + +int +mp_afs_bmap(AFS_MP_VC_ARG(*a), off_t b, ssize_t c, int d, struct cred *e, + struct bmapval *f, int *g) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_bmap(a, b, c, d, e, f, g); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_bmap(a, b, c, d, e, f, g); + AFS_GUNLOCK(); + return rv; } -void mp_afs_strategy(AFS_MP_VC_ARG(*a), struct buf *b) +void +mp_afs_strategy(AFS_MP_VC_ARG(*a), struct buf *b) { - int rv; - AFS_GLOCK(); - afs_lockedvnodeops.vop_strategy(a, b); - AFS_GUNLOCK(); - return; + int rv; + AFS_GLOCK(); + afs_lockedvnodeops.vop_strategy(a, b); + AFS_GUNLOCK(); + return; } #ifdef AFS_SGI65_ENV -int mp_afs_map(AFS_MP_VC_ARG(*a), off_t b, size_t c, mprot_t d, - u_int e, struct cred *f, vnode_t **g) +int +mp_afs_map(AFS_MP_VC_ARG(*a), off_t b, size_t c, mprot_t d, u_int e, + struct cred *f, vnode_t ** g) #else -int mp_afs_map(AFS_MP_VC_ARG(*a), off_t b, struct pregion *c, char ** d, - size_t e, u_int f, u_int g, u_int h, struct cred *i) +int +mp_afs_map(AFS_MP_VC_ARG(*a), off_t b, struct pregion *c, char **d, size_t e, + u_int f, u_int g, u_int h, struct cred *i) #endif { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_map(a, b, c, d, e, f, g + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_map(a, b, c, d, e, f, g #ifndef AFS_SGI65_ENV - , h, i + , h, i #endif - ); - AFS_GUNLOCK(); - return rv; + ); + AFS_GUNLOCK(); + return rv; } #ifndef AFS_SGI65_ENV /* As of Irix 6.5, addmap and delmap are only for devices */ -int mp_afs_addmap(AFS_MP_VC_ARG(*a), off_t b, struct pregion *c, addr_t d, - size_t e, u_int f, u_int g, u_int h, struct cred *i) +int +mp_afs_addmap(AFS_MP_VC_ARG(*a), off_t b, struct pregion *c, addr_t d, + size_t e, u_int f, u_int g, u_int h, struct cred *i) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_addmap(a, b, c, d, e, f, g, h, i); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_addmap(a, b, c, d, e, f, g, h, i); + AFS_GUNLOCK(); + return rv; } -int mp_afs_delmap(AFS_MP_VC_ARG(*a), off_t b, struct pregion *c, addr_t d, - size_t e, u_int f, u_int g, u_int h, struct cred *i) +int +mp_afs_delmap(AFS_MP_VC_ARG(*a), off_t b, struct pregion *c, addr_t d, + size_t e, u_int f, u_int g, u_int h, struct cred *i) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_delmap(a, b, c, d, e, f, g, h, i); - AFS_GUNLOCK(); - return rv; + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_delmap(a, b, c, d, e, f, g, h, i); + AFS_GUNLOCK(); + return rv; } #endif /* ! AFS_SGI65_ENV */ -int mp_fs_poll(AFS_MP_VC_ARG(*a), short b, int c, short *d, - struct pollhead **e +int +mp_fs_poll(AFS_MP_VC_ARG(*a), short b, int c, short *d, struct pollhead **e #ifdef AFS_SGI65_ENV - , unsigned int *f + , unsigned int *f #endif - ) + ) { - int rv; - AFS_GLOCK(); - rv = afs_lockedvnodeops.vop_poll(a, b, c, d, e + int rv; + AFS_GLOCK(); + rv = afs_lockedvnodeops.vop_poll(a, b, c, d, e #ifdef AFS_SGI65_ENV - , f + , f #endif - ); - AFS_GUNLOCK(); - return rv; + ); + AFS_GUNLOCK(); + return rv; } struct vnodeops Afs_vnodeops = { #ifdef AFS_SGI64_ENV #ifdef AFS_SGI65_ENV - BHV_IDENTITY_INIT_POSITION(VNODE_POSITION_BASE), + BHV_IDENTITY_INIT_POSITION(VNODE_POSITION_BASE), #else - VNODE_POSITION_BASE, -#endif -#endif - mp_afs_open, - mp_afs_close, - mp_afs_read, - mp_afs_write, - mp_afs_ioctl, - mp_fs_setfl, - mp_afs_getattr, - mp_afs_setattr, - mp_afs_access, - mp_afs_lookup, - mp_afs_create, - mp_afs_remove, - mp_afs_link, - mp_afs_rename, - mp_afs_mkdir, - mp_afs_rmdir, - mp_afs_readdir, - mp_afs_symlink, - mp_afs_readlink, - mp_afs_fsync, - mp_afs_inactive, - mp_afs_fid, - mp_afs_fid2, - mp_afs_rwlock, - mp_afs_rwunlock, - mp_afs_seek, - mp_fs_cmp, - mp_afs_frlock, - fs_nosys, /* realvp */ - mp_afs_bmap, - mp_afs_strategy, - mp_afs_map, + VNODE_POSITION_BASE, +#endif +#endif + mp_afs_open, + mp_afs_close, + mp_afs_read, + mp_afs_write, + mp_afs_ioctl, + mp_fs_setfl, + mp_afs_getattr, + mp_afs_setattr, + mp_afs_access, + mp_afs_lookup, + mp_afs_create, + mp_afs_remove, + mp_afs_link, + mp_afs_rename, + mp_afs_mkdir, + mp_afs_rmdir, + mp_afs_readdir, + mp_afs_symlink, + mp_afs_readlink, + mp_afs_fsync, + mp_afs_inactive, + mp_afs_fid, + mp_afs_fid2, + mp_afs_rwlock, + mp_afs_rwunlock, + mp_afs_seek, + mp_fs_cmp, + mp_afs_frlock, + fs_nosys, /* realvp */ + mp_afs_bmap, + mp_afs_strategy, + mp_afs_map, #ifdef AFS_SGI65_ENV - fs_noerr, /* addmap - devices only */ - fs_noerr, /* delmap - devices only */ + fs_noerr, /* addmap - devices only */ + fs_noerr, /* delmap - devices only */ #else - mp_afs_addmap, - mp_afs_delmap, -#endif - mp_fs_poll, /* poll */ - fs_nosys, /* dump */ - fs_pathconf, - fs_nosys, /* allocstore */ - fs_nosys, /* fcntl */ - afs_reclaim, /* reclaim */ - fs_nosys, /* attr_get */ - fs_nosys, /* attr_set */ - fs_nosys, /* attr_remove */ - fs_nosys, /* attr_list */ + mp_afs_addmap, + mp_afs_delmap, +#endif + mp_fs_poll, /* poll */ + fs_nosys, /* dump */ + fs_pathconf, + fs_nosys, /* allocstore */ + fs_nosys, /* fcntl */ + afs_reclaim, /* reclaim */ + fs_nosys, /* attr_get */ + fs_nosys, /* attr_set */ + fs_nosys, /* attr_remove */ + fs_nosys, /* attr_list */ #ifdef AFS_SGI64_ENV #ifdef AFS_SGI65_ENV - fs_cover, - (vop_link_removed_t)fs_noval, - fs_vnode_change, - fs_tosspages, - fs_flushinval_pages, - fs_flush_pages, - fs_invalfree_pages, - fs_pages_sethole, - (vop_commit_t)fs_nosys, - (vop_readbuf_t)fs_nosys, - fs_strgetmsg, - fs_strputmsg, + fs_cover, + (vop_link_removed_t) fs_noval, + fs_vnode_change, + fs_tosspages, + fs_flushinval_pages, + fs_flush_pages, + fs_invalfree_pages, + fs_pages_sethole, + (vop_commit_t) fs_nosys, + (vop_readbuf_t) fs_nosys, + fs_strgetmsg, + fs_strputmsg, #else - fs_mount, + fs_mount, #endif #endif }; @@ -1823,15 +1893,16 @@ struct vnodeops *afs_ops = &Afs_vnodeops; int afs_CacheFSType = -1; vnodeops_t *afs_efs_vnodeopsp; vnodeops_t *afs_xfs_vnodeopsp; -vnode_t * (*afs_IGetVnode)(ino_t); +vnode_t *(*afs_IGetVnode) (ino_t); -extern vnode_t *afs_EFSIGetVnode(ino_t); /* defined in osi_file.c */ -extern vnode_t *afs_XFSIGetVnode(ino_t); /* defined in osi_file.c */ +extern vnode_t *afs_EFSIGetVnode(ino_t); /* defined in osi_file.c */ +extern vnode_t *afs_XFSIGetVnode(ino_t); /* defined in osi_file.c */ -extern afs_lock_t afs_xosi; /* lock is for tvattr */ +extern afs_lock_t afs_xosi; /* lock is for tvattr */ /* Initialize the cache operations. Called while initializing cache files. */ -void afs_InitDualFSCacheOps(struct vnode *vp) +void +afs_InitDualFSCacheOps(struct vnode *vp) { static int inited = 0; struct vfssw *swp; @@ -1845,8 +1916,8 @@ void afs_InitDualFSCacheOps(struct vnode *vp) #ifdef AFS_SGI_EFS_IOPS_ENV swp = vfs_getvfssw("efs"); if (swp) { - afs_efs_vnodeopsp = swp->vsw_vnodeops; - if(vp && vp->v_op == afs_efs_vnodeopsp) { + afs_efs_vnodeopsp = swp->vsw_vnodeops; + if (vp && vp->v_op == afs_efs_vnodeopsp) { afs_CacheFSType = AFS_SGI_EFS_CACHE; afs_IGetVnode = afs_EFSIGetVnode; found = 1; @@ -1858,7 +1929,7 @@ void afs_InitDualFSCacheOps(struct vnode *vp) if (swp) { afs_xfs_vnodeopsp = swp->vsw_vnodeops; if (!found) { - if (vp &&vp->v_op == afs_xfs_vnodeopsp) { + if (vp && vp->v_op == afs_xfs_vnodeopsp) { afs_CacheFSType = AFS_SGI_XFS_CACHE; afs_IGetVnode = afs_XFSIGetVnode; found = 1; @@ -1866,18 +1937,19 @@ void afs_InitDualFSCacheOps(struct vnode *vp) } } - if (vp && !found) + if (vp && !found) osi_Panic("osi_InitCacheFSType: Can't find fstype for vnode 0x%llx\n", vp); } -ino_t VnodeToIno(vnode_t *vp) +ino_t +VnodeToIno(vnode_t * vp) { int code; struct vattr vattr; - MObtainWriteLock(&afs_xosi,579); - vattr.va_mask = AT_FSID|AT_NODEID; /* quick return using this mask. */ + MObtainWriteLock(&afs_xosi, 579); + vattr.va_mask = AT_FSID | AT_NODEID; /* quick return using this mask. */ AFS_GUNLOCK(); AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code); AFS_GLOCK(); @@ -1888,13 +1960,14 @@ ino_t VnodeToIno(vnode_t *vp) return vattr.va_nodeid; } -dev_t VnodeToDev(vnode_t *vp) +dev_t +VnodeToDev(vnode_t * vp) { int code; struct vattr vattr; - MObtainWriteLock(&afs_xosi,580); - vattr.va_mask = AT_FSID|AT_NODEID; /* quick return using this mask. */ + MObtainWriteLock(&afs_xosi, 580); + vattr.va_mask = AT_FSID | AT_NODEID; /* quick return using this mask. */ AFS_GUNLOCK(); AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code); AFS_GLOCK(); @@ -1902,15 +1975,16 @@ dev_t VnodeToDev(vnode_t *vp) osi_Panic("VnodeToDev"); } MReleaseWriteLock(&afs_xosi); - return (dev_t)vattr.va_fsid; + return (dev_t) vattr.va_fsid; } -off_t VnodeToSize(vnode_t *vp) +off_t +VnodeToSize(vnode_t * vp) { int code; struct vattr vattr; - MObtainWriteLock(&afs_xosi,581); + MObtainWriteLock(&afs_xosi, 581); vattr.va_mask = AT_SIZE; AFS_GUNLOCK(); AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code); diff --git a/src/afs/LINUX/osi_alloc.c b/src/afs/LINUX/osi_alloc.c index 0e30d67d3..1c0525f28 100644 --- a/src/afs/LINUX/osi_alloc.c +++ b/src/afs/LINUX/osi_alloc.c @@ -14,7 +14,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" @@ -24,13 +25,13 @@ RCSID("$Header$"); #include "afs_atomlist.h" #include "afs_lhash.h" -#define MAX_KMALLOC_SIZE PAGE_SIZE /* Max we should alloc with kmalloc */ -#define MAX_BUCKET_LEN 30 /* max. no. of entries per buckets we expect to see */ -#define STAT_INTERVAL 8192 /* we collect stats once every STAT_INTERVAL allocs*/ +#define MAX_KMALLOC_SIZE PAGE_SIZE /* Max we should alloc with kmalloc */ +#define MAX_BUCKET_LEN 30 /* max. no. of entries per buckets we expect to see */ +#define STAT_INTERVAL 8192 /* we collect stats once every STAT_INTERVAL allocs */ /* types of alloc */ -#define KM_TYPE 1 /* kmalloc */ -#define VM_TYPE 2 /* vmalloc */ +#define KM_TYPE 1 /* kmalloc */ +#define VM_TYPE 2 /* vmalloc */ struct osi_linux_mem { void *chunk; @@ -41,30 +42,31 @@ struct osi_linux_mem { #define MEMADDR(A) (void *)((unsigned long)(A) & (~0x3)) /* globals */ -afs_atomlist *al_mem_pool; /* pool of osi_linux_mem structures */ -afs_lhash *lh_mem_htab; /* mem hash table */ -unsigned int allocator_init = 0; /* has the allocator been initialized? */ +afs_atomlist *al_mem_pool; /* pool of osi_linux_mem structures */ +afs_lhash *lh_mem_htab; /* mem hash table */ +unsigned int allocator_init = 0; /* has the allocator been initialized? */ unsigned int afs_linux_cur_allocs = 0; unsigned int afs_linux_total_allocs = 0; -unsigned int afs_linux_hash_verify_count = 0; /* used by hash_verify */ -struct afs_lhash_stat afs_linux_lsb; /* hash table statistics */ -unsigned int afs_linux_hash_bucket_dist[MAX_BUCKET_LEN]; /* bucket population distribution in our hash table */ +unsigned int afs_linux_hash_verify_count = 0; /* used by hash_verify */ +struct afs_lhash_stat afs_linux_lsb; /* hash table statistics */ +unsigned int afs_linux_hash_bucket_dist[MAX_BUCKET_LEN]; /* bucket population distribution in our hash table */ #if defined(AFS_LINUX24_ENV) #include "h/vmalloc.h" #else /* externs : can we do this in a better way. Including vmalloc.h causes other * problems.*/ -extern void vfree(void * addr); +extern void vfree(void *addr); extern void *vmalloc(unsigned long size); #endif /* Allocator support functions (static) */ -static int hash_equal(const void *a, const void *b) +static int +hash_equal(const void *a, const void *b) { - return ( MEMADDR(((struct osi_linux_mem *)a)->chunk) == - MEMADDR(((struct osi_linux_mem *)b)->chunk) ); + return (MEMADDR(((struct osi_linux_mem *)a)->chunk) == + MEMADDR(((struct osi_linux_mem *)b)->chunk)); } @@ -76,30 +78,30 @@ static int hash_equal(const void *a, const void *b) * returns NULL if we failed to allocate memory. * or pointer to memory if we succeeded. */ -static void *linux_alloc(unsigned int asize, int drop_glock) +static void * +linux_alloc(unsigned int asize, int drop_glock) { void *new = NULL; int max_retry = 10; int haveGlock = ISAFS_GLOCK(); /* if we can use kmalloc use it to allocate the required memory. */ - while(!new && max_retry) - { - if (asize <= MAX_KMALLOC_SIZE) { - new = (void *)(unsigned long)kmalloc(asize, + while (!new && max_retry) { + if (asize <= MAX_KMALLOC_SIZE) { + new = (void *)(unsigned long)kmalloc(asize, #ifdef GFP_NOFS - GFP_NOFS + GFP_NOFS #else - GFP_KERNEL + GFP_KERNEL #endif - ); - if (new) /* piggy back alloc type */ - (unsigned long)new |= KM_TYPE; - } else { - new = (void *)vmalloc(asize); - if (new) /* piggy back alloc type */ - (unsigned long)new |= VM_TYPE; - } + ); + if (new) /* piggy back alloc type */ + (unsigned long)new |= KM_TYPE; + } else { + new = (void *)vmalloc(asize); + if (new) /* piggy back alloc type */ + (unsigned long)new |= VM_TYPE; + } if (!new) { #ifdef set_current_state @@ -107,16 +109,18 @@ static void *linux_alloc(unsigned int asize, int drop_glock) #else current->state = TASK_INTERRUPTIBLE; #endif - if (drop_glock && haveGlock) AFS_GUNLOCK(); + if (drop_glock && haveGlock) + AFS_GUNLOCK(); schedule_timeout(HZ); - if (drop_glock && haveGlock) AFS_GLOCK(); + if (drop_glock && haveGlock) + AFS_GLOCK(); #ifdef set_current_state - set_current_state(TASK_RUNNING); + set_current_state(TASK_RUNNING); #else - current->state = TASK_RUNNING; + current->state = TASK_RUNNING; #endif - --max_retry; - } + --max_retry; + } } if (new) memset(MEMADDR(new), 0, asize); @@ -124,23 +128,24 @@ static void *linux_alloc(unsigned int asize, int drop_glock) return new; } -static void linux_free(void *p) +static void +linux_free(void *p) { - + /* mask out the type information from the pointer and - * use the appropriate free routine to free the chunk. + * use the appropriate free routine to free the chunk. */ - switch(MEMTYPE(p)) { - case KM_TYPE: - kfree(MEMADDR(p)); - break; - case VM_TYPE: - vfree(MEMADDR(p)); - break; - default: - printf("afs_osi_Free: Asked to free unknown type %d at 0x%x\n", - MEMTYPE(p), MEMADDR(p)); - break; + switch (MEMTYPE(p)) { + case KM_TYPE: + kfree(MEMADDR(p)); + break; + case VM_TYPE: + vfree(MEMADDR(p)); + break; + default: + printf("afs_osi_Free: Asked to free unknown type %d at 0x%x\n", + MEMTYPE(p), MEMADDR(p)); + break; } } @@ -152,12 +157,13 @@ static void linux_free(void *p) */ #define HASH_CONST 32786 #define HASH_PRIME 79367 -static unsigned hash_chunk(void *p) +static unsigned +hash_chunk(void *p) { unsigned int key; key = (unsigned int)(long)p >> 2; - key = (key * HASH_CONST)%HASH_PRIME; + key = (key * HASH_CONST) % HASH_PRIME; return key; } @@ -190,23 +196,30 @@ hash_verify(size_t index, unsigned key, void *data) memtype = MEMTYPE(lmp->chunk); #if defined(AFS_SPARC64_LINUX24_ENV) || defined(AFS_I386_UMLINUX20_ENV) if ((memtype == KM_TYPE) && (!VALID_PAGE(virt_to_page(lmp->chunk)))) { - printf("osi_linux_verify_alloced_memory: address 0x%x outside range, index=%d, key=%d\n", lmp->chunk, index, key); + printf + ("osi_linux_verify_alloced_memory: address 0x%x outside range, index=%d, key=%d\n", + lmp->chunk, index, key); } #else if ((memtype == KM_TYPE) && (AFS_LINUX_MAP_NR(lmp->chunk) > max_mapnr)) { - printf("osi_linux_verify_alloced_memory: address 0x%x outside range, index=%d, key=%d\n", lmp->chunk, index, key); + printf + ("osi_linux_verify_alloced_memory: address 0x%x outside range, index=%d, key=%d\n", + lmp->chunk, index, key); } #endif - + if (memtype != KM_TYPE && memtype != VM_TYPE) { - printf("osi_linux_verify_alloced_memory: unknown type %d at 0x%x, index=%d\n", memtype, lmp->chunk, index); + printf + ("osi_linux_verify_alloced_memory: unknown type %d at 0x%x, index=%d\n", + memtype, lmp->chunk, index); } afs_linux_hash_verify_count++; } /* local_free() : wrapper for vfree(), to deal with incompatible protoypes */ -static void local_free(void *p, size_t n) +static void +local_free(void *p, size_t n) { vfree(p); } @@ -218,57 +231,62 @@ static void local_free(void *p, size_t n) * 0 - failure * 1 - success */ -static int linux_alloc_init() +static int +linux_alloc_init() { /* initiate our pool of osi_linux_mem structs */ - al_mem_pool = afs_atomlist_create(sizeof(struct osi_linux_mem), - sizeof(long)*1024, (void *)vmalloc, - local_free); + al_mem_pool = + afs_atomlist_create(sizeof(struct osi_linux_mem), sizeof(long) * 1024, + (void *)vmalloc, local_free); if (!al_mem_pool) { - printf("afs_osi_Alloc: Error in initialization(atomlist_create)\n"); - return 0; + printf("afs_osi_Alloc: Error in initialization(atomlist_create)\n"); + return 0; } /* initialize the hash table to hold references to alloc'ed chunks */ lh_mem_htab = afs_lhash_create(hash_equal, (void *)vmalloc, local_free); if (!lh_mem_htab) { - printf("afs_osi_Alloc: Error in initialization(lhash_create)\n"); - return 0; + printf("afs_osi_Alloc: Error in initialization(lhash_create)\n"); + return 0; } - + return 1; - + } /* hash_bucket_stat() : Counts the no. of elements in each bucket and * stores results in our bucket stats vector. */ static unsigned int cur_bucket, cur_bucket_len; -static void hash_bucket_stat(size_t index, unsigned key, void *data) +static void +hash_bucket_stat(size_t index, unsigned key, void *data) { - if (index == cur_bucket) { + if (index == cur_bucket) { /* while still on the same bucket, inc len & return */ cur_bucket_len++; return; - } - else { /* if we're on the next bucket, store the distribution */ + } else { /* if we're on the next bucket, store the distribution */ if (cur_bucket_len < MAX_BUCKET_LEN) afs_linux_hash_bucket_dist[cur_bucket_len]++; else - printf("afs_get_hash_stats: Warning! exceeded max bucket len %d\n", cur_bucket_len); + printf + ("afs_get_hash_stats: Warning! exceeded max bucket len %d\n", + cur_bucket_len); cur_bucket = index; cur_bucket_len = 1; } } + /* get_hash_stats() : get hash table statistics */ -static void get_hash_stats() +static void +get_hash_stats() { int i; afs_lhash_stat(lh_mem_htab, &afs_linux_lsb); /* clear out the bucket stat vector */ - for(i=0;ichunk); /* this contains the piggybacked type info*/ - afs_atomlist_put(al_mem_pool, lmp); /* return osi_linux_mem struct to pool*/ - afs_linux_cur_allocs--; - } - else { - printf("osi_linux_free: failed to remove chunk from hashtable\n"); + if ((lmp = + (struct osi_linux_mem *)afs_lhash_remove(lh_mem_htab, + hash_chunk(addr), &lmem))) { + linux_free(lmp->chunk); /* this contains the piggybacked type info */ + afs_atomlist_put(al_mem_pool, lmp); /* return osi_linux_mem struct to pool */ + afs_linux_cur_allocs--; + } else { + printf("osi_linux_free: failed to remove chunk from hashtable\n"); } up(&afs_linux_alloc_sem); @@ -364,7 +385,8 @@ void osi_linux_free(void *addr) /* osi_linux_free_afs_memory() - free all chunks of memory allocated. */ -void osi_linux_free_afs_memory(void) +void +osi_linux_free_afs_memory(void) { down(&afs_linux_alloc_sem); @@ -379,20 +401,21 @@ void osi_linux_free_afs_memory(void) /* free the hashlist. */ afs_lhash_destroy(lh_mem_htab); - + /* change the state so that the allocator is now uninitialized. */ allocator_init = 0; } - up(&afs_linux_alloc_sem); + up(&afs_linux_alloc_sem); } /* osi_linux_verify_alloced_memory(): verify all chunks of alloced memory in * our hash table. */ -void osi_linux_verify_alloced_memory() +void +osi_linux_verify_alloced_memory() { down(&afs_linux_alloc_sem); - + /* count of times hash_verify was called. reset it to 0 before iteration */ afs_linux_hash_verify_count = 0; @@ -401,10 +424,11 @@ void osi_linux_verify_alloced_memory() if (afs_linux_hash_verify_count != afs_linux_cur_allocs) { /* hmm, some pieces of memory are missing. */ - printf("osi_linux_verify_alloced_memory: %d chunks of memory are not accounted for during verify!\n", afs_linux_hash_verify_count - afs_linux_cur_allocs); + printf + ("osi_linux_verify_alloced_memory: %d chunks of memory are not accounted for during verify!\n", + afs_linux_hash_verify_count - afs_linux_cur_allocs); } up(&afs_linux_alloc_sem); return; } - diff --git a/src/afs/LINUX/osi_cred.c b/src/afs/LINUX/osi_cred.c index 087a49d58..cfa0fac54 100644 --- a/src/afs/LINUX/osi_cred.c +++ b/src/afs/LINUX/osi_cred.c @@ -14,13 +14,14 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" /* Setup a pool for creds. Allocate several at a time. */ -#define CRED_ALLOC_STEP 29 /* at 140 bytes/cred = 4060 bytes. */ +#define CRED_ALLOC_STEP 29 /* at 140 bytes/cred = 4060 bytes. */ static cred_t *cred_pool = NULL; @@ -39,7 +40,8 @@ static struct semaphore linux_cred_pool_lock = MUTEX; #define CRED_LOCK() down(&linux_cred_pool_lock) #define CRED_UNLOCK() up(&linux_cred_pool_lock) -cred_t *crget(void) +cred_t * +crget(void) { cred_t *tmp; int i; @@ -47,16 +49,16 @@ cred_t *crget(void) CRED_LOCK(); if (!cred_pool) { cred_allocs++; - cred_pool = (cred_t*)osi_Alloc(CRED_ALLOC_STEP * sizeof(cred_t)); + cred_pool = (cred_t *) osi_Alloc(CRED_ALLOC_STEP * sizeof(cred_t)); if (!cred_pool) osi_Panic("crget: No more memory for creds!\n"); - - for (i=0; i < CRED_ALLOC_STEP-1; i++) - cred_pool[i].cr_ref = (long)&cred_pool[i+1]; + + for (i = 0; i < CRED_ALLOC_STEP - 1; i++) + cred_pool[i].cr_ref = (long)&cred_pool[i + 1]; cred_pool[i].cr_ref = 0; } tmp = cred_pool; - cred_pool = (cred_t*)tmp->cr_ref; + cred_pool = (cred_t *) tmp->cr_ref; ncreds_inuse++; CRED_UNLOCK(); @@ -65,7 +67,8 @@ cred_t *crget(void) return tmp; } -void crfree(cred_t *cr) +void +crfree(cred_t * cr) { if (cr->cr_ref > 1) { cr->cr_ref--; @@ -76,12 +79,13 @@ void crfree(cred_t *cr) cr->cr_ref = (long)cred_pool; cred_pool = cr; CRED_UNLOCK(); - ncreds_inuse --; + ncreds_inuse--; } /* Return a duplicate of the cred. */ -cred_t *crdup(cred_t *cr) +cred_t * +crdup(cred_t * cr) { cred_t *tmp = crget(); *tmp = *cr; @@ -89,7 +93,8 @@ cred_t *crdup(cred_t *cr) return tmp; } -cred_t *crref(void) +cred_t * +crref(void) { cred_t *cr = crget(); cr->cr_uid = current->fsuid; @@ -103,7 +108,8 @@ cred_t *crref(void) /* Set the cred info into the current task */ -void crset(cred_t *cr) +void +crset(cred_t * cr) { current->fsuid = cr->cr_uid; current->uid = cr->cr_ruid; diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 73d2316d5..d7e5f62e2 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -10,21 +10,23 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #include "h/smp_lock.h" -int afs_osicred_initialized=0; -struct AFS_UCRED afs_osi_cred; +int afs_osicred_initialized = 0; +struct AFS_UCRED afs_osi_cred; afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct super_block *afs_cacheSBp; -void *osi_UFSOpen(afs_int32 ainode) +void * +osi_UFSOpen(afs_int32 ainode) { struct inode *ip; register struct osi_file *afile = NULL; @@ -34,7 +36,7 @@ void *osi_UFSOpen(afs_int32 ainode) struct inode *tip = NULL; struct file *filp = NULL; AFS_STATCNT(osi_UFSOpen); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) { + if (cacheDiskType != AFS_FCACHE_TYPE_UFS) { osi_Panic("UFSOpen called for non-UFS cache\n"); } if (!afs_osicred_initialized) { @@ -43,20 +45,20 @@ void *osi_UFSOpen(afs_int32 ainode) crhold(&afs_osi_cred); /* don't let it evaporate, since it is static */ afs_osicred_initialized = 1; } - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); if (!afile) { osi_Panic("osi_UFSOpen: Failed to allocate %d bytes for osi_file.\n", - sizeof(struct osi_file)); + sizeof(struct osi_file)); } memset(afile, 0, sizeof(struct osi_file)); filp = &afile->file; filp->f_dentry = &afile->dentry; - tip = iget(afs_cacheSBp, (u_long)ainode); + tip = iget(afs_cacheSBp, (u_long) ainode); if (!tip) osi_Panic("Can't get inode %d\n", ainode); FILE_INODE(filp) = tip; - tip->i_flags |= MS_NOATIME; /* Disable updating access times. */ + tip->i_flags |= MS_NOATIME; /* Disable updating access times. */ filp->f_flags = O_RDWR; #if defined(AFS_LINUX24_ENV) filp->f_op = fops_get(tip->i_fop); @@ -70,16 +72,17 @@ void *osi_UFSOpen(afs_int32 ainode) afile->size = tip->i_size; AFS_GLOCK(); afile->offset = 0; - afile->proc = (int (*)()) 0; - afile->inum = ainode; /* for hint validity checking */ + afile->proc = (int (*)())0; + afile->inum = ainode; /* for hint validity checking */ return (void *)afile; } -int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) +int +afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) { register afs_int32 code; AFS_STATCNT(osi_Stat); - MObtainWriteLock(&afs_xosi,320); + MObtainWriteLock(&afs_xosi, 320); astat->size = FILE_INODE(&afile->file)->i_size; astat->blksize = FILE_INODE(&afile->file)->i_blksize; astat->mtime = FILE_INODE(&afile->file)->i_mtime; @@ -89,23 +92,25 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta return code; } -int osi_UFSClose(register struct osi_file *afile) - { - AFS_STATCNT(osi_Close); - if (afile) { - if (FILE_INODE(&afile->file)) { - struct file *filp = &afile->file; - if (filp->f_op && filp->f_op->release) - filp->f_op->release(FILE_INODE(filp), filp); - iput(FILE_INODE(filp)); - } - } - - osi_FreeSmallSpace(afile); - return 0; - } +int +osi_UFSClose(register struct osi_file *afile) +{ + AFS_STATCNT(osi_Close); + if (afile) { + if (FILE_INODE(&afile->file)) { + struct file *filp = &afile->file; + if (filp->f_op && filp->f_op->release) + filp->f_op->release(FILE_INODE(filp), filp); + iput(FILE_INODE(filp)); + } + } + + osi_FreeSmallSpace(afile); + return 0; +} -int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) +int +osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) { struct AFS_UCRED *oldCred; register afs_int32 code; @@ -119,8 +124,9 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) * small enough. Check now and save some time. */ code = afs_osi_Stat(afile, &tstat); - if (code || tstat.size <= asize) return code; - MObtainWriteLock(&afs_xosi,321); + if (code || tstat.size <= asize) + return code; + MObtainWriteLock(&afs_xosi, 321); AFS_GUNLOCK(); #ifdef STRUCT_INODE_HAS_I_ALLOC_SEM down_write(&inode->i_alloc_sem); @@ -165,68 +171,74 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) /* Generic read interface */ -int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize) +int +afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; size_t resid; register afs_int32 code; - register afs_int32 cnt1=0; + register afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ - if ( !afile ) { - if ( !afs_shuttingdown ) + if (!afile) { + if (!afs_shuttingdown) osi_Panic("osi_Read called with null param"); else return EIO; } - if (offset != -1) afile->offset = offset; + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); code = osi_rdwr(UIO_READ, afile, (caddr_t) aptr, asize, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; - } - else { + } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, - ICL_TYPE_INT32, code); + ICL_TYPE_INT32, code); code = -1; } return code; } /* Generic write interface */ -int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) +int +afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; size_t resid; register afs_int32 code; AFS_STATCNT(osi_Write); - if ( !afile ) { - if ( !afs_shuttingdown ) + if (!afile) { + if (!afs_shuttingdown) osi_Panic("afs_osi_Write called with null param"); else return EIO; - } - if (offset != -1) afile->offset = offset; + } + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); - code = osi_rdwr(UIO_WRITE, afile, (caddr_t)aptr, asize, &resid); + code = osi_rdwr(UIO_WRITE, afile, (caddr_t) aptr, asize, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; - } - else { - if (code == ENOSPC) afs_warnuser("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); + } else { + if (code == ENOSPC) + afs_warnuser + ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); code = -1; } if (afile->proc) { - (*afile->proc)(afile, code); + (*afile->proc) (afile, code); } return code; } @@ -235,7 +247,8 @@ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, /* This work should be handled by physstrat in ca/machdep.c. This routine written from the RT NFS port strategy routine. It has been generalized a bit, but should still be pretty clear. */ -int afs_osi_MapStrategy(int (*aproc)(struct buf *bp), register struct buf *bp) +int +afs_osi_MapStrategy(int (*aproc) (struct buf * bp), register struct buf *bp) { afs_int32 returnCode; @@ -245,13 +258,13 @@ int afs_osi_MapStrategy(int (*aproc)(struct buf *bp), register struct buf *bp) return returnCode; } -void shutdown_osifile(void) +void +shutdown_osifile(void) { - extern int afs_cold_shutdown; + extern int afs_cold_shutdown; - AFS_STATCNT(shutdown_osifile); - if (afs_cold_shutdown) { - afs_osicred_initialized = 0; - } + AFS_STATCNT(shutdown_osifile); + if (afs_cold_shutdown) { + afs_osicred_initialized = 0; + } } - diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index ef957f946..2e2cb225a 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -16,22 +16,25 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #ifdef AFS_LINUX22_ENV #include "h/smp_lock.h" #endif -static int afs_getgroups(cred_t *cr, gid_t *groups); -static int afs_setgroups(cred_t **cr, int ngroups, gid_t *gidset, int change_parent); +static int afs_getgroups(cred_t * cr, gid_t * groups); +static int afs_setgroups(cred_t ** cr, int ngroups, gid_t * gidset, + int change_parent); /* Only propogate the PAG to the parent process. Unix's propogate to * all processes sharing the cred. */ -int set_pag_in_parent(int pag, int g0, int g1) +int +set_pag_in_parent(int pag, int g0, int g1) { #ifdef STRUCT_TASK_STRUCT_HAS_PARENT gid_t *gp = current->parent->groups; @@ -41,7 +44,7 @@ int set_pag_in_parent(int pag, int g0, int g1) int ngroups; int i; - + #ifdef STRUCT_TASK_STRUCT_HAS_PARENT ngroups = current->parent->ngroups; #else @@ -53,9 +56,9 @@ int set_pag_in_parent(int pag, int g0, int g1) if (ngroups + 2 > NGROUPS) { return EINVAL; } - for (i = ngroups-1; i >= 0; i--) { - gp[i+2] = gp[i]; - } + for (i = ngroups - 1; i >= 0; i--) { + gp[i + 2] = gp[i]; + } ngroups += 2; } gp[0] = g0; @@ -71,7 +74,9 @@ int set_pag_in_parent(int pag, int g0, int g1) return 0; } -int setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, int change_parent) +int +setpag(cred_t ** cr, afs_uint32 pagvalue, afs_uint32 * newpag, + int change_parent) { gid_t *gidset; afs_int32 ngroups, code = 0; @@ -79,21 +84,21 @@ int setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, int change_pare AFS_STATCNT(setpag); - gidset = (gid_t *) osi_Alloc(NGROUPS*sizeof(gidset[0])); + gidset = (gid_t *) osi_Alloc(NGROUPS * sizeof(gidset[0])); ngroups = afs_getgroups(*cr, gidset); if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) { /* We will have to shift grouplist to make room for pag */ if (ngroups + 2 > NGROUPS) { - osi_Free((char *)gidset, NGROUPS*sizeof(int)); + osi_Free((char *)gidset, NGROUPS * sizeof(int)); return EINVAL; } for (j = ngroups - 1; j >= 0; j--) { - gidset[j+2] = gidset[j]; - } + gidset[j + 2] = gidset[j]; + } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]); code = afs_setgroups(cr, ngroups, gidset, change_parent); @@ -104,14 +109,15 @@ int setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, int change_pare code = set_pag_in_parent(*newpag, gidset[0], gidset[1]); } - osi_Free((char *)gidset, NGROUPS*sizeof(int)); + osi_Free((char *)gidset, NGROUPS * sizeof(int)); return code; } /* Intercept the standard system call. */ -extern long (*sys_setgroupsp)(int gidsetsize, gid_t *grouplist); -asmlinkage long afs_xsetgroups(int gidsetsize, gid_t *grouplist) +extern long (*sys_setgroupsp) (int gidsetsize, gid_t * grouplist); +asmlinkage long +afs_xsetgroups(int gidsetsize, gid_t * grouplist) { long code; cred_t *cr = crref(); @@ -123,7 +129,7 @@ asmlinkage long afs_xsetgroups(int gidsetsize, gid_t *grouplist) crfree(cr); unlock_kernel(); - code = (*sys_setgroupsp)(gidsetsize, grouplist); + code = (*sys_setgroupsp) (gidsetsize, grouplist); if (code) { return code; } @@ -138,25 +144,26 @@ asmlinkage long afs_xsetgroups(int gidsetsize, gid_t *grouplist) unlock_kernel(); /* Linux syscall ABI returns errno as negative */ - return (- code); + return (-code); } #if defined(AFS_LINUX24_ENV) /* Intercept the standard uid32 system call. */ -extern long (*sys_setgroups32p)(int gidsetsize, gid_t *grouplist); -asmlinkage long afs_xsetgroups32(int gidsetsize, gid_t *grouplist) +extern long (*sys_setgroups32p) (int gidsetsize, gid_t * grouplist); +asmlinkage long +afs_xsetgroups32(int gidsetsize, gid_t * grouplist) { long code; cred_t *cr = crref(); afs_uint32 junk; int old_pag; - + lock_kernel(); old_pag = PagInCred(cr); crfree(cr); unlock_kernel(); - code = (*sys_setgroups32p)(gidsetsize, grouplist); + code = (*sys_setgroups32p) (gidsetsize, grouplist); if (code) { return code; @@ -172,14 +179,15 @@ asmlinkage long afs_xsetgroups32(int gidsetsize, gid_t *grouplist) unlock_kernel(); /* Linux syscall ABI returns errno as negative */ - return (- code); + return (-code); } #endif #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_AMD64_LINUX20_ENV) /* Intercept the uid16 system call as used by 32bit programs. */ -extern long (*sys32_setgroupsp)(int gidsetsize, old_gid_t *grouplist); -asmlinkage long afs32_xsetgroups(int gidsetsize, old_gid_t *grouplist) +extern long (*sys32_setgroupsp) (int gidsetsize, old_gid_t * grouplist); +asmlinkage long +afs32_xsetgroups(int gidsetsize, old_gid_t * grouplist) { long code; cred_t *cr = crref(); @@ -191,7 +199,7 @@ asmlinkage long afs32_xsetgroups(int gidsetsize, old_gid_t *grouplist) crfree(cr); unlock_kernel(); - code = (*sys32_setgroupsp)(gidsetsize, grouplist); + code = (*sys32_setgroupsp) (gidsetsize, grouplist); if (code) { return code; } @@ -206,12 +214,14 @@ asmlinkage long afs32_xsetgroups(int gidsetsize, old_gid_t *grouplist) unlock_kernel(); /* Linux syscall ABI returns errno as negative */ - return (- code); + return (-code); } + #ifdef AFS_LINUX24_ENV /* Intercept the uid32 system call as used by 32bit programs. */ -extern long (*sys32_setgroups32p)(int gidsetsize, gid_t *grouplist); -asmlinkage long afs32_xsetgroups32(int gidsetsize, gid_t *grouplist) +extern long (*sys32_setgroups32p) (int gidsetsize, gid_t * grouplist); +asmlinkage long +afs32_xsetgroups32(int gidsetsize, gid_t * grouplist) { long code; cred_t *cr = crref(); @@ -223,7 +233,7 @@ asmlinkage long afs32_xsetgroups32(int gidsetsize, gid_t *grouplist) crfree(cr); unlock_kernel(); - code = (*sys32_setgroups32p)(gidsetsize, grouplist); + code = (*sys32_setgroups32p) (gidsetsize, grouplist); if (code) { return code; } @@ -238,12 +248,13 @@ asmlinkage long afs32_xsetgroups32(int gidsetsize, gid_t *grouplist) unlock_kernel(); /* Linux syscall ABI returns errno as negative */ - return (- code); + return (-code); } #endif #endif -static int afs_setgroups(cred_t **cr, int ngroups, gid_t *gidset, int change_parent) +static int +afs_setgroups(cred_t ** cr, int ngroups, gid_t * gidset, int change_parent) { int ngrps; int i; @@ -256,7 +267,7 @@ static int afs_setgroups(cred_t **cr, int ngroups, gid_t *gidset, int change_par gp = (*cr)->cr_groups; if (ngroups < NGROUPS) - gp[ngroups] = (gid_t)NOGROUP; + gp[ngroups] = (gid_t) NOGROUP; for (i = ngroups; i > 0; i--) { *gp++ = *gidset++; @@ -270,16 +281,16 @@ static int afs_setgroups(cred_t **cr, int ngroups, gid_t *gidset, int change_par /* Returns number of groups. And we trust groups to be large enough to * hold all the groups. */ -static int afs_getgroups(cred_t *cr, gid_t *groups) +static int +afs_getgroups(cred_t * cr, gid_t * groups) { int i; gid_t *gp = cr->cr_groups; int n = cr->cr_ngroups; AFS_STATCNT(afs_getgroups); - for (i = 0; (i < n) && (*gp != (gid_t)NOGROUP); i++) { + for (i = 0; (i < n) && (*gp != (gid_t) NOGROUP); i++) { *groups++ = *gp++; } return i; } - diff --git a/src/afs/LINUX/osi_inode.c b/src/afs/LINUX/osi_inode.c index 6625a6a18..0612db511 100644 --- a/src/afs/LINUX/osi_inode.c +++ b/src/afs/LINUX/osi_inode.c @@ -20,12 +20,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ #include "afs/osi_inode.h" -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #define BAD_IGET -1000 @@ -36,21 +37,24 @@ RCSID("$Header$"); /* * `INODESPECIAL' type inodes are ones that describe volumes. */ -#define INODESPECIAL 0xffffffff /* ... from ../vol/viceinode.h */ +#define INODESPECIAL 0xffffffff /* ... from ../vol/viceinode.h */ #endif -int afs_syscall_icreate(void) +int +afs_syscall_icreate(void) { return 0; } -int afs_syscall_iopen(void) +int +afs_syscall_iopen(void) { return 0; } -int afs_syscall_iincdec(void) +int +afs_syscall_iincdec(void) { return 0; } diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h index 97cb32290..3184f7f57 100644 --- a/src/afs/LINUX/osi_machdep.h +++ b/src/afs/LINUX/osi_machdep.h @@ -35,7 +35,7 @@ #else #define RECALC_SIGPENDING(X) recalc_sigpending(X) #endif - + #if defined (STRUCT_TASK_STRUCT_HAS_SIGMASK_LOCK) #define SIG_LOCK(X) spin_lock_irq(&X->sigmask_lock) #define SIG_UNLOCK(X) spin_unlock_irq(&X->sigmask_lock) @@ -121,10 +121,10 @@ typedef struct cred { /* maps to task field: */ #else int cr_ref; #endif - uid_t cr_uid; /* euid */ - uid_t cr_ruid; /* uid */ - gid_t cr_gid; /* egid */ - gid_t cr_rgid; /* gid */ + uid_t cr_uid; /* euid */ + uid_t cr_ruid; /* uid */ + gid_t cr_gid; /* egid */ + gid_t cr_rgid; /* gid */ gid_t cr_groups[NGROUPS]; /* 32 groups - empty set to NOGROUP */ int cr_ngroups; } cred_t; @@ -136,12 +136,12 @@ typedef struct cred { /* maps to task field: */ typedef enum { AFS_UIOSYS, AFS_UIOUSER } uio_seg_t; typedef enum { UIO_READ, UIO_WRITE } uio_flag_t; typedef struct uio { - struct iovec *uio_iov; - int uio_iovcnt; - afs_offs_t uio_offset; - uio_seg_t uio_seg; - int uio_resid; - uio_flag_t uio_flag; + struct iovec *uio_iov; + int uio_iovcnt; + afs_offs_t uio_offset; + uio_seg_t uio_seg; + int uio_resid; + uio_flag_t uio_flag; } uio_t; #define afsio_iov uio_iov #define afsio_iovcnt uio_iovcnt diff --git a/src/afs/LINUX/osi_misc.c b/src/afs/LINUX/osi_misc.c index 89f89f5b4..7c928bc1e 100644 --- a/src/afs/LINUX/osi_misc.c +++ b/src/afs/LINUX/osi_misc.c @@ -14,7 +14,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" @@ -23,22 +24,23 @@ RCSID("$Header$"); #include "h/smp_lock.h" #endif -char *crash_addr = 0; /* Induce an oops by writing here. */ +char *crash_addr = 0; /* Induce an oops by writing here. */ #if defined(AFS_LINUX24_ENV) /* Lookup name and return vnode for same. */ -int osi_lookupname_internal(char *aname, uio_seg_t seg, int followlink, - vnode_t **dirvpp, struct dentry **dpp, - struct nameidata *nd) +int +osi_lookupname_internal(char *aname, uio_seg_t seg, int followlink, + vnode_t ** dirvpp, struct dentry **dpp, + struct nameidata *nd) { int code; code = ENOENT; if (seg == AFS_UIOUSER) { - code = followlink ? - user_path_walk(aname, nd) : user_path_walk_link(aname, nd); - } - else { + code = + followlink ? user_path_walk(aname, + nd) : user_path_walk_link(aname, nd); + } else { if (path_init(aname, followlink ? LOOKUP_FOLLOW : 0, nd)) code = path_walk(aname, nd); } @@ -56,8 +58,9 @@ int osi_lookupname_internal(char *aname, uio_seg_t seg, int followlink, } #endif -int osi_lookupname(char *aname, uio_seg_t seg, int followlink, - vnode_t **dirvpp, struct dentry **dpp) +int +osi_lookupname(char *aname, uio_seg_t seg, int followlink, vnode_t ** dirvpp, + struct dentry **dpp) { #if defined(AFS_LINUX24_ENV) struct nameidata nd; @@ -65,17 +68,16 @@ int osi_lookupname(char *aname, uio_seg_t seg, int followlink, &nd); if (!code) path_release(&nd); - + return (code); #else struct dentry *dp = NULL; int code; - + code = ENOENT; if (seg == AFS_UIOUSER) { dp = followlink ? namei(aname) : lnamei(aname); - } - else { + } else { dp = lookup_dentry(aname, NULL, followlink ? 1 : 0); } @@ -83,17 +85,17 @@ int osi_lookupname(char *aname, uio_seg_t seg, int followlink, if (dp->d_inode) { *dpp = dp; code = 0; - } - else + } else dput(dp); } - + return code; #endif } /* Intialize cache device info and fragment size for disk cache partition. */ -int osi_InitCacheInfo(char *aname) +int +osi_InitCacheInfo(char *aname) { int code; struct dentry *dp; @@ -103,9 +105,11 @@ int osi_InitCacheInfo(char *aname) extern struct super_block *afs_cacheSBp; extern struct nameidata afs_cacheNd; - code = osi_lookupname_internal(aname, AFS_UIOSYS, 1, NULL, &dp, - &afs_cacheNd); - if (code) return ENOENT; + code = + osi_lookupname_internal(aname, AFS_UIOSYS, 1, NULL, &dp, + &afs_cacheNd); + if (code) + return ENOENT; cacheInode = dp->d_inode->i_ino; cacheDev.dev = dp->d_inode->i_dev; @@ -125,8 +129,9 @@ int osi_InitCacheInfo(char *aname) * Seek, then read or write to an open inode. addrp points to data in * kernel space. */ -int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize, - size_t *resid) +int +osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize, + size_t * resid) { int code = 0; KERNEL_SPACE_DECL; @@ -136,10 +141,9 @@ int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize, /* Seek to the desired position. Return -1 on error. */ if (filp->f_op->llseek) { - if (filp->f_op->llseek(filp, (loff_t)offset, 0) != offset) + if (filp->f_op->llseek(filp, (loff_t) offset, 0) != offset) return -1; - } - else + } else filp->f_pos = offset; savelim = current->rlim[RLIMIT_FSIZE].rlim_cur; @@ -151,24 +155,24 @@ int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize, code = FOP_READ(filp, addrp, asize); else if (rw == UIO_WRITE) code = FOP_WRITE(filp, addrp, asize); - else /* all is well? */ + else /* all is well? */ code = asize; TO_KERNEL_SPACE(); current->rlim[RLIMIT_FSIZE].rlim_cur = savelim; - if (code >=0) { + if (code >= 0) { *resid = asize - code; return 0; - } - else + } else return -1; } /* This variant is called from AFS read/write routines and takes a uio * struct and, if successful, returns 0. */ -int osi_file_uio_rdwr(struct osi_file *osifile, uio_t *uiop, int rw) +int +osi_file_uio_rdwr(struct osi_file *osifile, uio_t * uiop, int rw) { struct file *filp = &osifile->file; struct inode *ip = FILE_INODE(&osifile->file); @@ -203,7 +207,7 @@ int osi_file_uio_rdwr(struct osi_file *osifile, uio_t *uiop, int rw) code = -code; break; } - + iov->iov_base += code; iov->iov_len -= code; uiop->uio_resid -= code; @@ -222,9 +226,9 @@ int osi_file_uio_rdwr(struct osi_file *osifile, uio_t *uiop, int rw) /* setup_uio * Setup a uio struct. */ -void setup_uio(uio_t *uiop, struct iovec *iovecp, char *buf, - afs_offs_t pos, int count, uio_flag_t flag, - uio_seg_t seg) +void +setup_uio(uio_t * uiop, struct iovec *iovecp, char *buf, afs_offs_t pos, + int count, uio_flag_t flag, uio_seg_t seg) { iovecp->iov_base = buf; iovecp->iov_len = count; @@ -241,7 +245,8 @@ void setup_uio(uio_t *uiop, struct iovec *iovecp, char *buf, * UIO_READ : dp -> uio * UIO_WRITE : uio -> dp */ -int uiomove(char *dp, int length, uio_flag_t rw, uio_t *uiop) +int +uiomove(char *dp, int length, uio_flag_t rw, uio_t * uiop) { int count, n; struct iovec *iov; @@ -259,25 +264,29 @@ int uiomove(char *dp, int length, uio_flag_t rw, uio_t *uiop) if (count > length) count = length; - - switch(uiop->uio_seg) { + + switch (uiop->uio_seg) { case AFS_UIOSYS: - switch(rw) { + switch (rw) { case UIO_READ: - memcpy(iov->iov_base, dp, count); break; + memcpy(iov->iov_base, dp, count); + break; case UIO_WRITE: - memcpy(dp, iov->iov_base, count); break; + memcpy(dp, iov->iov_base, count); + break; default: printf("uiomove: Bad rw = %d\n", rw); return -EINVAL; } break; case AFS_UIOUSER: - switch(rw) { + switch (rw) { case UIO_READ: - AFS_COPYOUT(dp, iov->iov_base, count, code); break; + AFS_COPYOUT(dp, iov->iov_base, count, code); + break; case UIO_WRITE: - AFS_COPYIN(iov->iov_base, dp, count, code); break; + AFS_COPYIN(iov->iov_base, dp, count, code); + break; default: printf("uiomove: Bad rw = %d\n", rw); return -EINVAL; @@ -298,22 +307,24 @@ int uiomove(char *dp, int length, uio_flag_t rw, uio_t *uiop) return 0; } -void afs_osi_SetTime(osi_timeval_t *tvp) +void +afs_osi_SetTime(osi_timeval_t * tvp) { - extern int (*sys_settimeofdayp)(struct timeval *tv, struct timezone *tz); + extern int (*sys_settimeofdayp) (struct timeval * tv, + struct timezone * tz); #ifdef AFS_LINUX_64BIT_KERNEL struct timeval tv; AFS_STATCNT(osi_SetTime); tv.tv_sec = tvp->tv_sec; tv.tv_usec = tvp->tv_usec; - (void) (*sys_settimeofdayp)(&tv, NULL); + (void)(*sys_settimeofdayp) (&tv, NULL); #else KERNEL_SPACE_DECL; AFS_STATCNT(osi_SetTime); TO_USER_SPACE(); - (void) (*sys_settimeofdayp)(tvp, NULL); + (void)(*sys_settimeofdayp) (tvp, NULL); TO_KERNEL_SPACE(); #endif } @@ -321,15 +332,16 @@ void afs_osi_SetTime(osi_timeval_t *tvp) /* Free all the pages on any of the vnodes in the vlru. Must be done before * freeing all memory. */ -void osi_linux_free_inode_pages(void) +void +osi_linux_free_inode_pages(void) { int i; struct vcache *tvc; struct inode *ip; extern struct vcache *afs_vhashT[VCSIZE]; - for (i=0; ihnext) { + for (i = 0; i < VCSIZE; i++) { + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { ip = AFSTOI(tvc); #if defined(AFS_LINUX24_ENV) if (ip->i_data.nrpages) { @@ -337,9 +349,9 @@ void osi_linux_free_inode_pages(void) if (ip->i_nrpages) { #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) - truncate_inode_pages(&ip->i_data, 0); + truncate_inode_pages(&ip->i_data, 0); #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15) - truncate_inode_pages(ip, 0); + truncate_inode_pages(ip, 0); #else invalidate_inode_pages(ip); #endif @@ -356,7 +368,8 @@ void osi_linux_free_inode_pages(void) } } -void osi_clear_inode(struct inode *ip) +void +osi_clear_inode(struct inode *ip) { cred_t *credp = crref(); struct vcache *vcp = ITOAFS(ip); @@ -366,7 +379,8 @@ void osi_clear_inode(struct inode *ip) #else if (ip->i_count > 1) #endif - printf("afs_put_inode: ino %d (0x%x) has count %d\n", ip->i_ino, ip, ip->i_count); + printf("afs_put_inode: ino %d (0x%x) has count %d\n", ip->i_ino, ip, + ip->i_count); afs_InactiveVCache(vcp, credp); ObtainWriteLock(&vcp->lock, 504); @@ -375,7 +389,7 @@ void osi_clear_inode(struct inode *ip) #else ip->i_count = 0; #endif - ip->i_nlink = 0; /* iput checks this after calling this routine. */ + ip->i_nlink = 0; /* iput checks this after calling this routine. */ ReleaseWriteLock(&vcp->lock); crfree(credp); } @@ -384,13 +398,15 @@ void osi_clear_inode(struct inode *ip) * to call iput on AFS inodes, since they would then end up on Linux's * inode_unsed list. */ -void osi_iput(struct inode *ip) +void +osi_iput(struct inode *ip) { extern struct vfs *afs_globalVFS; AFS_GLOCK(); #if defined(AFS_LINUX24_ENV) - if (atomic_read(&ip->i_count) == 0 || atomic_read(&ip->i_count) & 0xffff0000) { + if (atomic_read(&ip->i_count) == 0 + || atomic_read(&ip->i_count) & 0xffff0000) { #else if (ip->i_count == 0 || ip->i_count & 0xffff0000) { #endif @@ -401,17 +417,16 @@ void osi_iput(struct inode *ip) ip->i_count, ip); #endif } - if (afs_globalVFS && afs_globalVFS == ip->i_sb ) { + if (afs_globalVFS && afs_globalVFS == ip->i_sb) { #if defined(AFS_LINUX24_ENV) atomic_dec(&ip->i_count); if (!atomic_read(&ip->i_count)) #else - ip->i_count --; + ip->i_count--; if (!ip->i_count) #endif osi_clear_inode(ip); - } - else + } else iput(ip); AFS_GUNLOCK(); } @@ -432,44 +447,46 @@ void osi_iput(struct inode *ip) * to the correct parent and mountpoint fids. */ -void check_bad_parent(struct dentry *dp) +void +check_bad_parent(struct dentry *dp) { - cred_t *credp; - struct vcache *vcp = ITOAFS(dp->d_inode), *avc = NULL; - struct vcache *pvc = ITOAFS(dp->d_parent->d_inode); - - if (vcp->mvid->Fid.Volume != pvc->fid.Fid.Volume) { /* bad parent */ - credp = crref(); - - - /* force a lookup, so vcp->mvid is fixed up */ - afs_lookup(pvc, dp->d_name.name, &avc, credp); - if (!avc || vcp != avc) { /* bad, very bad.. */ - afs_Trace4(afs_iclSetp, CM_TRACE_TMP_1S3L, ICL_TYPE_STRING, - "afs_linux_revalidate : bad pointer returned from afs_lookup origvc newvc dentry", - ICL_TYPE_POINTER, vcp, - ICL_TYPE_POINTER, avc, - ICL_TYPE_POINTER, dp); + cred_t *credp; + struct vcache *vcp = ITOAFS(dp->d_inode), *avc = NULL; + struct vcache *pvc = ITOAFS(dp->d_parent->d_inode); + + if (vcp->mvid->Fid.Volume != pvc->fid.Fid.Volume) { /* bad parent */ + credp = crref(); + + + /* force a lookup, so vcp->mvid is fixed up */ + afs_lookup(pvc, dp->d_name.name, &avc, credp); + if (!avc || vcp != avc) { /* bad, very bad.. */ + afs_Trace4(afs_iclSetp, CM_TRACE_TMP_1S3L, ICL_TYPE_STRING, + "afs_linux_revalidate : bad pointer returned from afs_lookup origvc newvc dentry", + ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, avc, + ICL_TYPE_POINTER, dp); + } + if (avc) + AFS_RELE(avc); + crfree(credp); } - if (avc) - AFS_RELE(avc); - crfree(credp); - } /* if bad parent */ - - return; + /* if bad parent */ + return; } struct task_struct *rxk_ListenerTask; -void osi_linux_mask(void) +void +osi_linux_mask(void) { SIG_LOCK(current); sigfillset(¤t->blocked); RECALC_SIGPENDING(current); SIG_UNLOCK(current); } - -void osi_linux_rxkreg(void) + +void +osi_linux_rxkreg(void) { rxk_ListenerTask = current; } diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index a3a05f97e..353a3173d 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -14,11 +14,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "h/unistd.h" /* For syscall numbers. */ +#include "h/unistd.h" /* For syscall numbers. */ #include "h/mm.h" #ifdef AFS_AMD64_LINUX20_ENV @@ -36,23 +37,24 @@ RCSID("$Header$"); #endif #ifdef AFS_SPARC64_LINUX24_ENV -#define __NR_setgroups32 82 /* This number is not exported for some bizarre reason. */ +#define __NR_setgroups32 82 /* This number is not exported for some bizarre reason. */ #endif -asmlinkage int (*sys_settimeofdayp)(struct timeval *tv, struct timezone *tz); -asmlinkage long (*sys_setgroupsp)(int gidsetsize, gid_t *grouplist); +asmlinkage int (*sys_settimeofdayp) (struct timeval * tv, + struct timezone * tz); +asmlinkage long (*sys_setgroupsp) (int gidsetsize, gid_t * grouplist); #ifdef EXPORTED_SYS_CALL_TABLE #ifdef AFS_SPARC64_LINUX20_ENV -extern unsigned int sys_call_table[]; /* changed to uint because SPARC64 has syscaltable of 32bit items */ +extern unsigned int sys_call_table[]; /* changed to uint because SPARC64 has syscaltable of 32bit items */ #else -extern void * sys_call_table[]; /* safer for other linuces */ +extern void *sys_call_table[]; /* safer for other linuces */ #endif #else /* EXPORTED_SYS_CALL_TABLE */ #ifdef AFS_SPARC64_LINUX20_ENV -static unsigned int *sys_call_table; /* changed to uint because SPARC64 has syscaltable of 32bit items */ +static unsigned int *sys_call_table; /* changed to uint because SPARC64 has syscaltable of 32bit items */ #else -static void ** sys_call_table; /* safer for other linuces */ +static void **sys_call_table; /* safer for other linuces */ #endif #endif extern struct file_system_type afs_file_system; @@ -65,7 +67,7 @@ DECLARE_MUTEX(afs_global_lock); struct semaphore afs_global_lock = MUTEX; #endif int afs_global_owner = 0; -unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */ +unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */ /* Since sys_ni_syscall is not exported, I need to cache it in order to restore * it. @@ -73,28 +75,30 @@ unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */ #ifdef AFS_SPARC64_LINUX20_ENV static unsigned int afs_ni_syscall = 0; #else -static void* afs_ni_syscall = 0; +static void *afs_ni_syscall = 0; #endif - + #ifdef AFS_AMD64_LINUX20_ENV #ifdef EXPORTED_IA32_SYS_CALL_TABLE -extern void * ia32_sys_call_table[]; +extern void *ia32_sys_call_table[]; #else static void **ia32_sys_call_table; #endif static void *ia32_ni_syscall = 0; -asmlinkage long (*sys32_setgroupsp)(int gidsetsize, old_gid_t *grouplist); +asmlinkage long (*sys32_setgroupsp) (int gidsetsize, old_gid_t * grouplist); #if defined(__NR_ia32_setgroups32) -asmlinkage long (*sys32_setgroups32p)(int gidsetsize, gid_t *grouplist); +asmlinkage long (*sys32_setgroups32p) (int gidsetsize, gid_t * grouplist); #endif /* __NR_ia32_setgroups32 */ #endif /* AFS_AMD64_LINUX20_ENV */ #ifdef AFS_SPARC64_LINUX20_ENV static unsigned int afs_ni_syscall32 = 0; -asmlinkage int (*sys32_setgroupsp)(int gidsetsize, __kernel_gid_t32 *grouplist); +asmlinkage int (*sys32_setgroupsp) (int gidsetsize, + __kernel_gid_t32 * grouplist); #if defined(__NR_setgroups32) -asmlinkage int (*sys32_setgroups32p)(int gidsetsize, __kernel_gid_t32 *grouplist); +asmlinkage int (*sys32_setgroups32p) (int gidsetsize, + __kernel_gid_t32 * grouplist); #endif /* __NR_setgroups32 */ #ifdef EXPORTED_SYS_CALL_TABLE extern unsigned int sys_call_table32[]; @@ -102,15 +106,13 @@ extern unsigned int sys_call_table32[]; static unsigned int *sys_call_table32; #endif /* EXPORTED_SYS_CALL_TABLE */ -asmlinkage int afs_syscall32(long syscall, long parm1, long parm2, long parm3, - long parm4, long parm5) +asmlinkage int +afs_syscall32(long syscall, long parm1, long parm2, long parm3, long parm4, + long parm5) { -__asm__ __volatile__ ("srl %o4, 0, %o4\n\t" - "mov %o7, %i7\n\t" - "call afs_syscall\n\t" - "srl %o5, 0, %o5\n\t" - "ret\n\t" - "nop"); + __asm__ __volatile__("srl %o4, 0, %o4\n\t" "mov %o7, %i7\n\t" + "call afs_syscall\n\t" "srl %o5, 0, %o5\n\t" + "ret\n\t" "nop"); } #endif /* AFS_SPARC64_LINUX20_ENV */ @@ -119,77 +121,33 @@ __asm__ __volatile__ ("srl %o4, 0, %o4\n\t" asmlinkage long afs_syscall_stub(int r0, int r1, long r2, long r3, long r4, long gp) { -__asm__ __volatile__ ("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" - "mov r41 = b0\n\t" /* save rp */ - "mov out0 = in0\n\t" - "mov out1 = in1\n\t" - "mov out2 = in2\n\t" - "mov out3 = in3\n\t" - "mov out4 = in4\n\t" - "mov out5 = gp\n\t" /* save gp */ - ";;\n" - ".L1: mov r3 = ip\n\t" - ";;\n\t" - "addl r15=.fptr_afs_syscall-.L1,r3\n\t" - ";;\n\t" - "ld8 r15=[r15]\n\t" - ";;\n\t" - "ld8 r16=[r15],8\n\t" - ";;\n\t" - "ld8 gp=[r15]\n\t" - "mov b6=r16\n\t" - "br.call.sptk.many b0 = b6\n\t" - ";;\n\t" - "mov ar.pfs = r42\n\t" - "mov b0 = r41\n\t" - "mov gp = r48\n\t" /* restore gp */ - "br.ret.sptk.many b0\n" - ".fptr_afs_syscall:\n\t" - "data8 @fptr(afs_syscall)"); + __asm__ __volatile__("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" "mov r41 = b0\n\t" /* save rp */ + "mov out0 = in0\n\t" "mov out1 = in1\n\t" "mov out2 = in2\n\t" "mov out3 = in3\n\t" "mov out4 = in4\n\t" "mov out5 = gp\n\t" /* save gp */ + ";;\n" ".L1: mov r3 = ip\n\t" ";;\n\t" "addl r15=.fptr_afs_syscall-.L1,r3\n\t" ";;\n\t" "ld8 r15=[r15]\n\t" ";;\n\t" "ld8 r16=[r15],8\n\t" ";;\n\t" "ld8 gp=[r15]\n\t" "mov b6=r16\n\t" "br.call.sptk.many b0 = b6\n\t" ";;\n\t" "mov ar.pfs = r42\n\t" "mov b0 = r41\n\t" "mov gp = r48\n\t" /* restore gp */ + "br.ret.sptk.many b0\n" ".fptr_afs_syscall:\n\t" + "data8 @fptr(afs_syscall)"); } asmlinkage long afs_xsetgroups_stub(int r0, int r1, long r2, long r3, long r4, long gp) { -__asm__ __volatile__ ("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" - "mov r41 = b0\n\t" /* save rp */ - "mov out0 = in0\n\t" - "mov out1 = in1\n\t" - "mov out2 = in2\n\t" - "mov out3 = in3\n\t" - "mov out4 = in4\n\t" - "mov out5 = gp\n\t" /* save gp */ - ";;\n" - ".L2: mov r3 = ip\n\t" - ";;\n\t" - "addl r15=.fptr_afs_xsetgroups - .L2,r3\n\t" - ";;\n\t" - "ld8 r15=[r15]\n\t" - ";;\n\t" - "ld8 r16=[r15],8\n\t" - ";;\n\t" - "ld8 gp=[r15]\n\t" - "mov b6=r16\n\t" - "br.call.sptk.many b0 = b6\n\t" - ";;\n\t" - "mov ar.pfs = r42\n\t" - "mov b0 = r41\n\t" - "mov gp = r48\n\t" /* restore gp */ - "br.ret.sptk.many b0\n" - ".fptr_afs_xsetgroups:\n\t" - "data8 @fptr(afs_xsetgroups)"); + __asm__ __volatile__("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" "mov r41 = b0\n\t" /* save rp */ + "mov out0 = in0\n\t" "mov out1 = in1\n\t" "mov out2 = in2\n\t" "mov out3 = in3\n\t" "mov out4 = in4\n\t" "mov out5 = gp\n\t" /* save gp */ + ";;\n" ".L2: mov r3 = ip\n\t" ";;\n\t" "addl r15=.fptr_afs_xsetgroups - .L2,r3\n\t" ";;\n\t" "ld8 r15=[r15]\n\t" ";;\n\t" "ld8 r16=[r15],8\n\t" ";;\n\t" "ld8 gp=[r15]\n\t" "mov b6=r16\n\t" "br.call.sptk.many b0 = b6\n\t" ";;\n\t" "mov ar.pfs = r42\n\t" "mov b0 = r41\n\t" "mov gp = r48\n\t" /* restore gp */ + "br.ret.sptk.many b0\n" ".fptr_afs_xsetgroups:\n\t" + "data8 @fptr(afs_xsetgroups)"); } -struct fptr -{ - void *ip; - unsigned long gp; +struct fptr { + void *ip; + unsigned long gp; }; #endif /* AFS_IA64_LINUX20_ENV */ #ifdef AFS_LINUX24_ENV -asmlinkage int (*sys_setgroups32p)(int gidsetsize, __kernel_gid32_t *grouplist); +asmlinkage int (*sys_setgroups32p) (int gidsetsize, + __kernel_gid32_t * grouplist); #endif /* AFS_LINUX24_ENV */ #ifdef AFS_SPARC64_LINUX20_ENV @@ -201,9 +159,11 @@ asmlinkage int (*sys_setgroups32p)(int gidsetsize, __kernel_gid32_t *grouplist); #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) -int __init afs_init(void) +int __init +afs_init(void) #else -int init_module(void) +int +init_module(void) #endif { #if defined(AFS_IA64_LINUX20_ENV) @@ -231,15 +191,15 @@ int init_module(void) unsigned long datalen; int ret; unsigned long token; - char *mod_name; - unsigned long mod_start; - unsigned long mod_end; - char *sec_name; - unsigned long sec_start; - unsigned long sec_end; - char *sym_name; - unsigned long sym_start; - unsigned long sym_end; + char *mod_name; + unsigned long mod_start; + unsigned long mod_end; + char *sec_name; + unsigned long sec_start; + unsigned long sec_end; + char *sym_name; + unsigned long sym_start; + unsigned long sym_end; #endif /* EXPORTED_SYS_CALL_TABLE */ RWLOCK_INIT(&afs_xosi, "afs_xosi"); @@ -249,78 +209,84 @@ int init_module(void) #ifndef AFS_S390_LINUX22_ENV if (afs_linux_page_offset == 0) { - /* couldn't obtain page offset so can't continue */ - printf("afs: Unable to obtain PAGE_OFFSET. Exiting.."); - return -EIO; + /* couldn't obtain page offset so can't continue */ + printf("afs: Unable to obtain PAGE_OFFSET. Exiting.."); + return -EIO; } #endif #ifndef EXPORTED_SYS_CALL_TABLE - sys_call_table=0; + sys_call_table = 0; #ifdef EXPORTED_KALLSYMS_SYMBOL - ret=1; - token=0; + ret = 1; + token = 0; while (ret) { - sym_start=0; - ret=kallsyms_symbol_to_address("sys_call_table", &token, &mod_name, - &mod_start, &mod_end, &sec_name, &sec_start, &sec_end, - &sym_name, &sym_start, &sym_end); - if (ret && !strcmp(mod_name, "kernel")) - break; + sym_start = 0; + ret = + kallsyms_symbol_to_address("sys_call_table", &token, &mod_name, + &mod_start, &mod_end, &sec_name, + &sec_start, &sec_end, &sym_name, + &sym_start, &sym_end); + if (ret && !strcmp(mod_name, "kernel")) + break; } if (ret && sym_start) { - sys_call_table=sym_start; + sys_call_table = sym_start; } #else #ifdef EXPORTED_KALLSYMS_ADDRESS - ret=kallsyms_address_to_symbol((unsigned long)&init_mm, &mod_name, - &mod_start, &mod_end, &sec_name, &sec_start, &sec_end, - &sym_name, &sym_start, &sym_end); - ptr=(unsigned long *)sec_start; - datalen=(sec_end-sec_start)/sizeof(unsigned long); + ret = + kallsyms_address_to_symbol((unsigned long)&init_mm, &mod_name, + &mod_start, &mod_end, &sec_name, + &sec_start, &sec_end, &sym_name, + &sym_start, &sym_end); + ptr = (unsigned long *)sec_start; + datalen = (sec_end - sec_start) / sizeof(unsigned long); #else #if defined(AFS_IA64_LINUX20_ENV) - ptr = (unsigned long *) (&sys_close - 0x180000); - datalen=0x180000/sizeof(ptr); + ptr = (unsigned long *)(&sys_close - 0x180000); + datalen = 0x180000 / sizeof(ptr); #else #if defined(AFS_AMD64_LINUX20_ENV) - ptr=(unsigned long *)&init_mm; - datalen=0x180000/sizeof(ptr); + ptr = (unsigned long *)&init_mm; + datalen = 0x180000 / sizeof(ptr); #else - ptr=(unsigned long *)&init_mm; - datalen=16384; + ptr = (unsigned long *)&init_mm; + datalen = 16384; #endif #endif #endif - for (offset=0;offset ip; - unsigned long chdir_ip=(unsigned long) ((struct fptr *)&sys_chdir)->ip; - unsigned long write_ip=(unsigned long) ((struct fptr *)&sys_write)->ip; - if (ptr[0] == close_ip && - ptr[__NR_chdir - __NR_close] == chdir_ip && - ptr[__NR_write - __NR_close] == write_ip) { - sys_call_table=(void *) &(ptr[ -1 * (__NR_close-1024)]); + unsigned long close_ip = + (unsigned long)((struct fptr *)&sys_close)->ip; + unsigned long chdir_ip = + (unsigned long)((struct fptr *)&sys_chdir)->ip; + unsigned long write_ip = + (unsigned long)((struct fptr *)&sys_write)->ip; + if (ptr[0] == close_ip && ptr[__NR_chdir - __NR_close] == chdir_ip + && ptr[__NR_write - __NR_close] == write_ip) { + sys_call_table = (void *)&(ptr[-1 * (__NR_close - 1024)]); break; } #else #if defined(EXPORTED_SYS_WAIT4) && defined(EXPORTED_SYS_CLOSE) - if (ptr[0] == (unsigned long)&sys_close && - ptr[__NR_wait4 - __NR_close] == (unsigned long)&sys_wait4) { - sys_call_table=ptr - __NR_close; - break; - } + if (ptr[0] == (unsigned long)&sys_close + && ptr[__NR_wait4 - __NR_close] == (unsigned long)&sys_wait4) { + sys_call_table = ptr - __NR_close; + break; + } #else #if defined(EXPORTED_SYS_CHDIR) && defined(EXPORTED_SYS_CLOSE) - if (ptr[0] == (unsigned long)&sys_close && - ptr[__NR_chdir - __NR_close] == (unsigned long)&sys_chdir) { - sys_call_table=ptr - __NR_close; + if (ptr[0] == (unsigned long)&sys_close + && ptr[__NR_chdir - __NR_close] == (unsigned long)&sys_chdir) { + sys_call_table = ptr - __NR_close; break; } #else - if (ptr[0] == (unsigned long)&sys_exit && - ptr[__NR_open - __NR_exit] == (unsigned long)&sys_open) { - sys_call_table=ptr - __NR_exit; + if (ptr[0] == (unsigned long)&sys_exit + && ptr[__NR_open - __NR_exit] == (unsigned long)&sys_open) { + sys_call_table = ptr - __NR_exit; break; } #endif @@ -328,78 +294,83 @@ int init_module(void) #endif } #ifdef EXPORTED_KALLSYMS_ADDRESS - ret=kallsyms_address_to_symbol((unsigned long)sys_call_table, &mod_name, - &mod_start, &mod_end, &sec_name, &sec_start, &sec_end, - &sym_name, &sym_start, &sym_end); + ret = + kallsyms_address_to_symbol((unsigned long)sys_call_table, &mod_name, + &mod_start, &mod_end, &sec_name, + &sec_start, &sec_end, &sym_name, + &sym_start, &sym_end); if (ret && strcmp(sym_name, "sys_call_table")) - sys_call_table=0; + sys_call_table = 0; #endif #endif if (!sys_call_table) { - printf("Failed to find address of sys_call_table\n"); - return -EIO; + printf("Failed to find address of sys_call_table\n"); + return -EIO; } printf("Found sys_call_table at %x\n", sys_call_table); # ifdef AFS_SPARC64_LINUX20_ENV error cant support this yet. #endif -#endif /* EXPORTED_SYS_CALL_TABLE */ - +#endif /* EXPORTED_SYS_CALL_TABLE */ #ifdef AFS_AMD64_LINUX20_ENV #ifndef EXPORTED_IA32_SYS_CALL_TABLE - ia32_sys_call_table=0; + ia32_sys_call_table = 0; #ifdef EXPORTED_KALLSYMS_SYMBOL - ret=1; - token=0; + ret = 1; + token = 0; while (ret) { - sym_start=0; - ret=kallsyms_symbol_to_address("ia32_sys_call_table", &token, - &mod_name, &mod_start, &mod_end, + sym_start = 0; + ret = + kallsyms_symbol_to_address("ia32_sys_call_table", &token, + &mod_name, &mod_start, &mod_end, &sec_name, &sec_start, &sec_end, &sym_name, &sym_start, &sym_end); if (ret && !strcmp(mod_name, "kernel")) - break; + break; } if (ret && sym_start) { - ia32_sys_call_table=sym_start; + ia32_sys_call_table = sym_start; } #else /* EXPORTED_KALLSYMS_SYMBOL */ #ifdef EXPORTED_KALLSYMS_ADDRESS - ret=kallsyms_address_to_symbol((unsigned long)&interruptible_sleep_on, + ret = + kallsyms_address_to_symbol((unsigned long)&interruptible_sleep_on, &mod_name, &mod_start, &mod_end, &sec_name, - &sec_start, &sec_end, - &sym_name, &sym_start, &sym_end); - ptr=(unsigned long *)sec_start; - datalen=(sec_end-sec_start)/sizeof(unsigned long); + &sec_start, &sec_end, &sym_name, + &sym_start, &sym_end); + ptr = (unsigned long *)sec_start; + datalen = (sec_end - sec_start) / sizeof(unsigned long); #else /* EXPORTED_KALLSYMS_ADDRESS */ #if defined(AFS_AMD64_LINUX20_ENV) - ptr=(unsigned long *)&interruptible_sleep_on; - datalen=0x180000/sizeof(ptr); + ptr = (unsigned long *)&interruptible_sleep_on; + datalen = 0x180000 / sizeof(ptr); #else /* AFS_AMD64_LINUX20_ENV */ - ptr=(unsigned long *)&interruptible_sleep_on; - datalen=16384; + ptr = (unsigned long *)&interruptible_sleep_on; + datalen = 16384; #endif /* AFS_AMD64_LINUX20_ENV */ #endif /* EXPORTED_KALLSYMS_ADDRESS */ - for (offset=0;offset gp; - sys_settimeofdayp = (void *) &sys_settimeofday; + sys_settimeofdayp = (void *)&sys_settimeofday; ((struct fptr *)sys_settimeofdayp)->ip = - SYSCALL2POINTER sys_call_table[__NR_settimeofday - 1024]; + SYSCALL2POINTER sys_call_table[__NR_settimeofday - 1024]; ((struct fptr *)sys_settimeofdayp)->gp = kernel_gp; - + #else /* !AFS_IA64_LINUX20_ENV */ sys_settimeofdayp = SYSCALL2POINTER sys_call_table[__NR_settimeofday]; #endif /* AFS_IA64_LINUX20_ENV */ @@ -423,18 +394,18 @@ int init_module(void) /* setup AFS entry point. */ if ( #if defined(AFS_IA64_LINUX20_ENV) - SYSCALL2POINTER sys_call_table[__NR_afs_syscall - 1024] + SYSCALL2POINTER sys_call_table[__NR_afs_syscall - 1024] #else - SYSCALL2POINTER sys_call_table[__NR_afs_syscall] + SYSCALL2POINTER sys_call_table[__NR_afs_syscall] #endif - == afs_syscall) { + == afs_syscall) { printf("AFS syscall entry point already in use!\n"); return -EBUSY; } - #if defined(AFS_IA64_LINUX20_ENV) afs_ni_syscall = sys_call_table[__NR_afs_syscall - 1024]; - sys_call_table[__NR_afs_syscall - 1024] = POINTER2SYSCALL ((struct fptr *)afs_syscall_stub)->ip; + sys_call_table[__NR_afs_syscall - 1024] = + POINTER2SYSCALL((struct fptr *)afs_syscall_stub)->ip; #else /* AFS_IA64_LINUX20_ENV */ afs_ni_syscall = sys_call_table[__NR_afs_syscall]; sys_call_table[__NR_afs_syscall] = POINTER2SYSCALL afs_syscall; @@ -446,7 +417,8 @@ int init_module(void) #ifdef AFS_AMD64_LINUX20_ENV if (ia32_sys_call_table) { ia32_ni_syscall = ia32_sys_call_table[__NR_ia32_afs_syscall]; - ia32_sys_call_table[__NR_ia32_afs_syscall] = POINTER2SYSCALL afs_syscall; + ia32_sys_call_table[__NR_ia32_afs_syscall] = + POINTER2SYSCALL afs_syscall; } #endif /* AFS_S390_LINUX22_ENV */ @@ -455,13 +427,14 @@ int init_module(void) /* Intercept setgroups calls */ #if defined(AFS_IA64_LINUX20_ENV) - sys_setgroupsp = (void *) &sys_setgroups; + sys_setgroupsp = (void *)&sys_setgroups; ((struct fptr *)sys_setgroupsp)->ip = - SYSCALL2POINTER sys_call_table[__NR_setgroups - 1024]; + SYSCALL2POINTER sys_call_table[__NR_setgroups - 1024]; ((struct fptr *)sys_setgroupsp)->gp = kernel_gp; - sys_call_table[__NR_setgroups - 1024] = POINTER2SYSCALL ((struct fptr *)afs_xsetgroups_stub)->ip; + sys_call_table[__NR_setgroups - 1024] = + POINTER2SYSCALL((struct fptr *)afs_xsetgroups_stub)->ip; #else /* AFS_IA64_LINUX20_ENV */ sys_setgroupsp = SYSCALL2POINTER sys_call_table[__NR_setgroups]; sys_call_table[__NR_setgroups] = POINTER2SYSCALL afs_xsetgroups; @@ -477,16 +450,16 @@ int init_module(void) sys_call_table32[__NR_setgroups32] = POINTER2SYSCALL afs32_xsetgroups32; #endif /* AFS_SPARC64_LINUX20_ENV */ #endif /* __NR_setgroups32 */ -#ifdef AFS_AMD64_LINUX20_ENV +#ifdef AFS_AMD64_LINUX20_ENV if (ia32_sys_call_table) { - sys32_setgroupsp = + sys32_setgroupsp = SYSCALL2POINTER ia32_sys_call_table[__NR_ia32_setgroups]; - ia32_sys_call_table[__NR_ia32_setgroups] = + ia32_sys_call_table[__NR_ia32_setgroups] = POINTER2SYSCALL afs32_xsetgroups; #if defined(__NR_ia32_setgroups32) - sys32_setgroups32p = + sys32_setgroups32p = SYSCALL2POINTER ia32_sys_call_table[__NR_ia32_setgroups32]; - ia32_sys_call_table[__NR_ia32_setgroups32] = + ia32_sys_call_table[__NR_ia32_setgroups32] = POINTER2SYSCALL afs32_xsetgroups32; #endif /* __NR_ia32_setgroups32 */ } @@ -499,9 +472,11 @@ int init_module(void) } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) -void __exit afs_cleanup(void) +void __exit +afs_cleanup(void) #else -void cleanup_module(void) +void +cleanup_module(void) #endif { struct task_struct *t; @@ -509,7 +484,8 @@ void cleanup_module(void) osi_sysctl_clean(); #if defined(AFS_IA64_LINUX20_ENV) - sys_call_table[__NR_setgroups - 1024] = POINTER2SYSCALL ((struct fptr *) sys_setgroupsp)->ip; + sys_call_table[__NR_setgroups - 1024] = + POINTER2SYSCALL((struct fptr *)sys_setgroupsp)->ip; sys_call_table[__NR_afs_syscall - 1024] = afs_ni_syscall; #else /* AFS_IA64_LINUX20_ENV */ sys_call_table[__NR_setgroups] = POINTER2SYSCALL sys_setgroupsp; @@ -527,19 +503,19 @@ void cleanup_module(void) #endif /* AFS_IA64_LINUX20_ENV */ #ifdef AFS_AMD64_LINUX20_ENV if (ia32_sys_call_table) { - ia32_sys_call_table[__NR_ia32_setgroups] = + ia32_sys_call_table[__NR_ia32_setgroups] = POINTER2SYSCALL sys32_setgroupsp; - ia32_sys_call_table[__NR_ia32_afs_syscall] = + ia32_sys_call_table[__NR_ia32_afs_syscall] = POINTER2SYSCALL ia32_ni_syscall; # if defined(__NR_setgroups32) - ia32_sys_call_table[__NR_ia32_setgroups32] = + ia32_sys_call_table[__NR_ia32_setgroups32] = POINTER2SYSCALL sys32_setgroups32p; #endif } #endif unregister_filesystem(&afs_file_system); - osi_linux_free_inode_pages(); /* Invalidate all pages using AFS inodes. */ + osi_linux_free_inode_pages(); /* Invalidate all pages using AFS inodes. */ osi_linux_free_afs_memory(); return; @@ -551,7 +527,8 @@ module_exit(afs_cleanup); #endif -static long get_page_offset(void) +static long +get_page_offset(void) { #if defined(AFS_PPC_LINUX22_ENV) || defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV) || defined(AFS_ALPHA_LINUX20_ENV) || defined(AFS_S390_LINUX22_ENV) || defined(AFS_IA64_LINUX20_ENV) || defined(AFS_PARISC_LINUX24_ENV) || defined(AFS_AMD64_LINUX20_ENV) return PAGE_OFFSET; @@ -564,21 +541,21 @@ static long get_page_offset(void) #endif /* search backward thru the circular list */ #ifdef DEFINED_PREV_TASK - for(q = current; p = q; q = prev_task(p)) { + for (q = current; p = q; q = prev_task(p)) { #else - for(p = current; p; p = p->prev_task) { + for (p = current; p; p = p->prev_task) { #endif - if (p->pid == 1) { + if (p->pid == 1) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) - read_unlock(&tasklist_lock); + read_unlock(&tasklist_lock); #endif - return p->addr_limit.seg; - } + return p->addr_limit.seg; + } } - + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) read_unlock(&tasklist_lock); #endif - return 0; + return 0; #endif } diff --git a/src/afs/LINUX/osi_prototypes.h b/src/afs/LINUX/osi_prototypes.h index 20af9d15c..b39361a6d 100644 --- a/src/afs/LINUX/osi_prototypes.h +++ b/src/afs/LINUX/osi_prototypes.h @@ -22,25 +22,25 @@ extern void osi_linux_verify_alloced_memory(void); /* osi_cred.c */ extern cred_t *crget(void); -extern void crfree(cred_t *cr); -extern cred_t *crdup(cred_t *cr); +extern void crfree(cred_t * cr); +extern cred_t *crdup(cred_t * cr); extern cred_t *crref(void); -extern void crset(cred_t *cr); +extern void crset(cred_t * cr); /* osi_file.c */ extern afs_rwlock_t afs_xosi; /* osi_misc.c */ extern int osi_lookupname(char *aname, uio_seg_t seg, int followlink, - vnode_t **dirvpp, struct dentry **dpp); + vnode_t ** dirvpp, struct dentry **dpp); extern int osi_InitCacheInfo(char *aname); -extern int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize, - size_t *resid); -extern void inline setup_uio(uio_t *uiop, struct iovec *iovecp, char *buf, +extern int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, + size_t asize, size_t * resid); +extern void inline setup_uio(uio_t * uiop, struct iovec *iovecp, char *buf, afs_offs_t pos, int count, uio_flag_t flag, uio_seg_t seg); -extern int osi_file_uio_rdwr(struct osi_file *osifile, uio_t *uiop, int rw); -extern void afs_osi_SetTime(osi_timeval_t *tvp); +extern int osi_file_uio_rdwr(struct osi_file *osifile, uio_t * uiop, int rw); +extern void afs_osi_SetTime(osi_timeval_t * tvp); extern void osi_linux_free_inode_pages(void); extern void check_bad_parent(struct dentry *dp); diff --git a/src/afs/LINUX/osi_sleep.c b/src/afs/LINUX/osi_sleep.c index 47b7b954a..c9ca2e3d2 100644 --- a/src/afs/LINUX/osi_sleep.c +++ b/src/afs/LINUX/osi_sleep.c @@ -10,31 +10,35 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok); static char waitV, dummyV; -void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) +void +afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) { AFS_STATCNT(osi_InitWaitHandle); achandle->proc = (caddr_t) 0; } /* cancel osi_Wait */ -void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) { caddr_t proc; AFS_STATCNT(osi_CancelWait); proc = achandle->proc; - if (proc == 0) return; - achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ + if (proc == 0) + return; + achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ afs_osi_Wakeup(&waitV); } @@ -42,21 +46,23 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) * Waits for data on ahandle, or ams ms later. ahandle may be null. * Returns 0 if timeout and EINTR if signalled. */ -int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) +int +afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { afs_int32 endTime; struct timer_list *timer = NULL; int code; AFS_STATCNT(osi_Wait); - endTime = osi_Time() + (ams/1000); + endTime = osi_Time() + (ams / 1000); if (ahandle) ahandle->proc = (caddr_t) current; do { AFS_ASSERT_GLOCK(); - code = osi_TimedSleep(&waitV, ams, 1); - if (code) break; + code = osi_TimedSleep(&waitV, ams, 1); + if (code) + break; if (ahandle && (ahandle->proc == (caddr_t) 0)) { /* we've been signalled */ break; @@ -73,8 +79,8 @@ typedef struct afs_event { char *event; /* lwp event: an address */ int refcount; /* Is it in use? */ int seq; /* Sequence number: this is incremented - by wakeup calls; wait will not return until - it changes */ + * by wakeup calls; wait will not return until + * it changes */ #if defined(AFS_LINUX24_ENV) wait_queue_head_t cond; #else @@ -83,13 +89,14 @@ typedef struct afs_event { } afs_event_t; #define HASHSIZE 128 -afs_event_t *afs_evhasht[HASHSIZE];/* Hash table for events */ +afs_event_t *afs_evhasht[HASHSIZE]; /* Hash table for events */ #define afs_evhash(event) (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1)); int afs_evhashcnt = 0; /* Get and initialize event structure corresponding to lwp event (i.e. address) * */ -static afs_event_t *afs_getevent(char *event) +static afs_event_t * +afs_getevent(char *event) { afs_event_t *evp, *newp = 0; int hashcode; @@ -126,11 +133,12 @@ static afs_event_t *afs_getevent(char *event) * a deadlock). */ -static void afs_addevent(char *event) +static void +afs_addevent(char *event) { int hashcode; afs_event_t *newp; - + AFS_ASSERT_GLOCK(); hashcode = afs_evhash(event); newp = osi_linux_alloc(sizeof(afs_event_t), 0); @@ -143,7 +151,7 @@ static void afs_addevent(char *event) init_waitqueue(&newp->cond); #endif newp->seq = 0; - newp->event = &dummyV; /* Dummy address for new events */ + newp->event = &dummyV; /* Dummy address for new events */ newp->refcount = 0; } @@ -159,7 +167,8 @@ static void afs_addevent(char *event) * Waits for an event to be notified, returning early if a signal * is received. Returns EINTR if signaled, and 0 otherwise. */ -int afs_osi_SleepSig(void *event) +int +afs_osi_SleepSig(void *event) { struct afs_event *evp; int seq, retval; @@ -171,8 +180,8 @@ int afs_osi_SleepSig(void *event) evp = afs_getevent(event); if (!evp) { - afs_addevent(event); - evp = afs_getevent(event); + afs_addevent(event); + evp = afs_getevent(event); } seq = evp->seq; @@ -180,7 +189,7 @@ int afs_osi_SleepSig(void *event) add_wait_queue(&evp->cond, &wait); while (seq == evp->seq) { - set_current_state(TASK_INTERRUPTIBLE); + set_current_state(TASK_INTERRUPTIBLE); AFS_ASSERT_GLOCK(); AFS_GUNLOCK(); schedule(); @@ -204,7 +213,8 @@ int afs_osi_SleepSig(void *event) * caller that the wait has been interrupted and the stack should be cleaned * up preparatory to signal delivery */ -void afs_osi_Sleep(void *event) +void +afs_osi_Sleep(void *event) { sigset_t saved_set; @@ -232,7 +242,8 @@ void afs_osi_Sleep(void *event) * Returns 0 if timeout, EINTR if signalled, and EGAIN if it might * have raced. */ -static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) +static int +osi_TimedSleep(char *event, afs_int32 ams, int aintok) { int code = 0; long ticks = (ams * HZ / 1000) + 1; @@ -245,21 +256,21 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) evp = afs_getevent(event); if (!evp) { - afs_addevent(event); + afs_addevent(event); evp = afs_getevent(event); } add_wait_queue(&evp->cond, &wait); set_current_state(TASK_INTERRUPTIBLE); - /* always sleep TASK_INTERRUPTIBLE to keep load average - from artifically increasing. */ + /* always sleep TASK_INTERRUPTIBLE to keep load average + * from artifically increasing. */ AFS_GUNLOCK(); if (aintok) { - if (schedule_timeout(ticks)) - code = EINTR; + if (schedule_timeout(ticks)) + code = EINTR; } else - schedule_timeout(ticks); + schedule_timeout(ticks); AFS_GLOCK(); remove_wait_queue(&evp->cond, &wait); @@ -271,19 +282,20 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) } -int afs_osi_Wakeup(void *event) +int +afs_osi_Wakeup(void *event) { - int ret=2; + int ret = 2; struct afs_event *evp; evp = afs_getevent(event); - if (!evp) /* No sleepers */ + if (!evp) /* No sleepers */ return 1; if (evp->refcount > 1) { - evp->seq++; + evp->seq++; wake_up(&evp->cond); - ret=0; + ret = 0; } relevent(evp); return ret; diff --git a/src/afs/LINUX/osi_sysctl.c b/src/afs/LINUX/osi_sysctl.c index 5bb9a5a5d..d47868fd4 100644 --- a/src/afs/LINUX/osi_sysctl.c +++ b/src/afs/LINUX/osi_sysctl.c @@ -11,7 +11,7 @@ #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #include #include @@ -25,44 +25,51 @@ extern afs_int32 hm_retry_int; static struct ctl_table_header *afs_sysctl = NULL; static ctl_table afs_sysctl_table[] = { - {1, "hm_retry_RO", - &hm_retry_RO, sizeof(afs_int32), 0644, NULL, - &proc_dointvec}, - {2, "hm_retry_RW", - &hm_retry_RW, sizeof(afs_int32), 0644, NULL, - &proc_dointvec}, - {3, "hm_retry_int", - &hm_retry_int, sizeof(afs_int32), 0644, NULL, - &proc_dointvec}, - {4, "GCPAGs", - &afs_gcpags, sizeof(afs_int32), 0644, NULL, - &proc_dointvec}, - {5, "rx_deadtime", - &afs_rx_deadtime, sizeof(afs_int32), 0644, NULL, - &proc_dointvec}, - {0} + {1, "hm_retry_RO", + &hm_retry_RO, sizeof(afs_int32), 0644, NULL, + &proc_dointvec} + , + {2, "hm_retry_RW", + &hm_retry_RW, sizeof(afs_int32), 0644, NULL, + &proc_dointvec} + , + {3, "hm_retry_int", + &hm_retry_int, sizeof(afs_int32), 0644, NULL, + &proc_dointvec} + , + {4, "GCPAGs", + &afs_gcpags, sizeof(afs_int32), 0644, NULL, + &proc_dointvec} + , + {5, "rx_deadtime", + &afs_rx_deadtime, sizeof(afs_int32), 0644, NULL, + &proc_dointvec} + , + {0} }; static ctl_table fs_sysctl_table[] = { - {1, "afs", NULL, 0, 0555, afs_sysctl_table}, - {0} + {1, "afs", NULL, 0, 0555, afs_sysctl_table}, + {0} }; -int osi_sysctl_init() +int +osi_sysctl_init() { - afs_sysctl = register_sysctl_table(fs_sysctl_table, 0); - if (!afs_sysctl) - return -1; + afs_sysctl = register_sysctl_table(fs_sysctl_table, 0); + if (!afs_sysctl) + return -1; - return 0; + return 0; } -void osi_sysctl_clean() +void +osi_sysctl_clean() { - if (afs_sysctl) { - unregister_sysctl_table(afs_sysctl); - afs_sysctl = NULL; - } + if (afs_sysctl) { + unregister_sysctl_table(afs_sysctl); + afs_sysctl = NULL; + } } #endif /* CONFIG_SYSCTL */ diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index b9880cb5a..7ef1bc704 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -15,7 +15,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" @@ -25,14 +26,14 @@ RCSID("$Header$"); #include "h/smp_lock.h" #endif -#define __NO_VERSION__ /* don't define kernel_verion in module.h */ +#define __NO_VERSION__ /* don't define kernel_verion in module.h */ #include struct vcache *afs_globalVp = 0; struct vfs *afs_globalVFS = 0; struct nameidata afs_cacheNd; -int afs_was_mounted = 0; /* Used to force reload if mount/unmount/mount */ +int afs_was_mounted = 0; /* Used to force reload if mount/unmount/mount */ extern struct super_operations afs_sops; extern afs_rwlock_t afs_xvcache; @@ -59,11 +60,11 @@ void put_inode_on_dummy_list(struct inode *ip); DECLARE_FSTYPE(afs_file_system, "afs", afs_read_super, 0); #else struct file_system_type afs_file_system = { - "afs", /* name - used by mount operation. */ - 0, /* requires_dev - no for network filesystems. mount() will - * pass us an "unnamed" device. */ - afs_read_super, /* wrapper to afs_mount */ - NULL /* pointer to next file_system_type once registered. */ + "afs", /* name - used by mount operation. */ + 0, /* requires_dev - no for network filesystems. mount() will + * pass us an "unnamed" device. */ + afs_read_super, /* wrapper to afs_mount */ + NULL /* pointer to next file_system_type once registered. */ }; #endif @@ -71,14 +72,15 @@ struct file_system_type afs_file_system = { * read the "super block" for AFS - roughly eguivalent to struct vfs. * dev, covered, s_rd_only, s_dirt, and s_type will be set by read_super. */ -struct super_block *afs_read_super(struct super_block *sb, void *data, - int silent) +struct super_block * +afs_read_super(struct super_block *sb, void *data, int silent) { int code = 0; AFS_GLOCK(); if (afs_was_mounted) { - printf("You must reload the AFS kernel extensions before remounting AFS.\n"); + printf + ("You must reload the AFS kernel extensions before remounting AFS.\n"); AFS_GUNLOCK(); return NULL; } @@ -112,11 +114,12 @@ struct super_block *afs_read_super(struct super_block *sb, void *data, /* afs_root - stat the root of the file system. AFS global held on entry. */ -static int afs_root(struct super_block *afsp) +static int +afs_root(struct super_block *afsp) { register afs_int32 code = 0; struct vrequest treq; - register struct vcache *tvp=0; + register struct vcache *tvp = 0; AFS_STATCNT(afs_root); if (afs_globalVp && (afs_globalVp->states & CStatd)) { @@ -129,15 +132,14 @@ static int afs_root(struct super_block *afsp) afs_globalVp = NULL; } - if (!(code = afs_InitReq(&treq, credp)) && - !(code = afs_CheckInit())) { + if (!(code = afs_InitReq(&treq, credp)) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); if (tvp) { extern struct inode_operations afs_dir_iops; #if defined(AFS_LINUX24_ENV) extern struct file_operations afs_dir_fops; #endif - + /* "/afs" is a directory, reset inode ops accordingly. */ AFSTOV(tvp)->v_op = &afs_dir_iops; #if defined(AFS_LINUX24_ENV) @@ -171,7 +173,8 @@ static int afs_root(struct super_block *afsp) * inode information, so we don't really care what happens here. * For Linux 2.2, we'll be called if we participate in the inode pool. */ -void afs_read_inode(struct inode *ip) +void +afs_read_inode(struct inode *ip) { /* I don't think we ever get called with this. So print if we do. */ printf("afs_read_inode: Called for inode %d\n", ip->i_ino); @@ -182,7 +185,8 @@ void afs_read_inode(struct inode *ip) * Linux version of setattr call. What to change is in the iattr struct. * We need to set bits in both the Linux inode as well as the vcache. */ -int afs_notify_change(struct dentry *dp, struct iattr* iattrp) +int +afs_notify_change(struct dentry *dp, struct iattr *iattrp) { struct vattr vattr; int code; @@ -191,7 +195,7 @@ int afs_notify_change(struct dentry *dp, struct iattr* iattrp) AFS_GLOCK(); VATTR_NULL(&vattr); - iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */ + iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */ update_inode_cache(ip, &vattr); code = afs_setattr(ITOAFS(ip), &vattr, credp); afs_CopyOutAttrs(ITOAFS(ip), &vattr); @@ -224,9 +228,11 @@ static LIST_HEAD(dummy_inode_list); * has synced some pages of a file to disk. */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) -void afs_write_inode(struct inode *ip, int unused) +void +afs_write_inode(struct inode *ip, int unused) #else -void afs_write_inode(struct inode *ip) +void +afs_write_inode(struct inode *ip) #endif { /* and put it back on our dummy list. */ @@ -245,7 +251,8 @@ void afs_write_inode(struct inode *ip) * That will trigger the call to delete routine. */ -void afs_delete_inode(struct inode *ip) +void +afs_delete_inode(struct inode *ip) { struct vcache *vc = ITOAFS(ip); @@ -257,7 +264,8 @@ void afs_delete_inode(struct inode *ip) /* afs_put_super * Called from unmount to release super_block. */ -void afs_put_super(struct super_block *sbp) +void +afs_put_super(struct super_block *sbp) { extern int afs_afs_cold_shutdown; int code = 0; @@ -277,7 +285,7 @@ void afs_put_super(struct super_block *sbp) path_release(&afs_cacheNd); osi_linux_verify_alloced_memory(); - done: + done: AFS_GUNLOCK(); if (!code) { @@ -289,14 +297,16 @@ void afs_put_super(struct super_block *sbp) #ifdef NOTUSED /* afs_write_super * Not required since we don't write out a super block. */ -void afs_write_super(struct super_block *sbp) +void +afs_write_super(struct super_block *sbp) { } /* afs_remount_fs * Used to remount filesystems with different flags. Not relevant for AFS. */ -int afs_remount_fs(struct super_block *sbp, int *, char *) +int +afs_remount_fs(struct super_block *sbp, int *, char *) { return -EINVAL; } @@ -307,9 +317,11 @@ int afs_remount_fs(struct super_block *sbp, int *, char *) * copy it. */ #if defined(AFS_LINUX24_ENV) -int afs_statfs(struct super_block *sbp, struct statfs *statp) +int +afs_statfs(struct super_block *sbp, struct statfs *statp) #else -int afs_statfs(struct super_block *sbp, struct statfs *statp, int size) +int +afs_statfs(struct super_block *sbp, struct statfs *statp, int size) #endif { struct statfs stat; @@ -319,12 +331,12 @@ int afs_statfs(struct super_block *sbp, struct statfs *statp, int size) #if !defined(AFS_LINUX24_ENV) if (size < sizeof(struct statfs)) return; - + memset(&stat, 0, size); #endif - stat.f_type = 0; /* Can we get a real type sometime? */ + stat.f_type = 0; /* Can we get a real type sometime? */ stat.f_bsize = sbp->s_blocksize; - stat.f_blocks = stat.f_bfree = stat.f_bavail = stat.f_files = + stat.f_blocks = stat.f_bfree = stat.f_bavail = stat.f_files = stat.f_ffree = 9000000; stat.f_fsid.val[0] = AFS_VFSMAGIC; stat.f_fsid.val[1] = AFS_VFSFSID; @@ -339,33 +351,33 @@ int afs_statfs(struct super_block *sbp, struct statfs *statp, int size) } -void +void afs_umount_begin(struct super_block *sbp) { - afs_shuttingdown=1; + afs_shuttingdown = 1; } #if defined(AFS_LINUX24_ENV) struct super_operations afs_sops = { - read_inode: afs_read_inode, - write_inode: afs_write_inode, - delete_inode: afs_delete_inode, - put_super: afs_put_super, - statfs: afs_statfs, - umount_begin: afs_umount_begin + read_inode:afs_read_inode, + write_inode:afs_write_inode, + delete_inode:afs_delete_inode, + put_super:afs_put_super, + statfs:afs_statfs, + umount_begin:afs_umount_begin }; #else struct super_operations afs_sops = { afs_read_inode, afs_write_inode, /* afs_write_inode - see doc above. */ - NULL, /* afs_put_inode */ + NULL, /* afs_put_inode */ afs_delete_inode, afs_notify_change, afs_put_super, - NULL, /* afs_write_super - see doc above */ + NULL, /* afs_write_super - see doc above */ afs_statfs, - NULL, /* afs_remount_fs - see doc above */ - NULL, /* afs_clear_inode */ + NULL, /* afs_remount_fs - see doc above */ + NULL, /* afs_clear_inode */ afs_umount_begin }; #endif @@ -375,7 +387,8 @@ struct super_operations afs_sops = { /* vattr_setattr * Set iattr data into vattr. Assume vattr cleared before call. */ -static void iattr2vattr(struct vattr *vattrp, struct iattr *iattrp) +static void +iattr2vattr(struct vattr *vattrp, struct iattr *iattrp) { vattrp->va_mask = iattrp->ia_valid; if (iattrp->ia_valid & ATTR_MODE) @@ -404,7 +417,8 @@ static void iattr2vattr(struct vattr *vattrp, struct iattr *iattrp) * Update inode with info from vattr struct. Use va_mask to determine what * to update. */ -static void update_inode_cache(struct inode *ip, struct vattr *vp) +static void +update_inode_cache(struct inode *ip, struct vattr *vp) { if (vp->va_mask & ATTR_MODE) ip->i_mode = vp->va_mode; @@ -425,7 +439,8 @@ static void update_inode_cache(struct inode *ip, struct vattr *vp) /* vattr2inode * Rewrite the inode cache from the attr. Assumes all vattr fields are valid. */ -void vattr2inode(struct inode *ip, struct vattr *vp) +void +vattr2inode(struct inode *ip, struct vattr *vp) { ip->i_ino = vp->va_nodeid; ip->i_nlink = vp->va_nlink; @@ -440,11 +455,11 @@ void vattr2inode(struct inode *ip, struct vattr *vp) ip->i_mtime = vp->va_mtime.tv_sec; ip->i_ctime = vp->va_ctime.tv_sec; - /* we should put our inodes on a dummy inode list to keep linux happy.*/ - if (!ip->i_list.prev && !ip->i_list.next) { + /* we should put our inodes on a dummy inode list to keep linux happy. */ + if (!ip->i_list.prev && !ip->i_list.next) { /* this might be bad as we are reaching under the covers of the * list structure but we want to avoid putting the inode - * on the list more than once. */ + * on the list more than once. */ put_inode_on_dummy_list(ip); } } @@ -453,23 +468,26 @@ void vattr2inode(struct inode *ip, struct vattr *vp) * nicely strung up in lists. Linux inode syncing code chokes on our inodes if * they're not on any lists. */ -void put_inode_on_dummy_list(struct inode *ip) +void +put_inode_on_dummy_list(struct inode *ip) { /* Initialize list. See explanation above. */ list_add(&ip->i_list, &dummy_inode_list); } /* And yet another routine to update the inode cache - called from ProcessFS */ -void vcache2inode(struct vcache *avc) +void +vcache2inode(struct vcache *avc) { struct vattr vattr; VATTR_NULL(&vattr); - afs_CopyOutAttrs(avc, &vattr); /* calls vattr2inode */ + afs_CopyOutAttrs(avc, &vattr); /* calls vattr2inode */ } /* Yet another one for fakestat'ed mountpoints */ -void vcache2fakeinode(struct vcache *rootvp, struct vcache *mpvp) +void +vcache2fakeinode(struct vcache *rootvp, struct vcache *mpvp) { struct vattr vattr; diff --git a/src/afs/LINUX/osi_vm.c b/src/afs/LINUX/osi_vm.c index 0c15dcb87..9d6259fc1 100644 --- a/src/afs/LINUX/osi_vm.c +++ b/src/afs/LINUX/osi_vm.c @@ -10,7 +10,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ @@ -39,7 +40,8 @@ RCSID("$Header$"); * is not dropped and re-acquired for any platform. It may be that *slept is * therefore obsolescent. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { struct inode *ip = AFSTOI(avc); @@ -68,7 +70,8 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Since we drop and re-obtain the lock, we can't guarantee that there won't * be some pages around when we return, newly created by concurrent activity. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { invalidate_inode_pages(AFSTOI(avc)); } @@ -77,7 +80,8 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) * * Locking: only the global lock is held. */ -void osi_VM_FSyncInval(struct vcache *avc) +void +osi_VM_FSyncInval(struct vcache *avc) { } @@ -87,7 +91,8 @@ void osi_VM_FSyncInval(struct vcache *avc) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { struct inode *ip = AFSTOI(avc); @@ -106,7 +111,8 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * * Locking: No lock is held, not even the global lock. */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) struct inode *ip = AFSTOI(avc); @@ -127,7 +133,8 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * activeV is raised. This is supposed to block pageins, but at present * it only works on Solaris. */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) struct inode *ip = AFSTOI(avc); diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index a88afdba6..d6bbf18af 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -23,7 +23,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" @@ -55,11 +56,14 @@ extern struct inode_operations afs_symlink_iops; #ifdef NOTUSED -static int afs_linux_lseek(struct inode *ip, struct file *fp, off_t, int) {} +static int +afs_linux_lseek(struct inode *ip, struct file *fp, off_t, int) +{ +} #endif -static ssize_t afs_linux_read(struct file *fp, char *buf, size_t count, - loff_t *offp) +static ssize_t +afs_linux_read(struct file *fp, char *buf, size_t count, loff_t * offp) { ssize_t code; struct vcache *vcp = ITOAFS(fp->f_dentry->d_inode); @@ -68,9 +72,8 @@ static ssize_t afs_linux_read(struct file *fp, char *buf, size_t count, AFS_GLOCK(); afs_Trace4(afs_iclSetp, CM_TRACE_READOP, ICL_TYPE_POINTER, vcp, - ICL_TYPE_OFFSET, offp, - ICL_TYPE_INT32, count, - ICL_TYPE_INT32, 99999); + ICL_TYPE_OFFSET, offp, ICL_TYPE_INT32, count, ICL_TYPE_INT32, + 99999); /* get a validated vcache entry */ code = afs_InitReq(&treq, credp); @@ -82,8 +85,8 @@ static ssize_t afs_linux_read(struct file *fp, char *buf, size_t count, else { #ifdef AFS_64BIT_CLIENT if (*offp + count > afs_vmMappingEnd) { - uio_t tuio; - struct iovec iov; + uio_t tuio; + struct iovec iov; afs_size_t oldOffset = *offp; afs_int32 xfered = 0; @@ -91,7 +94,7 @@ static ssize_t afs_linux_read(struct file *fp, char *buf, size_t count, /* special case of a buffer crossing the VM mapping end */ afs_int32 tcount = afs_vmMappingEnd - *offp; count -= tcount; - osi_FlushPages(vcp, credp); /* ensure stale pages are gone */ + osi_FlushPages(vcp, credp); /* ensure stale pages are gone */ AFS_GUNLOCK(); code = generic_file_read(fp, buf, tcount, offp); AFS_GLOCK(); @@ -99,23 +102,22 @@ static ssize_t afs_linux_read(struct file *fp, char *buf, size_t count, goto done; } xfered = tcount; - } - setup_uio(&tuio, &iov, buf + xfered, (afs_offs_t) *offp, count, - UIO_READ, AFS_UIOSYS); - code = afs_read(vcp, &tuio, credp, 0, 0, 0); + } + setup_uio(&tuio, &iov, buf + xfered, (afs_offs_t) * offp, count, + UIO_READ, AFS_UIOSYS); + code = afs_read(vcp, &tuio, credp, 0, 0, 0); xfered += count - tuio.uio_resid; if (code != 0) { - afs_Trace4(afs_iclSetp, CM_TRACE_READOP, ICL_TYPE_POINTER, vcp, - ICL_TYPE_OFFSET, offp, - ICL_TYPE_INT32, -1, - ICL_TYPE_INT32, code); + afs_Trace4(afs_iclSetp, CM_TRACE_READOP, ICL_TYPE_POINTER, + vcp, ICL_TYPE_OFFSET, offp, ICL_TYPE_INT32, -1, + ICL_TYPE_INT32, code); code = xfered; *offp += count - tuio.uio_resid; } else { code = xfered; *offp += count; } -done: + done: } else { #endif /* AFS_64BIT_CLIENT */ osi_FlushPages(vcp, credp); /* ensure stale pages are gone */ @@ -128,9 +130,8 @@ done: } afs_Trace4(afs_iclSetp, CM_TRACE_READOP, ICL_TYPE_POINTER, vcp, - ICL_TYPE_OFFSET, offp, - ICL_TYPE_INT32, count, - ICL_TYPE_INT32, code); + ICL_TYPE_OFFSET, offp, ICL_TYPE_INT32, count, ICL_TYPE_INT32, + code); AFS_GUNLOCK(); crfree(credp); @@ -142,8 +143,8 @@ done: * also takes care of re-positioning the pointer if file is open in append * mode. Call fake open/close to ensure we do writes of core dumps. */ -static ssize_t afs_linux_write(struct file *fp, const char *buf, size_t count, - loff_t *offp) +static ssize_t +afs_linux_write(struct file *fp, const char *buf, size_t count, loff_t * offp) { ssize_t code = 0; int code2; @@ -155,15 +156,14 @@ static ssize_t afs_linux_write(struct file *fp, const char *buf, size_t count, AFS_GLOCK(); afs_Trace4(afs_iclSetp, CM_TRACE_WRITEOP, ICL_TYPE_POINTER, vcp, - ICL_TYPE_OFFSET, offp, - ICL_TYPE_INT32, count, - ICL_TYPE_INT32, (fp->f_flags & O_APPEND) ? 99998 : 99999); + ICL_TYPE_OFFSET, offp, ICL_TYPE_INT32, count, ICL_TYPE_INT32, + (fp->f_flags & O_APPEND) ? 99998 : 99999); /* get a validated vcache entry */ - code = (ssize_t)afs_InitReq(&treq, credp); + code = (ssize_t) afs_InitReq(&treq, credp); if (!code) - code = (ssize_t)afs_VerifyVCache(vcp, &treq); + code = (ssize_t) afs_VerifyVCache(vcp, &treq); ObtainWriteLock(&vcp->lock, 529); afs_FakeOpen(vcp); @@ -173,11 +173,11 @@ static ssize_t afs_linux_write(struct file *fp, const char *buf, size_t count, else { #ifdef AFS_64BIT_CLIENT toffs = *offp; - if (fp->f_flags & O_APPEND) + if (fp->f_flags & O_APPEND) toffs += vcp->m.Length; if (toffs + count > afs_vmMappingEnd) { - uio_t tuio; - struct iovec iov; + uio_t tuio; + struct iovec iov; afs_size_t oldOffset = *offp; afs_int32 xfered = 0; @@ -193,60 +193,60 @@ static ssize_t afs_linux_write(struct file *fp, const char *buf, size_t count, } xfered = tcount; toffs += tcount; - } + } setup_uio(&tuio, &iov, buf + xfered, (afs_offs_t) toffs, count, - UIO_WRITE, AFS_UIOSYS); - code = afs_write(vcp, &tuio, fp->f_flags, credp, 0); + UIO_WRITE, AFS_UIOSYS); + code = afs_write(vcp, &tuio, fp->f_flags, credp, 0); xfered += count - tuio.uio_resid; if (code != 0) { code = xfered; *offp += count - tuio.uio_resid; } else { - /* Purge dirty chunks of file if there are too many dirty chunks. - * Inside the write loop, we only do this at a chunk boundary. - * Clean up partial chunk if necessary at end of loop. - */ - if (AFS_CHUNKBASE(tuio.afsio_offset) != AFS_CHUNKBASE(oldOffset)) { - ObtainWriteLock(&vcp->lock,402); - code = afs_DoPartialWrite(vcp, &treq); - vcp->states |= CDirty; - ReleaseWriteLock(&vcp->lock); - } + /* Purge dirty chunks of file if there are too many dirty chunks. + * Inside the write loop, we only do this at a chunk boundary. + * Clean up partial chunk if necessary at end of loop. + */ + if (AFS_CHUNKBASE(tuio.afsio_offset) != + AFS_CHUNKBASE(oldOffset)) { + ObtainWriteLock(&vcp->lock, 402); + code = afs_DoPartialWrite(vcp, &treq); + vcp->states |= CDirty; + ReleaseWriteLock(&vcp->lock); + } code = xfered; *offp += count; toffs += count; - ObtainWriteLock(&vcp->lock,400); - vcp->m.Date = osi_Time(); /* Set file date (for ranlib) */ - /* extend file */ - if (!(fp->f_flags & O_APPEND) && toffs > vcp->m.Length) { + ObtainWriteLock(&vcp->lock, 400); + vcp->m.Date = osi_Time(); /* Set file date (for ranlib) */ + /* extend file */ + if (!(fp->f_flags & O_APPEND) && toffs > vcp->m.Length) { vcp->m.Length = toffs; - } - ReleaseWriteLock(&vcp->lock); + } + ReleaseWriteLock(&vcp->lock); } -done: + done: } else { #endif /* AFS_64BIT_CLIENT */ - AFS_GUNLOCK(); + AFS_GUNLOCK(); code = generic_file_write(fp, buf, count, offp); - AFS_GLOCK(); + AFS_GLOCK(); #ifdef AFS_64BIT_CLIENT } #endif /* AFS_64BIT_CLIENT */ } ObtainWriteLock(&vcp->lock, 530); - vcp->m.Date = osi_Time(); /* set modification time */ + vcp->m.Date = osi_Time(); /* set modification time */ afs_FakeClose(vcp, credp); - if (code>=0) - code2 = afs_DoPartialWrite(vcp, &treq); - if (code2 && code >=0) - code = (ssize_t) -code2; + if (code >= 0) + code2 = afs_DoPartialWrite(vcp, &treq); + if (code2 && code >= 0) + code = (ssize_t) - code2; ReleaseWriteLock(&vcp->lock); - + afs_Trace4(afs_iclSetp, CM_TRACE_WRITEOP, ICL_TYPE_POINTER, vcp, - ICL_TYPE_OFFSET, offp, - ICL_TYPE_INT32, count, - ICL_TYPE_INT32, code); + ICL_TYPE_OFFSET, offp, ICL_TYPE_INT32, count, ICL_TYPE_INT32, + code); AFS_GUNLOCK(); crfree(credp); @@ -257,10 +257,10 @@ done: * filldir instead of afs_readdir_move. Note that changes to vcache/dcache * handling and use of bulkstats will need to be reflected here as well. */ -static int afs_linux_readdir(struct file *fp, - void *dirbuf, filldir_t filldir) +static int +afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) { - extern struct DirEntry * afs_dir_GetBlob(); + extern struct DirEntry *afs_dir_GetBlob(); struct vcache *avc = ITOAFS(FILE_INODE(fp)); struct vrequest treq; register struct dcache *tdc; @@ -293,7 +293,7 @@ static int afs_linux_readdir(struct file *fp, } /* update the cache entry */ -tagain: + tagain: code = afs_VerifyVCache(avc, &treq); if (code) { afs_PutFakeStat(&fakestat); @@ -339,7 +339,7 @@ tagain: */ code = 0; offset = (int)fp->f_pos; - while(1) { + while (1) { dirpos = BlobScan(&tdc->f.inode, offset); if (!dirpos) break; @@ -349,56 +349,55 @@ tagain: break; ino = (avc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode); - ino &= 0x7fffffff; /* Assumes 32 bit ino_t ..... */ + ino &= 0x7fffffff; /* Assumes 32 bit ino_t ..... */ len = strlen(de->name); /* filldir returns -EINVAL when the buffer is full. */ #if (defined(AFS_LINUX24_ENV) || defined(pgoff2loff)) && defined(DECLARE_FSTYPE) - { - unsigned int type=DT_UNKNOWN; - struct VenusFid afid; - struct vcache *tvc; - int vtype; - afid.Cell=avc->fid.Cell; - afid.Fid.Volume=avc->fid.Fid.Volume; - afid.Fid.Vnode=ntohl(de->fid.vnode); - afid.Fid.Unique=ntohl(de->fid.vunique); - if ((avc->states & CForeign) == 0 && - (ntohl(de->fid.vnode) & 1)) { - type=DT_DIR; - } else if ((tvc=afs_FindVCache(&afid,0,0))) { - if (tvc->mvstat) { - type=DT_DIR; - } else if (((tvc->states) & (CStatd|CTruth))) { - /* CTruth will be set if the object has - *ever* been statd */ - vtype=vType(tvc); - if (vtype == VDIR) - type=DT_DIR; - else if (vtype == VREG) - type=DT_REG; - /* Don't do this until we're sure it can't be a mtpt */ - /* else if (vtype == VLNK) - type=DT_LNK; */ - /* what other types does AFS support? */ - } - /* clean up from afs_FindVCache */ - afs_PutVCache(tvc); - } - code = (*filldir)(dirbuf, de->name, len, offset, ino, type); - } + { + unsigned int type = DT_UNKNOWN; + struct VenusFid afid; + struct vcache *tvc; + int vtype; + afid.Cell = avc->fid.Cell; + afid.Fid.Volume = avc->fid.Fid.Volume; + afid.Fid.Vnode = ntohl(de->fid.vnode); + afid.Fid.Unique = ntohl(de->fid.vunique); + if ((avc->states & CForeign) == 0 && (ntohl(de->fid.vnode) & 1)) { + type = DT_DIR; + } else if ((tvc = afs_FindVCache(&afid, 0, 0))) { + if (tvc->mvstat) { + type = DT_DIR; + } else if (((tvc->states) & (CStatd | CTruth))) { + /* CTruth will be set if the object has + *ever* been statd */ + vtype = vType(tvc); + if (vtype == VDIR) + type = DT_DIR; + else if (vtype == VREG) + type = DT_REG; + /* Don't do this until we're sure it can't be a mtpt */ + /* else if (vtype == VLNK) + * type=DT_LNK; */ + /* what other types does AFS support? */ + } + /* clean up from afs_FindVCache */ + afs_PutVCache(tvc); + } + code = (*filldir) (dirbuf, de->name, len, offset, ino, type); + } #else - code = (*filldir)(dirbuf, de->name, len, offset, ino); + code = (*filldir) (dirbuf, de->name, len, offset, ino); #endif DRelease(de, 0); if (code) break; - offset = dirpos + 1 + ((len+16)>>5); + offset = dirpos + 1 + ((len + 16) >> 5); } /* If filldir didn't fill in the last one this is still pointing to that * last attempt. */ - fp->f_pos = (loff_t)offset; + fp->f_pos = (loff_t) offset; ReleaseReadLock(&tdc->lock); afs_PutDCache(tdc); @@ -413,8 +412,8 @@ int afs_linux_select(struct inode *ip, struct file *fp, int, select_table *); #endif /* in afs_pioctl.c */ -extern int afs_xioctl(struct inode *ip, struct file *fp, - unsigned int com, unsigned long arg); +extern int afs_xioctl(struct inode *ip, struct file *fp, unsigned int com, + unsigned long arg); /* We need to detect unmap's after close. To do that, we need our own @@ -427,7 +426,8 @@ static int afs_private_mmap_ops_inited = 0; static struct vm_operations_struct afs_shared_mmap_ops; static int afs_shared_mmap_ops_inited = 0; -void afs_linux_vma_close(struct vm_area_struct *vmap) +void +afs_linux_vma_close(struct vm_area_struct *vmap) { struct vcache *vcp; cred_t *credp; @@ -441,27 +441,26 @@ void afs_linux_vma_close(struct vm_area_struct *vmap) return; AFS_GLOCK(); - afs_Trace4(afs_iclSetp, CM_TRACE_VM_CLOSE, - ICL_TYPE_POINTER, vcp, - ICL_TYPE_INT32, vcp->mapcnt, - ICL_TYPE_INT32, vcp->opens, + afs_Trace4(afs_iclSetp, CM_TRACE_VM_CLOSE, ICL_TYPE_POINTER, vcp, + ICL_TYPE_INT32, vcp->mapcnt, ICL_TYPE_INT32, vcp->opens, ICL_TYPE_INT32, vcp->execsOrWriters); if ((&vcp->lock)->excl_locked == 0 || (&vcp->lock)->pid_writer == MyPidxx) { ObtainWriteLock(&vcp->lock, 532); need_unlock = 1; } else - printk("AFS_VMA_CLOSE(%d): Skipping Already locked vcp=%p vmap=%p\n", MyPidxx, &vcp, &vmap); + printk("AFS_VMA_CLOSE(%d): Skipping Already locked vcp=%p vmap=%p\n", + MyPidxx, &vcp, &vmap); if (vcp->mapcnt) { vcp->mapcnt--; if (need_unlock) ReleaseWriteLock(&vcp->lock); if (!vcp->mapcnt) { - if(need_unlock && vcp->execsOrWriters < 2) { + if (need_unlock && vcp->execsOrWriters < 2) { credp = crref(); - (void) afs_close(vcp, vmap->vm_file->f_flags, credp); + (void)afs_close(vcp, vmap->vm_file->f_flags, credp); /* only decrement the execsOrWriters flag if this is not a - writable file. */ - if (! (vmap->vm_file->f_flags & (FWRITE | FTRUNC))) + * writable file. */ + if (!(vmap->vm_file->f_flags & (FWRITE | FTRUNC))) vcp->execsOrWriters--; vcp->states &= ~CMAPPED; crfree(credp); @@ -474,17 +473,17 @@ void afs_linux_vma_close(struct vm_area_struct *vmap) vcp->execsOrWriters = 1; } } - } - else { + } else { if (need_unlock) ReleaseWriteLock(&vcp->lock); } - unlock_exit: + unlock_exit: AFS_GUNLOCK(); } -static int afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap) +static int +afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap) { struct vcache *vcp = ITOAFS(FILE_INODE(fp)); cred_t *credp = crref(); @@ -494,13 +493,13 @@ static int afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap) AFS_GLOCK(); #if defined(AFS_LINUX24_ENV) afs_Trace3(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vcp, - ICL_TYPE_POINTER, vmap->vm_start, - ICL_TYPE_INT32, vmap->vm_end - vmap->vm_start); + ICL_TYPE_POINTER, vmap->vm_start, ICL_TYPE_INT32, + vmap->vm_end - vmap->vm_start); #else afs_Trace4(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vcp, - ICL_TYPE_POINTER, vmap->vm_start, - ICL_TYPE_INT32, vmap->vm_end - vmap->vm_start, - ICL_TYPE_INT32, vmap->vm_offset); + ICL_TYPE_POINTER, vmap->vm_start, ICL_TYPE_INT32, + vmap->vm_end - vmap->vm_start, ICL_TYPE_INT32, + vmap->vm_offset); #endif /* get a validated vcache entry */ @@ -520,7 +519,7 @@ static int afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap) } if (code == 0) { - ObtainWriteLock(&vcp->lock,531); + ObtainWriteLock(&vcp->lock, 531); /* Set out vma ops so we catch the close. The following test should be * the same as used in generic_file_mmap. */ @@ -531,8 +530,7 @@ static int afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap) afs_shared_mmap_ops.close = afs_linux_vma_close; } vmap->vm_ops = &afs_shared_mmap_ops; - } - else { + } else { if (!afs_private_mmap_ops_inited) { afs_private_mmap_ops_inited = 1; afs_private_mmap_ops = *vmap->vm_ops; @@ -557,7 +555,8 @@ static int afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap) return code; } -int afs_linux_open(struct inode *ip, struct file *fp) +int +afs_linux_open(struct inode *ip, struct file *fp) { int code; cred_t *credp = crref(); @@ -566,7 +565,7 @@ int afs_linux_open(struct inode *ip, struct file *fp) #ifdef AFS_LINUX24_ENV lock_kernel(); #endif - code = afs_open((struct vcache**)&ip, fp->f_flags, credp); + code = afs_open((struct vcache **)&ip, fp->f_flags, credp); #ifdef AFS_LINUX24_ENV unlock_kernel(); #endif @@ -583,7 +582,8 @@ int afs_linux_open(struct inode *ip, struct file *fp) * fput. See afs_linux_flush for notes on interactions between release and * flush. */ -static int afs_linux_release(struct inode *ip, struct file *fp) +static int +afs_linux_release(struct inode *ip, struct file *fp) { int code = 0; cred_t *credp = crref(); @@ -594,9 +594,8 @@ static int afs_linux_release(struct inode *ip, struct file *fp) lock_kernel(); #endif if (vcp->flushcnt) { - vcp->flushcnt--; /* protected by AFS global lock. */ - } - else { + vcp->flushcnt--; /* protected by AFS global lock. */ + } else { code = afs_close(vcp, fp->f_flags, credp); } #ifdef AFS_LINUX24_ENV @@ -609,9 +608,11 @@ static int afs_linux_release(struct inode *ip, struct file *fp) } #if defined(AFS_LINUX24_ENV) -static int afs_linux_fsync(struct file *fp, struct dentry *dp, int datasync) +static int +afs_linux_fsync(struct file *fp, struct dentry *dp, int datasync) #else -static int afs_linux_fsync(struct file *fp, struct dentry *dp) +static int +afs_linux_fsync(struct file *fp, struct dentry *dp) #endif { int code; @@ -629,7 +630,7 @@ static int afs_linux_fsync(struct file *fp, struct dentry *dp) AFS_GUNLOCK(); crfree(credp); return -code; - + } #ifdef NOTUSED @@ -643,7 +644,8 @@ int afs_linux_check_media_change(kdev_t dev); int afs_linux_file_revalidate(kdev_t dev); #endif /* NOTUSED */ -static int afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) +static int +afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) { int code = 0; struct vcache *vcp = ITOAFS(FILE_INODE(fp)); @@ -653,9 +655,9 @@ static int afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) #else struct flock flock; #endif - + /* Convert to a lock format afs_lockctl understands. */ - memset((char*)&flock, 0, sizeof(flock)); + memset((char *)&flock, 0, sizeof(flock)); flock.l_type = flp->fl_type; flock.l_pid = flp->fl_pid; flock.l_whence = 0; @@ -684,7 +686,7 @@ static int afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) crfree(credp); return -code; - + } /* afs_linux_flush @@ -699,7 +701,8 @@ static int afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) * on the just flushed file is wasteful, since the background daemon will * execute the code that finally decides there is nothing to do. */ -int afs_linux_flush(struct file *fp) +int +afs_linux_flush(struct file *fp) { struct vcache *vcp = ITOAFS(FILE_INODE(fp)); int code = 0; @@ -717,7 +720,7 @@ int afs_linux_flush(struct file *fp) AFS_GLOCK(); code = afs_close(vcp, fp->f_flags, credp); - vcp->flushcnt++; /* protected by AFS global lock. */ + vcp->flushcnt++; /* protected by AFS global lock. */ AFS_GUNLOCK(); crfree(credp); @@ -725,7 +728,8 @@ int afs_linux_flush(struct file *fp) } /* Not allowed to directly read a directory. */ -ssize_t afs_linux_dir_read(struct file *fp, char *buf, size_t count, loff_t *ppos) +ssize_t +afs_linux_dir_read(struct file * fp, char *buf, size_t count, loff_t * ppos) { return -EISDIR; } @@ -734,64 +738,64 @@ ssize_t afs_linux_dir_read(struct file *fp, char *buf, size_t count, loff_t *ppo #if defined(AFS_LINUX24_ENV) struct file_operations afs_dir_fops = { - read: generic_read_dir, - readdir: afs_linux_readdir, - ioctl: afs_xioctl, - open: afs_linux_open, - release: afs_linux_release, + read:generic_read_dir, + readdir:afs_linux_readdir, + ioctl:afs_xioctl, + open:afs_linux_open, + release:afs_linux_release, }; #else struct file_operations afs_dir_fops = { - NULL, /* afs_linux_lseek */ + NULL, /* afs_linux_lseek */ afs_linux_dir_read, - NULL, /* afs_linux_write */ + NULL, /* afs_linux_write */ afs_linux_readdir, - NULL, /* afs_linux_select */ - afs_xioctl, /* close enough to use the ported AFS one */ - NULL, /* afs_linux_mmap */ + NULL, /* afs_linux_select */ + afs_xioctl, /* close enough to use the ported AFS one */ + NULL, /* afs_linux_mmap */ afs_linux_open, - NULL, /* afs_linux_flush */ + NULL, /* afs_linux_flush */ afs_linux_release, afs_linux_fsync, - NULL, /* afs_linux_fasync */ - NULL, /* afs_linux_check_media_change */ - NULL, /* afs_linux_file_revalidate */ + NULL, /* afs_linux_fasync */ + NULL, /* afs_linux_check_media_change */ + NULL, /* afs_linux_file_revalidate */ afs_linux_lock, }; #endif #if defined(AFS_LINUX24_ENV) struct file_operations afs_file_fops = { - read: afs_linux_read, - write: afs_linux_write, - ioctl: afs_xioctl, - mmap: afs_linux_mmap, - open: afs_linux_open, - flush: afs_linux_flush, - release: afs_linux_release, - fsync: afs_linux_fsync, - lock: afs_linux_lock, + read:afs_linux_read, + write:afs_linux_write, + ioctl:afs_xioctl, + mmap:afs_linux_mmap, + open:afs_linux_open, + flush:afs_linux_flush, + release:afs_linux_release, + fsync:afs_linux_fsync, + lock:afs_linux_lock, }; #else struct file_operations afs_file_fops = { - NULL, /* afs_linux_lseek */ + NULL, /* afs_linux_lseek */ afs_linux_read, afs_linux_write, - NULL, /* afs_linux_readdir */ - NULL, /* afs_linux_select */ - afs_xioctl, /* close enough to use the ported AFS one */ + NULL, /* afs_linux_readdir */ + NULL, /* afs_linux_select */ + afs_xioctl, /* close enough to use the ported AFS one */ afs_linux_mmap, afs_linux_open, afs_linux_flush, afs_linux_release, afs_linux_fsync, - NULL, /* afs_linux_fasync */ - NULL, /* afs_linux_check_media_change */ - NULL, /* afs_linux_file_revalidate */ + NULL, /* afs_linux_fasync */ + NULL, /* afs_linux_check_media_change */ + NULL, /* afs_linux_file_revalidate */ afs_linux_lock, }; #endif - + /********************************************************************** * AFS Linux dentry operations @@ -800,7 +804,8 @@ struct file_operations afs_file_fops = { /* afs_linux_revalidate * Ensure vcache is stat'd before use. Return 0 if entry is valid. */ -static int afs_linux_revalidate(struct dentry *dp) +static int +afs_linux_revalidate(struct dentry *dp) { int code; cred_t *credp; @@ -810,21 +815,20 @@ static int afs_linux_revalidate(struct dentry *dp) AFS_GLOCK(); - if (afs_fakestat_enable && vcp->mvstat == 1 && vcp->mvid && - (vcp->states & CMValid) && (vcp->states & CStatd)) { + if (afs_fakestat_enable && vcp->mvstat == 1 && vcp->mvid + && (vcp->states & CMValid) && (vcp->states & CStatd)) { ObtainSharedLock(&afs_xvcache, 680); rootvp = afs_FindVCache(vcp->mvid, 0, 0); ReleaseSharedLock(&afs_xvcache); } - #ifdef AFS_LINUX24_ENV lock_kernel(); #endif /* Make this a fast path (no crref), since it's called so often. */ if (vcp->states & CStatd) { - if (*dp->d_name.name != '/' && vcp->mvstat == 2) /* root vnode */ - check_bad_parent(dp); /* check and correct mvid */ + if (*dp->d_name.name != '/' && vcp->mvstat == 2) /* root vnode */ + check_bad_parent(dp); /* check and correct mvid */ if (rootvp) vcache2fakeinode(rootvp, vcp); else @@ -832,7 +836,8 @@ static int afs_linux_revalidate(struct dentry *dp) #ifdef AFS_LINUX24_ENV unlock_kernel(); #endif - if (rootvp) afs_PutVCache(rootvp); + if (rootvp) + afs_PutVCache(rootvp); AFS_GUNLOCK(); return 0; } @@ -848,7 +853,7 @@ static int afs_linux_revalidate(struct dentry *dp) AFS_GUNLOCK(); crfree(credp); - return -code ; + return -code; } @@ -860,9 +865,11 @@ static int afs_linux_revalidate(struct dentry *dp) * later on, we shouldn't have to do it until later. Perhaps in the future.. */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10) -static int afs_linux_dentry_revalidate(struct dentry *dp, int flags) +static int +afs_linux_dentry_revalidate(struct dentry *dp, int flags) #else -static int afs_linux_dentry_revalidate(struct dentry *dp) +static int +afs_linux_dentry_revalidate(struct dentry *dp) #endif { char *name; @@ -881,32 +888,32 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) /* If it's a negative dentry, then there's nothing to do. */ if (!vcp || !parentvcp) - goto done; + goto done; /* If it is the AFS root, then there's no chance it needs - revalidating */ + * revalidating */ if (vcp == afs_globalVp) { bad_dentry = 0; goto done; } if ((code = afs_InitReq(&treq, credp))) - goto done; + goto done; Check_AtSys(parentvcp, dp->d_name.name, &sysState, &treq); name = sysState.name; /* First try looking up the DNLC */ if ((lookupvcp = osi_dnlc_lookup(parentvcp, name, WRITE_LOCK))) { - /* Verify that the dentry does not point to an old inode */ - if (vcp != lookupvcp) - goto done; - /* Check and correct mvid */ - if (*name != '/' && vcp->mvstat == 2) - check_bad_parent(dp); + /* Verify that the dentry does not point to an old inode */ + if (vcp != lookupvcp) + goto done; + /* Check and correct mvid */ + if (*name != '/' && vcp->mvstat == 2) + check_bad_parent(dp); vcache2inode(vcp); - bad_dentry = 0; - goto done; + bad_dentry = 0; + goto done; } /* A DNLC lookup failure cannot be trusted. Try a real lookup */ @@ -914,23 +921,23 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) /* Verify that the dentry does not point to an old inode */ if (vcp != lookupvcp) - goto done; + goto done; bad_dentry = 0; -done: + done: /* Clean up */ if (lookupvcp) - afs_PutVCache(lookupvcp); + afs_PutVCache(lookupvcp); if (sysState.allocked) - osi_FreeLargeSpace(name); + osi_FreeLargeSpace(name); AFS_GUNLOCK(); crfree(credp); if (bad_dentry) { - shrink_dcache_parent(dp); - d_drop(dp); + shrink_dcache_parent(dp); + d_drop(dp); } unlock_kernel(); @@ -939,9 +946,11 @@ done: #ifdef notdef #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10) -static int afs_linux_dentry_revalidate(struct dentry *dp, int flags) +static int +afs_linux_dentry_revalidate(struct dentry *dp, int flags) #else -static int afs_linux_dentry_revalidate(struct dentry *dp) +static int +afs_linux_dentry_revalidate(struct dentry *dp) #endif { int code; @@ -949,7 +958,7 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) struct vrequest treq; struct inode *ip = AFSTOI(dp->d_inode); - unsigned long timeout = 3*HZ; /* 3 seconds */ + unsigned long timeout = 3 * HZ; /* 3 seconds */ if (!ip) printk("negative dentry: %s\n", dp->d_name.name); @@ -957,28 +966,28 @@ static int afs_linux_dentry_revalidate(struct dentry *dp) if (!(flags & LOOKUP_CONTINUE)) { long diff = CURRENT_TIME - dp->d_parent->d_inode->i_mtime; - if (diff < 15*60) + if (diff < 15 * 60) timeout = 0; } if (time_after(jiffies, dp->d_time + timeout)) goto out_bad; - out_valid: + out_valid: return 1; - out_bad: + out_bad: return 0; } #endif /* afs_dentry_iput */ -static void afs_dentry_iput(struct dentry *dp, struct inode *ip) +static void +afs_dentry_iput(struct dentry *dp, struct inode *ip) { if (ICL_SETACTIVE(afs_iclSetp)) { AFS_GLOCK(); - afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYIPUT, - ICL_TYPE_POINTER, ip, + afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYIPUT, ICL_TYPE_POINTER, ip, ICL_TYPE_STRING, dp->d_parent->d_name.name, ICL_TYPE_STRING, dp->d_name.name); AFS_GUNLOCK(); @@ -987,37 +996,38 @@ static void afs_dentry_iput(struct dentry *dp, struct inode *ip) osi_iput(ip); } -static int afs_dentry_delete(struct dentry *dp) +static int +afs_dentry_delete(struct dentry *dp) { if (ICL_SETACTIVE(afs_iclSetp)) { AFS_GLOCK(); - afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYDELETE, ICL_TYPE_POINTER, + afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYDELETE, ICL_TYPE_POINTER, dp->d_inode, ICL_TYPE_STRING, dp->d_parent->d_name.name, ICL_TYPE_STRING, dp->d_name.name); AFS_GUNLOCK(); } if (dp->d_inode && (ITOAFS(dp->d_inode)->states & CUnlinked)) - return 1; /* bad inode? */ + return 1; /* bad inode? */ return 0; } #if defined(AFS_LINUX24_ENV) struct dentry_operations afs_dentry_operations = { - d_revalidate: afs_linux_dentry_revalidate, - d_iput: afs_dentry_iput, - d_delete: afs_dentry_delete, + d_revalidate:afs_linux_dentry_revalidate, + d_iput:afs_dentry_iput, + d_delete:afs_dentry_delete, }; struct dentry_operations *afs_dops = &afs_dentry_operations; #else struct dentry_operations afs_dentry_operations = { - afs_linux_dentry_revalidate, /* d_validate(struct dentry *) */ - NULL, /* d_hash */ - NULL, /* d_compare */ - afs_dentry_delete, /* d_delete(struct dentry *) */ - NULL, /* d_release(struct dentry *) */ - afs_dentry_iput /* d_iput(struct dentry *, struct inode *) */ + afs_linux_dentry_revalidate, /* d_validate(struct dentry *) */ + NULL, /* d_hash */ + NULL, /* d_compare */ + afs_dentry_delete, /* d_delete(struct dentry *) */ + NULL, /* d_release(struct dentry *) */ + afs_dentry_iput /* d_iput(struct dentry *, struct inode *) */ }; struct dentry_operations *afs_dops = &afs_dentry_operations; #endif @@ -1034,7 +1044,8 @@ struct dentry_operations *afs_dops = &afs_dentry_operations; * * name is in kernel space at this point. */ -int afs_linux_create(struct inode *dip, struct dentry *dp, int mode) +int +afs_linux_create(struct inode *dip, struct dentry *dp, int mode) { int code; cred_t *credp = crref(); @@ -1047,26 +1058,27 @@ int afs_linux_create(struct inode *dip, struct dentry *dp, int mode) vattr.va_mode = mode; AFS_GLOCK(); - code = afs_create(ITOAFS(dip), name, &vattr, NONEXCL, mode, - (struct vcache**)&ip, credp); + code = + afs_create(ITOAFS(dip), name, &vattr, NONEXCL, mode, + (struct vcache **)&ip, credp); if (!code) { vattr2inode(ip, &vattr); /* Reset ops if symlink or directory. */ #if defined(AFS_LINUX24_ENV) - if (S_ISREG(ip->i_mode)) { - ip->i_op = &afs_file_iops; - ip->i_fop = &afs_file_fops; - ip->i_data.a_ops = &afs_file_aops; - } else if (S_ISDIR(ip->i_mode)) { - ip->i_op = &afs_dir_iops; - ip->i_fop = &afs_dir_fops; - } else if (S_ISLNK(ip->i_mode)) { - ip->i_op = &afs_symlink_iops; - ip->i_data.a_ops = &afs_symlink_aops; - ip->i_mapping = &ip->i_data; - } else - printk("afs_linux_create: FIXME\n"); + if (S_ISREG(ip->i_mode)) { + ip->i_op = &afs_file_iops; + ip->i_fop = &afs_file_fops; + ip->i_data.a_ops = &afs_file_aops; + } else if (S_ISDIR(ip->i_mode)) { + ip->i_op = &afs_dir_iops; + ip->i_fop = &afs_dir_fops; + } else if (S_ISLNK(ip->i_mode)) { + ip->i_op = &afs_symlink_iops; + ip->i_data.a_ops = &afs_symlink_aops; + ip->i_mapping = &ip->i_data; + } else + printk("afs_linux_create: FIXME\n"); #else if (S_ISDIR(ip->i_mode)) ip->i_op = &afs_dir_iops; @@ -1086,14 +1098,16 @@ int afs_linux_create(struct inode *dip, struct dentry *dp, int mode) /* afs_linux_lookup */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10) -struct dentry *afs_linux_lookup(struct inode *dip, struct dentry *dp) +struct dentry * +afs_linux_lookup(struct inode *dip, struct dentry *dp) #else -int afs_linux_lookup(struct inode *dip, struct dentry *dp) +int +afs_linux_lookup(struct inode *dip, struct dentry *dp) #endif { int code = 0; cred_t *credp = crref(); - struct vcache *vcp=NULL; + struct vcache *vcp = NULL; const char *comp = dp->d_name.name; AFS_GLOCK(); code = afs_lookup(ITOAFS(dip), comp, &vcp, credp); @@ -1102,26 +1116,28 @@ int afs_linux_lookup(struct inode *dip, struct dentry *dp) struct inode *ip = AFSTOI(vcp); /* Reset ops if symlink or directory. */ #if defined(AFS_LINUX24_ENV) - if (S_ISREG(ip->i_mode)) { - ip->i_op = &afs_file_iops; - ip->i_fop = &afs_file_fops; - ip->i_data.a_ops = &afs_file_aops; - } else if (S_ISDIR(ip->i_mode)) { - ip->i_op = &afs_dir_iops; - ip->i_fop = &afs_dir_fops; - } else if (S_ISLNK(ip->i_mode)) { - ip->i_op = &afs_symlink_iops; - ip->i_data.a_ops = &afs_symlink_aops; - ip->i_mapping = &ip->i_data; + if (S_ISREG(ip->i_mode)) { + ip->i_op = &afs_file_iops; + ip->i_fop = &afs_file_fops; + ip->i_data.a_ops = &afs_file_aops; + } else if (S_ISDIR(ip->i_mode)) { + ip->i_op = &afs_dir_iops; + ip->i_fop = &afs_dir_fops; + } else if (S_ISLNK(ip->i_mode)) { + ip->i_op = &afs_symlink_iops; + ip->i_data.a_ops = &afs_symlink_aops; + ip->i_mapping = &ip->i_data; } else - printk("afs_linux_lookup: ip->i_mode 0x%x dp->d_name.name %s code %d\n", ip->i_mode, dp->d_name.name, code); + printk + ("afs_linux_lookup: ip->i_mode 0x%x dp->d_name.name %s code %d\n", + ip->i_mode, dp->d_name.name, code); #else if (S_ISDIR(ip->i_mode)) ip->i_op = &afs_dir_iops; else if (S_ISLNK(ip->i_mode)) ip->i_op = &afs_symlink_iops; #endif - } + } dp->d_time = jiffies; dp->d_op = afs_dops; d_add(dp, AFSTOI(vcp)); @@ -1144,8 +1160,8 @@ int afs_linux_lookup(struct inode *dip, struct dentry *dp) #endif } -int afs_linux_link(struct dentry *olddp, struct inode *dip, - struct dentry *newdp) +int +afs_linux_link(struct dentry *olddp, struct inode *dip, struct dentry *newdp) { int code; cred_t *credp = crref(); @@ -1165,7 +1181,8 @@ int afs_linux_link(struct dentry *olddp, struct inode *dip, return -code; } -int afs_linux_unlink(struct inode *dip, struct dentry *dp) +int +afs_linux_unlink(struct inode *dip, struct dentry *dp) { int code; cred_t *credp = crref(); @@ -1181,8 +1198,8 @@ int afs_linux_unlink(struct inode *dip, struct dentry *dp) } -int afs_linux_symlink(struct inode *dip, struct dentry *dp, - const char *target) +int +afs_linux_symlink(struct inode *dip, struct dentry *dp, const char *target) { int code; cred_t *credp = crref(); @@ -1202,7 +1219,8 @@ int afs_linux_symlink(struct inode *dip, struct dentry *dp, return -code; } -int afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode) +int +afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode) { int code; cred_t *credp = crref(); @@ -1231,7 +1249,8 @@ int afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode) return -code; } -int afs_linux_rmdir(struct inode *dip, struct dentry *dp) +int +afs_linux_rmdir(struct inode *dip, struct dentry *dp) { int code; cred_t *credp = crref(); @@ -1247,7 +1266,7 @@ int afs_linux_rmdir(struct inode *dip, struct dentry *dp) if (code == EEXIST) { code = ENOTEMPTY; } - + if (!code) { d_drop(dp); } @@ -1259,8 +1278,9 @@ int afs_linux_rmdir(struct inode *dip, struct dentry *dp) -int afs_linux_rename(struct inode *oldip, struct dentry *olddp, - struct inode *newip, struct dentry *newdp) +int +afs_linux_rename(struct inode *oldip, struct dentry *olddp, + struct inode *newip, struct dentry *newdp) { int code; cred_t *credp = crref(); @@ -1279,8 +1299,7 @@ int afs_linux_rename(struct inode *oldip, struct dentry *olddp, d_drop(newdp); } AFS_GLOCK(); - code = afs_rename(ITOAFS(oldip), oldname, ITOAFS(newip), - newname, credp); + code = afs_rename(ITOAFS(oldip), oldname, ITOAFS(newip), newname, credp); AFS_GUNLOCK(); if (!code) { @@ -1298,8 +1317,8 @@ int afs_linux_rename(struct inode *oldip, struct dentry *olddp, * Internal readlink which can return link contents to user or kernel space. * Note that the buffer is NOT supposed to be null-terminated. */ -static int afs_linux_ireadlink(struct inode *ip, char *target, int maxlen, - uio_seg_t seg) +static int +afs_linux_ireadlink(struct inode *ip, char *target, int maxlen, uio_seg_t seg) { int code; cred_t *credp = crref(); @@ -1320,7 +1339,8 @@ static int afs_linux_ireadlink(struct inode *ip, char *target, int maxlen, /* afs_linux_readlink * Fill target (which is in user space) with contents of symlink. */ -int afs_linux_readlink(struct dentry *dp, char *target, int maxlen) +int +afs_linux_readlink(struct dentry *dp, char *target, int maxlen) { int code; struct inode *ip = dp->d_inode; @@ -1335,9 +1355,9 @@ int afs_linux_readlink(struct dentry *dp, char *target, int maxlen) /* afs_linux_follow_link * a file system dependent link following routine. */ -struct dentry * afs_linux_follow_link(struct dentry *dp, - struct dentry *basep, - unsigned int follow) +struct dentry * +afs_linux_follow_link(struct dentry *dp, struct dentry *basep, + unsigned int follow) { int code = 0; char *name; @@ -1345,7 +1365,7 @@ struct dentry * afs_linux_follow_link(struct dentry *dp, AFS_GLOCK(); - name = osi_Alloc(PATH_MAX+1); + name = osi_Alloc(PATH_MAX + 1); if (!name) { AFS_GUNLOCK(); dput(basep); @@ -1355,17 +1375,16 @@ struct dentry * afs_linux_follow_link(struct dentry *dp, code = afs_linux_ireadlink(dp->d_inode, name, PATH_MAX, AFS_UIOSYS); AFS_GUNLOCK(); - if (code<0) { + if (code < 0) { dput(basep); res = ERR_PTR(code); - } - else { + } else { name[code] = '\0'; res = lookup_dentry(name, basep, follow); } AFS_GLOCK(); - osi_Free(name, PATH_MAX+1); + osi_Free(name, PATH_MAX + 1); AFS_GUNLOCK(); return res; } @@ -1374,7 +1393,8 @@ struct dentry * afs_linux_follow_link(struct dentry *dp, /* afs_linux_readpage * all reads come through here. A strategy-like read call. */ -int afs_linux_readpage(struct file *fp, struct page *pp) +int +afs_linux_readpage(struct file *fp, struct page *pp) { int code; cred_t *credp = crref(); @@ -1392,11 +1412,7 @@ int afs_linux_readpage(struct file *fp, struct page *pp) struct vcache *avc = ITOAFS(ip); AFS_GLOCK(); - afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, - ICL_TYPE_POINTER, ip, - ICL_TYPE_POINTER, pp, - ICL_TYPE_INT32, cnt, - ICL_TYPE_INT32, 99999); /* not a possible code value */ + afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, ICL_TYPE_POINTER, ip, ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, cnt, ICL_TYPE_INT32, 99999); /* not a possible code value */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) address = kmap(pp); ClearPageError(pp); @@ -1404,29 +1420,28 @@ int afs_linux_readpage(struct file *fp, struct page *pp) lock_kernel(); #else atomic_add(1, &pp->count); - set_bit(PG_locked, &pp->flags); /* other bits? See mm.h */ + set_bit(PG_locked, &pp->flags); /* other bits? See mm.h */ clear_bit(PG_error, &pp->flags); #endif - setup_uio(&tuio, &iovec, (char*)address, offset, PAGESIZE, - UIO_READ, AFS_UIOSYS); + setup_uio(&tuio, &iovec, (char *)address, offset, PAGESIZE, UIO_READ, + AFS_UIOSYS); code = afs_rdwr(avc, &tuio, UIO_READ, 0, credp); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) unlock_kernel(); #endif if (!code) { - if (tuio.uio_resid) /* zero remainder of page */ - memset((void*)(address+(PAGESIZE-tuio.uio_resid)), 0, + if (tuio.uio_resid) /* zero remainder of page */ + memset((void *)(address + (PAGESIZE - tuio.uio_resid)), 0, tuio.uio_resid); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) - flush_dcache_page(pp); - SetPageUptodate(pp); + flush_dcache_page(pp); + SetPageUptodate(pp); #else - set_bit(PG_uptodate, &pp->flags); + set_bit(PG_uptodate, &pp->flags); #endif } - #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) kunmap(pp); UnlockPage(pp); @@ -1453,17 +1468,16 @@ int afs_linux_readpage(struct file *fp, struct page *pp) } crfree(credp); - afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, - ICL_TYPE_POINTER, ip, - ICL_TYPE_POINTER, pp, - ICL_TYPE_INT32, cnt, - ICL_TYPE_INT32, code); + afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, ICL_TYPE_POINTER, ip, + ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, cnt, ICL_TYPE_INT32, + code); AFS_GUNLOCK(); return -code; } #if defined(AFS_LINUX24_ENV) -int afs_linux_writepage(struct page *pp) +int +afs_linux_writepage(struct page *pp) { struct address_space *mapping = pp->mapping; struct inode *inode; @@ -1471,18 +1485,18 @@ int afs_linux_writepage(struct page *pp) unsigned offset = PAGE_CACHE_SIZE; long status; - inode = (struct inode *) mapping->host; + inode = (struct inode *)mapping->host; end_index = inode->i_size >> PAGE_CACHE_SHIFT; /* easy case */ if (pp->index < end_index) goto do_it; /* things got complicated... */ - offset = inode->i_size & (PAGE_CACHE_SIZE-1); + offset = inode->i_size & (PAGE_CACHE_SIZE - 1); /* OK, are we completely out? */ - if (pp->index >= end_index+1 || !offset) + if (pp->index >= end_index + 1 || !offset) return -EIO; -do_it: + do_it: AFS_GLOCK(); status = afs_linux_writepage_sync(inode, pp, 0, offset); AFS_GUNLOCK(); @@ -1497,13 +1511,18 @@ do_it: #ifdef NOTUSED /* afs_linux_bmap - supports generic_readpage, but we roll our own. */ -int afs_linux_bmap(struct inode *ip, int) { return -EINVAL; } +int +afs_linux_bmap(struct inode *ip, int) +{ + return -EINVAL; +} /* afs_linux_truncate * Handles discarding disk blocks if this were a device. ext2 indicates we * may need to zero partial last pages of memory mapped files. */ -void afs_linux_truncate(struct inode *ip) +void +afs_linux_truncate(struct inode *ip) { } #endif @@ -1511,16 +1530,20 @@ void afs_linux_truncate(struct inode *ip) /* afs_linux_permission * Check access rights - returns error if can't check or permission denied. */ -int afs_linux_permission(struct inode *ip, int mode) +int +afs_linux_permission(struct inode *ip, int mode) { int code; cred_t *credp = crref(); int tmp = 0; AFS_GLOCK(); - if (mode & MAY_EXEC) tmp |= VEXEC; - if (mode & MAY_READ) tmp |= VREAD; - if (mode & MAY_WRITE) tmp |= VWRITE; + if (mode & MAY_EXEC) + tmp |= VEXEC; + if (mode & MAY_READ) + tmp |= VREAD; + if (mode & MAY_WRITE) + tmp |= VWRITE; code = afs_access(ITOAFS(ip), tmp, credp); AFS_GUNLOCK(); @@ -1531,13 +1554,17 @@ int afs_linux_permission(struct inode *ip, int mode) #ifdef NOTUSED /* msdos sector mapping hack for memory mapping. */ -int afs_linux_smap(struct inode *ip, int) { return -EINVAL; } +int +afs_linux_smap(struct inode *ip, int) +{ + return -EINVAL; +} #endif #if defined(AFS_LINUX24_ENV) -int afs_linux_writepage_sync(struct inode *ip, struct page *pp, - unsigned long offset, - unsigned int count) +int +afs_linux_writepage_sync(struct inode *ip, struct page *pp, + unsigned long offset, unsigned int count) { struct vcache *vcp = ITOAFS(ip); char *buffer; @@ -1553,9 +1580,8 @@ int afs_linux_writepage_sync(struct inode *ip, struct page *pp, credp = crref(); afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp, - ICL_TYPE_POINTER, pp, - ICL_TYPE_INT32, atomic_read(&pp->count), - ICL_TYPE_INT32, 99999); + ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, atomic_read(&pp->count), + ICL_TYPE_INT32, 99999); setup_uio(&tuio, &iovec, buffer, base, count, UIO_WRITE, AFS_UIOSYS); @@ -1563,8 +1589,9 @@ int afs_linux_writepage_sync(struct inode *ip, struct page *pp, vcache2inode(vcp); - if (!code && afs_stats_cmperf.cacheCurrDirtyChunks > - afs_stats_cmperf.cacheMaxDirtyChunks) { + if (!code + && afs_stats_cmperf.cacheCurrDirtyChunks > + afs_stats_cmperf.cacheMaxDirtyChunks) { struct vrequest treq; ObtainWriteLock(&vcp->lock, 533); @@ -1575,18 +1602,17 @@ int afs_linux_writepage_sync(struct inode *ip, struct page *pp, code = code ? -code : count - tuio.uio_resid; afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp, - ICL_TYPE_POINTER, pp, - ICL_TYPE_INT32, atomic_read(&pp->count), - ICL_TYPE_INT32, code); + ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, atomic_read(&pp->count), + ICL_TYPE_INT32, code); crfree(credp); kunmap(pp); return code; -} +} static int -afs_linux_updatepage(struct file *file, struct page *page, +afs_linux_updatepage(struct file *file, struct page *page, unsigned long offset, unsigned int count) { struct dentry *dentry = file->f_dentry; @@ -1599,27 +1625,27 @@ afs_linux_updatepage(struct file *file, struct page *page, * Called from generic_file_write. buffer is still in user space. pagep * has been filled in with old data if we're updating less than a page. */ -int afs_linux_updatepage(struct file *fp, struct page *pp, - unsigned long offset, - unsigned int count, int sync) +int +afs_linux_updatepage(struct file *fp, struct page *pp, unsigned long offset, + unsigned int count, int sync) { struct vcache *vcp = ITOAFS(FILE_INODE(fp)); - u8 *page_addr = (u8*) afs_linux_page_address(pp); + u8 *page_addr = (u8 *) afs_linux_page_address(pp); int code = 0; cred_t *credp; uio_t tuio; struct iovec iovec; - + set_bit(PG_locked, &pp->flags); credp = crref(); AFS_GLOCK(); afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp, - ICL_TYPE_POINTER, pp, - ICL_TYPE_INT32, atomic_read(&pp->count), + ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, atomic_read(&pp->count), ICL_TYPE_INT32, 99999); - setup_uio(&tuio, &iovec, page_addr + offset, (afs_offs_t)(pageoff(pp) + offset), - count, UIO_WRITE, AFS_UIOSYS); + setup_uio(&tuio, &iovec, page_addr + offset, + (afs_offs_t) (pageoff(pp) + offset), count, UIO_WRITE, + AFS_UIOSYS); code = afs_write(vcp, &tuio, fp->f_flags, credp, 0); @@ -1627,8 +1653,7 @@ int afs_linux_updatepage(struct file *fp, struct page *pp, code = code ? -code : count - tuio.uio_resid; afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp, - ICL_TYPE_POINTER, pp, - ICL_TYPE_INT32, atomic_read(&pp->count), + ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, atomic_read(&pp->count), ICL_TYPE_INT32, code); AFS_GUNLOCK(); @@ -1640,13 +1665,15 @@ int afs_linux_updatepage(struct file *fp, struct page *pp, #endif #if defined(AFS_LINUX24_ENV) -static int afs_linux_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to) +static int +afs_linux_commit_write(struct file *file, struct page *page, unsigned offset, + unsigned to) { int code; AFS_GLOCK(); lock_kernel(); - code = afs_linux_updatepage(file, page, offset, to-offset); + code = afs_linux_updatepage(file, page, offset, to - offset); unlock_kernel(); AFS_GUNLOCK(); kunmap(page); @@ -1654,50 +1681,51 @@ static int afs_linux_commit_write(struct file *file, struct page *page, unsigned return code; } -static int afs_linux_prepare_write(struct file *file, struct page *page, - unsigned from, unsigned to) +static int +afs_linux_prepare_write(struct file *file, struct page *page, unsigned from, + unsigned to) { kmap(page); return 0; } -extern int afs_notify_change(struct dentry *dp, struct iattr* iattrp); +extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp); #endif #if defined(AFS_LINUX24_ENV) struct inode_operations afs_file_iops = { - revalidate: afs_linux_revalidate, - setattr: afs_notify_change, - permission: afs_linux_permission, + revalidate:afs_linux_revalidate, + setattr:afs_notify_change, + permission:afs_linux_permission, }; struct address_space_operations afs_file_aops = { - readpage: afs_linux_readpage, - writepage: afs_linux_writepage, - commit_write: afs_linux_commit_write, - prepare_write: afs_linux_prepare_write, + readpage:afs_linux_readpage, + writepage:afs_linux_writepage, + commit_write:afs_linux_commit_write, + prepare_write:afs_linux_prepare_write, }; struct inode_operations *afs_ops = &afs_file_iops; #else struct inode_operations afs_iops = { - &afs_file_fops, /* file operations */ - NULL, /* afs_linux_create */ - NULL, /* afs_linux_lookup */ - NULL, /* afs_linux_link */ - NULL, /* afs_linux_unlink */ - NULL, /* afs_linux_symlink */ - NULL, /* afs_linux_mkdir */ - NULL, /* afs_linux_rmdir */ - NULL, /* afs_linux_mknod */ - NULL, /* afs_linux_rename */ - NULL, /* afs_linux_readlink */ - NULL, /* afs_linux_follow_link */ + &afs_file_fops, /* file operations */ + NULL, /* afs_linux_create */ + NULL, /* afs_linux_lookup */ + NULL, /* afs_linux_link */ + NULL, /* afs_linux_unlink */ + NULL, /* afs_linux_symlink */ + NULL, /* afs_linux_mkdir */ + NULL, /* afs_linux_rmdir */ + NULL, /* afs_linux_mknod */ + NULL, /* afs_linux_rename */ + NULL, /* afs_linux_readlink */ + NULL, /* afs_linux_follow_link */ afs_linux_readpage, - NULL, /* afs_linux_writepage */ - NULL, /* afs_linux_bmap */ - NULL, /* afs_linux_truncate */ + NULL, /* afs_linux_writepage */ + NULL, /* afs_linux_bmap */ + NULL, /* afs_linux_truncate */ afs_linux_permission, - NULL, /* afs_linux_smap */ + NULL, /* afs_linux_smap */ afs_linux_updatepage, afs_linux_revalidate, }; @@ -1710,21 +1738,21 @@ struct inode_operations *afs_ops = &afs_iops; */ #if defined(AFS_LINUX24_ENV) struct inode_operations afs_dir_iops = { - create: afs_linux_create, - lookup: afs_linux_lookup, - link: afs_linux_link, - unlink: afs_linux_unlink, - symlink: afs_linux_symlink, - mkdir: afs_linux_mkdir, - rmdir: afs_linux_rmdir, - rename: afs_linux_rename, - revalidate: afs_linux_revalidate, - setattr: afs_notify_change, - permission: afs_linux_permission, + create:afs_linux_create, + lookup:afs_linux_lookup, + link:afs_linux_link, + unlink:afs_linux_unlink, + symlink:afs_linux_symlink, + mkdir:afs_linux_mkdir, + rmdir:afs_linux_rmdir, + rename:afs_linux_rename, + revalidate:afs_linux_revalidate, + setattr:afs_notify_change, + permission:afs_linux_permission, }; #else struct inode_operations afs_dir_iops = { - &afs_dir_fops, /* file operations for directories */ + &afs_dir_fops, /* file operations for directories */ afs_linux_create, afs_linux_lookup, afs_linux_link, @@ -1732,17 +1760,17 @@ struct inode_operations afs_dir_iops = { afs_linux_symlink, afs_linux_mkdir, afs_linux_rmdir, - NULL, /* afs_linux_mknod */ + NULL, /* afs_linux_mknod */ afs_linux_rename, - NULL, /* afs_linux_readlink */ - NULL, /* afs_linux_follow_link */ - NULL, /* afs_linux_readpage */ - NULL, /* afs_linux_writepage */ - NULL, /* afs_linux_bmap */ - NULL, /* afs_linux_truncate */ + NULL, /* afs_linux_readlink */ + NULL, /* afs_linux_follow_link */ + NULL, /* afs_linux_readpage */ + NULL, /* afs_linux_writepage */ + NULL, /* afs_linux_bmap */ + NULL, /* afs_linux_truncate */ afs_linux_permission, - NULL, /* afs_linux_smap */ - NULL, /* afs_linux_updatepage */ + NULL, /* afs_linux_smap */ + NULL, /* afs_linux_updatepage */ afs_linux_revalidate, }; #endif @@ -1751,9 +1779,10 @@ struct inode_operations afs_dir_iops = { * determines if it _is_ a link by checking if the follow_link op is set. */ #if defined(AFS_LINUX24_ENV) -static int afs_symlink_filler(struct file *file, struct page *page) +static int +afs_symlink_filler(struct file *file, struct page *page) { - struct inode *ip = (struct inode *) page->mapping->host; + struct inode *ip = (struct inode *)page->mapping->host; char *p = (char *)kmap(page); int code; @@ -1761,9 +1790,9 @@ static int afs_symlink_filler(struct file *file, struct page *page) lock_kernel(); code = afs_linux_ireadlink(ip, p, PAGE_SIZE, AFS_UIOSYS); - if (code<0) - goto fail; - p[code] = '\0'; /* null terminate? */ + if (code < 0) + goto fail; + p[code] = '\0'; /* null terminate? */ unlock_kernel(); AFS_GUNLOCK(); @@ -1772,7 +1801,7 @@ static int afs_symlink_filler(struct file *file, struct page *page) UnlockPage(page); return 0; -fail: + fail: unlock_kernel(); AFS_GUNLOCK(); @@ -1783,35 +1812,35 @@ fail: } struct address_space_operations afs_symlink_aops = { - readpage: afs_symlink_filler + readpage:afs_symlink_filler }; struct inode_operations afs_symlink_iops = { - readlink: page_readlink, - follow_link: page_follow_link, - setattr: afs_notify_change, + readlink:page_readlink, + follow_link:page_follow_link, + setattr:afs_notify_change, }; #else struct inode_operations afs_symlink_iops = { - NULL, /* file operations */ - NULL, /* create */ - NULL, /* lookup */ - NULL, /* link */ - NULL, /* unlink */ - NULL, /* symlink */ - NULL, /* mkdir */ - NULL, /* rmdir */ - NULL, /* afs_linux_mknod */ - NULL, /* rename */ + NULL, /* file operations */ + NULL, /* create */ + NULL, /* lookup */ + NULL, /* link */ + NULL, /* unlink */ + NULL, /* symlink */ + NULL, /* mkdir */ + NULL, /* rmdir */ + NULL, /* afs_linux_mknod */ + NULL, /* rename */ afs_linux_readlink, afs_linux_follow_link, - NULL, /* readpage */ - NULL, /* afs_linux_writepage */ - NULL, /* afs_linux_bmap */ - NULL, /* afs_linux_truncate */ - afs_linux_permission, /* tho the code appears to indicate not used? */ - NULL, /* afs_linux_smap */ - NULL, /* updatepage */ - afs_linux_revalidate, /* tho the code appears to indicate not used? */ + NULL, /* readpage */ + NULL, /* afs_linux_writepage */ + NULL, /* afs_linux_bmap */ + NULL, /* afs_linux_truncate */ + afs_linux_permission, /* tho the code appears to indicate not used? */ + NULL, /* afs_linux_smap */ + NULL, /* updatepage */ + afs_linux_revalidate, /* tho the code appears to indicate not used? */ }; #endif diff --git a/src/afs/NBSD/osi_file.c b/src/afs/NBSD/osi_file.c index da66dc560..c2eaafeaa 100644 --- a/src/afs/NBSD/osi_file.c +++ b/src/afs/NBSD/osi_file.c @@ -10,21 +10,23 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ -int afs_osicred_initialized=0; -struct AFS_UCRED afs_osi_cred; +int afs_osicred_initialized = 0; +struct AFS_UCRED afs_osi_cred; afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct mount *afs_cacheVfsp; -void *osi_UFSOpen(afs_int32 ainode) +void * +osi_UFSOpen(afs_int32 ainode) { struct inode *ip; register struct osi_file *afile = NULL; @@ -32,7 +34,7 @@ void *osi_UFSOpen(afs_int32 ainode) afs_int32 code = 0; int dummy; AFS_STATCNT(osi_UFSOpen); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) { + if (cacheDiskType != AFS_FCACHE_TYPE_UFS) { osi_Panic("UFSOpen called for non-UFS cache\n"); } if (!afs_osicred_initialized) { @@ -41,9 +43,11 @@ void *osi_UFSOpen(afs_int32 ainode) afs_osi_cred.cr_ref++; afs_osicred_initialized = 1; } - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); - code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode, &ip, &dummy); + code = + igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode, &ip, + &dummy); AFS_GLOCK(); if (code) { osi_FreeSmallSpace(afile); @@ -53,17 +57,18 @@ void *osi_UFSOpen(afs_int32 ainode) afile->vnode = ITOV(ip); afile->size = VTOI(afile->vnode)->i_size; afile->offset = 0; - afile->proc = (int (*)()) 0; - afile->inum = ainode; /* for hint validity checking */ + afile->proc = (int (*)())0; + afile->inum = ainode; /* for hint validity checking */ return (void *)afile; } -int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) +int +afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) { register afs_int32 code; struct vattr tvattr; AFS_STATCNT(osi_Stat); - MObtainWriteLock(&afs_xosi,320); + MObtainWriteLock(&afs_xosi, 320); AFS_GUNLOCK(); VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, code); AFS_GLOCK(); @@ -77,18 +82,20 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta return code; } -int osi_UFSClose(register struct osi_file *afile) - { - AFS_STATCNT(osi_Close); - if(afile->vnode) { +int +osi_UFSClose(register struct osi_file *afile) +{ + AFS_STATCNT(osi_Close); + if (afile->vnode) { AFS_RELE(afile->vnode); - } - - osi_FreeSmallSpace(afile); - return 0; - } + } + + osi_FreeSmallSpace(afile); + return 0; +} -int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) +int +osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) { struct AFS_UCRED *oldCred; struct vattr tvattr; @@ -101,97 +108,106 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) * small enough. Check now and save some time. */ code = afs_osi_Stat(afile, &tstat); - if (code || tstat.size <= asize) return code; - MObtainWriteLock(&afs_xosi,321); + if (code || tstat.size <= asize) + return code; + MObtainWriteLock(&afs_xosi, 321); VATTR_NULL(&tvattr); /* note that this credential swapping stuff is only necessary because - of ufs's references directly to cred instead of to - credentials parameter. Probably should fix ufs some day. */ - oldCred = curproc->p_cred->pc_ucred; /* remember old credentials pointer */ + * of ufs's references directly to cred instead of to + * credentials parameter. Probably should fix ufs some day. */ + oldCred = curproc->p_cred->pc_ucred; /* remember old credentials pointer */ curproc->p_cred->pc_ucred = &afs_osi_cred; /* temporarily use superuser credentials */ tvattr.va_size = asize; AFS_GUNLOCK(); VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, code); AFS_GLOCK(); - curproc->p_cred->pc_ucred = oldCred; /* restore */ + curproc->p_cred->pc_ucred = oldCred; /* restore */ MReleaseWriteLock(&afs_xosi); return code; } -void osi_DisableAtimes(struct vnode *avp) +void +osi_DisableAtimes(struct vnode *avp) { - struct inode *ip = VTOI(avp); - ip->i_flag &= ~IACC; + struct inode *ip = VTOI(avp); + ip->i_flag &= ~IACC; } /* Generic read interface */ -int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize) +int +afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; unsigned int resid; register afs_int32 code; - register afs_int32 cnt1=0; + register afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ - if ( !afile ) { - if ( !afs_shuttingdown ) + if (!afile) { + if (!afs_shuttingdown) osi_Panic("osi_Read called with null param"); else return EIO; } - if (offset != -1) afile->offset = offset; + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); - code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, + AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); - } - else { + } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, - ICL_TYPE_INT32, code); + ICL_TYPE_INT32, code); code = -1; } return code; } /* Generic write interface */ -int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) +int +afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; unsigned int resid; register afs_int32 code; AFS_STATCNT(osi_Write); - if ( !afile ) - osi_Panic("afs_osi_Write called with null param"); - if (offset != -1) afile->offset = offset; + if (!afile) + osi_Panic("afs_osi_Write called with null param"); + if (offset != -1) + afile->offset = offset; { - struct ucred *tmpcred = curproc->p_cred->pc_ucred; + struct ucred *tmpcred = curproc->p_cred->pc_ucred; curproc->p_cred->pc_ucred = &afs_osi_cred; AFS_GUNLOCK(); - code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, + afile->offset, AFS_UIOSYS, IO_UNIT, &afs_osi_cred, + &resid); AFS_GLOCK(); curproc->p_cred->pc_ucred = tmpcred; } if (code == 0) { code = asize - resid; afile->offset += code; - } - else { + } else { code = -1; } if (afile->proc) { - (*afile->proc)(afile, code); + (*afile->proc) (afile, code); } return code; } @@ -200,7 +216,8 @@ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, /* This work should be handled by physstrat in ca/machdep.c. This routine written from the RT NFS port strategy routine. It has been generalized a bit, but should still be pretty clear. */ -int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) +int +afs_osi_MapStrategy(int (*aproc) (), register struct buf *bp) { afs_int32 returnCode; @@ -212,13 +229,13 @@ int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) -void shutdown_osifile(void) +void +shutdown_osifile(void) { - extern int afs_cold_shutdown; + extern int afs_cold_shutdown; - AFS_STATCNT(shutdown_osifile); - if (afs_cold_shutdown) { - afs_osicred_initialized = 0; - } + AFS_STATCNT(shutdown_osifile); + if (afs_cold_shutdown) { + afs_osicred_initialized = 0; + } } - diff --git a/src/afs/NBSD/osi_groups.c b/src/afs/NBSD/osi_groups.c index c512413a1..ac0d24c82 100644 --- a/src/afs/NBSD/osi_groups.c +++ b/src/afs/NBSD/osi_groups.c @@ -18,11 +18,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #define NOCRED ((struct ucred *) -1) #define NOUID ((uid_t) -1) @@ -30,24 +31,17 @@ RCSID("$Header$"); static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset); + afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset); static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent); + afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent); int Afs_xsetgroups(p, args, retval) - struct proc *p; - void *args; - int *retval; + struct proc *p; + void *args; + int *retval; { int code = 0; struct vrequest treq; @@ -58,7 +52,8 @@ Afs_xsetgroups(p, args, retval) /* code = afs_InitReq(&treq, u.u_cred); */ code = afs_InitReq(&treq, curproc->p_cred->pc_ucred); AFS_GUNLOCK(); - if (code) return code; + if (code) + return code; code = setgroups(p, args, retval); /* Note that if there is a pag already in the new groups we don't @@ -78,11 +73,11 @@ Afs_xsetgroups(p, args, retval) int setpag(proc, cred, pagvalue, newpag, change_parent) - struct proc *proc; - struct ucred **cred; - afs_uint32 pagvalue; - afs_uint32 *newpag; - afs_uint32 change_parent; + struct proc *proc; + struct ucred **cred; + afs_uint32 pagvalue; + afs_uint32 *newpag; + afs_uint32 change_parent; { gid_t gidset[NGROUPS]; int ngroups, code; @@ -95,12 +90,12 @@ setpag(proc, cred, pagvalue, newpag, change_parent) if (ngroups + 2 > NGROUPS) { return (E2BIG); } - for (j = ngroups -1; j >= 0; j--) { - gidset[j+2] = gidset[j]; - } + for (j = ngroups - 1; j >= 0; j--) { + gidset[j + 2] = gidset[j]; + } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]); code = afs_setgroups(proc, cred, ngroups, gidset, change_parent); return code; @@ -108,10 +103,7 @@ setpag(proc, cred, pagvalue, newpag, change_parent) static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset) +afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset) { int ngrps, savengrps; gid_t *gp; @@ -120,19 +112,15 @@ afs_getgroups( savengrps = ngrps = MIN(ngroups, cred->cr_ngroups); gp = cred->cr_groups; while (ngrps--) - *gidset++ = *gp++; + *gidset++ = *gp++; return savengrps; } static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent) { int ngrps; int i; @@ -160,5 +148,5 @@ afs_setgroups( substitute_real_creds(proc, NOUID, NOUID, NOGID, NOGID, newcr); } *cred = newcr; - return(0); + return (0); } diff --git a/src/afs/NBSD/osi_inode.c b/src/afs/NBSD/osi_inode.c index 2b1020aa0..f7985f820 100644 --- a/src/afs/NBSD/osi_inode.c +++ b/src/afs/NBSD/osi_inode.c @@ -16,12 +16,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ #include "afs/osi_inode.h" -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include #include #include @@ -45,39 +46,40 @@ getinode(fs, dev, inode, ipp, perror) register struct ufsmount *ump; register struct vnode *vp; register struct mount *mp; - + MOUNTLIST_LOCK(); - if (mp = TAILQ_FIRST(&mountlist)) do { - /* - * XXX Also do the test for MFS - */ + if (mp = TAILQ_FIRST(&mountlist)) + do { + /* + * XXX Also do the test for MFS + */ #undef m_data #undef m_next - if (mp->mnt_stat.f_type == MOUNT_UFS) { - MOUNTLIST_UNLOCK(); - ump = VFSTOUFS(mp); - if (ump->um_fs == NULL) - break; - if (ump->um_dev == dev) { - fs = ump->um_mountp; + if (mp->mnt_stat.f_type == MOUNT_UFS) { + MOUNTLIST_UNLOCK(); + ump = VFSTOUFS(mp); + if (ump->um_fs == NULL) + break; + if (ump->um_dev == dev) { + fs = ump->um_mountp; + } + MOUNTLIST_LOCK(); } - MOUNTLIST_LOCK(); - } - mp = TAILQ_NEXT(mp, mnt_list); - } while (mp != TAILQ_FIRST(&mountlist)); + mp = TAILQ_NEXT(mp, mnt_list); + } while (mp != TAILQ_FIRST(&mountlist)); MOUNTLIST_UNLOCK(); if (!fs) - return(ENXIO); + return (ENXIO); } - vp = (struct vnode *) fake_vnode; + vp = (struct vnode *)fake_vnode; fake_inode_init(vp, fs); code = iget(VTOI(vp), inode, &ip, 0); if (code != 0) { *perror = BAD_IGET; - return code; + return code; } else { *ipp = ip; - return(0); + return (0); } } @@ -97,26 +99,26 @@ igetinode(vfsp, dev, inode, ipp, perror) AFS_STATCNT(igetinode); if ((code = getinode(vfsp, dev, inode, &ip, perror)) != 0) { - return(code); + return (code); } if (ip->i_mode == 0) { /* Not an allocated inode */ - iforget(ip); - return(ENOENT); + iforget(ip); + return (ENOENT); } - if (ip->i_nlink == 0 || (ip->i_mode&IFMT) != IFREG) { + if (ip->i_nlink == 0 || (ip->i_mode & IFMT) != IFREG) { iput(ip); - return(ENOENT); + return (ENOENT); } *ipp = ip; - return(0); + return (0); } iforget(ip) -struct inode *ip; + struct inode *ip; { struct vnode *vp = ITOV(ip); @@ -139,73 +141,73 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval) long *retval; long dev, near_inode, param1, param2, param3, param4; { - int dummy, err=0; + int dummy, err = 0; struct inode *ip, *newip; register int code; struct vnode *vp; - + AFS_STATCNT(afs_syscall_icreate); - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = getinode(0, (dev_t)dev, 2, &ip, &dummy); + code = getinode(0, (dev_t) dev, 2, &ip, &dummy); if (code) { - return(ENOENT); + return (ENOENT); } - code = ialloc(ip, (ino_t)near_inode, 0, &newip); + code = ialloc(ip, (ino_t) near_inode, 0, &newip); iput(ip); if (code) { - return(code); + return (code); } IN_LOCK(newip); - newip->i_flag |= IACC|IUPD|ICHG; - + newip->i_flag |= IACC | IUPD | ICHG; + newip->i_nlink = 1; newip->i_mode = IFREG; - + IN_UNLOCK(newip); vp = ITOV(newip); VN_LOCK(vp); vp->v_type = VREG; VN_UNLOCK(vp); - + /* - if ( !vp->v_object) - { - extern struct vfs_ubcops ufs_ubcops; - extern struct vm_ubc_object* ubc_object_allocate(); - struct vm_ubc_object* vop; - vop = ubc_object_allocate(&vp, &ufs_ubcops, - vp->v_mount->m_funnel); - VN_LOCK(vp); - vp->v_object = vop; - VN_UNLOCK(vp); - } - */ - + * if ( !vp->v_object) + * { + * extern struct vfs_ubcops ufs_ubcops; + * extern struct vm_ubc_object* ubc_object_allocate(); + * struct vm_ubc_object* vop; + * vop = ubc_object_allocate(&vp, &ufs_ubcops, + * vp->v_mount->m_funnel); + * VN_LOCK(vp); + * vp->v_object = vop; + * VN_UNLOCK(vp); + * } + */ + IN_LOCK(newip); /* newip->i_flags |= IC_XUID|IC_XGID; */ /* newip->i_flags &= ~IC_PROPLIST; */ newip->i_vicep1 = param1; - if (param2 == 0x1fffffff/*INODESPECIAL*/) { + if (param2 == 0x1fffffff /*INODESPECIAL*/) { newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3)); - newip->i_vicep3a = (u_short)(param3 >> 16); - newip->i_vicep3b = (u_short)param3; + newip->i_vicep3a = (u_short) (param3 >> 16); + newip->i_vicep3b = (u_short) param3; } else { - newip->i_vicep2 = (((param2 >> 16) & 0x1f) << 27) + - (((param4 >> 16) & 0x1f) << 22) + - (param3 & 0x3fffff); - newip->i_vicep3a = (u_short)param4; - newip->i_vicep3b = (u_short)param2; + newip->i_vicep2 = + (((param2 >> 16) & 0x1f) << 27) + + (((param4 >> 16) & 0x1f) << 22) + (param3 & 0x3fffff); + newip->i_vicep3a = (u_short) param4; + newip->i_vicep3b = (u_short) param2; } newip->i_vicemagic = VICEMAGIC; - + *retval = newip->i_number; IN_UNLOCK(newip); iput(newip); - return(code); + return (code); } @@ -220,31 +222,31 @@ afs_syscall_iopen(dev, inode, usrmod, retval) int fd; extern struct fileops vnops; register int code; - + AFS_STATCNT(afs_syscall_iopen); - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy); + code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy); if (code) { - return(code); + return (code); } if ((code = falloc(curproc, &fp, &fd)) != 0) { iput(ip); - return(code); + return (code); } IN_UNLOCK(ip); - + /* FreeBSD doesn't do much mp stuff yet :( */ /* FP_LOCK(fp); */ fp->f_flag = (usrmod) & FMASK; fp->f_type = DTYPE_VNODE; fp->f_ops = &vnops; - fp->f_data = (caddr_t)ITOV(ip); - + fp->f_data = (caddr_t) ITOV(ip); + /* FP_UNLOCK(fp); */ - return(0); + return (0); } @@ -260,18 +262,18 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount) int dummy; struct inode *ip; register int code; - + if (!afs_suser()) - return(EPERM); + return (EPERM); - code = igetinode(0, (dev_t)dev, (ino_t)inode, &ip, &dummy); + code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy); if (code) { - return(code); + return (code); } if (!IS_VICEMAGIC(ip)) { - return(EPERM); + return (EPERM); } else if (ip->i_vicep1 != inode_p1) { - return(ENXIO); + return (ENXIO); } ip->i_nlink += amount; if (ip->i_nlink == 0) { @@ -279,5 +281,5 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount) } ip->i_flag |= ICHG; iput(ip); - return(0); + return (0); } diff --git a/src/afs/NBSD/osi_inode.h b/src/afs/NBSD/osi_inode.h index 39c706fa1..d63526c95 100644 --- a/src/afs/NBSD/osi_inode.h +++ b/src/afs/NBSD/osi_inode.h @@ -46,7 +46,7 @@ #define di_vicep2 di_gid #define di_vicep3a di_u.oldids[0] #define di_vicep3b di_u.oldids[1] -#define di_vicep4 di_spare[1] /* not used */ +#define di_vicep4 di_spare[1] /* not used */ /* * Macros for handling inode numbers: diff --git a/src/afs/NBSD/osi_misc.c b/src/afs/NBSD/osi_misc.c index 8c48c799d..c07775086 100644 --- a/src/afs/NBSD/osi_misc.c +++ b/src/afs/NBSD/osi_misc.c @@ -17,7 +17,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ @@ -28,11 +29,12 @@ RCSID("$Header$"); * Note that it must NOT set errno. */ -afs_suser() { +afs_suser() +{ int error; if (suser(curproc) == 0) { - return(1); + return (1); } - return(0); + return (0); } diff --git a/src/afs/NBSD/osi_sleep.c b/src/afs/NBSD/osi_sleep.c index 6948109d4..0ee567813 100644 --- a/src/afs/NBSD/osi_sleep.c +++ b/src/afs/NBSD/osi_sleep.c @@ -11,11 +11,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ @@ -23,21 +24,24 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok); static char waitV; -void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) +void +afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) { AFS_STATCNT(osi_InitWaitHandle); achandle->proc = (caddr_t) 0; } /* cancel osi_Wait */ -void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) { caddr_t proc; AFS_STATCNT(osi_CancelWait); proc = achandle->proc; - if (proc == 0) return; - achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ + if (proc == 0) + return; + achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ afs_osi_Wakeup(&waitV); } @@ -45,21 +49,23 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) * Waits for data on ahandle, or ams ms later. ahandle may be null. * Returns 0 if timeout and EINTR if signalled. */ -int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) +int +afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int code; afs_int32 endTime, tid; AFS_STATCNT(osi_Wait); - endTime = osi_Time() + (ams/1000); + endTime = osi_Time() + (ams / 1000); if (ahandle) - ahandle->proc = (caddr_t) curproc; + ahandle->proc = (caddr_t) curproc; do { AFS_ASSERT_GLOCK(); code = 0; code = osi_TimedSleep(&waitV, ams, aintok); - if (code) break; /* if something happened, quit now */ + if (code) + break; /* if something happened, quit now */ /* if we we're cancelled, quit now */ if (ahandle && (ahandle->proc == (caddr_t) 0)) { /* we've been signalled */ @@ -77,19 +83,20 @@ typedef struct afs_event { char *event; /* lwp event: an address */ int refcount; /* Is it in use? */ int seq; /* Sequence number: this is incremented - by wakeup calls; wait will not return until - it changes */ + * by wakeup calls; wait will not return until + * it changes */ int cond; } afs_event_t; #define HASHSIZE 128 -afs_event_t *afs_evhasht[HASHSIZE];/* Hash table for events */ +afs_event_t *afs_evhasht[HASHSIZE]; /* Hash table for events */ #define afs_evhash(event) (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1)); int afs_evhashcnt = 0; /* Get and initialize event structure corresponding to lwp event (i.e. address) * */ -static afs_event_t *afs_getevent(char *event) +static afs_event_t * +afs_getevent(char *event) { afs_event_t *evp, *newp = 0; int hashcode; @@ -107,7 +114,7 @@ static afs_event_t *afs_getevent(char *event) evp = evp->next; } if (!newp) { - newp = (afs_event_t *) osi_AllocSmallSpace(sizeof (afs_event_t)); + newp = (afs_event_t *) osi_AllocSmallSpace(sizeof(afs_event_t)); afs_evhashcnt++; newp->next = afs_evhasht[hashcode]; afs_evhasht[hashcode] = newp; @@ -122,7 +129,8 @@ static afs_event_t *afs_getevent(char *event) #define relevent(evp) ((evp)->refcount--) -void afs_osi_Sleep(void *event) +void +afs_osi_Sleep(void *event) { struct afs_event *evp; int seq; @@ -131,7 +139,7 @@ void afs_osi_Sleep(void *event) seq = evp->seq; while (seq == evp->seq) { AFS_ASSERT_GLOCK(); - assert_wait((vm_offset_t)(&evp->cond), 0); + assert_wait((vm_offset_t) (&evp->cond), 0); AFS_GUNLOCK(); thread_block(); AFS_GLOCK(); @@ -139,7 +147,8 @@ void afs_osi_Sleep(void *event) relevent(evp); } -int afs_osi_SleepSig(void *event) +int +afs_osi_SleepSig(void *event) { afs_osi_Sleep(event); return 0; @@ -154,40 +163,42 @@ int afs_osi_SleepSig(void *event) * * Returns 0 if timeout and EINTR if signalled. */ -static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) +static int +osi_TimedSleep(char *event, afs_int32 ams, int aintok) { int code = 0; struct afs_event *evp; int ticks; - ticks = ( ams * afs_hz )/1000; + ticks = (ams * afs_hz) / 1000; evp = afs_getevent(event); - assert_wait((vm_offset_t)(&evp->cond), aintok); + assert_wait((vm_offset_t) (&evp->cond), aintok); AFS_GUNLOCK(); thread_set_timeout(ticks); thread_block(); AFS_GLOCK(); /* if (current_thread()->wait_result != THREAD_AWAKENED) - code = EINTR; */ - + * code = EINTR; */ + relevent(evp); return code; } -int afs_osi_Wakeup(void *event) +int +afs_osi_Wakeup(void *event) { - int ret=1; + int ret = 1; struct afs_event *evp; evp = afs_getevent(event); if (evp->refcount > 1) { - evp->seq++; - thread_wakeup((vm_offset_t)(&evp->cond)); - ret=0; + evp->seq++; + thread_wakeup((vm_offset_t) (&evp->cond)); + ret = 0; } relevent(evp); return ret; diff --git a/src/afs/NBSD/osi_vfsops.c b/src/afs/NBSD/osi_vfsops.c index ff9d3a8de..4bb0b3cc5 100644 --- a/src/afs/NBSD/osi_vfsops.c +++ b/src/afs/NBSD/osi_vfsops.c @@ -13,11 +13,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include #include #include @@ -37,10 +38,8 @@ udecl_simple_lock_data(, afsmntid_lock) #define AFSMNTID_LOCK() usimple_lock(&afsmntid_lock) #define AFSMNTID_UNLOCK() usimple_unlock(&afsmntid_lock) #define AFSMNTID_LOCK_INIT() usimple_lock_init(&afsmntid_lock) - - -int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, - struct nameidata *ndp) + int mp_afs_mount(struct mount *afsp, char *path, caddr_t data, + struct nameidata *ndp) { u_int size; @@ -51,7 +50,7 @@ int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, AFS_GLOCK(); AFS_STATCNT(afs_mount); - if (afs_globalVFS) { /* Don't allow remounts. */ + if (afs_globalVFS) { /* Don't allow remounts. */ AFS_GUNLOCK(); return (EBUSY); } @@ -65,7 +64,7 @@ int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, afsp->m_stat.f_fsid.val[1] = MOUNT_AFS; AFSMNTID_LOCK(); if (++afs_mntid == 0) - ++afs_mntid; + ++afs_mntid; AFSMNTID_UNLOCK(); BM(AFSMNTID_LOCK()); tfsid.val[0] = makedev(130, afs_mntid); @@ -73,29 +72,30 @@ int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, BM(AFSMNTID_UNLOCK()); while (xmp = getvfs(&tfsid)) { - UNMOUNT_READ_UNLOCK(xmp); - tfsid.val[0]++; - AFSMNTID_LOCK(); - afs_mntid++; - AFSMNTID_UNLOCK(); + UNMOUNT_READ_UNLOCK(xmp); + tfsid.val[0]++; + AFSMNTID_LOCK(); + afs_mntid++; + AFSMNTID_UNLOCK(); } if (major(tfsid.val[0]) != 130) { AFS_GUNLOCK(); - return (ENOENT); + return (ENOENT); } afsp->m_stat.f_fsid.val[0] = tfsid.val[0]; afsp->m_stat.f_mntonname = AFS_KALLOC(MNAMELEN); - afsp->m_stat.f_mntfromname = AFS_KALLOC(MNAMELEN); - if ( !afsp->m_stat.f_mntonname || !afsp->m_stat.f_mntfromname) + afsp->m_stat.f_mntfromname = AFS_KALLOC(MNAMELEN); + if (!afsp->m_stat.f_mntonname || !afsp->m_stat.f_mntfromname) panic("malloc failure in afs_mount\n"); memset(afsp->m_stat.f_mntonname, 0, MNAMELEN); memset(afsp->m_stat.f_mntfromname, 0, MNAMELEN); - AFS_COPYINSTR(path, (caddr_t)afsp->m_stat.f_mntonname, MNAMELEN, &size, code); + AFS_COPYINSTR(path, (caddr_t) afsp->m_stat.f_mntonname, MNAMELEN, &size, + code); memcpy(afsp->m_stat.f_mntfromname, "AFS", 4); AFS_GUNLOCK(); - (void) mp_afs_statfs(afsp); + (void)mp_afs_statfs(afsp); AFS_GLOCK(); afs_vfsdev = afsp->m_stat.f_fsid.val[0]; @@ -109,7 +109,8 @@ int mp_afs_mount(struct mount *afsp,char * path, caddr_t data, } -int mp_afs_unmount (struct mount *afsp, int flag) +int +mp_afs_unmount(struct mount *afsp, int flag) { AFS_GLOCK(); AFS_STATCNT(afs_unmount); @@ -120,16 +121,18 @@ int mp_afs_unmount (struct mount *afsp, int flag) } -int mp_afs_start(struct mount *mp, int flags) +int +mp_afs_start(struct mount *mp, int flags) { - return(0); + return (0); } -int mp_afs_root (struct mount *afsp, struct vnode **avpp) +int +mp_afs_root(struct mount *afsp, struct vnode **avpp) { register afs_int32 code = 0; struct vrequest treq; - register struct vcache *tvp=0; + register struct vcache *tvp = 0; AFS_GLOCK(); AFS_STATCNT(afs_root); @@ -141,8 +144,7 @@ int mp_afs_root (struct mount *afsp, struct vnode **avpp) afs_globalVp = NULL; } - if (!(code = afs_InitReq(&treq, cred)) && - !(code = afs_CheckInit())) { + if (!(code = afs_InitReq(&treq, cred)) && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); /* we really want this to stay around */ if (tvp) { @@ -155,12 +157,12 @@ int mp_afs_root (struct mount *afsp, struct vnode **avpp) AFS_GUNLOCK(); VN_HOLD((struct vnode *)tvp); VN_LOCK((struct vnode *)tvp); - tvp->v.v_flag |= VROOT; /* No-op on Ultrix 2.2 */ + tvp->v.v_flag |= VROOT; /* No-op on Ultrix 2.2 */ VN_UNLOCK((struct vnode *)tvp); AFS_GLOCK(); afs_globalVFS = afsp; - *avpp = (struct vnode *) tvp; + *avpp = (struct vnode *)tvp; } afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp, @@ -170,12 +172,13 @@ int mp_afs_root (struct mount *afsp, struct vnode **avpp) } -mp_afs_quotactl(struct mount *mp, int cmd, uid_t uid, caddr_t arg) +mp_afs_quotactl(struct mount * mp, int cmd, uid_t uid, caddr_t arg) { return EOPNOTSUPP; } -int mp_afs_statfs(struct mount *afsp) +int +mp_afs_statfs(struct mount *afsp) { struct nstatfs *abp = &afsp->m_stat; @@ -190,7 +193,7 @@ int mp_afs_statfs(struct mount *afsp) * storing something there. */ abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 2000000; + abp->f_ffree = 2000000; abp->f_fsize = 1024; abp->f_fsid.val[0] = afsp->m_stat.f_fsid.val[0]; @@ -201,14 +204,16 @@ int mp_afs_statfs(struct mount *afsp) } -int mp_afs_sync(struct mount *mp, int flags) +int +mp_afs_sync(struct mount *mp, int flags) { AFS_STATCNT(afs_sync); return 0; } -int mp_afs_fhtovp(struct mount *afsp, struct fid *fidp, struct vnode **avcp) +int +mp_afs_fhtovp(struct mount *afsp, struct fid *fidp, struct vnode **avcp) { struct vrequest treq; register code = 0; @@ -219,7 +224,7 @@ int mp_afs_fhtovp(struct mount *afsp, struct fid *fidp, struct vnode **avcp) *avcp = NULL; if ((code = afs_InitReq(&treq, cred)) == 0) { - code = afs_osi_vget((struct vcache**)avcp, fidp, &treq); + code = afs_osi_vget((struct vcache **)avcp, fidp, &treq); } afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp, @@ -259,11 +264,12 @@ int mp_afs_fhtovp(struct mount *afsp, struct fid *fidp, struct vnode **avcp) */ #define AFS_FIDDATASIZE 8 -#define AFS_SIZEOFSMALLFID 12 /* full size of fid, including len field */ -extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */ -int afs_fid_vnodeoverflow=0, afs_fid_uniqueoverflow=0; +#define AFS_SIZEOFSMALLFID 12 /* full size of fid, including len field */ +extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */ +int afs_fid_vnodeoverflow = 0, afs_fid_uniqueoverflow = 0; -int mp_afs_vptofh(struct vnode *avn, struct fid *fidp) +int +mp_afs_vptofh(struct vnode *avn, struct fid *fidp) { struct SmallFid Sfid; long addr[2]; @@ -279,13 +285,14 @@ int mp_afs_vptofh(struct vnode *avn, struct fid *fidp) return EIO; } - if (afs_NFSRootOnly && (avc == afs_globalVp)) rootvp = 1; + if (afs_NFSRootOnly && (avc == afs_globalVp)) + rootvp = 1; if (!afs_NFSRootOnly || rootvp) { tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); Sfid.Volume = avc->fid.Fid.Volume; fidp->fid_reserved = avc->fid.Fid.Vnode; - Sfid.CellAndUnique = ((tcell->cellIndex << 24) + - (avc->fid.Fid.Unique & 0xffffff)); + Sfid.CellAndUnique = + ((tcell->cellIndex << 24) + (avc->fid.Fid.Unique & 0xffffff)); afs_PutCell(tcell, READ_LOCK); if (avc->fid.Fid.Vnode > 0xffff) afs_fid_vnodeoverflow++; @@ -303,26 +310,27 @@ int mp_afs_vptofh(struct vnode *avn, struct fid *fidp) fidp->fid_len = AFS_SIZEOFSMALLFID; if (afs_NFSRootOnly) { if (rootvp) { - memcpy(fidp->fid_data, (caddr_t)&Sfid, AFS_FIDDATASIZE); + memcpy(fidp->fid_data, (caddr_t) & Sfid, AFS_FIDDATASIZE); } else { - memcpy(fidp->fid_data, (caddr_t)addr, AFS_FIDDATASIZE); + memcpy(fidp->fid_data, (caddr_t) addr, AFS_FIDDATASIZE); } } else { - memcpy(fidp->fid_data, (caddr_t)&Sfid, AFS_FIDDATASIZE); + memcpy(fidp->fid_data, (caddr_t) & Sfid, AFS_FIDDATASIZE); } AFS_GUNLOCK(); return 0; } -int mp_Afs_init(void); /* vfs_init - defined below */ +int mp_Afs_init(void); /* vfs_init - defined below */ /* This is only called by vfs_mount when afs is going to be mounted as root. * Since we don't support diskless clients we shouldn't come here. */ -int afsmountroot=0; -int mp_afs_mountroot(struct mount *afsp, struct vnode **vp) +int afsmountroot = 0; +int +mp_afs_mountroot(struct mount *afsp, struct vnode **vp) { AFS_GLOCK(); AFS_STATCNT(afs_mountroot); @@ -335,8 +343,9 @@ int mp_afs_mountroot(struct mount *afsp, struct vnode **vp) /* It's called to setup swapping over the net for diskless clients; again * not for us. */ -int afsswapvp=0; -int mp_afs_swapvp(void) +int afsswapvp = 0; +int +mp_afs_swapvp(void) { AFS_GLOCK(); AFS_STATCNT(afs_swapvp); @@ -354,7 +363,7 @@ struct vfsops afs_vfsops = { mp_afs_quotactl, mp_afs_statfs, mp_afs_sync, - mp_afs_fhtovp, /* afs_vget */ + mp_afs_fhtovp, /* afs_vget */ mp_afs_vptofh, mp_Afs_init, mp_afs_mountroot, @@ -367,16 +376,16 @@ struct vfsops afs_vfsops = { */ #define NULL_FUNC (int (*)(int))0 -int (*afs_syscall_func)() = NULL_FUNC; -int (*afs_xsetgroups_func)() = NULL_FUNC; -int (*afs_xioctl_func)() = NULL_FUNC; +int (*afs_syscall_func) () = NULL_FUNC; +int (*afs_xsetgroups_func) () = NULL_FUNC; +int (*afs_xioctl_func) () = NULL_FUNC; afssyscall(p, args, retval) - struct proc *p; - void *args; - long *retval; + struct proc *p; + void *args; + long *retval; { - int (*func)(); + int (*func) (); int code; AFS_GLOCK(); @@ -384,18 +393,18 @@ afssyscall(p, args, retval) if (func == NULL_FUNC) { code = nosys(p, args, retval); } else { - code = (*func)(p, args, retval); + code = (*func) (p, args, retval); } AFS_GUNLOCK(); return code; } afsxsetgroups(p, args, retval) - struct proc *p; - void *args; - long *retval; + struct proc *p; + void *args; + long *retval; { - int (*func)(); + int (*func) (); int code; AFS_GLOCK(); @@ -403,18 +412,18 @@ afsxsetgroups(p, args, retval) if (func == NULL_FUNC) { code = nosys(p, args, retval); } else { - code = (*func)(p, args, retval); + code = (*func) (p, args, retval); } AFS_GUNLOCK(); return code; } afsxioctl(p, args, retval) - struct proc *p; - void *args; - long *retval; + struct proc *p; + void *args; + long *retval; { - int (*func)(); + int (*func) (); int code; AFS_GLOCK(); @@ -422,7 +431,7 @@ afsxioctl(p, args, retval) if (func == NULL_FUNC) { code = nosys(p, args, retval); } else { - code = (*func)(p, args, retval); + code = (*func) (p, args, retval); } AFS_GUNLOCK(); return code; @@ -439,15 +448,16 @@ afs_unconfig() } -cfg_subsys_attr_t afs_attributes[] = { +cfg_subsys_attr_t afs_attributes[] = { {"", 0, 0, 0, 0, 0, 0} /* must be the last element */ }; -afs_configure(cfg_op_t op, caddr_t indata, size_t indata_size, caddr_t outdata, size_t outdata_size) +afs_configure(cfg_op_t op, caddr_t indata, size_t indata_size, + caddr_t outdata, size_t outdata_size) { - cfg_attr_t *attributes; - int ret = ESUCCESS; - int i, j, size; + cfg_attr_t *attributes; + int ret = ESUCCESS; + int i, j, size; caddr_t p; switch (op) { @@ -457,11 +467,11 @@ afs_configure(cfg_op_t op, caddr_t indata, size_t indata_size, caddr_t outdata, * indata_size is the count of attributes. */ if ((ret = vfssw_add_fsname(MOUNT_AFS, &afs_vfsops, "afs")) != 0) - return(ret); + return (ret); break; case CFG_OP_UNCONFIGURE: if ((ret = afs_unconfig()) != 0) - return(ret); + return (ret); break; default: ret = EINVAL; @@ -471,16 +481,17 @@ afs_configure(cfg_op_t op, caddr_t indata, size_t indata_size, caddr_t outdata, } -int mp_Afs_init(void) +int +mp_Afs_init(void) { extern int Afs_xsetgroups(), afs_xioctl(), afs3_syscall(); - + AFS_GLOCK(); sysent[AFS_SYSCALL].sy_call = afs3_syscall; sysent[AFS_SYSCALL].sy_parallel = 0; sysent[AFS_SYSCALL].sy_narg = 6; sysent[SYS_setgroups].sy_call = Afs_xsetgroups; - afs_xioctl_func = afsxioctl; + afs_xioctl_func = afsxioctl; afs_xsetgroups_func = afsxsetgroups; afs_syscall_func = afssyscall; AFS_GUNLOCK(); diff --git a/src/afs/NBSD/osi_vm.c b/src/afs/NBSD/osi_vm.c index 8a1008461..888982d3d 100644 --- a/src/afs/NBSD/osi_vm.c +++ b/src/afs/NBSD/osi_vm.c @@ -21,11 +21,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ /* #include */ #include #include @@ -46,7 +47,8 @@ RCSID("$Header$"); * * OSF/1 Locking: VN_LOCK has been called. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { #ifdef SECRETLY_OSF1 if (avc->vrefCount > 1) @@ -93,7 +95,8 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * * Called with the global lock NOT held. */ -static void osi_ubc_flush_dirty_and_wait(struct vnode *vp, int flags) +static void +osi_ubc_flush_dirty_and_wait(struct vnode *vp, int flags) { int retry; vm_page_t pp; @@ -101,9 +104,9 @@ static void osi_ubc_flush_dirty_and_wait(struct vnode *vp, int flags) #ifdef SECRETLY_OSF1 do { - struct vm_ubc_object* vop; - vop = (struct vm_ubc_object*)(vp->v_object); - ubc_flush_dirty(vop, flags); + struct vm_ubc_object *vop; + vop = (struct vm_ubc_object *)(vp->v_object); + ubc_flush_dirty(vop, flags); vm_object_lock(vop); if (vop->vu_dirtypl) @@ -118,14 +121,15 @@ static void osi_ubc_flush_dirty_and_wait(struct vnode *vp, int flags) if (pp->pg_busy) { retry = 1; pp->pg_wait = 1; - assert_wait_mesg((vm_offset_t)pp, FALSE, "pg_wait"); + assert_wait_mesg((vm_offset_t) pp, FALSE, "pg_wait"); vm_object_unlock(vop); thread_block(); break; } } } - if (retry) continue; + if (retry) + continue; } vm_object_unlock(vop); } while (retry); @@ -137,14 +141,15 @@ static void osi_ubc_flush_dirty_and_wait(struct vnode *vp, int flags) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { #ifdef SECRETLY_OSF1 ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); osi_ubc_flush_dirty_and_wait((struct vnode *)avc, 0); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,94); + ObtainWriteLock(&avc->lock, 94); #endif /* SECRETLY_OSF1 */ } @@ -157,7 +162,8 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * Since we drop and re-obtain the lock, we can't guarantee that there won't * be some pages around when we return, newly created by concurrent activity. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { #ifdef SECRETLY_OSF1 ReleaseWriteLock(&avc->lock); @@ -165,7 +171,7 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) osi_ubc_flush_dirty_and_wait((struct vnode *)avc, 0); ubc_invalidate(((struct vnode *)avc)->v_object, 0, 0, B_INVAL); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,59); + ObtainWriteLock(&avc->lock, 59); #endif /* SECRETLY_OSF1 */ } @@ -173,7 +179,8 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) * * Locking: No lock is held, not even the global lock. */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { #ifdef SECRETLY_OSF1 ubc_flush_dirty(((struct vnode *)avc)->v_object, 0); @@ -187,10 +194,11 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * activeV is raised. This is supposed to block pageins, but at present * it only works on Solaris. */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { #ifdef SECRETLY_OSF1 - ubc_invalidate(((struct vnode *)avc)->v_object, alen, - MAXINT - alen, B_INVAL); + ubc_invalidate(((struct vnode *)avc)->v_object, alen, MAXINT - alen, + B_INVAL); #endif /* SECRETLY_OSF1 */ } diff --git a/src/afs/NBSD/osi_vnodeops.c b/src/afs/NBSD/osi_vnodeops.c index 23bb5f063..a8e193335 100644 --- a/src/afs/NBSD/osi_vnodeops.c +++ b/src/afs/NBSD/osi_vnodeops.c @@ -14,12 +14,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include #include #include @@ -50,48 +51,48 @@ int mp_afs_closex(); #if 0 /* AFS vnodeops */ struct vnodeops Afs_vnodeops = { - mp_afs_lookup, - mp_afs_create, - afs_noop, /* vn_mknod */ - mp_afs_open, - mp_afs_close, - mp_afs_access, - mp_afs_getattr, - mp_afs_setattr, - mp_afs_ubcrdwr, - mp_afs_ubcrdwr, - afs_badop, /* vn_ioctl */ - seltrue, /* vn_select */ - mp_afs_mmap, - mp_afs_fsync, - mp_afs_seek, - mp_afs_remove, - mp_afs_link, - mp_afs_rename, - mp_afs_mkdir, - mp_afs_rmdir, - mp_afs_symlink, - mp_afs_readdir, - mp_afs_readlink, - mp_afs_abortop, - mp_afs_inactive, - mp_afs_reclaim, - mp_afs_bmap, - mp_afs_strategy, - mp_afs_print, - mp_afs_page_read, - mp_afs_page_write, - mp_afs_swap, - mp_afs_bread, - mp_afs_brelse, - mp_afs_lockctl, - mp_afs_syncdata, - afs_noop, /* Lock */ - afs_noop, /* unLock */ - afs_noop, /* get ext attrs */ - afs_noop, /* set ext attrs */ - afs_noop, /* del ext attrs */ - vn_pathconf_default, + mp_afs_lookup, + mp_afs_create, + afs_noop, /* vn_mknod */ + mp_afs_open, + mp_afs_close, + mp_afs_access, + mp_afs_getattr, + mp_afs_setattr, + mp_afs_ubcrdwr, + mp_afs_ubcrdwr, + afs_badop, /* vn_ioctl */ + seltrue, /* vn_select */ + mp_afs_mmap, + mp_afs_fsync, + mp_afs_seek, + mp_afs_remove, + mp_afs_link, + mp_afs_rename, + mp_afs_mkdir, + mp_afs_rmdir, + mp_afs_symlink, + mp_afs_readdir, + mp_afs_readlink, + mp_afs_abortop, + mp_afs_inactive, + mp_afs_reclaim, + mp_afs_bmap, + mp_afs_strategy, + mp_afs_print, + mp_afs_page_read, + mp_afs_page_write, + mp_afs_swap, + mp_afs_bread, + mp_afs_brelse, + mp_afs_lockctl, + mp_afs_syncdata, + afs_noop, /* Lock */ + afs_noop, /* unLock */ + afs_noop, /* get ext attrs */ + afs_noop, /* set ext attrs */ + afs_noop, /* del ext attrs */ + vn_pathconf_default, }; struct vnodeops *afs_ops = &Afs_vnodeops; #endif /* 0 */ @@ -113,8 +114,8 @@ struct fileops afs_fileops = { #if 0 mp_afs_lookup(adp, ndp) - struct vcache *adp; - struct nameidata *ndp; + struct vcache *adp; + struct nameidata *ndp; { int code; AFS_GLOCK(); @@ -124,8 +125,8 @@ mp_afs_lookup(adp, ndp) } mp_afs_create(ndp, attrs) - struct nameidata *ndp; - struct vattr *attrs; + struct nameidata *ndp; + struct vattr *attrs; { int code; AFS_GLOCK(); @@ -135,9 +136,9 @@ mp_afs_create(ndp, attrs) } mp_afs_open(avcp, aflags, acred) - struct vcache **avcp; - afs_int32 aflags; - struct AFS_UCRED *acred; + struct vcache **avcp; + afs_int32 aflags; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -147,9 +148,9 @@ mp_afs_open(avcp, aflags, acred) } mp_afs_access(avc, amode, acred) - struct vcache *avc; - afs_int32 amode; - struct AFS_UCRED *acred; + struct vcache *avc; + afs_int32 amode; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -159,9 +160,9 @@ mp_afs_access(avc, amode, acred) } mp_afs_close(avc, flags, cred) - struct vnode *avc; - int flags; - struct ucred *cred; + struct vnode *avc; + int flags; + struct ucred *cred; { int code; AFS_GLOCK(); @@ -171,9 +172,9 @@ mp_afs_close(avc, flags, cred) } mp_afs_getattr(avc, attrs, acred) - struct vcache *avc; - struct vattr *attrs; - struct AFS_UCRED *acred; + struct vcache *avc; + struct vattr *attrs; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -183,9 +184,9 @@ mp_afs_getattr(avc, attrs, acred) } mp_afs_setattr(avc, attrs, acred) - struct vcache *avc; - struct vattr *attrs; - struct AFS_UCRED *acred; + struct vcache *avc; + struct vattr *attrs; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -195,10 +196,10 @@ mp_afs_setattr(avc, attrs, acred) } mp_afs_fsync(avc, fflags, acred, waitfor) - struct vcache *avc; - int fflags; - struct AFS_UCRED *acred; - int waitfor; + struct vcache *avc; + int fflags; + struct AFS_UCRED *acred; + int waitfor; { int code; AFS_GLOCK(); @@ -208,7 +209,7 @@ mp_afs_fsync(avc, fflags, acred, waitfor) } mp_afs_remove(ndp) - struct nameidata *ndp; + struct nameidata *ndp; { int code; AFS_GLOCK(); @@ -218,8 +219,8 @@ mp_afs_remove(ndp) } mp_afs_link(avc, ndp) - struct vcache *avc; - struct nameidata *ndp; + struct vcache *avc; + struct nameidata *ndp; { int code; AFS_GLOCK(); @@ -229,7 +230,7 @@ mp_afs_link(avc, ndp) } mp_afs_rename(fndp, tndp) - struct nameidata *fndp, *tndp; + struct nameidata *fndp, *tndp; { int code; AFS_GLOCK(); @@ -239,8 +240,8 @@ mp_afs_rename(fndp, tndp) } mp_afs_mkdir(ndp, attrs) - struct nameidata *ndp; - struct vattr *attrs; + struct nameidata *ndp; + struct vattr *attrs; { int code; AFS_GLOCK(); @@ -250,7 +251,7 @@ mp_afs_mkdir(ndp, attrs) } mp_afs_rmdir(ndp) - struct nameidata *ndp; + struct nameidata *ndp; { int code; AFS_GLOCK(); @@ -260,9 +261,9 @@ mp_afs_rmdir(ndp) } mp_afs_symlink(ndp, attrs, atargetName) - struct nameidata *ndp; - struct vattr *attrs; - register char *atargetName; + struct nameidata *ndp; + struct vattr *attrs; + register char *atargetName; { int code; AFS_GLOCK(); @@ -272,10 +273,10 @@ mp_afs_symlink(ndp, attrs, atargetName) } mp_afs_readdir(avc, auio, acred, eofp) - struct vcache *avc; - struct uio *auio; - struct AFS_UCRED *acred; - int *eofp; + struct vcache *avc; + struct uio *auio; + struct AFS_UCRED *acred; + int *eofp; { int code; AFS_GLOCK(); @@ -285,9 +286,9 @@ mp_afs_readdir(avc, auio, acred, eofp) } mp_afs_readlink(avc, auio, acred) - struct vcache *avc; - struct uio *auio; - struct AFS_UCRED *acred; + struct vcache *avc; + struct uio *auio; + struct AFS_UCRED *acred; { int code; AFS_GLOCK(); @@ -297,12 +298,12 @@ mp_afs_readlink(avc, auio, acred) } mp_afs_lockctl(avc, af, flag, acred, clid, offset) - struct vcache *avc; - struct eflock *af; - struct AFS_UCRED *acred; - int flag; - pid_t clid; - off_t offset; + struct vcache *avc; + struct eflock *af; + struct AFS_UCRED *acred; + int flag; + pid_t clid; + off_t offset; { int code; AFS_GLOCK(); @@ -312,7 +313,7 @@ mp_afs_lockctl(avc, af, flag, acred, clid, offset) } mp_afs_closex(afd) - struct file *afd; + struct file *afd; { int code; AFS_GLOCK(); @@ -322,25 +323,25 @@ mp_afs_closex(afd) } mp_afs_seek(avc, oldoff, newoff, cred) - struct vcache *avc; - off_t oldoff, newoff; - struct ucred *cred; + struct vcache *avc; + off_t oldoff, newoff; + struct ucred *cred; { - if ((int) newoff < 0) - return(EINVAL); + if ((int)newoff < 0) + return (EINVAL); else - return(0); + return (0); } mp_afs_abortop(ndp) - struct nameidata *ndp; + struct nameidata *ndp; { - return(0); + return (0); } mp_afs_inactive(avc, acred) - register struct vcache *avc; - struct AFS_UCRED *acred; + register struct vcache *avc; + struct AFS_UCRED *acred; { AFS_GLOCK(); afs_InactiveVCache(avc, acred); @@ -349,21 +350,21 @@ mp_afs_inactive(avc, acred) mp_afs_reclaim(avc) - struct vcache *avc; + struct vcache *avc; { - return(0); + return (0); } mp_afs_print(avc) - struct vcache *avc; + struct vcache *avc; { - return(0); + return (0); } mp_afs_page_read(avc, uio, acred) - struct vcache *avc; - struct uio *uio; - struct ucred *acred; + struct vcache *avc; + struct uio *uio; + struct ucred *acred; { int error; struct vrequest treq; @@ -371,26 +372,26 @@ mp_afs_page_read(avc, uio, acred) AFS_GLOCK(); error = afs_rdwr(avc, uio, UIO_READ, 0, acred); afs_Trace3(afs_iclSetp, CM_TRACE_PAGE_READ, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, error, ICL_TYPE_INT32, avc->states); + ICL_TYPE_INT32, error, ICL_TYPE_INT32, avc->states); if (error) { error = EIO; } else if ((avc->states) == 0) { afs_InitReq(&treq, acred); - ObtainWriteLock(&avc->lock,161); + ObtainWriteLock(&avc->lock, 161); afs_Wire(avc, &treq); ReleaseWriteLock(&avc->lock); } AFS_GUNLOCK(); - return(error); + return (error); } mp_afs_page_write(avc, uio, acred, pager, offset) - struct vcache *avc; - struct uio *uio; - struct ucred *acred; - memory_object_t pager; - vm_offset_t offset; + struct vcache *avc; + struct uio *uio; + struct ucred *acred; + memory_object_t pager; + vm_offset_t offset; { int error; @@ -402,20 +403,20 @@ mp_afs_page_write(avc, uio, acred, pager, offset) error = EIO; } AFS_GUNLOCK(); - return(error); + return (error); } -int DO_FLUSH=1; +int DO_FLUSH = 1; mp_afs_ubcrdwr(avc, uio, ioflag, cred) - struct vcache *avc; - struct uio *uio; - int ioflag; - struct ucred *cred; + struct vcache *avc; + struct uio *uio; + int ioflag; + struct ucred *cred; { register afs_int32 code; register char *data; - afs_int32 fileBase, size, cnt=0; + afs_int32 fileBase, size, cnt = 0; afs_int32 pageBase; register afs_int32 tsize; register afs_int32 pageOffset; @@ -423,26 +424,26 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) struct vrequest treq; int rw = uio->uio_rw; int rv, flags; - int newpage=0; + int newpage = 0; vm_page_t page; afs_int32 save_resid; struct dcache *tdc; - int didFakeOpen=0; - int counter=0; + int didFakeOpen = 0; + int counter = 0; AFS_GLOCK(); afs_InitReq(&treq, cred); if (AFS_NFSXLATORREQ(cred) && rw == UIO_READ) { - if (!afs_AccessOK(avc, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) { + if (!afs_AccessOK + (avc, PRSFS_READ, &treq, + CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) { AFS_GUNLOCK(); return EACCES; } } afs_Trace4(afs_iclSetp, CM_TRACE_VMRW, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, (rw==UIO_WRITE? 1 : 0), - ICL_TYPE_LONG, uio->uio_offset, - ICL_TYPE_LONG, uio->uio_resid); + ICL_TYPE_INT32, (rw == UIO_WRITE ? 1 : 0), ICL_TYPE_LONG, + uio->uio_offset, ICL_TYPE_LONG, uio->uio_resid); code = afs_VerifyVCache(avc, &treq); if (code) { code = afs_CheckCode(code, &treq, 35); @@ -451,25 +452,26 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) } if (vType(avc) != VREG) { AFS_GUNLOCK(); - return EISDIR; /* can't read or write other things */ + return EISDIR; /* can't read or write other things */ } afs_BozonLock(&avc->pvnLock, avc); osi_FlushPages(avc); /* hold bozon lock, but not basic vnode lock */ - ObtainWriteLock(&avc->lock,162); + ObtainWriteLock(&avc->lock, 162); /* adjust parameters when appending files */ if ((ioflag & IO_APPEND) && uio->uio_rw == UIO_WRITE) uio->uio_offset = avc->m.Length; /* write at EOF position */ if (uio->uio_rw == UIO_WRITE) { avc->states |= CDirty; afs_FakeOpen(avc); - didFakeOpen=1; + didFakeOpen = 1; /* * before starting any I/O, we must ensure that the file is big enough * to hold the results (since afs_putpage will be called to force * the I/O. */ size = uio->afsio_resid + uio->afsio_offset; /* new file size */ - if (size > avc->m.Length) avc->m.Length = size; /* file grew */ + if (size > avc->m.Length) + avc->m.Length = size; /* file grew */ avc->m.Date = osi_Time(); /* Set file date (for ranlib) */ if (uio->afsio_resid > PAGE_SIZE) cnt = uio->afsio_resid / PAGE_SIZE; @@ -481,26 +483,29 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) * compute the amount of data to move into this block, * based on uio->afsio_resid. */ - size = uio->afsio_resid; /* transfer size */ - fileBase = uio->afsio_offset; /* start file position */ - pageBase = fileBase & ~(PAGE_SIZE-1); /* file position of the page */ - pageOffset = fileBase & (PAGE_SIZE-1); /* start offset within page */ - tsize = PAGE_SIZE-pageOffset; /* amount left in this page */ + size = uio->afsio_resid; /* transfer size */ + fileBase = uio->afsio_offset; /* start file position */ + pageBase = fileBase & ~(PAGE_SIZE - 1); /* file position of the page */ + pageOffset = fileBase & (PAGE_SIZE - 1); /* start offset within page */ + tsize = PAGE_SIZE - pageOffset; /* amount left in this page */ /* * we'll read tsize bytes, * but first must make sure tsize isn't too big */ - if (tsize > size) tsize = size; /* don't read past end of request */ - eof = 0; /* flag telling us if we hit the EOF on the read */ + if (tsize > size) + tsize = size; /* don't read past end of request */ + eof = 0; /* flag telling us if we hit the EOF on the read */ if (uio->uio_rw == UIO_READ) { /* we're doing a read operation */ /* don't read past EOF */ if (tsize + fileBase > avc->m.Length) { tsize = avc->m.Length - fileBase; eof = 1; /* we did hit the EOF */ - if (tsize < 0) tsize = 0; /* better safe than sorry */ + if (tsize < 0) + tsize = 0; /* better safe than sorry */ } } - if (tsize <= 0) break; /* nothing to transfer, we're done */ + if (tsize <= 0) + break; /* nothing to transfer, we're done */ /* Purge dirty chunks of file if there are too many dirty chunks. * Inside the write loop, we only do this at a chunk boundary. @@ -519,24 +524,27 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) flags = 0; ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); - code = ubc_lookup(((struct vnode *)avc)->v_object, pageBase, - PAGE_SIZE, PAGE_SIZE, &page, &flags); + code = + ubc_lookup(((struct vnode *)avc)->v_object, pageBase, PAGE_SIZE, + PAGE_SIZE, &page, &flags); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,163); + ObtainWriteLock(&avc->lock, 163); if (code) { break; } if (flags & B_NOCACHE) { /* - No page found. We should not read the page in if - 1. the write starts on a page edge (ie, pageoffset == 0) - and either - 1. we will fill the page (ie, size == PAGESIZE), or - 2. we are writing past eof + * No page found. We should not read the page in if + * 1. the write starts on a page edge (ie, pageoffset == 0) + * and either + * 1. we will fill the page (ie, size == PAGESIZE), or + * 2. we are writing past eof */ - if ((uio->uio_rw == UIO_WRITE) && - ((pageOffset == 0 && (size == PAGE_SIZE || fileBase >= avc->m.Length)))) { + if ((uio->uio_rw == UIO_WRITE) + && + ((pageOffset == 0 + && (size == PAGE_SIZE || fileBase >= avc->m.Length)))) { struct vnode *vp = (struct vnode *)avc; /* we're doing a write operation past eof; no need to read it */ newpage = 1; @@ -556,13 +564,13 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) bp->b_blkno = btodb(pageBase); ReleaseWriteLock(&avc->lock); code = afs_ustrategy(bp, cred); /* do the I/O */ - ObtainWriteLock(&avc->lock,164); + ObtainWriteLock(&avc->lock, 164); AFS_GUNLOCK(); ubc_sync_iodone(bp); AFS_GLOCK(); if (code) { AFS_GUNLOCK(); - ubc_page_release(page, 0); + ubc_page_release(page, 0); AFS_GLOCK(); break; } @@ -570,55 +578,55 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) } AFS_GUNLOCK(); ubc_page_wait(page); - data = (char *)page->pg_addr; /* DUX 4.0D */ + data = (char *)page->pg_addr; /* DUX 4.0D */ if (data == 0) - data = (char *)PHYS_TO_KSEG(page->pg_phys_addr); /* DUX 4.0E */ + data = (char *)PHYS_TO_KSEG(page->pg_phys_addr); /* DUX 4.0E */ AFS_GLOCK(); ReleaseWriteLock(&avc->lock); /* uiomove may page fault */ AFS_GUNLOCK(); - code = uiomove(data+pageOffset, tsize, uio); + code = uiomove(data + pageOffset, tsize, uio); ubc_unload(page, pageOffset, page_size); if (uio->uio_rw == UIO_WRITE) { - vm_offset_t toffset; - - /* Mark the page dirty and release it to avoid a deadlock - * in ubc_dirty_kluster when more than one process writes - * this page at the same time. */ - toffset = page->pg_offset; - flags |= B_DIRTY; - ubc_page_release(page, flags); - - if (cnt > 10) { - vm_page_t pl; - int kpcnt; - struct buf *bp; - - /* We released the page, so we can get a null page - * list if another thread calls the strategy routine. - */ - pl = ubc_dirty_kluster(((struct vnode *)avc)->v_object, - NULL, toffset, 0, B_WANTED, FALSE, &kpcnt); - if (pl) { - bp = ubc_bufalloc(pl, 1, PAGE_SIZE, 1, B_WRITE); - bp->b_dev = 0; - bp->b_vp = (struct vnode *)avc; - bp->b_blkno = btodb(pageBase); + vm_offset_t toffset; + + /* Mark the page dirty and release it to avoid a deadlock + * in ubc_dirty_kluster when more than one process writes + * this page at the same time. */ + toffset = page->pg_offset; + flags |= B_DIRTY; + ubc_page_release(page, flags); + + if (cnt > 10) { + vm_page_t pl; + int kpcnt; + struct buf *bp; + + /* We released the page, so we can get a null page + * list if another thread calls the strategy routine. + */ + pl = ubc_dirty_kluster(((struct vnode *)avc)->v_object, NULL, + toffset, 0, B_WANTED, FALSE, &kpcnt); + if (pl) { + bp = ubc_bufalloc(pl, 1, PAGE_SIZE, 1, B_WRITE); + bp->b_dev = 0; + bp->b_vp = (struct vnode *)avc; + bp->b_blkno = btodb(pageBase); + AFS_GLOCK(); + code = afs_ustrategy(bp, cred); /* do the I/O */ + AFS_GUNLOCK(); + ubc_sync_iodone(bp); + if (code) { AFS_GLOCK(); - code = afs_ustrategy(bp, cred); /* do the I/O */ - AFS_GUNLOCK(); - ubc_sync_iodone(bp); - if (code) { - AFS_GLOCK(); - ObtainWriteLock(&avc->lock,415); - break; - } + ObtainWriteLock(&avc->lock, 415); + break; } } + } } else { ubc_page_release(page, flags); } AFS_GLOCK(); - ObtainWriteLock(&avc->lock,165); + ObtainWriteLock(&avc->lock, 165); /* * If reading at a chunk boundary, start prefetch of next chunk. */ @@ -632,7 +640,8 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) } } counter++; - if (code) break; + if (code) + break; } if (didFakeOpen) afs_FakeClose(avc, cred); @@ -643,7 +652,7 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) afs_BozonUnlock(&avc->pvnLock, avc); if (DO_FLUSH || (!newpage && (cnt < 10))) { AFS_GUNLOCK(); - ubc_flush_dirty(((struct vnode *)avc)->v_object, flags); + ubc_flush_dirty(((struct vnode *)avc)->v_object, flags); AFS_GLOCK(); } @@ -669,7 +678,7 @@ mp_afs_ubcrdwr(avc, uio, ioflag, cred) && !AFS_NFSXLATORREQ(cred)) { code = afs_fsync(avc, 0, cred, 0); } -out: + out: code = afs_CheckCode(code, &treq, 36); AFS_GUNLOCK(); return code; @@ -685,15 +694,15 @@ out: */ mp_afs_mmap(avc, offset, map, addrp, len, prot, maxprot, flags, cred) - register struct vcache *avc; - vm_offset_t offset; - vm_map_t map; - vm_offset_t *addrp; - vm_size_t len; - vm_prot_t prot; - vm_prot_t maxprot; - int flags; - struct ucred *cred; + register struct vcache *avc; + vm_offset_t offset; + vm_map_t map; + vm_offset_t *addrp; + vm_size_t len; + vm_prot_t prot; + vm_prot_t maxprot; + int flags; + struct ucred *cred; { struct vp_mmap_args args; register struct vp_mmap_args *ap = &args; @@ -708,21 +717,20 @@ mp_afs_mmap(avc, offset, map, addrp, len, prot, maxprot, flags, cred) afs_InitReq(&treq, cred); code = afs_VerifyVCache(avc, &treq); if (code) { - code = afs_CheckCode(code, &treq, 37); - AFS_GUNLOCK(); - return code; + code = afs_CheckCode(code, &treq, 37); + AFS_GUNLOCK(); + return code; } afs_BozonLock(&avc->pvnLock, avc); osi_FlushPages(avc); /* ensure old pages are gone */ afs_BozonUnlock(&avc->pvnLock, avc); - ObtainWriteLock(&avc->lock,166); + ObtainWriteLock(&avc->lock, 166); avc->states |= CMAPPED; ReleaseWriteLock(&avc->lock); ap->a_offset = offset; ap->a_vaddr = addrp; ap->a_size = len; - ap->a_prot = prot, - ap->a_maxprot = maxprot; + ap->a_prot = prot, ap->a_maxprot = maxprot; ap->a_flags = flags; AFS_GUNLOCK(); code = u_vp_create(map, vp->v_object, (vm_offset_t) ap); @@ -733,17 +741,18 @@ mp_afs_mmap(avc, offset, map, addrp, len, prot, maxprot, flags, cred) } -int mp_afs_getpage(vop, offset, len, protp, pl, plsz, mape, addr, rw, cred) - vm_ubc_object_t vop; - vm_offset_t offset; - vm_size_t len; - vm_prot_t *protp; - vm_page_t *pl; - int plsz; - vm_map_entry_t mape; - vm_offset_t addr; - int rw; - struct ucred *cred; +int +mp_afs_getpage(vop, offset, len, protp, pl, plsz, mape, addr, rw, cred) + vm_ubc_object_t vop; + vm_offset_t offset; + vm_size_t len; + vm_prot_t *protp; + vm_page_t *pl; + int plsz; + vm_map_entry_t mape; + vm_offset_t addr; + int rw; + struct ucred *cred; { register afs_int32 code; struct vrequest treq; @@ -752,7 +761,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz, mape, addr, rw, cred) vm_page_t *pagep; vm_offset_t off; - struct vcache *avc = VTOAFS(vop->vu_vp); + struct vcache *avc = VTOAFS(vop->vu_vp); /* first, obtain the proper lock for the VM system */ @@ -761,37 +770,39 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz, mape, addr, rw, cred) code = afs_VerifyVCache(avc, &treq); if (code) { *pl = VM_PAGE_NULL; - code = afs_CheckCode(code, &treq, 39); /* failed to get it */ + code = afs_CheckCode(code, &treq, 39); /* failed to get it */ AFS_GUNLOCK(); return code; } - + /* clean all dirty pages for this vnode */ AFS_GUNLOCK(); - ubc_flush_dirty(vop,0); + ubc_flush_dirty(vop, 0); AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); - ObtainWriteLock(&avc->lock,167); + ObtainWriteLock(&avc->lock, 167); afs_Trace4(afs_iclSetp, CM_TRACE_PAGEIN, ICL_TYPE_POINTER, avc, - ICL_TYPE_LONG, offset, ICL_TYPE_LONG, len, - ICL_TYPE_INT32, (int) rw); + ICL_TYPE_LONG, offset, ICL_TYPE_LONG, len, ICL_TYPE_INT32, + (int)rw); for (i = 0; i < pages; i++) { pagep = &pl[i]; off = offset + PAGE_SIZE * i; - if (protp) protp[i] = 0; + if (protp) + protp[i] = 0; flags = 0; ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); - code = ubc_lookup(((struct vnode *)avc)->v_object, off, - PAGE_SIZE, PAGE_SIZE, pagep, &flags); + code = + ubc_lookup(((struct vnode *)avc)->v_object, off, PAGE_SIZE, + PAGE_SIZE, pagep, &flags); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,168); + ObtainWriteLock(&avc->lock, 168); if (code) { goto out; } - if(flags & B_NOCACHE) { /* if (page) */ - if ((rw & B_WRITE) && (offset+len >= avc->m.Length)) { + if (flags & B_NOCACHE) { /* if (page) */ + if ((rw & B_WRITE) && (offset + len >= avc->m.Length)) { struct vnode *vp = (struct vnode *)avc; /* we're doing a write operation past eof; no need to read it */ AFS_GUNLOCK(); @@ -810,7 +821,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz, mape, addr, rw, cred) bp->b_blkno = btodb(off); ReleaseWriteLock(&avc->lock); code = afs_ustrategy(bp, cred); /* do the I/O */ - ObtainWriteLock(&avc->lock,169); + ObtainWriteLock(&avc->lock, 169); AFS_GUNLOCK(); ubc_sync_iodone(bp); AFS_GLOCK(); @@ -832,7 +843,7 @@ int mp_afs_getpage(vop, offset, len, protp, pl, plsz, mape, addr, rw, cred) } } } -out: + out: pl[i] = VM_PAGE_NULL; ReleaseWriteLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); @@ -844,14 +855,15 @@ out: } -int mp_afs_putpage(vop, pl, pcnt, flags, cred) - vm_ubc_object_t vop; - vm_page_t *pl; - int pcnt; - int flags; - struct ucred *cred; +int +mp_afs_putpage(vop, pl, pcnt, flags, cred) + vm_ubc_object_t vop; + vm_page_t *pl; + int pcnt; + int flags; + struct ucred *cred; { - register afs_int32 code=0; + register afs_int32 code = 0; struct vcache *avc = VTOAFS(vop->vu_vp); struct vnode *vp = (struct vnode *)avc; int i; @@ -866,10 +878,10 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred) if (vp->v_flag & VXLOCK) { VN_UNLOCK(vp); for (i = 0; i < pcnt; i++) { - ubc_page_release(pl[i], B_DONE|B_DIRTY); + ubc_page_release(pl[i], B_DONE | B_DIRTY); pl[i] = VM_PAGE_NULL; } - return(0); + return (0); } else { VN_UNLOCK(vp); } @@ -878,7 +890,7 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred) /* first, obtain the proper lock for the VM system */ afs_BozonLock(&avc->pvnLock, avc); - ObtainWriteLock(&avc->lock,170); + ObtainWriteLock(&avc->lock, 170); for (i = 0; i < pcnt; i++) { vm_page_t page = pl[i]; struct buf *bp; @@ -892,7 +904,7 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred) bp->b_blkno = btodb(page->pg_offset); ReleaseWriteLock(&avc->lock); code = afs_ustrategy(bp, cred); /* do the I/O */ - ObtainWriteLock(&avc->lock,171); + ObtainWriteLock(&avc->lock, 171); AFS_GUNLOCK(); ubc_sync_iodone(bp); AFS_GLOCK(); @@ -902,7 +914,7 @@ int mp_afs_putpage(vop, pl, pcnt, flags, cred) pl[i] = VM_PAGE_NULL; } } -done: + done: ReleaseWriteLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); afs_Trace2(afs_iclSetp, CM_TRACE_PAGEOUTDONE, ICL_TYPE_INT32, code, @@ -912,20 +924,22 @@ done: } -int mp_afs_swap(avc, swapop, argp) - struct vcache *avc; - vp_swap_op_t swapop; - vm_offset_t argp; +int +mp_afs_swap(avc, swapop, argp) + struct vcache *avc; + vp_swap_op_t swapop; + vm_offset_t argp; { return EIO; } -int mp_afs_syncdata(avc, flag, offset, length, cred) - struct vcache *avc; - int flag; - vm_offset_t offset; - vm_size_t length; - struct ucred *cred; +int +mp_afs_syncdata(avc, flag, offset, length, cred) + struct vcache *avc; + int flag; + vm_offset_t offset; + vm_size_t length; + struct ucred *cred; { /* NFS V3 makes this call, ignore it. We'll sync the data in afs_fsync. */ if (AFS_NFSXLATORREQ(cred)) @@ -942,90 +956,90 @@ struct buf *afs_bread_freebp = 0; * Thus we can use fake bufs (ie not from the real buffer pool). */ mp_afs_bread(vp, lbn, bpp, cred) - struct ucred *cred; - struct vnode *vp; - daddr_t lbn; - struct buf **bpp; + struct ucred *cred; + struct vnode *vp; + daddr_t lbn; + struct buf **bpp; { - int offset, fsbsize, error; - struct buf *bp; - struct iovec iov; - struct uio uio; + int offset, fsbsize, error; + struct buf *bp; + struct iovec iov; + struct uio uio; - AFS_GLOCK(); - AFS_STATCNT(afs_bread); - fsbsize = vp->v_vfsp->vfs_bsize; - offset = lbn * fsbsize; - if (afs_bread_freebp) { - bp = afs_bread_freebp; - afs_bread_freebp = 0; - } else { - bp = (struct buf *) AFS_KALLOC(sizeof(*bp)); - bp->b_un.b_addr = (caddr_t) AFS_KALLOC(fsbsize); - } + AFS_GLOCK(); + AFS_STATCNT(afs_bread); + fsbsize = vp->v_vfsp->vfs_bsize; + offset = lbn * fsbsize; + if (afs_bread_freebp) { + bp = afs_bread_freebp; + afs_bread_freebp = 0; + } else { + bp = (struct buf *)AFS_KALLOC(sizeof(*bp)); + bp->b_un.b_addr = (caddr_t) AFS_KALLOC(fsbsize); + } - iov.iov_base = bp->b_un.b_addr; - iov.iov_len = fsbsize; - uio.afsio_iov = &iov; - uio.afsio_iovcnt = 1; - uio.afsio_seg = AFS_UIOSYS; - uio.afsio_offset = offset; - uio.afsio_resid = fsbsize; - *bpp = 0; - error = afs_read(VTOAFS(vp), &uio, cred, lbn, bpp, 0); - if (error) { - afs_bread_freebp = bp; - AFS_GUNLOCK(); - return error; - } - if (*bpp) { - afs_bread_freebp = bp; - } else { - *(struct buf **)&bp->b_vp = bp; /* mark as fake */ - *bpp = bp; - } + iov.iov_base = bp->b_un.b_addr; + iov.iov_len = fsbsize; + uio.afsio_iov = &iov; + uio.afsio_iovcnt = 1; + uio.afsio_seg = AFS_UIOSYS; + uio.afsio_offset = offset; + uio.afsio_resid = fsbsize; + *bpp = 0; + error = afs_read(VTOAFS(vp), &uio, cred, lbn, bpp, 0); + if (error) { + afs_bread_freebp = bp; AFS_GUNLOCK(); - return 0; + return error; + } + if (*bpp) { + afs_bread_freebp = bp; + } else { + *(struct buf **)&bp->b_vp = bp; /* mark as fake */ + *bpp = bp; + } + AFS_GUNLOCK(); + return 0; } mp_afs_brelse(vp, bp) -struct vnode *vp; -struct buf *bp; + struct vnode *vp; + struct buf *bp; { AFS_GLOCK(); AFS_STATCNT(afs_brelse); - if ((struct buf *)bp->b_vp != bp) { /* not fake */ - brelse(bp); - } else if (afs_bread_freebp) { - AFS_KFREE(bp->b_un.b_addr, vp->v_vfsp->vfs_bsize); - AFS_KFREE(bp, sizeof(*bp)); - } else { - afs_bread_freebp = bp; - } + if ((struct buf *)bp->b_vp != bp) { /* not fake */ + brelse(bp); + } else if (afs_bread_freebp) { + AFS_KFREE(bp->b_un.b_addr, vp->v_vfsp->vfs_bsize); + AFS_KFREE(bp, sizeof(*bp)); + } else { + afs_bread_freebp = bp; + } AFS_GUNLOCK(); } mp_afs_bmap(avc, abn, anvp, anbn) - register struct vcache *avc; - afs_int32 abn, *anbn; - struct vcache **anvp; + register struct vcache *avc; + afs_int32 abn, *anbn; + struct vcache **anvp; { AFS_GLOCK(); AFS_STATCNT(afs_bmap); if (anvp) *anvp = avc; if (anbn) - *anbn = abn * (8192 / DEV_BSIZE); /* in 512 byte units */ + *anbn = abn * (8192 / DEV_BSIZE); /* in 512 byte units */ AFS_GUNLOCK(); return 0; } /* real strategy */ -mp_afs_strategy (abp) - register struct buf *abp; +mp_afs_strategy(abp) + register struct buf *abp; { register afs_int32 code; @@ -1039,29 +1053,29 @@ mp_afs_strategy (abp) mp_afs_refer(vm_ubc_object_t vop) { - VREF(vop->vu_vp); + VREF(vop->vu_vp); } mp_afs_release(vm_ubc_object_t vop) { - vrele(vop->vu_vp); + vrele(vop->vu_vp); } mp_afs_write_check(vm_ubc_object_t vop, vm_page_t pp) { - return TRUE; + return TRUE; } struct vfs_ubcops afs_ubcops = { - mp_afs_refer, /* refer vnode */ - mp_afs_release, /* release vnode */ - mp_afs_getpage, /* get page */ - mp_afs_putpage, /* put page */ - mp_afs_write_check, /* check writablity */ + mp_afs_refer, /* refer vnode */ + mp_afs_release, /* release vnode */ + mp_afs_getpage, /* get page */ + mp_afs_putpage, /* put page */ + mp_afs_write_check, /* check writablity */ }; #endif /* 0 */ @@ -1072,17 +1086,17 @@ struct vfs_ubcops afs_ubcops = { * locked after return. */ lookupname(namep, seg, follow, dvpp, cvpp) - char *namep; /* path name */ - int seg; /* address space containing name */ - int follow; /* follow symbolic links */ - struct vnode **dvpp; /* result, containing parent vnode */ - struct vnode **cvpp; /* result, containing final component vnode */ + char *namep; /* path name */ + int seg; /* address space containing name */ + int follow; /* follow symbolic links */ + struct vnode **dvpp; /* result, containing parent vnode */ + struct vnode **cvpp; /* result, containing final component vnode */ { /* Should I use free-bee in u-area? */ struct nameidata *ndp = &u.u_nd; int error; - ndp->ni_nameiop = ((follow) ? (LOOKUP|FOLLOW) : (LOOKUP)); + ndp->ni_nameiop = ((follow) ? (LOOKUP | FOLLOW) : (LOOKUP)); ndp->ni_segflg = seg; ndp->ni_dirp = namep; error = namei(ndp); @@ -1090,6 +1104,5 @@ lookupname(namep, seg, follow, dvpp, cvpp) *dvpp = ndp->ni_dvp; if (cvpp != NULL) *cvpp = ndp->ni_vp; - return(error); + return (error); } - diff --git a/src/afs/OBSD/osi_file.c b/src/afs/OBSD/osi_file.c index 07eb87301..879cf8537 100644 --- a/src/afs/OBSD/osi_file.c +++ b/src/afs/OBSD/osi_file.c @@ -10,21 +10,23 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afs/afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ int afs_osicred_initialized; -struct AFS_UCRED afs_osi_cred; +struct AFS_UCRED afs_osi_cred; afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct mount *afs_cacheVfsp; -void *osi_UFSOpen(afs_int32 ainode) +void * +osi_UFSOpen(afs_int32 ainode) { struct osi_file *afile; struct vnode *vp; @@ -34,7 +36,7 @@ void *osi_UFSOpen(afs_int32 ainode) AFS_STATCNT(osi_UFSOpen); if (cacheDiskType != AFS_FCACHE_TYPE_UFS) osi_Panic("UFSOpen called for non-UFS cache\n"); - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); code = VFS_VGET(cacheDev.mp, (ino_t) ainode, &vp); if (code) { osi_FreeSmallSpace(afile); @@ -46,10 +48,11 @@ void *osi_UFSOpen(afs_int32 ainode) afile->proc = NULL; afile->inum = ainode; /* for hint validity checking */ VOP_UNLOCK(vp, 0, curproc); - return (void *) afile; + return (void *)afile; } -int afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat) +int +afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat) { afs_int32 code; struct vattr tvattr; @@ -69,7 +72,8 @@ int afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat) return code; } -int osi_UFSClose(struct osi_file *afile) +int +osi_UFSClose(struct osi_file *afile) { AFS_STATCNT(osi_Close); @@ -80,7 +84,8 @@ int osi_UFSClose(struct osi_file *afile) return 0; } -int osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) +int +osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) { struct vattr tvattr; afs_int32 code; @@ -97,7 +102,7 @@ int osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) if (code || tstat.size <= asize) return code; - MObtainWriteLock(&afs_xosi,321); + MObtainWriteLock(&afs_xosi, 321); VATTR_NULL(&tvattr); tvattr.va_size = asize; AFS_GUNLOCK(); @@ -111,7 +116,8 @@ int osi_UFSTruncate(struct osi_file *afile, afs_int32 asize) return code; } -void osi_DisableAtimes(struct vnode *avp) +void +osi_DisableAtimes(struct vnode *avp) { #if 0 VTOI(avp)->i_flag &= ~IN_ACCESS; @@ -120,7 +126,8 @@ void osi_DisableAtimes(struct vnode *avp) /* Generic read interface */ -int afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize) +int +afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize) { unsigned int resid; afs_int32 code; @@ -141,8 +148,9 @@ int afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize if (offset != -1) afile->offset = offset; AFS_GUNLOCK(); - code = vn_rdwr(UIO_READ, afile->vnode, aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid, curproc); + code = + vn_rdwr(UIO_READ, afile->vnode, aptr, asize, afile->offset, + AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid, curproc); AFS_GLOCK(); if (code == 0) { code = asize - resid; @@ -157,21 +165,24 @@ int afs_osi_Read(struct osi_file *afile, int offset, void *aptr, afs_int32 asize } /* Generic write interface */ -int afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) +int +afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, + afs_int32 asize) { unsigned int resid; afs_int32 code; AFS_STATCNT(osi_Write); if (!afile) - osi_Panic("afs_osi_Write called with null afile"); + osi_Panic("afs_osi_Write called with null afile"); if (offset != -1) afile->offset = offset; AFS_GUNLOCK(); VOP_LOCK(afile->vnode, LK_EXCLUSIVE | LK_RETRY, curproc); - code = vn_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid, curproc); + code = + vn_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset, + AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid, curproc); VOP_UNLOCK(afile->vnode, 0, curproc); AFS_GLOCK(); @@ -184,7 +195,7 @@ int afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afs_int3 code = -1; if (afile->proc) - (*afile->proc)(afile, code); + (*afile->proc) (afile, code); return code; } @@ -194,17 +205,19 @@ int afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afs_int3 * written from the RT NFS port strategy routine. It has been generalized a * bit, but should still be pretty clear. */ -int afs_osi_MapStrategy(int (*aproc)(), struct buf *bp) +int +afs_osi_MapStrategy(int (*aproc) (), struct buf *bp) { afs_int32 returnCode; AFS_STATCNT(osi_MapStrategy); - returnCode = (*aproc)(bp); + returnCode = (*aproc) (bp); return returnCode; } -void shutdown_osifile(void) +void +shutdown_osifile(void) { AFS_STATCNT(shutdown_osifile); if (afs_cold_shutdown) diff --git a/src/afs/OBSD/osi_groups.c b/src/afs/OBSD/osi_groups.c index c170b1e2a..dc320d9fd 100644 --- a/src/afs/OBSD/osi_groups.c +++ b/src/afs/OBSD/osi_groups.c @@ -18,11 +18,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afs/afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "sys/syscallargs.h" #define NOUID ((uid_t) -1) @@ -30,24 +31,17 @@ RCSID("$Header$"); static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset); + afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset); static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent); + afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent); int Afs_xsetgroups(p, args, retval) - struct proc *p; - void *args; - int *retval; + struct proc *p; + void *args; + int *retval; { int code = 0; struct vrequest treq; @@ -79,7 +73,7 @@ Afs_xsetgroups(p, args, retval) int setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue, - afs_uint32 *newpag, int change_parent) + afs_uint32 * newpag, int change_parent) { gid_t gidset[NGROUPS]; int ngroups, code; @@ -92,12 +86,12 @@ setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue, if (ngroups + 2 > NGROUPS) { return (E2BIG); } - for (j = ngroups -1; j >= 0; j--) { - gidset[j+2] = gidset[j]; - } + for (j = ngroups - 1; j >= 0; j--) { + gidset[j + 2] = gidset[j]; + } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]); code = afs_setgroups(proc, cred, ngroups, gidset, change_parent); return code; @@ -105,10 +99,7 @@ setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue, static int -afs_getgroups( - struct ucred *cred, - int ngroups, - gid_t *gidset) +afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset) { int ngrps, savengrps; gid_t *gp; @@ -123,12 +114,8 @@ afs_getgroups( static int -afs_setgroups( - struct proc *proc, - struct ucred **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups, + gid_t * gidset, int change_parent) { struct ucred *cr = *cred; int i; @@ -148,5 +135,5 @@ afs_setgroups( cr->cr_ngroups = ngroups; *cred = cr; - return(0); + return (0); } diff --git a/src/afs/OBSD/osi_machdep.h b/src/afs/OBSD/osi_machdep.h index 6fa91bd79..1cb9d781a 100644 --- a/src/afs/OBSD/osi_machdep.h +++ b/src/afs/OBSD/osi_machdep.h @@ -40,7 +40,7 @@ extern struct simplelock afs_rxglobal_lock; #define v_vfsp v_mount /* vnode */ -#define SetAfsVnode(vn) /* nothing; done in getnewvnode() */ +#define SetAfsVnode(vn) /* nothing; done in getnewvnode() */ #define IsAfsVnode(vn) ((vn)->v_op == afs_vnodeop_p) #define AFS_HOLD(vp) afs_nbsd_ref(vp) #define AFS_RELE(vp) afs_nbsd_rele(vp) @@ -68,7 +68,7 @@ extern struct simplelock afs_rxglobal_lock; /* proc, cred */ #define AFS_PROC struct proc #define AFS_UCRED ucred -#define afs_suser() afs_osi_suser(osi_curcred()) +#define afs_suser() afs_osi_suser(osi_curcred()) #define getpid() curproc #define osi_curcred() (curproc->p_cred->pc_ucred) #define osi_curproc() curproc @@ -102,8 +102,9 @@ extern struct timeval time; /* This is not always in scope yet */ struct vcache; -extern int afs_nbsd_lookupname(char *fnamep, enum uio_seg segflg, int followlink, - struct vnode **dirvpp, struct vnode **compvpp); +extern int afs_nbsd_lookupname(char *fnamep, enum uio_seg segflg, + int followlink, struct vnode **dirvpp, + struct vnode **compvpp); extern void afs_nbsd_getnewvnode(struct vcache *tvc); extern void afs_nbsd_ref(struct vnode *); extern void afs_nbsd_rele(struct vnode *); @@ -115,10 +116,10 @@ extern int afs_vget(); afs_nbsd_lookupname((fnamep), (segflg), (followlink), (dirvpp), (compvpp)) #ifdef KERNEL -extern int (**afs_vnodeop_p)(); +extern int (**afs_vnodeop_p) (); #ifdef AFS_GLOBAL_SUNLOCK -extern struct proc * afs_global_owner; +extern struct proc *afs_global_owner; extern struct lock afs_global_lock; #define AFS_GLOCK() \ do { \ diff --git a/src/afs/OBSD/osi_misc.c b/src/afs/OBSD/osi_misc.c index 25d5252c2..138f8e0c4 100644 --- a/src/afs/OBSD/osi_misc.c +++ b/src/afs/OBSD/osi_misc.c @@ -46,7 +46,8 @@ such damages. #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afs/afsincludes.h" /* Afs-based standard headers */ @@ -66,7 +67,7 @@ RCSID("$Header$"); int afs_osi_suser(void *credp) { - return (suser((struct ucred *) credp, &curproc->p_acflag) ? 0 : 1); + return (suser((struct ucred *)credp, &curproc->p_acflag) ? 0 : 1); } void * @@ -86,23 +87,23 @@ afs_nbsd_Free(void *p, size_t asize) int afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval) -long *retval; -long dev, near_inode, param1, param2, param3, param4; + long *retval; + long dev, near_inode, param1, param2, param3, param4; { return EINVAL; } int afs_syscall_iopen(dev, inode, usrmod, retval) -long *retval; -int dev, inode, usrmod; + long *retval; + int dev, inode, usrmod; { return EINVAL; } int afs_syscall_iincdec(dev, inode, inode_p1, amount) -int dev, inode, inode_p1, amount; + int dev, inode, inode_p1, amount; { return EINVAL; } diff --git a/src/afs/OBSD/osi_sleep.c b/src/afs/OBSD/osi_sleep.c index 5780d1d8d..5fd1c0e3c 100644 --- a/src/afs/OBSD/osi_sleep.c +++ b/src/afs/OBSD/osi_sleep.c @@ -44,23 +44,26 @@ such damages. #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afs/afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ static char waitV; -void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) +void +afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) { AFS_STATCNT(osi_InitWaitHandle); achandle->proc = NULL; } /* cancel osi_Wait */ -void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) { caddr_t proc; @@ -76,7 +79,8 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) * Waits for data on ahandle, or ams ms later. ahandle may be null. * Returns 0 if timeout and EINTR if signalled. */ -int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) +int +afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int timo, code = 0; struct timeval atv, endTime; @@ -113,7 +117,8 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) return code; } -void afs_osi_Sleep(void *event) +void +afs_osi_Sleep(void *event) { AFS_ASSERT_GLOCK(); AFS_GUNLOCK(); @@ -121,7 +126,8 @@ void afs_osi_Sleep(void *event) AFS_GLOCK(); } -int afs_osi_SleepSig(void *event) +int +afs_osi_SleepSig(void *event) { AFS_ASSERT_GLOCK(); AFS_GUNLOCK(); @@ -130,7 +136,8 @@ int afs_osi_SleepSig(void *event) return 0; } -int afs_osi_Wakeup(void *event) +int +afs_osi_Wakeup(void *event) { wakeup(event); return 1; diff --git a/src/afs/OBSD/osi_vfsops.c b/src/afs/OBSD/osi_vfsops.c index 3bfca8139..f09839ae7 100644 --- a/src/afs/OBSD/osi_vfsops.c +++ b/src/afs/OBSD/osi_vfsops.c @@ -93,11 +93,12 @@ NONINFRINGEMENT. #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afs/afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include #include @@ -112,7 +113,7 @@ extern void insmntque(struct vnode *, struct mount *); extern int sys_lkmnosys(), afs3_syscall(), afs_xioctl(), Afs_xsetgroups(); static int lkmid = -1; -static int afs_badcall(struct proc *p, void *xx, register_t *yy); +static int afs_badcall(struct proc *p, void *xx, register_t * yy); static struct sysent old_sysent; char afs_NetBSD_osname[] = "OpenBSD"; @@ -150,11 +151,8 @@ struct vfsops afs_vfsops = { }; int -afs_nbsd_lookupname(char *fnamep, - enum uio_seg segflg, - int followlink, - struct vnode **dirvpp, - struct vnode **compvpp) +afs_nbsd_lookupname(char *fnamep, enum uio_seg segflg, int followlink, + struct vnode **dirvpp, struct vnode **compvpp) { struct nameidata nd; int niflag; @@ -168,11 +166,8 @@ afs_nbsd_lookupname(char *fnamep, /* XXX LOCKLEAF ? */ niflag = followlink ? FOLLOW : NOFOLLOW; if (dirvpp) - niflag |= WANTPARENT; /* XXX LOCKPARENT? */ - NDINIT(&nd, LOOKUP, - niflag, - segflg, - fnamep, osi_curproc()); + niflag |= WANTPARENT; /* XXX LOCKPARENT? */ + NDINIT(&nd, LOOKUP, niflag, segflg, fnamep, osi_curproc()); if ((error = namei(&nd))) return error; *compvpp = nd.ni_vp; @@ -201,9 +196,9 @@ afs_checkexp() int afs_fhtovp(mp, fhp, vpp) -struct mount *mp; -struct fid *fhp; -struct vnode **vpp; + struct mount *mp; + struct fid *fhp; + struct vnode **vpp; { return (EINVAL); @@ -211,8 +206,8 @@ struct vnode **vpp; int afs_vptofh(vp, fhp) -struct vnode *vp; -struct fid *fhp; + struct vnode *vp; + struct fid *fhp; { return (EINVAL); @@ -220,23 +215,23 @@ struct fid *fhp; int afs_start(mp, flags, p) -struct mount *mp; -int flags; -struct proc *p; + struct mount *mp; + int flags; + struct proc *p; { - return (0); /* nothing to do. ? */ + return (0); /* nothing to do. ? */ } int afs_mount(mp, path, data, ndp, p) -register struct mount *mp; -char *path; -caddr_t data; -struct nameidata *ndp; -struct proc *p; + register struct mount *mp; + char *path; + caddr_t data; + struct nameidata *ndp; + struct proc *p; { /* ndp contains the mounted-from device. Just ignore it. - we also don't care about our proc struct. */ + * we also don't care about our proc struct. */ int size; if (mp->mnt_flag & MNT_UPDATE) @@ -257,25 +252,25 @@ struct proc *p; #endif afs_globalVFS = mp; mp->osi_vfs_bsize = 8192; - mp->osi_vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ - mp->osi_vfs_fsid.val[1] = (int) AFS_VFSFSID; + mp->osi_vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ + mp->osi_vfs_fsid.val[1] = (int)AFS_VFSFSID; - (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN-1, &size); + (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size); bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); bzero(mp->mnt_stat.f_mntfromname, MNAMELEN); strcpy(mp->mnt_stat.f_mntfromname, "AFS"); /* null terminated string "AFS" will fit, just leave it be. */ strcpy(mp->mnt_stat.f_fstypename, MOUNT_AFS); - (void) afs_statfs(mp, &mp->mnt_stat); + (void)afs_statfs(mp, &mp->mnt_stat); return 0; } int afs_unmount(afsp, flags, p) -struct mount *afsp; -int flags; -struct proc *p; + struct mount *afsp; + int flags; + struct proc *p; { extern int sys_ioctl(), sys_setgroups(); @@ -291,12 +286,12 @@ struct proc *p; AFS_RELE(AFSTOV(afs_globalVp)); afs_globalVp = NULL; - vflush(afsp, NULLVP, 0); /* don't support forced */ + vflush(afsp, NULLVP, 0); /* don't support forced */ afsp->mnt_data = NULL; AFS_GLOCK(); afs_globalVFS = 0; afs_cold_shutdown = 1; - afs_shutdown(); /* XXX */ + afs_shutdown(); /* XXX */ AFS_GUNLOCK(); /* give up syscall entries for ioctl & setgroups, which we've stolen */ @@ -307,12 +302,14 @@ struct proc *p; sysent[AFS_SYSCALL].sy_narg = 0; sysent[AFS_SYSCALL].sy_argsize = 0; sysent[AFS_SYSCALL].sy_call = afs_badcall; - printf("AFS unmounted--use `/sbin/modunload -i %d' to unload before restarting AFS\n", lkmid); + printf + ("AFS unmounted--use `/sbin/modunload -i %d' to unload before restarting AFS\n", + lkmid); return 0; } static int -afs_badcall(struct proc *p, void *xx, register_t *yy) +afs_badcall(struct proc *p, void *xx, register_t * yy) { return ENOSYS; } @@ -328,8 +325,7 @@ afs_nbsd_getnewvnode(struct vcache *tvc) } int -afs_root(struct mount *mp, - struct vnode **vpp) +afs_root(struct mount *mp, struct vnode **vpp) { struct vrequest treq; struct vcache *tvp; @@ -338,12 +334,12 @@ afs_root(struct mount *mp, AFS_STATCNT(afs_root); AFS_GLOCK(); - if (!(code = afs_InitReq(&treq, osi_curcred())) && - !(code = afs_CheckInit())) { + if (!(code = afs_InitReq(&treq, osi_curcred())) + && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); if (tvp) { /* There is really no reason to over-hold this bugger--it's held - by the root filesystem reference. */ + * by the root filesystem reference. */ if (afs_globalVp != tvp) { #ifdef AFS_DONT_OVERHOLD_GLOBALVP if (afs_globalVp) @@ -361,7 +357,7 @@ afs_root(struct mount *mp, AFS_GUNLOCK(); if (!code) - vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curproc); /* return it locked */ + vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curproc); /* return it locked */ return code; } @@ -377,9 +373,10 @@ afs_statfs(struct osi_vfs *afsp, struct statfs *abp) * enough * space in the device partition before storing something there * (like * ed(1)) */ - abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = abp->f_ffree = 9000000; - abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */ - abp->f_fsid.val[1] = (int) AFS_VFSFSID; + abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = + abp->f_ffree = 9000000; + abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */ + abp->f_fsid.val[1] = (int)AFS_VFSFSID; return 0; } @@ -416,8 +413,8 @@ afs_nbsd_rele(struct vnode *vp) int afs_vget(vp, lfl) -struct vnode *vp; -int lfl; + struct vnode *vp; + int lfl; { int error; @@ -467,8 +464,7 @@ afsinit() } int -afs_vfs_load(struct lkm_table *lkmtp, - int cmd) +afs_vfs_load(struct lkm_table *lkmtp, int cmd) { extern char *memname[]; @@ -517,8 +513,7 @@ libafs_lkmentry(struct lkm_table *lkmtp, int cmd, int ver) if (cmd == LKM_E_LOAD) { if (strcmp(ostype, afs_NetBSD_osname)) { printf("This is %s version %s\n", ostype, osrelease); - printf("This version of AFS is only for %s\n", - afs_NetBSD_osname); + printf("This version of AFS is only for %s\n", afs_NetBSD_osname); return EPROGMISMATCH; } if (sysent[AFS_SYSCALL].sy_call == afs3_syscall @@ -527,5 +522,5 @@ libafs_lkmentry(struct lkm_table *lkmtp, int cmd, int ver) return EINVAL; } } - DISPATCH(lkmtp,cmd,ver,afs_vfs_load,afs_vfs_unload,lkm_nofunc); + DISPATCH(lkmtp, cmd, ver, afs_vfs_load, afs_vfs_unload, lkm_nofunc); } diff --git a/src/afs/OBSD/osi_vm.c b/src/afs/OBSD/osi_vm.c index ff9cf2418..5eaaad3c6 100644 --- a/src/afs/OBSD/osi_vm.c +++ b/src/afs/OBSD/osi_vm.c @@ -21,11 +21,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afs/afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ /* #include */ #include #include @@ -46,7 +47,8 @@ RCSID("$Header$"); * * OSF/1 Locking: VN_LOCK has been called. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { return 0; } @@ -56,7 +58,8 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { } @@ -69,7 +72,8 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * Since we drop and re-obtain the lock, we can't guarantee that there won't * be some pages around when we return, newly created by concurrent activity. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { } @@ -77,7 +81,8 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) * * Locking: No lock is held, not even the global lock. */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { } @@ -87,6 +92,7 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * activeV is raised. This is supposed to block pageins, but at present * it only works on Solaris. */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { } diff --git a/src/afs/OBSD/osi_vnodeops.c b/src/afs/OBSD/osi_vnodeops.c index 5b315f856..7a753dfbc 100644 --- a/src/afs/OBSD/osi_vnodeops.c +++ b/src/afs/OBSD/osi_vnodeops.c @@ -98,11 +98,12 @@ NONINFRINGEMENT. #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afs/afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include #include @@ -115,7 +116,7 @@ RCSID("$Header$"); extern int afs_FlushVS(struct vcache *tvc); #endif -#define M_AFSNODE (M_TEMP-1) /* XXX */ +#define M_AFSNODE (M_TEMP-1) /* XXX */ int afs_nbsd_lookup(struct vop_lookup_args *); int afs_nbsd_create(struct vop_create_args *); @@ -157,45 +158,45 @@ int afs_nbsd_advlock(struct vop_advlock_args *); /* Global vfs data structures for AFS. */ int (**afs_vnodeop_p) __P((void *)); struct vnodeopv_entry_desc afs_vnodeop_entries[] = { - { &vop_default_desc, vn_default_error }, - { &vop_lookup_desc, afs_nbsd_lookup }, /* lookup */ - { &vop_create_desc, afs_nbsd_create }, /* create */ - { &vop_mknod_desc, afs_nbsd_mknod }, /* mknod */ - { &vop_open_desc, afs_nbsd_open }, /* open */ - { &vop_close_desc, afs_nbsd_close }, /* close */ - { &vop_access_desc, afs_nbsd_access }, /* access */ - { &vop_getattr_desc, afs_nbsd_getattr }, /* getattr */ - { &vop_setattr_desc, afs_nbsd_setattr }, /* setattr */ - { &vop_read_desc, afs_nbsd_read }, /* read */ - { &vop_write_desc, afs_nbsd_write }, /* write */ - { &vop_ioctl_desc, afs_nbsd_ioctl }, /* XXX ioctl */ - { &vop_select_desc, afs_nbsd_select }, /* select */ - { &vop_fsync_desc, afs_nbsd_fsync }, /* fsync */ - { &vop_remove_desc, afs_nbsd_remove }, /* remove */ - { &vop_link_desc, afs_nbsd_link }, /* link */ - { &vop_rename_desc, afs_nbsd_rename }, /* rename */ - { &vop_mkdir_desc, afs_nbsd_mkdir }, /* mkdir */ - { &vop_rmdir_desc, afs_nbsd_rmdir }, /* rmdir */ - { &vop_symlink_desc, afs_nbsd_symlink }, /* symlink */ - { &vop_readdir_desc, afs_nbsd_readdir }, /* readdir */ - { &vop_readlink_desc, afs_nbsd_readlink }, /* readlink */ - { &vop_abortop_desc, vop_generic_abortop }, /* abortop */ - { &vop_inactive_desc, afs_nbsd_inactive }, /* inactive */ - { &vop_reclaim_desc, afs_nbsd_reclaim }, /* reclaim */ - { &vop_lock_desc, afs_nbsd_lock }, /* lock */ - { &vop_unlock_desc, afs_nbsd_unlock }, /* unlock */ - { &vop_bmap_desc, afs_nbsd_bmap }, /* bmap */ - { &vop_strategy_desc, afs_nbsd_strategy }, /* strategy */ - { &vop_print_desc, afs_nbsd_print }, /* print */ - { &vop_islocked_desc, afs_nbsd_islocked }, /* islocked */ - { &vop_pathconf_desc, afs_nbsd_pathconf }, /* pathconf */ - { &vop_advlock_desc, afs_nbsd_advlock }, /* advlock */ - { &vop_reallocblks_desc, afs_nbsd_reallocblks }, /* reallocblks */ - { &vop_bwrite_desc, vop_generic_bwrite }, - { (struct vnodeop_desc *) NULL, (int (*) __P((void *))) NULL} + {&vop_default_desc, vn_default_error}, + {&vop_lookup_desc, afs_nbsd_lookup}, /* lookup */ + {&vop_create_desc, afs_nbsd_create}, /* create */ + {&vop_mknod_desc, afs_nbsd_mknod}, /* mknod */ + {&vop_open_desc, afs_nbsd_open}, /* open */ + {&vop_close_desc, afs_nbsd_close}, /* close */ + {&vop_access_desc, afs_nbsd_access}, /* access */ + {&vop_getattr_desc, afs_nbsd_getattr}, /* getattr */ + {&vop_setattr_desc, afs_nbsd_setattr}, /* setattr */ + {&vop_read_desc, afs_nbsd_read}, /* read */ + {&vop_write_desc, afs_nbsd_write}, /* write */ + {&vop_ioctl_desc, afs_nbsd_ioctl}, /* XXX ioctl */ + {&vop_select_desc, afs_nbsd_select}, /* select */ + {&vop_fsync_desc, afs_nbsd_fsync}, /* fsync */ + {&vop_remove_desc, afs_nbsd_remove}, /* remove */ + {&vop_link_desc, afs_nbsd_link}, /* link */ + {&vop_rename_desc, afs_nbsd_rename}, /* rename */ + {&vop_mkdir_desc, afs_nbsd_mkdir}, /* mkdir */ + {&vop_rmdir_desc, afs_nbsd_rmdir}, /* rmdir */ + {&vop_symlink_desc, afs_nbsd_symlink}, /* symlink */ + {&vop_readdir_desc, afs_nbsd_readdir}, /* readdir */ + {&vop_readlink_desc, afs_nbsd_readlink}, /* readlink */ + {&vop_abortop_desc, vop_generic_abortop}, /* abortop */ + {&vop_inactive_desc, afs_nbsd_inactive}, /* inactive */ + {&vop_reclaim_desc, afs_nbsd_reclaim}, /* reclaim */ + {&vop_lock_desc, afs_nbsd_lock}, /* lock */ + {&vop_unlock_desc, afs_nbsd_unlock}, /* unlock */ + {&vop_bmap_desc, afs_nbsd_bmap}, /* bmap */ + {&vop_strategy_desc, afs_nbsd_strategy}, /* strategy */ + {&vop_print_desc, afs_nbsd_print}, /* print */ + {&vop_islocked_desc, afs_nbsd_islocked}, /* islocked */ + {&vop_pathconf_desc, afs_nbsd_pathconf}, /* pathconf */ + {&vop_advlock_desc, afs_nbsd_advlock}, /* advlock */ + {&vop_reallocblks_desc, afs_nbsd_reallocblks}, /* reallocblks */ + {&vop_bwrite_desc, vop_generic_bwrite}, + {(struct vnodeop_desc *)NULL, (int (*)__P((void *)))NULL} }; struct vnodeopv_desc afs_vnodeop_opv_desc = - { &afs_vnodeop_p, afs_vnodeop_entries }; + { &afs_vnodeop_p, afs_vnodeop_entries }; #define GETNAME() \ struct componentname *cnp = ap->a_cnp; \ @@ -217,7 +218,8 @@ int afs_debug; extern int afs_lookup(); extern int afs_open(); extern int afs_close(); -extern int HandleIoctl(struct vcache *avc, afs_int32 acom, struct afs_ioctl *adata); +extern int HandleIoctl(struct vcache *avc, afs_int32 acom, + struct afs_ioctl *adata); extern int afs_fsync(); extern int afs_remove(); extern int afs_link(); @@ -231,23 +233,23 @@ extern int afs_readlink(); int afs_nbsd_lookup(ap) -struct vop_lookup_args /* { - struct vnodeop_desc * a_desc; - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - } */ *ap; + struct vop_lookup_args /* { + * struct vnodeop_desc * a_desc; + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * } */ *ap; { int code; struct vcache *vcp; struct vnode *vp, *dvp; int flags = ap->a_cnp->cn_flags; - int lockparent; /* 1 => lockparent flag is set */ - int wantparent; /* 1 => wantparent or lockparent flag */ + int lockparent; /* 1 => lockparent flag is set */ + int wantparent; /* 1 => wantparent or lockparent flag */ GETNAME(); lockparent = flags & LOCKPARENT; - wantparent = flags & (LOCKPARENT|WANTPARENT); + wantparent = flags & (LOCKPARENT | WANTPARENT); #ifdef PDIRUNLOCK cnp->cn_flags &= ~PDIRUNLOCK; #endif @@ -259,13 +261,14 @@ struct vop_lookup_args /* { } dvp = ap->a_dvp; if (afs_debug & AFSDEB_VNLAYER && !(dvp->v_flag & VROOT)) - printf("nbsd_lookup dvp %p flags %x name %s cnt %d\n", dvp, flags, name, dvp->v_usecount); + printf("nbsd_lookup dvp %p flags %x name %s cnt %d\n", dvp, flags, + name, dvp->v_usecount); AFS_GLOCK(); code = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred); AFS_GUNLOCK(); if (code) { - if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) && - (flags & ISLASTCN) && code == ENOENT) + if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) + && (flags & ISLASTCN) && code == ENOENT) code = EJUSTRETURN; if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN)) cnp->cn_flags |= SAVENAME; @@ -273,7 +276,7 @@ struct vop_lookup_args /* { *ap->a_vpp = NULL; return (code); } - vp = AFSTOV(vcp); /* always get a node if no error */ + vp = AFSTOV(vcp); /* always get a node if no error */ /* * The parent directory comes in locked. We unlock it on return @@ -283,12 +286,12 @@ struct vop_lookup_args /* { if (vp == dvp) { /* they're the same; afs_lookup() already ref'ed the leaf. - It came in locked, so we don't need to ref OR lock it */ + * It came in locked, so we don't need to ref OR lock it */ if (afs_debug & AFSDEB_VNLAYER) printf("ref'ed %p as .\n", dvp); } else { if (!lockparent || !(flags & ISLASTCN)) { - VOP_UNLOCK(dvp, 0, curproc); /* done with parent. */ + VOP_UNLOCK(dvp, 0, curproc); /* done with parent. */ #ifdef PDIRUNLOCK cnp->cn_flags |= PDIRUNLOCK; #endif @@ -311,12 +314,12 @@ struct vop_lookup_args /* { int afs_nbsd_create(ap) - struct vop_create_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap; + struct vop_create_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * } */ *ap; { int code = 0; struct vcache *vcp; @@ -329,22 +332,22 @@ afs_nbsd_create(ap) /* vnode layer handles excl/nonexcl */ AFS_GLOCK(); - code = afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL, - ap->a_vap->va_mode, &vcp, - cnp->cn_cred); + code = + afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL, ap->a_vap->va_mode, + &vcp, cnp->cn_cred); AFS_GUNLOCK(); if (code) { VOP_ABORTOP(dvp, cnp); vput(dvp); DROPNAME(); - return(code); + return (code); } if (vcp) { *ap->a_vpp = AFSTOV(vcp); vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, curproc); - } - else *ap->a_vpp = 0; + } else + *ap->a_vpp = 0; if ((cnp->cn_flags & SAVESTART) == 0) FREE(cnp->cn_pnbuf, M_NAMEI); @@ -357,26 +360,26 @@ afs_nbsd_create(ap) int afs_nbsd_mknod(ap) - struct vop_mknod_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap; + struct vop_mknod_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * } */ *ap; { free(ap->a_cnp->cn_pnbuf, M_NAMEI); vput(ap->a_dvp); - return(ENODEV); + return (ENODEV); } int afs_nbsd_open(ap) - struct vop_open_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_open_args /* { + * struct vnode *a_vp; + * int a_mode; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; struct vcache *vc = VTOAFS(ap->a_vp); @@ -393,12 +396,12 @@ afs_nbsd_open(ap) int afs_nbsd_close(ap) - struct vop_close_args /* { - struct vnode *a_vp; - int a_fflag; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_close_args /* { + * struct vnode *a_vp; + * int a_fflag; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; @@ -410,12 +413,12 @@ afs_nbsd_close(ap) int afs_nbsd_access(ap) - struct vop_access_args /* { - struct vnode *a_vp; - int a_mode; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_access_args /* { + * struct vnode *a_vp; + * int a_mode; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; @@ -427,12 +430,12 @@ afs_nbsd_access(ap) int afs_nbsd_getattr(ap) - struct vop_getattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_getattr_args /* { + * struct vnode *a_vp; + * struct vattr *a_vap; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; @@ -444,12 +447,12 @@ afs_nbsd_getattr(ap) int afs_nbsd_setattr(ap) - struct vop_setattr_args /* { - struct vnode *a_vp; - struct vattr *a_vap; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_setattr_args /* { + * struct vnode *a_vp; + * struct vattr *a_vap; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; @@ -461,53 +464,56 @@ afs_nbsd_setattr(ap) int afs_nbsd_read(ap) - struct vop_read_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap; + struct vop_read_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * int a_ioflag; + * struct ucred *a_cred; + * } */ *ap; { int code; AFS_GLOCK(); - code = afs_read(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, (daddr_t)0, NULL, 0); + code = + afs_read(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, (daddr_t) 0, NULL, + 0); AFS_GUNLOCK(); return code; } int afs_nbsd_write(ap) - struct vop_write_args /* { - struct vnode *a_vp; - struct uio *a_uio; - int a_ioflag; - struct ucred *a_cred; - } */ *ap; + struct vop_write_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * int a_ioflag; + * struct ucred *a_cred; + * } */ *ap; { int code; #ifdef UVM - (void) uvm_vnp_uncache(ap->a_vp); /* toss stale pages */ + (void)uvm_vnp_uncache(ap->a_vp); /* toss stale pages */ #else vnode_pager_uncache(ap->a_vp); #endif AFS_GLOCK(); - code = afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0); + code = + afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0); AFS_GUNLOCK(); return code; } int afs_nbsd_ioctl(ap) - struct vop_ioctl_args /* { - struct vnode *a_vp; - int a_command; - caddr_t a_data; - int a_fflag; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_ioctl_args /* { + * struct vnode *a_vp; + * int a_command; + * caddr_t a_data; + * int a_fflag; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { int code; @@ -517,7 +523,9 @@ afs_nbsd_ioctl(ap) AFS_GLOCK(); if (((ap->a_command >> 8) & 0xff) == 'V') /* This is a VICEIOCTL call */ - code = HandleIoctl(VTOAFS(ap->a_vp), ap->a_command, (struct afs_ioctl *) ap->a_data); + code = + HandleIoctl(VTOAFS(ap->a_vp), ap->a_command, + (struct afs_ioctl *)ap->a_data); else /* No-op call; just return. */ code = ENOTTY; @@ -528,13 +536,13 @@ afs_nbsd_ioctl(ap) /* ARGSUSED */ int afs_nbsd_select(ap) - struct vop_select_args /* { - struct vnode *a_vp; - int a_which; - int a_fflags; - struct ucred *a_cred; - struct proc *a_p; - } */ *ap; + struct vop_select_args /* { + * struct vnode *a_vp; + * int a_which; + * int a_fflags; + * struct ucred *a_cred; + * struct proc *a_p; + * } */ *ap; { /* * We should really check to see if I/O is possible. @@ -544,12 +552,12 @@ afs_nbsd_select(ap) int afs_nbsd_fsync(ap) - struct vop_fsync_args /* { - struct vnode *a_vp; - struct ucred *a_cred; - int a_waitfor; - struct proc *a_p; - } */ *ap; + struct vop_fsync_args /* { + * struct vnode *a_vp; + * struct ucred *a_cred; + * int a_waitfor; + * struct proc *a_p; + * } */ *ap; { int wait = ap->a_waitfor == MNT_WAIT; struct vnode *vp = ap->a_vp; @@ -564,11 +572,11 @@ afs_nbsd_fsync(ap) int afs_nbsd_remove(ap) - struct vop_remove_args /* { - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; - } */ *ap; + struct vop_remove_args /* { + * struct vnode *a_dvp; + * struct vnode *a_vp; + * struct componentname *a_cnp; + * } */ *ap; { int code; struct vnode *vp = ap->a_vp; @@ -576,7 +584,7 @@ afs_nbsd_remove(ap) GETNAME(); AFS_GLOCK(); - code = afs_remove(VTOAFS(dvp), name, cnp->cn_cred); + code = afs_remove(VTOAFS(dvp), name, cnp->cn_cred); AFS_GUNLOCK(); if (dvp == vp) vrele(vp); @@ -590,11 +598,11 @@ afs_nbsd_remove(ap) int afs_nbsd_link(ap) - struct vop_link_args /* { - struct vnode *a_vp; - struct vnode *a_tdvp; - struct componentname *a_cnp; - } */ *ap; + struct vop_link_args /* { + * struct vnode *a_vp; + * struct vnode *a_tdvp; + * struct componentname *a_cnp; + * } */ *ap; { int code; struct vnode *dvp = ap->a_dvp; @@ -623,7 +631,7 @@ afs_nbsd_link(ap) if (dvp != vp) VOP_UNLOCK(vp, 0, curproc); -out: + out: vput(dvp); DROPNAME(); return code; @@ -631,14 +639,14 @@ out: int afs_nbsd_rename(ap) - struct vop_rename_args /* { - struct vnode *a_fdvp; - struct vnode *a_fvp; - struct componentname *a_fcnp; - struct vnode *a_tdvp; - struct vnode *a_tvp; - struct componentname *a_tcnp; - } */ *ap; + struct vop_rename_args /* { + * struct vnode *a_fdvp; + * struct vnode *a_fvp; + * struct componentname *a_fcnp; + * struct vnode *a_tdvp; + * struct vnode *a_tvp; + * struct componentname *a_tcnp; + * } */ *ap; { int code = 0; struct componentname *fcnp = ap->a_fcnp; @@ -653,18 +661,18 @@ afs_nbsd_rename(ap) /* * Check for cross-device rename. */ - if ((fvp->v_mount != tdvp->v_mount) || - (tvp && (fvp->v_mount != tvp->v_mount))) { + if ((fvp->v_mount != tdvp->v_mount) + || (tvp && (fvp->v_mount != tvp->v_mount))) { code = EXDEV; -abortit: - VOP_ABORTOP(tdvp, tcnp); /* XXX, why not in NFS? */ + abortit: + VOP_ABORTOP(tdvp, tcnp); /* XXX, why not in NFS? */ if (tdvp == tvp) vrele(tdvp); else vput(tdvp); if (tvp) vput(tvp); - VOP_ABORTOP(fdvp, fcnp); /* XXX, why not in NFS? */ + VOP_ABORTOP(fdvp, fcnp); /* XXX, why not in NFS? */ vrele(fdvp); vrele(fvp); return (code); @@ -693,31 +701,32 @@ abortit: if ((fcnp->cn_flags & SAVESTART) == 0) panic("afs_rename: lost from startdir"); fcnp->cn_nameiop = DELETE; - (void) relookup(fdvp, &fvp, fcnp); + (void)relookup(fdvp, &fvp, fcnp); return (VOP_REMOVE(fdvp, fvp, fcnp)); } if ((code = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, curproc))) goto abortit; - MALLOC(fname, char *, fcnp->cn_namelen+1, M_TEMP, M_WAITOK); + MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK); bcopy(fcnp->cn_nameptr, fname, fcnp->cn_namelen); fname[fcnp->cn_namelen] = '\0'; - MALLOC(tname, char *, tcnp->cn_namelen+1, M_TEMP, M_WAITOK); + MALLOC(tname, char *, tcnp->cn_namelen + 1, M_TEMP, M_WAITOK); bcopy(tcnp->cn_nameptr, tname, tcnp->cn_namelen); tname[tcnp->cn_namelen] = '\0'; AFS_GLOCK(); /* XXX use "from" or "to" creds? NFS uses "to" creds */ - code = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred); + code = + afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred); AFS_GUNLOCK(); VOP_UNLOCK(fvp, 0, curproc); FREE(fname, M_TEMP); FREE(tname, M_TEMP); if (code) - goto abortit; /* XXX */ + goto abortit; /* XXX */ if (tdvp == tvp) vrele(tdvp); else @@ -731,12 +740,12 @@ abortit: int afs_nbsd_mkdir(ap) - struct vop_mkdir_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - } */ *ap; + struct vop_mkdir_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * } */ *ap; { struct vnode *dvp = ap->a_dvp; struct vattr *vap = ap->a_vap; @@ -755,7 +764,7 @@ afs_nbsd_mkdir(ap) VOP_ABORTOP(dvp, cnp); vput(dvp); DROPNAME(); - return(code); + return (code); } if (vcp) { *ap->a_vpp = AFSTOV(vcp); @@ -770,11 +779,11 @@ afs_nbsd_mkdir(ap) int afs_nbsd_rmdir(ap) - struct vop_rmdir_args /* { - struct vnode *a_dvp; - struct vnode *a_vp; - struct componentname *a_cnp; - } */ *ap; + struct vop_rmdir_args /* { + * struct vnode *a_dvp; + * struct vnode *a_vp; + * struct componentname *a_cnp; + * } */ *ap; { int code; struct vnode *vp = ap->a_vp; @@ -800,13 +809,13 @@ afs_nbsd_rmdir(ap) int afs_nbsd_symlink(ap) - struct vop_symlink_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - struct vattr *a_vap; - char *a_target; - } */ *ap; + struct vop_symlink_args /* { + * struct vnode *a_dvp; + * struct vnode **a_vpp; + * struct componentname *a_cnp; + * struct vattr *a_vap; + * char *a_target; + * } */ *ap; { struct vnode *dvp = ap->a_dvp; int code; @@ -814,8 +823,8 @@ afs_nbsd_symlink(ap) GETNAME(); AFS_GLOCK(); - code = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, - cnp->cn_cred); + code = + afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, cnp->cn_cred); AFS_GUNLOCK(); DROPNAME(); FREE(cnp->cn_pnbuf, M_NAMEI); @@ -825,14 +834,14 @@ afs_nbsd_symlink(ap) int afs_nbsd_readdir(ap) - struct vop_readdir_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - int *a_eofflag; - int *a_ncookies; - u_long **a_cookies; - } */ *ap; + struct vop_readdir_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * struct ucred *a_cred; + * int *a_eofflag; + * int *a_ncookies; + * u_long **a_cookies; + * } */ *ap; { int code; @@ -840,10 +849,12 @@ afs_nbsd_readdir(ap) #ifdef AFS_HAVE_COOKIES printf("readdir %p cookies %p ncookies %d\n", ap->a_vp, ap->a_cookies, ap->a_ncookies); - code = afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, - ap->a_eofflag, ap->a_ncookies, ap->a_cookies); + code = + afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag, + ap->a_ncookies, ap->a_cookies); #else - code = afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag); + code = + afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag); #endif AFS_GUNLOCK(); return code; @@ -851,11 +862,11 @@ afs_nbsd_readdir(ap) int afs_nbsd_readlink(ap) - struct vop_readlink_args /* { - struct vnode *a_vp; - struct uio *a_uio; - struct ucred *a_cred; - } */ *ap; + struct vop_readlink_args /* { + * struct vnode *a_vp; + * struct uio *a_uio; + * struct ucred *a_cred; + * } */ *ap; { int code; @@ -869,9 +880,9 @@ extern int prtactive; int afs_nbsd_inactive(ap) - struct vop_inactive_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_inactive_args /* { + * struct vnode *a_vp; + * } */ *ap; { struct vnode *vp = ap->a_vp; struct vcache *vc = VTOAFS(vp); @@ -884,7 +895,7 @@ afs_nbsd_inactive(ap) if (!haveGlock) AFS_GLOCK(); - afs_InactiveVCache(vc, 0); /* decrs ref counts */ + afs_InactiveVCache(vc, 0); /* decrs ref counts */ if (!haveGlock) AFS_GUNLOCK(); @@ -894,9 +905,9 @@ afs_nbsd_inactive(ap) int afs_nbsd_reclaim(ap) - struct vop_reclaim_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_reclaim_args /* { + * struct vnode *a_vp; + * } */ *ap; { int code, slept; struct vnode *vp = ap->a_vp; @@ -909,7 +920,7 @@ afs_nbsd_reclaim(ap) if (!haveVlock) ObtainWriteLock(&afs_xvcache, 901); #ifndef AFS_DISCON_ENV - code = afs_FlushVCache(avc, &slept); /* tosses our stuff from vnode */ + code = afs_FlushVCache(avc, &slept); /* tosses our stuff from vnode */ #else /* reclaim the vnode and the in-memory vcache, but keep the on-disk vcache */ code = afs_FlushVS(avc); @@ -923,45 +934,47 @@ afs_nbsd_reclaim(ap) int afs_nbsd_lock(ap) - struct vop_lock_args /* { - struct vnode *a_vp; - int a_flags; - sturct proc *a_p; - } */ *ap; + struct vop_lock_args /* { + * struct vnode *a_vp; + * int a_flags; + * sturct proc *a_p; + * } */ *ap; { struct vnode *vp = ap->a_vp; struct vcache *vc = VTOAFS(vp); if (!vc) panic("afs_nbsd_lock: null vcache"); - return lockmgr(&vc->rwlock, ap->a_flags | LK_CANRECURSE, &vp->v_interlock, ap->a_p); + return lockmgr(&vc->rwlock, ap->a_flags | LK_CANRECURSE, &vp->v_interlock, + ap->a_p); } int afs_nbsd_unlock(ap) - struct vop_unlock_args /* { - struct vnode *a_vp; - int a_flags; - struct proc *a_p; - } */ *ap; + struct vop_unlock_args /* { + * struct vnode *a_vp; + * int a_flags; + * struct proc *a_p; + * } */ *ap; { struct vnode *vp = ap->a_vp; struct vcache *vc = VTOAFS(vp); if (!vc) panic("afs_nbsd_unlock: null vcache"); - return lockmgr(&vc->rwlock, ap->a_flags | LK_RELEASE, &vp->v_interlock, ap->a_p); + return lockmgr(&vc->rwlock, ap->a_flags | LK_RELEASE, &vp->v_interlock, + ap->a_p); } int afs_nbsd_bmap(ap) - struct vop_bmap_args /* { - struct vnode *a_vp; - daddr_t a_bn; - struct vnode **a_vpp; - daddr_t *a_bnp; - int *a_runp; - } */ *ap; + struct vop_bmap_args /* { + * struct vnode *a_vp; + * daddr_t a_bn; + * struct vnode **a_vpp; + * daddr_t *a_bnp; + * int *a_runp; + * } */ *ap; { struct vcache *vcp = VTOAFS(ap->a_vp); @@ -975,9 +988,9 @@ afs_nbsd_bmap(ap) int afs_nbsd_strategy(ap) - struct vop_strategy_args /* { - struct buf *a_bp; - } */ *ap; + struct vop_strategy_args /* { + * struct buf *a_bp; + * } */ *ap; { struct buf *abp = ap->a_bp; struct uio tuio; @@ -1000,7 +1013,8 @@ afs_nbsd_strategy(ap) if ((abp->b_flags & B_READ) == B_READ) { code = afs_rdwr(tvc, &tuio, UIO_READ, 0, credp); if (code == 0 && tuio.afsio_resid > 0) - bzero(abp->b_un.b_addr + len - tuio.afsio_resid, tuio.afsio_resid); + bzero(abp->b_un.b_addr + len - tuio.afsio_resid, + tuio.afsio_resid); } else code = afs_rdwr(tvc, &tuio, UIO_WRITE, 0, credp); AFS_GUNLOCK(); @@ -1012,15 +1026,16 @@ afs_nbsd_strategy(ap) int afs_nbsd_print(ap) - struct vop_print_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_print_args /* { + * struct vnode *a_vp; + * } */ *ap; { struct vnode *vp = ap->a_vp; struct vcache *vc = VTOAFS(ap->a_vp); printf("tag %d, fid: %d.%x.%x.%x, ", vp->v_tag, vc->fid.Cell, - (int) vc->fid.Fid.Volume, (int) vc->fid.Fid.Vnode, (int) vc->fid.Fid.Unique); + (int)vc->fid.Fid.Volume, (int)vc->fid.Fid.Vnode, + (int)vc->fid.Fid.Unique); lockmgr_printinfo(&vc->rwlock); printf("\n"); return 0; @@ -1028,9 +1043,9 @@ afs_nbsd_print(ap) int afs_nbsd_islocked(ap) - struct vop_islocked_args /* { - struct vnode *a_vp; - } */ *ap; + struct vop_islocked_args /* { + * struct vnode *a_vp; + * } */ *ap; { return lockstatus(&VTOAFS(ap->a_vp)->rwlock); } @@ -1040,11 +1055,11 @@ afs_nbsd_islocked(ap) */ int afs_nbsd_pathconf(ap) - struct vop_pathconf_args /* { - struct vnode *a_vp; - int a_name; - int *a_retval; - } */ *ap; + struct vop_pathconf_args /* { + * struct vnode *a_vp; + * int a_name; + * int *a_retval; + * } */ *ap; { AFS_STATCNT(afs_cntl); switch (ap->a_name) { @@ -1073,26 +1088,28 @@ afs_nbsd_pathconf(ap) } extern int -afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd, struct AFS_UCRED *acred, pid_t clid); + afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd, + struct AFS_UCRED *acred, pid_t clid); /* * Advisory record locking support (fcntl() POSIX style) */ int afs_nbsd_advlock(ap) - struct vop_advlock_args /* { - struct vnode *a_vp; - caddr_t a_id; - int a_op; - struct flock *a_fl; - int a_flags; - } */ *ap; + struct vop_advlock_args /* { + * struct vnode *a_vp; + * caddr_t a_id; + * int a_op; + * struct flock *a_fl; + * int a_flags; + * } */ *ap; { int code; AFS_GLOCK(); - code = afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, osi_curcred(), - (int) ap->a_id); + code = + afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, osi_curcred(), + (int)ap->a_id); AFS_GUNLOCK(); return code; } diff --git a/src/afs/SOLARIS/osi_file.c b/src/afs/SOLARIS/osi_file.c index 3b4f4e619..e06145b38 100644 --- a/src/afs/SOLARIS/osi_file.c +++ b/src/afs/SOLARIS/osi_file.c @@ -10,16 +10,17 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #include "afs/osi_inode.h" -int afs_osicred_initialized=0; -struct AFS_UCRED afs_osi_cred; +int afs_osicred_initialized = 0; +struct AFS_UCRED afs_osi_cred; afs_lock_t afs_xosi; /* lock is for tvattr */ extern struct osi_dev cacheDev; extern struct vfs *afs_cacheVfsp; @@ -35,17 +36,18 @@ extern struct vfs *afs_cacheVfsp; int afs_CacheFSType = -1; /* pointer to VXFS routine to access vnodes by inode number */ -int (*vxfs_vx_vp_byino)(); +int (*vxfs_vx_vp_byino) (); /* Initialize the cache operations. Called while initializing cache files. */ -void afs_InitDualFSCacheOps(struct vnode *vp) +void +afs_InitDualFSCacheOps(struct vnode *vp) { int code; static int inited = 0; struct vfs *vfsp; #ifdef AFS_SUN56_ENV struct statvfs64 vfst; -#else /* AFS_SUN56_ENV */ +#else /* AFS_SUN56_ENV */ struct statvfs vfst; #endif /* AFS_SUN56_ENV */ @@ -66,7 +68,8 @@ void afs_InitDualFSCacheOps(struct vnode *vp) if (strcmp(vfst.f_basetype, "vxfs") == 0) { vxfs_vx_vp_byino = (int (*)())modlookup("vxfs", "vx_vp_byino"); if (vxfs_vx_vp_byino == NULL) - osi_Panic("afs_InitDualFSCacheOps: modlookup(vx_vp_byino) failed"); + osi_Panic + ("afs_InitDualFSCacheOps: modlookup(vx_vp_byino) failed"); afs_CacheFSType = AFS_SUN_VXFS_CACHE; return; @@ -76,12 +79,13 @@ void afs_InitDualFSCacheOps(struct vnode *vp) return; } -ino_t VnodeToIno(vnode_t *vp) +ino_t +VnodeToIno(vnode_t * vp) { int code; struct vattr vattr; - vattr.va_mask = AT_FSID|AT_NODEID; /* quick return using this mask. */ + vattr.va_mask = AT_FSID | AT_NODEID; /* quick return using this mask. */ code = VOP_GETATTR(vp, &vattr, 0, &afs_osi_cred); if (code) { osi_Panic("VnodeToIno"); @@ -89,22 +93,24 @@ ino_t VnodeToIno(vnode_t *vp) return vattr.va_nodeid; } -dev_t VnodeToDev(vnode_t *vp) +dev_t +VnodeToDev(vnode_t * vp) { int code; struct vattr vattr; - vattr.va_mask = AT_FSID|AT_NODEID; /* quick return using this mask. */ + vattr.va_mask = AT_FSID | AT_NODEID; /* quick return using this mask. */ AFS_GUNLOCK(); code = VOP_GETATTR(vp, &vattr, 0, &afs_osi_cred); AFS_GLOCK(); if (code) { osi_Panic("VnodeToDev"); } - return (dev_t)vattr.va_fsid; + return (dev_t) vattr.va_fsid; } -afs_int32 VnodeToSize(vnode_t *vp) +afs_int32 +VnodeToSize(vnode_t * vp) { int code; struct vattr vattr; @@ -112,8 +118,8 @@ afs_int32 VnodeToSize(vnode_t *vp) /* * We lock xosi in osi_Stat, so we probably should * lock it here too - RWH. - */ - MObtainWriteLock(&afs_xosi,578); + */ + MObtainWriteLock(&afs_xosi, 578); vattr.va_mask = AT_SIZE; AFS_GUNLOCK(); code = VOP_GETATTR(vp, &vattr, 0, &afs_osi_cred); @@ -122,18 +128,19 @@ afs_int32 VnodeToSize(vnode_t *vp) osi_Panic("VnodeToSize"); } MReleaseWriteLock(&afs_xosi); - return (afs_int32)(vattr.va_size); + return (afs_int32) (vattr.va_size); } -void *osi_VxfsOpen(afs_int32 ainode) +void * +osi_VxfsOpen(afs_int32 ainode) { struct vnode *vp; register struct osi_file *afile = NULL; afs_int32 code = 0; int dummy; - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); - code = (*vxfs_vx_vp_byino)(afs_cacheVfsp, &vp, (unsigned int)ainode); + code = (*vxfs_vx_vp_byino) (afs_cacheVfsp, &vp, (unsigned int)ainode); AFS_GLOCK(); if (code) { osi_FreeSmallSpace(afile); @@ -142,25 +149,29 @@ void *osi_VxfsOpen(afs_int32 ainode) afile->vnode = vp; afile->size = VnodeToSize(afile->vnode); afile->offset = 0; - afile->proc = (int (*)()) 0; - afile->inum = ainode; /* for hint validity checking */ + afile->proc = (int (*)())0; + afile->inum = ainode; /* for hint validity checking */ return (void *)afile; } #endif /* AFS_HAVE_VXFS */ #if defined(AFS_SUN57_64BIT_ENV) -void *osi_UfsOpen(ino_t ainode) +void * +osi_UfsOpen(ino_t ainode) #else -void *osi_UfsOpen(afs_int32 ainode) +void * +osi_UfsOpen(afs_int32 ainode) #endif { struct inode *ip; register struct osi_file *afile = NULL; afs_int32 code = 0; int dummy; - afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file)); + afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file)); AFS_GUNLOCK(); - code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode, &ip, CRED(),&dummy); + code = + igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode, &ip, + CRED(), &dummy); AFS_GLOCK(); if (code) { osi_FreeSmallSpace(afile); @@ -169,8 +180,8 @@ void *osi_UfsOpen(afs_int32 ainode) afile->vnode = ITOV(ip); afile->size = VTOI(afile->vnode)->i_size; afile->offset = 0; - afile->proc = (int (*)()) 0; - afile->inum = ainode; /* for hint validity checking */ + afile->proc = (int (*)())0; + afile->inum = ainode; /* for hint validity checking */ return (void *)afile; } @@ -178,14 +189,16 @@ void *osi_UfsOpen(afs_int32 ainode) * In Solaris 7 we use 64 bit inode numbers */ #if defined(AFS_SUN57_64BIT_ENV) -void *osi_UFSOpen(ino_t ainode) +void * +osi_UFSOpen(ino_t ainode) #else -void *osi_UFSOpen(afs_int32 ainode) +void * +osi_UFSOpen(afs_int32 ainode) #endif { extern int cacheDiskType; AFS_STATCNT(osi_UFSOpen); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) { + if (cacheDiskType != AFS_FCACHE_TYPE_UFS) { osi_Panic("UFSOpen called for non-UFS cache\n"); } if (!afs_osicred_initialized) { @@ -201,12 +214,13 @@ void *osi_UFSOpen(afs_int32 ainode) return osi_UfsOpen(ainode); } -int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) +int +afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat) { register afs_int32 code; struct vattr tvattr; AFS_STATCNT(osi_Stat); - MObtainWriteLock(&afs_xosi,320); + MObtainWriteLock(&afs_xosi, 320); /* Ufs doesn't seem to care about the flags so we pass 0 for now */ tvattr.va_mask = AT_ALL; AFS_GUNLOCK(); @@ -222,18 +236,20 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta return code; } -int osi_UFSClose(register struct osi_file *afile) - { - AFS_STATCNT(osi_Close); - if(afile->vnode) { +int +osi_UFSClose(register struct osi_file *afile) +{ + AFS_STATCNT(osi_Close); + if (afile->vnode) { AFS_RELE(afile->vnode); - } - - osi_FreeSmallSpace(afile); - return 0; - } + } -int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) + osi_FreeSmallSpace(afile); + return 0; +} + +int +osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) { struct AFS_UCRED *oldCred; struct vattr tvattr; @@ -246,8 +262,9 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) * small enough. Check now and save some time. */ code = afs_osi_Stat(afile, &tstat); - if (code || tstat.size <= asize) return code; - MObtainWriteLock(&afs_xosi,321); + if (code || tstat.size <= asize) + return code; + MObtainWriteLock(&afs_xosi, 321); tvattr.va_mask = AT_SIZE; tvattr.va_size = asize; /* @@ -260,21 +277,24 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize) return code; } -void osi_DisableAtimes(struct vnode *avp) +void +osi_DisableAtimes(struct vnode *avp) { - if (afs_CacheFSType == AFS_SUN_UFS_CACHE) { - struct inode *ip = VTOI(avp); - rw_enter(&ip->i_contents, RW_READER); - mutex_enter(&ip->i_tlock); - ip->i_flag &= ~IACC; - mutex_exit(&ip->i_tlock); - rw_exit(&ip->i_contents); - } + if (afs_CacheFSType == AFS_SUN_UFS_CACHE) { + struct inode *ip = VTOI(avp); + rw_enter(&ip->i_contents, RW_READER); + mutex_enter(&ip->i_tlock); + ip->i_flag &= ~IACC; + mutex_exit(&ip->i_tlock); + rw_exit(&ip->i_contents); + } } /* Generic read interface */ -int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize) +int +afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; #if defined(AFS_SUN57_ENV) @@ -283,66 +303,70 @@ int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_in int resid; #endif register afs_int32 code; - register afs_int32 cnt1=0; + register afs_int32 cnt1 = 0; AFS_STATCNT(osi_Read); /** * If the osi_file passed in is NULL, panic only if AFS is not shutting * down. No point in crashing when we are already shutting down */ - if ( !afile ) { - if ( !afs_shuttingdown ) - osi_Panic("osi_Read called with null param"); + if (!afile) { + if (!afs_shuttingdown) + osi_Panic("osi_Read called with null param"); else return EIO; } - if (offset != -1) afile->offset = offset; + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); - code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, - AFS_UIOSYS, 0, 0, &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset, + AFS_UIOSYS, 0, 0, &afs_osi_cred, &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; osi_DisableAtimes(afile->vnode); - } - else { + } else { afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid, - ICL_TYPE_INT32, code); + ICL_TYPE_INT32, code); code = -1; } return code; } /* Generic write interface */ -int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize) +int +afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, + afs_int32 asize) { struct AFS_UCRED *oldCred; #if defined(AFS_SUN57_ENV) ssize_t resid; #else - int resid; + int resid; #endif register afs_int32 code; AFS_STATCNT(osi_Write); - if ( !afile ) - osi_Panic("afs_osi_Write called with null param"); - if (offset != -1) afile->offset = offset; + if (!afile) + osi_Panic("afs_osi_Write called with null param"); + if (offset != -1) + afile->offset = offset; AFS_GUNLOCK(); - code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, - afile->offset, AFS_UIOSYS, 0, RLIM64_INFINITY, - &afs_osi_cred, &resid); + code = + gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, + afile->offset, AFS_UIOSYS, 0, RLIM64_INFINITY, &afs_osi_cred, + &resid); AFS_GLOCK(); if (code == 0) { code = asize - resid; afile->offset += code; - } - else { + } else { code = -1; } if (afile->proc) { - (*afile->proc)(afile, code); + (*afile->proc) (afile, code); } return code; } @@ -351,7 +375,8 @@ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, /* This work should be handled by physstrat in ca/machdep.c. This routine written from the RT NFS port strategy routine. It has been generalized a bit, but should still be pretty clear. */ -int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) +int +afs_osi_MapStrategy(int (*aproc) (), register struct buf *bp) { afs_int32 returnCode; @@ -363,13 +388,13 @@ int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp) -void shutdown_osifile(void) +void +shutdown_osifile(void) { - extern int afs_cold_shutdown; + extern int afs_cold_shutdown; - AFS_STATCNT(shutdown_osifile); - if (afs_cold_shutdown) { - afs_osicred_initialized = 0; - } + AFS_STATCNT(shutdown_osifile); + if (afs_cold_shutdown) { + afs_osicred_initialized = 0; + } } - diff --git a/src/afs/SOLARIS/osi_groups.c b/src/afs/SOLARIS/osi_groups.c index 048d4e3a8..82f779aba 100644 --- a/src/afs/SOLARIS/osi_groups.c +++ b/src/afs/SOLARIS/osi_groups.c @@ -16,40 +16,36 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ static int -afs_getgroups( - struct cred *cred, - gid_t *gidset); + afs_getgroups(struct cred *cred, gid_t * gidset); static int -afs_setgroups( - struct cred **cred, - int ngroups, - gid_t *gidset, - int change_parent); + afs_setgroups(struct cred **cred, int ngroups, gid_t * gidset, + int change_parent); #if defined(AFS_SUN55_ENV) int afs_xsetgroups(uap, rvp) -u_int uap; /* this is gidsetsize */ -gid_t *rvp; /* this is gidset */ -#else + u_int uap; /* this is gidsetsize */ + gid_t *rvp; /* this is gidset */ +#else struct setgroupsa { u_int gidsetsize; gid_t *gidset; }; -afs_xsetgroups(uap, rvp) - struct setgroupsa *uap; - rval_t *rvp; +afs_xsetgroups(uap, rvp) + struct setgroupsa *uap; + rval_t *rvp; #endif { int code = 0; @@ -60,7 +56,8 @@ afs_xsetgroups(uap, rvp) AFS_GLOCK(); code = afs_InitReq(&treq, proc->p_cred); AFS_GUNLOCK(); - if (code) return code; + if (code) + return code; code = setgroups(uap, rvp); /* Note that if there is a pag already in the new groups we don't @@ -79,10 +76,10 @@ afs_xsetgroups(uap, rvp) int setpag(cred, pagvalue, newpag, change_parent) - struct cred **cred; - afs_uint32 pagvalue; - afs_uint32 *newpag; - afs_uint32 change_parent; + struct cred **cred; + afs_uint32 pagvalue; + afs_uint32 *newpag; + afs_uint32 change_parent; { gid_t *gidset; int ngroups, code; @@ -97,16 +94,16 @@ setpag(cred, pagvalue, newpag, change_parent) if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) { /* We will have to shift grouplist to make room for pag */ - if ((sizeof gidset[0])*(ngroups + 2) > AFS_SMALLOCSIZ) { + if ((sizeof gidset[0]) * (ngroups + 2) > AFS_SMALLOCSIZ) { osi_FreeSmallSpace((char *)gidset); return (E2BIG); } - for (j = ngroups -1; j >= 0; j--) { - gidset[j+2] = gidset[j]; - } + for (j = ngroups - 1; j >= 0; j--) { + gidset[j + 2] = gidset[j]; + } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]); /* afs_setgroups will release curproc->p_crlock */ if (code = afs_setgroups(cred, ngroups, gidset, change_parent)) { @@ -119,9 +116,7 @@ setpag(cred, pagvalue, newpag, change_parent) static int -afs_getgroups( - struct cred *cred, - gid_t *gidset) +afs_getgroups(struct cred *cred, gid_t * gidset) { int ngrps, savengrps; gid_t *gp; @@ -132,18 +127,15 @@ afs_getgroups( savengrps = ngrps = cred->cr_ngroups; gp = cred->cr_groups; while (ngrps--) - *gidset++ = *gp++; + *gidset++ = *gp++; return savengrps; } static int -afs_setgroups( - struct cred **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct cred **cred, int ngroups, gid_t * gidset, + int change_parent) { int ngrps; int i; @@ -163,6 +155,6 @@ afs_setgroups( *gp++ = *gidset++; mutex_exit(&curproc->p_crlock); if (!change_parent) - crset(curproc, *cred); /* broadcast to all threads */ + crset(curproc, *cred); /* broadcast to all threads */ return (0); } diff --git a/src/afs/SOLARIS/osi_inode.c b/src/afs/SOLARIS/osi_inode.c index 4fc5dfeb3..5a414fc13 100644 --- a/src/afs/SOLARIS/osi_inode.c +++ b/src/afs/SOLARIS/osi_inode.c @@ -16,15 +16,16 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ #include "afs/osi_inode.h" -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ -extern int (*ufs_iallocp)(), (*ufs_iupdatp)(), (*ufs_igetp)(), - (*ufs_itimes_nolockp)(); +extern int (*ufs_iallocp) (), (*ufs_iupdatp) (), (*ufs_igetp) (), + (*ufs_itimes_nolockp) (); #define AFS_ITIMES(ip) { \ mutex_enter(&(ip)->i_tlock); \ @@ -35,7 +36,7 @@ extern int (*ufs_iallocp)(), (*ufs_iupdatp)(), (*ufs_igetp)(), #define AFS_ITIMES_NOLOCK(ip) \ (*ufs_itimes_nolockp)(ip); -getinode(vfsp, dev, inode, ipp, credp,perror) +getinode(vfsp, dev, inode, ipp, credp, perror) struct vfs *vfsp; struct AFS_UCRED *credp; struct inode **ipp; @@ -49,16 +50,16 @@ getinode(vfsp, dev, inode, ipp, credp,perror) struct fs *fs; struct inode *pip; struct ufsvfs *ufsvfsp; - + AFS_STATCNT(getinode); - + *perror = 0; - - if (!vfsp + + if (!vfsp #if !defined(AFS_SUN58_ENV) && !(vfsp = vfs_devsearch(dev)) #else - && !(vfsp = vfs_dev2vfsp(dev)) + && !(vfsp = vfs_dev2vfsp(dev)) #endif ) { return (ENODEV); @@ -68,7 +69,7 @@ getinode(vfsp, dev, inode, ipp, credp,perror) #ifdef HAVE_VFS_DQRWLOCK rw_enter(&ufsvfsp->vfs_dqrwlock, RW_READER); #endif - code = (*ufs_igetp)(vfsp, inode, &ip, credp); + code = (*ufs_igetp) (vfsp, inode, &ip, credp); #ifdef HAVE_VFS_DQRWLOCK rw_exit(&ufsvfsp->vfs_dqrwlock); #endif @@ -82,7 +83,7 @@ getinode(vfsp, dev, inode, ipp, credp,perror) } /* get an existing inode. Common code for iopen, iread/write, iinc/dec. */ -igetinode(vfsp, dev, inode, ipp, credp,perror) +igetinode(vfsp, dev, inode, ipp, credp, perror) struct AFS_UCRED *credp; struct inode **ipp; struct vfs *vfsp; @@ -93,44 +94,44 @@ igetinode(vfsp, dev, inode, ipp, credp,perror) struct inode *pip, *ip; extern struct osi_dev cacheDev; register int code = 0; - + *perror = 0; - + AFS_STATCNT(igetinode); - - code = getinode(vfsp, dev, inode, &ip, credp,perror); - if (code) + + code = getinode(vfsp, dev, inode, &ip, credp, perror); + if (code) return code; - + rw_enter(&ip->i_contents, RW_READER); - + if (ip->i_mode == 0) { /* Not an allocated inode */ rw_exit(&ip->i_contents); VN_RELE(ITOV(ip)); return (ENOENT); } - - if (ip->i_nlink == 0 || (ip->i_mode&IFMT) != IFREG) { + + if (ip->i_nlink == 0 || (ip->i_mode & IFMT) != IFREG) { AFS_ITIMES(ip); rw_exit(&ip->i_contents); VN_RELE(ITOV(ip)); return (ENOENT); } - + /* On VFS40 systems, iput does major synchronous write action, but only - when the reference count on the vnode goes to 0. Normally, Sun users - don't notice this because the DNLC keep references for them, but we - notice 'cause we don't. So, we make a fake dnlc entry which gets - cleaned up by iget when it needs the space. */ + * when the reference count on the vnode goes to 0. Normally, Sun users + * don't notice this because the DNLC keep references for them, but we + * notice 'cause we don't. So, we make a fake dnlc entry which gets + * cleaned up by iget when it needs the space. */ if (dev != cacheDev.dev) { /* * Don't call dnlc for the cm inodes since it's a big performance * penalty there! */ - dnlc_enter(ITOV(ip), "a", ITOV(ip), (struct AFS_UCRED *) 0); + dnlc_enter(ITOV(ip), "a", ITOV(ip), (struct AFS_UCRED *)0); } - + *ipp = ip; rw_exit(&ip->i_contents); return (code); @@ -138,34 +139,35 @@ igetinode(vfsp, dev, inode, ipp, credp,perror) int CrSync = 1; -afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, credp) +afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, + credp) rval_t *rvp; struct AFS_UCRED *credp; long near_inode, param1, param2, param3, param4; dev_t dev; { - int dummy, err=0; + int dummy, err = 0; struct inode *ip, *newip; register int code; dev_t newdev; struct ufsvfs *ufsvfsp; AFS_STATCNT(afs_syscall_icreate); - + if (!afs_suser(credp)) return (EPERM); - + /** Code to convert a 32 bit dev_t into a 64 bit dev_t * This conversion is needed only for the 64 bit OS. */ - + #ifdef AFS_SUN57_64BIT_ENV - newdev = expldev( (dev32_t) dev); + newdev = expldev((dev32_t) dev); #else newdev = dev; #endif - code = getinode(0, (dev_t)newdev, 2, &ip, credp,&dummy); + code = getinode(0, (dev_t) newdev, 2, &ip, credp, &dummy); if (code) { return (code); } @@ -176,7 +178,7 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, credp) rw_enter(&ufsvfsp->vfs_dqrwlock, RW_READER); #endif rw_enter(&ip->i_contents, RW_WRITER); - code = (*ufs_iallocp)(ip, near_inode, 0, &newip, credp); + code = (*ufs_iallocp) (ip, near_inode, 0, &newip, credp); AFS_ITIMES_NOLOCK(ip); rw_exit(&ip->i_contents); #ifdef HAVE_VFS_DQRWLOCK @@ -189,7 +191,7 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, credp) return (code); } rw_enter(&newip->i_contents, RW_WRITER); - newip->i_flag |= IACC|IUPD|ICHG; + newip->i_flag |= IACC | IUPD | ICHG; #if defined(AFS_SUN56_ENV) newip->i_vicemagic = VICEMAGIC; @@ -200,15 +202,15 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, credp) newip->i_nlink = 1; newip->i_mode = IFREG; newip->i_vnode.v_type = VREG; - + newip->i_vicep1 = param1; - if (param2 == 0x1fffffff/*INODESPECIAL*/) { + if (param2 == 0x1fffffff /*INODESPECIAL*/) { newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3)); newip->i_vicep3 = param3; } else { - newip->i_vicep2 = (((param2 >> 16) & 0x1f) << 27) + - (((param4 >> 16) & 0x1f) << 22) + - (param3 & 0x3fffff); + newip->i_vicep2 = + (((param2 >> 16) & 0x1f) << 27) + + (((param4 >> 16) & 0x1f) << 22) + (param3 & 0x3fffff); newip->i_vicep3 = ((param4 << 16) + (param2 & 0xffff)); } #ifdef AFS_SUN57_64BIT_ENV @@ -216,12 +218,12 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, credp) #else rvp->r_val1 = newip->i_number; #endif - + /* * We're being conservative and sync to the disk */ if (CrSync) - (*ufs_iupdatp)(newip, 1); + (*ufs_iupdatp) (newip, 1); AFS_ITIMES_NOLOCK(newip); rw_exit(&newip->i_contents); VN_RELE(ITOV(newip)); @@ -231,7 +233,7 @@ afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, rvp, credp) afs_syscall_iopen(dev, inode, usrmod, rvp, credp) rval_t *rvp; struct AFS_UCRED *credp; - int inode, usrmod; + int inode, usrmod; dev_t dev; { struct file *fp; @@ -250,18 +252,18 @@ afs_syscall_iopen(dev, inode, usrmod, rvp, credp) /** Code to convert a 32 bit dev_t into a 64 bit dev_t * This conversion is needed only for the 64 bit OS. */ - + #ifdef AFS_SUN57_64BIT_ENV - newdev = expldev( (dev32_t) dev); + newdev = expldev((dev32_t) dev); #else newdev = dev; #endif - code = igetinode(0, (dev_t)newdev, (ino_t)inode, &ip, credp,&dummy); + code = igetinode(0, (dev_t) newdev, (ino_t) inode, &ip, credp, &dummy); if (code) { return (code); } - code = falloc((struct vnode *)NULL, FWRITE|FREAD, &fp, &fd); + code = falloc((struct vnode *)NULL, FWRITE | FREAD, &fp, &fd); if (code) { rw_enter(&ip->i_contents, RW_READER); AFS_ITIMES(ip); @@ -269,14 +271,14 @@ afs_syscall_iopen(dev, inode, usrmod, rvp, credp) VN_RELE(ITOV(ip)); return (code); } - + /* fp->f_count, f_audit_data are set by falloc */ fp->f_vnode = ITOV(ip); - - fp->f_flag = (usrmod+1) & (FMASK); - + + fp->f_flag = (usrmod + 1) & (FMASK); + /* fp->f_count, f_msgcount are set by falloc */ - + /* fp->f_offset zeroed by falloc */ /* f_cred set by falloc */ /* @@ -312,17 +314,17 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount, rvp, credp) if (!afs_suser(credp)) return (EPERM); - /** Code to convert a 32 bit dev_t into a 64 bit dev_t + /** Code to convert a 32 bit dev_t into a 64 bit dev_t * This conversion is needed only for the 64 bit OS. */ - + #ifdef AFS_SUN57_64BIT_ENV - newdev = expldev( (dev32_t) dev); + newdev = expldev((dev32_t) dev); #else newdev = dev; #endif - code = igetinode(0, (dev_t)newdev, (ino_t)inode, &ip, credp,&dummy); + code = igetinode(0, (dev_t) newdev, (ino_t) inode, &ip, credp, &dummy); if (code) { return (code); } @@ -343,11 +345,10 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount, rvp, credp) ip->i_flag |= ICHG; /* We may want to force the inode to the disk in case of crashes, other references, etc. */ if (IncSync) - (*ufs_iupdatp)(ip, 1); + (*ufs_iupdatp) (ip, 1); AFS_ITIMES_NOLOCK(ip); rw_exit(&ip->i_contents); VN_RELE(ITOV(ip)); } return (code); } - diff --git a/src/afs/SOLARIS/osi_inode.h b/src/afs/SOLARIS/osi_inode.h index 2a5cffac5..e131651d8 100644 --- a/src/afs/SOLARIS/osi_inode.h +++ b/src/afs/SOLARIS/osi_inode.h @@ -40,8 +40,8 @@ #endif #if defined(AFS_SUN56_ENV) -#define IS_VICEMAGIC(ip) ((ip)->i_vicemagic == VICEMAGIC) -#define IS_DVICEMAGIC(dp) ((dp)->di_vicemagic == VICEMAGIC) +#define IS_VICEMAGIC(ip) ((ip)->i_vicemagic == VICEMAGIC) +#define IS_DVICEMAGIC(dp) ((dp)->di_vicemagic == VICEMAGIC) #define CLEAR_VICEMAGIC(ip) (ip)->i_vicemagic = (ip)->i_vicep3 = 0 #define CLEAR_DVICEMAGIC(dp) (dp)->di_vicemagic = (dp)->di_vicep3 = 0 diff --git a/src/afs/SOLARIS/osi_machdep.h b/src/afs/SOLARIS/osi_machdep.h index 09403c6b8..a7d051b1a 100644 --- a/src/afs/SOLARIS/osi_machdep.h +++ b/src/afs/SOLARIS/osi_machdep.h @@ -19,7 +19,7 @@ #define _OSI_MACHDEP_H_ #ifdef AFS_SUN57_64BIT_ENV -#include /* for get_udatamodel() */ +#include /* for get_udatamodel() */ #endif #define getpid() curproc->p_pid @@ -45,9 +45,9 @@ extern void gethrestime(timespec_t *); static int local_osi_Time() { - timespec_t start; - gethrestime(&start); - return start.tv_sec; + timespec_t start; + gethrestime(&start); + return start.tv_sec; } #else #define osi_Time() (hrestime.tv_sec) @@ -71,7 +71,7 @@ extern void *afs_osi_Alloc_NoSleep(size_t size); extern kmutex_t afs_global_lock; extern kmutex_t afs_rxglobal_lock; -#define AFS_GLOCK() mutex_enter(&afs_global_lock); +#define AFS_GLOCK() mutex_enter(&afs_global_lock); #define AFS_GUNLOCK() mutex_exit(&afs_global_lock); #define ISAFS_GLOCK() mutex_owned(&afs_global_lock) @@ -82,10 +82,10 @@ extern kmutex_t afs_rxglobal_lock; /* Associate the Berkley signal equivalent lock types to System V's */ -#define LOCK_SH 1 /* F_RDLCK */ -#define LOCK_EX 2 /* F_WRLCK */ -#define LOCK_NB 4 /* XXX */ -#define LOCK_UN 8 /* F_UNLCK */ +#define LOCK_SH 1 /* F_RDLCK */ +#define LOCK_EX 2 /* F_WRLCK */ +#define LOCK_NB 4 /* XXX */ +#define LOCK_UN 8 /* F_UNLCK */ #ifndef IO_APPEND #define IO_APPEND FAPPEND @@ -106,4 +106,3 @@ extern kmutex_t afs_rxglobal_lock; #endif #endif /* _OSI_MACHDEP_H_ */ - diff --git a/src/afs/SOLARIS/osi_prototypes.h b/src/afs/SOLARIS/osi_prototypes.h index 1390222f3..a4e260958 100644 --- a/src/afs/SOLARIS/osi_prototypes.h +++ b/src/afs/SOLARIS/osi_prototypes.h @@ -16,16 +16,16 @@ extern afs_rwlock_t afs_xosi; /* osi_vnodeops.c */ int afs_putapage(struct vnode *vp, struct page *pages, #if defined(AFS_SUN56_ENV) - u_offset_t *offp, + u_offset_t * offp, #else - u_int *offp, + u_int * offp, #endif #if defined(AFS_SUN58_ENV) - size_t *lenp, + size_t * lenp, #else - u_int *lenp, + u_int * lenp, #endif - int flags, struct AFS_UCRED *credp); + int flags, struct AFS_UCRED *credp); diff --git a/src/afs/SOLARIS/osi_sleep.c b/src/afs/SOLARIS/osi_sleep.c index 5505f1045..e0afef4bc 100644 --- a/src/afs/SOLARIS/osi_sleep.c +++ b/src/afs/SOLARIS/osi_sleep.c @@ -10,31 +10,35 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok); static char waitV; -void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) +void +afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle) { AFS_STATCNT(osi_InitWaitHandle); achandle->proc = (caddr_t) 0; } /* cancel osi_Wait */ -void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) { caddr_t proc; AFS_STATCNT(osi_CancelWait); proc = achandle->proc; - if (proc == 0) return; - achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ + if (proc == 0) + return; + achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */ afs_osi_Wakeup(&waitV); } @@ -42,13 +46,14 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) * Waits for data on ahandle, or ams ms later. ahandle may be null. * Returns 0 if timeout and EINTR if signalled. */ -int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) +int +afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int code; afs_int32 endTime, tid; AFS_STATCNT(osi_Wait); - endTime = osi_Time() + (ams/1000); + endTime = osi_Time() + (ams / 1000); if (ahandle) ahandle->proc = (caddr_t) curthread; do { @@ -56,7 +61,8 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) code = 0; code = osi_TimedSleep(&waitV, ams, aintok); - if (code) break; /* if something happened, quit now */ + if (code) + break; /* if something happened, quit now */ /* if we we're cancelled, quit now */ if (ahandle && (ahandle->proc == (caddr_t) 0)) { /* we've been signalled */ @@ -74,19 +80,20 @@ typedef struct afs_event { char *event; /* lwp event: an address */ int refcount; /* Is it in use? */ int seq; /* Sequence number: this is incremented - by wakeup calls; wait will not return until - it changes */ + * by wakeup calls; wait will not return until + * it changes */ kcondvar_t cond; /* Currently associated condition variable */ } afs_event_t; #define HASHSIZE 128 -afs_event_t *afs_evhasht[HASHSIZE];/* Hash table for events */ +afs_event_t *afs_evhasht[HASHSIZE]; /* Hash table for events */ #define afs_evhash(event) (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1)); int afs_evhashcnt = 0; /* Get and initialize event structure corresponding to lwp event (i.e. address) * */ -static afs_event_t *afs_getevent(char *event) +static afs_event_t * +afs_getevent(char *event) { afs_event_t *evp, *newp = 0; int hashcode; @@ -104,7 +111,7 @@ static afs_event_t *afs_getevent(char *event) evp = evp->next; } if (!newp) { - newp = (afs_event_t *) osi_AllocSmallSpace(sizeof (afs_event_t)); + newp = (afs_event_t *) osi_AllocSmallSpace(sizeof(afs_event_t)); afs_evhashcnt++; newp->next = afs_evhasht[hashcode]; afs_evhasht[hashcode] = newp; @@ -120,7 +127,8 @@ static afs_event_t *afs_getevent(char *event) #define relevent(evp) ((evp)->refcount--) -void afs_osi_Sleep(void *event) +void +afs_osi_Sleep(void *event) { struct afs_event *evp; int seq; @@ -134,7 +142,8 @@ void afs_osi_Sleep(void *event) relevent(evp); } -int afs_osi_SleepSig(void *event) +int +afs_osi_SleepSig(void *event) { struct afs_event *evp; int seq, code = 0; @@ -161,14 +170,15 @@ int afs_osi_SleepSig(void *event) * * Returns 0 if timeout and EINTR if signalled. */ -static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) +static int +osi_TimedSleep(char *event, afs_int32 ams, int aintok) { int code = 0; struct afs_event *evp; clock_t ticks; - ticks = ( ams * afs_hz )/1000; - ticks = ticks + lbolt; + ticks = (ams * afs_hz) / 1000; + ticks = ticks + lbolt; evp = afs_getevent(event); @@ -179,22 +189,23 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok) } else { cv_timedwait(&evp->cond, &afs_global_lock, ticks); } - + relevent(evp); return code; } -int afs_osi_Wakeup(void *event) +int +afs_osi_Wakeup(void *event) { - int ret=1; + int ret = 1; struct afs_event *evp; evp = afs_getevent(event); if (evp->refcount > 1) { - evp->seq++; + evp->seq++; cv_broadcast(&evp->cond); - ret=0; + ret = 0; } relevent(evp); return 0; diff --git a/src/afs/SOLARIS/osi_vfsops.c b/src/afs/SOLARIS/osi_vfsops.c index 5cf3c157b..0ef96eccc 100644 --- a/src/afs/SOLARIS/osi_vfsops.c +++ b/src/afs/SOLARIS/osi_vfsops.c @@ -13,11 +13,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #include "h/modctl.h" #include "h/syscall.h" #include @@ -33,7 +34,8 @@ extern struct sysent sysent32[]; int afsfstype = 0; -int afs_mount(struct vfs *afsp, struct vnode *amvp, struct mounta *uap, +int +afs_mount(struct vfs *afsp, struct vnode *amvp, struct mounta *uap, struct AFS_UCRED *credp) { @@ -47,15 +49,15 @@ int afs_mount(struct vfs *afsp, struct vnode *amvp, struct mounta *uap, } afsp->vfs_fstype = afsfstype; - if (afs_globalVFS) { /* Don't allow remounts. */ + if (afs_globalVFS) { /* Don't allow remounts. */ AFS_GUNLOCK(); return EBUSY; } afs_globalVFS = afsp; afsp->vfs_bsize = 8192; - afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ - afsp->vfs_fsid.val[1] = AFS_VFSFSID; + afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ + afsp->vfs_fsid.val[1] = AFS_VFSFSID; afsp->vfs_dev = AFS_VFSMAGIC; AFS_GUNLOCK(); @@ -63,9 +65,11 @@ int afs_mount(struct vfs *afsp, struct vnode *amvp, struct mounta *uap, } #if defined(AFS_SUN58_ENV) -int afs_unmount (struct vfs *afsp, int flag, struct AFS_UCRED *credp) +int +afs_unmount(struct vfs *afsp, int flag, struct AFS_UCRED *credp) #else -int afs_unmount (struct vfs *afsp, struct AFS_UCRED *credp) +int +afs_unmount(struct vfs *afsp, struct AFS_UCRED *credp) #endif { AFS_GLOCK(); @@ -82,11 +86,12 @@ int afs_unmount (struct vfs *afsp, struct AFS_UCRED *credp) return 0; } -int afs_root (struct vfs *afsp, struct vnode **avpp) +int +afs_root(struct vfs *afsp, struct vnode **avpp) { register afs_int32 code = 0; struct vrequest treq; - register struct vcache *tvp=0; + register struct vcache *tvp = 0; struct proc *proc = ttoproc(curthread); struct vnode *vp = afsp->vfs_vnodecovered; int locked = 0; @@ -116,8 +121,8 @@ int afs_root (struct vfs *afsp, struct vnode **avpp) afs_globalVp = NULL; } - if (!(code = afs_InitReq(&treq, proc->p_cred)) && - !(code = afs_CheckInit())) { + if (!(code = afs_InitReq(&treq, proc->p_cred)) + && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); /* we really want this to stay around */ if (tvp) { @@ -153,9 +158,11 @@ int afs_root (struct vfs *afsp, struct vnode **avpp) } #ifdef AFS_SUN56_ENV -int afs_statvfs(struct vfs *afsp, struct statvfs64 *abp) +int +afs_statvfs(struct vfs *afsp, struct statvfs64 *abp) #else -int afs_statvfs(struct vfs *afsp, struct statvfs *abp) +int +afs_statvfs(struct vfs *afsp, struct statvfs *abp) #endif { AFS_GLOCK(); @@ -163,22 +170,24 @@ int afs_statvfs(struct vfs *afsp, struct statvfs *abp) AFS_STATCNT(afs_statfs); abp->f_frsize = 1024; - abp->f_favail = 9000000; + abp->f_favail = 9000000; abp->f_bsize = afsp->vfs_bsize; abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files = - abp->f_ffree = 9000000; + abp->f_ffree = 9000000; abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID; AFS_GUNLOCK(); return 0; } -int afs_sync(struct vfs *afsp, short flags, struct AFS_UCRED *credp) +int +afs_sync(struct vfs *afsp, short flags, struct AFS_UCRED *credp) { return 0; } -int afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp) +int +afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp) { cred_t *credp = CRED(); struct vrequest treq; @@ -190,7 +199,7 @@ int afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp) *avcp = NULL; if (!(code = afs_InitReq(&treq, credp))) { - code = afs_osi_vget((struct vcache**)avcp, fidp, &treq); + code = afs_osi_vget((struct vcache **)avcp, fidp, &treq); } afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp, @@ -204,7 +213,7 @@ int afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp) /* This is only called by vfs_mount when afs is going to be mounted as root. * Since we don't support diskless clients we shouldn't come here. */ -int afsmountroot=0; +int afsmountroot = 0; afs_mountroot(struct vfs *afsp, whymountroot_t why) { AFS_GLOCK(); @@ -217,7 +226,7 @@ afs_mountroot(struct vfs *afsp, whymountroot_t why) /* afs_swapvp is called to setup swapping over the net for diskless clients. * Again not for us. */ -int afsswapvp=0; +int afsswapvp = 0; afs_swapvp(struct vfs *afsp, struct vnode **avpp, char *nm) { AFS_GLOCK(); @@ -246,13 +255,13 @@ struct vfsops Afs_vfsops = { /* * afsinit - intialize VFS */ -int (*ufs_iallocp)(); -void (*ufs_iupdatp)(); -int (*ufs_igetp)(); -void (*ufs_itimes_nolockp)(); +int (*ufs_iallocp) (); +void (*ufs_iupdatp) (); +int (*ufs_igetp) (); +void (*ufs_itimes_nolockp) (); -int (*afs_orig_ioctl)(), (*afs_orig_ioctl32)(); -int (*afs_orig_setgroups)(), (*afs_orig_setgroups32)(); +int (*afs_orig_ioctl) (), (*afs_orig_ioctl32) (); +int (*afs_orig_setgroups) (), (*afs_orig_setgroups32) (); struct streamtab *udp_infop = 0; struct ill_s *ill_g_headp = 0; @@ -260,12 +269,12 @@ struct ill_s *ill_g_headp = 0; int afs_sinited = 0; #if !defined(AFS_NONFSTRANS) -int (*nfs_rfsdisptab_v2)(); -int (*nfs_rfsdisptab_v3)(); -int (*nfs_acldisptab_v2)(); -int (*nfs_acldisptab_v3)(); +int (*nfs_rfsdisptab_v2) (); +int (*nfs_rfsdisptab_v3) (); +int (*nfs_acldisptab_v2) (); +int (*nfs_acldisptab_v3) (); -int (*nfs_checkauth)(); +int (*nfs_checkauth) (); #endif extern Afs_syscall(); @@ -294,45 +303,44 @@ afsinit(struct vfssw *vfsswp, int fstype) #if !defined(AFS_NONFSTRANS) - nfs_rfsdisptab_v2 = (int (*)()) modlookup("nfssrv", "rfsdisptab_v2"); - if ( !nfs_rfsdisptab_v2 ) { + nfs_rfsdisptab_v2 = (int (*)())modlookup("nfssrv", "rfsdisptab_v2"); + if (!nfs_rfsdisptab_v2) { afs_warn("warning : rfsdisptab_v2 NOT FOUND\n"); } if (nfs_rfsdisptab_v2) { - nfs_acldisptab_v2 = (int (*)()) modlookup("nfssrv", "acldisptab_v2"); - if ( !nfs_acldisptab_v2 ) { + nfs_acldisptab_v2 = (int (*)())modlookup("nfssrv", "acldisptab_v2"); + if (!nfs_acldisptab_v2) { afs_warn("warning : acldisptab_v2 NOT FOUND\n"); - } - else { + } else { afs_xlatorinit_v2(nfs_rfsdisptab_v2, nfs_acldisptab_v2); } } - nfs_rfsdisptab_v3 = (int (*)()) modlookup("nfssrv", "rfsdisptab_v3"); - if ( !nfs_rfsdisptab_v3 ) { + nfs_rfsdisptab_v3 = (int (*)())modlookup("nfssrv", "rfsdisptab_v3"); + if (!nfs_rfsdisptab_v3) { afs_warn("warning : rfsdisptab_v3 NOT FOUND\n"); } if (nfs_rfsdisptab_v3) { - nfs_acldisptab_v3 = (int (*)()) modlookup("nfssrv", "acldisptab_v3"); - if ( !nfs_acldisptab_v3 ) { + nfs_acldisptab_v3 = (int (*)())modlookup("nfssrv", "acldisptab_v3"); + if (!nfs_acldisptab_v3) { afs_warn("warning : acldisptab_v3 NOT FOUND\n"); - } - else { + } else { afs_xlatorinit_v3(nfs_rfsdisptab_v3, nfs_acldisptab_v3); } } - nfs_checkauth = (int (*)()) modlookup("nfssrv", "checkauth"); - if ( !nfs_checkauth ) afs_warn("nfs_checkauth not initialised"); + nfs_checkauth = (int (*)())modlookup("nfssrv", "checkauth"); + if (!nfs_checkauth) + afs_warn("nfs_checkauth not initialised"); #endif - ufs_iallocp = (int (*)()) modlookup("ufs", "ufs_ialloc"); - ufs_iupdatp = (void (*)()) modlookup("ufs", "ufs_iupdat"); - ufs_igetp = (int (*)()) modlookup("ufs", "ufs_iget"); - ufs_itimes_nolockp = (void (*)()) modlookup("ufs", "ufs_itimes_nolock"); - udp_infop = (struct streamtab *) modlookup("udp", "udpinfo"); - ill_g_headp = (struct ill_s *) modlookup("ip", "ill_g_head"); - - if ( !ufs_iallocp || !ufs_iupdatp || !ufs_itimes_nolockp || - !ufs_igetp || !udp_infop || !ill_g_headp ) + ufs_iallocp = (int (*)())modlookup("ufs", "ufs_ialloc"); + ufs_iupdatp = (void (*)())modlookup("ufs", "ufs_iupdat"); + ufs_igetp = (int (*)())modlookup("ufs", "ufs_iget"); + ufs_itimes_nolockp = (void (*)())modlookup("ufs", "ufs_itimes_nolock"); + udp_infop = (struct streamtab *)modlookup("udp", "udpinfo"); + ill_g_headp = (struct ill_s *)modlookup("ip", "ill_g_head"); + + if (!ufs_iallocp || !ufs_iupdatp || !ufs_itimes_nolockp || !ufs_igetp + || !udp_infop || !ill_g_headp) afs_warn("AFS to UFS mapping cannot be fully initialised\n"); afs_sinited = 1; @@ -345,13 +353,13 @@ static struct vfssw afs_vfw = { afsinit, &Afs_vfsops, 0 - }; +}; static struct sysent afssysent = { 6, 0, Afs_syscall - }; +}; /* inter-module dependencies */ char _depends_on[] = "drv/ip drv/udp strmod/rpcmod"; @@ -366,13 +374,13 @@ static struct modlfs afsmodlfs = { &mod_fsops, "afs filesystem", &afs_vfw - }; +}; static struct modlsys afsmodlsys = { &mod_syscallops, "afs syscall interface", &afssysent - }; +}; /** The two structures afssysent32 and afsmodlsys32 are being added * for supporting 32 bit syscalls. In Solaris 7 there are two system @@ -402,7 +410,7 @@ static struct modlinkage afs_modlinkage = { #endif (void *)&afsmodlfs, NULL - }; +}; /** This is the function that modload calls when loading the afs kernel * extensions. The solaris modload program searches for the _init @@ -420,29 +428,38 @@ _init() if (afs_sinited) return EBUSY; - if ((!(mp = mod_find_by_filename("fs", "ufs")) && - !(mp = mod_find_by_filename(NULL, "/kernel/fs/ufs")) && - !(mp = mod_find_by_filename(NULL, "sys/ufs"))) || - (mp && !mp->mod_installed)) { - printf("ufs module must be loaded before loading afs; use modload /kernel/fs/ufs\n"); + if ((!(mp = mod_find_by_filename("fs", "ufs")) + && !(mp = mod_find_by_filename(NULL, "/kernel/fs/ufs")) + && !(mp = mod_find_by_filename(NULL, "sys/ufs"))) || (mp + && !mp-> + mod_installed)) + { + printf + ("ufs module must be loaded before loading afs; use modload /kernel/fs/ufs\n"); return (ENOSYS); } #ifndef AFS_NONFSTRANS #if defined(AFS_SUN55_ENV) - if ((!(mp = mod_find_by_filename("misc", "nfssrv")) && - !(mp = mod_find_by_filename(NULL, NFSSRV)) && - !(mp = mod_find_by_filename(NULL, NFSSRV_V9))) || - (mp && !mp->mod_installed)) { - printf("misc/nfssrv module must be loaded before loading afs with nfs-xlator\n"); - return (ENOSYS); + if ((!(mp = mod_find_by_filename("misc", "nfssrv")) + && !(mp = mod_find_by_filename(NULL, NFSSRV)) + && !(mp = mod_find_by_filename(NULL, NFSSRV_V9))) || (mp + && !mp-> + mod_installed)) + { + printf + ("misc/nfssrv module must be loaded before loading afs with nfs-xlator\n"); + return (ENOSYS); } #else /* !AFS_SUN55_ENV */ #if defined(AFS_SUN52_ENV) - if ((!(mp = mod_find_by_filename("fs", "nfs")) && - !(mp = mod_find_by_filename(NULL, "/kernel/fs/nfs")) && - !(mp = mod_find_by_filename(NULL, "sys/nfs"))) || - (mp && !mp->mod_installed)) { - printf("fs/nfs module must be loaded before loading afs with nfs-xlator\n"); + if ((!(mp = mod_find_by_filename("fs", "nfs")) + && !(mp = mod_find_by_filename(NULL, "/kernel/fs/nfs")) + && !(mp = mod_find_by_filename(NULL, "sys/nfs"))) || (mp + && !mp-> + mod_installed)) + { + printf + ("fs/nfs module must be loaded before loading afs with nfs-xlator\n"); return (ENOSYS); } #endif /* AFS_SUN52_ENV */ @@ -471,25 +488,25 @@ _init() if (sysent[AFS_SYSCALL].sy_call == nosys) { if ((sysn = mod_getsysname(AFS_SYSCALL)) != NULL) { sysent[AFS_SYSCALL].sy_lock = - (krwlock_t *) kobj_zalloc(sizeof (krwlock_t), KM_SLEEP); + (krwlock_t *) kobj_zalloc(sizeof(krwlock_t), KM_SLEEP); rw_init(sysent[AFS_SYSCALL].sy_lock, "afs_syscall", #ifdef AFS_SUN57_ENV RW_DEFAULT, NULL); #else /* !AFS_SUN57_ENV */ - RW_DEFAULT, DEFAULT_WT); + RW_DEFAULT, DEFAULT_WT); #endif /* AFS_SUN57_ENV */ } } #endif /* !AFS_SUN58_ENV */ - osi_Init(); /* initialize global lock, etc */ + osi_Init(); /* initialize global lock, etc */ code = mod_install(&afs_modlinkage); return code; } _info(modp) - struct modinfo *modp; + struct modinfo *modp; { int code; diff --git a/src/afs/SOLARIS/osi_vm.c b/src/afs/SOLARIS/osi_vm.c index d8a214bd5..f47321406 100644 --- a/src/afs/SOLARIS/osi_vm.c +++ b/src/afs/SOLARIS/osi_vm.c @@ -10,12 +10,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ -#include "afs/nfsclient.h" +#include "afs/afs_stats.h" /* statistics */ +#include "afs/nfsclient.h" #if defined(AFS_SUN5_ENV) /* This file contains Solaris VM-related code for the cache manager. */ @@ -42,15 +43,15 @@ RCSID("$Header$"); * * Locking: only the global lock is held on entry. */ -int osi_VM_GetDownD(struct vcache *avc, struct dcache *adc) +int +osi_VM_GetDownD(struct vcache *avc, struct dcache *adc) { int code; AFS_GUNLOCK(); - code = afs_putpage(AFSTOV(avc), - (offset_t) AFS_CHUNKTOBASE(adc->f.chunk), - AFS_CHUNKTOSIZE(adc->f.chunk), - B_INVAL, CRED()); + code = + afs_putpage(AFSTOV(avc), (offset_t) AFS_CHUNKTOBASE(adc->f.chunk), + AFS_CHUNKTOSIZE(adc->f.chunk), B_INVAL, CRED()); AFS_GLOCK(); return code; @@ -70,7 +71,8 @@ int osi_VM_GetDownD(struct vcache *avc, struct dcache *adc) * is not dropped and re-acquired for any platform. It may be that *slept is * therefore obsolescent. */ -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { if (avc->vrefCount != 0) return EBUSY; @@ -85,12 +87,12 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) return EBUSY; AFS_GUNLOCK(); - pvn_vplist_dirty(AFSTOV(avc), 0, NULL, B_TRUNC|B_INVAL, CRED()); + pvn_vplist_dirty(AFSTOV(avc), 0, NULL, B_TRUNC | B_INVAL, CRED()); AFS_GLOCK(); /* Might as well make the obvious check */ if (AFSTOV(avc)->v_pages) - return EBUSY; /* should be all gone still */ + return EBUSY; /* should be all gone still */ rw_destroy(&avc->rwlock); if (avc->credp) { @@ -107,14 +109,15 @@ int osi_VM_FlushVCache(struct vcache *avc, int *slept) * Locking: the vcache entry's lock is held. It will usually be dropped and * re-obtained. */ -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { AFS_GUNLOCK(); #if defined(AFS_SUN56_ENV) - (void) pvn_vplist_dirty(AFSTOV(avc), (u_offset_t)0, afs_putapage, - 0, CRED()); + (void)pvn_vplist_dirty(AFSTOV(avc), (u_offset_t) 0, afs_putapage, 0, + CRED()); #else - (void) pvn_vplist_dirty(AFSTOV(avc), 0, afs_putapage, 0, CRED()); + (void)pvn_vplist_dirty(AFSTOV(avc), 0, afs_putapage, 0, CRED()); #endif AFS_GLOCK(); } @@ -125,15 +128,16 @@ void osi_VM_StoreAllSegments(struct vcache *avc) * Locking: the vcache entry's lock is held. It may be dropped and * re-obtained. */ -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { AFS_GUNLOCK(); #if defined(AFS_SUN56_ENV) - (void) pvn_vplist_dirty(AFSTOV(avc), (u_offset_t)0, afs_putapage, - (sync ? B_INVAL : B_FREE), acred); + (void)pvn_vplist_dirty(AFSTOV(avc), (u_offset_t) 0, afs_putapage, + (sync ? B_INVAL : B_FREE), acred); #else - (void) pvn_vplist_dirty(AFSTOV(avc), 0, afs_putapage, - (sync ? B_INVAL : B_FREE), acred); + (void)pvn_vplist_dirty(AFSTOV(avc), 0, afs_putapage, + (sync ? B_INVAL : B_FREE), acred); #endif AFS_GLOCK(); } @@ -142,13 +146,13 @@ void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) * * Locking: No lock is held, not even the global lock. */ -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { extern int afs_pvn_vptrunc; afs_pvn_vptrunc++; - (void) afs_putpage(AFSTOV(avc), (offset_t)0, 0, - B_TRUNC|B_INVAL, credp); + (void)afs_putpage(AFSTOV(avc), (offset_t) 0, 0, B_TRUNC | B_INVAL, credp); } /* Zero no-longer-used part of last page, when truncating a file @@ -159,7 +163,8 @@ void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) * The caller will raise activeV (to prevent pageins), but this function must * be called first, since it causes a pagein. */ -void osi_VM_PreTruncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_PreTruncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { page_t *pp; int pageOffset = (alen & PAGEOFFSET); @@ -176,7 +181,7 @@ void osi_VM_PreTruncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) page_unlock(pp); } AFS_GLOCK(); - ObtainWriteLock(&avc->lock,563); + ObtainWriteLock(&avc->lock, 563); } /* Purge pages beyond end-of-file, when truncating a file. @@ -184,13 +189,14 @@ void osi_VM_PreTruncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) * Locking: no lock is held, not even the global lock. * Pageins are blocked (activeV is raised). */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { /* * It's OK to specify afs_putapage here, even though we aren't holding * the vcache entry lock, because it isn't going to get called. */ - pvn_vplist_dirty(AFSTOV(avc), alen, afs_putapage, B_TRUNC|B_INVAL, + pvn_vplist_dirty(AFSTOV(avc), alen, afs_putapage, B_TRUNC | B_INVAL, acred); } diff --git a/src/afs/SOLARIS/osi_vnodeops.c b/src/afs/SOLARIS/osi_vnodeops.c index 6d6b9b830..d495125c1 100644 --- a/src/afs/SOLARIS/osi_vnodeops.c +++ b/src/afs/SOLARIS/osi_vnodeops.c @@ -10,7 +10,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV) /* @@ -34,8 +35,8 @@ RCSID("$Header$"); */ #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ -#include "afs/nfsclient.h" +#include "afs/afs_stats.h" /* statistics */ +#include "afs/nfsclient.h" #include @@ -47,7 +48,7 @@ RCSID("$Header$"); #include #include #include -#if defined(AFS_SUN5_ENV) +#if defined(AFS_SUN5_ENV) #include #include #else @@ -100,9 +101,9 @@ afs_fc2errno(faultcode_t fc) } -extern struct as kas; /* kernel addr space */ -extern unsigned char *afs_indexFlags; -extern afs_lock_t afs_xdcache; +extern struct as kas; /* kernel addr space */ +extern unsigned char *afs_indexFlags; +extern afs_lock_t afs_xdcache; /* Additional vnodeops for SunOS 4.0.x */ int afs_nfsrdwr(), afs_getpage(), afs_putpage(), afs_map(); @@ -112,35 +113,38 @@ int afs_pvn_vptrunc; #ifdef AFS_SUN5_ENV -int afs_addmap(avp, offset, asp, addr, length, prot, maxprot, flags, credp) - register struct vnode *avp; - offset_t offset; - struct as *asp; - caddr_t addr; - int length, prot, maxprot, flags; - struct AFS_UCRED *credp; +int +afs_addmap(avp, offset, asp, addr, length, prot, maxprot, flags, credp) + register struct vnode *avp; + offset_t offset; + struct as *asp; + caddr_t addr; + int length, prot, maxprot, flags; + struct AFS_UCRED *credp; { /* XXX What should we do here?? XXX */ return (0); } -int afs_delmap(avp, offset, asp, addr, length, prot, maxprot, flags, credp) - register struct vnode *avp; - offset_t offset; - struct as *asp; - caddr_t addr; - int length, prot, maxprot, flags; - struct AFS_UCRED *credp; +int +afs_delmap(avp, offset, asp, addr, length, prot, maxprot, flags, credp) + register struct vnode *avp; + offset_t offset; + struct as *asp; + caddr_t addr; + int length, prot, maxprot, flags; + struct AFS_UCRED *credp; { /* XXX What should we do here?? XXX */ return (0); } -int afs_vmread(avp, auio, ioflag, acred) - register struct vnode *avp; - struct uio *auio; - int ioflag; - struct AFS_UCRED *acred; +int +afs_vmread(avp, auio, ioflag, acred) + register struct vnode *avp; + struct uio *auio; + int ioflag; + struct AFS_UCRED *acred; { register int code; @@ -153,11 +157,12 @@ int afs_vmread(avp, auio, ioflag, acred) } -int afs_vmwrite(avp, auio, ioflag, acred) - register struct vnode *avp; - struct uio *auio; - int ioflag; - struct AFS_UCRED *acred; +int +afs_vmwrite(avp, auio, ioflag, acred) + register struct vnode *avp; + struct uio *auio; + int ioflag; + struct AFS_UCRED *acred; { register int code; @@ -169,24 +174,25 @@ int afs_vmwrite(avp, auio, ioflag, acred) return code; } -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ -int afs_getpage(vp, off, len, protp, pl, plsz, seg, addr, rw, acred) -struct vnode *vp; -u_int len; -u_int *protp; -struct page *pl[]; -u_int plsz; -struct seg *seg; +int +afs_getpage(vp, off, len, protp, pl, plsz, seg, addr, rw, acred) + struct vnode *vp; + u_int len; + u_int *protp; + struct page *pl[]; + u_int plsz; + struct seg *seg; #ifdef AFS_SUN5_ENV -offset_t off; -caddr_t addr; + offset_t off; + caddr_t addr; #else -u_int off; -addr_t addr; + u_int off; + addr_t addr; #endif -enum seg_rw rw; -struct AFS_UCRED *acred; + enum seg_rw rw; + struct AFS_UCRED *acred; { register afs_int32 code = 0; AFS_STATCNT(afs_getpage); @@ -200,17 +206,18 @@ struct AFS_UCRED *acred; #if defined(AFS_SUN56_ENV) if (len <= PAGESIZE) - code = afs_GetOnePage(vp, off, len, protp, pl, plsz, - seg, addr, rw, acred); + code = + afs_GetOnePage(vp, off, len, protp, pl, plsz, seg, addr, rw, + acred); #else #ifdef AFS_SUN5_ENV if (len <= PAGESIZE) - code = afs_GetOnePage(vp, (u_int)off, len, protp, pl, plsz, - seg, addr, rw, acred); + code = + afs_GetOnePage(vp, (u_int) off, len, protp, pl, plsz, seg, addr, + rw, acred); #else if (len == PAGESIZE) - code = afs_GetOnePage(vp, off, protp, pl, plsz, - seg, addr, rw, acred); + code = afs_GetOnePage(vp, off, protp, pl, plsz, seg, addr, rw, acred); #endif #endif else { @@ -222,11 +229,13 @@ struct AFS_UCRED *acred; #endif afs_BozonLock(&vcp->pvnLock, vcp); #if defined(AFS_SUN56_ENV) - code = pvn_getpages(afs_GetOnePage, vp, off, - len, protp, pl, plsz, seg, addr, rw, acred); + code = + pvn_getpages(afs_GetOnePage, vp, off, len, protp, pl, plsz, seg, + addr, rw, acred); #else - code = pvn_getpages(afs_GetOnePage, vp, (u_int)off, - len, protp, pl, plsz, seg, addr, rw, acred); + code = + pvn_getpages(afs_GetOnePage, vp, (u_int) off, len, protp, pl, + plsz, seg, addr, rw, acred); #endif afs_BozonUnlock(&vcp->pvnLock, vcp); #ifdef AFS_SUN5_ENV @@ -241,28 +250,30 @@ struct AFS_UCRED *acred; /* Return all the pages from [off..off+len) in file */ #ifdef AFS_SUN5_ENV -int afs_GetOnePage(vp, off, alen, protp, pl, plsz, seg, addr, rw, acred) -u_int alen; +int +afs_GetOnePage(vp, off, alen, protp, pl, plsz, seg, addr, rw, acred) + u_int alen; #else -int afs_GetOnePage(vp, off, protp, pl, plsz, seg, addr, rw, acred) +int +afs_GetOnePage(vp, off, protp, pl, plsz, seg, addr, rw, acred) #endif -struct vnode *vp; + struct vnode *vp; #if defined(AFS_SUN56_ENV) -u_offset_t off; + u_offset_t off; #else -u_int off; + u_int off; #endif -u_int *protp; -struct page *pl[]; -u_int plsz; -struct seg *seg; + u_int *protp; + struct page *pl[]; + u_int plsz; + struct seg *seg; #ifdef AFS_SUN5_ENV -caddr_t addr; + caddr_t addr; #else -addr_t addr; + addr_t addr; #endif -enum seg_rw rw; -struct AFS_UCRED *acred; + enum seg_rw rw; + struct AFS_UCRED *acred; { register struct page *page; register afs_int32 code = 0; @@ -275,28 +286,30 @@ struct AFS_UCRED *acred; int slot; afs_size_t offset, nlen; struct vrequest treq; - afs_int32 mapForRead = 0, Code=0; + afs_int32 mapForRead = 0, Code = 0; #if defined(AFS_SUN56_ENV) - u_offset_t toffset; + u_offset_t toffset; #else - afs_int32 toffset; + afs_int32 toffset; #endif - if (!acred) + if (!acred) #ifdef AFS_SUN5_ENV osi_Panic("GetOnePage: !acred"); #else - acred = u.u_cred; /* better than nothing */ + acred = u.u_cred; /* better than nothing */ #endif - avc = VTOAFS(vp); /* cast to afs vnode */ + avc = VTOAFS(vp); /* cast to afs vnode */ #ifdef AFS_SUN5_ENV - if (avc->credp /*&& AFS_NFSXLATORREQ(acred)*/ && AFS_NFSXLATORREQ(avc->credp)) { + if (avc->credp /*&& AFS_NFSXLATORREQ(acred) */ + && AFS_NFSXLATORREQ(avc->credp)) { acred = avc->credp; } #endif - if (code = afs_InitReq(&treq, acred)) return code; + if (code = afs_InitReq(&treq, acred)) + return code; if (!pl) { /* This is a read-ahead request, e.g. due to madvise. */ @@ -309,8 +322,11 @@ struct AFS_UCRED *acred; while (plen > 0 && !afs_BBusy()) { /* Obtain a dcache entry at off. 2 means don't fetch data. */ - tdc = afs_GetDCache(avc, (afs_offs_t)off, &treq, &offset, &nlen, 2); - if (!tdc) break; + tdc = + afs_GetDCache(avc, (afs_offs_t) off, &treq, &offset, &nlen, + 2); + if (!tdc) + break; /* Write-lock the dcache entry, if we don't succeed, just go on */ if (0 != NBObtainWriteLock(&tdc->lock, 642)) { @@ -338,13 +354,14 @@ struct AFS_UCRED *acred; afs_PutDCache(tdc); } -next_prefetch: + next_prefetch: /* Adjust our offset and remaining length values */ off += nlen; plen -= nlen; /* If we aren't making progress for some reason, bail out */ - if (nlen <= 0) break; + if (nlen <= 0) + break; } ReleaseReadLock(&avc->lock); @@ -352,7 +369,7 @@ next_prefetch: } len = PAGESIZE; - pl[0] = NULL; /* Make sure it's empty */ + pl[0] = NULL; /* Make sure it's empty */ /* first, obtain the proper lock for the VM system */ @@ -363,44 +380,46 @@ next_prefetch: * pages for the range covered by a chunk when we swap out the * chunk. */ - if (rw == S_READ || rw == S_EXEC) + if (rw == S_READ || rw == S_EXEC) mapForRead = 1; - if (protp) *protp = PROT_ALL; + if (protp) + *protp = PROT_ALL; #ifndef AFS_SUN5_ENV if (AFS_NFSXLATORREQ(acred)) { if (rw == S_READ) { - if (!afs_AccessOK(avc, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) { + if (!afs_AccessOK + (avc, PRSFS_READ, &treq, + CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) { return EACCES; } } } #endif -retry: + retry: #ifdef AFS_SUN5_ENV if (rw == S_WRITE || rw == S_CREATE) - tdc = afs_GetDCache(avc, (afs_offs_t)off, &treq, &offset, &nlen, 5); + tdc = afs_GetDCache(avc, (afs_offs_t) off, &treq, &offset, &nlen, 5); else - tdc = afs_GetDCache(avc, (afs_offs_t)off, &treq, &offset, &nlen, 1); - if (!tdc) return EINVAL; + tdc = afs_GetDCache(avc, (afs_offs_t) off, &treq, &offset, &nlen, 1); + if (!tdc) + return EINVAL; #endif code = afs_VerifyVCache(avc, &treq); if (code) { #ifdef AFS_SUN5_ENV afs_PutDCache(tdc); -#endif - return afs_CheckCode(code, &treq, 44); /* failed to get it */ +#endif + return afs_CheckCode(code, &treq, 44); /* failed to get it */ } afs_BozonLock(&avc->pvnLock, avc); ObtainReadLock(&avc->lock); afs_Trace4(afs_iclSetp, CM_TRACE_PAGEIN, ICL_TYPE_POINTER, (afs_int32) vp, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(off), - ICL_TYPE_LONG, len, - ICL_TYPE_LONG, (int) rw); + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(off), ICL_TYPE_LONG, len, + ICL_TYPE_LONG, (int)rw); tlen = len; slot = 0; @@ -410,10 +429,10 @@ retry: * the locks and try again when the VM purge is done. */ ObtainWriteLock(&avc->vlock, 550); if (avc->activeV) { - ReleaseReadLock(&avc->lock); - ReleaseWriteLock(&avc->vlock); + ReleaseReadLock(&avc->lock); + ReleaseWriteLock(&avc->vlock); afs_BozonUnlock(&avc->pvnLock, avc); - afs_PutDCache(tdc); + afs_PutDCache(tdc); /* Check activeV again, it may have been turned off * while we were waiting for a lock in afs_PutDCache */ ObtainWriteLock(&avc->vlock, 574); @@ -426,7 +445,7 @@ retry: } goto retry; } - ReleaseWriteLock(&avc->vlock); + ReleaseWriteLock(&avc->vlock); #endif /* We're about to do stuff with our dcache entry.. Lock it. */ @@ -436,22 +455,23 @@ retry: if (!(avc->states & CStatd) || !hsame(avc->m.DataVersion, tdc->f.versionNo)) { ReleaseReadLock(&tdc->lock); - ReleaseReadLock(&avc->lock); + ReleaseReadLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); afs_PutDCache(tdc); goto retry; } AFS_GUNLOCK(); - while (1) { /* loop over all pages */ + while (1) { /* loop over all pages */ /* now, try to find the page in memory (it may already be intransit or laying - around the free list */ - page = page_lookup( vp, toffset, (rw == S_CREATE ? SE_EXCL : SE_SHARED) ); - if (page) + * around the free list */ + page = + page_lookup(vp, toffset, (rw == S_CREATE ? SE_EXCL : SE_SHARED)); + if (page) goto nextpage; /* if we make it here, we can't find the page in memory. Do a real disk read - from the cache to get the data */ + * from the cache to get the data */ Code |= 0x200; /* XXX */ #ifdef AFS_SUN5_ENV #if defined(AFS_SUN54_ENV) @@ -461,9 +481,13 @@ retry: * in case someone tries to relax all the serialization of read and write * operations with harmless things like stat. */ #if defined(AFS_SUN58_ENV) - page = page_create_va(vp, toffset, PAGESIZE, PG_WAIT|PG_EXCL, seg, addr); + page = + page_create_va(vp, toffset, PAGESIZE, PG_WAIT | PG_EXCL, seg, + addr); #else - page = page_create_va(vp, toffset, PAGESIZE, PG_WAIT|PG_EXCL, seg->s_as, addr); + page = + page_create_va(vp, toffset, PAGESIZE, PG_WAIT | PG_EXCL, + seg->s_as, addr); #endif #else page = page_create(vp, toffset, PAGESIZE, PG_WAIT); @@ -472,37 +496,40 @@ retry: continue; } if (alen < PAGESIZE) - pagezero(page, alen, PAGESIZE-alen); + pagezero(page, alen, PAGESIZE - alen); #else page = rm_allocpage(seg, addr, PAGESIZE, 1); /* can't fail */ - if (!page) osi_Panic("afs_getpage alloc page"); + if (!page) + osi_Panic("afs_getpage alloc page"); /* we get a circularly-linked list of pages back, but we expect only - one, since that's what we asked for */ - if (page->p_next != page) osi_Panic("afs_getpage list"); + * one, since that's what we asked for */ + if (page->p_next != page) + osi_Panic("afs_getpage list"); /* page enter returns a locked page; we'll drop the lock as a side-effect - of the pvn_done done by afs_ustrategy. If we decide not to call - strategy, we must be sure to call pvn_fail, at least, to release the - page locks and otherwise reset the pages. The page, while locked, is - not held, for what it is worth */ + * of the pvn_done done by afs_ustrategy. If we decide not to call + * strategy, we must be sure to call pvn_fail, at least, to release the + * page locks and otherwise reset the pages. The page, while locked, is + * not held, for what it is worth */ page->p_intrans = 1; /* set appropriate flags */ page->p_pagein = 1; /* next call shouldn't fail, since we have pvnLock set */ - if (page_enter(page, vp, toffset)) osi_Panic("afs_getpage enter race"); -#endif /* AFS_SUN5_ENV */ + if (page_enter(page, vp, toffset)) + osi_Panic("afs_getpage enter race"); +#endif /* AFS_SUN5_ENV */ #ifdef AFS_SUN5_ENV - if (rw == S_CREATE) { + if (rw == S_CREATE) { /* XXX Don't read from AFS in write only cases XXX */ page_io_unlock(page); - } else + } else #else if (0) { /* XXX Don't read from AFS in write only cases XXX */ page->p_intrans = page->p_pagein = 0; page_unlock(page); /* XXX */ - } else + } else #endif - { + { #ifndef AFS_SUN5_ENV PAGE_HOLD(page); #endif @@ -513,7 +540,7 @@ retry: #endif buf->b_dev = 0; buf->b_blkno = btodb(toffset); - bp_mapin(buf); /* map it in to our address space */ + bp_mapin(buf); /* map it in to our address space */ #if defined(AFS_SUN5_ENV) AFS_GLOCK(); @@ -552,9 +579,9 @@ retry: #ifdef AFS_SUN5_ENV /* The p_selock must be downgraded to a shared lock after the page is read */ #if defined(AFS_SUN56_ENV) - if ((rw != S_CREATE) && !(PAGE_SHARED(page))) + if ((rw != S_CREATE) && !(PAGE_SHARED(page))) #else - if ((rw != S_CREATE) && !(se_shared_assert(&page->p_selock))) + if ((rw != S_CREATE) && !(se_shared_assert(&page->p_selock))) #endif { page_downgrade(page); @@ -568,8 +595,9 @@ retry: toffset += PAGESIZE; addr += PAGESIZE; tlen -= PAGESIZE; - if (tlen <= 0) break; /* done all the pages */ - } /* while (1) ... */ + if (tlen <= 0) + break; /* done all the pages */ + } /* while (1) ... */ AFS_GLOCK(); pl[slot] = NULL; @@ -583,7 +611,7 @@ retry: ReleaseReadLock(&avc->lock); #ifdef AFS_SUN5_ENV - ObtainWriteLock(&afs_xdcache,246); + ObtainWriteLock(&afs_xdcache, 246); if (!mapForRead) { /* track that we have dirty (or dirty-able) pages for this chunk. */ afs_indexFlags[tdc->index] |= IFDirtyPages; @@ -595,20 +623,20 @@ retry: #ifdef AFS_SUN5_ENV afs_PutDCache(tdc); #endif - afs_Trace3(afs_iclSetp, CM_TRACE_PAGEINDONE, ICL_TYPE_LONG, code, ICL_TYPE_LONG, (int)page, - ICL_TYPE_LONG, Code); + afs_Trace3(afs_iclSetp, CM_TRACE_PAGEINDONE, ICL_TYPE_LONG, code, + ICL_TYPE_LONG, (int)page, ICL_TYPE_LONG, Code); return 0; bad: AFS_GLOCK(); - afs_Trace3(afs_iclSetp, CM_TRACE_PAGEINDONE, ICL_TYPE_LONG, code, ICL_TYPE_LONG, (int)page, - ICL_TYPE_LONG, Code); + afs_Trace3(afs_iclSetp, CM_TRACE_PAGEINDONE, ICL_TYPE_LONG, code, + ICL_TYPE_LONG, (int)page, ICL_TYPE_LONG, Code); /* release all pages, drop locks, return code */ #ifdef AFS_SUN5_ENV - if (page) + if (page) pvn_read_done(page, B_ERROR); #else - for(i=0; ilock); @@ -621,12 +649,13 @@ retry: } #ifdef AFS_SUN5_ENV -int afs_putpage(vp, off, len, flags, cred) - struct vnode *vp; - offset_t off; - u_int len; - int flags; - struct AFS_UCRED *cred; +int +afs_putpage(vp, off, len, flags, cred) + struct vnode *vp; + offset_t off; + u_int len; + int flags; + struct AFS_UCRED *cred; { struct vcache *avc; struct page *pages; @@ -637,7 +666,7 @@ int afs_putpage(vp, off, len, flags, cred) afs_int32 tlen; #endif afs_offs_t endPos; - afs_int32 NPages=0; + afs_int32 NPages = 0; #if defined(AFS_SUN56_ENV) u_offset_t toff = off; #else @@ -646,35 +675,35 @@ int afs_putpage(vp, off, len, flags, cred) int didWriteLock; AFS_STATCNT(afs_putpage); - if (vp->v_flag & VNOMAP) /* file doesn't allow mapping */ + if (vp->v_flag & VNOMAP) /* file doesn't allow mapping */ return (ENOSYS); /* * Putpage (ASYNC) is called every sec to flush out dirty vm pages */ AFS_GLOCK(); - afs_Trace4(afs_iclSetp, CM_TRACE_PAGEOUT, ICL_TYPE_POINTER, (afs_int32) vp, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(off), - ICL_TYPE_INT32, (afs_int32) len, - ICL_TYPE_LONG, (int) flags); + afs_Trace4(afs_iclSetp, CM_TRACE_PAGEOUT, ICL_TYPE_POINTER, + (afs_int32) vp, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(off), + ICL_TYPE_INT32, (afs_int32) len, ICL_TYPE_LONG, (int)flags); avc = VTOAFS(vp); afs_BozonLock(&avc->pvnLock, avc); - ObtainSharedLock(&avc->lock,247); + ObtainSharedLock(&avc->lock, 247); didWriteLock = 0; /* Get a list of modified (or whatever) pages */ if (len) { - endPos = (afs_offs_t)off + len; /* position we're supposed to write up to */ - while ((afs_offs_t)toff < endPos && (afs_offs_t)toff < avc->m.Length) { + endPos = (afs_offs_t) off + len; /* position we're supposed to write up to */ + while ((afs_offs_t) toff < endPos + && (afs_offs_t) toff < avc->m.Length) { /* If not invalidating pages use page_lookup_nowait to avoid reclaiming * them from the free list */ AFS_GUNLOCK(); - if (flags & (B_FREE|B_INVAL)) + if (flags & (B_FREE | B_INVAL)) pages = page_lookup(vp, toff, SE_EXCL); else pages = page_lookup_nowait(vp, toff, SE_SHARED); - if (!pages || !pvn_getdirty(pages, flags)) + if (!pages || !pvn_getdirty(pages, flags)) tlen = PAGESIZE; else { if (!didWriteLock) { @@ -700,10 +729,10 @@ int afs_putpage(vp, off, len, flags, cred) } AFS_GUNLOCK(); -#if defined(AFS_SUN56_ENV) +#if defined(AFS_SUN56_ENV) code = pvn_vplist_dirty(vp, toff, afs_putapage, flags, cred); #else - code = pvn_vplist_dirty(vp, (u_int)off, afs_putapage, flags, cred); + code = pvn_vplist_dirty(vp, (u_int) off, afs_putapage, flags, cred); #endif AFS_GLOCK(); } @@ -721,30 +750,32 @@ int afs_putpage(vp, off, len, flags, cred) else ReleaseSharedLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); - afs_Trace2(afs_iclSetp, CM_TRACE_PAGEOUTDONE, ICL_TYPE_LONG, code, ICL_TYPE_LONG, NPages); + afs_Trace2(afs_iclSetp, CM_TRACE_PAGEOUTDONE, ICL_TYPE_LONG, code, + ICL_TYPE_LONG, NPages); AFS_GUNLOCK(); return (code); } -int afs_putapage(struct vnode *vp, struct page *pages, +int +afs_putapage(struct vnode *vp, struct page *pages, #if defined(AFS_SUN56_ENV) - u_offset_t *offp, + u_offset_t * offp, #else - u_int *offp, + u_int * offp, #endif #if defined(AFS_SUN58_ENV) - size_t *lenp, + size_t * lenp, #else - u_int *lenp, + u_int * lenp, #endif - int flags, struct AFS_UCRED *credp) + int flags, struct AFS_UCRED *credp) { struct buf *tbuf; struct vcache *avc = VTOAFS(vp); afs_int32 code = 0; u_int tlen = PAGESIZE; - afs_offs_t off = (pages->p_offset/PAGESIZE)*PAGESIZE; + afs_offs_t off = (pages->p_offset / PAGESIZE) * PAGESIZE; /* * Now we've got the modified pages. All pages are locked and held @@ -755,7 +786,7 @@ int afs_putapage(struct vnode *vp, struct page *pages, tlen = avc->m.Length - off; } /* can't call mapout with 0 length buffers (rmfree panics) */ - if (((tlen>>24)&0xff) == 0xff) { + if (((tlen >> 24) & 0xff) == 0xff) { tlen = 0; } if ((int)tlen > 0) { @@ -763,38 +794,41 @@ int afs_putapage(struct vnode *vp, struct page *pages, * Can't call mapout with 0 length buffers since we'll get rmfree panics */ tbuf = pageio_setup(pages, tlen, vp, B_WRITE | flags); - if (!tbuf) return (ENOMEM); + if (!tbuf) + return (ENOMEM); tbuf->b_dev = 0; tbuf->b_blkno = btodb(pages->p_offset); bp_mapin(tbuf); AFS_GLOCK(); - afs_Trace4(afs_iclSetp, CM_TRACE_PAGEOUTONE, ICL_TYPE_LONG, avc, - ICL_TYPE_LONG, pages, - ICL_TYPE_LONG, tlen, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(off)); + afs_Trace4(afs_iclSetp, CM_TRACE_PAGEOUTONE, ICL_TYPE_LONG, avc, + ICL_TYPE_LONG, pages, ICL_TYPE_LONG, tlen, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(off)); code = afs_ustrategy(tbuf, credp); /* unlocks page */ AFS_GUNLOCK(); bp_mapout(tbuf); } - pvn_write_done(pages, ((code) ? B_ERROR:0) | B_WRITE | flags); + pvn_write_done(pages, ((code) ? B_ERROR : 0) | B_WRITE | flags); if ((int)tlen > 0) pageio_done(tbuf); - if (offp) *offp = off; - if (lenp) *lenp = tlen; + if (offp) + *offp = off; + if (lenp) + *lenp = tlen; return code; } -#else AFS_SUN5_ENV +#else /* AFS_SUN5_ENV */ -int afs_putpage(vp, off, len, flags, cred) -struct vnode *vp; -u_int off; -u_int len; -int flags; -struct AFS_UCRED *cred; +int +afs_putpage(vp, off, len, flags, cred) + struct vnode *vp; + u_int off; + u_int len; + int flags; + struct AFS_UCRED *cred; { - int wholeEnchilada; /* true if we must get all of the pages */ + int wholeEnchilada; /* true if we must get all of the pages */ struct vcache *avc; struct page *pages; struct page *tpage; @@ -805,44 +839,49 @@ struct AFS_UCRED *cred; afs_int32 clusterStart, clusterEnd, endPos; /* In the wholeEnchilada case, we must ensure that we get all of the pages - from the system, since we're doing this to shutdown the use of a vnode */ + * from the system, since we're doing this to shutdown the use of a vnode */ AFS_STATCNT(afs_putpage); - wholeEnchilada = (off == 0 && len == 0 && (flags & (B_INVAL|B_ASYNC)) == B_INVAL); + wholeEnchilada = (off == 0 && len == 0 + && (flags & (B_INVAL | B_ASYNC)) == B_INVAL); avc = VTOAFS(vp); afs_BozonLock(&avc->pvnLock, avc); - ObtainWriteLock(&avc->lock,248); + ObtainWriteLock(&avc->lock, 248); while (1) { /* in whole enchilada case, loop until call to pvn_getdirty can't find - any more modified pages */ + * any more modified pages */ /* first we try to get a list of modified (or whatever) pages */ if (len == 0) { pages = pvn_vplist_dirty(vp, off, flags); - } - else { + } else { endPos = off + len; /* position we're supposed to write up to */ - if (endPos > avc->m.Length) endPos = avc->m.Length; /* bound by this */ - clusterStart = off & ~(PAGESIZE-1); /* round down to nearest page */ - clusterEnd = ((endPos-1) | (PAGESIZE-1))+1; /* round up to nearest page */ - pages = pvn_range_dirty(vp, off, endPos, clusterStart, clusterEnd, flags); + if (endPos > avc->m.Length) + endPos = avc->m.Length; /* bound by this */ + clusterStart = off & ~(PAGESIZE - 1); /* round down to nearest page */ + clusterEnd = ((endPos - 1) | (PAGESIZE - 1)) + 1; /* round up to nearest page */ + pages = + pvn_range_dirty(vp, off, endPos, clusterStart, clusterEnd, + flags); } - + /* Now we've got the modified pages. All pages are locked and held */ rcode = 0; /* return code */ - while(pages) { /* look over all pages in the returned set */ + while (pages) { /* look over all pages in the returned set */ tpage = pages; /* get first page in the list */ /* write out the page */ poffset = tpage->p_offset; /* where the page starts in the file */ /* tlen will represent the end of the range to write, for a while */ - tlen = PAGESIZE+poffset; /* basic place to end tpage write */ + tlen = PAGESIZE + poffset; /* basic place to end tpage write */ /* but we also don't want to write past end of off..off+len range */ - if (len != 0 && tlen > off+len) tlen = off+len; + if (len != 0 && tlen > off + len) + tlen = off + len; /* and we don't want to write past the end of the file */ - if (tlen > avc->m.Length) tlen = avc->m.Length; + if (tlen > avc->m.Length) + tlen = avc->m.Length; /* and we don't want to write at all if page starts after end */ if (poffset >= tlen) { pvn_fail(pages, B_WRITE | flags); @@ -853,28 +892,29 @@ struct AFS_UCRED *cred; page_sub(&pages, tpage); /* remove tpage from "pages" list */ tbuf = pageio_setup(tpage, tlen, vp, B_WRITE | flags); if (!tbuf) { - pvn_fail(tpage, B_WRITE|flags); - pvn_fail(pages, B_WRITE|flags); + pvn_fail(tpage, B_WRITE | flags); + pvn_fail(pages, B_WRITE | flags); goto done; } tbuf->b_dev = 0; tbuf->b_blkno = btodb(tpage->p_offset); bp_mapin(tbuf); ReleaseWriteLock(&avc->lock); /* can't hold during strategy call */ - code = afs_ustrategy(tbuf); /* unlocks page */ - ObtainWriteLock(&avc->lock,249); /* re-obtain */ + code = afs_ustrategy(tbuf); /* unlocks page */ + ObtainWriteLock(&avc->lock, 249); /* re-obtain */ if (code) { /* unlocking of tpage is done by afs_ustrategy */ rcode = code; if (pages) /* may have already removed last page */ - pvn_fail(pages, B_WRITE|flags); + pvn_fail(pages, B_WRITE | flags); goto done; } - } /* for (tpage=pages....) */ + } /* for (tpage=pages....) */ /* see if we've gotten all of the pages in the whole enchilada case */ - if (!wholeEnchilada || !vp->v_pages) break; - } /* while(1) obtaining all pages */ + if (!wholeEnchilada || !vp->v_pages) + break; + } /* while(1) obtaining all pages */ /* * If low on chunks, and if writing the last byte of a chunk, try to @@ -882,14 +922,15 @@ struct AFS_UCRED *cred; * calls afs_putpage, so this is recursion. It stops there because we * insist on len being non-zero. */ - if (afs_stats_cmperf.cacheCurrDirtyChunks > afs_stats_cmperf.cacheMaxDirtyChunks - && len != 0 && AFS_CHUNKOFFSET((off + len)) == 0) { + if (afs_stats_cmperf.cacheCurrDirtyChunks > + afs_stats_cmperf.cacheMaxDirtyChunks && len != 0 + && AFS_CHUNKOFFSET((off + len)) == 0) { struct vrequest treq; if (!afs_InitReq(&treq, cred ? cred : u.u_cred)) { rcode = afs_DoPartialWrite(avc, &treq); /* XXX */ } } - + done: if (rcode && !avc->vc_error) @@ -901,14 +942,15 @@ struct AFS_UCRED *cred; return rcode; } -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ -int afs_nfsrdwr(avc, auio, arw, ioflag, acred) -register struct vcache *avc; -struct uio *auio; -enum uio_rw arw; -int ioflag; -struct AFS_UCRED *acred; +int +afs_nfsrdwr(avc, auio, arw, ioflag, acred) + register struct vcache *avc; + struct uio *auio; + enum uio_rw arw; + int ioflag; + struct AFS_UCRED *acred; { register afs_int32 code; afs_int32 code2; @@ -919,10 +961,10 @@ struct AFS_UCRED *acred; afs_size_t fileBase, size; afs_size_t pageBase; register afs_int32 tsize; - register afs_int32 pageOffset, extraResid=0; - register afs_size_t origLength; /* length when reading/writing started */ - register long appendLength; /* length when this call will finish */ - int created; /* created pages instead of faulting them */ + register afs_int32 pageOffset, extraResid = 0; + register afs_size_t origLength; /* length when reading/writing started */ + register long appendLength; /* length when this call will finish */ + int created; /* created pages instead of faulting them */ int lockCode; int didFakeOpen, eof; struct vrequest treq; @@ -932,36 +974,40 @@ struct AFS_UCRED *acred; AFS_STATCNT(afs_nfsrdwr); /* can't read or write other things */ - if (vType(avc) != VREG) return EISDIR; + if (vType(avc) != VREG) + return EISDIR; if (auio->uio_resid == 0) return (0); - afs_Trace4(afs_iclSetp, CM_TRACE_VMRW, ICL_TYPE_POINTER, (afs_int32)avc, - ICL_TYPE_LONG, (arw==UIO_WRITE? 1 : 0), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(auio->uio_offset), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(auio->uio_resid)); + afs_Trace4(afs_iclSetp, CM_TRACE_VMRW, ICL_TYPE_POINTER, (afs_int32) avc, + ICL_TYPE_LONG, (arw == UIO_WRITE ? 1 : 0), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(auio->uio_offset), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(auio->uio_resid)); #ifndef AFS_64BIT_CLIENT - if ( AfsLargeFileUio(auio) ) /* file is larger than 2 GB */ + if (AfsLargeFileUio(auio)) /* file is larger than 2 GB */ return (EFBIG); #endif - + #ifdef AFS_SUN5_ENV - if (!acred) osi_Panic("rdwr: !acred"); + if (!acred) + osi_Panic("rdwr: !acred"); #else - if (!acred) acred = u.u_cred; + if (!acred) + acred = u.u_cred; #endif - if (code = afs_InitReq(&treq, acred)) return code; + if (code = afs_InitReq(&treq, acred)) + return code; /* It's not really possible to know if a write cause a growth in the * cache size, we we wait for a cache drain for any write. */ afs_MaybeWakeupTruncateDaemon(); - while ((arw == UIO_WRITE) && - (afs_blocksUsed > (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100)) { + while ((arw == UIO_WRITE) + && (afs_blocksUsed > (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100)) { if (afs_blocksUsed - afs_blocksDiscarded > - (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100) { + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) { afs_WaitForCacheDrain = 1; afs_osi_Sleep(&afs_WaitForCacheDrain); } @@ -969,60 +1015,59 @@ struct AFS_UCRED *acred; afs_MaybeWakeupTruncateDaemon(); } code = afs_VerifyVCache(avc, &treq); - if (code) return afs_CheckCode(code, &treq, 45); + if (code) + return afs_CheckCode(code, &treq, 45); afs_BozonLock(&avc->pvnLock, avc); osi_FlushPages(avc, acred); /* hold bozon lock, but not basic vnode lock */ - ObtainWriteLock(&avc->lock,250); + ObtainWriteLock(&avc->lock, 250); /* adjust parameters when appending files */ - if ((ioflag & IO_APPEND) && arw == UIO_WRITE) - { + if ((ioflag & IO_APPEND) && arw == UIO_WRITE) { #if defined(AFS_SUN56_ENV) auio->uio_loffset = 0; #endif auio->uio_offset = avc->m.Length; /* write at EOF position */ } if (auio->uio_offset < 0 || (auio->uio_offset + auio->uio_resid) < 0) { - ReleaseWriteLock(&avc->lock); + ReleaseWriteLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); return EINVAL; } - #ifndef AFS_64BIT_CLIENT - /* file is larger than 2GB */ - if ( AfsLargeFileSize(auio->uio_offset, auio->uio_resid) ) { - ReleaseWriteLock(&avc->lock); + /* file is larger than 2GB */ + if (AfsLargeFileSize(auio->uio_offset, auio->uio_resid)) { + ReleaseWriteLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); return EFBIG; } #endif - didFakeOpen=0; /* keep track of open so we can do close */ + didFakeOpen = 0; /* keep track of open so we can do close */ if (arw == UIO_WRITE) { /* do ulimit processing; shrink resid or fail */ #if defined(AFS_SUN56_ENV) if (auio->uio_loffset + auio->afsio_resid > auio->uio_llimit) { if (auio->uio_llimit >= auio->uio_llimit) { - ReleaseWriteLock(&avc->lock); - afs_BozonUnlock(&avc->pvnLock, avc); - return EFBIG; - } else { - /* track # of bytes we should write, but won't because of - * ulimit; we must add this into the final resid value - * so caller knows we punted some data. - */ - extraResid = auio->uio_resid; - auio->uio_resid = auio->uio_llimit - auio->uio_loffset; - extraResid -= auio->uio_resid; - } - } + ReleaseWriteLock(&avc->lock); + afs_BozonUnlock(&avc->pvnLock, avc); + return EFBIG; + } else { + /* track # of bytes we should write, but won't because of + * ulimit; we must add this into the final resid value + * so caller knows we punted some data. + */ + extraResid = auio->uio_resid; + auio->uio_resid = auio->uio_llimit - auio->uio_loffset; + extraResid -= auio->uio_resid; + } + } #else -#ifdef AFS_SUN52_ENV +#ifdef AFS_SUN52_ENV if (auio->afsio_offset + auio->afsio_resid > auio->uio_limit) { if (auio->afsio_offset >= auio->uio_limit) { - ReleaseWriteLock(&avc->lock); + ReleaseWriteLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); return EFBIG; } else { @@ -1039,33 +1084,33 @@ struct AFS_UCRED *acred; #endif /* SUN56 */ mode = S_WRITE; /* segment map-in mode */ afs_FakeOpen(avc); /* do this for writes, so data gets put back - when we want it to be put back */ + * when we want it to be put back */ didFakeOpen = 1; /* we'll be doing a fake open */ /* before starting any I/O, we must ensure that the file is big enough - to hold the results (since afs_putpage will be called to force the I/O */ + * to hold the results (since afs_putpage will be called to force the I/O */ size = auio->afsio_resid + auio->afsio_offset; /* new file size */ - appendLength = size; + appendLength = size; origLength = avc->m.Length; if (size > avc->m.Length) { - afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_LONG, __LINE__, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(size)); + afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_LONG, __LINE__, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(size)); avc->m.Length = size; /* file grew */ } - avc->states |= CDirty; /* Set the dirty bit */ + avc->states |= CDirty; /* Set the dirty bit */ avc->m.Date = osi_Time(); /* Set file date (for ranlib) */ } else { - mode = S_READ; /* map-in read-only */ + mode = S_READ; /* map-in read-only */ origLength = avc->m.Length; } if (acred && AFS_NFSXLATORREQ(acred)) { if (arw == UIO_READ) { - if (!afs_AccessOK(avc, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) { - ReleaseWriteLock(&avc->lock); + if (!afs_AccessOK + (avc, PRSFS_READ, &treq, + CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) { + ReleaseWriteLock(&avc->lock); afs_BozonUnlock(&avc->pvnLock, avc); return EACCES; } @@ -1078,59 +1123,59 @@ struct AFS_UCRED *acred; avc->credp = acred; #endif } - counter = 0; /* don't call afs_DoPartialWrite first time through. */ + counter = 0; /* don't call afs_DoPartialWrite first time through. */ while (1) { /* compute the amount of data to move into this block, - based on auio->afsio_resid. Note that we copy data in units of - MAXBSIZE, not PAGESIZE. This is because segmap_getmap panics if you - call it with an offset based on blocks smaller than MAXBSIZE - (implying that it should be named BSIZE, since it is clearly both a - max and a min). */ - size = auio->afsio_resid; /* transfer size */ - fileBase = auio->afsio_offset; /* start file position for xfr */ - pageBase = fileBase & ~(MAXBSIZE-1); /* file position of the page */ - pageOffset = fileBase & (MAXBSIZE-1); /* xfr start's offset within page */ - tsize = MAXBSIZE-pageOffset; /* how much more fits in this page */ + * based on auio->afsio_resid. Note that we copy data in units of + * MAXBSIZE, not PAGESIZE. This is because segmap_getmap panics if you + * call it with an offset based on blocks smaller than MAXBSIZE + * (implying that it should be named BSIZE, since it is clearly both a + * max and a min). */ + size = auio->afsio_resid; /* transfer size */ + fileBase = auio->afsio_offset; /* start file position for xfr */ + pageBase = fileBase & ~(MAXBSIZE - 1); /* file position of the page */ + pageOffset = fileBase & (MAXBSIZE - 1); /* xfr start's offset within page */ + tsize = MAXBSIZE - pageOffset; /* how much more fits in this page */ /* we'll read tsize bytes, but first must make sure tsize isn't too big */ - if (tsize > size) tsize = size; /* don't read past end of request */ - eof = 0; /* flag telling us if we hit the EOF on the read */ - if (arw == UIO_READ) { /* we're doing a read operation */ + if (tsize > size) + tsize = size; /* don't read past end of request */ + eof = 0; /* flag telling us if we hit the EOF on the read */ + if (arw == UIO_READ) { /* we're doing a read operation */ /* don't read past EOF */ if (fileBase + tsize > origLength) { tsize = origLength - fileBase; - eof = 1; /* we did hit the EOF */ - if (tsize < 0) tsize = 0; /* better safe than sorry */ + eof = 1; /* we did hit the EOF */ + if (tsize < 0) + tsize = 0; /* better safe than sorry */ } sflags = 0; - } - else { + } else { #ifdef AFS_SUN5_ENV /* Purge dirty chunks of file if there are too many dirty * chunks. Inside the write loop, we only do this at a chunk * boundary. Clean up partial chunk if necessary at end of loop. */ - if (counter > 0 && code == 0 && AFS_CHUNKOFFSET(fileBase) == 0) - { - code = afs_DoPartialWrite(avc, &treq); - if (code) - break; - } -#endif /* AFS_SUN5_ENV */ + if (counter > 0 && code == 0 && AFS_CHUNKOFFSET(fileBase) == 0) { + code = afs_DoPartialWrite(avc, &treq); + if (code) + break; + } +#endif /* AFS_SUN5_ENV */ /* write case, we ask segmap_release to call putpage. Really, we - don't have to do this on every page mapin, but for now we're - lazy, and don't modify the rest of AFS to scan for modified - pages on a close or other "synchronize with file server" - operation. This makes things a little cleaner, but probably - hurts performance. */ + * don't have to do this on every page mapin, but for now we're + * lazy, and don't modify the rest of AFS to scan for modified + * pages on a close or other "synchronize with file server" + * operation. This makes things a little cleaner, but probably + * hurts performance. */ sflags = SM_WRITE; } if (tsize <= 0) { code = 0; - break; /* nothing to transfer, we're done */ + break; /* nothing to transfer, we're done */ } #ifdef AFS_SUN5_ENV if (arw == UIO_WRITE) - avc->states |= CDirty; /* may have been cleared by DoPartialWrite*/ + avc->states |= CDirty; /* may have been cleared by DoPartialWrite */ /* Before dropping lock, hold the chunk (create it if necessary). This * serves two purposes: (1) Ensure Cache Truncate Daemon doesn't try @@ -1157,7 +1202,7 @@ struct AFS_UCRED *acred; afs_size_t toff, tlen; dcp = afs_GetDCache(avc, fileBase, &treq, &toff, &tlen, 2); if (!dcp) { - code = ENOENT; + code = ENOENT; break; } } @@ -1165,30 +1210,32 @@ struct AFS_UCRED *acred; ReleaseWriteLock(&avc->lock); /* uiomove may page fault */ AFS_GUNLOCK(); #if defined(AFS_SUN56_ENV) - data = segmap_getmap(segkmap,AFSTOV(avc),(u_offset_t)pageBase); + data = segmap_getmap(segkmap, AFSTOV(avc), (u_offset_t) pageBase); #else data = segmap_getmap(segkmap, AFSTOV(avc), pageBase); #endif #ifndef AFS_SUN5_ENV - code = afs_fc2errno(as_fault(&kas, data+pageOffset, tsize, - F_SOFTLOCK, mode)); + code = + afs_fc2errno(as_fault + (&kas, data + pageOffset, tsize, F_SOFTLOCK, mode)); if (code == 0) { - AFS_UIOMOVE(data+pageOffset, tsize, arw, auio, code); - as_fault(&kas, data+pageOffset, tsize, F_SOFTUNLOCK, mode); + AFS_UIOMOVE(data + pageOffset, tsize, arw, auio, code); + as_fault(&kas, data + pageOffset, tsize, F_SOFTUNLOCK, mode); code2 = segmap_release(segkmap, data, sflags); if (!code) code = code2; - } - else { - (void) segmap_release(segkmap, data, 0); + } else { + (void)segmap_release(segkmap, data, 0); } #else #if defined(AFS_SUN56_ENV) - raddr = (caddr_t) (((uintptr_t)data +pageOffset) & PAGEMASK); + raddr = (caddr_t) (((uintptr_t) data + pageOffset) & PAGEMASK); #else - raddr = (caddr_t) (((u_int)data +pageOffset) & PAGEMASK); + raddr = (caddr_t) (((u_int) data + pageOffset) & PAGEMASK); #endif - rsize = (((u_int)data+pageOffset+tsize+PAGEOFFSET) & PAGEMASK)-(u_int)raddr; + rsize = + (((u_int) data + pageOffset + tsize + PAGEOFFSET) & PAGEMASK) - + (u_int) raddr; if (code == 0) { /* if we're doing a write, and we're starting at the rounded * down page base, and we're writing enough data to cover all @@ -1196,9 +1243,8 @@ struct AFS_UCRED *acred; * in this MAXBSIZE window that we're creating. */ created = 0; - if (arw == UIO_WRITE - && ((long)raddr == (long)data+pageOffset) - && tsize >= rsize) { + if (arw == UIO_WRITE && ((long)raddr == (long)data + pageOffset) + && tsize >= rsize) { /* probably the dcache backing this guy is around, but if * not, we can't do this optimization, since we're creating * writable pages, which must be backed by a chunk. @@ -1207,8 +1253,8 @@ struct AFS_UCRED *acred; dcp_newpage = afs_FindDCache(avc, pageBase); if (dcp_newpage && hsame(avc->m.DataVersion, dcp_newpage->f.versionNo)) { - ObtainWriteLock(&avc->lock,251); - ObtainWriteLock(&avc->vlock,576); + ObtainWriteLock(&avc->lock, 251); + ObtainWriteLock(&avc->vlock, 576); ObtainReadLock(&dcp_newpage->lock); if ((avc->activeV == 0) && hsame(avc->m.DataVersion, dcp_newpage->f.versionNo) @@ -1216,56 +1262,58 @@ struct AFS_UCRED *acred; AFS_GUNLOCK(); segmap_pagecreate(segkmap, raddr, rsize, 1); AFS_GLOCK(); - ObtainWriteLock(&afs_xdcache,252); + ObtainWriteLock(&afs_xdcache, 252); /* Mark the pages as created and dirty */ afs_indexFlags[dcp_newpage->index] |= (IFAnyPages | IFDirtyPages); - ReleaseWriteLock(&afs_xdcache); + ReleaseWriteLock(&afs_xdcache); created = 1; } ReleaseReadLock(&dcp_newpage->lock); afs_PutDCache(dcp_newpage); ReleaseWriteLock(&avc->vlock); ReleaseWriteLock(&avc->lock); - } - else if ( dcp_newpage ) + } else if (dcp_newpage) afs_PutDCache(dcp_newpage); AFS_GUNLOCK(); } if (!created) - code = afs_fc2errno(segmap_fault(kas.a_hat, segkmap, raddr, - rsize, F_SOFTLOCK, mode)); + code = + afs_fc2errno(segmap_fault + (kas.a_hat, segkmap, raddr, rsize, + F_SOFTLOCK, mode)); } if (code == 0) { - AFS_UIOMOVE(data+pageOffset, tsize, arw, auio, code); - segmap_fault(kas.a_hat, segkmap, raddr, rsize, F_SOFTUNLOCK, mode); + AFS_UIOMOVE(data + pageOffset, tsize, arw, auio, code); + segmap_fault(kas.a_hat, segkmap, raddr, rsize, F_SOFTUNLOCK, + mode); } if (code == 0) { code = segmap_release(segkmap, data, sflags); } else { - (void) segmap_release(segkmap, data, 0); + (void)segmap_release(segkmap, data, 0); } -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ AFS_GLOCK(); - ObtainWriteLock(&avc->lock,253); + ObtainWriteLock(&avc->lock, 253); #ifdef AFS_SUN5_ENV counter++; - if (dcp) - afs_PutDCache(dcp); -#endif /* AFS_SUN5_ENV */ - if (code) break; + if (dcp) + afs_PutDCache(dcp); +#endif /* AFS_SUN5_ENV */ + if (code) + break; } if (didFakeOpen) { afs_FakeClose(avc, acred); } - #ifdef AFS_SUN5_ENV if (arw == UIO_WRITE && (avc->states & CDirty)) { code2 = afs_DoPartialWrite(avc, &treq); if (!code) code = code2; } -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ if (!code && avc->vc_error) { code = avc->vc_error; @@ -1274,7 +1322,8 @@ struct AFS_UCRED *acred; afs_BozonUnlock(&avc->pvnLock, avc); if (!code) { #ifdef AFS_SUN53_ENV - if ((ioflag & FSYNC) && (arw == UIO_WRITE) && !AFS_NFSXLATORREQ(acred)) + if ((ioflag & FSYNC) && (arw == UIO_WRITE) + && !AFS_NFSXLATORREQ(acred)) code = afs_fsync(avc, 0, acred); #else if ((ioflag & IO_SYNC) && (arw == UIO_WRITE) @@ -1282,7 +1331,7 @@ struct AFS_UCRED *acred; code = afs_fsync(avc, acred); #endif } -#ifdef AFS_SUN52_ENV +#ifdef AFS_SUN52_ENV /* * If things worked, add in as remaining in request any bytes * we didn't write due to file size ulimit. @@ -1294,114 +1343,114 @@ struct AFS_UCRED *acred; } afs_map(vp, off, as, addr, len, prot, maxprot, flags, cred) -struct vnode *vp; -struct as *as; + struct vnode *vp; + struct as *as; #ifdef AFS_SUN5_ENV -offset_t off; -caddr_t *addr; + offset_t off; + caddr_t *addr; #else -u_int off; -addr_t *addr; + u_int off; + addr_t *addr; #endif -u_int len; + u_int len; #ifdef AFS_SUN5_ENV -u_char prot, maxprot; + u_char prot, maxprot; #else -u_int prot, maxprot; + u_int prot, maxprot; #endif -u_int flags; -struct AFS_UCRED *cred; + u_int flags; + struct AFS_UCRED *cred; { - struct segvn_crargs crargs; - register afs_int32 code; - struct vrequest treq; - register struct vcache *avc = VTOAFS(vp); + struct segvn_crargs crargs; + register afs_int32 code; + struct vrequest treq; + register struct vcache *avc = VTOAFS(vp); - AFS_STATCNT(afs_map); + AFS_STATCNT(afs_map); - /* check for reasonableness on segment bounds; apparently len can be < 0 */ - if (off < 0 || off + len < 0) { - return (EINVAL); - } + /* check for reasonableness on segment bounds; apparently len can be < 0 */ + if (off < 0 || off + len < 0) { + return (EINVAL); + } #ifndef AFS_64BIT_CLIENT - if ( AfsLargeFileSize(off, len) ) /* file is larger than 2 GB */ - { - code = EFBIG; - goto out; - } + if (AfsLargeFileSize(off, len)) { /* file is larger than 2 GB */ + code = EFBIG; + goto out; + } #endif #if defined(AFS_SUN5_ENV) - if (vp->v_flag & VNOMAP) /* File isn't allowed to be mapped */ - return (ENOSYS); + if (vp->v_flag & VNOMAP) /* File isn't allowed to be mapped */ + return (ENOSYS); - if (vp->v_filocks) /* if locked, disallow mapping */ - return (EAGAIN); + if (vp->v_filocks) /* if locked, disallow mapping */ + return (EAGAIN); #endif - AFS_GLOCK(); - if (code = afs_InitReq(&treq, cred)) goto out; + AFS_GLOCK(); + if (code = afs_InitReq(&treq, cred)) + goto out; - if (vp->v_type != VREG) { - code = ENODEV; - goto out; - } + if (vp->v_type != VREG) { + code = ENODEV; + goto out; + } - code = afs_VerifyVCache(avc, &treq); - if (code) { - goto out; - } - afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc, cred); /* ensure old pages are gone */ - avc->states |= CMAPPED; /* flag cleared at afs_inactive */ - afs_BozonUnlock(&avc->pvnLock, avc); + code = afs_VerifyVCache(avc, &treq); + if (code) { + goto out; + } + afs_BozonLock(&avc->pvnLock, avc); + osi_FlushPages(avc, cred); /* ensure old pages are gone */ + avc->states |= CMAPPED; /* flag cleared at afs_inactive */ + afs_BozonUnlock(&avc->pvnLock, avc); - AFS_GUNLOCK(); + AFS_GUNLOCK(); #ifdef AFS_SUN5_ENV - as_rangelock(as); + as_rangelock(as); #endif - if ((flags & MAP_FIXED) == 0) { + if ((flags & MAP_FIXED) == 0) { #if defined(AFS_SUN57_ENV) - map_addr(addr, len, off, 1, flags); + map_addr(addr, len, off, 1, flags); #elif defined(AFS_SUN56_ENV) - map_addr(addr, len, off, 1); + map_addr(addr, len, off, 1); #else - map_addr(addr, len, (off_t)off, 1); + map_addr(addr, len, (off_t) off, 1); #endif - if (*addr == NULL) { + if (*addr == NULL) { #ifdef AFS_SUN5_ENV - as_rangeunlock(as); + as_rangeunlock(as); #endif - code = ENOMEM; - goto out1; - } - } else - (void) as_unmap(as, *addr, len); /* unmap old address space use */ - /* setup the create parameter block for the call */ - crargs.vp = AFSTOV(avc); - crargs.offset = (u_int)off; - crargs.cred = cred; - crargs.type = flags&MAP_TYPE; - crargs.prot = prot; - crargs.maxprot = maxprot; - crargs.amp = (struct anon_map *) 0; + code = ENOMEM; + goto out1; + } + } else + (void)as_unmap(as, *addr, len); /* unmap old address space use */ + /* setup the create parameter block for the call */ + crargs.vp = AFSTOV(avc); + crargs.offset = (u_int) off; + crargs.cred = cred; + crargs.type = flags & MAP_TYPE; + crargs.prot = prot; + crargs.maxprot = maxprot; + crargs.amp = (struct anon_map *)0; #if defined(AFS_SUN5_ENV) - crargs.flags = flags & ~MAP_TYPE; + crargs.flags = flags & ~MAP_TYPE; #endif - code = as_map(as, *addr, len, segvn_create, (char *) &crargs); + code = as_map(as, *addr, len, segvn_create, (char *)&crargs); #ifdef AFS_SUN5_ENV - as_rangeunlock(as); + as_rangeunlock(as); #endif -out1: - AFS_GLOCK(); - code = afs_CheckCode(code, &treq, 47); - AFS_GUNLOCK(); - return code; -out: - code = afs_CheckCode(code, &treq, 48); - AFS_GUNLOCK(); - return code; + out1: + AFS_GLOCK(); + code = afs_CheckCode(code, &treq, 47); + AFS_GUNLOCK(); + return code; + out: + code = afs_CheckCode(code, &treq, 48); + AFS_GUNLOCK(); + return code; } /* Sun 4.0.X-specific code. It computes the number of bytes that need @@ -1410,16 +1459,19 @@ out: will be passed to pvn_vptrunc by the truncate code */ #ifndef AFS_SUN5_ENV /* Not good for Solaris */ afs_PageLeft(alen) -register afs_int32 alen; { + register afs_int32 alen; +{ register afs_int32 nbytes; AFS_STATCNT(afs_PageLeft); - nbytes = PAGESIZE - (alen & PAGEOFFSET); /* amount to zap in last page */ + nbytes = PAGESIZE - (alen & PAGEOFFSET); /* amount to zap in last page */ /* now check if we'd zero the entire last page. Don't need to do this - since pvn_vptrunc will handle this case properly (it will invalidate - this page) */ - if (nbytes == PAGESIZE) nbytes = 0; - if (nbytes < 0) nbytes = 0; /* just in case */ + * since pvn_vptrunc will handle this case properly (it will invalidate + * this page) */ + if (nbytes == PAGESIZE) + nbytes = 0; + if (nbytes < 0) + nbytes = 0; /* just in case */ return nbytes; } #endif @@ -1431,45 +1483,45 @@ register afs_int32 alen; { */ #if defined(AFS_SUN5_ENV) afs_pathconf(vp, cmd, outdatap, credp) - register struct AFS_UCRED *credp; + register struct AFS_UCRED *credp; #else afs_cntl(vp, cmd, indatap, outdatap, inflag, outflag) - int inflag, outflag; - char *indatap; + int inflag, outflag; + char *indatap; #endif - struct vnode *vp; - int cmd; - u_long *outdatap; + struct vnode *vp; + int cmd; + u_long *outdatap; { AFS_STATCNT(afs_cntl); switch (cmd) { - case _PC_LINK_MAX: + case _PC_LINK_MAX: *outdatap = MAXLINK; break; - case _PC_NAME_MAX: + case _PC_NAME_MAX: *outdatap = MAXNAMLEN; break; - case _PC_PATH_MAX: + case _PC_PATH_MAX: *outdatap = MAXPATHLEN; break; - case _PC_CHOWN_RESTRICTED: + case _PC_CHOWN_RESTRICTED: *outdatap = 1; break; - case _PC_NO_TRUNC: + case _PC_NO_TRUNC: *outdatap = 1; break; #if !defined(AFS_SUN5_ENV) - case _PC_MAX_CANON: + case _PC_MAX_CANON: *outdatap = CANBSIZ; break; - case _PC_VDISABLE: + case _PC_VDISABLE: *outdatap = VDISABLE; break; - case _PC_PIPE_BUF: + case _PC_PIPE_BUF: return EINVAL; break; #endif - default: + default: return EINVAL; } return 0; @@ -1480,25 +1532,27 @@ afs_cntl(vp, cmd, indatap, outdatap, inflag, outflag) #if defined(AFS_SUN5_ENV) afs_ioctl(vnp, com, arg, flag, credp, rvalp) - struct vnode *vnp; - int com, arg, flag; - cred_t *credp; - int *rvalp; + struct vnode *vnp; + int com, arg, flag; + cred_t *credp; + int *rvalp; { return (ENOTTY); } -void afs_rwlock(vnp, wlock) - struct vnode *vnp; - int wlock; +void +afs_rwlock(vnp, wlock) + struct vnode *vnp; + int wlock; { rw_enter(&(VTOAFS(vnp))->rwlock, (wlock ? RW_WRITER : RW_READER)); } -void afs_rwunlock(vnp, wlock) - struct vnode *vnp; - int wlock; +void +afs_rwunlock(vnp, wlock) + struct vnode *vnp; + int wlock; { rw_exit(&(VTOAFS(vnp))->rwlock); } @@ -1506,9 +1560,9 @@ void afs_rwunlock(vnp, wlock) /* NOT SUPPORTED */ afs_seek(vnp, ooff, noffp) - struct vnode *vnp; - offset_t ooff; - offset_t *noffp; + struct vnode *vnp; + offset_t ooff; + offset_t *noffp; { register int code = 0; @@ -1517,24 +1571,25 @@ afs_seek(vnp, ooff, noffp) return code; } -int afs_frlock(vnp, cmd, ap, flag, off, +int +afs_frlock(vnp, cmd, ap, flag, off, #ifdef AFS_SUN59_ENV - flkcb, + flkcb, #endif - credp) - struct vnode *vnp; - int cmd; + credp) + struct vnode *vnp; + int cmd; #if defined(AFS_SUN56_ENV) - struct flock64 *ap; + struct flock64 *ap; #else - struct flock *ap; + struct flock *ap; #endif - int flag; - offset_t off; + int flag; + offset_t off; #ifdef AFS_SUN59_ENV - struct flk_callback *flkcb; + struct flk_callback *flkcb; #endif - struct AFS_UCRED *credp; + struct AFS_UCRED *credp; { register afs_int32 code = 0; /* @@ -1545,7 +1600,8 @@ int afs_frlock(vnp, cmd, ap, flag, off, if (flkcb) afs_warn("Don't know how to deal with flk_callback's!\n"); #endif - if ((cmd == F_GETLK) || (cmd == F_O_GETLK) || (cmd == F_SETLK) || (cmd == F_SETLKW)) { + if ((cmd == F_GETLK) || (cmd == F_O_GETLK) || (cmd == F_SETLK) + || (cmd == F_SETLKW)) { #ifdef AFS_SUN53_ENV ap->l_pid = ttoproc(curthread)->p_pid; ap->l_sysid = 0; @@ -1558,9 +1614,10 @@ int afs_frlock(vnp, cmd, ap, flag, off, #ifdef AFS_SUN56_ENV code = convoff(vnp, ap, 0, off); #else - code = convoff(vnp, ap, 0, (off_t)off); + code = convoff(vnp, ap, 0, (off_t) off); #endif - if (code) return code; + if (code) + return code; AFS_GLOCK(); } @@ -1570,17 +1627,18 @@ int afs_frlock(vnp, cmd, ap, flag, off, } -int afs_space(vnp, cmd, ap, flag, off, credp) - struct vnode *vnp; - int cmd; +int +afs_space(vnp, cmd, ap, flag, off, credp) + struct vnode *vnp; + int cmd; #if defined(AFS_SUN56_ENV) - struct flock64 *ap; + struct flock64 *ap; #else - struct flock *ap; + struct flock *ap; #endif - int flag; - offset_t off; - struct AFS_UCRED *credp; + int flag; + offset_t off; + struct AFS_UCRED *credp; { register afs_int32 code = EINVAL; struct vattr vattr; @@ -1589,14 +1647,14 @@ int afs_space(vnp, cmd, ap, flag, off, credp) #ifdef AFS_SUN56_ENV && ((code = convoff(vnp, ap, 0, off)) == 0)) { #else - && ((code = convoff(vnp, ap, 0, (off_t)off)) == 0)) { + && ((code = convoff(vnp, ap, 0, (off_t) off)) == 0)) { #endif AFS_GLOCK(); if (!ap->l_len) { vattr.va_mask = AT_SIZE; vattr.va_size = ap->l_start; code = afs_setattr(VTOAFS(vnp), &vattr, 0, credp); - } + } AFS_GUNLOCK(); } return (code); @@ -1605,10 +1663,11 @@ int afs_space(vnp, cmd, ap, flag, off, credp) #endif -int afs_dump(vp, addr, i1, i2) -struct vnode *vp; -caddr_t addr; -int i1, i2; +int +afs_dump(vp, addr, i1, i2) + struct vnode *vp; + caddr_t addr; + int i1, i2; { AFS_STATCNT(afs_dump); afs_warn("AFS_DUMP. MUST IMPLEMENT THIS!!!\n"); @@ -1617,40 +1676,44 @@ int i1, i2; /* Nothing fancy here; just compare if vnodes are identical ones */ -afs_cmp(vp1, vp2) -struct vnode *vp1, *vp2; +afs_cmp(vp1, vp2) + struct vnode *vp1, *vp2; { AFS_STATCNT(afs_cmp); - return(vp1 == vp2); + return (vp1 == vp2); } -int afs_realvp(struct vnode *vp, struct vnode **vpp) { +int +afs_realvp(struct vnode *vp, struct vnode **vpp) +{ AFS_STATCNT(afs_realvp); return EINVAL; } -int afs_pageio(vp, pp, ui1, ui2, i1, credp) -struct vnode *vp; -struct page *pp; -u_int ui1, ui2; -int i1; -struct cred *credp; +int +afs_pageio(vp, pp, ui1, ui2, i1, credp) + struct vnode *vp; + struct page *pp; + u_int ui1, ui2; + int i1; + struct cred *credp; { afs_warn("afs_pageio: Not implemented\n"); return EINVAL; } -int afs_dumpctl(vp, i +int +afs_dumpctl(vp, i #ifdef AFS_SUN59_ENV - , blkp + , blkp #endif - ) -struct vnode *vp; -int i; + ) + struct vnode *vp; + int i; #ifdef AFS_SUN59_ENV -int *blkp; + int *blkp; #endif { afs_warn("afs_dumpctl: Not implemented\n"); @@ -1658,29 +1721,32 @@ int *blkp; } #ifdef AFS_SUN54_ENV -extern void afs_dispose(vp, p, fl, dn, cr) - struct vnode *vp; - struct page *p; - int fl, dn; - struct cred *cr; +extern void +afs_dispose(vp, p, fl, dn, cr) + struct vnode *vp; + struct page *p; + int fl, dn; + struct cred *cr; { fs_dispose(vp, p, fl, dn, cr); } -int afs_setsecattr(vp, vsecattr, flag, creds) -struct vnode *vp; -vsecattr_t *vsecattr; -int flag; -struct cred *creds; +int +afs_setsecattr(vp, vsecattr, flag, creds) + struct vnode *vp; + vsecattr_t *vsecattr; + int flag; + struct cred *creds; { return ENOSYS; } -int afs_getsecattr(vp, vsecattr, flag, creds) -struct vnode *vp; -vsecattr_t *vsecattr; -int flag; -struct cred *creds; +int +afs_getsecattr(vp, vsecattr, flag, creds) + struct vnode *vp; + vsecattr_t *vsecattr; + int flag; + struct cred *creds; { return fs_fab_acl(vp, vsecattr, flag, creds); } @@ -1696,52 +1762,52 @@ extern int afs_lockctl(); extern void gafs_inactive(); struct vnodeops Afs_vnodeops = { - gafs_open, - gafs_close, - afs_vmread, - afs_vmwrite, - afs_ioctl, - fs_setfl, - gafs_getattr, - gafs_setattr, - gafs_access, - gafs_lookup, - gafs_create, - gafs_remove, - gafs_link, - gafs_rename, - gafs_mkdir, - gafs_rmdir, - gafs_readdir, - gafs_symlink, - gafs_readlink, - gafs_fsync, - gafs_inactive, - gafs_fid, - afs_rwlock, - afs_rwunlock, - afs_seek, - afs_cmp, - afs_frlock, - afs_space, - afs_realvp, - afs_getpage, - afs_putpage, - afs_map, - afs_addmap, - afs_delmap, - fs_poll, - afs_dump, - afs_pathconf, - afs_pageio, - afs_dumpctl, + gafs_open, + gafs_close, + afs_vmread, + afs_vmwrite, + afs_ioctl, + fs_setfl, + gafs_getattr, + gafs_setattr, + gafs_access, + gafs_lookup, + gafs_create, + gafs_remove, + gafs_link, + gafs_rename, + gafs_mkdir, + gafs_rmdir, + gafs_readdir, + gafs_symlink, + gafs_readlink, + gafs_fsync, + gafs_inactive, + gafs_fid, + afs_rwlock, + afs_rwunlock, + afs_seek, + afs_cmp, + afs_frlock, + afs_space, + afs_realvp, + afs_getpage, + afs_putpage, + afs_map, + afs_addmap, + afs_delmap, + fs_poll, + afs_dump, + afs_pathconf, + afs_pageio, + afs_dumpctl, #ifdef AFS_SUN54_ENV - afs_dispose, - afs_setsecattr, - afs_getsecattr, + afs_dispose, + afs_setsecattr, + afs_getsecattr, #endif #if defined(AFS_SUN56_ENV) - fs_shrlock, + fs_shrlock, #endif }; struct vnodeops *afs_ops = &Afs_vnodeops; @@ -1749,9 +1815,9 @@ struct vnodeops *afs_ops = &Afs_vnodeops; gafs_open(avcp, aflags, acred) - register struct vcache **avcp; - afs_int32 aflags; - struct AFS_UCRED *acred; + register struct vcache **avcp; + afs_int32 aflags; + struct AFS_UCRED *acred; { register int code; @@ -1763,11 +1829,11 @@ gafs_open(avcp, aflags, acred) gafs_close(avc, aflags, count, offset, acred) - offset_t offset; - int count; - register struct vcache *avc; - afs_int32 aflags; - struct AFS_UCRED *acred; + offset_t offset; + int count; + register struct vcache *avc; + afs_int32 aflags; + struct AFS_UCRED *acred; { register int code; @@ -1779,10 +1845,10 @@ gafs_close(avc, aflags, count, offset, acred) gafs_getattr(avc, attrs, flags, acred) - int flags; - register struct vcache *avc; - register struct vattr *attrs; - struct AFS_UCRED *acred; + int flags; + register struct vcache *avc; + register struct vattr *attrs; + struct AFS_UCRED *acred; { register int code; @@ -1794,10 +1860,10 @@ gafs_getattr(avc, attrs, flags, acred) gafs_setattr(avc, attrs, flags, acred) - int flags; - register struct vcache *avc; - register struct vattr *attrs; - struct AFS_UCRED *acred; + int flags; + register struct vcache *avc; + register struct vattr *attrs; + struct AFS_UCRED *acred; { register int code; @@ -1809,10 +1875,10 @@ gafs_setattr(avc, attrs, flags, acred) gafs_access(avc, amode, flags, acred) - int flags; - register struct vcache *avc; - register afs_int32 amode; - struct AFS_UCRED *acred; + int flags; + register struct vcache *avc; + register afs_int32 amode; + struct AFS_UCRED *acred; { register int code; @@ -1824,12 +1890,12 @@ gafs_access(avc, amode, flags, acred) gafs_lookup(adp, aname, avcp, pnp, flags, rdir, acred) - struct pathname *pnp; - int flags; - struct vnode *rdir; - register struct vcache *adp, **avcp; - char *aname; - struct AFS_UCRED *acred; + struct pathname *pnp; + int flags; + struct vnode *rdir; + register struct vcache *adp, **avcp; + char *aname; + struct AFS_UCRED *acred; { register int code; @@ -1841,13 +1907,13 @@ gafs_lookup(adp, aname, avcp, pnp, flags, rdir, acred) gafs_create(adp, aname, attrs, aexcl, amode, avcp, acred) - register struct vcache *adp; - char *aname; - struct vattr *attrs; - enum vcexcl aexcl; - int amode; - struct vcache **avcp; - struct AFS_UCRED *acred; + register struct vcache *adp; + char *aname; + struct vattr *attrs; + enum vcexcl aexcl; + int amode; + struct vcache **avcp; + struct AFS_UCRED *acred; { register int code; @@ -1858,9 +1924,9 @@ gafs_create(adp, aname, attrs, aexcl, amode, avcp, acred) } gafs_remove(adp, aname, acred) - register struct vcache *adp; - char *aname; - struct AFS_UCRED *acred; + register struct vcache *adp; + char *aname; + struct AFS_UCRED *acred; { register int code; @@ -1871,10 +1937,10 @@ gafs_remove(adp, aname, acred) } gafs_link(adp, avc, aname, acred) - register struct vcache *avc; - register struct vcache *adp; - char *aname; - struct AFS_UCRED *acred; + register struct vcache *avc; + register struct vcache *adp; + char *aname; + struct AFS_UCRED *acred; { register int code; @@ -1885,9 +1951,9 @@ gafs_link(adp, avc, aname, acred) } gafs_rename(aodp, aname1, andp, aname2, acred) - register struct vcache *aodp, *andp; - char *aname1, *aname2; - struct AFS_UCRED *acred; + register struct vcache *aodp, *andp; + char *aname1, *aname2; + struct AFS_UCRED *acred; { register int code; @@ -1898,11 +1964,11 @@ gafs_rename(aodp, aname1, andp, aname2, acred) } gafs_mkdir(adp, aname, attrs, avcp, acred) - register struct vcache *adp; - register struct vcache **avcp; - char *aname; - struct vattr *attrs; - struct AFS_UCRED *acred; + register struct vcache *adp; + register struct vcache **avcp; + char *aname; + struct vattr *attrs; + struct AFS_UCRED *acred; { register int code; @@ -1914,10 +1980,10 @@ gafs_mkdir(adp, aname, attrs, avcp, acred) gafs_rmdir(adp, aname, cdirp, acred) - struct vnode *cdirp; - register struct vcache *adp; - char *aname; - struct AFS_UCRED *acred; + struct vnode *cdirp; + register struct vcache *adp; + char *aname; + struct AFS_UCRED *acred; { register int code; @@ -1929,25 +1995,25 @@ gafs_rmdir(adp, aname, cdirp, acred) gafs_readdir(avc, auio, acred, eofp) - int *eofp; - register struct vcache *avc; - struct uio *auio; - struct AFS_UCRED *acred; + int *eofp; + register struct vcache *avc; + struct uio *auio; + struct AFS_UCRED *acred; { register int code; AFS_GLOCK(); code = afs_readdir(avc, auio, acred, eofp); AFS_GUNLOCK(); - return (code); + return (code); } gafs_symlink(adp, aname, attrs, atargetName, acred) - register struct vcache *adp; - register char *atargetName; - char *aname; - struct vattr *attrs; - struct AFS_UCRED *acred; + register struct vcache *adp; + register char *atargetName; + char *aname; + struct vattr *attrs; + struct AFS_UCRED *acred; { register int code; @@ -1959,9 +2025,9 @@ gafs_symlink(adp, aname, attrs, atargetName, acred) gafs_readlink(avc, auio, acred) - register struct vcache *avc; - struct uio *auio; - struct AFS_UCRED *acred; + register struct vcache *avc; + struct uio *auio; + struct AFS_UCRED *acred; { register int code; @@ -1973,12 +2039,12 @@ gafs_readlink(avc, auio, acred) #ifdef AFS_SUN53_ENV gafs_fsync(avc, flag, acred) - int flag; + int flag; #else gafs_fsync(avc, acred) #endif - register struct vcache *avc; - struct AFS_UCRED *acred; + register struct vcache *avc; + struct AFS_UCRED *acred; { register int code; @@ -1992,26 +2058,29 @@ gafs_fsync(avc, acred) return (code); } -void afs_inactive(struct vcache *avc, struct AFS_UCRED *acred) +void +afs_inactive(struct vcache *avc, struct AFS_UCRED *acred) { struct vnode *vp = AFSTOV(avc); - if (afs_shuttingdown) return ; + if (afs_shuttingdown) + return; /* * In Solaris and HPUX s800 and HP-UX10.0 they actually call us with * v_count 1 on last reference! */ mutex_enter(&vp->v_lock); - if (avc->vrefCount <= 0) osi_Panic("afs_inactive : v_count <=0\n"); + if (avc->vrefCount <= 0) + osi_Panic("afs_inactive : v_count <=0\n"); /* * If more than 1 don't unmap the vnode but do decrement the ref count */ vp->v_count--; if (vp->v_count > 0) { - mutex_exit(&vp->v_lock); - return; - } + mutex_exit(&vp->v_lock); + return; + } mutex_exit(&vp->v_lock); /* @@ -2028,9 +2097,10 @@ void afs_inactive(struct vcache *avc, struct AFS_UCRED *acred) afs_InactiveVCache(avc, acred); } -void gafs_inactive(avc, acred) - register struct vcache *avc; - struct AFS_UCRED *acred; +void +gafs_inactive(avc, acred) + register struct vcache *avc; + struct AFS_UCRED *acred; { AFS_GLOCK(); afs_inactive(avc, acred); @@ -2039,8 +2109,8 @@ void gafs_inactive(avc, acred) gafs_fid(avc, fidpp) -struct vcache *avc; -struct fid **fidpp; + struct vcache *avc; + struct fid **fidpp; { register int code; @@ -2050,4 +2120,4 @@ struct fid **fidpp; return (code); } -#endif /* AFS_GLOBAL_SUNLOCK */ +#endif /* AFS_GLOBAL_SUNLOCK */ diff --git a/src/afs/UKERNEL/afs_usrops.c b/src/afs/UKERNEL/afs_usrops.c index 61995c0ff..b8930647f 100644 --- a/src/afs/UKERNEL/afs_usrops.c +++ b/src/afs/UKERNEL/afs_usrops.c @@ -14,7 +14,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef UKERNEL @@ -62,40 +63,40 @@ struct usr_vfs afs_RootVfs; struct usr_vnode *afs_RootVnode = NULL; struct usr_vnode *afs_CurrentDir = NULL; -afs_int32 cacheBlocks; /* Num blocks in cache */ -afs_int32 cacheFiles = 1000; /* Num files in workstation cache */ -afs_int32 cacheStatEntries = 300; /* Num of stat cache entries */ -char cacheBaseDir[1024]; /* AFS cache directory */ -char confDir[1024]; /* AFS configuration directory */ -char afs_mountDir[1024]; /* AFS mount point */ -int afs_mountDirLen; /* strlen of AFS mount point */ -char fullpn_DCacheFile[1024]; /* Full pathname of DCACHEFILE */ -char fullpn_VolInfoFile[1024]; /* Full pathname of VOLINFOFILE */ -char fullpn_AFSLogFile[1024]; /* Full pathname of AFSLOGFILE */ -char fullpn_CacheInfo[1024]; /* Full pathname of CACHEINFO */ -char fullpn_VFile[1024]; /* Full pathname of data cache files */ -char *vFileNumber; /* Ptr to number in file pathname */ +afs_int32 cacheBlocks; /* Num blocks in cache */ +afs_int32 cacheFiles = 1000; /* Num files in workstation cache */ +afs_int32 cacheStatEntries = 300; /* Num of stat cache entries */ +char cacheBaseDir[1024]; /* AFS cache directory */ +char confDir[1024]; /* AFS configuration directory */ +char afs_mountDir[1024]; /* AFS mount point */ +int afs_mountDirLen; /* strlen of AFS mount point */ +char fullpn_DCacheFile[1024]; /* Full pathname of DCACHEFILE */ +char fullpn_VolInfoFile[1024]; /* Full pathname of VOLINFOFILE */ +char fullpn_AFSLogFile[1024]; /* Full pathname of AFSLOGFILE */ +char fullpn_CacheInfo[1024]; /* Full pathname of CACHEINFO */ +char fullpn_VFile[1024]; /* Full pathname of data cache files */ +char *vFileNumber; /* Ptr to number in file pathname */ char rootVolume[64] = "root.afs"; /* AFS root volume name */ -afs_int32 isHomeCell; /* Is current cell info for home cell */ -afs_int32 lookingForHomeCell; /* Are we still looking for home cell */ -int createAndTrunc = O_CREAT | O_TRUNC; /* Create & truncate on open */ -int ownerRWmode = 0600; /* Read/write OK by owner */ -static int nDaemons = 2; /* Number of background daemons */ -static int chunkSize = 0; /* 2^chunkSize bytes per chunk */ -static int dCacheSize = 300; /* # of dcache entries */ -static int vCacheSize = 50; /* # of volume cache entries */ -static int cacheFlags = 0; /* Flags to cache manager */ -static int preallocs = 400; /* Def # of allocated memory blocks */ -int afsd_verbose = 0; /* Are we being chatty? */ -int afsd_debug = 0; /* Are we printing debugging info? */ -int afsd_CloseSynch = 0; /* Are closes synchronous or not? */ +afs_int32 isHomeCell; /* Is current cell info for home cell */ +afs_int32 lookingForHomeCell; /* Are we still looking for home cell */ +int createAndTrunc = O_CREAT | O_TRUNC; /* Create & truncate on open */ +int ownerRWmode = 0600; /* Read/write OK by owner */ +static int nDaemons = 2; /* Number of background daemons */ +static int chunkSize = 0; /* 2^chunkSize bytes per chunk */ +static int dCacheSize = 300; /* # of dcache entries */ +static int vCacheSize = 50; /* # of volume cache entries */ +static int cacheFlags = 0; /* Flags to cache manager */ +static int preallocs = 400; /* Def # of allocated memory blocks */ +int afsd_verbose = 0; /* Are we being chatty? */ +int afsd_debug = 0; /* Are we printing debugging info? */ +int afsd_CloseSynch = 0; /* Are closes synchronous or not? */ #define AFSD_INO_T afs_uint32 -char **pathname_for_V; /* Array of cache file pathnames */ -int missing_DCacheFile = 1; /* Is the DCACHEFILE missing? */ -int missing_VolInfoFile = 1; /* Is the VOLINFOFILE missing? */ -struct afs_cacheParams cparams; /* params passed to cache manager */ -struct afsconf_dir *afs_cdir; /* config dir */ +char **pathname_for_V; /* Array of cache file pathnames */ +int missing_DCacheFile = 1; /* Is the DCACHEFILE missing? */ +int missing_VolInfoFile = 1; /* Is the VOLINFOFILE missing? */ +struct afs_cacheParams cparams; /* params passed to cache manager */ +struct afsconf_dir *afs_cdir; /* config dir */ static int HandleMTab(); @@ -128,7 +129,7 @@ afs_lock_t osi_fsplock; void *vnodefops; #ifndef NETSCAPE_NSAPI - + /* * Mutex and condition variable used to implement sleep */ @@ -145,14 +146,14 @@ int call_syscall(long, long, long, long, long, long); * osi_Sleep/osi_Wakeup and osi_Wait/osi_Wakeup */ typedef struct osi_wait { - caddr_t addr; - usr_cond_t cond; - int flag; - struct osi_wait *next; - struct osi_wait *prev; - time_t expiration; - struct osi_wait *timedNext; - struct osi_wait *timedPrev; + caddr_t addr; + usr_cond_t cond; + int flag; + struct osi_wait *next; + struct osi_wait *prev; + time_t expiration; + struct osi_wait *timedNext; + struct osi_wait *timedPrev; } osi_wait_t; /* @@ -169,14 +170,15 @@ osi_wait_t *osi_timedwait_head; osi_wait_t *osi_timedwait_tail; struct { - osi_wait_t *head; - osi_wait_t *tail; + osi_wait_t *head; + osi_wait_t *tail; } osi_waithash_table[OSI_WAITHASH_SIZE]; /* * Never call afs_brelse */ -int ufs_brelse(struct usr_vnode *vp, struct usr_buf *bp) +int +ufs_brelse(struct usr_vnode *vp, struct usr_buf *bp) { usr_assert(0); } @@ -184,12 +186,14 @@ int ufs_brelse(struct usr_vnode *vp, struct usr_buf *bp) /* * I am not sure what to do with these, they assert for now */ -int iodone(struct usr_buf *bp) +int +iodone(struct usr_buf *bp) { usr_assert(0); } -struct usr_file *getf(int fd) +struct usr_file * +getf(int fd) { usr_assert(0); } @@ -197,12 +201,14 @@ struct usr_file *getf(int fd) /* * Every user is a super user */ -int afs_osi_suser(void *credp) +int +afs_osi_suser(void *credp) { return 1; } -int afs_suser(void *credp) +int +afs_suser(void *credp) { return 1; } @@ -211,7 +217,8 @@ int afs_suser(void *credp) * These are no-ops in user space */ -void afs_osi_SetTime(osi_timeval_t *atv) +void +afs_osi_SetTime(osi_timeval_t * atv) { return; } @@ -220,7 +227,8 @@ void afs_osi_SetTime(osi_timeval_t *atv) * xflock should never fall through, the only files we know * about are AFS files */ -int usr_flock(void) +int +usr_flock(void) { usr_assert(0); } @@ -229,7 +237,8 @@ int usr_flock(void) * ioctl should never fall through, the only files we know * about are AFS files */ -int usr_ioctl(void) +int +usr_ioctl(void) { usr_assert(0); } @@ -237,22 +246,26 @@ int usr_ioctl(void) /* * We do not support the inode related system calls */ -int afs_syscall_icreate(void) +int +afs_syscall_icreate(void) { usr_assert(0); } -int afs_syscall_iincdec(void) +int +afs_syscall_iincdec(void) { usr_assert(0); } -int afs_syscall_iopen(void) +int +afs_syscall_iopen(void) { usr_assert(0); } -int afs_syscall_ireadwrite(void) +int +afs_syscall_ireadwrite(void) { usr_assert(0); } @@ -261,22 +274,26 @@ int afs_syscall_ireadwrite(void) * these routines are referenced in the vfsops structure, but * should never get called */ -int vno_close(void) +int +vno_close(void) { usr_assert(0); } -int vno_ioctl(void) +int +vno_ioctl(void) { usr_assert(0); } -int vno_rw(void) +int +vno_rw(void) { usr_assert(0); } -int vno_select(void) +int +vno_select(void) { usr_assert(0); } @@ -284,7 +301,8 @@ int vno_select(void) /* * uiomove copies data between kernel buffers and uio buffers */ -int usr_uiomove(char *kbuf, int n, int rw, struct usr_uio *uio) +int +usr_uiomove(char *kbuf, int n, int rw, struct usr_uio *uio) { int nio; int len; @@ -301,7 +319,7 @@ int usr_uiomove(char *kbuf, int n, int rw, struct usr_uio *uio) * copy the data */ ptr = kbuf; - while(nio > 0 && n > 0) { + while (nio > 0 && n > 0) { len = MIN(n, iovp->iov_len); if (rw == UIO_READ) { memcpy(iovp->iov_base, ptr, len); @@ -326,7 +344,8 @@ int usr_uiomove(char *kbuf, int n, int rw, struct usr_uio *uio) /* * routines to manage user credentials */ -struct usr_ucred *usr_crcopy(struct usr_ucred *credp) +struct usr_ucred * +usr_crcopy(struct usr_ucred *credp) { struct usr_ucred *newcredp; @@ -336,7 +355,8 @@ struct usr_ucred *usr_crcopy(struct usr_ucred *credp) return newcredp; } -struct usr_ucred *usr_crget(void) +struct usr_ucred * +usr_crget(void) { struct usr_ucred *newcredp; @@ -345,7 +365,8 @@ struct usr_ucred *usr_crget(void) return newcredp; } -int usr_crfree(struct usr_ucred *credp) +int +usr_crfree(struct usr_ucred *credp) { credp->cr_ref--; if (credp->cr_ref == 0) { @@ -353,16 +374,18 @@ int usr_crfree(struct usr_ucred *credp) } } -int usr_crhold(struct usr_ucred *credp) +int +usr_crhold(struct usr_ucred *credp) { credp->cr_ref++; } -void usr_vattr_null(struct usr_vattr *vap) +void +usr_vattr_null(struct usr_vattr *vap) { int n; char *cp; - + n = sizeof(struct usr_vattr); cp = (char *)vap; while (n--) { @@ -375,7 +398,8 @@ void usr_vattr_null(struct usr_vattr *vap) * kernel environment for each thread. The user structure * is stored in the thread specific data. */ -void uafs_InitThread(void) +void +uafs_InitThread(void) { int st; struct usr_user *uptr; @@ -385,13 +409,14 @@ void uafs_InitThread(void) * allocate the data block, so pthread_finish can free the buffer * when this thread terminates. */ - uptr = (struct usr_user *)malloc(sizeof(struct usr_user) + - sizeof(struct usr_ucred)); + uptr = + (struct usr_user *)malloc(sizeof(struct usr_user) + + sizeof(struct usr_ucred)); usr_assert(uptr != NULL); uptr->u_error = 0; uptr->u_prio = 0; uptr->u_procp = afs_global_procp; - uptr->u_cred = (struct usr_ucred *)(uptr+1); + uptr->u_cred = (struct usr_ucred *)(uptr + 1); *uptr->u_cred = *afs_global_ucredp; st = usr_setspecific(afs_global_u_key, (void *)uptr); usr_assert(st == 0); @@ -402,13 +427,14 @@ void uafs_InitThread(void) * this routine is used to implement the global 'u' structure. Initializes * the thread if needed. */ -struct usr_user *get_user_struct(void) +struct usr_user * +get_user_struct(void) { struct usr_user *uptr; int st; st = usr_getspecific(afs_global_u_key, (void **)&uptr); usr_assert(st == 0); - if(uptr == NULL) { + if (uptr == NULL) { uafs_InitThread(); st = usr_getspecific(afs_global_u_key, (void **)&uptr); usr_assert(st == 0); @@ -426,7 +452,8 @@ struct usr_user *get_user_struct(void) /* * Sleep on an event */ -void afs_osi_Sleep(void *x) +void +afs_osi_Sleep(void *x) { int index; osi_wait_t *waitp; @@ -442,7 +469,7 @@ void afs_osi_Sleep(void *x) } index = WAITHASH(x); if (osi_waithash_avail == NULL) { - waitp = (osi_wait_t *)afs_osi_Alloc(sizeof(osi_wait_t)); + waitp = (osi_wait_t *) afs_osi_Alloc(sizeof(osi_wait_t)); usr_cond_init(&waitp->cond); } else { waitp = osi_waithash_avail; @@ -471,13 +498,15 @@ void afs_osi_Sleep(void *x) } } -int afs_osi_SleepSig(void *x) +int +afs_osi_SleepSig(void *x) { afs_osi_Sleep(x); return 0; } -int afs_osi_Wakeup(void *x) +int +afs_osi_Wakeup(void *x) { int index; osi_wait_t *waitp; @@ -495,7 +524,8 @@ int afs_osi_Wakeup(void *x) usr_mutex_unlock(&osi_waitq_lock); } -int afs_osi_Wait(afs_int32 msec, struct afs_osi_WaitHandle *handle, int intok) +int +afs_osi_Wait(afs_int32 msec, struct afs_osi_WaitHandle *handle, int intok) { int index; osi_wait_t *waitp; @@ -517,7 +547,7 @@ int afs_osi_Wait(afs_int32 msec, struct afs_osi_WaitHandle *handle, int intok) ret = 0; if (glockOwner) { AFS_GLOCK(); - } + } if (rxGlockOwner) { AFS_RXGLOCK(); } @@ -529,22 +559,22 @@ int afs_osi_Wait(afs_int32 msec, struct afs_osi_WaitHandle *handle, int intok) if (rxGlockOwner) { AFS_RXGUNLOCK(); } - index = WAITHASH((caddr_t)handle); + index = WAITHASH((caddr_t) handle); if (osi_waithash_avail == NULL) { - waitp = (osi_wait_t *)afs_osi_Alloc(sizeof(osi_wait_t)); + waitp = (osi_wait_t *) afs_osi_Alloc(sizeof(osi_wait_t)); usr_cond_init(&waitp->cond); } else { waitp = osi_waithash_avail; osi_waithash_avail = osi_waithash_avail->next; } - waitp->addr = (caddr_t)handle; + waitp->addr = (caddr_t) handle; waitp->flag = 0; DLL_INSERT_TAIL(waitp, osi_waithash_table[index].head, osi_waithash_table[index].tail, next, prev); tv.tv_sec += time(NULL); - waitp->expiration = tv.tv_sec + ((tv.tv_nsec == 0)?0:1); + waitp->expiration = tv.tv_sec + ((tv.tv_nsec == 0) ? 0 : 1); DLL_INSERT_TAIL(waitp, osi_timedwait_head, osi_timedwait_tail, - timedNext, timedPrev); + timedNext, timedPrev); usr_cond_wait(&waitp->cond, &osi_waitq_lock); if (waitp->flag) { ret = 2; @@ -553,8 +583,8 @@ int afs_osi_Wait(afs_int32 msec, struct afs_osi_WaitHandle *handle, int intok) } DLL_DELETE(waitp, osi_waithash_table[index].head, osi_waithash_table[index].tail, next, prev); - DLL_DELETE(waitp, osi_timedwait_head, osi_timedwait_tail, - timedNext, timedPrev); + DLL_DELETE(waitp, osi_timedwait_head, osi_timedwait_tail, timedNext, + timedPrev); waitp->next = osi_waithash_avail; osi_waithash_avail = waitp; usr_mutex_unlock(&osi_waitq_lock); @@ -568,7 +598,8 @@ int afs_osi_Wait(afs_int32 msec, struct afs_osi_WaitHandle *handle, int intok) return ret; } -void afs_osi_CancelWait(struct afs_osi_WaitHandle *handle) +void +afs_osi_CancelWait(struct afs_osi_WaitHandle *handle) { afs_osi_Wakeup(handle); } @@ -577,7 +608,8 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *handle) * Netscape NSAPI doesn't have a cond_timed_wait, so we need * to explicitly signal cond_timed_waits when their timers expire */ -int afs_osi_CheckTimedWaits(void) +int +afs_osi_CheckTimedWaits(void) { time_t curTime; osi_wait_t *waitp; @@ -614,15 +646,16 @@ int max_osi_files = 0; * Allocate a slot in the file table if there is not one there already, * copy in the file name and kludge up the vnode and inode structures */ -int lookupname(char *fnamep, int segflg, int followlink, - struct usr_vnode **dirvpp, struct usr_vnode **compvpp) +int +lookupname(char *fnamep, int segflg, int followlink, + struct usr_vnode **dirvpp, struct usr_vnode **compvpp) { int i; int code; struct usr_inode *ip; struct usr_vnode *vp; - /*usr_assert(followlink == 0);*/ + /*usr_assert(followlink == 0); */ usr_assert(dirvpp == NULL); /* @@ -637,7 +670,7 @@ int lookupname(char *fnamep, int segflg, int followlink, usr_mutex_lock(&osi_inode_lock); - for (i = 0 ; i < n_osi_files ; i++) { + for (i = 0; i < n_osi_files; i++) { if (strcmp(fnamep, osi_file_table[i].name) == 0) { *compvpp = &osi_file_table[i].i_node.i_vnode; (*compvpp)->v_count++; @@ -651,12 +684,12 @@ int lookupname(char *fnamep, int segflg, int followlink, return ENOSPC; } - osi_file_table[n_osi_files].name = afs_osi_Alloc(strlen(fnamep)+1); + osi_file_table[n_osi_files].name = afs_osi_Alloc(strlen(fnamep) + 1); usr_assert(osi_file_table[n_osi_files].name != NULL); strcpy(osi_file_table[n_osi_files].name, fnamep); ip = &osi_file_table[i].i_node; vp = &ip->i_vnode; - vp->v_data = (caddr_t)ip; + vp->v_data = (caddr_t) ip; ip->i_dev = -1; n_osi_files++; ip->i_number = n_osi_files; @@ -669,7 +702,8 @@ int lookupname(char *fnamep, int segflg, int followlink, /* * open a file given its i-node number */ -void *osi_UFSOpen(afs_int32 ino) +void * +osi_UFSOpen(afs_int32 ino) { int rc; struct osi_file *fp; @@ -685,7 +719,7 @@ void *osi_UFSOpen(afs_int32 ino) AFS_GUNLOCK(); fp = (struct osi_file *)afs_osi_Alloc(sizeof(struct osi_file)); usr_assert(fp != NULL); - fp->fd = open(osi_file_table[ino-1].name, O_RDWR|O_CREAT, 0); + fp->fd = open(osi_file_table[ino - 1].name, O_RDWR | O_CREAT, 0); if (fp->fd < 0) { u.u_error = errno; afs_osi_Free((char *)fp, sizeof(struct osi_file)); @@ -708,7 +742,8 @@ void *osi_UFSOpen(afs_int32 ino) return fp; } -int osi_UFSClose(struct osi_file *fp) +int +osi_UFSClose(struct osi_file *fp) { int rc; @@ -727,7 +762,8 @@ int osi_UFSClose(struct osi_file *fp) return 0; } -int osi_UFSTruncate(struct osi_file *fp, afs_int32 len) +int +osi_UFSTruncate(struct osi_file *fp, afs_int32 len) { int rc; @@ -745,7 +781,8 @@ int osi_UFSTruncate(struct osi_file *fp, afs_int32 len) return 0; } -int afs_osi_Read(struct osi_file *fp, int offset, void *buf, afs_int32 len) +int +afs_osi_Read(struct osi_file *fp, int offset, void *buf, afs_int32 len) { int rc, ret; int code; @@ -783,7 +820,8 @@ int afs_osi_Read(struct osi_file *fp, int offset, void *buf, afs_int32 len) return ret; } -int afs_osi_Write(struct osi_file *fp, afs_int32 offset, void *buf, afs_int32 len) +int +afs_osi_Write(struct osi_file *fp, afs_int32 offset, void *buf, afs_int32 len) { int rc, ret; int code; @@ -821,7 +859,8 @@ int afs_osi_Write(struct osi_file *fp, afs_int32 offset, void *buf, afs_int32 le return ret; } -int afs_osi_Stat(struct osi_file *fp, struct osi_stat *stp) +int +afs_osi_Stat(struct osi_file *fp, struct osi_stat *stp) { int rc; struct stat st; @@ -831,7 +870,7 @@ int afs_osi_Stat(struct osi_file *fp, struct osi_stat *stp) if (rc < 0) { u.u_error = errno; AFS_GLOCK(); - return -1; + return -1; } stp->size = st.st_size; stp->blksize = st.st_blksize; @@ -844,12 +883,9 @@ int afs_osi_Stat(struct osi_file *fp, struct osi_stat *stp) /* * VOP_RDWR routine */ -int afs_osi_VOP_RDWR( - struct usr_vnode *vnodeP, - struct usr_uio *uioP, - int rw, - int flags, - struct usr_ucred* credP) +int +afs_osi_VOP_RDWR(struct usr_vnode *vnodeP, struct usr_uio *uioP, int rw, + int flags, struct usr_ucred *credP) { int rc; struct osi_file *fp = (struct osi_file *)vnodeP; @@ -862,13 +898,11 @@ int afs_osi_VOP_RDWR( if (rw == UIO_WRITE) { usr_assert(uioP->uio_fmode == FWRITE); - rc = afs_osi_Write(fp, uioP->uio_offset, - uioP->uio_iov[0].iov_base, + rc = afs_osi_Write(fp, uioP->uio_offset, uioP->uio_iov[0].iov_base, uioP->uio_iov[0].iov_len); } else { usr_assert(uioP->uio_fmode == FREAD); - rc = afs_osi_Read(fp, uioP->uio_offset, - uioP->uio_iov[0].iov_base, + rc = afs_osi_Read(fp, uioP->uio_offset, uioP->uio_iov[0].iov_base, uioP->uio_iov[0].iov_len); } if (rc < 0) { @@ -889,118 +923,138 @@ int afs_osi_VOP_RDWR( static char *afs_check_string1 = "UAFS"; static char *afs_check_string2 = "AFS_OSI_"; -void *afs_osi_Alloc(size_t size) +void * +afs_osi_Alloc(size_t size) { return malloc(size); } -void afs_osi_Free(void *ptr, size_t size) +void +afs_osi_Free(void *ptr, size_t size) { free(ptr); } -void afs_osi_FreeStr(char *ptr) +void +afs_osi_FreeStr(char *ptr) { free(ptr); } -void *osi_AllocLargeSpace(size_t size) +void * +osi_AllocLargeSpace(size_t size) { AFS_STATCNT(osi_AllocLargeSpace); return afs_osi_Alloc(size); } -void osi_FreeLargeSpace(void *ptr) +void +osi_FreeLargeSpace(void *ptr) { AFS_STATCNT(osi_FreeLargeSpace); afs_osi_Free(ptr, 0); } -void *osi_AllocSmallSpace(size_t size) +void * +osi_AllocSmallSpace(size_t size) { AFS_STATCNT(osi_AllocSmallSpace); return afs_osi_Alloc(size); } -void osi_FreeSmallSpace(void *ptr) +void +osi_FreeSmallSpace(void *ptr) { AFS_STATCNT(osi_FreeSmallSpace); afs_osi_Free(ptr, 0); } -void shutdown_osi(void) +void +shutdown_osi(void) { AFS_STATCNT(shutdown_osi); return; } -void shutdown_osinet(void) +void +shutdown_osinet(void) { AFS_STATCNT(shutdown_osinet); return; } -void shutdown_osifile(void) +void +shutdown_osifile(void) { AFS_STATCNT(shutdown_osifile); return; } -int afs_nfsclient_init(void) +int +afs_nfsclient_init(void) { return 0; } -void shutdown_nfsclnt(void) +void +shutdown_nfsclnt(void) { return; } -void afs_osi_Invisible(void) +void +afs_osi_Invisible(void) { return; } -int osi_GetTime(struct timeval *tv) +int +osi_GetTime(struct timeval *tv) { gettimeofday(tv, NULL); return 0; } -int osi_SetTime(struct timeval *tv) +int +osi_SetTime(struct timeval *tv) { return 0; } -int osi_Active(struct vcache *avc) +int +osi_Active(struct vcache *avc) { AFS_STATCNT(osi_Active); - if (avc->opens > 0) return(1); + if (avc->opens > 0) + return (1); return 0; } -int afs_osi_MapStrategy(int (*aproc)(), struct usr_buf *bp) +int +afs_osi_MapStrategy(int (*aproc) (), struct usr_buf *bp) { afs_int32 returnCode; - returnCode = (*aproc)(bp); + returnCode = (*aproc) (bp); return returnCode; } -void osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp) +void +osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp) { - ObtainSharedLock(&avc->lock,555); - if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) || - ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) { + ObtainSharedLock(&avc->lock, 555); + if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) + || ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) { ReleaseSharedLock(&avc->lock); return; } - UpgradeSToWLock(&avc->lock,565); + UpgradeSToWLock(&avc->lock, 565); hset(avc->mapDV, avc->m.DataVersion); ReleaseWriteLock(&avc->lock); return; } -void osi_FlushText_really(register struct vcache *vp) +void +osi_FlushText_really(register struct vcache *vp) { if (hcmp(vp->m.DataVersion, vp->flushDV) > 0) { hset(vp->flushDV, vp->m.DataVersion); @@ -1008,17 +1062,20 @@ void osi_FlushText_really(register struct vcache *vp) return; } -int osi_SyncVM(struct vcache *avc) +int +osi_SyncVM(struct vcache *avc) { return 0; } -void osi_ReleaseVM(struct vcache *avc, int len, struct usr_ucred *credp) +void +osi_ReleaseVM(struct vcache *avc, int len, struct usr_ucred *credp) { return; } -void osi_Init(void) +void +osi_Init(void) { int i; int rc; @@ -1029,7 +1086,7 @@ void osi_Init(void) */ max_osi_files = cacheFiles + 100; osi_file_table = (osi_file_table_t *) - afs_osi_Alloc(max_osi_files * sizeof(osi_file_table_t)); + afs_osi_Alloc(max_osi_files * sizeof(osi_file_table_t)); usr_assert(osi_file_table != NULL); #ifndef NETSCAPE_NSAPI @@ -1044,7 +1101,7 @@ void osi_Init(void) /* * Initialize the hash table used for sleep/wakeup */ - for (i = 0 ; i < OSI_WAITHASH_SIZE ; i++) { + for (i = 0; i < OSI_WAITHASH_SIZE; i++) { DLL_INIT_LIST(osi_waithash_table[i].head, osi_waithash_table[i].tail); } DLL_INIT_LIST(osi_timedwait_head, osi_timedwait_tail); @@ -1053,7 +1110,7 @@ void osi_Init(void) /* * Initialize the AFS file table */ - for (i = 0 ; i < MAX_OSI_FILES ; i++) { + for (i = 0; i < MAX_OSI_FILES; i++) { afs_FileTable[i] = NULL; } @@ -1097,11 +1154,12 @@ void osi_Init(void) * None. *------------------------------------------------------------------------*/ -int GetVFileNumber(char *fname) +int +GetVFileNumber(char *fname) { - int computedVNumber; /*The computed file number we return*/ - int filenameLen; /*Number of chars in filename*/ - int currDigit; /*Current digit being processed*/ + int computedVNumber; /*The computed file number we return */ + int filenameLen; /*Number of chars in filename */ + int currDigit; /*Current digit being processed */ /* * The filename must have at least two characters, the first of which must be a ``V'' @@ -1109,11 +1167,11 @@ int GetVFileNumber(char *fname) */ filenameLen = strlen(fname); if (filenameLen < 2) - return(-1); + return (-1); if (fname[0] != 'V') - return(-1); + return (-1); if ((filenameLen > 2) && (fname[1] == '0')) - return(-1); + return (-1); /* * Scan through the characters in the given filename, failing immediately if a non-digit @@ -1121,7 +1179,7 @@ int GetVFileNumber(char *fname) */ for (currDigit = 1; currDigit < filenameLen; currDigit++) if (isdigit(fname[currDigit]) == 0) - return(-1); + return (-1); /* * All relevant characters are digits. Pull out the decimal number they represent. @@ -1129,9 +1187,9 @@ int GetVFileNumber(char *fname) */ computedVNumber = atoi(++fname); if (computedVNumber < cacheFiles) - return(computedVNumber); + return (computedVNumber); else - return(-1); + return (-1); } /*--------------------------------------------------------------------- @@ -1155,29 +1213,30 @@ int GetVFileNumber(char *fname) * As described. *------------------------------------------------------------------------*/ -int CreateCacheFile(char *fname) +int +CreateCacheFile(char *fname) { - static char rn[] = "CreateCacheFile"; /*Routine name*/ - int cfd; /*File descriptor to AFS cache file*/ - int closeResult; /*Result of close()*/ + static char rn[] = "CreateCacheFile"; /*Routine name */ + int cfd; /*File descriptor to AFS cache file */ + int closeResult; /*Result of close() */ if (afsd_verbose) - printf("%s: Creating cache file '%s'\n", - rn, fname); + printf("%s: Creating cache file '%s'\n", rn, fname); cfd = open(fname, createAndTrunc, ownerRWmode); - if (cfd <= 0) { - printf("%s: Can't create '%s', error return is %d (%d)\n", - rn, fname, cfd, errno); - return(-1); + if (cfd <= 0) { + printf("%s: Can't create '%s', error return is %d (%d)\n", rn, fname, + cfd, errno); + return (-1); } closeResult = close(cfd); - if (closeResult) { - printf("%s: Can't close newly-created AFS cache file '%s' (code %d)\n", - rn, fname, errno); - return(-1); + if (closeResult) { + printf + ("%s: Can't close newly-created AFS cache file '%s' (code %d)\n", + rn, fname, errno); + return (-1); } - return(0); + return (0); } /*--------------------------------------------------------------------- @@ -1208,15 +1267,16 @@ int CreateCacheFile(char *fname) * delete files as explained above. *------------------------------------------------------------------------*/ -int SweepAFSCache(int *vFilesFound) +int +SweepAFSCache(int *vFilesFound) { - static char rn[] = "SweepAFSCache"; /*Routine name*/ - char fullpn_FileToDelete[1024]; /*File to be deleted from cache*/ - char *fileToDelete; /*Ptr to last component of above*/ - DIR *cdirp; /*Ptr to cache directory structure*/ + static char rn[] = "SweepAFSCache"; /*Routine name */ + char fullpn_FileToDelete[1024]; /*File to be deleted from cache */ + char *fileToDelete; /*Ptr to last component of above */ + DIR *cdirp; /*Ptr to cache directory structure */ #undef dirent - struct dirent *currp; /*Current directory entry*/ - int vFileNum; /*Data cache file's associated number*/ + struct dirent *currp; /*Current directory entry */ + int vFileNum; /*Data cache file's associated number */ if (cacheFlags & AFSCALL_INIT_MEMCACHE) { if (afsd_debug) @@ -1226,19 +1286,18 @@ int SweepAFSCache(int *vFilesFound) } if (afsd_debug) - printf("%s: Opening cache directory '%s'\n", - rn, cacheBaseDir); + printf("%s: Opening cache directory '%s'\n", rn, cacheBaseDir); - if (chmod(cacheBaseDir, 0700)) { /* force it to be 700 */ - printf("%s: Can't 'chmod 0700' the cache dir, '%s'.\n", - rn, cacheBaseDir); + if (chmod(cacheBaseDir, 0700)) { /* force it to be 700 */ + printf("%s: Can't 'chmod 0700' the cache dir, '%s'.\n", rn, + cacheBaseDir); return (-1); } cdirp = opendir(cacheBaseDir); - if (cdirp == (DIR *)0) { - printf("%s: Can't open AFS cache directory, '%s'.\n", - rn, cacheBaseDir); - return(-1); + if (cdirp == (DIR *) 0) { + printf("%s: Can't open AFS cache directory, '%s'.\n", rn, + cacheBaseDir); + return (-1); } /* @@ -1249,13 +1308,11 @@ int SweepAFSCache(int *vFilesFound) sprintf(fullpn_FileToDelete, "%s/", cacheBaseDir); fileToDelete = fullpn_FileToDelete + strlen(fullpn_FileToDelete); - for (currp = readdir(cdirp); currp; currp = readdir(cdirp)) - { + for (currp = readdir(cdirp); currp; currp = readdir(cdirp)) { if (afsd_debug) { - printf("%s: Current directory entry:\n", - rn); - printf("\tinode=%d, reclen=%d, name='%s'\n", - currp->d_ino, currp->d_reclen, currp->d_name); + printf("%s: Current directory entry:\n", rn); + printf("\tinode=%d, reclen=%d, name='%s'\n", currp->d_ino, + currp->d_reclen, currp->d_name); } /* @@ -1267,43 +1324,39 @@ int SweepAFSCache(int *vFilesFound) * Found a valid data cache filename. Remember this file's name * and bump the number of files found. */ - pathname_for_V[vFileNum] = afs_osi_Alloc(strlen(currp->d_name) + - strlen(cacheBaseDir) + 2); + pathname_for_V[vFileNum] = + afs_osi_Alloc(strlen(currp->d_name) + strlen(cacheBaseDir) + + 2); usr_assert(pathname_for_V[vFileNum] != NULL); - sprintf(pathname_for_V[vFileNum], "%s/%s", - cacheBaseDir, currp->d_name); + sprintf(pathname_for_V[vFileNum], "%s/%s", cacheBaseDir, + currp->d_name); (*vFilesFound)++; - } - else if (strcmp(currp->d_name, DCACHEFILE) == 0) { + } else if (strcmp(currp->d_name, DCACHEFILE) == 0) { /* * Found the file holding the dcache entries. */ missing_DCacheFile = 0; - } - else if (strcmp(currp->d_name, VOLINFOFILE) == 0) { + } else if (strcmp(currp->d_name, VOLINFOFILE) == 0) { /* * Found the file holding the volume info. */ missing_VolInfoFile = 0; - } - else if ((strcmp(currp->d_name, ".") == 0) || - (strcmp(currp->d_name, "..") == 0) || - (strcmp(currp->d_name, "lost+found") == 0)) { + } else if ((strcmp(currp->d_name, ".") == 0) + || (strcmp(currp->d_name, "..") == 0) + || (strcmp(currp->d_name, "lost+found") == 0)) { /* * Don't do anything - this file is legit, and is to be left alone. */ - } - else { + } else { /* * This file doesn't belong in the cache. Nuke it. */ sprintf(fileToDelete, "%s", currp->d_name); if (afsd_verbose) - printf("%s: Deleting '%s'\n", - rn, fullpn_FileToDelete); + printf("%s: Deleting '%s'\n", rn, fullpn_FileToDelete); if (unlink(fullpn_FileToDelete)) { - printf("%s: Can't unlink '%s', errno is %d\n", - rn, fullpn_FileToDelete, errno); + printf("%s: Can't unlink '%s', errno is %d\n", rn, + fullpn_FileToDelete, errno); } } } @@ -1313,19 +1366,15 @@ int SweepAFSCache(int *vFilesFound) */ if (missing_DCacheFile) { if (afsd_verbose) - printf("%s: Creating '%s'\n", - rn, fullpn_DCacheFile); + printf("%s: Creating '%s'\n", rn, fullpn_DCacheFile); if (CreateCacheFile(fullpn_DCacheFile)) - printf("%s: Can't create '%s'\n", - rn, fullpn_DCacheFile); + printf("%s: Can't create '%s'\n", rn, fullpn_DCacheFile); } if (missing_VolInfoFile) { if (afsd_verbose) - printf("%s: Creating '%s'\n", - rn, fullpn_VolInfoFile); + printf("%s: Creating '%s'\n", rn, fullpn_VolInfoFile); if (CreateCacheFile(fullpn_VolInfoFile)) - printf("%s: Can't create '%s'\n", - rn, fullpn_VolInfoFile); + printf("%s: Can't create '%s'\n", rn, fullpn_VolInfoFile); } if (*vFilesFound < cacheFiles) { @@ -1334,14 +1383,12 @@ int SweepAFSCache(int *vFilesFound) * list and create all missing files. */ for (vFileNum = 0; vFileNum < cacheFiles; vFileNum++) - if (pathname_for_V[vFileNum] == (AFSD_INO_T)0) { + if (pathname_for_V[vFileNum] == (AFSD_INO_T) 0) { sprintf(vFileNumber, "%d", vFileNum); if (afsd_verbose) - printf("%s: Creating '%s'\n", - rn, fullpn_VFile); + printf("%s: Creating '%s'\n", rn, fullpn_VFile); if (CreateCacheFile(fullpn_VFile)) - printf("%s: Can't create '%s'\n", - rn, fullpn_VFile); + printf("%s: Can't create '%s'\n", rn, fullpn_VFile); } } @@ -1349,13 +1396,14 @@ int SweepAFSCache(int *vFilesFound) * Close the directory, return success. */ if (afsd_debug) - printf("%s: Closing cache directory.\n", - rn); + printf("%s: Closing cache directory.\n", rn); closedir(cdirp); - return(0); + return (0); } -static ConfigCell(register struct afsconf_cell *aci, char *arock, struct afsconf_dir *adir) +static +ConfigCell(register struct afsconf_cell *aci, char *arock, + struct afsconf_dir *adir) { register int isHomeCell; register int i; @@ -1366,32 +1414,32 @@ static ConfigCell(register struct afsconf_cell *aci, char *arock, struct afsconf isHomeCell = (strcmp(aci->name, afs_LclCellName) == 0); if (isHomeCell) { lookingForHomeCell = 0; - cellFlags = 1; /* home cell, suid is ok */ - } - else { - cellFlags = 2; /* not home, suid is forbidden */ + cellFlags = 1; /* home cell, suid is ok */ + } else { + cellFlags = 2; /* not home, suid is forbidden */ } /* build address list */ - for(i=0;ihostAddr[i].sin_addr, sizeof(afs_int32)); - if (aci->linkedCell) cellFlags |= 4; /* Flag that linkedCell arg exists, - for upwards compatibility */ + if (aci->linkedCell) + cellFlags |= 4; /* Flag that linkedCell arg exists, + * for upwards compatibility */ /* configure one cell */ - call_syscall(AFSCALL_CALL, AFSOP_ADDCELL2, - (long)hosts, /* server addresses */ - (long)aci->name, /* cell name */ - (long)cellFlags, /* is this the home cell? */ - (long)aci->linkedCell); /* Linked cell, if any */ + call_syscall(AFSCALL_CALL, AFSOP_ADDCELL2, (long)hosts, /* server addresses */ + (long)aci->name, /* cell name */ + (long)cellFlags, /* is this the home cell? */ + (long)aci->linkedCell); /* Linked cell, if any */ return 0; } /* * Set the UDP port number RX uses for UDP datagrams */ -void uafs_SetRxPort(int port) +void +uafs_SetRxPort(int port) { usr_assert(usr_rx_port == 0); usr_rx_port = port; @@ -1401,32 +1449,22 @@ void uafs_SetRxPort(int port) /* * Initialize the user space client. */ -void uafs_Init( - char *rn, - char *mountDirParam, - char *confDirParam, - char *cacheBaseDirParam, - int cacheBlocksParam, - int cacheFilesParam, - int cacheStatEntriesParam, - int dCacheSizeParam, - int vCacheSizeParam, - int chunkSizeParam, - int closeSynchParam, - int debugParam, - int nDaemonsParam, - int cacheFlagsParam, - char *logFile) +void +uafs_Init(char *rn, char *mountDirParam, char *confDirParam, + char *cacheBaseDirParam, int cacheBlocksParam, int cacheFilesParam, + int cacheStatEntriesParam, int dCacheSizeParam, int vCacheSizeParam, + int chunkSizeParam, int closeSynchParam, int debugParam, + int nDaemonsParam, int cacheFlagsParam, char *logFile) { int st; struct usr_proc *procp; struct usr_ucred *ucredp; int i; int rc; - int currVFile; /* Current AFS cache file number */ - int lookupResult; /* Result of GetLocalCellName() */ - int cacheIteration; /* cache verification loop counter */ - int vFilesFound; /* Num data cache files found in sweep */ + int currVFile; /* Current AFS cache file number */ + int lookupResult; /* Result of GetLocalCellName() */ + int cacheIteration; /* cache verification loop counter */ + int vFilesFound; /* Num data cache files found in sweep */ FILE *logfd; afs_int32 vfs1_type = -1; struct afs_ioctl iob; @@ -1446,7 +1484,7 @@ void uafs_Init( * Initialize the global ucred structure */ afs_global_ucredp = (struct usr_ucred *) - afs_osi_Alloc(sizeof(struct usr_ucred)); + afs_osi_Alloc(sizeof(struct usr_ucred)); usr_assert(afs_global_ucredp != NULL); afs_global_ucredp->cr_ref = 1; afs_global_ucredp->cr_uid = geteuid(); @@ -1458,7 +1496,7 @@ void uafs_Init( st = getgroups(NGROUPS, &afs_global_ucredp->cr_groups[0]); usr_assert(st >= 0); afs_global_ucredp->cr_ngroups = (unsigned long)st; - for (i = st ; i < NGROUPS ; i++) { + for (i = st; i < NGROUPS; i++) { afs_global_ucredp->cr_groups[i] = NOGROUP; } @@ -1466,10 +1504,10 @@ void uafs_Init( * Initialize the global process structure */ afs_global_procp = (struct usr_proc *) - afs_osi_Alloc(sizeof(struct usr_proc)); + afs_osi_Alloc(sizeof(struct usr_proc)); usr_assert(afs_global_procp != NULL); afs_global_procp->p_pid = getpid(); - afs_global_procp->p_ppid = (pid_t)1; + afs_global_procp->p_ppid = (pid_t) 1; afs_global_procp->p_ucred = afs_global_ucredp; /* @@ -1484,7 +1522,7 @@ void uafs_Init( } afs_mountDir[0] = '/'; afs_mountDirLen = 1; - for (lastchar = '/', p = &tbuffer[0] ; *p != '\0' ; p++) { + for (lastchar = '/', p = &tbuffer[0]; *p != '\0'; p++) { if (lastchar != '/' || *p != '/') { afs_mountDir[afs_mountDirLen++] = lastchar = *p; } @@ -1502,7 +1540,7 @@ void uafs_Init( if (cacheFilesParam != 0) { cacheFiles = cacheFilesParam; } else { - cacheFiles = cacheBlocks/10; + cacheFiles = cacheBlocks / 10; } if (cacheStatEntriesParam != 0) { cacheStatEntries = cacheStatEntriesParam; @@ -1519,7 +1557,7 @@ void uafs_Init( if (dCacheSizeParam != 0) { dCacheSize = dCacheSizeParam; } else { - dCacheSize = cacheFiles/2; + dCacheSize = cacheFiles / 2; } if (vCacheSizeParam != 0) { vCacheSize = vCacheSizeParam; @@ -1530,12 +1568,12 @@ void uafs_Init( cacheFlags = cacheFlagsParam; } if (cacheFlags & AFSCALL_INIT_MEMCACHE) { - cacheFiles = dCacheSize; + cacheFiles = dCacheSize; } - sprintf(fullpn_CacheInfo, "%s/%s", confDir, CACHEINFOFILE); + sprintf(fullpn_CacheInfo, "%s/%s", confDir, CACHEINFOFILE); if (logFile == NULL) { - sprintf(fullpn_AFSLogFile, "%s/%s", confDir, AFSLOGFILE); + sprintf(fullpn_AFSLogFile, "%s/%s", confDir, AFSLOGFILE); } else { strcpy(fullpn_AFSLogFile, logFile); } @@ -1573,13 +1611,13 @@ void uafs_Init( exit(1); } - lookupResult = afsconf_GetLocalCell(afs_cdir, afs_LclCellName, - sizeof(afs_LclCellName)); + lookupResult = + afsconf_GetLocalCell(afs_cdir, afs_LclCellName, + sizeof(afs_LclCellName)); if (lookupResult) { - printf("%s: Can't get my home cell name! [Error is %d]\n", - rn, lookupResult); - } - else { + printf("%s: Can't get my home cell name! [Error is %d]\n", rn, + lookupResult); + } else { if (afsd_verbose) printf("%s: My home cell is '%s'\n", rn, afs_LclCellName); } @@ -1587,12 +1625,15 @@ void uafs_Init( /* * Set the primary cell name. */ - call_syscall(AFSOP_SET_THISCELL, (long) afs_LclCellName, 0, 0, 0, 0); + call_syscall(AFSOP_SET_THISCELL, (long)afs_LclCellName, 0, 0, 0, 0); - if ((logfd = fopen(fullpn_AFSLogFile,"r+")) == 0) { - if (afsd_verbose) printf("%s: Creating '%s'\n", rn, fullpn_AFSLogFile); + if ((logfd = fopen(fullpn_AFSLogFile, "r+")) == 0) { + if (afsd_verbose) + printf("%s: Creating '%s'\n", rn, fullpn_AFSLogFile); if (CreateCacheFile(fullpn_AFSLogFile)) { - printf("%s: Can't create '%s' (You may want to use the -logfile option)\n", rn, fullpn_AFSLogFile); + printf + ("%s: Can't create '%s' (You may want to use the -logfile option)\n", + rn, fullpn_AFSLogFile); exit(1); } } else @@ -1609,29 +1650,29 @@ void uafs_Init( } memset(pathname_for_V, 0, (cacheFiles * sizeof(char *))); if (afsd_debug) - printf("%s: %d pathname_for_V entries at 0x%x, %d bytes\n", - rn, cacheFiles, pathname_for_V, (cacheFiles * sizeof(AFSD_INO_T))); + printf("%s: %d pathname_for_V entries at 0x%x, %d bytes\n", rn, + cacheFiles, pathname_for_V, (cacheFiles * sizeof(AFSD_INO_T))); /* * Set up all the pathnames we'll need for later. */ - sprintf(fullpn_DCacheFile, "%s/%s", cacheBaseDir, DCACHEFILE); + sprintf(fullpn_DCacheFile, "%s/%s", cacheBaseDir, DCACHEFILE); sprintf(fullpn_VolInfoFile, "%s/%s", cacheBaseDir, VOLINFOFILE); - sprintf(fullpn_VFile, "%s/V", cacheBaseDir); + sprintf(fullpn_VFile, "%s/V", cacheBaseDir); vFileNumber = fullpn_VFile + strlen(fullpn_VFile); /* * Start the RX listener. */ if (afsd_debug) - printf("%s: Calling AFSOP_RXLISTENER_DAEMON\n", rn); + printf("%s: Calling AFSOP_RXLISTENER_DAEMON\n", rn); fork_syscall(AFSCALL_CALL, AFSOP_RXLISTENER_DAEMON, FALSE); /* * Start the RX event handler. */ if (afsd_debug) - printf("%s: Calling AFSOP_RXEVENT_DAEMON\n", rn); + printf("%s: Calling AFSOP_RXEVENT_DAEMON\n", rn); fork_syscall(AFSCALL_CALL, AFSOP_RXEVENT_DAEMON, FALSE); /* @@ -1640,29 +1681,31 @@ void uafs_Init( /* initialize AFS callback interface */ { - /* parse multihomed address files */ - char reason[1024]; - st=parseNetFiles(buffer,maskbuffer,mtubuffer,MAXIPADDRS,reason, - AFSDIR_CLIENT_NETINFO_FILEPATH, - AFSDIR_CLIENT_NETRESTRICT_FILEPATH); - if(st>0) - call_syscall(AFSCALL_CALL, AFSOP_ADVISEADDR, st, (long) (&buffer[0]), - (long) (&maskbuffer[0]), (long) (&mtubuffer[0])); - else { - printf("ADVISEADDR: Error in specifying interface addresses:%s\n",reason); - exit(1); - } + /* parse multihomed address files */ + char reason[1024]; + st = parseNetFiles(buffer, maskbuffer, mtubuffer, MAXIPADDRS, reason, + AFSDIR_CLIENT_NETINFO_FILEPATH, + AFSDIR_CLIENT_NETRESTRICT_FILEPATH); + if (st > 0) + call_syscall(AFSCALL_CALL, AFSOP_ADVISEADDR, st, + (long)(&buffer[0]), (long)(&maskbuffer[0]), + (long)(&mtubuffer[0])); + else { + printf("ADVISEADDR: Error in specifying interface addresses:%s\n", + reason); + exit(1); + } } if (afsd_verbose) printf("%s: Forking rx callback listener.\n", rn); /* Child */ - if (preallocs < cacheStatEntries+50) - preallocs = cacheStatEntries+50; + if (preallocs < cacheStatEntries + 50) + preallocs = cacheStatEntries + 50; fork_syscall(AFSCALL_CALL, AFSOP_START_RXCALLBACK, preallocs); if (afsd_verbose) - printf("%s: Initializing AFS daemon.\n", rn); + printf("%s: Initializing AFS daemon.\n", rn); fork_syscall(AFSCALL_CALL, AFSOP_BASIC_INIT); if (afsd_verbose) @@ -1675,7 +1718,7 @@ void uafs_Init( if (afsd_verbose) printf("%s: Forking %d background daemons.\n", rn, nDaemons); - for (i=0;icr_suid = getuid(); crp->cr_groups[0] = getgid(); crp->cr_ngroups = 1; - for (i = 1 ; i < NGROUPS ; i++) { + for (i = 1; i < NGROUPS; i++) { crp->cr_groups[i] = NOGROUP; } - call_syscall(sysArgsP->syscall, sysArgsP->afscall, - sysArgsP->param1, sysArgsP->param2, - sysArgsP->param3, sysArgsP->param4); + call_syscall(sysArgsP->syscall, sysArgsP->afscall, sysArgsP->param1, + sysArgsP->param2, sysArgsP->param3, sysArgsP->param4); afs_osi_Free(argp, -1); } fork_syscall(syscall, afscall, param1, param2, param3, param4) -long syscall, afscall, param1, param2, param3, param4; + long syscall, afscall, param1, param2, param3, param4; { usr_thread_t tid; struct syscallThreadArgs *sysArgsP; sysArgsP = (struct syscallThreadArgs *) - afs_osi_Alloc(sizeof(struct syscallThreadArgs)); + afs_osi_Alloc(sizeof(struct syscallThreadArgs)); usr_assert(sysArgsP != NULL); sysArgsP->syscall = syscall; sysArgsP->afscall = afscall; @@ -1970,7 +2015,7 @@ long syscall, afscall, param1, param2, param3, param4; } call_syscall(syscall, afscall, param1, param2, param3, param4) -long syscall, afscall, param1, param2, param3, param4; + long syscall, afscall, param1, param2, param3, param4; { int code = 0; struct a { @@ -1996,7 +2041,8 @@ long syscall, afscall, param1, param2, param3, param4; return code; } -int uafs_SetTokens(char *tbuffer, int tlen) +int +uafs_SetTokens(char *tbuffer, int tlen) { int rc; struct afs_ioctl iob; @@ -2014,7 +2060,8 @@ int uafs_SetTokens(char *tbuffer, int tlen) return 0; } -int uafs_RPCStatsEnableProc(void) +int +uafs_RPCStatsEnableProc(void) { int rc; struct afs_ioctl iob; @@ -2033,7 +2080,8 @@ int uafs_RPCStatsEnableProc(void) return rc; } -int uafs_RPCStatsDisableProc(void) +int +uafs_RPCStatsDisableProc(void) { int rc; struct afs_ioctl iob; @@ -2052,7 +2100,8 @@ int uafs_RPCStatsDisableProc(void) return rc; } -int uafs_RPCStatsClearProc(void) +int +uafs_RPCStatsClearProc(void) { int rc; struct afs_ioctl iob; @@ -2071,7 +2120,8 @@ int uafs_RPCStatsClearProc(void) return rc; } -int uafs_RPCStatsEnablePeer(void) +int +uafs_RPCStatsEnablePeer(void) { int rc; struct afs_ioctl iob; @@ -2090,7 +2140,8 @@ int uafs_RPCStatsEnablePeer(void) return rc; } -int uafs_RPCStatsDisablePeer(void) +int +uafs_RPCStatsDisablePeer(void) { int rc; struct afs_ioctl iob; @@ -2109,7 +2160,8 @@ int uafs_RPCStatsDisablePeer(void) return rc; } -int uafs_RPCStatsClearPeer(void) +int +uafs_RPCStatsClearPeer(void) { int rc; struct afs_ioctl iob; @@ -2135,12 +2187,9 @@ int uafs_RPCStatsClearPeer(void) * * Note: Caller must hold the AFS global lock. */ -int uafs_LookupName( - char *path, - struct usr_vnode *parentVp, - struct usr_vnode **vpp, - int follow, - int no_eval_mtpt) +int +uafs_LookupName(char *path, struct usr_vnode *parentVp, + struct usr_vnode **vpp, int follow, int no_eval_mtpt) { int code; int linkCount; @@ -2169,7 +2218,7 @@ int uafs_LookupName( /* * Loop through the path looking for the new directory */ - tmpPath = afs_osi_Alloc(strlen(path)+1); + tmpPath = afs_osi_Alloc(strlen(path) + 1); usr_assert(tmpPath != NULL); strcpy(tmpPath, path); VN_HOLD(vp); @@ -2192,7 +2241,7 @@ int uafs_LookupName( */ if (vp->v_type != VDIR) { VN_RELE(vp); - afs_osi_Free(tmpPath, strlen(path)+1); + afs_osi_Free(tmpPath, strlen(path) + 1); return ENOTDIR; } @@ -2208,7 +2257,7 @@ int uafs_LookupName( code = afs_access(vp, VEXEC, u.u_cred); if (code != 0) { VN_RELE(vp); - afs_osi_Free(tmpPath, strlen(path)+1); + afs_osi_Free(tmpPath, strlen(path) + 1); return code; } @@ -2218,16 +2267,18 @@ int uafs_LookupName( */ nextVp = NULL; #ifdef AFS_WEB_ENHANCEMENTS - if ((nextPathP != NULL && *nextPathP != '\0') || !no_eval_mtpt) - code = afs_lookup(vp, pathP, &nextVp, u.u_cred, 0); - else - code = afs_lookup(vp, pathP, &nextVp, u.u_cred, AFS_LOOKUP_NOEVAL); + if ((nextPathP != NULL && *nextPathP != '\0') || !no_eval_mtpt) + code = afs_lookup(vp, pathP, &nextVp, u.u_cred, 0); + else + code = + afs_lookup(vp, pathP, &nextVp, u.u_cred, + AFS_LOOKUP_NOEVAL); #else - code = afs_lookup(vp, pathP, &nextVp, u.u_cred, 0); + code = afs_lookup(vp, pathP, &nextVp, u.u_cred, 0); #endif /* AFS_WEB_ENHANCEMENTS */ if (code != 0) { VN_RELE(vp); - afs_osi_Free(tmpPath, strlen(path)+1); + afs_osi_Free(tmpPath, strlen(path) + 1); return code; } } @@ -2238,18 +2289,18 @@ int uafs_LookupName( */ if ((nextPathP != NULL && *nextPathP != '\0') || follow) { linkCount = 0; - while(nextVp->v_type == VLNK) { + while (nextVp->v_type == VLNK) { if (++linkCount > MAX_OSI_LINKS) { VN_RELE(vp); VN_RELE(nextVp); - afs_osi_Free(tmpPath, strlen(path)+1); + afs_osi_Free(tmpPath, strlen(path) + 1); return code; } code = uafs_LookupLink(nextVp, vp, &linkVp); if (code) { VN_RELE(vp); VN_RELE(nextVp); - afs_osi_Free(tmpPath, strlen(path)+1); + afs_osi_Free(tmpPath, strlen(path) + 1); return code; } VN_RELE(nextVp); @@ -2267,11 +2318,11 @@ int uafs_LookupName( */ if (nextPathP != NULL && vp->v_type != VDIR) { VN_RELE(vp); - afs_osi_Free(tmpPath, strlen(path)+1); + afs_osi_Free(tmpPath, strlen(path) + 1); return ENOTDIR; } - afs_osi_Free(tmpPath, strlen(path)+1); + afs_osi_Free(tmpPath, strlen(path) + 1); *vpp = vp; return 0; } @@ -2283,10 +2334,9 @@ int uafs_LookupName( * * Note: Caller must hold the AFS global lock. */ -int uafs_LookupLink( - struct usr_vnode *vp, - struct usr_vnode *parentVp, - struct usr_vnode **vpp) +int +uafs_LookupLink(struct usr_vnode *vp, struct usr_vnode *parentVp, + struct usr_vnode **vpp) { int code; int len; @@ -2297,27 +2347,27 @@ int uafs_LookupLink( AFS_ASSERT_GLOCK(); - pathP = afs_osi_Alloc(MAX_OSI_PATH+1); + pathP = afs_osi_Alloc(MAX_OSI_PATH + 1); usr_assert(pathP != NULL); /* * set up the uio buffer */ iov[0].iov_base = pathP; - iov[0].iov_len = MAX_OSI_PATH+1; + iov[0].iov_len = MAX_OSI_PATH + 1; uio.uio_iov = &iov[0]; uio.uio_iovcnt = 1; uio.uio_offset = 0; uio.uio_segflg = 0; uio.uio_fmode = FREAD; - uio.uio_resid = MAX_OSI_PATH+1; + uio.uio_resid = MAX_OSI_PATH + 1; /* * Read the link data */ code = afs_readlink(vp, &uio, u.u_cred); if (code) { - afs_osi_Free(pathP, MAX_OSI_PATH+1); + afs_osi_Free(pathP, MAX_OSI_PATH + 1); return code; } len = MAX_OSI_PATH + 1 - uio.uio_resid; @@ -2328,11 +2378,11 @@ int uafs_LookupLink( */ code = uafs_LookupName(pathP, parentVp, &linkVp, 1, 0); if (code) { - afs_osi_Free(pathP, MAX_OSI_PATH+1); + afs_osi_Free(pathP, MAX_OSI_PATH + 1); return code; } - afs_osi_Free(pathP, MAX_OSI_PATH+1); + afs_osi_Free(pathP, MAX_OSI_PATH + 1); *vpp = linkVp; return 0; } @@ -2344,9 +2394,8 @@ int uafs_LookupLink( * * Note: Caller must hold the AFS global lock. */ -int uafs_LookupParent( - char *path, - struct usr_vnode **vpp) +int +uafs_LookupParent(char *path, struct usr_vnode **vpp) { int len; int code; @@ -2369,13 +2418,13 @@ int uafs_LookupParent( * Find the length of the parent path */ len = strlen(path); - while(len > 0 && path[len-1] == '/') { + while (len > 0 && path[len - 1] == '/') { len--; } if (len == 0) { return EINVAL; } - while(len > 0 && path[len-1] != '/') { + while (len > 0 && path[len - 1] != '/') { len--; } if (len == 0) { @@ -2384,8 +2433,8 @@ int uafs_LookupParent( pathP = afs_osi_Alloc(len); usr_assert(pathP != NULL); - memcpy(pathP, path, len-1); - pathP[len-1] = '\0'; + memcpy(pathP, path, len - 1); + pathP[len - 1] = '\0'; /* * look up the parent @@ -2408,15 +2457,16 @@ int uafs_LookupParent( * Return a pointer to the first character in the last component * of a pathname */ -char *uafs_LastPath(char *path) +char * +uafs_LastPath(char *path) { int len; len = strlen(path); - while (len > 0 && path[len-1] == '/') { + while (len > 0 && path[len - 1] == '/') { len--; } - while (len > 0 && path[len-1] != '/') { + while (len > 0 && path[len - 1] != '/') { len--; } if (len == 0) { @@ -2428,7 +2478,8 @@ char *uafs_LastPath(char *path) /* * Set the working directory. */ -int uafs_chdir(char *path) +int +uafs_chdir(char *path) { int retval; AFS_GLOCK(); @@ -2437,7 +2488,8 @@ int uafs_chdir(char *path) return retval; } -int uafs_chdir_r(char *path) +int +uafs_chdir_r(char *path) { int code; struct vnode *dirP; @@ -2460,7 +2512,8 @@ int uafs_chdir_r(char *path) /* * Create a directory. */ -int uafs_mkdir(char *path, int mode) +int +uafs_mkdir(char *path, int mode) { int retval; AFS_GLOCK(); @@ -2469,7 +2522,8 @@ int uafs_mkdir(char *path, int mode) return retval; } -int uafs_mkdir_r(char *path, int mode) +int +uafs_mkdir_r(char *path, int mode) { int code; char *nameP; @@ -2528,9 +2582,10 @@ int uafs_mkdir_r(char *path, int mode) /* * Return 1 if path is the AFS root, otherwise return 0 */ -int uafs_IsRoot(char *path) +int +uafs_IsRoot(char *path) { - while(*path == '/' && *(path+1) == '/') { + while (*path == '/' && *(path + 1) == '/') { path++; } if (strncmp(path, afs_mountDir, afs_mountDirLen) != 0) { @@ -2550,7 +2605,8 @@ int uafs_IsRoot(char *path) * Open a file * Note: file name may not end in a slash. */ -int uafs_open(char *path, int flags, int mode) +int +uafs_open(char *path, int flags, int mode) { int retval; AFS_GLOCK(); @@ -2559,7 +2615,8 @@ int uafs_open(char *path, int flags, int mode) return retval; } -int uafs_open_r(char *path, int flags, int mode) +int +uafs_open_r(char *path, int flags, int mode) { int fd; int code; @@ -2612,13 +2669,14 @@ int uafs_open_r(char *path, int flags, int mode) attrs.va_size = 0; } fileP = NULL; - code = afs_create(dirP, nameP, &attrs, - (flags & O_EXCL)?usr_EXCL:usr_NONEXCL, - mode, &fileP, u.u_cred); + code = + afs_create(dirP, nameP, &attrs, + (flags & O_EXCL) ? usr_EXCL : usr_NONEXCL, mode, + &fileP, u.u_cred); VN_RELE(dirP); if (code != 0) { - errno = code; - return -1; + errno = code; + return -1; } } else { fileP = NULL; @@ -2633,13 +2691,14 @@ int uafs_open_r(char *path, int flags, int mode) * Check whether we have access to this file */ fileMode = 0; - if (flags & (O_RDONLY|O_RDWR)) { + if (flags & (O_RDONLY | O_RDWR)) { fileMode |= VREAD; } - if (flags & (O_WRONLY|O_RDWR)) { + if (flags & (O_WRONLY | O_RDWR)) { fileMode |= VWRITE; } - if (!fileMode) fileMode = VREAD; /* since O_RDONLY is 0 */ + if (!fileMode) + fileMode = VREAD; /* since O_RDONLY is 0 */ code = afs_access(fileP, fileMode, u.u_cred); if (code != 0) { VN_RELE(fileP); @@ -2675,10 +2734,10 @@ int uafs_open_r(char *path, int flags, int mode) if (flags & O_SYNC) { openFlags |= FSYNC; } - if (flags & (O_RDONLY|O_RDWR)) { + if (flags & (O_RDONLY | O_RDWR)) { openFlags |= FREAD; } - if (flags & (O_WRONLY|O_RDWR)) { + if (flags & (O_WRONLY | O_RDWR)) { openFlags |= FWRITE; } @@ -2709,7 +2768,7 @@ int uafs_open_r(char *path, int flags, int mode) /* * Put the vnode pointer into the file table */ - for (fd = 0 ; fd < MAX_OSI_FILES ; fd++) { + for (fd = 0; fd < MAX_OSI_FILES; fd++) { if (afs_FileTable[fd] == NULL) { afs_FileTable[fd] = fileP; afs_FileFlags[fd] = openFlags; @@ -2733,24 +2792,27 @@ int uafs_open_r(char *path, int flags, int mode) /* * Create a file */ -int uafs_creat(char *path, int mode) +int +uafs_creat(char *path, int mode) { int rc; - rc = uafs_open(path, O_CREAT|O_WRONLY|O_TRUNC, mode); + rc = uafs_open(path, O_CREAT | O_WRONLY | O_TRUNC, mode); return rc; } -int uafs_creat_r(char *path, int mode) +int +uafs_creat_r(char *path, int mode) { int rc; - rc = uafs_open_r(path, O_CREAT|O_WRONLY|O_TRUNC, mode); + rc = uafs_open_r(path, O_CREAT | O_WRONLY | O_TRUNC, mode); return rc; } /* * Write to a file */ -int uafs_write(int fd, char *buf, int len) +int +uafs_write(int fd, char *buf, int len) { int retval; AFS_GLOCK(); @@ -2759,7 +2821,8 @@ int uafs_write(int fd, char *buf, int len) return retval; } -int uafs_write_r(int fd, char *buf, int len) +int +uafs_write_r(int fd, char *buf, int len) { int code; struct usr_uio uio; @@ -2798,13 +2861,14 @@ int uafs_write_r(int fd, char *buf, int len) } afs_FileOffsets[fd] = uio.uio_offset; - return(len - uio.uio_resid); + return (len - uio.uio_resid); } /* * Read from a file */ -int uafs_read(int fd, char *buf, int len) +int +uafs_read(int fd, char *buf, int len) { int retval; AFS_GLOCK(); @@ -2813,7 +2877,8 @@ int uafs_read(int fd, char *buf, int len) return retval; } -int uafs_read_r(int fd, char *buf, int len) +int +uafs_read_r(int fd, char *buf, int len) { int code; struct usr_uio uio; @@ -2852,7 +2917,7 @@ int uafs_read_r(int fd, char *buf, int len) } afs_FileOffsets[fd] = uio.uio_offset; - return(len - uio.uio_resid); + return (len - uio.uio_resid); } /* @@ -2860,7 +2925,8 @@ int uafs_read_r(int fd, char *buf, int len) * * NOTE: Caller must hold the global AFS lock. */ -int uafs_GetAttr(struct usr_vnode *vp, struct stat *stats) +int +uafs_GetAttr(struct usr_vnode *vp, struct stat *stats) { int code; struct usr_vattr attrs; @@ -2899,9 +2965,8 @@ int uafs_GetAttr(struct usr_vnode *vp, struct stat *stats) /* * Get the attributes of a file, do follow links */ -int uafs_stat( - char *path, - struct stat *buf) +int +uafs_stat(char *path, struct stat *buf) { int retval; AFS_GLOCK(); @@ -2910,9 +2975,8 @@ int uafs_stat( return retval; } -int uafs_stat_r( - char *path, - struct stat *buf) +int +uafs_stat_r(char *path, struct stat *buf) { int code; struct vnode *vp; @@ -2934,9 +2998,8 @@ int uafs_stat_r( /* * Get the attributes of a file, don't follow links */ -int uafs_lstat( - char *path, - struct stat *buf) +int +uafs_lstat(char *path, struct stat *buf) { int retval; AFS_GLOCK(); @@ -2945,9 +3008,8 @@ int uafs_lstat( return retval; } -int uafs_lstat_r( - char *path, - struct stat *buf) +int +uafs_lstat_r(char *path, struct stat *buf) { int code; struct vnode *vp; @@ -2969,9 +3031,8 @@ int uafs_lstat_r( /* * Get the attributes of an open file */ -int uafs_fstat( - int fd, - struct stat *buf) +int +uafs_fstat(int fd, struct stat *buf) { int retval; AFS_GLOCK(); @@ -2980,9 +3041,8 @@ int uafs_fstat( return retval; } -int uafs_fstat_r( - int fd, - struct stat *buf) +int +uafs_fstat_r(int fd, struct stat *buf) { int code; struct vnode *vp; @@ -3004,9 +3064,8 @@ int uafs_fstat_r( /* * change the permissions on a file */ -int uafs_chmod( - char *path, - int mode) +int +uafs_chmod(char *path, int mode) { int retval; AFS_GLOCK(); @@ -3015,9 +3074,8 @@ int uafs_chmod( return retval; } -int uafs_chmod_r( - char *path, - int mode) +int +uafs_chmod_r(char *path, int mode) { int code; struct vnode *vp; @@ -3042,9 +3100,8 @@ int uafs_chmod_r( /* * change the permissions on an open file */ -int uafs_fchmod( - int fd, - int mode) +int +uafs_fchmod(int fd, int mode) { int retval; AFS_GLOCK(); @@ -3053,9 +3110,8 @@ int uafs_fchmod( return retval; } -int uafs_fchmod_r( - int fd, - int mode) +int +uafs_fchmod_r(int fd, int mode) { int code; struct vnode *vp; @@ -3079,9 +3135,8 @@ int uafs_fchmod_r( /* * truncate a file */ -int uafs_truncate( - char *path, - int length) +int +uafs_truncate(char *path, int length) { int retval; AFS_GLOCK(); @@ -3090,9 +3145,8 @@ int uafs_truncate( return retval; } -int uafs_truncate_r( - char *path, - int length) +int +uafs_truncate_r(char *path, int length) { int code; struct vnode *vp; @@ -3117,9 +3171,8 @@ int uafs_truncate_r( /* * truncate an open file */ -int uafs_ftruncate( - int fd, - int length) +int +uafs_ftruncate(int fd, int length) { int retval; AFS_GLOCK(); @@ -3128,9 +3181,8 @@ int uafs_ftruncate( return retval; } -int uafs_ftruncate_r( - int fd, - int length) +int +uafs_ftruncate_r(int fd, int length) { int code; struct vnode *vp; @@ -3154,10 +3206,8 @@ int uafs_ftruncate_r( /* * set the read/write file pointer of an open file */ -int uafs_lseek( - int fd, - int offset, - int whence) +int +uafs_lseek(int fd, int offset, int whence) { int retval; AFS_GLOCK(); @@ -3166,10 +3216,8 @@ int uafs_lseek( return retval; } -int uafs_lseek_r( - int fd, - int offset, - int whence) +int +uafs_lseek_r(int fd, int offset, int whence) { int code; int newpos; @@ -3182,13 +3230,13 @@ int uafs_lseek_r( return -1; } switch (whence) { - case SEEK_CUR: + case SEEK_CUR: newpos = afs_FileOffsets[fd] + offset; break; - case SEEK_SET: + case SEEK_SET: newpos = offset; break; - case SEEK_END: + case SEEK_END: code = afs_getattr(vp, &attrs, u.u_cred); if (code != 0) { errno = code; @@ -3196,7 +3244,7 @@ int uafs_lseek_r( } newpos = attrs.va_size + offset; break; - default: + default: errno = EINVAL; return -1; } @@ -3211,8 +3259,8 @@ int uafs_lseek_r( /* * sync a file */ -int uafs_fsync( - int fd) +int +uafs_fsync(int fd) { int retval; AFS_GLOCK(); @@ -3221,8 +3269,8 @@ int uafs_fsync( return retval; } -int uafs_fsync_r( - int fd) +int +uafs_fsync_r(int fd) { int code; struct usr_vnode *fileP; @@ -3240,14 +3288,14 @@ int uafs_fsync_r( return -1; } - return 0; + return 0; } /* * Close a file */ -int uafs_close( - int fd) +int +uafs_close(int fd) { int retval; AFS_GLOCK(); @@ -3256,8 +3304,8 @@ int uafs_close( return retval; } -int uafs_close_r( - int fd) +int +uafs_close_r(int fd) { int code; struct usr_vnode *fileP; @@ -3276,16 +3324,15 @@ int uafs_close_r( return -1; } - return 0; + return 0; } /* * Create a hard link from the source to the target * Note: file names may not end in a slash. */ -int uafs_link( - char *existing, - char *new) +int +uafs_link(char *existing, char *new) { int retval; AFS_GLOCK(); @@ -3294,9 +3341,8 @@ int uafs_link( return retval; } -int uafs_link_r( - char *existing, - char *new) +int +uafs_link_r(char *existing, char *new) { int code; struct usr_vnode *existP; @@ -3360,9 +3406,8 @@ int uafs_link_r( * Create a symbolic link from the source to the target * Note: file names may not end in a slash. */ -int uafs_symlink( - char *target, - char *source) +int +uafs_symlink(char *target, char *source) { int retval; AFS_GLOCK(); @@ -3371,9 +3416,8 @@ int uafs_symlink( return retval; } -int uafs_symlink_r( - char *target, - char *source) +int +uafs_symlink_r(char *target, char *source) { int code; struct usr_vnode *dirP; @@ -3429,10 +3473,8 @@ int uafs_symlink_r( /* * Read a symbolic link into the buffer */ -int uafs_readlink( - char *path, - char *buf, - int len) +int +uafs_readlink(char *path, char *buf, int len) { int retval; AFS_GLOCK(); @@ -3441,10 +3483,8 @@ int uafs_readlink( return retval; } -int uafs_readlink_r( - char *path, - char *buf, - int len) +int +uafs_readlink_r(char *path, char *buf, int len) { int code; struct usr_vnode *vp; @@ -3481,7 +3521,7 @@ int uafs_readlink_r( code = afs_readlink(vp, &uio, u.u_cred); VN_RELE(vp); if (code) { - errno = code; + errno = code; return -1; } @@ -3495,8 +3535,8 @@ int uafs_readlink_r( * Remove a file (or directory) * Note: file name may not end in a slash. */ -int uafs_unlink( - char *path) +int +uafs_unlink(char *path) { int retval; AFS_GLOCK(); @@ -3505,8 +3545,8 @@ int uafs_unlink( return retval; } -int uafs_unlink_r( - char *path) +int +uafs_unlink_r(char *path) { int code; int openFlags; @@ -3559,9 +3599,8 @@ int uafs_unlink_r( /* * Rename a file (or directory) */ -int uafs_rename( - char *old, - char *new) +int +uafs_rename(char *old, char *new) { int retval; AFS_GLOCK(); @@ -3570,9 +3609,8 @@ int uafs_rename( return retval; } -int uafs_rename_r( - char *old, - char *new) +int +uafs_rename_r(char *old, char *new) { int code; char *onameP; @@ -3640,8 +3678,8 @@ int uafs_rename_r( * Remove a or directory * Note: file name may not end in a slash. */ -int uafs_rmdir( - char *path) +int +uafs_rmdir(char *path) { int retval; AFS_GLOCK(); @@ -3650,8 +3688,8 @@ int uafs_rmdir( return retval; } -int uafs_rmdir_r( - char *path) +int +uafs_rmdir_r(char *path) { int code; int openFlags; @@ -3704,8 +3742,8 @@ int uafs_rmdir_r( /* * Flush a file from the AFS cache */ -int uafs_FlushFile( - char *path) +int +uafs_FlushFile(char *path) { int code; struct afs_ioctl iob; @@ -3715,8 +3753,9 @@ int uafs_FlushFile( iob.out = NULL; iob.out_size = 0; - code = call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(6), - (long)&iob, 0, 0); + code = + call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(6), (long)&iob, 0, + 0); if (code != 0) { errno = code; return -1; @@ -3724,8 +3763,9 @@ int uafs_FlushFile( return 0; } -int uafs_FlushFile_r( - char *path) + +int +uafs_FlushFile_r(char *path) { int retval; AFS_GUNLOCK(); @@ -3737,8 +3777,8 @@ int uafs_FlushFile_r( /* * open a directory */ -usr_DIR *uafs_opendir( - char *path) +usr_DIR * +uafs_opendir(char *path) { usr_DIR *retval; AFS_GLOCK(); @@ -3747,8 +3787,8 @@ usr_DIR *uafs_opendir( return retval; } -usr_DIR *uafs_opendir_r( - char *path) +usr_DIR * +uafs_opendir_r(char *path) { usr_DIR *dirp; struct usr_vnode *fileP; @@ -3764,22 +3804,23 @@ usr_DIR *uafs_opendir_r( fileP = afs_FileTable[fd]; if (fileP == NULL) { - return NULL; + return NULL; } if (fileP->v_type != VDIR) { - uafs_close_r(fd); - errno = ENOTDIR; - return NULL; + uafs_close_r(fd); + errno = ENOTDIR; + return NULL; } /* * Set up the directory structures */ - dirp = (usr_DIR *)afs_osi_Alloc(sizeof(usr_DIR) + USR_DIRSIZE + - sizeof(struct usr_dirent)); + dirp = + (usr_DIR *) afs_osi_Alloc(sizeof(usr_DIR) + USR_DIRSIZE + + sizeof(struct usr_dirent)); usr_assert(dirp != NULL); - dirp->dd_buf = (char *)(dirp+1); + dirp->dd_buf = (char *)(dirp + 1); dirp->dd_fd = fd; dirp->dd_loc = 0; dirp->dd_size = 0; @@ -3793,10 +3834,8 @@ usr_DIR *uafs_opendir_r( * This routine was developed to support AFS cache consistency testing. * You should use uafs_readdir instead. */ -int uafs_getdents( - int fd, - struct min_direct *buf, - int len) +int +uafs_getdents(int fd, struct min_direct *buf, int len) { int retval; AFS_GLOCK(); @@ -3805,10 +3844,8 @@ int uafs_getdents( return retval; } -int uafs_getdents_r( - int fd, - struct min_direct *buf, - int len) +int +uafs_getdents_r(int fd, struct min_direct *buf, int len) { int code; struct usr_uio uio; @@ -3847,14 +3884,14 @@ int uafs_getdents_r( } afs_FileOffsets[fd] = uio.uio_offset; - return(len - uio.uio_resid); + return (len - uio.uio_resid); } /* * read from a directory (names only) */ -struct usr_dirent *uafs_readdir( - usr_DIR *dirp) +struct usr_dirent * +uafs_readdir(usr_DIR * dirp) { struct usr_dirent *retval; AFS_GLOCK(); @@ -3863,8 +3900,8 @@ struct usr_dirent *uafs_readdir( return retval; } -struct usr_dirent *uafs_readdir_r( - usr_DIR *dirp) +struct usr_dirent * +uafs_readdir_r(usr_DIR * dirp) { int rc; int code; @@ -3888,7 +3925,7 @@ struct usr_dirent *uafs_readdir_r( * If there are no entries in the stream buffer * then read another chunk */ - directP = (struct min_direct *)(dirp->dd_buf+dirp->dd_loc); + directP = (struct min_direct *)(dirp->dd_buf + dirp->dd_loc); if (dirp->dd_size == 0 || directP->d_fileno == 0) { /* * set up the uio buffer @@ -3914,7 +3951,7 @@ struct usr_dirent *uafs_readdir_r( dirp->dd_size = USR_DIRSIZE - iov[0].iov_len; dirp->dd_loc = 0; - directP = (struct min_direct *)(dirp->dd_buf+dirp->dd_loc); + directP = (struct min_direct *)(dirp->dd_buf + dirp->dd_loc); } /* @@ -3924,18 +3961,18 @@ struct usr_dirent *uafs_readdir_r( errno = 0; return NULL; } - len = ((sizeof(struct min_direct)+directP->d_namlen+4) & (~3)); + len = ((sizeof(struct min_direct) + directP->d_namlen + 4) & (~3)); usr_assert(len <= dirp->dd_size); /* * Copy the next entry into the usr_dirent structure and advance */ - direntP = (struct usr_dirent *)(dirp->dd_buf+USR_DIRSIZE); + direntP = (struct usr_dirent *)(dirp->dd_buf + USR_DIRSIZE); direntP->d_ino = directP->d_fileno; direntP->d_off = direntP->d_reclen; - direntP->d_reclen = sizeof(struct usr_dirent) - MAXNAMLEN + - directP->d_namlen + 1; - memcpy(&direntP->d_name[0], (void *)(directP+1), directP->d_namlen); + direntP->d_reclen = + sizeof(struct usr_dirent) - MAXNAMLEN + directP->d_namlen + 1; + memcpy(&direntP->d_name[0], (void *)(directP + 1), directP->d_namlen); direntP->d_name[directP->d_namlen] = '\0'; dirp->dd_loc += len; dirp->dd_size -= len; @@ -3946,8 +3983,8 @@ struct usr_dirent *uafs_readdir_r( /* * Close a directory */ -int uafs_closedir( - usr_DIR *dirp) +int +uafs_closedir(usr_DIR * dirp) { int retval; AFS_GLOCK(); @@ -3956,8 +3993,8 @@ int uafs_closedir( return retval; } -int uafs_closedir_r( - usr_DIR *dirp) +int +uafs_closedir_r(usr_DIR * dirp) { int fd; int rc; @@ -3972,29 +4009,23 @@ int uafs_closedir_r( /* * Do AFS authentication */ -int uafs_klog( - char *user, - char *cell, - char *passwd, - char **reason) +int +uafs_klog(char *user, char *cell, char *passwd, char **reason) { int code; afs_int32 password_expires = -1; usr_mutex_lock(&osi_authenticate_lock); - code = ka_UserAuthenticateGeneral( - KA_USERAUTH_VERSION+KA_USERAUTH_DOSETPAG2, user, - NULL, cell, passwd, 0, &password_expires, - 0, reason); + code = + ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION + + KA_USERAUTH_DOSETPAG2, user, NULL, cell, + passwd, 0, &password_expires, 0, reason); usr_mutex_unlock(&osi_authenticate_lock); return code; } -int uafs_klog_r( - char *user, - char *cell, - char *passwd, - char **reason) +int +uafs_klog_r(char *user, char *cell, char *passwd, char **reason) { int retval; AFS_GUNLOCK(); @@ -4006,7 +4037,8 @@ int uafs_klog_r( /* * Destroy AFS credentials from the kernel cache */ -int uafs_unlog(void) +int +uafs_unlog(void) { int code; @@ -4016,7 +4048,8 @@ int uafs_unlog(void) return code; } -int uafs_unlog_r(void) +int +uafs_unlog_r(void) { int retval; AFS_GUNLOCK(); @@ -4030,7 +4063,8 @@ int uafs_unlog_r(void) * NULL if the path is a relative pathname or if the path * doesn't start with the AFS mount point string. */ -char *uafs_afsPathName(char *path) +char * +uafs_afsPathName(char *path) { char *p; char lastchar; @@ -4039,7 +4073,7 @@ char *uafs_afsPathName(char *path) if (path[0] != '/') return NULL; lastchar = '/'; - for (i = 1, p = path+1; *p != '\0' ; p++) { + for (i = 1, p = path + 1; *p != '\0'; p++) { /* Ignore duplicate slashes */ if (*p == '/' && lastchar == '/') continue; @@ -4068,20 +4102,17 @@ char *uafs_afsPathName(char *path) * uafs_klog_nopag * klog but don't allocate a new pag */ -int uafs_klog_nopag( - char *user, - char *cell, - char *passwd, - char **reason) +int +uafs_klog_nopag(char *user, char *cell, char *passwd, char **reason) { int code; afs_int32 password_expires = -1; usr_mutex_lock(&osi_authenticate_lock); - code = ka_UserAuthenticateGeneral( - KA_USERAUTH_VERSION /*+KA_USERAUTH_DOSETPAG2*/, user, - NULL, cell, passwd, 0, &password_expires, - 0, reason); + code = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION + /*+KA_USERAUTH_DOSETPAG2 */ , user, + NULL, cell, passwd, 0, + &password_expires, 0, reason); usr_mutex_unlock(&osi_authenticate_lock); return code; } @@ -4090,88 +4121,91 @@ int uafs_klog_nopag( * uafs_getcellstatus * get the cell status */ -int uafs_getcellstatus(char *cell, afs_int32 *status) +int +uafs_getcellstatus(char *cell, afs_int32 * status) { - int rc; - struct afs_ioctl iob; + int rc; + struct afs_ioctl iob; - iob.in = cell; - iob.in_size = strlen(cell)+1; - iob.out = 0; - iob.out_size = 0; + iob.in = cell; + iob.in_size = strlen(cell) + 1; + iob.out = 0; + iob.out_size = 0; - rc = call_syscall(AFSCALL_PIOCTL, /*path*/0, _VICEIOCTL(35), - (long)&iob, 0, 0); + rc = call_syscall(AFSCALL_PIOCTL, /*path */ 0, _VICEIOCTL(35), + (long)&iob, 0, 0); - if (rc < 0) { - errno = rc; - return -1; - } + if (rc < 0) { + errno = rc; + return -1; + } - *status = (afs_int32) iob.out; - return 0; + *status = (afs_int32) iob.out; + return 0; } /* * uafs_getvolquota * Get quota of volume associated with path */ -int uafs_getvolquota(char *path, afs_int32 *BlocksInUse, afs_int32 *MaxQuota) +int +uafs_getvolquota(char *path, afs_int32 * BlocksInUse, afs_int32 * MaxQuota) { - int rc; - struct afs_ioctl iob; - VolumeStatus *status; - char buf[1024]; + int rc; + struct afs_ioctl iob; + VolumeStatus *status; + char buf[1024]; - iob.in = 0; - iob.in_size = 0; - iob.out = buf; - iob.out_size = 1024; + iob.in = 0; + iob.in_size = 0; + iob.out = buf; + iob.out_size = 1024; - rc = call_syscall(AFSCALL_PIOCTL, (long) path, _VICEIOCTL(4), - (long)&iob, 0, 0); + rc = call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(4), (long)&iob, + 0, 0); - if (rc != 0) { - errno = rc; - return -1; - } + if (rc != 0) { + errno = rc; + return -1; + } - status = (VolumeStatus *) buf; - *BlocksInUse = status->BlocksInUse; - *MaxQuota = status->MaxQuota; - return 0; + status = (VolumeStatus *) buf; + *BlocksInUse = status->BlocksInUse; + *MaxQuota = status->MaxQuota; + return 0; } /* * uafs_setvolquota * Set quota of volume associated with path */ -int uafs_setvolquota(char *path, afs_int32 MaxQuota) +int +uafs_setvolquota(char *path, afs_int32 MaxQuota) { - int rc; - struct afs_ioctl iob; - VolumeStatus *status; - char buf[1024]; + int rc; + struct afs_ioctl iob; + VolumeStatus *status; + char buf[1024]; - iob.in = buf; - iob.in_size = 1024; - iob.out = 0; - iob.out_size = 0; + iob.in = buf; + iob.in_size = 1024; + iob.out = 0; + iob.out_size = 0; - memset(buf, 0, sizeof(VolumeStatus)); - status = (VolumeStatus *) buf; - status->MaxQuota = MaxQuota; - status->MinQuota = -1; + memset(buf, 0, sizeof(VolumeStatus)); + status = (VolumeStatus *) buf; + status->MaxQuota = MaxQuota; + status->MinQuota = -1; - rc = call_syscall(AFSCALL_PIOCTL, (long) path, _VICEIOCTL(5), - (long)&iob, 0, 0); + rc = call_syscall(AFSCALL_PIOCTL, (long)path, _VICEIOCTL(5), (long)&iob, + 0, 0); - if (rc != 0) { - errno = rc; - return -1; - } + if (rc != 0) { + errno = rc; + return -1; + } - return 0; + return 0; } /* @@ -4179,7 +4213,8 @@ int uafs_setvolquota(char *path, afs_int32 MaxQuota) * Determine whether a dir. is a mount point or not * return 1 if mount point, 0 if not */ -int uafs_statmountpoint(char *path) +int +uafs_statmountpoint(char *path) { int retval; int code; @@ -4191,7 +4226,8 @@ int uafs_statmountpoint(char *path) return retval; } -int uafs_statmountpoint_r(char *path) +int +uafs_statmountpoint_r(char *path) { int code; struct vnode *vp; @@ -4201,8 +4237,8 @@ int uafs_statmountpoint_r(char *path) code = uafs_LookupName(path, afs_CurrentDir, &vp, 0, 1); if (code != 0) { - errno = code; - return -1; + errno = code; + return -1; } avc = VTOAFS(vp); @@ -4216,7 +4252,8 @@ int uafs_statmountpoint_r(char *path) * uafs_getRights * Get a list of rights for the current user on path. */ -int uafs_getRights(char *path) +int +uafs_getRights(char *path) { int code, rc; struct vnode *vp; @@ -4225,20 +4262,16 @@ int uafs_getRights(char *path) AFS_GLOCK(); code = uafs_LookupName(path, afs_CurrentDir, &vp, 1, 0); if (code != 0) { - errno = code; - AFS_GUNLOCK(); - return -1; + errno = code; + AFS_GUNLOCK(); + return -1; } - afs_rights = PRSFS_READ | - PRSFS_WRITE | - PRSFS_INSERT | - PRSFS_LOOKUP | - PRSFS_DELETE | - PRSFS_LOCK | - PRSFS_ADMINISTER; + afs_rights = + PRSFS_READ | PRSFS_WRITE | PRSFS_INSERT | PRSFS_LOOKUP | PRSFS_DELETE + | PRSFS_LOCK | PRSFS_ADMINISTER; - afs_rights = afs_getRights (vp, afs_rights, u.u_cred); + afs_rights = afs_getRights(vp, afs_rights, u.u_cred); AFS_GUNLOCK(); return afs_rights; diff --git a/src/afs/UKERNEL/afs_usrops.h b/src/afs/UKERNEL/afs_usrops.h index 0ef5fe6e4..b119d2d14 100644 --- a/src/afs/UKERNEL/afs_usrops.h +++ b/src/afs/UKERNEL/afs_usrops.h @@ -68,14 +68,14 @@ extern int afs_mountDirLen; extern void uafs_InitClient(void); extern void uafs_InitThread(void); -extern void uafs_Init(char *, char *, char *, char *, int, int, int, int, - int, int, int, int, int, int, char *); +extern void uafs_Init(char *, char *, char *, char *, int, int, int, int, int, + int, int, int, int, int, char *); extern void uafs_RxServerProc(void); extern int uafs_LookupLink(struct usr_vnode *vp, struct usr_vnode *parentP, struct usr_vnode **vpp); extern int uafs_LookupName(char *path, struct usr_vnode *parentP, struct usr_vnode **vpp, int follow, - int no_eval_mtpt); + int no_eval_mtpt); extern int uafs_LookupParent(char *path, struct usr_vnode **vpp); extern int uafs_GetAttr(struct usr_vnode *vp, struct stat *stats); @@ -127,16 +127,16 @@ extern int uafs_FlushFile(char *path); extern int uafs_FlushFile_r(char *path); extern usr_DIR *uafs_opendir(char *path); extern usr_DIR *uafs_opendir_r(char *path); -extern struct usr_dirent *uafs_readdir(usr_DIR *dirp); -extern struct usr_dirent *uafs_readdir_r(usr_DIR *dirp); +extern struct usr_dirent *uafs_readdir(usr_DIR * dirp); +extern struct usr_dirent *uafs_readdir_r(usr_DIR * dirp); extern int uafs_getdents(int fd, struct min_direct *buf, int len); extern int uafs_getdents_r(int fd, struct min_direct *buf, int len); -extern int uafs_closedir(usr_DIR *dirp); -extern int uafs_closedir_r(usr_DIR *dirp); +extern int uafs_closedir(usr_DIR * dirp); +extern int uafs_closedir_r(usr_DIR * dirp); extern void uafs_ThisCell(char *namep); extern void uafs_ThisCell_r(char *namep); -extern int uafs_klog(char *user,char *cell,char *passwd,char **reason); -extern int uafs_klog_r(char *user,char *cell,char *passwd,char **reason); +extern int uafs_klog(char *user, char *cell, char *passwd, char **reason); +extern int uafs_klog_r(char *user, char *cell, char *passwd, char **reason); extern int uafs_unlog(void); extern int uafs_unlog_r(void); extern void uafs_SetRxPort(int); diff --git a/src/afs/UKERNEL/osi_groups.c b/src/afs/UKERNEL/osi_groups.c index 71a641b16..849dbdde7 100644 --- a/src/afs/UKERNEL/osi_groups.c +++ b/src/afs/UKERNEL/osi_groups.c @@ -14,22 +14,22 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ -int afs_xsetgroups() +int +afs_xsetgroups() { usr_assert(0); } static int -afs_getgroups( - struct AFS_UCRED *cred, - gid_t *gidset) +afs_getgroups(struct AFS_UCRED *cred, gid_t * gidset) { int ngrps, savengrps; gid_t *gp; @@ -40,18 +40,15 @@ afs_getgroups( savengrps = ngrps = cred->cr_ngroups; gp = cred->cr_groups; while (ngrps--) - *gidset++ = *gp++; + *gidset++ = *gp++; return savengrps; } static int -afs_setgroups( - struct AFS_UCRED **cred, - int ngroups, - gid_t *gidset, - int change_parent) +afs_setgroups(struct AFS_UCRED **cred, int ngroups, gid_t * gidset, + int change_parent) { int ngrps; int i; @@ -70,11 +67,9 @@ afs_setgroups( return (0); } -int usr_setpag( - struct usr_ucred **cred, - afs_uint32 pagvalue, - afs_uint32 *newpag, - int change_parent) +int +usr_setpag(struct usr_ucred **cred, afs_uint32 pagvalue, afs_uint32 * newpag, + int change_parent) { gid_t *gidset; int ngroups, code; @@ -87,16 +82,16 @@ int usr_setpag( if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) { /* We will have to shift grouplist to make room for pag */ - if ((sizeof gidset[0])*(ngroups + 2) > AFS_SMALLOCSIZ) { + if ((sizeof gidset[0]) * (ngroups + 2) > AFS_SMALLOCSIZ) { osi_FreeSmallSpace((char *)gidset); return (E2BIG); } - for (j = ngroups -1; j >= 0; j--) { - gidset[j+2] = gidset[j]; - } + for (j = ngroups - 1; j >= 0; j--) { + gidset[j + 2] = gidset[j]; + } ngroups += 2; } - *newpag = (pagvalue == -1 ? genpag(): pagvalue); + *newpag = (pagvalue == -1 ? genpag() : pagvalue); afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]); if ((code = afs_setgroups(cred, ngroups, gidset, change_parent))) { osi_FreeSmallSpace((char *)gidset); diff --git a/src/afs/UKERNEL/osi_machdep.h b/src/afs/UKERNEL/osi_machdep.h index b4a52465f..be85d6f61 100644 --- a/src/afs/UKERNEL/osi_machdep.h +++ b/src/afs/UKERNEL/osi_machdep.h @@ -23,7 +23,7 @@ #define MAX_OSI_PATH 1024 #define MAX_OSI_FILES 1024 #define MAX_OSI_LINKS 25 -#define OSI_WAITHASH_SIZE 128 /* must be power of two */ +#define OSI_WAITHASH_SIZE 128 /* must be power of two */ #define MAX_HOSTADDR 32 #define AFS_UCRED usr_ucred @@ -65,4 +65,3 @@ extern usr_mutex_t afs_global_lock; extern int afs_bufferpages; #endif /* _OSI_MACHDEP_H_ */ - diff --git a/src/afs/UKERNEL/osi_vfsops.c b/src/afs/UKERNEL/osi_vfsops.c index db1fcdcda..7a89f9b43 100644 --- a/src/afs/UKERNEL/osi_vfsops.c +++ b/src/afs/UKERNEL/osi_vfsops.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ int afs_mount(); @@ -40,41 +41,43 @@ int afs_rootCellIndex = 0; #endif afs_mount(afsp, path, data) - char *path; - caddr_t data; - struct vfs *afsp; + char *path; + caddr_t data; + struct vfs *afsp; { AFS_STATCNT(afs_mount); if (afs_globalVFS) { /* Don't allow remounts since some system (like AIX) don't handle it well */ - return (setuerror(EBUSY)); + return (setuerror(EBUSY)); } afs_globalVFS = afsp; afsp->vfs_bsize = 8192; - afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ - afsp->vfs_fsid.val[1] = (afs_int32) AFS_VFSFSID; + afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */ + afsp->vfs_fsid.val[1] = (afs_int32) AFS_VFSFSID; return 0; } -afs_unmount (afsp) - struct vfs *afsp; { +afs_unmount(afsp) + struct vfs *afsp; +{ AFS_STATCNT(afs_unmount); afs_globalVFS = 0; afs_shutdown(); return 0; } -afs_root (OSI_VFS_ARG(afsp), avpp) +afs_root(OSI_VFS_ARG(afsp), avpp) OSI_VFS_DECL(afsp); - struct vnode **avpp; { + struct vnode **avpp; +{ register afs_int32 code = 0; struct vrequest treq; - register struct vcache *tvp=0; + register struct vcache *tvp = 0; OSI_VFS_CONVERT(afsp) - AFS_STATCNT(afs_root); + AFS_STATCNT(afs_root); if (afs_globalVp && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; } else { @@ -83,8 +86,8 @@ afs_root (OSI_VFS_ARG(afsp), avpp) afs_globalVp = NULL; } - if (!(code = afs_InitReq(&treq, u.u_cred)) && - !(code = afs_CheckInit())) { + if (!(code = afs_InitReq(&treq, u.u_cred)) + && !(code = afs_CheckInit())) { tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); /* we really want this to stay around */ if (tvp) { @@ -96,7 +99,7 @@ afs_root (OSI_VFS_ARG(afsp), avpp) if (tvp) { VN_HOLD(AFSTOV(tvp)); - AFSTOV(tvp)->v_flag |= VROOT; /* No-op on Ultrix 2.2 */ + AFSTOV(tvp)->v_flag |= VROOT; /* No-op on Ultrix 2.2 */ afs_globalVFS = afsp; *avpp = AFSTOV(tvp); } @@ -107,32 +110,32 @@ afs_root (OSI_VFS_ARG(afsp), avpp) } afs_sync(afsp) - struct vfs *afsp; + struct vfs *afsp; { AFS_STATCNT(afs_sync); return 0; } afs_statfs(afsp, abp) - register struct vfs *afsp; - struct statfs *abp; - { - AFS_STATCNT(afs_statfs); - abp->f_type = 0; - abp->f_bsize = afsp->vfs_bsize; - abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */ - abp->f_fsid.val[1] = (afs_int32) AFS_VFSFSID; - return 0; + register struct vfs *afsp; + struct statfs *abp; +{ + AFS_STATCNT(afs_statfs); + abp->f_type = 0; + abp->f_bsize = afsp->vfs_bsize; + abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */ + abp->f_fsid.val[1] = (afs_int32) AFS_VFSFSID; + return 0; } afs_mountroot() { AFS_STATCNT(afs_mountroot); - return(EINVAL); + return (EINVAL); } -afs_swapvp() +afs_swapvp() { AFS_STATCNT(afs_swapvp); - return(EINVAL); + return (EINVAL); } diff --git a/src/afs/UKERNEL/osi_vm.c b/src/afs/UKERNEL/osi_vm.c index 960a6464e..5d066d730 100644 --- a/src/afs/UKERNEL/osi_vm.c +++ b/src/afs/UKERNEL/osi_vm.c @@ -10,33 +10,39 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ -void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) +void +osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred) { return; } -int osi_VM_FlushVCache(struct vcache *avc, int *slept) +int +osi_VM_FlushVCache(struct vcache *avc, int *slept) { return 0; } -void osi_VM_StoreAllSegments(struct vcache *avc) +void +osi_VM_StoreAllSegments(struct vcache *avc) { return; } -void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) +void +osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync) { return; } -void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) +void +osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp) { return; } diff --git a/src/afs/UKERNEL/osi_vnodeops.c b/src/afs/UKERNEL/osi_vnodeops.c index aaee48776..edd02b738 100644 --- a/src/afs/UKERNEL/osi_vnodeops.c +++ b/src/afs/UKERNEL/osi_vnodeops.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ extern int afs_noop(); extern int afs_badop(); @@ -38,12 +39,9 @@ extern int afs_fsync(); extern int afs_lockctl(); extern int afs_fid(); -int afs_vrdwr( - struct usr_vnode *avc, - struct usr_uio *uio, - int rw, - int io, - struct usr_ucred* cred) +int +afs_vrdwr(struct usr_vnode *avc, struct usr_uio *uio, int rw, int io, + struct usr_ucred *cred) { int rc; @@ -56,42 +54,44 @@ int afs_vrdwr( return rc; } -int afs_inactive(struct vcache *avc, struct AFS_UCRED *acred) +int +afs_inactive(struct vcache *avc, struct AFS_UCRED *acred) { struct vnode *vp = AFSTOV(avc); - if (afs_shuttingdown) return ; + if (afs_shuttingdown) + return; usr_assert(avc->vrefCount == 0); afs_InactiveVCache(avc, acred); } struct usr_vnodeops Afs_vnodeops = { - afs_open, - afs_close, - afs_vrdwr, - afs_badop, /* ioctl */ - afs_noop, /* select */ - afs_getattr, - afs_setattr, - afs_access, - afs_lookup, - afs_create, - afs_remove, - afs_link, - afs_rename, - afs_mkdir, - afs_rmdir, - afs_readdir, - afs_symlink, - afs_readlink, - afs_fsync, - afs_inactive, - afs_badop, /* bmap */ - afs_badop, /* strategy */ - afs_badop, /* bread */ - afs_badop, /* brelse */ - afs_lockctl, - afs_fid + afs_open, + afs_close, + afs_vrdwr, + afs_badop, /* ioctl */ + afs_noop, /* select */ + afs_getattr, + afs_setattr, + afs_access, + afs_lookup, + afs_create, + afs_remove, + afs_link, + afs_rename, + afs_mkdir, + afs_rmdir, + afs_readdir, + afs_symlink, + afs_readlink, + afs_fsync, + afs_inactive, + afs_badop, /* bmap */ + afs_badop, /* strategy */ + afs_badop, /* bread */ + afs_badop, /* brelse */ + afs_lockctl, + afs_fid }; struct usr_vnodeops *afs_ops = &Afs_vnodeops; diff --git a/src/afs/UKERNEL/sysincludes.h b/src/afs/UKERNEL/sysincludes.h index b4ab7daf0..95cf27566 100644 --- a/src/afs/UKERNEL/sysincludes.h +++ b/src/afs/UKERNEL/sysincludes.h @@ -11,7 +11,7 @@ #define __AFS_SYSINCLUDESH__ 1 #include -#if !defined(AFS_USR_DARWIN_ENV) && !defined(AFS_USR_FBSD_ENV) /* must be included after KERNEL undef'd */ +#if !defined(AFS_USR_DARWIN_ENV) && !defined(AFS_USR_FBSD_ENV) /* must be included after KERNEL undef'd */ #include #endif #include @@ -98,9 +98,9 @@ #endif /* AFS_USR_OSF_ENV */ #ifdef AFS_USR_LINUX22_ENV -#include /* _IOW() */ -#include /* struct iovec */ -#include /* struct timeval */ +#include /* _IOW() */ +#include /* struct iovec */ +#include /* struct timeval */ #include #include #include @@ -147,7 +147,7 @@ #define pthread_attr_setstacksize(a,b) 0 #endif -#include /* afs_usrops.h uses struct stat in prototypes */ +#include /* afs_usrops.h uses struct stat in prototypes */ #ifdef NETSCAPE_NSAPI @@ -631,7 +631,7 @@ typedef int usr_vtype_t; #ifdef IO_SYNC #undef IO_SYNC #endif - + #define FAPPEND 0x0100 #define IO_APPEND FAPPEND #define FSYNC 0x0200 @@ -840,9 +840,9 @@ enum usr_uio_rw { USR_UIO_READ, USR_UIO_WRITE }; * waking when we do the signal. */ typedef struct { - int waiters; - CRITICAL lock; - CONDVAR cond; + int waiters; + CRITICAL lock; + CONDVAR cond; } usr_cond_t; #define usr_mutex_t CRITICAL @@ -991,7 +991,7 @@ extern pthread_cond_t usr_sleep_cond; { \ (vp)->v_count++; \ } - + #define VN_RELE(vp) \ do { \ AFS_ASSERT_GLOCK(); \ @@ -1001,40 +1001,40 @@ do { \ } while(0) struct usr_statfs { - unsigned long f_type; - unsigned long f_bsize; - unsigned long f_frsize; - unsigned long f_ffree; - unsigned long f_favail; - struct { - unsigned long val[2]; - } f_fsid; - char f_basetype[FSTYPSZ]; - unsigned long f_flag; - unsigned long f_namemax; - unsigned long f_blocks; - unsigned long f_bfree; - unsigned long f_bavail; - unsigned long f_files; + unsigned long f_type; + unsigned long f_bsize; + unsigned long f_frsize; + unsigned long f_ffree; + unsigned long f_favail; + struct { + unsigned long val[2]; + } f_fsid; + char f_basetype[FSTYPSZ]; + unsigned long f_flag; + unsigned long f_namemax; + unsigned long f_blocks; + unsigned long f_bfree; + unsigned long f_bavail; + unsigned long f_files; }; struct usr_vattr { - long va_mask; - usr_vtype_t va_type; - unsigned short va_mode; - long va_uid; - long va_gid; - unsigned long va_fsid; - unsigned long va_nodeid; - unsigned long va_nlink; - unsigned long va_size; - struct timeval va_atime; - struct timeval va_mtime; - struct timeval va_ctime; - unsigned long va_rdev; - unsigned long va_blocksize; - unsigned long va_blocks; - unsigned long va_vcode; + long va_mask; + usr_vtype_t va_type; + unsigned short va_mode; + long va_uid; + long va_gid; + unsigned long va_fsid; + unsigned long va_nodeid; + unsigned long va_nlink; + unsigned long va_size; + struct timeval va_atime; + struct timeval va_mtime; + struct timeval va_ctime; + unsigned long va_rdev; + unsigned long va_blocksize; + unsigned long va_blocks; + unsigned long va_vcode; }; #ifdef VSUID @@ -1056,7 +1056,7 @@ struct usr_vattr { #undef VEXEC #endif -#define VSUID 04000 +#define VSUID 04000 #define VSGID 02000 #define VSVTX 01000 #define VREAD 00400 @@ -1065,74 +1065,74 @@ struct usr_vattr { struct usr_vnode { - unsigned short v_flag; - unsigned long v_count; - struct usr_vnodeops *v_op; - struct usr_vfs * v_vfsp; - long v_type; - unsigned long v_rdev; - char * v_data; + unsigned short v_flag; + unsigned long v_count; + struct usr_vnodeops *v_op; + struct usr_vfs *v_vfsp; + long v_type; + unsigned long v_rdev; + char *v_data; }; -struct usr_inode { - daddr_t i_db[NDADDR]; - struct usr_vnode *i_devvp; - unsigned long i_dev; - long i_flag; - struct usr_inode *i_freef; - struct usr_inode **i_freeb; - long i_gid; - daddr_t i_ib[NIADDR]; - unsigned short i_mode; - short i_nlink; - unsigned long i_number; - long i_size; - long i_uid; - struct usr_vnode i_vnode; - struct { - unsigned long ic_spare[4]; - } i_ic; +struct usr_inode { + daddr_t i_db[NDADDR]; + struct usr_vnode *i_devvp; + unsigned long i_dev; + long i_flag; + struct usr_inode *i_freef; + struct usr_inode **i_freeb; + long i_gid; + daddr_t i_ib[NIADDR]; + unsigned short i_mode; + short i_nlink; + unsigned long i_number; + long i_size; + long i_uid; + struct usr_vnode i_vnode; + struct { + unsigned long ic_spare[4]; + } i_ic; }; extern struct usr_inode *iget(); struct usr_fileops { - int (*vno_rw)(void); - int (*vno_ioctl)(void); - int (*vno_select)(void); - int (*vno_closex)(void); + int (*vno_rw) (void); + int (*vno_ioctl) (void); + int (*vno_select) (void); + int (*vno_closex) (void); }; struct usr_file { - unsigned short f_flag; - offset_t f_offset; - struct usr_ucred *f_cred; - struct usr_fileops *f_ops; - char * f_data; - long f_type; + unsigned short f_flag; + offset_t f_offset; + struct usr_ucred *f_cred; + struct usr_fileops *f_ops; + char *f_data; + long f_type; }; extern struct usr_file *falloc(); extern struct usr_file *getf(int); -#ifdef fid_len -#undef fid_len +#ifdef fid_len +#undef fid_len #endif #ifdef fid_data #undef fid_data #endif struct usr_fid { - unsigned short fid_len; - unsigned short fid_reserved; - char fid_data[MAXFIDSZ]; + unsigned short fid_len; + unsigned short fid_reserved; + char fid_data[MAXFIDSZ]; }; struct usr_flock { - short l_type; - short l_whence; - off_t l_start; - off_t l_len; - long l_sysid; - pid_t l_pid; + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + long l_sysid; + pid_t l_pid; }; extern struct usr_ucred *usr_crget(void); @@ -1141,23 +1141,23 @@ extern int usr_crhold(struct usr_ucred *); extern int usr_crfree(struct usr_ucred *); extern struct usr_ucred *afs_global_ucredp; -struct usr_proc { - unsigned long p_flag; - pid_t p_pid; - pid_t p_ppid; - struct usr_ucred *p_ucred; - char p_cursig; +struct usr_proc { + unsigned long p_flag; + pid_t p_pid; + pid_t p_ppid; + struct usr_ucred *p_ucred; + char p_cursig; }; -struct usr_a { - int fd; - int syscall; - int parm1; - int parm2; - int parm3; - int parm4; - int parm5; - int parm6; +struct usr_a { + int fd; + int syscall; + int parm1; + int parm2; + int parm3; + int parm4; + int parm5; + int parm6; }; #ifdef uio_offset @@ -1165,12 +1165,12 @@ struct usr_a { #endif struct usr_uio { - struct iovec *uio_iov; - int uio_iovcnt; - long uio_offset; - int uio_segflg; - short uio_fmode; - int uio_resid; + struct iovec *uio_iov; + int uio_iovcnt; + long uio_offset; + int uio_segflg; + short uio_fmode; + int uio_resid; }; #ifdef b_blkno @@ -1180,111 +1180,110 @@ struct usr_uio { #undef b_vp #endif -struct usr_buf { - int b_flags; - short b_dev; - unsigned b_bcount; - struct { - char * b_addr; - struct usr_fs *b_fs; - } b_un; - long b_blkno; - unsigned int b_resid; - struct usr_vnode *b_vp; +struct usr_buf { + int b_flags; + short b_dev; + unsigned b_bcount; + struct { + char *b_addr; + struct usr_fs *b_fs; + } b_un; + long b_blkno; + unsigned int b_resid; + struct usr_vnode *b_vp; }; struct usr_socket { - int sock; - short port; + int sock; + short port; }; #define NDIRSIZ_LEN(len) \ ((sizeof (struct usr_dirent)+4 - (MAXNAMLEN+1)) + (((len)+1 + 3) &~ 3)) struct usr_vnodeops { - int (*vn_open)(char *path, int flags, int mode); - int (*vn_close)(int fd); - int (*vn_rdwr)(); - int (*vn_ioctl)(void); - int (*vn_select)(void); - int (*vn_getattr)(); - int (*vn_setattr)(); - int (*vn_access)(); - int (*vn_lookup)(); - int (*vn_create)(); - int (*vn_remove)(); - int (*vn_link)(); - int (*vn_rename)(); - int (*vn_mkdir)(); - int (*vn_rmdir)(); - int (*vn_readdir)(); - int (*vn_symlink)(); - int (*vn_readlink)(); - int (*vn_fsync)(); - int (*vn_inactive)(); - int (*vn_bmap)(); - int (*vn_strategy)(); - int (*vn_bread)(); - int (*vn_brelse)(); - int (*vn_lockctl)(); - int (*vn_fid)(); + int (*vn_open) (char *path, int flags, int mode); + int (*vn_close) (int fd); + int (*vn_rdwr) (); + int (*vn_ioctl) (void); + int (*vn_select) (void); + int (*vn_getattr) (); + int (*vn_setattr) (); + int (*vn_access) (); + int (*vn_lookup) (); + int (*vn_create) (); + int (*vn_remove) (); + int (*vn_link) (); + int (*vn_rename) (); + int (*vn_mkdir) (); + int (*vn_rmdir) (); + int (*vn_readdir) (); + int (*vn_symlink) (); + int (*vn_readlink) (); + int (*vn_fsync) (); + int (*vn_inactive) (); + int (*vn_bmap) (); + int (*vn_strategy) (); + int (*vn_bread) (); + int (*vn_brelse) (); + int (*vn_lockctl) (); + int (*vn_fid) (); }; struct usr_fs { - int dummy; + int dummy; }; -struct usr_mount -{ - char m_flags; - unsigned long m_dev; - struct usr_inode *m_inodp; - struct usr_buf *m_bufp; - struct usr_vnode *m_mount; +struct usr_mount { + char m_flags; + unsigned long m_dev; + struct usr_inode *m_inodp; + struct usr_buf *m_bufp; + struct usr_vnode *m_mount; }; extern struct usr_mount *getmp(unsigned long); typedef long usr_whymountroot_t; struct usr_vfsops { - int (*vfs_mount)(); - int (*vfs_unmount)(); - int (*vfs_root)(); - int (*vfs_statfs)(); - int (*vfs_mountroot)(); - int (*vfs_swapvp)(); + int (*vfs_mount) (); + int (*vfs_unmount) (); + int (*vfs_root) (); + int (*vfs_statfs) (); + int (*vfs_mountroot) (); + int (*vfs_swapvp) (); }; struct usr_vfs { - struct usr_vnode *vfs_vnodecovered; - struct { - unsigned long val[2]; - } vfs_fsid; - char * vfs_data; - unsigned long vfs_bsize; - struct usr_mount *vfs_mount; - struct usr_vfsops *vfs_op; + struct usr_vnode *vfs_vnodecovered; + struct { + unsigned long val[2]; + } vfs_fsid; + char *vfs_data; + unsigned long vfs_bsize; + struct usr_mount *vfs_mount; + struct usr_vfsops *vfs_op; }; struct usr_sysent { - char sy_narg; - int (*sy_call)(); + char sy_narg; + int (*sy_call) (); }; extern struct usr_sysent usr_sysent[]; struct usr_ifnet { - struct usr_ifnet *if_next; - short if_flags; - u_int if_mtu; - u_int if_metric; - struct usr_ifaddr *if_addrlist; + struct usr_ifnet *if_next; + short if_flags; + u_int if_mtu; + u_int if_metric; + struct usr_ifaddr *if_addrlist; }; extern struct usr_ifnet *usr_ifnet; struct usr_ifaddr { - struct usr_ifaddr *ifa_next; - struct usr_ifnet *ifa_ifp; - struct sockaddr ifa_addr; + struct usr_ifaddr *ifa_next; + struct usr_ifnet *ifa_ifp; + struct sockaddr ifa_addr; }; #ifdef ia_ifp @@ -1295,14 +1294,14 @@ struct usr_ifaddr { #endif struct usr_in_ifaddr { - struct usr_in_ifaddr *ia_next; - struct usr_ifnet *ia_ifp; - struct sockaddr_in ia_addr; - unsigned long ia_net; - unsigned long ia_netmask; - unsigned long ia_subnet; - unsigned long ia_subnetmask; - struct in_addr ia_netbroadcast; + struct usr_in_ifaddr *ia_next; + struct usr_ifnet *ia_ifp; + struct sockaddr_in ia_addr; + unsigned long ia_net; + unsigned long ia_netmask; + unsigned long ia_subnet; + unsigned long ia_subnetmask; + struct in_addr ia_netbroadcast; }; extern struct usr_in_ifaddr *usr_in_ifaddr; @@ -1318,12 +1317,12 @@ extern long V; struct min_direct { #if defined(AFS_OFS_ENV) || defined(AFS_USR_OSF_ENV) - unsigned int d_fileno; -#else /* AFS_OFS_ENV || AFS_USR_OSF_ENV */ - unsigned long d_fileno; -#endif /* AFS_OFS_ENV || AFS_USR_OSF_ENV */ - unsigned short d_reclen; - unsigned short d_namlen; + unsigned int d_fileno; +#else /* AFS_OFS_ENV || AFS_USR_OSF_ENV */ + unsigned long d_fileno; +#endif /* AFS_OFS_ENV || AFS_USR_OSF_ENV */ + unsigned short d_reclen; + unsigned short d_namlen; }; #ifndef NGROUPS @@ -1337,33 +1336,33 @@ struct min_direct { #endif struct usr_ucred { - unsigned long cr_ref; - long cr_uid; - long cr_gid; - long cr_ruid; - long cr_rgid; - long cr_suid; - long cr_sgid; - long cr_ngroups; - gid_t cr_groups[NGROUPS]; + unsigned long cr_ref; + long cr_uid; + long cr_gid; + long cr_ruid; + long cr_rgid; + long cr_suid; + long cr_sgid; + long cr_ngroups; + gid_t cr_groups[NGROUPS]; }; #ifdef u_rval1 #undef u_rval1 #endif -struct usr_user { - int u_error; - int u_prio; - char * u_ap; - int u_rval1; - long u_viceid; - unsigned long u_expiration; - struct usr_proc *u_procp; - struct usr_ucred *u_cred; - struct { - int r_val1; - } u_r; +struct usr_user { + int u_error; + int u_prio; + char *u_ap; + int u_rval1; + long u_viceid; + unsigned long u_expiration; + struct usr_proc *u_procp; + struct usr_ucred *u_cred; + struct { + int r_val1; + } u_r; }; #define u_rval1 u_r.r_val1 #define u (*(get_user_struct())) @@ -1373,18 +1372,18 @@ extern struct usr_user *get_user_struct(void); #define USR_DIRSIZE 2048 struct usr_dirent { - unsigned long d_ino; - unsigned long d_off; - unsigned short d_reclen; - char d_name[MAXNAMLEN+1]; + unsigned long d_ino; + unsigned long d_off; + unsigned short d_reclen; + char d_name[MAXNAMLEN + 1]; }; typedef struct { - int dd_fd; - int dd_loc; - int dd_size; - int dd_reserved; - char *dd_buf; + int dd_fd; + int dd_loc; + int dd_size; + int dd_reserved; + char *dd_buf; } usr_DIR; extern unsigned short usr_rx_port; diff --git a/src/afs/VNOPS/afs_vnop_access.c b/src/afs/VNOPS/afs_vnop_access.c index 69fcd333d..afd6c9c64 100644 --- a/src/afs/VNOPS/afs_vnop_access.c +++ b/src/afs/VNOPS/afs_vnop_access.c @@ -22,17 +22,18 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" #ifndef ANONYMOUSID -#define ANONYMOUSID 32766 /* make sure this is same as in ptserver.h */ +#define ANONYMOUSID 32766 /* make sure this is same as in ptserver.h */ #endif @@ -51,8 +52,9 @@ static char fileModeMap[8] = { }; /* avc must be held. Returns bit map of mode bits. Ignores file mode bits */ -afs_int32 afs_GetAccessBits(register struct vcache *avc, register afs_int32 arights, - register struct vrequest *areq) +afs_int32 +afs_GetAccessBits(register struct vcache *avc, register afs_int32 arights, + register struct vrequest *areq) { AFS_STATCNT(afs_GetAccessBits); /* see if anyuser has the required access bits */ @@ -61,41 +63,40 @@ afs_int32 afs_GetAccessBits(register struct vcache *avc, register afs_int32 arig } /* look in per-pag cache */ - if (avc->Access) { /* not beautiful, but Sun's cc will tolerate it */ - struct axscache *ac; + if (avc->Access) { /* not beautiful, but Sun's cc will tolerate it */ + struct axscache *ac; - ac = afs_FindAxs(avc->Access, areq->uid); - if (ac) { - return (arights & ac->axess); - } + ac = afs_FindAxs(avc->Access, areq->uid); + if (ac) { + return (arights & ac->axess); + } } - if (!(avc->states & CForeign)) { - /* If there aren't any bits cached for this user (but the vnode - * _is_ cached, obviously), make sure this user has valid tokens - * before bothering with the RPC. */ - struct unixuser *tu; - extern struct unixuser *afs_FindUser(); - tu = afs_FindUser( areq->uid, avc->fid.Cell, READ_LOCK ); - if (!tu) { - return (arights & avc->anyAccess); - } - if ((tu->vid == UNDEFVID) || !(tu->states & UHasTokens) || - (tu->states & UTokensBad)) { - afs_PutUser(tu, READ_LOCK); - return (arights & avc->anyAccess); - } - else { - afs_PutUser(tu, READ_LOCK); - } + if (!(avc->states & CForeign)) { + /* If there aren't any bits cached for this user (but the vnode + * _is_ cached, obviously), make sure this user has valid tokens + * before bothering with the RPC. */ + struct unixuser *tu; + extern struct unixuser *afs_FindUser(); + tu = afs_FindUser(areq->uid, avc->fid.Cell, READ_LOCK); + if (!tu) { + return (arights & avc->anyAccess); + } + if ((tu->vid == UNDEFVID) || !(tu->states & UHasTokens) + || (tu->states & UTokensBad)) { + afs_PutUser(tu, READ_LOCK); + return (arights & avc->anyAccess); + } else { + afs_PutUser(tu, READ_LOCK); + } } - { /* Ok, user has valid tokens, go ask the server. */ - struct AFSFetchStatus OutStatus; - afs_int32 code; - - code = afs_FetchStatus(avc, &avc->fid, areq, &OutStatus); - return (code ? 0 : OutStatus.CallerAccess & arights); + { /* Ok, user has valid tokens, go ask the server. */ + struct AFSFetchStatus OutStatus; + afs_int32 code; + + code = afs_FetchStatus(avc, &avc->fid, areq, &OutStatus); + return (code ? 0 : OutStatus.CallerAccess & arights); } } @@ -103,8 +104,9 @@ afs_int32 afs_GetAccessBits(register struct vcache *avc, register afs_int32 arig /* the new access ok function. AVC must be held but not locked. if avc is a * file, its parent need not be held, and should not be locked. */ -int afs_AccessOK(struct vcache *avc, afs_int32 arights, struct vrequest *areq, - afs_int32 check_mode_bits) +int +afs_AccessOK(struct vcache *avc, afs_int32 arights, struct vrequest *areq, + afs_int32 check_mode_bits) { register struct vcache *tvc; struct VenusFid dirFid; @@ -115,10 +117,9 @@ int afs_AccessOK(struct vcache *avc, afs_int32 arights, struct vrequest *areq, AFS_STATCNT(afs_AccessOK); if ((vType(avc) == VDIR) || (avc->states & CForeign)) { - /* rights are just those from acl */ - return (arights == afs_GetAccessBits(avc, arights, areq)); - } - else { + /* rights are just those from acl */ + return (arights == afs_GetAccessBits(avc, arights, areq)); + } else { /* some rights come from dir and some from file. Specifically, you * have "a" rights to a file if you are its owner, which comes * back as "a" rights to the file. You have other rights just @@ -138,8 +139,7 @@ int afs_AccessOK(struct vcache *avc, afs_int32 arights, struct vrequest *areq, dirBits = afs_GetAccessBits(tvc, arights, areq); afs_PutVCache(tvc); } - } - else + } else dirBits = 0xffffffff; /* assume OK; this is a race condition */ if (arights & PRSFS_ADMINISTER) fileBits = afs_GetAccessBits(avc, arights, areq); @@ -147,25 +147,28 @@ int afs_AccessOK(struct vcache *avc, afs_int32 arights, struct vrequest *areq, fileBits = 0; /* don't make call if results don't matter */ /* compute basic rights in fileBits, taking A from file bits */ - fileBits = (fileBits & PRSFS_ADMINISTER) | (dirBits & ~PRSFS_ADMINISTER); + fileBits = + (fileBits & PRSFS_ADMINISTER) | (dirBits & ~PRSFS_ADMINISTER); /* for files, throw in R and W if have I and A (owner). This makes - insert-only dirs work properly */ - if (vType(avc) != VDIR && (fileBits & (PRSFS_ADMINISTER | PRSFS_INSERT)) == + * insert-only dirs work properly */ + if (vType(avc) != VDIR + && (fileBits & (PRSFS_ADMINISTER | PRSFS_INSERT)) == (PRSFS_ADMINISTER | PRSFS_INSERT)) fileBits |= (PRSFS_READ | PRSFS_WRITE); if (check_mode_bits & CHECK_MODE_BITS) { /* owner mode bits are further restrictions on the access mode - * The mode bits are mapped to protection bits through the - * fileModeMap. If CMB_ALLOW_EXEC_AS_READ is set, it's from the - * NFS translator and we don't know if it's a read or execute - * on the NFS client, but both need to read the data. - */ + * The mode bits are mapped to protection bits through the + * fileModeMap. If CMB_ALLOW_EXEC_AS_READ is set, it's from the + * NFS translator and we don't know if it's a read or execute + * on the NFS client, but both need to read the data. + */ mask = (avc->m.Mode & 0700) >> 6; /* file restrictions to use */ fileBits &= ~fileModeMap[mask]; if (check_mode_bits & CMB_ALLOW_EXEC_AS_READ) { - if (avc->m.Mode & 0100) fileBits |= PRSFS_READ; + if (avc->m.Mode & 0100) + fileBits |= PRSFS_READ; } } return ((fileBits & arights) == arights); /* true if all rights bits are on */ @@ -174,9 +177,13 @@ int afs_AccessOK(struct vcache *avc, afs_int32 arights, struct vrequest *areq, #if defined(AFS_SUN5_ENV) || (defined(AFS_SGI_ENV) && !defined(AFS_SGI65_ENV)) -int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, int flags, struct AFS_UCRED *acred) +int +afs_access(OSI_VC_DECL(avc), register afs_int32 amode, int flags, + struct AFS_UCRED *acred) #else -int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, struct AFS_UCRED *acred) +int +afs_access(OSI_VC_DECL(avc), register afs_int32 amode, + struct AFS_UCRED *acred) #endif { register afs_int32 code; @@ -184,12 +191,13 @@ int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, struct AFS_UCRED *acr struct afs_fakestat_state fakestate; OSI_VC_CONVERT(avc) - AFS_STATCNT(afs_access); - afs_Trace3(afs_iclSetp, CM_TRACE_ACCESS, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, amode, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); + AFS_STATCNT(afs_access); + afs_Trace3(afs_iclSetp, CM_TRACE_ACCESS, ICL_TYPE_POINTER, avc, + ICL_TYPE_INT32, amode, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length)); afs_InitFakeStat(&fakestate); - if ((code = afs_InitReq(&treq, acred))) return code; + if ((code = afs_InitReq(&treq, acred))) + return code; code = afs_EvalFakeStat(&avc, &fakestate, &treq); if (code) { @@ -199,9 +207,9 @@ int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, struct AFS_UCRED *acr code = afs_VerifyVCache(avc, &treq); if (code) { - afs_PutFakeStat(&fakestate); - code = afs_CheckCode(code, &treq, 16); - return code; + afs_PutFakeStat(&fakestate); + code = afs_CheckCode(code, &treq, 16); + return code; } /* if we're looking for write access and we have a read-only file system, report it */ @@ -209,7 +217,7 @@ int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, struct AFS_UCRED *acr afs_PutFakeStat(&fakestate); return EROFS; } - code = 1; /* Default from here on in is access ok. */ + code = 1; /* Default from here on in is access ok. */ if (avc->states & CForeign) { /* In the dfs xlator the EXEC bit is mapped to LOOKUP */ if (amode & VEXEC) @@ -218,24 +226,33 @@ int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, struct AFS_UCRED *acr code = afs_AccessOK(avc, PRSFS_WRITE, &treq, CHECK_MODE_BITS); if (code && (vType(avc) == VDIR)) { if (code) - code = afs_AccessOK(avc, PRSFS_INSERT, &treq, CHECK_MODE_BITS); - if (!code) - code = afs_AccessOK(avc, PRSFS_DELETE, &treq, CHECK_MODE_BITS); - } - } - if (code && (amode & VREAD)) + code = + afs_AccessOK(avc, PRSFS_INSERT, &treq, + CHECK_MODE_BITS); + if (!code) + code = + afs_AccessOK(avc, PRSFS_DELETE, &treq, + CHECK_MODE_BITS); + } + } + if (code && (amode & VREAD)) code = afs_AccessOK(avc, PRSFS_READ, &treq, CHECK_MODE_BITS); } else { if (vType(avc) == VDIR) { - if (amode & VEXEC) - code = afs_AccessOK(avc, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS); + if (amode & VEXEC) + code = + afs_AccessOK(avc, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS); if (code && (amode & VWRITE)) { - code = afs_AccessOK(avc, PRSFS_INSERT, &treq, CHECK_MODE_BITS); - if (!code) - code = afs_AccessOK(avc, PRSFS_DELETE, &treq, CHECK_MODE_BITS); + code = + afs_AccessOK(avc, PRSFS_INSERT, &treq, CHECK_MODE_BITS); + if (!code) + code = + afs_AccessOK(avc, PRSFS_DELETE, &treq, + CHECK_MODE_BITS); } if (code && (amode & VREAD)) - code = afs_AccessOK(avc, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS); + code = + afs_AccessOK(avc, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS); } else { if (amode & VEXEC) { code = afs_AccessOK(avc, PRSFS_READ, &treq, CHECK_MODE_BITS); @@ -252,32 +269,36 @@ int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, struct AFS_UCRED *acr */ if (!((amode & VREAD) && AFS_NFSXLATORREQ(acred))) #endif - if ((avc->m.Mode & 0100) == 0) code = 0; - } else if (avc->m.Mode & 0100) code = 1; + if ((avc->m.Mode & 0100) == 0) + code = 0; + } else if (avc->m.Mode & 0100) + code = 1; } - if (code && (amode & VWRITE)) - { - code = afs_AccessOK(avc, PRSFS_WRITE, &treq, CHECK_MODE_BITS); - - /* The above call fails when the NFS translator tries to copy - ** a file with r--r--r-- permissions into a directory which - ** has system:anyuser acl. This is because the destination file - ** file is first created with r--r--r-- permissions through an - ** unauthenticated connectin. hence, the above afs_AccessOK - ** call returns failure. hence, we retry without any file - ** mode bit checking */ - if ( !code && AFS_NFSXLATORREQ(acred) && avc->m.Owner == ANONYMOUSID) - code=afs_AccessOK(avc,PRSFS_WRITE, &treq, DONT_CHECK_MODE_BITS); + if (code && (amode & VWRITE)) { + code = afs_AccessOK(avc, PRSFS_WRITE, &treq, CHECK_MODE_BITS); + + /* The above call fails when the NFS translator tries to copy + ** a file with r--r--r-- permissions into a directory which + ** has system:anyuser acl. This is because the destination file + ** file is first created with r--r--r-- permissions through an + ** unauthenticated connectin. hence, the above afs_AccessOK + ** call returns failure. hence, we retry without any file + ** mode bit checking */ + if (!code && AFS_NFSXLATORREQ(acred) + && avc->m.Owner == ANONYMOUSID) + code = + afs_AccessOK(avc, PRSFS_WRITE, &treq, + DONT_CHECK_MODE_BITS); } - if (code && (amode & VREAD)) - code = afs_AccessOK(avc, PRSFS_READ, &treq, CHECK_MODE_BITS); + if (code && (amode & VREAD)) + code = afs_AccessOK(avc, PRSFS_READ, &treq, CHECK_MODE_BITS); } } afs_PutFakeStat(&fakestate); if (code) { return 0; /* if access is ok */ } else { - code = afs_CheckCode(EACCES, &treq, 17); /* failure code */ + code = afs_CheckCode(EACCES, &treq, 17); /* failure code */ return code; } } @@ -287,18 +308,21 @@ int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, struct AFS_UCRED *acr * afs_getRights * This function is just an interface to afs_GetAccessBits */ -int afs_getRights(OSI_VC_DECL(avc), register afs_int32 arights, struct AFS_UCRED *acred) +int +afs_getRights(OSI_VC_DECL(avc), register afs_int32 arights, + struct AFS_UCRED *acred) { register afs_int32 code; struct vrequest treq; OSI_VC_CONVERT(avc) - if (code = afs_InitReq(&treq, acred)) return code; + if (code = afs_InitReq(&treq, acred)) + return code; code = afs_VerifyVCache(avc, &treq); if (code) { - code = afs_CheckCode(code, &treq, 16); - return code; + code = afs_CheckCode(code, &treq, 16); + return code; } return afs_GetAccessBits(avc, arights, &treq); diff --git a/src/afs/VNOPS/afs_vnop_attrs.c b/src/afs/VNOPS/afs_vnop_attrs.c index c75384b33..9dd48f84a 100644 --- a/src/afs/VNOPS/afs_vnop_attrs.c +++ b/src/afs/VNOPS/afs_vnop_attrs.c @@ -21,11 +21,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -38,7 +39,8 @@ extern struct vfs *afs_globalVFS; #endif /* copy out attributes from cache entry */ -int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) +int +afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) { register struct volume *tvp; register struct cell *tcell; @@ -48,21 +50,22 @@ int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) if (afs_fakestat_enable && avc->mvstat == 1) fakedir = 1; #if defined(AFS_MACH_ENV ) - attrs->va_mode = fakedir ? VDIR | 0755 : vType(avc) | (avc->m.Mode&~VFMT); + attrs->va_mode = + fakedir ? VDIR | 0755 : vType(avc) | (avc->m.Mode & ~VFMT); #else /* AFS_MACH_ENV */ attrs->va_type = fakedir ? VDIR : vType(avc); #if defined(AFS_SGI_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV) - attrs->va_mode = fakedir ? 0755 : (mode_t)(avc->m.Mode & 0xffff); + attrs->va_mode = fakedir ? 0755 : (mode_t) (avc->m.Mode & 0xffff); #else attrs->va_mode = fakedir ? VDIR | 0755 : avc->m.Mode; #endif #endif /* AFS_MACH_ENV */ - if (avc->m.Mode & (VSUID|VSGID)) { + if (avc->m.Mode & (VSUID | VSGID)) { /* setuid or setgid, make sure we're allowed to run them from this cell */ tcell = afs_GetCell(avc->fid.Cell, 0); if (tcell && (tcell->states & CNoSUID)) - attrs->va_mode &= ~(VSUID|VSGID); + attrs->va_mode &= ~(VSUID | VSGID); } #if defined(AFS_DARWIN_ENV) /* Mac OS X uses the mode bits to determine whether a file or directory @@ -71,18 +74,18 @@ int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) * ID. So we set the mode bits conservatively. */ if (S_ISDIR(attrs->va_mode)) { - /* all access bits need to be set for directories, since even - * a mode 0 directory can still be used normally. - */ - attrs->va_mode |= ACCESSPERMS; + /* all access bits need to be set for directories, since even + * a mode 0 directory can still be used normally. + */ + attrs->va_mode |= ACCESSPERMS; } else { - /* for other files, replicate the user bits to group and other */ - mode_t ubits = (attrs->va_mode & S_IRWXU) >> 6; - attrs->va_mode |= ubits | (ubits << 3); + /* for other files, replicate the user bits to group and other */ + mode_t ubits = (attrs->va_mode & S_IRWXU) >> 6; + attrs->va_mode |= ubits | (ubits << 3); } #endif /* AFS_DARWIN_ENV */ attrs->va_uid = fakedir ? 0 : avc->m.Owner; - attrs->va_gid = fakedir ? 0 : avc->m.Group; /* yeah! */ + attrs->va_gid = fakedir ? 0 : avc->m.Group; /* yeah! */ #if defined(AFS_SUN56_ENV) attrs->va_fsid = avc->v.v_vfsp->vfs_fsid.val[0]; #else @@ -91,7 +94,7 @@ int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) attrs->va_fsid = 1; #else #ifdef AFS_OSF_ENV - attrs->va_fsid = avc->v.v_mount->m_stat.f_fsid.val[0]; + attrs->va_fsid = avc->v.v_mount->m_stat.f_fsid.val[0]; #else attrs->va_fsid = 1; #endif @@ -100,16 +103,16 @@ int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) if (avc->mvstat == 2) { tvp = afs_GetVolume(&avc->fid, 0, READ_LOCK); /* The mount point's vnode. */ - if (tvp) { + if (tvp) { attrs->va_nodeid = tvp->mtpoint.Fid.Vnode + (tvp->mtpoint.Fid.Volume << 16); if (FidCmp(&afs_rootFid, &avc->fid) && !attrs->va_nodeid) attrs->va_nodeid = 2; afs_PutVolume(tvp, READ_LOCK); - } - else attrs->va_nodeid = 2; - } - else attrs->va_nodeid = avc->fid.Fid.Vnode + (avc->fid.Fid.Volume << 16); + } else + attrs->va_nodeid = 2; + } else + attrs->va_nodeid = avc->fid.Fid.Vnode + (avc->fid.Fid.Volume << 16); attrs->va_nodeid &= 0x7fffffff; /* Saber C hates negative inode #s! */ attrs->va_nlink = fakedir ? 100 : avc->m.LinkCount; attrs->va_size = fakedir ? 4096 : avc->m.Length; @@ -124,14 +127,15 @@ int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) */ #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) /* nfs on these systems puts an 0 in nsec and stores the nfs usec (aka - dataversion) in va_gen */ + * dataversion) in va_gen */ attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec = attrs->va_ctime.tv_nsec = 0; attrs->va_gen = hgetlo(avc->m.DataVersion); #elif defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_OBSD_ENV) attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec = - attrs->va_ctime.tv_nsec = (hgetlo(avc->m.DataVersion) & 0x7ffff) * 1000; + attrs->va_ctime.tv_nsec = + (hgetlo(avc->m.DataVersion) & 0x7ffff) * 1000; #else attrs->va_atime.tv_usec = attrs->va_mtime.tv_usec = attrs->va_ctime.tv_usec = (hgetlo(avc->m.DataVersion) & 0x7ffff); @@ -140,9 +144,9 @@ int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) attrs->va_flags = 0; #endif #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) - attrs->va_blksize = PAGESIZE; /* XXX Was 8192 XXX */ + attrs->va_blksize = PAGESIZE; /* XXX Was 8192 XXX */ #else - attrs->va_blocksize = PAGESIZE; /* XXX Was 8192 XXX */ + attrs->va_blocksize = PAGESIZE; /* XXX Was 8192 XXX */ #endif #ifdef AFS_DEC_ENV /* Have to use real device #s in Ultrix, since that's how FS type is @@ -153,35 +157,38 @@ int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) attrs->va_rdev = ((struct mount *)(afs_globalVFS->vfs_data))->m_dev; else attrs->va_rdev = 1; /* better than nothing */ -#else +#else attrs->va_rdev = 1; #endif #if defined(AFS_HPUX110_ENV) - if (afs_globalVFS) attrs->va_fstype = afs_globalVFS->vfs_mtype; + if (afs_globalVFS) + attrs->va_fstype = afs_globalVFS->vfs_mtype; #endif /* * Below return 0 (and not 1) blocks if the file is zero length. This conforms - * better with the other filesystems that do return 0. + * better with the other filesystems that do return 0. */ #if !defined(AFS_OSF_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) #if !defined(AFS_HPUX_ENV) #ifdef AFS_SUN5_ENV - attrs->va_nblocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) << 1 : 0); + attrs->va_nblocks = + (attrs->va_size ? ((attrs->va_size + 1023) >> 10) << 1 : 0); #elif defined(AFS_SGI_ENV) attrs->va_blocks = BTOBB(attrs->va_size); #else - attrs->va_blocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) << 1 : 0); + attrs->va_blocks = + (attrs->va_size ? ((attrs->va_size + 1023) >> 10) << 1 : 0); #endif #else /* !defined(AFS_HPUX_ENV) */ - attrs->va_blocks = (attrs->va_size? ((attrs->va_size + 1023)>>10) : 0); + attrs->va_blocks = (attrs->va_size ? ((attrs->va_size + 1023) >> 10) : 0); #endif /* !defined(AFS_HPUX_ENV) */ -#else /* ! AFS_OSF_ENV && !AFS_DARWIN_ENV && !AFS_XBSD_ENV */ - attrs->va_bytes = (attrs->va_size? (attrs->va_size + 1023) : 1024); +#else /* ! AFS_OSF_ENV && !AFS_DARWIN_ENV && !AFS_XBSD_ENV */ + attrs->va_bytes = (attrs->va_size ? (attrs->va_size + 1023) : 1024); #ifdef va_bytes_rsv attrs->va_bytes_rsv = -1; #endif -#endif /* ! AFS_OSF_ENV && !AFS_DARWIN_ENV && !AFS_XBSD_ENV */ +#endif /* ! AFS_OSF_ENV && !AFS_DARWIN_ENV && !AFS_XBSD_ENV */ #ifdef AFS_LINUX22_ENV /* And linux has its own stash as well. */ @@ -189,13 +196,12 @@ int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) #endif #ifdef notdef #ifdef AFS_AIX51_ENV - afs_Trace2(afs_iclSetp, CM_TRACE_STATACLX, - ICL_TYPE_POINTER, attrs->va_acl, - ICL_TYPE_INT32, attrs->va_aclsiz); + afs_Trace2(afs_iclSetp, CM_TRACE_STATACLX, ICL_TYPE_POINTER, + attrs->va_acl, ICL_TYPE_INT32, attrs->va_aclsiz); if (attrs->va_acl && attrs->va_aclsiz >= 12) { struct acl *ap; - ap = (struct acl *) attrs->va_acl; + ap = (struct acl *)attrs->va_acl; ap->acl_len = 8; ap->acl_mode = ACL_MODE; ap->acl_rsvd = 0; @@ -211,9 +217,12 @@ int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) -int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, int flags, struct AFS_UCRED *acred) +int +afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, int flags, + struct AFS_UCRED *acred) #else -int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred) +int +afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred) #endif { afs_int32 code; @@ -223,15 +232,16 @@ int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred) int inited = 0; OSI_VC_CONVERT(avc) - AFS_STATCNT(afs_getattr); - afs_Trace2(afs_iclSetp, CM_TRACE_GETATTR, ICL_TYPE_POINTER, avc, + AFS_STATCNT(afs_getattr); + afs_Trace2(afs_iclSetp, CM_TRACE_GETATTR, ICL_TYPE_POINTER, avc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); if (afs_fakestat_enable && avc->mvstat == 1) { struct afs_fakestat_state fakestat; code = afs_InitReq(&treq, acred); - if (code) return code; + if (code) + return code; afs_InitFakeStat(&fakestat); code = afs_TryEvalFakeStat(&avc, &fakestat, &treq); if (code) { @@ -243,17 +253,16 @@ int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred) afs_PutFakeStat(&fakestat); return code; } - #if defined(AFS_SUN5_ENV) if (flags & ATTR_HINT) { - code = afs_CopyOutAttrs(avc, attrs); - return code; + code = afs_CopyOutAttrs(avc, attrs); + return code; } #endif #if defined(AFS_DARWIN_ENV) if (avc->states & CUBCinit) { - code = afs_CopyOutAttrs(avc, attrs); - return code; + code = afs_CopyOutAttrs(avc, attrs); + return code; } #endif @@ -261,102 +270,106 @@ int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred) afs_BozonLock(&avc->pvnLock, avc); #endif - if (afs_shuttingdown) return EIO; + if (afs_shuttingdown) + return EIO; if (!(avc->states & CStatd)) { - if (!(code = afs_InitReq(&treq, acred))) { - code = afs_VerifyVCache2(avc, &treq); - inited = 1; - } - } - else code = 0; + if (!(code = afs_InitReq(&treq, acred))) { + code = afs_VerifyVCache2(avc, &treq); + inited = 1; + } + } else + code = 0; #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) - if (code == 0) osi_FlushPages(avc, acred); + if (code == 0) + osi_FlushPages(avc, acred); afs_BozonUnlock(&avc->pvnLock, avc); #endif if (code == 0) { - osi_FlushText(avc); /* only needed to flush text if text locked last time */ + osi_FlushText(avc); /* only needed to flush text if text locked last time */ code = afs_CopyOutAttrs(avc, attrs); if (afs_nfsexporter) { - if (!inited) { - if ((code = afs_InitReq(&treq, acred))) - return code; - inited = 1; - } - if (AFS_NFSXLATORREQ(acred)) { - if ((vType(avc) != VDIR) && - !afs_AccessOK(avc, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) { - return EACCES; - } - if (avc->mvstat == 2) { + if (!inited) { + if ((code = afs_InitReq(&treq, acred))) + return code; + inited = 1; + } + if (AFS_NFSXLATORREQ(acred)) { + if ((vType(avc) != VDIR) + && !afs_AccessOK(avc, PRSFS_READ, &treq, + CHECK_MODE_BITS | + CMB_ALLOW_EXEC_AS_READ)) { + return EACCES; + } + if (avc->mvstat == 2) { #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - attrs->va_mtime.tv_nsec += ((++avc->xlatordv) * 1000); + attrs->va_mtime.tv_nsec += ((++avc->xlatordv) * 1000); #else - attrs->va_mtime.tv_usec += ++avc->xlatordv; -#endif - } - } - if ((au = afs_FindUser(treq.uid, -1, READ_LOCK))) { - register struct afs_exporter *exporter = au->exporter; - - if (exporter && !(afs_nfsexporter->exp_states & EXP_UNIXMODE)) { - unsigned int ubits; - /* - * If the remote user wishes to enforce default Unix mode semantics, - * like in the nfs exporter case, we OR in the user bits - * into the group and other bits. We need to do this - * because there is no RFS_ACCESS call and thus nfs - * clients implement nfs_access by interpreting the - * mode bits in the traditional way, which of course - * loses with afs. - */ - ubits = (attrs->va_mode & 0700) >> 6; - attrs->va_mode = attrs->va_mode | ubits | (ubits << 3); - /* If it's the root of AFS, replace the inode number with the - * inode number of the mounted on directory; otherwise this - * confuses getwd()... */ -#ifdef AFS_LINUX22_ENV - if (avc == afs_globalVp) { - struct inode *ip = avc->v.i_sb->s_root->d_inode; - attrs->va_nodeid = ip->i_ino; + attrs->va_mtime.tv_usec += ++avc->xlatordv; +#endif } + } + if ((au = afs_FindUser(treq.uid, -1, READ_LOCK))) { + register struct afs_exporter *exporter = au->exporter; + + if (exporter && !(afs_nfsexporter->exp_states & EXP_UNIXMODE)) { + unsigned int ubits; + /* + * If the remote user wishes to enforce default Unix mode semantics, + * like in the nfs exporter case, we OR in the user bits + * into the group and other bits. We need to do this + * because there is no RFS_ACCESS call and thus nfs + * clients implement nfs_access by interpreting the + * mode bits in the traditional way, which of course + * loses with afs. + */ + ubits = (attrs->va_mode & 0700) >> 6; + attrs->va_mode = attrs->va_mode | ubits | (ubits << 3); + /* If it's the root of AFS, replace the inode number with the + * inode number of the mounted on directory; otherwise this + * confuses getwd()... */ +#ifdef AFS_LINUX22_ENV + if (avc == afs_globalVp) { + struct inode *ip = avc->v.i_sb->s_root->d_inode; + attrs->va_nodeid = ip->i_ino; + } #else - if (AFSTOV(avc)->v_flag & VROOT) { - struct vnode *vp = AFSTOV(avc); + if (AFSTOV(avc)->v_flag & VROOT) { + struct vnode *vp = AFSTOV(avc); - vp = vp->v_vfsp->vfs_vnodecovered; - if (vp) { /* Ignore weird failures */ + vp = vp->v_vfsp->vfs_vnodecovered; + if (vp) { /* Ignore weird failures */ #ifdef AFS_SGI62_ENV - attrs->va_nodeid = VnodeToIno(vp); + attrs->va_nodeid = VnodeToIno(vp); #else - struct inode *ip; - - ip = (struct inode *) VTOI(vp); - if (ip) /* Ignore weird failures */ - attrs->va_nodeid = ip->i_number; + struct inode *ip; + + ip = (struct inode *)VTOI(vp); + if (ip) /* Ignore weird failures */ + attrs->va_nodeid = ip->i_number; #endif + } } - } #endif /* AFS_LINUX22_ENV */ - } - afs_PutUser(au, READ_LOCK); - } + } + afs_PutUser(au, READ_LOCK); + } } } if (!code) - return 0; + return 0; code = afs_CheckCode(code, &treq, 14); return code; } /* convert a Unix request into a status store request */ -int afs_VAttrToAS(register struct vcache *avc, register struct vattr *av, - register struct AFSStoreStatus *as) +int +afs_VAttrToAS(register struct vcache *avc, register struct vattr *av, + register struct AFSStoreStatus *as) { register int mask; mask = 0; @@ -374,12 +387,11 @@ int afs_VAttrToAS(register struct vcache *avc, register struct vattr *av, mask |= AFS_SETMODE; as->UnixModeBits = av->va_mode & 0xffff; if (avc->states & CForeign) { - ObtainWriteLock(&avc->lock,127); + ObtainWriteLock(&avc->lock, 127); afs_FreeAllAxs(&(avc->Access)); ReleaseWriteLock(&avc->lock); } } - #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV) if (av->va_mask & AT_GID) { #else @@ -396,7 +408,6 @@ int afs_VAttrToAS(register struct vcache *avc, register struct vattr *av, mask |= AFS_SETGROUP; as->Group = av->va_gid; } - #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV) if (av->va_mask & AT_UID) { #else @@ -438,9 +449,13 @@ int afs_VAttrToAS(register struct vcache *avc, register struct vattr *av, * synchronously, therefore, it's not needed. */ #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) -int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, int flags, struct AFS_UCRED *acred) +int +afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, int flags, + struct AFS_UCRED *acred) #else -int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFS_UCRED *acred) +int +afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, + struct AFS_UCRED *acred) #endif { struct vrequest treq; @@ -449,27 +464,28 @@ int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFS_UCRED struct afs_fakestat_state fakestate; OSI_VC_CONVERT(avc) - AFS_STATCNT(afs_setattr); + AFS_STATCNT(afs_setattr); #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV) - afs_Trace4(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, attrs->va_mask, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(attrs->va_size), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); + afs_Trace4(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc, + ICL_TYPE_INT32, attrs->va_mask, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(attrs->va_size), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length)); #else - afs_Trace4(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, attrs->va_mode, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(attrs->va_size), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); + afs_Trace4(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc, + ICL_TYPE_INT32, attrs->va_mode, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(attrs->va_size), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length)); #endif - if ((code = afs_InitReq(&treq, acred))) return code; - + if ((code = afs_InitReq(&treq, acred))) + return code; + afs_InitFakeStat(&fakestate); code = afs_EvalFakeStat(&avc, &fakestate, &treq); if (code) goto done; if (avc->states & CRO) { - code=EROFS; + code = EROFS; goto done; } #if defined(AFS_SGI_ENV) @@ -521,19 +537,19 @@ int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFS_UCRED #endif #if defined(AFS_SGI_ENV) - AFS_RWLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE); #endif #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV) if (attrs->va_mask & AT_SIZE) { #else #if defined(AFS_OSF_ENV) if (attrs->va_size != VNOVAL) { -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ if (attrs->va_size != -1) { #endif #endif afs_size_t tsize = attrs->va_size; - ObtainWriteLock(&avc->lock,128); + ObtainWriteLock(&avc->lock, 128); avc->states |= CDirty; code = afs_TruncateAllSegments(avc, tsize, &treq, acred); /* if date not explicitly set by this call, set it ourselves, since we @@ -543,14 +559,14 @@ int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFS_UCRED astat.ClientModTime = osi_Time(); } if (code == 0) { - if ( ( (avc->execsOrWriters <= 0 ) && (avc->states & CCreating) == 0) - || ( avc->execsOrWriters == 1 && AFS_NFSXLATORREQ(acred)) ) { - code = afs_StoreAllSegments(avc, &treq, AFS_ASYNC); - if (!code) - avc->states &= ~CDirty; - } + if (((avc->execsOrWriters <= 0) && (avc->states & CCreating) == 0) + || (avc->execsOrWriters == 1 && AFS_NFSXLATORREQ(acred))) { + code = afs_StoreAllSegments(avc, &treq, AFS_ASYNC); + if (!code) + avc->states &= ~CDirty; + } } else - avc->states &= ~CDirty; + avc->states &= ~CDirty; ReleaseWriteLock(&avc->lock); hzero(avc->flushDV); @@ -561,20 +577,19 @@ int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFS_UCRED #endif } if (code == 0) { - ObtainSharedLock(&avc->lock,16); /* lock entry */ - code = afs_WriteVCache(avc, &astat, &treq); /* send request */ + ObtainSharedLock(&avc->lock, 16); /* lock entry */ + code = afs_WriteVCache(avc, &astat, &treq); /* send request */ ReleaseSharedLock(&avc->lock); /* release lock */ } if (code) { - ObtainWriteLock(&afs_xcbhash, 487); - afs_DequeueCallback(avc); - avc->states &= ~CStatd; - ReleaseWriteLock(&afs_xcbhash); - if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR)) - osi_dnlc_purgedp(avc); - /* error? erase any changes we made to vcache entry */ - } - + ObtainWriteLock(&afs_xcbhash, 487); + afs_DequeueCallback(avc); + avc->states &= ~CStatd; + ReleaseWriteLock(&afs_xcbhash); + if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR)) + osi_dnlc_purgedp(avc); + /* error? erase any changes we made to vcache entry */ + } #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) if (AFS_NFSXLATORREQ(acred)) { avc->execsOrWriters--; @@ -584,9 +599,9 @@ int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFS_UCRED afs_BozonUnlock(&avc->pvnLock, avc); #endif #if defined(AFS_SGI_ENV) - AFS_RWUNLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE); #endif -done: + done: afs_PutFakeStat(&fakestate); code = afs_CheckCode(code, &treq, 15); return code; diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c index 6064e34c2..c79a7b50c 100644 --- a/src/afs/VNOPS/afs_vnop_create.c +++ b/src/afs/VNOPS/afs_vnop_create.c @@ -16,11 +16,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /* Standard vendor system headers */ -#include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/sysincludes.h" /* Standard vendor system headers */ +#include "afsincludes.h" /* Afs-based standard headers */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -30,22 +31,26 @@ RCSID("$Header$"); * afs_setattr is called in here for truncation. */ #ifdef AFS_OSF_ENV -int afs_create(struct nameidata *ndp, struct vattr *attrs) -#else /* AFS_OSF_ENV */ +int +afs_create(struct nameidata *ndp, struct vattr *attrs) +#else /* AFS_OSF_ENV */ #ifdef AFS_SGI64_ENV -int afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, int flags, - int amode, struct vcache **avcp, struct AFS_UCRED *acred) +int +afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, int flags, + int amode, struct vcache **avcp, struct AFS_UCRED *acred) #else /* AFS_SGI64_ENV */ -int afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, enum vcexcl aexcl, - int amode, struct vcache **avcp, struct AFS_UCRED *acred) -#endif /* AFS_SGI64_ENV */ -#endif /* AFS_OSF_ENV */ - { +int +afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, + enum vcexcl aexcl, int amode, struct vcache **avcp, + struct AFS_UCRED *acred) +#endif /* AFS_SGI64_ENV */ +#endif /* AFS_OSF_ENV */ +{ #ifdef AFS_OSF_ENV register struct vcache *adp = VTOAFS(ndp->ni_dvp); char *aname = ndp->ni_dent.d_name; - enum vcexcl aexcl = NONEXCL; /* XXX - create called properly */ - int amode = 0; /* XXX - checked in higher level */ + enum vcexcl aexcl = NONEXCL; /* XXX - create called properly */ + int amode = 0; /* XXX - checked in higher level */ struct vcache **avcp = (struct vcache **)&(ndp->ni_vp); struct ucred *acred = ndp->ni_cred; #endif @@ -62,16 +67,15 @@ int afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, enum vcexcl a afs_int32 now; struct dcache *tdc; afs_size_t offset, len; - struct server *hostp=0; + struct server *hostp = 0; struct vcache *tvc; - struct volume* volp = 0; + struct volume *volp = 0; struct afs_fakestat_state fakestate; - XSTATS_DECLS - OSI_VC_CONVERT(adp) + XSTATS_DECLS OSI_VC_CONVERT(adp) - AFS_STATCNT(afs_create); - if ((code = afs_InitReq(&treq, acred))) + AFS_STATCNT(afs_create); + if ((code = afs_InitReq(&treq, acred))) goto done2; afs_Trace3(afs_iclSetp, CM_TRACE_CREATE, ICL_TYPE_POINTER, adp, @@ -107,28 +111,31 @@ int afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, enum vcexcl a #endif case VFIFO: /* We don't support special devices or FIFOs */ - code = EINVAL; + code = EINVAL; goto done; default: ; } code = afs_EvalFakeStat(&adp, &fakestate, &treq); - if (code) goto done; -tagain: + if (code) + goto done; + tagain: code = afs_VerifyVCache(adp, &treq); - if (code) goto done; + if (code) + goto done; /** If the volume is read-only, return error without making an RPC to the * fileserver */ - if ( adp->states & CRO ) { - code = EROFS; + if (adp->states & CRO) { + code = EROFS; goto done; } tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); - ObtainWriteLock(&adp->lock,135); - if (tdc) ObtainSharedLock(&tdc->lock,630); + ObtainWriteLock(&adp->lock, 135); + if (tdc) + ObtainSharedLock(&tdc->lock, 630); /* * Make sure that the data in the cache is current. We may have @@ -146,7 +153,7 @@ tagain: if (tdc) { /* see if file already exists. If it does, we only set * the size attributes (to handle O_TRUNC) */ - code = afs_dir_Lookup(&tdc->f.inode, aname, &newFid.Fid); /* use dnlc first xxx */ + code = afs_dir_Lookup(&tdc->f.inode, aname, &newFid.Fid); /* use dnlc first xxx */ if (code == 0) { ReleaseSharedLock(&tdc->lock); afs_PutDCache(tdc); @@ -156,7 +163,7 @@ tagain: #else if (aexcl != NONEXCL) { #endif - code = EEXIST; /* file exists in excl mode open */ + code = EEXIST; /* file exists in excl mode open */ goto done; } /* found the file, so use it */ @@ -164,10 +171,10 @@ tagain: newFid.Fid.Volume = adp->fid.Fid.Volume; tvc = NULL; if (newFid.Fid.Unique == 0) { - tvc = afs_LookupVCache(&newFid, &treq, NULL, adp, aname); + tvc = afs_LookupVCache(&newFid, &treq, NULL, adp, aname); } - if (!tvc) /* lookup failed or wasn't called */ - tvc = afs_GetVCache(&newFid, &treq, NULL, NULL); + if (!tvc) /* lookup failed or wasn't called */ + tvc = afs_GetVCache(&newFid, &treq, NULL, NULL); if (tvc) { /* if the thing exists, we need the right access to open it. @@ -178,36 +185,36 @@ tagain: * We used to check always for READ access before; the * problem is that we will fail if the existing file * has mode -w-w-w, which is wrong. - */ - if ((amode & VREAD) && - !afs_AccessOK(tvc, PRSFS_READ, &treq, CHECK_MODE_BITS)) { - afs_PutVCache(tvc); - code = EACCES; - goto done; + */ + if ((amode & VREAD) + && !afs_AccessOK(tvc, PRSFS_READ, &treq, CHECK_MODE_BITS)) { + afs_PutVCache(tvc); + code = EACCES; + goto done; } - #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) - if ((amode & VWRITE) || (attrs->va_mask & AT_SIZE)) + if ((amode & VWRITE) || (attrs->va_mask & AT_SIZE)) #else - if ((amode & VWRITE) || len != 0xffffffff) + if ((amode & VWRITE) || len != 0xffffffff) #endif - { + { /* needed for write access check */ tvc->parentVnode = adp->fid.Fid.Vnode; tvc->parentUnique = adp->fid.Fid.Unique; /* need write mode for these guys */ - if (!afs_AccessOK(tvc, PRSFS_WRITE, &treq, CHECK_MODE_BITS)) { + if (!afs_AccessOK + (tvc, PRSFS_WRITE, &treq, CHECK_MODE_BITS)) { afs_PutVCache(tvc); code = EACCES; goto done; } } #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) - if (attrs->va_mask & AT_SIZE) + if (attrs->va_mask & AT_SIZE) #else - if (len != 0xffffffff) + if (len != 0xffffffff) #endif - { + { if (vType(tvc) != VREG) { afs_PutVCache(tvc); code = EISDIR; @@ -220,20 +227,21 @@ tagain: VATTR_NULL(attrs); #endif attrs->va_size = len; - ObtainWriteLock(&tvc->lock,136); + ObtainWriteLock(&tvc->lock, 136); tvc->states |= CCreating; ReleaseWriteLock(&tvc->lock); #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) #if defined(AFS_SGI64_ENV) - code = afs_setattr(VNODE_TO_FIRST_BHV((vnode_t*)tvc), - attrs, 0, acred); + code = + afs_setattr(VNODE_TO_FIRST_BHV((vnode_t *) tvc), + attrs, 0, acred); #else code = afs_setattr(tvc, attrs, 0, acred); #endif /* AFS_SGI64_ENV */ #else /* SUN5 || SGI */ code = afs_setattr(tvc, attrs, acred); #endif /* SUN5 || SGI */ - ObtainWriteLock(&tvc->lock,137); + ObtainWriteLock(&tvc->lock, 137); tvc->states &= ~CCreating; ReleaseWriteLock(&tvc->lock); if (code) { @@ -242,8 +250,8 @@ tagain: } } *avcp = tvc; - } - else code = ENOENT; /* shouldn't get here */ + } else + code = ENOENT; /* shouldn't get here */ /* make sure vrefCount bumped only if code == 0 */ goto done; } @@ -252,59 +260,60 @@ tagain: /* if we create the file, we don't do any access checks, since * that's how O_CREAT is supposed to work */ if (adp->states & CForeign) { - origCBs = afs_allCBs; - origZaps = afs_allZaps; + origCBs = afs_allCBs; + origZaps = afs_allZaps; } else { - origCBs = afs_evenCBs; /* if changes, we don't really have a callback */ - origZaps = afs_evenZaps; /* number of even numbered vnodes discarded */ + origCBs = afs_evenCBs; /* if changes, we don't really have a callback */ + origZaps = afs_evenZaps; /* number of even numbered vnodes discarded */ } InStatus.Mask = AFS_SETMODTIME | AFS_SETMODE | AFS_SETGROUP; InStatus.ClientModTime = osi_Time(); - InStatus.Group = (afs_int32)acred->cr_gid; + InStatus.Group = (afs_int32) acred->cr_gid; if (AFS_NFSXLATORREQ(acred)) { /* * XXX The following is mainly used to fix a bug in the HP-UX * nfs client where they create files with mode of 0 without * doing any setattr later on to fix it. * XXX - */ + */ #if defined(AFS_AIX_ENV) if (attrs->va_mode != -1) { #else #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) - if (attrs->va_mask & AT_MODE) { + if (attrs->va_mask & AT_MODE) { #else if (attrs->va_mode != ((unsigned short)-1)) { #endif #endif if (!attrs->va_mode) - attrs->va_mode = 0x1b6; /* XXX default mode: rw-rw-rw XXX */ + attrs->va_mode = 0x1b6; /* XXX default mode: rw-rw-rw XXX */ } } - InStatus.UnixModeBits = attrs->va_mode & 0xffff; /* only care about protection bits */ + InStatus.UnixModeBits = attrs->va_mode & 0xffff; /* only care about protection bits */ do { tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK); if (tc) { - hostp = tc->srvr->server; /* remember for callback processing */ + hostp = tc->srvr->server; /* remember for callback processing */ now = osi_Time(); XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_CREATEFILE); RX_AFS_GUNLOCK(); - code = RXAFS_CreateFile(tc->id, (struct AFSFid *) &adp->fid.Fid, - aname, &InStatus, (struct AFSFid *) - &newFid.Fid, &OutFidStatus, - &OutDirStatus, &CallBack, &tsync); + code = + RXAFS_CreateFile(tc->id, (struct AFSFid *)&adp->fid.Fid, + aname, &InStatus, (struct AFSFid *) + &newFid.Fid, &OutFidStatus, &OutDirStatus, + &CallBack, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; CallBack.ExpirationTime += now; - } - else code = -1; - } while - (afs_Analyze(tc, code, &adp->fid, &treq, - AFS_STATS_FS_RPCIDX_CREATEFILE, SHARED_LOCK, NULL)); + } else + code = -1; + } while (afs_Analyze + (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_CREATEFILE, + SHARED_LOCK, NULL)); #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) if (code == EEXIST && aexcl == NONEXCL) { /* This lookup was handled in the common vn_open code in the - vnode layer */ + * vnode layer */ if (tdc) { ReleaseSharedLock(&tdc->lock); afs_PutDCache(tdc); @@ -312,7 +321,7 @@ tagain: ReleaseWriteLock(&adp->lock); goto done; } -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ #ifdef AFS_SGI64_ENV if (code == EEXIST && !(flags & VEXCL)) { #else /* AFS_SGI64_ENV */ @@ -326,12 +335,11 @@ tagain: ReleaseWriteLock(&adp->lock); #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) #if defined(AFS_SGI64_ENV) - code = afs_lookup(VNODE_TO_FIRST_BHV((vnode_t*)adp), aname, avcp, - NULL, 0, - NULL, acred); + code = + afs_lookup(VNODE_TO_FIRST_BHV((vnode_t *) adp), aname, avcp, NULL, + 0, NULL, acred); #else - code = afs_lookup(adp, aname, avcp, NULL, 0, - NULL, acred); + code = afs_lookup(adp, aname, avcp, NULL, 0, NULL, acred); #endif /* AFS_SGI64_ENV */ #else /* SUN5 || SGI */ code = afs_lookup(adp, aname, avcp, acred); @@ -341,11 +349,11 @@ tagain: #endif /* AFS_OSF_ENV */ if (code) { if (code < 0) { - ObtainWriteLock(&afs_xcbhash, 488); - afs_DequeueCallback(adp); - adp->states &= ~CStatd; - ReleaseWriteLock(&afs_xcbhash); - osi_dnlc_purgedp(adp); + ObtainWriteLock(&afs_xcbhash, 488); + afs_DequeueCallback(adp); + adp->states &= ~CStatd; + ReleaseWriteLock(&afs_xcbhash); + osi_dnlc_purgedp(adp); } ReleaseWriteLock(&adp->lock); if (tdc) { @@ -355,13 +363,14 @@ tagain: goto done; } /* otherwise, we should see if we can make the change to the dir locally */ - if (tdc) UpgradeSToWLock(&tdc->lock, 631); + if (tdc) + UpgradeSToWLock(&tdc->lock, 631); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ code = afs_dir_Create(&tdc->f.inode, aname, &newFid.Fid); if (code) { - ZapDCE(tdc); - DZap(&tdc->f.inode); + ZapDCE(tdc); + DZap(&tdc->f.inode); } } if (tdc) { @@ -374,38 +383,38 @@ tagain: volp = afs_FindVolume(&newFid, READ_LOCK); /* New tricky optimistic callback handling algorithm for file creation works - as follows. We create the file essentially with no locks set at all. File - server may thus handle operations from others cache managers as well as from - this very own cache manager that reference the file in question before - we managed to create the cache entry. However, if anyone else changes - any of the status information for a file, we'll see afs_evenCBs increase - (files always have even fids). If someone on this workstation manages - to do something to the file, they'll end up having to create a cache - entry for the new file. Either we'll find it once we've got the afs_xvcache - lock set, or it was also *deleted* the vnode before we got there, in which case - we will find evenZaps has changed, too. Thus, we only assume we have the right - status information if no callbacks or vnode removals have occurred to even - numbered files from the time the call started until the time that we got the xvcache - lock set. Of course, this also assumes that any call that modifies a file first - gets a write lock on the file's vnode, but if that weren't true, the whole cache manager - would fail, since no call would be able to update the local vnode status after modifying - a file on a file server. */ - ObtainWriteLock(&afs_xvcache,138); - if (adp->states & CForeign) - finalZaps = afs_allZaps; /* do this before calling newvcache */ + * as follows. We create the file essentially with no locks set at all. File + * server may thus handle operations from others cache managers as well as from + * this very own cache manager that reference the file in question before + * we managed to create the cache entry. However, if anyone else changes + * any of the status information for a file, we'll see afs_evenCBs increase + * (files always have even fids). If someone on this workstation manages + * to do something to the file, they'll end up having to create a cache + * entry for the new file. Either we'll find it once we've got the afs_xvcache + * lock set, or it was also *deleted* the vnode before we got there, in which case + * we will find evenZaps has changed, too. Thus, we only assume we have the right + * status information if no callbacks or vnode removals have occurred to even + * numbered files from the time the call started until the time that we got the xvcache + * lock set. Of course, this also assumes that any call that modifies a file first + * gets a write lock on the file's vnode, but if that weren't true, the whole cache manager + * would fail, since no call would be able to update the local vnode status after modifying + * a file on a file server. */ + ObtainWriteLock(&afs_xvcache, 138); + if (adp->states & CForeign) + finalZaps = afs_allZaps; /* do this before calling newvcache */ else - finalZaps = afs_evenZaps; /* do this before calling newvcache */ + finalZaps = afs_evenZaps; /* do this before calling newvcache */ /* don't need to call RemoveVCB, since only path leaving a callback is the - one where we pass through afs_NewVCache. Can't have queued a VCB unless - we created and freed an entry between file creation time and here, and the - freeing of the vnode will change evenZaps. Don't need to update the VLRU - queue, since the find will only succeed in the event of a create race, and - then the vcache will be at the front of the VLRU queue anyway... */ + * one where we pass through afs_NewVCache. Can't have queued a VCB unless + * we created and freed an entry between file creation time and here, and the + * freeing of the vnode will change evenZaps. Don't need to update the VLRU + * queue, since the find will only succeed in the event of a create race, and + * then the vcache will be at the front of the VLRU queue anyway... */ if (!(tvc = afs_FindVCache(&newFid, 0, DO_STATS))) { tvc = afs_NewVCache(&newFid, hostp); if (tvc) { int finalCBs; - ObtainWriteLock(&tvc->lock,139); + ObtainWriteLock(&tvc->lock, 139); ObtainWriteLock(&afs_xcbhash, 489); finalCBs = afs_evenCBs; @@ -415,42 +424,40 @@ tagain: finalCBs = afs_allCBs; } if (origCBs == finalCBs && origZaps == finalZaps) { - tvc->states |= CStatd; /* we've fake entire thing, so don't stat */ + tvc->states |= CStatd; /* we've fake entire thing, so don't stat */ tvc->states &= ~CBulkFetching; tvc->cbExpires = CallBack.ExpirationTime; afs_QueueCallback(tvc, CBHash(CallBack.ExpirationTime), volp); - } - else { - afs_DequeueCallback(tvc); - tvc->states &= ~(CStatd | CUnique); - tvc->callback = 0; - if (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR)) - osi_dnlc_purgedp(tvc); + } else { + afs_DequeueCallback(tvc); + tvc->states &= ~(CStatd | CUnique); + tvc->callback = 0; + if (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR)) + osi_dnlc_purgedp(tvc); } ReleaseWriteLock(&afs_xcbhash); afs_ProcessFS(tvc, &OutFidStatus, &treq); ReleaseWriteLock(&tvc->lock); *avcp = tvc; code = 0; - } - else code = ENOENT; - } - else { - /* otherwise cache entry already exists, someone else must - * have created it. Comments used to say: "don't need write - * lock to *clear* these flags" but we should do it anyway. - * Code used to clear stat bit and callback, but I don't see - * the point -- we didn't have a create race, somebody else just - * snuck into NewVCache before we got here, probably a racing - * lookup. - */ + } else + code = ENOENT; + } else { + /* otherwise cache entry already exists, someone else must + * have created it. Comments used to say: "don't need write + * lock to *clear* these flags" but we should do it anyway. + * Code used to clear stat bit and callback, but I don't see + * the point -- we didn't have a create race, somebody else just + * snuck into NewVCache before we got here, probably a racing + * lookup. + */ *avcp = tvc; code = 0; } ReleaseWriteLock(&afs_xvcache); -done: - if ( volp ) + done: + if (volp) afs_PutVolume(volp, READ_LOCK); if (code == 0) { @@ -458,7 +465,6 @@ done: /* return the new status in vattr */ afs_CopyOutAttrs(*avcp, attrs); } - #ifdef AFS_OSF_ENV if (!code && !strcmp(aname, "core")) tvc->states |= CCore1; @@ -467,10 +473,10 @@ done: afs_PutFakeStat(&fakestate); code = afs_CheckCode(code, &treq, 20); -done2: + done2: #ifdef AFS_OSF_ENV afs_PutVCache(adp); -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ return code; } @@ -486,8 +492,9 @@ done2: * This routine must be called with the stat cache entry write-locked, * and dcache entry write-locked. */ -int afs_LocalHero(register struct vcache *avc, register struct dcache *adc, - register AFSFetchStatus *astat, register int aincr) +int +afs_LocalHero(register struct vcache *avc, register struct dcache *adc, + register AFSFetchStatus * astat, register int aincr) { register afs_int32 ok; afs_hyper_t avers; @@ -496,14 +503,13 @@ int afs_LocalHero(register struct vcache *avc, register struct dcache *adc, hset64(avers, astat->dataVersionHigh, astat->DataVersion); /* this *is* the version number, no matter what */ if (adc) { - ok = (hsame(avc->m.DataVersion, adc->f.versionNo) && avc->callback + ok = (hsame(avc->m.DataVersion, adc->f.versionNo) && avc->callback && (avc->states & CStatd) && avc->cbExpires >= osi_Time()); - } - else { + } else { ok = 0; } #if defined(AFS_SGI_ENV) - osi_Assert(avc->v.v_type == VDIR); + osi_Assert(avc->v.v_type == VDIR); #endif /* The bulk status code used the length as a sequence number. */ /* Don't update the vcache entry unless the stats are current. */ @@ -521,8 +527,7 @@ int afs_LocalHero(register struct vcache *avc, register struct dcache *adc, adc->dflags |= DFEntryMod; adc->f.versionNo = avers; return 1; - } - else { + } else { if (adc) { ZapDCE(adc); DZap(&adc->f.inode); diff --git a/src/afs/VNOPS/afs_vnop_dirops.c b/src/afs/VNOPS/afs_vnop_dirops.c index a3f2a63ec..f82a6e1c1 100644 --- a/src/afs/VNOPS/afs_vnop_dirops.c +++ b/src/afs/VNOPS/afs_vnop_dirops.c @@ -20,11 +20,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -36,19 +37,21 @@ extern afs_rwlock_t afs_xcbhash; #ifdef AFS_OSF_ENV afs_mkdir(ndp, attrs) - struct nameidata *ndp; - struct vattr *attrs; { + struct nameidata *ndp; + struct vattr *attrs; +{ register struct vcache *adp = VTOAFS(ndp->ni_dvp); char *aname = ndp->ni_dent.d_name; register struct vcache **avcp = (struct vcache **)&(ndp->ni_vp); struct ucred *acred = ndp->ni_cred; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred) OSI_VC_DECL(adp); - register struct vcache **avcp; - char *aname; - struct vattr *attrs; - struct AFS_UCRED *acred; { + register struct vcache **avcp; + char *aname; + struct vattr *attrs; + struct AFS_UCRED *acred; +{ #endif struct vrequest treq; register afs_int32 code; @@ -63,14 +66,13 @@ afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred) struct AFSVolSync tsync; afs_int32 now; struct afs_fakestat_state fakestate; - XSTATS_DECLS - OSI_VC_CONVERT(adp) + XSTATS_DECLS OSI_VC_CONVERT(adp) - AFS_STATCNT(afs_mkdir); + AFS_STATCNT(afs_mkdir); afs_Trace2(afs_iclSetp, CM_TRACE_MKDIR, ICL_TYPE_POINTER, adp, ICL_TYPE_STRING, aname); - if ((code = afs_InitReq(&treq, acred))) + if ((code = afs_InitReq(&treq, acred))) goto done2; afs_InitFakeStat(&fakestate); @@ -84,61 +86,67 @@ afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred) goto done; } code = afs_EvalFakeStat(&adp, &fakestate, &treq); - if (code) goto done; + if (code) + goto done; code = afs_VerifyVCache(adp, &treq); - if (code) goto done; + if (code) + goto done; /** If the volume is read-only, return error without making an RPC to the * fileserver */ - if ( adp->states & CRO ) { - code = EROFS; - goto done; + if (adp->states & CRO) { + code = EROFS; + goto done; } InStatus.Mask = AFS_SETMODTIME | AFS_SETMODE | AFS_SETGROUP; InStatus.ClientModTime = osi_Time(); - InStatus.UnixModeBits = attrs->va_mode & 0xffff; /* only care about protection bits */ - InStatus.Group = (afs_int32)acred->cr_gid; + InStatus.UnixModeBits = attrs->va_mode & 0xffff; /* only care about protection bits */ + InStatus.Group = (afs_int32) acred->cr_gid; tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); - ObtainWriteLock(&adp->lock,153); + ObtainWriteLock(&adp->lock, 153); do { tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_MAKEDIR); - now = osi_Time(); - RX_AFS_GUNLOCK(); - code = RXAFS_MakeDir(tc->id, (struct AFSFid *) &adp->fid.Fid, aname, - &InStatus, (struct AFSFid *) &newFid.Fid, - &OutFidStatus, &OutDirStatus, &CallBack, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_MAKEDIR); + now = osi_Time(); + RX_AFS_GUNLOCK(); + code = + RXAFS_MakeDir(tc->id, (struct AFSFid *)&adp->fid.Fid, aname, + &InStatus, (struct AFSFid *)&newFid.Fid, + &OutFidStatus, &OutDirStatus, &CallBack, + &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; CallBack.ExpirationTime += now; /* DON'T forget to Set the callback value... */ - } - else code = -1; - } while - (afs_Analyze(tc, code, &adp->fid, &treq, - AFS_STATS_FS_RPCIDX_MAKEDIR, SHARED_LOCK, NULL)); + } else + code = -1; + } while (afs_Analyze + (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_MAKEDIR, + SHARED_LOCK, NULL)); if (code) { if (code < 0) { - ObtainWriteLock(&afs_xcbhash, 490); - afs_DequeueCallback(adp); - adp->states &= ~CStatd; - ReleaseWriteLock(&afs_xcbhash); - osi_dnlc_purgedp(adp); + ObtainWriteLock(&afs_xcbhash, 490); + afs_DequeueCallback(adp); + adp->states &= ~CStatd; + ReleaseWriteLock(&afs_xcbhash); + osi_dnlc_purgedp(adp); } ReleaseWriteLock(&adp->lock); - if (tdc) afs_PutDCache(tdc); + if (tdc) + afs_PutDCache(tdc); goto done; } /* otherwise, we should see if we can make the change to the dir locally */ - if (tdc) ObtainWriteLock(&tdc->lock, 632); + if (tdc) + ObtainWriteLock(&tdc->lock, 632); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { - /* we can do it locally */ - code = afs_dir_Create(&tdc->f.inode, aname, &newFid.Fid); - if (code) { + /* we can do it locally */ + code = afs_dir_Create(&tdc->f.inode, aname, &newFid.Fid); + if (code) { ZapDCE(tdc); /* surprise error -- use invalid value */ DZap(&tdc->f.inode); } @@ -156,36 +164,38 @@ afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred) if (tvc) { code = 0; *avcp = tvc; - } - else code = ENOENT; -done: + } else + code = ENOENT; + done: afs_PutFakeStat(&fakestate); code = afs_CheckCode(code, &treq, 26); -done2: + done2: #ifdef AFS_OSF_ENV AFS_RELE(ndp->ni_dvp); -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ return code; } #ifdef AFS_OSF_ENV afs_rmdir(ndp) - struct nameidata *ndp; { + struct nameidata *ndp; +{ register struct vcache *adp = VTOAFS(ndp->ni_dvp); char *aname = ndp->ni_dent.d_name; struct ucred *acred = ndp->ni_cred; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ /* don't set CDirty in here because RPC is called synchronously */ #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) afs_rmdir(OSI_VC_ARG(adp), aname, cdirp, acred) - struct vnode *cdirp; + struct vnode *cdirp; #else afs_rmdir(adp, aname, acred) #endif OSI_VC_DECL(adp); - char *aname; - struct AFS_UCRED *acred; { + char *aname; + struct AFS_UCRED *acred; +{ #endif struct vrequest treq; register struct dcache *tdc; @@ -196,12 +206,11 @@ afs_rmdir(adp, aname, acred) struct AFSFetchStatus OutDirStatus; struct AFSVolSync tsync; struct afs_fakestat_state fakestate; - XSTATS_DECLS - OSI_VC_CONVERT(adp) + XSTATS_DECLS OSI_VC_CONVERT(adp) - AFS_STATCNT(afs_rmdir); + AFS_STATCNT(afs_rmdir); - afs_Trace2(afs_iclSetp, CM_TRACE_RMDIR, ICL_TYPE_POINTER, adp, + afs_Trace2(afs_iclSetp, CM_TRACE_RMDIR, ICL_TYPE_POINTER, adp, ICL_TYPE_STRING, aname); if ((code = afs_InitReq(&treq, acred))) @@ -218,34 +227,37 @@ afs_rmdir(adp, aname, acred) goto done; code = afs_VerifyVCache(adp, &treq); - if (code) goto done; + if (code) + goto done; /** If the volume is read-only, return error without making an RPC to the * fileserver */ - if ( adp->states & CRO ) { - code = EROFS; - goto done; + if (adp->states & CRO) { + code = EROFS; + goto done; } - tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); /* test for error below */ - ObtainWriteLock(&adp->lock,154); - if (tdc) ObtainSharedLock(&tdc->lock, 633); + tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); /* test for error below */ + ObtainWriteLock(&adp->lock, 154); + if (tdc) + ObtainSharedLock(&tdc->lock, 633); if (tdc && (adp->states & CForeign)) { struct VenusFid unlinkFid; unlinkFid.Fid.Vnode = 0; code = afs_dir_Lookup(&tdc->f.inode, aname, &unlinkFid.Fid); - if (code == 0) { - afs_int32 cached=0; + if (code == 0) { + afs_int32 cached = 0; unlinkFid.Cell = adp->fid.Cell; unlinkFid.Fid.Volume = adp->fid.Fid.Volume; if (unlinkFid.Fid.Unique == 0) { - tvc = afs_LookupVCache(&unlinkFid, &treq, &cached, adp, aname); + tvc = + afs_LookupVCache(&unlinkFid, &treq, &cached, adp, aname); } else { ObtainReadLock(&afs_xvcache); - tvc = afs_FindVCache(&unlinkFid, 0, 1/* do xstats */); + tvc = afs_FindVCache(&unlinkFid, 0, 1 /* do xstats */ ); ReleaseReadLock(&afs_xvcache); } } @@ -254,17 +266,18 @@ afs_rmdir(adp, aname, acred) do { tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEDIR); - RX_AFS_GUNLOCK(); - code = RXAFS_RemoveDir(tc->id, (struct AFSFid *) &adp->fid.Fid, - aname, &OutDirStatus, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &adp->fid, &treq, - AFS_STATS_FS_RPCIDX_REMOVEDIR, SHARED_LOCK, NULL)); + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEDIR); + RX_AFS_GUNLOCK(); + code = + RXAFS_RemoveDir(tc->id, (struct AFSFid *)&adp->fid.Fid, aname, + &OutDirStatus, &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_REMOVEDIR, + SHARED_LOCK, NULL)); if (code) { if (tdc) { @@ -272,22 +285,23 @@ afs_rmdir(adp, aname, acred) afs_PutDCache(tdc); } if (code < 0) { - ObtainWriteLock(&afs_xcbhash, 491); - afs_DequeueCallback(adp); - adp->states &= ~CStatd; - ReleaseWriteLock(&afs_xcbhash); - osi_dnlc_purgedp(adp); + ObtainWriteLock(&afs_xcbhash, 491); + afs_DequeueCallback(adp); + adp->states &= ~CStatd; + ReleaseWriteLock(&afs_xcbhash); + osi_dnlc_purgedp(adp); } ReleaseWriteLock(&adp->lock); goto done; } /* here if rpc worked; update the in-core link count */ adp->m.LinkCount = OutDirStatus.LinkCount; - if (tdc) UpgradeSToWLock(&tdc->lock, 634); + if (tdc) + UpgradeSToWLock(&tdc->lock, 634); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ code = afs_dir_Delete(&tdc->f.inode, aname); - if (code) { + if (code) { ZapDCE(tdc); /* surprise error -- invalid value */ DZap(&tdc->f.inode); } @@ -299,14 +313,14 @@ afs_rmdir(adp, aname, acred) if (tvc) { - osi_dnlc_purgedp (tvc); /* get rid of any entries for this directory */ + osi_dnlc_purgedp(tvc); /* get rid of any entries for this directory */ afs_symhint_inval(tvc); } else - osi_dnlc_remove (adp, aname, 0); + osi_dnlc_remove(adp, aname, 0); if (tvc) { - ObtainWriteLock(&tvc->lock,155); - tvc->states &= ~CUnique; /* For the dfs xlator */ + ObtainWriteLock(&tvc->lock, 155); + tvc->states &= ~CUnique; /* For the dfs xlator */ ReleaseWriteLock(&tvc->lock); afs_PutVCache(tvc); } @@ -314,13 +328,13 @@ afs_rmdir(adp, aname, acred) /* don't worry about link count since dirs can not be hardlinked */ code = 0; -done: + done: afs_PutFakeStat(&fakestate); - code = afs_CheckCode(code, &treq, 27); -done2: + code = afs_CheckCode(code, &treq, 27); + done2: #ifdef AFS_OSF_ENV afs_PutVCache(adp); afs_PutVCache(ndp->ni_vp); -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ return code; } diff --git a/src/afs/VNOPS/afs_vnop_fid.c b/src/afs/VNOPS/afs_vnop_fid.c index 8086a019c..3eb414b9c 100644 --- a/src/afs/VNOPS/afs_vnop_fid.c +++ b/src/afs/VNOPS/afs_vnop_fid.c @@ -17,19 +17,20 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #if !defined(AFS_DUX40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_OBSD_ENV) #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" -int afs_fid_vnodeoverflow=0, afs_fid_uniqueoverflow=0; +int afs_fid_vnodeoverflow = 0, afs_fid_uniqueoverflow = 0; /* * afs_fid @@ -64,21 +65,21 @@ int afs_iauth_initd = 0; #endif -extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */ +extern int afs_NFSRootOnly; /* 1 => only allow NFS mounts of /afs. */ int #if !defined(AFS_DEC_ENV) && !defined(AFS_ATHENA_ENV) #ifdef AFS_AIX41_ENV afs_fid(OSI_VC_ARG(avc), fidpp, credp) - struct ucred *credp ; + struct ucred *credp; #else afs_fid(OSI_VC_ARG(avc), fidpp) -#endif /* AFS_AIX41_ENV */ +#endif /* AFS_AIX41_ENV */ OSI_VC_DECL(avc); #if defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN54_ENV) -struct fid *fidpp; + struct fid *fidpp; #else -struct fid **fidpp; + struct fid **fidpp; #endif { struct SmallFid Sfid; @@ -89,11 +90,13 @@ struct fid **fidpp; int rootvp = 0; OSI_VC_CONVERT(avc) - AFS_STATCNT(afs_fid); + AFS_STATCNT(afs_fid); - if (afs_shuttingdown) return EIO; + if (afs_shuttingdown) + return EIO; - if (afs_NFSRootOnly && (avc == afs_globalVp)) rootvp = 1; + if (afs_NFSRootOnly && (avc == afs_globalVp)) + rootvp = 1; if (!afs_NFSRootOnly || rootvp #ifdef AFS_AIX41_ENV || USE_SMALLFID(credp) @@ -101,9 +104,9 @@ struct fid **fidpp; ) { tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); Sfid.Volume = avc->fid.Fid.Volume; - Sfid.Vnode = avc->fid.Fid.Vnode; - Sfid.CellAndUnique = ((tcell->cellIndex << 24) + - (avc->fid.Fid.Unique & 0xffffff)); + Sfid.Vnode = avc->fid.Fid.Vnode; + Sfid.CellAndUnique = + ((tcell->cellIndex << 24) + (avc->fid.Fid.Unique & 0xffffff)); afs_PutCell(tcell, READ_LOCK); if (avc->fid.Fid.Vnode > 0xffff) afs_fid_vnodeoverflow++; @@ -111,7 +114,7 @@ struct fid **fidpp; afs_fid_uniqueoverflow++; } else { #if defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64)) - addr[1] = (long)AFS_XLATOR_MAGIC << 48 ; + addr[1] = (long)AFS_XLATOR_MAGIC << 48; #else /* defined(AFS_SGI61_ENV) && (_MIPS_SZPTR == 64) */ addr[1] = AFS_XLATOR_MAGIC; SizeOfSmallFid = sizeof(addr); @@ -129,25 +132,25 @@ struct fid **fidpp; if (afs_NFSRootOnly) { if (rootvp #ifdef AFS_AIX41_ENV - || USE_SMALLFID(credp) + || USE_SMALLFID(credp) #endif ) { - memcpy(fidpp->fid_data, (caddr_t)&Sfid, SizeOfSmallFid); + memcpy(fidpp->fid_data, (caddr_t) & Sfid, SizeOfSmallFid); } else { - memcpy(fidpp->fid_data, (caddr_t)addr, SizeOfSmallFid); + memcpy(fidpp->fid_data, (caddr_t) addr, SizeOfSmallFid); } } else { - memcpy(fidpp->fid_data, (caddr_t)&Sfid, SizeOfSmallFid); + memcpy(fidpp->fid_data, (caddr_t) & Sfid, SizeOfSmallFid); } #else /* malloc a fid pointer ourselves. */ - *fidpp = (struct fid *) AFS_KALLOC(SizeOfSmallFid+2); + *fidpp = (struct fid *)AFS_KALLOC(SizeOfSmallFid + 2); (*fidpp)->fid_len = SizeOfSmallFid; if (afs_NFSRootOnly) { if (rootvp) { memcpy((*fidpp)->fid_data, (char *)&Sfid, SizeOfSmallFid); } else { - memcpy((*fidpp)->fid_data, (char *)addr, SizeOfSmallFid); + memcpy((*fidpp)->fid_data, (char *)addr, SizeOfSmallFid); } } else { memcpy((*fidpp)->fid_data, (char *)&Sfid, SizeOfSmallFid); diff --git a/src/afs/VNOPS/afs_vnop_flock.c b/src/afs/VNOPS/afs_vnop_flock.c index 9a6c659e4..8b3c0e99a 100644 --- a/src/afs/VNOPS/afs_vnop_flock.c +++ b/src/afs/VNOPS/afs_vnop_flock.c @@ -15,28 +15,32 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" /* Static prototypes */ static int HandleGetLock(register struct vcache *avc, - register struct AFS_FLOCK *af, register struct vrequest *areq, int clid); + register struct AFS_FLOCK *af, + register struct vrequest *areq, int clid); static int GetFlockCount(struct vcache *avc, struct vrequest *areq); -static int lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp, - register struct SimpleLocks *alp, int onlymine, int clid); +static int lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp, + register struct SimpleLocks *alp, int onlymine, + int clid); static void DoLockWarning(void); /* int clid; * non-zero on SGI, OSF, SunOS, Darwin, xBSD ** XXX ptr type */ -void lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid) +void +lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid) { #if defined(AFS_SUN5_ENV) - register proc_t *procp = ttoproc(curthread); + register proc_t *procp = ttoproc(curthread); #else #if !defined(AFS_AIX41_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_SGI65_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) #ifdef AFS_SGI_ENV @@ -74,9 +78,9 @@ void lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid) #ifdef AFS_SGI65_ENV slp->sysid = flid.fl_sysid; #else - slp->sysid = OSI_GET_CURRENT_SYSID(); + slp->sysid = OSI_GET_CURRENT_SYSID(); #endif - slp->pid = clid; + slp->pid = clid; #else #if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) slp->pid = clid; @@ -84,7 +88,7 @@ void lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid) #if defined(AFS_LINUX20_ENV) || defined(AFS_HPUX_ENV) slp->pid = getpid(); #else - slp->pid = u.u_procp->p_pid; + slp->pid = u.u_procp->p_pid; #endif #endif #endif /* AFS_AIX_ENV */ @@ -113,9 +117,9 @@ void lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid) #ifdef AFS_SGI65_ENV flock->l_sysid = flid.fl_sysid; #else - flock->l_sysid = OSI_GET_CURRENT_SYSID(); + flock->l_sysid = OSI_GET_CURRENT_SYSID(); #endif - flock->l_pid = clid; + flock->l_pid = clid; #else #if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) flock->l_pid = clid; @@ -129,8 +133,8 @@ void lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid) #endif #endif /* AFS_AIX_ENV */ #endif /* AFS_AIX32_ENV */ - } -} + } +} /* return 1 (true) if specified flock does not match alp (if * specified), or any of the slp structs (if alp == 0) @@ -143,12 +147,13 @@ void lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid) /* onlymine - don't match any locks which are held by my parent */ /* clid - only irix 6.5 */ -static int lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp, - register struct SimpleLocks *alp, int onlymine, int clid) +static int +lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp, + register struct SimpleLocks *alp, int onlymine, int clid) { register struct SimpleLocks *slp; #if defined(AFS_SUN5_ENV) - register proc_t *procp = ttoproc(curthread); + register proc_t *procp = ttoproc(curthread); #else #if !defined(AFS_AIX41_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_SGI65_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) #ifdef AFS_SGI64_ENV @@ -161,38 +166,38 @@ static int lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp, if (alp) { #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) - if (flock1->l_sysid != alp->sysid) { - return 1; - } + if (flock1->l_sysid != alp->sysid) { + return 1; + } #endif - if ((flock1->l_pid == alp->pid) || + if ((flock1->l_pid == alp->pid) || #if defined(AFS_AIX41_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_HPUX_ENV) - (!onlymine && (flock1->l_pid == getppid())) + (!onlymine && (flock1->l_pid == getppid())) #else #if defined(AFS_SGI65_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - /* XXX check this. used to be *only* irix for some reason. */ - (!onlymine && (flock1->l_pid == clid)) + /* XXX check this. used to be *only* irix for some reason. */ + (!onlymine && (flock1->l_pid == clid)) #else - (!onlymine && (flock1->l_pid == procp->p_ppid)) + (!onlymine && (flock1->l_pid == procp->p_ppid)) #endif #endif - ) { - return 0; - } - return 1; + ) { + return 0; + } + return 1; } for (slp = vp->slocks; slp; slp = slp->next) { #if defined(AFS_HAVE_FLOCK_SYSID) if (flock1->l_sysid != slp->sysid) { - continue; + continue; } #endif if (flock1->l_pid == slp->pid) { return 0; - } + } } - return (1); /* failure */ + return (1); /* failure */ } @@ -211,8 +216,9 @@ static int lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp, innocent closes by children to unlock files in the parent process. */ /* clid - nonzero on sgi sunos osf1 only */ -int HandleFlock(register struct vcache *avc, int acom, - struct vrequest *areq, pid_t clid, int onlymine) +int +HandleFlock(register struct vcache *avc, int acom, struct vrequest *areq, + pid_t clid, int onlymine) { struct conn *tc; struct SimpleLocks *slp, *tlp, **slpp; @@ -220,25 +226,23 @@ int HandleFlock(register struct vcache *avc, int acom, struct AFSVolSync tsync; afs_int32 lockType; struct AFS_FLOCK flock; - XSTATS_DECLS - - AFS_STATCNT(HandleFlock); - code = 0; /* default when we don't make any network calls */ + XSTATS_DECLS AFS_STATCNT(HandleFlock); + code = 0; /* default when we don't make any network calls */ lockIdSet(&flock, NULL, clid); #if defined(AFS_SGI_ENV) osi_Assert(valusema(&avc->vc_rwlock) <= 0); osi_Assert(OSI_GET_LOCKID() == avc->vc_rwlockid); #endif - ObtainWriteLock(&avc->lock,118); + ObtainWriteLock(&avc->lock, 118); if (acom & LOCK_UN) { /* defect 3083 */ #ifdef AFS_AIX_ENV /* If the lock is held exclusive, then only the owning process - * or a child can unlock it. Use pid and ppid because they are - * unique identifiers. + * or a child can unlock it. Use pid and ppid because they are + * unique identifiers. */ if ((avc->flockCount < 0) && (getpid() != avc->ownslock)) { #ifdef AFS_AIX41_ENV @@ -252,20 +256,20 @@ int HandleFlock(register struct vcache *avc, int acom, } #endif if (lockIdcmp2(&flock, avc, NULL, onlymine, clid)) { - ReleaseWriteLock(&avc->lock); + ReleaseWriteLock(&avc->lock); return 0; - } + } #ifdef AFS_AIX_ENV - avc->ownslock = 0; + avc->ownslock = 0; #endif - if (avc->flockCount == 0) { + if (avc->flockCount == 0) { ReleaseWriteLock(&avc->lock); - return 0 /*ENOTTY*/; + return 0 /*ENOTTY*/; /* no lock held */ - } - /* unlock the lock */ + } + /* unlock the lock */ if (avc->flockCount > 0) { - slpp = &avc->slocks; + slpp = &avc->slocks; for (slp = *slpp; slp;) { if (!lockIdcmp2(&flock, avc, slp, onlymine, clid)) { avc->flockCount--; @@ -277,42 +281,39 @@ int HandleFlock(register struct vcache *avc, int acom, slp = *slpp; } } - } - else if (avc->flockCount == -1) { - afs_StoreAllSegments(avc, areq, AFS_ASYNC); /* fsync file early */ - avc->flockCount = 0; + } else if (avc->flockCount == -1) { + afs_StoreAllSegments(avc, areq, AFS_ASYNC); /* fsync file early */ + avc->flockCount = 0; /* And remove the (only) exclusive lock entry from the list... */ osi_FreeSmallSpace(avc->slocks); avc->slocks = 0; - } - if (avc->flockCount == 0) { - do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); - if (tc) { + } + if (avc->flockCount == 0) { + do { + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RELEASELOCK); RX_AFS_GUNLOCK(); code = RXAFS_ReleaseLock(tc->id, (struct AFSFid *) &avc->fid.Fid, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_RELEASELOCK, - SHARED_LOCK, NULL)); + } else + code = -1; + } while (afs_Analyze + (tc, code, &avc->fid, areq, + AFS_STATS_FS_RPCIDX_RELEASELOCK, SHARED_LOCK, NULL)); } - } - else { - while (1) { /* set a new lock */ + } else { + while (1) { /* set a new lock */ /* * Upgrading from shared locks to Exclusive and vice versa - * is a bit tricky and we don't really support it yet. But - * we try to support the common used one which is upgrade - * a shared lock to an exclusive for the same process... - */ - if ((avc->flockCount > 0 && (acom & LOCK_EX)) || - (avc->flockCount == -1 && (acom & LOCK_SH))) { + * is a bit tricky and we don't really support it yet. But + * we try to support the common used one which is upgrade + * a shared lock to an exclusive for the same process... + */ + if ((avc->flockCount > 0 && (acom & LOCK_EX)) + || (avc->flockCount == -1 && (acom & LOCK_SH))) { /* * Upgrading from shared locks to an exclusive one: * For now if all the shared locks belong to the @@ -325,7 +326,8 @@ int HandleFlock(register struct vcache *avc, int acom, */ slpp = &avc->slocks; for (slp = *slpp; slp;) { - if (!lockIdcmp2(&flock, avc, slp, 1/*!onlymine*/, clid)) { + if (!lockIdcmp2 + (&flock, avc, slp, 1 /*!onlymine */ , clid)) { if (acom & LOCK_EX) avc->flockCount--; else @@ -339,23 +341,25 @@ int HandleFlock(register struct vcache *avc, int acom, slp = *slpp; } } - if (!code && avc->flockCount == 0) { + if (!code && avc->flockCount == 0) { do { tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RELEASELOCK); - RX_AFS_GUNLOCK(); - code = RXAFS_ReleaseLock(tc->id, - (struct AFSFid *) &avc->fid.Fid, - &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_RELEASELOCK, - SHARED_LOCK, NULL)); + XSTATS_START_TIME + (AFS_STATS_FS_RPCIDX_RELEASELOCK); + RX_AFS_GUNLOCK(); + code = + RXAFS_ReleaseLock(tc->id, + (struct AFSFid *)&avc->fid. + Fid, &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &avc->fid, areq, + AFS_STATS_FS_RPCIDX_RELEASELOCK, SHARED_LOCK, + NULL)); } } else if (avc->flockCount == -1 && (acom & LOCK_EX)) { if (lockIdcmp2(&flock, avc, NULL, 1, clid)) { @@ -365,43 +369,45 @@ int HandleFlock(register struct vcache *avc, int acom, } if (code == 0) { /* compatible here, decide if needs to go to file server. If - we've already got the file locked (and thus read-locked, since - we've already checked for compatibility), we shouldn't send - the call through to the server again */ + * we've already got the file locked (and thus read-locked, since + * we've already checked for compatibility), we shouldn't send + * the call through to the server again */ if (avc->flockCount == 0) { /* we're the first on our block, send the call through */ - lockType = ((acom & LOCK_EX)? LockWrite : LockRead); + lockType = ((acom & LOCK_EX) ? LockWrite : LockRead); do { tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETLOCK); - RX_AFS_GUNLOCK(); - code = RXAFS_SetLock(tc->id, (struct AFSFid *) - &avc->fid.Fid, lockType, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_SETLOCK, - SHARED_LOCK, NULL)); - } - else code = 0; /* otherwise, pretend things worked */ + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETLOCK); + RX_AFS_GUNLOCK(); + code = RXAFS_SetLock(tc->id, (struct AFSFid *) + &avc->fid.Fid, lockType, + &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &avc->fid, areq, + AFS_STATS_FS_RPCIDX_SETLOCK, SHARED_LOCK, + NULL)); + } else + code = 0; /* otherwise, pretend things worked */ } if (code == 0) { - slp = (struct SimpleLocks *) osi_AllocSmallSpace(sizeof(struct SimpleLocks)); + slp = (struct SimpleLocks *) + osi_AllocSmallSpace(sizeof(struct SimpleLocks)); if (acom & LOCK_EX) { /* defect 3083 */ #ifdef AFS_AIX_ENV - /* Record unique id of process owning exclusive lock. */ - avc->ownslock = getpid(); + /* Record unique id of process owning exclusive lock. */ + avc->ownslock = getpid(); #endif slp->type = LockWrite; - slp->next = NULL; + slp->next = NULL; avc->slocks = slp; avc->flockCount = -1; } else { @@ -415,56 +421,62 @@ int HandleFlock(register struct vcache *avc, int acom, break; } /* now, if we got EWOULDBLOCK, and we're supposed to wait, we do */ - if(((code == EWOULDBLOCK) || (code == EAGAIN)) && !(acom & LOCK_NB)) { + if (((code == EWOULDBLOCK) || (code == EAGAIN)) + && !(acom & LOCK_NB)) { /* sleep for a second, allowing interrupts */ ReleaseWriteLock(&avc->lock); #if defined(AFS_SGI_ENV) - AFS_RWUNLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE); #endif code = afs_osi_Wait(1000, NULL, 1); #if defined(AFS_SGI_ENV) - AFS_RWLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE); #endif - ObtainWriteLock(&avc->lock,120); + ObtainWriteLock(&avc->lock, 120); if (code) { code = EINTR; /* return this if ^C typed */ break; } - } - else break; - } /* while loop */ + } else + break; + } /* while loop */ } ReleaseWriteLock(&avc->lock); - code = afs_CheckCode(code, areq, 1); /* defeat a buggy AIX optimization */ + code = afs_CheckCode(code, areq, 1); /* defeat a buggy AIX optimization */ return code; } /* warn a user that a lock has been ignored */ -afs_int32 lastWarnTime = 0; /* this is used elsewhere */ -static void DoLockWarning(void) +afs_int32 lastWarnTime = 0; /* this is used elsewhere */ +static void +DoLockWarning(void) { register afs_int32 now; now = osi_Time(); AFS_STATCNT(DoLockWarning); /* check if we've already warned someone recently */ - if (now < lastWarnTime + 120) return; + if (now < lastWarnTime + 120) + return; /* otherwise, it is time to nag the user */ lastWarnTime = now; - afs_warn("afs: byte-range lock/unlock ignored; make sure no one else is running this program.\n"); + afs_warn + ("afs: byte-range lock/unlock ignored; make sure no one else is running this program.\n"); } #ifdef AFS_OSF_ENV -afs_lockctl(struct vcache *avc, struct eflock *af, int flag, - struct AFS_UCRED *acred, pid_t clid, off_t offset) +afs_lockctl(struct vcache * avc, struct eflock * af, int flag, + struct AFS_UCRED * acred, pid_t clid, off_t offset) #elif defined(AFS_SGI_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) -afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd, struct AFS_UCRED *acred, pid_t clid) +afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd, + struct AFS_UCRED * acred, pid_t clid) #else -u_int clid=0; -afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd, struct AFS_UCRED *acred) +u_int clid = 0; +afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd, + struct AFS_UCRED * acred) #endif { struct vrequest treq; @@ -475,7 +487,8 @@ afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd, struct AFS_UCRED struct afs_fakestat_state fakestate; AFS_STATCNT(afs_lockctl); - if ((code = afs_InitReq(&treq, acred))) return code; + if ((code = afs_InitReq(&treq, acred))) + return code; afs_InitFakeStat(&fakestate); code = afs_EvalFakeStat(&avc, &fakestate, &treq); if (code) { @@ -483,7 +496,7 @@ afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd, struct AFS_UCRED return code; } #ifdef AFS_OSF_ENV - if (flag & VNOFLCK) { + if (flag & VNOFLCK) { afs_PutFakeStat(&fakestate); return 0; } @@ -504,67 +517,69 @@ afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd, struct AFS_UCRED afs_PutFakeStat(&fakestate); return 0; } -#ifndef AFS_OSF_ENV /* getlock is a no-op for osf (for now) */ +#ifndef AFS_OSF_ENV /* getlock is a no-op for osf (for now) */ code = HandleGetLock(avc, af, &treq, clid); #endif - code = afs_CheckCode(code, &treq, 2); /* defeat buggy AIX optimz */ + code = afs_CheckCode(code, &treq, 2); /* defeat buggy AIX optimz */ afs_PutFakeStat(&fakestate); return code; - } - else if ((acmd == F_SETLK) || (acmd == F_SETLKW) + } else if ((acmd == F_SETLK) || (acmd == F_SETLKW) #if (defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)) && !defined(AFS_SUN58_ENV) - || (acmd == F_RSETLK)|| (acmd == F_RSETLKW)) { + || (acmd == F_RSETLK) || (acmd == F_RSETLKW)) { #else ) { #endif - /* this next check is safer when left out, but more applications work - with it in. However, they fail in race conditions. The question is - what to do for people who don't have source to their application; - this way at least, they can get work done */ + /* this next check is safer when left out, but more applications work + * with it in. However, they fail in race conditions. The question is + * what to do for people who don't have source to their application; + * this way at least, they can get work done */ #ifdef AFS_LINUX24_ENV - if (af->l_len == OFFSET_MAX) - af->l_len = 0; /* since some systems indicate it as EOF */ + if (af->l_len == OFFSET_MAX) + af->l_len = 0; /* since some systems indicate it as EOF */ #else - if (af->l_len == 0x7fffffff) - af->l_len = 0; /* since some systems indicate it as EOF */ + if (af->l_len == 0x7fffffff) + af->l_len = 0; /* since some systems indicate it as EOF */ #ifdef AFS_LINUX_64BIT_KERNEL - if (af->l_len == LONG_MAX) - af->l_len = 0; /* since some systems indicate it as EOF */ + if (af->l_len == LONG_MAX) + af->l_len = 0; /* since some systems indicate it as EOF */ #endif #endif - /* next line makes byte range locks always succeed, - even when they should block */ - if (af->l_whence != 0 || af->l_start != 0 || af->l_len != 0) { - DoLockWarning(); - afs_PutFakeStat(&fakestate); - return 0; - } - /* otherwise we can turn this into a whole-file flock */ - if (af->l_type == F_RDLCK) code = LOCK_SH; - else if (af->l_type == F_WRLCK) code = LOCK_EX; - else if (af->l_type == F_UNLCK) code = LOCK_UN; - else { - afs_PutFakeStat(&fakestate); - return EINVAL; /* unknown lock type */ - } - if (((acmd == F_SETLK) + /* next line makes byte range locks always succeed, + * even when they should block */ + if (af->l_whence != 0 || af->l_start != 0 || af->l_len != 0) { + DoLockWarning(); + afs_PutFakeStat(&fakestate); + return 0; + } + /* otherwise we can turn this into a whole-file flock */ + if (af->l_type == F_RDLCK) + code = LOCK_SH; + else if (af->l_type == F_WRLCK) + code = LOCK_EX; + else if (af->l_type == F_UNLCK) + code = LOCK_UN; + else { + afs_PutFakeStat(&fakestate); + return EINVAL; /* unknown lock type */ + } + if (((acmd == F_SETLK) #if (defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV)) && !defined(AFS_SUN58_ENV) - || (acmd == F_RSETLK) + || (acmd == F_RSETLK) #endif ) && code != LOCK_UN) - code |= LOCK_NB; /* non-blocking, s.v.p. */ -#if (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) || defined(AFS_OSF_ENV) - code = HandleFlock(avc, code, &treq, clid, 0/*!onlymine*/); + code |= LOCK_NB; /* non-blocking, s.v.p. */ +#if (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) || defined(AFS_OSF_ENV) + code = HandleFlock(avc, code, &treq, clid, 0 /*!onlymine */ ); #elif defined(AFS_SGI_ENV) - AFS_RWLOCK((vnode_t *)avc, VRWLOCK_WRITE); - code = HandleFlock(avc, code, &treq, clid, 0/*!onlymine*/); - AFS_RWUNLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE); + code = HandleFlock(avc, code, &treq, clid, 0 /*!onlymine */ ); + AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE); #else - code = HandleFlock(avc, code, &treq, 0, 0/*!onlymine*/); + code = HandleFlock(avc, code, &treq, 0, 0 /*!onlymine */ ); #endif - code = afs_CheckCode(code, &treq, 3); /* defeat AIX -O bug */ - afs_PutFakeStat(&fakestate); - return code; + code = afs_CheckCode(code, &treq, 3); /* defeat AIX -O bug */ + afs_PutFakeStat(&fakestate); + return code; } afs_PutFakeStat(&fakestate); return EINVAL; @@ -582,16 +597,17 @@ afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd, struct AFS_UCRED * 2. Asking for write lock, and only the current * PID has the file read locked. */ -#ifndef AFS_OSF_ENV /* getlock is a no-op for osf (for now) */ -static int HandleGetLock(register struct vcache *avc, - register struct AFS_FLOCK *af, register struct vrequest *areq, int clid) +#ifndef AFS_OSF_ENV /* getlock is a no-op for osf (for now) */ +static int +HandleGetLock(register struct vcache *avc, register struct AFS_FLOCK *af, + register struct vrequest *areq, int clid) { register afs_int32 code; struct AFS_FLOCK flock; lockIdSet(&flock, NULL, clid); - ObtainWriteLock(&avc->lock,122); + ObtainWriteLock(&avc->lock, 122); if (avc->flockCount == 0) { /* * We don't know ourselves, so ask the server. Unfortunately, we @@ -621,21 +637,21 @@ static int HandleGetLock(register struct vcache *avc, * read locks, or we are the one with the * write lock, say it is unlocked. */ - if (avc->flockCount > 0 || /* only read locks */ + if (avc->flockCount > 0 || /* only read locks */ !lockIdcmp2(&flock, avc, NULL, 1, clid)) { af->l_type = F_UNLCK; goto unlck_leave; } /* one write lock, but who? */ - af->l_type = F_WRLCK; /* not us, so lock would block */ - if (avc->slocks) { /* we know who, so tell */ + af->l_type = F_WRLCK; /* not us, so lock would block */ + if (avc->slocks) { /* we know who, so tell */ af->l_pid = avc->slocks->pid; #if defined(AFS_HAVE_FLOCK_SYSID) af->l_sysid = avc->slocks->sysid; #endif } else { - af->l_pid = 0; /* XXX can't happen?? */ + af->l_pid = 0; /* XXX can't happen?? */ #if defined(AFS_HAVE_FLOCK_SYSID) af->l_sysid = 0; #endif @@ -656,14 +672,14 @@ static int HandleGetLock(register struct vcache *avc, af->l_sysid = avc->slocks->sysid; #endif } else { - af->l_pid = 0; /* XXX can't happen?? */ + af->l_pid = 0; /* XXX can't happen?? */ #if defined(AFS_HAVE_FLOCK_SYSID) af->l_sysid = 0; #endif } goto done; } - /* we are the one with the write lock */ + /* we are the one with the write lock */ af->l_type = F_UNLCK; goto unlck_leave; } @@ -675,7 +691,7 @@ static int HandleGetLock(register struct vcache *avc, if ((avc->flockCount > 1) || lockIdcmp2(&flock, avc, NULL, 1, clid)) { struct SimpleLocks *slp; - + af->l_type = F_RDLCK; af->l_pid = 0; #if defined(AFS_HAVE_FLOCK_SYSID) @@ -683,94 +699,94 @@ static int HandleGetLock(register struct vcache *avc, #endif /* find a pid that isn't our own */ for (slp = avc->slocks; slp; slp = slp->next) { - if (lockIdcmp2(&flock, NULL, slp, 1, clid)) { - af->l_pid = slp->pid; + if (lockIdcmp2(&flock, NULL, slp, 1, clid)) { + af->l_pid = slp->pid; #if defined(AFS_HAVE_FLOCK_SYSID) - af->l_sysid = avc->slocks->sysid; + af->l_sysid = avc->slocks->sysid; #endif break; - } - } + } + } goto done; } - /* - * Ok, we want a write lock. If there is a write lock - * already, and it is not this process, we fail. - */ - if (avc->flockCount < 0) { - if (lockIdcmp2(&flock, avc, NULL, 1, clid)) { - af->l_type = F_WRLCK; - if (avc->slocks) { - af->l_pid = avc->slocks->pid; + /* + * Ok, we want a write lock. If there is a write lock + * already, and it is not this process, we fail. + */ + if (avc->flockCount < 0) { + if (lockIdcmp2(&flock, avc, NULL, 1, clid)) { + af->l_type = F_WRLCK; + if (avc->slocks) { + af->l_pid = avc->slocks->pid; #if defined(AFS_HAVE_FLOCK_SYSID) - af->l_sysid = avc->slocks->sysid; + af->l_sysid = avc->slocks->sysid; #endif - } else { - af->l_pid = 0; /* XXX can't happen?? */ + } else { + af->l_pid = 0; /* XXX can't happen?? */ #if defined(AFS_HAVE_FLOCK_SYSID) - af->l_sysid = 0; + af->l_sysid = 0; #endif - } - goto done; } - /* we are the one with the write lock */ - af->l_type = F_UNLCK; - goto unlck_leave; + goto done; } + /* we are the one with the write lock */ + af->l_type = F_UNLCK; + goto unlck_leave; + } - /* - * Want a write lock, and we know there are read locks. - * If there is more than one, or it isn't us, we cannot lock. - */ - if ((avc->flockCount > 1) - || lockIdcmp2(&flock, avc, NULL, 1, clid)) { - struct SimpleLocks *slp; - af->l_type = F_RDLCK; - af->l_pid = 0; + /* + * Want a write lock, and we know there are read locks. + * If there is more than one, or it isn't us, we cannot lock. + */ + if ((avc->flockCount > 1) + || lockIdcmp2(&flock, avc, NULL, 1, clid)) { + struct SimpleLocks *slp; + af->l_type = F_RDLCK; + af->l_pid = 0; #if defined(AFS_HAVE_FLOCK_SYSID) - af->l_sysid = 0; + af->l_sysid = 0; #endif - /* find a pid that isn't our own */ - for (slp = avc->slocks; slp; slp = slp->next) { - if (lockIdcmp2(&flock, NULL, slp, 1, clid)) { - af->l_pid = slp->pid; + /* find a pid that isn't our own */ + for (slp = avc->slocks; slp; slp = slp->next) { + if (lockIdcmp2(&flock, NULL, slp, 1, clid)) { + af->l_pid = slp->pid; #if defined(AFS_HAVE_FLOCK_SYSID) - af->l_sysid = avc->slocks->sysid; + af->l_sysid = avc->slocks->sysid; #endif - break; - } + break; } - goto done; - } - - /* - * Want a write lock, and there is just one read lock, and it - * is this process with a read lock. Ask the server if there - * are any more processes with the file locked. - */ - code = GetFlockCount(avc, areq); - if (code == 0 || code == 1) { - af->l_type = F_UNLCK; - goto unlck_leave; } - if (code > 0) - af->l_type = F_RDLCK; - else - af->l_type = F_WRLCK; - af->l_pid = 0; + goto done; + } + + /* + * Want a write lock, and there is just one read lock, and it + * is this process with a read lock. Ask the server if there + * are any more processes with the file locked. + */ + code = GetFlockCount(avc, areq); + if (code == 0 || code == 1) { + af->l_type = F_UNLCK; + goto unlck_leave; + } + if (code > 0) + af->l_type = F_RDLCK; + else + af->l_type = F_WRLCK; + af->l_pid = 0; #if defined(AFS_HAVE_FLOCK_SYSID) - af->l_sysid = 0; + af->l_sysid = 0; #endif -done: - af->l_whence = 0; - af->l_start = 0; - af->l_len = 0; /* to end of file */ + done: + af->l_whence = 0; + af->l_start = 0; + af->l_len = 0; /* to end of file */ -unlck_leave: - ReleaseWriteLock(&avc->lock); - return 0; + unlck_leave: + ReleaseWriteLock(&avc->lock); + return 0; } /* Get the 'flock' count from the server. This comes back in a 'spare' @@ -779,7 +795,8 @@ unlck_leave: * the spare field will be a zero, saying the file is unlocked. This is * OK, as a further 'lock' request will do the right thing. */ -static int GetFlockCount(struct vcache *avc, struct vrequest *areq) +static int +GetFlockCount(struct vcache *avc, struct vrequest *areq) { register struct conn *tc; register afs_int32 code; @@ -787,33 +804,32 @@ static int GetFlockCount(struct vcache *avc, struct vrequest *areq) struct AFSCallBack CallBack; struct AFSVolSync tsync; int temp; - XSTATS_DECLS - - temp = areq->flags & O_NONBLOCK; + XSTATS_DECLS temp = areq->flags & O_NONBLOCK; areq->flags |= O_NONBLOCK; do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); - if (tc){ - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHSTATUS); - RX_AFS_GUNLOCK(); - code = RXAFS_FetchStatus(tc->id, (struct AFSFid *) &avc->fid.Fid, - &OutStatus, &CallBack, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } else code = -1; - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_FETCHSTATUS, - SHARED_LOCK, NULL)); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + if (tc) { + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHSTATUS); + RX_AFS_GUNLOCK(); + code = + RXAFS_FetchStatus(tc->id, (struct AFSFid *)&avc->fid.Fid, + &OutStatus, &CallBack, &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_FETCHSTATUS, + SHARED_LOCK, NULL)); if (temp) areq->flags &= ~O_NONBLOCK; if (code) { - return(0); /* failed, say it is 'unlocked' */ + return (0); /* failed, say it is 'unlocked' */ } else { - return((int)OutStatus.lockCount); + return ((int)OutStatus.lockCount); } } #endif @@ -824,9 +840,11 @@ static int GetFlockCount(struct vcache *avc, struct vrequest *areq) #ifdef AFS_OSF_ENV extern struct fileops afs_fileops; -int afs_xflock (struct proc *p, void *args, int *retval) +int +afs_xflock(struct proc *p, void *args, int *retval) #else /* AFS_OSF_ENV */ -int afs_xflock (void) +int +afs_xflock(void) #endif { int code = 0; @@ -869,7 +887,7 @@ int afs_xflock (void) /* find real vcache entry; shouldn't be null if gnode ref count * is greater than 0. */ - tvc = VTOAFS(afs_gntovn)(tvc); + tvc = VTOAFS(afs_gntovn) (tvc); if (!tvc) { u.u_error = ENOENT; afs_PutFakeStat(&fakestate); @@ -884,19 +902,21 @@ int afs_xflock (void) if ((fd->f_flag & (FEXLOCK | FSHLOCK)) && !(uap->com & LOCK_UN)) { /* First, if fd already has lock, release it for relock path */ #if defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) - HandleFlock(tvc, LOCK_UN, &treq, u.u_procp->p_pid, 0/*!onlymine*/); + HandleFlock(tvc, LOCK_UN, &treq, u.u_procp->p_pid, + 0 /*!onlymine */ ); #else - HandleFlock(tvc, LOCK_UN, &treq, 0, 0/*!onlymine*/); + HandleFlock(tvc, LOCK_UN, &treq, 0, 0 /*!onlymine */ ); #endif fd->f_flag &= ~(FEXLOCK | FSHLOCK); } /* now try the requested operation */ #if defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) - code = HandleFlock(tvc, uap->com, &treq, - u.u_procp->p_pid, 0/*!onlymine*/); + code = + HandleFlock(tvc, uap->com, &treq, u.u_procp->p_pid, + 0 /*!onlymine */ ); #else - code = HandleFlock(tvc, uap->com, &treq, 0, 0/*!onlymine*/); + code = HandleFlock(tvc, uap->com, &treq, 0, 0 /*!onlymine */ ); #endif #ifndef AFS_OSF_ENV u.u_error = code; @@ -905,15 +925,16 @@ int afs_xflock (void) if (uap->com & LOCK_UN) { /* gave up lock */ fd->f_flag &= ~(FEXLOCK | FSHLOCK); - } - else { + } else { #ifdef AFS_OSF_ENV if (!code) { #else /* AFS_OSF_ENV */ if (!u.u_error) { #endif - if (uap->com & LOCK_SH) fd->f_flag |= FSHLOCK; - else if (uap->com & LOCK_EX) fd->f_flag |= FEXLOCK; + if (uap->com & LOCK_SH) + fd->f_flag |= FSHLOCK; + else if (uap->com & LOCK_EX) + fd->f_flag |= FEXLOCK; } } flockDone = 1; @@ -930,16 +951,15 @@ int afs_xflock (void) #endif afs_PutFakeStat(&fakestate); return code; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ if (!flockDone) #ifdef DYNEL - (*afs_longcall_procs.LC_flock)(); + (*afs_longcall_procs.LC_flock) (); #else - flock(); + flock(); #endif afs_PutFakeStat(&fakestate); return; #endif } #endif /* !defined(AFS_AIX_ENV) && !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV) && !defined(UKERNEL) && !defined(AFS_LINUX20_ENV) */ - diff --git a/src/afs/VNOPS/afs_vnop_link.c b/src/afs/VNOPS/afs_vnop_link.c index d240a0e36..40937f74a 100644 --- a/src/afs/VNOPS/afs_vnop_link.c +++ b/src/afs/VNOPS/afs_vnop_link.c @@ -16,11 +16,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -32,21 +33,22 @@ extern afs_rwlock_t afs_xcbhash; #ifdef AFS_OSF_ENV afs_link(avc, ndp) - struct vcache *avc; - struct nameidata *ndp; { + struct vcache *avc; + struct nameidata *ndp; +{ struct vcache *adp = VTOAFS(ndp->ni_dvp); char *aname = ndp->ni_dent.d_name; struct ucred *acred = ndp->ni_cred; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) afs_link(OSI_VC_ARG(adp), avc, aname, acred) #else afs_link(avc, OSI_VC_ARG(adp), aname, acred) #endif OSI_VC_DECL(adp); - struct vcache *avc; - char *aname; - struct AFS_UCRED *acred; + struct vcache *avc; + char *aname; + struct AFS_UCRED *acred; { #endif struct vrequest treq; @@ -57,24 +59,26 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred) struct AFSFetchStatus OutFidStatus, OutDirStatus; struct AFSVolSync tsync; struct afs_fakestat_state vfakestate, dfakestate; - XSTATS_DECLS - OSI_VC_CONVERT(adp) + XSTATS_DECLS OSI_VC_CONVERT(adp) - AFS_STATCNT(afs_link); + AFS_STATCNT(afs_link); afs_Trace3(afs_iclSetp, CM_TRACE_LINK, ICL_TYPE_POINTER, adp, ICL_TYPE_POINTER, avc, ICL_TYPE_STRING, aname); /* create a hard link; new entry is aname in dir adp */ - if ((code = afs_InitReq(&treq, acred))) + if ((code = afs_InitReq(&treq, acred))) goto done2; afs_InitFakeStat(&vfakestate); afs_InitFakeStat(&dfakestate); code = afs_EvalFakeStat(&avc, &vfakestate, &treq); - if (code) goto done; + if (code) + goto done; code = afs_EvalFakeStat(&adp, &dfakestate, &treq); - if (code) goto done; + if (code) + goto done; - if (avc->fid.Cell != adp->fid.Cell || avc->fid.Fid.Volume != adp->fid.Fid.Volume) { + if (avc->fid.Cell != adp->fid.Cell + || avc->fid.Fid.Volume != adp->fid.Fid.Volume) { code = EXDEV; goto done; } @@ -83,48 +87,52 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred) goto done; } code = afs_VerifyVCache(adp, &treq); - if (code) goto done; + if (code) + goto done; /** If the volume is read-only, return error without making an RPC to the * fileserver */ - if ( adp->states & CRO ) { - code = EROFS; + if (adp->states & CRO) { + code = EROFS; goto done; } - tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); /* test for error below */ - ObtainWriteLock(&adp->lock,145); + tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); /* test for error below */ + ObtainWriteLock(&adp->lock, 145); do { tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_LINK); - RX_AFS_GUNLOCK(); - code = RXAFS_Link(tc->id, (struct AFSFid *) &adp->fid.Fid, aname, - (struct AFSFid *) &avc->fid.Fid, &OutFidStatus, - &OutDirStatus, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - - } - else code = -1; - } while - (afs_Analyze(tc, code, &adp->fid, &treq, - AFS_STATS_FS_RPCIDX_LINK, SHARED_LOCK, NULL)); + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_LINK); + RX_AFS_GUNLOCK(); + code = + RXAFS_Link(tc->id, (struct AFSFid *)&adp->fid.Fid, aname, + (struct AFSFid *)&avc->fid.Fid, &OutFidStatus, + &OutDirStatus, &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + + } else + code = -1; + } while (afs_Analyze + (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_LINK, + SHARED_LOCK, NULL)); if (code) { - if (tdc) afs_PutDCache(tdc); + if (tdc) + afs_PutDCache(tdc); if (code < 0) { - ObtainWriteLock(&afs_xcbhash, 492); - afs_DequeueCallback(adp); - adp->states &= ~CStatd; - ReleaseWriteLock(&afs_xcbhash); - osi_dnlc_purgedp(adp); + ObtainWriteLock(&afs_xcbhash, 492); + afs_DequeueCallback(adp); + adp->states &= ~CStatd; + ReleaseWriteLock(&afs_xcbhash); + osi_dnlc_purgedp(adp); } ReleaseWriteLock(&adp->lock); goto done; } - if (tdc) ObtainWriteLock(&tdc->lock, 635); + if (tdc) + ObtainWriteLock(&tdc->lock, 635); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ code = afs_dir_Create(&tdc->f.inode, aname, &avc->fid.Fid); @@ -138,7 +146,7 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred) afs_PutDCache(tdc); /* drop ref count */ } ReleaseWriteLock(&adp->lock); - ObtainWriteLock(&avc->lock,146); /* correct link count */ + ObtainWriteLock(&avc->lock, 146); /* correct link count */ /* we could lock both dir and file; since we get the new fid * status back, you'd think we could put it in the cache status @@ -149,20 +157,19 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred) ObtainWriteLock(&afs_xcbhash, 493); afs_DequeueCallback(avc); - avc->states &= ~CStatd; /* don't really know new link count */ + avc->states &= ~CStatd; /* don't really know new link count */ ReleaseWriteLock(&afs_xcbhash); if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR)) osi_dnlc_purgedp(avc); ReleaseWriteLock(&avc->lock); code = 0; -done: + done: code = afs_CheckCode(code, &treq, 24); afs_PutFakeStat(&vfakestate); afs_PutFakeStat(&dfakestate); -done2: + done2: #ifdef AFS_OSF_ENV afs_PutVCache(adp); -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ return code; } - diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index ca09e0416..6aafccde8 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -17,18 +17,19 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/exporter.h" #include "afs/afs_osidnlc.h" -extern struct DirEntry * afs_dir_GetBlob(); +extern struct DirEntry *afs_dir_GetBlob(); #ifdef AFS_LINUX22_ENV extern struct inode_operations afs_symlink_iops, afs_dir_iops; @@ -54,76 +55,85 @@ int afs_fakestat_enable = 0; /* 1: fakestat-all, 2: fakestat-crosscell */ * * NOTE: this function returns a held volume structure in *volpp if it returns 0! */ -int EvalMountPoint(register struct vcache *avc, struct vcache *advc, - struct volume **avolpp, register struct vrequest *areq) +int +EvalMountPoint(register struct vcache *avc, struct vcache *advc, + struct volume **avolpp, register struct vrequest *areq) { - afs_int32 code; + afs_int32 code; struct volume *tvp = 0; struct VenusFid tfid; struct cell *tcell; - char *cpos, *volnamep; - char type, *buf; - afs_int32 prefetchRO; /* 1=>No 2=>Yes */ - afs_int32 mtptCell, assocCell, hac=0; - afs_int32 samecell, roname, len; + char *cpos, *volnamep; + char type, *buf; + afs_int32 prefetchRO; /* 1=>No 2=>Yes */ + afs_int32 mtptCell, assocCell, hac = 0; + afs_int32 samecell, roname, len; AFS_STATCNT(EvalMountPoint); #ifdef notdef - if (avc->mvid && (avc->states & CMValid)) return 0; /* done while racing */ + if (avc->mvid && (avc->states & CMValid)) + return 0; /* done while racing */ #endif *avolpp = NULL; code = afs_HandleLink(avc, areq); - if (code) return code; + if (code) + return code; /* Determine which cell and volume the mointpoint goes to */ - type = avc->linkData[0]; /* '#'=>Regular '%'=>RW */ - cpos = afs_strchr(&avc->linkData[1], ':'); /* if cell name present */ + type = avc->linkData[0]; /* '#'=>Regular '%'=>RW */ + cpos = afs_strchr(&avc->linkData[1], ':'); /* if cell name present */ if (cpos) { - volnamep = cpos+1; - *cpos = 0; - tcell = afs_GetCellByName(&avc->linkData[1], READ_LOCK); - *cpos = ':'; + volnamep = cpos + 1; + *cpos = 0; + tcell = afs_GetCellByName(&avc->linkData[1], READ_LOCK); + *cpos = ':'; } else { - volnamep = &avc->linkData[1]; - tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); + volnamep = &avc->linkData[1]; + tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); } - if (!tcell) return ENODEV; + if (!tcell) + return ENODEV; - mtptCell = tcell->cellNum; /* The cell for the mountpoint */ + mtptCell = tcell->cellNum; /* The cell for the mountpoint */ if (tcell->lcellp) { - hac = 1; /* has associated cell */ - assocCell = tcell->lcellp->cellNum; /* The associated cell */ + hac = 1; /* has associated cell */ + assocCell = tcell->lcellp->cellNum; /* The associated cell */ } - afs_PutCell(tcell, READ_LOCK); + afs_PutCell(tcell, READ_LOCK); /* Is volume name a ".backup" or ".readonly" name */ len = strlen(volnamep); - roname = ((len > 9) && (strcmp(&volnamep[len - 9],".readonly") == 0)) || - ((len > 7) && (strcmp(&volnamep[len - 7],".backup") == 0)); + roname = ((len > 9) && (strcmp(&volnamep[len - 9], ".readonly") == 0)) + || ((len > 7) && (strcmp(&volnamep[len - 7], ".backup") == 0)); /* When we cross mountpoint, do we stay in the same cell */ - samecell = (avc->fid.Cell == mtptCell) || (hac && (avc->fid.Cell == assocCell)); + samecell = (avc->fid.Cell == mtptCell) || (hac + && (avc->fid.Cell == + assocCell)); /* Decide whether to prefetch the RO. Also means we want the RO. * If this is a regular mountpoint with a RW volume name and * we cross a cell boundary -or- start from a RO volume, then we will * want to prefetch the RO volume when we get the RW below. */ - if ( (type == '#') && !roname && (!samecell || (avc->states & CRO)) ) { - prefetchRO = 2; /* Yes, prefetch the RO */ + if ((type == '#') && !roname && (!samecell || (avc->states & CRO))) { + prefetchRO = 2; /* Yes, prefetch the RO */ } else { - prefetchRO = 1; /* No prefetch of the RO */ + prefetchRO = 1; /* No prefetch of the RO */ } /* Get the volume struct. Unless this volume name has ".readonly" or * ".backup" in it, this will get the volume struct for the RW volume. * The RO volume will be prefetched if requested (but not returned). */ - tvp = afs_GetVolumeByName(volnamep, mtptCell, prefetchRO, areq, WRITE_LOCK); + tvp = + afs_GetVolumeByName(volnamep, mtptCell, prefetchRO, areq, WRITE_LOCK); /* If no volume was found in this cell, try the associated linked cell */ if (!tvp && hac && areq->volumeError) { - tvp = afs_GetVolumeByName(volnamep, assocCell, prefetchRO, areq, WRITE_LOCK); + tvp = + afs_GetVolumeByName(volnamep, assocCell, prefetchRO, areq, + WRITE_LOCK); } /* Still not found. If we are looking for the RO, then perhaps the RW @@ -131,21 +141,22 @@ int EvalMountPoint(register struct vcache *avc, struct vcache *advc, * Don't know why we do this. Would have still found it in above call - jpm. */ if (!tvp && (prefetchRO == 2)) { - buf = (char *)osi_AllocSmallSpace(strlen(volnamep)+10); + buf = (char *)osi_AllocSmallSpace(strlen(volnamep) + 10); strcpy(buf, volnamep); afs_strcat(buf, ".readonly"); tvp = afs_GetVolumeByName(buf, mtptCell, 1, areq, WRITE_LOCK); - + /* Try the associated linked cell if failed */ if (!tvp && hac && areq->volumeError) { tvp = afs_GetVolumeByName(buf, assocCell, 1, areq, WRITE_LOCK); } osi_FreeSmallSpace(buf); } - - if (!tvp) return ENODEV; /* Couldn't find the volume */ + + if (!tvp) + return ENODEV; /* Couldn't find the volume */ /* Don't cross mountpoint from a BK to a BK volume */ if ((avc->states & CBackup) && (tvp->states & VBackup)) { @@ -157,15 +168,17 @@ int EvalMountPoint(register struct vcache *avc, struct vcache *advc, * RW volume and get the RO. Othewise, go with the RW. */ if ((prefetchRO == 2) && tvp->roVol) { - tfid.Fid.Volume = tvp->roVol; /* remember RO volume */ - tfid.Cell = tvp->cell; - afs_PutVolume(tvp, WRITE_LOCK); /* release old volume */ - tvp = afs_GetVolume(&tfid, areq, WRITE_LOCK); /* get the new one */ - if (!tvp) return ENODEV; /* oops, can't do it */ + tfid.Fid.Volume = tvp->roVol; /* remember RO volume */ + tfid.Cell = tvp->cell; + afs_PutVolume(tvp, WRITE_LOCK); /* release old volume */ + tvp = afs_GetVolume(&tfid, areq, WRITE_LOCK); /* get the new one */ + if (!tvp) + return ENODEV; /* oops, can't do it */ } if (avc->mvid == 0) - avc->mvid = (struct VenusFid *) osi_AllocSmallSpace(sizeof(struct VenusFid)); + avc->mvid = + (struct VenusFid *)osi_AllocSmallSpace(sizeof(struct VenusFid)); avc->mvid->Cell = tvp->cell; avc->mvid->Fid.Volume = tvp->volume; avc->mvid->Fid.Vnode = 1; @@ -188,7 +201,8 @@ int EvalMountPoint(register struct vcache *avc, struct vcache *advc, * to the new path. */ tvp->mtpoint = avc->fid; /* setup back pointer to mtpoint */ - if (advc) tvp->dotdot = advc->fid; + if (advc) + tvp->dotdot = advc->fid; *avolpp = tvp; return 0; @@ -202,7 +216,8 @@ int EvalMountPoint(register struct vcache *avc, struct vcache *advc, * without calling afs_EvalFakeStat is legal, as long as this * function is called. */ -void afs_InitFakeStat(struct afs_fakestat_state *state) +void +afs_InitFakeStat(struct afs_fakestat_state *state) { if (!afs_fakestat_enable) return; @@ -220,8 +235,9 @@ void afs_InitFakeStat(struct afs_fakestat_state *state) * * Only issues RPCs if canblock is non-zero. */ -int afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state, - struct vrequest *areq, int canblock) +int +afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state, + struct vrequest *areq, int canblock) { struct vcache *tvc, *root_vp; struct volume *tvolp = NULL; @@ -293,7 +309,7 @@ int afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state, code = canblock ? ENOENT : 0; } -done: + done: if (tvolp) afs_PutVolume(tvolp, WRITE_LOCK); return code; @@ -314,7 +330,7 @@ done: */ int afs_EvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state, - struct vrequest *areq) + struct vrequest *areq) { return afs_EvalFakeStat_int(avcp, state, areq, 1); } @@ -329,8 +345,9 @@ afs_EvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state, * Returns 0 if everything succeeds and *avcp points to a valid * vcache entry (possibly evaluated). */ -int afs_TryEvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state, - struct vrequest *areq) +int +afs_TryEvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state, + struct vrequest *areq) { return afs_EvalFakeStat_int(avcp, state, areq, 0); } @@ -341,7 +358,8 @@ int afs_TryEvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state, * Perform any necessary cleanup at the end of a vnode op, given that * afs_InitFakeStat was previously called with this state. */ -void afs_PutFakeStat(struct afs_fakestat_state *state) +void +afs_PutFakeStat(struct afs_fakestat_state *state) { if (!afs_fakestat_enable) return; @@ -351,19 +369,22 @@ void afs_PutFakeStat(struct afs_fakestat_state *state) afs_PutVCache(state->root_vp); state->valid = 0; } - -int afs_ENameOK(register char *aname) + +int +afs_ENameOK(register char *aname) { register int tlen; AFS_STATCNT(ENameOK); tlen = strlen(aname); - if (tlen >= 4 && strcmp(aname+tlen-4, "@sys") == 0) return 0; + if (tlen >= 4 && strcmp(aname + tlen - 4, "@sys") == 0) + return 0; return 1; } -int afs_getsysname(register struct vrequest *areq, register struct vcache *adp, - register char *bufp) +int +afs_getsysname(register struct vrequest *areq, register struct vcache *adp, + register char *bufp) { register struct unixuser *au; register afs_int32 error; @@ -374,10 +395,10 @@ int afs_getsysname(register struct vrequest *areq, register struct vcache *adp, } AFS_STATCNT(getsysname); au = afs_GetUser(areq->uid, adp->fid.Cell, 0); - afs_PutUser(au, 0); + afs_PutUser(au, 0); if (au->exporter) { error = EXP_SYSNAME(au->exporter, NULL, bufp); - if (error) + if (error) strcpy(bufp, "@sys"); return -1; } else { @@ -386,12 +407,13 @@ int afs_getsysname(register struct vrequest *areq, register struct vcache *adp, } } -void Check_AtSys(register struct vcache *avc, const char *aname, - struct sysname_info *state, struct vrequest *areq) +void +Check_AtSys(register struct vcache *avc, const char *aname, + struct sysname_info *state, struct vrequest *areq) { if (AFS_EQ_ATSYS(aname)) { state->offset = 0; - state->name = (char *) osi_AllocLargeSpace(AFS_SMALLOCSIZ); + state->name = (char *)osi_AllocLargeSpace(AFS_SMALLOCSIZ); state->allocked = 1; state->index = afs_getsysname(areq, avc, state->name); } else { @@ -402,42 +424,44 @@ void Check_AtSys(register struct vcache *avc, const char *aname, } } -int Next_AtSys(register struct vcache *avc, struct vrequest *areq, - struct sysname_info *state) +int +Next_AtSys(register struct vcache *avc, struct vrequest *areq, + struct sysname_info *state) { - if (state->index == -1) - return 0; /* No list */ - - /* Check for the initial state of aname != "@sys" in Check_AtSys*/ - if (state->offset == -1 && state->allocked == 0) { - register char *tname; - /* Check for .*@sys */ - for (tname=state->name; *tname; tname++) - /*Move to the end of the string*/; - if ((tname > state->name + 4) && (AFS_EQ_ATSYS(tname-4))) { - state->offset = (tname - 4) - state->name; - tname = (char *) osi_AllocLargeSpace(AFS_LRALLOCSIZ); - strncpy(tname, state->name, state->offset); - state->name = tname; - state->allocked = 1; - state->index = afs_getsysname(areq, avc, state->name+state->offset); - return 1; - } else - return 0; /* .*@sys doesn't match either */ - } else if (++(state->index) >= afs_sysnamecount - || !afs_sysnamelist[(int)state->index]) - return 0; /* end of list */ - strcpy(state->name+state->offset, afs_sysnamelist[(int)state->index]); - return 1; + if (state->index == -1) + return 0; /* No list */ + + /* Check for the initial state of aname != "@sys" in Check_AtSys */ + if (state->offset == -1 && state->allocked == 0) { + register char *tname; + /* Check for .*@sys */ + for (tname = state->name; *tname; tname++) + /*Move to the end of the string */ ; + if ((tname > state->name + 4) && (AFS_EQ_ATSYS(tname - 4))) { + state->offset = (tname - 4) - state->name; + tname = (char *)osi_AllocLargeSpace(AFS_LRALLOCSIZ); + strncpy(tname, state->name, state->offset); + state->name = tname; + state->allocked = 1; + state->index = + afs_getsysname(areq, avc, state->name + state->offset); + return 1; + } else + return 0; /* .*@sys doesn't match either */ + } else if (++(state->index) >= afs_sysnamecount + || !afs_sysnamelist[(int)state->index]) + return 0; /* end of list */ + strcpy(state->name + state->offset, afs_sysnamelist[(int)state->index]); + return 1; } #if (defined(AFS_SGI62_ENV) || defined(AFS_SUN57_64BIT_ENV)) -extern int BlobScan(ino64_t *afile, afs_int32 ablob); +extern int BlobScan(ino64_t * afile, afs_int32 ablob); #else #if defined AFS_LINUX_64BIT_KERNEL extern int BlobScan(long *afile, afs_int32 ablob); #else -extern int BlobScan(afs_int32 *afile, afs_int32 ablob); +extern int BlobScan(afs_int32 * afile, afs_int32 ablob); #endif #endif @@ -460,7 +484,8 @@ extern int BlobScan(afs_int32 *afile, afs_int32 ablob); */ static struct vcache *BStvc = NULL; -int afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) +int +afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) { int nentries; /* # of entries to prefetch */ int nskip; /* # of slots in the LRU queue to skip */ @@ -492,39 +517,41 @@ int afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) int i; struct VenusFid afid; /* file ID we are using now */ struct VenusFid tfid; /* another temp. file ID */ - afs_int32 retry; /* handle low-level SGI MP race conditions */ + afs_int32 retry; /* handle low-level SGI MP race conditions */ long volStates; /* flags from vol structure */ - struct volume *volp=0; /* volume ptr */ + struct volume *volp = 0; /* volume ptr */ struct VenusFid dotdot; - int flagIndex; /* First file with bulk fetch flag set */ - int inlinebulk=0; /* Did we use InlineBulk RPC or not? */ + int flagIndex; /* First file with bulk fetch flag set */ + int inlinebulk = 0; /* Did we use InlineBulk RPC or not? */ XSTATS_DECLS - - /* first compute some basic parameters. We dont want to prefetch more - * than a fraction of the cache in any given call, and we want to preserve - * a portion of the LRU queue in any event, so as to avoid thrashing - * the entire stat cache (we will at least leave some of it alone). - * presently dont stat more than 1/8 the cache in any one call. */ - nentries = afs_cacheStats / 8; + /* first compute some basic parameters. We dont want to prefetch more + * than a fraction of the cache in any given call, and we want to preserve + * a portion of the LRU queue in any event, so as to avoid thrashing + * the entire stat cache (we will at least leave some of it alone). + * presently dont stat more than 1/8 the cache in any one call. */ + nentries = afs_cacheStats / 8; /* dont bother prefetching more than one calls worth of info */ - if (nentries > AFSCBMAX) nentries = AFSCBMAX; + if (nentries > AFSCBMAX) + nentries = AFSCBMAX; /* heuristic to make sure that things fit in 4K. This means that * we shouldnt make it any bigger than 47 entries. I am typically * going to keep it a little lower, since we don't want to load * too much of the stat cache. */ - if (nentries > 30) nentries = 30; + if (nentries > 30) + nentries = 30; /* now, to reduce the stack size, well allocate two 4K blocks, * one for fids and callbacks, and one for stat info. Well set * up our pointers to the memory from there, too. */ statMemp = osi_AllocLargeSpace(nentries * sizeof(AFSFetchStatus)); - statsp = (struct AFSFetchStatus *) statMemp; - cbfMemp = osi_AllocLargeSpace(nentries * - (sizeof(AFSCallBack) + sizeof(AFSFid))); + statsp = (struct AFSFetchStatus *)statMemp; + cbfMemp = + osi_AllocLargeSpace(nentries * + (sizeof(AFSCallBack) + sizeof(AFSFid))); fidsp = (AFSFid *) cbfMemp; cbsp = (AFSCallBack *) (cbfMemp + nentries * sizeof(AFSFid)); @@ -533,9 +560,10 @@ int afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) * We skip files that already have stat cache entries, since we * dont want to bulk stat files that are already in the cache. */ -tagain: + tagain: code = afs_VerifyVCache(adp, areqp); - if (code) goto done; + if (code) + goto done; dcp = afs_GetDCache(adp, (afs_size_t) 0, areqp, &temp, &temp, 1); if (!dcp) { @@ -556,11 +584,9 @@ tagain: while ((adp->states & CStatd) && (dcp->dflags & DFFetching) && hsame(adp->m.DataVersion, dcp->f.versionNo)) { - afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, dcp, - ICL_TYPE_INT32, dcp->dflags); + afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_INT32, __LINE__, ICL_TYPE_POINTER, dcp, + ICL_TYPE_INT32, dcp->dflags); ReleaseReadLock(&dcp->lock); ReleaseReadLock(&adp->lock); afs_osi_Sleep(&dcp->validPos); @@ -587,24 +613,27 @@ tagain: /* now we have dir data in the cache, so scan the dir page */ fidIndex = 0; flagIndex = 0; - while (1) { /* Should probably have some constant bound */ + while (1) { /* Should probably have some constant bound */ /* look for first safe entry to examine in the directory. BlobScan * looks for a the 1st allocated dir after the dirCookie slot. */ - newIndex = BlobScan(&dcp->f.inode, (dirCookie>>5)); - if (newIndex == 0) break; + newIndex = BlobScan(&dcp->f.inode, (dirCookie >> 5)); + if (newIndex == 0) + break; /* remember the updated directory cookie */ dirCookie = newIndex << 5; /* get a ptr to the dir entry */ - dirEntryp =(struct DirEntry *)afs_dir_GetBlob(&dcp->f.inode, newIndex); - if (!dirEntryp) break; + dirEntryp = + (struct DirEntry *)afs_dir_GetBlob(&dcp->f.inode, newIndex); + if (!dirEntryp) + break; /* dont copy more than we have room for */ if (fidIndex >= nentries) { - DRelease((struct buffer *) dirEntryp, 0); - break; + DRelease((struct buffer *)dirEntryp, 0); + break; } /* now, if the dir entry looks good, copy it out to our list. Vnode @@ -620,25 +649,25 @@ tagain: tfid.Fid.Vnode = ntohl(dirEntryp->fid.vnode); tfid.Fid.Unique = ntohl(dirEntryp->fid.vunique); do { - retry = 0; - ObtainWriteLock(&afs_xvcache, 130); - tvcp = afs_FindVCache(&tfid, &retry, 0 /* no stats | LRU */); - if (tvcp && retry) { - ReleaseWriteLock(&afs_xvcache); - afs_PutVCache(tvcp); - } + retry = 0; + ObtainWriteLock(&afs_xvcache, 130); + tvcp = afs_FindVCache(&tfid, &retry, 0 /* no stats | LRU */ ); + if (tvcp && retry) { + ReleaseWriteLock(&afs_xvcache); + afs_PutVCache(tvcp); + } } while (tvcp && retry); - if (!tvcp) { /* otherwise, create manually */ - tvcp = afs_NewVCache(&tfid, hostp); - ObtainWriteLock(&tvcp->lock, 505); - ReleaseWriteLock(&afs_xvcache); - afs_RemoveVCB(&tfid); - ReleaseWriteLock(&tvcp->lock); + if (!tvcp) { /* otherwise, create manually */ + tvcp = afs_NewVCache(&tfid, hostp); + ObtainWriteLock(&tvcp->lock, 505); + ReleaseWriteLock(&afs_xvcache); + afs_RemoveVCB(&tfid); + ReleaseWriteLock(&tvcp->lock); } else { - ReleaseWriteLock(&afs_xvcache); + ReleaseWriteLock(&afs_xvcache); } if (!tvcp) - goto done; /* can't happen at present, more's the pity */ + goto done; /* can't happen at present, more's the pity */ /* WARNING: afs_DoBulkStat uses the Length field to store a * sequence number for each bulk status request. Under no @@ -646,14 +675,14 @@ tagain: * if the new length will be ignored when afs_ProcessFS is * called with new stats. */ #ifdef AFS_SGI_ENV - if (!(tvcp->states & (CStatd|CBulkFetching)) - && (tvcp->execsOrWriters <= 0) - && !afs_DirtyPages(tvcp) - && !AFS_VN_MAPPED((vnode_t*)tvcp)) + if (!(tvcp->states & (CStatd | CBulkFetching)) + && (tvcp->execsOrWriters <= 0) + && !afs_DirtyPages(tvcp) + && !AFS_VN_MAPPED((vnode_t *) tvcp)) #else - if (!(tvcp->states & (CStatd|CBulkFetching)) - && (tvcp->execsOrWriters <= 0) - && !afs_DirtyPages(tvcp)) + if (!(tvcp->states & (CStatd | CBulkFetching)) + && (tvcp->execsOrWriters <= 0) + && !afs_DirtyPages(tvcp)) #endif { @@ -671,22 +700,25 @@ tagain: * preserve the value of the file size. We could * flush the pages, but it wouldn't be worthwhile. */ - memcpy((char *)(fidsp+fidIndex), (char *) &tfid.Fid, sizeof(*fidsp)); + memcpy((char *)(fidsp + fidIndex), (char *)&tfid.Fid, + sizeof(*fidsp)); tvcp->states |= CBulkFetching; tvcp->m.Length = statSeqNo; fidIndex++; } afs_PutVCache(tvcp); - } /* if dir vnode has non-zero entry */ + } + /* if dir vnode has non-zero entry */ /* move to the next dir entry by adding in the # of entries * used by this dir entry. */ temp = afs_dir_NameBlobs(dirEntryp->name) << 5; - DRelease((struct buffer *) dirEntryp, 0); - if (temp <= 0) break; + DRelease((struct buffer *)dirEntryp, 0); + if (temp <= 0) + break; dirCookie += temp; - } /* while loop over all dir entries */ + } /* while loop over all dir entries */ /* now release the dir lock and prepare to make the bulk RPC */ ReleaseReadLock(&dcp->lock); @@ -696,7 +728,8 @@ tagain: afs_PutDCache(dcp); /* dont make a null call */ - if (fidIndex == 0) goto done; + if (fidIndex == 0) + goto done; do { /* setup the RPC parm structures */ @@ -717,29 +750,34 @@ tagain: RX_AFS_GUNLOCK(); if (!(tcp->srvr->server->flags & SNO_INLINEBULK)) { - code = RXAFS_InlineBulkStatus(tcp->id, &fidParm, &statParm, - &cbParm, &volSync); + code = + RXAFS_InlineBulkStatus(tcp->id, &fidParm, &statParm, + &cbParm, &volSync); if (code == RXGEN_OPCODE) { tcp->srvr->server->flags |= SNO_INLINEBULK; inlinebulk = 0; - code = RXAFS_BulkStatus(tcp->id, &fidParm, &statParm, - &cbParm, &volSync); + code = + RXAFS_BulkStatus(tcp->id, &fidParm, &statParm, + &cbParm, &volSync); } else - inlinebulk=1; + inlinebulk = 1; } else { - inlinebulk=0; - code = RXAFS_BulkStatus(tcp->id, &fidParm, &statParm, &cbParm, - &volSync); + inlinebulk = 0; + code = + RXAFS_BulkStatus(tcp->id, &fidParm, &statParm, &cbParm, + &volSync); } RX_AFS_GLOCK(); XSTATS_END_TIME; - } - else code = -1; - } while (afs_Analyze(tcp, code, &adp->fid, areqp, - AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, NULL)); + } else + code = -1; + } while (afs_Analyze + (tcp, code, &adp->fid, areqp, AFS_STATS_FS_RPCIDX_BULKSTATUS, + SHARED_LOCK, NULL)); /* now, if we didnt get the info, bail out. */ - if (code) goto done; + if (code) + goto done; /* we need vol flags to create the entries properly */ dotdot.Fid.Volume = 0; @@ -748,8 +786,8 @@ tagain: volStates = volp->states; if (volp->dotdot.Fid.Volume != 0) dotdot = volp->dotdot; - } - else volStates = 0; + } else + volStates = 0; /* find the place to merge the info into We do this by skipping * nskip entries in the LRU queue. The more we skip, the more @@ -757,27 +795,30 @@ tagain: * referenced file. */ reskip: - nskip = afs_cacheStats / 2; /* preserved fraction of the cache */ + nskip = afs_cacheStats / 2; /* preserved fraction of the cache */ ObtainReadLock(&afs_xvcache); if (QEmpty(&VLRU)) { - /* actually a serious error, probably should panic. Probably will - * panic soon, oh well. */ - ReleaseReadLock(&afs_xvcache); - afs_warnuser("afs_DoBulkStat: VLRU empty!"); - goto done; + /* actually a serious error, probably should panic. Probably will + * panic soon, oh well. */ + ReleaseReadLock(&afs_xvcache); + afs_warnuser("afs_DoBulkStat: VLRU empty!"); + goto done; } if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("Bulkstat VLRU inconsistent"); + refpanic("Bulkstat VLRU inconsistent"); } - for(tq = VLRU.next; tq != &VLRU; tq = QNext(tq)) { - if (--nskip <= 0) break; + for (tq = VLRU.next; tq != &VLRU; tq = QNext(tq)) { + if (--nskip <= 0) + break; else if (QNext(QPrev(tq)) != tq) { - BStvc = QTOV(tq); - refpanic ("BulkStat VLRU inconsistent"); + BStvc = QTOV(tq); + refpanic("BulkStat VLRU inconsistent"); } } - if (tq != &VLRU) lruvcp = QTOV(tq); - else lruvcp = QTOV(VLRU.next); + if (tq != &VLRU) + lruvcp = QTOV(tq); + else + lruvcp = QTOV(VLRU.next); /* now we have to hold this entry, so that it does not get moved * into the free list while we're running. It could still get @@ -786,9 +827,9 @@ tagain: */ retry = 0; osi_vnhold(lruvcp, &retry); - ReleaseReadLock(&afs_xvcache); /* could be read lock */ + ReleaseReadLock(&afs_xvcache); /* could be read lock */ if (retry) - goto reskip; + goto reskip; /* otherwise, merge in the info. We have to be quite careful here, * since we need to ensure that we don't merge old info over newer @@ -799,18 +840,18 @@ tagain: * * We also have to take into account racing token revocations. */ - for(i=0; ierrorCode) + for (i = 0; i < fidIndex; i++) { + if ((&statsp[i])->errorCode) continue; afid.Cell = adp->fid.Cell; afid.Fid.Volume = adp->fid.Fid.Volume; afid.Fid.Vnode = fidsp[i].Vnode; afid.Fid.Unique = fidsp[i].Unique; do { - retry = 0; - ObtainReadLock(&afs_xvcache); - tvcp = afs_FindVCache(&afid, &retry, 0/* !stats&!lru*/); - ReleaseReadLock(&afs_xvcache); + retry = 0; + ObtainReadLock(&afs_xvcache); + tvcp = afs_FindVCache(&afid, &retry, 0 /* !stats&!lru */ ); + ReleaseReadLock(&afs_xvcache); } while (tvcp && retry); /* The entry may no longer exist */ @@ -819,7 +860,7 @@ tagain: } /* now we have the entry held, but we need to fill it in */ - ObtainWriteLock(&tvcp->lock,131); + ObtainWriteLock(&tvcp->lock, 131); /* if CBulkFetching is not set, or if the file size no longer * matches the value we placed there when we set the CBulkFetching @@ -835,37 +876,42 @@ tagain: } /* now copy ".." entry back out of volume structure, if necessary */ - if (tvcp->mvstat == 2 && (dotdot.Fid.Volume != 0)) { + if (tvcp->mvstat == 2 && (dotdot.Fid.Volume != 0)) { if (!tvcp->mvid) - tvcp->mvid = (struct VenusFid *) osi_AllocSmallSpace(sizeof(struct VenusFid)); + tvcp->mvid = (struct VenusFid *) + osi_AllocSmallSpace(sizeof(struct VenusFid)); *tvcp->mvid = dotdot; } - ObtainWriteLock(&afs_xvcache,132); + ObtainWriteLock(&afs_xvcache, 132); if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("Bulkstat VLRU inconsistent2"); + refpanic("Bulkstat VLRU inconsistent2"); } - if ((QNext(QPrev(&tvcp->vlruq)) != &tvcp->vlruq) - || (QPrev(QNext(&tvcp->vlruq)) != &tvcp->vlruq)) - { refpanic ("Bulkstat VLRU inconsistent4"); } - if ((QNext(QPrev(&lruvcp->vlruq)) != &lruvcp->vlruq) - || (QPrev(QNext(&lruvcp->vlruq)) != &lruvcp->vlruq)) - { refpanic ("Bulkstat VLRU inconsistent5"); } - - if (tvcp != lruvcp) { /* if they are == don't move it, don't corrupt vlru */ - QRemove(&tvcp->vlruq); - QAdd(&lruvcp->vlruq, &tvcp->vlruq); + if ((QNext(QPrev(&tvcp->vlruq)) != &tvcp->vlruq) + || (QPrev(QNext(&tvcp->vlruq)) != &tvcp->vlruq)) { + refpanic("Bulkstat VLRU inconsistent4"); + } + if ((QNext(QPrev(&lruvcp->vlruq)) != &lruvcp->vlruq) + || (QPrev(QNext(&lruvcp->vlruq)) != &lruvcp->vlruq)) { + refpanic("Bulkstat VLRU inconsistent5"); + } + + if (tvcp != lruvcp) { /* if they are == don't move it, don't corrupt vlru */ + QRemove(&tvcp->vlruq); + QAdd(&lruvcp->vlruq, &tvcp->vlruq); } if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("Bulkstat VLRU inconsistent3"); + refpanic("Bulkstat VLRU inconsistent3"); + } + if ((QNext(QPrev(&tvcp->vlruq)) != &tvcp->vlruq) + || (QPrev(QNext(&tvcp->vlruq)) != &tvcp->vlruq)) { + refpanic("Bulkstat VLRU inconsistent5"); + } + if ((QNext(QPrev(&lruvcp->vlruq)) != &lruvcp->vlruq) + || (QPrev(QNext(&lruvcp->vlruq)) != &lruvcp->vlruq)) { + refpanic("Bulkstat VLRU inconsistent6"); } - if ((QNext(QPrev(&tvcp->vlruq)) != &tvcp->vlruq) - || (QPrev(QNext(&tvcp->vlruq)) != &tvcp->vlruq)) - { refpanic ("Bulkstat VLRU inconsistent5"); } - if ((QNext(QPrev(&lruvcp->vlruq)) != &lruvcp->vlruq) - || (QPrev(QNext(&lruvcp->vlruq)) != &lruvcp->vlruq)) - { refpanic ("Bulkstat VLRU inconsistent6"); } ReleaseWriteLock(&afs_xvcache); ObtainWriteLock(&afs_xcbhash, 494); @@ -903,9 +949,12 @@ tagain: afs_bulkStatsDone++; /* merge in vol info */ - if (volStates & VRO) tvcp->states |= CRO; - if (volStates & VBackup) tvcp->states |= CBackup; - if (volStates & VForeign) tvcp->states |= CForeign; + if (volStates & VRO) + tvcp->states |= CRO; + if (volStates & VBackup) + tvcp->states |= CBackup; + if (volStates & VForeign) + tvcp->states |= CForeign; /* merge in the callback info */ tvcp->states |= CTruth; @@ -914,66 +963,62 @@ tagain: tcbp = cbsp + i; if (tcbp->ExpirationTime != 0) { - tvcp->cbExpires = tcbp->ExpirationTime+startTime; + tvcp->cbExpires = tcbp->ExpirationTime + startTime; tvcp->callback = hostp; tvcp->states |= CStatd; afs_QueueCallback(tvcp, CBHash(tcbp->ExpirationTime), volp); - } - else if (tvcp->states & CRO) { + } else if (tvcp->states & CRO) { /* ordinary callback on a read-only volume -- AFS 3.2 style */ - tvcp->cbExpires = 3600+startTime; + tvcp->cbExpires = 3600 + startTime; tvcp->callback = hostp; tvcp->states |= CStatd; afs_QueueCallback(tvcp, CBHash(3600), volp); - } - else { + } else { tvcp->callback = 0; - tvcp->states &= ~(CStatd|CUnique); + tvcp->states &= ~(CStatd | CUnique); afs_DequeueCallback(tvcp); - if ((tvcp->states & CForeign) || (vType(tvcp) == VDIR)) - osi_dnlc_purgedp (tvcp); /* if it (could be) a directory */ + if ((tvcp->states & CForeign) || (vType(tvcp) == VDIR)) + osi_dnlc_purgedp(tvcp); /* if it (could be) a directory */ } ReleaseWriteLock(&afs_xcbhash); ReleaseWriteLock(&tvcp->lock); /* finally, we're done with the entry */ afs_PutVCache(tvcp); - } /* for all files we got back */ + } /* for all files we got back */ /* finally return the pointer into the LRU queue */ afs_PutVCache(lruvcp); done: /* Be sure to turn off the CBulkFetching flags */ - for(i=flagIndex; ifid.Cell; afid.Fid.Volume = adp->fid.Fid.Volume; afid.Fid.Vnode = fidsp[i].Vnode; afid.Fid.Unique = fidsp[i].Unique; do { - retry = 0; - ObtainReadLock(&afs_xvcache); - tvcp = afs_FindVCache(&afid, &retry, 0/* !stats&!lru*/); - ReleaseReadLock(&afs_xvcache); + retry = 0; + ObtainReadLock(&afs_xvcache); + tvcp = afs_FindVCache(&afid, &retry, 0 /* !stats&!lru */ ); + ReleaseReadLock(&afs_xvcache); } while (tvcp && retry); - if (tvcp != NULL - && (tvcp->states & CBulkFetching) + if (tvcp != NULL && (tvcp->states & CBulkFetching) && (tvcp->m.Length == statSeqNo)) { - tvcp->states &= ~CBulkFetching; + tvcp->states &= ~CBulkFetching; } if (tvcp != NULL) { - afs_PutVCache(tvcp); + afs_PutVCache(tvcp); } } - if ( volp ) + if (volp) afs_PutVolume(volp, READ_LOCK); - + /* If we did the InlineBulk RPC pull out the return code */ if (inlinebulk) { if ((&statsp[0])->errorCode) { - afs_Analyze(tcp, (&statsp[0])->errorCode, &adp->fid, areqp, - AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, - NULL); + afs_Analyze(tcp, (&statsp[0])->errorCode, &adp->fid, areqp, + AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, NULL); code = (&statsp[0])->errorCode; } } else { @@ -990,44 +1035,46 @@ static int AFSDOBULK = 1; int #ifdef AFS_OSF_ENV afs_lookup(adp, ndp) - struct vcache *adp; - struct nameidata *ndp; { - char aname[MAXNAMLEN+1]; /* XXX */ + struct vcache *adp; + struct nameidata *ndp; +{ + char aname[MAXNAMLEN + 1]; /* XXX */ struct vcache **avcp = (struct vcache **)&(ndp->ni_vp); struct ucred *acred = ndp->ni_cred; int wantparent = ndp->ni_nameiop & WANTPARENT; int opflag = ndp->ni_nameiop & OPFLAG; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) afs_lookup(OSI_VC_ARG(adp), aname, avcp, pnp, flags, rdir, acred) - struct pathname *pnp; - int flags; - struct vnode *rdir; + struct pathname *pnp; + int flags; + struct vnode *rdir; #else #if defined(UKERNEL) afs_lookup(adp, aname, avcp, acred, flags) - int flags; -#else + int flags; +#else afs_lookup(adp, aname, avcp, acred) -#endif /* UKERNEL */ -#endif /* SUN5 || SGI */ - OSI_VC_DECL(adp); - struct vcache **avcp; - char *aname; - struct AFS_UCRED *acred; { +#endif /* UKERNEL */ +#endif /* SUN5 || SGI */ +OSI_VC_DECL(adp); + struct vcache **avcp; + char *aname; + struct AFS_UCRED *acred; +{ #endif struct vrequest treq; char *tname = NULL; - register struct vcache *tvc=0; + register struct vcache *tvc = 0; register afs_int32 code; register afs_int32 bulkcode = 0; int pass = 0, hit = 0; long dirCookie; - extern afs_int32 afs_mariner; /*Writing activity to log?*/ + extern afs_int32 afs_mariner; /*Writing activity to log? */ OSI_VC_CONVERT(adp) afs_hyper_t versionNo; int no_read_access = 0; - struct sysname_info sysState; /* used only for @sys checking */ + struct sysname_info sysState; /* used only for @sys checking */ int dynrootRetry = 1; struct afs_fakestat_state fakestate; int tryEvalOnly = 0; @@ -1042,7 +1089,7 @@ afs_lookup(adp, aname, avcp, acred) ndp->ni_dvp = AFSTOV(adp); memcpy(aname, ndp->ni_ptr, ndp->ni_namelen); aname[ndp->ni_namelen] = '\0'; -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ #if defined(AFS_DARWIN_ENV) /* Workaround for MacOSX Finder, which tries to look for @@ -1065,26 +1112,26 @@ afs_lookup(adp, aname, avcp, acred) if (code) goto done; - *avcp = NULL; /* Since some callers don't initialize it */ + *avcp = NULL; /* Since some callers don't initialize it */ /* come back to here if we encounter a non-existent object in a read-only - volume's directory */ + * volume's directory */ redo: - *avcp = NULL; /* Since some callers don't initialize it */ + *avcp = NULL; /* Since some callers don't initialize it */ bulkcode = 0; if (!(adp->states & CStatd)) { if ((code = afs_VerifyVCache2(adp, &treq))) { goto done; } - } - else code = 0; + } else + code = 0; /* watch for ".." in a volume root */ if (adp->mvstat == 2 && aname[0] == '.' && aname[1] == '.' && !aname[2]) { /* looking up ".." in root via special hacks */ - if (adp->mvid == (struct VenusFid *) 0 || adp->mvid->Fid.Volume == 0) { + if (adp->mvid == (struct VenusFid *)0 || adp->mvid->Fid.Volume == 0) { #ifdef AFS_OSF_ENV extern struct vcache *afs_globalVp; if (adp == afs_globalVp) { @@ -1103,9 +1150,8 @@ afs_lookup(adp, aname, avcp, acred) } /* otherwise we have the fid here, so we use it */ tvc = afs_GetVCache(adp->mvid, &treq, NULL, NULL); - afs_Trace3(afs_iclSetp, CM_TRACE_GETVCDOTDOT, - ICL_TYPE_FID, adp->mvid, ICL_TYPE_POINTER, tvc, - ICL_TYPE_INT32, code); + afs_Trace3(afs_iclSetp, CM_TRACE_GETVCDOTDOT, ICL_TYPE_FID, adp->mvid, + ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, code); *avcp = tvc; code = (tvc ? 0 : ENOENT); hit = 1; @@ -1113,23 +1159,23 @@ afs_lookup(adp, aname, avcp, acred) osi_Panic("TT1"); } if (code) { - /*printf("LOOKUP GETVCDOTDOT -> %d\n", code);*/ + /*printf("LOOKUP GETVCDOTDOT -> %d\n", code); */ } goto done; } /* now check the access */ - if (treq.uid != adp->last_looker) { + if (treq.uid != adp->last_looker) { if (!afs_AccessOK(adp, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS)) { *avcp = NULL; code = EACCES; goto done; - } - else adp->last_looker = treq.uid; - } + } else + adp->last_looker = treq.uid; + } /* Check for read access as well. We need read access in order to - stat files, but not to stat subdirectories. */ + * stat files, but not to stat subdirectories. */ if (!afs_AccessOK(adp, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS)) no_read_access = 1; @@ -1138,10 +1184,10 @@ afs_lookup(adp, aname, avcp, acred) * I'm not fiddling with the LRUQ here, either, perhaps I should, or else * invent a lightweight version of GetVCache. */ - if (aname[0] == '.' && !aname[1]) { /* special case */ - ObtainReadLock(&afs_xvcache); + if (aname[0] == '.' && !aname[1]) { /* special case */ + ObtainReadLock(&afs_xvcache); osi_vnhold(adp, 0); - ReleaseReadLock(&afs_xvcache); + ReleaseReadLock(&afs_xvcache); code = 0; *avcp = tvc = adp; hit = 1; @@ -1155,14 +1201,14 @@ afs_lookup(adp, aname, avcp, acred) tname = sysState.name; /* 1st Check_AtSys and lookup by tname is required here, for now, - because the dnlc is *not* told to remove entries for the parent - dir of file/dir op that afs_LocalHero likes, but dnlc is informed - if the cached entry for the parent dir is invalidated for a - non-local change. - Otherwise, we'd be able to do a dnlc lookup on an entry ending - w/@sys and know the dnlc was consistent with reality. */ - tvc = osi_dnlc_lookup (adp, tname, WRITE_LOCK); - *avcp = tvc; /* maybe wasn't initialized, but it is now */ + * because the dnlc is *not* told to remove entries for the parent + * dir of file/dir op that afs_LocalHero likes, but dnlc is informed + * if the cached entry for the parent dir is invalidated for a + * non-local change. + * Otherwise, we'd be able to do a dnlc lookup on an entry ending + * w/@sys and know the dnlc was consistent with reality. */ + tvc = osi_dnlc_lookup(adp, tname, WRITE_LOCK); + *avcp = tvc; /* maybe wasn't initialized, but it is now */ if (tvc) { if (no_read_access && vType(tvc) != VDIR && vType(tvc) != VLNK) { /* need read access on dir to stat non-directory / non-link */ @@ -1172,11 +1218,10 @@ afs_lookup(adp, aname, avcp, acred) goto done; } #ifdef AFS_LINUX22_ENV - if (tvc->mvstat == 2) { /* we don't trust the dnlc for root vcaches */ + if (tvc->mvstat == 2) { /* we don't trust the dnlc for root vcaches */ AFS_RELE(tvc); *avcp = 0; - } - else { + } else { code = 0; hit = 1; goto done; @@ -1188,155 +1233,162 @@ afs_lookup(adp, aname, avcp, acred) #endif /* linux22 */ } - { /* sub-block just to reduce stack usage */ - register struct dcache *tdc; - afs_size_t dirOffset, dirLen; - ino_t theDir; - struct VenusFid tfid; - - /* now we have to lookup the next fid */ - tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &dirOffset, &dirLen, 1); - if (!tdc) { - *avcp = NULL; /* redundant, but harmless */ - code = EIO; - goto done; - } - - /* now we will just call dir package with appropriate inode. - Dirs are always fetched in their entirety for now */ - ObtainReadLock(&adp->lock); - ObtainReadLock(&tdc->lock); + { /* sub-block just to reduce stack usage */ + register struct dcache *tdc; + afs_size_t dirOffset, dirLen; + ino_t theDir; + struct VenusFid tfid; + + /* now we have to lookup the next fid */ + tdc = + afs_GetDCache(adp, (afs_size_t) 0, &treq, &dirOffset, &dirLen, 1); + if (!tdc) { + *avcp = NULL; /* redundant, but harmless */ + code = EIO; + goto done; + } - /* - * Make sure that the data in the cache is current. There are two - * cases we need to worry about: - * 1. The cache data is being fetched by another process. - * 2. The cache data is no longer valid - */ - while ((adp->states & CStatd) - && (tdc->dflags & DFFetching) - && hsame(adp->m.DataVersion, tdc->f.versionNo)) { - ReleaseReadLock(&tdc->lock); - ReleaseReadLock(&adp->lock); - afs_osi_Sleep(&tdc->validPos); + /* now we will just call dir package with appropriate inode. + * Dirs are always fetched in their entirety for now */ ObtainReadLock(&adp->lock); ObtainReadLock(&tdc->lock); - } - if (!(adp->states & CStatd) - || !hsame(adp->m.DataVersion, tdc->f.versionNo)) { - ReleaseReadLock(&tdc->lock); - ReleaseReadLock(&adp->lock); - afs_PutDCache(tdc); - goto redo; - } - - /* Save the version number for when we call osi_dnlc_enter */ - hset(versionNo, tdc->f.versionNo); - - /* - * check for, and handle "@sys" if it's there. We should be able - * to avoid the alloc and the strcpy with a little work, but it's - * not pressing. If there aren't any remote users (ie, via the - * NFS translator), we have a slightly easier job. - * the faster way to do this is to check for *aname == '@' and if - * it's there, check for @sys, otherwise, assume there's no @sys - * then, if the lookup fails, check for .*@sys... - */ - /* above now implemented by Check_AtSys and Next_AtSys */ - /* lookup the name in the appropriate dir, and return a cache entry - on the resulting fid */ - theDir = tdc->f.inode; - code = afs_dir_LookupOffset(&theDir, sysState.name, &tfid.Fid, &dirCookie); + /* + * Make sure that the data in the cache is current. There are two + * cases we need to worry about: + * 1. The cache data is being fetched by another process. + * 2. The cache data is no longer valid + */ + while ((adp->states & CStatd) + && (tdc->dflags & DFFetching) + && hsame(adp->m.DataVersion, tdc->f.versionNo)) { + ReleaseReadLock(&tdc->lock); + ReleaseReadLock(&adp->lock); + afs_osi_Sleep(&tdc->validPos); + ObtainReadLock(&adp->lock); + ObtainReadLock(&tdc->lock); + } + if (!(adp->states & CStatd) + || !hsame(adp->m.DataVersion, tdc->f.versionNo)) { + ReleaseReadLock(&tdc->lock); + ReleaseReadLock(&adp->lock); + afs_PutDCache(tdc); + goto redo; + } - /* If the first lookup doesn't succeed, maybe it's got @sys in the name */ - while (code == ENOENT && Next_AtSys(adp, &treq, &sysState)) - code = afs_dir_LookupOffset(&theDir, sysState.name, &tfid.Fid, &dirCookie); - tname = sysState.name; + /* Save the version number for when we call osi_dnlc_enter */ + hset(versionNo, tdc->f.versionNo); + + /* + * check for, and handle "@sys" if it's there. We should be able + * to avoid the alloc and the strcpy with a little work, but it's + * not pressing. If there aren't any remote users (ie, via the + * NFS translator), we have a slightly easier job. + * the faster way to do this is to check for *aname == '@' and if + * it's there, check for @sys, otherwise, assume there's no @sys + * then, if the lookup fails, check for .*@sys... + */ + /* above now implemented by Check_AtSys and Next_AtSys */ + + /* lookup the name in the appropriate dir, and return a cache entry + * on the resulting fid */ + theDir = tdc->f.inode; + code = + afs_dir_LookupOffset(&theDir, sysState.name, &tfid.Fid, + &dirCookie); + + /* If the first lookup doesn't succeed, maybe it's got @sys in the name */ + while (code == ENOENT && Next_AtSys(adp, &treq, &sysState)) + code = + afs_dir_LookupOffset(&theDir, sysState.name, &tfid.Fid, + &dirCookie); + tname = sysState.name; - ReleaseReadLock(&tdc->lock); - afs_PutDCache(tdc); + ReleaseReadLock(&tdc->lock); + afs_PutDCache(tdc); - if (code == ENOENT && afs_IsDynroot(adp) && dynrootRetry) { - ReleaseReadLock(&adp->lock); - dynrootRetry = 0; - if (tname[0] == '.') - afs_LookupAFSDB(tname + 1); - else - afs_LookupAFSDB(tname); - if (tname && tname != aname) osi_FreeLargeSpace(tname); - goto redo; - } else { - ReleaseReadLock(&adp->lock); - } + if (code == ENOENT && afs_IsDynroot(adp) && dynrootRetry) { + ReleaseReadLock(&adp->lock); + dynrootRetry = 0; + if (tname[0] == '.') + afs_LookupAFSDB(tname + 1); + else + afs_LookupAFSDB(tname); + if (tname && tname != aname) + osi_FreeLargeSpace(tname); + goto redo; + } else { + ReleaseReadLock(&adp->lock); + } - /* new fid has same cell and volume */ - tfid.Cell = adp->fid.Cell; - tfid.Fid.Volume = adp->fid.Fid.Volume; - afs_Trace4(afs_iclSetp, CM_TRACE_LOOKUP, ICL_TYPE_POINTER, adp, - ICL_TYPE_STRING, tname, - ICL_TYPE_FID, &tfid, ICL_TYPE_INT32, code); + /* new fid has same cell and volume */ + tfid.Cell = adp->fid.Cell; + tfid.Fid.Volume = adp->fid.Fid.Volume; + afs_Trace4(afs_iclSetp, CM_TRACE_LOOKUP, ICL_TYPE_POINTER, adp, + ICL_TYPE_STRING, tname, ICL_TYPE_FID, &tfid, + ICL_TYPE_INT32, code); - if (code) { - if (code != ENOENT) { - printf("LOOKUP dirLookupOff -> %d\n", code); + if (code) { + if (code != ENOENT) { + printf("LOOKUP dirLookupOff -> %d\n", code); + } + goto done; } - goto done; - } - /* prefetch some entries, if the dir is currently open. The variable - * dirCookie tells us where to start prefetching from. - */ - if (AFSDOBULK && adp->opens > 0 && !(adp->states & CForeign) && !afs_IsDynroot(adp)) { - afs_int32 retry; - /* if the entry is not in the cache, or is in the cache, - * but hasn't been statd, then do a bulk stat operation. + /* prefetch some entries, if the dir is currently open. The variable + * dirCookie tells us where to start prefetching from. */ - do { - retry = 0; - ObtainReadLock(&afs_xvcache); - tvc = afs_FindVCache(&tfid, &retry, 0 /* !stats,!lru */); - ReleaseReadLock(&afs_xvcache); - } while (tvc && retry); - - if (!tvc || !(tvc->states & CStatd)) - bulkcode = afs_DoBulkStat(adp, dirCookie, &treq); - else - bulkcode = 0; - - /* if the vcache isn't usable, release it */ - if (tvc && !(tvc->states & CStatd)) { - afs_PutVCache(tvc); + if (AFSDOBULK && adp->opens > 0 && !(adp->states & CForeign) + && !afs_IsDynroot(adp)) { + afs_int32 retry; + /* if the entry is not in the cache, or is in the cache, + * but hasn't been statd, then do a bulk stat operation. + */ + do { + retry = 0; + ObtainReadLock(&afs_xvcache); + tvc = afs_FindVCache(&tfid, &retry, 0 /* !stats,!lru */ ); + ReleaseReadLock(&afs_xvcache); + } while (tvc && retry); + + if (!tvc || !(tvc->states & CStatd)) + bulkcode = afs_DoBulkStat(adp, dirCookie, &treq); + else + bulkcode = 0; + + /* if the vcache isn't usable, release it */ + if (tvc && !(tvc->states & CStatd)) { + afs_PutVCache(tvc); + tvc = NULL; + } + } else { tvc = NULL; + bulkcode = 0; } - } else { - tvc = NULL; - bulkcode = 0; - } - /* now get the status info, if we don't already have it */ - /* This is kind of weird, but we might wind up accidentally calling - * RXAFS_Lookup because we happened upon a file which legitimately - * has a 0 uniquifier. That is the result of allowing unique to wrap - * to 0. This was fixed in AFS 3.4. For CForeign, Unique == 0 means that - * the file has not yet been looked up. - */ - if (!tvc) { - afs_int32 cached = 0; - if (!tfid.Fid.Unique && (adp->states & CForeign)) { - tvc = afs_LookupVCache(&tfid, &treq, &cached, adp, tname); - } - if (!tvc && !bulkcode) { /* lookup failed or wasn't called */ - tvc = afs_GetVCache(&tfid, &treq, &cached, NULL); - } - } /* if !tvc */ - } /* sub-block just to reduce stack usage */ + /* now get the status info, if we don't already have it */ + /* This is kind of weird, but we might wind up accidentally calling + * RXAFS_Lookup because we happened upon a file which legitimately + * has a 0 uniquifier. That is the result of allowing unique to wrap + * to 0. This was fixed in AFS 3.4. For CForeign, Unique == 0 means that + * the file has not yet been looked up. + */ + if (!tvc) { + afs_int32 cached = 0; + if (!tfid.Fid.Unique && (adp->states & CForeign)) { + tvc = afs_LookupVCache(&tfid, &treq, &cached, adp, tname); + } + if (!tvc && !bulkcode) { /* lookup failed or wasn't called */ + tvc = afs_GetVCache(&tfid, &treq, &cached, NULL); + } + } /* if !tvc */ + } /* sub-block just to reduce stack usage */ if (tvc) { int force_eval = afs_fakestat_enable ? 0 : 1; if (adp->states & CForeign) - tvc->states |= CForeign; + tvc->states |= CForeign; tvc->parentVnode = adp->fid.Fid.Vnode; tvc->parentUnique = adp->fid.Fid.Unique; tvc->states &= ~CBulkStat; @@ -1355,87 +1407,89 @@ afs_lookup(adp, aname, avcp, acred) force_eval = 1; ReleaseReadLock(&tvc->lock); } - #if defined(UKERNEL) && defined(AFS_WEB_ENHANCEMENTS) - if (!(flags & AFS_LOOKUP_NOEVAL)) + if (!(flags & AFS_LOOKUP_NOEVAL)) /* don't eval mount points */ #endif /* UKERNEL && AFS_WEB_ENHANCEMENTS */ - if (tvc->mvstat == 1 && force_eval) { - /* a mt point, possibly unevaluated */ - struct volume *tvolp; + if (tvc->mvstat == 1 && force_eval) { + /* a mt point, possibly unevaluated */ + struct volume *tvolp; - ObtainWriteLock(&tvc->lock,133); - code = EvalMountPoint(tvc, adp, &tvolp, &treq); - ReleaseWriteLock(&tvc->lock); + ObtainWriteLock(&tvc->lock, 133); + code = EvalMountPoint(tvc, adp, &tvolp, &treq); + ReleaseWriteLock(&tvc->lock); - if (code) { - afs_PutVCache(tvc); - if (tvolp) afs_PutVolume(tvolp, WRITE_LOCK); - goto done; - } - - /* next, we want to continue using the target of the mt point */ - if (tvc->mvid && (tvc->states & CMValid)) { - struct vcache *uvc; - /* now lookup target, to set .. pointer */ - afs_Trace2(afs_iclSetp, CM_TRACE_LOOKUP1, - ICL_TYPE_POINTER, tvc, ICL_TYPE_FID, &tvc->fid); - uvc = tvc; /* remember for later */ - - if (tvolp && (tvolp->states & VForeign)) { - /* XXXX tvolp has ref cnt on but not locked! XXX */ - tvc = afs_GetRootVCache(tvc->mvid, &treq, NULL, tvolp); - } else { - tvc = afs_GetVCache(tvc->mvid, &treq, NULL, NULL); + if (code) { + afs_PutVCache(tvc); + if (tvolp) + afs_PutVolume(tvolp, WRITE_LOCK); + goto done; } - afs_PutVCache(uvc); /* we're done with it */ - if (!tvc) { - code = ENOENT; + /* next, we want to continue using the target of the mt point */ + if (tvc->mvid && (tvc->states & CMValid)) { + struct vcache *uvc; + /* now lookup target, to set .. pointer */ + afs_Trace2(afs_iclSetp, CM_TRACE_LOOKUP1, + ICL_TYPE_POINTER, tvc, ICL_TYPE_FID, + &tvc->fid); + uvc = tvc; /* remember for later */ + + if (tvolp && (tvolp->states & VForeign)) { + /* XXXX tvolp has ref cnt on but not locked! XXX */ + tvc = + afs_GetRootVCache(tvc->mvid, &treq, NULL, tvolp); + } else { + tvc = afs_GetVCache(tvc->mvid, &treq, NULL, NULL); + } + afs_PutVCache(uvc); /* we're done with it */ + + if (!tvc) { + code = ENOENT; + if (tvolp) { + afs_PutVolume(tvolp, WRITE_LOCK); + } + goto done; + } + + /* now, if we came via a new mt pt (say because of a new + * release of a R/O volume), we must reevaluate the .. + * ptr to point back to the appropriate place */ if (tvolp) { + ObtainWriteLock(&tvc->lock, 134); + if (tvc->mvid == NULL) { + tvc->mvid = (struct VenusFid *) + osi_AllocSmallSpace(sizeof(struct VenusFid)); + } + /* setup backpointer */ + *tvc->mvid = tvolp->dotdot; + ReleaseWriteLock(&tvc->lock); afs_PutVolume(tvolp, WRITE_LOCK); } + } else { + afs_PutVCache(tvc); + code = ENOENT; + if (tvolp) + afs_PutVolume(tvolp, WRITE_LOCK); goto done; } - - /* now, if we came via a new mt pt (say because of a new - * release of a R/O volume), we must reevaluate the .. - * ptr to point back to the appropriate place */ - if (tvolp) { - ObtainWriteLock(&tvc->lock,134); - if (tvc->mvid == NULL) { - tvc->mvid = (struct VenusFid *) osi_AllocSmallSpace(sizeof(struct VenusFid)); - } - /* setup backpointer */ - *tvc->mvid = tvolp->dotdot; - ReleaseWriteLock(&tvc->lock); - afs_PutVolume(tvolp, WRITE_LOCK); - } } - else { - afs_PutVCache(tvc); - code = ENOENT; - if (tvolp) afs_PutVolume(tvolp, WRITE_LOCK); - goto done; - } - } *avcp = tvc; if (tvc && !VREFCOUNT(tvc)) { osi_Panic("TT3"); } code = 0; - } - else { + } else { /* if we get here, we found something in a directory that couldn't - be located (a Multics "connection failure"). If the volume is - read-only, we try flushing this entry from the cache and trying - again. */ + * be located (a Multics "connection failure"). If the volume is + * read-only, we try flushing this entry from the cache and trying + * again. */ if (pass == 0) { struct volume *tv; tv = afs_GetVolume(&adp->fid, &treq, READ_LOCK); if (tv) { if (tv->states & VRO) { - pass = 1; /* try this *once* */ + pass = 1; /* try this *once* */ ObtainWriteLock(&afs_xcbhash, 495); afs_DequeueCallback(adp); /* re-stat to get later version */ @@ -1451,47 +1505,49 @@ afs_lookup(adp, aname, avcp, acred) code = ENOENT; } -done: + done: /* put the network buffer back, if need be */ - if (tname != aname && tname) osi_FreeLargeSpace(tname); + if (tname != aname && tname) + osi_FreeLargeSpace(tname); if (code == 0) { #ifdef AFS_OSF_ENV /* Handle RENAME; only need to check rename "." */ if (opflag == RENAME && wantparent && *ndp->ni_next == 0) { - if (!FidCmp(&(tvc->fid), &(adp->fid))) { + if (!FidCmp(&(tvc->fid), &(adp->fid))) { afs_PutVCache(*avcp); *avcp = NULL; afs_PutFakeStat(&fakestate); return afs_CheckCode(EISDIR, &treq, 18); } } -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ if (afs_mariner) - afs_AddMarinerName(aname, tvc); + afs_AddMarinerName(aname, tvc); #if defined(UKERNEL) && defined(AFS_WEB_ENHANCEMENTS) - if (!(flags & AFS_LOOKUP_NOEVAL)) - /* Here we don't enter the name into the DNLC because we want the - evaluated mount dir to be there (the vcache for the mounted volume) - rather than the vc of the mount point itself. we can still find the - mount point's vc in the vcache by its fid. */ + if (!(flags & AFS_LOOKUP_NOEVAL)) + /* Here we don't enter the name into the DNLC because we want the + * evaluated mount dir to be there (the vcache for the mounted volume) + * rather than the vc of the mount point itself. we can still find the + * mount point's vc in the vcache by its fid. */ #endif /* UKERNEL && AFS_WEB_ENHANCEMENTS */ - if (!hit) { - osi_dnlc_enter (adp, aname, tvc, &versionNo); - } - else { + if (!hit) { + osi_dnlc_enter(adp, aname, tvc, &versionNo); + } else { #ifdef AFS_LINUX20_ENV - /* So Linux inode cache is up to date. */ - code = afs_VerifyVCache(tvc, &treq); + /* So Linux inode cache is up to date. */ + code = afs_VerifyVCache(tvc, &treq); #else - afs_PutFakeStat(&fakestate); - return 0; /* can't have been any errors if hit and !code */ + afs_PutFakeStat(&fakestate); + return 0; /* can't have been any errors if hit and !code */ #endif - } + } } - if (bulkcode) code = bulkcode; else - code = afs_CheckCode(code, &treq, 19); + if (bulkcode) + code = bulkcode; + else + code = afs_CheckCode(code, &treq, 19); if (code) { /* If there is an error, make sure *avcp is null. * Alphas panic otherwise - defect 10719. diff --git a/src/afs/VNOPS/afs_vnop_open.c b/src/afs/VNOPS/afs_vnop_open.c index f5624b68e..04c707e08 100644 --- a/src/afs/VNOPS/afs_vnop_open.c +++ b/src/afs/VNOPS/afs_vnop_open.c @@ -17,11 +17,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -34,7 +35,8 @@ RCSID("$Header$"); */ int #ifdef AFS_SGI64_ENV -afs_open(bhv_desc_t *bhv, struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *acred) +afs_open(bhv_desc_t * bhv, struct vcache **avcp, afs_int32 aflags, + struct AFS_UCRED *acred) #else afs_open(struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *acred) #endif @@ -44,9 +46,10 @@ afs_open(struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *acred) struct vcache *tvc; int writing; struct afs_fakestat_state fakestate; - + AFS_STATCNT(afs_open); - if ((code = afs_InitReq(&treq, acred))) return code; + if ((code = afs_InitReq(&treq, acred))) + return code; #ifdef AFS_SGI64_ENV /* avcpp can be, but is not necesarily, bhp's vnode. */ tvc = VTOAFS(BHV_TO_VNODE(bhv)); @@ -57,31 +60,34 @@ afs_open(struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *acred) ICL_TYPE_INT32, aflags); afs_InitFakeStat(&fakestate); code = afs_EvalFakeStat(&tvc, &fakestate, &treq); - if (code) goto done; + if (code) + goto done; code = afs_VerifyVCache(tvc, &treq); - if (code) goto done; - if (aflags & (FWRITE | FTRUNC)) writing = 1; - else writing = 0; + if (code) + goto done; + if (aflags & (FWRITE | FTRUNC)) + writing = 1; + else + writing = 0; if (vType(tvc) == VDIR) { /* directory */ if (writing) { code = EISDIR; goto done; - } - else { - if (!afs_AccessOK(tvc, - ((tvc->states & CForeign) ? PRSFS_READ: PRSFS_LOOKUP), - &treq, CHECK_MODE_BITS)) { + } else { + if (!afs_AccessOK + (tvc, ((tvc->states & CForeign) ? PRSFS_READ : PRSFS_LOOKUP), + &treq, CHECK_MODE_BITS)) { code = EACCES; goto done; } } - } - else { + } else { #ifdef AFS_SUN5_ENV - if (AFS_NFSXLATORREQ(acred) && (aflags & FREAD)) { - if (!afs_AccessOK(tvc, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) { + if (AFS_NFSXLATORREQ(acred) && (aflags & FREAD)) { + if (!afs_AccessOK + (tvc, PRSFS_READ, &treq, + CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) { code = EACCES; goto done; } @@ -91,32 +97,32 @@ afs_open(struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *acred) if (aflags & FRSHARE) { /* * Hack for AIX 4.1: - * Apparently it is possible for a file to get mapped without - * either VNOP_MAP or VNOP_RDWR being called, if (1) it is a - * sharable library, and (2) it has already been loaded. We must - * ensure that the credp is up to date. We detect the situation - * by checking for O_RSHARE at open time. + * Apparently it is possible for a file to get mapped without + * either VNOP_MAP or VNOP_RDWR being called, if (1) it is a + * sharable library, and (2) it has already been loaded. We must + * ensure that the credp is up to date. We detect the situation + * by checking for O_RSHARE at open time. */ /* * We keep the caller's credentials since an async daemon will * handle the request at some point. We assume that the same * credentials will be used. */ - ObtainWriteLock(&tvc->lock,140); + ObtainWriteLock(&tvc->lock, 140); if (!tvc->credp || (tvc->credp != acred)) { - crhold(acred); - if (tvc->credp) { - struct ucred *crp = tvc->credp; - tvc->credp = NULL; - crfree(crp); - } - tvc->credp = acred; + crhold(acred); + if (tvc->credp) { + struct ucred *crp = tvc->credp; + tvc->credp = NULL; + crfree(crp); + } + tvc->credp = acred; } ReleaseWriteLock(&tvc->lock); } #endif /* normal file or symlink */ - osi_FlushText(tvc); /* only needed to flush text if text locked last time */ + osi_FlushText(tvc); /* only needed to flush text if text locked last time */ #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) afs_BozonLock(&tvc->pvnLock, tvc); #endif @@ -128,13 +134,14 @@ afs_open(struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *acred) /* set date on file if open in O_TRUNC mode */ if (aflags & FTRUNC) { /* this fixes touch */ - ObtainWriteLock(&tvc->lock,123); + ObtainWriteLock(&tvc->lock, 123); tvc->m.Date = osi_Time(); tvc->states |= CDirty; ReleaseWriteLock(&tvc->lock); } ObtainReadLock(&tvc->lock); - if (writing) tvc->execsOrWriters++; + if (writing) + tvc->execsOrWriters++; tvc->opens++; #if defined(AFS_SGI_ENV) if (writing && tvc->cred == NULL) { @@ -143,9 +150,9 @@ afs_open(struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *acred) } #endif ReleaseReadLock(&tvc->lock); -done: + done: afs_PutFakeStat(&fakestate); - code = afs_CheckCode(code, &treq, 4); /* avoid AIX -O bug */ + code = afs_CheckCode(code, &treq, 4); /* avoid AIX -O bug */ afs_Trace2(afs_iclSetp, CM_TRACE_OPEN, ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, 999999); diff --git a/src/afs/VNOPS/afs_vnop_read.c b/src/afs/VNOPS/afs_vnop_read.c index e1d1eb39d..d828e9c74 100644 --- a/src/afs/VNOPS/afs_vnop_read.c +++ b/src/afs/VNOPS/afs_vnop_read.c @@ -18,11 +18,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -31,31 +32,33 @@ RCSID("$Header$"); extern char afs_zeros[AFS_ZEROS]; afs_int32 maxIHint; -afs_int32 nihints; /* # of above actually in-use */ +afs_int32 nihints; /* # of above actually in-use */ afs_int32 usedihint; /* Imported variables */ extern afs_rwlock_t afs_xdcache; extern unsigned char *afs_indexFlags; -extern afs_hyper_t *afs_indexTimes; /* Dcache entry Access times */ -extern afs_hyper_t afs_indexCounter; /* Fake time for marking index */ +extern afs_hyper_t *afs_indexTimes; /* Dcache entry Access times */ +extern afs_hyper_t afs_indexCounter; /* Fake time for marking index */ /* Forward declarations */ void afs_PrefetchChunk(struct vcache *avc, struct dcache *adc, - struct AFS_UCRED *acred, struct vrequest *areq); + struct AFS_UCRED *acred, struct vrequest *areq); -int afs_MemRead(register struct vcache *avc, struct uio *auio, struct AFS_UCRED *acred, - daddr_t albn, struct buf **abpp, int noLock) +int +afs_MemRead(register struct vcache *avc, struct uio *auio, + struct AFS_UCRED *acred, daddr_t albn, struct buf **abpp, + int noLock) { afs_size_t totalLength; afs_size_t transferLength; afs_size_t filePos; afs_size_t offset, len, tlen; afs_int32 trimlen; - struct dcache *tdc=0; - afs_int32 error, trybusy=1; + struct dcache *tdc = 0; + afs_int32 error, trybusy = 1; struct uio tuio; struct iovec *tvec; afs_int32 code; @@ -66,31 +69,32 @@ int afs_MemRead(register struct vcache *avc, struct uio *auio, struct AFS_UCRED return EIO; /* check that we have the latest status info in the vnode cache */ - if ((code = afs_InitReq(&treq, acred))) return code; + if ((code = afs_InitReq(&treq, acred))) + return code; if (!noLock) { code = afs_VerifyVCache(avc, &treq); if (code) { - code = afs_CheckCode(code, &treq, 8); /* failed to get it */ - return code; + code = afs_CheckCode(code, &treq, 8); /* failed to get it */ + return code; } } - #ifndef AFS_VM_RDWR_ENV if (AFS_NFSXLATORREQ(acred)) { - if (!afs_AccessOK(avc, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) { + if (!afs_AccessOK + (avc, PRSFS_READ, &treq, + CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) { return afs_CheckCode(EACCES, &treq, 9); } } #endif - tvec = (struct iovec *) osi_AllocSmallSpace(sizeof(struct iovec)); + tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec)); totalLength = auio->afsio_resid; filePos = auio->afsio_offset; - afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), - ICL_TYPE_INT32, totalLength, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); + afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc, + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_INT32, + totalLength, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length)); error = 0; transferLength = 0; if (!noLock) @@ -107,7 +111,8 @@ int afs_MemRead(register struct vcache *avc, struct uio *auio, struct AFS_UCRED */ while (totalLength > 0) { /* read all of the cached info */ - if (filePos >= avc->m.Length) break; /* all done */ + if (filePos >= avc->m.Length) + break; /* all done */ if (noLock) { if (tdc) { ReleaseReadLock(&tdc->lock); @@ -121,34 +126,34 @@ int afs_MemRead(register struct vcache *avc, struct uio *auio, struct AFS_UCRED } } else { /* a tricky question: does the presence of the DFFetching flag - mean that we're fetching the latest version of the file? No. - The server could update the file as soon as the fetch responsible - for the setting of the DFFetching flag completes. - - However, the presence of the DFFetching flag (visible under - a dcache read lock since it is set and cleared only under a - dcache write lock) means that we're fetching as good a version - as was known to this client at the time of the last call to - afs_VerifyVCache, since the latter updates the stat cache's - m.DataVersion field under a vcache write lock, and from the - time that the DFFetching flag goes on in afs_GetDCache (before - the fetch starts), to the time it goes off (after the fetch - completes), afs_GetDCache keeps at least a read lock on the - vcache entry. - - This means that if the DFFetching flag is set, we can use that - data for any reads that must come from the current version of - the file (current == m.DataVersion). - - Another way of looking at this same point is this: if we're - fetching some data and then try do an afs_VerifyVCache, the - VerifyVCache operation will not complete until after the - DFFetching flag is turned off and the dcache entry's f.versionNo - field is updated. - - Note, by the way, that if DFFetching is set, - m.DataVersion > f.versionNo (the latter is not updated until - after the fetch completes). + * mean that we're fetching the latest version of the file? No. + * The server could update the file as soon as the fetch responsible + * for the setting of the DFFetching flag completes. + * + * However, the presence of the DFFetching flag (visible under + * a dcache read lock since it is set and cleared only under a + * dcache write lock) means that we're fetching as good a version + * as was known to this client at the time of the last call to + * afs_VerifyVCache, since the latter updates the stat cache's + * m.DataVersion field under a vcache write lock, and from the + * time that the DFFetching flag goes on in afs_GetDCache (before + * the fetch starts), to the time it goes off (after the fetch + * completes), afs_GetDCache keeps at least a read lock on the + * vcache entry. + * + * This means that if the DFFetching flag is set, we can use that + * data for any reads that must come from the current version of + * the file (current == m.DataVersion). + * + * Another way of looking at this same point is this: if we're + * fetching some data and then try do an afs_VerifyVCache, the + * VerifyVCache operation will not complete until after the + * DFFetching flag is turned off and the dcache entry's f.versionNo + * field is updated. + * + * Note, by the way, that if DFFetching is set, + * m.DataVersion > f.versionNo (the latter is not updated until + * after the fetch completes). */ if (tdc) { ReleaseReadLock(&tdc->lock); @@ -164,7 +169,7 @@ int afs_MemRead(register struct vcache *avc, struct uio *auio, struct AFS_UCRED && !hsame(avc->m.DataVersion, tdc->f.versionNo)) { /* have cache entry, it is not coming in now, * and we'll need new data */ -tagain: + tagain: if (trybusy && !afs_BBusy()) { struct brequest *bp; /* daemon is not busy */ @@ -174,7 +179,7 @@ tagain: UpgradeSToWLock(&tdc->mflock, 666); tdc->mflags |= DFFetchReq; bp = afs_BQueue(BOP_FETCH, avc, B_DONTWAIT, 0, acred, - (afs_size_t)filePos, (afs_size_t) 0, + (afs_size_t) filePos, (afs_size_t) 0, tdc); if (!bp) { tdc->mflags &= ~DFFetchReq; @@ -189,10 +194,9 @@ tagain: ConvertSToRLock(&tdc->mflock); while (!code && tdc->mflags & DFFetchReq) { afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_INT32, tdc->dflags); + ICL_TYPE_STRING, __FILE__, ICL_TYPE_INT32, + __LINE__, ICL_TYPE_POINTER, tdc, + ICL_TYPE_INT32, tdc->dflags); /* don't need waiting flag on this one */ ReleaseReadLock(&tdc->mflock); ReleaseReadLock(&tdc->lock); @@ -213,15 +217,14 @@ tagain: * data is now streaming in, then wait for some interesting stuff. */ code = 0; - while (!code && (tdc->dflags & DFFetching) && - tdc->validPos <= filePos) { + while (!code && (tdc->dflags & DFFetching) + && tdc->validPos <= filePos) { /* too early: wait for DFFetching flag to vanish, * or data to appear */ - afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_INT32, tdc->dflags); + afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_INT32, __LINE__, + ICL_TYPE_POINTER, tdc, ICL_TYPE_INT32, + tdc->dflags); ReleaseReadLock(&tdc->lock); ReleaseReadLock(&avc->lock); code = afs_osi_SleepSig(&tdc->validPos); @@ -239,20 +242,18 @@ tagain: * compute length and offset */ offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk); len = tdc->validPos - filePos; - } - else { + } else { /* no longer fetching, verify data version * (avoid new GetDCache call) */ - if (hsame(avc->m.DataVersion, tdc->f.versionNo) + if (hsame(avc->m.DataVersion, tdc->f.versionNo) && ((len = tdc->validPos - filePos) > 0)) { offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk); - } - else { + } else { /* don't have current data, so get it below */ afs_Trace3(afs_iclSetp, CM_TRACE_VERSIONNO, - ICL_TYPE_INT64, ICL_HANDLE_OFFSET(filePos), - ICL_TYPE_HYPER, &avc->m.DataVersion, - ICL_TYPE_HYPER, &tdc->f.versionNo); + ICL_TYPE_INT64, ICL_HANDLE_OFFSET(filePos), + ICL_TYPE_HYPER, &avc->m.DataVersion, + ICL_TYPE_HYPER, &tdc->f.versionNo); ReleaseReadLock(&tdc->lock); afs_PutDCache(tdc); tdc = NULL; @@ -260,21 +261,21 @@ tagain: } if (!tdc) { - /* If we get, it was not possible to start the - * background daemon. With flag == 1 afs_GetDCache - * does the FetchData rpc synchronously. - */ + /* If we get, it was not possible to start the + * background daemon. With flag == 1 afs_GetDCache + * does the FetchData rpc synchronously. + */ ReleaseReadLock(&avc->lock); tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 1); ObtainReadLock(&avc->lock); - if (tdc) ObtainReadLock(&tdc->lock); + if (tdc) + ObtainReadLock(&tdc->lock); } } - afs_Trace3(afs_iclSetp, CM_TRACE_VNODEREAD, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(offset), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(len)); + afs_Trace3(afs_iclSetp, CM_TRACE_VNODEREAD, ICL_TYPE_POINTER, tdc, + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(offset), + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(len)); if (!tdc) { error = EIO; break; @@ -286,15 +287,19 @@ tagain: * tdc->lock(R) */ - if (len > totalLength) len = totalLength; /* will read len bytes */ - if (len <= 0) { /* shouldn't get here if DFFetching is on */ + if (len > totalLength) + len = totalLength; /* will read len bytes */ + if (len <= 0) { /* shouldn't get here if DFFetching is on */ /* read past the end of a chunk, may not be at next chunk yet, and yet - also not at eof, so may have to supply fake zeros */ - len = AFS_CHUNKTOSIZE(tdc->f.chunk) - offset; /* bytes left in chunk addr space */ - if (len > totalLength) len = totalLength; /* and still within xfr request */ - tlen = avc->m.Length - offset; /* and still within file */ - if (len > tlen) len = tlen; - if (len > AFS_ZEROS) len = sizeof(afs_zeros); /* and in 0 buffer */ + * also not at eof, so may have to supply fake zeros */ + len = AFS_CHUNKTOSIZE(tdc->f.chunk) - offset; /* bytes left in chunk addr space */ + if (len > totalLength) + len = totalLength; /* and still within xfr request */ + tlen = avc->m.Length - offset; /* and still within file */ + if (len > tlen) + len = tlen; + if (len > AFS_ZEROS) + len = sizeof(afs_zeros); /* and in 0 buffer */ afsio_copy(auio, &tuio, tvec); trimlen = len; afsio_trim(&tuio, trimlen); @@ -303,8 +308,7 @@ tagain: error = code; break; } - } - else { + } else { /* get the data from the mem cache */ /* mung uio structure to be right for this transfer */ @@ -321,15 +325,16 @@ tagain: } } /* otherwise we've read some, fixup length, etc and continue with next seg */ - len = len - tuio.afsio_resid; /* compute amount really transferred */ + len = len - tuio.afsio_resid; /* compute amount really transferred */ trimlen = len; - afsio_skip(auio, trimlen); /* update input uio structure */ + afsio_skip(auio, trimlen); /* update input uio structure */ totalLength -= len; transferLength += len; filePos += len; - if (len <= 0) break; /* surprise eof */ - } /* the whole while loop */ + if (len <= 0) + break; /* surprise eof */ + } /* the whole while loop */ /* * Locks held: @@ -367,18 +372,20 @@ tagain: * This function must be called with the vnode at least read-locked, and * no locks on the dcache, because it plays around with dcache entries. */ -void afs_PrefetchChunk(struct vcache *avc, struct dcache *adc, - struct AFS_UCRED *acred, struct vrequest *areq) +void +afs_PrefetchChunk(struct vcache *avc, struct dcache *adc, + struct AFS_UCRED *acred, struct vrequest *areq) { register struct dcache *tdc; afs_size_t offset; - afs_size_t j1, j2; /* junk vbls for GetDCache to trash */ + afs_size_t j1, j2; /* junk vbls for GetDCache to trash */ - offset = adc->f.chunk+1; /* next chunk we'll need */ - offset = AFS_CHUNKTOBASE(offset); /* base of next chunk */ + offset = adc->f.chunk + 1; /* next chunk we'll need */ + offset = AFS_CHUNKTOBASE(offset); /* base of next chunk */ ObtainReadLock(&adc->lock); ObtainSharedLock(&adc->mflock, 662); - if (offset < avc->m.Length && !(adc->mflags & DFNextStarted) && !afs_BBusy()) { + if (offset < avc->m.Length && !(adc->mflags & DFNextStarted) + && !afs_BBusy()) { struct brequest *bp; UpgradeSToWLock(&adc->mflock, 663); @@ -428,21 +435,23 @@ void afs_PrefetchChunk(struct vcache *avc, struct dcache *adc, } } -int afs_UFSRead(register struct vcache *avc, struct uio *auio, - struct AFS_UCRED *acred, daddr_t albn, struct buf **abpp, int noLock) +int +afs_UFSRead(register struct vcache *avc, struct uio *auio, + struct AFS_UCRED *acred, daddr_t albn, struct buf **abpp, + int noLock) { afs_size_t totalLength; afs_size_t transferLength; afs_size_t filePos; afs_size_t offset, len, tlen; afs_int32 trimlen; - struct dcache *tdc=0; + struct dcache *tdc = 0; afs_int32 error; struct uio tuio; struct iovec *tvec; struct osi_file *tfile; afs_int32 code; - int trybusy=1; + int trybusy = 1; struct vrequest treq; AFS_STATCNT(afs_UFSRead); @@ -450,35 +459,36 @@ int afs_UFSRead(register struct vcache *avc, struct uio *auio, return EIO; /* check that we have the latest status info in the vnode cache */ - if ((code = afs_InitReq(&treq, acred))) return code; + if ((code = afs_InitReq(&treq, acred))) + return code; if (!noLock) { - if (!avc) - osi_Panic ("null avc in afs_UFSRead"); - else { - code = afs_VerifyVCache(avc, &treq); - if (code) { - code = afs_CheckCode(code, &treq, 11); /* failed to get it */ - return code; + if (!avc) + osi_Panic("null avc in afs_UFSRead"); + else { + code = afs_VerifyVCache(avc, &treq); + if (code) { + code = afs_CheckCode(code, &treq, 11); /* failed to get it */ + return code; + } } - } } - #ifndef AFS_VM_RDWR_ENV if (AFS_NFSXLATORREQ(acred)) { - if (!afs_AccessOK(avc, PRSFS_READ, &treq, - CHECK_MODE_BITS|CMB_ALLOW_EXEC_AS_READ)) { + if (!afs_AccessOK + (avc, PRSFS_READ, &treq, + CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) { return afs_CheckCode(EACCES, &treq, 12); } } #endif - tvec = (struct iovec *) osi_AllocSmallSpace(sizeof(struct iovec)); + tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec)); totalLength = auio->afsio_resid; filePos = auio->afsio_offset; - afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), - ICL_TYPE_INT32, totalLength, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); + afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc, + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_INT32, + totalLength, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length)); error = 0; transferLength = 0; if (!noLock) @@ -488,10 +498,11 @@ int afs_UFSRead(register struct vcache *avc, struct uio *auio, hset(avc->flushDV, avc->m.DataVersion); } #endif - + while (totalLength > 0) { /* read all of the cached info */ - if (filePos >= avc->m.Length) break; /* all done */ + if (filePos >= avc->m.Length) + break; /* all done */ if (noLock) { if (tdc) { ReleaseReadLock(&tdc->lock); @@ -505,34 +516,34 @@ int afs_UFSRead(register struct vcache *avc, struct uio *auio, } } else { /* a tricky question: does the presence of the DFFetching flag - mean that we're fetching the latest version of the file? No. - The server could update the file as soon as the fetch responsible - for the setting of the DFFetching flag completes. - - However, the presence of the DFFetching flag (visible under - a dcache read lock since it is set and cleared only under a - dcache write lock) means that we're fetching as good a version - as was known to this client at the time of the last call to - afs_VerifyVCache, since the latter updates the stat cache's - m.DataVersion field under a vcache write lock, and from the - time that the DFFetching flag goes on in afs_GetDCache (before - the fetch starts), to the time it goes off (after the fetch - completes), afs_GetDCache keeps at least a read lock on the - vcache entry. - - This means that if the DFFetching flag is set, we can use that - data for any reads that must come from the current version of - the file (current == m.DataVersion). - - Another way of looking at this same point is this: if we're - fetching some data and then try do an afs_VerifyVCache, the - VerifyVCache operation will not complete until after the - DFFetching flag is turned off and the dcache entry's f.versionNo - field is updated. - - Note, by the way, that if DFFetching is set, - m.DataVersion > f.versionNo (the latter is not updated until - after the fetch completes). + * mean that we're fetching the latest version of the file? No. + * The server could update the file as soon as the fetch responsible + * for the setting of the DFFetching flag completes. + * + * However, the presence of the DFFetching flag (visible under + * a dcache read lock since it is set and cleared only under a + * dcache write lock) means that we're fetching as good a version + * as was known to this client at the time of the last call to + * afs_VerifyVCache, since the latter updates the stat cache's + * m.DataVersion field under a vcache write lock, and from the + * time that the DFFetching flag goes on in afs_GetDCache (before + * the fetch starts), to the time it goes off (after the fetch + * completes), afs_GetDCache keeps at least a read lock on the + * vcache entry. + * + * This means that if the DFFetching flag is set, we can use that + * data for any reads that must come from the current version of + * the file (current == m.DataVersion). + * + * Another way of looking at this same point is this: if we're + * fetching some data and then try do an afs_VerifyVCache, the + * VerifyVCache operation will not complete until after the + * DFFetching flag is turned off and the dcache entry's f.versionNo + * field is updated. + * + * Note, by the way, that if DFFetching is set, + * m.DataVersion > f.versionNo (the latter is not updated until + * after the fetch completes). */ if (tdc) { ReleaseReadLock(&tdc->lock); @@ -546,7 +557,7 @@ int afs_UFSRead(register struct vcache *avc, struct uio *auio, if (!(tdc->dflags & DFFetching) && !hsame(avc->m.DataVersion, tdc->f.versionNo)) { /* have cache entry, it is not coming in now, and we'll need new data */ -tagain: + tagain: if (trybusy && !afs_BBusy()) { struct brequest *bp; /* daemon is not busy */ @@ -570,10 +581,9 @@ tagain: ConvertSToRLock(&tdc->mflock); while (!code && tdc->mflags & DFFetchReq) { afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_INT32, tdc->dflags); + ICL_TYPE_STRING, __FILE__, ICL_TYPE_INT32, + __LINE__, ICL_TYPE_POINTER, tdc, + ICL_TYPE_INT32, tdc->dflags); /* don't need waiting flag on this one */ ReleaseReadLock(&tdc->mflock); ReleaseReadLock(&tdc->lock); @@ -594,15 +604,14 @@ tagain: * data is now streaming in, then wait for some interesting stuff. */ code = 0; - while (!code && (tdc->dflags & DFFetching) && - tdc->validPos <= filePos) { + while (!code && (tdc->dflags & DFFetching) + && tdc->validPos <= filePos) { /* too early: wait for DFFetching flag to vanish, * or data to appear */ - afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_INT32, tdc->dflags); + afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_INT32, __LINE__, + ICL_TYPE_POINTER, tdc, ICL_TYPE_INT32, + tdc->dflags); ReleaseReadLock(&tdc->lock); ReleaseReadLock(&avc->lock); code = afs_osi_SleepSig(&tdc->validPos); @@ -620,20 +629,18 @@ tagain: * compute length and offset */ offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk); len = tdc->validPos - filePos; - } - else { + } else { /* no longer fetching, verify data version (avoid new * GetDCache call) */ - if (hsame(avc->m.DataVersion, tdc->f.versionNo) + if (hsame(avc->m.DataVersion, tdc->f.versionNo) && ((len = tdc->validPos - filePos) > 0)) { offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk); - } - else { + } else { /* don't have current data, so get it below */ afs_Trace3(afs_iclSetp, CM_TRACE_VERSIONNO, - ICL_TYPE_INT64, ICL_HANDLE_OFFSET(filePos), - ICL_TYPE_HYPER, &avc->m.DataVersion, - ICL_TYPE_HYPER, &tdc->f.versionNo); + ICL_TYPE_INT64, ICL_HANDLE_OFFSET(filePos), + ICL_TYPE_HYPER, &avc->m.DataVersion, + ICL_TYPE_HYPER, &tdc->f.versionNo); ReleaseReadLock(&tdc->lock); afs_PutDCache(tdc); tdc = NULL; @@ -648,33 +655,36 @@ tagain: ReleaseReadLock(&avc->lock); tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 1); ObtainReadLock(&avc->lock); - if (tdc) ObtainReadLock(&tdc->lock); + if (tdc) + ObtainReadLock(&tdc->lock); } } - + if (!tdc) { error = EIO; break; } len = tdc->validPos - filePos; - afs_Trace3(afs_iclSetp, CM_TRACE_VNODEREAD, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(offset), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(len)); - if (len > totalLength) len = totalLength; /* will read len bytes */ - if (len <= 0) { /* shouldn't get here if DFFetching is on */ - afs_Trace4(afs_iclSetp, CM_TRACE_VNODEREAD2, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(tdc->validPos), - ICL_TYPE_INT32, tdc->f.chunkBytes, - ICL_TYPE_INT32, tdc->dflags); + afs_Trace3(afs_iclSetp, CM_TRACE_VNODEREAD, ICL_TYPE_POINTER, tdc, + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(offset), + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(len)); + if (len > totalLength) + len = totalLength; /* will read len bytes */ + if (len <= 0) { /* shouldn't get here if DFFetching is on */ + afs_Trace4(afs_iclSetp, CM_TRACE_VNODEREAD2, ICL_TYPE_POINTER, + tdc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(tdc->validPos), + ICL_TYPE_INT32, tdc->f.chunkBytes, ICL_TYPE_INT32, + tdc->dflags); /* read past the end of a chunk, may not be at next chunk yet, and yet - also not at eof, so may have to supply fake zeros */ - len = AFS_CHUNKTOSIZE(tdc->f.chunk) - offset; /* bytes left in chunk addr space */ - if (len > totalLength) len = totalLength; /* and still within xfr request */ - tlen = avc->m.Length - offset; /* and still within file */ - if (len > tlen) len = tlen; - if (len > AFS_ZEROS) len = sizeof(afs_zeros); /* and in 0 buffer */ + * also not at eof, so may have to supply fake zeros */ + len = AFS_CHUNKTOSIZE(tdc->f.chunk) - offset; /* bytes left in chunk addr space */ + if (len > totalLength) + len = totalLength; /* and still within xfr request */ + tlen = avc->m.Length - offset; /* and still within file */ + if (len > tlen) + len = tlen; + if (len > AFS_ZEROS) + len = sizeof(afs_zeros); /* and in 0 buffer */ afsio_copy(auio, &tuio, tvec); trimlen = len; afsio_trim(&tuio, trimlen); @@ -683,42 +693,42 @@ tagain: error = code; break; } - } - else { + } else { /* get the data from the file */ #ifdef IHINT - if (tfile = tdc->ihint) { - if (tdc->f.inode != tfile->inum){ - afs_warn( "afs_UFSRead: %x hint mismatch tdc %d inum %d\n", - tdc, tdc->f.inode, tfile->inum ); - osi_UFSClose(tfile); + if (tfile = tdc->ihint) { + if (tdc->f.inode != tfile->inum) { + afs_warn("afs_UFSRead: %x hint mismatch tdc %d inum %d\n", + tdc, tdc->f.inode, tfile->inum); + osi_UFSClose(tfile); tdc->ihint = tfile = 0; nihints--; - } - } - if (tfile != 0) { - usedihint++; - } - else + } + } + if (tfile != 0) { + usedihint++; + } else #endif /* IHINT */ - tfile = (struct osi_file *)osi_UFSOpen(tdc->f.inode); + tfile = (struct osi_file *)osi_UFSOpen(tdc->f.inode); /* mung uio structure to be right for this transfer */ afsio_copy(auio, &tuio, tvec); trimlen = len; afsio_trim(&tuio, trimlen); tuio.afsio_offset = offset; #if defined(AFS_AIX41_ENV) - AFS_GUNLOCK(); - code = VNOP_RDWR(tfile->vnode, UIO_READ, FREAD, &tuio, NULL, NULL, - NULL, &afs_osi_cred); - AFS_GLOCK(); + AFS_GUNLOCK(); + code = + VNOP_RDWR(tfile->vnode, UIO_READ, FREAD, &tuio, NULL, NULL, + NULL, &afs_osi_cred); + AFS_GLOCK(); #elif defined(AFS_AIX32_ENV) - code = VNOP_RDWR(tfile->vnode, UIO_READ, FREAD, &tuio, NULL, NULL); - /* Flush all JFS pages now for big performance gain in big file cases - * If we do something like this, must check to be sure that AFS file - * isn't mmapped... see afs_gn_map() for why. - */ + code = + VNOP_RDWR(tfile->vnode, UIO_READ, FREAD, &tuio, NULL, NULL); + /* Flush all JFS pages now for big performance gain in big file cases + * If we do something like this, must check to be sure that AFS file + * isn't mmapped... see afs_gn_map() for why. + */ /* if (tfile->vnode->v_gnode && tfile->vnode->v_gnode->gn_seg) { many different ways to do similar things: @@ -740,13 +750,15 @@ tagain: } */ #elif defined(AFS_AIX_ENV) - code = VNOP_RDWR(tfile->vnode, UIO_READ, FREAD, (off_t)&offset, &tuio, NULL, NULL, -1); + code = + VNOP_RDWR(tfile->vnode, UIO_READ, FREAD, (off_t) & offset, + &tuio, NULL, NULL, -1); #elif defined(AFS_SUN5_ENV) - AFS_GUNLOCK(); + AFS_GUNLOCK(); VOP_RWLOCK(tfile->vnode, 0); code = VOP_READ(tfile->vnode, &tuio, 0, &afs_osi_cred); VOP_RWUNLOCK(tfile->vnode, 0); - AFS_GLOCK(); + AFS_GLOCK(); #elif defined(AFS_SGI_ENV) AFS_GUNLOCK(); AFS_VOP_RWLOCK(tfile->vnode, VRWLOCK_READ); @@ -770,35 +782,34 @@ tagain: code = osi_file_uio_rdwr(tfile, &tuio, UIO_READ); AFS_GLOCK(); #elif defined(AFS_DARWIN_ENV) - AFS_GUNLOCK(); - VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc()); - code = VOP_READ(tfile->vnode, &tuio, 0, &afs_osi_cred); - VOP_UNLOCK(tfile->vnode, 0, current_proc()); - AFS_GLOCK(); + AFS_GUNLOCK(); + VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc()); + code = VOP_READ(tfile->vnode, &tuio, 0, &afs_osi_cred); + VOP_UNLOCK(tfile->vnode, 0, current_proc()); + AFS_GLOCK(); #elif defined(AFS_FBSD50_ENV) - AFS_GUNLOCK(); - VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curthread); - code = VOP_READ(tfile->vnode, &tuio, 0, &afs_osi_cred); - VOP_UNLOCK(tfile->vnode, 0, curthread); - AFS_GLOCK(); + AFS_GUNLOCK(); + VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curthread); + code = VOP_READ(tfile->vnode, &tuio, 0, &afs_osi_cred); + VOP_UNLOCK(tfile->vnode, 0, curthread); + AFS_GLOCK(); #elif defined(AFS_XBSD_ENV) - AFS_GUNLOCK(); - VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curproc); - code = VOP_READ(tfile->vnode, &tuio, 0, &afs_osi_cred); - VOP_UNLOCK(tfile->vnode, 0, curproc); - AFS_GLOCK(); + AFS_GUNLOCK(); + VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curproc); + code = VOP_READ(tfile->vnode, &tuio, 0, &afs_osi_cred); + VOP_UNLOCK(tfile->vnode, 0, curproc); + AFS_GLOCK(); #else code = VOP_RDWR(tfile->vnode, &tuio, UIO_READ, 0, &afs_osi_cred); #endif #ifdef IHINT - if (!tdc->ihint && nihints < maxIHint) { - tdc->ihint = tfile; - nihints++; - } - else + if (!tdc->ihint && nihints < maxIHint) { + tdc->ihint = tfile; + nihints++; + } else #endif /* IHINT */ - osi_UFSClose(tfile); + osi_UFSClose(tfile); if (code) { error = code; @@ -806,13 +817,14 @@ tagain: } } /* otherwise we've read some, fixup length, etc and continue with next seg */ - len = len - tuio.afsio_resid; /* compute amount really transferred */ + len = len - tuio.afsio_resid; /* compute amount really transferred */ trimlen = len; - afsio_skip(auio, trimlen); /* update input uio structure */ + afsio_skip(auio, trimlen); /* update input uio structure */ totalLength -= len; transferLength += len; filePos += len; - if (len <= 0) break; /* surprise eof */ + if (len <= 0) + break; /* surprise eof */ } /* if we make it here with tdc non-zero, then it is the last chunk we diff --git a/src/afs/VNOPS/afs_vnop_readdir.c b/src/afs/VNOPS/afs_vnop_readdir.c index 58b38722f..e1e194468 100644 --- a/src/afs/VNOPS/afs_vnop_readdir.c +++ b/src/afs/VNOPS/afs_vnop_readdir.c @@ -22,11 +22,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -41,8 +42,8 @@ RCSID("$Header$"); * A few definitions. This is until we have a proper header file * which ahs prototypes for all functions */ - -extern struct DirEntry * afs_dir_GetBlob(); + +extern struct DirEntry *afs_dir_GetBlob(); /* * AFS readdir vnodeop and bulk stat support. */ @@ -66,12 +67,15 @@ extern struct DirEntry * afs_dir_GetBlob(); become static. */ #if defined(AFS_SGI62_ENV) || defined(AFS_SUN57_64BIT_ENV) -int BlobScan(ino64_t *afile, afs_int32 ablob) +int +BlobScan(ino64_t * afile, afs_int32 ablob) #else #ifdef AFS_LINUX_64BIT_KERNEL -int BlobScan(long *afile, afs_int32 ablob) +int +BlobScan(long *afile, afs_int32 ablob) #else -int BlobScan(afs_int32 *afile, afs_int32 ablob) +int +BlobScan(afs_int32 * afile, afs_int32 ablob) #endif #endif { @@ -83,27 +87,31 @@ int BlobScan(afs_int32 *afile, afs_int32 ablob) AFS_STATCNT(BlobScan); /* advance ablob over free and header blobs */ while (1) { - pageBlob = ablob & ~(EPP-1); /* base blob in same page */ - tpe = (struct PageHeader *) afs_dir_GetBlob(afile, pageBlob); - if (!tpe) return 0; /* we've past the end */ - relativeBlob = ablob - pageBlob; /* relative to page's first blob */ + pageBlob = ablob & ~(EPP - 1); /* base blob in same page */ + tpe = (struct PageHeader *)afs_dir_GetBlob(afile, pageBlob); + if (!tpe) + return 0; /* we've past the end */ + relativeBlob = ablob - pageBlob; /* relative to page's first blob */ /* first watch for headers */ - if (pageBlob == 0) { /* first dir page has extra-big header */ + if (pageBlob == 0) { /* first dir page has extra-big header */ /* first page */ - if (relativeBlob < DHE+1) relativeBlob = DHE+1; - } - else { /* others have one header blob */ - if (relativeBlob == 0) relativeBlob = 1; + if (relativeBlob < DHE + 1) + relativeBlob = DHE + 1; + } else { /* others have one header blob */ + if (relativeBlob == 0) + relativeBlob = 1; } /* make sure blob is allocated */ - for(i = relativeBlob; i < EPP; i++) { - if (tpe->freebitmap[i>>3] & (1<<(i&7))) break; + for (i = relativeBlob; i < EPP; i++) { + if (tpe->freebitmap[i >> 3] & (1 << (i & 7))) + break; } /* now relativeBlob is the page-relative first allocated blob, - or EPP (if there are none in this page). */ - DRelease((struct buffer *) tpe, 0); - if (i != EPP) return i+pageBlob; - ablob = pageBlob + EPP; /* go around again */ + * or EPP (if there are none in this page). */ + DRelease((struct buffer *)tpe, 0); + if (i != EPP) + return i + pageBlob; + ablob = pageBlob + EPP; /* go around again */ } /* never get here */ } @@ -122,18 +130,18 @@ int BlobScan(afs_int32 *afile, afs_int32 ablob) #if !defined(UKERNEL) #if defined(AFS_SGI_ENV) /* Long form for 64 bit apps and kernel requests. */ -struct min_dirent { /* miniature dirent structure */ - /* If struct dirent changes, this must too */ - ino_t d_fileno; /* This is 32 bits for 3.5, 64 for 6.2+ */ - off64_t d_off; - u_short d_reclen; +struct min_dirent { /* miniature dirent structure */ + /* If struct dirent changes, this must too */ + ino_t d_fileno; /* This is 32 bits for 3.5, 64 for 6.2+ */ + off64_t d_off; + u_short d_reclen; }; /* Short form for 32 bit apps. */ -struct irix5_min_dirent { /* miniature dirent structure */ - /* If struct dirent changes, this must too */ - afs_uint32 d_fileno; - afs_int32 d_off; - u_short d_reclen; +struct irix5_min_dirent { /* miniature dirent structure */ + /* If struct dirent changes, this must too */ + afs_uint32 d_fileno; + afs_int32 d_off; + u_short d_reclen; }; #ifdef AFS_SGI62_ENV #define AFS_DIRENT32BASESIZE IRIX5_DIRENTBASESIZE @@ -143,29 +151,29 @@ struct irix5_min_dirent { /* miniature dirent structure */ #define AFS_DIRENT64BASESIZE DIRENTBASESIZE #endif /* AFS_SGI62_ENV */ #else -struct min_direct { /* miniature direct structure */ - /* If struct direct changes, this must too */ +struct min_direct { /* miniature direct structure */ + /* If struct direct changes, this must too */ #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - afs_uint32 d_fileno; - u_short d_reclen; - u_char d_type; - u_char d_namlen; -#else + afs_uint32 d_fileno; + u_short d_reclen; + u_char d_type; + u_char d_namlen; +#else #ifdef AFS_SUN5_ENV - afs_uint32 d_fileno; - afs_int32 d_off; - u_short d_reclen; + afs_uint32 d_fileno; + afs_int32 d_off; + u_short d_reclen; #else #if defined(AFS_SUN_ENV) || defined(AFS_AIX32_ENV) - afs_int32 d_off; - afs_uint32 d_fileno; + afs_int32 d_off; + afs_uint32 d_fileno; #endif #if defined(AFS_HPUX100_ENV) unsigned long long d_off; - afs_uint32 d_fileno; + afs_uint32 d_fileno; #endif - u_short d_reclen; - u_short d_namlen; + u_short d_reclen; + u_short d_namlen; #endif #endif }; @@ -173,10 +181,10 @@ struct min_direct { /* miniature direct structure */ #if defined(AFS_HPUX_ENV) || defined(AFS_OSF_ENV) struct minnfs_direct { - afs_int32 d_off; /* XXX */ - afs_uint32 d_fileno; - u_short d_reclen; - u_short d_namlen; + afs_int32 d_off; /* XXX */ + afs_uint32 d_fileno; + u_short d_reclen; + u_short d_namlen; }; #define NDIRSIZ_LEN(len) ((sizeof (struct dirent)+4 - (MAXNAMLEN+1)) + (((len)+1 + DIRPAD) &~ DIRPAD)) #endif @@ -191,8 +199,8 @@ struct minnfs_direct { */ #define READDIR_STASH AFSCBMAX -struct AFSFid afs_readdir_stash[READDIR_STASH]; -int afs_rd_stash_i = 0; +struct AFSFid afs_readdir_stash[READDIR_STASH]; +int afs_rd_stash_i = 0; /* *------------------------------------------------------------------------------ @@ -231,42 +239,42 @@ int afs_rd_stash_i = 0; #endif /* AFS_DIRENT */ #endif /* AFS_SUN5_ENV */ #endif /* AFS_SUN56_ENV */ -#endif /* AFS_HPUX100_ENV */ +#endif /* AFS_HPUX100_ENV */ #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) -int afs_readdir_type(avc, ade) -struct DirEntry * ade; -struct vcache * avc; +int +afs_readdir_type(avc, ade) + struct DirEntry *ade; + struct vcache *avc; { - struct VenusFid tfid; - struct vcache *tvc; - int vtype; - tfid.Cell=avc->fid.Cell; - tfid.Fid.Volume=avc->fid.Fid.Volume; - tfid.Fid.Vnode=ntohl(ade->fid.vnode); - tfid.Fid.Unique=ntohl(ade->fid.vunique); - if ((avc->states & CForeign) == 0 && - (ntohl(ade->fid.vnode) & 1)) { - return DT_DIR; - } else if ((tvc=afs_FindVCache(&tfid,0,0))) { - if (tvc->mvstat) { - afs_PutVCache(tvc); - return DT_DIR; - } else if (((tvc->states) & (CStatd|CTruth))) { - /* CTruth will be set if the object has - *ever* been statd */ - vtype=vType(tvc); - afs_PutVCache(tvc); - if (vtype == VDIR) - return DT_DIR; - else if (vtype == VREG) - return DT_REG; - /* Don't do this until we're sure it can't be a mtpt */ - /* else if (vtype == VLNK) - type=DT_LNK; */ - /* what other types does AFS support? */ - } else - afs_PutVCache(tvc); + struct VenusFid tfid; + struct vcache *tvc; + int vtype; + tfid.Cell = avc->fid.Cell; + tfid.Fid.Volume = avc->fid.Fid.Volume; + tfid.Fid.Vnode = ntohl(ade->fid.vnode); + tfid.Fid.Unique = ntohl(ade->fid.vunique); + if ((avc->states & CForeign) == 0 && (ntohl(ade->fid.vnode) & 1)) { + return DT_DIR; + } else if ((tvc = afs_FindVCache(&tfid, 0, 0))) { + if (tvc->mvstat) { + afs_PutVCache(tvc); + return DT_DIR; + } else if (((tvc->states) & (CStatd | CTruth))) { + /* CTruth will be set if the object has + *ever* been statd */ + vtype = vType(tvc); + afs_PutVCache(tvc); + if (vtype == VDIR) + return DT_DIR; + else if (vtype == VREG) + return DT_REG; + /* Don't do this until we're sure it can't be a mtpt */ + /* else if (vtype == VLNK) + * type=DT_LNK; */ + /* what other types does AFS support? */ + } else + afs_PutVCache(tvc); } return DT_UNKNOWN; } @@ -279,20 +287,20 @@ struct vcache * avc; #define AFS_MOVE_LOCK() #define AFS_MOVE_UNLOCK() #endif -char bufofzeros[64]; /* gotta fill with something */ -afs_readdir_move (de, vc, auio, slen, rlen, off) -struct DirEntry * de; -struct vcache * vc; -struct uio * auio; -int slen; +char bufofzeros[64]; /* gotta fill with something */ +afs_readdir_move(de, vc, auio, slen, rlen, off) + struct DirEntry *de; + struct vcache *vc; + struct uio *auio; + int slen; #ifdef AFS_SGI65_ENV -ssize_t rlen; + ssize_t rlen; #else -int rlen; + int rlen; #endif -afs_size_t off; + afs_size_t off; { - int code = 0; + int code = 0; #if defined(AFS_SUN56_ENV) struct dirent64 *direntp; #else @@ -306,75 +314,86 @@ afs_size_t off; AFS_STATCNT(afs_readdir_move); #ifdef AFS_SGI53_ENV -{ - afs_int32 use64BitDirent; + { + afs_int32 use64BitDirent; #ifdef AFS_SGI61_ENV #ifdef AFS_SGI62_ENV - use64BitDirent = ABI_IS(ABI_IRIX5_64, - GETDENTS_ABI*OSI_GET_CURRENT_ABI(), auio)); + use64BitDirent = + ABI_IS(ABI_IRIX5_64, GETDENTS_ABI(OSI_GET_CURRENT_ABI(), auio)); #else - use64BitDirent = (auio->uio_segflg != UIO_USERSPACE) ? ABI_IRIX5_64 : - (ABI_IS(ABI_IRIX5_64 | ABI_IRIX5_N32, u.u_procp->p_abi)); + use64BitDirent = + (auio->uio_segflg != + UIO_USERSPACE) ? ABI_IRIX5_64 : (ABI_IS(ABI_IRIX5_64 | + ABI_IRIX5_N32, + u.u_procp->p_abi)); #endif #else /* AFS_SGI61_ENV */ - use64BitDirent = (auio->uio_segflg != UIO_USERSPACE) ? ABI_IRIX5_64 : - (ABI_IS(ABI_IRIX5_64, u.u_procp->p_abi)); + use64BitDirent = + (auio->uio_segflg != + UIO_USERSPACE) ? ABI_IRIX5_64 : (ABI_IS(ABI_IRIX5_64, + u.u_procp->p_abi)); #endif /* AFS_SGI61_ENV */ - if (use64BitDirent) { - struct min_dirent sdirEntry; - sdirEntry.d_fileno = (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode); - FIXUPSTUPIDINODE(sdirEntry.d_fileno); - sdirEntry.d_reclen = rlen; - sdirEntry.d_off = (off_t)off; - AFS_UIOMOVE(&sdirEntry, AFS_DIRENT64BASESIZE, UIO_READ, auio, code); - if (code == 0) - AFS_UIOMOVE(de->name, slen-1, UIO_READ, auio, code); - if (code == 0) - AFS_UIOMOVE(bufofzeros, - DIRENTSIZE(slen) - (AFS_DIRENT64BASESIZE + slen - 1), - UIO_READ, auio, code); - if (DIRENTSIZE(slen) < rlen) { - while(DIRENTSIZE(slen) < rlen) { - int minLen = rlen - DIRENTSIZE(slen); - if (minLen > sizeof(bufofzeros)) minLen = sizeof(bufofzeros); - AFS_UIOMOVE(bufofzeros, minLen, UIO_READ, auio, code); - rlen -= minLen; + if (use64BitDirent) { + struct min_dirent sdirEntry; + sdirEntry.d_fileno = + (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode); + FIXUPSTUPIDINODE(sdirEntry.d_fileno); + sdirEntry.d_reclen = rlen; + sdirEntry.d_off = (off_t) off; + AFS_UIOMOVE(&sdirEntry, AFS_DIRENT64BASESIZE, UIO_READ, auio, + code); + if (code == 0) + AFS_UIOMOVE(de->name, slen - 1, UIO_READ, auio, code); + if (code == 0) + AFS_UIOMOVE(bufofzeros, + DIRENTSIZE(slen) - (AFS_DIRENT64BASESIZE + slen - + 1), UIO_READ, auio, code); + if (DIRENTSIZE(slen) < rlen) { + while (DIRENTSIZE(slen) < rlen) { + int minLen = rlen - DIRENTSIZE(slen); + if (minLen > sizeof(bufofzeros)) + minLen = sizeof(bufofzeros); + AFS_UIOMOVE(bufofzeros, minLen, UIO_READ, auio, code); + rlen -= minLen; + } } - } - } else { - struct irix5_min_dirent sdirEntry; - sdirEntry.d_fileno = (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode); - FIXUPSTUPIDINODE(sdirEntry.d_fileno); - sdirEntry.d_reclen = rlen; - sdirEntry.d_off = (afs_int32)off; - AFS_UIOMOVE(&sdirEntry, AFS_DIRENT32BASESIZE, UIO_READ, auio, code); - if (code == 0) - AFS_UIOMOVE(de->name, slen-1, UIO_READ, auio, code); - if (code == 0) - AFS_UIOMOVE(bufofzeros, - IRIX5_DIRENTSIZE(slen) - - (AFS_DIRENT32BASESIZE + slen - 1), - UIO_READ, auio, code); - if (IRIX5_DIRENTSIZE(slen) < rlen) { - while(IRIX5_DIRENTSIZE(slen) < rlen) { - int minLen = rlen - IRIX5_DIRENTSIZE(slen); - if (minLen > sizeof(bufofzeros)) minLen = sizeof(bufofzeros); - AFS_UIOMOVE(bufofzeros, minLen, UIO_READ, auio, code); - rlen -= minLen; + } else { + struct irix5_min_dirent sdirEntry; + sdirEntry.d_fileno = + (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode); + FIXUPSTUPIDINODE(sdirEntry.d_fileno); + sdirEntry.d_reclen = rlen; + sdirEntry.d_off = (afs_int32) off; + AFS_UIOMOVE(&sdirEntry, AFS_DIRENT32BASESIZE, UIO_READ, auio, + code); + if (code == 0) + AFS_UIOMOVE(de->name, slen - 1, UIO_READ, auio, code); + if (code == 0) + AFS_UIOMOVE(bufofzeros, + IRIX5_DIRENTSIZE(slen) - (AFS_DIRENT32BASESIZE + + slen - 1), UIO_READ, + auio, code); + if (IRIX5_DIRENTSIZE(slen) < rlen) { + while (IRIX5_DIRENTSIZE(slen) < rlen) { + int minLen = rlen - IRIX5_DIRENTSIZE(slen); + if (minLen > sizeof(bufofzeros)) + minLen = sizeof(bufofzeros); + AFS_UIOMOVE(bufofzeros, minLen, UIO_READ, auio, code); + rlen -= minLen; + } } } } -} #else /* AFS_SGI53_ENV */ #if defined(AFS_SUN5_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) #if defined(AFS_SUN56_ENV) - direntp = (struct dirent64 *) osi_AllocLargeSpace(AFS_LRALLOCSIZ); + direntp = (struct dirent64 *)osi_AllocLargeSpace(AFS_LRALLOCSIZ); #else - direntp = (struct dirent *) osi_AllocLargeSpace(AFS_LRALLOCSIZ); + direntp = (struct dirent *)osi_AllocLargeSpace(AFS_LRALLOCSIZ); #endif - direntp->d_ino = (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode); + direntp->d_ino = (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode); FIXUPSTUPIDINODE(direntp->d_ino); #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) direntp->d_offset = off; @@ -384,12 +403,11 @@ afs_size_t off; #endif direntp->d_reclen = rlen; strcpy(direntp->d_name, de->name); - AFS_UIOMOVE((caddr_t)direntp, rlen, UIO_READ, auio, code); + AFS_UIOMOVE((caddr_t) direntp, rlen, UIO_READ, auio, code); osi_FreeLargeSpace((char *)direntp); #else /* AFS_SUN5_ENV */ /* Note the odd mechanism for building the inode number */ - sdirEntry.d_fileno = (vc->fid.Fid.Volume << 16) + - ntohl(de->fid.vnode); + sdirEntry.d_fileno = (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode); FIXUPSTUPIDINODE(sdirEntry.d_fileno); sdirEntry.d_reclen = rlen; #if !defined(AFS_SGI_ENV) @@ -399,15 +417,17 @@ afs_size_t off; sdirEntry.d_off = off; #endif #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - sdirEntry.d_type=afs_readdir_type(vc, de); + sdirEntry.d_type = afs_readdir_type(vc, de); #endif #if defined(AFS_SGI_ENV) AFS_UIOMOVE(&sdirEntry, DIRENTBASESIZE, UIO_READ, auio, code); if (code == 0) - AFS_UIOMOVE(de->name, slen-1, UIO_READ, auio, code); + AFS_UIOMOVE(de->name, slen - 1, UIO_READ, auio, code); if (code == 0) - AFS_UIOMOVE(bufofzeros, DIRSIZ_LEN(slen) - (DIRENTBASESIZE + slen - 1), UIO_READ, auio, code); + AFS_UIOMOVE(bufofzeros, + DIRSIZ_LEN(slen) - (DIRENTBASESIZE + slen - 1), UIO_READ, + auio, code); #else /* AFS_SGI_ENV */ AFS_MOVE_UNLOCK(); AFS_UIOMOVE((char *)&sdirEntry, sizeof(sdirEntry), UIO_READ, auio, code); @@ -417,30 +437,28 @@ afs_size_t off; } /* pad out the remaining characters with zeros */ - if (code == 0) { - AFS_UIOMOVE(bufofzeros, ((slen + 1 + DIRPAD) & ~DIRPAD) - slen, UIO_READ, - auio, code); + if (code == 0) { + AFS_UIOMOVE(bufofzeros, ((slen + 1 + DIRPAD) & ~DIRPAD) - slen, + UIO_READ, auio, code); } AFS_MOVE_LOCK(); #endif /* AFS_SGI_ENV */ /* pad out the difference between rlen and slen... */ - if (DIRSIZ_LEN(slen) < rlen) - { + if (DIRSIZ_LEN(slen) < rlen) { AFS_MOVE_UNLOCK(); - while(DIRSIZ_LEN(slen) < rlen) - { - int minLen = rlen - DIRSIZ_LEN(slen); - if (minLen > sizeof(bufofzeros)) - minLen = sizeof(bufofzeros); - AFS_UIOMOVE(bufofzeros, minLen, UIO_READ, auio, code); - rlen -= minLen; - } - AFS_MOVE_LOCK(); + while (DIRSIZ_LEN(slen) < rlen) { + int minLen = rlen - DIRSIZ_LEN(slen); + if (minLen > sizeof(bufofzeros)) + minLen = sizeof(bufofzeros); + AFS_UIOMOVE(bufofzeros, minLen, UIO_READ, auio, code); + rlen -= minLen; } -#endif /* AFS_SUN5_ENV */ -#endif /* AFS_SGI53_ENV */ - return(code); + AFS_MOVE_LOCK(); + } +#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SGI53_ENV */ + return (code); } @@ -460,9 +478,10 @@ afs_size_t off; * This routine encodes knowledge of Vice dirs. */ -void afs_bulkstat_send( avc, req ) - struct vcache * avc; - struct vrequest * req; +void +afs_bulkstat_send(avc, req) + struct vcache *avc; + struct vrequest *req; { afs_rd_stash_i = 0; } @@ -474,17 +493,17 @@ void afs_bulkstat_send( avc, req ) #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) afs_readdir(OSI_VC_ARG(avc), auio, acred, eofp) - int *eofp; + int *eofp; #else -#if defined(AFS_HPUX100_ENV) +#if defined(AFS_HPUX100_ENV) afs_readdir2(OSI_VC_ARG(avc), auio, acred) #else afs_readdir(OSI_VC_ARG(avc), auio, acred) -#endif +#endif #endif OSI_VC_DECL(avc); - struct uio *auio; - struct AFS_UCRED *acred; + struct uio *auio; + struct AFS_UCRED *acred; { struct vrequest treq; register struct dcache *tdc; @@ -500,44 +519,50 @@ afs_readdir(OSI_VC_ARG(avc), auio, acred) #endif /* defined(AFS_SGI53_ENV) */ OSI_VC_CONVERT(avc) #ifdef AFS_HPUX_ENV - /* - * XXX All the hacks for alloced sdirEntry and inlining of afs_readdir_move instead of calling - * it is necessary for hpux due to stack problems that seem to occur when coming thru the nfs - * translator side XXX - */ - struct min_direct *sdirEntry = (struct min_direct *)osi_AllocSmallSpace(sizeof(struct min_direct)); + /* + * XXX All the hacks for alloced sdirEntry and inlining of afs_readdir_move instead of calling + * it is necessary for hpux due to stack problems that seem to occur when coming thru the nfs + * translator side XXX + */ + struct min_direct *sdirEntry = + (struct min_direct *)osi_AllocSmallSpace(sizeof(struct min_direct)); afs_int32 rlen; #endif /* opaque value is pointer into a vice dir; use bit map to decide - if the entries are in use. Always assumed to be valid. 0 is - special, means start of a new dir. Int32 inode, followed by - short reclen and short namelen. Namelen does not include - the null byte. Followed by null-terminated string. - */ + * if the entries are in use. Always assumed to be valid. 0 is + * special, means start of a new dir. Int32 inode, followed by + * short reclen and short namelen. Namelen does not include + * the null byte. Followed by null-terminated string. + */ AFS_STATCNT(afs_readdir); #if defined(AFS_SGI53_ENV) #ifdef AFS_SGI61_ENV #ifdef AFS_SGI62_ENV - use64BitDirent = ABI_IS(ABI_IRIX5_64, - GETDENTS_ABI(OSI_GET_CURRENT_ABI(), auio)); + use64BitDirent = + ABI_IS(ABI_IRIX5_64, GETDENTS_ABI(OSI_GET_CURRENT_ABI(), auio)); #else - use64BitDirent = (auio->uio_segflg != UIO_USERSPACE) ? ABI_IRIX5_64 : - (ABI_IS(ABI_IRIX5_64 | ABI_IRIX5_N32, u.u_procp->p_abi)); + use64BitDirent = + (auio->uio_segflg != + UIO_USERSPACE) ? ABI_IRIX5_64 : (ABI_IS(ABI_IRIX5_64 | ABI_IRIX5_N32, + u.u_procp->p_abi)); #endif /* AFS_SGI62_ENV */ #else /* AFS_SGI61_ENV */ - use64BitDirent = (auio->uio_segflg != UIO_USERSPACE) ? ABI_IRIX5_64 : - (ABI_IS(ABI_IRIX5_64, u.u_procp->p_abi)); + use64BitDirent = + (auio->uio_segflg != + UIO_USERSPACE) ? ABI_IRIX5_64 : (ABI_IS(ABI_IRIX5_64, + u.u_procp->p_abi)); #endif /* AFS_SGI61_ENV */ #endif /* defined(AFS_SGI53_ENV) */ #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) /* Not really used by the callee so we ignore it for now */ - if (eofp) *eofp = 0; + if (eofp) + *eofp = 0; #endif - if ( AfsLargeFileUio(auio) /* file is large than 2 GB */ - || AfsLargeFileSize(auio->uio_offset, auio->uio_resid) ) + if (AfsLargeFileUio(auio) /* file is large than 2 GB */ + ||AfsLargeFileSize(auio->uio_offset, auio->uio_resid)) return EFBIG; if ((code = afs_InitReq(&treq, acred))) { @@ -549,10 +574,12 @@ afs_readdir(OSI_VC_ARG(avc), auio, acred) /* update the cache entry */ afs_InitFakeStat(&fakestate); code = afs_EvalFakeStat(&avc, &fakestate, &treq); - if (code) goto done; -tagain: + if (code) + goto done; + tagain: code = afs_VerifyVCache(avc, &treq); - if (code) goto done; + if (code) + goto done; /* get a reference to the entire directory */ tdc = afs_GetDCache(avc, (afs_size_t) 0, &treq, &origOffset, &tlen, 1); len = tlen; @@ -572,11 +599,9 @@ tagain: while ((avc->states & CStatd) && (tdc->dflags & DFFetching) && hsame(avc->m.DataVersion, tdc->f.versionNo)) { - afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_INT32, tdc->dflags); + afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_INT32, __LINE__, ICL_TYPE_POINTER, tdc, + ICL_TYPE_INT32, tdc->dflags); ReleaseReadLock(&tdc->lock); ReleaseReadLock(&avc->lock); afs_osi_Sleep(&tdc->validPos); @@ -592,61 +617,65 @@ tagain: } /* - * iterator for the directory reads. Takes the AFS DirEntry - * structure and slams them into UFS direct structures. - * uses afs_readdir_move to get the struct to the user space. + * iterator for the directory reads. Takes the AFS DirEntry + * structure and slams them into UFS direct structures. + * uses afs_readdir_move to get the struct to the user space. * - * The routine works by looking ahead one AFS directory entry. - * That's because the AFS entry we are currenly working with - * may not fit into the buffer the user has provided. If it - * doesn't we have to change the size of the LAST AFS directory - * entry, so that it will FIT perfectly into the block the - * user has provided. - * - * The 'forward looking' of the code makes it a bit tough to read. - * Remember we need to get an entry, see if it it fits, then - * set it up as the LAST entry, and find the next one. + * The routine works by looking ahead one AFS directory entry. + * That's because the AFS entry we are currenly working with + * may not fit into the buffer the user has provided. If it + * doesn't we have to change the size of the LAST AFS directory + * entry, so that it will FIT perfectly into the block the + * user has provided. + * + * The 'forward looking' of the code makes it a bit tough to read. + * Remember we need to get an entry, see if it it fits, then + * set it up as the LAST entry, and find the next one. * - * Tough to take: We give out an EINVAL if we don't have enough - * space in the buffer, and at the same time, don't have an entry - * to put into the buffer. This CAN happen if the first AFS entry - * we get can't fit into the 512 character buffer provided. Seems - * it ought not happen... + * Tough to take: We give out an EINVAL if we don't have enough + * space in the buffer, and at the same time, don't have an entry + * to put into the buffer. This CAN happen if the first AFS entry + * we get can't fit into the 512 character buffer provided. Seems + * it ought not happen... * - * Assumption: don't need to use anything but one dc entry: - * this means the directory ought not be greater than 64k. + * Assumption: don't need to use anything but one dc entry: + * this means the directory ought not be greater than 64k. */ len = 0; #ifdef AFS_HPUX_ENV auio->uio_fpflags = 0; #endif - while (code==0) { + while (code == 0) { origOffset = auio->afsio_offset; /* scan for the next interesting entry scan for in-use blob otherwise up point at * this blob note that ode, if non-zero, also represents a held dir page */ - if (!(us = BlobScan(&tdc->f.inode, (origOffset >> 5)) ) - || !(nde = (struct DirEntry *) afs_dir_GetBlob(&tdc->f.inode, us) ) ) { + if (!(us = BlobScan(&tdc->f.inode, (origOffset >> 5))) + || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f.inode, us))) { /* failed to setup nde, return what we've got, and release ode */ if (len) { /* something to hand over. */ #ifdef AFS_HPUX_ENV - sdirEntry->d_fileno = (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); + sdirEntry->d_fileno = + (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); FIXUPSTUPIDINODE(sdirEntry->d_fileno); sdirEntry->d_reclen = rlen = auio->afsio_resid; sdirEntry->d_namlen = o_slen; #if defined(AFS_SUN_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV) sdirEntry->d_off = origOffset; #endif - AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, auio, code); + AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, + auio, code); if (code == 0) AFS_UIOMOVE(ode->name, o_slen, UIO_READ, auio, code); /* pad out the remaining characters with zeros */ if (code == 0) { - AFS_UIOMOVE(bufofzeros, ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, UIO_READ, auio, code); + AFS_UIOMOVE(bufofzeros, + ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, + UIO_READ, auio, code); } /* pad out the difference between rlen and slen... */ if (DIRSIZ_LEN(o_slen) < rlen) { - while(DIRSIZ_LEN(o_slen) < rlen) { + while (DIRSIZ_LEN(o_slen) < rlen) { int minLen = rlen - DIRSIZ_LEN(o_slen); if (minLen > sizeof(bufofzeros)) minLen = sizeof(bufofzeros); @@ -657,7 +686,7 @@ tagain: #else code = afs_readdir_move(ode, avc, auio, o_slen, #if defined(AFS_SUN5_ENV) - len, origOffset); + len, origOffset); #else auio->afsio_resid, origOffset); #endif @@ -669,9 +698,11 @@ tagain: /* nothin to hand over */ } #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - if (eofp) *eofp = 1; /* Set it properly */ + if (eofp) + *eofp = 1; /* Set it properly */ #endif - if (ode) DRelease((struct buffer *) ode, 0); + if (ode) + DRelease((struct buffer *)ode, 0); goto dirend; } /* by here nde is set */ @@ -683,33 +714,37 @@ tagain: n_slen = strlen(nde->name); #endif #ifdef AFS_SGI53_ENV - dirsiz = use64BitDirent ? DIRENTSIZE(n_slen) : - IRIX5_DIRENTSIZE(n_slen); - if (dirsiz >= (auio->afsio_resid-len)) { + dirsiz = + use64BitDirent ? DIRENTSIZE(n_slen) : IRIX5_DIRENTSIZE(n_slen); + if (dirsiz >= (auio->afsio_resid - len)) { #else - if (DIRSIZ_LEN(n_slen) >= (auio->afsio_resid-len)) { + if (DIRSIZ_LEN(n_slen) >= (auio->afsio_resid - len)) { #endif /* AFS_SGI53_ENV */ /* No can do no more now; ya know... at this time */ - DRelease ((struct buffer *) nde, 0); /* can't use this one. */ + DRelease((struct buffer *)nde, 0); /* can't use this one. */ if (len) { #ifdef AFS_HPUX_ENV - sdirEntry->d_fileno = (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); + sdirEntry->d_fileno = + (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); FIXUPSTUPIDINODE(sdirEntry->d_fileno); sdirEntry->d_reclen = rlen = auio->afsio_resid; sdirEntry->d_namlen = o_slen; #if defined(AFS_SUN_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV) sdirEntry->d_off = origOffset; #endif - AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, auio, code); + AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, + auio, code); if (code == 0) AFS_UIOMOVE(ode->name, o_slen, UIO_READ, auio, code); /* pad out the remaining characters with zeros */ if (code == 0) { - AFS_UIOMOVE(bufofzeros, ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, UIO_READ, auio, code); + AFS_UIOMOVE(bufofzeros, + ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, + UIO_READ, auio, code); } /* pad out the difference between rlen and slen... */ if (DIRSIZ_LEN(o_slen) < rlen) { - while(DIRSIZ_LEN(o_slen) < rlen) { + while (DIRSIZ_LEN(o_slen) < rlen) { int minLen = rlen - DIRSIZ_LEN(o_slen); if (minLen > sizeof(bufofzeros)) minLen = sizeof(bufofzeros); @@ -718,21 +753,23 @@ tagain: } } #else /* AFS_HPUX_ENV */ - code = afs_readdir_move(ode, avc, auio, o_slen, - auio->afsio_resid, origOffset); + code = + afs_readdir_move(ode, avc, auio, o_slen, + auio->afsio_resid, origOffset); #endif /* AFS_HPUX_ENV */ /* this next line used to be AFSVFS40 or AIX 3.1, but is * really generic */ auio->afsio_offset = origOffset; - auio->afsio_resid = 0; - } else { /* trouble, can't give anything to the user! */ + auio->afsio_resid = 0; + } else { /* trouble, can't give anything to the user! */ /* even though he has given us a buffer, * even though we have something to give us, * Looks like we lost something somewhere. */ code = EINVAL; } - if (ode) DRelease((struct buffer *) ode, 0); + if (ode) + DRelease((struct buffer *)ode, 0); goto dirend; } @@ -750,18 +787,19 @@ tagain: #if defined(AFS_SUN_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_HPUX100_ENV) sdirEntry->d_off = origOffset; #endif - AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, - auio, code); + AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, auio, + code); if (code == 0) AFS_UIOMOVE(ode->name, o_slen, UIO_READ, auio, code); /* pad out the remaining characters with zeros */ if (code == 0) { - AFS_UIOMOVE(bufofzeros, ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, + AFS_UIOMOVE(bufofzeros, + ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, UIO_READ, auio, code); } /* pad out the difference between rlen and slen... */ if (DIRSIZ_LEN(o_slen) < rlen) { - while(DIRSIZ_LEN(o_slen) < rlen) { + while (DIRSIZ_LEN(o_slen) < rlen) { int minLen = rlen - DIRSIZ_LEN(o_slen); if (minLen > sizeof(bufofzeros)) minLen = sizeof(bufofzeros); @@ -770,27 +808,31 @@ tagain: } } #else /* AFS_HPUX_ENV */ - code = afs_readdir_move (ode, avc, auio, o_slen, len, origOffset); + code = afs_readdir_move(ode, avc, auio, o_slen, len, origOffset); #endif /* AFS_HPUX_ENV */ } #ifdef AFS_SGI53_ENV - len = use64BitDirent ? DIRENTSIZE(o_slen = n_slen) : - IRIX5_DIRENTSIZE(o_slen = n_slen); + len = use64BitDirent ? DIRENTSIZE(o_slen = + n_slen) : IRIX5_DIRENTSIZE(o_slen = + n_slen); #else - len = DIRSIZ_LEN( o_slen = n_slen ); + len = DIRSIZ_LEN(o_slen = n_slen); #endif /* AFS_SGI53_ENV */ - if (ode) DRelease((struct buffer *) ode, 0); + if (ode) + DRelease((struct buffer *)ode, 0); ode = nde; - auio->afsio_offset = (afs_int32)((us + afs_dir_NameBlobs(nde->name)) << 5); + auio->afsio_offset = + (afs_int32) ((us + afs_dir_NameBlobs(nde->name)) << 5); } - if (ode) DRelease((struct buffer *) ode, 0); + if (ode) + DRelease((struct buffer *)ode, 0); -dirend: + dirend: ReleaseReadLock(&tdc->lock); afs_PutDCache(tdc); ReleaseReadLock(&avc->lock); -done: + done: #ifdef AFS_HPUX_ENV osi_FreeSmallSpace((char *)sdirEntry); #endif @@ -802,13 +844,14 @@ done: #if defined(AFS_HPUX_ENV) || defined(AFS_OSF_ENV) #ifdef AFS_OSF_ENV afs1_readdir(avc, auio, acred, eofp) - int *eofp; + int *eofp; #else afs1_readdir(avc, auio, acred) #endif - struct vcache *avc; - struct uio *auio; - struct AFS_UCRED *acred; { + struct vcache *avc; + struct uio *auio; + struct AFS_UCRED *acred; +{ struct vrequest treq; register struct dcache *tdc; afs_size_t origOffset, len; @@ -822,14 +865,16 @@ afs1_readdir(avc, auio, acred) * it is necessary for hpux due to stack problems that seem to occur when coming thru the nfs * translator side XXX */ - struct minnfs_direct *sdirEntry = (struct minnfs_direct *)osi_AllocSmallSpace(sizeof(struct min_direct)); + struct minnfs_direct *sdirEntry = (struct minnfs_direct *) + osi_AllocSmallSpace(sizeof(struct min_direct)); afs_int32 rlen; #endif struct afs_fakestat_state fakestate; AFS_STATCNT(afs_readdir); #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) - if (eofp) *eofp = 0; + if (eofp) + *eofp = 0; #endif if (code = afs_InitReq(&treq, acred)) { #ifdef AFS_HPUX_ENV @@ -847,9 +892,10 @@ afs1_readdir(avc, auio, acred) return code; } /* update the cache entry */ -tagain: + tagain: code = afs_VerifyVCache(avc, &treq); - if (code) goto done; + if (code) + goto done; /* get a reference to the entire directory */ tdc = afs_GetDCache(avc, (afs_size_t) 0, &treq, &origOffset, &len, 1); if (!tdc) { @@ -868,11 +914,9 @@ tagain: while ((avc->states & CStatd) && (tdc->dflags & DFFetching) && hsame(avc->m.DataVersion, tdc->f.versionNo)) { - afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_INT32, tdc->dflags); + afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_INT32, __LINE__, ICL_TYPE_POINTER, tdc, + ICL_TYPE_INT32, tdc->dflags); ReleaseReadLock(&tdc->lock); ReleaseReadLock(&avc->lock); afs_osi_Sleep(&tdc->validPos); @@ -891,34 +935,38 @@ tagain: #ifdef AFS_HPUX_ENV auio->uio_fpflags = 0; #endif - while (code==0) { + while (code == 0) { origOffset = auio->afsio_offset; /* scan for the next interesting entry scan for in-use blob otherwise up point at * this blob note that ode, if non-zero, also represents a held dir page */ - if (!(us = BlobScan(&tdc->f.inode, (origOffset >> 5)) ) - || !(nde = (struct DirEntry *) afs_dir_GetBlob(&tdc->f.inode, us) ) ) { + if (!(us = BlobScan(&tdc->f.inode, (origOffset >> 5))) + || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f.inode, us))) { /* failed to setup nde, return what we've got, and release ode */ if (len) { /* something to hand over. */ #if defined(AFS_HPUX_ENV) || defined(AFS_OSF_ENV) - sdirEntry->d_fileno = (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); + sdirEntry->d_fileno = + (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); FIXUPSTUPIDINODE(sdirEntry->d_fileno); sdirEntry->d_reclen = rlen = auio->afsio_resid; sdirEntry->d_namlen = o_slen; sdirEntry->d_off = origOffset; - AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, auio, code); + AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, + auio, code); if (code == 0) { AFS_UIOMOVE(ode->name, o_slen, UIO_READ, auio, code); } /* pad out the remaining characters with zeros */ if (code == 0) { - AFS_UIOMOVE(bufofzeros, ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, UIO_READ, auio, code); + AFS_UIOMOVE(bufofzeros, + ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, + UIO_READ, auio, code); } /* pad out the difference between rlen and slen... */ if (NDIRSIZ_LEN(o_slen) < rlen) { - while(NDIRSIZ_LEN(o_slen) < rlen) { - int minLen = rlen - NDIRSIZ_LEN(o_slen); + while (NDIRSIZ_LEN(o_slen) < rlen) { + int minLen = rlen - NDIRSIZ_LEN(o_slen); if (minLen > sizeof(bufofzeros)) minLen = sizeof(bufofzeros); AFS_UIOMOVE(bufofzeros, minLen, UIO_READ, auio, code); @@ -926,17 +974,20 @@ tagain: } } #else - code = afs_readdir_move(ode, avc, auio, o_slen, - auio->afsio_resid, origOffset); + code = + afs_readdir_move(ode, avc, auio, o_slen, + auio->afsio_resid, origOffset); #endif /* AFS_HPUX_ENV */ - auio->afsio_resid = 0; + auio->afsio_resid = 0; } else { /* nothin to hand over */ } #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) - if (eofp) *eofp = 1; + if (eofp) + *eofp = 1; #endif - if (ode) DRelease(ode, 0); + if (ode) + DRelease(ode, 0); goto dirend; } /* by here nde is set */ @@ -947,26 +998,30 @@ tagain: #else n_slen = strlen(nde->name); #endif - if (NDIRSIZ_LEN(n_slen) >= (auio->afsio_resid-len)) { + if (NDIRSIZ_LEN(n_slen) >= (auio->afsio_resid - len)) { /* No can do no more now; ya know... at this time */ - DRelease (nde, 0); /* can't use this one. */ + DRelease(nde, 0); /* can't use this one. */ if (len) { #if defined(AFS_HPUX_ENV) || defined(AFS_OSF_ENV) - sdirEntry->d_fileno = (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); + sdirEntry->d_fileno = + (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); FIXUPSTUPIDINODE(sdirEntry->d_fileno); sdirEntry->d_reclen = rlen = auio->afsio_resid; sdirEntry->d_namlen = o_slen; sdirEntry->d_off = origOffset; - AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, auio, code); + AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, + auio, code); if (code == 0) AFS_UIOMOVE(ode->name, o_slen, UIO_READ, auio, code); /* pad out the remaining characters with zeros */ if (code == 0) { - AFS_UIOMOVE(bufofzeros, ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, UIO_READ, auio, code); + AFS_UIOMOVE(bufofzeros, + ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, + UIO_READ, auio, code); } /* pad out the difference between rlen and slen... */ if (NDIRSIZ_LEN(o_slen) < rlen) { - while(NDIRSIZ_LEN(o_slen) < rlen) { + while (NDIRSIZ_LEN(o_slen) < rlen) { int minLen = rlen - NDIRSIZ_LEN(o_slen); if (minLen > sizeof(bufofzeros)) minLen = sizeof(bufofzeros); @@ -975,20 +1030,22 @@ tagain: } } #else - code = afs_readdir_move(ode, avc, auio, o_slen, - auio->afsio_resid, origOffset); + code = + afs_readdir_move(ode, avc, auio, o_slen, + auio->afsio_resid, origOffset); #endif /* AFS_HPUX_ENV */ /* this next line used to be AFSVFS40 or AIX 3.1, but is really generic */ auio->afsio_offset = origOffset; - auio->afsio_resid = 0; - } else { /* trouble, can't give anything to the user! */ + auio->afsio_resid = 0; + } else { /* trouble, can't give anything to the user! */ /* even though he has given us a buffer, * even though we have something to give us, * Looks like we lost something somewhere. */ code = EINVAL; } - if (ode) DRelease(ode, 0); + if (ode) + DRelease(ode, 0); goto dirend; } @@ -998,21 +1055,25 @@ tagain: */ if (len) { #if defined(AFS_HPUX_ENV) || defined(AFS_OSF_ENV) - sdirEntry->d_fileno = (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); + sdirEntry->d_fileno = + (avc->fid.Fid.Volume << 16) + ntohl(ode->fid.vnode); FIXUPSTUPIDINODE(sdirEntry->d_fileno); sdirEntry->d_reclen = rlen = len; sdirEntry->d_namlen = o_slen; sdirEntry->d_off = origOffset; - AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, auio, code); + AFS_UIOMOVE((char *)sdirEntry, sizeof(*sdirEntry), UIO_READ, auio, + code); if (code == 0) AFS_UIOMOVE(ode->name, o_slen, UIO_READ, auio, code); /* pad out the remaining characters with zeros */ if (code == 0) { - AFS_UIOMOVE(bufofzeros, ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, UIO_READ, auio, code); + AFS_UIOMOVE(bufofzeros, + ((o_slen + 1 + DIRPAD) & ~DIRPAD) - o_slen, + UIO_READ, auio, code); } /* pad out the difference between rlen and slen... */ if (NDIRSIZ_LEN(o_slen) < rlen) { - while(NDIRSIZ_LEN(o_slen) < rlen) { + while (NDIRSIZ_LEN(o_slen) < rlen) { int minLen = rlen - NDIRSIZ_LEN(o_slen); if (minLen > sizeof(bufofzeros)) minLen = sizeof(bufofzeros); @@ -1021,22 +1082,24 @@ tagain: } } #else - code = afs_readdir_move (ode, avc, auio, o_slen, len, origOffset); + code = afs_readdir_move(ode, avc, auio, o_slen, len, origOffset); #endif /* AFS_HPUX_ENV */ } - len = NDIRSIZ_LEN( o_slen = n_slen ); - if (ode) DRelease(ode, 0); + len = NDIRSIZ_LEN(o_slen = n_slen); + if (ode) + DRelease(ode, 0); ode = nde; auio->afsio_offset = ((us + afs_dir_NameBlobs(nde->name)) << 5); } - if (ode) DRelease(ode, 0); + if (ode) + DRelease(ode, 0); -dirend: + dirend: ReleaseReadLock(&tdc->lock); afs_PutDCache(tdc); ReleaseReadLock(&avc->lock); -done: + done: #if defined(AFS_HPUX_ENV) || defined(AFS_OSF_ENV) osi_FreeSmallSpace((char *)sdirEntry); #endif diff --git a/src/afs/VNOPS/afs_vnop_remove.c b/src/afs/VNOPS/afs_vnop_remove.c index 95d17c956..65e4c0006 100644 --- a/src/afs/VNOPS/afs_vnop_remove.c +++ b/src/afs/VNOPS/afs_vnop_remove.c @@ -22,11 +22,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -45,36 +46,41 @@ extern afs_rwlock_t afs_xcbhash; * afs_IsWired notices that the file is no longer Active. */ afs_Wire(avc, areq) -#else /* AFS_OSF_ENV */ -static void FetchWholeEnchilada(avc, areq) +#else /* AFS_OSF_ENV */ +static void +FetchWholeEnchilada(avc, areq) #endif -struct vrequest *areq; -register struct vcache *avc; { + struct vrequest *areq; + register struct vcache *avc; +{ register afs_int32 nextChunk; register struct dcache *tdc; afs_size_t pos, offset, len; AFS_STATCNT(FetchWholeEnchilada); - if ((avc->states & CStatd) == 0) return; /* don't know size */ - for(nextChunk=0;nextChunk<1024;nextChunk++) { /* sanity check on N chunks */ + if ((avc->states & CStatd) == 0) + return; /* don't know size */ + for (nextChunk = 0; nextChunk < 1024; nextChunk++) { /* sanity check on N chunks */ pos = AFS_CHUNKTOBASE(nextChunk); #if defined(AFS_OSF_ENV) - if (pos >= avc->m.Length) break; /* all done */ -#else /* AFS_OSF_ENV */ - if (pos >= avc->m.Length) return; /* all done */ + if (pos >= avc->m.Length) + break; /* all done */ +#else /* AFS_OSF_ENV */ + if (pos >= avc->m.Length) + return; /* all done */ #endif tdc = afs_GetDCache(avc, pos, areq, &offset, &len, 0); - if (!tdc) + if (!tdc) #if defined(AFS_OSF_ENV) break; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ return; #endif afs_PutDCache(tdc); } #if defined(AFS_OSF_ENV) avc->states |= CWired; -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ } #if defined(AFS_OSF_ENV) @@ -83,7 +89,8 @@ register struct vcache *avc; { * is found to be inactive (ie not open and not being paged from). */ afs_IsWired(avc) - register struct vcache *avc; { + register struct vcache *avc; +{ if (avc->states & CWired) { if (osi_Active(avc)) { return 1; @@ -92,55 +99,59 @@ afs_IsWired(avc) } return 0; } -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ -int afsremove(register struct vcache *adp, register struct dcache *tdc, - register struct vcache *tvc, char *aname, struct AFS_UCRED *acred, - struct vrequest *treqp) +int +afsremove(register struct vcache *adp, register struct dcache *tdc, + register struct vcache *tvc, char *aname, struct AFS_UCRED *acred, + struct vrequest *treqp) { register afs_int32 code; register struct conn *tc; struct AFSFetchStatus OutDirStatus; struct AFSVolSync tsync; XSTATS_DECLS - do { tc = afs_Conn(&adp->fid, treqp, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEFILE); + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEFILE); RX_AFS_GUNLOCK(); - code = RXAFS_RemoveFile(tc->id, (struct AFSFid *) &adp->fid.Fid, - aname, &OutDirStatus, &tsync); + code = + RXAFS_RemoveFile(tc->id, (struct AFSFid *)&adp->fid.Fid, + aname, &OutDirStatus, &tsync); RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &adp->fid, treqp, - AFS_STATS_FS_RPCIDX_REMOVEFILE, SHARED_LOCK, NULL)); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &adp->fid, treqp, AFS_STATS_FS_RPCIDX_REMOVEFILE, + SHARED_LOCK, NULL)); - osi_dnlc_remove (adp, aname, tvc); - if (tvc) afs_symhint_inval(tvc); /* XXX: don't really need to be so extreme */ + osi_dnlc_remove(adp, aname, tvc); + if (tvc) + afs_symhint_inval(tvc); /* XXX: don't really need to be so extreme */ if (code) { if (tdc) { ReleaseSharedLock(&tdc->lock); afs_PutDCache(tdc); } - if (tvc) afs_PutVCache(tvc); + if (tvc) + afs_PutVCache(tvc); if (code < 0) { - ObtainWriteLock(&afs_xcbhash, 497); - afs_DequeueCallback(adp); - adp->states &= ~CStatd; - ReleaseWriteLock(&afs_xcbhash); - osi_dnlc_purgedp(adp); + ObtainWriteLock(&afs_xcbhash, 497); + afs_DequeueCallback(adp); + adp->states &= ~CStatd; + ReleaseWriteLock(&afs_xcbhash); + osi_dnlc_purgedp(adp); } ReleaseWriteLock(&adp->lock); code = afs_CheckCode(code, treqp, 21); return code; } - if (tdc) UpgradeSToWLock(&tdc->lock, 637); + if (tdc) + UpgradeSToWLock(&tdc->lock, 637); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ code = afs_dir_Delete(&tdc->f.inode, aname); @@ -161,17 +172,18 @@ int afsremove(register struct vcache *adp, register struct dcache *tdc, * gone, we won't be able to fetch the status info anyway. */ if (tvc) { #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) - afs_BozonLock(&tvc->pvnLock, tvc); + afs_BozonLock(&tvc->pvnLock, tvc); /* Since afs_TryToSmush will do a pvn_vptrunc */ #endif - ObtainWriteLock(&tvc->lock,141); + ObtainWriteLock(&tvc->lock, 141); /* note that callback will be broken on the deleted file if there are * still >0 links left to it, so we'll get the stat right */ tvc->m.LinkCount--; - tvc->states &= ~CUnique; /* For the dfs xlator */ + tvc->states &= ~CUnique; /* For the dfs xlator */ if (tvc->m.LinkCount == 0 && !osi_Active(tvc)) { - if (!AFS_NFSXLATORREQ(acred)) afs_TryToSmush(tvc, acred, 0); - } + if (!AFS_NFSXLATORREQ(acred)) + afs_TryToSmush(tvc, acred, 0); + } ReleaseWriteLock(&tvc->lock); #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) afs_BozonUnlock(&tvc->pvnLock, tvc); @@ -181,15 +193,17 @@ int afsremove(register struct vcache *adp, register struct dcache *tdc, return (0); } -static char *newname(void) +static char * +newname(void) { char *name, *sp, *p = ".__afs"; afs_int32 rd = afs_random() & 0xffff; sp = name = osi_AllocSmallSpace(AFS_SMALLOCSIZ); - while (*p != '\0') *sp++ = *p++; + while (*p != '\0') + *sp++ = *p++; while (rd) { - *sp++= "0123456789ABCDEF"[rd & 0x0f]; + *sp++ = "0123456789ABCDEF"[rd & 0x0f]; rd >>= 4; } *sp = '\0'; @@ -197,7 +211,7 @@ static char *newname(void) } /* these variables appear to exist for debugging purposes */ -struct vcache * Tadp1, * Ttvc; +struct vcache *Tadp1, *Ttvc; int Tadpr, Ttvcr; char *Tnam; char *Tnam1; @@ -207,15 +221,17 @@ char *Tnam1; int #ifdef AFS_OSF_ENV afs_remove(ndp) - struct nameidata *ndp; { + struct nameidata *ndp; +{ register struct vcache *adp = VTOAFS(ndp->ni_dvp); char *aname = ndp->ni_dent.d_name; struct ucred *acred = ndp->ni_cred; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ afs_remove(OSI_VC_ARG(adp), aname, acred) - OSI_VC_DECL(adp); - char *aname; - struct AFS_UCRED *acred; { +OSI_VC_DECL(adp); + char *aname; + struct AFS_UCRED *acred; +{ #endif struct vrequest treq; register struct dcache *tdc; @@ -226,12 +242,12 @@ afs_remove(OSI_VC_ARG(adp), aname, acred) struct afs_fakestat_state fakestate; OSI_VC_CONVERT(adp) - AFS_STATCNT(afs_remove); + AFS_STATCNT(afs_remove); afs_Trace2(afs_iclSetp, CM_TRACE_REMOVE, ICL_TYPE_POINTER, adp, ICL_TYPE_STRING, aname); #ifdef AFS_OSF_ENV - tvc = (struct vcache *)ndp->ni_vp; /* should never be null */ + tvc = (struct vcache *)ndp->ni_vp; /* should never be null */ #endif if ((code = afs_InitReq(&treq, acred))) { @@ -271,17 +287,17 @@ afs_remove(OSI_VC_ARG(adp), aname, acred) #endif return ENAMETOOLONG; } -tagain: + tagain: code = afs_VerifyVCache(adp, &treq); #ifdef AFS_OSF_ENV - tvc = VTOAFS(ndp->ni_vp); /* should never be null */ + tvc = VTOAFS(ndp->ni_vp); /* should never be null */ if (code) { afs_PutVCache(adp); afs_PutVCache(tvc); afs_PutFakeStat(&fakestate); return afs_CheckCode(code, &treq, 22); } -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ tvc = NULL; if (code) { code = afs_CheckCode(code, &treq, 23); @@ -293,19 +309,20 @@ tagain: /** If the volume is read-only, return error without making an RPC to the * fileserver */ - if ( adp->states & CRO ) { + if (adp->states & CRO) { #ifdef AFS_OSF_ENV - afs_PutVCache(adp); - afs_PutVCache(tvc); + afs_PutVCache(adp); + afs_PutVCache(tvc); #endif - code = EROFS; + code = EROFS; afs_PutFakeStat(&fakestate); return code; } - tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); /* test for error below */ - ObtainWriteLock(&adp->lock,142); - if (tdc) ObtainSharedLock(&tdc->lock, 638); + tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); /* test for error below */ + ObtainWriteLock(&adp->lock, 142); + if (tdc) + ObtainSharedLock(&tdc->lock, 638); /* * Make sure that the data in the cache is current. We may have @@ -323,55 +340,66 @@ tagain: unlinkFid.Fid.Vnode = 0; if (!tvc) { - tvc = osi_dnlc_lookup (adp, aname, WRITE_LOCK); + tvc = osi_dnlc_lookup(adp, aname, WRITE_LOCK); } /* This should not be necessary since afs_lookup() has already * done the work */ if (!tvc) - if (tdc) { - code = afs_dir_Lookup(&tdc->f.inode, aname, &unlinkFid.Fid); - if (code == 0) { - afs_int32 cached=0; - - unlinkFid.Cell = adp->fid.Cell; - unlinkFid.Fid.Volume = adp->fid.Fid.Volume; - if (unlinkFid.Fid.Unique == 0) { - tvc = afs_LookupVCache(&unlinkFid, &treq, &cached, adp, aname); - } else { - ObtainReadLock(&afs_xvcache); - tvc = afs_FindVCache(&unlinkFid, 0, DO_STATS); - ReleaseReadLock(&afs_xvcache); + if (tdc) { + code = afs_dir_Lookup(&tdc->f.inode, aname, &unlinkFid.Fid); + if (code == 0) { + afs_int32 cached = 0; + + unlinkFid.Cell = adp->fid.Cell; + unlinkFid.Fid.Volume = adp->fid.Fid.Volume; + if (unlinkFid.Fid.Unique == 0) { + tvc = + afs_LookupVCache(&unlinkFid, &treq, &cached, adp, + aname); + } else { + ObtainReadLock(&afs_xvcache); + tvc = afs_FindVCache(&unlinkFid, 0, DO_STATS); + ReleaseReadLock(&afs_xvcache); + } } } - } if (tvc && osi_Active(tvc)) { /* about to delete whole file, prefetch it first */ ReleaseWriteLock(&adp->lock); - ObtainWriteLock(&tvc->lock,143); + ObtainWriteLock(&tvc->lock, 143); #if defined(AFS_OSF_ENV) afs_Wire(tvc, &treq); -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ FetchWholeEnchilada(tvc, &treq); #endif ReleaseWriteLock(&tvc->lock); - ObtainWriteLock(&adp->lock,144); + ObtainWriteLock(&adp->lock, 144); } - osi_dnlc_remove ( adp, aname, tvc); - if (tvc) afs_symhint_inval(tvc); - - Tadp1 = adp; Tadpr = VREFCOUNT(adp); Ttvc = tvc; Tnam = aname; Tnam1 = 0; - if (tvc) Ttvcr = VREFCOUNT(tvc); + osi_dnlc_remove(adp, aname, tvc); + if (tvc) + afs_symhint_inval(tvc); + + Tadp1 = adp; + Tadpr = VREFCOUNT(adp); + Ttvc = tvc; + Tnam = aname; + Tnam1 = 0; + if (tvc) + Ttvcr = VREFCOUNT(tvc); #ifdef AFS_AIX_ENV - if (tvc && (VREFCOUNT(tvc) > 2) && tvc->opens > 0 && !(tvc->states & CUnlinked)) { + if (tvc && (VREFCOUNT(tvc) > 2) && tvc->opens > 0 + && !(tvc->states & CUnlinked)) { #else - if (tvc && (VREFCOUNT(tvc) > 1) && tvc->opens > 0 && !(tvc->states & CUnlinked)) { + if (tvc && (VREFCOUNT(tvc) > 1) && tvc->opens > 0 + && !(tvc->states & CUnlinked)) { #endif char *unlname = newname(); ReleaseWriteLock(&adp->lock); - if (tdc) ReleaseSharedLock(&tdc->lock); + if (tdc) + ReleaseSharedLock(&tdc->lock); code = afsrename(adp, aname, adp, unlname, acred, &treq); Tnam1 = unlname; if (!code) { @@ -383,17 +411,17 @@ tagain: tvc->uncred = acred; tvc->states |= CUnlinked; } else { - osi_FreeSmallSpace(unlname); + osi_FreeSmallSpace(unlname); } - if ( tdc ) - afs_PutDCache(tdc); - afs_PutVCache(tvc); + if (tdc) + afs_PutDCache(tdc); + afs_PutVCache(tvc); } else { code = afsremove(adp, tdc, tvc, aname, acred, &treq); } #ifdef AFS_OSF_ENV afs_PutVCache(adp); -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ afs_PutFakeStat(&fakestate); return code; } @@ -404,7 +432,8 @@ tagain: * * CAUTION -- may be called with avc unheld. */ -int afs_remunlink(register struct vcache *avc, register int doit) +int +afs_remunlink(register struct vcache *avc, register int doit) { struct AFS_UCRED *cred; char *unlname; @@ -412,16 +441,15 @@ int afs_remunlink(register struct vcache *avc, register int doit) struct vrequest treq; struct VenusFid dirFid; register struct dcache *tdc; - afs_int32 code=0; + afs_int32 code = 0; if (NBObtainWriteLock(&avc->lock, 423)) return 0; if (avc->mvid && (doit || (avc->states & CUnlinkedDel))) { - if ((code = afs_InitReq(&treq, avc->uncred))) { + if ((code = afs_InitReq(&treq, avc->uncred))) { ReleaseWriteLock(&avc->lock); - } - else { + } else { /* Must bump the refCount because GetVCache may block. * Also clear mvid so no other thread comes here if we block. */ @@ -431,13 +459,13 @@ int afs_remunlink(register struct vcache *avc, register int doit) avc->uncred = NULL; #ifdef AFS_DARWIN_ENV - /* this is called by vrele (via VOP_INACTIVE) when the refcount - is 0. we can't just call VN_HOLD since vref will panic. - we can't just call osi_vnhold because a later AFS_RELE will call - vrele again, which will try to call VOP_INACTIVE again after - vn_locking the vnode. which would be fine except that our vrele - caller also locked the vnode... So instead, we just gimmick the - refcounts and hope nobody else can touch the file now */ + /* this is called by vrele (via VOP_INACTIVE) when the refcount + * is 0. we can't just call VN_HOLD since vref will panic. + * we can't just call osi_vnhold because a later AFS_RELE will call + * vrele again, which will try to call VOP_INACTIVE again after + * vn_locking the vnode. which would be fine except that our vrele + * caller also locked the vnode... So instead, we just gimmick the + * refcounts and hope nobody else can touch the file now */ osi_Assert(VREFCOUNT(avc) == 0); VREFCOUNT_SET(avc, 1); #endif @@ -446,7 +474,7 @@ int afs_remunlink(register struct vcache *avc, register int doit) /* We'll only try this once. If it fails, just release the vnode. * Clear after doing hold so that NewVCache doesn't find us yet. */ - avc->states &= ~(CUnlinked | CUnlinkedDel); + avc->states &= ~(CUnlinked | CUnlinkedDel); ReleaseWriteLock(&avc->lock); @@ -455,11 +483,12 @@ int afs_remunlink(register struct vcache *avc, register int doit) dirFid.Fid.Vnode = avc->parentVnode; dirFid.Fid.Unique = avc->parentUnique; adp = afs_GetVCache(&dirFid, &treq, NULL, NULL); - + if (adp) { - tdc = afs_FindDCache(adp, (afs_size_t)0); + tdc = afs_FindDCache(adp, (afs_size_t) 0); ObtainWriteLock(&adp->lock, 159); - if (tdc) ObtainSharedLock(&tdc->lock, 639); + if (tdc) + ObtainSharedLock(&tdc->lock, 639); /* afsremove releases the adp & tdc locks, and does vn_rele(avc) */ code = afsremove(adp, tdc, avc, unlname, cred, &treq); @@ -474,9 +503,8 @@ int afs_remunlink(register struct vcache *avc, register int doit) osi_Assert(VREFCOUNT(avc) == 1); VREFCOUNT_SET(avc, 0); #endif - } - } - else { + } + } else { ReleaseWriteLock(&avc->lock); } diff --git a/src/afs/VNOPS/afs_vnop_rename.c b/src/afs/VNOPS/afs_vnop_rename.c index dd332a5f0..ba3ef8798 100644 --- a/src/afs/VNOPS/afs_vnop_rename.c +++ b/src/afs/VNOPS/afs_vnop_rename.c @@ -17,11 +17,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -31,8 +32,9 @@ extern afs_rwlock_t afs_xcbhash; /* Note that we don't set CDirty here, this is OK because the rename * RPC is called synchronously. */ -int afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, - char *aname2, struct AFS_UCRED *acred, struct vrequest *areq) +int +afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, + char *aname2, struct AFS_UCRED *acred, struct vrequest *areq) { register struct conn *tc; register afs_int32 code; @@ -44,10 +46,8 @@ int afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, struct dcache *tdc1, *tdc2; struct AFSFetchStatus OutOldDirStatus, OutNewDirStatus; struct AFSVolSync tsync; - XSTATS_DECLS - - AFS_STATCNT(afs_rename); - afs_Trace4(afs_iclSetp, CM_TRACE_RENAME, ICL_TYPE_POINTER, aodp, + XSTATS_DECLS AFS_STATCNT(afs_rename); + afs_Trace4(afs_iclSetp, CM_TRACE_RENAME, ICL_TYPE_POINTER, aodp, ICL_TYPE_STRING, aname1, ICL_TYPE_POINTER, andp, ICL_TYPE_STRING, aname2); @@ -57,14 +57,17 @@ int afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, } /* verify the latest versions of the stat cache entries */ -tagain: + tagain: code = afs_VerifyVCache(aodp, areq); - if (code) goto done; + if (code) + goto done; code = afs_VerifyVCache(andp, areq); - if (code) goto done; - + if (code) + goto done; + /* lock in appropriate order, after some checks */ - if (aodp->fid.Cell != andp->fid.Cell || aodp->fid.Fid.Volume != andp->fid.Fid.Volume) { + if (aodp->fid.Cell != andp->fid.Cell + || aodp->fid.Fid.Volume != andp->fid.Fid.Volume) { code = EXDEV; goto done; } @@ -78,7 +81,7 @@ tagain: code = 0; goto done; } - ObtainWriteLock(&andp->lock,147); + ObtainWriteLock(&andp->lock, 147); tdc1 = afs_GetDCache(aodp, (afs_size_t) 0, areq, &offset, &len, 0); if (!tdc1) { code = ENOENT; @@ -86,38 +89,37 @@ tagain: ObtainWriteLock(&tdc1->lock, 643); } tdc2 = tdc1; - oneDir = 1; /* only one dude locked */ - } - else if ((andp->states & CRO) || (aodp->states & CRO)) { - code = EROFS; - goto done; - } - else if (andp->fid.Fid.Vnode < aodp->fid.Fid.Vnode) { - ObtainWriteLock(&andp->lock,148); /* lock smaller one first */ - ObtainWriteLock(&aodp->lock,149); - tdc2 = afs_FindDCache(andp, (afs_size_t)0); - if (tdc2) ObtainWriteLock(&tdc2->lock, 644); + oneDir = 1; /* only one dude locked */ + } else if ((andp->states & CRO) || (aodp->states & CRO)) { + code = EROFS; + goto done; + } else if (andp->fid.Fid.Vnode < aodp->fid.Fid.Vnode) { + ObtainWriteLock(&andp->lock, 148); /* lock smaller one first */ + ObtainWriteLock(&aodp->lock, 149); + tdc2 = afs_FindDCache(andp, (afs_size_t) 0); + if (tdc2) + ObtainWriteLock(&tdc2->lock, 644); tdc1 = afs_GetDCache(aodp, (afs_size_t) 0, areq, &offset, &len, 0); if (tdc1) ObtainWriteLock(&tdc1->lock, 645); else code = ENOENT; - } - else { - ObtainWriteLock(&aodp->lock,150); /* lock smaller one first */ - ObtainWriteLock(&andp->lock,557); + } else { + ObtainWriteLock(&aodp->lock, 150); /* lock smaller one first */ + ObtainWriteLock(&andp->lock, 557); tdc1 = afs_GetDCache(aodp, (afs_size_t) 0, areq, &offset, &len, 0); if (tdc1) ObtainWriteLock(&tdc1->lock, 646); else code = ENOENT; - tdc2 = afs_FindDCache(andp, (afs_size_t)0); - if (tdc2) ObtainWriteLock(&tdc2->lock, 647); + tdc2 = afs_FindDCache(andp, (afs_size_t) 0); + if (tdc2) + ObtainWriteLock(&tdc2->lock, 647); } - osi_dnlc_remove (aodp, aname1, 0); - osi_dnlc_remove (andp, aname2, 0); - afs_symhint_inval(aodp); + osi_dnlc_remove(aodp, aname1, 0); + osi_dnlc_remove(andp, aname2, 0); + afs_symhint_inval(aodp); afs_symhint_inval(andp); /* @@ -164,26 +166,28 @@ tagain: do { tc = afs_Conn(&aodp->fid, areq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RENAME); - RX_AFS_GUNLOCK(); - code = RXAFS_Rename(tc->id, (struct AFSFid *) &aodp->fid.Fid, aname1, - (struct AFSFid *) &andp->fid.Fid, aname2, - &OutOldDirStatus, &OutNewDirStatus, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } else code = -1; + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RENAME); + RX_AFS_GUNLOCK(); + code = + RXAFS_Rename(tc->id, (struct AFSFid *)&aodp->fid.Fid, aname1, + (struct AFSFid *)&andp->fid.Fid, aname2, + &OutOldDirStatus, &OutNewDirStatus, &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + + } while (afs_Analyze + (tc, code, &andp->fid, areq, AFS_STATS_FS_RPCIDX_RENAME, + SHARED_LOCK, NULL)); - } while - (afs_Analyze(tc, code, &andp->fid, areq, - AFS_STATS_FS_RPCIDX_RENAME, SHARED_LOCK, NULL)); + returnCode = code; /* remember for later */ - returnCode = code; /* remember for later */ - /* Now we try to do things locally. This is really loathsome code. */ unlinkFid.Fid.Vnode = 0; if (code == 0) { /* In any event, we don't really care if the data (tdc2) is not - in the cache; if it isn't, we won't do the update locally. */ + * in the cache; if it isn't, we won't do the update locally. */ /* see if version numbers increased properly */ doLocally = 1; if (oneDir) { @@ -191,8 +195,7 @@ tagain: if (!afs_LocalHero(aodp, tdc1, &OutOldDirStatus, 1)) { doLocally = 0; } - } - else { + } else { /* two separate dirs, each increasing by 1 */ if (!afs_LocalHero(aodp, tdc1, &OutOldDirStatus, 1)) doLocally = 0; @@ -218,8 +221,9 @@ tagain: code = afs_dir_Delete(&tdc1->f.inode, aname1); } /* first see if target is there */ - if (code == 0 && - afs_dir_Lookup(&tdc2->f.inode, aname2, &unlinkFid.Fid) == 0) { + if (code == 0 + && afs_dir_Lookup(&tdc2->f.inode, aname2, + &unlinkFid.Fid) == 0) { /* target already exists, and will be unlinked by server */ code = afs_dir_Delete(&tdc2->f.inode, aname2); } @@ -241,19 +245,18 @@ tagain: if (!oneDir) andp->m.LinkCount = OutNewDirStatus.LinkCount; - } - else { /* operation failed (code != 0) */ - if (code < 0) { + } else { /* operation failed (code != 0) */ + if (code < 0) { /* if failed, server might have done something anyway, and * assume that we know about it */ - ObtainWriteLock(&afs_xcbhash, 498); - afs_DequeueCallback(aodp); - afs_DequeueCallback(andp); - andp->states &= ~CStatd; - aodp->states &= ~CStatd; - ReleaseWriteLock(&afs_xcbhash); - osi_dnlc_purgedp(andp); - osi_dnlc_purgedp(aodp); + ObtainWriteLock(&afs_xcbhash, 498); + afs_DequeueCallback(aodp); + afs_DequeueCallback(andp); + andp->states &= ~CStatd; + aodp->states &= ~CStatd; + ReleaseWriteLock(&afs_xcbhash); + osi_dnlc_purgedp(andp); + osi_dnlc_purgedp(aodp); } } @@ -269,20 +272,21 @@ tagain: } ReleaseWriteLock(&aodp->lock); - if (!oneDir) ReleaseWriteLock(&andp->lock); - + if (!oneDir) + ReleaseWriteLock(&andp->lock); + if (returnCode) { code = returnCode; goto done; } /* now, some more details. if unlinkFid.Fid.Vnode then we should decrement - the link count on this file. Note that if fileFid is a dir, then we don't - have to invalidate its ".." entry, since its DataVersion # should have - changed. However, interface is not good enough to tell us the - *file*'s new DataVersion, so we're stuck. Our hack: delete mark - the data as having an "unknown" version (effectively discarding the ".." - entry */ + * the link count on this file. Note that if fileFid is a dir, then we don't + * have to invalidate its ".." entry, since its DataVersion # should have + * changed. However, interface is not good enough to tell us the + * *file*'s new DataVersion, so we're stuck. Our hack: delete mark + * the data as having an "unknown" version (effectively discarding the ".." + * entry */ if (unlinkFid.Fid.Vnode) { unlinkFid.Fid.Volume = aodp->fid.Fid.Volume; unlinkFid.Cell = aodp->fid.Cell; @@ -290,26 +294,27 @@ tagain: if (!unlinkFid.Fid.Unique) { tvc = afs_LookupVCache(&unlinkFid, areq, NULL, aodp, aname1); } - if (!tvc) /* lookup failed or wasn't called */ - tvc = afs_GetVCache(&unlinkFid, areq, NULL, NULL); + if (!tvc) /* lookup failed or wasn't called */ + tvc = afs_GetVCache(&unlinkFid, areq, NULL, NULL); if (tvc) { #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) afs_BozonLock(&tvc->pvnLock, tvc); /* Since afs_TryToSmush will do a pvn_vptrunc */ #endif - ObtainWriteLock(&tvc->lock,151); + ObtainWriteLock(&tvc->lock, 151); tvc->m.LinkCount--; - tvc->states &= ~CUnique; /* For the dfs xlator */ + tvc->states &= ~CUnique; /* For the dfs xlator */ if (tvc->m.LinkCount == 0 && !osi_Active(tvc)) { /* if this was last guy (probably) discard from cache. - * We have to be careful to not get rid of the stat - * information, since otherwise operations will start - * failing even if the file was still open (or - * otherwise active), and the server no longer has the - * info. If the file still has valid links, we'll get - * a break-callback msg from the server, so it doesn't - * matter that we don't discard the status info */ - if (!AFS_NFSXLATORREQ(acred)) afs_TryToSmush(tvc, acred, 0); + * We have to be careful to not get rid of the stat + * information, since otherwise operations will start + * failing even if the file was still open (or + * otherwise active), and the server no longer has the + * info. If the file still has valid links, we'll get + * a break-callback msg from the server, so it doesn't + * matter that we don't discard the status info */ + if (!AFS_NFSXLATORREQ(acred)) + afs_TryToSmush(tvc, acred, 0); } ReleaseWriteLock(&tvc->lock); #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) @@ -326,10 +331,10 @@ tagain: if (!fileFid.Fid.Unique) tvc = afs_LookupVCache(&fileFid, areq, NULL, andp, aname2); else - tvc = afs_GetVCache(&fileFid, areq, NULL, (struct vcache*)0); + tvc = afs_GetVCache(&fileFid, areq, NULL, (struct vcache *)0); if (tvc && (vType(tvc) == VDIR)) { - ObtainWriteLock(&tvc->lock,152); - tdc1 = afs_FindDCache(tvc, (afs_size_t)0); + ObtainWriteLock(&tvc->lock, 152); + tdc1 = afs_FindDCache(tvc, (afs_size_t) 0); if (tdc1) { ObtainWriteLock(&tdc1->lock, 648); ZapDCE(tdc1); /* mark as unknown */ @@ -348,29 +353,31 @@ tagain: } } code = returnCode; -done: + done: return code; } #ifdef AFS_OSF_ENV afs_rename(fndp, tndp) - struct nameidata *fndp, *tndp; { + struct nameidata *fndp, *tndp; +{ struct vcache *aodp = VTOAFS(fndp->ni_dvp); char *aname1 = fndp->ni_dent.d_name; struct vcache *andp = VTOAFS(tndp->ni_dvp); char *aname2 = tndp->ni_dent.d_name; struct ucred *acred = tndp->ni_cred; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ #if defined(AFS_SGI_ENV) afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, npnp, acred) - struct pathname *npnp; + struct pathname *npnp; #else afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, acred) #endif OSI_VC_DECL(aodp); - struct vcache *andp; - char *aname1, *aname2; - struct AFS_UCRED *acred; { + struct vcache *andp; + char *aname1, *aname2; + struct AFS_UCRED *acred; +{ #endif register afs_int32 code; struct afs_fakestat_state ofakestate; @@ -378,16 +385,19 @@ afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, acred) struct vrequest treq; OSI_VC_CONVERT(aodp) - code = afs_InitReq(&treq, acred); - if (code) return code; + code = afs_InitReq(&treq, acred); + if (code) + return code; afs_InitFakeStat(&ofakestate); afs_InitFakeStat(&nfakestate); code = afs_EvalFakeStat(&aodp, &ofakestate, &treq); - if (code) goto done; + if (code) + goto done; code = afs_EvalFakeStat(&andp, &nfakestate, &treq); - if (code) goto done; + if (code) + goto done; code = afsrename(aodp, aname1, andp, aname2, acred, &treq); -done: + done: afs_PutFakeStat(&ofakestate); afs_PutFakeStat(&nfakestate); #ifdef AFS_OSF_ENV @@ -397,7 +407,7 @@ done: } AFS_RELE(fndp->ni_dvp); AFS_RELE(fndp->ni_vp); -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ code = afs_CheckCode(code, &treq, 25); return code; } diff --git a/src/afs/VNOPS/afs_vnop_strategy.c b/src/afs/VNOPS/afs_vnop_strategy.c index 554f16384..896add74f 100644 --- a/src/afs/VNOPS/afs_vnop_strategy.c +++ b/src/afs/VNOPS/afs_vnop_strategy.c @@ -15,13 +15,14 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #if !defined(AFS_HPUX_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV) #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -31,11 +32,12 @@ RCSID("$Header$"); int #if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) afs_ustrategy(abp, credp) - struct AFS_UCRED *credp; + struct AFS_UCRED *credp; #else afs_ustrategy(abp) #endif - register struct buf *abp; { + register struct buf *abp; +{ register afs_int32 code; struct uio tuio; register struct vcache *tvc = VTOAFS(abp->b_vp); @@ -55,7 +57,7 @@ afs_ustrategy(abp) * So that it won't change while reading it */ ObtainReadLock(&tvc->lock); - if (tvc->credp) { + if (tvc->credp) { credp = tvc->credp; crhold(credp); } else { @@ -70,10 +72,10 @@ afs_ustrategy(abp) if ((abp->b_flags & B_READ) == B_READ) { #endif /* read b_bcount bytes into kernel address b_un.b_addr starting - at byte DEV_BSIZE * b_blkno. Bzero anything we can't read, - and finally call iodone(abp). File is in abp->b_vp. Credentials - are from u area?? - */ + * at byte DEV_BSIZE * b_blkno. Bzero anything we can't read, + * and finally call iodone(abp). File is in abp->b_vp. Credentials + * are from u area?? + */ tuio.afsio_iov = tiovec; tuio.afsio_iovcnt = 1; #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_XBSD_ENV) @@ -100,7 +102,7 @@ afs_ustrategy(abp) #endif /* AFS_XBSD_ENV */ tiovec[0].iov_len = abp->b_bcount; /* are user's credentials valid here? probably, but this - sure seems like the wrong things to do. */ + * sure seems like the wrong things to do. */ #if defined(AFS_SUN5_ENV) code = afs_nlrdwr(VTOAFS(abp->b_vp), &tuio, UIO_READ, 0, credp); #else @@ -109,9 +111,11 @@ afs_ustrategy(abp) if (code == 0) { if (tuio.afsio_resid > 0) #if defined(AFS_XBSD_ENV) - memset(abp->b_saveaddr + abp->b_bcount - tuio.afsio_resid, 0, tuio.afsio_resid); + memset(abp->b_saveaddr + abp->b_bcount - tuio.afsio_resid, 0, + tuio.afsio_resid); #else - memset(abp->b_un.b_addr + abp->b_bcount - tuio.afsio_resid, 0, tuio.afsio_resid); + memset(abp->b_un.b_addr + abp->b_bcount - tuio.afsio_resid, 0, + tuio.afsio_resid); #endif /* AFS_XBSD_ENV */ #ifdef AFS_AIX32_ENV /* @@ -122,15 +126,14 @@ afs_ustrategy(abp) if (dbtob(abp->b_blkno) + abp->b_bcount > tvc->m.Length) { if ((abp->b_flags & B_PFSTORE) == 0) { AFS_GUNLOCK(); - vm_protectp(tvc->segid, dbtob(abp->b_blkno)/PAGESIZE, - abp->b_bcount/PAGESIZE, RDONLY); + vm_protectp(tvc->segid, dbtob(abp->b_blkno) / PAGESIZE, + abp->b_bcount / PAGESIZE, RDONLY); AFS_GLOCK(); } } #endif } - } - else { + } else { tuio.afsio_iov = tiovec; tuio.afsio_iovcnt = 1; #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) @@ -156,7 +159,7 @@ afs_ustrategy(abp) #ifdef AFS_UIOFMODE tuio.afsio_fmode = 0; #endif -#ifdef AFS_AIX32_ENV +#ifdef AFS_AIX32_ENV /* * XXX It this really right? Ideally we should always write block size multiple * and not any arbitrary size, right? XXX @@ -164,8 +167,10 @@ afs_ustrategy(abp) len = MIN(len, tvc->m.Length - dbtob(abp->b_blkno)); #endif #ifdef AFS_ALPHA_ENV - len = MIN(abp->b_bcount, (VTOAFS(abp->b_vp))->m.Length - dbtob(abp->b_blkno)); -#endif /* AFS_ALPHA_ENV */ + len = + MIN(abp->b_bcount, + (VTOAFS(abp->b_vp))->m.Length - dbtob(abp->b_blkno)); +#endif /* AFS_ALPHA_ENV */ tuio.afsio_resid = len; #if defined(AFS_XBSD_ENV) tiovec[0].iov_base = abp->b_saveaddr; @@ -174,7 +179,7 @@ afs_ustrategy(abp) #endif /* AFS_XBSD_ENV */ tiovec[0].iov_len = len; /* are user's credentials valid here? probably, but this - sure seems like the wrong things to do. */ + * sure seems like the wrong things to do. */ #if defined(AFS_SUN5_ENV) code = afs_nlrdwr(VTOAFS(abp->b_vp), &tuio, UIO_WRITE, 0, credp); #else @@ -193,12 +198,11 @@ afs_ustrategy(abp) /* prevent ubc from retrying writes */ AFS_GUNLOCK(); ubc_invalidate(AFSTOV(tvc)->v_object, - (vm_offset_t)dbtob(abp->b_blkno), - PAGE_SIZE, B_INVAL); + (vm_offset_t) dbtob(abp->b_blkno), PAGE_SIZE, B_INVAL); AFS_GLOCK(); } #endif -#else /* AFS_DUX40_ENV */ +#else /* AFS_DUX40_ENV */ iodone(abp); #endif /* AFS_DUX40_ENV */ #endif @@ -206,8 +210,7 @@ afs_ustrategy(abp) crfree(credp); #endif afs_Trace3(afs_iclSetp, CM_TRACE_STRATEGYDONE, ICL_TYPE_POINTER, tvc, - ICL_TYPE_INT32, code, - ICL_TYPE_LONG, tuio.afsio_resid); + ICL_TYPE_INT32, code, ICL_TYPE_LONG, tuio.afsio_resid); return code; } diff --git a/src/afs/VNOPS/afs_vnop_symlink.c b/src/afs/VNOPS/afs_vnop_symlink.c index 5e9e5977e..1f5e988e8 100644 --- a/src/afs/VNOPS/afs_vnop_symlink.c +++ b/src/afs/VNOPS/afs_vnop_symlink.c @@ -21,11 +21,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -41,22 +42,23 @@ extern afs_rwlock_t afs_xcbhash; /* don't set CDirty in here because RPC is called synchronously */ int -afs_symlink + afs_symlink #ifdef AFS_OSF_ENV (ndp, attrs, atargetName) - struct nameidata *ndp; - struct vattr *attrs; - register char *atargetName; { + struct nameidata *ndp; + struct vattr *attrs; + register char *atargetName; +{ register struct vcache *adp = VTOAFS(ndp->ni_dvp); char *aname = ndp->ni_dent.d_name; struct ucred *acred = ndp->ni_cred; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ (OSI_VC_ARG(adp), aname, attrs, atargetName, acred) - OSI_VC_DECL(adp); - char *atargetName; - char *aname; - struct vattr *attrs; - struct AFS_UCRED *acred; { + OSI_VC_DECL(adp); +char *atargetName; +char *aname; +struct vattr *attrs; +struct AFS_UCRED *acred; { #endif afs_uint32 now = 0; struct vrequest treq; @@ -66,20 +68,19 @@ afs_symlink struct dcache *tdc; afs_size_t offset, len; afs_int32 alen; - struct server *hostp=0; + struct server *hostp = 0; struct vcache *tvc; struct AFSStoreStatus InStatus; struct AFSFetchStatus OutFidStatus, OutDirStatus; struct AFSCallBack CallBack; struct AFSVolSync tsync; - struct volume* volp=0; + struct volume *volp = 0; struct afs_fakestat_state fakestate; - XSTATS_DECLS - OSI_VC_CONVERT(adp) - - AFS_STATCNT(afs_symlink); + XSTATS_DECLS OSI_VC_CONVERT(adp) + + AFS_STATCNT(afs_symlink); afs_Trace2(afs_iclSetp, CM_TRACE_SYMLINK, ICL_TYPE_POINTER, adp, - ICL_TYPE_STRING, aname); + ICL_TYPE_STRING, aname); if ((code = afs_InitReq(&treq, acred))) goto done2; @@ -100,7 +101,7 @@ afs_symlink } code = afs_VerifyVCache(adp, &treq); - if (code) { + if (code) { code = afs_CheckCode(code, &treq, 30); goto done; } @@ -108,26 +109,28 @@ afs_symlink /** If the volume is read-only, return error without making an RPC to the * fileserver */ - if ( adp->states & CRO ) { - code = EROFS; + if (adp->states & CRO) { + code = EROFS; goto done; } InStatus.Mask = AFS_SETMODTIME | AFS_SETMODE; InStatus.ClientModTime = osi_Time(); - alen = strlen(atargetName); /* we want it to include the null */ + alen = strlen(atargetName); /* we want it to include the null */ if (*atargetName == '#' || *atargetName == '%') { InStatus.UnixModeBits = 0644; /* mt pt: null from "." at end */ - if (alen == 1) alen++; /* Empty string */ + if (alen == 1) + alen++; /* Empty string */ } else { InStatus.UnixModeBits = 0755; - alen++; /* add in the null */ + alen++; /* add in the null */ } tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); - volp = afs_FindVolume(&adp->fid, READ_LOCK); /*parent is also in same vol*/ - ObtainWriteLock(&adp->lock,156); - if (tdc) ObtainWriteLock(&tdc->lock, 636); - ObtainSharedLock(&afs_xvcache,17); /* prevent others from creating this entry */ + volp = afs_FindVolume(&adp->fid, READ_LOCK); /*parent is also in same vol */ + ObtainWriteLock(&adp->lock, 156); + if (tdc) + ObtainWriteLock(&tdc->lock, 636); + ObtainSharedLock(&afs_xvcache, 17); /* prevent others from creating this entry */ /* XXX Pay attention to afs_xvcache around the whole thing!! XXX */ do { tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK); @@ -137,32 +140,37 @@ afs_symlink if (adp->states & CForeign) { now = osi_Time(); RX_AFS_GUNLOCK(); - code = RXAFS_DFSSymlink(tc->id, (struct AFSFid *) &adp->fid.Fid, aname, - atargetName, &InStatus, (struct AFSFid *) &newFid.Fid, - &OutFidStatus, &OutDirStatus, &CallBack, &tsync); + code = + RXAFS_DFSSymlink(tc->id, (struct AFSFid *)&adp->fid.Fid, + aname, atargetName, &InStatus, + (struct AFSFid *)&newFid.Fid, + &OutFidStatus, &OutDirStatus, &CallBack, + &tsync); RX_AFS_GLOCK(); } else { RX_AFS_GUNLOCK(); - code = RXAFS_Symlink(tc->id, (struct AFSFid *) &adp->fid.Fid, aname, - atargetName, &InStatus, (struct AFSFid *) &newFid.Fid, - &OutFidStatus, &OutDirStatus, &tsync); + code = + RXAFS_Symlink(tc->id, (struct AFSFid *)&adp->fid.Fid, + aname, atargetName, &InStatus, + (struct AFSFid *)&newFid.Fid, &OutFidStatus, + &OutDirStatus, &tsync); RX_AFS_GLOCK(); } - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &adp->fid, &treq, - AFS_STATS_FS_RPCIDX_SYMLINK, SHARED_LOCK, NULL)); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_SYMLINK, + SHARED_LOCK, NULL)); - UpgradeSToWLock(&afs_xvcache,40); + UpgradeSToWLock(&afs_xvcache, 40); if (code) { if (code < 0) { - ObtainWriteLock(&afs_xcbhash, 499); - afs_DequeueCallback(adp); - adp->states &= ~CStatd; - ReleaseWriteLock(&afs_xcbhash); - osi_dnlc_purgedp(adp); + ObtainWriteLock(&afs_xcbhash, 499); + afs_DequeueCallback(adp); + adp->states &= ~CStatd; + ReleaseWriteLock(&afs_xcbhash); + osi_dnlc_purgedp(adp); } ReleaseWriteLock(&adp->lock); ReleaseWriteLock(&afs_xvcache); @@ -176,7 +184,7 @@ afs_symlink if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ code = afs_dir_Create(&tdc->f.inode, aname, &newFid.Fid); - if (code) { + if (code) { ZapDCE(tdc); /* surprise error -- use invalid value */ DZap(&tdc->f.inode); } @@ -193,9 +201,9 @@ afs_symlink * no one can get a pointer to the new cache entry until we release * the xvcache lock. */ tvc = afs_NewVCache(&newFid, hostp); - ObtainWriteLock(&tvc->lock,157); + ObtainWriteLock(&tvc->lock, 157); ObtainWriteLock(&afs_xcbhash, 500); - tvc->states |= CStatd; /* have valid info */ + tvc->states |= CStatd; /* have valid info */ tvc->states &= ~CBulkFetching; if (adp->states & CForeign) { @@ -203,84 +211,88 @@ afs_symlink /* We don't have to worry about losing the callback since we're doing it * under the afs_xvcache lock actually, afs_NewVCache may drop the * afs_xvcache lock, if it calls afs_FlushVCache */ - tvc->cbExpires = CallBack.ExpirationTime + now; - afs_QueueCallback(tvc, CBHash(CallBack.ExpirationTime), volp); + tvc->cbExpires = CallBack.ExpirationTime + now; + afs_QueueCallback(tvc, CBHash(CallBack.ExpirationTime), volp); } else { tvc->cbExpires = 0x7fffffff; /* never expires, they can't change */ - /* since it never expires, we don't have to queue the callback */ + /* since it never expires, we don't have to queue the callback */ } ReleaseWriteLock(&afs_xcbhash); afs_ProcessFS(tvc, &OutFidStatus, &treq); if (!tvc->linkData) { - tvc->linkData = (char *) afs_osi_Alloc(alen); - strncpy(tvc->linkData, atargetName, alen-1); - tvc->linkData[alen-1] = 0; + tvc->linkData = (char *)afs_osi_Alloc(alen); + strncpy(tvc->linkData, atargetName, alen - 1); + tvc->linkData[alen - 1] = 0; } ReleaseWriteLock(&tvc->lock); ReleaseWriteLock(&afs_xvcache); afs_PutVCache(tvc); code = 0; -done: + done: afs_PutFakeStat(&fakestate); - if ( volp ) + if (volp) afs_PutVolume(volp, READ_LOCK); code = afs_CheckCode(code, &treq, 31); -done2: + done2: #ifdef AFS_OSF_ENV AFS_RELE(ndp->ni_dvp); -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ return code; } -int afs_MemHandleLink(register struct vcache *avc, struct vrequest *areq) +int +afs_MemHandleLink(register struct vcache *avc, struct vrequest *areq) { - register struct dcache *tdc; - register char *tp, *rbuf; - afs_size_t offset, len; - afs_int32 tlen, alen; - register afs_int32 code; + register struct dcache *tdc; + register char *tp, *rbuf; + afs_size_t offset, len; + afs_int32 tlen, alen; + register afs_int32 code; - AFS_STATCNT(afs_MemHandleLink); - /* two different formats, one for links protected 644, have a "." at - the end of the file name, which we turn into a null. Others, - protected 755, we add a null to the end of */ - if (!avc->linkData) { - void *addr; - tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 0); - if (!tdc) { - return EIO; - } - /* otherwise we have the data loaded, go for it */ - if (len > 1024) { - afs_PutDCache(tdc); - return EFAULT; - } - if (avc->m.Mode & 0111) alen = len+1; /* regular link */ - else alen = len; /* mt point */ - rbuf = (char *) osi_AllocLargeSpace(AFS_LRALLOCSIZ); - ObtainReadLock(&tdc->lock); - addr = afs_MemCacheOpen(tdc->f.inode); - tlen = len; - code = afs_MemReadBlk(addr, 0, rbuf, tlen); - afs_MemCacheClose(addr); - ReleaseReadLock(&tdc->lock); - afs_PutDCache(tdc); - rbuf[alen-1] = 0; - alen = strlen(rbuf) + 1; - tp = afs_osi_Alloc(alen); /* make room for terminating null */ - memcpy(tp, rbuf, alen); - osi_FreeLargeSpace(rbuf); - if (code != len) { - afs_osi_Free(tp, alen); - return EIO; - } - avc->linkData = tp; - } - return 0; - } + AFS_STATCNT(afs_MemHandleLink); + /* two different formats, one for links protected 644, have a "." at + * the end of the file name, which we turn into a null. Others, + * protected 755, we add a null to the end of */ + if (!avc->linkData) { + void *addr; + tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 0); + if (!tdc) { + return EIO; + } + /* otherwise we have the data loaded, go for it */ + if (len > 1024) { + afs_PutDCache(tdc); + return EFAULT; + } + if (avc->m.Mode & 0111) + alen = len + 1; /* regular link */ + else + alen = len; /* mt point */ + rbuf = (char *)osi_AllocLargeSpace(AFS_LRALLOCSIZ); + ObtainReadLock(&tdc->lock); + addr = afs_MemCacheOpen(tdc->f.inode); + tlen = len; + code = afs_MemReadBlk(addr, 0, rbuf, tlen); + afs_MemCacheClose(addr); + ReleaseReadLock(&tdc->lock); + afs_PutDCache(tdc); + rbuf[alen - 1] = 0; + alen = strlen(rbuf) + 1; + tp = afs_osi_Alloc(alen); /* make room for terminating null */ + memcpy(tp, rbuf, alen); + osi_FreeLargeSpace(rbuf); + if (code != len) { + afs_osi_Free(tp, alen); + return EIO; + } + avc->linkData = tp; + } + return 0; +} -int afs_UFSHandleLink(register struct vcache *avc, struct vrequest *areq) +int +afs_UFSHandleLink(register struct vcache *avc, struct vrequest *areq) { register struct dcache *tdc; register char *tp, *rbuf; @@ -290,14 +302,14 @@ int afs_UFSHandleLink(register struct vcache *avc, struct vrequest *areq) register afs_int32 code; /* two different formats, one for links protected 644, have a "." at the - end of the file name, which we turn into a null. Others, protected - 755, we add a null to the end of */ + * end of the file name, which we turn into a null. Others, protected + * 755, we add a null to the end of */ AFS_STATCNT(afs_UFSHandleLink); if (!avc->linkData) { tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 0); afs_Trace3(afs_iclSetp, CM_TRACE_UFSLINK, ICL_TYPE_POINTER, avc, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); + ICL_TYPE_POINTER, tdc, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length)); if (!tdc) { return EIO; } @@ -306,17 +318,19 @@ int afs_UFSHandleLink(register struct vcache *avc, struct vrequest *areq) afs_PutDCache(tdc); return EFAULT; } - if (avc->m.Mode & 0111) alen = len+1; /* regular link */ - else alen = len; /* mt point */ - rbuf = (char *) osi_AllocLargeSpace(AFS_LRALLOCSIZ); + if (avc->m.Mode & 0111) + alen = len + 1; /* regular link */ + else + alen = len; /* mt point */ + rbuf = (char *)osi_AllocLargeSpace(AFS_LRALLOCSIZ); tlen = len; ObtainReadLock(&tdc->lock); - tfile = osi_UFSOpen (tdc->f.inode); + tfile = osi_UFSOpen(tdc->f.inode); code = afs_osi_Read(tfile, -1, rbuf, tlen); osi_UFSClose(tfile); ReleaseReadLock(&tdc->lock); afs_PutDCache(tdc); - rbuf[alen-1] = '\0'; + rbuf[alen - 1] = '\0'; alen = strlen(rbuf) + 1; tp = afs_osi_Alloc(alen); /* make room for terminating null */ memcpy(tp, rbuf, alen); @@ -332,9 +346,9 @@ int afs_UFSHandleLink(register struct vcache *avc, struct vrequest *areq) int afs_readlink(OSI_VC_ARG(avc), auio, acred) - OSI_VC_DECL(avc); - struct uio *auio; - struct AFS_UCRED *acred; +OSI_VC_DECL(avc); + struct uio *auio; + struct AFS_UCRED *acred; { register afs_int32 code; struct vrequest treq; @@ -342,30 +356,34 @@ afs_readlink(OSI_VC_ARG(avc), auio, acred) struct afs_fakestat_state fakestat; OSI_VC_CONVERT(avc) - AFS_STATCNT(afs_readlink); + AFS_STATCNT(afs_readlink); afs_Trace1(afs_iclSetp, CM_TRACE_READLINK, ICL_TYPE_POINTER, avc); - if ((code = afs_InitReq(&treq, acred))) return code; + if ((code = afs_InitReq(&treq, acred))) + return code; afs_InitFakeStat(&fakestat); code = afs_EvalFakeStat(&avc, &fakestat, &treq); - if (code) goto done; + if (code) + goto done; code = afs_VerifyVCache(avc, &treq); - if (code) goto done; + if (code) + goto done; if (vType(avc) != VLNK) { code = EINVAL; goto done; } - ObtainWriteLock(&avc->lock,158); + ObtainWriteLock(&avc->lock, 158); code = afs_HandleLink(avc, &treq); /* finally uiomove it to user-land */ if (code == 0) { tp = avc->linkData; - if (tp) AFS_UIOMOVE(tp, strlen(tp), UIO_READ, auio, code); + if (tp) + AFS_UIOMOVE(tp, strlen(tp), UIO_READ, auio, code); else { code = EIO; } } ReleaseWriteLock(&avc->lock); -done: + done: afs_PutFakeStat(&fakestat); code = afs_CheckCode(code, &treq, 32); return code; diff --git a/src/afs/VNOPS/afs_vnop_write.c b/src/afs/VNOPS/afs_vnop_write.c index 387cf6396..2b8695c69 100644 --- a/src/afs/VNOPS/afs_vnop_write.c +++ b/src/afs/VNOPS/afs_vnop_write.c @@ -20,11 +20,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -37,10 +38,12 @@ extern unsigned char *afs_indexFlags; * afs_FlushActiveVCaches routine (when CCORE is on). * avc->lock must be write-locked. */ -int afs_StoreOnLastReference(register struct vcache *avc, register struct vrequest *treq) +int +afs_StoreOnLastReference(register struct vcache *avc, + register struct vrequest *treq) { int code = 0; - + AFS_STATCNT(afs_StoreOnLastReference); /* if CCore flag is set, we clear it and do the extra decrement * ourselves now. If we're called by the CCore clearer, the CCore @@ -57,9 +60,9 @@ int afs_StoreOnLastReference(register struct vcache *avc, register struct vreque * top level code. */ avc->opens--; avc->execsOrWriters--; - AFS_RELE(AFSTOV(avc)); /* VN_HOLD at set CCore(afs_FakeClose)*/ + AFS_RELE(AFSTOV(avc)); /* VN_HOLD at set CCore(afs_FakeClose) */ crfree((struct AFS_UCRED *)avc->linkData); /* "crheld" in afs_FakeClose */ - avc->linkData = NULL; + avc->linkData = NULL; } /* Now, send the file back. Used to require 0 writers left, but now do * it on every close for write, since two closes in a row are harmless @@ -68,7 +71,7 @@ int afs_StoreOnLastReference(register struct vcache *avc, register struct vreque * inadvertently, since with old system, writes to the server would never * happen again. */ - code = afs_StoreAllSegments(avc, treq, AFS_LASTSTORE/*!sync-to-disk*/); + code = afs_StoreAllSegments(avc, treq, AFS_LASTSTORE /*!sync-to-disk */ ); /* * We have to do these after the above store in done: in some systems like * aix they'll need to flush all the vm dirty pages to the disk via the @@ -86,8 +89,9 @@ int afs_StoreOnLastReference(register struct vcache *avc, register struct vreque -int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, - struct AFS_UCRED *acred, int noLock) +int +afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, + struct AFS_UCRED *acred, int noLock) { afs_size_t totalLength; afs_size_t transferLength; @@ -102,42 +106,43 @@ int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, #endif afs_int32 error; struct uio tuio; - struct iovec *tvec; /* again, should have define */ + struct iovec *tvec; /* again, should have define */ register afs_int32 code; struct vrequest treq; AFS_STATCNT(afs_MemWrite); if (avc->vc_error) - return avc->vc_error; + return avc->vc_error; startDate = osi_Time(); - if ((code = afs_InitReq(&treq, acred))) return code; + if ((code = afs_InitReq(&treq, acred))) + return code; /* otherwise we read */ totalLength = auio->afsio_resid; filePos = auio->afsio_offset; error = 0; transferLength = 0; - afs_Trace4(afs_iclSetp, CM_TRACE_WRITE, ICL_TYPE_POINTER, avc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(totalLength), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); + afs_Trace4(afs_iclSetp, CM_TRACE_WRITE, ICL_TYPE_POINTER, avc, + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(totalLength), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length)); if (!noLock) { afs_MaybeWakeupTruncateDaemon(); - ObtainWriteLock(&avc->lock,126); + ObtainWriteLock(&avc->lock, 126); } #if defined(AFS_SGI_ENV) { - off_t diff; - /* - * afs_xwrite handles setting m.Length - * and handles APPEND mode. - * Since we are called via strategy, we need to trim the write to - * the actual size of the file - */ - osi_Assert(filePos <= avc->m.Length); - diff = avc->m.Length - filePos; - auio->afsio_resid = MIN(totalLength, diff); - totalLength = auio->afsio_resid; + off_t diff; + /* + * afs_xwrite handles setting m.Length + * and handles APPEND mode. + * Since we are called via strategy, we need to trim the write to + * the actual size of the file + */ + osi_Assert(filePos <= avc->m.Length); + diff = avc->m.Length - filePos; + auio->afsio_resid = MIN(totalLength, diff); + totalLength = auio->afsio_resid; } #else if (aio & IO_APPEND) { @@ -152,11 +157,12 @@ int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, * Note that we use startDate rather than calling osi_Time() here. * This is to avoid counting lock-waiting time in file date (for ranlib). */ - avc->m.Date = startDate; + avc->m.Date = startDate; #if defined(AFS_HPUX_ENV) || defined(AFS_GFS_ENV) #if defined(AFS_HPUX101_ENV) - if ((totalLength + filePos) >> 9 > (p_rlimit(u.u_procp))[RLIMIT_FSIZE].rlim_cur) { + if ((totalLength + filePos) >> 9 > + (p_rlimit(u.u_procp))[RLIMIT_FSIZE].rlim_cur) { #else #ifdef AFS_HPUX_ENV if ((totalLength + filePos) >> 9 > u.u_rlimit[RLIMIT_FSIZE].rlim_cur) { @@ -175,13 +181,14 @@ int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, * high-level write op. */ if (avc->execsOrWriters <= 0) { - printf("WARNING: afs_ufswr vp=%x, exOrW=%d\n", avc, avc->execsOrWriters); + printf("WARNING: afs_ufswr vp=%x, exOrW=%d\n", avc, + avc->execsOrWriters); } #else afs_FakeOpen(avc); #endif avc->states |= CDirty; - tvec = (struct iovec *) osi_AllocSmallSpace(sizeof(struct iovec)); + tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec)); while (totalLength > 0) { /* Read the cached info. If we call GetDCache while the cache * truncate daemon is running we risk overflowing the disk cache. @@ -191,13 +198,15 @@ int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, */ if (noLock) { tdc = afs_FindDCache(avc, filePos); - if (tdc) ObtainWriteLock(&tdc->lock, 653); - } else if (afs_blocksUsed > (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100) { + if (tdc) + ObtainWriteLock(&tdc->lock, 653); + } else if (afs_blocksUsed > + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) { tdc = afs_FindDCache(avc, filePos); if (tdc) { ObtainWriteLock(&tdc->lock, 654); - if (!hsame(tdc->f.versionNo, avc->m.DataVersion) || - (tdc->dflags & DFFetching)) { + if (!hsame(tdc->f.versionNo, avc->m.DataVersion) + || (tdc->dflags & DFFetching)) { ReleaseWriteLock(&tdc->lock); afs_PutDCache(tdc); tdc = NULL; @@ -206,32 +215,34 @@ int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, if (!tdc) { afs_MaybeWakeupTruncateDaemon(); while (afs_blocksUsed > - (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100) { + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) { ReleaseWriteLock(&avc->lock); if (afs_blocksUsed - afs_blocksDiscarded > - (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100) { + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) { afs_WaitForCacheDrain = 1; afs_osi_Sleep(&afs_WaitForCacheDrain); } afs_MaybeFreeDiscardedDCache(); afs_MaybeWakeupTruncateDaemon(); - ObtainWriteLock(&avc->lock,506); + ObtainWriteLock(&avc->lock, 506); } avc->states |= CDirty; tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 4); - if (tdc) ObtainWriteLock(&tdc->lock, 655); + if (tdc) + ObtainWriteLock(&tdc->lock, 655); } } else { tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 4); - if (tdc) ObtainWriteLock(&tdc->lock, 656); + if (tdc) + ObtainWriteLock(&tdc->lock, 656); } if (!tdc) { error = EIO; break; } if (!(afs_indexFlags[tdc->index] & IFDataMod)) { - afs_stats_cmperf.cacheCurrDirtyChunks++; - afs_indexFlags[tdc->index] |= IFDataMod; /* so it doesn't disappear */ + afs_stats_cmperf.cacheCurrDirtyChunks++; + afs_indexFlags[tdc->index] |= IFDataMod; /* so it doesn't disappear */ } if (!(tdc->f.states & DWriting)) { /* don't mark entry as mod if we don't have to */ @@ -241,9 +252,9 @@ int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, len = totalLength; /* write this amount by default */ offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk); max = AFS_CHUNKTOSIZE(tdc->f.chunk); /* max size of this chunk */ - if (max <= len + offset) { /*if we'd go past the end of this chunk */ + if (max <= len + offset) { /*if we'd go past the end of this chunk */ /* it won't all fit in this chunk, so write as much - as will fit */ + * as will fit */ len = max - offset; } /* mung uio structure to be right for this transfer */ @@ -254,42 +265,41 @@ int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, code = afs_MemWriteUIO(tdc->f.inode, &tuio); if (code) { - void *mep; /* XXX in prototype world is struct memCacheEntry * */ + void *mep; /* XXX in prototype world is struct memCacheEntry * */ error = code; - ZapDCE(tdc); /* bad data */ + ZapDCE(tdc); /* bad data */ mep = afs_MemCacheOpen(tdc->f.inode); afs_MemCacheTruncate(mep, 0); afs_MemCacheClose(mep); afs_stats_cmperf.cacheCurrDirtyChunks--; - afs_indexFlags[tdc->index] &= ~IFDataMod; /* so it does disappear */ + afs_indexFlags[tdc->index] &= ~IFDataMod; /* so it does disappear */ ReleaseWriteLock(&tdc->lock); afs_PutDCache(tdc); break; } /* otherwise we've written some, fixup length, etc and continue with next seg */ - len = len - tuio.afsio_resid; /* compute amount really transferred */ + len = len - tuio.afsio_resid; /* compute amount really transferred */ tlen = len; - afsio_skip(auio, tlen); /* advance auio over data written */ + afsio_skip(auio, tlen); /* advance auio over data written */ /* compute new file size */ if (offset + len > tdc->f.chunkBytes) { - afs_int32 tlength = offset+len; + afs_int32 tlength = offset + len; afs_AdjustSize(tdc, tlength); - if (tdc->validPos < filePos + len) - tdc->validPos = filePos + len; + if (tdc->validPos < filePos + len) + tdc->validPos = filePos + len; } totalLength -= len; transferLength += len; filePos += len; #if defined(AFS_SGI_ENV) - /* afs_xwrite handles setting m.Length */ - osi_Assert(filePos <= avc->m.Length); + /* afs_xwrite handles setting m.Length */ + osi_Assert(filePos <= avc->m.Length); #else if (filePos > avc->m.Length) { - afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_LONG, __LINE__, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos)); + afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_LONG, __LINE__, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(filePos)); avc->m.Length = filePos; } #endif @@ -319,8 +329,8 @@ int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, osi_FreeSmallSpace(tvec); #ifdef AFS_DEC_ENV /* next, on GFS systems, we update g_size so that lseek's relative to EOF will - work. GFS is truly a poorly-designed interface! */ - afs_gfshack((struct gnode *) avc); + * work. GFS is truly a poorly-designed interface! */ + afs_gfshack((struct gnode *)avc); #endif error = afs_CheckCode(error, &treq, 6); return error; @@ -328,15 +338,16 @@ int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, /* called on writes */ -int afs_UFSWrite(register struct vcache *avc, struct uio *auio, - int aio, struct AFS_UCRED *acred, int noLock) +int +afs_UFSWrite(register struct vcache *avc, struct uio *auio, int aio, + struct AFS_UCRED *acred, int noLock) { afs_size_t totalLength; afs_size_t transferLength; afs_size_t filePos; afs_size_t offset, len; - afs_int32 tlen; - afs_int32 trimlen; + afs_int32 tlen; + afs_int32 trimlen; afs_int32 startDate; afs_int32 max; register struct dcache *tdc; @@ -345,49 +356,50 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, #endif afs_int32 error; struct uio tuio; - struct iovec *tvec; /* again, should have define */ + struct iovec *tvec; /* again, should have define */ struct osi_file *tfile; register afs_int32 code; struct vrequest treq; AFS_STATCNT(afs_UFSWrite); if (avc->vc_error) - return avc->vc_error; + return avc->vc_error; startDate = osi_Time(); - if ((code = afs_InitReq(&treq, acred))) return code; + if ((code = afs_InitReq(&treq, acred))) + return code; /* otherwise we read */ totalLength = auio->afsio_resid; filePos = auio->afsio_offset; error = 0; transferLength = 0; - afs_Trace4(afs_iclSetp, CM_TRACE_WRITE, ICL_TYPE_POINTER, avc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(totalLength), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); + afs_Trace4(afs_iclSetp, CM_TRACE_WRITE, ICL_TYPE_POINTER, avc, + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(totalLength), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length)); if (!noLock) { afs_MaybeWakeupTruncateDaemon(); - ObtainWriteLock(&avc->lock,556); + ObtainWriteLock(&avc->lock, 556); } #if defined(AFS_SGI_ENV) { - off_t diff; - /* - * afs_xwrite handles setting m.Length - * and handles APPEND mode. - * Since we are called via strategy, we need to trim the write to - * the actual size of the file - */ - osi_Assert(filePos <= avc->m.Length); - diff = avc->m.Length - filePos; - auio->afsio_resid = MIN(totalLength, diff); - totalLength = auio->afsio_resid; + off_t diff; + /* + * afs_xwrite handles setting m.Length + * and handles APPEND mode. + * Since we are called via strategy, we need to trim the write to + * the actual size of the file + */ + osi_Assert(filePos <= avc->m.Length); + diff = avc->m.Length - filePos; + auio->afsio_resid = MIN(totalLength, diff); + totalLength = auio->afsio_resid; } #else if (aio & IO_APPEND) { /* append mode, start it at the right spot */ #if defined(AFS_SUN56_ENV) - auio->uio_loffset = 0; + auio->uio_loffset = 0; #endif filePos = auio->afsio_offset = avc->m.Length; } @@ -396,11 +408,12 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, * Note that we use startDate rather than calling osi_Time() here. * This is to avoid counting lock-waiting time in file date (for ranlib). */ - avc->m.Date = startDate; + avc->m.Date = startDate; #if defined(AFS_HPUX_ENV) || defined(AFS_GFS_ENV) #if defined(AFS_HPUX101_ENV) - if ((totalLength + filePos) >> 9 > p_rlimit(u.u_procp)[RLIMIT_FSIZE].rlim_cur) { + if ((totalLength + filePos) >> 9 > + p_rlimit(u.u_procp)[RLIMIT_FSIZE].rlim_cur) { #else #ifdef AFS_HPUX_ENV if ((totalLength + filePos) >> 9 > u.u_rlimit[RLIMIT_FSIZE].rlim_cur) { @@ -419,16 +432,17 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, * high-level write op. */ if (avc->execsOrWriters <= 0) { - printf("WARNING: afs_ufswr vcp=%x, exOrW=%d\n", avc, avc->execsOrWriters); + printf("WARNING: afs_ufswr vcp=%x, exOrW=%d\n", avc, + avc->execsOrWriters); } #else afs_FakeOpen(avc); #endif avc->states |= CDirty; - tvec = (struct iovec *) osi_AllocSmallSpace(sizeof(struct iovec)); + tvec = (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec)); while (totalLength > 0) { - /* - * The following line is necessary because afs_GetDCache with + /* + * The following line is necessary because afs_GetDCache with * flag == 4 expects the length field to be filled. It decides * from this whether it's necessary to fetch data into the chunk * before writing or not (when the whole chunk is overwritten!). @@ -437,13 +451,15 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, /* read the cached info */ if (noLock) { tdc = afs_FindDCache(avc, filePos); - if (tdc) ObtainWriteLock(&tdc->lock, 657); - } else if (afs_blocksUsed > (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100) { + if (tdc) + ObtainWriteLock(&tdc->lock, 657); + } else if (afs_blocksUsed > + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) { tdc = afs_FindDCache(avc, filePos); if (tdc) { ObtainWriteLock(&tdc->lock, 658); - if (!hsame(tdc->f.versionNo, avc->m.DataVersion) || - (tdc->dflags & DFFetching)) { + if (!hsame(tdc->f.versionNo, avc->m.DataVersion) + || (tdc->dflags & DFFetching)) { ReleaseWriteLock(&tdc->lock); afs_PutDCache(tdc); tdc = NULL; @@ -452,32 +468,34 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, if (!tdc) { afs_MaybeWakeupTruncateDaemon(); while (afs_blocksUsed > - (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100) { + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) { ReleaseWriteLock(&avc->lock); if (afs_blocksUsed - afs_blocksDiscarded > - (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100) { + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) { afs_WaitForCacheDrain = 1; afs_osi_Sleep(&afs_WaitForCacheDrain); } afs_MaybeFreeDiscardedDCache(); afs_MaybeWakeupTruncateDaemon(); - ObtainWriteLock(&avc->lock,509); + ObtainWriteLock(&avc->lock, 509); } avc->states |= CDirty; tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 4); - if (tdc) ObtainWriteLock(&tdc->lock, 659); + if (tdc) + ObtainWriteLock(&tdc->lock, 659); } } else { tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 4); - if (tdc) ObtainWriteLock(&tdc->lock, 660); + if (tdc) + ObtainWriteLock(&tdc->lock, 660); } if (!tdc) { error = EIO; break; } if (!(afs_indexFlags[tdc->index] & IFDataMod)) { - afs_stats_cmperf.cacheCurrDirtyChunks++; - afs_indexFlags[tdc->index] |= IFDataMod; /* so it doesn't disappear */ + afs_stats_cmperf.cacheCurrDirtyChunks++; + afs_indexFlags[tdc->index] |= IFDataMod; /* so it doesn't disappear */ } if (!(tdc->f.states & DWriting)) { /* don't mark entry as mod if we don't have to */ @@ -488,9 +506,9 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, len = totalLength; /* write this amount by default */ offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk); max = AFS_CHUNKTOSIZE(tdc->f.chunk); /* max size of this chunk */ - if (max <= len + offset) { /*if we'd go past the end of this chunk */ + if (max <= len + offset) { /*if we'd go past the end of this chunk */ /* it won't all fit in this chunk, so write as much - as will fit */ + * as will fit */ len = max - offset; } /* mung uio structure to be right for this transfer */ @@ -501,13 +519,17 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, #ifdef AFS_AIX_ENV #ifdef AFS_AIX41_ENV AFS_GUNLOCK(); - code = VNOP_RDWR(tfile->vnode, UIO_WRITE, FWRITE, &tuio, NULL, NULL, NULL, &afs_osi_cred); + code = + VNOP_RDWR(tfile->vnode, UIO_WRITE, FWRITE, &tuio, NULL, NULL, + NULL, &afs_osi_cred); AFS_GLOCK(); #else #ifdef AFS_AIX32_ENV code = VNOP_RDWR(tfile->vnode, UIO_WRITE, FWRITE, &tuio, NULL, NULL); #else - code = VNOP_RDWR(tfile->vnode, UIO_WRITE, FWRITE, (off_t)&offset, &tuio, NULL, NULL, -1); + code = + VNOP_RDWR(tfile->vnode, UIO_WRITE, FWRITE, (off_t) & offset, + &tuio, NULL, NULL, -1); #endif #endif /* AFS_AIX41_ENV */ #else /* AFS_AIX_ENV */ @@ -517,34 +539,36 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, code = VOP_WRITE(tfile->vnode, &tuio, 0, &afs_osi_cred); VOP_RWUNLOCK(tfile->vnode, 1); AFS_GLOCK(); - if (code == ENOSPC) afs_warnuser("\n\n\n*** Cache partition is full - decrease cachesize!!! ***\n\n\n"); + if (code == ENOSPC) + afs_warnuser + ("\n\n\n*** Cache partition is full - decrease cachesize!!! ***\n\n\n"); #else #if defined(AFS_SGI_ENV) AFS_GUNLOCK(); - avc->states |= CWritingUFS; + avc->states |= CWritingUFS; AFS_VOP_RWLOCK(tfile->vnode, VRWLOCK_WRITE); AFS_VOP_WRITE(tfile->vnode, &tuio, IO_ISLOCKED, &afs_osi_cred, code); AFS_VOP_RWUNLOCK(tfile->vnode, VRWLOCK_WRITE); - avc->states &= ~CWritingUFS; + avc->states &= ~CWritingUFS; AFS_GLOCK(); #else #ifdef AFS_OSF_ENV - { - struct ucred *tmpcred = u.u_cred; - u.u_cred = &afs_osi_cred; - tuio.uio_rw = UIO_WRITE; - AFS_GUNLOCK(); - VOP_WRITE(tfile->vnode, &tuio, 0, &afs_osi_cred, code); - AFS_GLOCK(); - u.u_cred = tmpcred; - } -#else /* AFS_OSF_ENV */ + { + struct ucred *tmpcred = u.u_cred; + u.u_cred = &afs_osi_cred; + tuio.uio_rw = UIO_WRITE; + AFS_GUNLOCK(); + VOP_WRITE(tfile->vnode, &tuio, 0, &afs_osi_cred, code); + AFS_GLOCK(); + u.u_cred = tmpcred; + } +#else /* AFS_OSF_ENV */ #if defined(AFS_HPUX100_ENV) - { - AFS_GUNLOCK(); - code = VOP_RDWR(tfile->vnode, &tuio, UIO_WRITE, 0, &afs_osi_cred); - AFS_GLOCK(); - } + { + AFS_GUNLOCK(); + code = VOP_RDWR(tfile->vnode, &tuio, UIO_WRITE, 0, &afs_osi_cred); + AFS_GLOCK(); + } #else #ifdef AFS_HPUX_ENV tuio.uio_fpflags &= ~FSYNCIO; /* don't do sync io */ @@ -555,18 +579,18 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, AFS_GLOCK(); #else #if defined(AFS_DARWIN_ENV) - AFS_GUNLOCK(); - VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc()); - code = VOP_WRITE(tfile->vnode, &tuio, 0, &afs_osi_cred); - VOP_UNLOCK(tfile->vnode, 0, current_proc()); - AFS_GLOCK(); + AFS_GUNLOCK(); + VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, current_proc()); + code = VOP_WRITE(tfile->vnode, &tuio, 0, &afs_osi_cred); + VOP_UNLOCK(tfile->vnode, 0, current_proc()); + AFS_GLOCK(); #else #if defined(AFS_XBSD_ENV) - AFS_GUNLOCK(); - VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curproc); - code = VOP_WRITE(tfile->vnode, &tuio, 0, &afs_osi_cred); - VOP_UNLOCK(tfile->vnode, 0, curproc); - AFS_GLOCK(); + AFS_GUNLOCK(); + VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curproc); + code = VOP_WRITE(tfile->vnode, &tuio, 0, &afs_osi_cred); + VOP_UNLOCK(tfile->vnode, 0, curproc); + AFS_GLOCK(); #else code = VOP_RDWR(tfile->vnode, &tuio, UIO_WRITE, 0, &afs_osi_cred); #endif /* AFS_XBSD_ENV */ @@ -579,40 +603,39 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, #endif /* AFS_AIX41_ENV */ if (code) { error = code; - ZapDCE(tdc); /* bad data */ - osi_UFSTruncate(tfile,0); /* fake truncate the segment */ - afs_AdjustSize(tdc, 0); /* sets f.chunkSize to 0 */ + ZapDCE(tdc); /* bad data */ + osi_UFSTruncate(tfile, 0); /* fake truncate the segment */ + afs_AdjustSize(tdc, 0); /* sets f.chunkSize to 0 */ afs_stats_cmperf.cacheCurrDirtyChunks--; - afs_indexFlags[tdc->index] &= ~IFDataMod; /* so it does disappear */ + afs_indexFlags[tdc->index] &= ~IFDataMod; /* so it does disappear */ afs_CFileClose(tfile); ReleaseWriteLock(&tdc->lock); afs_PutDCache(tdc); break; } /* otherwise we've written some, fixup length, etc and continue with next seg */ - len = len - tuio.afsio_resid; /* compute amount really transferred */ + len = len - tuio.afsio_resid; /* compute amount really transferred */ tlen = len; - afsio_skip(auio, tlen); /* advance auio over data written */ + afsio_skip(auio, tlen); /* advance auio over data written */ /* compute new file size */ if (offset + len > tdc->f.chunkBytes) { - afs_int32 tlength = offset+len; + afs_int32 tlength = offset + len; afs_AdjustSize(tdc, tlength); - if (tdc->validPos < filePos + len) - tdc->validPos = filePos + len; + if (tdc->validPos < filePos + len) + tdc->validPos = filePos + len; } totalLength -= len; transferLength += len; filePos += len; #if defined(AFS_SGI_ENV) - /* afs_xwrite handles setting m.Length */ - osi_Assert(filePos <= avc->m.Length); + /* afs_xwrite handles setting m.Length */ + osi_Assert(filePos <= avc->m.Length); #else if (filePos > avc->m.Length) { - afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_LONG, __LINE__, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos)); + afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_LONG, __LINE__, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(filePos)); avc->m.Length = filePos; } #endif @@ -645,8 +668,8 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, osi_FreeSmallSpace(tvec); #ifdef AFS_DEC_ENV /* next, on GFS systems, we update g_size so that lseek's relative to EOF will - work. GFS is truly a poorly-designed interface! */ - afs_gfshack((struct gnode *) avc); + * work. GFS is truly a poorly-designed interface! */ + afs_gfshack((struct gnode *)avc); #endif #ifndef AFS_VM_RDWR_ENV /* @@ -654,14 +677,14 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, * write op. */ #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - if (noLock && (aio & IO_SYNC)) { -#else + if (noLock && (aio & IO_SYNC)) { +#else #ifdef AFS_HPUX_ENV /* On hpux on synchronous writes syncio will be set to IO_SYNC. If * we're doing them because the file was opened with O_SYNCIO specified, * we have to look in the u area. No single mechanism here!! */ - if (noLock && ((aio & IO_SYNC) | (auio->uio_fpflags & FSYNCIO))) { + if (noLock && ((aio & IO_SYNC) | (auio->uio_fpflags & FSYNCIO))) { #else if (noLock && (aio & FSYNC)) { #endif @@ -674,15 +697,17 @@ int afs_UFSWrite(register struct vcache *avc, struct uio *auio, } /* do partial write if we're low on unmodified chunks */ -int afs_DoPartialWrite(register struct vcache *avc, struct vrequest *areq) +int +afs_DoPartialWrite(register struct vcache *avc, struct vrequest *areq) { register afs_int32 code; - if (afs_stats_cmperf.cacheCurrDirtyChunks <= afs_stats_cmperf.cacheMaxDirtyChunks) - return 0; /* nothing to do */ + if (afs_stats_cmperf.cacheCurrDirtyChunks <= + afs_stats_cmperf.cacheMaxDirtyChunks) + return 0; /* nothing to do */ /* otherwise, call afs_StoreDCache (later try to do this async, if possible) */ afs_Trace2(afs_iclSetp, CM_TRACE_PARTIALWRITE, ICL_TYPE_POINTER, avc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); #if defined(AFS_SUN5_ENV) code = afs_StoreAllSegments(avc, areq, AFS_ASYNC | AFS_VMSYNC_INVAL); #else @@ -714,7 +739,8 @@ int afs_DoPartialWrite(register struct vcache *avc, struct vrequest *areq) * N.B: Intercepting close syscall doesn't trap aborts or exit system * calls. */ -int afs_closex(register struct file *afd) +int +afs_closex(register struct file *afd) { struct vrequest treq; struct vcache *tvc; @@ -725,7 +751,8 @@ int afs_closex(register struct file *afd) AFS_STATCNT(afs_closex); /* setup the credentials */ - if ((code = afs_InitReq(&treq, u.u_cred))) return code; + if ((code = afs_InitReq(&treq, u.u_cred))) + return code; afs_InitFakeStat(&fakestat); closeDone = 0; @@ -744,15 +771,15 @@ int afs_closex(register struct file *afd) flags = afd->f_flag & (FSHLOCK | FEXLOCK); afd->f_flag &= ~(FSHLOCK | FEXLOCK); code = vno_close(afd); - if (flags) + if (flags) #if defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV) - HandleFlock(tvc, LOCK_UN, &treq, - u.u_procp->p_pid, 1/*onlymine*/); + HandleFlock(tvc, LOCK_UN, &treq, u.u_procp->p_pid, + 1 /*onlymine */ ); #else - HandleFlock(tvc, LOCK_UN, &treq, 0, 1/*onlymine*/); + HandleFlock(tvc, LOCK_UN, &treq, 0, 1 /*onlymine */ ); #endif #ifdef AFS_DEC_ENV - grele((struct gnode *) tvc); + grele((struct gnode *)tvc); #else AFS_RELE(AFSTOV(tvc)); #endif @@ -764,7 +791,7 @@ int afs_closex(register struct file *afd) code = vno_close(afd); } afs_PutFakeStat(&fakestat); - return code; /* return code from vnode layer */ + return code; /* return code from vnode layer */ } #endif @@ -780,28 +807,28 @@ afs_close(OSI_VC_ARG(avc), aflags, lastclose, #if defined(AFS_SGI64_ENV) && !defined(AFS_SGI65_ENV) , flp #endif - ) -lastclose_t lastclose; + ) + lastclose_t lastclose; #if !defined(AFS_SGI65_ENV) -off_t offset; + off_t offset; #if defined(AFS_SGI64_ENV) -struct flid *flp; + struct flid *flp; #endif #endif #elif defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV) #ifdef AFS_SUN5_ENV afs_close(OSI_VC_ARG(avc), aflags, count, offset, acred) - offset_t offset; + offset_t offset; #else afs_close(OSI_VC_ARG(avc), aflags, count, acred) #endif -int count; + int count; #else afs_close(OSI_VC_ARG(avc), aflags, acred) #endif - OSI_VC_DECL(avc); - afs_int32 aflags; - struct AFS_UCRED *acred; +OSI_VC_DECL(avc); + afs_int32 aflags; + struct AFS_UCRED *acred; { register afs_int32 code; register struct brequest *tb; @@ -812,11 +839,12 @@ afs_close(OSI_VC_ARG(avc), aflags, acred) struct afs_fakestat_state fakestat; OSI_VC_CONVERT(avc) - AFS_STATCNT(afs_close); + AFS_STATCNT(afs_close); afs_Trace2(afs_iclSetp, CM_TRACE_CLOSE, ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, aflags); code = afs_InitReq(&treq, acred); - if (code) return code; + if (code) + return code; afs_InitFakeStat(&fakestat); code = afs_EvalFakeStat(&avc, &fakestat, &treq); if (code) { @@ -825,13 +853,13 @@ afs_close(OSI_VC_ARG(avc), aflags, acred) } #ifdef AFS_SUN5_ENV if (avc->flockCount) { - HandleFlock(avc, LOCK_UN, &treq, 0, 1/*onlymine*/); + HandleFlock(avc, LOCK_UN, &treq, 0, 1 /*onlymine */ ); } #endif #if defined(AFS_SGI_ENV) if (!lastclose) { afs_PutFakeStat(&fakestat); - return 0; + return 0; } #elif defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) if (count > 1) { @@ -843,27 +871,27 @@ afs_close(OSI_VC_ARG(avc), aflags, acred) #ifndef AFS_SUN5_ENV #if defined(AFS_SGI_ENV) /* unlock any locks for pid - could be wrong for child .. */ - AFS_RWLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE); #ifdef AFS_SGI65_ENV get_current_flid(&flid); - cleanlocks((vnode_t *)avc, flid.fl_pid, flid.fl_sysid); - HandleFlock(avc, LOCK_UN, &treq, flid.fl_pid, 1/*onlymine*/); + cleanlocks((vnode_t *) avc, flid.fl_pid, flid.fl_sysid); + HandleFlock(avc, LOCK_UN, &treq, flid.fl_pid, 1 /*onlymine */ ); #else #ifdef AFS_SGI64_ENV - cleanlocks((vnode_t *)avc, flp); + cleanlocks((vnode_t *) avc, flp); #else /* AFS_SGI64_ENV */ - cleanlocks((vnode_t *)avc, u.u_procp->p_epid, u.u_procp->p_sysid); + cleanlocks((vnode_t *) avc, u.u_procp->p_epid, u.u_procp->p_sysid); #endif /* AFS_SGI64_ENV */ - HandleFlock(avc, LOCK_UN, &treq, OSI_GET_CURRENT_PID(), 1/*onlymine*/); + HandleFlock(avc, LOCK_UN, &treq, OSI_GET_CURRENT_PID(), 1 /*onlymine */ ); #endif /* AFS_SGI65_ENV */ /* afs_chkpgoob will drop and re-acquire the global lock. */ afs_chkpgoob(&avc->v, btoc(avc->m.Length)); #else /* AFS_SGI_ENV */ - if (avc->flockCount) { /* Release Lock */ + if (avc->flockCount) { /* Release Lock */ #if defined(AFS_OSF_ENV) || defined(AFS_SUN_ENV) - HandleFlock(avc, LOCK_UN, &treq, u.u_procp->p_pid, 1/*onlymine*/); + HandleFlock(avc, LOCK_UN, &treq, u.u_procp->p_pid, 1 /*onlymine */ ); #else - HandleFlock(avc, LOCK_UN, &treq, 0, 1/*onlymine*/); + HandleFlock(avc, LOCK_UN, &treq, 0, 1 /*onlymine */ ); #endif } #endif /* AFS_SGI_ENV */ @@ -871,22 +899,21 @@ afs_close(OSI_VC_ARG(avc), aflags, acred) if (aflags & (FWRITE | FTRUNC)) { if (afs_BBusy()) { /* do it yourself if daemons are all busy */ - ObtainWriteLock(&avc->lock,124); + ObtainWriteLock(&avc->lock, 124); code = afs_StoreOnLastReference(avc, &treq); ReleaseWriteLock(&avc->lock); #if defined(AFS_SGI_ENV) - AFS_RWUNLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE); #endif - } - else { + } else { #if defined(AFS_SGI_ENV) - AFS_RWUNLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE); #endif /* at least one daemon is idle, so ask it to do the store. - Also, note that we don't lock it any more... */ - tb = afs_BQueue(BOP_STORE, avc, 0, 1, acred, - (afs_size_t) acred->cr_uid, (afs_size_t) 0, - (void *) 0); + * Also, note that we don't lock it any more... */ + tb = afs_BQueue(BOP_STORE, avc, 0, 1, acred, + (afs_size_t) acred->cr_uid, (afs_size_t) 0, + (void *)0); /* sleep waiting for the store to start, then retrieve error code */ while ((tb->flags & BUVALID) == 0) { tb->flags |= BUWAIT; @@ -897,16 +924,16 @@ afs_close(OSI_VC_ARG(avc), aflags, acred) } /* VNOVNODE is "acceptable" error code from close, since - may happen when deleting a file on another machine while - it is open here. We do the same for ENOENT since in afs_CheckCode we map VNOVNODE -> ENOENT */ + * may happen when deleting a file on another machine while + * it is open here. We do the same for ENOENT since in afs_CheckCode we map VNOVNODE -> ENOENT */ if (code == VNOVNODE || code == ENOENT) code = 0; - + /* Ensure last closer gets the error. If another thread caused * DoPartialWrite and this thread does not actually store the data, * it may not see the quota error. */ - ObtainWriteLock(&avc->lock,406); + ObtainWriteLock(&avc->lock, 406); if (avc->vc_error) { #ifdef AFS_AIX32_ENV osi_ReleaseVM(avc, acred); @@ -922,13 +949,13 @@ afs_close(OSI_VC_ARG(avc), aflags, acred) } #ifdef AFS_SUN5_ENV else if (code == ENOSPC) { - afs_warnuser("afs: failed to store file (over quota or partition full)\n"); + afs_warnuser + ("afs: failed to store file (over quota or partition full)\n"); } #else else if (code == ENOSPC) { afs_warnuser("afs: failed to store file (partition full)\n"); - } - else if (code == EDQUOT) { + } else if (code == EDQUOT) { afs_warnuser("afs: failed to store file (over quota)\n"); } #endif @@ -938,10 +965,9 @@ afs_close(OSI_VC_ARG(avc), aflags, acred) /* finally, we flush any text pages lying around here */ hzero(avc->flushDV); osi_FlushText(avc); - } - else { + } else { #if defined(AFS_SGI_ENV) - AFS_RWUNLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE); osi_Assert(avc->opens > 0); #endif /* file open for read */ @@ -970,25 +996,25 @@ afs_close(OSI_VC_ARG(avc), aflags, acred) int #ifdef AFS_OSF_ENV afs_fsync(avc, fflags, acred, waitfor) -int fflags; -int waitfor; -#else /* AFS_OSF_ENV */ + int fflags; + int waitfor; +#else /* AFS_OSF_ENV */ #if defined(AFS_SGI_ENV) || defined(AFS_SUN53_ENV) afs_fsync(OSI_VC_ARG(avc), flag, acred #ifdef AFS_SGI65_ENV - , start, stop + , start, stop #endif - ) + ) #else afs_fsync(avc, acred) #endif #endif - OSI_VC_DECL(avc); +OSI_VC_DECL(avc); struct AFS_UCRED *acred; #if defined(AFS_SGI_ENV) || defined(AFS_SUN53_ENV) -int flag; + int flag; #ifdef AFS_SGI65_ENV -off_t start, stop; + off_t start, stop; #endif #endif { @@ -996,41 +1022,41 @@ off_t start, stop; struct vrequest treq; OSI_VC_CONVERT(avc) - if (avc->vc_error) + if (avc->vc_error) return avc->vc_error; #if defined(AFS_SUN5_ENV) - /* back out if called from NFS server */ + /* back out if called from NFS server */ if (curthread->t_flag & T_DONTPEND) return 0; #endif AFS_STATCNT(afs_fsync); afs_Trace1(afs_iclSetp, CM_TRACE_FSYNC, ICL_TYPE_POINTER, avc); - if ((code = afs_InitReq(&treq, acred))) return code; + if ((code = afs_InitReq(&treq, acred))) + return code; #if defined(AFS_SGI_ENV) - AFS_RWLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE); if (flag & FSYNC_INVAL) osi_VM_FSyncInval(avc); #endif /* AFS_SGI_ENV */ - ObtainSharedLock(&avc->lock,18); + ObtainSharedLock(&avc->lock, 18); code = 0; if (avc->execsOrWriters > 0) { /* put the file back */ - UpgradeSToWLock(&avc->lock,41); + UpgradeSToWLock(&avc->lock, 41); code = afs_StoreAllSegments(avc, &treq, AFS_SYNC); ConvertWToSLock(&avc->lock); } - #if defined(AFS_SGI_ENV) - AFS_RWUNLOCK((vnode_t *)avc, VRWLOCK_WRITE); + AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE); if (code == VNOVNODE) { /* syncing an unlinked file! - non-informative to pass an errno * 102 (== VNOVNODE) to user */ - code = ENOENT; + code = ENOENT; } #endif diff --git a/src/afs/afs.h b/src/afs/afs.h index b47683f64..77abf0773 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -61,26 +61,26 @@ extern int afs_shuttingdown; /* The basic defines for the Andrew file system better keep things powers of two so "& (foo-1)" hack works for masking bits */ -#define MAXHOSTS 13 /* max hosts per single volume */ -#define OMAXHOSTS 8 /* backwards compatibility */ -#define MAXCELLHOSTS 8 /* max vldb servers per cell */ -#define NBRS 15 /* max number of queued daemon requests */ -#define NUSERS 16 /* hash table size for unixuser table */ -#define NSERVERS 16 /* hash table size for server table */ -#define NVOLS 64 /* hash table size for volume table */ -#define NFENTRIES 256 /* hash table size for disk volume table */ -#define VCSIZE 1024 /* stat cache hash table size */ -#define DCSIZE 512 /* disk cache hash table size */ -#define PIGGYSIZE 1350 /* max piggyback size */ -#define MAXVOLS 128 /* max vols we can store */ -#define MAXSYSNAME 128 /* max sysname (i.e. @sys) size */ -#define MAXNUMSYSNAMES 16 /* max that current constants allow */ -#define NOTOKTIMEOUT (2*3600) /* time after which to timeout conns sans tokens */ +#define MAXHOSTS 13 /* max hosts per single volume */ +#define OMAXHOSTS 8 /* backwards compatibility */ +#define MAXCELLHOSTS 8 /* max vldb servers per cell */ +#define NBRS 15 /* max number of queued daemon requests */ +#define NUSERS 16 /* hash table size for unixuser table */ +#define NSERVERS 16 /* hash table size for server table */ +#define NVOLS 64 /* hash table size for volume table */ +#define NFENTRIES 256 /* hash table size for disk volume table */ +#define VCSIZE 1024 /* stat cache hash table size */ +#define DCSIZE 512 /* disk cache hash table size */ +#define PIGGYSIZE 1350 /* max piggyback size */ +#define MAXVOLS 128 /* max vols we can store */ +#define MAXSYSNAME 128 /* max sysname (i.e. @sys) size */ +#define MAXNUMSYSNAMES 16 /* max that current constants allow */ +#define NOTOKTIMEOUT (2*3600) /* time after which to timeout conns sans tokens */ #define NOPAG 0xffffffff -#define AFS_NCBRS 300 /* max # of call back return entries */ -#define AFS_MAXCBRSCALL 16 /* max to return in a given call */ -#define AFS_SALLOC_LOW_WATER 250 /* Min free blocks before allocating more */ -#define AFS_LRALLOCSIZ 4096 /* "Large" allocated size */ +#define AFS_NCBRS 300 /* max # of call back return entries */ +#define AFS_MAXCBRSCALL 16 /* max to return in a given call */ +#define AFS_SALLOC_LOW_WATER 250 /* Min free blocks before allocating more */ +#define AFS_LRALLOCSIZ 4096 /* "Large" allocated size */ #define VCACHE_FREE 5 #define AFS_NRXPACKETS 80 #define AFS_RXDEADTIME 50 @@ -90,13 +90,13 @@ extern afs_int32 afs_rx_deadtime; extern afs_int32 afs_rx_harddead; struct sysname_info { - char *name; - short offset; - char index, allocked; + char *name; + short offset; + char index, allocked; }; /* flags to use with AFSOP_CACHEINIT */ -#define AFSCALL_INIT_MEMCACHE 0x1 /* use a memory-based cache */ +#define AFSCALL_INIT_MEMCACHE 0x1 /* use a memory-based cache */ /* below here used only for kernel procedures */ #ifdef KERNEL @@ -111,12 +111,12 @@ struct sysname_info { /* background request structure */ #define BPARMS 4 -#define BOP_NOOP 0 /* leave 0 unused */ -#define BOP_FETCH 1 /* parm1 is chunk to get */ -#define BOP_STORE 2 /* parm1 is chunk to store */ -#define BOP_PATH 3 /* parm1 is path, parm2 is chunk to fetch */ +#define BOP_NOOP 0 /* leave 0 unused */ +#define BOP_FETCH 1 /* parm1 is chunk to get */ +#define BOP_STORE 2 /* parm1 is chunk to store */ +#define BOP_PATH 3 /* parm1 is path, parm2 is chunk to fetch */ -#define B_DONTWAIT 1 /* On failure return; don't wait */ +#define B_DONTWAIT 1 /* On failure return; don't wait */ /* protocol is: refCount is incremented by user to take block out of free pool. Next, BSTARTED is set when daemon finds request. This prevents @@ -124,19 +124,19 @@ struct sysname_info { request is done, refCount is zeroed. BDONE and BWAIT are used by dudes waiting for operation to proceed to a certain point before returning. */ -#define BSTARTED 1 /* request picked up by a daemon */ -#define BUVALID 2 /* code is valid (store) */ -#define BUWAIT 4 /* someone is waiting for BUVALID */ +#define BSTARTED 1 /* request picked up by a daemon */ +#define BUVALID 2 /* code is valid (store) */ +#define BUWAIT 4 /* someone is waiting for BUVALID */ struct brequest { - struct vcache *vc; /* vnode to use, with vrefcount bumped */ - struct AFS_UCRED *cred; /* credentials to use for operation */ - afs_size_t size_parm[BPARMS]; /* random parameters */ - void *ptr_parm[BPARMS]; /* pointer parameters */ - afs_int32 code; /* return code */ - short refCount; /* use counter for this structure */ - char opcode; /* what to do (store, fetch, etc) */ - char flags; /* free, etc */ - afs_int32 ts; /* counter "timestamp" */ + struct vcache *vc; /* vnode to use, with vrefcount bumped */ + struct AFS_UCRED *cred; /* credentials to use for operation */ + afs_size_t size_parm[BPARMS]; /* random parameters */ + void *ptr_parm[BPARMS]; /* pointer parameters */ + afs_int32 code; /* return code */ + short refCount; /* use counter for this structure */ + char opcode; /* what to do (store, fetch, etc) */ + char flags; /* free, etc */ + afs_int32 ts; /* counter "timestamp" */ }; struct SecretToken { @@ -144,15 +144,15 @@ struct SecretToken { }; struct ClearToken { - afs_int32 AuthHandle; - char HandShakeKey[8]; - afs_int32 ViceId; - afs_int32 BeginTimestamp; - afs_int32 EndTimestamp; + afs_int32 AuthHandle; + char HandShakeKey[8]; + afs_int32 ViceId; + afs_int32 BeginTimestamp; + afs_int32 EndTimestamp; }; struct VenusFid { - afs_int32 Cell; /* better sun packing if at end of structure */ + afs_int32 Cell; /* better sun packing if at end of structure */ struct AFSFid Fid; }; @@ -175,9 +175,9 @@ struct afs_q { }; struct vrequest { - afs_int32 uid; /* user id making the request */ - afs_int32 busyCount; /* how many busies we've seen so far */ - afs_int32 flags; /* things like O_SYNC, O_NONBLOCK go here */ + afs_int32 uid; /* user id making the request */ + afs_int32 busyCount; /* how many busies we've seen so far */ + afs_int32 flags; /* things like O_SYNC, O_NONBLOCK go here */ char initd; /* if non-zero, non-uid fields meaningful */ char accessError; /* flags for overriding error return code */ char volumeError; /* encountered a missing or busy volume */ @@ -206,18 +206,18 @@ struct afs_cbr { #define CLinkedCell 0x20 /* has a linked cell in lcellp */ struct cell { - struct afs_q lruq; /* lru q next and prev */ - char *cellName; /* char string name of cell */ - afs_int32 cellIndex; /* sequence number */ - afs_int32 cellNum; /* semi-permanent cell number */ - struct server *cellHosts[MAXCELLHOSTS]; /* volume *location* hosts */ - struct cell *lcellp; /* Associated linked cell */ - u_short fsport; /* file server port */ - u_short vlport; /* volume server port */ - short states; /* state flags */ - time_t timeout; /* data expire time, if non-zero */ - struct cell_name *cnamep; /* pointer to our cell_name */ - afs_rwlock_t lock; /* protects cell data */ + struct afs_q lruq; /* lru q next and prev */ + char *cellName; /* char string name of cell */ + afs_int32 cellIndex; /* sequence number */ + afs_int32 cellNum; /* semi-permanent cell number */ + struct server *cellHosts[MAXCELLHOSTS]; /* volume *location* hosts */ + struct cell *lcellp; /* Associated linked cell */ + u_short fsport; /* file server port */ + u_short vlport; /* volume server port */ + short states; /* state flags */ + time_t timeout; /* data expire time, if non-zero */ + struct cell_name *cnamep; /* pointer to our cell_name */ + afs_rwlock_t lock; /* protects cell data */ }; struct cell_name { @@ -237,11 +237,11 @@ struct cell_alias { #define afs_PutCell(cellp, locktype) /* the unixuser flag bit definitions */ -#define UHasTokens 1 /* are the st and ct fields valid (ever set)? */ -#define UTokensBad 2 /* are tokens bad? */ -#define UPrimary 4 /* on iff primary identity */ -#define UNeedsReset 8 /* needs afs_ResetAccessCache call done */ -#define UPAGCounted 16 /* entry seen during PAG search (for stats) */ +#define UHasTokens 1 /* are the st and ct fields valid (ever set)? */ +#define UTokensBad 2 /* are tokens bad? */ +#define UPrimary 4 /* on iff primary identity */ +#define UNeedsReset 8 /* needs afs_ResetAccessCache call done */ +#define UPAGCounted 16 /* entry seen during PAG search (for stats) */ /* A flag used by afs_GCPAGs to keep track of * which entries in afs_users need to be deleted. * The lifetime of its presence in the table is the @@ -250,47 +250,39 @@ struct cell_alias { #define TMP_UPAGNotReferenced 128 /* values for afs_gcpags */ -enum -{ AFS_GCPAGS_NOTCOMPILED = 0 -, AFS_GCPAGS_OK = 1 -, AFS_GCPAGS_USERDISABLED -, AFS_GCPAGS_EPROC0 -, AFS_GCPAGS_EPROCN -, AFS_GCPAGS_EEQPID -, AFS_GCPAGS_EINEXACT -, AFS_GCPAGS_EPROCEND -, AFS_GCPAGS_EPROCWALK -, AFS_GCPAGS_ECREDWALK -, AFS_GCPAGS_EPIDCHECK -, AFS_GCPAGS_ENICECHECK +enum { AFS_GCPAGS_NOTCOMPILED = 0, AFS_GCPAGS_OK = + 1, AFS_GCPAGS_USERDISABLED, AFS_GCPAGS_EPROC0, AFS_GCPAGS_EPROCN, + AFS_GCPAGS_EEQPID, AFS_GCPAGS_EINEXACT, AFS_GCPAGS_EPROCEND, + AFS_GCPAGS_EPROCWALK, AFS_GCPAGS_ECREDWALK, AFS_GCPAGS_EPIDCHECK, + AFS_GCPAGS_ENICECHECK }; extern afs_int32 afs_gcpags; extern afs_int32 afs_gcpags_procsize; struct unixuser { - struct unixuser *next; /* next hash pointer */ - afs_int32 uid; /* search based on uid and cell */ + struct unixuser *next; /* next hash pointer */ + afs_int32 uid; /* search based on uid and cell */ afs_int32 cell; - afs_int32 vid; /* corresponding vice id in specified cell */ - short refCount; /* reference count for allocation */ - char states; /* flag info */ - afs_int32 tokenTime; /* last time tokens were set, used for timing out conn data */ - afs_int32 stLen; /* ticket length (if kerberos, includes kvno at head) */ - char *stp; /* pointer to ticket itself */ + afs_int32 vid; /* corresponding vice id in specified cell */ + short refCount; /* reference count for allocation */ + char states; /* flag info */ + afs_int32 tokenTime; /* last time tokens were set, used for timing out conn data */ + afs_int32 stLen; /* ticket length (if kerberos, includes kvno at head) */ + char *stp; /* pointer to ticket itself */ struct ClearToken ct; - struct afs_exporter *exporter; /* more info about the exporter for the remote user */ + struct afs_exporter *exporter; /* more info about the exporter for the remote user */ }; struct conn { /* Per-connection block. */ - struct conn *next; /* Next dude same server. */ - struct unixuser *user; /* user validated with respect to. */ - struct rx_connection *id; /* RPC connid. */ - struct srvAddr *srvr; /* server associated with this conn */ - short refCount; /* reference count for allocation */ - unsigned short port; /* port associated with this connection */ - char forceConnectFS; /* Should we try again with these tokens? */ + struct conn *next; /* Next dude same server. */ + struct unixuser *user; /* user validated with respect to. */ + struct rx_connection *id; /* RPC connid. */ + struct srvAddr *srvr; /* server associated with this conn */ + short refCount; /* reference count for allocation */ + unsigned short port; /* port associated with this connection */ + char forceConnectFS; /* Should we try again with these tokens? */ }; @@ -333,13 +325,13 @@ struct conn { #define SRVADDR_MH 1 #define SRVADDR_ISDOWN 0x20 /* same as SRVR_ISDOWN */ -#define SRVADDR_NOUSE 0x40 /* Don't use this srvAddr */ +#define SRVADDR_NOUSE 0x40 /* Don't use this srvAddr */ struct srvAddr { - struct srvAddr *next_bkt; /* next item in hash bucket */ - struct srvAddr *next_sa; /* another interface on same host */ + struct srvAddr *next_bkt; /* next item in hash bucket */ + struct srvAddr *next_sa; /* another interface on same host */ struct server *server; /* back to parent */ - struct conn *conns; /* All user connections to this server */ - afs_int32 sa_ip; /* Host addr in network byte order */ + struct conn *conns; /* All user connections to this server */ + afs_int32 sa_ip; /* Host addr in network byte order */ u_short sa_iprank; /* indiv ip address priority */ u_short sa_portal; /* port addr in network byte order */ u_char sa_flags; @@ -359,7 +351,7 @@ struct srvAddr { #define SRVR_MULTIHOMED 0x40 #define SRVR_ISGONE 0x80 #define SNO_INLINEBULK 0x100 -#define SNO_64BIT 0x200 +#define SNO_64BIT 0x200 #define afs_serverSetNo64Bit(s) ((s)->srvr->server->flags |= SNO_64BIT) #define afs_serverHasNo64Bit(s) ((s)->srvr->server->flags & SNO_64BIT) @@ -371,9 +363,9 @@ struct server { afs_int32 addr_uniquifier; afs_int32 spares[2]; } _srvUuid; - struct { + struct { struct srvAddr haddr; - } _srvId; + } _srvId; } _suid; #define sr_uuid _suid._srvUuid.suuid #define sr_addr_uniquifier _suid._srvUuid.addr_uniquifier @@ -383,112 +375,109 @@ struct server { #define sr_flags _suid._srvId.haddr.flags #define sr_conns _suid._srvId.haddr.conns struct server *next; /* Ptr to next server in hash chain */ - struct cell *cell; /* Cell in which this host resides */ + struct cell *cell; /* Cell in which this host resides */ struct afs_cbr *cbrs; /* Return list of callbacks */ afs_int32 activationTime; /* Time when this record was first activated */ afs_int32 lastDowntimeStart; /* Time when last downtime incident began */ afs_int32 numDowntimeIncidents; /* # (completed) downtime incidents */ afs_int32 sumOfDowntimes; /* Total downtime experienced, in seconds */ struct srvAddr *addr; - afs_uint32 flags; /* Misc flags*/ + afs_uint32 flags; /* Misc flags */ }; -#define afs_PutServer(servp, locktype) +#define afs_PutServer(servp, locktype) /* structs for some pioctls - these are (or should be) * also in venus.h */ struct spref { - struct in_addr host; - unsigned short rank; + struct in_addr host; + unsigned short rank; }; struct sprefrequest_33 { - unsigned short offset; - unsigned short num_servers; + unsigned short offset; + unsigned short num_servers; }; -struct sprefrequest { /* new struct for 3.4 */ - unsigned short offset; - unsigned short num_servers; - unsigned short flags; +struct sprefrequest { /* new struct for 3.4 */ + unsigned short offset; + unsigned short num_servers; + unsigned short flags; }; #define DBservers 1 struct sprefinfo { - unsigned short next_offset; - unsigned short num_servers; - struct spref servers[1]; /* we overrun this array intentionally...*/ + unsigned short next_offset; + unsigned short num_servers; + struct spref servers[1]; /* we overrun this array intentionally... */ }; struct setspref { - unsigned short flags; - unsigned short num_servers; - struct spref servers[1]; /* we overrun this array intentionally...*/ + unsigned short flags; + unsigned short num_servers; + struct spref servers[1]; /* we overrun this array intentionally... */ }; /* struct for GAG pioctl */ struct gaginfo { - afs_uint32 showflags, logflags, logwritethruflag, spare[3]; - unsigned char spare2[128]; + afs_uint32 showflags, logflags, logwritethruflag, spare[3]; + unsigned char spare2[128]; }; #define GAGUSER 1 #define GAGCONSOLE 2 #define logwritethruON 1 struct rxparams { - afs_int32 rx_initReceiveWindow, rx_maxReceiveWindow, - rx_initSendWindow, rx_maxSendWindow, rxi_nSendFrags, - rxi_nRecvFrags, rxi_OrphanFragSize; - afs_int32 rx_maxReceiveSize, rx_MyMaxSendSize; - afs_uint32 spare[21]; - }; + afs_int32 rx_initReceiveWindow, rx_maxReceiveWindow, rx_initSendWindow, + rx_maxSendWindow, rxi_nSendFrags, rxi_nRecvFrags, rxi_OrphanFragSize; + afs_int32 rx_maxReceiveSize, rx_MyMaxSendSize; + afs_uint32 spare[21]; +}; /* struct for checkservers */ -struct chservinfo -{ - int magic; - char tbuffer[128]; - int tsize; - afs_int32 tinterval; - afs_int32 tflags; -} -; +struct chservinfo { + int magic; + char tbuffer[128]; + int tsize; + afs_int32 tinterval; + afs_int32 tflags; +}; /* state bits for volume */ -#define VRO 1 /* volume is readonly */ -#define VRecheck 2 /* recheck volume info with server */ -#define VBackup 4 /* is this a backup volume? */ -#define VForeign 8 /* this is a non-afs volume */ -#define VResort 16 /* server order was rearranged, sort when able */ -#define VMoreReps 32 /* This volume has more replicas than we are */ - /* keeping track of now -- check with VLDB */ +#define VRO 1 /* volume is readonly */ +#define VRecheck 2 /* recheck volume info with server */ +#define VBackup 4 /* is this a backup volume? */ +#define VForeign 8 /* this is a non-afs volume */ +#define VResort 16 /* server order was rearranged, sort when able */ +#define VMoreReps 32 /* This volume has more replicas than we are */ + /* keeping track of now -- check with VLDB */ - enum repstate { not_busy, end_not_busy = 6, rd_busy, rdwr_busy, offline }; +enum repstate { not_busy, end_not_busy = 6, rd_busy, rdwr_busy, offline }; struct volume { /* One structure per volume, describing where the volume is located - and where its mount points are. */ + * and where its mount points are. */ struct volume *next; /* Next volume in hash list. */ - afs_int32 cell; /* the cell in which the volume resides */ + afs_int32 cell; /* the cell in which the volume resides */ afs_rwlock_t lock; /* the lock for this structure */ afs_int32 volume; /* This volume's ID number. */ char *name; /* This volume's name, or 0 if unknown */ - struct server *serverHost[MAXHOSTS]; /* servers serving this volume */ - enum repstate status[MAXHOSTS]; /* busy, offline, etc */ + struct server *serverHost[MAXHOSTS]; /* servers serving this volume */ + enum repstate status[MAXHOSTS]; /* busy, offline, etc */ struct VenusFid dotdot; /* dir to access as .. */ struct VenusFid mtpoint; /* The mount point for this volume. */ afs_int32 rootVnode, rootUnique; /* Volume's root fid */ afs_int32 roVol; afs_int32 backVol; - afs_int32 rwVol; /* For r/o vols, original read/write volume. */ - afs_int32 accessTime; /* last time we used it */ - afs_int32 vtix; /* volume table index */ + afs_int32 rwVol; /* For r/o vols, original read/write volume. */ + afs_int32 accessTime; /* last time we used it */ + afs_int32 vtix; /* volume table index */ afs_int32 copyDate; /* copyDate field, for tracking vol releases */ - afs_int32 expireTime; /* for per-volume callbacks... */ + afs_int32 expireTime; /* for per-volume callbacks... */ short refCount; /* reference count for allocation */ char states; /* here for alignment reasons */ }; @@ -497,9 +486,9 @@ struct volume { /* format of an entry in volume info file */ struct fvolume { - afs_int32 cell; /* cell for this entry */ + afs_int32 cell; /* cell for this entry */ afs_int32 volume; /* volume */ - afs_int32 next; /* has index */ + afs_int32 next; /* has index */ struct VenusFid dotdot; /* .. value */ struct VenusFid mtpoint; /* mt point's fid */ afs_int32 rootVnode, rootUnique; /* Volume's root fid */ @@ -585,27 +574,27 @@ struct SimpleLocks { #define DCOUNT(d) ((d)->d_count) #endif -#define AFS_MAXDV 0x7fffffff /* largest dataversion number */ +#define AFS_MAXDV 0x7fffffff /* largest dataversion number */ #ifdef AFS_64BIT_CLIENT -#define AFS_NOTRUNC 0x7fffffffffffffffLL /* largest positive int64 number */ +#define AFS_NOTRUNC 0x7fffffffffffffffLL /* largest positive int64 number */ #else /* AFS_64BIT_CLIENT */ -#define AFS_NOTRUNC 0x7fffffff /* largest dataversion number */ +#define AFS_NOTRUNC 0x7fffffff /* largest dataversion number */ #endif /* AFS_64BIT_CLIENT */ -extern afs_int32 vmPageHog; /* counter for # of vnodes which are page hogs. */ +extern afs_int32 vmPageHog; /* counter for # of vnodes which are page hogs. */ /* * Fast map from vcache to dcache */ struct vtodc { - struct dcache * dc; - afs_uint32 stamp; - struct osi_file * f; - afs_offs_t minLoc; /* smallest offset into dc. */ - afs_offs_t len; /* largest offset into dc. */ + struct dcache *dc; + afs_uint32 stamp; + struct osi_file *f; + afs_offs_t minLoc; /* smallest offset into dc. */ + afs_offs_t len; /* largest offset into dc. */ }; -extern afs_uint32 afs_stampValue; /* stamp for pair's usage */ +extern afs_uint32 afs_stampValue; /* stamp for pair's usage */ #define MakeStamp() (++afs_stampValue) #if defined(AFS_OBSD_ENV) @@ -629,28 +618,28 @@ struct vcache { #if defined(AFS_OBSD_ENV) struct vnode *v; #else - struct vnode v; /* Has reference count in v.v_count */ + struct vnode v; /* Has reference count in v.v_count */ #endif - struct afs_q vlruq; /* lru q next and prev */ - struct vcache *nextfree; /* next on free list (if free) */ - struct vcache *hnext; /* Hash next */ + struct afs_q vlruq; /* lru q next and prev */ + struct vcache *nextfree; /* next on free list (if free) */ + struct vcache *hnext; /* Hash next */ struct VenusFid fid; struct mstat { - afs_size_t Length; - afs_hyper_t DataVersion; - afs_uint32 Date; - afs_uint32 Owner; + afs_size_t Length; + afs_hyper_t DataVersion; + afs_uint32 Date; + afs_uint32 Owner; afs_uint32 Group; - ushort Mode; /* XXXX Should be afs_int32 XXXX */ - ushort LinkCount; + ushort Mode; /* XXXX Should be afs_int32 XXXX */ + ushort LinkCount; /* vnode type is in v.v_type */ } m; - afs_rwlock_t lock; /* The lock on the vcache contents. */ + afs_rwlock_t lock; /* The lock on the vcache contents. */ #if defined(AFS_SUN5_ENV) /* Lock used to protect the activeV, multipage, and vstates fields. * Do not try to get the vcache lock when the vlock is held */ afs_rwlock_t vlock; -#endif /* defined(AFS_SUN5_ENV) */ +#endif /* defined(AFS_SUN5_ENV) */ #if defined(AFS_SUN5_ENV) krwlock_t rwlock; struct cred *credp; @@ -664,76 +653,76 @@ struct vcache { #if defined(AFS_AIX51_ENV) vmid_t segid; #else - int segid; + int segid; #endif struct ucred *credp; #endif #ifdef AFS_AIX_ENV - int ownslock; /* pid of owner of excl lock, else 0 - defect 3083 */ + int ownslock; /* pid of owner of excl lock, else 0 - defect 3083 */ #endif #ifdef AFS_DARWIN_ENV - struct lock__bsd__ rwlock; + struct lock__bsd__ rwlock; #endif #ifdef AFS_XBSD_ENV - struct lock rwlock; + struct lock rwlock; #endif - afs_int32 parentVnode; /* Parent dir, if a file. */ + afs_int32 parentVnode; /* Parent dir, if a file. */ afs_int32 parentUnique; - struct VenusFid *mvid; /* Either parent dir (if root) or root (if mt pt) */ - char *linkData; /* Link data if a symlink. */ - afs_hyper_t flushDV; /* data version last flushed from text */ - afs_hyper_t mapDV; /* data version last flushed from map */ - afs_size_t truncPos; /* truncate file to this position at next store */ - struct server *callback; /* The callback host, if any */ - afs_uint32 cbExpires; /* time the callback expires */ - struct afs_q callsort; /* queue in expiry order, sort of */ - struct axscache *Access; /* a list of cached access bits */ - afs_int32 anyAccess; /* System:AnyUser's access to this. */ - afs_int32 last_looker; /* pag/uid from last lookup here */ + struct VenusFid *mvid; /* Either parent dir (if root) or root (if mt pt) */ + char *linkData; /* Link data if a symlink. */ + afs_hyper_t flushDV; /* data version last flushed from text */ + afs_hyper_t mapDV; /* data version last flushed from map */ + afs_size_t truncPos; /* truncate file to this position at next store */ + struct server *callback; /* The callback host, if any */ + afs_uint32 cbExpires; /* time the callback expires */ + struct afs_q callsort; /* queue in expiry order, sort of */ + struct axscache *Access; /* a list of cached access bits */ + afs_int32 anyAccess; /* System:AnyUser's access to this. */ + afs_int32 last_looker; /* pag/uid from last lookup here */ #if defined(AFS_SUN5_ENV) afs_int32 activeV; -#endif /* defined(AFS_SUN5_ENV) */ +#endif /* defined(AFS_SUN5_ENV) */ struct SimpleLocks *slocks; - short opens; /* The numbers of opens, read or write, on this file. */ - short execsOrWriters; /* The number of execs (if < 0) or writers (if > 0) of - this file. */ - short flockCount; /* count of flock readers, or -1 if writer */ - char mvstat; /* 0->normal, 1->mt pt, 2->root. */ - afs_uint32 states; /* state bits */ + short opens; /* The numbers of opens, read or write, on this file. */ + short execsOrWriters; /* The number of execs (if < 0) or writers (if > 0) of + * this file. */ + short flockCount; /* count of flock readers, or -1 if writer */ + char mvstat; /* 0->normal, 1->mt pt, 2->root. */ + afs_uint32 states; /* state bits */ #if defined(AFS_SUN5_ENV) - afs_uint32 vstates; /* vstate bits */ -#endif /* defined(AFS_SUN5_ENV) */ + afs_uint32 vstates; /* vstate bits */ +#endif /* defined(AFS_SUN5_ENV) */ struct vtodc quick; afs_uint32 symhintstamp; union { - struct vcache *symhint; - struct dcache *dchint; + struct vcache *symhint; + struct dcache *dchint; } h1; #ifdef AFS_LINUX22_ENV - u_short flushcnt; /* Number of flushes which haven't released yet. */ - u_short mapcnt; /* Number of mappings of this file. */ + u_short flushcnt; /* Number of flushes which haven't released yet. */ + u_short mapcnt; /* Number of mappings of this file. */ #endif #if defined(AFS_SGI_ENV) - daddr_t lastr; /* for read-ahead */ + daddr_t lastr; /* for read-ahead */ #ifdef AFS_SGI64_ENV - uint64_t vc_rwlockid; /* kthread owning rwlock */ + uint64_t vc_rwlockid; /* kthread owning rwlock */ #else - short vc_rwlockid; /* pid of process owning rwlock */ + short vc_rwlockid; /* pid of process owning rwlock */ #endif - short vc_locktrips; /* # of rwlock reacquisitions */ - sema_t vc_rwlock; /* vop_rwlock for afs */ - pgno_t mapcnt; /* # of pages mapped */ - struct cred *cred; /* last writer's cred */ + short vc_locktrips; /* # of rwlock reacquisitions */ + sema_t vc_rwlock; /* vop_rwlock for afs */ + pgno_t mapcnt; /* # of pages mapped */ + struct cred *cred; /* last writer's cred */ #ifdef AFS_SGI64_ENV struct bhv_desc vc_bhv_desc; /* vnode's behavior data. */ #endif -#endif /* AFS_SGI_ENV */ - afs_int32 vc_error; /* stash write error for this vnode. */ - int xlatordv; /* Used by nfs xlator */ +#endif /* AFS_SGI_ENV */ + afs_int32 vc_error; /* stash write error for this vnode. */ + int xlatordv; /* Used by nfs xlator */ struct AFS_UCRED *uncred; - int asynchrony; /* num kbytes to store behind */ + int asynchrony; /* num kbytes to store behind */ #ifdef AFS_SUN5_ENV - short multiPage; /* count of multi-page getpages in progress */ + short multiPage; /* count of multi-page getpages in progress */ #endif }; @@ -742,7 +731,7 @@ struct vcache { #define DONT_CHECK_MODE_BITS 0 #define CHECK_MODE_BITS 1 -#define CMB_ALLOW_EXEC_AS_READ 2 /* For the NFS xlator */ +#define CMB_ALLOW_EXEC_AS_READ 2 /* For the NFS xlator */ #if defined(AFS_SGI_ENV) #define AVCRWLOCK(avc) (valusema(&(avc)->vc_rwlock) <= 0) @@ -758,7 +747,7 @@ struct vcache { #ifdef AFS_SGI53_ENV #ifdef AFS_SGI62_ENV #define AFS_RWLOCK_T vrwlock_t -#else +#else #define AFS_RWLOCK_T int #endif /* AFS_SGI62_ENV */ #ifdef AFS_SGI64_ENV @@ -782,7 +771,7 @@ struct vcxstat { struct VenusFid fid; afs_hyper_t DataVersion; afs_rwlock_t lock; - afs_int32 parentVnode; + afs_int32 parentVnode; afs_int32 parentUnique; afs_hyper_t flushDV; afs_hyper_t mapDV; @@ -800,14 +789,14 @@ struct vcxstat { }; struct sbstruct { - int sb_thisfile; - int sb_default; + int sb_thisfile; + int sb_default; }; /* CM inititialization parameters. What CM actually used after calculations * based on passed in arguments. */ -#define CMI_VERSION 1 /* increment when adding new fields. */ +#define CMI_VERSION 1 /* increment when adding new fields. */ struct cm_initparams { int cmi_version; int cmi_nChunkFiles; @@ -816,10 +805,10 @@ struct cm_initparams { int cmi_nVolumeCaches; int cmi_firstChunkSize; int cmi_otherChunkSize; - int cmi_cacheSize; /* The original cache size, in 1K blocks. */ + int cmi_cacheSize; /* The original cache size, in 1K blocks. */ unsigned cmi_setTime:1; unsigned cmi_memCache:1; - int spare[16-9]; /* size of struct is 16 * 4 = 64 bytes */ + int spare[16 - 9]; /* size of struct is 16 * 4 = 64 bytes */ }; @@ -855,19 +844,19 @@ struct cm_initparams { /* flags in afs_indexFlags array */ -#define IFEverUsed 1 /* index entry has >= 1 byte of data */ -#define IFFree 2 /* index entry in freeDCList */ -#define IFDataMod 4 /* file needs to be written out */ -#define IFFlag 8 /* utility flag */ +#define IFEverUsed 1 /* index entry has >= 1 byte of data */ +#define IFFree 2 /* index entry in freeDCList */ +#define IFDataMod 4 /* file needs to be written out */ +#define IFFlag 8 /* utility flag */ #define IFDirtyPages 16 #define IFAnyPages 32 -#define IFDiscarded 64 /* index entry in discardDCList */ +#define IFDiscarded 64 /* index entry in discardDCList */ struct afs_ioctl { - char *in; /* input buffer */ - char *out; /* output buffer */ - short in_size; /* Size of input buffer <= 2K */ - short out_size; /* Maximum size of output buffer, <= 2K */ + char *in; /* input buffer */ + char *out; /* output buffer */ + short in_size; /* Size of input buffer <= 2K */ + short out_size; /* Maximum size of output buffer, <= 2K */ }; /* @@ -890,7 +879,7 @@ struct afs_ioctl32 { * instead of using it. */ struct afs_fheader { -#define AFS_FHMAGIC 0x7635abaf /* uses version number */ +#define AFS_FHMAGIC 0x7635abaf /* uses version number */ afs_int32 magic; #if defined(AFS_SUN57_64BIT_ENV) #define AFS_CI_VERSION 3 @@ -944,7 +933,7 @@ struct dcache { afs_rwlock_t tlock; /* Atomizes updates to refCount */ afs_rwlock_t mflock; /* Atomizes accesses/updates to mflags */ afs_size_t validPos; /* number of valid bytes during fetch */ - afs_int32 index; /* The index in the CacheInfo file*/ + afs_int32 index; /* The index in the CacheInfo file */ short refCount; /* Associated reference count. */ char dflags; /* Data flags */ char mflags; /* Meta flags */ @@ -983,7 +972,7 @@ struct dcache { */ }; /* this is obsolete and should be removed */ -#define ihint stamp +#define ihint stamp /* macro to mark a dcache entry as bad */ #define ZapDCE(x) \ @@ -1025,9 +1014,9 @@ struct dcache { avc->opens--; \ avc->execsOrWriters--; \ } \ -} +} -#define AFS_ZEROS 64 /* zero buffer */ +#define AFS_ZEROS 64 /* zero buffer */ /*#define afs_DirtyPages(avc) (((avc)->states & CDirty) || osi_VMDirty_p((avc)))*/ #define afs_DirtyPages(avc) ((avc)->states & CDirty) @@ -1038,31 +1027,31 @@ struct dcache { */ /* extern int afs_dhashsize; */ #define DCHash(v, c) ((((v)->Fid.Vnode + (v)->Fid.Volume + (c))) & (afs_dhashsize-1)) - /*Vnode, Chunk -> Hash table index*/ + /*Vnode, Chunk -> Hash table index */ #define DVHash(v) ((((v)->Fid.Vnode + (v)->Fid.Volume )) & (afs_dhashsize-1)) - /*Vnode -> Other hash table index*/ + /*Vnode -> Other hash table index */ /* don't hash on the cell, our callback-breaking code sometimes fails to compute the cell correctly, and only scans one hash bucket */ #define VCHash(fid) (((fid)->Fid.Volume + (fid)->Fid.Vnode) & (VCSIZE-1)) -extern struct dcache **afs_indexTable; /*Pointers to in-memory dcache entries*/ -extern afs_int32 *afs_indexUnique; /*dcache entry Fid.Unique */ -extern afs_int32 *afs_dvnextTbl; /*Dcache hash table links */ -extern afs_int32 *afs_dcnextTbl; /*Dcache hash table links */ -extern afs_int32 afs_cacheFiles; /*Size of afs_indexTable*/ -extern afs_int32 afs_cacheBlocks; /*1K blocks in cache*/ -extern afs_int32 afs_cacheStats; /*Stat entries in cache*/ -extern struct vcache *afs_vhashT[VCSIZE]; /*Stat cache hash table*/ -extern afs_int32 afs_initState; /*Initialization state*/ -extern afs_int32 afs_termState; /* Termination state */ -extern struct VenusFid afs_rootFid; /*Root for whole file system*/ -extern afs_int32 afs_allCBs; /* Count of callbacks*/ -extern afs_int32 afs_oddCBs; /* Count of odd callbacks*/ -extern afs_int32 afs_evenCBs; /* Count of even callbacks*/ -extern afs_int32 afs_allZaps; /* Count of fid deletes */ -extern afs_int32 afs_oddZaps; /* Count of odd fid deletes */ -extern afs_int32 afs_evenZaps; /* Count of even fid deletes */ -extern struct brequest afs_brs[NBRS]; /* request structures */ +extern struct dcache **afs_indexTable; /*Pointers to in-memory dcache entries */ +extern afs_int32 *afs_indexUnique; /*dcache entry Fid.Unique */ +extern afs_int32 *afs_dvnextTbl; /*Dcache hash table links */ +extern afs_int32 *afs_dcnextTbl; /*Dcache hash table links */ +extern afs_int32 afs_cacheFiles; /*Size of afs_indexTable */ +extern afs_int32 afs_cacheBlocks; /*1K blocks in cache */ +extern afs_int32 afs_cacheStats; /*Stat entries in cache */ +extern struct vcache *afs_vhashT[VCSIZE]; /*Stat cache hash table */ +extern afs_int32 afs_initState; /*Initialization state */ +extern afs_int32 afs_termState; /* Termination state */ +extern struct VenusFid afs_rootFid; /*Root for whole file system */ +extern afs_int32 afs_allCBs; /* Count of callbacks */ +extern afs_int32 afs_oddCBs; /* Count of odd callbacks */ +extern afs_int32 afs_evenCBs; /* Count of even callbacks */ +extern afs_int32 afs_allZaps; /* Count of fid deletes */ +extern afs_int32 afs_oddZaps; /* Count of odd fid deletes */ +extern afs_int32 afs_evenZaps; /* Count of even fid deletes */ +extern struct brequest afs_brs[NBRS]; /* request structures */ #define UHash(auid) ((auid) & (NUSERS-1)) #define VHash(avol) ((avol)&(NVOLS-1)) @@ -1088,7 +1077,7 @@ extern struct brequest afs_brs[NBRS]; /* request structures */ #endif #endif -#define DO_STATS 1 /* bits used by FindVCache */ +#define DO_STATS 1 /* bits used by FindVCache */ #define DO_VLRU 2 /* values for flag param of afs_CheckVolumeNames */ @@ -1121,12 +1110,12 @@ extern struct brequest afs_brs[NBRS]; /* request structures */ * afs_GetDownD wakes those processes once the cache is 95% full * (CM_CACHESIZEDRAINEDPCT). */ -#define CM_MAXDISCARDEDCHUNKS 16 /* # of chunks */ -#define CM_DCACHECOUNTFREEPCT 95 /* max pct of chunks in use */ -#define CM_DCACHESPACEFREEPCT 90 /* max pct of space in use */ -#define CM_DCACHEEXTRAPCT 5 /* extra to get when freeing */ -#define CM_CACHESIZEDRAINEDPCT 95 /* wakeup processes when down to here.*/ -#define CM_WAITFORDRAINPCT 98 /* sleep if cache is this full. */ +#define CM_MAXDISCARDEDCHUNKS 16 /* # of chunks */ +#define CM_DCACHECOUNTFREEPCT 95 /* max pct of chunks in use */ +#define CM_DCACHESPACEFREEPCT 90 /* max pct of space in use */ +#define CM_DCACHEEXTRAPCT 5 /* extra to get when freeing */ +#define CM_CACHESIZEDRAINEDPCT 95 /* wakeup processes when down to here. */ +#define CM_WAITFORDRAINPCT 98 /* sleep if cache is this full. */ #define afs_CacheIsTooFull() \ (afs_blocksUsed - afs_blocksDiscarded > \ @@ -1135,7 +1124,7 @@ extern struct brequest afs_brs[NBRS]; /* request structures */ ((100-CM_DCACHECOUNTFREEPCT)*afs_cacheFiles)/100) /* Handy max length of a numeric string. */ -#define CVBS 12 /* max afs_int32 is 2^32 ~ 4*10^9, +1 for NULL, +luck */ +#define CVBS 12 /* max afs_int32 is 2^32 ~ 4*10^9, +1 for NULL, +luck */ #define refpanic(foo) if (afs_norefpanic) \ { printf( foo ); afs_norefpanic++;} else osi_Panic( foo ) @@ -1204,7 +1193,7 @@ struct afs_fakestat_state { extern int afs_fakestat_enable; struct buffer { - ino_t fid[1]; /* Unique cache key + i/o addressing */ + ino_t fid[1]; /* Unique cache key + i/o addressing */ afs_int32 page; afs_int32 accesstime; struct buffer *hashNext; @@ -1215,15 +1204,15 @@ struct buffer { #if AFS_USEBUFFERS struct buf *bufp; #endif - afs_rwlock_t lock; /* the lock for this structure */ + afs_rwlock_t lock; /* the lock for this structure */ }; /* afs_memcache.c */ struct memCacheEntry { - int size; /* # of valid bytes in this entry */ - int dataSize; /* size of allocated data area */ + int size; /* # of valid bytes in this entry */ + int dataSize; /* size of allocated data area */ afs_lock_t afs_memLock; - char *data; /* bytes */ + char *data; /* bytes */ }; /* First 32 bits of capabilities */ @@ -1231,5 +1220,4 @@ struct memCacheEntry { #define CAPABILITY_BITS 1 -#endif /* _AFS_H_ */ - +#endif /* _AFS_H_ */ diff --git a/src/afs/afs_analyze.c b/src/afs/afs_analyze.c index 5dcad918c..275a826b7 100644 --- a/src/afs/afs_analyze.c +++ b/src/afs/afs_analyze.c @@ -13,7 +13,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/stds.h" #include "afs/sysincludes.h" /* Standard vendor system headers */ @@ -33,7 +34,7 @@ RCSID("$Header$"); #endif /* !UKERNEL */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #include "afs/afs_util.h" #include "afs/unified_afs.h" @@ -64,150 +65,155 @@ RCSID("$Header$"); #endif /* vlserver error base define */ -int afs_BusyWaitPeriod = 15; /* poll every 15 seconds */ +int afs_BusyWaitPeriod = 15; /* poll every 15 seconds */ -afs_int32 hm_retry_RO=0; /* don't wait */ -afs_int32 hm_retry_RW=0; /* don't wait */ -afs_int32 hm_retry_int=0; /* don't wait */ +afs_int32 hm_retry_RO = 0; /* don't wait */ +afs_int32 hm_retry_RW = 0; /* don't wait */ +afs_int32 hm_retry_int = 0; /* don't wait */ static int et2sys[512]; -void init_et_to_sys_error(void) { +void +init_et_to_sys_error(void) +{ memset(&et2sys, 0, sizeof(et2sys)); - et2sys[(UAEPERM-ERROR_TABLE_BASE_uae)] = EPERM; - et2sys[(UAENOENT-ERROR_TABLE_BASE_uae)] = ENOENT; - et2sys[(UAESRCH-ERROR_TABLE_BASE_uae)] = ESRCH; - et2sys[(UAEINTR-ERROR_TABLE_BASE_uae)] = EINTR; - et2sys[(UAEIO-ERROR_TABLE_BASE_uae)] = EIO; - et2sys[(UAENXIO-ERROR_TABLE_BASE_uae)] = ENXIO; - et2sys[(UAE2BIG-ERROR_TABLE_BASE_uae)] = E2BIG; - et2sys[(UAENOEXEC-ERROR_TABLE_BASE_uae)] = ENOEXEC; - et2sys[(UAEBADF-ERROR_TABLE_BASE_uae)] = EBADF; - et2sys[(UAECHILD-ERROR_TABLE_BASE_uae)] = ECHILD; - et2sys[(UAEAGAIN-ERROR_TABLE_BASE_uae)] = EAGAIN; - et2sys[(UAENOMEM-ERROR_TABLE_BASE_uae)] = ENOMEM; - et2sys[(UAEACCES-ERROR_TABLE_BASE_uae)] = EACCES; - et2sys[(UAEFAULT-ERROR_TABLE_BASE_uae)] = EFAULT; - et2sys[(UAENOTBLK-ERROR_TABLE_BASE_uae)] = ENOTBLK; - et2sys[(UAEBUSY-ERROR_TABLE_BASE_uae)] = EBUSY; - et2sys[(UAEEXIST-ERROR_TABLE_BASE_uae)] = EEXIST; - et2sys[(UAEXDEV-ERROR_TABLE_BASE_uae)] = EXDEV; - et2sys[(UAENODEV-ERROR_TABLE_BASE_uae)] = ENODEV; - et2sys[(UAENOTDIR-ERROR_TABLE_BASE_uae)] = ENOTDIR; - et2sys[(UAEISDIR-ERROR_TABLE_BASE_uae)] = EISDIR; - et2sys[(UAEINVAL-ERROR_TABLE_BASE_uae)] = EINVAL; - et2sys[(UAENFILE-ERROR_TABLE_BASE_uae)] = ENFILE; - et2sys[(UAEMFILE-ERROR_TABLE_BASE_uae)] = EMFILE; - et2sys[(UAENOTTY-ERROR_TABLE_BASE_uae)] = ENOTTY; - et2sys[(UAETXTBSY-ERROR_TABLE_BASE_uae)] = ETXTBSY; - et2sys[(UAEFBIG-ERROR_TABLE_BASE_uae)] = EFBIG; - et2sys[(UAENOSPC-ERROR_TABLE_BASE_uae)] = ENOSPC; - et2sys[(UAESPIPE-ERROR_TABLE_BASE_uae)] = ESPIPE; - et2sys[(UAEROFS-ERROR_TABLE_BASE_uae)] = EROFS; - et2sys[(UAEMLINK-ERROR_TABLE_BASE_uae)] = EMLINK; - et2sys[(UAEPIPE-ERROR_TABLE_BASE_uae)] = EPIPE; - et2sys[(UAEDOM-ERROR_TABLE_BASE_uae)] = EDOM; - et2sys[(UAERANGE-ERROR_TABLE_BASE_uae)] = ERANGE; - et2sys[(UAEDEADLK-ERROR_TABLE_BASE_uae)] = EDEADLK; - et2sys[(UAENAMETOOLONG-ERROR_TABLE_BASE_uae)] = ENAMETOOLONG; - et2sys[(UAENOLCK-ERROR_TABLE_BASE_uae)] = ENOLCK; - et2sys[(UAENOSYS-ERROR_TABLE_BASE_uae)] = ENOSYS; - et2sys[(UAENOTEMPTY-ERROR_TABLE_BASE_uae)] = ENOTEMPTY; - et2sys[(UAELOOP-ERROR_TABLE_BASE_uae)] = ELOOP; - et2sys[(UAEWOULDBLOCK-ERROR_TABLE_BASE_uae)] = EWOULDBLOCK; - et2sys[(UAENOMSG-ERROR_TABLE_BASE_uae)] = ENOMSG; - et2sys[(UAEIDRM-ERROR_TABLE_BASE_uae)] = EIDRM; - et2sys[(UAECHRNG-ERROR_TABLE_BASE_uae)] = ECHRNG; - et2sys[(UAEL2NSYNC-ERROR_TABLE_BASE_uae)] = EL2NSYNC; - et2sys[(UAEL3HLT-ERROR_TABLE_BASE_uae)] = EL3HLT; - et2sys[(UAEL3RST-ERROR_TABLE_BASE_uae)] = EL3RST; - et2sys[(UAELNRNG-ERROR_TABLE_BASE_uae)] = ELNRNG; - et2sys[(UAEUNATCH-ERROR_TABLE_BASE_uae)] = EUNATCH; - et2sys[(UAENOCSI-ERROR_TABLE_BASE_uae)] = ENOCSI; - et2sys[(UAEL2HLT-ERROR_TABLE_BASE_uae)] = EL2HLT; - et2sys[(UAEBADE-ERROR_TABLE_BASE_uae)] = EBADE; - et2sys[(UAEBADR-ERROR_TABLE_BASE_uae)] = EBADR; - et2sys[(UAEXFULL-ERROR_TABLE_BASE_uae)] = EXFULL; - et2sys[(UAENOANO-ERROR_TABLE_BASE_uae)] = ENOANO; - et2sys[(UAEBADRQC-ERROR_TABLE_BASE_uae)] = EBADRQC; - et2sys[(UAEBADSLT-ERROR_TABLE_BASE_uae)] = EBADSLT; - et2sys[(UAEBFONT-ERROR_TABLE_BASE_uae)] = EBFONT; - et2sys[(UAENOSTR-ERROR_TABLE_BASE_uae)] = ENOSTR; - et2sys[(UAENODATA-ERROR_TABLE_BASE_uae)] = ENODATA; - et2sys[(UAETIME-ERROR_TABLE_BASE_uae)] = ETIME; - et2sys[(UAENOSR-ERROR_TABLE_BASE_uae)] = ENOSR; - et2sys[(UAENONET-ERROR_TABLE_BASE_uae)] = ENONET; - et2sys[(UAENOPKG-ERROR_TABLE_BASE_uae)] = ENOPKG; - et2sys[(UAEREMOTE-ERROR_TABLE_BASE_uae)] = EREMOTE; - et2sys[(UAENOLINK-ERROR_TABLE_BASE_uae)] = ENOLINK; - et2sys[(UAEADV-ERROR_TABLE_BASE_uae)] = EADV; - et2sys[(UAESRMNT-ERROR_TABLE_BASE_uae)] = ESRMNT; - et2sys[(UAECOMM-ERROR_TABLE_BASE_uae)] = ECOMM; - et2sys[(UAEPROTO-ERROR_TABLE_BASE_uae)] = EPROTO; - et2sys[(UAEMULTIHOP-ERROR_TABLE_BASE_uae)] = EMULTIHOP; - et2sys[(UAEDOTDOT-ERROR_TABLE_BASE_uae)] = EDOTDOT; - et2sys[(UAEBADMSG-ERROR_TABLE_BASE_uae)] = EBADMSG; - et2sys[(UAEOVERFLOW-ERROR_TABLE_BASE_uae)] = EOVERFLOW; - et2sys[(UAENOTUNIQ-ERROR_TABLE_BASE_uae)] = ENOTUNIQ; - et2sys[(UAEBADFD-ERROR_TABLE_BASE_uae)] = EBADFD; - et2sys[(UAEREMCHG-ERROR_TABLE_BASE_uae)] = EREMCHG; - et2sys[(UAELIBACC-ERROR_TABLE_BASE_uae)] = ELIBACC; - et2sys[(UAELIBBAD-ERROR_TABLE_BASE_uae)] = ELIBBAD; - et2sys[(UAELIBSCN-ERROR_TABLE_BASE_uae)] = ELIBSCN; - et2sys[(UAELIBMAX-ERROR_TABLE_BASE_uae)] = ELIBMAX; - et2sys[(UAELIBEXEC-ERROR_TABLE_BASE_uae)] = ELIBEXEC; - et2sys[(UAEILSEQ-ERROR_TABLE_BASE_uae)] = EILSEQ; - et2sys[(UAERESTART-ERROR_TABLE_BASE_uae)] = ERESTART; - et2sys[(UAESTRPIPE-ERROR_TABLE_BASE_uae)] = ESTRPIPE; - et2sys[(UAEUSERS-ERROR_TABLE_BASE_uae)] = EUSERS; - et2sys[(UAENOTSOCK-ERROR_TABLE_BASE_uae)] = ENOTSOCK; - et2sys[(UAEDESTADDRREQ-ERROR_TABLE_BASE_uae)] = EDESTADDRREQ; - et2sys[(UAEMSGSIZE-ERROR_TABLE_BASE_uae)] = EMSGSIZE; - et2sys[(UAEPROTOTYPE-ERROR_TABLE_BASE_uae)] = EPROTOTYPE; - et2sys[(UAENOPROTOOPT-ERROR_TABLE_BASE_uae)] = ENOPROTOOPT; - et2sys[(UAEPROTONOSUPPORT-ERROR_TABLE_BASE_uae)] = EPROTONOSUPPORT; - et2sys[(UAESOCKTNOSUPPORT-ERROR_TABLE_BASE_uae)] = ESOCKTNOSUPPORT; - et2sys[(UAEOPNOTSUPP-ERROR_TABLE_BASE_uae)] = EOPNOTSUPP; - et2sys[(UAEPFNOSUPPORT-ERROR_TABLE_BASE_uae)] = EPFNOSUPPORT; - et2sys[(UAEAFNOSUPPORT-ERROR_TABLE_BASE_uae)] = EAFNOSUPPORT; - et2sys[(UAEADDRINUSE-ERROR_TABLE_BASE_uae)] = EADDRINUSE; - et2sys[(UAEADDRNOTAVAIL-ERROR_TABLE_BASE_uae)] = EADDRNOTAVAIL; - et2sys[(UAENETDOWN-ERROR_TABLE_BASE_uae)] = ENETDOWN; - et2sys[(UAENETUNREACH-ERROR_TABLE_BASE_uae)] = ENETUNREACH; - et2sys[(UAENETRESET-ERROR_TABLE_BASE_uae)] = ENETRESET; - et2sys[(UAECONNABORTED-ERROR_TABLE_BASE_uae)] = ECONNABORTED; - et2sys[(UAECONNRESET-ERROR_TABLE_BASE_uae)] = ECONNRESET; - et2sys[(UAENOBUFS-ERROR_TABLE_BASE_uae)] = ENOBUFS; - et2sys[(UAEISCONN-ERROR_TABLE_BASE_uae)] = EISCONN; - et2sys[(UAENOTCONN-ERROR_TABLE_BASE_uae)] = ENOTCONN; - et2sys[(UAESHUTDOWN-ERROR_TABLE_BASE_uae)] = ESHUTDOWN; - et2sys[(UAETOOMANYREFS-ERROR_TABLE_BASE_uae)] = ETOOMANYREFS; - et2sys[(UAETIMEDOUT-ERROR_TABLE_BASE_uae)] = ETIMEDOUT; - et2sys[(UAECONNREFUSED-ERROR_TABLE_BASE_uae)] = ECONNREFUSED; - et2sys[(UAEHOSTDOWN-ERROR_TABLE_BASE_uae)] = EHOSTDOWN; - et2sys[(UAEHOSTUNREACH-ERROR_TABLE_BASE_uae)] = EHOSTUNREACH; - et2sys[(UAEALREADY-ERROR_TABLE_BASE_uae)] = EALREADY; - et2sys[(UAEINPROGRESS-ERROR_TABLE_BASE_uae)] = EINPROGRESS; - et2sys[(UAESTALE-ERROR_TABLE_BASE_uae)] = ESTALE; - et2sys[(UAEUCLEAN-ERROR_TABLE_BASE_uae)] = EUCLEAN; - et2sys[(UAENOTNAM-ERROR_TABLE_BASE_uae)] = ENOTNAM; - et2sys[(UAENAVAIL-ERROR_TABLE_BASE_uae)] = ENAVAIL; - et2sys[(UAEISNAM-ERROR_TABLE_BASE_uae)] = EISNAM; - et2sys[(UAEREMOTEIO-ERROR_TABLE_BASE_uae)] = EREMOTEIO; - et2sys[(UAEDQUOT-ERROR_TABLE_BASE_uae)] = EDQUOT; - et2sys[(UAENOMEDIUM-ERROR_TABLE_BASE_uae)] = ENOMEDIUM; - et2sys[(UAEMEDIUMTYPE-ERROR_TABLE_BASE_uae)] = EMEDIUMTYPE; + et2sys[(UAEPERM - ERROR_TABLE_BASE_uae)] = EPERM; + et2sys[(UAENOENT - ERROR_TABLE_BASE_uae)] = ENOENT; + et2sys[(UAESRCH - ERROR_TABLE_BASE_uae)] = ESRCH; + et2sys[(UAEINTR - ERROR_TABLE_BASE_uae)] = EINTR; + et2sys[(UAEIO - ERROR_TABLE_BASE_uae)] = EIO; + et2sys[(UAENXIO - ERROR_TABLE_BASE_uae)] = ENXIO; + et2sys[(UAE2BIG - ERROR_TABLE_BASE_uae)] = E2BIG; + et2sys[(UAENOEXEC - ERROR_TABLE_BASE_uae)] = ENOEXEC; + et2sys[(UAEBADF - ERROR_TABLE_BASE_uae)] = EBADF; + et2sys[(UAECHILD - ERROR_TABLE_BASE_uae)] = ECHILD; + et2sys[(UAEAGAIN - ERROR_TABLE_BASE_uae)] = EAGAIN; + et2sys[(UAENOMEM - ERROR_TABLE_BASE_uae)] = ENOMEM; + et2sys[(UAEACCES - ERROR_TABLE_BASE_uae)] = EACCES; + et2sys[(UAEFAULT - ERROR_TABLE_BASE_uae)] = EFAULT; + et2sys[(UAENOTBLK - ERROR_TABLE_BASE_uae)] = ENOTBLK; + et2sys[(UAEBUSY - ERROR_TABLE_BASE_uae)] = EBUSY; + et2sys[(UAEEXIST - ERROR_TABLE_BASE_uae)] = EEXIST; + et2sys[(UAEXDEV - ERROR_TABLE_BASE_uae)] = EXDEV; + et2sys[(UAENODEV - ERROR_TABLE_BASE_uae)] = ENODEV; + et2sys[(UAENOTDIR - ERROR_TABLE_BASE_uae)] = ENOTDIR; + et2sys[(UAEISDIR - ERROR_TABLE_BASE_uae)] = EISDIR; + et2sys[(UAEINVAL - ERROR_TABLE_BASE_uae)] = EINVAL; + et2sys[(UAENFILE - ERROR_TABLE_BASE_uae)] = ENFILE; + et2sys[(UAEMFILE - ERROR_TABLE_BASE_uae)] = EMFILE; + et2sys[(UAENOTTY - ERROR_TABLE_BASE_uae)] = ENOTTY; + et2sys[(UAETXTBSY - ERROR_TABLE_BASE_uae)] = ETXTBSY; + et2sys[(UAEFBIG - ERROR_TABLE_BASE_uae)] = EFBIG; + et2sys[(UAENOSPC - ERROR_TABLE_BASE_uae)] = ENOSPC; + et2sys[(UAESPIPE - ERROR_TABLE_BASE_uae)] = ESPIPE; + et2sys[(UAEROFS - ERROR_TABLE_BASE_uae)] = EROFS; + et2sys[(UAEMLINK - ERROR_TABLE_BASE_uae)] = EMLINK; + et2sys[(UAEPIPE - ERROR_TABLE_BASE_uae)] = EPIPE; + et2sys[(UAEDOM - ERROR_TABLE_BASE_uae)] = EDOM; + et2sys[(UAERANGE - ERROR_TABLE_BASE_uae)] = ERANGE; + et2sys[(UAEDEADLK - ERROR_TABLE_BASE_uae)] = EDEADLK; + et2sys[(UAENAMETOOLONG - ERROR_TABLE_BASE_uae)] = ENAMETOOLONG; + et2sys[(UAENOLCK - ERROR_TABLE_BASE_uae)] = ENOLCK; + et2sys[(UAENOSYS - ERROR_TABLE_BASE_uae)] = ENOSYS; + et2sys[(UAENOTEMPTY - ERROR_TABLE_BASE_uae)] = ENOTEMPTY; + et2sys[(UAELOOP - ERROR_TABLE_BASE_uae)] = ELOOP; + et2sys[(UAEWOULDBLOCK - ERROR_TABLE_BASE_uae)] = EWOULDBLOCK; + et2sys[(UAENOMSG - ERROR_TABLE_BASE_uae)] = ENOMSG; + et2sys[(UAEIDRM - ERROR_TABLE_BASE_uae)] = EIDRM; + et2sys[(UAECHRNG - ERROR_TABLE_BASE_uae)] = ECHRNG; + et2sys[(UAEL2NSYNC - ERROR_TABLE_BASE_uae)] = EL2NSYNC; + et2sys[(UAEL3HLT - ERROR_TABLE_BASE_uae)] = EL3HLT; + et2sys[(UAEL3RST - ERROR_TABLE_BASE_uae)] = EL3RST; + et2sys[(UAELNRNG - ERROR_TABLE_BASE_uae)] = ELNRNG; + et2sys[(UAEUNATCH - ERROR_TABLE_BASE_uae)] = EUNATCH; + et2sys[(UAENOCSI - ERROR_TABLE_BASE_uae)] = ENOCSI; + et2sys[(UAEL2HLT - ERROR_TABLE_BASE_uae)] = EL2HLT; + et2sys[(UAEBADE - ERROR_TABLE_BASE_uae)] = EBADE; + et2sys[(UAEBADR - ERROR_TABLE_BASE_uae)] = EBADR; + et2sys[(UAEXFULL - ERROR_TABLE_BASE_uae)] = EXFULL; + et2sys[(UAENOANO - ERROR_TABLE_BASE_uae)] = ENOANO; + et2sys[(UAEBADRQC - ERROR_TABLE_BASE_uae)] = EBADRQC; + et2sys[(UAEBADSLT - ERROR_TABLE_BASE_uae)] = EBADSLT; + et2sys[(UAEBFONT - ERROR_TABLE_BASE_uae)] = EBFONT; + et2sys[(UAENOSTR - ERROR_TABLE_BASE_uae)] = ENOSTR; + et2sys[(UAENODATA - ERROR_TABLE_BASE_uae)] = ENODATA; + et2sys[(UAETIME - ERROR_TABLE_BASE_uae)] = ETIME; + et2sys[(UAENOSR - ERROR_TABLE_BASE_uae)] = ENOSR; + et2sys[(UAENONET - ERROR_TABLE_BASE_uae)] = ENONET; + et2sys[(UAENOPKG - ERROR_TABLE_BASE_uae)] = ENOPKG; + et2sys[(UAEREMOTE - ERROR_TABLE_BASE_uae)] = EREMOTE; + et2sys[(UAENOLINK - ERROR_TABLE_BASE_uae)] = ENOLINK; + et2sys[(UAEADV - ERROR_TABLE_BASE_uae)] = EADV; + et2sys[(UAESRMNT - ERROR_TABLE_BASE_uae)] = ESRMNT; + et2sys[(UAECOMM - ERROR_TABLE_BASE_uae)] = ECOMM; + et2sys[(UAEPROTO - ERROR_TABLE_BASE_uae)] = EPROTO; + et2sys[(UAEMULTIHOP - ERROR_TABLE_BASE_uae)] = EMULTIHOP; + et2sys[(UAEDOTDOT - ERROR_TABLE_BASE_uae)] = EDOTDOT; + et2sys[(UAEBADMSG - ERROR_TABLE_BASE_uae)] = EBADMSG; + et2sys[(UAEOVERFLOW - ERROR_TABLE_BASE_uae)] = EOVERFLOW; + et2sys[(UAENOTUNIQ - ERROR_TABLE_BASE_uae)] = ENOTUNIQ; + et2sys[(UAEBADFD - ERROR_TABLE_BASE_uae)] = EBADFD; + et2sys[(UAEREMCHG - ERROR_TABLE_BASE_uae)] = EREMCHG; + et2sys[(UAELIBACC - ERROR_TABLE_BASE_uae)] = ELIBACC; + et2sys[(UAELIBBAD - ERROR_TABLE_BASE_uae)] = ELIBBAD; + et2sys[(UAELIBSCN - ERROR_TABLE_BASE_uae)] = ELIBSCN; + et2sys[(UAELIBMAX - ERROR_TABLE_BASE_uae)] = ELIBMAX; + et2sys[(UAELIBEXEC - ERROR_TABLE_BASE_uae)] = ELIBEXEC; + et2sys[(UAEILSEQ - ERROR_TABLE_BASE_uae)] = EILSEQ; + et2sys[(UAERESTART - ERROR_TABLE_BASE_uae)] = ERESTART; + et2sys[(UAESTRPIPE - ERROR_TABLE_BASE_uae)] = ESTRPIPE; + et2sys[(UAEUSERS - ERROR_TABLE_BASE_uae)] = EUSERS; + et2sys[(UAENOTSOCK - ERROR_TABLE_BASE_uae)] = ENOTSOCK; + et2sys[(UAEDESTADDRREQ - ERROR_TABLE_BASE_uae)] = EDESTADDRREQ; + et2sys[(UAEMSGSIZE - ERROR_TABLE_BASE_uae)] = EMSGSIZE; + et2sys[(UAEPROTOTYPE - ERROR_TABLE_BASE_uae)] = EPROTOTYPE; + et2sys[(UAENOPROTOOPT - ERROR_TABLE_BASE_uae)] = ENOPROTOOPT; + et2sys[(UAEPROTONOSUPPORT - ERROR_TABLE_BASE_uae)] = EPROTONOSUPPORT; + et2sys[(UAESOCKTNOSUPPORT - ERROR_TABLE_BASE_uae)] = ESOCKTNOSUPPORT; + et2sys[(UAEOPNOTSUPP - ERROR_TABLE_BASE_uae)] = EOPNOTSUPP; + et2sys[(UAEPFNOSUPPORT - ERROR_TABLE_BASE_uae)] = EPFNOSUPPORT; + et2sys[(UAEAFNOSUPPORT - ERROR_TABLE_BASE_uae)] = EAFNOSUPPORT; + et2sys[(UAEADDRINUSE - ERROR_TABLE_BASE_uae)] = EADDRINUSE; + et2sys[(UAEADDRNOTAVAIL - ERROR_TABLE_BASE_uae)] = EADDRNOTAVAIL; + et2sys[(UAENETDOWN - ERROR_TABLE_BASE_uae)] = ENETDOWN; + et2sys[(UAENETUNREACH - ERROR_TABLE_BASE_uae)] = ENETUNREACH; + et2sys[(UAENETRESET - ERROR_TABLE_BASE_uae)] = ENETRESET; + et2sys[(UAECONNABORTED - ERROR_TABLE_BASE_uae)] = ECONNABORTED; + et2sys[(UAECONNRESET - ERROR_TABLE_BASE_uae)] = ECONNRESET; + et2sys[(UAENOBUFS - ERROR_TABLE_BASE_uae)] = ENOBUFS; + et2sys[(UAEISCONN - ERROR_TABLE_BASE_uae)] = EISCONN; + et2sys[(UAENOTCONN - ERROR_TABLE_BASE_uae)] = ENOTCONN; + et2sys[(UAESHUTDOWN - ERROR_TABLE_BASE_uae)] = ESHUTDOWN; + et2sys[(UAETOOMANYREFS - ERROR_TABLE_BASE_uae)] = ETOOMANYREFS; + et2sys[(UAETIMEDOUT - ERROR_TABLE_BASE_uae)] = ETIMEDOUT; + et2sys[(UAECONNREFUSED - ERROR_TABLE_BASE_uae)] = ECONNREFUSED; + et2sys[(UAEHOSTDOWN - ERROR_TABLE_BASE_uae)] = EHOSTDOWN; + et2sys[(UAEHOSTUNREACH - ERROR_TABLE_BASE_uae)] = EHOSTUNREACH; + et2sys[(UAEALREADY - ERROR_TABLE_BASE_uae)] = EALREADY; + et2sys[(UAEINPROGRESS - ERROR_TABLE_BASE_uae)] = EINPROGRESS; + et2sys[(UAESTALE - ERROR_TABLE_BASE_uae)] = ESTALE; + et2sys[(UAEUCLEAN - ERROR_TABLE_BASE_uae)] = EUCLEAN; + et2sys[(UAENOTNAM - ERROR_TABLE_BASE_uae)] = ENOTNAM; + et2sys[(UAENAVAIL - ERROR_TABLE_BASE_uae)] = ENAVAIL; + et2sys[(UAEISNAM - ERROR_TABLE_BASE_uae)] = EISNAM; + et2sys[(UAEREMOTEIO - ERROR_TABLE_BASE_uae)] = EREMOTEIO; + et2sys[(UAEDQUOT - ERROR_TABLE_BASE_uae)] = EDQUOT; + et2sys[(UAENOMEDIUM - ERROR_TABLE_BASE_uae)] = ENOMEDIUM; + et2sys[(UAEMEDIUMTYPE - ERROR_TABLE_BASE_uae)] = EMEDIUMTYPE; } -static afs_int32 et_to_sys_error(afs_int32 in) { - if (in < ERROR_TABLE_BASE_uae || in >= ERROR_TABLE_BASE_uae + 512) +static afs_int32 +et_to_sys_error(afs_int32 in) +{ + if (in < ERROR_TABLE_BASE_uae || in >= ERROR_TABLE_BASE_uae + 512) return in; - if (et2sys[in-ERROR_TABLE_BASE_uae] != 0) - return et2sys[in-ERROR_TABLE_BASE_uae]; + if (et2sys[in - ERROR_TABLE_BASE_uae] != 0) + return et2sys[in - ERROR_TABLE_BASE_uae]; return in; } -void afs_CopyError(register struct vrequest *afrom, register struct vrequest *ato) +void +afs_CopyError(register struct vrequest *afrom, register struct vrequest *ato) { AFS_STATCNT(afs_CopyError); if (!afrom->initd) @@ -224,7 +230,8 @@ void afs_CopyError(register struct vrequest *afrom, register struct vrequest *at } -void afs_FinalizeReq(register struct vrequest *areq) +void +afs_FinalizeReq(register struct vrequest *areq) { AFS_STATCNT(afs_FinalizeReq); if (areq->initd) @@ -238,14 +245,15 @@ void afs_FinalizeReq(register struct vrequest *areq) } -int afs_CheckCode(afs_int32 acode, struct vrequest *areq, int where) +int +afs_CheckCode(afs_int32 acode, struct vrequest *areq, int where) { AFS_STATCNT(afs_CheckCode); - if (acode) { - afs_Trace2(afs_iclSetp, CM_TRACE_CHECKCODE, - ICL_TYPE_INT32, acode, ICL_TYPE_INT32, where); + if (acode) { + afs_Trace2(afs_iclSetp, CM_TRACE_CHECKCODE, ICL_TYPE_INT32, acode, + ICL_TYPE_INT32, where); } - if ((acode & ~0xff) == ERROR_TABLE_BASE_uae) + if ((acode & ~0xff) == ERROR_TABLE_BASE_uae) acode = et_to_sys_error(acode); if (!areq || !areq->initd) return acode; @@ -274,7 +282,7 @@ int afs_CheckCode(afs_int32 acode, struct vrequest *areq, int where) return acode; -} /*afs_CheckCode*/ +} /*afs_CheckCode */ #define VSleep(at) afs_osi_Wait((at)*1000, 0, 0) @@ -295,33 +303,36 @@ int lastcode; #define DIFFERENT 0 #define SAME 1 #define DUNNO 2 -static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) +static int +VLDB_Same(struct VenusFid *afid, struct vrequest *areq) { struct vrequest treq; struct conn *tconn; - int i, type=0; - union { - struct vldbentry tve; - struct nvldbentry ntve; - struct uvldbentry utve; + int i, type = 0; + union { + struct vldbentry tve; + struct nvldbentry ntve; + struct uvldbentry utve; } *v; struct volume *tvp; struct cell *tcell; - char *bp, tbuf[CVBS]; /* biggest volume id is 2^32, ~ 4*10^9 */ + char *bp, tbuf[CVBS]; /* biggest volume id is 2^32, ~ 4*10^9 */ unsigned int changed; struct server *(oldhosts[NMAXNSERVERS]); AFS_STATCNT(CheckVLDB); afs_FinalizeReq(areq); - if ((i = afs_InitReq(&treq, &afs_osi_cred))) return DUNNO; + if ((i = afs_InitReq(&treq, &afs_osi_cred))) + return DUNNO; v = afs_osi_Alloc(sizeof(*v)); tcell = afs_GetCell(afid->Cell, READ_LOCK); bp = afs_cv2string(&tbuf[CVBS], afid->Fid.Volume); do { - VSleep(2); /* Better safe than sorry. */ - tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, - tcell->cellNum, &treq, SHARED_LOCK); + VSleep(2); /* Better safe than sorry. */ + tconn = + afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum, + &treq, SHARED_LOCK); if (tconn) { if (tconn->srvr->server->flags & SNO_LHOSTS) { type = 0; @@ -342,7 +353,7 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) if (i == RXGEN_OPCODE) { type = 1; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve); + i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve); RX_AFS_GLOCK(); if (i == RXGEN_OPCODE) { type = 0; @@ -353,14 +364,13 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) } else if (!i) tconn->srvr->server->flags |= SYES_LHOSTS; } else if (!i) - tconn->srvr->server->flags |= SVLSRV_UUID; + tconn->srvr->server->flags |= SVLSRV_UUID; } - lastcode = i; + lastcode = i; } } else i = -1; - } while (afs_Analyze(tconn, i, NULL, &treq, - -1, /* no op code for this */ + } while (afs_Analyze(tconn, i, NULL, &treq, -1, /* no op code for this */ SHARED_LOCK, tcell)); afs_PutCell(tcell, READ_LOCK); @@ -375,49 +385,45 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) changed = 0; tvp = afs_FindVolume(afid, WRITE_LOCK); if (tvp) { - ObtainWriteLock(&tvp->lock,107); - for (i=0; i < NMAXNSERVERS && tvp->serverHost[i]; i++) { - oldhosts[i] = tvp->serverHost[i]; - } - - if (type == 2) { - InstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, &treq); - } - else if (type == 1) { - InstallNVolumeEntry(tvp, &v->ntve, afid->Cell); - } - else { - InstallVolumeEntry(tvp, &v->tve, afid->Cell); - } - - if (i < NMAXNSERVERS && tvp->serverHost[i]) { + ObtainWriteLock(&tvp->lock, 107); + for (i = 0; i < NMAXNSERVERS && tvp->serverHost[i]; i++) { + oldhosts[i] = tvp->serverHost[i]; + } + + if (type == 2) { + InstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, &treq); + } else if (type == 1) { + InstallNVolumeEntry(tvp, &v->ntve, afid->Cell); + } else { + InstallVolumeEntry(tvp, &v->tve, afid->Cell); + } + + if (i < NMAXNSERVERS && tvp->serverHost[i]) { changed = 1; - } - for (--i;!changed && i >= 0; i--) { - if (tvp->serverHost[i] != oldhosts[i]) { - changed = 1; /* also happens if prefs change. big deal. */ - } - } - - ReleaseWriteLock(&tvp->lock); - afs_PutVolume(tvp, WRITE_LOCK); - } - else { /* can't find volume */ - tvp = afs_GetVolume(afid, &treq, WRITE_LOCK); - if (tvp) { + } + for (--i; !changed && i >= 0; i--) { + if (tvp->serverHost[i] != oldhosts[i]) { + changed = 1; /* also happens if prefs change. big deal. */ + } + } + + ReleaseWriteLock(&tvp->lock); afs_PutVolume(tvp, WRITE_LOCK); - afs_osi_Free(v, sizeof(*v)); - return DIFFERENT; - } - else { - afs_osi_Free(v, sizeof(*v)); - return DUNNO; - } + } else { /* can't find volume */ + tvp = afs_GetVolume(afid, &treq, WRITE_LOCK); + if (tvp) { + afs_PutVolume(tvp, WRITE_LOCK); + afs_osi_Free(v, sizeof(*v)); + return DIFFERENT; + } else { + afs_osi_Free(v, sizeof(*v)); + return DUNNO; + } } afs_osi_Free(v, sizeof(*v)); return (changed ? DIFFERENT : SAME); -} /*VLDB_Same */ +} /*VLDB_Same */ /*------------------------------------------------------------------------ @@ -452,9 +458,10 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) * The retry return value is used by afs_StoreAllSegments to determine * if this is a temporary or permanent error. *------------------------------------------------------------------------*/ -int afs_Analyze(register struct conn *aconn, afs_int32 acode, - struct VenusFid *afid, register struct vrequest *areq, int op, - afs_int32 locktype, struct cell *cellp) +int +afs_Analyze(register struct conn *aconn, afs_int32 acode, + struct VenusFid *afid, register struct vrequest *areq, int op, + afs_int32 locktype, struct cell *cellp) { afs_int32 i; struct srvAddr *sa; @@ -465,78 +472,81 @@ int afs_Analyze(register struct conn *aconn, afs_int32 acode, AFS_STATCNT(afs_Analyze); afs_Trace4(afs_iclSetp, CM_TRACE_ANALYZE, ICL_TYPE_INT32, op, - ICL_TYPE_POINTER, aconn, - ICL_TYPE_INT32, acode, ICL_TYPE_LONG, areq->uid); + ICL_TYPE_POINTER, aconn, ICL_TYPE_INT32, acode, ICL_TYPE_LONG, + areq->uid); - aerrP = (struct afs_stats_RPCErrors *) 0; + aerrP = (struct afs_stats_RPCErrors *)0; if ((op >= 0) && (op < AFS_STATS_NUM_FS_RPC_OPS)) - aerrP = &(afs_stats_cmfullperf.rpc.fsRPCErrors[op]); + aerrP = &(afs_stats_cmfullperf.rpc.fsRPCErrors[op]); afs_FinalizeReq(areq); - if (!aconn && areq->busyCount) { /* one RPC or more got VBUSY/VRESTARTING */ - - tvp = afs_FindVolume(afid, READ_LOCK); - if (tvp) { - afs_warnuser("afs: Waiting for busy volume %u (%s) in cell %s\n", - (afid ? afid->Fid.Volume : 0), - (tvp->name ? tvp->name : ""), - ((tvp->serverHost[0] && tvp->serverHost[0]->cell) ? - tvp->serverHost[0]->cell->cellName : "")); - - for (i=0; i < MAXHOSTS; i++) { - if (tvp->status[i] != not_busy && tvp->status[i] != offline) { - tvp->status[i] = not_busy; + if (!aconn && areq->busyCount) { /* one RPC or more got VBUSY/VRESTARTING */ + + tvp = afs_FindVolume(afid, READ_LOCK); + if (tvp) { + afs_warnuser("afs: Waiting for busy volume %u (%s) in cell %s\n", + (afid ? afid->Fid.Volume : 0), + (tvp->name ? tvp->name : ""), + ((tvp->serverHost[0] + && tvp->serverHost[0]->cell) ? tvp->serverHost[0]-> + cell->cellName : "")); + + for (i = 0; i < MAXHOSTS; i++) { + if (tvp->status[i] != not_busy && tvp->status[i] != offline) { + tvp->status[i] = not_busy; + } + if (tvp->status[i] == not_busy) + shouldRetry = 1; } - if (tvp->status[i] == not_busy) - shouldRetry = 1; - } - afs_PutVolume(tvp, READ_LOCK); - } else { - afs_warnuser("afs: Waiting for busy volume %u\n", - (afid ? afid->Fid.Volume : 0)); - } - - if (areq->busyCount > 100) { - if (aerrP) - (aerrP->err_Volume)++; - areq->volumeError = VOLBUSY; - shouldRetry = 0; - } else { - VSleep(afs_BusyWaitPeriod); /* poll periodically */ - } - if (shouldRetry != 0) - areq->busyCount++; + afs_PutVolume(tvp, READ_LOCK); + } else { + afs_warnuser("afs: Waiting for busy volume %u\n", + (afid ? afid->Fid.Volume : 0)); + } - return shouldRetry; /* should retry */ + if (areq->busyCount > 100) { + if (aerrP) + (aerrP->err_Volume)++; + areq->volumeError = VOLBUSY; + shouldRetry = 0; + } else { + VSleep(afs_BusyWaitPeriod); /* poll periodically */ + } + if (shouldRetry != 0) + areq->busyCount++; + + return shouldRetry; /* should retry */ } - + if (!aconn) { if (!areq->volumeError) { if (aerrP) (aerrP->err_Network)++; - if (hm_retry_int && !(areq->flags & O_NONBLOCK) && /* "hard" mount */ - ((afid && afs_IsPrimaryCellNum(afid->Cell)) || - (cellp && afs_IsPrimaryCell(cellp)))) { + if (hm_retry_int && !(areq->flags & O_NONBLOCK) && /* "hard" mount */ + ((afid && afs_IsPrimaryCellNum(afid->Cell)) + || (cellp && afs_IsPrimaryCell(cellp)))) { if (!afid) { - afs_warnuser("afs: hard-mount waiting for a vlserver to return to service\n"); + afs_warnuser + ("afs: hard-mount waiting for a vlserver to return to service\n"); VSleep(hm_retry_int); - afs_CheckServers(1,cellp); - shouldRetry=1; + afs_CheckServers(1, cellp); + shouldRetry = 1; } else { tvp = afs_FindVolume(afid, READ_LOCK); if (!tvp || (tvp->states & VRO)) { - shouldRetry = hm_retry_RO; - } else { - shouldRetry = hm_retry_RW; + shouldRetry = hm_retry_RO; + } else { + shouldRetry = hm_retry_RW; } if (tvp) afs_PutVolume(tvp, READ_LOCK); if (shouldRetry) { - afs_warnuser("afs: hard-mount waiting for volume %u\n", - afid->Fid.Volume); - VSleep(hm_retry_int); - afs_CheckServers(1,cellp); + afs_warnuser + ("afs: hard-mount waiting for volume %u\n", + afid->Fid.Volume); + VSleep(hm_retry_int); + afs_CheckServers(1, cellp); } } } /* if (hm_retry_int ... */ @@ -552,26 +562,26 @@ int afs_Analyze(register struct conn *aconn, afs_int32 acode, tsp = sa->server; /* Before we do anything with acode, make sure we translate it back to - a system error */ - if ((acode & ~0xff) == ERROR_TABLE_BASE_uae) + * a system error */ + if ((acode & ~0xff) == ERROR_TABLE_BASE_uae) acode = et_to_sys_error(acode); if (acode == 0) { - /* If we previously took an error, mark this volume not busy */ - if (areq->volumeError) { - tvp = afs_FindVolume(afid, READ_LOCK); - if (tvp) { - for (i=0; iserverHost[i] == tsp) { - tvp->status[i] = not_busy ; + /* If we previously took an error, mark this volume not busy */ + if (areq->volumeError) { + tvp = afs_FindVolume(afid, READ_LOCK); + if (tvp) { + for (i = 0; i < MAXHOSTS; i++) { + if (tvp->serverHost[i] == tsp) { + tvp->status[i] = not_busy; + } } - } - afs_PutVolume(tvp, READ_LOCK); - } - } + afs_PutVolume(tvp, READ_LOCK); + } + } - afs_PutConn(aconn, locktype); - return 0; + afs_PutConn(aconn, locktype); + return 0; } /* If network troubles, mark server as having bogued out again. */ @@ -579,42 +589,41 @@ int afs_Analyze(register struct conn *aconn, afs_int32 acode, * with 3.4 file servers and older cache managers */ #ifdef AFS_64BIT_CLIENT if (acode == -455) - acode = 455; + acode = 455; #endif /* AFS_64BIT_CLIENT */ - if ((acode < 0) && (acode != VRESTARTING)) { + if ((acode < 0) && (acode != VRESTARTING)) { afs_ServerDown(sa); - ForceNewConnections(sa); /*multi homed clients lock:afs_xsrvAddr?*/ + ForceNewConnections(sa); /*multi homed clients lock:afs_xsrvAddr? */ if (aerrP) (aerrP->err_Server)++; } if (acode == VBUSY || acode == VRESTARTING) { if (acode == VBUSY) { - areq->busyCount++; - if (aerrP) - (aerrP->err_VolumeBusies)++; - } - else areq->busyCount = 1; + areq->busyCount++; + if (aerrP) + (aerrP->err_VolumeBusies)++; + } else + areq->busyCount = 1; tvp = afs_FindVolume(afid, READ_LOCK); if (tvp) { - for (i=0; i < MAXHOSTS ; i++ ) { - if (tvp->serverHost[i] == tsp) { - tvp->status[i] = rdwr_busy ; /* can't tell which yet */ - /* to tell which, have to look at the op code. */ + for (i = 0; i < MAXHOSTS; i++) { + if (tvp->serverHost[i] == tsp) { + tvp->status[i] = rdwr_busy; /* can't tell which yet */ + /* to tell which, have to look at the op code. */ + } } - } - afs_PutVolume(tvp, READ_LOCK); - } - else { - afs_warnuser("afs: Waiting for busy volume %u in cell %s\n", - (afid? afid->Fid.Volume : 0), tsp->cell->cellName); - VSleep(afs_BusyWaitPeriod); /* poll periodically */ + afs_PutVolume(tvp, READ_LOCK); + } else { + afs_warnuser("afs: Waiting for busy volume %u in cell %s\n", + (afid ? afid->Fid.Volume : 0), tsp->cell->cellName); + VSleep(afs_BusyWaitPeriod); /* poll periodically */ } shouldRetry = 1; acode = 0; - } - else if (acode == VICETOKENDEAD || (acode & ~0xff) == ERROR_TABLE_BASE_RXK) { + } else if (acode == VICETOKENDEAD + || (acode & ~0xff) == ERROR_TABLE_BASE_RXK) { /* any rxkad error is treated as token expiration */ struct unixuser *tu; @@ -628,24 +637,28 @@ int afs_Analyze(register struct conn *aconn, afs_int32 acode, tu = afs_FindUser(areq->uid, tsp->cell->cellNum, READ_LOCK); if (tu) { if ((acode == VICETOKENDEAD) || (acode == RXKADEXPIRED)) - afs_warnuser("afs: Tokens for user of AFS id %d for cell %s have expired\n", - tu->vid, aconn->srvr->server->cell->cellName); + afs_warnuser + ("afs: Tokens for user of AFS id %d for cell %s have expired\n", + tu->vid, aconn->srvr->server->cell->cellName); else - afs_warnuser("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d)\n", - tu->vid, aconn->srvr->server->cell->cellName, acode); - afs_PutUser(tu, READ_LOCK); + afs_warnuser + ("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d)\n", + tu->vid, aconn->srvr->server->cell->cellName, acode); + afs_PutUser(tu, READ_LOCK); } else { /* The else case shouldn't be possible and should probably be replaced by a panic? */ if ((acode == VICETOKENDEAD) || (acode == RXKADEXPIRED)) - afs_warnuser("afs: Tokens for user %d for cell %s have expired\n", - areq->uid, aconn->srvr->server->cell->cellName); + afs_warnuser + ("afs: Tokens for user %d for cell %s have expired\n", + areq->uid, aconn->srvr->server->cell->cellName); else - afs_warnuser("afs: Tokens for user %d for cell %s are discarded (rxkad error = %d)\n", - areq->uid, aconn->srvr->server->cell->cellName, acode); + afs_warnuser + ("afs: Tokens for user %d for cell %s are discarded (rxkad error = %d)\n", + areq->uid, aconn->srvr->server->cell->cellName, acode); } - aconn->forceConnectFS = 0; /* don't check until new tokens set */ + aconn->forceConnectFS = 0; /* don't check until new tokens set */ aconn->user->states |= UTokensBad; - shouldRetry = 1; /* Try again (as root). */ + shouldRetry = 1; /* Try again (as root). */ } /* Check for access violation. */ else if (acode == EACCES) { @@ -658,62 +671,58 @@ int afs_Analyze(register struct conn *aconn, afs_int32 acode, shouldRetry = 0; } /* check for ubik errors; treat them like crashed servers */ - else if (acode >= ERROR_TABLE_BASE_U && acode < ERROR_TABLE_BASE_U+255) { + else if (acode >= ERROR_TABLE_BASE_U && acode < ERROR_TABLE_BASE_U + 255) { afs_ServerDown(sa); if (aerrP) (aerrP->err_Server)++; - shouldRetry = 1; /* retryable (maybe one is working) */ - VSleep(1); /* just in case */ + shouldRetry = 1; /* retryable (maybe one is working) */ + VSleep(1); /* just in case */ } /* Check for bad volume data base / missing volume. */ - else if (acode == VSALVAGE || acode == VOFFLINE - || acode == VNOVOL || acode == VNOSERVICE || acode == VMOVED) { + else if (acode == VSALVAGE || acode == VOFFLINE || acode == VNOVOL + || acode == VNOSERVICE || acode == VMOVED) { struct cell *tcell; - int same; + int same; shouldRetry = 1; areq->volumeError = VOLMISSING; if (aerrP) - (aerrP->err_Volume)++; + (aerrP->err_Volume)++; if (afid && (tcell = afs_GetCell(afid->Cell, 0))) { - same = VLDB_Same(afid, areq); - tvp = afs_FindVolume(afid, READ_LOCK); - if (tvp) { - for (i=0; i < MAXHOSTS && tvp->serverHost[i]; i++ ) { - if (tvp->serverHost[i] == tsp) { - if (tvp->status[i] == end_not_busy) - tvp->status[i] = offline ; - else - tvp->status[i]++; - } - else if (!same) { - tvp->status[i] = not_busy; /* reset the others */ - } - } - afs_PutVolume(tvp, READ_LOCK); - } + same = VLDB_Same(afid, areq); + tvp = afs_FindVolume(afid, READ_LOCK); + if (tvp) { + for (i = 0; i < MAXHOSTS && tvp->serverHost[i]; i++) { + if (tvp->serverHost[i] == tsp) { + if (tvp->status[i] == end_not_busy) + tvp->status[i] = offline; + else + tvp->status[i]++; + } else if (!same) { + tvp->status[i] = not_busy; /* reset the others */ + } + } + afs_PutVolume(tvp, READ_LOCK); + } } - } - else if (acode >= ERROR_TABLE_BASE_VL - && acode <= ERROR_TABLE_BASE_VL + 255) /* vlserver errors */ { - shouldRetry = 0; - areq->volumeError = VOLMISSING; - } - else if (acode >= 0) { + } else if (acode >= ERROR_TABLE_BASE_VL && acode <= ERROR_TABLE_BASE_VL + 255) { /* vlserver errors */ + shouldRetry = 0; + areq->volumeError = VOLMISSING; + } else if (acode >= 0) { if (aerrP) (aerrP->err_Other)++; if (op == AFS_STATS_FS_RPCIDX_STOREDATA) areq->permWriteError = 1; - shouldRetry = 0; /* Other random Vice error. */ - } else if (acode == RX_MSGSIZE) { /* same meaning as EMSGSIZE... */ - VSleep(1); /* Just a hack for desperate times. */ + shouldRetry = 0; /* Other random Vice error. */ + } else if (acode == RX_MSGSIZE) { /* same meaning as EMSGSIZE... */ + VSleep(1); /* Just a hack for desperate times. */ if (aerrP) (aerrP->err_Other)++; - shouldRetry = 1; /* packet was too big, please retry call */ - } + shouldRetry = 1; /* packet was too big, please retry call */ + } - if (acode < 0 && acode != RX_MSGSIZE && acode != VRESTARTING) { - /* If we get here, code < 0 and we have network/Server troubles. + if (acode < 0 && acode != RX_MSGSIZE && acode != VRESTARTING) { + /* If we get here, code < 0 and we have network/Server troubles. * areq->networkError is not set here, since we always * retry in case there is another server. However, if we find * no connection (aconn == 0) we set the networkError flag. @@ -724,9 +733,8 @@ int afs_Analyze(register struct conn *aconn, afs_int32 acode, VSleep(1); /* Just a hack for desperate times. */ shouldRetry = 1; } - + /* now unlock the connection and return */ afs_PutConn(aconn, locktype); return (shouldRetry); -} /*afs_Analyze*/ - +} /*afs_Analyze */ diff --git a/src/afs/afs_axscache.c b/src/afs/afs_axscache.c index 23083c6be..ab585f0b5 100644 --- a/src/afs/afs_axscache.c +++ b/src/afs/afs_axscache.c @@ -10,14 +10,17 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/stds.h" static struct axscache *afs_axsfreelist = NULL; -static struct xfreelist { struct xfreelist *next; } *xfreemallocs = 0; +static struct xfreelist { + struct xfreelist *next; +} *xfreemallocs = 0; static int afs_xaxscnt = 0; afs_rwlock_t afs_xaxs; @@ -25,51 +28,54 @@ afs_rwlock_t afs_xaxs; /* PRECONDITION: first field has been checked and doesn't match! * INVARIANT: isparent(i,j) ^ isparent(j,i) (ie, they switch around) */ -struct axscache *afs_SlowFindAxs(struct axscache **cachep, afs_int32 id) +struct axscache * +afs_SlowFindAxs(struct axscache **cachep, afs_int32 id) { - register struct axscache *i,*j; + register struct axscache *i, *j; - j=(*cachep); - i=j->next; + j = (*cachep); + i = j->next; while (i) { if (i->uid == id) { - axs_Front(cachep,j,i); /* maintain LRU queue */ - return(i); + axs_Front(cachep, j, i); /* maintain LRU queue */ + return (i); } - if ((j=i->next)) { /* ASSIGNMENT HERE! */ + if ((j = i->next)) { /* ASSIGNMENT HERE! */ if (j->uid == id) { - axs_Front(cachep,i,j); - return(j); + axs_Front(cachep, i, j); + return (j); } - } else - return ((struct axscache *) NULL); - i=j->next; + } else + return ((struct axscache *)NULL); + i = j->next; } - return ((struct axscache *) NULL); + return ((struct axscache *)NULL); } #define NAXSs (1000 / sizeof(struct axscache)) -struct axscache *axs_Alloc(void) +struct axscache * +axs_Alloc(void) { register struct axscache *i, *j, *xsp; struct axscache *h; int k; - ObtainWriteLock(&afs_xaxs,174); + ObtainWriteLock(&afs_xaxs, 174); if ((h = afs_axsfreelist)) { afs_axsfreelist = h->next; } else { - h=i=j= (struct axscache *) afs_osi_Alloc(NAXSs * sizeof(struct axscache)); + h = i = j = + (struct axscache *)afs_osi_Alloc(NAXSs * sizeof(struct axscache)); afs_xaxscnt++; xsp = (struct axscache *)xfreemallocs; xfreemallocs = (struct xfreelist *)h; xfreemallocs->next = (struct xfreelist *)xsp; - for (k = 0; k < NAXSs-1; k++, i++) { + for (k = 0; k < NAXSs - 1; k++, i++) { i->uid = -2; i->axess = 0; - i->next = ++j; /* need j because order of evaluation not defined */ + i->next = ++j; /* need j because order of evaluation not defined */ } i->uid = -2; i->axess = 0; @@ -77,8 +83,8 @@ struct axscache *axs_Alloc(void) afs_axsfreelist = h->next; } ReleaseWriteLock(&afs_xaxs); - return(h); -} + return (h); +} #define axs_Free(axsp) { \ @@ -91,35 +97,36 @@ struct axscache *axs_Alloc(void) /* I optimize for speed on lookup, and don't give a RIP about delete. */ -void afs_RemoveAxs(struct axscache **headp, struct axscache *axsp) +void +afs_RemoveAxs(struct axscache **headp, struct axscache *axsp) { struct axscache *i, *j; - if (*headp && axsp) { /* is bullet-proofing really neccessary? */ - if (*headp == axsp) { /* most common case, I think */ + if (*headp && axsp) { /* is bullet-proofing really neccessary? */ + if (*headp == axsp) { /* most common case, I think */ *headp = axsp->next; axs_Free(axsp); return; } - i= *headp; - j=i->next; - + i = *headp; + j = i->next; + while (j) { if (j == axsp) { i->next = j->next; axs_Free(axsp); return; } - if ((i = j->next)) { /* ASSIGNMENT HERE! */ + if ((i = j->next)) { /* ASSIGNMENT HERE! */ j->next = i->next; axs_Free(axsp); return; } } - } /* end of "if neither pointer is NULL" */ - - return; /* !#@ FAILED to find it! */ + } + /* end of "if neither pointer is NULL" */ + return; /* !#@ FAILED to find it! */ } @@ -127,45 +134,47 @@ void afs_RemoveAxs(struct axscache **headp, struct axscache *axsp) * Takes an entire list of access cache structs and prepends them, lock, stock, * and barrel, to the front of the freelist. */ -void afs_FreeAllAxs(struct axscache **headp) +void +afs_FreeAllAxs(struct axscache **headp) { - struct axscache *i,*j; + struct axscache *i, *j; - i= *headp; - j=NULL; + i = *headp; + j = NULL; - while (i) { /* chase down the list 'til we reach the end */ - j=i->next; + while (i) { /* chase down the list 'til we reach the end */ + j = i->next; if (!j) { - ObtainWriteLock (&afs_xaxs,176); - i->next = afs_axsfreelist; /* tack on the freelist to the end */ + ObtainWriteLock(&afs_xaxs, 176); + i->next = afs_axsfreelist; /* tack on the freelist to the end */ afs_axsfreelist = *headp; - ReleaseWriteLock (&afs_xaxs); + ReleaseWriteLock(&afs_xaxs); *headp = NULL; return; } - i=j->next; + i = j->next; } - if (j) { /* we ran off the end of the list... */ - ObtainWriteLock (&afs_xaxs,177); - j->next = afs_axsfreelist; /* tack on the freelist to the end */ + if (j) { /* we ran off the end of the list... */ + ObtainWriteLock(&afs_xaxs, 177); + j->next = afs_axsfreelist; /* tack on the freelist to the end */ afs_axsfreelist = *headp; - ReleaseWriteLock (&afs_xaxs); - } + ReleaseWriteLock(&afs_xaxs); + } *headp = NULL; return; } - + /* doesn't appear to be used at all */ #if 0 -static void shutdown_xscache(void) +static void +shutdown_xscache(void) { struct xfreelist *xp, *nxp; RWLOCK_INIT(&afs_xaxs, "afs_xaxs"); - xp = xfreemallocs; + xp = xfreemallocs; while (xp) { nxp = xp->next; afs_osi_Free((char *)xp, NAXSs * sizeof(struct axscache)); diff --git a/src/afs/afs_axscache.h b/src/afs/afs_axscache.h index 58c38185c..370d3a993 100644 --- a/src/afs/afs_axscache.h +++ b/src/afs/afs_axscache.h @@ -26,9 +26,9 @@ */ struct axscache { - afs_int32 uid; /* most frequently used field, I think */ - afs_int32 axess; - struct axscache * next; + afs_int32 uid; /* most frequently used field, I think */ + afs_int32 axess; + struct axscache *next; }; /* DON'T use this with a NULL pointer! @@ -47,4 +47,3 @@ struct axscache { cachep = ac; }} #endif - diff --git a/src/afs/afs_buffer.c b/src/afs/afs_buffer.c index 4c8556c60..f80b7196f 100644 --- a/src/afs/afs_buffer.c +++ b/src/afs/afs_buffer.c @@ -10,7 +10,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" #include "afsincludes.h" @@ -22,7 +23,7 @@ RCSID("$Header$"); #include "h/limits.h" #endif #if !defined(AFS_AIX_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV) -#include "h/kernel.h" /* Doesn't needed, so it should go */ +#include "h/kernel.h" /* Doesn't needed, so it should go */ #endif #endif /* !defined(UKERNEL) */ @@ -66,7 +67,7 @@ RCSID("$Header$"); | (page & PHPAGEMASK)) #ifdef dirty -#undef dirty /* XXX */ +#undef dirty /* XXX */ #endif static struct buffer *Buffers = 0; @@ -87,63 +88,69 @@ static int nbuffers; static afs_int32 timecounter; /* Prototypes for static routines */ -static struct buffer *afs_newslot (afs_inode_t *afid, afs_int32 apage,register struct buffer *lp); +static struct buffer *afs_newslot(afs_inode_t * afid, afs_int32 apage, + register struct buffer *lp); static int dinit_flag = 0; -void DInit (int abuffers) +void +DInit(int abuffers) { /* Initialize the venus buffer system. */ register int i; register struct buffer *tb; #if AFS_USEBUFFERS - struct buf *tub; /* unix buffer for allocation */ + struct buf *tub; /* unix buffer for allocation */ #endif AFS_STATCNT(DInit); - if (dinit_flag) return; + if (dinit_flag) + return; dinit_flag = 1; #if AFS_USEBUFFERS /* round up to next multiple of NPB, since we allocate multiple pages per chunk */ - abuffers = ((abuffers-1) | (NPB-1)) + 1; + abuffers = ((abuffers - 1) | (NPB - 1)) + 1; #endif LOCK_INIT(&afs_bufferLock, "afs_bufferLock"); - Buffers = (struct buffer *) afs_osi_Alloc(abuffers * sizeof(struct buffer)); + Buffers = + (struct buffer *)afs_osi_Alloc(abuffers * sizeof(struct buffer)); #if !AFS_USEBUFFERS - BufferData = (char *) afs_osi_Alloc(abuffers * AFS_BUFFER_PAGESIZE); + BufferData = (char *)afs_osi_Alloc(abuffers * AFS_BUFFER_PAGESIZE); #endif timecounter = 1; afs_stats_cmperf.bufAlloced = nbuffers = abuffers; - for(i=0;ib_un.b_addr; + tub = geteblk(AFS_BUFFER_PAGESIZE * NPB); + BufferData = (char *)tub->b_un.b_addr; } #endif - /* Fill in each buffer with an empty indication. */ + /* Fill in each buffer with an empty indication. */ tb = &Buffers[i]; - dirp_Zap(tb->fid); - tb->accesstime = 0; + dirp_Zap(tb->fid); + tb->accesstime = 0; tb->lockers = 0; #if AFS_USEBUFFERS - if ((i & (NPB-1)) == 0) + if ((i & (NPB - 1)) == 0) tb->bufp = tub; else tb->bufp = 0; - tb->data = &BufferData[AFS_BUFFER_PAGESIZE * (i&(NPB-1))]; + tb->data = &BufferData[AFS_BUFFER_PAGESIZE * (i & (NPB - 1))]; #else - tb->data = &BufferData[AFS_BUFFER_PAGESIZE*i]; + tb->data = &BufferData[AFS_BUFFER_PAGESIZE * i]; #endif tb->hashIndex = 0; - tb->dirty = 0; + tb->dirty = 0; RWLOCK_INIT(&tb->lock, "buffer lock"); } return; } -char *DRead(register afs_inode_t *fid, register int page) +char * +DRead(register afs_inode_t * fid, register int page) { /* Read a page from the disk. */ register struct buffer *tb, *tb2; @@ -151,7 +158,7 @@ char *DRead(register afs_inode_t *fid, register int page) int code; AFS_STATCNT(DRead); - MObtainWriteLock(&afs_bufferLock,256); + MObtainWriteLock(&afs_bufferLock, 256); #define bufmatch(tb) (tb->page == page && dirp_Eq(tb->fid, fid)) #define buf_Front(head,parent,p) {(parent)->hashNext = (p)->hashNext; (p)->hashNext= *(head);*(head)=(p);} @@ -162,47 +169,46 @@ char *DRead(register afs_inode_t *fid, register int page) * of larger code size. This could be simplified by better use of * macros. */ - if ((tb = phTable[pHash(fid,page)])) { + if ((tb = phTable[pHash(fid, page)])) { if (bufmatch(tb)) { - MObtainWriteLock(&tb->lock,257); + MObtainWriteLock(&tb->lock, 257); ReleaseWriteLock(&afs_bufferLock); tb->lockers++; tb->accesstime = timecounter++; AFS_STATS(afs_stats_cmperf.bufHits++); MReleaseWriteLock(&tb->lock); return tb->data; - } - else { - register struct buffer **bufhead; - bufhead = &( phTable[pHash(fid,page)] ); - while ((tb2 = tb->hashNext)) { - if (bufmatch(tb2)) { - buf_Front(bufhead,tb,tb2); - MObtainWriteLock(&tb2->lock,258); - ReleaseWriteLock(&afs_bufferLock); - tb2->lockers++; - tb2->accesstime = timecounter++; - AFS_STATS(afs_stats_cmperf.bufHits++); - MReleaseWriteLock(&tb2->lock); - return tb2->data; + } else { + register struct buffer **bufhead; + bufhead = &(phTable[pHash(fid, page)]); + while ((tb2 = tb->hashNext)) { + if (bufmatch(tb2)) { + buf_Front(bufhead, tb, tb2); + MObtainWriteLock(&tb2->lock, 258); + ReleaseWriteLock(&afs_bufferLock); + tb2->lockers++; + tb2->accesstime = timecounter++; + AFS_STATS(afs_stats_cmperf.bufHits++); + MReleaseWriteLock(&tb2->lock); + return tb2->data; + } + if ((tb = tb2->hashNext)) { + if (bufmatch(tb)) { + buf_Front(bufhead, tb2, tb); + MObtainWriteLock(&tb->lock, 259); + ReleaseWriteLock(&afs_bufferLock); + tb->lockers++; + tb->accesstime = timecounter++; + AFS_STATS(afs_stats_cmperf.bufHits++); + MReleaseWriteLock(&tb->lock); + return tb->data; + } + } else + break; } - if ((tb = tb2->hashNext)) { - if (bufmatch(tb)) { - buf_Front(bufhead,tb2,tb); - MObtainWriteLock(&tb->lock,259); - ReleaseWriteLock(&afs_bufferLock); - tb->lockers++; - tb->accesstime = timecounter++; - AFS_STATS(afs_stats_cmperf.bufHits++); - MReleaseWriteLock(&tb->lock); - return tb->data; - } - } - else break; - } } - } - else tb2 = NULL; + } else + tb2 = NULL; AFS_STATS(afs_stats_cmperf.bufMisses++); /* can't find it */ @@ -215,7 +221,7 @@ char *DRead(register afs_inode_t *fid, register int page) MReleaseWriteLock(&afs_bufferLock); return NULL; } - MObtainWriteLock(&tb->lock,260); + MObtainWriteLock(&tb->lock, 260); MReleaseWriteLock(&afs_bufferLock); tb->lockers++; tfile = afs_CFileOpen(fid[0]); @@ -226,8 +232,9 @@ char *DRead(register afs_inode_t *fid, register int page) afs_CFileClose(tfile); return NULL; } - code = afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, - tb->data, AFS_BUFFER_PAGESIZE); + code = + afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data, + AFS_BUFFER_PAGESIZE); afs_CFileClose(tfile); if (code < AFS_BUFFER_PAGESIZE) { dirp_Zap(tb->fid); @@ -241,7 +248,8 @@ char *DRead(register afs_inode_t *fid, register int page) return tb->data; } -static void FixupBucket(register struct buffer *ap) +static void +FixupBucket(register struct buffer *ap) { register struct buffer **lp, *tp; register int i; @@ -250,7 +258,7 @@ static void FixupBucket(register struct buffer *ap) AFS_STATCNT(FixupBucket); i = ap->hashIndex; lp = &phTable[i]; - for(tp = *lp; tp; tp=tp->hashNext) { + for (tp = *lp; tp; tp = tp->hashNext) { if (tp == ap) { *lp = tp->hashNext; break; @@ -258,14 +266,15 @@ static void FixupBucket(register struct buffer *ap) lp = &tp->hashNext; } /* now figure the new hash bucket */ - i = pHash(ap->fid,ap->page); + i = pHash(ap->fid, ap->page); ap->hashIndex = i; /* remember where we are for deletion */ ap->hashNext = phTable[i]; /* add us to the list */ - phTable[i] = ap; /* at the front, since it's LRU */ + phTable[i] = ap; /* at the front, since it's LRU */ } /* lp is pointer to a fairly-old buffer */ -static struct buffer *afs_newslot (afs_inode_t *afid, afs_int32 apage,register struct buffer *lp) +static struct buffer * +afs_newslot(afs_inode_t * afid, afs_int32 apage, register struct buffer *lp) { /* Find a usable buffer slot */ register afs_int32 i; @@ -281,11 +290,10 @@ static struct buffer *afs_newslot (afs_inode_t *afid, afs_int32 apage,register s * case" for loop below. */ if (lp && (lp->lockers == 0)) { - lt = lp->accesstime; - } - else { - lp = 0; - lt = BUF_TIME_MAX; + lt = lp->accesstime; + } else { + lp = 0; + lt = BUF_TIME_MAX; } /* timecounter might have wrapped, if machine is very very busy @@ -303,44 +311,43 @@ static struct buffer *afs_newslot (afs_inode_t *afid, afs_int32 apage,register s * themselves back out after just a few more DReads. */ if (timecounter < 0) { - timecounter = 1; - tp = Buffers; - for (i=0;iaccesstime = 0; - if (!lp && !tp->lockers) /* one is as good as the rest, I guess */ - lp = tp; - } - } - else { - /* this is the typical case */ - tp = Buffers; - for (i=0;ilockers == 0) { - if (tp->accesstime < lt) { - lp = tp; - lt = tp->accesstime; - } + timecounter = 1; + tp = Buffers; + for (i = 0; i < nbuffers; i++, tp++) { + tp->accesstime = 0; + if (!lp && !tp->lockers) /* one is as good as the rest, I guess */ + lp = tp; + } + } else { + /* this is the typical case */ + tp = Buffers; + for (i = 0; i < nbuffers; i++, tp++) { + if (tp->lockers == 0) { + if (tp->accesstime < lt) { + lp = tp; + lt = tp->accesstime; + } + } } - } } if (lp == 0) { - /* There are no unlocked buffers -- this used to panic, but that - * seems extreme. To the best of my knowledge, all the callers - * of DRead are prepared to handle a zero return. Some of them - * just panic directly, but not all of them. */ - afs_warn ("all buffers locked"); - return 0; + /* There are no unlocked buffers -- this used to panic, but that + * seems extreme. To the best of my knowledge, all the callers + * of DRead are prepared to handle a zero return. Some of them + * just panic directly, but not all of them. */ + afs_warn("all buffers locked"); + return 0; } if (lp->dirty) { tfile = afs_CFileOpen(lp->fid[0]); - afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, - lp->data, AFS_BUFFER_PAGESIZE); - lp->dirty = 0; + afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data, + AFS_BUFFER_PAGESIZE); + lp->dirty = 0; afs_CFileClose(tfile); AFS_STATS(afs_stats_cmperf.bufFlushDirty++); - } + } /* Now fill in the header. */ dirp_Cpy(lp->fid, afid); /* set this */ @@ -351,7 +358,8 @@ static struct buffer *afs_newslot (afs_inode_t *afid, afs_int32 apage,register s return lp; } -void DRelease (register struct buffer *bp, int flag) +void +DRelease(register struct buffer *bp, int flag) { /* Release a buffer, specifying whether or not the buffer has been * modified by the locker. */ @@ -361,29 +369,33 @@ void DRelease (register struct buffer *bp, int flag) #endif AFS_STATCNT(DRelease); - if (!bp) return; + if (!bp) + return; #if AFS_USEBUFFERS /* look for buffer by scanning Unix buffers for appropriate address */ tp = Buffers; - for(index = 0; index < nbuffers; index += NPB, tp += NPB) { - if ((afs_int32)bp >= (afs_int32)tp->data - && (afs_int32)bp < (afs_int32)tp->data + AFS_BUFFER_PAGESIZE*NPB) { + for (index = 0; index < nbuffers; index += NPB, tp += NPB) { + if ((afs_int32) bp >= (afs_int32) tp->data + && (afs_int32) bp < + (afs_int32) tp->data + AFS_BUFFER_PAGESIZE * NPB) { /* we found the right range */ - index += ((afs_int32)bp - (afs_int32)tp->data) >> LOGPS; + index += ((afs_int32) bp - (afs_int32) tp->data) >> LOGPS; break; } } #else - index = (((char *)bp)-((char *)BufferData))>>LOGPS; + index = (((char *)bp) - ((char *)BufferData)) >> LOGPS; #endif bp = &(Buffers[index]); - MObtainWriteLock(&bp->lock,261); + MObtainWriteLock(&bp->lock, 261); bp->lockers--; - if (flag) bp->dirty=1; + if (flag) + bp->dirty = 1; MReleaseWriteLock(&bp->lock); } -int DVOffset (register void *ap) +int +DVOffset(register void *ap) { /* Return the byte within a file represented by a buffer pointer. */ register struct buffer *bp; @@ -392,23 +404,26 @@ int DVOffset (register void *ap) register struct buffer *tp; #endif AFS_STATCNT(DVOffset); - bp=ap; + bp = ap; #if AFS_USEBUFFERS /* look for buffer by scanning Unix buffers for appropriate address */ tp = Buffers; - for(index = 0; index < nbuffers; index += NPB, tp += NPB) { - if ((afs_int32)bp >= (afs_int32)tp->data && (afs_int32)bp < (afs_int32)tp->data + AFS_BUFFER_PAGESIZE*NPB) { + for (index = 0; index < nbuffers; index += NPB, tp += NPB) { + if ((afs_int32) bp >= (afs_int32) tp->data + && (afs_int32) bp < + (afs_int32) tp->data + AFS_BUFFER_PAGESIZE * NPB) { /* we found the right range */ - index += ((afs_int32)bp - (afs_int32)tp->data) >> LOGPS; + index += ((afs_int32) bp - (afs_int32) tp->data) >> LOGPS; break; } } #else - index = (((char *)bp)-((char *)BufferData))>>LOGPS; + index = (((char *)bp) - ((char *)BufferData)) >> LOGPS; #endif - if (index<0 || index >= nbuffers) return -1; + if (index < 0 || index >= nbuffers) + return -1; bp = &(Buffers[index]); - return AFS_BUFFER_PAGESIZE*bp->page+(int)(((char *)ap)-bp->data); + return AFS_BUFFER_PAGESIZE * bp->page + (int)(((char *)ap) - bp->data); } /* 1/1/91 - I've modified the hash function to take the page as well @@ -417,27 +432,29 @@ int DVOffset (register void *ap) * of the hash function. Oh well. This should use the list traversal * method of DRead... */ -void DZap (afs_inode_t *fid) +void +DZap(afs_inode_t * fid) { register int i; /* Destroy all buffers pertaining to a particular fid. */ register struct buffer *tb; - + AFS_STATCNT(DZap); MObtainReadLock(&afs_bufferLock); - for (i=0;i<=PHPAGEMASK;i++) - for(tb=phTable[pHash(fid,i)]; tb; tb=tb->hashNext) - if (dirp_Eq(tb->fid,fid)) { - MObtainWriteLock(&tb->lock,262); - dirp_Zap(tb->fid); - tb->dirty = 0; - MReleaseWriteLock(&tb->lock); - } + for (i = 0; i <= PHPAGEMASK; i++) + for (tb = phTable[pHash(fid, i)]; tb; tb = tb->hashNext) + if (dirp_Eq(tb->fid, fid)) { + MObtainWriteLock(&tb->lock, 262); + dirp_Zap(tb->fid); + tb->dirty = 0; + MReleaseWriteLock(&tb->lock); + } MReleaseReadLock(&afs_bufferLock); } -void DFlush (void) +void +DFlush(void) { /* Flush all the modified buffers. */ register int i; @@ -447,9 +464,9 @@ void DFlush (void) AFS_STATCNT(DFlush); tb = Buffers; MObtainReadLock(&afs_bufferLock); - for(i=0;idirty) { - MObtainWriteLock(&tb->lock,263); + for (i = 0; i < nbuffers; i++, tb++) { + if (tb->dirty) { + MObtainWriteLock(&tb->lock, 263); tb->lockers++; MReleaseReadLock(&afs_bufferLock); if (tb->dirty) { @@ -467,24 +484,26 @@ void DFlush (void) MReleaseReadLock(&afs_bufferLock); } -char *DNew (register afs_inode_t *fid, register int page) +char * +DNew(register afs_inode_t * fid, register int page) { /* Same as read, only do *not* even try to read the page, since it probably doesn't exist. */ register struct buffer *tb; AFS_STATCNT(DNew); - MObtainWriteLock(&afs_bufferLock,264); - if ((tb = afs_newslot(fid,page,NULL)) == 0) { + MObtainWriteLock(&afs_bufferLock, 264); + if ((tb = afs_newslot(fid, page, NULL)) == 0) { MReleaseWriteLock(&afs_bufferLock); return 0; } - MObtainWriteLock(&tb->lock,265); + MObtainWriteLock(&tb->lock, 265); MReleaseWriteLock(&afs_bufferLock); tb->lockers++; MReleaseWriteLock(&tb->lock); return tb->data; } -void shutdown_bufferpackage(void) +void +shutdown_bufferpackage(void) { #if AFS_USEBUFFERS register struct buffer *tp; @@ -496,25 +515,27 @@ void shutdown_bufferpackage(void) /* Free all allocated Buffers and associated buffer pages */ DFlush(); if (afs_cold_shutdown) { - dinit_flag = 0; + dinit_flag = 0; #if !AFS_USEBUFFERS - afs_osi_Free(BufferData, nbuffers * AFS_BUFFER_PAGESIZE); + afs_osi_Free(BufferData, nbuffers * AFS_BUFFER_PAGESIZE); #else - tp = Buffers; - for (i=0; i < nbuffers; i+= NPB, tp += NPB) { - /* The following check shouldn't be necessary and it will be removed soon */ - if (!tp->bufp) - afs_warn("shutdown_bufferpackage: bufp == 0!! Shouldn't happen\n"); - else { - brelse(tp->bufp); - tp->bufp = 0; + tp = Buffers; + for (i = 0; i < nbuffers; i += NPB, tp += NPB) { + /* The following check shouldn't be necessary and it will be removed soon */ + if (!tp->bufp) + afs_warn + ("shutdown_bufferpackage: bufp == 0!! Shouldn't happen\n"); + else { + brelse(tp->bufp); + tp->bufp = 0; + } } - } #endif - afs_osi_Free(Buffers, nbuffers * sizeof(struct buffer)); - nbuffers = 0; - timecounter = 1; - for(i=0;i #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ @@ -42,11 +43,11 @@ struct afsop_cell { }; char afs_zeros[AFS_ZEROS]; -char afs_rootVolumeName[64]=""; -struct afs_icl_set *afs_iclSetp = (struct afs_icl_set*)0; -struct afs_icl_set *afs_iclLongTermSetp = (struct afs_icl_set*)0; +char afs_rootVolumeName[64] = ""; +struct afs_icl_set *afs_iclSetp = (struct afs_icl_set *)0; +struct afs_icl_set *afs_iclLongTermSetp = (struct afs_icl_set *)0; -#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) +#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) kmutex_t afs_global_lock; kmutex_t afs_rxglobal_lock; #endif @@ -97,7 +98,7 @@ afs_int32 afs_rx_deadtime = AFS_RXDEADTIME; afs_int32 afs_rx_harddead = AFS_HARDDEADTIME; static int -Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval); + Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval); #if defined(AFS_HPUX_ENV) extern int afs_vfs_mount(); @@ -106,7 +107,8 @@ extern int afs_vfs_mount(); /* This is code which needs to be called once when the first daemon enters * the client. A non-zero return means an error and AFS should not start. */ -static int afs_InitSetup(int preallocs) +static int +afs_InitSetup(int preallocs) { extern void afs_InitStats(); int code; @@ -122,7 +124,7 @@ static int afs_InitSetup(int preallocs) */ afs_InitStats(); #endif /* AFS_NOSTATS */ - + memset(afs_zeros, 0, AFS_ZEROS); /* start RX */ @@ -148,15 +150,17 @@ struct afsd_thread_info { struct completion *complete; }; -static int afsd_thread(void *rock) { - struct afsd_thread_info *arg=rock; - unsigned long parm=arg->parm; +static int +afsd_thread(void *rock) +{ + struct afsd_thread_info *arg = rock; + unsigned long parm = arg->parm; #ifdef SYS_SETPRIORITY_EXPORTED - int (*sys_setpriority)(int,int,int) = sys_call_table[__NR_setpriority]; + int (*sys_setpriority) (int, int, int) = sys_call_table[__NR_setpriority]; #endif - daemonize(); /* doesn't do much, since we were forked from keventd, but - does call mm_release, which wakes up our parent (since it - used CLONE_VFORK) */ + daemonize(); /* doesn't do much, since we were forked from keventd, but + * does call mm_release, which wakes up our parent (since it + * used CLONE_VFORK) */ reparent_to_init(); afs_osi_MaskSignals(); switch (parm) { @@ -164,53 +168,53 @@ static int afsd_thread(void *rock) { sprintf(current->comm, "afs_cbstart"); AFS_GLOCK(); complete(arg->complete); - afs_CB_Running = 1; + afs_CB_Running = 1; while (afs_RX_Running != 2) afs_osi_Sleep(&afs_RX_Running); sprintf(current->comm, "afs_callback"); afs_RXCallBackServer(); AFS_GUNLOCK(); - complete_and_exit(0,0); + complete_and_exit(0, 0); break; case AFSOP_START_AFS: sprintf(current->comm, "afs_afsstart"); AFS_GLOCK(); complete(arg->complete); AFS_Running = 1; - while (afs_initState < AFSOP_START_AFS) + while (afs_initState < AFSOP_START_AFS) afs_osi_Sleep(&afs_initState); afs_initState = AFSOP_START_BKG; afs_osi_Wakeup(&afs_initState); sprintf(current->comm, "afsd"); afs_Daemon(); AFS_GUNLOCK(); - complete_and_exit(0,0); + complete_and_exit(0, 0); break; case AFSOP_START_BKG: sprintf(current->comm, "afs_bkgstart"); AFS_GLOCK(); complete(arg->complete); - while (afs_initState < AFSOP_START_BKG) + while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); if (afs_initState < AFSOP_GO) { afs_initState = AFSOP_GO; afs_osi_Wakeup(&afs_initState); } - sprintf(current->comm, "afs_background"); + sprintf(current->comm, "afs_background"); afs_BackgroundDaemon(); AFS_GUNLOCK(); - complete_and_exit(0,0); + complete_and_exit(0, 0); break; case AFSOP_START_TRUNCDAEMON: sprintf(current->comm, "afs_trimstart"); AFS_GLOCK(); complete(arg->complete); - while (afs_initState < AFSOP_GO) + while (afs_initState < AFSOP_GO) afs_osi_Sleep(&afs_initState); sprintf(current->comm, "afs_cachetrim"); afs_CacheTruncateDaemon(); AFS_GUNLOCK(); - complete_and_exit(0,0); + complete_and_exit(0, 0); break; case AFSOP_START_CS: sprintf(current->comm, "afs_checkserver"); @@ -218,33 +222,33 @@ static int afsd_thread(void *rock) { complete(arg->complete); afs_CheckServerDaemon(); AFS_GUNLOCK(); - complete_and_exit(0,0); + complete_and_exit(0, 0); break; case AFSOP_RXEVENT_DAEMON: sprintf(current->comm, "afs_evtstart"); #ifdef SYS_SETPRIORITY_EXPORTED - sys_setpriority(PRIO_PROCESS,0,-10); + sys_setpriority(PRIO_PROCESS, 0, -10); #else #ifdef CURRENT_INCLUDES_NICE - current->nice=-10; + current->nice = -10; #endif #endif AFS_GLOCK(); complete(arg->complete); - while (afs_initState < AFSOP_START_BKG) + while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); sprintf(current->comm, "afs_rxevent"); afs_rxevent_daemon(); AFS_GUNLOCK(); - complete_and_exit(0,0); + complete_and_exit(0, 0); break; case AFSOP_RXLISTENER_DAEMON: sprintf(current->comm, "afs_lsnstart"); #ifdef SYS_SETPRIORITY_EXPORTED - sys_setpriority(PRIO_PROCESS,0,-10); + sys_setpriority(PRIO_PROCESS, 0, -10); #else #ifdef CURRENT_INCLUDES_NICE - current->nice=-10; + current->nice = -10; #endif #endif AFS_GLOCK(); @@ -257,7 +261,7 @@ static int afsd_thread(void *rock) { sprintf(current->comm, "afs_rxlistener"); rxk_Listener(); AFS_GUNLOCK(); - complete_and_exit(0,0); + complete_and_exit(0, 0); break; default: printf("Unknown op %d in StartDaemon()\n"); @@ -266,23 +270,28 @@ static int afsd_thread(void *rock) { return 0; } -void afsd_launcher(void *rock) { - if (!kernel_thread(afsd_thread,rock, CLONE_VFORK|SIGCHLD)) +void +afsd_launcher(void *rock) +{ + if (!kernel_thread(afsd_thread, rock, CLONE_VFORK | SIGCHLD)) printf("kernel_thread failed. afs startup will not complete\n"); } -void afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5, - long parm6) +void +afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5, + long parm6) { int code; DECLARE_COMPLETION(c); struct tq_struct tq; - struct afsd_thread_info info; + struct afsd_thread_info info; if (parm == AFSOP_START_RXCALLBACK) { - if (afs_CB_Running) return; + if (afs_CB_Running) + return; } else if (parm == AFSOP_RXLISTENER_DAEMON) { - if (afs_RX_Running) return; - afs_RX_Running=1; + if (afs_RX_Running) + return; + afs_RX_Running = 1; code = afs_InitSetup(parm2); if (parm3) { rx_enablePeerRPCStats(); @@ -293,14 +302,15 @@ void afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5, if (code) return; } else if (parm == AFSOP_START_AFS) { - if (AFS_Running) return; - } /* other functions don't need setup in the parent */ - info.complete=&c; - info.parm=parm; - tq.sync=0; + if (AFS_Running) + return; + } /* other functions don't need setup in the parent */ + info.complete = &c; + info.parm = parm; + tq.sync = 0; INIT_LIST_HEAD(&tq.list); - tq.routine=afsd_launcher; - tq.data=&info; + tq.routine = afsd_launcher; + tq.data = &info; schedule_task(&tq); AFS_GUNLOCK(); /* we need to wait cause we passed stack pointers around.... */ @@ -313,28 +323,28 @@ void afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5, with partial list */ int afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6) -long parm, parm2, parm3, parm4, parm5, parm6; + long parm, parm2, parm3, parm4, parm5, parm6; { afs_int32 code = 0; #if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - size_t bufferSize; + size_t bufferSize; #else /* AFS_SGI61_ENV */ - u_int bufferSize; + u_int bufferSize; #endif /* AFS_SGI61_ENV */ AFS_STATCNT(afs_syscall_call); #ifdef AFS_SUN5_ENV - if (!afs_suser(CRED()) && (parm != AFSOP_GETMTU) + if (!afs_suser(CRED()) && (parm != AFSOP_GETMTU) && (parm != AFSOP_GETMASK)) { - /* only root can run this code */ + /* only root can run this code */ return (EACCES); #else if (!afs_suser() && (parm != AFSOP_GETMTU) && (parm != AFSOP_GETMASK)) { - /* only root can run this code */ + /* only root can run this code */ #if defined(KERNEL_HAVE_UERROR) setuerror(EACCES); - return(EACCES); + return (EACCES); #else #if defined(AFS_OSF_ENV) return EACCES; @@ -347,28 +357,29 @@ long parm, parm2, parm3, parm4, parm5, parm6; AFS_GLOCK(); #if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS) && !defined(UKERNEL) if (parm < AFSOP_ADDCELL || parm == AFSOP_RXEVENT_DAEMON - || parm == AFSOP_RXLISTENER_DAEMON) { - afs_DaemonOp(parm,parm2,parm3,parm4,parm5,parm6); + || parm == AFSOP_RXLISTENER_DAEMON) { + afs_DaemonOp(parm, parm2, parm3, parm4, parm5, parm6); } #else /* !(AFS_LINUX24_ENV && !UKERNEL) */ if (parm == AFSOP_START_RXCALLBACK) { - if (afs_CB_Running) goto out; + if (afs_CB_Running) + goto out; afs_CB_Running = 1; #ifndef RXK_LISTENER_ENV code = afs_InitSetup(parm2); - if (!code) + if (!code) #endif /* !RXK_LISTENER_ENV */ - { + { #ifdef RXK_LISTENER_ENV - while (afs_RX_Running != 2) - afs_osi_Sleep(&afs_RX_Running); + while (afs_RX_Running != 2) + afs_osi_Sleep(&afs_RX_Running); #else /* !RXK_LISTENER_ENV */ - afs_initState = AFSOP_START_AFS; - afs_osi_Wakeup(&afs_initState); + afs_initState = AFSOP_START_AFS; + afs_osi_Wakeup(&afs_initState); #endif /* RXK_LISTENER_ENV */ - afs_osi_Invisible(); - afs_RXCallBackServer(); - } + afs_osi_Invisible(); + afs_RXCallBackServer(); + } #ifdef AFS_SGI_ENV AFS_GUNLOCK(); exit(CLD_EXITED, code); @@ -376,7 +387,8 @@ long parm, parm2, parm3, parm4, parm5, parm6; } #ifdef RXK_LISTENER_ENV else if (parm == AFSOP_RXLISTENER_DAEMON) { - if (afs_RX_Running) goto out; + if (afs_RX_Running) + goto out; afs_RX_Running = 1; code = afs_InitSetup(parm2); if (parm3) { @@ -404,9 +416,10 @@ long parm, parm2, parm3, parm4, parm5, parm6; #endif /* RXK_LISTENER_ENV */ else if (parm == AFSOP_START_AFS) { /* afs daemon */ - if (AFS_Running) goto out; + if (AFS_Running) + goto out; AFS_Running = 1; - while (afs_initState < AFSOP_START_AFS) + while (afs_initState < AFSOP_START_AFS) afs_osi_Sleep(&afs_initState); afs_initState = AFSOP_START_BKG; @@ -417,17 +430,15 @@ long parm, parm2, parm3, parm4, parm5, parm6; AFS_GUNLOCK(); exit(CLD_EXITED, 0); #endif /* AFS_SGI_ENV */ - } - else if (parm == AFSOP_START_CS) { + } else if (parm == AFSOP_START_CS) { afs_osi_Invisible(); afs_CheckServerDaemon(); #ifdef AFS_SGI_ENV AFS_GUNLOCK(); exit(CLD_EXITED, 0); #endif /* AFS_SGI_ENV */ - } - else if (parm == AFSOP_START_BKG) { - while (afs_initState < AFSOP_START_BKG) + } else if (parm == AFSOP_START_BKG) { + while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); if (afs_initState < AFSOP_GO) { afs_initState = AFSOP_GO; @@ -445,9 +456,8 @@ long parm, parm2, parm3, parm4, parm5, parm6; AFS_GUNLOCK(); exit(CLD_EXITED, 0); #endif /* AFS_SGI_ENV */ - } - else if (parm == AFSOP_START_TRUNCDAEMON) { - while (afs_initState < AFSOP_GO) + } else if (parm == AFSOP_START_TRUNCDAEMON) { + while (afs_initState < AFSOP_GO) afs_osi_Sleep(&afs_initState); /* start the bkg daemon */ afs_osi_Invisible(); @@ -459,7 +469,8 @@ long parm, parm2, parm3, parm4, parm5, parm6; } #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV) else if (parm == AFSOP_RXEVENT_DAEMON) { - while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); + while (afs_initState < AFSOP_START_BKG) + afs_osi_Sleep(&afs_initState); afs_osi_Invisible(); afs_rxevent_daemon(); #ifdef AFS_SGI_ENV @@ -476,33 +487,33 @@ long parm, parm2, parm3, parm4, parm5, parm6; afs_osi_Sleep(&afs_InitSetup_done); #if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - temp = AFS_MINBUFFERS; /* Should fix this soon */ + temp = AFS_MINBUFFERS; /* Should fix this soon */ #else /* number of 2k buffers we could get from all of the buffer space */ - temp = ((afs_bufferpages * NBPG)>>11); - temp = temp>>2; /* don't take more than 25% (our magic parameter) */ + temp = ((afs_bufferpages * NBPG) >> 11); + temp = temp >> 2; /* don't take more than 25% (our magic parameter) */ if (temp < AFS_MINBUFFERS) - temp = AFS_MINBUFFERS; /* though we really should have this many */ + temp = AFS_MINBUFFERS; /* though we really should have this many */ #endif DInit(temp); afs_rootFid.Fid.Volume = 0; code = 0; - } - else if (parm == AFSOP_ADDCELL) { + } else if (parm == AFSOP_ADDCELL) { /* add a cell. Parameter 2 is 8 hosts (in net order), parm 3 is the null-terminated - name. Parameter 4 is the length of the name, including the null. Parm 5 is the - home cell flag (0x1 bit) and the nosuid flag (0x2 bit) */ + * name. Parameter 4 is the length of the name, including the null. Parm 5 is the + * home cell flag (0x1 bit) and the nosuid flag (0x2 bit) */ struct afsop_cell *tcell = afs_osi_Alloc(sizeof(struct afsop_cell)); - AFS_COPYIN((char *)parm2, (char *)tcell->hosts, sizeof(tcell->hosts), code); + AFS_COPYIN((char *)parm2, (char *)tcell->hosts, sizeof(tcell->hosts), + code); if (!code) { if (parm4 > sizeof(tcell->cellName)) code = EFAULT; else { AFS_COPYIN((char *)parm3, tcell->cellName, parm4, code); - if (!code) - afs_NewCell(tcell->cellName, tcell->hosts, parm5, - NULL, 0, 0, 0); + if (!code) + afs_NewCell(tcell->cellName, tcell->hosts, parm5, NULL, 0, + 0, 0); } } afs_osi_Free(tcell, sizeof(struct afsop_cell)); @@ -514,30 +525,34 @@ long parm, parm2, parm3, parm4, parm5, parm6; #if 0 /* wait for basic init - XXX can't find any reason we need this? */ - while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); + while (afs_initState < AFSOP_START_BKG) + afs_osi_Sleep(&afs_initState); #endif - AFS_COPYIN((char *)parm2, (char *)tcell->hosts, sizeof(tcell->hosts), code); + AFS_COPYIN((char *)parm2, (char *)tcell->hosts, sizeof(tcell->hosts), + code); if (!code) { - AFS_COPYINSTR((char *)parm3, tbuffer1, AFS_SMALLOCSIZ, &bufferSize, code); + AFS_COPYINSTR((char *)parm3, tbuffer1, AFS_SMALLOCSIZ, + &bufferSize, code); if (!code) { if (parm4 & 4) { - AFS_COPYINSTR((char *)parm5, tbuffer, AFS_SMALLOCSIZ, &bufferSize, code); + AFS_COPYINSTR((char *)parm5, tbuffer, AFS_SMALLOCSIZ, + &bufferSize, code); if (!code) { lcnamep = tbuffer; cflags |= CLinkedCell; } } if (!code) - code = afs_NewCell(tbuffer1, tcell->hosts, cflags, - lcnamep, 0, 0, 0); + code = + afs_NewCell(tbuffer1, tcell->hosts, cflags, lcnamep, + 0, 0, 0); } } afs_osi_Free(tcell, sizeof(struct afsop_cell)); osi_FreeSmallSpace(tbuffer); osi_FreeSmallSpace(tbuffer1); - } - else if (parm == AFSOP_ADDCELLALIAS) { + } else if (parm == AFSOP_ADDCELLALIAS) { /* * Call arguments: * parm2 is the alias name @@ -546,30 +561,33 @@ long parm, parm2, parm3, parm4, parm5, parm6; char *aliasName = osi_AllocSmallSpace(AFS_SMALLOCSIZ); char *cellName = osi_AllocSmallSpace(AFS_SMALLOCSIZ); - AFS_COPYINSTR((char *)parm2, aliasName, AFS_SMALLOCSIZ, &bufferSize, code); - if (!code) AFS_COPYINSTR((char *)parm3, cellName, AFS_SMALLOCSIZ, &bufferSize, code); - if (!code) afs_NewCellAlias(aliasName, cellName); + AFS_COPYINSTR((char *)parm2, aliasName, AFS_SMALLOCSIZ, &bufferSize, + code); + if (!code) + AFS_COPYINSTR((char *)parm3, cellName, AFS_SMALLOCSIZ, + &bufferSize, code); + if (!code) + afs_NewCellAlias(aliasName, cellName); osi_FreeSmallSpace(aliasName); osi_FreeSmallSpace(cellName); - } - else if (parm == AFSOP_SET_THISCELL) { + } else if (parm == AFSOP_SET_THISCELL) { /* * Call arguments: * parm2 is the primary cell name */ char *cell = osi_AllocSmallSpace(AFS_SMALLOCSIZ); - AFS_COPYINSTR((char *) parm2, cell, AFS_SMALLOCSIZ, &bufferSize, code); + AFS_COPYINSTR((char *)parm2, cell, AFS_SMALLOCSIZ, &bufferSize, code); if (!code) afs_SetPrimaryCell(cell); osi_FreeSmallSpace(cell); - } - else if (parm == AFSOP_CACHEINIT) { + } else if (parm == AFSOP_CACHEINIT) { struct afs_cacheParams cparms; - if (afs_CacheInit_Done) goto out; + if (afs_CacheInit_Done) + goto out; - AFS_COPYIN((char *)parm2, (caddr_t) &cparms, sizeof(cparms), code); + AFS_COPYIN((char *)parm2, (caddr_t) & cparms, sizeof(cparms), code); if (code) { #if defined(KERNEL_HAVE_UERROR) setuerror(code); @@ -578,67 +596,63 @@ long parm, parm2, parm3, parm4, parm5, parm6; goto out; } afs_CacheInit_Done = 1; - { - struct afs_icl_log *logp; - /* initialize the ICL system */ - code = afs_icl_CreateLog("cmfx", 60*1024, &logp); - if (code == 0) - code = afs_icl_CreateSetWithFlags("cm", logp, NULL, - ICL_CRSET_FLAG_DEFAULT_OFF, - &afs_iclSetp); - code = afs_icl_CreateSet("cmlongterm", logp, NULL, - &afs_iclLongTermSetp); - } + { + struct afs_icl_log *logp; + /* initialize the ICL system */ + code = afs_icl_CreateLog("cmfx", 60 * 1024, &logp); + if (code == 0) + code = + afs_icl_CreateSetWithFlags("cm", logp, NULL, + ICL_CRSET_FLAG_DEFAULT_OFF, + &afs_iclSetp); + code = + afs_icl_CreateSet("cmlongterm", logp, NULL, + &afs_iclLongTermSetp); + } afs_setTime = cparms.setTimeFlag; - code = afs_CacheInit(cparms.cacheScaches, - cparms.cacheFiles, - cparms.cacheBlocks, - cparms.cacheDcaches, - cparms.cacheVolumes, - cparms.chunkSize, - cparms.memCacheFlag, - cparms.inodes, - cparms.users); + code = + afs_CacheInit(cparms.cacheScaches, cparms.cacheFiles, + cparms.cacheBlocks, cparms.cacheDcaches, + cparms.cacheVolumes, cparms.chunkSize, + cparms.memCacheFlag, cparms.inodes, cparms.users); - } - else if (parm == AFSOP_CACHEINODE) { + } else if (parm == AFSOP_CACHEINODE) { ino_t ainode = parm2; /* wait for basic init */ - while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); + while (afs_initState < AFSOP_START_BKG) + afs_osi_Sleep(&afs_initState); /* do it by inode */ #ifdef AFS_SGI62_ENV ainode = (ainode << 32) | (parm3 & 0xffffffff); #endif code = afs_InitCacheFile(NULL, ainode); - } - else if (parm == AFSOP_ROOTVOLUME) { + } else if (parm == AFSOP_ROOTVOLUME) { /* wait for basic init */ - while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); + while (afs_initState < AFSOP_START_BKG) + afs_osi_Sleep(&afs_initState); if (parm2) { - AFS_COPYINSTR((char *)parm2, afs_rootVolumeName, sizeof(afs_rootVolumeName), &bufferSize, code); - afs_rootVolumeName[sizeof(afs_rootVolumeName)-1] = 0; - } - else code = 0; - } - else if (parm == AFSOP_CACHEFILE || - parm == AFSOP_CACHEINFO || - parm == AFSOP_VOLUMEINFO || - parm == AFSOP_AFSLOG || - parm == AFSOP_CELLINFO) { + AFS_COPYINSTR((char *)parm2, afs_rootVolumeName, + sizeof(afs_rootVolumeName), &bufferSize, code); + afs_rootVolumeName[sizeof(afs_rootVolumeName) - 1] = 0; + } else + code = 0; + } else if (parm == AFSOP_CACHEFILE || parm == AFSOP_CACHEINFO + || parm == AFSOP_VOLUMEINFO || parm == AFSOP_AFSLOG + || parm == AFSOP_CELLINFO) { char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ); code = 0; - AFS_COPYINSTR((char *) parm2, tbuffer, AFS_SMALLOCSIZ, - &bufferSize, code); + AFS_COPYINSTR((char *)parm2, tbuffer, AFS_SMALLOCSIZ, &bufferSize, + code); if (code) { osi_FreeSmallSpace(tbuffer); goto out; } if (!code) { - tbuffer[AFS_SMALLOCSIZ-1] = '\0'; /* null-terminate the name */ + tbuffer[AFS_SMALLOCSIZ - 1] = '\0'; /* null-terminate the name */ /* We have the cache dir copied in. Call the cache init routine */ if (parm == AFSOP_CACHEFILE) code = afs_InitCacheFile(tbuffer, 0); @@ -650,58 +664,67 @@ long parm, parm2, parm3, parm4, parm5, parm6; code = afs_InitCellInfo(tbuffer); } osi_FreeSmallSpace(tbuffer); - } - else if (parm == AFSOP_GO) { + } else if (parm == AFSOP_GO) { /* the generic initialization calls come here. One parameter: should we do the - set-time operation on this workstation */ - if (afs_Go_Done) goto out; + * set-time operation on this workstation */ + if (afs_Go_Done) + goto out; afs_Go_Done = 1; - while (afs_initState < AFSOP_GO) afs_osi_Sleep(&afs_initState); + while (afs_initState < AFSOP_GO) + afs_osi_Sleep(&afs_initState); afs_initState = 101; afs_setTime = parm2; afs_osi_Wakeup(&afs_initState); #if (!defined(AFS_NONFSTRANS) && !defined(AFS_DEC_ENV)) || defined(AFS_AIX_IAUTH_ENV) afs_nfsclient_init(); #endif - printf("found %d non-empty cache files (%d%%).\n", afs_stats_cmperf.cacheFilesReused, - (100*afs_stats_cmperf.cacheFilesReused) / - (afs_stats_cmperf.cacheNumEntries?afs_stats_cmperf.cacheNumEntries : 1)); - } - else if (parm == AFSOP_ADVISEADDR) { + printf("found %d non-empty cache files (%d%%).\n", + afs_stats_cmperf.cacheFilesReused, + (100 * afs_stats_cmperf.cacheFilesReused) / + (afs_stats_cmperf.cacheNumEntries ? afs_stats_cmperf. + cacheNumEntries : 1)); + } else if (parm == AFSOP_ADVISEADDR) { /* pass in the host address to the rx package */ - afs_int32 count = parm2; - afs_int32 *buffer = afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); - afs_int32 *maskbuffer = afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); - afs_int32 *mtubuffer = afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); - int i; - int code; - - if ( count > AFS_MAX_INTERFACE_ADDR ) { - code = ENOMEM; - count = AFS_MAX_INTERFACE_ADDR; + afs_int32 count = parm2; + afs_int32 *buffer = + afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); + afs_int32 *maskbuffer = + afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); + afs_int32 *mtubuffer = + afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); + int i; + int code; + + if (count > AFS_MAX_INTERFACE_ADDR) { + code = ENOMEM; + count = AFS_MAX_INTERFACE_ADDR; } - - AFS_COPYIN( (char *)parm3, (char *)buffer, count*sizeof(afs_int32), code); + + AFS_COPYIN((char *)parm3, (char *)buffer, count * sizeof(afs_int32), + code); if (parm4) - AFS_COPYIN((char *)parm4, (char *)maskbuffer, count*sizeof(afs_int32), code); + AFS_COPYIN((char *)parm4, (char *)maskbuffer, + count * sizeof(afs_int32), code); if (parm5) - AFS_COPYIN((char *)parm5, (char *)mtubuffer, count*sizeof(afs_int32), code); + AFS_COPYIN((char *)parm5, (char *)mtubuffer, + count * sizeof(afs_int32), code); afs_cb_interface.numberOfInterfaces = count; - for (i=0; i < count ; i++) { - afs_cb_interface.addr_in[i] = buffer[i]; -#ifdef AFS_USERSPACE_IP_ADDR - /* AFS_USERSPACE_IP_ADDR means we have no way of finding the - * machines IP addresses when in the kernel (the in_ifaddr - * struct is not available), so we pass the info in at - * startup. We also pass in the subnetmask and mtu size. The - * subnetmask is used when setting the rank: - * afsi_SetServerIPRank(); and the mtu size is used when - * finding the best mtu size. rxi_FindIfnet() is replaced - * with rxi_Findcbi(). - */ - afs_cb_interface.subnetmask[i] = (parm4 ? maskbuffer[i] : 0xffffffff); - afs_cb_interface.mtu[i] = (parm5 ? mtubuffer[i] : htonl(1500)); + for (i = 0; i < count; i++) { + afs_cb_interface.addr_in[i] = buffer[i]; +#ifdef AFS_USERSPACE_IP_ADDR + /* AFS_USERSPACE_IP_ADDR means we have no way of finding the + * machines IP addresses when in the kernel (the in_ifaddr + * struct is not available), so we pass the info in at + * startup. We also pass in the subnetmask and mtu size. The + * subnetmask is used when setting the rank: + * afsi_SetServerIPRank(); and the mtu size is used when + * finding the best mtu size. rxi_FindIfnet() is replaced + * with rxi_Findcbi(). + */ + afs_cb_interface.subnetmask[i] = + (parm4 ? maskbuffer[i] : 0xffffffff); + afs_cb_interface.mtu[i] = (parm5 ? mtubuffer[i] : htonl(1500)); #endif } afs_uuid_create(&afs_cb_interface.uuid); @@ -710,28 +733,26 @@ long parm, parm2, parm3, parm4, parm5, parm6; afs_osi_Free(maskbuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); afs_osi_Free(mtubuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); } - #ifdef AFS_SGI53_ENV else if (parm == AFSOP_NFSSTATICADDR) { - extern int (*nfs_rfsdisptab_v2)(); + extern int (*nfs_rfsdisptab_v2) (); nfs_rfsdisptab_v2 = (int (*)())parm2; - } - else if (parm == AFSOP_NFSSTATICADDR2) { - extern int (*nfs_rfsdisptab_v2)(); + } else if (parm == AFSOP_NFSSTATICADDR2) { + extern int (*nfs_rfsdisptab_v2) (); #ifdef _K64U64 - nfs_rfsdisptab_v2 = (int (*)())((parm2<<32) | (parm3 & 0xffffffff)); + nfs_rfsdisptab_v2 = (int (*)())((parm2 << 32) | (parm3 & 0xffffffff)); #else /* _K64U64 */ nfs_rfsdisptab_v2 = (int (*)())(parm3 & 0xffffffff); #endif /* _K64U64 */ } #if defined(AFS_SGI62_ENV) && !defined(AFS_SGI65_ENV) else if (parm == AFSOP_SBLOCKSTATICADDR2) { - extern int (*afs_sblockp)(); - extern void (*afs_sbunlockp)(); + extern int (*afs_sblockp) (); + extern void (*afs_sbunlockp) (); #ifdef _K64U64 - afs_sblockp = (int (*)())((parm2<<32) | (parm3 & 0xffffffff)); - afs_sbunlockp = (void (*)())((parm4<<32) | (parm5 & 0xffffffff)); -#else + afs_sblockp = (int (*)())((parm2 << 32) | (parm3 & 0xffffffff)); + afs_sbunlockp = (void (*)())((parm4 << 32) | (parm5 & 0xffffffff)); +#else afs_sblockp = (int (*)())(parm3 & 0xffffffff); afs_sbunlockp = (void (*)())(parm5 & 0xffffffff); #endif /* _K64U64 */ @@ -740,7 +761,8 @@ long parm, parm2, parm3, parm4, parm5, parm6; #endif /* AFS_SGI53_ENV */ else if (parm == AFSOP_SHUTDOWN) { afs_cold_shutdown = 0; - if (parm == 1) afs_cold_shutdown = 1; + if (parm == 1) + afs_cold_shutdown = 1; #ifndef AFS_DARWIN_ENV if (afs_globalVFS != 0) { afs_warn("AFS isn't unmounted yet! Call aborted\n"); @@ -748,37 +770,35 @@ long parm, parm2, parm3, parm4, parm5, parm6; } else #endif afs_shutdown(); - } - else if (parm == AFSOP_AFS_VFSMOUNT) { + } else if (parm == AFSOP_AFS_VFSMOUNT) { #ifdef AFS_HPUX_ENV vfsmount(parm2, parm3, parm4, parm5); #else /* defined(AFS_HPUX_ENV) */ #if defined(KERNEL_HAVE_UERROR) - setuerror(EINVAL); + setuerror(EINVAL); #else - code = EINVAL; + code = EINVAL; #endif #endif /* defined(AFS_HPUX_ENV) */ - } - else if (parm == AFSOP_CLOSEWAIT) { + } else if (parm == AFSOP_CLOSEWAIT) { afs_SynchronousCloses = 'S'; - } - else if (parm == AFSOP_GETMTU) { - afs_uint32 mtu = 0; + } else if (parm == AFSOP_GETMTU) { + afs_uint32 mtu = 0; #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) #ifdef AFS_USERSPACE_IP_ADDR - afs_int32 i; - i = rxi_Findcbi(parm2); - mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]); + afs_int32 i; + i = rxi_Findcbi(parm2); + mtu = ((i == -1) ? htonl(1500) : afs_cb_interface.mtu[i]); #else /* AFS_USERSPACE_IP_ADDR */ - struct ifnet *tifnp; + struct ifnet *tifnp; - tifnp = rxi_FindIfnet(parm2, NULL); /* make iterative */ - mtu = (tifnp ? tifnp->if_mtu : htonl(1500)); + tifnp = rxi_FindIfnet(parm2, NULL); /* make iterative */ + mtu = (tifnp ? tifnp->if_mtu : htonl(1500)); #endif /* else AFS_USERSPACE_IP_ADDR */ #endif /* !AFS_SUN5_ENV */ - if (!code) - AFS_COPYOUT ((caddr_t)&mtu, (caddr_t)parm3, sizeof(afs_int32), code); + if (!code) + AFS_COPYOUT((caddr_t) & mtu, (caddr_t) parm3, sizeof(afs_int32), + code); #ifdef AFS_AIX32_ENV /* this is disabled for now because I can't figure out how to get access * to these kernel variables. It's only for supporting user-mode rx @@ -795,28 +815,28 @@ long parm, parm2, parm3, parm4, parm5, parm6; } } */ #endif /* AFS_AIX32_ENV */ - } - else if (parm == AFSOP_GETMASK) { /* parm2 == addr in net order */ - afs_uint32 mask = 0; + } else if (parm == AFSOP_GETMASK) { /* parm2 == addr in net order */ + afs_uint32 mask = 0; #if !defined(AFS_SUN5_ENV) #ifdef AFS_USERSPACE_IP_ADDR - afs_int32 i; - i = rxi_Findcbi(parm2); - if (i != -1) { - mask = afs_cb_interface.subnetmask[i]; - } else { - code = -1; - } + afs_int32 i; + i = rxi_Findcbi(parm2); + if (i != -1) { + mask = afs_cb_interface.subnetmask[i]; + } else { + code = -1; + } #else /* AFS_USERSPACE_IP_ADDR */ - struct ifnet *tifnp; + struct ifnet *tifnp; - tifnp = rxi_FindIfnet(parm2, &mask); /* make iterative */ - if (!tifnp) - code = -1; + tifnp = rxi_FindIfnet(parm2, &mask); /* make iterative */ + if (!tifnp) + code = -1; #endif /* else AFS_USERSPACE_IP_ADDR */ #endif /* !AFS_SUN5_ENV */ - if (!code) - AFS_COPYOUT ((caddr_t)&mask, (caddr_t)parm3, sizeof(afs_int32), code); + if (!code) + AFS_COPYOUT((caddr_t) & mask, (caddr_t) parm3, sizeof(afs_int32), + code); } #ifdef AFS_AFSDB_ENV else if (parm == AFSOP_AFSDB_HANDLER) { @@ -829,37 +849,37 @@ long parm, parm2, parm3, parm4, parm5, parm6; #ifndef UKERNEL afs_osi_MaskSignals(); #endif - AFS_COPYIN((afs_int32 *)parm2, cellname, cellLen, code); - AFS_COPYIN((afs_int32 *)parm3, kmsg, kmsgLen, code); + AFS_COPYIN((afs_int32 *) parm2, cellname, cellLen, code); + AFS_COPYIN((afs_int32 *) parm3, kmsg, kmsgLen, code); if (!code) { code = afs_AFSDBHandler(cellname, cellLen, kmsg); - if (*cellname == 1) *cellname = 0; + if (*cellname == 1) + *cellname = 0; if (code == -2) { /* Shutting down? */ *cellname = 1; code = 0; } } - if (!code) AFS_COPYOUT(cellname, (char *)parm2, cellLen, code); + if (!code) + AFS_COPYOUT(cellname, (char *)parm2, cellLen, code); afs_osi_Free(kmsg, kmsgLen); afs_osi_Free(cellname, cellLen); } #endif else if (parm == AFSOP_SET_DYNROOT) { code = afs_SetDynrootEnable(parm2); - } - else if (parm == AFSOP_SET_FAKESTAT) { + } else if (parm == AFSOP_SET_FAKESTAT) { afs_fakestat_enable = parm2; code = 0; - } - else - code = EINVAL; + } else + code = EINVAL; -out: - AFS_GUNLOCK(); + out: + AFS_GUNLOCK(); #ifdef AFS_LINUX20_ENV - return -code; + return -code; #else - return code; + return code; #endif } @@ -874,76 +894,80 @@ out: * THIS SHOULD BE CHANGED TO afs_syscall(), but requires * all the user-level calls to `syscall' to change. */ -syscall(syscall, p1, p2, p3, p4, p5, p6) { - register rval1=0, code; - register monster; - int retval=0; +syscall(syscall, p1, p2, p3, p4, p5, p6) +{ + register rval1 = 0, code; + register monster; + int retval = 0; #ifndef AFS_AIX41_ENV - extern lock_t kernel_lock; - monster = lockl(&kernel_lock, LOCK_SHORT); + extern lock_t kernel_lock; + monster = lockl(&kernel_lock, LOCK_SHORT); #endif /* !AFS_AIX41_ENV */ - AFS_STATCNT(syscall); - setuerror(0); - switch (syscall) { - case AFSCALL_CALL: - rval1 = afs_syscall_call(p1, p2, p3, p4, p5, p6); - break; + AFS_STATCNT(syscall); + setuerror(0); + switch (syscall) { + case AFSCALL_CALL: + rval1 = afs_syscall_call(p1, p2, p3, p4, p5, p6); + break; - case AFSCALL_SETPAG: - AFS_GLOCK(); - rval1 = afs_setpag(); - AFS_GUNLOCK(); - break; + case AFSCALL_SETPAG: + AFS_GLOCK(); + rval1 = afs_setpag(); + AFS_GUNLOCK(); + break; - case AFSCALL_PIOCTL: - AFS_GLOCK(); - rval1 = afs_syscall_pioctl(p1, p2, p3, p4); - AFS_GUNLOCK(); - break; + case AFSCALL_PIOCTL: + AFS_GLOCK(); + rval1 = afs_syscall_pioctl(p1, p2, p3, p4); + AFS_GUNLOCK(); + break; - case AFSCALL_ICREATE: - rval1 = afs_syscall_icreate(p1, p2, p3, p4, p5, p6); - break; + case AFSCALL_ICREATE: + rval1 = afs_syscall_icreate(p1, p2, p3, p4, p5, p6); + break; - case AFSCALL_IOPEN: - rval1 = afs_syscall_iopen(p1, p2, p3); - break; + case AFSCALL_IOPEN: + rval1 = afs_syscall_iopen(p1, p2, p3); + break; - case AFSCALL_IDEC: - rval1 = afs_syscall_iincdec(p1, p2, p3, -1); - break; + case AFSCALL_IDEC: + rval1 = afs_syscall_iincdec(p1, p2, p3, -1); + break; - case AFSCALL_IINC: - rval1 = afs_syscall_iincdec(p1, p2, p3, 1); - break; + case AFSCALL_IINC: + rval1 = afs_syscall_iincdec(p1, p2, p3, 1); + break; - case AFSCALL_ICL: - AFS_GLOCK(); - code = Afscall_icl(p1, p2, p3, p4, p5, &retval); - AFS_GUNLOCK(); - if (!code) rval1 = retval; - if (!rval1) rval1 = code; - break; + case AFSCALL_ICL: + AFS_GLOCK(); + code = Afscall_icl(p1, p2, p3, p4, p5, &retval); + AFS_GUNLOCK(); + if (!code) + rval1 = retval; + if (!rval1) + rval1 = code; + break; - default: - rval1 = EINVAL; - setuerror(EINVAL); - break; - } + default: + rval1 = EINVAL; + setuerror(EINVAL); + break; + } - out: + out: #ifndef AFS_AIX41_ENV - if (monster != LOCK_NEST) - unlockl(&kernel_lock); + if (monster != LOCK_NEST) + unlockl(&kernel_lock); #endif /* !AFS_AIX41_ENV */ - return getuerror() ? -1 : rval1; + return getuerror()? -1 : rval1; } /* * lsetpag - interface to afs_setpag(). */ -lsetpag() { +lsetpag() +{ AFS_STATCNT(lsetpag); return syscall(AFSCALL_SETPAG, 0, 0, 0, 0, 0); @@ -953,57 +977,63 @@ lsetpag() { * lpioctl - interface to pioctl() */ lpioctl(path, cmd, cmarg, follow) -char *path, *cmarg; { + char *path, *cmarg; +{ AFS_STATCNT(lpioctl); return syscall(AFSCALL_PIOCTL, path, cmd, cmarg, follow); } -#else /* !AFS_AIX32_ENV */ +#else /* !AFS_AIX32_ENV */ #if defined(AFS_SGI_ENV) -struct afsargs -{ - sysarg_t syscall; - sysarg_t parm1; - sysarg_t parm2; - sysarg_t parm3; - sysarg_t parm4; - sysarg_t parm5; +struct afsargs { + sysarg_t syscall; + sysarg_t parm1; + sysarg_t parm2; + sysarg_t parm3; + sysarg_t parm4; + sysarg_t parm5; }; int -Afs_syscall (struct afsargs *uap, rval_t *rvp) +Afs_syscall(struct afsargs *uap, rval_t * rvp) { int error; long retval; AFS_STATCNT(afs_syscall); - switch(uap->syscall) { + switch (uap->syscall) { case AFSCALL_ICL: retval = 0; AFS_GLOCK(); - error=Afscall_icl(uap->parm1,uap->parm2,uap->parm3,uap->parm4,uap->parm5, &retval); + error = + Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, + uap->parm5, &retval); AFS_GUNLOCK(); rvp->r_val1 = retval; break; #ifdef AFS_SGI_XFS_IOPS_ENV case AFSCALL_IDEC64: - error = afs_syscall_idec64(uap->parm1, uap->parm2, uap->parm3, - uap->parm4, uap->parm5); + error = + afs_syscall_idec64(uap->parm1, uap->parm2, uap->parm3, uap->parm4, + uap->parm5); break; case AFSCALL_IINC64: - error = afs_syscall_iinc64(uap->parm1, uap->parm2, uap->parm3, - uap->parm4, uap->parm5); + error = + afs_syscall_iinc64(uap->parm1, uap->parm2, uap->parm3, uap->parm4, + uap->parm5); break; case AFSCALL_ILISTINODE64: - error = afs_syscall_ilistinode64(uap->parm1, uap->parm2, uap->parm3, - uap->parm4, uap->parm5); + error = + afs_syscall_ilistinode64(uap->parm1, uap->parm2, uap->parm3, + uap->parm4, uap->parm5); break; case AFSCALL_ICREATENAME64: - error = afs_syscall_icreatename64(uap->parm1, uap->parm2, uap->parm3, - uap->parm4, uap->parm5); + error = + afs_syscall_icreatename64(uap->parm1, uap->parm2, uap->parm3, + uap->parm4, uap->parm5); break; #endif #ifdef AFS_SGI_VNODE_GLUE @@ -1012,8 +1042,9 @@ Afs_syscall (struct afsargs *uap, rval_t *rvp) break; #endif default: - error = afs_syscall_call(uap->syscall, uap->parm1, uap->parm2, - uap->parm3, uap->parm4, uap->parm5); + error = + afs_syscall_call(uap->syscall, uap->parm1, uap->parm2, uap->parm3, + uap->parm4, uap->parm5); } return error; } @@ -1038,10 +1069,10 @@ struct iparam32 { static void iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst) { - dst->param1 = src->param1; - dst->param2 = src->param2; - dst->param3 = src->param3; - dst->param4 = src->param4; + dst->param1 = src->param1; + dst->param2 = src->param2; + dst->param3 = src->param3; + dst->param4 = src->param4; } /* @@ -1052,53 +1083,52 @@ iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst) static int copyin_iparam(caddr_t cmarg, struct iparam *dst) { - int code; + int code; #if defined(AFS_HPUX_64BIT_ENV) - struct iparam32 dst32; + struct iparam32 dst32; - if (is_32bit(u.u_procp)) /* is_32bit() in proc_iface.h */ - { - AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code); - if (!code) - iparam32_to_iparam(&dst32, dst); - return code; - } + if (is_32bit(u.u_procp)) { /* is_32bit() in proc_iface.h */ + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + iparam32_to_iparam(&dst32, dst); + return code; + } #endif /* AFS_HPUX_64BIT_ENV */ #if defined(AFS_SUN57_64BIT_ENV) - struct iparam32 dst32; + struct iparam32 dst32; - if (get_udatamodel() == DATAMODEL_ILP32) { - AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code); - if (!code) - iparam32_to_iparam(&dst32, dst); - return code; - } + if (get_udatamodel() == DATAMODEL_ILP32) { + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + iparam32_to_iparam(&dst32, dst); + return code; + } #endif /* AFS_SUN57_64BIT_ENV */ #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) - struct iparam32 dst32; + struct iparam32 dst32; #ifdef AFS_SPARC64_LINUX24_ENV - if (current->thread.flags & SPARC_FLAG_32BIT) + if (current->thread.flags & SPARC_FLAG_32BIT) #elif defined(AFS_SPARC64_LINUX20_ENV) - if (current->tss.flags & SPARC_FLAG_32BIT) + if (current->tss.flags & SPARC_FLAG_32BIT) #elif defined(AFS_AMD64_LINUX20_ENV) - if (current->thread.flags & THREAD_IA32) + if (current->thread.flags & THREAD_IA32) #else #error Not done for this linux version -#endif - { - AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code); - if (!code) - iparam32_to_iparam(&dst32, dst); - return code; - } +#endif + { + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + iparam32_to_iparam(&dst32, dst); + return code; + } #endif /* AFS_LINUX_64BIT_KERNEL */ - AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code); - return code; + AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code); + return code; } /* Main entry of all afs system calls */ @@ -1132,7 +1162,7 @@ struct afssysa { }; #endif -Afs_syscall(register struct afssysa *uap, rval_t *rvp) +Afs_syscall(register struct afssysa *uap, rval_t * rvp) { int *retval = &rvp->r_val1; #else /* AFS_SUN5_ENV */ @@ -1140,12 +1170,12 @@ Afs_syscall(register struct afssysa *uap, rval_t *rvp) int afs3_syscall(p, args, retval) #ifdef AFS_FBSD50_ENV - struct thread *p; + struct thread *p; #else - struct proc *p; + struct proc *p; #endif - void *args; - int *retval; + void *args; + int *retval; { register struct a { long syscall; @@ -1156,7 +1186,7 @@ afs3_syscall(p, args, retval) long parm5; long parm6; } *uap = (struct a *)args; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ #ifdef AFS_LINUX20_ENV struct afssysargs { long syscall; @@ -1165,50 +1195,50 @@ struct afssysargs { long parm3; long parm4; long parm5; - long parm6; /* not actually used - should be removed */ + long parm6; /* not actually used - should be removed */ }; /* Linux system calls only set up for 5 arguments. */ -asmlinkage long afs_syscall(long syscall, long parm1, long parm2, long parm3, - long parm4) +asmlinkage long +afs_syscall(long syscall, long parm1, long parm2, long parm3, long parm4) { struct afssysargs args, *uap = &args; - long linux_ret=0; + long linux_ret = 0; long *retval = &linux_ret; - long eparm[4]; /* matches AFSCALL_ICL in fstrace.c */ + long eparm[4]; /* matches AFSCALL_ICL in fstrace.c */ #ifdef AFS_SPARC64_LINUX24_ENV afs_int32 eparm32[4]; #endif /* eparm is also used by AFSCALL_CALL in afsd.c */ #else #if defined(UKERNEL) -Afs_syscall () +Afs_syscall() { register struct a { - long syscall; - long parm1; - long parm2; - long parm3; - long parm4; - long parm5; - long parm6; - } *uap = (struct a *)u.u_ap; + long syscall; + long parm1; + long parm2; + long parm3; + long parm4; + long parm5; + long parm6; + } *uap = (struct a *)u.u_ap; #else /* UKERNEL */ int #if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV) -afs_syscall () +afs_syscall() #else -Afs_syscall () -#endif /* SUN && !SUN5 */ +Afs_syscall() +#endif /* SUN && !SUN5 */ { register struct a { - long syscall; - long parm1; - long parm2; - long parm3; - long parm4; - long parm5; - long parm6; - } *uap = (struct a *)u.u_ap; + long syscall; + long parm1; + long parm2; + long parm3; + long parm4; + long parm5; + long parm6; + } *uap = (struct a *)u.u_ap; #endif /* UKERNEL */ #if defined(AFS_DEC_ENV) int *retval = &u.u_r.r_val1; @@ -1251,19 +1281,18 @@ Afs_syscall () if (current->thread.flags & SPARC_FLAG_32BIT) { - AFS_COPYIN((char*)parm4, (char*)eparm32, sizeof(eparm32), code); - eparm[0]=AA(eparm32[0]); - eparm[1]=AA(eparm32[1]); - eparm[2]=AA(eparm32[2]); + AFS_COPYIN((char *)parm4, (char *)eparm32, sizeof(eparm32), code); + eparm[0] = AA(eparm32[0]); + eparm[1] = AA(eparm32[1]); + eparm[2] = AA(eparm32[2]); #undef AA -} else + } else #endif - AFS_COPYIN((char*)parm4, (char*)eparm, sizeof(eparm), code); + AFS_COPYIN((char *)parm4, (char *)eparm, sizeof(eparm), code); uap->parm4 = eparm[0]; uap->parm5 = eparm[1]; uap->parm6 = eparm[2]; - } - else { + } else { uap->parm4 = parm4; uap->parm5 = 0; uap->parm6 = 0; @@ -1281,10 +1310,13 @@ Afs_syscall () #endif if (uap->syscall == AFSCALL_CALL) { #ifdef AFS_SUN5_ENV - code = afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, - uap->parm4, uap->parm5, uap->parm6, rvp, CRED()); + code = + afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, uap->parm4, + uap->parm5, uap->parm6, rvp, CRED()); #else - code = afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, uap->parm4, uap->parm5, uap->parm6); + code = + afs_syscall_call(uap->parm1, uap->parm2, uap->parm3, uap->parm4, + uap->parm5, uap->parm6); #endif } else if (uap->syscall == AFSCALL_SETPAG) { #ifdef AFS_SUN5_ENV @@ -1292,13 +1324,13 @@ Afs_syscall () procp = ttoproc(curthread); AFS_GLOCK(); - code = afs_setpag(&procp->p_cred); + code = afs_setpag(&procp->p_cred); AFS_GUNLOCK(); #else AFS_GLOCK(); #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) code = afs_setpag(p, args, retval); -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ code = afs_setpag(); #endif AFS_GUNLOCK(); @@ -1306,13 +1338,21 @@ Afs_syscall () } else if (uap->syscall == AFSCALL_PIOCTL) { AFS_GLOCK(); #if defined(AFS_SUN5_ENV) - code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, rvp, CRED()); + code = + afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, + rvp, CRED()); #elif defined(AFS_FBSD50_ENV) - code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, p->td_ucred); + code = + afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, + p->td_ucred); #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, p->p_cred->pc_ucred); + code = + afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, + p->p_cred->pc_ucred); #else - code = afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, uap->parm4); + code = + afs_syscall_pioctl(uap->parm1, uap->parm2, uap->parm3, + uap->parm4); #endif AFS_GUNLOCK(); } else if (uap->syscall == AFSCALL_ICREATE) { @@ -1325,57 +1365,69 @@ Afs_syscall () #endif } else #ifdef AFS_SUN5_ENV - code = afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, iparams.param2, - iparams.param3, iparams.param4, rvp, CRED()); + code = + afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, + iparams.param2, iparams.param3, + iparams.param4, rvp, CRED()); #else - code = afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, iparams.param2, + code = + afs_syscall_icreate(uap->parm1, uap->parm2, iparams.param1, + iparams.param2, #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - iparams.param3, iparams.param4, retval); + iparams.param3, iparams.param4, retval); #else - iparams.param3, iparams.param4); + iparams.param3, iparams.param4); #endif -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ } else if (uap->syscall == AFSCALL_IOPEN) { #ifdef AFS_SUN5_ENV - code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp, CRED()); + code = + afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, rvp, + CRED()); #else #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3, retval); #else code = afs_syscall_iopen(uap->parm1, uap->parm2, uap->parm3); #endif -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ } else if (uap->syscall == AFSCALL_IDEC) { #ifdef AFS_SUN5_ENV - code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1, rvp, CRED()); + code = + afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1, rvp, + CRED()); #else code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, -1); -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ } else if (uap->syscall == AFSCALL_IINC) { #ifdef AFS_SUN5_ENV - code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1, rvp, CRED()); + code = + afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1, rvp, + CRED()); #else code = afs_syscall_iincdec(uap->parm1, uap->parm2, uap->parm3, 1); -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ } else if (uap->syscall == AFSCALL_ICL) { AFS_GLOCK(); - code = Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, uap->parm5, retval); + code = + Afscall_icl(uap->parm1, uap->parm2, uap->parm3, uap->parm4, + uap->parm5, retval); AFS_GUNLOCK(); #ifdef AFS_LINUX20_ENV if (!code) { /* ICL commands can return values. */ - code = -linux_ret; /* Gets negated again at exit below */ + code = -linux_ret; /* Gets negated again at exit below */ } #else - if (code) { + if (code) { #if defined(KERNEL_HAVE_UERROR) setuerror(code); #endif - } + } #endif /* !AFS_LINUX20_ENV */ } else { #if defined(KERNEL_HAVE_UERROR) - setuerror(EINVAL); + setuerror(EINVAL); #else code = EINVAL; #endif @@ -1388,7 +1440,7 @@ Afs_syscall () return code; } #endif /* AFS_SGI_ENV */ -#endif /* !AFS_AIX32_ENV */ +#endif /* !AFS_AIX32_ENV */ /* * Initstate in the range 0 < x < 100 are early initialization states. @@ -1400,22 +1452,25 @@ Afs_syscall () * incorrectly. * Initstate of 300 means that the volume has been *successfully* looked up. */ -int afs_CheckInit(void) +int +afs_CheckInit(void) { register int code = 0; AFS_STATCNT(afs_CheckInit); if (afs_initState <= 100) - code = ENXIO; /* never finished init phase */ + code = ENXIO; /* never finished init phase */ else if (afs_initState == 101) { /* init done, wait for afs_daemon */ - while (afs_initState < 200) afs_osi_Sleep(&afs_initState); - } else if (afs_initState == 200) - code = ETIMEDOUT; /* didn't find root volume */ + while (afs_initState < 200) + afs_osi_Sleep(&afs_initState); + } else if (afs_initState == 200) + code = ETIMEDOUT; /* didn't find root volume */ return code; } -int afs_shuttingdown = 0; -void afs_shutdown(void) +int afs_shuttingdown = 0; +void +afs_shutdown(void) { extern short afs_brsDaemons; extern afs_int32 afs_CheckServerDaemonStarted; @@ -1423,11 +1478,14 @@ void afs_shutdown(void) extern struct osi_file *afs_cacheInodep; AFS_STATCNT(afs_shutdown); - if (afs_shuttingdown) return; + if (afs_shuttingdown) + return; afs_shuttingdown = 1; - if (afs_cold_shutdown) afs_warn("COLD "); - else afs_warn("WARM "); - afs_warn("shutting down of: CB... "); + if (afs_cold_shutdown) + afs_warn("COLD "); + else + afs_warn("WARM "); + afs_warn("shutting down of: CB... "); afs_termState = AFSOP_STOP_RXCALLBACK; rx_WakeupServerProcs(); @@ -1455,7 +1513,7 @@ void afs_shutdown(void) afs_warn("CTrunc... "); /* Cancel cache truncate daemon. */ while (afs_termState == AFSOP_STOP_TRUNCDAEMON) { - afs_osi_Wakeup((char*)&afs_CacheTruncateDaemon); + afs_osi_Wakeup((char *)&afs_CacheTruncateDaemon); afs_osi_Sleep(&afs_termState); } #ifdef AFS_AFSDB_ENV @@ -1467,7 +1525,7 @@ void afs_shutdown(void) #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV) afs_warn("RxEvent... "); /* cancel rx event daemon */ - while (afs_termState == AFSOP_STOP_RXEVENT) + while (afs_termState == AFSOP_STOP_RXEVENT) afs_osi_Sleep(&afs_termState); #if defined(RXK_LISTENER_ENV) #ifndef UKERNEL @@ -1476,31 +1534,30 @@ void afs_shutdown(void) #endif /* cancel rx listener */ afs_warn("RxListener... "); - osi_StopListener(); /* This closes rx_socket. */ + osi_StopListener(); /* This closes rx_socket. */ while (afs_termState == AFSOP_STOP_RXK_LISTENER) { afs_warn("Sleep... "); afs_osi_Sleep(&afs_termState); } #endif #else - afs_termState = AFSOP_STOP_COMPLETE; + afs_termState = AFSOP_STOP_COMPLETE; #endif afs_warn("\n"); /* Close file only after daemons which can write to it are stopped. */ - if (afs_cacheInodep) /* memcache won't set this */ - { - osi_UFSClose(afs_cacheInodep); /* Since we always leave it open */ + if (afs_cacheInodep) { /* memcache won't set this */ + osi_UFSClose(afs_cacheInodep); /* Since we always leave it open */ afs_cacheInodep = 0; } - return; /* Just kill daemons for now */ + return; /* Just kill daemons for now */ #ifdef notdef - shutdown_CB(); + shutdown_CB(); shutdown_AFS(); shutdown_rxkernel(); - shutdown_rxevent(); + shutdown_rxevent(); shutdown_rx(); - afs_shutdown_BKG(); + afs_shutdown_BKG(); shutdown_bufferpackage(); shutdown_daemons(); shutdown_cache(); @@ -1529,20 +1586,22 @@ void afs_shutdown(void) #endif } -void shutdown_afstest(void) +void +shutdown_afstest(void) { AFS_STATCNT(shutdown_afstest); afs_initState = afs_termState = afs_setTime = 0; AFS_Running = afs_CB_Running = 0; afs_CacheInit_Done = afs_Go_Done = 0; if (afs_cold_shutdown) { - *afs_rootVolumeName = 0; + *afs_rootVolumeName = 0; } } /* In case there is a bunch of dynamically build bkg daemons to free */ -void afs_shutdown_BKG(void) +void +afs_shutdown_BKG(void) { AFS_STATCNT(shutdown_BKG); } @@ -1566,7 +1625,8 @@ int afs_icl_sizeofLong = 1; int afs_icl_inited = 0; /* init function, called once, under afs_icl_lock */ -int afs_icl_Init(void) +int +afs_icl_Init(void) { afs_icl_inited = 1; return 0; @@ -1602,7 +1662,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval) return (EACCES); } #else - if (!afs_suser()) { /* only root can run this code */ + if (!afs_suser()) { /* only root can run this code */ #if defined(KERNEL_HAVE_UERROR) setuerror(EACCES); return EACCES; @@ -1620,103 +1680,123 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval) * skip some records. */ AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code); - if (code) return code; + if (code) + return code; AFS_COPYIN((char *)p4, (char *)&startCookie, sizeof(afs_int32), code); - if (code) return code; + if (code) + return code; logp = afs_icl_FindLog(tname); - if (!logp) return ENOENT; + if (!logp) + return ENOENT; #define BUFFERSIZE AFS_LRALLOCSIZ lp = (afs_int32 *) osi_AllocLargeSpace(AFS_LRALLOCSIZ); elts = BUFFERSIZE / sizeof(afs_int32); - if (p3 < elts) elts = p3; + if (p3 < elts) + elts = p3; flags = (opcode == ICL_OP_COPYOUT) ? 0 : ICL_COPYOUTF_CLRAFTERREAD; - code = afs_icl_CopyOut(logp, lp, &elts, (afs_uint32 *) &startCookie, - &flags); + code = + afs_icl_CopyOut(logp, lp, &elts, (afs_uint32 *) & startCookie, + &flags); if (code) { - osi_FreeLargeSpace((struct osi_buffer *) lp); + osi_FreeLargeSpace((struct osi_buffer *)lp); break; } AFS_COPYOUT((char *)lp, (char *)p2, elts * sizeof(afs_int32), code); - if (code) goto done; - AFS_COPYOUT((char *) &startCookie, (char *)p4, sizeof(afs_int32), code); - if (code) goto done; + if (code) + goto done; + AFS_COPYOUT((char *)&startCookie, (char *)p4, sizeof(afs_int32), + code); + if (code) + goto done; #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) if (!(IS64U)) - *retval = ((long) ((flags<<24) | (elts & 0xffffff))) << 32; + *retval = ((long)((flags << 24) | (elts & 0xffffff))) << 32; else #endif - *retval = (flags<<24) | (elts & 0xffffff); + *retval = (flags << 24) | (elts & 0xffffff); done: afs_icl_LogRele(logp); - osi_FreeLargeSpace((struct osi_buffer *) lp); + osi_FreeLargeSpace((struct osi_buffer *)lp); break; case ICL_OP_ENUMLOGS: /* enumerate logs */ /* enumerate logs: p1=index, p2=&name, p3=sizeof(name), p4=&size. * return 0 for success, otherwise error. */ - for(tlp = afs_icl_allLogs; tlp; tlp=tlp->nextp) { - if (p1-- == 0) break; + for (tlp = afs_icl_allLogs; tlp; tlp = tlp->nextp) { + if (p1-- == 0) + break; } - if (!tlp) return ENOENT; /* past the end of file */ - temp = strlen(tlp->name)+1; - if (temp > p3) return EINVAL; - AFS_COPYOUT(tlp->name, (char *) p2, temp, code); - if (!code) /* copy out size of log */ - AFS_COPYOUT((char *)&tlp->logSize, (char *)p4, sizeof (afs_int32), code); + if (!tlp) + return ENOENT; /* past the end of file */ + temp = strlen(tlp->name) + 1; + if (temp > p3) + return EINVAL; + AFS_COPYOUT(tlp->name, (char *)p2, temp, code); + if (!code) /* copy out size of log */ + AFS_COPYOUT((char *)&tlp->logSize, (char *)p4, sizeof(afs_int32), + code); break; case ICL_OP_ENUMLOGSBYSET: /* enumerate logs by set name */ /* enumerate logs: p1=setname, p2=index, p3=&name, p4=sizeof(name). * return 0 for success, otherwise error. */ - AFS_COPYINSTR((char *)p1, tname, sizeof (tname), &temp, code); - if (code) return code; + AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code); + if (code) + return code; setp = afs_icl_FindSet(tname); - if (!setp) return ENOENT; + if (!setp) + return ENOENT; if (p2 > ICL_LOGSPERSET) return EINVAL; if (!(tlp = setp->logs[p2])) return EBADF; - temp = strlen(tlp->name)+1; - if (temp > p4) return EINVAL; + temp = strlen(tlp->name) + 1; + if (temp > p4) + return EINVAL; AFS_COPYOUT(tlp->name, (char *)p3, temp, code); break; - case ICL_OP_CLRLOG: /* clear specified log */ + case ICL_OP_CLRLOG: /* clear specified log */ /* zero out the specified log: p1=logname */ - AFS_COPYINSTR((char *)p1, tname, sizeof (tname), &temp, code); - if (code) return code; + AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code); + if (code) + return code; logp = afs_icl_FindLog(tname); - if (!logp) return ENOENT; + if (!logp) + return ENOENT; code = afs_icl_ZeroLog(logp); afs_icl_LogRele(logp); break; - case ICL_OP_CLRSET: /* clear specified set */ + case ICL_OP_CLRSET: /* clear specified set */ /* zero out the specified set: p1=setname */ - AFS_COPYINSTR((char *)p1, tname, sizeof (tname), &temp, code); - if (code) return code; + AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code); + if (code) + return code; setp = afs_icl_FindSet(tname); - if (!setp) return ENOENT; + if (!setp) + return ENOENT; code = afs_icl_ZeroSet(setp); afs_icl_SetRele(setp); break; - case ICL_OP_CLRALL: /* clear all logs */ + case ICL_OP_CLRALL: /* clear all logs */ /* zero out all logs -- no args */ code = 0; - ObtainWriteLock(&afs_icl_lock,178); - for(tlp = afs_icl_allLogs; tlp; tlp=tlp->nextp) { + ObtainWriteLock(&afs_icl_lock, 178); + for (tlp = afs_icl_allLogs; tlp; tlp = tlp->nextp) { tlp->refCount++; /* hold this guy */ ReleaseWriteLock(&afs_icl_lock); /* don't clear persistent logs */ if ((tlp->states & ICL_LOGF_PERSISTENT) == 0) code = afs_icl_ZeroLog(tlp); - ObtainWriteLock(&afs_icl_lock,179); + ObtainWriteLock(&afs_icl_lock, 179); if (--tlp->refCount == 0) afs_icl_ZapLog(tlp); - if (code) break; + if (code) + break; } ReleaseWriteLock(&afs_icl_lock); break; @@ -1725,23 +1805,29 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval) /* enumerate sets: p1=index, p2=&name, p3=sizeof(name), p4=&states. * return 0 for success, otherwise error. */ - for(setp = afs_icl_allSets; setp; setp = setp->nextp) { - if (p1-- == 0) break; + for (setp = afs_icl_allSets; setp; setp = setp->nextp) { + if (p1-- == 0) + break; } - if (!setp) return ENOENT; /* past the end of file */ - temp = strlen(setp->name)+1; - if (temp > p3) return EINVAL; + if (!setp) + return ENOENT; /* past the end of file */ + temp = strlen(setp->name) + 1; + if (temp > p3) + return EINVAL; AFS_COPYOUT(setp->name, (char *)p2, temp, code); - if (!code) /* copy out size of log */ - AFS_COPYOUT((char *)&setp->states,(char *)p4, sizeof (afs_int32), code); + if (!code) /* copy out size of log */ + AFS_COPYOUT((char *)&setp->states, (char *)p4, sizeof(afs_int32), + code); break; case ICL_OP_SETSTAT: /* set status on a set */ /* activate the specified set: p1=setname, p2=op */ AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code); - if (code) return code; + if (code) + return code; setp = afs_icl_FindSet(tname); - if (!setp) return ENOENT; + if (!setp) + return ENOENT; code = afs_icl_SetSetStat(setp, p2); afs_icl_SetRele(setp); break; @@ -1749,51 +1835,61 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval) case ICL_OP_SETSTATALL: /* set status on all sets */ /* activate the specified set: p1=op */ code = 0; - ObtainWriteLock(&afs_icl_lock,180); - for(setp = afs_icl_allSets; setp; setp=setp->nextp) { + ObtainWriteLock(&afs_icl_lock, 180); + for (setp = afs_icl_allSets; setp; setp = setp->nextp) { setp->refCount++; /* hold this guy */ ReleaseWriteLock(&afs_icl_lock); /* don't set states on persistent sets */ if ((setp->states & ICL_SETF_PERSISTENT) == 0) code = afs_icl_SetSetStat(setp, p1); - ObtainWriteLock(&afs_icl_lock,181); + ObtainWriteLock(&afs_icl_lock, 181); if (--setp->refCount == 0) afs_icl_ZapSet(setp); - if (code) break; + if (code) + break; } ReleaseWriteLock(&afs_icl_lock); break; - case ICL_OP_SETLOGSIZE: /* set size of log */ + case ICL_OP_SETLOGSIZE: /* set size of log */ /* set the size of the specified log: p1=logname, p2=size (in words) */ AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code); - if (code) return code; + if (code) + return code; logp = afs_icl_FindLog(tname); - if (!logp) return ENOENT; + if (!logp) + return ENOENT; code = afs_icl_LogSetSize(logp, p2); afs_icl_LogRele(logp); break; - case ICL_OP_GETLOGINFO: /* get size of log */ + case ICL_OP_GETLOGINFO: /* get size of log */ /* zero out the specified log: p1=logname, p2=&logSize, p3=&allocated */ AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code); - if (code) return code; + if (code) + return code; logp = afs_icl_FindLog(tname); - if (!logp) return ENOENT; + if (!logp) + return ENOENT; allocated = !!logp->datap; - AFS_COPYOUT((char *)&logp->logSize, (char *) p2, sizeof(afs_int32), code); + AFS_COPYOUT((char *)&logp->logSize, (char *)p2, sizeof(afs_int32), + code); if (!code) - AFS_COPYOUT((char *)&allocated, (char *) p3, sizeof(afs_int32), code); + AFS_COPYOUT((char *)&allocated, (char *)p3, sizeof(afs_int32), + code); afs_icl_LogRele(logp); break; - case ICL_OP_GETSETINFO: /* get state of set */ + case ICL_OP_GETSETINFO: /* get state of set */ /* zero out the specified set: p1=setname, p2=&state */ AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code); - if (code) return code; + if (code) + return code; setp = afs_icl_FindSet(tname); - if (!setp) return ENOENT; - AFS_COPYOUT((char *)&setp->states, (char *) p2, sizeof(afs_int32), code); + if (!setp) + return ENOENT; + AFS_COPYOUT((char *)&setp->states, (char *)p2, sizeof(afs_int32), + code); afs_icl_SetRele(setp); break; @@ -1808,8 +1904,9 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval) afs_lock_t afs_icl_lock; /* exported routine: a 4 parameter event */ -int afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT, long p1, long p2, long p3, long p4) +int +afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID, + afs_int32 lAndT, long p1, long p2, long p3, long p4) { afs_int32 mask; register int i; @@ -1821,17 +1918,18 @@ int afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID, return 0; AFS_ASSERT_GLOCK(); - mask = lAndT>>24 & 0xff; /* mask of which logs to log to */ + mask = lAndT >> 24 & 0xff; /* mask of which logs to log to */ ix = ICL_EVENTBYTE(eventID); ObtainReadLock(&setp->lock); if (setp->eventFlags[ix] & ICL_EVENTMASK(eventID)) { - for(i=0, tmask = 1; ilogs[i], eventID, lAndT & 0xffffff, - p1, p2, p3, p4); + p1, p2, p3, p4); } mask &= ~tmask; - if (mask == 0) break; /* break early */ + if (mask == 0) + break; /* break early */ } } ReleaseReadLock(&setp->lock); @@ -1842,28 +1940,34 @@ int afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID, * Whole purpose is to avoid compiler warnings about parameter # mismatches. * Otherwise, could call afs_icl_Event4 directly. */ -int afs_icl_Event3(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT, long p1, long p2, long p3) +int +afs_icl_Event3(register struct afs_icl_set *setp, afs_int32 eventID, + afs_int32 lAndT, long p1, long p2, long p3) { return afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, (long)0); } -int afs_icl_Event2(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT, long p1, long p2) +int +afs_icl_Event2(register struct afs_icl_set *setp, afs_int32 eventID, + afs_int32 lAndT, long p1, long p2) { return afs_icl_Event4(setp, eventID, lAndT, p1, p2, (long)0, (long)0); } -int afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT, long p1) +int +afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID, + afs_int32 lAndT, long p1) { - return afs_icl_Event4(setp, eventID, lAndT, p1, (long)0, (long)0, (long)0); + return afs_icl_Event4(setp, eventID, lAndT, p1, (long)0, (long)0, + (long)0); } -int afs_icl_Event0(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT) +int +afs_icl_Event0(register struct afs_icl_set *setp, afs_int32 eventID, + afs_int32 lAndT) { - return afs_icl_Event4(setp, eventID, lAndT, (long)0, (long)0, (long)0, (long)0); + return afs_icl_Event4(setp, eventID, lAndT, (long)0, (long)0, (long)0, + (long)0); } struct afs_icl_log *afs_icl_allLogs = 0; @@ -1874,7 +1978,8 @@ struct afs_icl_log *afs_icl_allLogs = 0; * * Log must be write-locked. */ -static void afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 minSpace) +static void +afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 minSpace) { register unsigned int tsize; @@ -1894,14 +1999,15 @@ static void afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 min * log must be write-locked. */ #define ICL_CHARSPERLONG 4 -static void afs_icl_AppendString(struct afs_icl_log *logp, char *astr) +static void +afs_icl_AppendString(struct afs_icl_log *logp, char *astr) { - char *op; /* ptr to char to write */ + char *op; /* ptr to char to write */ int tc; - register int bib; /* bytes in buffer */ + register int bib; /* bytes in buffer */ bib = 0; - op = (char *) &(logp->datap[logp->firstFree]); + op = (char *)&(logp->datap[logp->firstFree]); while (1) { tc = *astr++; *op++ = tc; @@ -1910,11 +2016,12 @@ static void afs_icl_AppendString(struct afs_icl_log *logp, char *astr) bib = 0; if (++(logp->firstFree) >= logp->logSize) { logp->firstFree = 0; - op = (char *) &(logp->datap[0]); + op = (char *)&(logp->datap[0]); } logp->logElements++; } - if (tc == 0) break; + if (tc == 0) + break; } if (bib > 0) { /* if we've used this word at all, allocate it */ @@ -1949,7 +2056,8 @@ static void afs_icl_AppendString(struct afs_icl_log *logp, char *astr) /* routine to tell whether we're dealing with the address or the * object itself */ -int afs_icl_UseAddr(int type) +int +afs_icl_UseAddr(int type) { if (type == ICL_TYPE_HYPER || type == ICL_TYPE_STRING || type == ICL_TYPE_FID || type == ICL_TYPE_INT64) @@ -1963,8 +2071,9 @@ int afs_icl_UseAddr(int type) * pretty soon, anyway. The log must be unlocked. */ -void afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op, - afs_int32 types, long p1, long p2, long p3, long p4) +void +afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op, + afs_int32 types, long p1, long p2, long p3, long p4) { int rsize; /* record size in longs */ register int tsize; /* temp size */ @@ -1980,7 +2089,7 @@ void afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op, t1 = types & 0x3f; osi_GetTime(&tv); /* It panics for solaris if inside */ - ObtainWriteLock(&logp->lock,182); + ObtainWriteLock(&logp->lock, 182); if (!logp->datap) { ReleaseWriteLock(&logp->lock); return; @@ -1990,23 +2099,24 @@ void afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op, * change that often. This algorithm ticks over every 20 minutes * or so (1000 seconds). Write a timestamp record if it has. */ - if (tv.tv_sec - logp->lastTS > 1024) - { + if (tv.tv_sec - logp->lastTS > 1024) { /* the timer has wrapped -- write a timestamp record */ if (logp->logSize - logp->logElements <= 5) afs_icl_GetLogSpace(logp, 5); - ICL_APPENDINT32(logp, (afs_int32)(5<<24) + (ICL_TYPE_UNIXDATE<<18)); - ICL_APPENDINT32(logp, (afs_int32)ICL_INFO_TIMESTAMP); - ICL_APPENDINT32(logp, (afs_int32)0); /* use thread ID zero for clocks */ ICL_APPENDINT32(logp, - (afs_int32)(tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec); - ICL_APPENDINT32(logp, (afs_int32)tv.tv_sec); + (afs_int32) (5 << 24) + (ICL_TYPE_UNIXDATE << 18)); + ICL_APPENDINT32(logp, (afs_int32) ICL_INFO_TIMESTAMP); + ICL_APPENDINT32(logp, (afs_int32) 0); /* use thread ID zero for clocks */ + ICL_APPENDINT32(logp, + (afs_int32) (tv.tv_sec & 0x3ff) * 1000000 + + tv.tv_usec); + ICL_APPENDINT32(logp, (afs_int32) tv.tv_sec); logp->lastTS = tv.tv_sec; } - rsize = 4; /* base case */ + rsize = 4; /* base case */ if (t1) { /* compute size of parameter p1. Only tricky case is string. * In that case, we have to call strlen to get the string length. @@ -2039,171 +2149,179 @@ void afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op, */ if (rsize > 255) { ReleaseWriteLock(&logp->lock); - return; /* log record too big to express */ + return; /* log record too big to express */ } if (logp->logSize - logp->logElements <= rsize) afs_icl_GetLogSpace(logp, rsize); ICL_APPENDINT32(logp, - (afs_int32)(rsize<<24) + (t1<<18) + (t2<<12) + (t3<<6) + t4); - ICL_APPENDINT32(logp, (afs_int32)op); - ICL_APPENDINT32(logp, (afs_int32)osi_ThreadUnique()); - ICL_APPENDINT32(logp, (afs_int32)(tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec); + (afs_int32) (rsize << 24) + (t1 << 18) + (t2 << 12) + + (t3 << 6) + t4); + ICL_APPENDINT32(logp, (afs_int32) op); + ICL_APPENDINT32(logp, (afs_int32) osi_ThreadUnique()); + ICL_APPENDINT32(logp, + (afs_int32) (tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec); if (t1) { /* marshall parameter 1 now */ if (t1 == ICL_TYPE_STRING) { - afs_icl_AppendString(logp, (char *) p1); - } - else if (t1 == ICL_TYPE_HYPER) { - ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p1)->high); - ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p1)->low); - } - else if (t1 == ICL_TYPE_INT64) { + afs_icl_AppendString(logp, (char *)p1); + } else if (t1 == ICL_TYPE_HYPER) { + ICL_APPENDINT32(logp, + (afs_int32) ((struct afs_hyper_t *)p1)->high); + ICL_APPENDINT32(logp, + (afs_int32) ((struct afs_hyper_t *)p1)->low); + } else if (t1 == ICL_TYPE_INT64) { #ifdef AFSLITTLE_ENDIAN #ifdef AFS_64BIT_CLIENT - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]); #else /* AFS_64BIT_CLIENT */ ICL_APPENDINT32(logp, (afs_int32) p1); ICL_APPENDINT32(logp, (afs_int32) 0); #endif /* AFS_64BIT_CLIENT */ #else /* AFSLITTLE_ENDIAN */ #ifdef AFS_64BIT_CLIENT - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]); #else /* AFS_64BIT_CLIENT */ ICL_APPENDINT32(logp, (afs_int32) 0); ICL_APPENDINT32(logp, (afs_int32) p1); #endif /* AFS_64BIT_CLIENT */ #endif /* AFSLITTLE_ENDIAN */ - } - else if (t1 == ICL_TYPE_FID) { - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[0]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[1]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[2]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p1)[3]); + } else if (t1 == ICL_TYPE_FID) { + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[2]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[3]); } #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) else if (t1 == ICL_TYPE_INT32) - ICL_APPENDINT32(logp, (afs_int32)p1); + ICL_APPENDINT32(logp, (afs_int32) p1); #endif /* AFS_ALPHA_ENV */ - else ICL_APPENDLONG(logp, p1); + else + ICL_APPENDLONG(logp, p1); } if (t2) { /* marshall parameter 2 now */ - if (t2 == ICL_TYPE_STRING) afs_icl_AppendString(logp, (char *) p2); + if (t2 == ICL_TYPE_STRING) + afs_icl_AppendString(logp, (char *)p2); else if (t2 == ICL_TYPE_HYPER) { - ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p2)->high); - ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p2)->low); - } - else if (t2 == ICL_TYPE_INT64) { + ICL_APPENDINT32(logp, + (afs_int32) ((struct afs_hyper_t *)p2)->high); + ICL_APPENDINT32(logp, + (afs_int32) ((struct afs_hyper_t *)p2)->low); + } else if (t2 == ICL_TYPE_INT64) { #ifdef AFSLITTLE_ENDIAN #ifdef AFS_64BIT_CLIENT - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]); #else /* AFS_64BIT_CLIENT */ ICL_APPENDINT32(logp, (afs_int32) p2); ICL_APPENDINT32(logp, (afs_int32) 0); #endif /* AFS_64BIT_CLIENT */ #else /* AFSLITTLE_ENDIAN */ #ifdef AFS_64BIT_CLIENT - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]); #else /* AFS_64BIT_CLIENT */ ICL_APPENDINT32(logp, (afs_int32) 0); ICL_APPENDINT32(logp, (afs_int32) p2); #endif /* AFS_64BIT_CLIENT */ #endif /* AFSLITTLE_ENDIAN */ - } - else if (t2 == ICL_TYPE_FID) { - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[0]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[1]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[2]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p2)[3]); + } else if (t2 == ICL_TYPE_FID) { + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[2]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[3]); } #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) else if (t2 == ICL_TYPE_INT32) - ICL_APPENDINT32(logp, (afs_int32)p2); + ICL_APPENDINT32(logp, (afs_int32) p2); #endif /* AFS_ALPHA_ENV */ - else ICL_APPENDLONG(logp, p2); + else + ICL_APPENDLONG(logp, p2); } if (t3) { /* marshall parameter 3 now */ - if (t3 == ICL_TYPE_STRING) afs_icl_AppendString(logp, (char *) p3); + if (t3 == ICL_TYPE_STRING) + afs_icl_AppendString(logp, (char *)p3); else if (t3 == ICL_TYPE_HYPER) { - ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p3)->high); - ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p3)->low); - } - else if (t3 == ICL_TYPE_INT64) { + ICL_APPENDINT32(logp, + (afs_int32) ((struct afs_hyper_t *)p3)->high); + ICL_APPENDINT32(logp, + (afs_int32) ((struct afs_hyper_t *)p3)->low); + } else if (t3 == ICL_TYPE_INT64) { #ifdef AFSLITTLE_ENDIAN #ifdef AFS_64BIT_CLIENT - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]); #else /* AFS_64BIT_CLIENT */ ICL_APPENDINT32(logp, (afs_int32) p3); ICL_APPENDINT32(logp, (afs_int32) 0); #endif /* AFS_64BIT_CLIENT */ #else /* AFSLITTLE_ENDIAN */ #ifdef AFS_64BIT_CLIENT - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]); #else /* AFS_64BIT_CLIENT */ ICL_APPENDINT32(logp, (afs_int32) 0); ICL_APPENDINT32(logp, (afs_int32) p3); #endif /* AFS_64BIT_CLIENT */ #endif /* AFSLITTLE_ENDIAN */ - } - else if (t3 == ICL_TYPE_FID) { - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[0]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[1]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[2]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p3)[3]); + } else if (t3 == ICL_TYPE_FID) { + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[2]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[3]); } #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) else if (t3 == ICL_TYPE_INT32) - ICL_APPENDINT32(logp, (afs_int32)p3); + ICL_APPENDINT32(logp, (afs_int32) p3); #endif /* AFS_ALPHA_ENV */ - else ICL_APPENDLONG(logp, p3); + else + ICL_APPENDLONG(logp, p3); } if (t4) { /* marshall parameter 4 now */ - if (t4 == ICL_TYPE_STRING) afs_icl_AppendString(logp, (char *) p4); + if (t4 == ICL_TYPE_STRING) + afs_icl_AppendString(logp, (char *)p4); else if (t4 == ICL_TYPE_HYPER) { - ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p4)->high); - ICL_APPENDINT32(logp, (afs_int32)((struct afs_hyper_t *)p4)->low); - } - else if (t4 == ICL_TYPE_INT64) { + ICL_APPENDINT32(logp, + (afs_int32) ((struct afs_hyper_t *)p4)->high); + ICL_APPENDINT32(logp, + (afs_int32) ((struct afs_hyper_t *)p4)->low); + } else if (t4 == ICL_TYPE_INT64) { #ifdef AFSLITTLE_ENDIAN #ifdef AFS_64BIT_CLIENT - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]); #else /* AFS_64BIT_CLIENT */ ICL_APPENDINT32(logp, (afs_int32) p4); ICL_APPENDINT32(logp, (afs_int32) 0); #endif /* AFS_64BIT_CLIENT */ #else /* AFSLITTLE_ENDIAN */ #ifdef AFS_64BIT_CLIENT - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]); #else /* AFS_64BIT_CLIENT */ ICL_APPENDINT32(logp, (afs_int32) 0); ICL_APPENDINT32(logp, (afs_int32) p4); #endif /* AFS_64BIT_CLIENT */ #endif /* AFSLITTLE_ENDIAN */ - } - else if (t4 == ICL_TYPE_FID) { - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[0]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[1]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[2]); - ICL_APPENDINT32(logp, (afs_int32)((afs_int32 *)p4)[3]); + } else if (t4 == ICL_TYPE_FID) { + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[2]); + ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[3]); } #if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) else if (t4 == ICL_TYPE_INT32) - ICL_APPENDINT32(logp, (afs_int32)p4); + ICL_APPENDINT32(logp, (afs_int32) p4); #endif /* AFS_ALPHA_ENV */ - else ICL_APPENDLONG(logp, p4); + else + ICL_APPENDLONG(logp, p4); } ReleaseWriteLock(&logp->lock); } @@ -2211,31 +2329,34 @@ void afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op, /* create a log with size logSize; return it in *outLogpp and tag * it with name "name." */ -int afs_icl_CreateLog(char *name, afs_int32 logSize, struct afs_icl_log **outLogpp) +int +afs_icl_CreateLog(char *name, afs_int32 logSize, + struct afs_icl_log **outLogpp) { - return afs_icl_CreateLogWithFlags(name, logSize, /*flags*/0, outLogpp); + return afs_icl_CreateLogWithFlags(name, logSize, /*flags */ 0, outLogpp); } /* create a log with size logSize; return it in *outLogpp and tag * it with name "name." 'flags' can be set to make the log unclearable. */ -int afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags, - struct afs_icl_log **outLogpp) +int +afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags, + struct afs_icl_log **outLogpp) { register struct afs_icl_log *logp; /* add into global list under lock */ - ObtainWriteLock(&afs_icl_lock,183); - if (!afs_icl_inited) afs_icl_Init(); + ObtainWriteLock(&afs_icl_lock, 183); + if (!afs_icl_inited) + afs_icl_Init(); - for (logp = afs_icl_allLogs; logp; logp=logp->nextp) { + for (logp = afs_icl_allLogs; logp; logp = logp->nextp) { if (strcmp(logp->name, name) == 0) { /* found it already created, just return it */ logp->refCount++; *outLogpp = logp; - if (flags & ICL_CRLOG_FLAG_PERSISTENT) - { - ObtainWriteLock(&logp->lock,184); + if (flags & ICL_CRLOG_FLAG_PERSISTENT) { + ObtainWriteLock(&logp->lock, 184); logp->states |= ICL_LOGF_PERSISTENT; ReleaseWriteLock(&logp->lock); } @@ -2243,17 +2364,17 @@ int afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags, return 0; } } - + logp = (struct afs_icl_log *) osi_AllocSmallSpace(sizeof(struct afs_icl_log)); - memset((caddr_t)logp, 0, sizeof(*logp)); + memset((caddr_t) logp, 0, sizeof(*logp)); logp->refCount = 1; - logp->name = osi_AllocSmallSpace(strlen(name)+1); + logp->name = osi_AllocSmallSpace(strlen(name) + 1); strcpy(logp->name, name); LOCK_INIT(&logp->lock, "logp lock"); logp->logSize = logSize; - logp->datap = NULL; /* don't allocate it until we need it */ + logp->datap = NULL; /* don't allocate it until we need it */ if (flags & ICL_CRLOG_FLAG_PERSISTENT) logp->states |= ICL_LOGF_PERSISTENT; @@ -2272,15 +2393,17 @@ int afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags, * in *flagsp. The flag ICL_COPYOUTF_MISSEDSOME is set if we can't * find the record with cookie value cookie. */ -int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, - afs_int32 *bufSizep, afs_uint32 *cookiep, afs_int32 *flagsp) +int +afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 * bufferp, + afs_int32 * bufSizep, afs_uint32 * cookiep, + afs_int32 * flagsp) { afs_int32 nwords; /* number of words to copy out */ afs_uint32 startCookie; /* first cookie to use */ afs_int32 outWords; /* words we've copied out */ afs_int32 inWords; /* max words to copy out */ - afs_int32 code; /* return code */ - afs_int32 ix; /* index we're copying from */ + afs_int32 code; /* return code */ + afs_int32 ix; /* index we're copying from */ afs_int32 outFlags; /* return flags */ afs_int32 inFlags; /* flags passed in */ afs_int32 end; @@ -2292,7 +2415,7 @@ int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, inFlags = *flagsp; code = 0; - ObtainWriteLock(&logp->lock,185); + ObtainWriteLock(&logp->lock, 185); if (!logp->datap) { ReleaseWriteLock(&logp->lock); goto done; @@ -2302,7 +2425,7 @@ int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, while (1) { /* (re-)compute where we should start */ if (startCookie < logp->baseCookie) { - if (startCookie) /* missed some output */ + if (startCookie) /* missed some output */ outFlags |= ICL_COPYOUTF_MISSEDSOME; /* skip to the first available record */ startCookie = logp->baseCookie; @@ -2311,14 +2434,15 @@ int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, /* compute where we find the first element to copy out */ ix = logp->firstUsed + startCookie - logp->baseCookie; - if (ix >= logp->logSize) ix -= logp->logSize; + if (ix >= logp->logSize) + ix -= logp->logSize; /* if have some data now, break out and process it */ - if (startCookie - logp->baseCookie < logp->logElements) break; + if (startCookie - logp->baseCookie < logp->logElements) + break; /* At end of log, so clear it if we need to */ - if (inFlags & ICL_COPYOUTF_CLRAFTERREAD) - { + if (inFlags & ICL_COPYOUTF_CLRAFTERREAD) { logp->firstUsed = logp->firstFree = 0; logp->logElements = 0; } @@ -2331,7 +2455,7 @@ int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, logp->states |= ICL_LOGF_WAITING; ReleaseWriteLock(&logp->lock); afs_osi_Sleep(&logp->lock); - ObtainWriteLock(&logp->lock,186); + ObtainWriteLock(&logp->lock, 186); } /* copy out data from ix to logSize or firstFree, depending * upon whether firstUsed <= firstFree (no wrap) or otherwise. @@ -2347,7 +2471,8 @@ int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, if (end - ix < nwords) nwords = end - ix; if (nwords > 0) { - memcpy((char *) bufferp, (char *) &logp->datap[ix], sizeof(afs_int32) * nwords); + memcpy((char *)bufferp, (char *)&logp->datap[ix], + sizeof(afs_int32) * nwords); outWords += nwords; inWords -= nwords; bufferp += nwords; @@ -2358,8 +2483,8 @@ int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, /* now, if active part of the log has wrapped, there's more stuff * starting at the head of the log. Copy out more from there. */ - if (logp->firstUsed > logp->firstFree - && ix < logp->firstFree && inWords > 0) { + if (logp->firstUsed > logp->firstFree && ix < logp->firstFree + && inWords > 0) { /* (more to) copy out from the wrapped section at the * start of the log. May get here even if didn't copy any * above, if the cookie points directly into the wrapped section. @@ -2367,7 +2492,8 @@ int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, nwords = inWords; if (logp->firstFree - ix < nwords) nwords = logp->firstFree - ix; - memcpy((char *) bufferp, (char *) &logp->datap[ix], sizeof(afs_int32) * nwords); + memcpy((char *)bufferp, (char *)&logp->datap[ix], + sizeof(afs_int32) * nwords); outWords += nwords; inWords -= nwords; bufferp += nwords; @@ -2384,8 +2510,9 @@ int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, } /* return basic parameter information about a log */ -int afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 *maxSizep, - afs_int32 *curSizep) +int +afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 * maxSizep, + afs_int32 * curSizep) { ObtainReadLock(&logp->lock); *maxSizep = logp->logSize; @@ -2396,32 +2523,36 @@ int afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 *maxSizep, /* hold and release logs */ -int afs_icl_LogHold(register struct afs_icl_log *logp) +int +afs_icl_LogHold(register struct afs_icl_log *logp) { - ObtainWriteLock(&afs_icl_lock,187); + ObtainWriteLock(&afs_icl_lock, 187); logp->refCount++; ReleaseWriteLock(&afs_icl_lock); return 0; } /* hold and release logs, called with lock already held */ -int afs_icl_LogHoldNL(register struct afs_icl_log *logp) +int +afs_icl_LogHoldNL(register struct afs_icl_log *logp) { logp->refCount++; return 0; } /* keep track of how many sets believe the log itself is allocated */ -int afs_icl_LogUse(register struct afs_icl_log *logp) +int +afs_icl_LogUse(register struct afs_icl_log *logp) { - ObtainWriteLock(&logp->lock,188); + ObtainWriteLock(&logp->lock, 188); if (logp->setCount == 0) { /* this is the first set actually using the log -- allocate it */ - if (logp->logSize == 0) { + if (logp->logSize == 0) { /* we weren't passed in a hint and it wasn't set */ logp->logSize = ICL_DEFAULT_LOGSIZE; } - logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize); + logp->datap = + (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize); #ifdef KERNEL_HAVE_PIN pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize); #endif @@ -2432,11 +2563,12 @@ int afs_icl_LogUse(register struct afs_icl_log *logp) } /* decrement the number of real users of the log, free if possible */ -int afs_icl_LogFreeUse(register struct afs_icl_log *logp) +int +afs_icl_LogFreeUse(register struct afs_icl_log *logp) { - ObtainWriteLock(&logp->lock,189); + ObtainWriteLock(&logp->lock, 189); if (--logp->setCount == 0) { - /* no more users -- free it (but keep log structure around)*/ + /* no more users -- free it (but keep log structure around) */ afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize); #ifdef KERNEL_HAVE_PIN unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize); @@ -2450,14 +2582,14 @@ int afs_icl_LogFreeUse(register struct afs_icl_log *logp) } /* set the size of the log to 'logSize' */ -int afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize) -{ - ObtainWriteLock(&logp->lock,190); +int +afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize) +{ + ObtainWriteLock(&logp->lock, 190); if (!logp->datap) { /* nothing to worry about since it's not allocated */ logp->logSize = logSize; - } - else { + } else { /* reset log */ logp->firstUsed = logp->firstFree = 0; logp->logElements = 0; @@ -2467,7 +2599,8 @@ int afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize) #ifdef KERNEL_HAVE_PIN unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize); #endif - logp->datap = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize); + logp->datap = + (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize); #ifdef KERNEL_HAVE_PIN pin((char *)logp->datap, sizeof(afs_int32) * logSize); #endif @@ -2479,27 +2612,29 @@ int afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize) } /* free a log. Called with afs_icl_lock locked. */ -int afs_icl_ZapLog(register struct afs_icl_log *logp) +int +afs_icl_ZapLog(register struct afs_icl_log *logp) { register struct afs_icl_log **lpp, *tp; - for(lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) { + for (lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) { if (tp == logp) { /* found the dude we want to remove */ *lpp = logp->nextp; osi_FreeSmallSpace(logp->name); osi_FreeSmallSpace(logp->datap); osi_FreeSmallSpace(logp); - break; /* won't find it twice */ + break; /* won't find it twice */ } } return 0; } /* do the release, watching for deleted entries */ -int afs_icl_LogRele(register struct afs_icl_log *logp) +int +afs_icl_LogRele(register struct afs_icl_log *logp) { - ObtainWriteLock(&afs_icl_lock,191); + ObtainWriteLock(&afs_icl_lock, 191); if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) { afs_icl_ZapLog(logp); /* destroys logp's lock! */ } @@ -2508,7 +2643,8 @@ int afs_icl_LogRele(register struct afs_icl_log *logp) } /* do the release, watching for deleted entries, log already held */ -int afs_icl_LogReleNL(register struct afs_icl_log *logp) +int +afs_icl_LogReleNL(register struct afs_icl_log *logp) { if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) { afs_icl_ZapLog(logp); /* destroys logp's lock! */ @@ -2517,9 +2653,10 @@ int afs_icl_LogReleNL(register struct afs_icl_log *logp) } /* zero out the log */ -int afs_icl_ZeroLog(register struct afs_icl_log *logp) +int +afs_icl_ZeroLog(register struct afs_icl_log *logp) { - ObtainWriteLock(&logp->lock,192); + ObtainWriteLock(&logp->lock, 192); logp->firstUsed = logp->firstFree = 0; logp->logElements = 0; logp->baseCookie = 0; @@ -2528,9 +2665,10 @@ int afs_icl_ZeroLog(register struct afs_icl_log *logp) } /* free a log entry, and drop its reference count */ -int afs_icl_LogFree(register struct afs_icl_log *logp) +int +afs_icl_LogFree(register struct afs_icl_log *logp) { - ObtainWriteLock(&logp->lock,193); + ObtainWriteLock(&logp->lock, 193); logp->states |= ICL_LOGF_DELETED; ReleaseWriteLock(&logp->lock); afs_icl_LogRele(logp); @@ -2538,11 +2676,12 @@ int afs_icl_LogFree(register struct afs_icl_log *logp) } /* find a log by name, returning it held */ -struct afs_icl_log *afs_icl_FindLog(char *name) +struct afs_icl_log * +afs_icl_FindLog(char *name) { register struct afs_icl_log *tp; - ObtainWriteLock(&afs_icl_lock,194); - for(tp = afs_icl_allLogs; tp; tp=tp->nextp) { + ObtainWriteLock(&afs_icl_lock, 194); + for (tp = afs_icl_allLogs; tp; tp = tp->nextp) { if (strcmp(tp->name, name) == 0) { /* this is the dude we want */ tp->refCount++; @@ -2553,23 +2692,27 @@ struct afs_icl_log *afs_icl_FindLog(char *name) return tp; } -int afs_icl_EnumerateLogs(int (*aproc)(char *name,char *arock,struct afs_icl_log *tp), char *arock) +int +afs_icl_EnumerateLogs(int (*aproc) + (char *name, char *arock, struct afs_icl_log * tp), + char *arock) { register struct afs_icl_log *tp; register afs_int32 code; code = 0; - ObtainWriteLock(&afs_icl_lock,195); - for(tp = afs_icl_allLogs; tp; tp=tp->nextp) { - tp->refCount++; /* hold this guy */ + ObtainWriteLock(&afs_icl_lock, 195); + for (tp = afs_icl_allLogs; tp; tp = tp->nextp) { + tp->refCount++; /* hold this guy */ ReleaseWriteLock(&afs_icl_lock); ObtainReadLock(&tp->lock); - code = (*aproc)(tp->name, arock, tp); + code = (*aproc) (tp->name, arock, tp); ReleaseReadLock(&tp->lock); - ObtainWriteLock(&afs_icl_lock,196); + ObtainWriteLock(&afs_icl_lock, 196); if (--tp->refCount == 0) afs_icl_ZapLog(tp); - if (code) break; + if (code) + break; } ReleaseWriteLock(&afs_icl_lock); return code; @@ -2577,11 +2720,13 @@ int afs_icl_EnumerateLogs(int (*aproc)(char *name,char *arock,struct afs_icl_log struct afs_icl_set *afs_icl_allSets = 0; -int afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp, - struct afs_icl_log *fatalLogp, struct afs_icl_set **outSetpp) +int +afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp, + struct afs_icl_log *fatalLogp, + struct afs_icl_set **outSetpp) { return afs_icl_CreateSetWithFlags(name, baseLogp, fatalLogp, - /*flags*/0, outSetpp); + /*flags */ 0, outSetpp); } /* create a set, given pointers to base and fatal logs, if any. @@ -2590,23 +2735,25 @@ int afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp, * addds references from the new afs_icl_set. When the set is destroyed, * those references will be released. */ -int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp, - struct afs_icl_log *fatalLogp, afs_uint32 flags, struct afs_icl_set **outSetpp) +int +afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp, + struct afs_icl_log *fatalLogp, afs_uint32 flags, + struct afs_icl_set **outSetpp) { register struct afs_icl_set *setp; register int i; afs_int32 states = ICL_DEFAULT_SET_STATES; - ObtainWriteLock(&afs_icl_lock,197); - if (!afs_icl_inited) afs_icl_Init(); + ObtainWriteLock(&afs_icl_lock, 197); + if (!afs_icl_inited) + afs_icl_Init(); for (setp = afs_icl_allSets; setp; setp = setp->nextp) { if (strcmp(setp->name, name) == 0) { setp->refCount++; *outSetpp = setp; - if (flags & ICL_CRSET_FLAG_PERSISTENT) - { - ObtainWriteLock(&setp->lock,198); + if (flags & ICL_CRSET_FLAG_PERSISTENT) { + ObtainWriteLock(&setp->lock, 198); setp->states |= ICL_SETF_PERSISTENT; ReleaseWriteLock(&setp->lock); } @@ -2614,7 +2761,7 @@ int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp, return 0; } } - + /* determine initial state */ if (flags & ICL_CRSET_FLAG_DEFAULT_ON) states = ICL_SETF_ACTIVE; @@ -2623,8 +2770,8 @@ int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp, if (flags & ICL_CRSET_FLAG_PERSISTENT) states |= ICL_SETF_PERSISTENT; - setp = (struct afs_icl_set *) afs_osi_Alloc(sizeof(struct afs_icl_set)); - memset((caddr_t)setp, 0, sizeof(*setp)); + setp = (struct afs_icl_set *)afs_osi_Alloc(sizeof(struct afs_icl_set)); + memset((caddr_t) setp, 0, sizeof(*setp)); setp->refCount = 1; if (states & ICL_SETF_FREED) states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */ @@ -2635,15 +2782,15 @@ int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp, * it doesn't matter, since no one can find this lock yet, since * the afs_icl_lock is still held, and thus the obtain can't block. */ - ObtainWriteLock(&setp->lock,199); - setp->name = osi_AllocSmallSpace(strlen(name)+1); + ObtainWriteLock(&setp->lock, 199); + setp->name = osi_AllocSmallSpace(strlen(name) + 1); strcpy(setp->name, name); setp->nevents = ICL_DEFAULTEVENTS; setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS); #ifdef KERNEL_HAVE_PIN pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS); #endif - for(i=0; ieventFlags[i] = 0xff; /* default to enabled */ /* update this global info under the afs_icl_lock */ @@ -2671,11 +2818,12 @@ int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp, } /* function to change event enabling information for a particular set */ -int afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue) +int +afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue) { char *tp; - ObtainWriteLock(&setp->lock,200); + ObtainWriteLock(&setp->lock, 200); if (!ICL_EVENTOK(setp, eventID)) { ReleaseWriteLock(&setp->lock); return -1; @@ -2693,8 +2841,8 @@ int afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue) * for tracing. If *getValuep is set to 0, the event is disabled, * otherwise it is enabled. All events start out enabled by default. */ -int afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, - int *getValuep) +int +afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, int *getValuep) { ObtainReadLock(&setp->lock); if (!ICL_EVENTOK(setp, eventID)) { @@ -2710,22 +2858,24 @@ int afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, } /* hold and release event sets */ -int afs_icl_SetHold(register struct afs_icl_set *setp) +int +afs_icl_SetHold(register struct afs_icl_set *setp) { - ObtainWriteLock(&afs_icl_lock,201); + ObtainWriteLock(&afs_icl_lock, 201); setp->refCount++; ReleaseWriteLock(&afs_icl_lock); return 0; } /* free a set. Called with afs_icl_lock locked */ -int afs_icl_ZapSet(register struct afs_icl_set *setp) +int +afs_icl_ZapSet(register struct afs_icl_set *setp) { register struct afs_icl_set **lpp, *tp; int i; register struct afs_icl_log *tlp; - for(lpp = &afs_icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) { + for (lpp = &afs_icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) { if (tp == setp) { /* found the dude we want to remove */ *lpp = setp->nextp; @@ -2734,21 +2884,22 @@ int afs_icl_ZapSet(register struct afs_icl_set *setp) #ifdef KERNEL_HAVE_PIN unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS); #endif - for(i=0; i < ICL_LOGSPERSET; i++) { + for (i = 0; i < ICL_LOGSPERSET; i++) { if ((tlp = setp->logs[i])) afs_icl_LogReleNL(tlp); } osi_FreeSmallSpace(setp); - break; /* won't find it twice */ + break; /* won't find it twice */ } } return 0; } /* do the release, watching for deleted entries */ -int afs_icl_SetRele(register struct afs_icl_set *setp) +int +afs_icl_SetRele(register struct afs_icl_set *setp) { - ObtainWriteLock(&afs_icl_lock,202); + ObtainWriteLock(&afs_icl_lock, 202); if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) { afs_icl_ZapSet(setp); /* destroys setp's lock! */ } @@ -2757,9 +2908,10 @@ int afs_icl_SetRele(register struct afs_icl_set *setp) } /* free a set entry, dropping its reference count */ -int afs_icl_SetFree(register struct afs_icl_set *setp) +int +afs_icl_SetFree(register struct afs_icl_set *setp) { - ObtainWriteLock(&setp->lock,203); + ObtainWriteLock(&setp->lock, 203); setp->states |= ICL_SETF_DELETED; ReleaseWriteLock(&setp->lock); afs_icl_SetRele(setp); @@ -2767,11 +2919,12 @@ int afs_icl_SetFree(register struct afs_icl_set *setp) } /* find a set by name, returning it held */ -struct afs_icl_set *afs_icl_FindSet(char *name) +struct afs_icl_set * +afs_icl_FindSet(char *name) { register struct afs_icl_set *tp; - ObtainWriteLock(&afs_icl_lock,204); - for(tp = afs_icl_allSets; tp; tp=tp->nextp) { + ObtainWriteLock(&afs_icl_lock, 204); + for (tp = afs_icl_allSets; tp; tp = tp->nextp) { if (strcmp(tp->name, name) == 0) { /* this is the dude we want */ tp->refCount++; @@ -2783,20 +2936,22 @@ struct afs_icl_set *afs_icl_FindSet(char *name) } /* zero out all the logs in the set */ -int afs_icl_ZeroSet(struct afs_icl_set *setp) +int +afs_icl_ZeroSet(struct afs_icl_set *setp) { register int i; int code = 0; int tcode; struct afs_icl_log *logp; - + ObtainReadLock(&setp->lock); - for(i = 0; i < ICL_LOGSPERSET; i++) { + for (i = 0; i < ICL_LOGSPERSET; i++) { logp = setp->logs[i]; if (logp) { afs_icl_LogHold(logp); tcode = afs_icl_ZeroLog(logp); - if (tcode != 0) code = tcode; /* save the last bad one */ + if (tcode != 0) + code = tcode; /* save the last bad one */ afs_icl_LogRele(logp); } } @@ -2804,34 +2959,39 @@ int afs_icl_ZeroSet(struct afs_icl_set *setp) return code; } -int afs_icl_EnumerateSets(int (*aproc)(char *name,char *arock,struct afs_icl_log *tp), char *arock) +int +afs_icl_EnumerateSets(int (*aproc) + (char *name, char *arock, struct afs_icl_log * tp), + char *arock) { register struct afs_icl_set *tp, *np; register afs_int32 code; code = 0; - ObtainWriteLock(&afs_icl_lock,205); - for(tp = afs_icl_allSets; tp; tp=np) { - tp->refCount++; /* hold this guy */ + ObtainWriteLock(&afs_icl_lock, 205); + for (tp = afs_icl_allSets; tp; tp = np) { + tp->refCount++; /* hold this guy */ ReleaseWriteLock(&afs_icl_lock); - code = (*aproc)(tp->name, arock, tp); - ObtainWriteLock(&afs_icl_lock,206); - np = tp->nextp; /* tp may disappear next, but not np */ + code = (*aproc) (tp->name, arock, tp); + ObtainWriteLock(&afs_icl_lock, 206); + np = tp->nextp; /* tp may disappear next, but not np */ if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED)) afs_icl_ZapSet(tp); - if (code) break; + if (code) + break; } ReleaseWriteLock(&afs_icl_lock); return code; } -int afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp) +int +afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp) { register int i; int code = -1; - - ObtainWriteLock(&setp->lock,207); - for(i = 0; i < ICL_LOGSPERSET; i++) { + + ObtainWriteLock(&setp->lock, 207); + for (i = 0; i < ICL_LOGSPERSET; i++) { if (!setp->logs[i]) { setp->logs[i] = newlogp; code = i; @@ -2847,14 +3007,15 @@ int afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp) return code; } -int afs_icl_SetSetStat(struct afs_icl_set *setp, int op) +int +afs_icl_SetSetStat(struct afs_icl_set *setp, int op) { int i; afs_int32 code; struct afs_icl_log *logp; - ObtainWriteLock(&setp->lock,208); - switch(op) { + ObtainWriteLock(&setp->lock, 208); + switch (op) { case ICL_OP_SS_ACTIVATE: /* activate a log */ /* * If we are not already active, see if we have released @@ -2864,7 +3025,7 @@ int afs_icl_SetSetStat(struct afs_icl_set *setp, int op) if (!(setp->states & ICL_SETF_ACTIVE)) { if (setp->states & ICL_SETF_FREED) { /* have to reassert desire for logs */ - for(i = 0; i < ICL_LOGSPERSET; i++) { + for (i = 0; i < ICL_LOGSPERSET; i++) { logp = setp->logs[i]; if (logp) { afs_icl_LogHold(logp); @@ -2894,7 +3055,7 @@ int afs_icl_SetSetStat(struct afs_icl_set *setp, int op) code = EINVAL; else { if (!(setp->states & ICL_SETF_FREED)) { - for(i = 0; i < ICL_LOGSPERSET; i++) { + for (i = 0; i < ICL_LOGSPERSET; i++) { logp = setp->logs[i]; if (logp) { afs_icl_LogHold(logp); @@ -2914,4 +3075,3 @@ int afs_icl_SetSetStat(struct afs_icl_set *setp, int op) ReleaseWriteLock(&setp->lock); return code; } - diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c index bc687e859..913ae320b 100644 --- a/src/afs/afs_callback.c +++ b/src/afs/afs_callback.c @@ -16,19 +16,20 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /*Standard vendor system headers*/ -#include "afsincludes.h" /*AFS-based standard headers*/ -#include "afs/afs_stats.h" /*Cache Manager stats*/ +#include "afs/sysincludes.h" /*Standard vendor system headers */ +#include "afsincludes.h" /*AFS-based standard headers */ +#include "afs/afs_stats.h" /*Cache Manager stats */ #include "afs/afs_args.h" -afs_int32 afs_allCBs = 0; /*Break callbacks on all objects */ -afs_int32 afs_oddCBs = 0; /*Break callbacks on dirs*/ -afs_int32 afs_evenCBs = 0; /*Break callbacks received on files*/ -afs_int32 afs_allZaps = 0; /*Objects entries deleted */ -afs_int32 afs_oddZaps = 0; /*Dir cache entries deleted*/ -afs_int32 afs_evenZaps = 0; /*File cache entries deleted*/ +afs_int32 afs_allCBs = 0; /*Break callbacks on all objects */ +afs_int32 afs_oddCBs = 0; /*Break callbacks on dirs */ +afs_int32 afs_evenCBs = 0; /*Break callbacks received on files */ +afs_int32 afs_allZaps = 0; /*Objects entries deleted */ +afs_int32 afs_oddZaps = 0; /*Dir cache entries deleted */ +afs_int32 afs_evenZaps = 0; /*File cache entries deleted */ afs_int32 afs_connectBacks = 0; /* @@ -37,29 +38,32 @@ afs_int32 afs_connectBacks = 0; static struct ltable { char *name; char *addr; -} ltable []= { - {"afs_xvcache", (char *)&afs_xvcache}, - {"afs_xdcache", (char *)&afs_xdcache}, - {"afs_xserver", (char *)&afs_xserver}, - {"afs_xvcb", (char *)&afs_xvcb}, - {"afs_xbrs", (char *)&afs_xbrs}, - {"afs_xcell", (char *)&afs_xcell}, - {"afs_xconn", (char *)&afs_xconn}, - {"afs_xuser", (char *)&afs_xuser}, - {"afs_xvolume", (char *)&afs_xvolume}, - {"puttofile", (char *)&afs_puttofileLock}, - {"afs_ftf", (char *)&afs_ftf}, - {"afs_xcbhash", (char *)&afs_xcbhash}, - {"afs_xaxs", (char *)&afs_xaxs}, - {"afs_xinterface", (char *)&afs_xinterface}, +} ltable[] = { + { + "afs_xvcache", (char *)&afs_xvcache}, { + "afs_xdcache", (char *)&afs_xdcache}, { + "afs_xserver", (char *)&afs_xserver}, { + "afs_xvcb", (char *)&afs_xvcb}, { + "afs_xbrs", (char *)&afs_xbrs}, { + "afs_xcell", (char *)&afs_xcell}, { + "afs_xconn", (char *)&afs_xconn}, { + "afs_xuser", (char *)&afs_xuser}, { + "afs_xvolume", (char *)&afs_xvolume}, { + "puttofile", (char *)&afs_puttofileLock}, { + "afs_ftf", (char *)&afs_ftf}, { + "afs_xcbhash", (char *)&afs_xcbhash}, { + "afs_xaxs", (char *)&afs_xaxs}, { + "afs_xinterface", (char *)&afs_xinterface}, #ifndef UKERNEL - {"afs_xosi", (char *)&afs_xosi}, + { + "afs_xosi", (char *)&afs_xosi}, #endif - {"afs_xsrvAddr",(char *)&afs_xsrvAddr} + { + "afs_xsrvAddr", (char *)&afs_xsrvAddr} }; -unsigned long lastCallBack_vnode; -unsigned int lastCallBack_dv; -osi_timeval_t lastCallBack_time; +unsigned long lastCallBack_vnode; +unsigned int lastCallBack_dv; +osi_timeval_t lastCallBack_time; /* these are for storing alternate interface addresses */ struct interfaceAddr afs_cb_interface; @@ -87,12 +91,14 @@ struct interfaceAddr afs_cb_interface; * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_GetCE(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCacheEntry *a_result) +int +SRXAFSCB_GetCE(struct rx_call *a_call, afs_int32 a_index, + struct AFSDBCacheEntry *a_result) { - register int i; /*Loop variable*/ - register struct vcache *tvc; /*Ptr to current cache entry*/ - int code; /*Return code*/ + register int i; /*Loop variable */ + register struct vcache *tvc; /*Ptr to current cache entry */ + int code; /*Return code */ XSTATS_DECLS; RX_AFS_GLOCK(); @@ -105,12 +111,12 @@ int SRXAFSCB_GetCE(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCacheE if (a_index == 0) goto searchDone; a_index--; - } /*Zip through current hash chain*/ - } /*Zip through hash chains*/ + } /*Zip through current hash chain */ + } /*Zip through hash chains */ searchDone: if (tvc == NULL) { - /*Past EOF*/ + /*Past EOF */ code = 1; goto fcnDone; } @@ -143,7 +149,7 @@ int SRXAFSCB_GetCE(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCacheE a_result->Length = tvc->m.Length; #endif /* AFS_64BIT_CLIENT */ a_result->DataVersion = hgetlo(tvc->m.DataVersion); - a_result->callback = afs_data_pointer_to_int32(tvc->callback); /* XXXX Now a pointer; change it XXXX */ + a_result->callback = afs_data_pointer_to_int32(tvc->callback); /* XXXX Now a pointer; change it XXXX */ a_result->cbExpires = tvc->cbExpires; a_result->refCount = VREFCOUNT(tvc); a_result->opens = tvc->opens; @@ -155,20 +161,22 @@ int SRXAFSCB_GetCE(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCacheE /* * Return our results. */ -fcnDone: + fcnDone: XSTATS_END_TIME; RX_AFS_GUNLOCK(); - return(code); + return (code); -} /*SRXAFSCB_GetCE*/ +} /*SRXAFSCB_GetCE */ -int SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCacheEntry64 *a_result) +int +SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index, + struct AFSDBCacheEntry64 *a_result) { - register int i; /*Loop variable*/ - register struct vcache *tvc; /*Ptr to current cache entry*/ - int code; /*Return code*/ + register int i; /*Loop variable */ + register struct vcache *tvc; /*Ptr to current cache entry */ + int code; /*Return code */ XSTATS_DECLS; RX_AFS_GLOCK(); @@ -181,12 +189,12 @@ int SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCach if (a_index == 0) goto searchDone; a_index--; - } /*Zip through current hash chain*/ - } /*Zip through hash chains*/ + } /*Zip through current hash chain */ + } /*Zip through hash chains */ searchDone: if (tvc == NULL) { - /*Past EOF*/ + /*Past EOF */ code = 1; goto fcnDone; } @@ -224,7 +232,7 @@ int SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCach #endif /* AFS_64BIT_CLIENT */ #endif /* AFS_64BIT_ENV */ a_result->DataVersion = hgetlo(tvc->m.DataVersion); - a_result->callback = afs_data_pointer_to_int32(tvc->callback); /* XXXX Now a pointer; change it XXXX */ + a_result->callback = afs_data_pointer_to_int32(tvc->callback); /* XXXX Now a pointer; change it XXXX */ a_result->cbExpires = tvc->cbExpires; a_result->refCount = VREFCOUNT(tvc); a_result->opens = tvc->opens; @@ -236,14 +244,14 @@ int SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCach /* * Return our results. */ -fcnDone: + fcnDone: XSTATS_END_TIME; RX_AFS_GUNLOCK(); - return(code); + return (code); -} /*SRXAFSCB_GetCE64*/ +} /*SRXAFSCB_GetCE64 */ /*------------------------------------------------------------------------ @@ -270,39 +278,47 @@ fcnDone: * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_GetLock (struct rx_call *a_call, afs_int32 a_index, struct AFSDBLock *a_result) +int +SRXAFSCB_GetLock(struct rx_call *a_call, afs_int32 a_index, + struct AFSDBLock *a_result) { - struct ltable *tl; /*Ptr to lock table entry*/ - int nentries; /*Num entries in table*/ - int code; /*Return code*/ + struct ltable *tl; /*Ptr to lock table entry */ + int nentries; /*Num entries in table */ + int code; /*Return code */ XSTATS_DECLS; RX_AFS_GLOCK(); XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETLOCK); - + AFS_STATCNT(SRXAFSCB_GetLock); - nentries = sizeof(ltable)/sizeof(struct ltable); + nentries = sizeof(ltable) / sizeof(struct ltable); if (a_index < 0 || a_index >= nentries) { /* - * Past EOF - */ + * Past EOF + */ code = 1; - } - else { + } else { /* * Found it - copy out its contents. */ tl = <able[a_index]; strcpy(a_result->name, tl->name); - a_result->lock.waitStates = ((struct afs_lock *)(tl->addr))->wait_states; - a_result->lock.exclLocked = ((struct afs_lock *)(tl->addr))->excl_locked; - a_result->lock.readersReading = ((struct afs_lock *)(tl->addr))->readers_reading; - a_result->lock.numWaiting = ((struct afs_lock *)(tl->addr))->num_waiting; + a_result->lock.waitStates = + ((struct afs_lock *)(tl->addr))->wait_states; + a_result->lock.exclLocked = + ((struct afs_lock *)(tl->addr))->excl_locked; + a_result->lock.readersReading = + ((struct afs_lock *)(tl->addr))->readers_reading; + a_result->lock.numWaiting = + ((struct afs_lock *)(tl->addr))->num_waiting; #ifdef INSTRUMENT_LOCKS - a_result->lock.pid_last_reader = ((struct afs_lock *)(tl->addr))->pid_last_reader; - a_result->lock.pid_writer = ((struct afs_lock *)(tl->addr))->pid_writer; - a_result->lock.src_indicator = ((struct afs_lock *)(tl->addr))->src_indicator; + a_result->lock.pid_last_reader = + ((struct afs_lock *)(tl->addr))->pid_last_reader; + a_result->lock.pid_writer = + ((struct afs_lock *)(tl->addr))->pid_writer; + a_result->lock.src_indicator = + ((struct afs_lock *)(tl->addr))->src_indicator; #else a_result->lock.pid_last_reader = 0; a_result->lock.pid_writer = 0; @@ -315,9 +331,9 @@ int SRXAFSCB_GetLock (struct rx_call *a_call, afs_int32 a_index, struct AFSDBLoc RX_AFS_GUNLOCK(); - return(code); + return (code); -} /*SRXAFSCB_GetLock*/ +} /*SRXAFSCB_GetLock */ /*------------------------------------------------------------------------ @@ -346,12 +362,14 @@ Appears to need to be called with GLOCK held, as the icl_Event4 stuff asserts ot *------------------------------------------------------------------------*/ -static int ClearCallBack(register struct rx_connection *a_conn, register struct AFSFid *a_fid) +static int +ClearCallBack(register struct rx_connection *a_conn, + register struct AFSFid *a_fid) { register struct vcache *tvc; register int i; struct VenusFid localFid; - struct volume * tv; + struct volume *tv; AFS_STATCNT(ClearCallBack); @@ -366,8 +384,8 @@ static int ClearCallBack(register struct rx_connection *a_conn, register struct localFid.Fid.Unique = a_fid->Unique; /* - * Volume ID of zero means don't do anything. - */ + * Volume ID of zero means don't do anything. + */ if (a_fid->Volume != 0) { if (a_fid->Vnode == 0) { /* @@ -378,26 +396,27 @@ static int ClearCallBack(register struct rx_connection *a_conn, register struct for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { if (tvc->fid.Fid.Volume == a_fid->Volume) { tvc->callback = NULL; - tvc->quick.stamp = 0; + tvc->quick.stamp = 0; if (!localFid.Cell) localFid.Cell = tvc->fid.Cell; - tvc->h1.dchint = NULL; /* invalidate hints */ + tvc->h1.dchint = NULL; /* invalidate hints */ ObtainWriteLock(&afs_xcbhash, 449); afs_DequeueCallback(tvc); tvc->states &= ~(CStatd | CUnique | CBulkFetching); afs_allCBs++; if (tvc->fid.Fid.Vnode & 1) - afs_oddCBs++; + afs_oddCBs++; else - afs_evenCBs++; + afs_evenCBs++; ReleaseWriteLock(&afs_xcbhash); if (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR)) osi_dnlc_purgedp(tvc); afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK, - ICL_TYPE_POINTER, tvc, - ICL_TYPE_INT32, tvc->states, - ICL_TYPE_INT32, a_fid->Volume); - } else if ((tvc->states & CMValid) && (tvc->mvid->Fid.Volume == a_fid->Volume)) { + ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, + tvc->states, ICL_TYPE_INT32, + a_fid->Volume); + } else if ((tvc->states & CMValid) + && (tvc->mvid->Fid.Volume == a_fid->Volume)) { tvc->states &= ~CMValid; if (!localFid.Cell) localFid.Cell = tvc->mvid->Cell; @@ -409,28 +428,28 @@ static int ClearCallBack(register struct rx_connection *a_conn, register struct */ tv = afs_FindVolume(&localFid, 0); if (tv) { - afs_ResetVolumeInfo(tv); - afs_PutVolume(tv, 0); - /* invalidate mtpoint? */ + afs_ResetVolumeInfo(tv); + afs_PutVolume(tv, 0); + /* invalidate mtpoint? */ } - } /*Clear callbacks for whole volume*/ + } /*Clear callbacks for whole volume */ else { /* * Clear callbacks just for the one file. */ afs_allCBs++; if (a_fid->Vnode & 1) - afs_oddCBs++; /*Could do this on volume basis, too*/ + afs_oddCBs++; /*Could do this on volume basis, too */ else - afs_evenCBs++; /*A particular fid was specified*/ + afs_evenCBs++; /*A particular fid was specified */ i = VCHash(&localFid); for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { if (tvc->fid.Fid.Vnode == a_fid->Vnode && tvc->fid.Fid.Volume == a_fid->Volume - && tvc->fid.Fid.Unique == a_fid->Unique ) { + && tvc->fid.Fid.Unique == a_fid->Unique) { tvc->callback = NULL; - tvc->quick.stamp = 0; - tvc->h1.dchint = NULL; /* invalidate hints */ + tvc->quick.stamp = 0; + tvc->h1.dchint = NULL; /* invalidate hints */ ObtainWriteLock(&afs_xcbhash, 450); afs_DequeueCallback(tvc); tvc->states &= ~(CStatd | CUnique | CBulkFetching); @@ -438,24 +457,25 @@ static int ClearCallBack(register struct rx_connection *a_conn, register struct if (a_fid->Vnode & 1 || (vType(tvc) == VDIR)) osi_dnlc_purgedp(tvc); afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK, - ICL_TYPE_POINTER, tvc, - ICL_TYPE_INT32, tvc->states, ICL_TYPE_LONG, 0); + ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, + tvc->states, ICL_TYPE_LONG, 0); #ifdef CBDEBUG lastCallBack_vnode = afid->Vnode; lastCallBack_dv = tvc->mstat.DataVersion.low; osi_GetuTime(&lastCallBack_time); #endif /* CBDEBUG */ } - } /*Walk through hash table*/ - } /*Clear callbacks for one file*/ - } /*Fid has non-zero volume ID*/ + } /*Walk through hash table */ + } /*Clear callbacks for one file */ + } + /*Fid has non-zero volume ID */ /* * Always return a predictable value. */ - return(0); + return (0); -} /*ClearCallBack*/ +} /*ClearCallBack */ /*------------------------------------------------------------------------ @@ -481,12 +501,14 @@ static int ClearCallBack(register struct rx_connection *a_conn, register struct * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_CallBack(struct rx_call *a_call, register struct AFSCBFids *a_fids, struct AFSCBs *a_callbacks) +int +SRXAFSCB_CallBack(struct rx_call *a_call, register struct AFSCBFids *a_fids, + struct AFSCBs *a_callbacks) { - register int i; /*Loop variable*/ - struct AFSFid *tfid; /*Ptr to current fid*/ - register struct rx_connection *tconn; /*Call's connection*/ - int code=0; + register int i; /*Loop variable */ + struct AFSFid *tfid; /*Ptr to current fid */ + register struct rx_connection *tconn; /*Call's connection */ + int code = 0; XSTATS_DECLS; RX_AFS_GLOCK(); @@ -494,23 +516,24 @@ int SRXAFSCB_CallBack(struct rx_call *a_call, register struct AFSCBFids *a_fids, XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_CALLBACK); AFS_STATCNT(SRXAFSCB_CallBack); - if (!(tconn = rx_ConnectionOf(a_call))) return(0); - tfid = (struct AFSFid *) a_fids->AFSCBFids_val; - + if (!(tconn = rx_ConnectionOf(a_call))) + return (0); + tfid = (struct AFSFid *)a_fids->AFSCBFids_val; + /* * For now, we ignore callbacks, since the File Server only *breaks* * callbacks at present. */ - for (i = 0; i < a_fids->AFSCBFids_len; i++) + for (i = 0; i < a_fids->AFSCBFids_len; i++) ClearCallBack(tconn, &tfid[i]); XSTATS_END_TIME; RX_AFS_GUNLOCK(); - - return(0); -} /*SRXAFSCB_CallBack*/ + return (0); + +} /*SRXAFSCB_CallBack */ /*------------------------------------------------------------------------ @@ -534,7 +557,8 @@ int SRXAFSCB_CallBack(struct rx_call *a_call, register struct AFSCBFids *a_fids, * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_Probe(struct rx_call *a_call) +int +SRXAFSCB_Probe(struct rx_call *a_call) { int code = 0; XSTATS_DECLS; @@ -547,9 +571,9 @@ int SRXAFSCB_Probe(struct rx_call *a_call) RX_AFS_GUNLOCK(); - return(0); + return (0); -} /*SRXAFSCB_Probe*/ +} /*SRXAFSCB_Probe */ /*------------------------------------------------------------------------ @@ -572,7 +596,8 @@ int SRXAFSCB_Probe(struct rx_call *a_call) * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_InitCallBackState(struct rx_call *a_call) +int +SRXAFSCB_InitCallBackState(struct rx_call *a_call) { register int i; register struct vcache *tvc; @@ -593,10 +618,11 @@ int SRXAFSCB_InitCallBackState(struct rx_call *a_call) if ((tconn = rx_ConnectionOf(a_call)) && (peer = rx_PeerOf(tconn))) { afs_allCBs++; - afs_oddCBs++; /*Including any missed via create race*/ - afs_evenCBs++; /*Including any missed via create race*/ + afs_oddCBs++; /*Including any missed via create race */ + afs_evenCBs++; /*Including any missed via create race */ - ts = afs_FindServer(rx_HostOf(peer), rx_PortOf(peer), (afsUUID *)0, 0); + ts = afs_FindServer(rx_HostOf(peer), rx_PortOf(peer), (afsUUID *) 0, + 0); if (ts) { for (i = 0; i < VCSIZE; i++) for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { @@ -610,30 +636,30 @@ int SRXAFSCB_InitCallBackState(struct rx_call *a_call) } } - - + + /* find any volumes residing on this server and flush their state */ { register struct volume *tv; register int j; - - for (i=0;inext) { - for (j=0; jnext) { + for (j = 0; j < MAXHOSTS; j++) if (tv->serverHost[j] == ts) afs_ResetVolumeInfo(tv); } } - osi_dnlc_purge(); /* may be a little bit extreme */ + osi_dnlc_purge(); /* may be a little bit extreme */ } XSTATS_END_TIME; RX_AFS_GUNLOCK(); - return(0); + return (0); -} /*SRXAFSCB_InitCallBackState*/ +} /*SRXAFSCB_InitCallBackState */ /*------------------------------------------------------------------------ @@ -657,9 +683,10 @@ int SRXAFSCB_InitCallBackState(struct rx_call *a_call) * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_XStatsVersion(struct rx_call *a_call, afs_int32 *a_versionP) +int +SRXAFSCB_XStatsVersion(struct rx_call *a_call, afs_int32 * a_versionP) { - int code=0; + int code = 0; XSTATS_DECLS; @@ -672,8 +699,8 @@ int SRXAFSCB_XStatsVersion(struct rx_call *a_call, afs_int32 *a_versionP) RX_AFS_GUNLOCK(); - return(0); -} /*SRXAFSCB_XStatsVersion*/ + return (0); +} /*SRXAFSCB_XStatsVersion */ /*------------------------------------------------------------------------ @@ -703,13 +730,14 @@ int SRXAFSCB_XStatsVersion(struct rx_call *a_call, afs_int32 *a_versionP) * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, - afs_int32 a_collectionNumber, afs_int32 *a_srvVersionNumP, - afs_int32 *a_timeP, AFSCB_CollData *a_dataP) +int +SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, + afs_int32 a_collectionNumber, afs_int32 * a_srvVersionNumP, + afs_int32 * a_timeP, AFSCB_CollData * a_dataP) { - register int code; /*Return value*/ - afs_int32 *dataBuffP; /*Ptr to data to be returned*/ - afs_int32 dataBytes; /*Bytes in data buffer*/ + register int code; /*Return value */ + afs_int32 *dataBuffP; /*Ptr to data to be returned */ + afs_int32 dataBytes; /*Bytes in data buffer */ XSTATS_DECLS; RX_AFS_GLOCK(); @@ -735,8 +763,8 @@ int SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, a_dataP->AFSCB_CollData_len = 0; a_dataP->AFSCB_CollData_val = NULL; #else - switch(a_collectionNumber) { - case AFSCB_XSTATSCOLL_CALL_INFO: + switch (a_collectionNumber) { + case AFSCB_XSTATSCOLL_CALL_INFO: /* * Pass back all the call-count-related data. * @@ -745,13 +773,13 @@ int SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, * >>> will be freed at the tail end of the server stub code. */ dataBytes = sizeof(struct afs_CMStats); - dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes); + dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes); memcpy((char *)dataBuffP, (char *)&afs_cmstats, dataBytes); - a_dataP->AFSCB_CollData_len = dataBytes>>2; + a_dataP->AFSCB_CollData_len = dataBytes >> 2; a_dataP->AFSCB_CollData_val = dataBuffP; break; - case AFSCB_XSTATSCOLL_PERF_INFO: + case AFSCB_XSTATSCOLL_PERF_INFO: /* * Update and then pass back all the performance-related data. * Note: the only performance fields that need to be computed @@ -765,13 +793,13 @@ int SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, afs_stats_cmperf.numPerfCalls++; afs_CountServers(); dataBytes = sizeof(afs_stats_cmperf); - dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes); + dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes); memcpy((char *)dataBuffP, (char *)&afs_stats_cmperf, dataBytes); - a_dataP->AFSCB_CollData_len = dataBytes>>2; + a_dataP->AFSCB_CollData_len = dataBytes >> 2; a_dataP->AFSCB_CollData_val = dataBuffP; break; - case AFSCB_XSTATSCOLL_FULL_PERF_INFO: + case AFSCB_XSTATSCOLL_FULL_PERF_INFO: /* * Pass back the full range of performance and statistical * data available. We have to bring the normal performance @@ -784,33 +812,34 @@ int SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, */ afs_stats_cmperf.numPerfCalls++; afs_CountServers(); - memcpy((char *)(&(afs_stats_cmfullperf.perf)), (char *)(&afs_stats_cmperf), sizeof(struct afs_stats_CMPerf)); + memcpy((char *)(&(afs_stats_cmfullperf.perf)), + (char *)(&afs_stats_cmperf), sizeof(struct afs_stats_CMPerf)); afs_stats_cmfullperf.numFullPerfCalls++; dataBytes = sizeof(afs_stats_cmfullperf); - dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes); + dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes); memcpy((char *)dataBuffP, (char *)(&afs_stats_cmfullperf), dataBytes); - a_dataP->AFSCB_CollData_len = dataBytes>>2; + a_dataP->AFSCB_CollData_len = dataBytes >> 2; a_dataP->AFSCB_CollData_val = dataBuffP; break; - default: + default: /* * Illegal collection number. */ a_dataP->AFSCB_CollData_len = 0; a_dataP->AFSCB_CollData_val = NULL; code = 1; - } /*Switch on collection number*/ + } /*Switch on collection number */ #endif /* AFS_NOSTATS */ XSTATS_END_TIME; RX_AFS_GUNLOCK(); - return(code); + return (code); -} /*SRXAFSCB_GetXStats*/ +} /*SRXAFSCB_GetXStats */ /*------------------------------------------------------------------------ @@ -832,7 +861,8 @@ int SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, * As advertised. *------------------------------------------------------------------------*/ -int afs_RXCallBackServer(void) +int +afs_RXCallBackServer(void) { AFS_STATCNT(afs_RXCallBackServer); @@ -846,9 +876,9 @@ int afs_RXCallBackServer(void) * Donate this process to Rx. */ rx_ServerProc(); - return(0); + return (0); -} /*afs_RXCallBackServer*/ +} /*afs_RXCallBackServer */ /*------------------------------------------------------------------------ @@ -870,18 +900,19 @@ int afs_RXCallBackServer(void) * As advertised. *------------------------------------------------------------------------*/ -int shutdown_CB(void) +int +shutdown_CB(void) { - AFS_STATCNT(shutdown_CB); + AFS_STATCNT(shutdown_CB); - if (afs_cold_shutdown) { - afs_oddCBs = afs_evenCBs = afs_allCBs = afs_allZaps = afs_oddZaps = afs_evenZaps = - afs_connectBacks = 0; - } + if (afs_cold_shutdown) { + afs_oddCBs = afs_evenCBs = afs_allCBs = afs_allZaps = afs_oddZaps = + afs_evenZaps = afs_connectBacks = 0; + } - return(0); + return (0); -} /*shutdown_CB*/ +} /*shutdown_CB */ /*------------------------------------------------------------------------ * EXPORTED SRXAFSCB_InitCallBackState2 @@ -903,9 +934,11 @@ int shutdown_CB(void) * None *------------------------------------------------------------------------*/ -int SRXAFSCB_InitCallBackState2(struct rx_call *a_call, struct interfaceAddr *addr) +int +SRXAFSCB_InitCallBackState2(struct rx_call *a_call, + struct interfaceAddr *addr) { - return RXGEN_OPCODE; + return RXGEN_OPCODE; } /*------------------------------------------------------------------------ @@ -932,7 +965,8 @@ int SRXAFSCB_InitCallBackState2(struct rx_call *a_call, struct interfaceAddr *ad * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr) +int +SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr) { int i; int code = 0; @@ -946,7 +980,7 @@ int SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr) /* return all network interface addresses */ addr->numberOfInterfaces = afs_cb_interface.numberOfInterfaces; addr->uuid = afs_cb_interface.uuid; - for ( i=0; i < afs_cb_interface.numberOfInterfaces; i++) { + for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) { addr->addr_in[i] = ntohl(afs_cb_interface.addr_in[i]); addr->subnetmask[i] = ntohl(afs_cb_interface.subnetmask[i]); addr->mtu[i] = ntohl(afs_cb_interface.mtu[i]); @@ -980,7 +1014,8 @@ int SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr) * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_InitCallBackState3(struct rx_call *a_call, afsUUID *a_uuid) +int +SRXAFSCB_InitCallBackState3(struct rx_call *a_call, afsUUID * a_uuid) { int code; @@ -991,7 +1026,7 @@ int SRXAFSCB_InitCallBackState3(struct rx_call *a_call, afsUUID *a_uuid) return code; } - + /*------------------------------------------------------------------------ * EXPORTED SRXAFSCB_ProbeUuid @@ -1016,7 +1051,8 @@ int SRXAFSCB_InitCallBackState3(struct rx_call *a_call, afsUUID *a_uuid) * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID *a_uuid) +int +SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID * a_uuid) { int code = 0; XSTATS_DECLS; @@ -1026,14 +1062,14 @@ int SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID *a_uuid) XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_PROBE); if (!afs_uuid_equal(a_uuid, &afs_cb_interface.uuid)) - code = 1; /* failure */ + code = 1; /* failure */ XSTATS_END_TIME; RX_AFS_GUNLOCK(); return code; } - + /*------------------------------------------------------------------------ * EXPORTED SRXAFSCB_GetServerPrefs @@ -1058,8 +1094,9 @@ int SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID *a_uuid) * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index, - afs_int32 *a_srvr_addr, afs_int32 *a_srvr_rank) +int +SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index, + afs_int32 * a_srvr_addr, afs_int32 * a_srvr_rank) { int i, j; struct srvAddr *sa; @@ -1072,7 +1109,7 @@ int SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index, /* Search the hash table for the server with this index */ *a_srvr_addr = 0xffffffff; *a_srvr_rank = 0xffffffff; - for (i=0, j=0; j < NSERVERS && i <= a_index; j++) { + for (i = 0, j = 0; j < NSERVERS && i <= a_index; j++) { for (sa = afs_srvAddrs[j]; sa && i <= a_index; sa = sa->next_bkt, i++) { if (i == a_index) { *a_srvr_addr = ntohl(sa->sa_ip); @@ -1087,7 +1124,7 @@ int SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index, return 0; } - + /*------------------------------------------------------------------------ * EXPORTED SRXAFSCB_GetCellServDB @@ -1111,8 +1148,9 @@ int SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index, * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index, - char **a_name, serverList *a_hosts) +int +SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index, + char **a_name, serverList * a_hosts) { afs_int32 i, j = 0; struct cell *tcell; @@ -1129,19 +1167,20 @@ int SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index, a_hosts->serverList_len = 0; } else { p_name = tcell->cellName; - for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++) - ; + for (j = 0; j < AFSMAXCELLHOSTS && tcell->cellHosts[j]; j++); i = strlen(p_name); - a_hosts->serverList_val = (afs_int32 *)afs_osi_Alloc(j*sizeof(afs_int32)); + a_hosts->serverList_val = + (afs_int32 *) afs_osi_Alloc(j * sizeof(afs_int32)); a_hosts->serverList_len = j; - for (j = 0 ; j < AFSMAXCELLHOSTS && tcell->cellHosts[j] ; j++) - a_hosts->serverList_val[j] = ntohl(tcell->cellHosts[j]->addr->sa_ip); + for (j = 0; j < AFSMAXCELLHOSTS && tcell->cellHosts[j]; j++) + a_hosts->serverList_val[j] = + ntohl(tcell->cellHosts[j]->addr->sa_ip); afs_PutCell(tcell, READ_LOCK); } - t_name = (char *)afs_osi_Alloc(i+1); + t_name = (char *)afs_osi_Alloc(i + 1); if (t_name == NULL) { - afs_osi_Free(a_hosts->serverList_val, (j*sizeof(afs_int32))); + afs_osi_Free(a_hosts->serverList_val, (j * sizeof(afs_int32))); RX_AFS_GUNLOCK(); return ENOMEM; } @@ -1155,7 +1194,7 @@ int SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index, *a_name = t_name; return 0; } - + /*------------------------------------------------------------------------ * EXPORTED SRXAFSCB_GetLocalCell @@ -1177,7 +1216,8 @@ int SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index, * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name) +int +SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name) { int plen; struct cell *tcell; @@ -1196,9 +1236,10 @@ int SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name) plen = strlen(p_name); else plen = 0; - t_name = (char *)afs_osi_Alloc(plen+1); + t_name = (char *)afs_osi_Alloc(plen + 1); if (t_name == NULL) { - if (tcell) afs_PutCell(tcell, READ_LOCK); + if (tcell) + afs_PutCell(tcell, READ_LOCK); RX_AFS_GUNLOCK(); return ENOMEM; } @@ -1210,7 +1251,8 @@ int SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name) RX_AFS_GUNLOCK(); *a_name = t_name; - if (tcell) afs_PutCell(tcell, READ_LOCK); + if (tcell) + afs_PutCell(tcell, READ_LOCK); return 0; } @@ -1230,8 +1272,9 @@ int SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name) * * Returns void. */ -static void afs_MarshallCacheConfig(afs_uint32 callerVersion, - cm_initparams_v1 *config, afs_uint32 *ptr) +static void +afs_MarshallCacheConfig(afs_uint32 callerVersion, cm_initparams_v1 * config, + afs_uint32 * ptr) { AFS_STATCNT(afs_MarshallCacheConfig); /* @@ -1247,7 +1290,7 @@ static void afs_MarshallCacheConfig(afs_uint32 callerVersion, *(ptr++) = config->setTime; *(ptr++) = config->memCache; } - + /*------------------------------------------------------------------------ * EXPORTED SRXAFSCB_GetCacheConfig @@ -1274,8 +1317,10 @@ static void afs_MarshallCacheConfig(afs_uint32 callerVersion, * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion, - afs_uint32 *serverVersion, afs_uint32 *configCount, cacheConfig *config) +int +SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion, + afs_uint32 * serverVersion, afs_uint32 * configCount, + cacheConfig * config) { afs_uint32 *t_config; size_t allocsize; @@ -1288,7 +1333,7 @@ int SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion, * Currently only support version 1 */ allocsize = sizeof(cm_initparams_v1); - t_config = (afs_uint32 *)afs_osi_Alloc(allocsize); + t_config = (afs_uint32 *) afs_osi_Alloc(allocsize); if (t_config == NULL) { RX_AFS_GUNLOCK(); return ENOMEM; @@ -1309,7 +1354,7 @@ int SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion, *serverVersion = AFS_CLIENT_RETRIEVAL_FIRST_EDITION; *configCount = allocsize; config->cacheConfig_val = t_config; - config->cacheConfig_len = allocsize/sizeof(afs_uint32); + config->cacheConfig_len = allocsize / sizeof(afs_uint32); RX_AFS_GUNLOCK(); @@ -1340,8 +1385,10 @@ int SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion, * * Side Effects: *------------------------------------------------------------------------*/ -int SRXAFSCB_FetchData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd, - afs_int64 Position, afs_int64 Length, afs_int64 *TotalLength) +int +SRXAFSCB_FetchData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd, + afs_int64 Position, afs_int64 Length, + afs_int64 * TotalLength) { return ENOSYS; } @@ -1371,8 +1418,10 @@ int SRXAFSCB_FetchData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd, * Side Effects: * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_StoreData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd, - afs_int64 Position, afs_int64 Length, afs_int64 *TotalLength) +int +SRXAFSCB_StoreData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd, + afs_int64 Position, afs_int64 Length, + afs_int64 * TotalLength) { return ENOSYS; } @@ -1400,8 +1449,9 @@ int SRXAFSCB_StoreData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd, * As advertised. *------------------------------------------------------------------------*/ -int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum, - char **a_name, serverList *a_hosts) +int +SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum, + char **a_name, serverList * a_hosts) { afs_int32 i, sn; struct cell *tcell; @@ -1422,10 +1472,10 @@ int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum, ObtainReadLock(&tcell->lock); *a_name = afs_strdup(tcell->cellName); - for (sn = 0; sn < AFSMAXCELLHOSTS && tcell->cellHosts[sn]; sn++) - ; + for (sn = 0; sn < AFSMAXCELLHOSTS && tcell->cellHosts[sn]; sn++); a_hosts->serverList_len = sn; - a_hosts->serverList_val = (afs_int32 *) afs_osi_Alloc(sn*sizeof(afs_int32)); + a_hosts->serverList_val = + (afs_int32 *) afs_osi_Alloc(sn * sizeof(afs_int32)); for (i = 0; i < sn; i++) a_hosts->serverList_val[i] = ntohl(tcell->cellHosts[i]->addr->sa_ip); @@ -1435,15 +1485,16 @@ int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum, RX_AFS_GUNLOCK(); return 0; } - -int SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call, - struct interfaceAddr *addr, - Capabilities *capabilities) + +int +SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call, + struct interfaceAddr *addr, + Capabilities * capabilities) { int i; int code = 0; - afs_int32 *dataBuffP; - afs_int32 dataBytes; + afs_int32 *dataBuffP; + afs_int32 dataBytes; RX_AFS_GLOCK(); @@ -1454,20 +1505,20 @@ int SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call, /* return all network interface addresses */ addr->numberOfInterfaces = afs_cb_interface.numberOfInterfaces; addr->uuid = afs_cb_interface.uuid; - for ( i=0; i < afs_cb_interface.numberOfInterfaces; i++) { + for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) { addr->addr_in[i] = ntohl(afs_cb_interface.addr_in[i]); addr->subnetmask[i] = ntohl(afs_cb_interface.subnetmask[i]); addr->mtu[i] = ntohl(afs_cb_interface.mtu[i]); } ReleaseReadLock(&afs_xinterface); - + RX_AFS_GUNLOCK(); - + dataBytes = 1 * sizeof(afs_int32); - dataBuffP = (afs_int32 *)afs_osi_Alloc(dataBytes); + dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes); dataBuffP[0] = CAPABILITY_ERRORTRANS; - capabilities->Capabilities_len = dataBytes/sizeof(afs_int32); + capabilities->Capabilities_len = dataBytes / sizeof(afs_int32); capabilities->Capabilities_val = dataBuffP; return code; diff --git a/src/afs/afs_cbqueue.c b/src/afs/afs_cbqueue.c index 33c0147d8..66601d850 100644 --- a/src/afs/afs_cbqueue.c +++ b/src/afs/afs_cbqueue.c @@ -74,10 +74,11 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /*Standard vendor system headers*/ -#include "afsincludes.h" /*AFS-based standard headers*/ +#include "afs/sysincludes.h" /*Standard vendor system headers */ +#include "afsincludes.h" /*AFS-based standard headers */ #include "afs/afs_cbqueue.h" #include "afs/afs.h" #include "afs/lock.h" @@ -85,10 +86,10 @@ RCSID("$Header$"); static unsigned int base = 0; static unsigned int basetime = 0; -static struct vcache *debugvc; /* used only for post-mortem debugging */ +static struct vcache *debugvc; /* used only for post-mortem debugging */ struct bucket { - struct afs_q head; - /* struct afs_lock lock; only if you want lots of locks... */ + struct afs_q head; + /* struct afs_lock lock; only if you want lots of locks... */ }; static struct bucket cbHashT[CBHTSIZE]; struct afs_lock afs_xcbhash; @@ -108,17 +109,18 @@ struct afs_lock afs_xcbhash; * NOTE: The caller must hold a write lock on afs_xcbhash */ -void afs_QueueCallback(struct vcache *avc, unsigned int atime, struct volume *avp) +void +afs_QueueCallback(struct vcache *avc, unsigned int atime, struct volume *avp) { -if (avp && (avp->expireTime < avc->cbExpires)) - avp->expireTime = avc->cbExpires; -if (!(avc->callsort.next)) { - atime = (atime + base) % CBHTSIZE; - QAdd(&(cbHashT[atime].head), &(avc->callsort)); -} + if (avp && (avp->expireTime < avc->cbExpires)) + avp->expireTime = avc->cbExpires; + if (!(avc->callsort.next)) { + atime = (atime + base) % CBHTSIZE; + QAdd(&(cbHashT[atime].head), &(avc->callsort)); + } -return ; -} /* afs_QueueCallback */ + return; +} /* afs_QueueCallback */ /* afs_DequeueCallback * Takes a write-locked vcache pointer and removes it from the callback @@ -132,19 +134,19 @@ return ; * * NOTE: The caller must hold a write lock on afs_xcbhash */ -void afs_DequeueCallback(struct vcache *avc) +void +afs_DequeueCallback(struct vcache *avc) { - debugvc=avc; - if (avc->callsort.prev) { - QRemove(&(avc->callsort)); - avc->callsort.prev = avc->callsort.next = NULL; - } - else ; /* must have got dequeued in a race */ - afs_symhint_inval(avc); + debugvc = avc; + if (avc->callsort.prev) { + QRemove(&(avc->callsort)); + avc->callsort.prev = avc->callsort.next = NULL; + } else; /* must have got dequeued in a race */ + afs_symhint_inval(avc); - return; -} /* afs_DequeueCallback */ + return; +} /* afs_DequeueCallback */ /* afs_CheckCallbacks * called periodically to determine which callbacks are likely to @@ -186,90 +188,92 @@ void afs_DequeueCallback(struct vcache *avc) #define CBQ_LIMIT (afs_cacheStats + afs_stats_cmperf.vcacheXAllocs + 10) #endif -void afs_CheckCallbacks(unsigned int secs) +void +afs_CheckCallbacks(unsigned int secs) { - struct vcache *tvc; - register struct afs_q *tq; - struct afs_q *uq; - afs_uint32 now; - struct volume *tvp; - register int safety; - - ObtainWriteLock(&afs_xcbhash,85); /* pretty likely I'm going to remove something */ - now=osi_Time(); - for(safety = 0, tq = cbHashT[base].head.prev; - (safety <= CBQ_LIMIT) && (tq != &(cbHashT[base].head)); - tq = uq, safety++) { - - uq = QPrev(tq); - tvc = CBQTOV(tq); - if (tvc->cbExpires < now + secs) { /* race #1 here */ - /* Get the volume, and if its callback expiration time is more than secs - * seconds into the future, update this vcache entry and requeue it below - */ - if ((tvc->states & CRO) && (tvp=afs_FindVolume(&(tvc->fid), READ_LOCK))) { - if (tvp->expireTime > now + secs) { - tvc->cbExpires = tvp->expireTime; /* XXX race here */ - } - else { - int i; - for (i=0; i < MAXHOSTS && tvp->serverHost[i]; i++) { - if (!(tvp->serverHost[i]->flags & SRVR_ISDOWN)) { - /* What about locking xvcache or vrefcount++ or - * write locking tvc? */ - QRemove(tq); - tq->prev = tq->next = NULL; - tvc->states &= ~(CStatd | CMValid | CUnique); - if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR)) - osi_dnlc_purgedp(tvc); - tvc->quick.stamp = 0; - tvc->h1.dchint = NULL;/*invalidate em */ - afs_ResetVolumeInfo(tvp); - break; + struct vcache *tvc; + register struct afs_q *tq; + struct afs_q *uq; + afs_uint32 now; + struct volume *tvp; + register int safety; + + ObtainWriteLock(&afs_xcbhash, 85); /* pretty likely I'm going to remove something */ + now = osi_Time(); + for (safety = 0, tq = cbHashT[base].head.prev; + (safety <= CBQ_LIMIT) && (tq != &(cbHashT[base].head)); + tq = uq, safety++) { + + uq = QPrev(tq); + tvc = CBQTOV(tq); + if (tvc->cbExpires < now + secs) { /* race #1 here */ + /* Get the volume, and if its callback expiration time is more than secs + * seconds into the future, update this vcache entry and requeue it below + */ + if ((tvc->states & CRO) + && (tvp = afs_FindVolume(&(tvc->fid), READ_LOCK))) { + if (tvp->expireTime > now + secs) { + tvc->cbExpires = tvp->expireTime; /* XXX race here */ + } else { + int i; + for (i = 0; i < MAXHOSTS && tvp->serverHost[i]; i++) { + if (!(tvp->serverHost[i]->flags & SRVR_ISDOWN)) { + /* What about locking xvcache or vrefcount++ or + * write locking tvc? */ + QRemove(tq); + tq->prev = tq->next = NULL; + tvc->states &= ~(CStatd | CMValid | CUnique); + if ((tvc->fid.Fid.Vnode & 1) + || (vType(tvc) == VDIR)) + osi_dnlc_purgedp(tvc); + tvc->quick.stamp = 0; + tvc->h1.dchint = NULL; /*invalidate em */ + afs_ResetVolumeInfo(tvp); + break; + } + } } - } - } - afs_PutVolume(tvp, READ_LOCK); - } - else { - /* Do I need to worry about things like execsorwriters? - * What about locking xvcache or vrefcount++ or write locking tvc? - */ - QRemove(tq); - tq->prev = tq->next = NULL; - tvc->states &= ~(CStatd | CMValid | CUnique); - if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR)) - osi_dnlc_purgedp(tvc); - } + afs_PutVolume(tvp, READ_LOCK); + } else { + /* Do I need to worry about things like execsorwriters? + * What about locking xvcache or vrefcount++ or write locking tvc? + */ + QRemove(tq); + tq->prev = tq->next = NULL; + tvc->states &= ~(CStatd | CMValid | CUnique); + if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR)) + osi_dnlc_purgedp(tvc); + } + } + + if ((tvc->cbExpires > basetime) && CBHash(tvc->cbExpires - basetime)) { + /* it's been renewed on us. Have to be careful not to put it back + * into this slot, or we may never get out of here. + */ + int slot; + slot = (CBHash(tvc->cbExpires - basetime) + base) % CBHTSIZE; + if (slot != base) { + if (QPrev(tq)) + QRemove(&(tvc->callsort)); + QAdd(&(cbHashT[slot].head), &(tvc->callsort)); + /* XXX remember to update volume expiration time */ + /* -- not needed for correctness, though */ + } + } } - if ((tvc->cbExpires > basetime) && CBHash(tvc->cbExpires - basetime)) { - /* it's been renewed on us. Have to be careful not to put it back - * into this slot, or we may never get out of here. - */ - int slot; - slot = (CBHash(tvc->cbExpires - basetime)+base)%CBHTSIZE ; - if (slot != base) { - if (QPrev(tq)) - QRemove(&(tvc->callsort)); - QAdd( &(cbHashT[slot].head), &(tvc->callsort) ); - /* XXX remember to update volume expiration time */ - /* -- not needed for correctness, though */ - } - } - } + if (safety > CBQ_LIMIT) { + afs_stats_cmperf.cbloops++; + if (afs_paniconwarn) + osi_Panic("CheckCallbacks"); - if (safety > CBQ_LIMIT) { - afs_stats_cmperf.cbloops++; - if (afs_paniconwarn) - osi_Panic ("CheckCallbacks"); - - afs_warn("AFS Internal Error (minor): please contact AFS Product Support.\n"); - ReleaseWriteLock(&afs_xcbhash); - afs_FlushCBs(); - return; - } - else ReleaseWriteLock(&afs_xcbhash); + afs_warn + ("AFS Internal Error (minor): please contact AFS Product Support.\n"); + ReleaseWriteLock(&afs_xcbhash); + afs_FlushCBs(); + return; + } else + ReleaseWriteLock(&afs_xcbhash); /* XXX future optimization: @@ -286,32 +290,33 @@ void afs_CheckCallbacks(unsigned int secs) } */ -return; -} /* afs_CheckCallback */ + return; +} /* afs_CheckCallback */ /* afs_FlushCBs * to be used only in dire circumstances, this drops all callbacks on * the floor, without giving them back to the server. It's ok, the server can * deal with it, but it is a little bit rude. */ -void afs_FlushCBs(void) +void +afs_FlushCBs(void) { - register int i; - register struct vcache *tvc; - - ObtainWriteLock(&afs_xcbhash,86); /* pretty likely I'm going to remove something */ - - for (i = 0; i < VCSIZE; i++) /* reset all the vnodes */ - for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { - tvc->callback = 0; - tvc->quick.stamp = 0; - tvc->h1.dchint = NULL; /* invalidate hints */ - tvc->states &= ~(CStatd); - if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR)) - osi_dnlc_purgedp(tvc); - tvc->callsort.prev = tvc->callsort.next = NULL; - } - + register int i; + register struct vcache *tvc; + + ObtainWriteLock(&afs_xcbhash, 86); /* pretty likely I'm going to remove something */ + + for (i = 0; i < VCSIZE; i++) /* reset all the vnodes */ + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { + tvc->callback = 0; + tvc->quick.stamp = 0; + tvc->h1.dchint = NULL; /* invalidate hints */ + tvc->states &= ~(CStatd); + if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR)) + osi_dnlc_purgedp(tvc); + tvc->callsort.prev = tvc->callsort.next = NULL; + } + afs_InitCBQueue(0); ReleaseWriteLock(&afs_xcbhash); @@ -322,49 +327,51 @@ void afs_FlushCBs(void) * the floor for a specific server, without giving them back to the server. * It's ok, the server can deal with it, but it is a little bit rude. */ -void afs_FlushServerCBs(struct server *srvp) +void +afs_FlushServerCBs(struct server *srvp) { - register int i; - register struct vcache *tvc; - - ObtainWriteLock(&afs_xcbhash,86); /* pretty likely I'm going to remove something */ - - for (i=0; ihnext) { - if (tvc->callback == srvp) { - tvc->callback = 0; - tvc->quick.stamp = 0; - tvc->h1.dchint = NULL; /* invalidate hints */ - tvc->states &= ~(CStatd); - if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR)) { - osi_dnlc_purgedp(tvc); - } - afs_DequeueCallback(tvc); - } - } - } - - ReleaseWriteLock(&afs_xcbhash); + register int i; + register struct vcache *tvc; + + ObtainWriteLock(&afs_xcbhash, 86); /* pretty likely I'm going to remove something */ + + for (i = 0; i < VCSIZE; i++) { /* reset all the vnodes */ + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { + if (tvc->callback == srvp) { + tvc->callback = 0; + tvc->quick.stamp = 0; + tvc->h1.dchint = NULL; /* invalidate hints */ + tvc->states &= ~(CStatd); + if ((tvc->fid.Fid.Vnode & 1) || (vType(tvc) == VDIR)) { + osi_dnlc_purgedp(tvc); + } + afs_DequeueCallback(tvc); + } + } + } + + ReleaseWriteLock(&afs_xcbhash); } /* afs_InitCBQueue * called to initialize static and global variables associated with * the Callback expiration management mechanism. */ -void afs_InitCBQueue(int doLockInit) +void +afs_InitCBQueue(int doLockInit) { -register int i; - -memset((char *)cbHashT, 0, CBHTSIZE*sizeof(struct bucket)); -for (i=0;i>7) #define CBQTOV(e) ((struct vcache *)(((char *) (e)) - (((char *)(&(((struct vcache *)(e))->callsort))) - ((char *)(e))))) - - - - - - - - - - - - - - - diff --git a/src/afs/afs_cell.c b/src/afs/afs_cell.c index bd8bd0087..342cdb05d 100644 --- a/src/afs/afs_cell.c +++ b/src/afs/afs_cell.c @@ -13,12 +13,13 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/stds.h" #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #include "afs/afs_osi.h" /* Local variables. */ @@ -48,7 +49,8 @@ static struct { char **realname; } afsdb_req; -void afs_StopAFSDB() +void +afs_StopAFSDB() { if (afsdb_handler_running) { afs_osi_Wakeup(&afsdb_req); @@ -58,9 +60,11 @@ void afs_StopAFSDB() } } -int afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 *kernelMsg) +int +afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 * kernelMsg) { - if (afsdb_handler_shutdown) return -2; + if (afsdb_handler_shutdown) + return -2; afsdb_handler_running = 1; ObtainSharedLock(&afsdb_req.lock, 683); @@ -70,14 +74,15 @@ int afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 *kernelMsg) UpgradeSToWLock(&afsdb_req.lock, 684); hostCount = kernelMsg[0]; *afsdb_req.timeout = kernelMsg[1]; - if (*afsdb_req.timeout) *afsdb_req.timeout += osi_Time(); + if (*afsdb_req.timeout) + *afsdb_req.timeout += osi_Time(); *afsdb_req.realname = afs_strdup(acellName); - for (i=0; i= hostCount) afsdb_req.cellhosts[i] = 0; else - afsdb_req.cellhosts[i] = kernelMsg[2+i]; + afsdb_req.cellhosts[i] = kernelMsg[2 + i]; } /* Request completed, wake up the relevant thread */ @@ -109,17 +114,19 @@ int afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 *kernelMsg) return -2; } - /* Return the lookup request to userspace */ + /* Return the lookup request to userspace */ strncpy(acellName, afsdb_req.cellname, acellNameLen); ReleaseReadLock(&afsdb_req.lock); return 0; } -static int afs_GetCellHostsAFSDB(char *acellName, afs_int32 *acellHosts, - int *timeout, char **realName) +static int +afs_GetCellHostsAFSDB(char *acellName, afs_int32 * acellHosts, int *timeout, + char **realName) { AFS_ASSERT_GLOCK(); - if (!afsdb_handler_running) return ENOENT; + if (!afsdb_handler_running) + return ENOENT; ObtainWriteLock(&afsdb_client_lock, 685); ObtainWriteLock(&afsdb_req.lock, 686); @@ -150,23 +157,26 @@ static int afs_GetCellHostsAFSDB(char *acellName, afs_int32 *acellHosts, } #endif -void afs_LookupAFSDB(char *acellName) +void +afs_LookupAFSDB(char *acellName) { #ifdef AFS_AFSDB_ENV afs_int32 cellHosts[MAXCELLHOSTS]; char *realName = NULL; int code, timeout; - + code = afs_GetCellHostsAFSDB(acellName, cellHosts, &timeout, &realName); - if (code) goto done; + if (code) + goto done; code = afs_NewCell(realName, cellHosts, CNoSUID, NULL, 0, 0, timeout); - if (code && code != EEXIST) goto done; + if (code && code != EEXIST) + goto done; /* If we found an alias, create it */ if (afs_strcasecmp(acellName, realName)) afs_NewCellAlias(acellName, realName); -done: + done: if (realName) afs_osi_FreeStr(realName); #endif @@ -189,14 +199,15 @@ static int afs_cellname_inode_set; static int afs_cellname_dirty; static afs_int32 afs_cellnum_next; -static struct cell_name *afs_cellname_new(char *name, afs_int32 cellnum) +static struct cell_name * +afs_cellname_new(char *name, afs_int32 cellnum) { struct cell_name *cn; if (cellnum == 0) cellnum = afs_cellnum_next; - cn = (struct cell_name *) afs_osi_Alloc(sizeof(*cn)); + cn = (struct cell_name *)afs_osi_Alloc(sizeof(*cn)); cn->next = afs_cellname_head; cn->cellnum = cellnum; cn->cellname = afs_strdup(name); @@ -209,7 +220,8 @@ static struct cell_name *afs_cellname_new(char *name, afs_int32 cellnum) return cn; } -static struct cell_name *afs_cellname_lookup_id(afs_int32 cellnum) +static struct cell_name * +afs_cellname_lookup_id(afs_int32 cellnum) { struct cell_name *cn; @@ -220,7 +232,8 @@ static struct cell_name *afs_cellname_lookup_id(afs_int32 cellnum) return NULL; } -static struct cell_name *afs_cellname_lookup_name(char *name) +static struct cell_name * +afs_cellname_lookup_name(char *name) { struct cell_name *cn; @@ -231,7 +244,8 @@ static struct cell_name *afs_cellname_lookup_name(char *name) return NULL; } -static void afs_cellname_ref(struct cell_name *cn) +static void +afs_cellname_ref(struct cell_name *cn) { if (!cn->used) { cn->used = 1; @@ -239,7 +253,8 @@ static void afs_cellname_ref(struct cell_name *cn) } } -int afs_cellname_init(ino_t inode, int lookupcode) +int +afs_cellname_init(ino_t inode, int lookupcode) { struct osi_file *tfile; int cc, off = 0; @@ -301,8 +316,8 @@ int afs_cellname_init(ino_t inode, int lookupcode) off += cc; cellname[clen] = '\0'; - if (afs_cellname_lookup_name(cellname) || - afs_cellname_lookup_id(cellnum)) { + if (afs_cellname_lookup_name(cellname) + || afs_cellname_lookup_id(cellnum)) { afs_osi_Free(cellname, clen + 1); break; } @@ -316,7 +331,8 @@ int afs_cellname_init(ino_t inode, int lookupcode) return 0; } -int afs_cellname_write(void) +int +afs_cellname_write(void) { struct osi_file *tfile; struct cell_name *cn; @@ -383,9 +399,10 @@ int afs_cellname_write(void) struct cell_alias *afs_cellalias_head; /* Export for kdump */ static afs_int32 afs_cellalias_index; -static int afs_CellOrAliasExists_nl(char *aname); /* Forward declaration */ +static int afs_CellOrAliasExists_nl(char *aname); /* Forward declaration */ -static struct cell_alias *afs_FindCellAlias(char *alias) +static struct cell_alias * +afs_FindCellAlias(char *alias) { struct cell_alias *tc; @@ -395,7 +412,8 @@ static struct cell_alias *afs_FindCellAlias(char *alias) return tc; } -struct cell_alias *afs_GetCellAlias(int index) +struct cell_alias * +afs_GetCellAlias(int index) { struct cell_alias *tc; @@ -408,12 +426,14 @@ struct cell_alias *afs_GetCellAlias(int index) return tc; } -void afs_PutCellAlias(struct cell_alias *a) +void +afs_PutCellAlias(struct cell_alias *a) { return; } -afs_int32 afs_NewCellAlias(char *alias, char *cell) +afs_int32 +afs_NewCellAlias(char *alias, char *cell) { struct cell_alias *tc; @@ -424,7 +444,7 @@ afs_int32 afs_NewCellAlias(char *alias, char *cell) } UpgradeSToWLock(&afs_xcell, 682); - tc = (struct cell_alias *) afs_osi_Alloc(sizeof(struct cell_alias)); + tc = (struct cell_alias *)afs_osi_Alloc(sizeof(struct cell_alias)); tc->alias = afs_strdup(alias); tc->cell = afs_strdup(cell); tc->next = afs_cellalias_head; @@ -463,9 +483,10 @@ afs_int32 afs_NewCellAlias(char *alias, char *cell) struct afs_q CellLRU; /* Export for kdump */ static char *afs_thiscell; -afs_int32 afs_cellindex; /* Export for kdump */ +afs_int32 afs_cellindex; /* Export for kdump */ -static void afs_UpdateCellLRU(struct cell *c) +static void +afs_UpdateCellLRU(struct cell *c) { ObtainWriteLock(&afs_xcell, 100); QRemove(&c->lruq); @@ -473,7 +494,8 @@ static void afs_UpdateCellLRU(struct cell *c) ReleaseWriteLock(&afs_xcell); } -static void afs_RefreshCell(struct cell *ac) +static void +afs_RefreshCell(struct cell *ac) { if (ac->states & CNoAFSDB) return; @@ -481,30 +503,33 @@ static void afs_RefreshCell(struct cell *ac) afs_LookupAFSDB(ac->cellName); } -static void *afs_TraverseCells_nl(void *(*cb)(struct cell *, void *), void *arg) +static void * +afs_TraverseCells_nl(void *(*cb) (struct cell *, void *), void *arg) { struct afs_q *cq, *tq; struct cell *tc; void *ret = NULL; for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tc = QTOC(cq); + tc = QTOC(cq); - /* This is assuming that a NULL return is acceptable. */ - if (cq) { - tq = QNext(cq); - } else { - return NULL; - } + /* This is assuming that a NULL return is acceptable. */ + if (cq) { + tq = QNext(cq); + } else { + return NULL; + } ret = cb(tc, arg); - if (ret) break; + if (ret) + break; } return ret; } -void *afs_TraverseCells(void *(*cb)(struct cell *, void *), void *arg) +void * +afs_TraverseCells(void *(*cb) (struct cell *, void *), void *arg) { void *ret; @@ -515,37 +540,43 @@ void *afs_TraverseCells(void *(*cb)(struct cell *, void *), void *arg) return ret; } -static void *afs_choose_cell_by_name(struct cell *cell, void *arg) +static void * +afs_choose_cell_by_name(struct cell *cell, void *arg) { - if ( !arg ) { - /* Safety net */ - return cell; + if (!arg) { + /* Safety net */ + return cell; } else { - return strcmp(cell->cellName, (char *) arg) ? NULL : cell; + return strcmp(cell->cellName, (char *)arg) ? NULL : cell; } } -static void *afs_choose_cell_by_num(struct cell *cell, void *arg) +static void * +afs_choose_cell_by_num(struct cell *cell, void *arg) { return (cell->cellNum == *((afs_int32 *) arg)) ? cell : NULL; } -static void *afs_choose_cell_by_index(struct cell *cell, void *arg) +static void * +afs_choose_cell_by_index(struct cell *cell, void *arg) { return (cell->cellIndex == *((afs_int32 *) arg)) ? cell : NULL; } -static struct cell *afs_FindCellByName_nl(char *acellName, afs_int32 locktype) +static struct cell * +afs_FindCellByName_nl(char *acellName, afs_int32 locktype) { return afs_TraverseCells_nl(&afs_choose_cell_by_name, acellName); } -static struct cell *afs_FindCellByName(char *acellName, afs_int32 locktype) +static struct cell * +afs_FindCellByName(char *acellName, afs_int32 locktype) { return afs_TraverseCells(&afs_choose_cell_by_name, acellName); } -struct cell *afs_GetCellByName(char *acellName, afs_int32 locktype) +struct cell * +afs_GetCellByName(char *acellName, afs_int32 locktype) { struct cell *tc; @@ -563,7 +594,8 @@ struct cell *afs_GetCellByName(char *acellName, afs_int32 locktype) return tc; } -struct cell *afs_GetCell(afs_int32 cellnum, afs_int32 locktype) +struct cell * +afs_GetCell(afs_int32 cellnum, afs_int32 locktype) { struct cell *tc; struct cell_name *cn; @@ -581,7 +613,8 @@ struct cell *afs_GetCell(afs_int32 cellnum, afs_int32 locktype) return tc; } -struct cell *afs_GetCellStale(afs_int32 cellnum, afs_int32 locktype) +struct cell * +afs_GetCellStale(afs_int32 cellnum, afs_int32 locktype) { struct cell *tc; @@ -593,7 +626,8 @@ struct cell *afs_GetCellStale(afs_int32 cellnum, afs_int32 locktype) return tc; } -struct cell *afs_GetCellByIndex(afs_int32 index, afs_int32 locktype) +struct cell * +afs_GetCellByIndex(afs_int32 index, afs_int32 locktype) { struct cell *tc; @@ -603,28 +637,31 @@ struct cell *afs_GetCellByIndex(afs_int32 index, afs_int32 locktype) return tc; } -struct cell *afs_GetPrimaryCell(afs_int32 locktype) +struct cell * +afs_GetPrimaryCell(afs_int32 locktype) { return afs_GetCellByName(afs_thiscell, locktype); } -int afs_IsPrimaryCell(struct cell *cell) +int +afs_IsPrimaryCell(struct cell *cell) { /* Simple safe checking */ if (!cell) { - return 0; - } else if ( !afs_thiscell ) { - /* This is simply a safety net to avoid seg faults especially when - * using a user-space library. afs_SetPrimaryCell() should be set - * prior to this call. */ - afs_SetPrimaryCell( cell->cellName ); - return 1; + return 0; + } else if (!afs_thiscell) { + /* This is simply a safety net to avoid seg faults especially when + * using a user-space library. afs_SetPrimaryCell() should be set + * prior to this call. */ + afs_SetPrimaryCell(cell->cellName); + return 1; } else { - return strcmp(cell->cellName, afs_thiscell) ? 0 : 1; + return strcmp(cell->cellName, afs_thiscell) ? 0 : 1; } } -int afs_IsPrimaryCellNum(afs_int32 cellnum) +int +afs_IsPrimaryCellNum(afs_int32 cellnum) { struct cell *tc; int primary = 0; @@ -638,7 +675,8 @@ int afs_IsPrimaryCellNum(afs_int32 cellnum) return primary; } -afs_int32 afs_SetPrimaryCell(char *acellName) +afs_int32 +afs_SetPrimaryCell(char *acellName) { ObtainWriteLock(&afs_xcell, 691); if (afs_thiscell) @@ -648,11 +686,12 @@ afs_int32 afs_SetPrimaryCell(char *acellName) return 0; } -afs_int32 afs_NewCell(char *acellName, afs_int32 *acellHosts, int aflags, - char *linkedcname, u_short fsport, u_short vlport, int timeout) +afs_int32 +afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags, + char *linkedcname, u_short fsport, u_short vlport, int timeout) { - struct cell *tc, *tcl=0; - afs_int32 i, newc=0, code=0; + struct cell *tc, *tcl = 0; + afs_int32 i, newc = 0, code = 0; AFS_STATCNT(afs_NewCell); @@ -662,8 +701,8 @@ afs_int32 afs_NewCell(char *acellName, afs_int32 *acellHosts, int aflags, if (tc) { aflags &= ~CNoSUID; } else { - tc = (struct cell *) afs_osi_Alloc(sizeof(struct cell)); - memset((char *) tc, 0, sizeof(*tc)); + tc = (struct cell *)afs_osi_Alloc(sizeof(struct cell)); + memset((char *)tc, 0, sizeof(*tc)); tc->cellName = afs_strdup(acellName); tc->fsport = AFS_FSPORT; tc->vlport = AFS_VLPORT; @@ -681,21 +720,24 @@ afs_int32 afs_NewCell(char *acellName, afs_int32 *acellHosts, int aflags, * it must get servers from AFSDB. */ if (timeout && !tc->timeout && tc->cellHosts[0]) { - code = EEXIST; /* This code is checked for in afs_LookupAFSDB */ + code = EEXIST; /* This code is checked for in afs_LookupAFSDB */ goto bad; } /* we don't want to keep pinging old vlservers which were down, * since they don't matter any more. It's easier to do this than * to remove the server from its various hash tables. */ - for (i=0; icellHosts[i]) break; + for (i = 0; i < MAXCELLHOSTS; i++) { + if (!tc->cellHosts[i]) + break; tc->cellHosts[i]->flags &= ~SRVR_ISDOWN; tc->cellHosts[i]->flags |= SRVR_ISGONE; } - if (fsport) tc->fsport = fsport; - if (vlport) tc->vlport = vlport; + if (fsport) + tc->fsport = fsport; + if (vlport) + tc->vlport = vlport; if (aflags & CLinkedCell) { if (!linkedcname) { @@ -718,10 +760,11 @@ afs_int32 afs_NewCell(char *acellName, afs_int32 *acellHosts, int aflags, tc->timeout = timeout; memset((char *)tc->cellHosts, 0, sizeof(tc->cellHosts)); - for (i=0; ivlport, WRITE_LOCK, NULL, 0); ts->cell = tc; ts->flags &= ~SRVR_ISGONE; @@ -750,7 +793,7 @@ afs_int32 afs_NewCell(char *acellName, afs_int32 *acellHosts, int aflags, afs_DynrootInvalidate(); return 0; -bad: + bad: if (newc) { afs_osi_FreeStr(tc->cellName); afs_osi_Free(tc, sizeof(struct cell)); @@ -771,7 +814,8 @@ bad: * afs_CellNumValid: check if a cell number is valid (also set the used flag) */ -void afs_CellInit() +void +afs_CellInit() { RWLOCK_INIT(&afs_xcell, "afs_xcell"); #ifdef AFS_AFSDB_ENV @@ -783,7 +827,8 @@ void afs_CellInit() afs_cellalias_index = 0; } -void shutdown_cell() +void +shutdown_cell() { struct afs_q *cq, *tq; struct cell *tc; @@ -791,25 +836,30 @@ void shutdown_cell() RWLOCK_INIT(&afs_xcell, "afs_xcell"); for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tc = QTOC(cq); tq = QNext(cq); - if (tc->cellName) afs_osi_FreeStr(tc->cellName); + tc = QTOC(cq); + tq = QNext(cq); + if (tc->cellName) + afs_osi_FreeStr(tc->cellName); afs_osi_Free(tc, sizeof(struct cell)); } QInit(&CellLRU); } -void afs_RemoveCellEntry(struct server *srvp) +void +afs_RemoveCellEntry(struct server *srvp) { struct cell *tc; afs_int32 j, k; tc = srvp->cell; - if (!tc) return; + if (!tc) + return; /* Remove the server structure from the cell list - if there */ ObtainWriteLock(&tc->lock, 200); - for (j=k=0; jcellHosts[j]) break; + for (j = k = 0; j < MAXCELLHOSTS; j++) { + if (!tc->cellHosts[j]) + break; if (tc->cellHosts[j] != srvp) { tc->cellHosts[k++] = tc->cellHosts[j]; } @@ -817,13 +867,14 @@ void afs_RemoveCellEntry(struct server *srvp) if (k == 0) { /* What do we do if we remove the last one? */ } - for (; kcellHosts[k] = 0; } ReleaseWriteLock(&tc->lock); } -static int afs_CellOrAliasExists_nl(char *aname) +static int +afs_CellOrAliasExists_nl(char *aname) { struct cell *c; struct cell_alias *ca; @@ -843,7 +894,8 @@ static int afs_CellOrAliasExists_nl(char *aname) return 0; } -int afs_CellOrAliasExists(char *aname) +int +afs_CellOrAliasExists(char *aname) { int ret; @@ -854,7 +906,8 @@ int afs_CellOrAliasExists(char *aname) return ret; } -int afs_CellNumValid(afs_int32 cellnum) +int +afs_CellNumValid(afs_int32 cellnum) { struct cell_name *cn; diff --git a/src/afs/afs_chunk.c b/src/afs/afs_chunk.c index b2720396b..562192b5d 100644 --- a/src/afs/afs_chunk.c +++ b/src/afs/afs_chunk.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/stds.h" -#include "afs/sysincludes.h" /* Standard vendor system headers */ -#include "afsincludes.h" /* Afs-based standard headers */ +#include "afs/sysincludes.h" /* Standard vendor system headers */ +#include "afsincludes.h" /* Afs-based standard headers */ #include "afs/afs_stats.h" /* @@ -26,20 +27,22 @@ afs_int32 afs_OtherCSize = AFS_DEFAULTCSIZE; afs_int32 afs_LogChunk = AFS_DEFAULTLSIZE; #ifdef notdef -int afs_ChunkOffset(offset) - afs_int32 offset; +int +afs_ChunkOffset(offset) + afs_int32 offset; { AFS_STATCNT(afs_ChunkOffset); - if (offset < afs_FirstCSize) + if (offset < afs_FirstCSize) return offset; else return ((offset - afs_FirstCSize) & (afs_OtherCSize - 1)); } -int afs_Chunk(offset) - afs_int32 offset; +int +afs_Chunk(offset) + afs_int32 offset; { AFS_STATCNT(afs_Chunk); if (offset < afs_FirstCSize) @@ -49,19 +52,22 @@ int afs_Chunk(offset) } -int afs_ChunkBase(offset) - int offset; +int +afs_ChunkBase(offset) + int offset; { AFS_STATCNT(afs_ChunkBase); if (offset < afs_FirstCSize) return 0; else - return (((offset - afs_FirstCSize) & ~(afs_OtherCSize - 1)) + afs_FirstCSize); + return (((offset - afs_FirstCSize) & ~(afs_OtherCSize - 1)) + + afs_FirstCSize); } -int afs_ChunkSize(offset) - afs_int32 offset; +int +afs_ChunkSize(offset) + afs_int32 offset; { AFS_STATCNT(afs_ChunkSize); if (offset < afs_FirstCSize) @@ -71,19 +77,21 @@ int afs_ChunkSize(offset) } -int afs_ChunkToBase(chunk) - afs_int32 chunk; +int +afs_ChunkToBase(chunk) + afs_int32 chunk; { AFS_STATCNT(afs_ChunkToBase); if (chunk == 0) return 0; - else + else return (afs_FirstCSize + ((chunk - 1) << afs_LogChunk)); } -int afs_ChunkToSize(chunk) - afs_int32 chunk; +int +afs_ChunkToSize(chunk) + afs_int32 chunk; { AFS_STATCNT(afs_ChunkToSize); if (chunk == 0) @@ -93,12 +101,13 @@ int afs_ChunkToSize(chunk) } /* sizes are a power of two */ -int afs_SetChunkSize(chunk) +int +afs_SetChunkSize(chunk) afs_int32 chunk; - { - AFS_STATCNT(afs_SetChunkSize); - afs_LogChunk = chunk; - afs_FirstCSize = afs_OtherCSize = (1 << chunk); - } +{ + AFS_STATCNT(afs_SetChunkSize); + afs_LogChunk = chunk; + afs_FirstCSize = afs_OtherCSize = (1 << chunk); +} #endif /* notdef */ diff --git a/src/afs/afs_chunkops.h b/src/afs/afs_chunkops.h index 4ee88760b..9a482dc3f 100644 --- a/src/afs/afs_chunkops.h +++ b/src/afs/afs_chunkops.h @@ -35,8 +35,8 @@ #endif /* AFS_NOCHUNKING */ -#define AFS_MINCHUNK 13 /* 8k is minimum */ -#define AFS_MAXCHUNK 18 /* 256K is maximum */ +#define AFS_MINCHUNK 13 /* 8k is minimum */ +#define AFS_MAXCHUNK 18 /* 256K is maximum */ #define AFS_CHUNKOFFSET(offset) ((offset < afs_FirstCSize) ? offset : \ ((offset - afs_FirstCSize) & (afs_OtherCSize - 1))) @@ -65,28 +65,34 @@ struct afs_cacheOps { #if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_SGI62_ENV) - void *(*open)(ino_t ainode); + void *(*open) (ino_t ainode); #else - void *(*open)(afs_int32 ainode); + void *(*open) (afs_int32 ainode); #endif - int (*truncate)(struct osi_file *fp, afs_int32 len); - int (*fread)(struct osi_file *fp, int offset, void *buf, afs_int32 len); - int (*fwrite)(struct osi_file *fp, afs_int32 offset, void *buf, afs_int32 len); - int (*close)(struct osi_file *fp); - int (*vread)(register struct vcache *avc, struct uio *auio, - struct AFS_UCRED *acred, daddr_t albn, struct buf **abpp, int noLock); - int (*vwrite)(register struct vcache *avc, struct uio *auio, - int aio, struct AFS_UCRED *acred, int noLock); - int (*FetchProc)(register struct rx_call *acall, - struct osi_file *afile, afs_size_t abase, struct dcache *adc, - struct vcache *avc, afs_size_t *abytesToXferP, - afs_size_t *abytesXferredP, afs_int32 lengthFound); - int (*StoreProc)(register struct rx_call *acall, - struct osi_file *afile, register afs_int32 alen, struct vcache *avc, - int *shouldWake, afs_size_t *abytesToXferP, afs_size_t *abytesXferredP); - struct dcache *(*GetDSlot)(register afs_int32 aslot, register struct dcache *tmpdc); - struct volume *(*GetVolSlot)(void); - int (*HandleLink)(register struct vcache *avc, struct vrequest *areq); + int (*truncate) (struct osi_file * fp, afs_int32 len); + int (*fread) (struct osi_file * fp, int offset, void *buf, afs_int32 len); + int (*fwrite) (struct osi_file * fp, afs_int32 offset, void *buf, + afs_int32 len); + int (*close) (struct osi_file * fp); + int (*vread) (register struct vcache * avc, struct uio * auio, + struct AFS_UCRED * acred, daddr_t albn, struct buf ** abpp, + int noLock); + int (*vwrite) (register struct vcache * avc, struct uio * auio, int aio, + struct AFS_UCRED * acred, int noLock); + int (*FetchProc) (register struct rx_call * acall, + struct osi_file * afile, afs_size_t abase, + struct dcache * adc, struct vcache * avc, + afs_size_t * abytesToXferP, afs_size_t * abytesXferredP, + afs_int32 lengthFound); + int (*StoreProc) (register struct rx_call * acall, + struct osi_file * afile, register afs_int32 alen, + struct vcache * avc, int *shouldWake, + afs_size_t * abytesToXferP, + afs_size_t * abytesXferredP); + struct dcache *(*GetDSlot) (register afs_int32 aslot, + register struct dcache * tmpdc); + struct volume *(*GetVolSlot) (void); + int (*HandleLink) (register struct vcache * avc, struct vrequest * areq); }; /* Ideally we should have used consistent naming - like COP_OPEN, COP_TRUNCATE, etc. */ @@ -105,6 +111,3 @@ struct afs_cacheOps { (*(afs_cacheType->StoreProc))(call, file, bytes, avc, wake, toxfer, xfered) #endif /* AFS_CHUNKOPS */ - - - diff --git a/src/afs/afs_conn.c b/src/afs/afs_conn.c index de261b5a9..744a23474 100644 --- a/src/afs/afs_conn.c +++ b/src/afs/afs_conn.c @@ -13,7 +13,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/stds.h" #include "afs/sysincludes.h" /* Standard vendor system headers */ @@ -33,7 +34,7 @@ RCSID("$Header$"); #endif /* !defined(UKERNEL) */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #if defined(AFS_SUN56_ENV) #include @@ -45,94 +46,95 @@ RCSID("$Header$"); #endif /* Exported variables */ -afs_rwlock_t afs_xconn; /* allocation lock for new things */ -afs_rwlock_t afs_xinterface; /* for multiple client address */ -afs_int32 cryptall = 0; /* encrypt all communications */ +afs_rwlock_t afs_xconn; /* allocation lock for new things */ +afs_rwlock_t afs_xinterface; /* for multiple client address */ +afs_int32 cryptall = 0; /* encrypt all communications */ unsigned int VNOSERVERS = 0; -struct conn *afs_Conn(register struct VenusFid *afid, - register struct vrequest *areq, afs_int32 locktype) +struct conn * +afs_Conn(register struct VenusFid *afid, register struct vrequest *areq, + afs_int32 locktype) { - u_short fsport=AFS_FSPORT; - struct volume *tv; - struct conn *tconn = NULL; - struct srvAddr *lowp= NULL; - struct unixuser *tu; - int notbusy; - int i; - struct srvAddr *sa1p; - - AFS_STATCNT(afs_Conn); - tv = afs_GetVolume(afid, areq, READ_LOCK); - if (!tv) { - if (areq) { - afs_FinalizeReq(areq); - areq->volumeError = 1; - } - return NULL; - } - - if (tv->serverHost[0] && tv->serverHost[0]->cell) { - fsport = tv->serverHost[0]->cell->fsport; - } - else { - VNOSERVERS++; - } - - /* First is always lowest rank, if it's up */ - if ((tv->status[0] == not_busy) && tv->serverHost[0] && - !(tv->serverHost[0]->addr->sa_flags & SRVR_ISDOWN)) - lowp = tv->serverHost[0]->addr; - - /* Otherwise we look at all of them. There are seven levels of - * not_busy. This means we will check a volume seven times before it - * is marked offline. Ideally, we only need two levels, but this - * serves a second purpose of waiting some number of seconds before - * the client decides the volume is offline (ie: a clone could finish - * in this time). - */ - for (notbusy = not_busy; (!lowp && (notbusy <= end_not_busy)); notbusy++) { - for (i=0 ;iserverHost[i];i++) { - if (tv->status[i] != notbusy) { - if (tv->status[i] == rd_busy || tv->status[i] == rdwr_busy) { - if (!areq->busyCount) - areq->busyCount++; - } else if (tv->status[i] == offline) { - if (!areq->volumeError) - areq->volumeError = VOLMISSING; + u_short fsport = AFS_FSPORT; + struct volume *tv; + struct conn *tconn = NULL; + struct srvAddr *lowp = NULL; + struct unixuser *tu; + int notbusy; + int i; + struct srvAddr *sa1p; + + AFS_STATCNT(afs_Conn); + tv = afs_GetVolume(afid, areq, READ_LOCK); + if (!tv) { + if (areq) { + afs_FinalizeReq(areq); + areq->volumeError = 1; + } + return NULL; + } + + if (tv->serverHost[0] && tv->serverHost[0]->cell) { + fsport = tv->serverHost[0]->cell->fsport; + } else { + VNOSERVERS++; + } + + /* First is always lowest rank, if it's up */ + if ((tv->status[0] == not_busy) && tv->serverHost[0] + && !(tv->serverHost[0]->addr->sa_flags & SRVR_ISDOWN)) + lowp = tv->serverHost[0]->addr; + + /* Otherwise we look at all of them. There are seven levels of + * not_busy. This means we will check a volume seven times before it + * is marked offline. Ideally, we only need two levels, but this + * serves a second purpose of waiting some number of seconds before + * the client decides the volume is offline (ie: a clone could finish + * in this time). + */ + for (notbusy = not_busy; (!lowp && (notbusy <= end_not_busy)); notbusy++) { + for (i = 0; i < MAXHOSTS && tv->serverHost[i]; i++) { + if (tv->status[i] != notbusy) { + if (tv->status[i] == rd_busy || tv->status[i] == rdwr_busy) { + if (!areq->busyCount) + areq->busyCount++; + } else if (tv->status[i] == offline) { + if (!areq->volumeError) + areq->volumeError = VOLMISSING; + } + continue; + } + for (sa1p = tv->serverHost[i]->addr; sa1p; sa1p = sa1p->next_sa) { + if (sa1p->sa_flags & SRVR_ISDOWN) + continue; + if (!lowp || (lowp->sa_iprank > sa1p->sa_iprank)) + lowp = sa1p; } - continue; - } - for (sa1p = tv->serverHost[i]->addr; sa1p; sa1p = sa1p->next_sa) { - if (sa1p->sa_flags & SRVR_ISDOWN) - continue; - if (!lowp || (lowp->sa_iprank > sa1p->sa_iprank)) - lowp = sa1p; - } - } - } - afs_PutVolume(tv, READ_LOCK); - - if (lowp) { - tu = afs_GetUser(areq->uid, afid->Cell, SHARED_LOCK); - tconn = afs_ConnBySA(lowp, fsport, afid->Cell, tu, - 0/*!force*/, 1/*create*/, locktype); - - afs_PutUser(tu, SHARED_LOCK); - } - - return tconn; -} /*afs_Conn*/ - - -struct conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, - afs_int32 acell, struct unixuser *tu, - int force_if_down, afs_int32 create, afs_int32 locktype) + } + } + afs_PutVolume(tv, READ_LOCK); + + if (lowp) { + tu = afs_GetUser(areq->uid, afid->Cell, SHARED_LOCK); + tconn = afs_ConnBySA(lowp, fsport, afid->Cell, tu, 0 /*!force */ , + 1 /*create */ , locktype); + + afs_PutUser(tu, SHARED_LOCK); + } + + return tconn; +} /*afs_Conn */ + + +struct conn * +afs_ConnBySA(struct srvAddr *sap, unsigned short aport, afs_int32 acell, + struct unixuser *tu, int force_if_down, afs_int32 create, + afs_int32 locktype) { - struct conn *tc=0; - struct rx_securityClass *csec; /*Security class object*/ - int isec; /*Security index*/ + struct conn *tc = 0; + struct rx_securityClass *csec; /*Security class object */ + int isec; /*Security index */ int service; if (!sap || ((sap->sa_flags & SRVR_ISDOWN) && !force_if_down)) { @@ -140,38 +142,38 @@ struct conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, return NULL; } - ObtainSharedLock(&afs_xconn,15); - for (tc = sap->conns; tc; tc=tc->next) { - if (tc->user == tu && tc->port == aport) { - break; - } - } + ObtainSharedLock(&afs_xconn, 15); + for (tc = sap->conns; tc; tc = tc->next) { + if (tc->user == tu && tc->port == aport) { + break; + } + } if (!tc && !create) { - ReleaseSharedLock(&afs_xconn); - return NULL; + ReleaseSharedLock(&afs_xconn); + return NULL; } if (!tc) { - /* No such connection structure exists. Create one and splice it in. - * Make sure the server record has been marked as used (for the purposes - * of calculating up & down times, it's now considered to be an - * ``active'' server). Also make sure the server's lastUpdateEvalTime - * gets set, marking the time of its ``birth''. - */ - UpgradeSToWLock(&afs_xconn,37); - tc = (struct conn *) afs_osi_Alloc(sizeof(struct conn)); + /* No such connection structure exists. Create one and splice it in. + * Make sure the server record has been marked as used (for the purposes + * of calculating up & down times, it's now considered to be an + * ``active'' server). Also make sure the server's lastUpdateEvalTime + * gets set, marking the time of its ``birth''. + */ + UpgradeSToWLock(&afs_xconn, 37); + tc = (struct conn *)afs_osi_Alloc(sizeof(struct conn)); memset((char *)tc, 0, sizeof(struct conn)); tc->user = tu; tc->port = aport; tc->srvr = sap; - tc->refCount = 0; /* bumped below */ + tc->refCount = 0; /* bumped below */ tc->forceConnectFS = 1; - tc->id = (struct rx_connection *) 0; + tc->id = (struct rx_connection *)0; tc->next = sap->conns; sap->conns = tc; - afs_ActivateServer(sap); + afs_ActivateServer(sap); ConvertWToSLock(&afs_xconn); } @@ -179,21 +181,21 @@ struct conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, if (tu->states & UTokensBad) { /* we may still have an authenticated RPC connection here, - * we'll have to create a new, unauthenticated, connection. - * Perhaps a better way to do this would be to set - * conn->forceConnectFS on all conns when the token first goes - * bad, but that's somewhat trickier, due to locking - * constraints (though not impossible). - */ + * we'll have to create a new, unauthenticated, connection. + * Perhaps a better way to do this would be to set + * conn->forceConnectFS on all conns when the token first goes + * bad, but that's somewhat trickier, due to locking + * constraints (though not impossible). + */ if (tc->id && (rx_SecurityClassOf(tc->id) != 0)) { - tc->forceConnectFS = 1; /* force recreation of connection */ + tc->forceConnectFS = 1; /* force recreation of connection */ } tu->vid = UNDEFVID; /* forcibly disconnect the authentication info */ } - if (tc->forceConnectFS) { - UpgradeSToWLock(&afs_xconn,38); - csec = (struct rx_securityClass *) 0; + if (tc->forceConnectFS) { + UpgradeSToWLock(&afs_xconn, 38); + csec = (struct rx_securityClass *)0; if (tc->id) { AFS_GUNLOCK(); rx_DestroyConnection(tc->id); @@ -209,26 +211,26 @@ struct conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, service = 1; isec = 0; if (tu->vid != UNDEFVID) { - int level; - - if (cryptall) { - level=rxkad_crypt; - } else { - level=rxkad_clear; - } - isec=2; - /* kerberos tickets on channel 2 */ - csec = rxkad_NewClientSecurityObject(level, tu->ct.HandShakeKey, - /* kvno */ - tu->ct.AuthHandle, - tu->stLen, tu->stp); + int level; + + if (cryptall) { + level = rxkad_crypt; + } else { + level = rxkad_clear; + } + isec = 2; + /* kerberos tickets on channel 2 */ + csec = rxkad_NewClientSecurityObject(level, tu->ct.HandShakeKey, + /* kvno */ + tu->ct.AuthHandle, tu->stLen, + tu->stp); } if (isec == 0) csec = rxnull_NewClientSecurityObject(); AFS_GUNLOCK(); tc->id = rx_NewConnection(sap->sa_ip, aport, service, csec, isec); AFS_GLOCK(); - if (service == 52) { + if (service == 52) { rx_SetConnHardDeadTime(tc->id, afs_rx_harddead); } @@ -241,6 +243,7 @@ struct conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, ReleaseSharedLock(&afs_xconn); return tc; } + /* * afs_ConnByHost * @@ -250,12 +253,13 @@ struct conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, * Having force... true and UTokensBad true simultaneously means that the tokens * went bad and we're supposed to create a new, unauthenticated, connection. */ -struct conn *afs_ConnByHost(struct server *aserver, unsigned short aport, - afs_int32 acell, struct vrequest *areq, int aforce, afs_int32 locktype) +struct conn * +afs_ConnByHost(struct server *aserver, unsigned short aport, afs_int32 acell, + struct vrequest *areq, int aforce, afs_int32 locktype) { struct unixuser *tu; - struct conn *tc=0; - struct srvAddr *sa=0; + struct conn *tc = 0; + struct srvAddr *sa = 0; AFS_STATCNT(afs_ConnByHost); /* @@ -266,32 +270,34 @@ struct conn *afs_ConnByHost(struct server *aserver, unsigned short aport, tu = afs_GetUser(areq->uid, acell, SHARED_LOCK); - for (sa = aserver->addr; sa; sa = sa->next_sa) { - tc = afs_ConnBySA(sa, aport, acell, tu, aforce, - 0/*don't create one*/, - locktype); - if (tc) + for (sa = aserver->addr; sa; sa = sa->next_sa) { + tc = afs_ConnBySA(sa, aport, acell, tu, aforce, + 0 /*don't create one */ , + locktype); + if (tc) break; } if (!tc) { - for (sa = aserver->addr; sa; sa = sa->next_sa) { - tc = afs_ConnBySA(sa, aport, acell, tu, aforce, - 1/*create one*/, - locktype); - if (tc) - break; - } + for (sa = aserver->addr; sa; sa = sa->next_sa) { + tc = afs_ConnBySA(sa, aport, acell, tu, aforce, + 1 /*create one */ , + locktype); + if (tc) + break; + } } afs_PutUser(tu, SHARED_LOCK); return tc; -} /*afs_ConnByHost*/ +} /*afs_ConnByHost */ -struct conn *afs_ConnByMHosts(struct server *ahosts[], unsigned short aport, - afs_int32 acell, register struct vrequest *areq, afs_int32 locktype) +struct conn * +afs_ConnByMHosts(struct server *ahosts[], unsigned short aport, + afs_int32 acell, register struct vrequest *areq, + afs_int32 locktype) { register afs_int32 i; register struct conn *tconn; @@ -299,47 +305,49 @@ struct conn *afs_ConnByMHosts(struct server *ahosts[], unsigned short aport, /* try to find any connection from the set */ AFS_STATCNT(afs_ConnByMHosts); - for (i=0;irefCount--; -} /*afs_PutConn*/ +} /*afs_PutConn */ /* for multi homed clients, an RPC may timeout because of a client network interface going down. We need to reopen new connections in this case */ -void ForceNewConnections(struct srvAddr *sap) +void +ForceNewConnections(struct srvAddr *sap) { - struct conn *tc=0; + struct conn *tc = 0; - if ( !sap) return; /* defensive check */ + if (!sap) + return; /* defensive check */ - /* if client is not multihomed, do nothing */ - ObtainReadLock(&afs_xinterface); - if ( afs_cb_interface.numberOfInterfaces <= 1 ) - { - ReleaseReadLock(&afs_xinterface); - return; - } + /* if client is not multihomed, do nothing */ + ObtainReadLock(&afs_xinterface); + if (afs_cb_interface.numberOfInterfaces <= 1) { ReleaseReadLock(&afs_xinterface); - - ObtainWriteLock(&afs_xconn,413); - for (tc = sap->conns; tc; tc=tc->next) - tc->forceConnectFS=1; - ReleaseWriteLock(&afs_xconn); + return; + } + ReleaseReadLock(&afs_xinterface); + + ObtainWriteLock(&afs_xconn, 413); + for (tc = sap->conns; tc; tc = tc->next) + tc->forceConnectFS = 1; + ReleaseWriteLock(&afs_xconn); } diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c index 322255207..849d4469c 100644 --- a/src/afs/afs_daemons.c +++ b/src/afs/afs_daemons.c @@ -10,7 +10,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_AIX51_ENV #define __FULL_PROTO @@ -19,8 +20,8 @@ RCSID("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics gathering code */ -#include "afs/afs_cbqueue.h" +#include "afs/afs_stats.h" /* statistics gathering code */ +#include "afs/afs_cbqueue.h" #ifdef AFS_AIX_ENV #include /* for vm_att(), vm_det() */ #endif @@ -31,40 +32,42 @@ afs_lock_t afs_xbrs; /* lock for brs */ static int brsInit = 0; short afs_brsWaiters = 0; /* number of users waiting for brs buffers */ short afs_brsDaemons = 0; /* number of daemons waiting for brs requests */ -struct brequest afs_brs[NBRS]; /* request structures */ +struct brequest afs_brs[NBRS]; /* request structures */ struct afs_osi_WaitHandle AFS_WaitHandler, AFS_CSWaitHandler; static int afs_brs_count = 0; /* request counter, to service reqs in order */ -static int rxepoch_checked=0; +static int rxepoch_checked = 0; #define afs_CheckRXEpoch() {if (rxepoch_checked == 0 && rxkad_EpochWasSet) { \ rxepoch_checked = 1; afs_GCUserData(/* force flag */ 1); } } /* PAG garbage collection */ /* We induce a compile error if param.h does not define AFS_GCPAGS */ -afs_int32 afs_gcpags=AFS_GCPAGS; +afs_int32 afs_gcpags = AFS_GCPAGS; afs_int32 afs_gcpags_procsize = 0; afs_int32 afs_CheckServerDaemonStarted = 0; #ifdef DEFAULT_PROBE_INTERVAL -afs_int32 PROBE_INTERVAL=DEFAULT_PROBE_INTERVAL; /* overridding during compile */ +afs_int32 PROBE_INTERVAL = DEFAULT_PROBE_INTERVAL; /* overridding during compile */ #else -afs_int32 PROBE_INTERVAL=180; /* default to 3 min */ +afs_int32 PROBE_INTERVAL = 180; /* default to 3 min */ #endif #define PROBE_WAIT() (1000 * (PROBE_INTERVAL - ((afs_random() & 0x7fffffff) \ % (PROBE_INTERVAL/2)))) -void afs_CheckServerDaemon(void) +void +afs_CheckServerDaemon(void) { afs_int32 now, delay, lastCheck, last10MinCheck; afs_CheckServerDaemonStarted = 1; - while (afs_initState < 101) afs_osi_Sleep(&afs_initState); - afs_osi_Wait(PROBE_WAIT(), &AFS_CSWaitHandler, 0); - + while (afs_initState < 101) + afs_osi_Sleep(&afs_initState); + afs_osi_Wait(PROBE_WAIT(), &AFS_CSWaitHandler, 0); + last10MinCheck = lastCheck = osi_Time(); - while ( 1 ) { + while (1) { if (afs_termState == AFSOP_STOP_CS) { afs_termState = AFSOP_STOP_BKG; afs_osi_Wakeup(&afs_termState); @@ -73,7 +76,7 @@ void afs_CheckServerDaemon(void) now = osi_Time(); if (PROBE_INTERVAL + lastCheck <= now) { - afs_CheckServers(1, NULL); /* check down servers */ + afs_CheckServers(1, NULL); /* check down servers */ lastCheck = now = osi_Time(); } @@ -96,12 +99,13 @@ void afs_CheckServerDaemon(void) delay -= now; if (delay < 1) delay = 1; - afs_osi_Wait(delay * 1000, &AFS_CSWaitHandler, 0); + afs_osi_Wait(delay * 1000, &AFS_CSWaitHandler, 0); } afs_CheckServerDaemonStarted = 0; } -void afs_Daemon(void) +void +afs_Daemon(void) { afs_int32 code; struct afs_exporter *exporter; @@ -112,10 +116,12 @@ void afs_Daemon(void) char cs_warned = 0; AFS_STATCNT(afs_Daemon); - last1MinCheck = last3MinCheck = last60MinCheck = last10MinCheck = lastNMinCheck = 0; + last1MinCheck = last3MinCheck = last60MinCheck = last10MinCheck = + lastNMinCheck = 0; afs_rootFid.Fid.Volume = 0; - while (afs_initState < 101) afs_osi_Sleep(&afs_initState); + while (afs_initState < 101) + afs_osi_Sleep(&afs_initState); now = osi_Time(); lastCBSlotBump = now; @@ -123,22 +129,22 @@ void afs_Daemon(void) /* when a lot of clients are booted simultaneously, they develop * annoying synchronous VL server bashing behaviors. So we stagger them. */ - last1MinCheck = now + ((afs_random() & 0x7fffffff) % 60); /* an extra 30 */ + last1MinCheck = now + ((afs_random() & 0x7fffffff) % 60); /* an extra 30 */ last3MinCheck = now - 90 + ((afs_random() & 0x7fffffff) % 180); last60MinCheck = now - 1800 + ((afs_random() & 0x7fffffff) % 3600); last10MinCheck = now - 300 + ((afs_random() & 0x7fffffff) % 600); lastNMinCheck = now - 90 + ((afs_random() & 0x7fffffff) % 180); /* start off with afs_initState >= 101 (basic init done) */ - while(1) { - afs_CheckCallbacks(20); /* unstat anything which will expire soon */ - + while (1) { + afs_CheckCallbacks(20); /* unstat anything which will expire soon */ + /* things to do every 20 seconds or less - required by protocol spec */ - if (afs_nfsexporter) + if (afs_nfsexporter) afs_FlushActiveVcaches(0); /* flush NFS writes */ - afs_FlushVCBs(1); /* flush queued callbacks */ + afs_FlushVCBs(1); /* flush queued callbacks */ afs_MaybeWakeupTruncateDaemon(); /* free cache space if have too */ - rx_CheckPackets(); /* Does RX need more packets? */ + rx_CheckPackets(); /* Does RX need more packets? */ #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) /* * Hack: We always want to make sure there are plenty free @@ -146,37 +152,39 @@ void afs_Daemon(void) * worry about rx (with disabled interrupts) to have to call * malloc). So we do the dummy call below... */ - if (((afs_stats_cmperf.SmallBlocksAlloced - afs_stats_cmperf.SmallBlocksActive) + if (((afs_stats_cmperf.SmallBlocksAlloced - + afs_stats_cmperf.SmallBlocksActive) <= AFS_SALLOC_LOW_WATER)) osi_FreeSmallSpace(osi_AllocSmallSpace(AFS_SMALLOCSIZ)); - if (((afs_stats_cmperf.MediumBlocksAlloced - afs_stats_cmperf.MediumBlocksActive) - <= AFS_MALLOC_LOW_WATER+50)) - osi_AllocMoreMSpace(AFS_MALLOC_LOW_WATER * 2); + if (((afs_stats_cmperf.MediumBlocksAlloced - + afs_stats_cmperf.MediumBlocksActive) + <= AFS_MALLOC_LOW_WATER + 50)) + osi_AllocMoreMSpace(AFS_MALLOC_LOW_WATER * 2); #endif - + now = osi_Time(); - if (lastCBSlotBump + CBHTSLOTLEN < now) { /* pretty time-dependant */ + if (lastCBSlotBump + CBHTSLOTLEN < now) { /* pretty time-dependant */ lastCBSlotBump = now; if (afs_BumpBase()) { - afs_CheckCallbacks(20); /* unstat anything which will expire soon */ + afs_CheckCallbacks(20); /* unstat anything which will expire soon */ } } - + if (last1MinCheck + 60 < now) { /* things to do every minute */ - DFlush(); /* write out dir buffers */ + DFlush(); /* write out dir buffers */ afs_WriteThroughDSlots(); /* write through cacheinfo entries */ - afs_FlushActiveVcaches(1);/* keep flocks held & flush nfs writes */ + afs_FlushActiveVcaches(1); /* keep flocks held & flush nfs writes */ #ifdef AFS_DISCON_ENV afs_StoreDirtyVcaches(); #endif afs_CheckRXEpoch(); last1MinCheck = now; } - + if (last3MinCheck + 180 < now) { afs_CheckTokenCache(); /* check for access cache resets due to expired - tickets */ + * tickets */ last3MinCheck = now; } if (!afs_CheckServerDaemonStarted) { @@ -192,29 +200,29 @@ void afs_Daemon(void) } } if (last10MinCheck + 600 < now) { -#ifdef AFS_USERSPACE_IP_ADDR +#ifdef AFS_USERSPACE_IP_ADDR extern int rxi_GetcbiInfo(void); #endif - afs_Trace1(afs_iclSetp, CM_TRACE_PROBEUP, - ICL_TYPE_INT32, 600); -#ifdef AFS_USERSPACE_IP_ADDR - if (rxi_GetcbiInfo()) { /* addresses changed from last time */ + afs_Trace1(afs_iclSetp, CM_TRACE_PROBEUP, ICL_TYPE_INT32, 600); +#ifdef AFS_USERSPACE_IP_ADDR + if (rxi_GetcbiInfo()) { /* addresses changed from last time */ afs_FlushCBs(); } -#else /* AFS_USERSPACE_IP_ADDR */ - if (rxi_GetIFInfo()) { /* addresses changed from last time */ +#else /* AFS_USERSPACE_IP_ADDR */ + if (rxi_GetIFInfo()) { /* addresses changed from last time */ afs_FlushCBs(); } #endif /* else AFS_USERSPACE_IP_ADDR */ if (!afs_CheckServerDaemonStarted) afs_CheckServers(0, NULL); - afs_GCUserData(0); /* gc old conns */ + afs_GCUserData(0); /* gc old conns */ /* This is probably the wrong way of doing GC for the various exporters but it will suffice for a while */ - for (exporter = root_exported; exporter; exporter = exporter->exp_next) { - (void) EXP_GC(exporter, 0); /* Generalize params */ + for (exporter = root_exported; exporter; + exporter = exporter->exp_next) { + (void)EXP_GC(exporter, 0); /* Generalize params */ } { - static int cnt=0; + static int cnt = 0; if (++cnt < 12) { afs_CheckVolumeNames(AFS_VOLCHECK_EXPIRED | AFS_VOLCHECK_BUSY); @@ -228,12 +236,12 @@ void afs_Daemon(void) last10MinCheck = now; } if (last60MinCheck + 3600 < now) { - afs_Trace1(afs_iclSetp, CM_TRACE_PROBEVOLUME, - ICL_TYPE_INT32, 3600); + afs_Trace1(afs_iclSetp, CM_TRACE_PROBEVOLUME, ICL_TYPE_INT32, + 3600); afs_CheckRootVolume(); #if AFS_GCPAGS if (afs_gcpags == AFS_GCPAGS_OK) { - afs_int32 didany; + afs_int32 didany; afs_GCPAGs(&didany); } #endif @@ -241,11 +249,13 @@ void afs_Daemon(void) } if (afs_initState < 300) { /* while things ain't rosy */ code = afs_CheckRootVolume(); - if (code == 0) afs_initState = 300; /* succeeded */ - if (afs_initState < 200) afs_initState = 200; /* tried once */ + if (code == 0) + afs_initState = 300; /* succeeded */ + if (afs_initState < 200) + afs_initState = 200; /* tried once */ afs_osi_Wakeup(&afs_initState); } - + /* 18285 is because we're trying to divide evenly into 128, that is, * CBSlotLen, while staying just under 20 seconds. If CBSlotLen * changes, should probably change this interval, too. @@ -253,9 +263,9 @@ void afs_Daemon(void) * might not want to wait the entire interval */ now = 18285 - (osi_Time() - now); if (now > 0) { - afs_osi_Wait(now, &AFS_WaitHandler, 0); + afs_osi_Wait(now, &AFS_WaitHandler, 0); } - + if (afs_termState == AFSOP_STOP_AFS) { if (afs_CheckServerDaemonStarted) afs_termState = AFSOP_STOP_CS; @@ -267,7 +277,8 @@ void afs_Daemon(void) } } -int afs_CheckRootVolume (void) +int +afs_CheckRootVolume(void) { char rootVolName[32]; struct volume *tvp = NULL; @@ -308,7 +319,7 @@ int afs_CheckRootVolume (void) } if (tvp) { if (!usingDynroot) { - int volid = (tvp->roVol? tvp->roVol : tvp->volume); + int volid = (tvp->roVol ? tvp->roVol : tvp->volume); afs_rootFid.Cell = localcell; if (afs_rootFid.Fid.Volume && afs_rootFid.Fid.Volume != volid && afs_globalVp) { @@ -326,7 +337,7 @@ int afs_CheckRootVolume (void) afs_rootFid.Fid.Vnode = 1; afs_rootFid.Fid.Unique = 1; } - afs_initState = 300; /* won */ + afs_initState = 300; /* won */ afs_osi_Wakeup(&afs_initState); afs_PutVolume(tvp, READ_LOCK); } @@ -339,26 +350,29 @@ int afs_CheckRootVolume (void) int code; /* Only do this if afs_globalVFS is properly set due to race conditions - this routine could be called before the gfs_mount is performed! - Furthermore, afs_root (called below) *waits* until - initState >= 200, so we don't try this until we've gotten - at least that far */ + * this routine could be called before the gfs_mount is performed! + * Furthermore, afs_root (called below) *waits* until + * initState >= 200, so we don't try this until we've gotten + * at least that far */ if (afs_globalVFS && afs_initState >= 200) { if (code = afs_root(afs_globalVFS, &rootgp)) return code; - mp = (struct mount *) afs_globalVFS->vfs_data ; + mp = (struct mount *)afs_globalVFS->vfs_data; mp->m_rootgp = gget(mp, 0, 0, (char *)rootgp); afs_unlock(mp->m_rootgp); /* unlock basic gnode */ - afs_vrele(VTOAFS(rootgp)); /* zap afs_root's vnode hold */ + afs_vrele(VTOAFS(rootgp)); /* zap afs_root's vnode hold */ } } #endif - if (afs_rootFid.Fid.Volume) return 0; - else return ENOENT; + if (afs_rootFid.Fid.Volume) + return 0; + else + return ENOENT; } /* ptr_parm 0 is the pathname, size_parm 0 to the fetch is the chunk number */ -static void BPath(register struct brequest *ab) +static void +BPath(register struct brequest *ab) { register struct dcache *tdc = NULL; struct vcache *tvc = NULL; @@ -371,18 +385,20 @@ static void BPath(register struct brequest *ab) afs_int32 code; AFS_STATCNT(BPath); - if ((code = afs_InitReq(&treq, ab->cred))) return; + if ((code = afs_InitReq(&treq, ab->cred))) + return; AFS_GUNLOCK(); #ifdef AFS_LINUX22_ENV - code = gop_lookupname((char *)ab->ptr_parm[0], AFS_UIOSYS, 1, NULL, &dp); + code = gop_lookupname((char *)ab->ptr_parm[0], AFS_UIOSYS, 1, NULL, &dp); if (dp) - tvn = (struct vnode*)dp->d_inode; + tvn = (struct vnode *)dp->d_inode; #else - code = gop_lookupname((char *)ab->ptr_parm[0], AFS_UIOSYS, 1, NULL, &tvn); + code = gop_lookupname((char *)ab->ptr_parm[0], AFS_UIOSYS, 1, NULL, &tvn); #endif AFS_GLOCK(); - osi_FreeLargeSpace((char *)ab->ptr_parm[0]); /* free path name buffer here */ - if (code) return; + osi_FreeLargeSpace((char *)ab->ptr_parm[0]); /* free path name buffer here */ + if (code) + return; /* now path may not have been in afs, so check that before calling our cache manager */ if (!tvn || !IsAfsVnode(tvn)) { /* release it and give up */ @@ -424,7 +440,8 @@ static void BPath(register struct brequest *ab) * ptr_parm 0 is the dcache entry to wakeup, * size_parm 1 is true iff we should release the dcache entry here. */ -static void BPrefetch(register struct brequest *ab) +static void +BPrefetch(register struct brequest *ab) { register struct dcache *tdc; register struct vcache *tvc; @@ -432,7 +449,8 @@ static void BPrefetch(register struct brequest *ab) struct vrequest treq; AFS_STATCNT(BPrefetch); - if ((len = afs_InitReq(&treq, ab->cred))) return; + if ((len = afs_InitReq(&treq, ab->cred))) + return; tvc = ab->vc; tdc = afs_GetDCache(tvc, ab->size_parm[0], &treq, &offset, &len, 1); if (tdc) { @@ -442,7 +460,7 @@ static void BPrefetch(register struct brequest *ab) * use tdc from GetDCache since afs_GetDCache may fail, but someone may * be waiting for our wakeup anyway. */ - tdc = (struct dcache *) (ab->ptr_parm[0]); + tdc = (struct dcache *)(ab->ptr_parm[0]); ObtainSharedLock(&tdc->lock, 640); if (tdc->mflags & DFFetchReq) { UpgradeSToWLock(&tdc->lock, 641); @@ -458,7 +476,8 @@ static void BPrefetch(register struct brequest *ab) } -static void BStore(register struct brequest *ab) +static void +BStore(register struct brequest *ab) { register struct vcache *tvc; register afs_int32 code; @@ -468,7 +487,8 @@ static void BStore(register struct brequest *ab) #endif AFS_STATCNT(BStore); - if ((code = afs_InitReq(&treq, ab->cred))) return; + if ((code = afs_InitReq(&treq, ab->cred))) + return; code = 0; tvc = ab->vc; #if defined(AFS_SGI_ENV) @@ -485,18 +505,18 @@ static void BStore(register struct brequest *ab) * operations, we hold the VOP_RWLOCK across this transaction as * do the other callers of StoreOnLastReference */ - AFS_RWLOCK((vnode_t *)tvc, 1); + AFS_RWLOCK((vnode_t *) tvc, 1); #endif - ObtainWriteLock(&tvc->lock,209); + ObtainWriteLock(&tvc->lock, 209); code = afs_StoreOnLastReference(tvc, &treq); ReleaseWriteLock(&tvc->lock); #if defined(AFS_SGI_ENV) OSI_SET_CURRENT_CRED(tmpcred); - AFS_RWUNLOCK((vnode_t *)tvc, 1); + AFS_RWUNLOCK((vnode_t *) tvc, 1); #endif /* now set final return code, and wakeup anyone waiting */ if ((ab->flags & BUVALID) == 0) { - ab->code = afs_CheckCode(code, &treq, 43); /* set final code, since treq doesn't go across processes */ + ab->code = afs_CheckCode(code, &treq, 43); /* set final code, since treq doesn't go across processes */ ab->flags |= BUVALID; if (ab->flags & BUWAIT) { ab->flags &= ~BUWAIT; @@ -506,39 +526,45 @@ static void BStore(register struct brequest *ab) } /* release a held request buffer */ -void afs_BRelease(register struct brequest *ab) +void +afs_BRelease(register struct brequest *ab) { AFS_STATCNT(afs_BRelease); - MObtainWriteLock(&afs_xbrs,294); + MObtainWriteLock(&afs_xbrs, 294); if (--ab->refCount <= 0) { ab->flags = 0; } - if (afs_brsWaiters) afs_osi_Wakeup(&afs_brsWaiters); + if (afs_brsWaiters) + afs_osi_Wakeup(&afs_brsWaiters); MReleaseWriteLock(&afs_xbrs); } /* return true if bkg fetch daemons are all busy */ -int afs_BBusy(void) +int +afs_BBusy(void) { AFS_STATCNT(afs_BBusy); - if (afs_brsDaemons > 0) return 0; + if (afs_brsDaemons > 0) + return 0; return 1; } -struct brequest *afs_BQueue(register short aopcode, register struct vcache *avc, - afs_int32 dontwait, afs_int32 ause, struct AFS_UCRED *acred, - afs_size_t asparm0, afs_size_t asparm1, void *apparm0) +struct brequest * +afs_BQueue(register short aopcode, register struct vcache *avc, + afs_int32 dontwait, afs_int32 ause, struct AFS_UCRED *acred, + afs_size_t asparm0, afs_size_t asparm1, void *apparm0) { register int i; register struct brequest *tb; AFS_STATCNT(afs_BQueue); - MObtainWriteLock(&afs_xbrs,296); + MObtainWriteLock(&afs_xbrs, 296); while (1) { tb = afs_brs; - for(i=0;irefCount == 0) break; + for (i = 0; i < NBRS; i++, tb++) { + if (tb->refCount == 0) + break; } if (i < NBRS) { /* found a buffer */ @@ -557,10 +583,10 @@ struct brequest *afs_BQueue(register short aopcode, register struct vcache *avc, #endif #endif } - tb->refCount = ause+1; + tb->refCount = ause + 1; tb->size_parm[0] = asparm0; tb->size_parm[1] = asparm1; - tb->ptr_parm[0] = apparm0; + tb->ptr_parm[0] = apparm0; tb->flags = 0; tb->code = 0; tb->ts = afs_brs_count++; @@ -571,7 +597,7 @@ struct brequest *afs_BQueue(register short aopcode, register struct vcache *avc, MReleaseWriteLock(&afs_xbrs); return tb; } - if (dontwait) { + if (dontwait) { MReleaseWriteLock(&afs_xbrs); return NULL; } @@ -579,7 +605,7 @@ struct brequest *afs_BQueue(register short aopcode, register struct vcache *avc, afs_brsWaiters++; MReleaseWriteLock(&afs_xbrs); afs_osi_Sleep(&afs_brsWaiters); - MObtainWriteLock(&afs_xbrs,301); + MObtainWriteLock(&afs_xbrs, 301); afs_brsWaiters--; } } @@ -589,7 +615,7 @@ struct brequest *afs_BQueue(register short aopcode, register struct vcache *avc, /* AIX 4.1 has a much different sleep/wakeup mechanism available for use. * The modifications here will work for either a UP or MP machine. */ -struct buf *afs_asyncbuf = (struct buf*)0; +struct buf *afs_asyncbuf = (struct buf *)0; tid_t afs_asyncbuf_cv = EVENT_NULL; afs_int32 afs_biodcnt = 0; @@ -620,47 +646,48 @@ afs_int32 afs_biodcnt = 0; * process and interrupts. */ Simple_lock afs_asyncbuf_lock; -/*static*/ struct buf *afs_get_bioreq() +/*static*/ struct buf * +afs_get_bioreq() { struct buf *bp = NULL; struct buf *bestbp; struct buf **bestlbpP, **lbpP; long bestage, stop; - struct buf *t1P, *t2P; /* temp pointers for list manipulation */ + struct buf *t1P, *t2P; /* temp pointers for list manipulation */ int oldPriority; afs_uint32 wait_ret; struct afs_bioqueue *s; /* ??? Does the forward pointer of the returned buffer need to be NULL? - */ - + */ + /* Disable interrupts from the strategy function, and save the * prior priority level and lock access to the afs_asyncbuf. */ AFS_GUNLOCK(); - oldPriority = disable_lock(INTMAX, &afs_asyncbuf_lock) ; + oldPriority = disable_lock(INTMAX, &afs_asyncbuf_lock); - while(1) { + while (1) { if (afs_asyncbuf) { /* look for oldest buffer */ bp = bestbp = afs_asyncbuf; - bestage = (long) bestbp->av_back; + bestage = (long)bestbp->av_back; bestlbpP = &afs_asyncbuf; while (1) { lbpP = &bp->av_forw; bp = *lbpP; - if (!bp) break; - if ((long) bp->av_back - bestage < 0) { + if (!bp) + break; + if ((long)bp->av_back - bestage < 0) { bestbp = bp; bestlbpP = lbpP; - bestage = (long) bp->av_back; + bestage = (long)bp->av_back; } } bp = bestbp; *bestlbpP = bp->av_forw; break; - } - else { + } else { /* If afs_asyncbuf is null, it is necessary to go to sleep. * e_wakeup_one() ensures that only one thread wakes. */ @@ -668,20 +695,20 @@ Simple_lock afs_asyncbuf_lock; /* The LOCK_HANDLER indicates to e_sleep_thread to only drop the * lock on an MP machine. */ - interrupted = e_sleep_thread(&afs_asyncbuf_cv, - &afs_asyncbuf_lock, - LOCK_HANDLER|INTERRUPTIBLE); - if (interrupted==THREAD_INTERRUPTED) { + interrupted = + e_sleep_thread(&afs_asyncbuf_cv, &afs_asyncbuf_lock, + LOCK_HANDLER | INTERRUPTIBLE); + if (interrupted == THREAD_INTERRUPTED) { /* re-enable interrupts from strategy */ unlock_enable(oldPriority, &afs_asyncbuf_lock); AFS_GLOCK(); - return(NULL); + return (NULL); } - } /* end of "else asyncbuf is empty" */ - } /* end of "inner loop" */ - - /*assert (bp);*/ - + } /* end of "else asyncbuf is empty" */ + } /* end of "inner loop" */ + + /*assert (bp); */ + unlock_enable(oldPriority, &afs_asyncbuf_lock); AFS_GLOCK(); @@ -692,14 +719,14 @@ Simple_lock afs_asyncbuf_lock; * ??? what happens to the gnodes? They're not just cut loose, * are they? */ - for(t1P=bp;;) { - t2P = (struct buf *) t1P->b_work; - t1P->b_vp = ((struct gnode *) t1P->b_vp)->gn_vnode; - if (!t2P) + for (t1P = bp;;) { + t2P = (struct buf *)t1P->b_work; + t1P->b_vp = ((struct gnode *)t1P->b_vp)->gn_vnode; + if (!t2P) break; - t1P = (struct buf *) t2P->b_work; - t2P->b_vp = ((struct gnode *) t2P->b_vp)->gn_vnode; + t1P = (struct buf *)t2P->b_work; + t2P->b_vp = ((struct gnode *)t2P->b_vp)->gn_vnode; if (!t1P) break; } @@ -711,12 +738,12 @@ Simple_lock afs_asyncbuf_lock; * violation, rather than a request for I/O. The remainder * of the outer loop handles the case where the B_PFPROT bit is clear. */ - if (bp->b_flags & B_PFPROT) { + if (bp->b_flags & B_PFPROT) { return (bp); } return (bp); -} /* end of function get_bioreq() */ +} /* end of function get_bioreq() */ /* afs_BioDaemon @@ -728,13 +755,14 @@ Simple_lock afs_asyncbuf_lock; * each making the appropriate syscall, which will cause this * function to be invoked. */ -static int afs_initbiod = 0; /* this is self-initializing code */ +static int afs_initbiod = 0; /* this is self-initializing code */ int DOvmlock = 0; -int afs_BioDaemon (afs_int32 nbiods) +int +afs_BioDaemon(afs_int32 nbiods) { afs_int32 code, s, pflg = 0; label_t jmpbuf; - struct buf *bp, *bp1, *tbp1, *tbp2; /* temp pointers only */ + struct buf *bp, *bp1, *tbp1, *tbp2; /* temp pointers only */ caddr_t tmpaddr; struct vnode *vp; struct vcache *vcp; @@ -745,19 +773,19 @@ int afs_BioDaemon (afs_int32 nbiods) /* pin lock, since we'll be using it in an interrupt. */ lock_alloc(&afs_asyncbuf_lock, LOCK_ALLOC_PIN, 2, 1); simple_lock_init(&afs_asyncbuf_lock); - pin (&afs_asyncbuf, sizeof(struct buf*)); - pin (&afs_asyncbuf_cv, sizeof(afs_int32)); + pin(&afs_asyncbuf, sizeof(struct buf *)); + pin(&afs_asyncbuf_cv, sizeof(afs_int32)); } /* Ignore HUP signals... */ { - sigset_t sigbits, osigbits; - /* - * add SIGHUP to the set of already masked signals - */ - SIGFILLSET(sigbits); /* allow all signals */ - SIGDELSET(sigbits, SIGHUP); /* except SIGHUP */ - limit_sigs(&sigbits, &osigbits); /* and already masked */ + sigset_t sigbits, osigbits; + /* + * add SIGHUP to the set of already masked signals + */ + SIGFILLSET(sigbits); /* allow all signals */ + SIGDELSET(sigbits, SIGHUP); /* except SIGHUP */ + limit_sigs(&sigbits, &osigbits); /* and already masked */ } /* Main body starts here -- this is an intentional infinite loop, and * should NEVER exit @@ -768,14 +796,14 @@ int afs_BioDaemon (afs_int32 nbiods) while (1) { bp = afs_get_bioreq(); if (!bp) - break; /* we were interrupted */ + break; /* we were interrupted */ if (code = setjmpx(&jmpbuf)) { /* This should not have happend, maybe a lack of resources */ AFS_GUNLOCK(); s = disable_lock(INTMAX, &afs_asyncbuf_lock); - for (bp1 = bp; bp ; bp = bp1) { + for (bp1 = bp; bp; bp = bp1) { if (bp1) - bp1 = (struct buf *) bp1->b_work; + bp1 = (struct buf *)bp1->b_work; bp->b_actf = 0; bp->b_error = code; bp->b_flags |= B_ERROR; @@ -787,16 +815,16 @@ int afs_BioDaemon (afs_int32 nbiods) } vcp = VTOAFS(bp->b_vp); if (bp->b_flags & B_PFSTORE) { /* XXXX */ - ObtainWriteLock(&vcp->lock,404); + ObtainWriteLock(&vcp->lock, 404); if (vcp->v.v_gnode->gn_mwrcnt) { - afs_offs_t newlength = - (afs_offs_t) dbtob(bp->b_blkno) + bp->b_bcount; + afs_offs_t newlength = + (afs_offs_t) dbtob(bp->b_blkno) + bp->b_bcount; if (vcp->m.Length < newlength) { afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_LONG, __LINE__, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(vcp->m.Length), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(newlength)); + ICL_TYPE_STRING, __FILE__, ICL_TYPE_LONG, + __LINE__, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(vcp->m.Length), + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(newlength)); vcp->m.Length = newlength; } } @@ -805,13 +833,13 @@ int afs_BioDaemon (afs_int32 nbiods) /* If the buffer represents a protection violation, rather than * an actual request for I/O, no special action need be taken. */ - if ( bp->b_flags & B_PFPROT ) { - iodone (bp); /* Notify all users of the buffer that we're done */ + if (bp->b_flags & B_PFPROT) { + iodone(bp); /* Notify all users of the buffer that we're done */ clrjmpx(&jmpbuf); continue; - } -if (DOvmlock) - ObtainWriteLock(&vcp->pvmlock,211); + } + if (DOvmlock) + ObtainWriteLock(&vcp->pvmlock, 211); /* * First map its data area to a region in the current address space * by calling vm_att with the subspace identifier, and a pointer to @@ -819,10 +847,10 @@ if (DOvmlock) * also want to hang onto the old one. */ tmpaddr = bp->b_baddr; - bp->b_baddr = (caddr_t) vm_att (bp->b_xmemd.subspace_id, tmpaddr); + bp->b_baddr = (caddr_t) vm_att(bp->b_xmemd.subspace_id, tmpaddr); tmperr = afs_ustrategy(bp); /* temp variable saves offset calculation */ - if (tmperr) { /* in non-error case */ - bp->b_flags |= B_ERROR; /* should other flags remain set ??? */ + if (tmperr) { /* in non-error case */ + bp->b_flags |= B_ERROR; /* should other flags remain set ??? */ bp->b_error = tmperr; } @@ -839,22 +867,22 @@ if (DOvmlock) * using it by calling iodone. * assumes iodone can modify the b_work field. */ - for(tbp1=bp;;) { - tbp2 = (struct buf *) tbp1->b_work; + for (tbp1 = bp;;) { + tbp2 = (struct buf *)tbp1->b_work; iodone(tbp1); - if (!tbp2) + if (!tbp2) break; - tbp1 = (struct buf *) tbp2->b_work; + tbp1 = (struct buf *)tbp2->b_work; iodone(tbp2); if (!tbp1) break; } -if (DOvmlock) - ReleaseWriteLock(&vcp->pvmlock); /* Unlock the vnode. */ + if (DOvmlock) + ReleaseWriteLock(&vcp->pvmlock); /* Unlock the vnode. */ clrjmpx(&jmpbuf); - } /* infinite loop (unless we're interrupted) */ -} /* end of afs_BioDaemon() */ + } /* infinite loop (unless we're interrupted) */ +} /* end of afs_BioDaemon() */ #else /* AFS_AIX41_ENV */ @@ -904,167 +932,165 @@ afs_int32 afs_biodcnt = 0; * The list of sleepers is variable afs_bioqueue. The unique address * on which to sleep is passed to get_bioreq as its parameter. */ -/*static*/ struct buf *afs_get_bioreq(self) - struct afs_bioqueue *self; /* address on which to sleep */ +/*static*/ struct buf * +afs_get_bioreq(self) + struct afs_bioqueue *self; /* address on which to sleep */ { struct buf *bp = NULL; struct buf *bestbp; struct buf **bestlbpP, **lbpP; int bestage, stop; - struct buf *t1P, *t2P; /* temp pointers for list manipulation */ + struct buf *t1P, *t2P; /* temp pointers for list manipulation */ int oldPriority; afs_uint32 wait_ret; -struct afs_bioqueue *s; + struct afs_bioqueue *s; /* ??? Does the forward pointer of the returned buffer need to be NULL? - */ - - /* Disable interrupts from the strategy function, and save the - * prior priority level - */ - oldPriority = i_disable ( INTMAX ) ; + */ - /* Each iteration of following loop either pulls - * a buffer off afs_asyncbuf, or sleeps. - */ - while (1) { /* inner loop */ - if (afs_asyncbuf) { - /* look for oldest buffer */ - bp = bestbp = afs_asyncbuf; - bestage = (int) bestbp->av_back; - bestlbpP = &afs_asyncbuf; - while (1) { - lbpP = &bp->av_forw; - bp = *lbpP; - if (!bp) break; - if ((int) bp->av_back - bestage < 0) { - bestbp = bp; - bestlbpP = lbpP; - bestage = (int) bp->av_back; - } - } - bp = bestbp; - *bestlbpP = bp->av_forw; - break; - } - else { - int interrupted; - - /* If afs_asyncbuf is null, it is necessary to go to sleep. - * There are two possibilities: either there is already a - * daemon that is sleeping on the address of afs_asyncbuf, - * or there isn't. - */ - if (afs_bioqueue.sleeper) { - /* enqueue */ - QAdd (&(afs_bioqueue.lruq), &(self->lruq)); - interrupted = sleep ((caddr_t) self, PCATCH|(PZERO + 1)); - if (self->lruq.next != &self->lruq) { /* XXX ##3 XXX */ - QRemove (&(self->lruq)); /* dequeue */ - } -self->cnt++; - afs_bioqueue.sleeper = FALSE; - if (interrupted) { - /* re-enable interrupts from strategy */ - i_enable (oldPriority); - return(NULL); - } - continue; - } else { - afs_bioqueue.sleeper = TRUE; - interrupted = sleep ((caddr_t) &afs_asyncbuf, PCATCH|(PZERO + 1)); - afs_bioqueue.sleeper = FALSE; - if (interrupted) - { - /* - * We need to wakeup another daemon if present - * since we were waiting on afs_asyncbuf. - */ -#ifdef notdef /* The following doesn't work as advertised */ - if (afs_bioqueue.lruq.next != &afs_bioqueue.lruq) - { - struct squeue *bq = afs_bioqueue.lruq.next; - QRemove (bq); - wakeup (bq); - } -#endif - /* re-enable interrupts from strategy */ - i_enable (oldPriority); - return(NULL); - } - continue; - } - - } /* end of "else asyncbuf is empty" */ - } /* end of "inner loop" */ - - /*assert (bp);*/ - - i_enable (oldPriority); /* re-enable interrupts from strategy */ - - /* For the convenience of other code, replace the gnodes in - * the b_vp field of bp and the other buffers on the b_work - * chain with the corresponding vnodes. - * - * ??? what happens to the gnodes? They're not just cut loose, - * are they? - */ - for(t1P=bp;;) { - t2P = (struct buf *) t1P->b_work; - t1P->b_vp = ((struct gnode *) t1P->b_vp)->gn_vnode; - if (!t2P) - break; - - t1P = (struct buf *) t2P->b_work; - t2P->b_vp = ((struct gnode *) t2P->b_vp)->gn_vnode; - if (!t1P) - break; - } + /* Disable interrupts from the strategy function, and save the + * prior priority level + */ + oldPriority = i_disable(INTMAX); - /* If the buffer does not specify I/O, it may immediately - * be returned to the caller. This condition is detected - * by examining the buffer's flags (the b_flags field). If - * the B_PFPROT bit is set, the buffer represents a protection - * violation, rather than a request for I/O. The remainder - * of the outer loop handles the case where the B_PFPROT bit is clear. - */ - if (bp->b_flags & B_PFPROT) { - return (bp); + /* Each iteration of following loop either pulls + * a buffer off afs_asyncbuf, or sleeps. + */ + while (1) { /* inner loop */ + if (afs_asyncbuf) { + /* look for oldest buffer */ + bp = bestbp = afs_asyncbuf; + bestage = (int)bestbp->av_back; + bestlbpP = &afs_asyncbuf; + while (1) { + lbpP = &bp->av_forw; + bp = *lbpP; + if (!bp) + break; + if ((int)bp->av_back - bestage < 0) { + bestbp = bp; + bestlbpP = lbpP; + bestage = (int)bp->av_back; + } } + bp = bestbp; + *bestlbpP = bp->av_forw; + break; + } else { + int interrupted; - /* wake up another process to handle the next buffer, and return - * bp to the caller. - */ - oldPriority = i_disable ( INTMAX ) ; - - /* determine where to find the sleeping process. - * There are two cases: either it is sleeping on - * afs_asyncbuf, or it is sleeping on its own unique - * address. These cases are distinguished by examining - * the sleeper field of afs_bioqueue. - */ - if (afs_bioqueue.sleeper) { - wakeup (&afs_asyncbuf); + /* If afs_asyncbuf is null, it is necessary to go to sleep. + * There are two possibilities: either there is already a + * daemon that is sleeping on the address of afs_asyncbuf, + * or there isn't. + */ + if (afs_bioqueue.sleeper) { + /* enqueue */ + QAdd(&(afs_bioqueue.lruq), &(self->lruq)); + interrupted = sleep((caddr_t) self, PCATCH | (PZERO + 1)); + if (self->lruq.next != &self->lruq) { /* XXX ##3 XXX */ + QRemove(&(self->lruq)); /* dequeue */ + } + self->cnt++; + afs_bioqueue.sleeper = FALSE; + if (interrupted) { + /* re-enable interrupts from strategy */ + i_enable(oldPriority); + return (NULL); } - else { - if (afs_bioqueue.lruq.next == &afs_bioqueue.lruq) { - /* queue is empty, what now? ???*/ - /* Should this be impossible, or does */ - /* it just mean that nobody is sleeping? */; - } - else { + continue; + } else { + afs_bioqueue.sleeper = TRUE; + interrupted = + sleep((caddr_t) & afs_asyncbuf, PCATCH | (PZERO + 1)); + afs_bioqueue.sleeper = FALSE; + if (interrupted) { + /* + * We need to wakeup another daemon if present + * since we were waiting on afs_asyncbuf. + */ +#ifdef notdef /* The following doesn't work as advertised */ + if (afs_bioqueue.lruq.next != &afs_bioqueue.lruq) { struct squeue *bq = afs_bioqueue.lruq.next; - QRemove (bq); - QInit (bq); - wakeup (bq); - afs_bioqueue.sleeper = TRUE; - } + QRemove(bq); + wakeup(bq); + } +#endif + /* re-enable interrupts from strategy */ + i_enable(oldPriority); + return (NULL); } - i_enable (oldPriority); /* re-enable interrupts from strategy */ + continue; + } + + } /* end of "else asyncbuf is empty" */ + } /* end of "inner loop" */ + + /*assert (bp); */ + + i_enable(oldPriority); /* re-enable interrupts from strategy */ + + /* For the convenience of other code, replace the gnodes in + * the b_vp field of bp and the other buffers on the b_work + * chain with the corresponding vnodes. + * + * ??? what happens to the gnodes? They're not just cut loose, + * are they? + */ + for (t1P = bp;;) { + t2P = (struct buf *)t1P->b_work; + t1P->b_vp = ((struct gnode *)t1P->b_vp)->gn_vnode; + if (!t2P) + break; + + t1P = (struct buf *)t2P->b_work; + t2P->b_vp = ((struct gnode *)t2P->b_vp)->gn_vnode; + if (!t1P) + break; + } + + /* If the buffer does not specify I/O, it may immediately + * be returned to the caller. This condition is detected + * by examining the buffer's flags (the b_flags field). If + * the B_PFPROT bit is set, the buffer represents a protection + * violation, rather than a request for I/O. The remainder + * of the outer loop handles the case where the B_PFPROT bit is clear. + */ + if (bp->b_flags & B_PFPROT) { return (bp); + } -} /* end of function get_bioreq() */ + /* wake up another process to handle the next buffer, and return + * bp to the caller. + */ + oldPriority = i_disable(INTMAX); + + /* determine where to find the sleeping process. + * There are two cases: either it is sleeping on + * afs_asyncbuf, or it is sleeping on its own unique + * address. These cases are distinguished by examining + * the sleeper field of afs_bioqueue. + */ + if (afs_bioqueue.sleeper) { + wakeup(&afs_asyncbuf); + } else { + if (afs_bioqueue.lruq.next == &afs_bioqueue.lruq) { + /* queue is empty, what now? ??? */ + /* Should this be impossible, or does */ + /* it just mean that nobody is sleeping? */ ; + } else { + struct squeue *bq = afs_bioqueue.lruq.next; + QRemove(bq); + QInit(bq); + wakeup(bq); + afs_bioqueue.sleeper = TRUE; + } + } + i_enable(oldPriority); /* re-enable interrupts from strategy */ + return (bp); + +} /* end of function get_bioreq() */ /* afs_BioDaemon @@ -1076,15 +1102,15 @@ self->cnt++; * each making the appropriate syscall, which will cause this * function to be invoked. */ -static int afs_initbiod = 0; /* this is self-initializing code */ +static int afs_initbiod = 0; /* this is self-initializing code */ int DOvmlock = 0; -afs_BioDaemon (nbiods) - afs_int32 nbiods; +afs_BioDaemon(nbiods) + afs_int32 nbiods; { struct afs_bioqueue *self; afs_int32 code, s, pflg = 0; label_t jmpbuf; - struct buf *bp, *bp1, *tbp1, *tbp2; /* temp pointers only */ + struct buf *bp, *bp1, *tbp1, *tbp2; /* temp pointers only */ caddr_t tmpaddr; struct vnode *vp; struct vcache *vcp; @@ -1093,17 +1119,17 @@ afs_BioDaemon (nbiods) /* XXX ###1 XXX */ afs_initbiod = 1; /* Initialize the queue of waiting processes, afs_bioqueue. */ - QInit (&(afs_bioqueue.lruq)); + QInit(&(afs_bioqueue.lruq)); } /* establish ourself as a kernel process so shutdown won't kill us */ /* u.u_procp->p_flag |= SKPROC;*/ /* Initialize a token (self) to use in the queue of sleeping processes. */ - self = (struct afs_bioqueue *) afs_osi_Alloc (sizeof (struct afs_bioqueue)); - pin (self, sizeof (struct afs_bioqueue)); /* fix in memory */ + self = (struct afs_bioqueue *)afs_osi_Alloc(sizeof(struct afs_bioqueue)); + pin(self, sizeof(struct afs_bioqueue)); /* fix in memory */ memset(self, 0, sizeof(*self)); - QInit (&(self->lruq)); /* initialize queue entry pointers */ + QInit(&(self->lruq)); /* initialize queue entry pointers */ /* Ignore HUP signals... */ @@ -1119,11 +1145,11 @@ afs_BioDaemon (nbiods) while (1) { bp = afs_get_bioreq(self); if (!bp) - break; /* we were interrupted */ + break; /* we were interrupted */ if (code = setjmpx(&jmpbuf)) { /* This should not have happend, maybe a lack of resources */ s = splimp(); - for (bp1 = bp; bp ; bp = bp1) { + for (bp1 = bp; bp; bp = bp1) { if (bp1) bp1 = bp1->b_work; bp->b_actf = 0; @@ -1136,16 +1162,16 @@ afs_BioDaemon (nbiods) } vcp = VTOAFS(bp->b_vp); if (bp->b_flags & B_PFSTORE) { - ObtainWriteLock(&vcp->lock,210); + ObtainWriteLock(&vcp->lock, 210); if (vcp->v.v_gnode->gn_mwrcnt) { - afs_offs_t newlength = - (afs_offs_t) dbtob(bp->b_blkno) + bp->b_bcount; + afs_offs_t newlength = + (afs_offs_t) dbtob(bp->b_blkno) + bp->b_bcount; if (vcp->m.Length < newlength) { afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_LONG, __LINE__, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(vcp->m.Length), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(newlength)); + ICL_TYPE_STRING, __FILE__, ICL_TYPE_LONG, + __LINE__, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(vcp->m.Length), + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(newlength)); vcp->m.Length = newlength; } } @@ -1154,12 +1180,12 @@ afs_BioDaemon (nbiods) /* If the buffer represents a protection violation, rather than * an actual request for I/O, no special action need be taken. */ - if ( bp->b_flags & B_PFPROT ) { - iodone (bp); /* Notify all users of the buffer that we're done */ + if (bp->b_flags & B_PFPROT) { + iodone(bp); /* Notify all users of the buffer that we're done */ continue; - } -if (DOvmlock) - ObtainWriteLock(&vcp->pvmlock,558); + } + if (DOvmlock) + ObtainWriteLock(&vcp->pvmlock, 558); /* * First map its data area to a region in the current address space * by calling vm_att with the subspace identifier, and a pointer to @@ -1167,10 +1193,10 @@ if (DOvmlock) * also want to hang onto the old one. */ tmpaddr = bp->b_baddr; - bp->b_baddr = vm_att (bp->b_xmemd.subspace_id, tmpaddr); + bp->b_baddr = vm_att(bp->b_xmemd.subspace_id, tmpaddr); tmperr = afs_ustrategy(bp); /* temp variable saves offset calculation */ - if (tmperr) { /* in non-error case */ - bp->b_flags |= B_ERROR; /* should other flags remain set ??? */ + if (tmperr) { /* in non-error case */ + bp->b_flags |= B_ERROR; /* should other flags remain set ??? */ bp->b_error = tmperr; } @@ -1187,30 +1213,31 @@ if (DOvmlock) * using it by calling iodone. * assumes iodone can modify the b_work field. */ - for(tbp1=bp;;) { - tbp2 = (struct buf *) tbp1->b_work; + for (tbp1 = bp;;) { + tbp2 = (struct buf *)tbp1->b_work; iodone(tbp1); - if (!tbp2) + if (!tbp2) break; - tbp1 = (struct buf *) tbp2->b_work; + tbp1 = (struct buf *)tbp2->b_work; iodone(tbp2); if (!tbp1) break; } -if (DOvmlock) - ReleaseWriteLock(&vcp->pvmlock); /* Unlock the vnode. */ + if (DOvmlock) + ReleaseWriteLock(&vcp->pvmlock); /* Unlock the vnode. */ clrjmpx(&jmpbuf); - } /* infinite loop (unless we're interrupted) */ - unpin (self, sizeof (struct afs_bioqueue)); - afs_osi_Free (self, sizeof (struct afs_bioqueue)); -} /* end of afs_BioDaemon() */ -#endif /* AFS_AIX41_ENV */ + } /* infinite loop (unless we're interrupted) */ + unpin(self, sizeof(struct afs_bioqueue)); + afs_osi_Free(self, sizeof(struct afs_bioqueue)); +} /* end of afs_BioDaemon() */ +#endif /* AFS_AIX41_ENV */ #endif /* AFS_AIX32_ENV */ int afs_nbrs = 0; -void afs_BackgroundDaemon(void) +void +afs_BackgroundDaemon(void) { struct brequest *tb; int i, foundAny; @@ -1222,18 +1249,18 @@ void afs_BackgroundDaemon(void) memset((char *)afs_brs, 0, sizeof(afs_brs)); brsInit = 1; #if defined (AFS_SGI_ENV) && defined(AFS_SGI_SHORTSTACK) - /* - * steal the first daemon for doing delayed DSlot flushing - * (see afs_GetDownDSlot) - */ + /* + * steal the first daemon for doing delayed DSlot flushing + * (see afs_GetDownDSlot) + */ AFS_GUNLOCK(); - afs_sgidaemon(); - return; + afs_sgidaemon(); + return; #endif } afs_nbrs++; - MObtainWriteLock(&afs_xbrs,302); + MObtainWriteLock(&afs_xbrs, 302); while (1) { int min_ts = 0; struct brequest *min_tb = NULL; @@ -1249,7 +1276,7 @@ void afs_BackgroundDaemon(void) /* find a request */ tb = afs_brs; foundAny = 0; - for(i=0; irefCount > 0) && !(tb->flags & BSTARTED)) { /* new request, not yet picked up */ @@ -1264,18 +1291,19 @@ void afs_BackgroundDaemon(void) tb->flags |= BSTARTED; MReleaseWriteLock(&afs_xbrs); foundAny = 1; - afs_Trace1(afs_iclSetp, CM_TRACE_BKG1, - ICL_TYPE_INT32, tb->opcode); + afs_Trace1(afs_iclSetp, CM_TRACE_BKG1, ICL_TYPE_INT32, + tb->opcode); if (tb->opcode == BOP_FETCH) BPrefetch(tb); else if (tb->opcode == BOP_STORE) BStore(tb); else if (tb->opcode == BOP_PATH) BPath(tb); - else panic("background bop"); + else + panic("background bop"); if (tb->vc) { #ifdef AFS_DEC_ENV - tb->vc->vrefCount--; /* fix up reference count */ + tb->vc->vrefCount--; /* fix up reference count */ #else AFS_RELE(AFSTOV(tb->vc)); /* MUST call vnode layer or could lose vnodes */ #endif @@ -1283,45 +1311,46 @@ void afs_BackgroundDaemon(void) } if (tb->cred) { crfree(tb->cred); - tb->cred = (struct AFS_UCRED *) 0; + tb->cred = (struct AFS_UCRED *)0; } - afs_BRelease(tb); /* this grabs and releases afs_xbrs lock */ - MObtainWriteLock(&afs_xbrs,305); + afs_BRelease(tb); /* this grabs and releases afs_xbrs lock */ + MObtainWriteLock(&afs_xbrs, 305); } if (!foundAny) { /* wait for new request */ afs_brsDaemons++; MReleaseWriteLock(&afs_xbrs); afs_osi_Sleep(&afs_brsDaemons); - MObtainWriteLock(&afs_xbrs,307); + MObtainWriteLock(&afs_xbrs, 307); afs_brsDaemons--; } } } -void shutdown_daemons(void) +void +shutdown_daemons(void) { - AFS_STATCNT(shutdown_daemons); - if (afs_cold_shutdown) { - afs_brsDaemons = brsInit = 0; - rxepoch_checked = afs_nbrs = 0; - memset((char *)afs_brs, 0, sizeof(afs_brs)); - memset((char *)&afs_xbrs, 0, sizeof(afs_lock_t)); - afs_brsWaiters = 0; + AFS_STATCNT(shutdown_daemons); + if (afs_cold_shutdown) { + afs_brsDaemons = brsInit = 0; + rxepoch_checked = afs_nbrs = 0; + memset((char *)afs_brs, 0, sizeof(afs_brs)); + memset((char *)&afs_xbrs, 0, sizeof(afs_lock_t)); + afs_brsWaiters = 0; #ifdef AFS_AIX32_ENV #ifdef AFS_AIX41_ENV - lock_free(&afs_asyncbuf_lock); - unpin(&afs_asyncbuf, sizeof(struct buf*)); - pin (&afs_asyncbuf_cv, sizeof(afs_int32)); + lock_free(&afs_asyncbuf_lock); + unpin(&afs_asyncbuf, sizeof(struct buf *)); + pin(&afs_asyncbuf_cv, sizeof(afs_int32)); #else /* AFS_AIX41_ENV */ - afs_busyq = NULL; - afs_biodcnt = 0; - memset((char *)&afs_bioqueue, 0, sizeof(struct afs_bioqueue)); + afs_busyq = NULL; + afs_biodcnt = 0; + memset((char *)&afs_bioqueue, 0, sizeof(struct afs_bioqueue)); #endif - afs_initbiod = 0; + afs_initbiod = 0; #endif - } + } } #if defined(AFS_SGI_ENV) && defined(AFS_SGI_SHORTSTACK) @@ -1338,38 +1367,38 @@ SV_TYPE afs_sgibkwait; lock_t afs_sgibklock; struct dcache *afs_sgibklist; -int afs_sgidaemon(void) +int +afs_sgidaemon(void) { - int s; - struct dcache *tdc; + int s; + struct dcache *tdc; - if (afs_sgibklock == NULL) { - SV_INIT(&afs_sgibksync, "bksync", 0, 0); - SV_INIT(&afs_sgibkwait, "bkwait", 0, 0); - SPINLOCK_INIT(&afs_sgibklock, "bklock"); - } - s = SPLOCK(afs_sgibklock); - for (;;) { - /* wait for something to do */ - SP_WAIT(afs_sgibklock, s, &afs_sgibksync, PINOD); - osi_Assert(afs_sgibklist); - - /* XX will probably need to generalize to real list someday */ - s = SPLOCK(afs_sgibklock); - while (afs_sgibklist) { - tdc = afs_sgibklist; - afs_sgibklist = NULL; - SPUNLOCK(afs_sgibklock, s); - AFS_GLOCK(); - tdc->dflags &= ~DFEntryMod; - afs_WriteDCache(tdc, 1); - AFS_GUNLOCK(); - s = SPLOCK(afs_sgibklock); - } + if (afs_sgibklock == NULL) { + SV_INIT(&afs_sgibksync, "bksync", 0, 0); + SV_INIT(&afs_sgibkwait, "bkwait", 0, 0); + SPINLOCK_INIT(&afs_sgibklock, "bklock"); + } + s = SPLOCK(afs_sgibklock); + for (;;) { + /* wait for something to do */ + SP_WAIT(afs_sgibklock, s, &afs_sgibksync, PINOD); + osi_Assert(afs_sgibklist); - /* done all the work - wake everyone up */ - while (SV_SIGNAL(&afs_sgibkwait)) - ; + /* XX will probably need to generalize to real list someday */ + s = SPLOCK(afs_sgibklock); + while (afs_sgibklist) { + tdc = afs_sgibklist; + afs_sgibklist = NULL; + SPUNLOCK(afs_sgibklock, s); + AFS_GLOCK(); + tdc->dflags &= ~DFEntryMod; + afs_WriteDCache(tdc, 1); + AFS_GUNLOCK(); + s = SPLOCK(afs_sgibklock); } + + /* done all the work - wake everyone up */ + while (SV_SIGNAL(&afs_sgibkwait)); + } } #endif diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 53ae1b38c..d0323ce1c 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -13,11 +13,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /*Standard vendor system headers*/ -#include "afsincludes.h" /*AFS-based standard headers*/ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/sysincludes.h" /*Standard vendor system headers */ +#include "afsincludes.h" /*AFS-based standard headers */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/afs_osidnlc.h" @@ -30,45 +31,45 @@ static void afs_FreeDCache(struct dcache *); /* * --------------------- Exported definitions --------------------- */ -afs_lock_t afs_xdcache; /*Lock: alloc new disk cache entries*/ -afs_int32 afs_freeDCList; /*Free list for disk cache entries*/ -afs_int32 afs_freeDCCount; /*Count of elts in freeDCList*/ -afs_int32 afs_discardDCList; /*Discarded disk cache entries*/ -afs_int32 afs_discardDCCount; /*Count of elts in discardDCList*/ -struct dcache *afs_freeDSList; /*Free list for disk slots */ -struct dcache *afs_Initial_freeDSList; /*Initial list for above*/ -ino_t cacheInode; /*Inode for CacheItems file*/ +afs_lock_t afs_xdcache; /*Lock: alloc new disk cache entries */ +afs_int32 afs_freeDCList; /*Free list for disk cache entries */ +afs_int32 afs_freeDCCount; /*Count of elts in freeDCList */ +afs_int32 afs_discardDCList; /*Discarded disk cache entries */ +afs_int32 afs_discardDCCount; /*Count of elts in discardDCList */ +struct dcache *afs_freeDSList; /*Free list for disk slots */ +struct dcache *afs_Initial_freeDSList; /*Initial list for above */ +ino_t cacheInode; /*Inode for CacheItems file */ struct osi_file *afs_cacheInodep = 0; /* file for CacheItems inode */ -struct afs_q afs_DLRU; /*dcache LRU*/ +struct afs_q afs_DLRU; /*dcache LRU */ afs_int32 afs_dhashsize = 1024; -afs_int32 *afs_dvhashTbl; /*Data cache hash table*/ -afs_int32 *afs_dchashTbl; /*Data cache hash table*/ -afs_int32 *afs_dvnextTbl; /*Dcache hash table links */ -afs_int32 *afs_dcnextTbl; /*Dcache hash table links */ -struct dcache **afs_indexTable; /*Pointers to dcache entries*/ -afs_hyper_t *afs_indexTimes; /*Dcache entry Access times*/ -afs_int32 *afs_indexUnique; /*dcache entry Fid.Unique */ -unsigned char *afs_indexFlags; /*(only one) Is there data there?*/ -afs_hyper_t afs_indexCounter; /*Fake time for marking index - entries*/ -afs_int32 afs_cacheFiles =0; /*Size of afs_indexTable*/ -afs_int32 afs_cacheBlocks; /*1K blocks in cache*/ -afs_int32 afs_cacheStats; /*Stat entries in cache*/ -afs_int32 afs_blocksUsed; /*Number of blocks in use*/ -afs_int32 afs_blocksDiscarded; /*Blocks freed but not truncated */ -afs_int32 afs_fsfragsize = 1023; /*Underlying Filesystem minimum unit +afs_int32 *afs_dvhashTbl; /*Data cache hash table */ +afs_int32 *afs_dchashTbl; /*Data cache hash table */ +afs_int32 *afs_dvnextTbl; /*Dcache hash table links */ +afs_int32 *afs_dcnextTbl; /*Dcache hash table links */ +struct dcache **afs_indexTable; /*Pointers to dcache entries */ +afs_hyper_t *afs_indexTimes; /*Dcache entry Access times */ +afs_int32 *afs_indexUnique; /*dcache entry Fid.Unique */ +unsigned char *afs_indexFlags; /*(only one) Is there data there? */ +afs_hyper_t afs_indexCounter; /*Fake time for marking index + * entries */ +afs_int32 afs_cacheFiles = 0; /*Size of afs_indexTable */ +afs_int32 afs_cacheBlocks; /*1K blocks in cache */ +afs_int32 afs_cacheStats; /*Stat entries in cache */ +afs_int32 afs_blocksUsed; /*Number of blocks in use */ +afs_int32 afs_blocksDiscarded; /*Blocks freed but not truncated */ +afs_int32 afs_fsfragsize = 1023; /*Underlying Filesystem minimum unit *of disk allocation usually 1K *this value is (truefrag -1 ) to *save a bunch of subtracts... */ #ifdef AFS_64BIT_CLIENT #ifdef AFS_VM_RDWR_ENV -afs_size_t afs_vmMappingEnd; /* for large files (>= 2GB) the VM - * mapping an 32bit addressing machines - * can only be used below the 2 GB - * line. From this point upwards we - * must do direct I/O into the cache - * files. The value should be on a - * chunk boundary. */ +afs_size_t afs_vmMappingEnd; /* for large files (>= 2GB) the VM + * mapping an 32bit addressing machines + * can only be used below the 2 GB + * line. From this point upwards we + * must do direct I/O into the cache + * files. The value should be on a + * chunk boundary. */ #endif /* AFS_VM_RDWR_ENV */ #endif /* AFS_64BIT_CLIENT */ @@ -79,7 +80,7 @@ int afs_WaitForCacheDrain = 0; int afs_TruncateDaemonRunning = 0; int afs_CacheTooFull = 0; -afs_int32 afs_dcentries; /* In-memory dcache entries */ +afs_int32 afs_dcentries; /* In-memory dcache entries */ int dcacheDisabled = 0; @@ -115,7 +116,7 @@ struct afs_cacheOps afs_MemCacheOps = { afs_MemHandleLink, }; -int cacheDiskType; /*Type of backing disk for cache*/ +int cacheDiskType; /*Type of backing disk for cache */ struct afs_cacheOps *afs_cacheType; @@ -138,70 +139,70 @@ struct afs_cacheOps *afs_cacheType; * Call this from close call when vnodeops is RCS unlocked. */ -void afs_StoreWarn(register afs_int32 acode, afs_int32 avolume, register afs_int32 aflags) +void +afs_StoreWarn(register afs_int32 acode, afs_int32 avolume, + register afs_int32 aflags) { static char problem_fmt[] = "afs: failed to store file in volume %d (%s)\n"; static char problem_fmt_w_error[] = "afs: failed to store file in volume %d (error %d)\n"; static char netproblems[] = "network problems"; - static char partfull[] = "partition full"; - static char overquota[] = "over quota"; + static char partfull[] = "partition full"; + static char overquota[] = "over quota"; AFS_STATCNT(afs_StoreWarn); if (acode < 0) { - /* + /* * Network problems */ - if (aflags & 1) + if (aflags & 1) afs_warn(problem_fmt, avolume, netproblems); - if (aflags & 2) + if (aflags & 2) afs_warnuser(problem_fmt, avolume, netproblems); - } - else - if (acode == ENOSPC) { - /* - * Partition full - */ - if (aflags & 1) - afs_warn(problem_fmt, avolume, partfull); - if (aflags & 2) - afs_warnuser(problem_fmt, avolume, partfull); - } - else + } else if (acode == ENOSPC) { + /* + * Partition full + */ + if (aflags & 1) + afs_warn(problem_fmt, avolume, partfull); + if (aflags & 2) + afs_warnuser(problem_fmt, avolume, partfull); + } else #ifdef EDQUOT - /* EDQUOT doesn't exist on solaris and won't be sent by the server. - * Instead ENOSPC will be sent... - */ - if (acode == EDQUOT) { - /* - * Quota exceeded - */ - if (aflags & 1) - afs_warn(problem_fmt, avolume, overquota); - if (aflags & 2) - afs_warnuser(problem_fmt, avolume, overquota); - } else + /* EDQUOT doesn't exist on solaris and won't be sent by the server. + * Instead ENOSPC will be sent... + */ + if (acode == EDQUOT) { + /* + * Quota exceeded + */ + if (aflags & 1) + afs_warn(problem_fmt, avolume, overquota); + if (aflags & 2) + afs_warnuser(problem_fmt, avolume, overquota); + } else #endif - { - /* - * Unknown error - */ - if (aflags & 1) - afs_warn(problem_fmt_w_error, avolume, acode); - if (aflags & 2) - afs_warnuser(problem_fmt_w_error, avolume, acode); - } -} /*afs_StoreWarn*/ + { + /* + * Unknown error + */ + if (aflags & 1) + afs_warn(problem_fmt_w_error, avolume, acode); + if (aflags & 2) + afs_warnuser(problem_fmt_w_error, avolume, acode); + } +} /*afs_StoreWarn */ -void afs_MaybeWakeupTruncateDaemon(void) +void +afs_MaybeWakeupTruncateDaemon(void) { if (!afs_CacheTooFull && afs_CacheIsTooFull()) { afs_CacheTooFull = 1; if (!afs_TruncateDaemonRunning) afs_osi_Wakeup((int *)afs_CacheTruncateDaemon); - } else if (!afs_TruncateDaemonRunning && - afs_blocksDiscarded > CM_MAXDISCARDEDCHUNKS) { + } else if (!afs_TruncateDaemonRunning + && afs_blocksDiscarded > CM_MAXDISCARDEDCHUNKS) { afs_osi_Wakeup((int *)afs_CacheTruncateDaemon); } } @@ -218,27 +219,33 @@ static struct CTD_stats { } CTD_stats; u_int afs_min_cache = 0; -void afs_CacheTruncateDaemon(void) +void +afs_CacheTruncateDaemon(void) { osi_timeval_t CTD_tmpTime; u_int counter; u_int cb_lowat; - u_int dc_hiwat = (100-CM_DCACHECOUNTFREEPCT+CM_DCACHEEXTRAPCT)*afs_cacheFiles/100; - afs_min_cache = (((10 * AFS_CHUNKSIZE(0)) + afs_fsfragsize) & ~afs_fsfragsize)>>10; + u_int dc_hiwat = + (100 - CM_DCACHECOUNTFREEPCT + + CM_DCACHEEXTRAPCT) * afs_cacheFiles / 100; + afs_min_cache = + (((10 * AFS_CHUNKSIZE(0)) + afs_fsfragsize) & ~afs_fsfragsize) >> 10; osi_GetuTime(&CTD_stats.CTD_afterSleep); afs_TruncateDaemonRunning = 1; while (1) { - cb_lowat = ((CM_DCACHESPACEFREEPCT-CM_DCACHEEXTRAPCT) - * afs_cacheBlocks) / 100; - MObtainWriteLock(&afs_xdcache,266); + cb_lowat = ((CM_DCACHESPACEFREEPCT - CM_DCACHEEXTRAPCT) + * afs_cacheBlocks) / 100; + MObtainWriteLock(&afs_xdcache, 266); if (afs_CacheTooFull) { - int space_needed, slots_needed; + int space_needed, slots_needed; /* if we get woken up, we should try to clean something out */ for (counter = 0; counter < 10; counter++) { - space_needed = afs_blocksUsed - afs_blocksDiscarded - cb_lowat; - slots_needed = dc_hiwat - afs_freeDCCount - afs_discardDCCount; - afs_GetDownD(slots_needed, &space_needed); + space_needed = + afs_blocksUsed - afs_blocksDiscarded - cb_lowat; + slots_needed = + dc_hiwat - afs_freeDCCount - afs_discardDCCount; + afs_GetDownD(slots_needed, &space_needed); if ((space_needed <= 0) && (slots_needed <= 0)) { break; } @@ -257,26 +264,24 @@ void afs_CacheTruncateDaemon(void) * any cache files then give up the global lock so other * threads get a chance to run. */ - if ((afs_termState!=AFSOP_STOP_TRUNCDAEMON) && afs_CacheTooFull && - (!afs_blocksDiscarded || afs_WaitForCacheDrain)) { - afs_osi_Wait(100, 0, 0); /* 100 milliseconds */ + if ((afs_termState != AFSOP_STOP_TRUNCDAEMON) && afs_CacheTooFull + && (!afs_blocksDiscarded || afs_WaitForCacheDrain)) { + afs_osi_Wait(100, 0, 0); /* 100 milliseconds */ } /* * This is where we free the discarded cache elements. */ - while(afs_blocksDiscarded && !afs_WaitForCacheDrain && - (afs_termState!=AFSOP_STOP_TRUNCDAEMON)) - { + while (afs_blocksDiscarded && !afs_WaitForCacheDrain + && (afs_termState != AFSOP_STOP_TRUNCDAEMON)) { afs_FreeDiscardedDCache(); } /* See if we need to continue to run. Someone may have * signalled us while we were executing. */ - if (!afs_WaitForCacheDrain && !afs_CacheTooFull && - (afs_termState!=AFSOP_STOP_TRUNCDAEMON)) - { + if (!afs_WaitForCacheDrain && !afs_CacheTooFull + && (afs_termState != AFSOP_STOP_TRUNCDAEMON)) { /* Collect statistics on truncate daemon. */ CTD_stats.CTD_nSleeps++; osi_GetuTime(&CTD_stats.CTD_beforeSleep); @@ -285,7 +290,7 @@ void afs_CacheTruncateDaemon(void) afs_stats_AddTo(CTD_stats.CTD_runTime, CTD_tmpTime); afs_TruncateDaemonRunning = 0; - afs_osi_Sleep((int *)afs_CacheTruncateDaemon); + afs_osi_Sleep((int *)afs_CacheTruncateDaemon); afs_TruncateDaemonRunning = 1; osi_GetuTime(&CTD_stats.CTD_afterSleep); @@ -322,18 +327,19 @@ void afs_CacheTruncateDaemon(void) * anewsize : New size desired. */ -void afs_AdjustSize(register struct dcache *adc, register afs_int32 newSize) +void +afs_AdjustSize(register struct dcache *adc, register afs_int32 newSize) { register afs_int32 oldSize; AFS_STATCNT(afs_AdjustSize); adc->dflags |= DFEntryMod; - oldSize = ((adc->f.chunkBytes + afs_fsfragsize)^afs_fsfragsize)>>10;/* round up */ + oldSize = ((adc->f.chunkBytes + afs_fsfragsize) ^ afs_fsfragsize) >> 10; /* round up */ adc->f.chunkBytes = newSize; if (!newSize) adc->validPos = 0; - newSize = ((newSize + afs_fsfragsize)^afs_fsfragsize)>>10;/* round up */ + newSize = ((newSize + afs_fsfragsize) ^ afs_fsfragsize) >> 10; /* round up */ if (newSize > oldSize) { /* We're growing the file, wakeup the daemon */ afs_MaybeWakeupTruncateDaemon(); @@ -369,7 +375,8 @@ void afs_AdjustSize(register struct dcache *adc, register afs_int32 newSize) */ #define MAXATONCE 16 /* max we can obtain at once */ -static void afs_GetDownD(int anumber, int *aneedSpace) +static void +afs_GetDownD(int anumber, int *aneedSpace) { struct dcache *tdc; @@ -380,10 +387,10 @@ static void afs_GetDownD(int anumber, int *aneedSpace) register struct vcache *tvc; afs_uint32 victims[MAXATONCE]; struct dcache *victimDCs[MAXATONCE]; - afs_hyper_t victimTimes[MAXATONCE];/* youngest (largest LRU time) first */ - afs_uint32 victimPtr; /* next free item in victim arrays */ - afs_hyper_t maxVictimTime; /* youngest (largest LRU time) victim */ - afs_uint32 maxVictimPtr; /* where it is */ + afs_hyper_t victimTimes[MAXATONCE]; /* youngest (largest LRU time) first */ + afs_uint32 victimPtr; /* next free item in victim arrays */ + afs_hyper_t maxVictimTime; /* youngest (largest LRU time) victim */ + afs_uint32 maxVictimPtr; /* where it is */ int discard; AFS_STATCNT(afs_GetDownD); @@ -394,11 +401,12 @@ static void afs_GetDownD(int anumber, int *aneedSpace) * because we should try to free space even if anumber <=0 */ if (!aneedSpace || *aneedSpace <= 0) { anumber -= afs_freeDCCount; - if (anumber <= 0) return; /* enough already free */ + if (anumber <= 0) + return; /* enough already free */ } /* bounds check parameter */ - if (anumber > MAXATONCE) - anumber = MAXATONCE; /* all we can do */ + if (anumber > MAXATONCE) + anumber = MAXATONCE; /* all we can do */ /* * The phase variable manages reclaims. Set to 0, the first pass, @@ -410,25 +418,26 @@ static void afs_GetDownD(int anumber, int *aneedSpace) /* turn off all flags */ afs_indexFlags[i] &= ~IFFlag; - while (anumber > 0 || (aneedSpace && *aneedSpace >0)) { + while (anumber > 0 || (aneedSpace && *aneedSpace > 0)) { /* find oldest entries for reclamation */ maxVictimPtr = victimPtr = 0; hzero(maxVictimTime); /* select victims from access time array */ for (i = 0; i < afs_cacheFiles; i++) { if (afs_indexFlags[i] & (IFDataMod | IFFree | IFDiscarded)) { - /* skip if dirty or already free */ - continue; + /* skip if dirty or already free */ + continue; } tdc = afs_indexTable[i]; if (tdc && (tdc->refCount != 0)) { - /* Referenced; can't use it! */ - continue; + /* Referenced; can't use it! */ + continue; } hset(vtime, afs_indexTimes[i]); /* if we've already looked at this one, skip it */ - if (afs_indexFlags[i] & IFFlag) continue; + if (afs_indexFlags[i] & IFFlag) + continue; if (victimPtr < MAXATONCE) { /* if there's at least one free victim slot left */ @@ -439,33 +448,33 @@ static void afs_GetDownD(int anumber, int *aneedSpace) maxVictimPtr = victimPtr; } victimPtr++; - } - else if (hcmp(vtime, maxVictimTime) < 0) { + } else if (hcmp(vtime, maxVictimTime) < 0) { /* * We're older than youngest victim, so we replace at * least one victim */ /* find youngest (largest LRU) victim */ - j = maxVictimPtr; - if (j == victimPtr) osi_Panic("getdownd local"); + j = maxVictimPtr; + if (j == victimPtr) + osi_Panic("getdownd local"); victims[j] = i; hset(victimTimes[j], vtime); /* recompute maxVictimTime */ hset(maxVictimTime, vtime); - for(j = 0; j < victimPtr; j++) + for (j = 0; j < victimPtr; j++) if (hcmp(maxVictimTime, victimTimes[j]) < 0) { hset(maxVictimTime, victimTimes[j]); maxVictimPtr = j; } } - } /* big for loop */ + } /* big for loop */ /* now really reclaim the victims */ - j = 0; /* flag to track if we actually got any of the victims */ + j = 0; /* flag to track if we actually got any of the victims */ /* first, hold all the victims, since we're going to release the lock * during the truncate operation. */ - for(i=0; i < victimPtr; i++) { + for (i = 0; i < victimPtr; i++) { tdc = afs_GetDSlot(victims[i], 0); /* We got tdc->tlock(R) here */ if (tdc->refCount == 1) @@ -473,9 +482,10 @@ static void afs_GetDownD(int anumber, int *aneedSpace) else victimDCs[i] = 0; ReleaseReadLock(&tdc->tlock); - if (!victimDCs[i]) afs_PutDCache(tdc); + if (!victimDCs[i]) + afs_PutDCache(tdc); } - for(i = 0; i < victimPtr; i++) { + for (i = 0; i < victimPtr; i++) { /* q is first elt in dcache entry */ tdc = victimDCs[i]; /* now, since we're dropping the afs_xdcache lock below, we @@ -487,7 +497,7 @@ static void afs_GetDownD(int anumber, int *aneedSpace) if (tdc && tdc->refCount == 1) { unsigned char chunkFlags; afs_size_t tchunkoffset = 0; - afid = &tdc->f.fid; + afid = &tdc->f.fid; /* xdcache is lower than the xvcache lock */ MReleaseWriteLock(&afs_xdcache); MObtainReadLock(&afs_xvcache); @@ -495,18 +505,22 @@ static void afs_GetDownD(int anumber, int *aneedSpace) MReleaseReadLock(&afs_xvcache); MObtainWriteLock(&afs_xdcache, 527); skip = 0; - if (tdc->refCount > 1) skip = 1; + if (tdc->refCount > 1) + skip = 1; if (tvc) { tchunkoffset = AFS_CHUNKTOBASE(tdc->f.chunk); chunkFlags = afs_indexFlags[tdc->index]; - if (phase == 0 && osi_Active(tvc)) skip = 1; - if (phase > 0 && osi_Active(tvc) && (tvc->states & CDCLock) - && (chunkFlags & IFAnyPages)) skip = 1; - if (chunkFlags & IFDataMod) skip = 1; + if (phase == 0 && osi_Active(tvc)) + skip = 1; + if (phase > 0 && osi_Active(tvc) + && (tvc->states & CDCLock) + && (chunkFlags & IFAnyPages)) + skip = 1; + if (chunkFlags & IFDataMod) + skip = 1; afs_Trace4(afs_iclSetp, CM_TRACE_GETDOWND, ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, skip, - ICL_TYPE_INT32, tdc->index, - ICL_TYPE_OFFSET, + ICL_TYPE_INT32, tdc->index, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(tchunkoffset)); #if defined(AFS_SUN5_ENV) @@ -533,10 +547,9 @@ static void afs_GetDownD(int anumber, int *aneedSpace) /* One last recheck */ MObtainWriteLock(&afs_xdcache, 333); chunkFlags = afs_indexFlags[tdc->index]; - if (tdc->refCount > 1 - || (chunkFlags & IFDataMod) + if (tdc->refCount > 1 || (chunkFlags & IFDataMod) || (osi_Active(tvc) && (tvc->states & CDCLock) - && (chunkFlags & IFAnyPages))) { + && (chunkFlags & IFAnyPages))) { skip = 1; MReleaseWriteLock(&afs_xdcache); goto endputpage; @@ -545,16 +558,18 @@ static void afs_GetDownD(int anumber, int *aneedSpace) code = osi_VM_GetDownD(tvc, tdc); - MObtainWriteLock(&afs_xdcache,269); + MObtainWriteLock(&afs_xdcache, 269); /* we actually removed all pages, clean and dirty */ if (code == 0) { - afs_indexFlags[tdc->index] &= ~(IFDirtyPages| IFAnyPages); + afs_indexFlags[tdc->index] &= + ~(IFDirtyPages | IFAnyPages); } else skip = 1; MReleaseWriteLock(&afs_xdcache); -endputpage: + endputpage: MObtainWriteLock(&tvc->vlock, 544); - if (--tvc->activeV == 0 && (tvc->vstates & VRevokeWait)) { + if (--tvc->activeV == 0 + && (tvc->vstates & VRevokeWait)) { tvc->vstates &= ~VRevokeWait; afs_osi_Wakeup((char *)&tvc->vstates); @@ -563,10 +578,10 @@ endputpage: tvc->vstates &= ~VPageCleaning; afs_osi_Wakeup((char *)&tvc->vstates); } -endmultipage: + endmultipage: MReleaseWriteLock(&tvc->vlock); } else -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ { MReleaseWriteLock(&afs_xdcache); } @@ -574,8 +589,10 @@ endmultipage: AFS_FAST_RELE(tvc); MObtainWriteLock(&afs_xdcache, 528); if (afs_indexFlags[tdc->index] & - (IFDataMod | IFDirtyPages | IFAnyPages)) skip = 1; - if (tdc->refCount > 1) skip = 1; + (IFDataMod | IFDirtyPages | IFAnyPages)) + skip = 1; + if (tdc->refCount > 1) + skip = 1; } #if defined(AFS_SUN5_ENV) else { @@ -586,7 +603,8 @@ endmultipage: * Hold vcache lock to prevent vnode from being * created while we're clearing IFDirtyPages. */ - afs_indexFlags[tdc->index] &= ~(IFDirtyPages | IFAnyPages); + afs_indexFlags[tdc->index] &= + ~(IFDirtyPages | IFAnyPages); } #endif if (skip) { @@ -594,21 +612,18 @@ endmultipage: afs_indexFlags[tdc->index] |= IFFlag; afs_Trace4(afs_iclSetp, CM_TRACE_GETDOWND, ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, 2, - ICL_TYPE_INT32, tdc->index, - ICL_TYPE_OFFSET, + ICL_TYPE_INT32, tdc->index, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(tchunkoffset)); - } - else { + } else { /* flush this dude from the data cache and reclaim; - * first, make sure no one will care that we damage - * it, by removing it from all hash tables. Then, - * melt it down for parts. Note that any concurrent - * (new possibility!) calls to GetDownD won't touch - * this guy because his reference count is > 0. */ + * first, make sure no one will care that we damage + * it, by removing it from all hash tables. Then, + * melt it down for parts. Note that any concurrent + * (new possibility!) calls to GetDownD won't touch + * this guy because his reference count is > 0. */ afs_Trace4(afs_iclSetp, CM_TRACE_GETDOWND, ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, 3, - ICL_TYPE_INT32, tdc->index, - ICL_TYPE_OFFSET, + ICL_TYPE_INT32, tdc->index, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(tchunkoffset)); #ifndef AFS_DEC_ENV AFS_STATCNT(afs_gget); @@ -617,7 +632,8 @@ endmultipage: if (tdc->f.chunkBytes != 0) { discard = 1; if (aneedSpace) - *aneedSpace -= (tdc->f.chunkBytes + afs_fsfragsize) >> 10; + *aneedSpace -= + (tdc->f.chunkBytes + afs_fsfragsize) >> 10; } else { discard = 0; } @@ -632,7 +648,7 @@ endmultipage: } afs_PutDCache(tdc); } - + if (phase == 0) { /* Phase is 0 and no one was found, so try phase 1 (ignore * osi_Active flag) */ @@ -642,15 +658,15 @@ endmultipage: /* turn off all flags */ afs_indexFlags[i] &= ~IFFlag; } - } - else { + } else { /* found no one in phase 1, we're hosed */ - if (victimPtr == 0) break; + if (victimPtr == 0) + break; } - } /* big while loop */ + } /* big while loop */ return; -} /*afs_GetDownD*/ +} /*afs_GetDownD */ /* @@ -661,7 +677,8 @@ endmultipage: * * Locks: Must have the afs_xdcache lock write-locked to call this function. */ -int afs_HashOutDCache(struct dcache *adc) +int +afs_HashOutDCache(struct dcache *adc) { int i, us; @@ -678,8 +695,7 @@ int afs_HashOutDCache(struct dcache *adc) if (us == adc->index) { /* first dude in the list */ afs_dchashTbl[i] = afs_dcnextTbl[adc->index]; - } - else { + } else { /* somewhere on the chain */ while (us != NULLIDX) { if (afs_dcnextTbl[us] == adc->index) { @@ -689,7 +705,8 @@ int afs_HashOutDCache(struct dcache *adc) } us = afs_dcnextTbl[us]; } - if (us == NULLIDX) osi_Panic("dcache hc"); + if (us == NULLIDX) + osi_Panic("dcache hc"); } /* remove entry from *other* hash chain */ i = DVHash(&adc->f.fid); @@ -697,8 +714,7 @@ int afs_HashOutDCache(struct dcache *adc) if (us == adc->index) { /* first dude in the list */ afs_dvhashTbl[i] = afs_dvnextTbl[adc->index]; - } - else { + } else { /* somewhere on the chain */ while (us != NULLIDX) { if (afs_dvnextTbl[us] == adc->index) { @@ -708,7 +724,8 @@ int afs_HashOutDCache(struct dcache *adc) } us = afs_dvnextTbl[us]; } - if (us == NULLIDX) osi_Panic("dcache hv"); + if (us == NULLIDX) + osi_Panic("dcache hv"); } } @@ -723,7 +740,7 @@ int afs_HashOutDCache(struct dcache *adc) /* all done */ return 0; -} /*afs_HashOutDCache */ +} /*afs_HashOutDCache */ /* @@ -741,7 +758,8 @@ int afs_HashOutDCache(struct dcache *adc) * (in write mode) */ -void afs_FlushDCache(register struct dcache *adc) +void +afs_FlushDCache(register struct dcache *adc) { AFS_STATCNT(afs_FlushDCache); /* @@ -766,12 +784,12 @@ void afs_FlushDCache(register struct dcache *adc) if (afs_WaitForCacheDrain) { if (afs_blocksUsed <= - (CM_CACHESIZEDRAINEDPCT*afs_cacheBlocks)/100) { + (CM_CACHESIZEDRAINEDPCT * afs_cacheBlocks) / 100) { afs_WaitForCacheDrain = 0; afs_osi_Wakeup(&afs_WaitForCacheDrain); } } -} /*afs_FlushDCache*/ +} /*afs_FlushDCache */ /* @@ -783,7 +801,8 @@ void afs_FlushDCache(register struct dcache *adc) * * Environment: called with afs_xdcache lock write-locked. */ -static void afs_FreeDCache(register struct dcache *adc) +static void +afs_FreeDCache(register struct dcache *adc) { /* Thread on free list, update free list count and mark entry as * freed in its indexFlags element. Also, ensure DCache entry gets @@ -798,7 +817,7 @@ static void afs_FreeDCache(register struct dcache *adc) if (afs_WaitForCacheDrain) { if ((afs_blocksUsed - afs_blocksDiscarded) <= - (CM_CACHESIZEDRAINEDPCT*afs_cacheBlocks)/100) { + (CM_CACHESIZEDRAINEDPCT * afs_cacheBlocks) / 100) { afs_WaitForCacheDrain = 0; afs_osi_Wakeup(&afs_WaitForCacheDrain); } @@ -825,7 +844,8 @@ static void afs_FreeDCache(register struct dcache *adc) * Must be called with afs_xdcache write-locked. */ -static void afs_DiscardDCache(register struct dcache *adc) +static void +afs_DiscardDCache(register struct dcache *adc) { register afs_int32 size; @@ -833,7 +853,7 @@ static void afs_DiscardDCache(register struct dcache *adc) osi_Assert(adc->refCount == 1); - size = ((adc->f.chunkBytes + afs_fsfragsize)^afs_fsfragsize)>>10;/* round up */ + size = ((adc->f.chunkBytes + afs_fsfragsize) ^ afs_fsfragsize) >> 10; /* round up */ afs_blocksDiscarded += size; afs_stats_cmperf.cacheBlocksDiscarded = afs_blocksDiscarded; @@ -847,13 +867,13 @@ static void afs_DiscardDCache(register struct dcache *adc) if (afs_WaitForCacheDrain) { if ((afs_blocksUsed - afs_blocksDiscarded) <= - (CM_CACHESIZEDRAINEDPCT*afs_cacheBlocks)/100) { + (CM_CACHESIZEDRAINEDPCT * afs_cacheBlocks) / 100) { afs_WaitForCacheDrain = 0; afs_osi_Wakeup(&afs_WaitForCacheDrain); } } -} /*afs_DiscardDCache*/ +} /*afs_DiscardDCache */ /* * afs_FreeDiscardedDCache @@ -861,15 +881,16 @@ static void afs_DiscardDCache(register struct dcache *adc) * Description: * Free the next element on the list of discarded cache elements. */ -static void afs_FreeDiscardedDCache(void) +static void +afs_FreeDiscardedDCache(void) { register struct dcache *tdc; - register struct osi_file *tfile; + register struct osi_file *tfile; register afs_int32 size; AFS_STATCNT(afs_FreeDiscardedDCache); - MObtainWriteLock(&afs_xdcache,510); + MObtainWriteLock(&afs_xdcache, 510); if (!afs_blocksDiscarded) { MReleaseWriteLock(&afs_xdcache); return; @@ -885,7 +906,7 @@ static void afs_FreeDiscardedDCache(void) afs_discardDCList = afs_dvnextTbl[tdc->index]; afs_dvnextTbl[tdc->index] = NULLIDX; afs_discardDCCount--; - size = ((tdc->f.chunkBytes + afs_fsfragsize)^afs_fsfragsize)>>10;/* round up */ + size = ((tdc->f.chunkBytes + afs_fsfragsize) ^ afs_fsfragsize) >> 10; /* round up */ afs_blocksDiscarded -= size; afs_stats_cmperf.cacheBlocksDiscarded = afs_blocksDiscarded; /* We can lock because we just took it off the free list */ @@ -903,7 +924,7 @@ static void afs_FreeDiscardedDCache(void) /* * Free the element we just truncated */ - MObtainWriteLock(&afs_xdcache,511); + MObtainWriteLock(&afs_xdcache, 511); afs_indexFlags[tdc->index] &= ~IFDiscarded; afs_FreeDCache(tdc); ReleaseWriteLock(&tdc->lock); @@ -921,13 +942,15 @@ static void afs_FreeDiscardedDCache(void) * Parameters: * None */ -int afs_MaybeFreeDiscardedDCache(void) +int +afs_MaybeFreeDiscardedDCache(void) { AFS_STATCNT(afs_MaybeFreeDiscardedDCache); - while (afs_blocksDiscarded && - (afs_blocksUsed > (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100)) { + while (afs_blocksDiscarded + && (afs_blocksUsed > + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100)) { afs_FreeDiscardedDCache(); } return 0; @@ -945,7 +968,8 @@ int afs_MaybeFreeDiscardedDCache(void) * Environment: * Must be called with afs_xdcache write-locked. */ -static void afs_GetDownDSlot(int anumber) +static void +afs_GetDownDSlot(int anumber) { struct afs_q *tq, *nq; struct dcache *tdc; @@ -960,17 +984,18 @@ static void afs_GetDownDSlot(int anumber) osi_Panic("getdowndslot nolock"); /* decrement anumber first for all dudes in free list */ - for(tdc = afs_freeDSList; tdc; tdc = (struct dcache *)tdc->lruq.next) + for (tdc = afs_freeDSList; tdc; tdc = (struct dcache *)tdc->lruq.next) anumber--; - if (anumber <= 0) - return; /* enough already free */ + if (anumber <= 0) + return; /* enough already free */ - for(cnt=0, tq = afs_DLRU.prev; tq != &afs_DLRU && anumber > 0; - tq = nq, cnt++) { - tdc = (struct dcache *) tq; /* q is first elt in dcache entry */ - nq = QPrev(tq); /* in case we remove it */ + for (cnt = 0, tq = afs_DLRU.prev; tq != &afs_DLRU && anumber > 0; + tq = nq, cnt++) { + tdc = (struct dcache *)tq; /* q is first elt in dcache entry */ + nq = QPrev(tq); /* in case we remove it */ if (tdc->refCount == 0) { - if ((ix=tdc->index) == NULLIDX) osi_Panic("getdowndslot"); + if ((ix = tdc->index) == NULLIDX) + osi_Panic("getdowndslot"); /* pull the entry out of the lruq and put it on the free list */ QRemove(&tdc->lruq); @@ -980,7 +1005,7 @@ static void afs_GetDownDSlot(int anumber) /* * ask proxy to do this for us - we don't have the stack space */ - while (tdc->dflags & DFEntryMod) { + while (tdc->dflags & DFEntryMod) { int s; AFS_GUNLOCK(); s = SPLOCK(afs_sgibklock); @@ -1001,12 +1026,12 @@ static void afs_GetDownDSlot(int anumber) tdc->stamp = 0; #ifdef IHINT - if (tdc->ihint) { - struct osi_file * f = (struct osi_file *)tdc->ihint; - tdc->ihint = 0; - afs_UFSClose(f); - nihints--; - } + if (tdc->ihint) { + struct osi_file *f = (struct osi_file *)tdc->ihint; + tdc->ihint = 0; + afs_UFSClose(f); + nihints--; + } #endif /* IHINT */ @@ -1014,12 +1039,12 @@ static void afs_GetDownDSlot(int anumber) afs_indexTable[ix] = NULL; afs_indexFlags[ix] &= ~IFEverUsed; tdc->index = NULLIDX; - tdc->lruq.next = (struct afs_q *) afs_freeDSList; + tdc->lruq.next = (struct afs_q *)afs_freeDSList; afs_freeDSList = tdc; anumber--; } } -} /*afs_GetDownDSlot*/ +} /*afs_GetDownDSlot */ /* @@ -1037,7 +1062,8 @@ static void afs_GetDownDSlot(int anumber) * Environment: * Nothing interesting. */ -int afs_RefDCache(struct dcache *adc) +int +afs_RefDCache(struct dcache *adc) { ObtainWriteLock(&adc->tlock, 627); if (adc->refCount < 0) @@ -1060,7 +1086,8 @@ int afs_RefDCache(struct dcache *adc) * Environment: * Nothing interesting. */ -int afs_PutDCache(register struct dcache *adc) +int +afs_PutDCache(register struct dcache *adc) { AFS_STATCNT(afs_PutDCache); ObtainWriteLock(&adc->tlock, 276); @@ -1085,8 +1112,8 @@ int afs_PutDCache(register struct dcache *adc) * Environment: * Both pvnLock and lock are write held. */ -void afs_TryToSmush(register struct vcache *avc, struct AFS_UCRED *acred, - int sync) +void +afs_TryToSmush(register struct vcache *avc, struct AFS_UCRED *acred, int sync) { register struct dcache *tdc; register int index; @@ -1094,11 +1121,11 @@ void afs_TryToSmush(register struct vcache *avc, struct AFS_UCRED *acred, AFS_STATCNT(afs_TryToSmush); afs_Trace2(afs_iclSetp, CM_TRACE_TRYTOSMUSH, ICL_TYPE_POINTER, avc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); - sync = 1; /* XX Temp testing XX*/ + sync = 1; /* XX Temp testing XX */ #if defined(AFS_SUN5_ENV) ObtainWriteLock(&avc->vlock, 573); - avc->activeV++; /* block new getpages */ + avc->activeV++; /* block new getpages */ ReleaseWriteLock(&avc->vlock); #endif @@ -1108,27 +1135,28 @@ void afs_TryToSmush(register struct vcache *avc, struct AFS_UCRED *acred, /* * Get the hash chain containing all dce's for this fid */ - i = DVHash(&avc->fid); - MObtainWriteLock(&afs_xdcache,277); - for(index = afs_dvhashTbl[i]; index != NULLIDX; index=i) { - i = afs_dvnextTbl[index]; /* next pointer this hash table */ - if (afs_indexUnique[index] == avc->fid.Fid.Unique) { - int releaseTlock = 1; - tdc = afs_GetDSlot(index, NULL); - if (!FidCmp(&tdc->f.fid, &avc->fid)) { - if (sync) { - if ((afs_indexFlags[index] & IFDataMod) == 0 && - tdc->refCount == 1) { - ReleaseReadLock(&tdc->tlock); - releaseTlock = 0; - afs_FlushDCache(tdc); - } - } else - afs_indexTable[index] = 0; + i = DVHash(&avc->fid); + MObtainWriteLock(&afs_xdcache, 277); + for (index = afs_dvhashTbl[i]; index != NULLIDX; index = i) { + i = afs_dvnextTbl[index]; /* next pointer this hash table */ + if (afs_indexUnique[index] == avc->fid.Fid.Unique) { + int releaseTlock = 1; + tdc = afs_GetDSlot(index, NULL); + if (!FidCmp(&tdc->f.fid, &avc->fid)) { + if (sync) { + if ((afs_indexFlags[index] & IFDataMod) == 0 + && tdc->refCount == 1) { + ReleaseReadLock(&tdc->tlock); + releaseTlock = 0; + afs_FlushDCache(tdc); + } + } else + afs_indexTable[index] = 0; + } + if (releaseTlock) + ReleaseReadLock(&tdc->tlock); + afs_PutDCache(tdc); } - if (releaseTlock) ReleaseReadLock(&tdc->tlock); - afs_PutDCache(tdc); - } } #if defined(AFS_SUN5_ENV) ObtainWriteLock(&avc->vlock, 545); @@ -1166,7 +1194,8 @@ void afs_TryToSmush(register struct vcache *avc, struct AFS_UCRED *acred, * The vcache entry is held upon entry. */ -struct dcache *afs_FindDCache(register struct vcache *avc, afs_size_t abyte) +struct dcache * +afs_FindDCache(register struct vcache *avc, afs_size_t abyte) { afs_int32 chunk; register afs_int32 i, index; @@ -1180,8 +1209,8 @@ struct dcache *afs_FindDCache(register struct vcache *avc, afs_size_t abyte) * after write-locking the dcache. */ i = DCHash(&avc->fid, chunk); - MObtainWriteLock(&afs_xdcache,278); - for(index = afs_dchashTbl[i]; index != NULLIDX;) { + MObtainWriteLock(&afs_xdcache, 278); + for (index = afs_dchashTbl[i]; index != NULLIDX;) { if (afs_indexUnique[index] == avc->fid.Fid.Unique) { tdc = afs_GetDSlot(index, NULL); ReleaseReadLock(&tdc->tlock); @@ -1197,11 +1226,10 @@ struct dcache *afs_FindDCache(register struct vcache *avc, afs_size_t abyte) hset(afs_indexTimes[tdc->index], afs_indexCounter); hadd32(afs_indexCounter, 1); return tdc; - } - else + } else return NULL; -} /*afs_FindDCache*/ +} /*afs_FindDCache */ /* @@ -1226,9 +1254,11 @@ struct dcache *afs_FindDCache(register struct vcache *avc, afs_size_t abyte) * Environment: * Nothing interesting. */ -static int afs_UFSCacheStoreProc(register struct rx_call *acall, - struct osi_file *afile, register afs_int32 alen, struct vcache *avc, - int *shouldWake, afs_size_t *abytesToXferP, afs_size_t *abytesXferredP) +static int +afs_UFSCacheStoreProc(register struct rx_call *acall, struct osi_file *afile, + register afs_int32 alen, struct vcache *avc, + int *shouldWake, afs_size_t * abytesToXferP, + afs_size_t * abytesXferredP) { afs_int32 code, got; register char *tbuffer; @@ -1241,19 +1271,18 @@ static int afs_UFSCacheStoreProc(register struct rx_call *acall, * In this case, alen is *always* the amount of data we'll be trying * to ship here. */ - (*abytesToXferP) = alen; + (*abytesToXferP) = alen; (*abytesXferredP) = 0; #endif /* AFS_NOSTATS */ afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc, - ICL_TYPE_FID, &(avc->fid), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length), - ICL_TYPE_INT32, alen); + ICL_TYPE_FID, &(avc->fid), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length), ICL_TYPE_INT32, alen); tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ); while (alen > 0) { tlen = (alen > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : alen); got = afs_osi_Read(afile, -1, tbuffer, tlen); - if ((got < 0) + if ((got < 0) #if defined(KERNEL_HAVE_UERROR) || (got != tlen && getuerror()) #endif @@ -1261,13 +1290,12 @@ static int afs_UFSCacheStoreProc(register struct rx_call *acall, osi_FreeLargeSpace(tbuffer); return EIO; } - afs_Trace2(afs_iclSetp, CM_TRACE_STOREPROC2, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(*tbuffer), - ICL_TYPE_INT32, got); + afs_Trace2(afs_iclSetp, CM_TRACE_STOREPROC2, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(*tbuffer), ICL_TYPE_INT32, got); RX_AFS_GUNLOCK(); - code = rx_Write(acall, tbuffer, got); /* writing 0 bytes will - * push a short packet. Is that really what we want, just because the - * data didn't come back from the disk yet? Let's try it and see. */ + code = rx_Write(acall, tbuffer, got); /* writing 0 bytes will + * push a short packet. Is that really what we want, just because the + * data didn't come back from the disk yet? Let's try it and see. */ RX_AFS_GLOCK(); #ifndef AFS_NOSTATS (*abytesXferredP) += code; @@ -1282,18 +1310,17 @@ static int afs_UFSCacheStoreProc(register struct rx_call *acall, * to continue. */ if (shouldWake && *shouldWake && (rx_GetRemoteStatus(acall) & 1)) { - *shouldWake = 0; /* only do this once */ + *shouldWake = 0; /* only do this once */ afs_wakeup(avc); } } afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc, - ICL_TYPE_FID, &(avc->fid), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length), - ICL_TYPE_INT32, alen); + ICL_TYPE_FID, &(avc->fid), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length), ICL_TYPE_INT32, alen); osi_FreeLargeSpace(tbuffer); return 0; -} /* afs_UFSCacheStoreProc*/ +} /* afs_UFSCacheStoreProc */ /* @@ -1320,10 +1347,11 @@ static int afs_UFSCacheStoreProc(register struct rx_call *acall, * Nothing interesting. */ -static int afs_UFSCacheFetchProc(register struct rx_call *acall, - struct osi_file *afile, afs_size_t abase, struct dcache *adc, - struct vcache *avc, afs_size_t *abytesToXferP, - afs_size_t *abytesXferredP, afs_int32 lengthFound) +static int +afs_UFSCacheFetchProc(register struct rx_call *acall, struct osi_file *afile, + afs_size_t abase, struct dcache *adc, + struct vcache *avc, afs_size_t * abytesToXferP, + afs_size_t * abytesXferredP, afs_int32 lengthFound) { afs_int32 length; register afs_int32 code; @@ -1333,10 +1361,10 @@ static int afs_UFSCacheFetchProc(register struct rx_call *acall, AFS_STATCNT(UFS_CacheFetchProc); osi_Assert(WriteLocked(&adc->lock)); - afile->offset = 0; /* Each time start from the beginning */ + afile->offset = 0; /* Each time start from the beginning */ length = lengthFound; #ifndef AFS_NOSTATS - (*abytesToXferP) = 0; + (*abytesToXferP) = 0; (*abytesXferredP) = 0; #endif /* AFS_NOSTATS */ tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ); @@ -1344,14 +1372,14 @@ static int afs_UFSCacheFetchProc(register struct rx_call *acall, do { if (moredata) { RX_AFS_GUNLOCK(); - code = rx_Read(acall, (char *)&length, sizeof(afs_int32)); + code = rx_Read(acall, (char *)&length, sizeof(afs_int32)); RX_AFS_GLOCK(); length = ntohl(length); - if (code != sizeof(afs_int32)) { - osi_FreeLargeSpace(tbuffer); - code = rx_Error(acall); - return (code?code:-1); /* try to return code, not -1 */ - } + if (code != sizeof(afs_int32)) { + osi_FreeLargeSpace(tbuffer); + code = rx_Error(acall); + return (code ? code : -1); /* try to return code, not -1 */ + } } /* * The fetch protocol is extended for the AFS/DFS translator @@ -1370,28 +1398,28 @@ static int afs_UFSCacheFetchProc(register struct rx_call *acall, } #ifndef AFS_NOSTATS (*abytesToXferP) += length; -#endif /* AFS_NOSTATS */ +#endif /* AFS_NOSTATS */ while (length > 0) { tlen = (length > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : length); #ifdef RX_KERNEL_TRACE - afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, - ICL_TYPE_STRING, "before rx_Read"); + afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING, + "before rx_Read"); #endif RX_AFS_GUNLOCK(); code = rx_Read(acall, tbuffer, tlen); RX_AFS_GLOCK(); #ifdef RX_KERNEL_TRACE - afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, - ICL_TYPE_STRING, "after rx_Read"); + afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING, + "after rx_Read"); #endif #ifndef AFS_NOSTATS (*abytesXferredP) += code; -#endif /* AFS_NOSTATS */ +#endif /* AFS_NOSTATS */ if (code != tlen) { osi_FreeLargeSpace(tbuffer); afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64READ, - ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code, - ICL_TYPE_INT32, length); + ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code, + ICL_TYPE_INT32, length); return -34; } code = afs_osi_Write(afile, -1, tbuffer, tlen); @@ -1403,17 +1431,16 @@ static int afs_UFSCacheFetchProc(register struct rx_call *acall, length -= tlen; adc->validPos = abase; if (afs_osi_Wakeup(&adc->validPos) == 0) - afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, adc, - ICL_TYPE_INT32, adc->dflags); + afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_INT32, __LINE__, + ICL_TYPE_POINTER, adc, ICL_TYPE_INT32, + adc->dflags); } } while (moredata); osi_FreeLargeSpace(tbuffer); return 0; -} /* afs_UFSCacheFetchProc*/ +} /* afs_UFSCacheFetchProc */ /* * afs_GetDCache @@ -1455,9 +1482,10 @@ struct tlocal1 { * Update the vnode-to-dcache hint if we can get the vnode lock * right away. Assumes dcache entry is at least read-locked. */ -void updateV2DC(int lockVc, struct vcache *v, struct dcache *d, int src) +void +updateV2DC(int lockVc, struct vcache *v, struct dcache *d, int src) { - if (!lockVc || 0 == NBObtainWriteLock(&v->lock,src)) { + if (!lockVc || 0 == NBObtainWriteLock(&v->lock, src)) { if (hsame(v->m.DataVersion, d->f.versionNo) && v->callback) { v->quick.dc = d; v->quick.stamp = d->stamp = MakeStamp(); @@ -1466,16 +1494,18 @@ void updateV2DC(int lockVc, struct vcache *v, struct dcache *d, int src) v->quick.len = d->f.chunkBytes; v->h1.dchint = d; } - if (lockVc) ReleaseWriteLock(&v->lock); + if (lockVc) + ReleaseWriteLock(&v->lock); } } /* avc - Write-locked unless aflags & 1 */ -struct dcache *afs_GetDCache(register struct vcache *avc, afs_size_t abyte, - register struct vrequest *areq, afs_size_t *aoffset, afs_size_t *alen, - int aflags) +struct dcache * +afs_GetDCache(register struct vcache *avc, afs_size_t abyte, + register struct vrequest *areq, afs_size_t * aoffset, + afs_size_t * alen, int aflags) { - register afs_int32 i, code, code1=0, shortcut; + register afs_int32 i, code, code1 = 0, shortcut; #if defined(AFS_AIX32_ENV) || defined(AFS_SGI_ENV) register afs_int32 adjustsize = 0; #endif @@ -1483,14 +1513,14 @@ struct dcache *afs_GetDCache(register struct vcache *avc, afs_size_t abyte, afs_int32 index; afs_int32 us; afs_int32 chunk; - afs_size_t maxGoodLength; /* amount of good data at server */ + afs_size_t maxGoodLength; /* amount of good data at server */ struct rx_call *tcall; afs_size_t Position = 0; #ifdef AFS_64BIT_CLIENT afs_size_t tsize; - afs_size_t lengthFound; /* as returned from server */ + afs_size_t lengthFound; /* as returned from server */ #endif /* AFS_64BIT_CLIENT */ - afs_int32 size, tlen; /* size of segment to transfer */ + afs_int32 size, tlen; /* size of segment to transfer */ struct tlocal1 *tsmall = 0; register struct dcache *tdc; register struct osi_file *file; @@ -1508,13 +1538,13 @@ struct dcache *afs_GetDCache(register struct vcache *avc, afs_size_t abyte, XSTATS_DECLS #ifndef AFS_NOSTATS struct afs_stats_xferData *xferP; /* Ptr to this op's xfer struct */ - osi_timeval_t xferStartTime, /*FS xfer start time*/ - xferStopTime; /*FS xfer stop time*/ - afs_size_t bytesToXfer; /* # bytes to xfer*/ - afs_size_t bytesXferred; /* # bytes actually xferred*/ - struct afs_stats_AccessInfo *accP; /*Ptr to access record in stats*/ - int fromReplica; /*Are we reading from a replica?*/ - int numFetchLoops; /*# times around the fetch/analyze loop*/ + osi_timeval_t xferStartTime, /*FS xfer start time */ + xferStopTime; /*FS xfer stop time */ + afs_size_t bytesToXfer; /* # bytes to xfer */ + afs_size_t bytesXferred; /* # bytes actually xferred */ + struct afs_stats_AccessInfo *accP; /*Ptr to access record in stats */ + int fromReplica; /*Are we reading from a replica? */ + int numFetchLoops; /*# times around the fetch/analyze loop */ #endif /* AFS_NOSTATS */ AFS_STATCNT(afs_GetDCache); @@ -1528,15 +1558,14 @@ struct dcache *afs_GetDCache(register struct vcache *avc, afs_size_t abyte, * Determine the chunk number and offset within the chunk corresponding * to the desired byte. */ - if (avc->fid.Fid.Vnode & 1) { /* if (vType(avc) == VDIR) */ + if (avc->fid.Fid.Vnode & 1) { /* if (vType(avc) == VDIR) */ chunk = 0; - } - else { + } else { chunk = AFS_CHUNK(abyte); } /* come back to here if we waited for the cache to drain. */ -RetryGetDCache: + RetryGetDCache: setNewCallback = setVcacheStatus = 0; @@ -1569,10 +1598,9 @@ RetryGetDCache: MObtainReadLock(&afs_xdcache); dcLocked = (0 == NBObtainSharedLock(&tdc->lock, 601)); - if (dcLocked && - (tdc->index != NULLIDX) && !FidCmp(&tdc->f.fid, &avc->fid) && - chunk == tdc->f.chunk && - !(afs_indexFlags[tdc->index] & (IFFree|IFDiscarded))) { + if (dcLocked && (tdc->index != NULLIDX) + && !FidCmp(&tdc->f.fid, &avc->fid) && chunk == tdc->f.chunk + && !(afs_indexFlags[tdc->index] & (IFFree | IFDiscarded))) { /* got the right one. It might not be the right version, and it * might be fetching, but it's the right dcache entry. */ @@ -1586,8 +1614,8 @@ RetryGetDCache: MReleaseReadLock(&afs_xdcache); shortcut = 1; - if (hsame(tdc->f.versionNo, avc->m.DataVersion) && - !(tdc->dflags & DFFetching)) { + if (hsame(tdc->f.versionNo, avc->m.DataVersion) + && !(tdc->dflags & DFFetching)) { afs_stats_cmperf.dcacheHits++; MObtainWriteLock(&afs_xdcache, 559); @@ -1603,7 +1631,8 @@ RetryGetDCache: goto done; } } else { - if (dcLocked) ReleaseSharedLock(&tdc->lock); + if (dcLocked) + ReleaseSharedLock(&tdc->lock); MReleaseReadLock(&afs_xdcache); } @@ -1617,12 +1646,12 @@ RetryGetDCache: * tdc->lock(S) if tdc */ - if (!tdc) { /* If the hint wasn't the right dcache entry */ + if (!tdc) { /* If the hint wasn't the right dcache entry */ /* * Hash on the [fid, chunk] and get the corresponding dcache index * after write-locking the dcache. */ -RetryLookup: + RetryLookup: /* Locks held: * avc->lock(R) if setLocks && !slowPass @@ -1633,9 +1662,9 @@ RetryLookup: /* check to make sure our space is fine */ afs_MaybeWakeupTruncateDaemon(); - MObtainWriteLock(&afs_xdcache,280); + MObtainWriteLock(&afs_xdcache, 280); us = NULLIDX; - for (index = afs_dchashTbl[i]; index != NULLIDX; ) { + for (index = afs_dchashTbl[i]; index != NULLIDX;) { if (afs_indexUnique[index] == avc->fid.Fid.Unique) { tdc = afs_GetDSlot(index, NULL); ReleaseReadLock(&tdc->tlock); @@ -1647,14 +1676,14 @@ RetryLookup: */ if (!FidCmp(&tdc->f.fid, &avc->fid) && chunk == tdc->f.chunk) { /* Move it up in the beginning of the list */ - if (afs_dchashTbl[i] != index) { + if (afs_dchashTbl[i] != index) { afs_dcnextTbl[us] = afs_dcnextTbl[index]; afs_dcnextTbl[index] = afs_dchashTbl[i]; afs_dchashTbl[i] = index; } MReleaseWriteLock(&afs_xdcache); ObtainSharedLock(&tdc->lock, 606); - break; /* leaving refCount high for caller */ + break; /* leaving refCount high for caller */ } afs_PutDCache(tdc); tdc = 0; @@ -1679,14 +1708,17 @@ RetryLookup: /* Make sure there is a free dcache entry for us to use */ if (afs_discardDCList == NULLIDX && afs_freeDCList == NULLIDX) { while (1) { - if (!setLocks) avc->states |= CDCLock; - afs_GetDownD(5, (int*)0); /* just need slots */ - if (!setLocks) avc->states &= ~CDCLock; - if (afs_discardDCList != NULLIDX || afs_freeDCList != NULLIDX) + if (!setLocks) + avc->states |= CDCLock; + afs_GetDownD(5, (int *)0); /* just need slots */ + if (!setLocks) + avc->states &= ~CDCLock; + if (afs_discardDCList != NULLIDX + || afs_freeDCList != NULLIDX) break; /* If we can't get space for 5 mins we give up and panic */ if (++downDCount > 300) - osi_Panic("getdcache"); + osi_Panic("getdcache"); MReleaseWriteLock(&afs_xdcache); /* * Locks held: @@ -1698,8 +1730,8 @@ RetryLookup: } } - if (afs_discardDCList == NULLIDX || - ((aflags & 2) && afs_freeDCList != NULLIDX)) { + if (afs_discardDCList == NULLIDX + || ((aflags & 2) && afs_freeDCList != NULLIDX)) { afs_indexFlags[afs_freeDCList] &= ~IFFree; tdc = afs_GetDSlot(afs_freeDCList, 0); @@ -1716,7 +1748,9 @@ RetryLookup: ObtainWriteLock(&tdc->lock, 605); afs_discardDCList = afs_dvnextTbl[tdc->index]; afs_discardDCCount--; - size = ((tdc->f.chunkBytes + afs_fsfragsize)^afs_fsfragsize)>>10; + size = + ((tdc->f.chunkBytes + + afs_fsfragsize) ^ afs_fsfragsize) >> 10; afs_blocksDiscarded -= size; afs_stats_cmperf.cacheBlocksDiscarded = afs_blocksDiscarded; if (aflags & 2) { @@ -1742,11 +1776,12 @@ RetryLookup: afs_indexFlags[tdc->index] &= ~(IFDirtyPages | IFAnyPages); tdc->f.fid = avc->fid; afs_indexUnique[tdc->index] = tdc->f.fid.Fid.Unique; - hones(tdc->f.versionNo); /* invalid value */ + hones(tdc->f.versionNo); /* invalid value */ tdc->f.chunk = chunk; tdc->validPos = AFS_CHUNKTOBASE(chunk); /* XXX */ - if (tdc->lruq.prev == &tdc->lruq) osi_Panic("lruq 1"); + if (tdc->lruq.prev == &tdc->lruq) + osi_Panic("lruq 1"); /* * Now add to the two hash chains - note that i is still set @@ -1764,19 +1799,20 @@ RetryLookup: MReleaseWriteLock(&afs_xdcache); ConvertWToSLock(&tdc->lock); } - } /* vcache->dcache hint failed */ + } + + /* vcache->dcache hint failed */ /* * Locks held: * avc->lock(R) if setLocks && !slowPass * avc->lock(W) if !setLocks || slowPass * tdc->lock(S) */ - afs_Trace4(afs_iclSetp, CM_TRACE_GETDCACHE2, ICL_TYPE_POINTER, avc, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_INT32, hgetlo(tdc->f.versionNo), - ICL_TYPE_INT32, hgetlo(avc->m.DataVersion)); + ICL_TYPE_POINTER, tdc, ICL_TYPE_INT32, + hgetlo(tdc->f.versionNo), ICL_TYPE_INT32, + hgetlo(avc->m.DataVersion)); /* * Here we have the entry in tdc, with its refCount incremented. * Note: we don't use the S-lock on avc; it costs concurrency when @@ -1791,16 +1827,15 @@ RetryLookup: * that this chunk's data hasn't been filled by another client. */ size = AFS_CHUNKSIZE(abyte); - if (aflags & 4) /* called from write */ + if (aflags & 4) /* called from write */ tlen = *alen; - else /* called from read */ + else /* called from read */ tlen = tdc->validPos - abyte; Position = AFS_CHUNKTOBASE(chunk); - afs_Trace4(afs_iclSetp, CM_TRACE_GETDCACHE3, - ICL_TYPE_INT32, tlen, - ICL_TYPE_INT32, aflags, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(abyte), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(Position)); + afs_Trace4(afs_iclSetp, CM_TRACE_GETDCACHE3, ICL_TYPE_INT32, tlen, + ICL_TYPE_INT32, aflags, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(abyte), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(Position)); if ((aflags & 4) && (hiszero(avc->m.DataVersion))) doAdjustSize = 1; if ((aflags & 4) && (abyte == Position) && (tlen >= size)) @@ -1809,22 +1844,25 @@ RetryLookup: #if defined(AFS_AIX32_ENV) || defined(AFS_SGI_ENV) #ifdef AFS_SGI_ENV #ifdef AFS_SGI64_ENV - if (doAdjustSize) adjustsize = NBPP; + if (doAdjustSize) + adjustsize = NBPP; #else /* AFS_SGI64_ENV */ - if (doAdjustSize) adjustsize = 8192; + if (doAdjustSize) + adjustsize = 8192; #endif /* AFS_SGI64_ENV */ #else /* AFS_SGI_ENV */ - if (doAdjustSize) adjustsize = 4096; + if (doAdjustSize) + adjustsize = 4096; #endif /* AFS_SGI_ENV */ - if (AFS_CHUNKTOBASE(chunk)+adjustsize >= avc->m.Length && + if (AFS_CHUNKTOBASE(chunk) + adjustsize >= avc->m.Length && #else /* defined(AFS_AIX32_ENV) || defined(AFS_SGI_ENV) */ #if defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) - if ((doAdjustSize || (AFS_CHUNKTOBASE(chunk) >= avc->m.Length)) && + if ((doAdjustSize || (AFS_CHUNKTOBASE(chunk) >= avc->m.Length)) && #else - if (AFS_CHUNKTOBASE(chunk) >= avc->m.Length && + if (AFS_CHUNKTOBASE(chunk) >= avc->m.Length && #endif #endif /* defined(AFS_AIX32_ENV) || defined(AFS_SGI_ENV) */ - !hsame(avc->m.DataVersion, tdc->f.versionNo)) + !hsame(avc->m.DataVersion, tdc->f.versionNo)) doReallyAdjustSize = 1; if (doReallyAdjustSize || overWriteWholeChunk) { @@ -1869,7 +1907,7 @@ RetryLookup: else ReleaseReadLock(&avc->lock); } - return tdc; /* check if we're done */ + return tdc; /* check if we're done */ } /* @@ -1942,24 +1980,25 @@ RetryLookup: /* Watch for standard race condition around osi_FlushText */ if (hsame(avc->m.DataVersion, tdc->f.versionNo)) { - updateV2DC(setLocks, avc, tdc, 569); /* set hint */ - afs_stats_cmperf.dcacheHits++; + updateV2DC(setLocks, avc, tdc, 569); /* set hint */ + afs_stats_cmperf.dcacheHits++; ConvertWToSLock(&tdc->lock); goto done; } /* Sleep here when cache needs to be drained. */ - if (setLocks && !slowPass && - (afs_blocksUsed > (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100)) { + if (setLocks && !slowPass + && (afs_blocksUsed > + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100)) { /* Make sure truncate daemon is running */ afs_MaybeWakeupTruncateDaemon(); ObtainWriteLock(&tdc->tlock, 614); - tdc->refCount--; /* we'll re-obtain the dcache when we re-try. */ + tdc->refCount--; /* we'll re-obtain the dcache when we re-try. */ ReleaseWriteLock(&tdc->tlock); ReleaseWriteLock(&tdc->lock); ReleaseReadLock(&avc->lock); - while ((afs_blocksUsed-afs_blocksDiscarded) > - (CM_WAITFORDRAINPCT*afs_cacheBlocks)/100) { + while ((afs_blocksUsed - afs_blocksDiscarded) > + (CM_WAITFORDRAINPCT * afs_cacheBlocks) / 100) { afs_WaitForCacheDrain = 1; afs_osi_Sleep(&afs_WaitForCacheDrain); } @@ -1970,7 +2009,8 @@ RetryLookup: /* Do not fetch data beyond truncPos. */ maxGoodLength = avc->m.Length; - if (avc->truncPos < maxGoodLength) maxGoodLength = avc->truncPos; + if (avc->truncPos < maxGoodLength) + maxGoodLength = avc->truncPos; Position = AFS_CHUNKBASE(abyte); if (vType(avc) == VDIR) { size = avc->m.Length; @@ -1978,42 +2018,41 @@ RetryLookup: /* pre-reserve space for file */ afs_AdjustSize(tdc, size); } - size = 999999999; /* max size for transfer */ - } - else { + size = 999999999; /* max size for transfer */ + } else { size = AFS_CHUNKSIZE(abyte); /* expected max size */ /* don't read past end of good data on server */ if (Position + size > maxGoodLength) size = maxGoodLength - Position; - if (size < 0) size = 0; /* Handle random races */ + if (size < 0) + size = 0; /* Handle random races */ if (size > tdc->f.chunkBytes) { /* pre-reserve space for file */ afs_AdjustSize(tdc, size); /* changes chunkBytes */ /* max size for transfer still in size */ } } - if (afs_mariner && !tdc->f.chunk) - afs_MarinerLog("fetch$Fetching", avc); /* , Position, size, afs_indexCounter );*/ + if (afs_mariner && !tdc->f.chunk) + afs_MarinerLog("fetch$Fetching", avc); /* , Position, size, afs_indexCounter ); */ /* * Right now, we only have one tool, and it's a hammer. So, we * fetch the whole file. */ DZap(&tdc->f.inode); /* pages in cache may be old */ #ifdef IHINT - if (file = tdc->ihint) { - if (tdc->f.inode == file->inum ) - usedihint++; - else { - tdc->ihint = 0; - afs_UFSClose(file); - file = 0; - nihints--; - file = osi_UFSOpen(tdc->f.inode); - } - } - else + if (file = tdc->ihint) { + if (tdc->f.inode == file->inum) + usedihint++; + else { + tdc->ihint = 0; + afs_UFSClose(file); + file = 0; + nihints--; + file = osi_UFSOpen(tdc->f.inode); + } + } else #endif /* IHINT */ - file = afs_CFileOpen(tdc->f.inode); + file = afs_CFileOpen(tdc->f.inode); afs_RemoveVCB(&avc->fid); tdc->f.states |= DWriting; tdc->dflags |= DFFetching; @@ -2021,13 +2060,13 @@ RetryLookup: if (tdc->mflags & DFFetchReq) { tdc->mflags &= ~DFFetchReq; if (afs_osi_Wakeup(&tdc->validPos) == 0) - afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_INT32, tdc->dflags); + afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_INT32, __LINE__, + ICL_TYPE_POINTER, tdc, ICL_TYPE_INT32, + tdc->dflags); } - tsmall = (struct tlocal1 *) osi_AllocLargeSpace(sizeof(struct tlocal1)); + tsmall = + (struct tlocal1 *)osi_AllocLargeSpace(sizeof(struct tlocal1)); setVcacheStatus = 0; #ifndef AFS_NOSTATS /* @@ -2044,11 +2083,11 @@ RetryLookup: #endif /* AFS_NOSTATS */ /* this is a cache miss */ afs_Trace4(afs_iclSetp, CM_TRACE_FETCHPROC, ICL_TYPE_POINTER, avc, - ICL_TYPE_FID, &(avc->fid), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(Position), - ICL_TYPE_INT32, size); + ICL_TYPE_FID, &(avc->fid), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(Position), ICL_TYPE_INT32, size); - if (size) afs_stats_cmperf.dcacheMisses++; + if (size) + afs_stats_cmperf.dcacheMisses++; code = 0; /* * Dynamic root support: fetch data from local memory. @@ -2063,7 +2102,8 @@ RetryLookup: dynrootLen -= Position; if (size > dynrootLen) size = dynrootLen; - if (size < 0) size = 0; + if (size < 0) + size = 0; code = afs_CFileWrite(file, 0, dynrootDir, size); afs_PutDynroot(); @@ -2073,242 +2113,269 @@ RetryLookup: code = -1; tdc->validPos = Position + size; - afs_CFileTruncate(file, size); /* prune it */ + afs_CFileTruncate(file, size); /* prune it */ } else - /* - * Not a dynamic vnode: do the real fetch. - */ - do { /* - * Locks held: - * avc->lock(R) if setLocks && !slowPass - * avc->lock(W) if !setLocks || slowPass - * tdc->lock(W) + * Not a dynamic vnode: do the real fetch. */ + do { + /* + * Locks held: + * avc->lock(R) if setLocks && !slowPass + * avc->lock(W) if !setLocks || slowPass + * tdc->lock(W) + */ - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); - if (tc) { - afs_int32 length_hi, length, bytes; + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + if (tc) { + afs_int32 length_hi, length, bytes; #ifndef AFS_NOSTATS - numFetchLoops++; - if (fromReplica) - (accP->numReplicasAccessed)++; - + numFetchLoops++; + if (fromReplica) + (accP->numReplicasAccessed)++; + #endif /* AFS_NOSTATS */ - if (!setLocks || slowPass) { - avc->callback = tc->srvr->server; - } else { - newCallback = tc->srvr->server; - setNewCallback = 1; - } - i = osi_Time(); - RX_AFS_GUNLOCK(); - tcall = rx_NewCall(tc->id); - RX_AFS_GLOCK(); + if (!setLocks || slowPass) { + avc->callback = tc->srvr->server; + } else { + newCallback = tc->srvr->server; + setNewCallback = 1; + } + i = osi_Time(); + RX_AFS_GUNLOCK(); + tcall = rx_NewCall(tc->id); + RX_AFS_GLOCK(); - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHDATA); + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHDATA); #ifdef AFS_64BIT_CLIENT - length_hi = code = 0; - if (!afs_serverHasNo64Bit(tc)) { - tsize = size; - RX_AFS_GUNLOCK(); - code = StartRXAFS_FetchData64(tcall, - (struct AFSFid *) &avc->fid.Fid, - Position, tsize); - if (code != 0) { - RX_AFS_GLOCK(); - afs_Trace2(afs_iclSetp, CM_TRACE_FETCH64CODE, - ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code); - } else { - bytes = rx_Read(tcall, (char *)&length_hi, sizeof(afs_int32)); - RX_AFS_GLOCK(); - if (bytes == sizeof(afs_int32)) { - length_hi = ntohl(length_hi); - } else { - length_hi = 0; - code = rx_Error(tcall); + length_hi = code = 0; + if (!afs_serverHasNo64Bit(tc)) { + tsize = size; + RX_AFS_GUNLOCK(); + code = + StartRXAFS_FetchData64(tcall, + (struct AFSFid *)&avc->fid. + Fid, Position, tsize); + if (code != 0) { + RX_AFS_GLOCK(); + afs_Trace2(afs_iclSetp, CM_TRACE_FETCH64CODE, + ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, + code); + } else { + bytes = + rx_Read(tcall, (char *)&length_hi, + sizeof(afs_int32)); + RX_AFS_GLOCK(); + if (bytes == sizeof(afs_int32)) { + length_hi = ntohl(length_hi); + } else { + length_hi = 0; + code = rx_Error(tcall); + RX_AFS_GUNLOCK(); + code1 = rx_EndCall(tcall, code); + RX_AFS_GLOCK(); + tcall = (struct rx_call *)0; + } + } + } + if (code == RXGEN_OPCODE || afs_serverHasNo64Bit(tc)) { + if (Position > 0x7FFFFFFF) { + code = EFBIG; + } else { + afs_int32 pos; + pos = Position; RX_AFS_GUNLOCK(); - code1 = rx_EndCall(tcall, code); - RX_AFS_GLOCK(); - tcall = (struct rx_call *) 0; + if (!tcall) + tcall = rx_NewCall(tc->id); + code = + StartRXAFS_FetchData(tcall, (struct AFSFid *) + &avc->fid.Fid, pos, + size); + RX_AFS_GLOCK(); } + afs_serverSetNo64Bit(tc); } - } - if (code == RXGEN_OPCODE || afs_serverHasNo64Bit(tc)) { - if (Position > 0x7FFFFFFF) { - code = EFBIG; - } else { - afs_int32 pos; - pos = Position; + if (code == 0) { RX_AFS_GUNLOCK(); - if (!tcall) - tcall = rx_NewCall(tc->id); - code = StartRXAFS_FetchData(tcall, - (struct AFSFid *) &avc->fid.Fid, pos, size); - RX_AFS_GLOCK(); - } - afs_serverSetNo64Bit(tc); - } - if (code == 0) { - RX_AFS_GUNLOCK(); - bytes = rx_Read(tcall, (char *)&length, sizeof(afs_int32)); - RX_AFS_GLOCK(); - if (bytes == sizeof(afs_int32)) { - length = ntohl(length); - } else { - code = rx_Error(tcall); + bytes = + rx_Read(tcall, (char *)&length, + sizeof(afs_int32)); + RX_AFS_GLOCK(); + if (bytes == sizeof(afs_int32)) { + length = ntohl(length); + } else { + code = rx_Error(tcall); + } } - } - FillInt64(lengthFound, length_hi, length); - afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64LENG, - ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(lengthFound)); + FillInt64(lengthFound, length_hi, length); + afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64LENG, + ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code, + ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(lengthFound)); #else /* AFS_64BIT_CLIENT */ - RX_AFS_GUNLOCK(); - code = StartRXAFS_FetchData(tcall, - (struct AFSFid *) &avc->fid.Fid, - Position, size); - RX_AFS_GLOCK(); - if (code == 0) { - RX_AFS_GUNLOCK(); - bytes = rx_Read(tcall, (char *)&length, sizeof(afs_int32)); + RX_AFS_GUNLOCK(); + code = + StartRXAFS_FetchData(tcall, + (struct AFSFid *)&avc->fid.Fid, + Position, size); RX_AFS_GLOCK(); - if (bytes == sizeof(afs_int32)) { - length = ntohl(length); - } else { - code = rx_Error(tcall); + if (code == 0) { + RX_AFS_GUNLOCK(); + bytes = + rx_Read(tcall, (char *)&length, + sizeof(afs_int32)); + RX_AFS_GLOCK(); + if (bytes == sizeof(afs_int32)) { + length = ntohl(length); + } else { + code = rx_Error(tcall); + } } - } #endif /* AFS_64BIT_CLIENT */ - if (code == 0) { + if (code == 0) { #ifndef AFS_NOSTATS - xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[AFS_STATS_FS_XFERIDX_FETCHDATA]); - osi_GetuTime(&xferStartTime); - - code = afs_CacheFetchProc(tcall, file, - (afs_size_t) Position, tdc, avc, - &bytesToXfer, &bytesXferred, length); - - osi_GetuTime(&xferStopTime); - (xferP->numXfers)++; - if (!code) { - (xferP->numSuccesses)++; - afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_FETCHDATA] += bytesXferred; - (xferP->sumBytes) += (afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_FETCHDATA] >> 10); - afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_FETCHDATA] &= 0x3FF; - if (bytesXferred < xferP->minBytes) - xferP->minBytes = bytesXferred; - if (bytesXferred > xferP->maxBytes) - xferP->maxBytes = bytesXferred; - - /* - * Tally the size of the object. Note: we tally the actual size, - * NOT the number of bytes that made it out over the wire. - */ - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0) - (xferP->count[0])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET1) - (xferP->count[1])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET2) - (xferP->count[2])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET3) - (xferP->count[3])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET4) - (xferP->count[4])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET5) - (xferP->count[5])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET6) - (xferP->count[6])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET7) - (xferP->count[7])++; - else - (xferP->count[8])++; - - afs_stats_GetDiff(elapsedTime, xferStartTime, xferStopTime); - afs_stats_AddTo((xferP->sumTime), elapsedTime); - afs_stats_SquareAddTo((xferP->sqrTime), elapsedTime); - if (afs_stats_TimeLessThan(elapsedTime, (xferP->minTime))) { - afs_stats_TimeAssign((xferP->minTime), elapsedTime); - } - if (afs_stats_TimeGreaterThan(elapsedTime, (xferP->maxTime))) { - afs_stats_TimeAssign((xferP->maxTime), elapsedTime); - } - } + xferP = + &(afs_stats_cmfullperf.rpc. + fsXferTimes[AFS_STATS_FS_XFERIDX_FETCHDATA]); + osi_GetuTime(&xferStartTime); + + code = + afs_CacheFetchProc(tcall, file, + (afs_size_t) Position, tdc, + avc, &bytesToXfer, + &bytesXferred, length); + + osi_GetuTime(&xferStopTime); + (xferP->numXfers)++; + if (!code) { + (xferP->numSuccesses)++; + afs_stats_XferSumBytes + [AFS_STATS_FS_XFERIDX_FETCHDATA] += + bytesXferred; + (xferP->sumBytes) += + (afs_stats_XferSumBytes + [AFS_STATS_FS_XFERIDX_FETCHDATA] >> 10); + afs_stats_XferSumBytes + [AFS_STATS_FS_XFERIDX_FETCHDATA] &= 0x3FF; + if (bytesXferred < xferP->minBytes) + xferP->minBytes = bytesXferred; + if (bytesXferred > xferP->maxBytes) + xferP->maxBytes = bytesXferred; + + /* + * Tally the size of the object. Note: we tally the actual size, + * NOT the number of bytes that made it out over the wire. + */ + if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0) + (xferP->count[0])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET1) + (xferP->count[1])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET2) + (xferP->count[2])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET3) + (xferP->count[3])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET4) + (xferP->count[4])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET5) + (xferP->count[5])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET6) + (xferP->count[6])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET7) + (xferP->count[7])++; + else + (xferP->count[8])++; + + afs_stats_GetDiff(elapsedTime, xferStartTime, + xferStopTime); + afs_stats_AddTo((xferP->sumTime), elapsedTime); + afs_stats_SquareAddTo((xferP->sqrTime), + elapsedTime); + if (afs_stats_TimeLessThan + (elapsedTime, (xferP->minTime))) { + afs_stats_TimeAssign((xferP->minTime), + elapsedTime); + } + if (afs_stats_TimeGreaterThan + (elapsedTime, (xferP->maxTime))) { + afs_stats_TimeAssign((xferP->maxTime), + elapsedTime); + } + } #else - code = afs_CacheFetchProc(tcall, file, Position, tdc, avc, 0, 0, length); + code = + afs_CacheFetchProc(tcall, file, Position, tdc, + avc, 0, 0, length); #endif /* AFS_NOSTATS */ - } - if (code == 0) { + } + if (code == 0) { + RX_AFS_GUNLOCK(); + code = + EndRXAFS_FetchData(tcall, &tsmall->OutStatus, + &tsmall->CallBack, + &tsmall->tsync); + RX_AFS_GLOCK(); + } + XSTATS_END_TIME; RX_AFS_GUNLOCK(); - code = EndRXAFS_FetchData(tcall, - &tsmall->OutStatus, - &tsmall->CallBack, - &tsmall->tsync); + if (tcall) + code1 = rx_EndCall(tcall, code); RX_AFS_GLOCK(); - } - XSTATS_END_TIME; - RX_AFS_GUNLOCK(); - if (tcall) - code1 = rx_EndCall(tcall, code); - RX_AFS_GLOCK(); - } - else { - code = -1; - } - if ( !code && code1 ) - code = code1; - - if (code == 0) { - /* callback could have been broken (or expired) in a race here, - * but we return the data anyway. It's as good as we knew about - * when we started. */ - /* - * validPos is updated by CacheFetchProc, and can only be - * modifed under a dcache write lock, which we've blocked out - */ - size = tdc->validPos - Position; /* actual segment size */ - if (size < 0) size = 0; - afs_CFileTruncate(file, size); /* prune it */ - } - else { - if (!setLocks || slowPass) { - ObtainWriteLock(&afs_xcbhash, 453); - afs_DequeueCallback(avc); - avc->states &= ~(CStatd | CUnique); - avc->callback = NULL; - ReleaseWriteLock(&afs_xcbhash); - if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR)) - osi_dnlc_purgedp(avc); } else { - /* Something lost. Forget about performance, and go - * back with a vcache write lock. + code = -1; + } + if (!code && code1) + code = code1; + + if (code == 0) { + /* callback could have been broken (or expired) in a race here, + * but we return the data anyway. It's as good as we knew about + * when we started. */ + /* + * validPos is updated by CacheFetchProc, and can only be + * modifed under a dcache write lock, which we've blocked out */ - afs_CFileTruncate(file, 0); - afs_AdjustSize(tdc, 0); - afs_CFileClose(file); - osi_FreeLargeSpace(tsmall); - tsmall = 0; - ReleaseWriteLock(&tdc->lock); - afs_PutDCache(tdc); - tdc = 0; - ReleaseReadLock(&avc->lock); - slowPass = 1; - goto RetryGetDCache; + size = tdc->validPos - Position; /* actual segment size */ + if (size < 0) + size = 0; + afs_CFileTruncate(file, size); /* prune it */ + } else { + if (!setLocks || slowPass) { + ObtainWriteLock(&afs_xcbhash, 453); + afs_DequeueCallback(avc); + avc->states &= ~(CStatd | CUnique); + avc->callback = NULL; + ReleaseWriteLock(&afs_xcbhash); + if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR)) + osi_dnlc_purgedp(avc); + } else { + /* Something lost. Forget about performance, and go + * back with a vcache write lock. + */ + afs_CFileTruncate(file, 0); + afs_AdjustSize(tdc, 0); + afs_CFileClose(file); + osi_FreeLargeSpace(tsmall); + tsmall = 0; + ReleaseWriteLock(&tdc->lock); + afs_PutDCache(tdc); + tdc = 0; + ReleaseReadLock(&avc->lock); + slowPass = 1; + goto RetryGetDCache; + } } - } - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_FETCHDATA, - SHARED_LOCK, NULL)); + } while (afs_Analyze + (tc, code, &avc->fid, areq, + AFS_STATS_FS_RPCIDX_FETCHDATA, SHARED_LOCK, NULL)); /* * Locks held: @@ -2332,12 +2399,11 @@ RetryLookup: tdc->dflags &= ~DFFetching; if (afs_osi_Wakeup(&tdc->validPos) == 0) - afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, tdc, - ICL_TYPE_INT32, tdc->dflags); - if (avc->execsOrWriters == 0) tdc->f.states &= ~DWriting; + afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_INT32, __LINE__, ICL_TYPE_POINTER, + tdc, ICL_TYPE_INT32, tdc->dflags); + if (avc->execsOrWriters == 0) + tdc->f.states &= ~DWriting; /* now, if code != 0, we have an error and should punt. * note that we have the vcache write lock, either because @@ -2355,7 +2421,7 @@ RetryLookup: afs_PutDCache(tdc); ObtainWriteLock(&afs_xcbhash, 454); afs_DequeueCallback(avc); - avc->states &= ~( CStatd | CUnique ); + avc->states &= ~(CStatd | CUnique); ReleaseWriteLock(&afs_xcbhash); if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR)) osi_dnlc_purgedp(avc); @@ -2365,12 +2431,12 @@ RetryLookup: */ osi_Assert(!setLocks || slowPass); tdc = NULL; - goto done; + goto done; } /* otherwise we copy in the just-fetched info */ afs_CFileClose(file); - afs_AdjustSize(tdc, size); /* new size */ + afs_AdjustSize(tdc, size); /* new size */ /* * Copy appropriate fields into vcache. Status is * copied later where we selectively acquire the @@ -2380,20 +2446,21 @@ RetryLookup: afs_ProcessFS(avc, &tsmall->OutStatus, areq); else setVcacheStatus = 1; - hset64(tdc->f.versionNo, tsmall->OutStatus.dataVersionHigh, tsmall->OutStatus.DataVersion); + hset64(tdc->f.versionNo, tsmall->OutStatus.dataVersionHigh, + tsmall->OutStatus.DataVersion); tdc->dflags |= DFEntryMod; afs_indexFlags[tdc->index] |= IFEverUsed; ConvertWToSLock(&tdc->lock); - } /*Data version numbers don't match*/ + } /*Data version numbers don't match */ else { /* * Data version numbers match. */ afs_stats_cmperf.dcacheHits++; - } /*Data version numbers match*/ + } /*Data version numbers match */ - updateV2DC(setLocks, avc, tdc, 335); /* set hint */ -done: + updateV2DC(setLocks, avc, tdc, 335); /* set hint */ + done: /* * Locks held: * avc->lock(R) if setLocks && !slowPass @@ -2455,7 +2522,7 @@ done: if (tsmall) { hset64(statusDV, tsmall->OutStatus.dataVersionHigh, - tsmall->OutStatus.DataVersion); + tsmall->OutStatus.DataVersion); if (setVcacheStatus && avc->m.Length != tsmall->OutStatus.Length) doVcacheUpdate = 1; @@ -2482,15 +2549,19 @@ done: /* Check if we need to perform any last-minute fixes with a write-lock */ if (!setLocks || doVcacheUpdate) { - if (setNewCallback) avc->callback = newCallback; - if (tsmall && setVcacheStatus) afs_ProcessFS(avc, &tsmall->OutStatus, areq); - if (setLocks) ReleaseWriteLock(&avc->lock); + if (setNewCallback) + avc->callback = newCallback; + if (tsmall && setVcacheStatus) + afs_ProcessFS(avc, &tsmall->OutStatus, areq); + if (setLocks) + ReleaseWriteLock(&avc->lock); } - if (tsmall) osi_FreeLargeSpace(tsmall); + if (tsmall) + osi_FreeLargeSpace(tsmall); return tdc; -} /*afs_GetDCache*/ +} /*afs_GetDCache */ /* @@ -2506,10 +2577,11 @@ done: * Environment: * The afs_xdcache is write-locked through this whole affair. */ -void afs_WriteThroughDSlots(void) +void +afs_WriteThroughDSlots(void) { register struct dcache *tdc; - register afs_int32 i, touchedit=0; + register afs_int32 i, touchedit = 0; struct dcache **ents; int entmax, entcount; @@ -2520,11 +2592,11 @@ void afs_WriteThroughDSlots(void) * holding afs_xdcache. So we enter xdcache, get a reference * for every dcache entry, and exit xdcache. */ - MObtainWriteLock(&afs_xdcache,283); + MObtainWriteLock(&afs_xdcache, 283); entmax = afs_cacheFiles; ents = afs_osi_Alloc(entmax * sizeof(struct dcache *)); entcount = 0; - for(i = 0; i < afs_cacheFiles; i++) { + for (i = 0; i < afs_cacheFiles; i++) { tdc = afs_indexTable[i]; /* Grab tlock in case the existing refcount isn't zero */ @@ -2560,7 +2632,8 @@ void afs_WriteThroughDSlots(void) MReleaseWriteLock(&afs_xdcache); touchedit = 1; } - if (wrLock) ReleaseWriteLock(&tdc->lock); + if (wrLock) + ReleaseWriteLock(&tdc->lock); } afs_PutDCache(tdc); @@ -2599,17 +2672,20 @@ void afs_WriteThroughDSlots(void) * Must be called with afs_xdcache write-locked. */ -struct dcache *afs_MemGetDSlot(register afs_int32 aslot, register struct dcache *tmpdc) +struct dcache * +afs_MemGetDSlot(register afs_int32 aslot, register struct dcache *tmpdc) { register struct dcache *tdc; int existing = 0; AFS_STATCNT(afs_MemGetDSlot); - if (CheckLock(&afs_xdcache) != -1) osi_Panic("getdslot nolock"); - if (aslot < 0 || aslot >= afs_cacheFiles) osi_Panic("getdslot slot"); + if (CheckLock(&afs_xdcache) != -1) + osi_Panic("getdslot nolock"); + if (aslot < 0 || aslot >= afs_cacheFiles) + osi_Panic("getdslot slot"); tdc = afs_indexTable[aslot]; if (tdc) { - QRemove(&tdc->lruq); /* move to queue head */ + QRemove(&tdc->lruq); /* move to queue head */ QAdd(&afs_DLRU, &tdc->lruq); /* We're holding afs_xdcache, but get tlock in case refCount != 0 */ ObtainWriteLock(&tdc->tlock, 624); @@ -2618,29 +2694,30 @@ struct dcache *afs_MemGetDSlot(register afs_int32 aslot, register struct dcache return tdc; } if (tmpdc == NULL) { - if (!afs_freeDSList) afs_GetDownDSlot(4); + if (!afs_freeDSList) + afs_GetDownDSlot(4); if (!afs_freeDSList) { /* none free, making one is better than a panic */ afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */ - tdc = (struct dcache *) afs_osi_Alloc(sizeof (struct dcache)); + tdc = (struct dcache *)afs_osi_Alloc(sizeof(struct dcache)); #ifdef KERNEL_HAVE_PIN pin((char *)tdc, sizeof(struct dcache)); /* XXX */ #endif } else { tdc = afs_freeDSList; - afs_freeDSList = (struct dcache *) tdc->lruq.next; + afs_freeDSList = (struct dcache *)tdc->lruq.next; existing = 1; } tdc->dflags = 0; /* up-to-date, not in free q */ tdc->mflags = 0; QAdd(&afs_DLRU, &tdc->lruq); - if (tdc->lruq.prev == &tdc->lruq) osi_Panic("lruq 3"); - } - else { + if (tdc->lruq.prev == &tdc->lruq) + osi_Panic("lruq 3"); + } else { tdc = tmpdc; tdc->f.states = 0; } - + /* initialize entry */ tdc->f.fid.Cell = 0; tdc->f.fid.Fid.Volume = 0; @@ -2662,12 +2739,12 @@ struct dcache *afs_MemGetDSlot(register afs_int32 aslot, register struct dcache RWLOCK_INIT(&tdc->tlock, "dcache tlock"); RWLOCK_INIT(&tdc->mflock, "dcache flock"); ObtainReadLock(&tdc->tlock); - + if (tmpdc == NULL) afs_indexTable[aslot] = tdc; return tdc; -} /*afs_MemGetDSlot*/ +} /*afs_MemGetDSlot */ unsigned int last_error = 0, lasterrtime = 0; @@ -2685,7 +2762,8 @@ unsigned int last_error = 0, lasterrtime = 0; * Environment: * afs_xdcache lock write-locked. */ -struct dcache *afs_UFSGetDSlot(register afs_int32 aslot, register struct dcache *tmpdc) +struct dcache * +afs_UFSGetDSlot(register afs_int32 aslot, register struct dcache *tmpdc) { register afs_int32 code; register struct dcache *tdc; @@ -2693,11 +2771,13 @@ struct dcache *afs_UFSGetDSlot(register afs_int32 aslot, register struct dcache int entryok; AFS_STATCNT(afs_UFSGetDSlot); - if (CheckLock(&afs_xdcache) != -1) osi_Panic("getdslot nolock"); - if (aslot < 0 || aslot >= afs_cacheFiles) osi_Panic("getdslot slot"); + if (CheckLock(&afs_xdcache) != -1) + osi_Panic("getdslot nolock"); + if (aslot < 0 || aslot >= afs_cacheFiles) + osi_Panic("getdslot slot"); tdc = afs_indexTable[aslot]; if (tdc) { - QRemove(&tdc->lruq); /* move to queue head */ + QRemove(&tdc->lruq); /* move to queue head */ QAdd(&afs_DLRU, &tdc->lruq); /* Grab tlock in case refCount != 0 */ ObtainWriteLock(&tdc->tlock, 625); @@ -2711,36 +2791,39 @@ struct dcache *afs_UFSGetDSlot(register afs_int32 aslot, register struct dcache * we have to allocate one. */ if (tmpdc == NULL) { - if (!afs_freeDSList) afs_GetDownDSlot(4); + if (!afs_freeDSList) + afs_GetDownDSlot(4); if (!afs_freeDSList) { /* none free, making one is better than a panic */ afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */ - tdc = (struct dcache *) afs_osi_Alloc(sizeof (struct dcache)); + tdc = (struct dcache *)afs_osi_Alloc(sizeof(struct dcache)); #ifdef KERNEL_HAVE_PIN pin((char *)tdc, sizeof(struct dcache)); /* XXX */ #endif } else { tdc = afs_freeDSList; - afs_freeDSList = (struct dcache *) tdc->lruq.next; + afs_freeDSList = (struct dcache *)tdc->lruq.next; existing = 1; } tdc->dflags = 0; /* up-to-date, not in free q */ tdc->mflags = 0; QAdd(&afs_DLRU, &tdc->lruq); - if (tdc->lruq.prev == &tdc->lruq) osi_Panic("lruq 3"); - } - else { + if (tdc->lruq.prev == &tdc->lruq) + osi_Panic("lruq 3"); + } else { tdc = tmpdc; tdc->f.states = 0; tdc->ihint = 0; } /* - * Seek to the aslot'th entry and read it in. - */ - code = afs_osi_Read(afs_cacheInodep, sizeof(struct fcache) * aslot + - sizeof(struct afs_fheader), - (char *)(&tdc->f), sizeof(struct fcache)); + * Seek to the aslot'th entry and read it in. + */ + code = + afs_osi_Read(afs_cacheInodep, + sizeof(struct fcache) * aslot + + sizeof(struct afs_fheader), (char *)(&tdc->f), + sizeof(struct fcache)); entryok = 1; if (code != sizeof(struct fcache)) entryok = 0; @@ -2785,7 +2868,7 @@ struct dcache *afs_UFSGetDSlot(register afs_int32 aslot, register struct dcache afs_indexTable[aslot] = tdc; return tdc; -} /*afs_UFSGetDSlot*/ +} /*afs_UFSGetDSlot */ @@ -2806,11 +2889,13 @@ struct dcache *afs_UFSGetDSlot(register afs_int32 aslot, register struct dcache * The reference count is not changed. */ -int afs_WriteDCache(register struct dcache *adc, int atime) +int +afs_WriteDCache(register struct dcache *adc, int atime) { register afs_int32 code; - if (cacheDiskType == AFS_FCACHE_TYPE_MEM) return 0; + if (cacheDiskType == AFS_FCACHE_TYPE_MEM) + return 0; AFS_STATCNT(afs_WriteDCache); if (atime) adc->f.modTime = osi_Time(); @@ -2818,10 +2903,13 @@ int afs_WriteDCache(register struct dcache *adc, int atime) * Seek to the right dcache slot and write the in-memory image out to disk. */ afs_cellname_write(); - code = afs_osi_Write(afs_cacheInodep, sizeof(struct fcache) * adc->index + - sizeof(struct afs_fheader), - (char *)(&adc->f), sizeof(struct fcache)); - if (code != sizeof(struct fcache)) return EIO; + code = + afs_osi_Write(afs_cacheInodep, + sizeof(struct fcache) * adc->index + + sizeof(struct afs_fheader), (char *)(&adc->f), + sizeof(struct fcache)); + if (code != sizeof(struct fcache)) + return EIO; return 0; } @@ -2841,7 +2929,8 @@ int afs_WriteDCache(register struct dcache *adc, int atime) * Nothing interesting. */ -int afs_wakeup(register struct vcache *avc) +int +afs_wakeup(register struct vcache *avc) { register int i; register struct brequest *tb; @@ -2891,7 +2980,8 @@ int afs_wakeup(register struct vcache *avc) * This function is called only during initialization. */ -int afs_InitCacheFile(char *afile, ino_t ainode) +int +afs_InitCacheFile(char *afile, ino_t ainode) { register afs_int32 code; #if defined(AFS_LINUX22_ENV) @@ -2907,9 +2997,10 @@ int afs_InitCacheFile(char *afile, ino_t ainode) AFS_STATCNT(afs_InitCacheFile); index = afs_stats_cmperf.cacheNumEntries; - if (index >= afs_cacheFiles) return EINVAL; + if (index >= afs_cacheFiles) + return EINVAL; - MObtainWriteLock(&afs_xdcache,282); + MObtainWriteLock(&afs_xdcache, 282); tdc = afs_GetDSlot(index, NULL); ReleaseReadLock(&tdc->tlock); MReleaseWriteLock(&afs_xdcache); @@ -2917,11 +3008,7 @@ int afs_InitCacheFile(char *afile, ino_t ainode) ObtainWriteLock(&tdc->lock, 621); MObtainWriteLock(&afs_xdcache, 622); if (afile) { - code = gop_lookupname(afile, - AFS_UIOSYS, - 0, - NULL, - &filevp); + code = gop_lookupname(afile, AFS_UIOSYS, 0, NULL, &filevp); if (code) { ReleaseWriteLock(&afs_xdcache); ReleaseWriteLock(&tdc->lock); @@ -2944,21 +3031,22 @@ int afs_InitCacheFile(char *afile, ino_t ainode) AFS_RELE(filevp); #endif #endif /* AFS_LINUX22_ENV */ - } - else { + } else { tdc->f.inode = ainode; } fileIsBad = 0; - if ((tdc->f.states & DWriting) || - tdc->f.fid.Fid.Volume == 0) fileIsBad = 1; + if ((tdc->f.states & DWriting) || tdc->f.fid.Fid.Volume == 0) + fileIsBad = 1; tfile = osi_UFSOpen(tdc->f.inode); code = afs_osi_Stat(tfile, &tstat); - if (code) osi_Panic("initcachefile stat"); + if (code) + osi_Panic("initcachefile stat"); /* * If file size doesn't match the cache info file, it's probably bad. */ - if (tdc->f.chunkBytes != tstat.size) fileIsBad = 1; + if (tdc->f.chunkBytes != tstat.size) + fileIsBad = 1; tdc->f.chunkBytes = 0; /* @@ -2967,14 +3055,17 @@ int afs_InitCacheFile(char *afile, ino_t ainode) * the cache info file may be incorrectly identified, and so slot * may be bad. */ - if (cacheInfoModTime < tstat.mtime + 120) fileIsBad = 1; - if (cacheInfoModTime < tdc->f.modTime + 120) fileIsBad = 1; + if (cacheInfoModTime < tstat.mtime + 120) + fileIsBad = 1; + if (cacheInfoModTime < tdc->f.modTime + 120) + fileIsBad = 1; /* In case write through is behind, make sure cache items entry is * at least as new as the chunk. */ - if (tdc->f.modTime < tstat.mtime) fileIsBad = 1; + if (tdc->f.modTime < tstat.mtime) + fileIsBad = 1; if (fileIsBad) { - tdc->f.fid.Fid.Volume = 0; /* not in the hash table */ + tdc->f.fid.Fid.Volume = 0; /* not in the hash table */ if (tstat.size != 0) osi_UFSTruncate(tfile, 0); /* put entry in free cache slot list */ @@ -2983,19 +3074,18 @@ int afs_InitCacheFile(char *afile, ino_t ainode) afs_freeDCCount++; afs_indexFlags[index] |= IFFree; afs_indexUnique[index] = 0; - } - else { + } else { /* * We must put this entry in the appropriate hash tables. * Note that i is still set from the above DCHash call */ code = DCHash(&tdc->f.fid, tdc->f.chunk); - afs_dcnextTbl[tdc->index] = afs_dchashTbl[code]; + afs_dcnextTbl[tdc->index] = afs_dchashTbl[code]; afs_dchashTbl[code] = tdc->index; code = DVHash(&tdc->f.fid); afs_dvnextTbl[tdc->index] = afs_dvhashTbl[code]; afs_dvhashTbl[code] = tdc->index; - afs_AdjustSize(tdc, tstat.size); /* adjust to new size */ + afs_AdjustSize(tdc, tstat.size); /* adjust to new size */ if (tstat.size > 0) /* has nontrivial amt of data */ afs_indexFlags[index] |= IFEverUsed; @@ -3009,7 +3099,7 @@ int afs_InitCacheFile(char *afile, ino_t ainode) hset32(afs_indexCounter, tstat.atime); } afs_indexUnique[index] = tdc->f.fid.Fid.Unique; - } /*File is not bad*/ + } /*File is not bad */ osi_UFSClose(tfile); tdc->f.states &= ~DWriting; @@ -3037,8 +3127,8 @@ int afs_InitCacheFile(char *afile, ino_t ainode) * Description: * Initialize dcache related variables. */ -void afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, - int aflags) +void +afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, int aflags) { register struct dcache *tdp; int i; @@ -3051,27 +3141,27 @@ void afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, hzero(afs_indexCounter); LOCK_INIT(&afs_xdcache, "afs_xdcache"); - + /* * Set chunk size */ if (achunk) { if (achunk < 0 || achunk > 30) - achunk = 13; /* Use default */ + achunk = 13; /* Use default */ AFS_SETCHUNKSIZE(achunk); } - - if(!aDentries) + + if (!aDentries) aDentries = DDSIZE; - - if(aflags & AFSCALL_INIT_MEMCACHE) { + + if (aflags & AFSCALL_INIT_MEMCACHE) { /* * Use a memory cache instead of a disk cache */ cacheDiskType = AFS_FCACHE_TYPE_MEM; afs_cacheType = &afs_MemCacheOps; - afiles = (afiles < aDentries) ? afiles : aDentries; /* min */ - ablocks = afiles * (AFS_FIRSTCSIZE/1024); + afiles = (afiles < aDentries) ? afiles : aDentries; /* min */ + ablocks = afiles * (AFS_FIRSTCSIZE / 1024); /* ablocks is reported in 1K blocks */ code = afs_InitMemCache(afiles, AFS_FIRSTCSIZE, aflags); if (code != 0) { @@ -3079,64 +3169,69 @@ void afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, printf("afsd: AFS files cannot be accessed.\n\n"); dcacheDisabled = 1; afiles = ablocks = 0; - } - else - printf("Memory cache: Allocating %d dcache entries...", aDentries); + } else + printf("Memory cache: Allocating %d dcache entries...", + aDentries); } else { cacheDiskType = AFS_FCACHE_TYPE_UFS; afs_cacheType = &afs_UfsCacheOps; } - if (aDentries > 512) + if (aDentries > 512) afs_dhashsize = 2048; /* initialize hash tables */ - afs_dvhashTbl = (afs_int32 *) afs_osi_Alloc(afs_dhashsize * sizeof(afs_int32)); - afs_dchashTbl = (afs_int32 *) afs_osi_Alloc(afs_dhashsize * sizeof(afs_int32)); - for(i=0;i< afs_dhashsize;i++) { + afs_dvhashTbl = + (afs_int32 *) afs_osi_Alloc(afs_dhashsize * sizeof(afs_int32)); + afs_dchashTbl = + (afs_int32 *) afs_osi_Alloc(afs_dhashsize * sizeof(afs_int32)); + for (i = 0; i < afs_dhashsize; i++) { afs_dvhashTbl[i] = NULLIDX; afs_dchashTbl[i] = NULLIDX; } afs_dvnextTbl = (afs_int32 *) afs_osi_Alloc(afiles * sizeof(afs_int32)); afs_dcnextTbl = (afs_int32 *) afs_osi_Alloc(afiles * sizeof(afs_int32)); - for(i=0;i< afiles;i++) { + for (i = 0; i < afiles; i++) { afs_dvnextTbl[i] = NULLIDX; afs_dcnextTbl[i] = NULLIDX; } - + /* Allocate and zero the pointer array to the dcache entries */ afs_indexTable = (struct dcache **) afs_osi_Alloc(sizeof(struct dcache *) * afiles); memset((char *)afs_indexTable, 0, sizeof(struct dcache *) * afiles); - afs_indexTimes = (afs_hyper_t *) afs_osi_Alloc(afiles * sizeof(afs_hyper_t)); + afs_indexTimes = + (afs_hyper_t *) afs_osi_Alloc(afiles * sizeof(afs_hyper_t)); memset((char *)afs_indexTimes, 0, afiles * sizeof(afs_hyper_t)); - afs_indexUnique = (afs_int32 *) afs_osi_Alloc(afiles * sizeof(afs_uint32)); + afs_indexUnique = + (afs_int32 *) afs_osi_Alloc(afiles * sizeof(afs_uint32)); memset((char *)afs_indexUnique, 0, afiles * sizeof(afs_uint32)); afs_indexFlags = (u_char *) afs_osi_Alloc(afiles * sizeof(u_char)); memset((char *)afs_indexFlags, 0, afiles * sizeof(char)); - + /* Allocate and thread the struct dcache entries themselves */ tdp = afs_Initial_freeDSList = - (struct dcache *) afs_osi_Alloc(aDentries * sizeof(struct dcache)); + (struct dcache *)afs_osi_Alloc(aDentries * sizeof(struct dcache)); memset((char *)tdp, 0, aDentries * sizeof(struct dcache)); #ifdef KERNEL_HAVE_PIN - pin((char *)afs_indexTable, sizeof(struct dcache *) * afiles);/* XXX */ - pin((char *)afs_indexTimes, sizeof(afs_hyper_t) * afiles); /* XXX */ - pin((char *)afs_indexFlags, sizeof(char) * afiles); /* XXX */ - pin((char *)afs_indexUnique, sizeof(afs_int32) * afiles); /* XXX */ - pin((char *)tdp, aDentries * sizeof(struct dcache)); /* XXX */ - pin((char *)afs_dvhashTbl, sizeof(afs_int32) * afs_dhashsize); /* XXX */ - pin((char *)afs_dchashTbl, sizeof(afs_int32) * afs_dhashsize); /* XXX */ - pin((char *)afs_dcnextTbl, sizeof(afs_int32) * afiles); /* XXX */ - pin((char *)afs_dvnextTbl, sizeof(afs_int32) * afiles); /* XXX */ + pin((char *)afs_indexTable, sizeof(struct dcache *) * afiles); /* XXX */ + pin((char *)afs_indexTimes, sizeof(afs_hyper_t) * afiles); /* XXX */ + pin((char *)afs_indexFlags, sizeof(char) * afiles); /* XXX */ + pin((char *)afs_indexUnique, sizeof(afs_int32) * afiles); /* XXX */ + pin((char *)tdp, aDentries * sizeof(struct dcache)); /* XXX */ + pin((char *)afs_dvhashTbl, sizeof(afs_int32) * afs_dhashsize); /* XXX */ + pin((char *)afs_dchashTbl, sizeof(afs_int32) * afs_dhashsize); /* XXX */ + pin((char *)afs_dcnextTbl, sizeof(afs_int32) * afiles); /* XXX */ + pin((char *)afs_dvnextTbl, sizeof(afs_int32) * afiles); /* XXX */ #endif afs_freeDSList = &tdp[0]; - for(i=0; i < aDentries-1; i++) { - tdp[i].lruq.next = (struct afs_q *) (&tdp[i+1]); + for (i = 0; i < aDentries - 1; i++) { + tdp[i].lruq.next = (struct afs_q *)(&tdp[i + 1]); } - tdp[aDentries-1].lruq.next = (struct afs_q *) 0; + tdp[aDentries - 1].lruq.next = (struct afs_q *)0; - afs_stats_cmperf.cacheBlocksOrig = afs_stats_cmperf.cacheBlocksTotal = afs_cacheBlocks = ablocks; + afs_stats_cmperf.cacheBlocksOrig = afs_stats_cmperf.cacheBlocksTotal = + afs_cacheBlocks = ablocks; afs_ComputeCacheParms(); /* compute parms based on cache size */ afs_dcentries = aDentries; @@ -3148,7 +3243,8 @@ void afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, * shutdown_dcache * */ -void shutdown_dcache(void) +void +shutdown_dcache(void) { int i; @@ -3158,19 +3254,20 @@ void shutdown_dcache(void) afs_osi_Free(afs_indexTimes, afs_cacheFiles * sizeof(afs_hyper_t)); afs_osi_Free(afs_indexUnique, afs_cacheFiles * sizeof(afs_uint32)); afs_osi_Free(afs_indexFlags, afs_cacheFiles * sizeof(u_char)); - afs_osi_Free(afs_Initial_freeDSList, afs_dcentries * sizeof(struct dcache)); + afs_osi_Free(afs_Initial_freeDSList, + afs_dcentries * sizeof(struct dcache)); #ifdef KERNEL_HAVE_PIN unpin((char *)afs_dcnextTbl, afs_cacheFiles * sizeof(afs_int32)); unpin((char *)afs_dvnextTbl, afs_cacheFiles * sizeof(afs_int32)); unpin((char *)afs_indexTable, afs_cacheFiles * sizeof(struct dcache *)); unpin((char *)afs_indexTimes, afs_cacheFiles * sizeof(afs_hyper_t)); unpin((char *)afs_indexUnique, afs_cacheFiles * sizeof(afs_uint32)); - unpin((u_char *)afs_indexFlags, afs_cacheFiles * sizeof(u_char)); + unpin((u_char *) afs_indexFlags, afs_cacheFiles * sizeof(u_char)); unpin(afs_Initial_freeDSList, afs_dcentries * sizeof(struct dcache)); #endif - for(i=0;i< afs_dhashsize;i++) { + for (i = 0; i < afs_dhashsize; i++) { afs_dvhashTbl[i] = NULLIDX; afs_dchashTbl[i] = NULLIDX; } @@ -3179,7 +3276,7 @@ void shutdown_dcache(void) afs_blocksUsed = afs_dcentries = 0; hzero(afs_indexCounter); - afs_freeDCCount = 0; + afs_freeDCCount = 0; afs_freeDCList = NULLIDX; afs_discardDCList = NULLIDX; afs_freeDSList = afs_Initial_freeDSList = 0; diff --git a/src/afs/afs_dynroot.c b/src/afs/afs_dynroot.c index a640b9596..a55949663 100644 --- a/src/afs/afs_dynroot.c +++ b/src/afs/afs_dynroot.c @@ -29,7 +29,7 @@ #include "afs/param.h" #include "afs/stds.h" -#include "afs/sysincludes.h" /* Standard vendor system headers */ +#include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" #include "afs/afs_osi.h" #include "afsint.h" @@ -94,7 +94,8 @@ static int afs_dynSymlinkIndex = 0; /* * Set up a cell for dynroot if it's not there yet. */ -static int afs_dynrootCellInit() +static int +afs_dynrootCellInit() { if (afs_dynrootEnable && !afs_dynrootCell) { afs_int32 cellHosts[MAXCELLHOSTS]; @@ -102,8 +103,9 @@ static int afs_dynrootCellInit() int code; memset(cellHosts, 0, sizeof(cellHosts)); - code = afs_NewCell(AFS_DYNROOT_CELLNAME, cellHosts, CNoSUID | CNoAFSDB, - NULL, 0, 0, 0); + code = + afs_NewCell(AFS_DYNROOT_CELLNAME, cellHosts, CNoSUID | CNoAFSDB, + NULL, 0, 0, 0); if (code) return code; tc = afs_GetCellByName(AFS_DYNROOT_CELLNAME, READ_LOCK); @@ -119,31 +121,32 @@ static int afs_dynrootCellInit() /* * Returns non-zero iff fid corresponds to the top of the dynroot volume. */ -int afs_IsDynrootFid(struct VenusFid *fid) +int +afs_IsDynrootFid(struct VenusFid *fid) { - return - (afs_dynrootEnable && - fid->Cell == afs_dynrootCell && - fid->Fid.Volume == AFS_DYNROOT_VOLUME && - fid->Fid.Vnode == AFS_DYNROOT_VNODE && - fid->Fid.Unique == AFS_DYNROOT_UNIQUE); + return (afs_dynrootEnable && fid->Cell == afs_dynrootCell + && fid->Fid.Volume == AFS_DYNROOT_VOLUME + && fid->Fid.Vnode == AFS_DYNROOT_VNODE + && fid->Fid.Unique == AFS_DYNROOT_UNIQUE); } /* * Obtain the magic dynroot volume Fid. */ -void afs_GetDynrootFid(struct VenusFid *fid) +void +afs_GetDynrootFid(struct VenusFid *fid) { - fid->Cell = afs_dynrootCell; + fid->Cell = afs_dynrootCell; fid->Fid.Volume = AFS_DYNROOT_VOLUME; - fid->Fid.Vnode = AFS_DYNROOT_VNODE; + fid->Fid.Vnode = AFS_DYNROOT_VNODE; fid->Fid.Unique = AFS_DYNROOT_UNIQUE; } /* * Returns non-zero iff avc is a pointer to the dynroot /afs vnode. */ -int afs_IsDynroot(struct vcache *avc) +int +afs_IsDynroot(struct vcache *avc) { return afs_IsDynrootFid(&avc->fid); } @@ -153,7 +156,8 @@ int afs_IsDynroot(struct vcache *avc) * appropriately so that the given file name can be appended. Used for * computing the size of a directory. */ -static void afs_dynroot_computeDirEnt(char *name, int *curPageP, int *curChunkP) +static void +afs_dynroot_computeDirEnt(char *name, int *curPageP, int *curChunkP) { int esize; @@ -170,10 +174,11 @@ static void afs_dynroot_computeDirEnt(char *name, int *curPageP, int *curChunkP) * caller has allocated the directory to be large enough to hold * the necessary entry. */ -static void afs_dynroot_addDirEnt(struct DirHeader *dirHeader, - int *curPageP, int *curChunkP, char *name, int vnode) +static void +afs_dynroot_addDirEnt(struct DirHeader *dirHeader, int *curPageP, + int *curChunkP, char *name, int vnode) { - char *dirBase = (char *) dirHeader; + char *dirBase = (char *)dirHeader; struct PageHeader *pageHeader; struct DirEntry *dirEntry; int sizeOfEntry, i, t1, t2; @@ -191,23 +196,23 @@ static void afs_dynroot_addDirEnt(struct DirHeader *dirHeader, didNewPage = 1; } - pageHeader = (struct PageHeader *) (dirBase + curPage * AFS_PAGESIZE); + pageHeader = (struct PageHeader *)(dirBase + curPage * AFS_PAGESIZE); if (didNewPage) { pageHeader->pgcount = 0; pageHeader->tag = htons(1234); pageHeader->freecount = 0; pageHeader->freebitmap[0] = 0x01; - for (i = 1; i < EPP/8; i++) + for (i = 1; i < EPP / 8; i++) pageHeader->freebitmap[i] = 0; dirHeader->alloMap[curPage] = EPP - 1; } - dirEntry = (struct DirEntry *) (pageHeader + curChunk); - dirEntry->flag = 1; - dirEntry->length = 0; - dirEntry->next = 0; - dirEntry->fid.vnode = htonl(vnode); + dirEntry = (struct DirEntry *)(pageHeader + curChunk); + dirEntry->flag = 1; + dirEntry->length = 0; + dirEntry->next = 0; + dirEntry->fid.vnode = htonl(vnode); dirEntry->fid.vunique = htonl(1); strcpy(dirEntry->name, name); @@ -235,7 +240,8 @@ static void afs_dynroot_addDirEnt(struct DirHeader *dirHeader, * Invalidate the /afs vnode for dynroot; called when the underlying * directory has changed and needs to be re-read. */ -void afs_DynrootInvalidate(void) +void +afs_DynrootInvalidate(void) { afs_int32 retry; struct vcache *tvc; @@ -268,7 +274,8 @@ void afs_DynrootInvalidate(void) * cells. Useful when the list of cells has changed due to * an AFSDB lookup, for instance. */ -static void afs_RebuildDynroot(void) +static void +afs_RebuildDynroot(void) { int cellidx, maxcellidx, i; int aliasidx, maxaliasidx; @@ -295,10 +302,12 @@ static void afs_RebuildDynroot(void) /* Reserve space for "." and ".." */ curChunk += 2; - for (cellidx = 0; ; cellidx++) { + for (cellidx = 0;; cellidx++) { c = afs_GetCellByIndex(cellidx, READ_LOCK); - if (!c) break; - if (c->cellNum == afs_dynrootCell) continue; + if (!c) + break; + if (c->cellNum == afs_dynrootCell) + continue; dotLen = strlen(c->cellName) + 2; dotCell = afs_osi_Alloc(dotLen); @@ -313,9 +322,10 @@ static void afs_RebuildDynroot(void) } maxcellidx = cellidx; - for (aliasidx = 0; ; aliasidx++) { + for (aliasidx = 0;; aliasidx++) { ca = afs_GetCellAlias(aliasidx); - if (!ca) break; + if (!ca) + break; dotLen = strlen(ca->alias) + 2; dotCell = afs_osi_Alloc(dotLen); @@ -345,7 +355,7 @@ static void afs_RebuildDynroot(void) */ curChunk = 13; curPage = 0; - dirHeader = (struct DirHeader *) newDir; + dirHeader = (struct DirHeader *)newDir; dirHeader->header.pgcount = 0; dirHeader->header.tag = htons(1234); @@ -353,7 +363,7 @@ static void afs_RebuildDynroot(void) dirHeader->header.freebitmap[0] = 0xff; dirHeader->header.freebitmap[1] = 0x1f; - for (i = 2; i < EPP/8; i++) + for (i = 2; i < EPP / 8; i++) dirHeader->header.freebitmap[i] = 0; dirHeader->alloMap[0] = EPP - DHE - 1; for (i = 1; i < MAXPAGES; i++) @@ -368,17 +378,19 @@ static void afs_RebuildDynroot(void) for (cellidx = 0; cellidx < maxcellidx; cellidx++) { c = afs_GetCellByIndex(cellidx, READ_LOCK); - if (!c) continue; - if (c->cellNum == afs_dynrootCell) continue; + if (!c) + continue; + if (c->cellNum == afs_dynrootCell) + continue; dotLen = strlen(c->cellName) + 2; dotCell = afs_osi_Alloc(dotLen); strcpy(dotCell, "."); afs_strcat(dotCell, c->cellName); - afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, - c->cellName, VNUM_FROM_CIDX_RW(cellidx, 0)); - afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, - dotCell, VNUM_FROM_CIDX_RW(cellidx, 1)); + afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, c->cellName, + VNUM_FROM_CIDX_RW(cellidx, 0)); + afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, dotCell, + VNUM_FROM_CIDX_RW(cellidx, 1)); afs_osi_Free(dotCell, dotLen); linkCount += 2; @@ -387,16 +399,17 @@ static void afs_RebuildDynroot(void) for (aliasidx = 0; aliasidx < maxaliasidx; aliasidx++) { ca = afs_GetCellAlias(aliasidx); - if (!ca) continue; + if (!ca) + continue; dotLen = strlen(ca->alias) + 2; dotCell = afs_osi_Alloc(dotLen); strcpy(dotCell, "."); afs_strcat(dotCell, ca->alias); - afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, - ca->alias, VNUM_FROM_CAIDX_RW(aliasidx, 0)); - afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, - dotCell, VNUM_FROM_CAIDX_RW(aliasidx, 1)); + afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, ca->alias, + VNUM_FROM_CAIDX_RW(aliasidx, 0)); + afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, dotCell, + VNUM_FROM_CAIDX_RW(aliasidx, 1)); afs_osi_Free(dotCell, dotLen); afs_PutCellAlias(ca); } @@ -404,15 +417,15 @@ static void afs_RebuildDynroot(void) ts = afs_dynSymlinkBase; while (ts) { int vnum = VNUM_FROM_TYPEID(VN_TYPE_SYMLINK, ts->index); - afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, - ts->name, vnum); + afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, ts->name, vnum); ts = ts->next; } ReleaseReadLock(&afs_dynSymlinkLock); ObtainWriteLock(&afs_dynrootDirLock, 549); - if (afs_dynrootDir) afs_osi_Free(afs_dynrootDir, afs_dynrootDirLen); + if (afs_dynrootDir) + afs_osi_Free(afs_dynrootDir, afs_dynrootDirLen); afs_dynrootDir = newDir; afs_dynrootDirLen = dirSize; afs_dynrootDirLinkcnt = linkCount; @@ -424,8 +437,9 @@ static void afs_RebuildDynroot(void) * Returns a pointer to the base of the dynroot directory in memory, * length thereof, and a FetchStatus. */ -void afs_GetDynroot(char **dynrootDir, int *dynrootLen, - struct AFSFetchStatus *status) +void +afs_GetDynroot(char **dynrootDir, int *dynrootLen, + struct AFSFetchStatus *status) { ObtainReadLock(&afs_dynrootDirLock); if (!afs_dynrootDir || afs_dynrootDirVersion != afs_dynrootVersion) { @@ -434,20 +448,22 @@ void afs_GetDynroot(char **dynrootDir, int *dynrootLen, ObtainReadLock(&afs_dynrootDirLock); } - if (dynrootDir) *dynrootDir = afs_dynrootDir; - if (dynrootLen) *dynrootLen = afs_dynrootDirLen; + if (dynrootDir) + *dynrootDir = afs_dynrootDir; + if (dynrootLen) + *dynrootLen = afs_dynrootDirLen; if (status) { memset(status, 0, sizeof(struct AFSFetchStatus)); - status->FileType = Directory; - status->LinkCount = afs_dynrootDirLinkcnt; - status->Length = afs_dynrootDirLen; - status->DataVersion = afs_dynrootVersion; - status->CallerAccess = PRSFS_LOOKUP | PRSFS_READ; + status->FileType = Directory; + status->LinkCount = afs_dynrootDirLinkcnt; + status->Length = afs_dynrootDirLen; + status->DataVersion = afs_dynrootVersion; + status->CallerAccess = PRSFS_LOOKUP | PRSFS_READ; status->AnonymousAccess = PRSFS_LOOKUP | PRSFS_READ; - status->UnixModeBits = 0755; - status->ParentVnode = 1; - status->ParentUnique = 1; + status->UnixModeBits = 0755; + status->ParentVnode = 1; + status->ParentUnique = 1; status->dataVersionHigh = afs_dynrootVersionHigh; } } @@ -455,7 +471,8 @@ void afs_GetDynroot(char **dynrootDir, int *dynrootLen, /* * Puts back the dynroot read lock. */ -void afs_PutDynroot(void) +void +afs_PutDynroot(void) { ReleaseReadLock(&afs_dynrootDirLock); } @@ -465,9 +482,11 @@ void afs_PutDynroot(void) * is non-zero if this vnode is handled by dynroot, in which case * FetchStatus will be filled in. */ -int afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status) +int +afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status) { - if (!afs_dynrootEnable) return 0; + if (!afs_dynrootEnable) + return 0; if (afs_IsDynroot(avc)) { afs_GetDynroot(0, 0, status); @@ -478,8 +497,8 @@ int afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status) /* * Check if this is an entry under /afs, e.g. /afs/cellname. */ - if (avc->fid.Cell == afs_dynrootCell && - avc->fid.Fid.Volume == AFS_DYNROOT_VOLUME) { + if (avc->fid.Cell == afs_dynrootCell + && avc->fid.Fid.Volume == AFS_DYNROOT_VOLUME) { struct cell *c; struct cell_alias *ca; @@ -487,13 +506,13 @@ int afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status) memset(status, 0, sizeof(struct AFSFetchStatus)); - status->FileType = SymbolicLink; - status->LinkCount = 1; - status->DataVersion = 1; - status->CallerAccess = PRSFS_LOOKUP | PRSFS_READ; + status->FileType = SymbolicLink; + status->LinkCount = 1; + status->DataVersion = 1; + status->CallerAccess = PRSFS_LOOKUP | PRSFS_READ; status->AnonymousAccess = PRSFS_LOOKUP | PRSFS_READ; - status->ParentVnode = 1; - status->ParentUnique = 1; + status->ParentVnode = 1; + status->ParentUnique = 1; if (VNUM_TO_VNTYPE(avc->fid.Fid.Vnode) == VN_TYPE_SYMLINK) { struct afs_dynSymlink *ts; @@ -502,7 +521,8 @@ int afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status) ObtainReadLock(&afs_dynSymlinkLock); ts = afs_dynSymlinkBase; while (ts) { - if (ts->index == index) break; + if (ts->index == index) + break; ts = ts->next; } @@ -511,7 +531,7 @@ int afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status) avc->linkData = afs_osi_Alloc(linklen + 1); strcpy(avc->linkData, ts->target); - status->Length = linklen; + status->Length = linklen; status->UnixModeBits = 0755; } ReleaseReadLock(&afs_dynSymlinkLock); @@ -519,8 +539,8 @@ int afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status) return ts ? 1 : 0; } - if (VNUM_TO_VNTYPE(avc->fid.Fid.Vnode) != VN_TYPE_CELL && - VNUM_TO_VNTYPE(avc->fid.Fid.Vnode) != VN_TYPE_ALIAS) { + if (VNUM_TO_VNTYPE(avc->fid.Fid.Vnode) != VN_TYPE_CELL + && VNUM_TO_VNTYPE(avc->fid.Fid.Vnode) != VN_TYPE_ALIAS) { afs_warn("dynroot vnode inconsistency, unknown VNTYPE %d\n", VNUM_TO_VNTYPE(avc->fid.Fid.Vnode)); return 0; @@ -591,7 +611,8 @@ int afs_DynrootNewVnode(struct vcache *avc, struct AFSFetchStatus *status) /* * Enable or disable dynroot. Returns 0 if successful. */ -int afs_SetDynrootEnable(int enable) +int +afs_SetDynrootEnable(int enable) { afs_dynrootEnable = enable; return afs_dynrootCellInit(); @@ -600,7 +621,8 @@ int afs_SetDynrootEnable(int enable) /* * Check if dynroot support is enabled. */ -int afs_GetDynrootEnable(void) +int +afs_GetDynrootEnable(void) { return afs_dynrootEnable; } @@ -608,8 +630,8 @@ int afs_GetDynrootEnable(void) /* * Remove a temporary symlink entry from /afs. */ -int afs_DynrootVOPRemove(struct vcache *avc, struct AFS_UCRED *acred, - char *aname) +int +afs_DynrootVOPRemove(struct vcache *avc, struct AFS_UCRED *acred, char *aname) { struct afs_dynSymlink **tpps; struct afs_dynSymlink *tps; @@ -648,8 +670,9 @@ int afs_DynrootVOPRemove(struct vcache *avc, struct AFS_UCRED *acred, /* * Create a temporary symlink entry in /afs. */ -int afs_DynrootVOPSymlink(struct vcache *avc, struct AFS_UCRED *acred, - char *aname, char *atargetName) +int +afs_DynrootVOPSymlink(struct vcache *avc, struct AFS_UCRED *acred, + char *aname, char *atargetName) { struct afs_dynSymlink *tps; diff --git a/src/afs/afs_exporter.c b/src/afs/afs_exporter.c index 49fc81b98..21646944d 100644 --- a/src/afs/afs_exporter.c +++ b/src/afs/afs_exporter.c @@ -10,21 +10,23 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics gathering code */ +#include "afs/afs_stats.h" /* statistics gathering code */ -struct afs_exporter *root_exported=0; /* Head of "exporters" link list */ -afs_lock_t afs_xexp; +struct afs_exporter *root_exported = 0; /* Head of "exporters" link list */ +afs_lock_t afs_xexp; /* Add a new "afs exporter" entry to the table of exporters. The default initial values of the entry are passed in as parameters. */ static afs_int32 init_xexported = 0; -struct afs_exporter *exporter_add(afs_int32 size, struct exporterops *ops, afs_int32 state, - afs_int32 type, char *data) +struct afs_exporter * +exporter_add(afs_int32 size, struct exporterops *ops, afs_int32 state, + afs_int32 type, char *data) { struct afs_exporter *ex, *op; afs_int32 length; @@ -35,14 +37,14 @@ struct afs_exporter *exporter_add(afs_int32 size, struct exporterops *ops, afs_i LOCK_INIT(&afs_xexp, "afs_xexp"); } length = (size ? size : sizeof(struct afs_exporter)); - ex = (struct afs_exporter *) afs_osi_Alloc(length); + ex = (struct afs_exporter *)afs_osi_Alloc(length); memset((char *)ex, 0, length); - MObtainWriteLock(&afs_xexp,308); + MObtainWriteLock(&afs_xexp, 308); for (op = root_exported; op; op = op->exp_next) { if (!op->exp_next) break; } - if (op) + if (op) op->exp_next = ex; else root_exported = ex; @@ -57,7 +59,8 @@ struct afs_exporter *exporter_add(afs_int32 size, struct exporterops *ops, afs_i /* Returns the "afs exporter" structure of type, "type". NULL is returned if not found */ -struct afs_exporter *exporter_find(int type) +struct afs_exporter * +exporter_find(int type) { struct afs_exporter *op; @@ -74,7 +77,8 @@ struct afs_exporter *exporter_find(int type) } -void shutdown_exporter(void) +void +shutdown_exporter(void) { struct afs_exporter *ex, *op; diff --git a/src/afs/afs_init.c b/src/afs/afs_init.c index b68634de2..661f4955f 100644 --- a/src/afs/afs_init.c +++ b/src/afs/afs_init.c @@ -16,26 +16,27 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/stds.h" #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ /* Exported variables */ -struct osi_dev cacheDev; /*Cache device*/ -afs_int32 cacheInfoModTime; /*Last time cache info modified*/ +struct osi_dev cacheDev; /*Cache device */ +afs_int32 cacheInfoModTime; /*Last time cache info modified */ #if defined(AFS_OSF_ENV) || defined(AFS_DEC_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) -struct mount *afs_cacheVfsp=0; +struct mount *afs_cacheVfsp = 0; #elif defined(AFS_LINUX20_ENV) struct super_block *afs_cacheSBp = 0; #else -struct vfs *afs_cacheVfsp=0; +struct vfs *afs_cacheVfsp = 0; #endif -afs_rwlock_t afs_puttofileLock; /* not used */ -char *afs_sysname = 0; /* So that superuser may change the - * local value of @sys */ +afs_rwlock_t afs_puttofileLock; /* not used */ +char *afs_sysname = 0; /* So that superuser may change the + * local value of @sys */ char *afs_sysnamelist[MAXNUMSYSNAMES]; /* For support of a list of sysname */ int afs_sysnamecount = 0; struct volume *Initialafs_freeVolList; @@ -77,9 +78,10 @@ static struct vnode *volumeVnode; struct cm_initparams cm_initParams; static int afs_cacheinit_flag = 0; -int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 - ablocks, afs_int32 aDentries, afs_int32 aVolumes, afs_int32 achunk, - afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers) +int +afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks, + afs_int32 aDentries, afs_int32 aVolumes, afs_int32 achunk, + afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers) { register afs_int32 i; register struct volume *tv; @@ -123,7 +125,8 @@ int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 preallocs = astatSize; else { preallocs = 3600 - afs_stats_cmperf.SmallBlocksAlloced; - if (preallocs <= 0) preallocs = 10; + if (preallocs <= 0) + preallocs = 10; } osi_AllocMoreSSpace(preallocs); } @@ -131,13 +134,15 @@ int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 /* * create volume list structure */ - if (aVolumes < 50) aVolumes = 50; - else if (aVolumes > 3000) aVolumes = 3000; - - tv = (struct volume *) afs_osi_Alloc(aVolumes * sizeof(struct volume)); - for (i=0;i 3000) + aVolumes = 3000; + + tv = (struct volume *)afs_osi_Alloc(aVolumes * sizeof(struct volume)); + for (i = 0; i < aVolumes - 1; i++) + tv[i].next = &tv[i + 1]; + tv[aVolumes - 1].next = NULL; afs_freeVolList = Initialafs_freeVolList = tv; afs_memvolumes = aVolumes; @@ -173,7 +178,7 @@ int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 return 0; -} /*afs_CacheInit*/ +} /*afs_CacheInit */ /* @@ -186,7 +191,8 @@ int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 * None. */ -void afs_ComputeCacheParms(void) +void +afs_ComputeCacheParms(void) { register afs_int32 i; afs_int32 afs_maxCacheDirty; @@ -194,7 +200,7 @@ void afs_ComputeCacheParms(void) /* * Don't allow more than 2/3 of the files in the cache to be dirty. */ - afs_maxCacheDirty = (2*afs_cacheFiles) / 3; + afs_maxCacheDirty = (2 * afs_cacheFiles) / 3; /* * Also, don't allow more than 2/3 of the total space get filled @@ -205,17 +211,16 @@ void afs_ComputeCacheParms(void) */ if (afs_cacheBlocks & 0xffe00000) { i = afs_cacheBlocks / (AFS_FIRSTCSIZE >> 10); - } - else { + } else { i = (afs_cacheBlocks << 10) / AFS_FIRSTCSIZE; } - i = (2*i) / 3; + i = (2 * i) / 3; if (afs_maxCacheDirty > i) afs_maxCacheDirty = i; if (afs_maxCacheDirty < 1) afs_maxCacheDirty = 1; afs_stats_cmperf.cacheMaxDirtyChunks = afs_maxCacheDirty; -} /*afs_ComputeCacheParms*/ +} /*afs_ComputeCacheParms */ /* @@ -225,20 +230,23 @@ void afs_ComputeCacheParms(void) * Optionally return the vnode too. * If the vnode is not returned, we rele it. */ -static int LookupInodeByPath(char *filename, ino_t *inode, struct vnode **fvpp) +static int +LookupInodeByPath(char *filename, ino_t * inode, struct vnode **fvpp) { afs_int32 code; #ifdef AFS_LINUX22_ENV struct dentry *dp; code = gop_lookupname(filename, AFS_UIOSYS, 0, NULL, &dp); - if (code) return code; + if (code) + return code; *inode = dp->d_inode->i_ino; dput(dp); #else struct vnode *filevp; code = gop_lookupname(filename, AFS_UIOSYS, 0, NULL, &filevp); - if (code) return code; + if (code) + return code; *inode = afs_vnodeToInumber(filevp); if (fvpp) *fvpp = filevp; @@ -254,7 +262,8 @@ static int LookupInodeByPath(char *filename, ino_t *inode, struct vnode **fvpp) return 0; } -int afs_InitCellInfo(char *afile) +int +afs_InitCellInfo(char *afile) { ino_t inode; int code; @@ -279,7 +288,8 @@ int afs_InitCellInfo(char *afile) * WARNING: Data will be written to this file over time by AFS. */ -int afs_InitVolumeInfo(char *afile) +int +afs_InitVolumeInfo(char *afile) { int code; struct osi_file *tfile; @@ -334,7 +344,8 @@ int afs_InitVolumeInfo(char *afile) * code. * */ -int afs_InitCacheInfo(register char *afile) +int +afs_InitCacheInfo(register char *afile) { register afs_int32 code; struct osi_stat tstat; @@ -344,14 +355,16 @@ int afs_InitCacheInfo(register char *afile) int goodFile; AFS_STATCNT(afs_InitCacheInfo); - if(cacheDiskType != AFS_FCACHE_TYPE_UFS) + if (cacheDiskType != AFS_FCACHE_TYPE_UFS) osi_Panic("afs_InitCacheInfo --- called for non-ufs cache!"); #ifdef AFS_LINUX22_ENV code = osi_InitCacheInfo(afile); - if (code) return code; + if (code) + return code; #else code = gop_lookupname(afile, AFS_UIOSYS, 0, NULL, &filevp); - if (code || !filevp) return ENOENT; + if (code || !filevp) + return ENOENT; { #if defined(AFS_SUN56_ENV) struct statvfs64 st; @@ -361,7 +374,7 @@ int afs_InitCacheInfo(register char *afile) #else #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) ||defined(AFS_HPUX100_ENV) struct statvfs st; -#else +#else #if defined(AFS_DUX40_ENV) struct nstatfs st; #else @@ -374,14 +387,14 @@ int afs_InitCacheInfo(register char *afile) #if defined(AFS_SGI_ENV) #ifdef AFS_SGI65_ENV VFS_STATVFS(filevp->v_vfsp, &st, NULL, code); - if (!code) + if (!code) #else if (!VFS_STATFS(filevp->v_vfsp, &st, NULL)) #endif /* AFS_SGI65_ENV */ #elif defined(AFS_SUN5_ENV) || defined(AFS_HPUX100_ENV) - if (!VFS_STATVFS(filevp->v_vfsp, &st)) + if (!VFS_STATVFS(filevp->v_vfsp, &st)) #elif defined(AFS_OSF_ENV) - + VFS_STATFS(filevp->v_vfsp, code); /* struct copy */ st = filevp->v_vfsp->m_stat; @@ -402,13 +415,13 @@ int afs_InitCacheInfo(register char *afile) if (!VFS_STATFS(filevp->v_mount, &st, curthread)) #elif defined(AFS_XBSD_ENV) if (!VFS_STATFS(filevp->v_mount, &st, curproc)) -#else - if (!VFS_STATFS(filevp->v_vfsp, &st)) +#else + if (!VFS_STATFS(filevp->v_vfsp, &st)) #endif /* SGI... */ #if defined(AFS_SUN5_ENV) || defined(AFS_HPUX100_ENV) - afs_fsfragsize = st.f_frsize - 1; + afs_fsfragsize = st.f_frsize - 1; #else - afs_fsfragsize = st.f_bsize - 1; + afs_fsfragsize = st.f_bsize - 1; #endif } #ifdef AFS_LINUX20_ENV @@ -438,11 +451,10 @@ int afs_InitCacheInfo(register char *afile) goodFile = 0; if (code == sizeof(theader)) { /* read the header correctly */ - if (theader.magic == AFS_FHMAGIC && - theader.firstCSize == AFS_FIRSTCSIZE && - theader.otherCSize == AFS_OTHERCSIZE && - theader.version == AFS_CI_VERSION - ) + if (theader.magic == AFS_FHMAGIC + && theader.firstCSize == AFS_FIRSTCSIZE + && theader.otherCSize == AFS_OTHERCSIZE + && theader.version == AFS_CI_VERSION) goodFile = 1; } if (!goodFile) { @@ -468,7 +480,8 @@ int afs_InitCacheInfo(register char *afile) } int afs_resourceinit_flag = 0; -int afs_ResourceInit(int preallocs) +int +afs_ResourceInit(int preallocs) { register afs_int32 i; static struct rx_securityClass *secobj; @@ -488,28 +501,28 @@ int afs_ResourceInit(int preallocs) RWLOCK_INIT(&afs_xconn, "afs_xconn"); afs_CellInit(); - afs_InitCBQueue(1); /* initialize callback queues */ + afs_InitCBQueue(1); /* initialize callback queues */ if (afs_resourceinit_flag == 0) { afs_resourceinit_flag = 1; - for (i=0;i 256) && (preallocs < 3600)) - afs_preallocs = preallocs; - osi_AllocMoreSSpace(afs_preallocs); - osi_AllocMoreMSpace(100); - } + if ((preallocs > 256) && (preallocs < 3600)) + afs_preallocs = preallocs; + osi_AllocMoreSSpace(afs_preallocs); + osi_AllocMoreMSpace(100); + } #endif } - + secobj = rxnull_NewServerSecurityObject(); afs_server = rx_NewService(0, 1, "afs", &secobj, 1, RXAFSCB_ExecuteRequest); @@ -520,7 +533,7 @@ int afs_ResourceInit(int preallocs) afs_osi_Wakeup(&afs_server); /* wakeup anyone waiting for it */ return 0; -} /*afs_ResourceInit*/ +} /*afs_ResourceInit */ #if defined(AFS_AIX_ENV) && !defined(AFS_AIX51_ENV) @@ -564,10 +577,11 @@ int afs_ResourceInit(int preallocs) * support features that require knowing the size of struct proc. */ -static void afs_procsize_init(void) +static void +afs_procsize_init(void) { - struct proc *p0; /* pointer to process 0 */ - struct proc *pN; /* pointer to process 0's first child */ + struct proc *p0; /* pointer to process 0 */ + struct proc *pN; /* pointer to process 0's first child */ #ifdef AFS_AIX51_ENV struct pvproc *pV; #endif @@ -580,7 +594,6 @@ static void afs_procsize_init(void) afs_gcpags = AFS_GCPAGS_EPROC0; return; } - #ifdef AFS_AIX51_ENV pN = (struct proc *)0; pV = p0->p_pvprocp; @@ -642,177 +655,181 @@ static void afs_procsize_init(void) * Environment: * Nothing interesting. */ -void shutdown_cache(void) +void +shutdown_cache(void) { - AFS_STATCNT(shutdown_cache); - afs_WriteThroughDSlots(); - if (afs_cold_shutdown) { - afs_cacheinit_flag = 0; - shutdown_dcache(); - shutdown_vcache(); - - afs_cacheStats = 0; - afs_cacheFiles = afs_cacheBlocks = 0; - pag_epoch = maxIHint = nihints = usedihint = 0; - pagCounter = 0; + AFS_STATCNT(shutdown_cache); + afs_WriteThroughDSlots(); + if (afs_cold_shutdown) { + afs_cacheinit_flag = 0; + shutdown_dcache(); + shutdown_vcache(); + + afs_cacheStats = 0; + afs_cacheFiles = afs_cacheBlocks = 0; + pag_epoch = maxIHint = nihints = usedihint = 0; + pagCounter = 0; #ifdef AFS_OBSD_ENV - AFS_RELE(volumeVnode); /* let it go, finally. */ - volumeVnode = NULL; - if (cacheDev.held_vnode) { - AFS_RELE(cacheDev.held_vnode); - cacheDev.held_vnode = NULL; - } + AFS_RELE(volumeVnode); /* let it go, finally. */ + volumeVnode = NULL; + if (cacheDev.held_vnode) { + AFS_RELE(cacheDev.held_vnode); + cacheDev.held_vnode = NULL; + } #endif - cacheInode = volumeInode = (ino_t)0; + cacheInode = volumeInode = (ino_t) 0; - cacheInfoModTime = 0; + cacheInfoModTime = 0; - afs_fsfragsize = 1023; - memset((char *)&afs_stats_cmperf, 0, sizeof(afs_stats_cmperf)); - memset((char *)&cacheDev, 0, sizeof(struct osi_dev)); - osi_dnlc_shutdown(); - } -} /*shutdown_cache*/ + afs_fsfragsize = 1023; + memset((char *)&afs_stats_cmperf, 0, sizeof(afs_stats_cmperf)); + memset((char *)&cacheDev, 0, sizeof(struct osi_dev)); + osi_dnlc_shutdown(); + } +} /*shutdown_cache */ -void shutdown_vnodeops(void) +void +shutdown_vnodeops(void) { #if !defined(AFS_SGI_ENV) && !defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV) struct buf *afs_bread_freebp = 0; #endif - + AFS_STATCNT(shutdown_vnodeops); if (afs_cold_shutdown) { -#ifndef AFS_SUN5_ENV /* XXX */ - lastWarnTime = 0; +#ifndef AFS_SUN5_ENV /* XXX */ + lastWarnTime = 0; #endif #ifndef AFS_LINUX20_ENV - afs_rd_stash_i = 0; + afs_rd_stash_i = 0; #endif #if !defined(AFS_SGI_ENV) && !defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV) - afs_bread_freebp = 0; + afs_bread_freebp = 0; #endif - shutdown_mariner(); - } + shutdown_mariner(); + } } -void shutdown_AFS(void) +void +shutdown_AFS(void) { int i; register struct srvAddr *sa; AFS_STATCNT(shutdown_AFS); if (afs_cold_shutdown) { - afs_resourceinit_flag = 0; - /* - * Free Volumes table allocations - */ - { - struct volume *tv; - for (i = 0; i < NVOLS; i++) { - for (tv = afs_volumes[i]; tv; tv = tv->next) { - if (tv->name) { - afs_osi_Free(tv->name, strlen(tv->name)+1); - tv->name = 0; + afs_resourceinit_flag = 0; + /* + * Free Volumes table allocations + */ + { + struct volume *tv; + for (i = 0; i < NVOLS; i++) { + for (tv = afs_volumes[i]; tv; tv = tv->next) { + if (tv->name) { + afs_osi_Free(tv->name, strlen(tv->name) + 1); + tv->name = 0; + } } + afs_volumes[i] = 0; } - afs_volumes[i] = 0; } - } - - /* - * Free FreeVolList allocations - */ - afs_osi_Free(Initialafs_freeVolList, afs_memvolumes * sizeof(struct volume)); - afs_freeVolList = Initialafs_freeVolList = 0; - - /* XXX HACK fort MEM systems XXX - * - * For -memcache cache managers when we run out of free in memory volumes - * we simply malloc more; we won't be able to free those additional volumes. - */ - - - - /* - * Free Users table allocation - */ - { - struct unixuser *tu, *ntu; - for (i=0; i < NUSERS; i++) { - for (tu=afs_users[i]; tu; tu = ntu) { - ntu = tu->next; - if (tu->stp) - afs_osi_Free(tu->stp, tu->stLen); - if (tu->exporter) - EXP_RELE(tu->exporter); - afs_osi_Free(tu, sizeof(struct unixuser)); + + /* + * Free FreeVolList allocations + */ + afs_osi_Free(Initialafs_freeVolList, + afs_memvolumes * sizeof(struct volume)); + afs_freeVolList = Initialafs_freeVolList = 0; + + /* XXX HACK fort MEM systems XXX + * + * For -memcache cache managers when we run out of free in memory volumes + * we simply malloc more; we won't be able to free those additional volumes. + */ + + + + /* + * Free Users table allocation + */ + { + struct unixuser *tu, *ntu; + for (i = 0; i < NUSERS; i++) { + for (tu = afs_users[i]; tu; tu = ntu) { + ntu = tu->next; + if (tu->stp) + afs_osi_Free(tu->stp, tu->stLen); + if (tu->exporter) + EXP_RELE(tu->exporter); + afs_osi_Free(tu, sizeof(struct unixuser)); + } + afs_users[i] = 0; } - afs_users[i] = 0; } - } - - /* - * Free Servers table allocation - */ - { - struct server *ts, *nts; - struct conn *tc, *ntc; - register struct afs_cbr *tcbrp, *tbrp; - - for (i=0; i < NSERVERS; i++) { - for (ts = afs_servers[i]; ts; ts = nts) { - nts = ts->next; - for (sa = ts->addr; sa; sa = sa->next_sa) { - if (sa->conns) { + + /* + * Free Servers table allocation + */ + { + struct server *ts, *nts; + struct conn *tc, *ntc; + register struct afs_cbr *tcbrp, *tbrp; + + for (i = 0; i < NSERVERS; i++) { + for (ts = afs_servers[i]; ts; ts = nts) { + nts = ts->next; + for (sa = ts->addr; sa; sa = sa->next_sa) { + if (sa->conns) { + /* + * Free all server's connection structs + */ + tc = sa->conns; + while (tc) { + ntc = tc->next; + AFS_GUNLOCK(); + rx_DestroyConnection(tc->id); + AFS_GLOCK(); + afs_osi_Free(tc, sizeof(struct conn)); + tc = ntc; + } + } + } + for (tcbrp = ts->cbrs; tcbrp; tcbrp = tbrp) { /* - * Free all server's connection structs + * Free all server's callback structs */ - tc = sa->conns; - while (tc) { - ntc = tc->next; - AFS_GUNLOCK(); - rx_DestroyConnection(tc->id); - AFS_GLOCK(); - afs_osi_Free(tc, sizeof(struct conn)); - tc = ntc; - } + tbrp = tcbrp->next; + afs_FreeCBR(tcbrp); } + afs_osi_Free(ts, sizeof(struct server)); } - for (tcbrp = ts->cbrs; tcbrp; tcbrp = tbrp) { - /* - * Free all server's callback structs - */ - tbrp = tcbrp->next; - afs_FreeCBR(tcbrp); - } - afs_osi_Free(ts, sizeof(struct server)); + afs_servers[i] = 0; } - afs_servers[i] = 0; } - } - for (i=0; i #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ /* probably needed if lock_trace is enabled - should ifdef */ -int afs_trclock=0; +int afs_trclock = 0; void Lock_Obtain(); void Lock_ReleaseR(); void Lock_ReleaseW(); -void Lock_Init(register struct afs_lock *lock) +void +Lock_Init(register struct afs_lock *lock) { AFS_STATCNT(Lock_Init); - lock -> readers_reading = 0; - lock -> excl_locked = 0; - lock -> wait_states = 0; - lock -> num_waiting = 0; + lock->readers_reading = 0; + lock->excl_locked = 0; + lock->wait_states = 0; + lock->num_waiting = 0; #if defined(INSTRUMENT_LOCKS) lock->pid_last_reader = 0; lock->pid_writer = 0; @@ -55,22 +57,23 @@ void Lock_Init(register struct afs_lock *lock) lock->time_waiting.tv_usec = 0; } -void ObtainLock(register struct afs_lock *lock, int how, - unsigned int src_indicator) +void +ObtainLock(register struct afs_lock *lock, int how, + unsigned int src_indicator) { switch (how) { - case READ_LOCK: + case READ_LOCK: if (!((lock)->excl_locked & WRITE_LOCK)) - (lock) -> readers_reading++; + (lock)->readers_reading++; else Afs_Lock_Obtain(lock, READ_LOCK); #if defined(INSTRUMENT_LOCKS) (lock)->pid_last_reader = MyPidxx; #endif /* INSTRUMENT_LOCKS */ break; - case WRITE_LOCK: + case WRITE_LOCK: if (!(lock)->excl_locked && !(lock)->readers_reading) - (lock) -> excl_locked = WRITE_LOCK; + (lock)->excl_locked = WRITE_LOCK; else Afs_Lock_Obtain(lock, WRITE_LOCK); #if defined(INSTRUMENT_LOCKS) @@ -78,9 +81,9 @@ void ObtainLock(register struct afs_lock *lock, int how, (lock)->src_indicator = src_indicator; #endif /* INSTRUMENT_LOCKS */ break; - case SHARED_LOCK: + case SHARED_LOCK: if (!(lock)->excl_locked) - (lock) -> excl_locked = SHARED_LOCK; + (lock)->excl_locked = SHARED_LOCK; else Afs_Lock_Obtain(lock, SHARED_LOCK); #if defined(INSTRUMENT_LOCKS) @@ -88,84 +91,92 @@ void ObtainLock(register struct afs_lock *lock, int how, (lock)->src_indicator = src_indicator; #endif /* INSTRUMENT_LOCKS */ break; - } + } } -void ReleaseLock(register struct afs_lock *lock, int how) +void +ReleaseLock(register struct afs_lock *lock, int how) { if (how == READ_LOCK) { - if (!--lock->readers_reading && lock->wait_states) - { + if (!--lock->readers_reading && lock->wait_states) { #if defined(INSTRUMENT_LOCKS) - if ( lock->pid_last_reader == MyPidxx ) + if (lock->pid_last_reader == MyPidxx) lock->pid_last_reader = 0; #endif /* INSTRUMENT_LOCKS */ - Afs_Lock_ReleaseW(lock); + Afs_Lock_ReleaseW(lock); } } else if (how == WRITE_LOCK) { lock->excl_locked &= ~WRITE_LOCK; #if defined(INSTRUMENT_LOCKS) lock->pid_writer = 0; #endif /* INSTRUMENT_LOCKS */ - if (lock->wait_states) Afs_Lock_ReleaseR(lock); + if (lock->wait_states) + Afs_Lock_ReleaseR(lock); } else if (how == SHARED_LOCK) { lock->excl_locked &= ~(SHARED_LOCK | WRITE_LOCK); #if defined(INSTRUMENT_LOCKS) lock->pid_writer = 0; #endif /* INSTRUMENT_LOCKS */ - if (lock->wait_states) Afs_Lock_ReleaseR(lock); + if (lock->wait_states) + Afs_Lock_ReleaseR(lock); } } -void Afs_Lock_Obtain(register struct afs_lock *lock, int how) +void +Afs_Lock_Obtain(register struct afs_lock *lock, int how) { osi_timeval_t tt1, tt2, et; afs_uint32 us; AFS_STATCNT(Lock_Obtain); - + AFS_ASSERT_GLOCK(); osi_GetuTime(&tt1); - + switch (how) { - case READ_LOCK: lock->num_waiting++; - do { - lock -> wait_states |= READ_LOCK; - afs_osi_Sleep(&lock->readers_reading); - } while (lock->excl_locked & WRITE_LOCK); - lock->num_waiting--; - lock->readers_reading++; - break; - - case WRITE_LOCK: lock->num_waiting++; - do { - lock -> wait_states |= WRITE_LOCK; - afs_osi_Sleep(&lock->excl_locked); - } while (lock->excl_locked || lock->readers_reading); - lock->num_waiting--; - lock->excl_locked = WRITE_LOCK; - break; - - case SHARED_LOCK: lock->num_waiting++; - do { - lock->wait_states |= SHARED_LOCK; - afs_osi_Sleep(&lock->excl_locked); - } while (lock->excl_locked); - lock->num_waiting--; - lock->excl_locked = SHARED_LOCK; - break; - - case BOOSTED_LOCK: lock->num_waiting++; - do { - lock->wait_states |= WRITE_LOCK; - afs_osi_Sleep(&lock->excl_locked); - } while (lock->readers_reading); - lock->num_waiting--; - lock->excl_locked = WRITE_LOCK; - break; - - default: osi_Panic("afs locktype"); + case READ_LOCK: + lock->num_waiting++; + do { + lock->wait_states |= READ_LOCK; + afs_osi_Sleep(&lock->readers_reading); + } while (lock->excl_locked & WRITE_LOCK); + lock->num_waiting--; + lock->readers_reading++; + break; + + case WRITE_LOCK: + lock->num_waiting++; + do { + lock->wait_states |= WRITE_LOCK; + afs_osi_Sleep(&lock->excl_locked); + } while (lock->excl_locked || lock->readers_reading); + lock->num_waiting--; + lock->excl_locked = WRITE_LOCK; + break; + + case SHARED_LOCK: + lock->num_waiting++; + do { + lock->wait_states |= SHARED_LOCK; + afs_osi_Sleep(&lock->excl_locked); + } while (lock->excl_locked); + lock->num_waiting--; + lock->excl_locked = SHARED_LOCK; + break; + + case BOOSTED_LOCK: + lock->num_waiting++; + do { + lock->wait_states |= WRITE_LOCK; + afs_osi_Sleep(&lock->excl_locked); + } while (lock->readers_reading); + lock->num_waiting--; + lock->excl_locked = WRITE_LOCK; + break; + + default: + osi_Panic("afs locktype"); } osi_GetuTime(&tt2); @@ -174,38 +185,36 @@ void Afs_Lock_Obtain(register struct afs_lock *lock, int how) us = (et.tv_sec << 20) + et.tv_usec; if (afs_trclock) { - afs_Trace3(afs_iclSetp, CM_TRACE_LOCKSLEPT, - ICL_TYPE_INT32, us, - ICL_TYPE_POINTER, lock, - ICL_TYPE_INT32, how); + afs_Trace3(afs_iclSetp, CM_TRACE_LOCKSLEPT, ICL_TYPE_INT32, us, + ICL_TYPE_POINTER, lock, ICL_TYPE_INT32, how); } } /* release a lock, giving preference to new readers */ -void Afs_Lock_ReleaseR(register struct afs_lock *lock) +void +Afs_Lock_ReleaseR(register struct afs_lock *lock) { AFS_STATCNT(Lock_ReleaseR); AFS_ASSERT_GLOCK(); if (lock->wait_states & READ_LOCK) { lock->wait_states &= ~READ_LOCK; afs_osi_Wakeup(&lock->readers_reading); - } - else { + } else { lock->wait_states &= ~EXCL_LOCKS; afs_osi_Wakeup(&lock->excl_locked); } } /* release a lock, giving preference to new writers */ -void Afs_Lock_ReleaseW(register struct afs_lock *lock) +void +Afs_Lock_ReleaseW(register struct afs_lock *lock) { AFS_STATCNT(Lock_ReleaseW); AFS_ASSERT_GLOCK(); if (lock->wait_states & EXCL_LOCKS) { lock->wait_states &= ~EXCL_LOCKS; afs_osi_Wakeup(&lock->excl_locked); - } - else { + } else { lock->wait_states &= ~READ_LOCK; afs_osi_Wakeup(&lock->readers_reading); } @@ -228,7 +237,8 @@ void Lock_Wait(register struct afs_lock *lock) */ /* release a write lock and sleep on an address, atomically */ -void afs_osi_SleepR(register char *addr, register struct afs_lock *alock) +void +afs_osi_SleepR(register char *addr, register struct afs_lock *alock) { AFS_STATCNT(osi_SleepR); ReleaseReadLock(alock); @@ -236,7 +246,8 @@ void afs_osi_SleepR(register char *addr, register struct afs_lock *alock) } /* release a write lock and sleep on an address, atomically */ -void afs_osi_SleepW(register char *addr, register struct afs_lock *alock) +void +afs_osi_SleepW(register char *addr, register struct afs_lock *alock) { AFS_STATCNT(osi_SleepW); ReleaseWriteLock(alock); @@ -244,7 +255,8 @@ void afs_osi_SleepW(register char *addr, register struct afs_lock *alock) } /* release a write lock and sleep on an address, atomically */ -void afs_osi_SleepS(register char *addr, register struct afs_lock *alock) +void +afs_osi_SleepS(register char *addr, register struct afs_lock *alock) { AFS_STATCNT(osi_SleepS); ReleaseSharedLock(alock); @@ -256,39 +268,39 @@ void afs_osi_SleepS(register char *addr, register struct afs_lock *alock) /* operations on locks that don't mind if we lock the same thing twice. I'd like to dedicate this function to Sun Microsystems' Version 4.0 virtual memory system, without which this wouldn't have been necessary */ -void afs_BozonLock(struct afs_bozoLock *alock, struct vcache *avc) +void +afs_BozonLock(struct afs_bozoLock *alock, struct vcache *avc) { AFS_STATCNT(afs_BozonLock); while (1) { if (alock->count == 0) { /* lock not held, we win */ #ifdef AFS_SUN5_ENV - alock->proc = (char *) ttoproc(curthread); + alock->proc = (char *)ttoproc(curthread); #else #ifdef AFS_64BITPOINTER_ENV /* To shut up SGI compiler on remark(1413) warnings. */ - alock->proc = (char *) (long)MyPidxx; + alock->proc = (char *)(long)MyPidxx; #else /* AFS_64BITPOINTER_ENV */ - alock->proc = (char *) MyPidxx; + alock->proc = (char *)MyPidxx; #endif /* AFS_64BITPOINTER_ENV */ #endif alock->count = 1; return; #ifdef AFS_SUN5_ENV - } else if (alock->proc == (char *) ttoproc(curthread)) { + } else if (alock->proc == (char *)ttoproc(curthread)) { #else #ifdef AFS_64BITPOINTER_ENV - /* To shut up SGI compiler on remark(1413) warnings. */ - } else if (alock->proc == (char *) (long)MyPidxx) { + /* To shut up SGI compiler on remark(1413) warnings. */ + } else if (alock->proc == (char *)(long)MyPidxx) { #else /* AFS_64BITPOINTER_ENV */ - } else if (alock->proc == (char *) MyPidxx) { + } else if (alock->proc == (char *)MyPidxx) { #endif /* AFS_64BITPOINTER_ENV */ #endif /* lock is held, but by us, so we win anyway */ alock->count++; return; - } - else { + } else { /* lock is held, and not by us; we wait */ alock->flags |= AFS_BOZONWAITING; afs_osi_Sleep(alock); @@ -297,7 +309,8 @@ void afs_BozonLock(struct afs_bozoLock *alock, struct vcache *avc) } /* releasing the same type of lock as defined above */ -void afs_BozonUnlock(struct afs_bozoLock *alock, struct vcache *avc) +void +afs_BozonUnlock(struct afs_bozoLock *alock, struct vcache *avc) { AFS_STATCNT(afs_BozonUnlock); if (alock->count <= 0) @@ -310,7 +323,8 @@ void afs_BozonUnlock(struct afs_bozoLock *alock, struct vcache *avc) } } -void afs_BozonInit(struct afs_bozoLock *alock, struct vcache *avc) +void +afs_BozonInit(struct afs_bozoLock *alock, struct vcache *avc) { AFS_STATCNT(afs_BozonInit); alock->count = 0; @@ -318,7 +332,8 @@ void afs_BozonInit(struct afs_bozoLock *alock, struct vcache *avc) alock->proc = NULL; } -int afs_CheckBozonLock(struct afs_bozoLock *alock) +int +afs_CheckBozonLock(struct afs_bozoLock *alock) { AFS_STATCNT(afs_CheckBozonLock); if (alock->count || (alock->flags & AFS_BOZONWAITING)) @@ -326,18 +341,19 @@ int afs_CheckBozonLock(struct afs_bozoLock *alock) return 0; } -int afs_CheckBozonLockBlocking(struct afs_bozoLock *alock) +int +afs_CheckBozonLockBlocking(struct afs_bozoLock *alock) { AFS_STATCNT(afs_CheckBozonLockBlocking); if (alock->count || (alock->flags & AFS_BOZONWAITING)) #ifdef AFS_SUN5_ENV - if (alock->proc != (char *) ttoproc(curthread)) + if (alock->proc != (char *)ttoproc(curthread)) #else #ifdef AFS_64BITPOINTER_ENV - /* To shut up SGI compiler on remark(1413) warnings. */ - if (alock->proc != (char *) (long)MyPidxx) + /* To shut up SGI compiler on remark(1413) warnings. */ + if (alock->proc != (char *)(long)MyPidxx) #else /* AFS_64BITPOINTER_ENV */ - if (alock->proc != (char *) MyPidxx) + if (alock->proc != (char *)MyPidxx) #endif /* AFS_64BITPOINTER_ENV */ #endif return 1; @@ -346,28 +362,32 @@ int afs_CheckBozonLockBlocking(struct afs_bozoLock *alock) #endif /* Not static - used conditionally if lock tracing is enabled */ -int Afs_Lock_Trace(int op, struct afs_lock *alock, int type, char *file, int line) +int +Afs_Lock_Trace(int op, struct afs_lock *alock, int type, char *file, int line) { int traceok; struct afs_icl_log *tlp; struct afs_icl_set *tsp; - if (!afs_trclock) return 1; - if ((alock) == &afs_icl_lock) return 1; + if (!afs_trclock) + return 1; + if ((alock) == &afs_icl_lock) + return 1; ObtainReadLock(&afs_icl_lock); traceok = 1; for (tlp = afs_icl_allLogs; tlp; tlp = tlp->nextp) - if ((alock) == &tlp->lock) traceok = 0; + if ((alock) == &tlp->lock) + traceok = 0; for (tsp = afs_icl_allSets; tsp; tsp = tsp->nextp) - if ((alock) == &tsp->lock) traceok = 0; + if ((alock) == &tsp->lock) + traceok = 0; ReleaseReadLock(&afs_icl_lock); - if (!traceok) return 1; + if (!traceok) + return 1; - afs_Trace4(afs_iclSetp, op, - ICL_TYPE_STRING, (long)file, - ICL_TYPE_INT32, (long)line, - ICL_TYPE_POINTER, (long)alock, - ICL_TYPE_LONG, (long)type); + afs_Trace4(afs_iclSetp, op, ICL_TYPE_STRING, (long)file, ICL_TYPE_INT32, + (long)line, ICL_TYPE_POINTER, (long)alock, ICL_TYPE_LONG, + (long)type); return 0; } diff --git a/src/afs/afs_mariner.c b/src/afs/afs_mariner.c index 1a8d7094e..cbdf9ca1a 100644 --- a/src/afs/afs_mariner.c +++ b/src/afs/afs_mariner.c @@ -16,18 +16,19 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /*Standard vendor system headers*/ -#include "afsincludes.h" /*AFS-based standard headers*/ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/sysincludes.h" /*Standard vendor system headers */ +#include "afsincludes.h" /*AFS-based standard headers */ +#include "afs/afs_stats.h" /* statistics */ /* Exported variables */ struct rx_service *afs_server; -#define SMAR 20 /* size of a mariner name */ -#define NMAR 10 /* number of mariner names */ +#define SMAR 20 /* size of a mariner name */ +#define NMAR 10 /* number of mariner names */ static char marinerNames[NMAR][SMAR]; static struct vcache *marinerVCs[NMAR]; static int marinerPtr = 0; /* pointer to next mariner slot to use */ @@ -36,7 +37,8 @@ static int marinerPtr = 0; /* pointer to next mariner slot to use */ afs_int32 afs_mariner = 0; afs_int32 afs_marinerHost = 0; -int afs_AddMarinerName(register char *aname, register struct vcache *avc) +int +afs_AddMarinerName(register char *aname, register struct vcache *avc) { register int i; register char *tp; @@ -49,16 +51,17 @@ int afs_AddMarinerName(register char *aname, register struct vcache *avc) } tp = marinerNames[i]; strncpy(tp, aname, SMAR); - tp[SMAR-1] = 0; + tp[SMAR - 1] = 0; marinerVCs[i] = avc; return 0; } -char *afs_GetMariner(register struct vcache *avc) +char * +afs_GetMariner(register struct vcache *avc) { register int i; AFS_STATCNT(afs_GetMariner); - for(i=0; isocket, &taddr, &dvec, 1, len, 0); + (void)osi_NetSend(afs_server->socket, &taddr, &dvec, 1, len, 0); AFS_GLOCK(); osi_FreeSmallSpace(tp1); -} /*afs_MarinerLogFetch*/ +} /*afs_MarinerLogFetch */ -void afs_MarinerLog(register char *astring, register struct vcache *avc) +void +afs_MarinerLog(register char *astring, register struct vcache *avc) { struct sockaddr_in taddr; register char *tp, *tp1, *buf; @@ -112,8 +117,8 @@ void afs_MarinerLog(register char *astring, register struct vcache *avc) taddr.sin_port = htons(2106); #ifdef STRUCT_SOCKADDR_HAS_SA_LEN taddr.sin_len = sizeof(taddr); -#endif /* AFS_OSF_ENV */ - tp = buf = (char *) osi_AllocSmallSpace(AFS_SMALLOCSIZ); +#endif /* AFS_OSF_ENV */ + tp = buf = (char *)osi_AllocSmallSpace(AFS_SMALLOCSIZ); strcpy(tp, astring); tp += strlen(astring); @@ -125,46 +130,21 @@ void afs_MarinerLog(register char *astring, register struct vcache *avc) /* note, console doesn't want a terminating null */ /* I don't care if mariner packets fail to be sent */ dvec.iov_base = buf; - dvec.iov_len = tp-buf; + dvec.iov_len = tp - buf; AFS_GUNLOCK(); - (void) osi_NetSend(afs_server->socket, &taddr, &dvec, 1, tp-buf, 0); + (void)osi_NetSend(afs_server->socket, &taddr, &dvec, 1, tp - buf, 0); AFS_GLOCK(); osi_FreeSmallSpace(buf); -} /*afs_MarinerLog*/ +} /*afs_MarinerLog */ -void shutdown_mariner(void) +void +shutdown_mariner(void) { int i; marinerPtr = 0; afs_mariner = 0; - for (i=0; i #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #ifndef AFS_LINUX22_ENV @@ -22,9 +23,9 @@ RCSID("$Header$"); #undef mem_alloc #undef mem_free #undef register -#endif /* AFS_ALPHA_ENV */ +#endif /* AFS_ALPHA_ENV */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ /* memory cache routines */ static struct memCacheEntry *memCache; @@ -34,455 +35,477 @@ static int memAllocMaySleep = 0; extern int cacheDiskType; -int afs_InitMemCache(int blkCount, int blkSize, int flags) - { - int index; - - AFS_STATCNT(afs_InitMemCache); - if(blkSize) - memCacheBlkSize = blkSize; - - memMaxBlkNumber = blkCount; - memCache = (struct memCacheEntry *) - afs_osi_Alloc(memMaxBlkNumber * sizeof(struct memCacheEntry)); - if (flags & AFSCALL_INIT_MEMCACHE_SLEEP) { - memAllocMaySleep = 1; - } - - for(index = 0; index < memMaxBlkNumber; index++) { - char *blk; - (memCache+index)->size = 0; - (memCache+index)->dataSize = memCacheBlkSize; - LOCK_INIT(&((memCache+index)->afs_memLock), "afs_memLock"); - if (memAllocMaySleep) { - blk = afs_osi_Alloc(memCacheBlkSize); - } else { - blk = afs_osi_Alloc_NoSleep(memCacheBlkSize); - } - if (blk == NULL) - goto nomem; - (memCache+index)->data = blk; - memset((memCache+index)->data, 0, memCacheBlkSize); - } +int +afs_InitMemCache(int blkCount, int blkSize, int flags) +{ + int index; + + AFS_STATCNT(afs_InitMemCache); + if (blkSize) + memCacheBlkSize = blkSize; + + memMaxBlkNumber = blkCount; + memCache = (struct memCacheEntry *) + afs_osi_Alloc(memMaxBlkNumber * sizeof(struct memCacheEntry)); + if (flags & AFSCALL_INIT_MEMCACHE_SLEEP) { + memAllocMaySleep = 1; + } + + for (index = 0; index < memMaxBlkNumber; index++) { + char *blk; + (memCache + index)->size = 0; + (memCache + index)->dataSize = memCacheBlkSize; + LOCK_INIT(&((memCache + index)->afs_memLock), "afs_memLock"); + if (memAllocMaySleep) { + blk = afs_osi_Alloc(memCacheBlkSize); + } else { + blk = afs_osi_Alloc_NoSleep(memCacheBlkSize); + } + if (blk == NULL) + goto nomem; + (memCache + index)->data = blk; + memset((memCache + index)->data, 0, memCacheBlkSize); + } #if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS) - afs_InitDualFSCacheOps((struct vnode*)0); + afs_InitDualFSCacheOps((struct vnode *)0); #endif - return 0; + return 0; -nomem: - printf("afsd: memCache allocation failure at %d KB.\n", - (index * memCacheBlkSize) / 1024); - while(--index >= 0) { - afs_osi_Free((memCache+index)->data, memCacheBlkSize); - (memCache+index)->data = NULL; - } - return ENOMEM; + nomem: + printf("afsd: memCache allocation failure at %d KB.\n", + (index * memCacheBlkSize) / 1024); + while (--index >= 0) { + afs_osi_Free((memCache + index)->data, memCacheBlkSize); + (memCache + index)->data = NULL; + } + return ENOMEM; - } +} -int afs_MemCacheClose(char *file) +int +afs_MemCacheClose(char *file) { return 0; } -void *afs_MemCacheOpen(ino_t blkno) - { - struct memCacheEntry *mep; - - if (blkno < 0 || blkno > memMaxBlkNumber) { - osi_Panic("afs_MemCacheOpen: invalid block #"); - } - mep = (memCache + blkno); - afs_Trace4(afs_iclSetp, CM_TRACE_MEMOPEN, - ICL_TYPE_INT32, blkno, - ICL_TYPE_POINTER, mep, - ICL_TYPE_POINTER, mep->data, - ICL_TYPE_STRING, mep->data); - return (void *) mep; - } +void * +afs_MemCacheOpen(ino_t blkno) +{ + struct memCacheEntry *mep; + + if (blkno < 0 || blkno > memMaxBlkNumber) { + osi_Panic("afs_MemCacheOpen: invalid block #"); + } + mep = (memCache + blkno); + afs_Trace4(afs_iclSetp, CM_TRACE_MEMOPEN, ICL_TYPE_INT32, blkno, + ICL_TYPE_POINTER, mep, ICL_TYPE_POINTER, mep->data, + ICL_TYPE_STRING, mep->data); + return (void *)mep; +} /* * this routine simulates a read in the Memory Cache */ -int afs_MemReadBlk(register struct memCacheEntry *mceP, int offset, char *dest, int size) - { - int bytesRead; - - MObtainReadLock(&mceP->afs_memLock); - AFS_STATCNT(afs_MemReadBlk); - if (offset < 0) { - MReleaseReadLock(&mceP->afs_memLock); - return 0; - } - /* use min of bytes in buffer or requested size */ - bytesRead = (size < mceP->size - offset) ? size : - mceP->size - offset; - - if(bytesRead > 0) { - AFS_GUNLOCK(); - memcpy(dest, mceP->data + offset, bytesRead); - AFS_GLOCK(); - } - else - bytesRead = 0; - - MReleaseReadLock(&mceP->afs_memLock); - return bytesRead; - } +int +afs_MemReadBlk(register struct memCacheEntry *mceP, int offset, char *dest, + int size) +{ + int bytesRead; + + MObtainReadLock(&mceP->afs_memLock); + AFS_STATCNT(afs_MemReadBlk); + if (offset < 0) { + MReleaseReadLock(&mceP->afs_memLock); + return 0; + } + /* use min of bytes in buffer or requested size */ + bytesRead = (size < mceP->size - offset) ? size : mceP->size - offset; + + if (bytesRead > 0) { + AFS_GUNLOCK(); + memcpy(dest, mceP->data + offset, bytesRead); + AFS_GLOCK(); + } else + bytesRead = 0; + + MReleaseReadLock(&mceP->afs_memLock); + return bytesRead; +} /* * this routine simulates a readv in the Memory Cache */ -int afs_MemReadvBlk(register struct memCacheEntry *mceP, int offset, struct iovec *iov, int nio, int size) - { - int i; - int bytesRead; - int bytesToRead; - - MObtainReadLock(&mceP->afs_memLock); - AFS_STATCNT(afs_MemReadBlk); - if (offset < 0) { - MReleaseReadLock(&mceP->afs_memLock); - return 0; - } - /* use min of bytes in buffer or requested size */ - bytesRead = (size < mceP->size - offset) ? size : - mceP->size - offset; - - if(bytesRead > 0) { - for (i = 0 , size = bytesRead ; i < nio && size > 0 ; i++) { - bytesToRead = (size < iov[i].iov_len) ? size : iov[i].iov_len; - AFS_GUNLOCK(); - memcpy(iov[i].iov_base, mceP->data + offset, bytesToRead); - AFS_GLOCK(); - offset += bytesToRead; - size -= bytesToRead; - } - bytesRead -= size; - } else - bytesRead = 0; - - MReleaseReadLock(&mceP->afs_memLock); - return bytesRead; - } - -int afs_MemReadUIO(ino_t blkno, struct uio *uioP) - { - register struct memCacheEntry *mceP = (struct memCacheEntry *)afs_MemCacheOpen(blkno); - int length = mceP->size - uioP->uio_offset; - afs_int32 code; - - AFS_STATCNT(afs_MemReadUIO); - MObtainReadLock(&mceP->afs_memLock); - length = (length < uioP->uio_resid) ? length : uioP->uio_resid; - AFS_UIOMOVE(mceP->data + uioP->uio_offset, length, UIO_READ, uioP, code); - MReleaseReadLock(&mceP->afs_memLock); - return code; - } +int +afs_MemReadvBlk(register struct memCacheEntry *mceP, int offset, + struct iovec *iov, int nio, int size) +{ + int i; + int bytesRead; + int bytesToRead; + + MObtainReadLock(&mceP->afs_memLock); + AFS_STATCNT(afs_MemReadBlk); + if (offset < 0) { + MReleaseReadLock(&mceP->afs_memLock); + return 0; + } + /* use min of bytes in buffer or requested size */ + bytesRead = (size < mceP->size - offset) ? size : mceP->size - offset; + + if (bytesRead > 0) { + for (i = 0, size = bytesRead; i < nio && size > 0; i++) { + bytesToRead = (size < iov[i].iov_len) ? size : iov[i].iov_len; + AFS_GUNLOCK(); + memcpy(iov[i].iov_base, mceP->data + offset, bytesToRead); + AFS_GLOCK(); + offset += bytesToRead; + size -= bytesToRead; + } + bytesRead -= size; + } else + bytesRead = 0; + + MReleaseReadLock(&mceP->afs_memLock); + return bytesRead; +} + +int +afs_MemReadUIO(ino_t blkno, struct uio *uioP) +{ + register struct memCacheEntry *mceP = + (struct memCacheEntry *)afs_MemCacheOpen(blkno); + int length = mceP->size - uioP->uio_offset; + afs_int32 code; + + AFS_STATCNT(afs_MemReadUIO); + MObtainReadLock(&mceP->afs_memLock); + length = (length < uioP->uio_resid) ? length : uioP->uio_resid; + AFS_UIOMOVE(mceP->data + uioP->uio_offset, length, UIO_READ, uioP, code); + MReleaseReadLock(&mceP->afs_memLock); + return code; +} /*XXX: this extends a block arbitrarily to support big directories */ -int afs_MemWriteBlk(register struct memCacheEntry *mceP, int offset, char *src, int size) - { - AFS_STATCNT(afs_MemWriteBlk); - MObtainWriteLock(&mceP->afs_memLock,560); - if (size + offset > mceP->dataSize) { - char *oldData = mceP->data; - - if (memAllocMaySleep) { - mceP->data = afs_osi_Alloc(size+offset); - } else { - mceP->data = afs_osi_Alloc_NoSleep(size+offset); - } - if ( mceP->data == NULL ) /* no available memory */ - { - mceP->data = oldData; /* revert back change that was made */ - MReleaseWriteLock(&mceP->afs_memLock); - afs_warn("afs: afs_MemWriteBlk mem alloc failure (%d bytes)\n", - size+offset); - return -ENOMEM; - } - - /* may overlap, but this is OK */ - AFS_GUNLOCK(); - memcpy(mceP->data, oldData, mceP->size); - AFS_GLOCK(); - afs_osi_Free(oldData,mceP->dataSize); - mceP->dataSize = size+offset; - } - AFS_GUNLOCK(); - if (mceP->size < offset) - memset(mceP->data+mceP->size, 0, offset-mceP->size); - memcpy(mceP->data + offset, src, size); - AFS_GLOCK(); - mceP->size = (size+offset < mceP->size) ? mceP->size : - size + offset; - - MReleaseWriteLock(&mceP->afs_memLock); - return size; - } +int +afs_MemWriteBlk(register struct memCacheEntry *mceP, int offset, char *src, + int size) +{ + AFS_STATCNT(afs_MemWriteBlk); + MObtainWriteLock(&mceP->afs_memLock, 560); + if (size + offset > mceP->dataSize) { + char *oldData = mceP->data; + + if (memAllocMaySleep) { + mceP->data = afs_osi_Alloc(size + offset); + } else { + mceP->data = afs_osi_Alloc_NoSleep(size + offset); + } + if (mceP->data == NULL) { /* no available memory */ + mceP->data = oldData; /* revert back change that was made */ + MReleaseWriteLock(&mceP->afs_memLock); + afs_warn("afs: afs_MemWriteBlk mem alloc failure (%d bytes)\n", + size + offset); + return -ENOMEM; + } + + /* may overlap, but this is OK */ + AFS_GUNLOCK(); + memcpy(mceP->data, oldData, mceP->size); + AFS_GLOCK(); + afs_osi_Free(oldData, mceP->dataSize); + mceP->dataSize = size + offset; + } + AFS_GUNLOCK(); + if (mceP->size < offset) + memset(mceP->data + mceP->size, 0, offset - mceP->size); + memcpy(mceP->data + offset, src, size); + AFS_GLOCK(); + mceP->size = (size + offset < mceP->size) ? mceP->size : size + offset; + + MReleaseWriteLock(&mceP->afs_memLock); + return size; +} /*XXX: this extends a block arbitrarily to support big directories */ -int afs_MemWritevBlk(register struct memCacheEntry *mceP, int offset, struct iovec *iov, int nio, int size) - { - int i; - int bytesWritten; - int bytesToWrite; - AFS_STATCNT(afs_MemWriteBlk); - MObtainWriteLock(&mceP->afs_memLock,561); - if (offset + size > mceP->dataSize) { - char *oldData = mceP->data; - - mceP->data = afs_osi_Alloc(size+offset); - - /* may overlap, but this is OK */ - AFS_GUNLOCK(); - memcpy(mceP->data, oldData, mceP->size); - AFS_GLOCK(); - afs_osi_Free(oldData,mceP->dataSize); - mceP->dataSize = size+offset; - } - AFS_GUNLOCK(); - if (mceP->size < offset) - memset(mceP->data+mceP->size, 0, offset-mceP->size); - for (bytesWritten = 0, i = 0 ; i < nio && size > 0 ; i++) { - bytesToWrite = (size < iov[i].iov_len) ? size : iov[i].iov_len; - memcpy(mceP->data + offset, iov[i].iov_base, bytesToWrite); - offset += bytesToWrite; - bytesWritten += bytesToWrite; - size -= bytesToWrite; - } - mceP->size = (offset < mceP->size) ? mceP->size : offset; - AFS_GLOCK(); - - MReleaseWriteLock(&mceP->afs_memLock); - return bytesWritten; - } - -int afs_MemWriteUIO(ino_t blkno, struct uio *uioP) - { - register struct memCacheEntry *mceP = (struct memCacheEntry *)afs_MemCacheOpen(blkno); - afs_int32 code; - - AFS_STATCNT(afs_MemWriteUIO); - MObtainWriteLock(&mceP->afs_memLock,312); - if(uioP->uio_resid + uioP->uio_offset > mceP->dataSize) { - char *oldData = mceP->data; - - mceP->data = afs_osi_Alloc(uioP->uio_resid + uioP->uio_offset); - - AFS_GUNLOCK(); - memcpy(mceP->data, oldData, mceP->size); - AFS_GLOCK(); - - afs_osi_Free(oldData,mceP->dataSize); - mceP->dataSize = uioP->uio_resid + uioP->uio_offset; - } - if (mceP->size < uioP->uio_offset) - memset(mceP->data+mceP->size, 0, (int)(uioP->uio_offset-mceP->size)); - AFS_UIOMOVE(mceP->data+uioP->uio_offset, uioP->uio_resid, UIO_WRITE, uioP, code); - if (uioP->uio_offset > mceP->size) - mceP->size = uioP->uio_offset; - - MReleaseWriteLock(&mceP->afs_memLock); - return code; - } - -int afs_MemCacheTruncate(register struct memCacheEntry *mceP, int size) - { - AFS_STATCNT(afs_MemCacheTruncate); - - MObtainWriteLock(&mceP->afs_memLock,313); - /* old directory entry; g.c. */ - if(size == 0 && mceP->dataSize > memCacheBlkSize) { - afs_osi_Free(mceP->data, mceP->dataSize); - mceP->data = afs_osi_Alloc(memCacheBlkSize); - mceP->dataSize = memCacheBlkSize; - } - - if (size < mceP->size) - mceP->size = size; - - MReleaseWriteLock(&mceP->afs_memLock); - return 0; - } - -int afs_MemCacheStoreProc(register struct rx_call *acall, register struct memCacheEntry *mceP, - register afs_int32 alen, struct vcache *avc, int *shouldWake, afs_size_t *abytesToXferP, - afs_size_t *abytesXferredP, afs_int32 length) - { - - register afs_int32 code; - register int tlen; - int offset = 0; - struct iovec *tiov; /* no data copying with iovec */ - int tnio; /* temp for iovec size */ - - AFS_STATCNT(afs_MemCacheStoreProc); +int +afs_MemWritevBlk(register struct memCacheEntry *mceP, int offset, + struct iovec *iov, int nio, int size) +{ + int i; + int bytesWritten; + int bytesToWrite; + AFS_STATCNT(afs_MemWriteBlk); + MObtainWriteLock(&mceP->afs_memLock, 561); + if (offset + size > mceP->dataSize) { + char *oldData = mceP->data; + + mceP->data = afs_osi_Alloc(size + offset); + + /* may overlap, but this is OK */ + AFS_GUNLOCK(); + memcpy(mceP->data, oldData, mceP->size); + AFS_GLOCK(); + afs_osi_Free(oldData, mceP->dataSize); + mceP->dataSize = size + offset; + } + AFS_GUNLOCK(); + if (mceP->size < offset) + memset(mceP->data + mceP->size, 0, offset - mceP->size); + for (bytesWritten = 0, i = 0; i < nio && size > 0; i++) { + bytesToWrite = (size < iov[i].iov_len) ? size : iov[i].iov_len; + memcpy(mceP->data + offset, iov[i].iov_base, bytesToWrite); + offset += bytesToWrite; + bytesWritten += bytesToWrite; + size -= bytesToWrite; + } + mceP->size = (offset < mceP->size) ? mceP->size : offset; + AFS_GLOCK(); + + MReleaseWriteLock(&mceP->afs_memLock); + return bytesWritten; +} + +int +afs_MemWriteUIO(ino_t blkno, struct uio *uioP) +{ + register struct memCacheEntry *mceP = + (struct memCacheEntry *)afs_MemCacheOpen(blkno); + afs_int32 code; + + AFS_STATCNT(afs_MemWriteUIO); + MObtainWriteLock(&mceP->afs_memLock, 312); + if (uioP->uio_resid + uioP->uio_offset > mceP->dataSize) { + char *oldData = mceP->data; + + mceP->data = afs_osi_Alloc(uioP->uio_resid + uioP->uio_offset); + + AFS_GUNLOCK(); + memcpy(mceP->data, oldData, mceP->size); + AFS_GLOCK(); + + afs_osi_Free(oldData, mceP->dataSize); + mceP->dataSize = uioP->uio_resid + uioP->uio_offset; + } + if (mceP->size < uioP->uio_offset) + memset(mceP->data + mceP->size, 0, + (int)(uioP->uio_offset - mceP->size)); + AFS_UIOMOVE(mceP->data + uioP->uio_offset, uioP->uio_resid, UIO_WRITE, + uioP, code); + if (uioP->uio_offset > mceP->size) + mceP->size = uioP->uio_offset; + + MReleaseWriteLock(&mceP->afs_memLock); + return code; +} + +int +afs_MemCacheTruncate(register struct memCacheEntry *mceP, int size) +{ + AFS_STATCNT(afs_MemCacheTruncate); + + MObtainWriteLock(&mceP->afs_memLock, 313); + /* old directory entry; g.c. */ + if (size == 0 && mceP->dataSize > memCacheBlkSize) { + afs_osi_Free(mceP->data, mceP->dataSize); + mceP->data = afs_osi_Alloc(memCacheBlkSize); + mceP->dataSize = memCacheBlkSize; + } + + if (size < mceP->size) + mceP->size = size; + + MReleaseWriteLock(&mceP->afs_memLock); + return 0; +} + +int +afs_MemCacheStoreProc(register struct rx_call *acall, + register struct memCacheEntry *mceP, + register afs_int32 alen, struct vcache *avc, + int *shouldWake, afs_size_t * abytesToXferP, + afs_size_t * abytesXferredP, afs_int32 length) +{ + + register afs_int32 code; + register int tlen; + int offset = 0; + struct iovec *tiov; /* no data copying with iovec */ + int tnio; /* temp for iovec size */ + + AFS_STATCNT(afs_MemCacheStoreProc); #ifndef AFS_NOSTATS - /* - * In this case, alen is *always* the amount of data we'll be trying - * to ship here. - */ - *(abytesToXferP) = alen; - *(abytesXferredP) = 0; + /* + * In this case, alen is *always* the amount of data we'll be trying + * to ship here. + */ + *(abytesToXferP) = alen; + *(abytesXferredP) = 0; #endif /* AFS_NOSTATS */ - /* - * We need to alloc the iovecs on the heap so that they are "pinned" rather than - * declare them on the stack - defect 11272 - */ - tiov = (struct iovec *) osi_AllocSmallSpace(sizeof(struct iovec)*RX_MAXIOVECS); - if(!tiov) { - osi_Panic("afs_MemCacheStoreProc: osi_AllocSmallSpace for iovecs returned NULL\n"); - } - + /* + * We need to alloc the iovecs on the heap so that they are "pinned" rather than + * declare them on the stack - defect 11272 + */ + tiov = + (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec) * + RX_MAXIOVECS); + if (!tiov) { + osi_Panic + ("afs_MemCacheStoreProc: osi_AllocSmallSpace for iovecs returned NULL\n"); + } #ifdef notdef /* do this at a higher level now -- it's a parameter */ - /* for now, only do 'continue from close' code if file fits in one - chunk. Could clearly do better: if only one modified chunk - then can still do this. can do this on *last* modified chunk */ - tlen = avc->m.Length-1; /* byte position of last byte we'll store */ - if (shouldWake) { - if (AFS_CHUNK(tlen) != 0) *shouldWake = 0; - else *shouldWake = 1; - } + /* for now, only do 'continue from close' code if file fits in one + * chunk. Could clearly do better: if only one modified chunk + * then can still do this. can do this on *last* modified chunk */ + tlen = avc->m.Length - 1; /* byte position of last byte we'll store */ + if (shouldWake) { + if (AFS_CHUNK(tlen) != 0) + *shouldWake = 0; + else + *shouldWake = 1; + } #endif /* notdef */ - - while (alen > 0) { - tlen = (alen > AFS_LRALLOCSIZ? AFS_LRALLOCSIZ : alen); - RX_AFS_GUNLOCK(); - code = rx_WritevAlloc(acall, tiov, &tnio, RX_MAXIOVECS, tlen); - RX_AFS_GLOCK(); - if (code <= 0) { - osi_FreeSmallSpace(tiov); - return -33; - } - tlen = code; - code = afs_MemReadvBlk(mceP, offset, tiov, tnio, tlen); - if (code != tlen) { - osi_FreeSmallSpace(tiov); - return -33; - } - RX_AFS_GUNLOCK(); - code = rx_Writev(acall, tiov, tnio, tlen); - RX_AFS_GLOCK(); + + while (alen > 0) { + tlen = (alen > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : alen); + RX_AFS_GUNLOCK(); + code = rx_WritevAlloc(acall, tiov, &tnio, RX_MAXIOVECS, tlen); + RX_AFS_GLOCK(); + if (code <= 0) { + osi_FreeSmallSpace(tiov); + return -33; + } + tlen = code; + code = afs_MemReadvBlk(mceP, offset, tiov, tnio, tlen); + if (code != tlen) { + osi_FreeSmallSpace(tiov); + return -33; + } + RX_AFS_GUNLOCK(); + code = rx_Writev(acall, tiov, tnio, tlen); + RX_AFS_GLOCK(); #ifndef AFS_NOSTATS - (*abytesXferredP) += code; + (*abytesXferredP) += code; #endif /* AFS_NOSTATS */ - if (code != tlen) { - osi_FreeSmallSpace(tiov); - return -33; - } - offset += tlen; - alen -= tlen; - /* if file has been locked on server, can allow store to continue */ - if (shouldWake && *shouldWake && (rx_GetRemoteStatus(acall) & 1)) { - *shouldWake = 0; /* only do this once */ - afs_wakeup(avc); - } - } - osi_FreeSmallSpace(tiov); - return 0; - } - -int afs_MemCacheFetchProc(register struct rx_call *acall, register struct memCacheEntry *mceP, - afs_size_t abase, struct dcache *adc, struct vcache *avc, afs_size_t *abytesToXferP, - afs_size_t *abytesXferredP, afs_int32 lengthFound) + if (code != tlen) { + osi_FreeSmallSpace(tiov); + return -33; + } + offset += tlen; + alen -= tlen; + /* if file has been locked on server, can allow store to continue */ + if (shouldWake && *shouldWake && (rx_GetRemoteStatus(acall) & 1)) { + *shouldWake = 0; /* only do this once */ + afs_wakeup(avc); + } + } + osi_FreeSmallSpace(tiov); + return 0; +} + +int +afs_MemCacheFetchProc(register struct rx_call *acall, + register struct memCacheEntry *mceP, afs_size_t abase, + struct dcache *adc, struct vcache *avc, + afs_size_t * abytesToXferP, afs_size_t * abytesXferredP, + afs_int32 lengthFound) { - register afs_int32 code; - afs_int32 length; - int moredata = 0; - struct iovec *tiov; /* no data copying with iovec */ - register int tlen, offset=0; - int tnio; /* temp for iovec size */ - - AFS_STATCNT(afs_MemCacheFetchProc); - length = lengthFound; - afs_Trace4(afs_iclSetp, CM_TRACE_MEMFETCH, - ICL_TYPE_POINTER, avc, - ICL_TYPE_POINTER, mceP, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(abase), - ICL_TYPE_INT32, length); + register afs_int32 code; + afs_int32 length; + int moredata = 0; + struct iovec *tiov; /* no data copying with iovec */ + register int tlen, offset = 0; + int tnio; /* temp for iovec size */ + + AFS_STATCNT(afs_MemCacheFetchProc); + length = lengthFound; + afs_Trace4(afs_iclSetp, CM_TRACE_MEMFETCH, ICL_TYPE_POINTER, avc, + ICL_TYPE_POINTER, mceP, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(abase), ICL_TYPE_INT32, length); #ifndef AFS_NOSTATS - (*abytesToXferP) = 0; - (*abytesXferredP) = 0; + (*abytesToXferP) = 0; + (*abytesXferredP) = 0; #endif /* AFS_NOSTATS */ - /* - * We need to alloc the iovecs on the heap so that they are "pinned" rather than - * declare them on the stack - defect 11272 - */ - tiov = (struct iovec *) osi_AllocSmallSpace(sizeof(struct iovec)*RX_MAXIOVECS); - if(!tiov) { - osi_Panic("afs_MemCacheFetchProc: osi_AllocSmallSpace for iovecs returned NULL\n"); - } - adc->validPos = abase; - do { - if (moredata) { - RX_AFS_GUNLOCK(); - code = rx_Read(acall, (char *)&length, sizeof(afs_int32)); - length = ntohl(length); - RX_AFS_GLOCK(); - if (code != sizeof(afs_int32)) { - code = rx_Error(acall); - osi_FreeSmallSpace(tiov); - return (code?code:-1); /* try to return code, not -1 */ - } - } - /* - * The fetch protocol is extended for the AFS/DFS translator - * to allow multiple blocks of data, each with its own length, - * to be returned. As long as the top bit is set, there are more - * blocks expected. - * - * We do not do this for AFS file servers because they sometimes - * return large negative numbers as the transfer size. - */ - if (avc->states & CForeign) { - moredata = length & 0x80000000; - length &= ~0x80000000; - } else { - moredata = 0; - } + /* + * We need to alloc the iovecs on the heap so that they are "pinned" rather than + * declare them on the stack - defect 11272 + */ + tiov = + (struct iovec *)osi_AllocSmallSpace(sizeof(struct iovec) * + RX_MAXIOVECS); + if (!tiov) { + osi_Panic + ("afs_MemCacheFetchProc: osi_AllocSmallSpace for iovecs returned NULL\n"); + } + adc->validPos = abase; + do { + if (moredata) { + RX_AFS_GUNLOCK(); + code = rx_Read(acall, (char *)&length, sizeof(afs_int32)); + length = ntohl(length); + RX_AFS_GLOCK(); + if (code != sizeof(afs_int32)) { + code = rx_Error(acall); + osi_FreeSmallSpace(tiov); + return (code ? code : -1); /* try to return code, not -1 */ + } + } + /* + * The fetch protocol is extended for the AFS/DFS translator + * to allow multiple blocks of data, each with its own length, + * to be returned. As long as the top bit is set, there are more + * blocks expected. + * + * We do not do this for AFS file servers because they sometimes + * return large negative numbers as the transfer size. + */ + if (avc->states & CForeign) { + moredata = length & 0x80000000; + length &= ~0x80000000; + } else { + moredata = 0; + } #ifndef AFS_NOSTATS - (*abytesToXferP) += length; -#endif /* AFS_NOSTATS */ - while (length > 0) { - tlen = (length > AFS_LRALLOCSIZ? AFS_LRALLOCSIZ : length); - RX_AFS_GUNLOCK(); - code = rx_Readv(acall, tiov, &tnio, RX_MAXIOVECS, tlen); - RX_AFS_GLOCK(); + (*abytesToXferP) += length; +#endif /* AFS_NOSTATS */ + while (length > 0) { + tlen = (length > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : length); + RX_AFS_GUNLOCK(); + code = rx_Readv(acall, tiov, &tnio, RX_MAXIOVECS, tlen); + RX_AFS_GLOCK(); #ifndef AFS_NOSTATS - (*abytesXferredP) += code; -#endif /* AFS_NOSTATS */ - if (code <= 0) { - afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64READ, - ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code, - ICL_TYPE_INT32, length); - osi_FreeSmallSpace(tiov); - return -34; - } - tlen = code; - afs_MemWritevBlk(mceP, offset, tiov, tnio, tlen); - offset += tlen; - abase += tlen; - length -= tlen; - adc->validPos = abase; - if (afs_osi_Wakeup(&adc->validPos) == 0) - afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, - ICL_TYPE_STRING, __FILE__, - ICL_TYPE_INT32, __LINE__, - ICL_TYPE_POINTER, adc, - ICL_TYPE_INT32, adc->dflags); - } - } while (moredata); - /* max of two sizes */ - osi_FreeSmallSpace(tiov); - return 0; - } - - -void shutdown_memcache(void) + (*abytesXferredP) += code; +#endif /* AFS_NOSTATS */ + if (code <= 0) { + afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64READ, + ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code, + ICL_TYPE_INT32, length); + osi_FreeSmallSpace(tiov); + return -34; + } + tlen = code; + afs_MemWritevBlk(mceP, offset, tiov, tnio, tlen); + offset += tlen; + abase += tlen; + length -= tlen; + adc->validPos = abase; + if (afs_osi_Wakeup(&adc->validPos) == 0) + afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, ICL_TYPE_STRING, + __FILE__, ICL_TYPE_INT32, __LINE__, + ICL_TYPE_POINTER, adc, ICL_TYPE_INT32, + adc->dflags); + } + } while (moredata); + /* max of two sizes */ + osi_FreeSmallSpace(tiov); + return 0; +} + + +void +shutdown_memcache(void) { register int index; @@ -490,9 +513,10 @@ void shutdown_memcache(void) return; memCacheBlkSize = 8192; for (index = 0; index < memMaxBlkNumber; index++) { - LOCK_INIT(&((memCache+index)->afs_memLock), "afs_memLock"); - afs_osi_Free((memCache+index)->data, (memCache+index)->dataSize); + LOCK_INIT(&((memCache + index)->afs_memLock), "afs_memLock"); + afs_osi_Free((memCache + index)->data, (memCache + index)->dataSize); } - afs_osi_Free((char *)memCache, memMaxBlkNumber * sizeof(struct memCacheEntry)); + afs_osi_Free((char *)memCache, + memMaxBlkNumber * sizeof(struct memCacheEntry)); memMaxBlkNumber = 0; } diff --git a/src/afs/afs_nfsclnt.c b/src/afs/afs_nfsclnt.c index a2ce0b320..c970f0ff3 100644 --- a/src/afs/afs_nfsclnt.c +++ b/src/afs/afs_nfsclnt.c @@ -10,7 +10,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #if !defined(AFS_NONFSTRANS) || defined(AFS_AIX_IAUTH_ENV) #ifndef AFS_DEC_ENV @@ -29,20 +30,21 @@ int afs_allnfsreqs, afs_nfscalls; struct exporterops nfs_exportops = { afs_nfsclient_reqhandler, afs_nfsclient_hold, - afs_PutNfsClientPag, /* Used to be afs_nfsclient_rele */ + afs_PutNfsClientPag, /* Used to be afs_nfsclient_rele */ afs_nfsclient_sysname, afs_nfsclient_GC, afs_nfsclient_stats, }; -struct nfsclientpag *afs_nfspags[NNFSCLIENTS]; -afs_lock_t afs_xnfspag /*, afs_xnfsreq */; -extern struct afs_exporter *afs_nfsexporter; +struct nfsclientpag *afs_nfspags[NNFSCLIENTS]; +afs_lock_t afs_xnfspag /*, afs_xnfsreq */ ; +extern struct afs_exporter *afs_nfsexporter; /* Creates an nfsclientpag structure for the (uid, host) pair if one doesn't exist. RefCount is incremented and it's time stamped. */ -static struct nfsclientpag *afs_GetNfsClientPag(uid, host) -register afs_int32 uid, host; +static struct nfsclientpag * +afs_GetNfsClientPag(uid, host) + register afs_int32 uid, host; { register struct nfsclientpag *np; register afs_int32 i, now; @@ -53,7 +55,7 @@ register afs_int32 uid, host; AFS_STATCNT(afs_GetNfsClientPag); i = NHash(host); now = osi_Time(); - MObtainWriteLock(&afs_xnfspag,314); + MObtainWriteLock(&afs_xnfspag, 314); for (np = afs_nfspags[i]; np; np = np->next) { if (np->uid == uid && np->host == host) { np->refCount++; @@ -71,7 +73,7 @@ register afs_int32 uid, host; return np; } } - np = (struct nfsclientpag *) afs_osi_Alloc(sizeof (struct nfsclientpag)); + np = (struct nfsclientpag *)afs_osi_Alloc(sizeof(struct nfsclientpag)); memset((char *)np, 0, sizeof(struct nfsclientpag)); /* Copy the necessary afs_exporter fields */ memcpy((char *)np, (char *)afs_nfsexporter, sizeof(struct afs_exporter)); @@ -88,8 +90,9 @@ register afs_int32 uid, host; /* Decrement refCount; must always match a previous afs_FindNfsClientPag/afs_GetNfsClientPag call . It's also called whenever a unixuser structure belonging to the remote user associated with the nfsclientpag structure, np, is garbage collected. */ -int afs_PutNfsClientPag(np) -register struct nfsclientpag *np; +int +afs_PutNfsClientPag(np) + register struct nfsclientpag *np; { #if defined(AFS_SGIMP_ENV) osi_Assert(ISAFS_GLOCK()); @@ -100,8 +103,9 @@ register struct nfsclientpag *np; /* Return the nfsclientpag structure associated with the (uid, host) or {pag, host} pair, if pag is nonzero. RefCount is incremented and it's time stamped. */ -static struct nfsclientpag *afs_FindNfsClientPag(uid, host, pag) -register afs_int32 uid, host, pag; +static struct nfsclientpag * +afs_FindNfsClientPag(uid, host, pag) + register afs_int32 uid, host, pag; { register struct nfsclientpag *np; register afs_int32 i; @@ -111,26 +115,26 @@ register afs_int32 uid, host, pag; #endif AFS_STATCNT(afs_FindNfsClientPag); i = NHash(host); - MObtainWriteLock(&afs_xnfspag,315); + MObtainWriteLock(&afs_xnfspag, 315); for (np = afs_nfspags[i]; np; np = np->next) { if (np->host == host) { - if ((pag && pag == np->pag) || (!pag && (uid == np->uid))) { - np->refCount++; - np->lastcall = osi_Time(); - MReleaseWriteLock(&afs_xnfspag); - return np; - } + if ((pag && pag == np->pag) || (!pag && (uid == np->uid))) { + np->refCount++; + np->lastcall = osi_Time(); + MReleaseWriteLock(&afs_xnfspag); + return np; + } } } /* still not there, try looking for a wildcard dude */ for (np = afs_nfspags[i]; np; np = np->next) { if (np->host == host) { - if (np->uid == NOPAG) { - np->refCount++; - np->lastcall = osi_Time(); - MReleaseWriteLock(&afs_xnfspag); - return np; - } + if (np->uid == NOPAG) { + np->refCount++; + np->lastcall = osi_Time(); + MReleaseWriteLock(&afs_xnfspag); + return np; + } } } MReleaseWriteLock(&afs_xnfspag); @@ -143,7 +147,8 @@ register afs_int32 uid, host, pag; */ struct afs_exporter *afs_nfsexported = 0; static afs_int32 init_nfsexporter = 0; -afs_nfsclient_init() { +afs_nfsclient_init() +{ #if defined(AFS_SGIMP_ENV) osi_Assert(ISAFS_GLOCK()); #endif @@ -152,7 +157,8 @@ afs_nfsclient_init() { init_nfsexporter = 1; LOCK_INIT(&afs_xnfspag, "afs_xnfspag"); - afs_nfsexported = exporter_add(0, &nfs_exportops, EXP_EXPORTED, EXP_NFS, NULL); + afs_nfsexported = + exporter_add(0, &nfs_exportops, EXP_EXPORTED, EXP_NFS, NULL); } } @@ -160,11 +166,12 @@ afs_nfsclient_init() { /* Main handler routine for the NFS exporter. It's called in the early * phases of any remote call (via the NFS server or pioctl). */ -int afs_nfsclient_reqhandler(exporter, cred, host, pagparam, outexporter) -register struct afs_exporter *exporter, **outexporter; -struct AFS_UCRED **cred; -register afs_int32 host; -afs_int32 *pagparam; +int +afs_nfsclient_reqhandler(exporter, cred, host, pagparam, outexporter) + register struct afs_exporter *exporter, **outexporter; + struct AFS_UCRED **cred; + register afs_int32 host; + afs_int32 *pagparam; { register struct nfsclientpag *np, *tnp; extern struct unixuser *afs_FindUser(), *afs_GetUser(); @@ -173,8 +180,9 @@ afs_int32 *pagparam; AFS_ASSERT_GLOCK(); AFS_STATCNT(afs_nfsclient_reqhandler); - if (!afs_nfsexporter) afs_nfsexporter = afs_nfsexported; - + if (!afs_nfsexporter) + afs_nfsexporter = afs_nfsexported; + afs_nfsexporter->exp_stats.calls++; if (!(afs_nfsexporter->exp_states & EXP_EXPORTED)) { /* No afs requests accepted as long as EXPORTED flag is turned 'off'. Set/Reset via a pioctl call (fs exportafs). Note that this is on top of the /etc/exports nfs requirement (i.e. /afs must be exported to all or whomever there too!) @@ -187,7 +195,7 @@ afs_int32 *pagparam; if (pag != NOPAG) { /* Do some minimal pag verification */ if (pag > getpag()) { - pag = NOPAG; /* treat it as not paged since couldn't be good */ + pag = NOPAG; /* treat it as not paged since couldn't be good */ } else { if (au = afs_FindUser(pag, -1, READ_LOCK)) { if (!au->exporter) { @@ -195,7 +203,7 @@ afs_int32 *pagparam; afs_PutUser(au, READ_LOCK); au = NULL; } - } else + } else pag = NOPAG; /* No unixuser struct so pag not trusted */ } } @@ -210,7 +218,8 @@ afs_int32 *pagparam; #else if (code = setpag(cred, -1, &pag, 1)) { #endif - if (au) afs_PutUser(au, READ_LOCK); + if (au) + afs_PutUser(au, READ_LOCK); /* ReleaseWriteLock(&afs_xnfsreq); */ #if defined(KERNEL_HAVE_UERROR) setuerror(code); @@ -233,9 +242,10 @@ afs_int32 *pagparam; #endif return (code); } - } else if (au->exporter && ((struct afs_exporter *)np != au->exporter)) { + } else if (au->exporter + && ((struct afs_exporter *)np != au->exporter)) { tnp = (struct nfsclientpag *)au->exporter; - if (tnp->uid && (tnp->uid != (afs_int32)-2)) { /* allow "root" initiators */ + if (tnp->uid && (tnp->uid != (afs_int32) - 2)) { /* allow "root" initiators */ /* Pag doesn't belong to caller; treat it as an unpaged call too */ #ifdef AFS_OSF_ENV if (code = setpag(u.u_procp, cred, np->pag, &pag, 1)) { /* XXX u.u_procp is a no-op XXX */ @@ -244,7 +254,7 @@ afs_int32 *pagparam; #endif afs_PutNfsClientPag(np); afs_PutUser(au, READ_LOCK); - /* ReleaseWriteLock(&afs_xnfsreq); */ + /* ReleaseWriteLock(&afs_xnfsreq); */ #if defined(KERNEL_HAVE_UERROR) setuerror(code); #endif @@ -254,7 +264,8 @@ afs_int32 *pagparam; } } } - if (au) afs_PutUser(au, READ_LOCK); + if (au) + afs_PutUser(au, READ_LOCK); au = afs_GetUser(pag, -1, WRITE_LOCK); if (!(au->exporter)) { /* Created new unixuser struct */ np->refCount++; /* so it won't disappear */ @@ -264,9 +275,9 @@ afs_int32 *pagparam; *outexporter = (struct afs_exporter *)np; afs_PutUser(au, WRITE_LOCK); #ifdef AFS_OSF_ENV - (*cred)->cr_ruid = NFSXLATOR_CRED; /* Identify it as nfs xlator call */ + (*cred)->cr_ruid = NFSXLATOR_CRED; /* Identify it as nfs xlator call */ #else - (*cred)->cr_rgid = NFSXLATOR_CRED; /* Identify it as nfs xlator call */ + (*cred)->cr_rgid = NFSXLATOR_CRED; /* Identify it as nfs xlator call */ #endif /* ReleaseWriteLock(&afs_xnfsreq); */ return 0; @@ -274,8 +285,9 @@ afs_int32 *pagparam; /* It's called whenever a new unixuser structure is created for the remote user associated with the nfsclientpag structure, np */ -int afs_nfsclient_hold(np) -register struct nfsclientpag *np; +int +afs_nfsclient_hold(np) + register struct nfsclientpag *np; { #if defined(AFS_SGIMP_ENV) osi_Assert(ISAFS_GLOCK()); @@ -286,9 +298,10 @@ register struct nfsclientpag *np; /* if inname is non-null, a new system name value is set for the remote user (inname contains the new sysname). In all cases, outname returns the current sysname value for this remote user */ -int afs_nfsclient_sysname(np, inname, outname) -register struct nfsclientpag *np; -char *inname, *outname; +int +afs_nfsclient_sysname(np, inname, outname) + register struct nfsclientpag *np; + char *inname, *outname; { #if defined(AFS_SGIMP_ENV) osi_Assert(ISAFS_GLOCK()); @@ -300,7 +313,7 @@ char *inname, *outname; } strcpy(np->sysname, inname); } else if (!np->sysname) { - return ENODEV; /* XXX */ + return ENODEV; /* XXX */ } strcpy(outname, np->sysname); return 0; @@ -308,9 +321,10 @@ char *inname, *outname; /* Garbage collect routine for the nfs exporter. When pag is -1 then all entries are removed (used by the nfsclient_shutdown routine); else if it's non zero then only the entry with that pag is removed, else all "timedout" entries are removed. TimedOut entries are those who have no "unixuser" structures associated with them (i.e. unixusercnt == 0) and they haven't had any activity the last NFSCLIENTGC seconds */ -int afs_nfsclient_GC(exporter, pag) -register struct afs_exporter *exporter; -register afs_int32 pag; +int +afs_nfsclient_GC(exporter, pag) + register struct afs_exporter *exporter; + register afs_int32 pag; { register struct nfsclientpag *np, **tnp, *nnp; register afs_int32 i, delflag; @@ -319,17 +333,19 @@ register afs_int32 pag; osi_Assert(ISAFS_GLOCK()); #endif AFS_STATCNT(afs_nfsclient_GC); - MObtainWriteLock(&afs_xnfspag,316); + MObtainWriteLock(&afs_xnfspag, 316); for (i = 0; i < NNFSCLIENTS; i++) { for (tnp = &afs_nfspags[i], np = *tnp; np; np = nnp) { nnp = np->next; delflag = 0; if (np->refCount == 0 && np->lastcall < osi_Time() - NFSCLIENTGC) delflag = 1; - if ((pag == -1) || (!pag && delflag) || (pag && (np->refCount == 0) && (np->pag == pag))) { + if ((pag == -1) || (!pag && delflag) + || (pag && (np->refCount == 0) && (np->pag == pag))) { *tnp = np->next; - if (np->sysname) afs_osi_Free(np->sysname, MAXSYSNAME); - afs_osi_Free(np, sizeof(struct nfsclientpag)); + if (np->sysname) + afs_osi_Free(np->sysname, MAXSYSNAME); + afs_osi_Free(np, sizeof(struct nfsclientpag)); } else { tnp = &np->next; } @@ -339,8 +355,9 @@ register afs_int32 pag; } -int afs_nfsclient_stats(export) -register struct afs_exporter *export; +int +afs_nfsclient_stats(export) + register struct afs_exporter *export; { /* Nothing much to do here yet since most important stats are collected directly in the afs_exporter structure itself */ AFS_STATCNT(afs_nfsclient_stats); @@ -359,37 +376,39 @@ char *afs_nfs_id = "AFSNFSTRANS"; /* afs_iauth_verify is the AFS authenticator for NFS. * * always returns 0. - */ -int afs_iauth_verify(long id, fsid_t *fsidp, long host, - int uid, struct AFS_UCRED *credp, struct exportinfo *exp) + */ +int +afs_iauth_verify(long id, fsid_t * fsidp, long host, int uid, + struct AFS_UCRED *credp, struct exportinfo *exp) { int code; struct nfsclientpag *nfs_pag; afs_int32 dummypag; struct afs_exporter *outexporter = 0; - + /* Still needs basic test to see if exporter is on. And need to check the * whole no submounts bit. */ if (id != (long)id) - return 0; /* not us. */ + return 0; /* not us. */ /* Only care if it's AFS */ if ((fsidp->val[0] != AFS_VFSMAGIC) || (fsidp->val[1] != AFS_VFSFSID)) { - return 0; + return 0; } AFS_GLOCK(); - code = afs_nfsclient_reqhandler((struct afs_exporter *)0, &credp, - host, &dummypag, &outexporter); + code = + afs_nfsclient_reqhandler((struct afs_exporter *)0, &credp, host, + &dummypag, &outexporter); if (!code && outexporter) EXP_RELE(outexporter); if (code) { /* ensure anonymous cred. */ - credp->cr_uid = credp->cr_ruid = (uid_t)-2; /* anonymous */ + credp->cr_uid = credp->cr_ruid = (uid_t) - 2; /* anonymous */ } /* Mark this thread as an NFS translator thread. */ @@ -402,7 +421,8 @@ int afs_iauth_verify(long id, fsid_t *fsidp, long host, /* afs_iauth_register - register the iauth verify routine. Returns 0 on success * and -1 on failure. Can fail because DFS has already registered. */ -int afs_iauth_register() +int +afs_iauth_register() { if (nfs_iauth_register((unsigned long)afs_nfs_id, afs_iauth_verify)) return -1; @@ -414,7 +434,8 @@ int afs_iauth_register() /* afs_iauth_unregister - unregister the iauth verify routine. Called on shutdown. */ -void afs_iauth_unregister() +void +afs_iauth_unregister() { if (afs_iauth_initd) nfs_iauth_unregister((unsigned long)afs_nfs_id); @@ -424,7 +445,8 @@ void afs_iauth_unregister() -shutdown_nfsclnt() { +shutdown_nfsclnt() +{ #if 0 extern int afs_allnfsreqs, afs_nfscalls; #endif @@ -432,7 +454,7 @@ shutdown_nfsclnt() { #if defined(AFS_SGIMP_ENV) osi_Assert(ISAFS_GLOCK()); #endif - AFS_STATCNT(afs_nfsclient_shutdown); + AFS_STATCNT(afs_nfsclient_shutdown); #ifdef AFS_AIX_IAUTH_ENV afs_iauth_register(); #endif @@ -445,4 +467,3 @@ shutdown_nfsclnt() { } #endif /* AFS_DEC_ENV */ #endif /* AFS_NONFSTRANS */ - diff --git a/src/afs/afs_nfsdisp.c b/src/afs/afs_nfsdisp.c index e4fbf9166..71eac0edd 100644 --- a/src/afs/afs_nfsdisp.c +++ b/src/afs/afs_nfsdisp.c @@ -10,13 +10,14 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); /* Ugly Ugly Ugly but precludes conflicting XDR macros; We want kernel xdr */ #define __XDR_INCLUDE__ #include "afs/stds.h" -#include "afs/sysincludes.h" /* Standard vendor system headers */ -#if defined(AFS_SUN55_ENV) && !defined(AFS_NONFSTRANS) +#include "afs/sysincludes.h" /* Standard vendor system headers */ +#if defined(AFS_SUN55_ENV) && !defined(AFS_NONFSTRANS) #include "rpc/types.h" #include "rpc/auth.h" #include "rpc/auth_unix.h" @@ -31,31 +32,31 @@ RCSID("$Header$"); #include "nfs/export.h" #include "nfs/nfs_clnt.h" #include "nfs/nfs_acl.h" -#include "afs/afsincludes.h" -#include "afs/afs_stats.h" +#include "afs/afsincludes.h" +#include "afs/afs_stats.h" #include "afs/exporter.h" -static int xlatorinit_v2_done=0; -static int xlatorinit_v3_done=0; +static int xlatorinit_v2_done = 0; +static int xlatorinit_v3_done = 0; extern int afs_nobody; extern int afs_NFSRootOnly; struct rfs_disp_tbl { - void (*dis_proc)(); + void (*dis_proc) (); xdrproc_t dis_xdrargs; xdrproc_t dis_fastxdrargs; - int dis_argsz; - xdrproc_t dis_xdrres; - xdrproc_t dis_fastxdrres; - int dis_ressz; - void (*dis_resfree)(); - int dis_flags; - fhandle_t (*dis_getfh)(); + int dis_argsz; + xdrproc_t dis_xdrres; + xdrproc_t dis_fastxdrres; + int dis_ressz; + void (*dis_resfree) (); + int dis_flags; + fhandle_t(*dis_getfh) (); }; struct afs_nfs_disp_tbl { - void (*afs_proc)(); - void (*orig_proc)(); + void (*afs_proc) (); + void (*orig_proc) (); }; struct afs_nfs2_resp { enum nfsstat status; @@ -68,107 +69,109 @@ struct afs_nfs_disp_tbl afs_rfs_disp_tbl[RFS_NPROC]; struct afs_nfs_disp_tbl afs_acl_disp_tbl[ACL2_NPROC]; static int -is_afs_fh(fhandle_t *fhp) { - if ((fhp->fh_fsid.val[0] == AFS_VFSMAGIC) && - (fhp->fh_fsid.val[1] == AFS_VFSFSID)) +is_afs_fh(fhandle_t * fhp) +{ + if ((fhp->fh_fsid.val[0] == AFS_VFSMAGIC) + && (fhp->fh_fsid.val[1] == AFS_VFSFSID)) return 1; return 0; } afs_int32 -nfs2_to_afs_call(int which, caddr_t *args, fhandle_t **fhpp, fhandle_t **fh2pp) +nfs2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp, + fhandle_t ** fh2pp) { struct vnode *vp; - fhandle_t *fhp1=0; - fhandle_t *fhp2=0; + fhandle_t *fhp1 = 0; + fhandle_t *fhp2 = 0; int errorcode; - + afs_Trace1(afs_iclSetp, CM_TRACE_NFSIN, ICL_TYPE_INT32, which); - *fh2pp = (fhandle_t *)0; + *fh2pp = (fhandle_t *) 0; switch (which) { case RFS_GETATTR: case RFS_READLINK: case RFS_STATFS: - fhp1 = (fhandle_t *)args; + fhp1 = (fhandle_t *) args; break; case RFS_SETATTR: - { - struct nfssaargs *sargs = (struct nfssaargs *)args; - fhp1 = (fhandle_t *)&sargs->saa_fh; - break; - } + { + struct nfssaargs *sargs = (struct nfssaargs *)args; + fhp1 = (fhandle_t *) & sargs->saa_fh; + break; + } case RFS_LOOKUP: - { - struct nfsdiropargs *sargs = (struct nfsdiropargs *)args; - fhp1 = sargs->da_fhandle; - break; - } + { + struct nfsdiropargs *sargs = (struct nfsdiropargs *)args; + fhp1 = sargs->da_fhandle; + break; + } case RFS_READ: - { - struct nfsreadargs *sargs = (struct nfsreadargs *)args; - fhp1 = (fhandle_t *)&sargs->ra_fhandle; - break; - } + { + struct nfsreadargs *sargs = (struct nfsreadargs *)args; + fhp1 = (fhandle_t *) & sargs->ra_fhandle; + break; + } case RFS_WRITE: - { - struct nfswriteargs *sargs = (struct nfswriteargs *)args; - fhp1 = (fhandle_t *)&sargs->wa_fhandle; - break; - } + { + struct nfswriteargs *sargs = (struct nfswriteargs *)args; + fhp1 = (fhandle_t *) & sargs->wa_fhandle; + break; + } case RFS_CREATE: - { - struct nfscreatargs *sargs = (struct nfscreatargs *)args; - fhp1 = sargs->ca_da.da_fhandle; - break; - } + { + struct nfscreatargs *sargs = (struct nfscreatargs *)args; + fhp1 = sargs->ca_da.da_fhandle; + break; + } case RFS_REMOVE: - { - struct nfsdiropargs *sargs = (struct nfsdiropargs *)args; - fhp1 = sargs->da_fhandle; - break; - } + { + struct nfsdiropargs *sargs = (struct nfsdiropargs *)args; + fhp1 = sargs->da_fhandle; + break; + } case RFS_RENAME: - { - struct nfsrnmargs *sargs = (struct nfsrnmargs *)args; - fhp1 = sargs->rna_from.da_fhandle; - fhp2 = sargs->rna_to.da_fhandle; - break; - } + { + struct nfsrnmargs *sargs = (struct nfsrnmargs *)args; + fhp1 = sargs->rna_from.da_fhandle; + fhp2 = sargs->rna_to.da_fhandle; + break; + } case RFS_LINK: - { - struct nfslinkargs *sargs = (struct nfslinkargs *)args; - fhp1 = sargs->la_from; - fhp2 = sargs->la_to.da_fhandle; - break; - } + { + struct nfslinkargs *sargs = (struct nfslinkargs *)args; + fhp1 = sargs->la_from; + fhp2 = sargs->la_to.da_fhandle; + break; + } case RFS_SYMLINK: - { - struct nfsslargs *sargs = (struct nfsslargs *)args; - fhp1 = sargs->sla_from.da_fhandle; - break; - } + { + struct nfsslargs *sargs = (struct nfsslargs *)args; + fhp1 = sargs->sla_from.da_fhandle; + break; + } case RFS_MKDIR: - { - struct nfscreatargs *sargs = (struct nfscreatargs *)args; - fhp1 = sargs->ca_da.da_fhandle; - break; - } + { + struct nfscreatargs *sargs = (struct nfscreatargs *)args; + fhp1 = sargs->ca_da.da_fhandle; + break; + } case RFS_RMDIR: - { - struct nfsdiropargs *sargs = (struct nfsdiropargs *)args; - fhp1 = sargs->da_fhandle; - break; - } + { + struct nfsdiropargs *sargs = (struct nfsdiropargs *)args; + fhp1 = sargs->da_fhandle; + break; + } case RFS_READDIR: - { - struct nfsrddirargs *sargs = (struct nfsrddirargs *)args; - fhp1 = (fhandle_t *)&sargs->rda_fh; - break; - } + { + struct nfsrddirargs *sargs = (struct nfsrddirargs *)args; + fhp1 = (fhandle_t *) & sargs->rda_fh; + break; + } default: return NULL; } - + /* Ok if arg 1 is in AFS or if 2 args and arg 2 is in AFS */ if (is_afs_fh(fhp1)) { *fhpp = fhp1; @@ -185,70 +188,70 @@ nfs2_to_afs_call(int which, caddr_t *args, fhandle_t **fhpp, fhandle_t **fh2pp) } afs_int32 -acl2_to_afs_call(int which, caddr_t *args, fhandle_t **fhpp) +acl2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp) { fhandle_t *fhp; - - switch(which) { + + switch (which) { case ACLPROC2_NULL: - { - return NULL; - } + { + return NULL; + } case ACLPROC2_GETACL: - { - struct GETACL2args *sargs = (struct GETACL2args *) args; - fhp = &sargs->fh; - break; - } + { + struct GETACL2args *sargs = (struct GETACL2args *)args; + fhp = &sargs->fh; + break; + } case ACLPROC2_SETACL: - { - struct SETACL2args *sargs = (struct SETACL2args *) args; - fhp = &sargs->fh; - break; - } + { + struct SETACL2args *sargs = (struct SETACL2args *)args; + fhp = &sargs->fh; + break; + } case ACLPROC2_GETATTR: - { - struct GETATTR2args *sargs = (struct GETATTR2args *) args; - fhp = &sargs->fh; - break; - } + { + struct GETATTR2args *sargs = (struct GETATTR2args *)args; + fhp = &sargs->fh; + break; + } case ACLPROC2_ACCESS: - { - struct ACCESS2args *sargs = (struct ACCESS2args *) args; - fhp = &sargs->fh; - break; - } + { + struct ACCESS2args *sargs = (struct ACCESS2args *)args; + fhp = &sargs->fh; + break; + } default: return NULL; } - + if (is_afs_fh(fhp)) { *fhpp = fhp; return 1; } - + return NULL; } int afs_nfs2_dispatcher(int type, afs_int32 which, char *argp, - struct exportinfo **expp, - struct svc_req *rp, struct AFS_UCRED *crp) + struct exportinfo **expp, struct svc_req *rp, + struct AFS_UCRED *crp) { afs_int32 call = 0; afs_int32 code = 0; afs_int32 client = 0; struct sockaddr *sa; - fhandle_t *fh = (fhandle_t *)argp; - fhandle_t *fh2 = (fhandle_t *)0; - + fhandle_t *fh = (fhandle_t *) argp; + fhandle_t *fh2 = (fhandle_t *) 0; + if (!xlatorinit_v2_done) return 2; - + sa = (struct sockaddr *)svc_getrpccaller(rp->rq_xprt)->buf; if (sa->sa_family == AF_INET) client = ((struct sockaddr_in *)sa)->sin_addr.s_addr; - + AFS_GLOCK(); code = 0; switch (type) { @@ -261,17 +264,16 @@ afs_nfs2_dispatcher(int type, afs_int32 which, char *argp, default: break; } - + if (code) { struct afs_exporter *out = 0; afs_int32 dummy; static int once = 0; struct SmallFid Sfid; - + memcpy((char *)&Sfid, fh->fh_data, SIZEOF_SMALLFID); - - afs_Trace2(afs_iclSetp, CM_TRACE_NFSIN1, - ICL_TYPE_POINTER, client, + + afs_Trace2(afs_iclSetp, CM_TRACE_NFSIN1, ICL_TYPE_POINTER, client, ICL_TYPE_FID, &Sfid); /* We ran */ @@ -280,16 +282,17 @@ afs_nfs2_dispatcher(int type, afs_int32 which, char *argp, afs_nobody = (*expp)->exi_export.ex_anon; once = 1; } - code = afs_nfsclient_reqhandler((struct afs_exporter *)0, &crp, - client, &dummy, &out); - + code = + afs_nfsclient_reqhandler((struct afs_exporter *)0, &crp, client, + &dummy, &out); + if (!code && out) EXP_RELE(out); - + if (code == EINVAL) call = 2; } - + AFS_GUNLOCK(); return call; } @@ -297,41 +300,40 @@ afs_nfs2_dispatcher(int type, afs_int32 which, char *argp, void afs_nfs2_smallfidder(struct nfsdiropres *dr) { - register fhandle_t *fhp = (fhandle_t *)&dr->dr_fhandle; + register fhandle_t *fhp = (fhandle_t *) & dr->dr_fhandle; afs_int32 addr[2]; struct vcache *vcp; - + #if defined(AFS_SUN57_64BIT_ENV) - /* See also afs_fid() */ + /* See also afs_fid() */ memcpy((char *)addr, fhp->fh_data, SIZEOF_SMALLFID); addr[1] = (addr[1] >> 48) & 0xffff; -#else +#else memcpy((char *)addr, fhp->fh_data, 2 * sizeof(long)); #endif - + AFS_GLOCK(); - vcp = VTOAFS((struct vnode*)addr[0]); - - if (addr[1] == AFS_XLATOR_MAGIC) - { + vcp = VTOAFS((struct vnode *)addr[0]); + + if (addr[1] == AFS_XLATOR_MAGIC) { if (dr->dr_status == NFS_OK) { struct SmallFid Sfid; struct cell *tcell; - + /* Make up and copy out a SmallFid */ tcell = afs_GetCell(vcp->fid.Cell, READ_LOCK); Sfid.Volume = vcp->fid.Fid.Volume; - Sfid.CellAndUnique = ((tcell->cellIndex << 24) | - (vcp->fid.Fid.Unique & 0xffffff)); + Sfid.CellAndUnique = + ((tcell->cellIndex << 24) | (vcp->fid.Fid.Unique & 0xffffff)); afs_PutCell(tcell, READ_LOCK); - Sfid.Vnode = (u_short)(vcp->fid.Fid.Vnode & 0xffff); + Sfid.Vnode = (u_short) (vcp->fid.Fid.Vnode & 0xffff); fhp->fh_len = SIZEOF_SMALLFID; - memcpy(dr->dr_fhandle.fh_data, (char*)&Sfid, fhp->fh_len); + memcpy(dr->dr_fhandle.fh_data, (char *)&Sfid, fhp->fh_len); afs_Trace3(afs_iclSetp, CM_TRACE_NFSOUT, ICL_TYPE_INT32, 0, - ICL_TYPE_POINTER, vcp, ICL_TYPE_FID, &Sfid); + ICL_TYPE_POINTER, vcp, ICL_TYPE_FID, &Sfid); } - + /* If we have a ref, release it */ if (vcp->vrefCount >= 1) AFS_RELE(AFSTOV(vcp)); @@ -345,7 +347,8 @@ afs_nfs2_noaccess(struct afs_nfs2_resp *resp) resp->status = NFSERR_ACCES; } -void afs_nfs2_null(char *args, char *xp, char *exp, char *rp, char *crp) +void +afs_nfs2_null(char *args, char *xp, char *exp, char *rp, char *crp) { } @@ -359,262 +362,353 @@ afs_nfs2_writecache(char *args, char *xp, char *exp, char *rp, char *crp) { } -void afs_nfs2_getattr(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_GETATTR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_GETATTR].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_getattr(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_GETATTR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_GETATTR].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_setattr(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_SETATTR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_SETATTR].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_setattr(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_SETATTR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_SETATTR].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_lookup(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_LOOKUP, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else { (*afs_rfs_disp_tbl[RFS_LOOKUP].orig_proc)(args, xp, exp, rp, crp); - if (afs_NFSRootOnly && call) afs_nfs2_smallfidder(xp); } - curthread->t_cred = svcred; - return; +void +afs_nfs2_lookup(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_LOOKUP, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else { + (*afs_rfs_disp_tbl[RFS_LOOKUP].orig_proc) (args, xp, exp, rp, crp); + if (afs_NFSRootOnly && call) + afs_nfs2_smallfidder(xp); + } + curthread->t_cred = svcred; + return; } -void afs_nfs2_readlink(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_READLINK, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_READLINK].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_readlink(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_READLINK, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_READLINK].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_read(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_READ, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_READ].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_read(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_READ, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_READ].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_write(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_WRITE, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_WRITE].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_write(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_WRITE, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_WRITE].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_create(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_CREATE, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else { (*afs_rfs_disp_tbl[RFS_CREATE].orig_proc)(args, xp, exp, rp, crp); - if (afs_NFSRootOnly && call) afs_nfs2_smallfidder(xp); } - curthread->t_cred = svcred; - return; +void +afs_nfs2_create(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_CREATE, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else { + (*afs_rfs_disp_tbl[RFS_CREATE].orig_proc) (args, xp, exp, rp, crp); + if (afs_NFSRootOnly && call) + afs_nfs2_smallfidder(xp); + } + curthread->t_cred = svcred; + return; } -void afs_nfs2_remove(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_REMOVE, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_REMOVE].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_remove(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_REMOVE, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_REMOVE].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_rename(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_RENAME, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_RENAME].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_rename(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_RENAME, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_RENAME].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_link(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_LINK, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_LINK].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_link(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_LINK, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_LINK].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_symlink(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_SYMLINK, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_SYMLINK].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_symlink(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_SYMLINK, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_SYMLINK].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_mkdir(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_MKDIR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else { (*afs_rfs_disp_tbl[RFS_MKDIR].orig_proc)(args, xp, exp, rp, crp); - if (afs_NFSRootOnly && call) afs_nfs2_smallfidder(xp); } - curthread->t_cred = svcred; - return; +void +afs_nfs2_mkdir(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_MKDIR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else { + (*afs_rfs_disp_tbl[RFS_MKDIR].orig_proc) (args, xp, exp, rp, crp); + if (afs_NFSRootOnly && call) + afs_nfs2_smallfidder(xp); + } + curthread->t_cred = svcred; + return; } -void afs_nfs2_rmdir(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_RMDIR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_RMDIR].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_rmdir(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_RMDIR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_RMDIR].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_readdir(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_READDIR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_READDIR].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_readdir(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_READDIR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_READDIR].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs2_statfs(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(0, RFS_STATFS, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_rfs_disp_tbl[RFS_STATFS].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs2_statfs(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs2_dispatcher(0, RFS_STATFS, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_rfs_disp_tbl[RFS_STATFS].orig_proc) (args, xp, exp, rp, crp); + curthread->t_cred = svcred; + return; } struct afs_nfs_disp_tbl afs_rfs_disp_tbl[RFS_NPROC] = { - { afs_nfs2_null }, - { afs_nfs2_getattr }, - { afs_nfs2_setattr }, - { afs_nfs2_root }, - { afs_nfs2_lookup }, - { afs_nfs2_readlink }, - { afs_nfs2_read }, - { afs_nfs2_writecache }, - { afs_nfs2_write }, - { afs_nfs2_create }, - { afs_nfs2_remove }, - { afs_nfs2_rename }, - { afs_nfs2_link }, - { afs_nfs2_symlink }, - { afs_nfs2_mkdir }, - { afs_nfs2_rmdir }, - { afs_nfs2_readdir }, - { afs_nfs2_statfs } + {afs_nfs2_null}, + {afs_nfs2_getattr}, + {afs_nfs2_setattr}, + {afs_nfs2_root}, + {afs_nfs2_lookup}, + {afs_nfs2_readlink}, + {afs_nfs2_read}, + {afs_nfs2_writecache}, + {afs_nfs2_write}, + {afs_nfs2_create}, + {afs_nfs2_remove}, + {afs_nfs2_rename}, + {afs_nfs2_link}, + {afs_nfs2_symlink}, + {afs_nfs2_mkdir}, + {afs_nfs2_rmdir}, + {afs_nfs2_readdir}, + {afs_nfs2_statfs} }; -void afs_acl2_getacl(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(1, ACLPROC2_GETACL, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_acl_disp_tbl[ACLPROC2_GETACL].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_acl2_getacl(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs2_dispatcher(1, ACLPROC2_GETACL, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_acl_disp_tbl[ACLPROC2_GETACL].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_acl2_setacl(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(1, ACLPROC2_SETACL, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_acl_disp_tbl[ACLPROC2_SETACL].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_acl2_setacl(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs2_dispatcher(1, ACLPROC2_SETACL, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_acl_disp_tbl[ACLPROC2_SETACL].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_acl2_getattr(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(1, ACLPROC2_GETATTR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_acl_disp_tbl[ACLPROC2_GETATTR].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_acl2_getattr(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs2_dispatcher(1, ACLPROC2_GETATTR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_acl_disp_tbl[ACLPROC2_GETATTR].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_acl2_access(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs2_dispatcher(1, ACLPROC2_ACCESS, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); - else (*afs_acl_disp_tbl[ACLPROC2_ACCESS].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_acl2_access(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs2_dispatcher(1, ACLPROC2_ACCESS, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); + else + (*afs_acl_disp_tbl[ACLPROC2_ACCESS].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } struct afs_nfs_disp_tbl afs_acl_disp_tbl[5] = { - { afs_nfs2_null }, - { afs_acl2_getacl }, - { afs_acl2_setacl }, - { afs_acl2_getattr }, - { afs_acl2_access } + {afs_nfs2_null}, + {afs_acl2_getacl}, + {afs_acl2_setacl}, + {afs_acl2_getattr}, + {afs_acl2_access} }; /* Munge the dispatch tables to link us in first */ void afs_xlatorinit_v2(struct rfs_disp_tbl *_rfs_tbl, - struct rfs_disp_tbl *_acl_tbl) + struct rfs_disp_tbl *_acl_tbl) { int i; - - if (xlatorinit_v2_done++) return; - - for (i=0; i < RFS_NPROC; i++) { + + if (xlatorinit_v2_done++) + return; + + for (i = 0; i < RFS_NPROC; i++) { afs_rfs_disp_tbl[i].orig_proc = _rfs_tbl[i].dis_proc; _rfs_tbl[i].dis_proc = afs_rfs_disp_tbl[i].afs_proc; } - - for (i=0; i < 5; i++) { + + for (i = 0; i < 5; i++) { afs_acl_disp_tbl[i].orig_proc = _acl_tbl[i].dis_proc; _acl_tbl[i].dis_proc = afs_acl_disp_tbl[i].afs_proc; } @@ -638,9 +732,10 @@ struct afs_nfs3_resp { typedef struct afs_nfs3_resp afs_nfs3_resp; static int -is_afs_fh3(nfs_fh3 *fhp) { - if ((fhp->fh3_fsid.val[0] == AFS_VFSMAGIC) && - (fhp->fh3_fsid.val[1] == AFS_VFSFSID)) +is_afs_fh3(nfs_fh3 * fhp) +{ + if ((fhp->fh3_fsid.val[0] == AFS_VFSMAGIC) + && (fhp->fh3_fsid.val[1] == AFS_VFSFSID)) return 1; return 0; } @@ -653,152 +748,152 @@ afs_nfs3_noaccess(struct afs_nfs3_resp *resp) } afs_int32 -nfs3_to_afs_call(int which, caddr_t *args, nfs_fh3 **fhpp, nfs_fh3 **fh2pp) +nfs3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp, nfs_fh3 ** fh2pp) { struct vnode *vp; - nfs_fh3 *fhp1=0; - nfs_fh3 *fhp2=0; + nfs_fh3 *fhp1 = 0; + nfs_fh3 *fhp2 = 0; int errorcode; - + afs_Trace1(afs_iclSetp, CM_TRACE_NFS3IN, ICL_TYPE_INT32, which); - *fh2pp = (nfs_fh3 *)0; + *fh2pp = (nfs_fh3 *) 0; switch (which) { case NFSPROC3_GETATTR: - { - GETATTR3args *arg = (GETATTR3args *)args; - fhp1 = (nfs_fh3 *) &arg->object; - break; - } + { + GETATTR3args *arg = (GETATTR3args *) args; + fhp1 = (nfs_fh3 *) & arg->object; + break; + } case NFSPROC3_SETATTR: - { - SETATTR3args *arg = (SETATTR3args *)args; - fhp1 = (nfs_fh3 *) &arg->object; - break; - } + { + SETATTR3args *arg = (SETATTR3args *) args; + fhp1 = (nfs_fh3 *) & arg->object; + break; + } case NFSPROC3_LOOKUP: - { - LOOKUP3args *arg = (LOOKUP3args *)args; + { + LOOKUP3args *arg = (LOOKUP3args *) args; #ifdef AFS_SUN58_ENV - fhp1 = (nfs_fh3 *) arg->what.dirp; + fhp1 = (nfs_fh3 *) arg->what.dirp; #else - fhp1 = (nfs_fh3 *) &arg->what.dir; + fhp1 = (nfs_fh3 *) & arg->what.dir; #endif - break; - } + break; + } case NFSPROC3_ACCESS: - { - ACCESS3args *arg = (ACCESS3args *)args; - fhp1 = (nfs_fh3 *) &arg->object; - break; - } + { + ACCESS3args *arg = (ACCESS3args *) args; + fhp1 = (nfs_fh3 *) & arg->object; + break; + } case NFSPROC3_READLINK: - { - READLINK3args *arg = (READLINK3args *)args; - fhp1 = (nfs_fh3 *) &arg->symlink; - break; - } + { + READLINK3args *arg = (READLINK3args *) args; + fhp1 = (nfs_fh3 *) & arg->symlink; + break; + } case NFSPROC3_READ: - { - READ3args *arg = (READ3args *)args; - fhp1 = (nfs_fh3 *) &arg->file; - break; - } + { + READ3args *arg = (READ3args *) args; + fhp1 = (nfs_fh3 *) & arg->file; + break; + } case NFSPROC3_WRITE: - { - WRITE3args *arg = (WRITE3args *)args; - fhp1 = (nfs_fh3 *) &arg->file; - break; - } + { + WRITE3args *arg = (WRITE3args *) args; + fhp1 = (nfs_fh3 *) & arg->file; + break; + } case NFSPROC3_CREATE: - { - CREATE3args *arg = (CREATE3args *)args; - fhp1 = (nfs_fh3 *) &arg->where.dir; - break; - } + { + CREATE3args *arg = (CREATE3args *) args; + fhp1 = (nfs_fh3 *) & arg->where.dir; + break; + } case NFSPROC3_MKDIR: - { - MKDIR3args *arg = (MKDIR3args *)args; - fhp1 = (nfs_fh3 *) &arg->where.dir; - break; - } + { + MKDIR3args *arg = (MKDIR3args *) args; + fhp1 = (nfs_fh3 *) & arg->where.dir; + break; + } case NFSPROC3_SYMLINK: - { - SYMLINK3args *arg = (SYMLINK3args *)args; - fhp1 = (nfs_fh3 *) &arg->where.dir; - break; - } + { + SYMLINK3args *arg = (SYMLINK3args *) args; + fhp1 = (nfs_fh3 *) & arg->where.dir; + break; + } case NFSPROC3_MKNOD: - { - MKNOD3args *arg = (MKNOD3args *)args; - fhp1 = (nfs_fh3 *) &arg->where.dir; - break; - } + { + MKNOD3args *arg = (MKNOD3args *) args; + fhp1 = (nfs_fh3 *) & arg->where.dir; + break; + } case NFSPROC3_REMOVE: - { - REMOVE3args *arg = (REMOVE3args *)args; - fhp1 = (nfs_fh3 *) &arg->object.dir; - break; - } + { + REMOVE3args *arg = (REMOVE3args *) args; + fhp1 = (nfs_fh3 *) & arg->object.dir; + break; + } case NFSPROC3_RMDIR: - { - RMDIR3args *arg = (RMDIR3args *)args; - fhp1 = (nfs_fh3 *) &arg->object.dir; - break; - } + { + RMDIR3args *arg = (RMDIR3args *) args; + fhp1 = (nfs_fh3 *) & arg->object.dir; + break; + } case NFSPROC3_RENAME: - { - RENAME3args *arg = (RENAME3args *)args; - fhp1 = (nfs_fh3 *) &arg->from.dir; - fhp2 = (nfs_fh3 *) &arg->to.dir; - break; - } + { + RENAME3args *arg = (RENAME3args *) args; + fhp1 = (nfs_fh3 *) & arg->from.dir; + fhp2 = (nfs_fh3 *) & arg->to.dir; + break; + } case NFSPROC3_LINK: - { - LINK3args *arg = (LINK3args *)args; - fhp1 = (nfs_fh3 *) &arg->file; - fhp2 = (nfs_fh3 *) &arg->link.dir; - break; - } + { + LINK3args *arg = (LINK3args *) args; + fhp1 = (nfs_fh3 *) & arg->file; + fhp2 = (nfs_fh3 *) & arg->link.dir; + break; + } case NFSPROC3_READDIR: - { - READDIR3args *arg = (READDIR3args *)args; - fhp1 = (nfs_fh3 *) &arg->dir; - break; - } + { + READDIR3args *arg = (READDIR3args *) args; + fhp1 = (nfs_fh3 *) & arg->dir; + break; + } case NFSPROC3_READDIRPLUS: - { - READDIRPLUS3args *arg = (READDIRPLUS3args *)args; - fhp1 = (nfs_fh3 *) &arg->dir; - break; - } + { + READDIRPLUS3args *arg = (READDIRPLUS3args *) args; + fhp1 = (nfs_fh3 *) & arg->dir; + break; + } case NFSPROC3_FSSTAT: - { - FSSTAT3args *arg = (FSSTAT3args *)args; - fhp1 = (nfs_fh3 *) &arg->fsroot; - break; - } + { + FSSTAT3args *arg = (FSSTAT3args *) args; + fhp1 = (nfs_fh3 *) & arg->fsroot; + break; + } case NFSPROC3_FSINFO: - { - FSINFO3args *arg = (FSINFO3args *)args; - fhp1 = (nfs_fh3 *) &arg->fsroot; - break; - } + { + FSINFO3args *arg = (FSINFO3args *) args; + fhp1 = (nfs_fh3 *) & arg->fsroot; + break; + } case NFSPROC3_PATHCONF: - { - PATHCONF3args *arg = (PATHCONF3args *)args; - fhp1 = (nfs_fh3 *) &arg->object; - break; - } + { + PATHCONF3args *arg = (PATHCONF3args *) args; + fhp1 = (nfs_fh3 *) & arg->object; + break; + } case NFSPROC3_COMMIT: - { - COMMIT3args *arg = (COMMIT3args *)args; - fhp1 = (nfs_fh3 *) &arg->file; - break; - } + { + COMMIT3args *arg = (COMMIT3args *) args; + fhp1 = (nfs_fh3 *) & arg->file; + break; + } default: return NULL; } - + if (is_afs_fh3(fhp1)) { *fhpp = fhp1; if (fhp2) @@ -814,54 +909,54 @@ nfs3_to_afs_call(int which, caddr_t *args, nfs_fh3 **fhpp, nfs_fh3 **fh2pp) } afs_int32 -acl3_to_afs_call(int which, caddr_t *args, nfs_fh3 **fhpp) +acl3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp) { nfs_fh3 *fhp; - - switch(which) { + + switch (which) { case ACLPROC3_GETACL: - { - struct GETACL3args *sargs = (struct GETACL3args *) args; - fhp = &sargs->fh; - break; - } + { + struct GETACL3args *sargs = (struct GETACL3args *)args; + fhp = &sargs->fh; + break; + } case ACLPROC3_SETACL: - { - struct SETACL3args *sargs = (struct SETACL3args *) args; - fhp = &sargs->fh; - break; - } + { + struct SETACL3args *sargs = (struct SETACL3args *)args; + fhp = &sargs->fh; + break; + } default: return NULL; } - + if (is_afs_fh3(fhp)) { *fhpp = fhp; return 1; } - + return NULL; } int afs_nfs3_dispatcher(int type, afs_int32 which, char *argp, - struct exportinfo **expp, - struct svc_req *rp, struct AFS_UCRED *crp) + struct exportinfo **expp, struct svc_req *rp, + struct AFS_UCRED *crp) { afs_int32 call = 0; afs_int32 code = 0; afs_int32 client = 0; struct sockaddr *sa; - nfs_fh3 *fh = (nfs_fh3 *)argp; - nfs_fh3 *fh2 = (nfs_fh3 *)0; - + nfs_fh3 *fh = (nfs_fh3 *) argp; + nfs_fh3 *fh2 = (nfs_fh3 *) 0; + if (!xlatorinit_v3_done) return 2; - + sa = (struct sockaddr *)svc_getrpccaller(rp->rq_xprt)->buf; - if (sa->sa_family == AF_INET) + if (sa->sa_family == AF_INET) client = ((struct sockaddr_in *)sa)->sin_addr.s_addr; - + AFS_GLOCK(); code = 0; switch (type) { @@ -874,17 +969,16 @@ afs_nfs3_dispatcher(int type, afs_int32 which, char *argp, default: break; } - + if (code) { struct afs_exporter *out = 0; afs_int32 dummy; static int once = 0; struct SmallFid Sfid; - + memcpy((char *)&Sfid, fh->fh3_data, SIZEOF_SMALLFID); - - afs_Trace2(afs_iclSetp, CM_TRACE_NFS3IN1, - ICL_TYPE_INT32, client, + + afs_Trace2(afs_iclSetp, CM_TRACE_NFS3IN1, ICL_TYPE_INT32, client, ICL_TYPE_FID, &Sfid); call = 1; @@ -892,17 +986,18 @@ afs_nfs3_dispatcher(int type, afs_int32 which, char *argp, afs_nobody = (*expp)->exi_export.ex_anon; once = 1; } - code = afs_nfsclient_reqhandler((struct afs_exporter *)0, &crp, - client, &dummy, &out); - + code = + afs_nfsclient_reqhandler((struct afs_exporter *)0, &crp, client, + &dummy, &out); + if (!code && out) EXP_RELE(out); - - + + if (code == EINVAL) call = 2; } - + AFS_GUNLOCK(); return call; } @@ -912,39 +1007,38 @@ afs_nfs3_smallfidder(struct nfs_fh3 *fhp, int status) { afs_int32 addr[2]; struct vcache *vcp; - + #if defined(AFS_SUN57_64BIT_ENV) - /* See also afs_fid() */ + /* See also afs_fid() */ memcpy((char *)addr, fhp->fh3_data, 10); addr[1] = (addr[1] >> 48) & 0xffff; -#else +#else memcpy((char *)addr, fhp->fh3_data, 2 * sizeof(long)); #endif - + AFS_GLOCK(); - vcp = VTOAFS((struct vnode*)addr[0]); - + vcp = VTOAFS((struct vnode *)addr[0]); + /* See also afs_osi_vget */ - if (addr[1] == AFS_XLATOR_MAGIC) - { + if (addr[1] == AFS_XLATOR_MAGIC) { if (status == NFS_OK) { struct SmallFid Sfid; struct cell *tcell; - - /* Make up and copy out a SmallFid */ + + /* Make up and copy out a SmallFid */ tcell = afs_GetCell(vcp->fid.Cell, READ_LOCK); Sfid.Volume = vcp->fid.Fid.Volume; - Sfid.CellAndUnique = ((tcell->cellIndex << 24) | - (vcp->fid.Fid.Unique & 0xffffff)); + Sfid.CellAndUnique = + ((tcell->cellIndex << 24) | (vcp->fid.Fid.Unique & 0xffffff)); afs_PutCell(tcell, READ_LOCK); - Sfid.Vnode = (u_short)(vcp->fid.Fid.Vnode & 0xffff); + Sfid.Vnode = (u_short) (vcp->fid.Fid.Vnode & 0xffff); fhp->fh3_len = SIZEOF_SMALLFID; - memcpy(fhp->fh3_data, (char*)&Sfid, fhp->fh3_len); + memcpy(fhp->fh3_data, (char *)&Sfid, fhp->fh3_len); afs_Trace3(afs_iclSetp, CM_TRACE_NFS3OUT, ICL_TYPE_INT32, status, ICL_TYPE_POINTER, vcp, ICL_TYPE_FID, &Sfid); } - + /* If we have a ref, release it */ if (vcp->vrefCount >= 1) AFS_RELE(AFSTOV(vcp)); @@ -952,340 +1046,491 @@ afs_nfs3_smallfidder(struct nfs_fh3 *fhp, int status) AFS_GUNLOCK(); } -void afs_nfs3_getattr(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_GETATTR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_GETATTR].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_getattr(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_GETATTR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_GETATTR].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_setattr(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_SETATTR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_SETATTR].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_setattr(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_SETATTR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_SETATTR].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_lookup(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_LOOKUP, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else { (*afs_rfs3_disp_tbl[NFSPROC3_LOOKUP].orig_proc)(args, xp, exp, rp, crp); - if (afs_NFSRootOnly && call) { - LOOKUP3res *resp = ( LOOKUP3res *)xp; - afs_nfs3_smallfidder( &resp->resok.object , resp->status); } } - curthread->t_cred = svcred; - return; +void +afs_nfs3_lookup(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_LOOKUP, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else { + (*afs_rfs3_disp_tbl[NFSPROC3_LOOKUP].orig_proc) (args, xp, exp, rp, + crp); + if (afs_NFSRootOnly && call) { + LOOKUP3res *resp = (LOOKUP3res *) xp; + afs_nfs3_smallfidder(&resp->resok.object, resp->status); + } + } + curthread->t_cred = svcred; + return; } -void afs_nfs3_access(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_ACCESS, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_ACCESS].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_access(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_ACCESS, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_ACCESS].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_readlink(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_READLINK, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_READLINK].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_readlink(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_READLINK, (char *)args, &exp, rp, + crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_READLINK].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_read(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_READ, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_READ].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_read(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs3_dispatcher(0, NFSPROC3_READ, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_READ].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_write(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_WRITE, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_WRITE].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_write(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_WRITE, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_WRITE].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_create(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_CREATE, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else { (*afs_rfs3_disp_tbl[NFSPROC3_CREATE].orig_proc)(args, xp, exp, rp, crp); - if (afs_NFSRootOnly && call) { - CREATE3res *resp = ( CREATE3res *)xp; - afs_nfs3_smallfidder( &resp->resok.obj.handle , resp->status); } } - curthread->t_cred = svcred; - return; + +void +afs_nfs3_create(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_CREATE, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else { + (*afs_rfs3_disp_tbl[NFSPROC3_CREATE].orig_proc) (args, xp, exp, rp, + crp); + if (afs_NFSRootOnly && call) { + CREATE3res *resp = (CREATE3res *) xp; + afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status); + } + } + curthread->t_cred = svcred; + return; } -void afs_nfs3_mkdir(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_MKDIR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else { (*afs_rfs3_disp_tbl[NFSPROC3_MKDIR].orig_proc)(args, xp, exp, rp, crp); - if (afs_NFSRootOnly && call) { - MKDIR3res *resp = ( MKDIR3res *)xp; - afs_nfs3_smallfidder( &resp->resok.obj.handle , resp->status); } } - curthread->t_cred = svcred; - return; +void +afs_nfs3_mkdir(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_MKDIR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else { + (*afs_rfs3_disp_tbl[NFSPROC3_MKDIR].orig_proc) (args, xp, exp, rp, + crp); + if (afs_NFSRootOnly && call) { + MKDIR3res *resp = (MKDIR3res *) xp; + afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status); + } + } + curthread->t_cred = svcred; + return; } -void afs_nfs3_symlink(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_SYMLINK, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else { (*afs_rfs3_disp_tbl[NFSPROC3_SYMLINK].orig_proc)(args, xp, exp, rp, crp); - if (afs_NFSRootOnly && call) { - SYMLINK3res *resp = ( SYMLINK3res *)xp; - afs_nfs3_smallfidder( &resp->resok.obj.handle , resp->status); } } - curthread->t_cred = svcred; - return; +void +afs_nfs3_symlink(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_SYMLINK, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else { + (*afs_rfs3_disp_tbl[NFSPROC3_SYMLINK].orig_proc) (args, xp, exp, rp, + crp); + if (afs_NFSRootOnly && call) { + SYMLINK3res *resp = (SYMLINK3res *) xp; + afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status); + } + } + curthread->t_cred = svcred; + return; } -void afs_nfs3_mknod(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_MKNOD, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else { (*afs_rfs3_disp_tbl[NFSPROC3_MKNOD].orig_proc)(args, xp, exp, rp, crp); - if (afs_NFSRootOnly && call) { - MKNOD3res *resp = ( MKNOD3res *)xp; - afs_nfs3_smallfidder( &resp->resok.obj.handle , resp->status); } } - curthread->t_cred = svcred; - return; +void +afs_nfs3_mknod(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_MKNOD, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else { + (*afs_rfs3_disp_tbl[NFSPROC3_MKNOD].orig_proc) (args, xp, exp, rp, + crp); + if (afs_NFSRootOnly && call) { + MKNOD3res *resp = (MKNOD3res *) xp; + afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status); + } + } + curthread->t_cred = svcred; + return; } -void afs_nfs3_remove(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_REMOVE, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_REMOVE].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_remove(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_REMOVE, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_REMOVE].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_rmdir(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_RMDIR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_RMDIR].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_rmdir(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_RMDIR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_RMDIR].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_rename(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_RENAME, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_RENAME].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_rename(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_RENAME, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_RENAME].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_link(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_LINK, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_LINK].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_link(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = afs_nfs3_dispatcher(0, NFSPROC3_LINK, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_LINK].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_readdir(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_READDIR, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_READDIR].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_readdir(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_READDIR, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_READDIR].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_readdirplus(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_READDIRPLUS, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_READDIRPLUS].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_readdirplus(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_READDIRPLUS, (char *)args, &exp, rp, + crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_READDIRPLUS].orig_proc) (args, xp, exp, + rp, crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_fsstat(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_FSSTAT, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_FSSTAT].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_fsstat(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_FSSTAT, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_FSSTAT].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_fsinfo(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_FSINFO, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_FSINFO].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_fsinfo(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_FSINFO, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_FSINFO].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_pathconf(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_PATHCONF, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_PATHCONF].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_pathconf(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_PATHCONF, (char *)args, &exp, rp, + crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_PATHCONF].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_nfs3_commit(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(0, NFSPROC3_COMMIT, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_rfs3_disp_tbl[NFSPROC3_COMMIT].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_nfs3_commit(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + afs_nfs3_resp dummy; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(0, NFSPROC3_COMMIT, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_rfs3_disp_tbl[NFSPROC3_COMMIT].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } struct afs_nfs_disp_tbl afs_rfs3_disp_tbl[22] = { - { afs_nfs2_null }, - { afs_nfs3_getattr }, - { afs_nfs3_setattr }, - { afs_nfs3_lookup }, - { afs_nfs3_access }, - { afs_nfs3_readlink }, - { afs_nfs3_read }, - { afs_nfs3_write }, - { afs_nfs3_create }, - { afs_nfs3_mkdir }, - { afs_nfs3_symlink }, - { afs_nfs3_mknod }, - { afs_nfs3_remove }, - { afs_nfs3_rmdir }, - { afs_nfs3_rename }, - { afs_nfs3_link }, - { afs_nfs3_readdir }, - { afs_nfs3_readdirplus }, - { afs_nfs3_fsstat }, - { afs_nfs3_fsinfo }, - { afs_nfs3_pathconf }, - { afs_nfs3_commit } + {afs_nfs2_null}, + {afs_nfs3_getattr}, + {afs_nfs3_setattr}, + {afs_nfs3_lookup}, + {afs_nfs3_access}, + {afs_nfs3_readlink}, + {afs_nfs3_read}, + {afs_nfs3_write}, + {afs_nfs3_create}, + {afs_nfs3_mkdir}, + {afs_nfs3_symlink}, + {afs_nfs3_mknod}, + {afs_nfs3_remove}, + {afs_nfs3_rmdir}, + {afs_nfs3_rename}, + {afs_nfs3_link}, + {afs_nfs3_readdir}, + {afs_nfs3_readdirplus}, + {afs_nfs3_fsstat}, + {afs_nfs3_fsinfo}, + {afs_nfs3_pathconf}, + {afs_nfs3_commit} }; -void afs_acl3_getacl(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(1, ACLPROC3_GETACL, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_acl3_disp_tbl[ACLPROC3_GETACL].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_acl3_getacl(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(1, ACLPROC3_GETACL, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_acl3_disp_tbl[ACLPROC3_GETACL].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } -void afs_acl3_setacl(char *args, char *xp, char *exp, char *rp, char *crp) { - u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred*)crp; - call=afs_nfs3_dispatcher(1, ACLPROC3_SETACL, (char *)args, &exp, rp, crp); - if (call>1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); - else (*afs_acl3_disp_tbl[ACLPROC3_SETACL].orig_proc)(args, xp, exp, rp, crp); - curthread->t_cred = svcred; - return; +void +afs_acl3_setacl(char *args, char *xp, char *exp, char *rp, char *crp) +{ + u_int call; + struct cred *svcred = curthread->t_cred; + curthread->t_cred = (struct cred *)crp; + call = + afs_nfs3_dispatcher(1, ACLPROC3_SETACL, (char *)args, &exp, rp, crp); + if (call > 1) + afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); + else + (*afs_acl3_disp_tbl[ACLPROC3_SETACL].orig_proc) (args, xp, exp, rp, + crp); + curthread->t_cred = svcred; + return; } struct afs_nfs_disp_tbl afs_acl3_disp_tbl[3] = { - { afs_nfs2_null }, - { afs_acl3_getacl }, - { afs_acl3_setacl }, + {afs_nfs2_null}, + {afs_acl3_getacl}, + {afs_acl3_setacl}, }; /* Munge the dispatch tables to link us in first */ void afs_xlatorinit_v3(struct rfs_disp_tbl *_rfs_tbl, - struct rfs_disp_tbl *_acl_tbl) + struct rfs_disp_tbl *_acl_tbl) { int i; - - if (xlatorinit_v3_done++) return; - - for (i=0; i < 22; i++) { + + if (xlatorinit_v3_done++) + return; + + for (i = 0; i < 22; i++) { afs_rfs3_disp_tbl[i].orig_proc = _rfs_tbl[i].dis_proc; _rfs_tbl[i].dis_proc = afs_rfs3_disp_tbl[i].afs_proc; } - - for (i=0; i < 3; i++) { + + for (i = 0; i < 3; i++) { afs_acl3_disp_tbl[i].orig_proc = _acl_tbl[i].dis_proc; _acl_tbl[i].dis_proc = afs_acl3_disp_tbl[i].afs_proc; } diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index ea334f63f..bc452621a 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -10,16 +10,17 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #ifdef AFS_AIX_ENV #include /* for vm_att(), vm_det() */ #endif -static char memZero; /* address of 0 bytes for kmem_alloc */ +static char memZero; /* address of 0 bytes for kmem_alloc */ struct osimem { struct osimem *next; @@ -39,33 +40,34 @@ lock_t afs_event_lock; flid_t osi_flid; #endif -void osi_Init(void) +void +osi_Init(void) { static int once = 0; - if (once++ > 0) /* just in case */ + if (once++ > 0) /* just in case */ return; #if defined(AFS_HPUX_ENV) osi_InitGlock(); -#else /* AFS_HPUX_ENV */ +#else /* AFS_HPUX_ENV */ #if defined(AFS_GLOBAL_SUNLOCK) #if defined(AFS_SGI62_ENV) mutex_init(&afs_global_lock, MUTEX_DEFAULT, "afs_global_lock"); #elif defined(AFS_OSF_ENV) usimple_lock_init(&afs_global_lock); - afs_global_owner = (thread_t)0; + afs_global_owner = (thread_t) 0; #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) lockinit(&afs_global_lock, PLOCK, "afs global lock", 0, 0); afs_global_owner = 0; #elif defined(AFS_AIX41_ENV) - lock_alloc((void*)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1); + lock_alloc((void *)&afs_global_lock, LOCK_ALLOC_PIN, 1, 1); simple_lock_init((void *)&afs_global_lock); #elif !defined(AFS_LINUX22_ENV) - /* Linux initialization in osi directory. Should move the others. */ + /* Linux initialization in osi directory. Should move the others. */ mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL); #endif /* afs_rxglobal_lock is initialized in rx_Init. */ -#endif /* AFS_GLOBAL_SUNLOCK */ -#endif /* AFS_HPUX_ENV */ +#endif /* AFS_GLOBAL_SUNLOCK */ +#endif /* AFS_HPUX_ENV */ if (!afs_osicred_initialized) { memset(&afs_osi_cred, 0, sizeof(struct AFS_UCRED)); @@ -82,7 +84,6 @@ void osi_Init(void) #endif afs_osicred_initialized = 1; } - #ifdef AFS_SGI64_ENV osi_flid.fl_pid = osi_flid.fl_sysid = 0; #endif @@ -90,18 +91,23 @@ void osi_Init(void) init_et_to_sys_error(); } -int osi_Active(register struct vcache *avc) +int +osi_Active(register struct vcache *avc) { AFS_STATCNT(osi_Active); #if defined(AFS_SUN_ENV) || defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV) || (AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - if ((avc->opens > 0) || (avc->states & CMAPPED)) return 1; /* XXX: Warning, verify this XXX */ + if ((avc->opens > 0) || (avc->states & CMAPPED)) + return 1; /* XXX: Warning, verify this XXX */ #elif defined(AFS_MACH_ENV) - if (avc->opens > 0 || ((avc->v.v_flag & VTEXT) && !inode_uncache_try(avc))) return 1; + if (avc->opens > 0 + || ((avc->v.v_flag & VTEXT) && !inode_uncache_try(avc))) + return 1; #elif defined(AFS_SGI_ENV) if ((avc->opens > 0) || AFS_VN_MAPPED(AFSTOV(avc))) - return 1; + return 1; #else - if (avc->opens > 0 || (AFSTOV(avc)->v_flag & VTEXT)) return(1); + if (avc->opens > 0 || (AFSTOV(avc)->v_flag & VTEXT)) + return (1); #endif return 0; } @@ -115,23 +121,24 @@ int osi_Active(register struct vcache *avc) avc->pvnLock is already held, avc->lock is guaranteed not to be held (by us, of course). */ -void osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp) +void +osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp) { afs_hyper_t origDV; ObtainReadLock(&avc->lock); /* If we've already purged this version, or if we're the ones - writing this version, don't flush it (could lose the - data we're writing). */ - if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) || - ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) { + * writing this version, don't flush it (could lose the + * data we're writing). */ + if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) + || ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) { ReleaseReadLock(&avc->lock); return; } ReleaseReadLock(&avc->lock); - ObtainWriteLock(&avc->lock,10); + ObtainWriteLock(&avc->lock, 10); /* Check again */ - if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) || - ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) { + if ((hcmp((avc->m.DataVersion), (avc->mapDV)) <= 0) + || ((avc->execsOrWriters > 0) && afs_DirtyPages(avc))) { ReleaseWriteLock(&avc->lock); return; } @@ -144,16 +151,16 @@ void osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp) AFS_STATCNT(osi_FlushPages); hset(origDV, avc->m.DataVersion); afs_Trace3(afs_iclSetp, CM_TRACE_FLUSHPAGES, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->m.Length); + ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->m.Length); ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); osi_VM_FlushPages(avc, credp); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,88); + ObtainWriteLock(&avc->lock, 88); /* do this last, and to original version, since stores may occur - while executing above PUTPAGE call */ + * while executing above PUTPAGE call */ hset(avc->mapDV, origDV); ReleaseWriteLock(&avc->lock); } @@ -169,23 +176,25 @@ afs_lock_t afs_ftf; /* flush text lock */ * shouldn't do anything that would discard newly written data before * it is written to the file system. */ -void osi_FlushText_really(register struct vcache *vp) +void +osi_FlushText_really(register struct vcache *vp) { - afs_hyper_t fdv; /* version before which we'll flush */ + afs_hyper_t fdv; /* version before which we'll flush */ AFS_STATCNT(osi_FlushText); /* see if we've already flushed this data version */ - if (hcmp(vp->m.DataVersion, vp->flushDV) <= 0) return; + if (hcmp(vp->m.DataVersion, vp->flushDV) <= 0) + return; #ifdef AFS_DEC_ENV { - void afs_gfs_FlushText(); - afs_gfs_FlushText(vp); - return; + void afs_gfs_FlushText(); + afs_gfs_FlushText(vp); + return; } #else - MObtainWriteLock(&afs_ftf,317); + MObtainWriteLock(&afs_ftf, 317); hset(fdv, vp->m.DataVersion); /* why this disgusting code below? @@ -237,13 +246,14 @@ void osi_FlushText_really(register struct vcache *vp) * cacheinval(). But they would panic. So it might be worth looking * into some middle ground... */ -static void afs_gfs_FlushText(register struct vcache *vp) +static void +afs_gfs_FlushText(register struct vcache *vp) { afs_hyper_t fdv; /* version before which we'll flush */ register struct text *xp; - struct gnode * gp; + struct gnode *gp; - MObtainWriteLock(&afs_ftf,318); + MObtainWriteLock(&afs_ftf, 318); hset(fdv, vp->m.DataVersion); gp = afs_vntogn(vp); @@ -255,16 +265,16 @@ static void afs_gfs_FlushText(register struct vcache *vp) if (gp->g_flag & GTEXT) { if (gp->g_textp) { - xp = (struct text *) gp->g_textp ; + xp = (struct text *)gp->g_textp; /* if text object is locked, give up */ if (xp && (xp->x_flag & XLOCK)) { MReleaseWriteLock(&afs_ftf); return; } - } - else xp = NULL; + } else + xp = NULL; - if (gp->g_flag & GTEXT) { /* still has a text object? */ + if (gp->g_flag & GTEXT) { /* still has a text object? */ xinval(gp); } } @@ -283,7 +293,8 @@ static void afs_gfs_FlushText(register struct vcache *vp) #endif /* AFS_TEXT_ENV */ /* mask signals in afsds */ -void afs_osi_MaskSignals(void) +void +afs_osi_MaskSignals(void) { #ifdef AFS_LINUX22_ENV osi_linux_mask(); @@ -291,12 +302,14 @@ void afs_osi_MaskSignals(void) } /* unmask signals in rxk listener */ -void afs_osi_UnmaskRxkSignals(void) +void +afs_osi_UnmaskRxkSignals(void) { } /* register rxk listener proc info */ -void afs_osi_RxkRegister(void) +void +afs_osi_RxkRegister(void) { #ifdef AFS_LINUX22_ENV osi_linux_rxkreg(); @@ -304,7 +317,8 @@ void afs_osi_RxkRegister(void) } /* procedure for making our processes as invisible as we can */ -void afs_osi_Invisible(void) +void +afs_osi_Invisible(void) { #ifdef AFS_LINUX22_ENV afs_osi_MaskSignals(); @@ -329,12 +343,13 @@ void afs_osi_Invisible(void) #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV) /* set the real time */ -void afs_osi_SetTime(osi_timeval_t *atv) +void +afs_osi_SetTime(osi_timeval_t * atv) { #if defined(AFS_AIX32_ENV) struct timestruc_t t; - t.tv_sec = atv->tv_sec; + t.tv_sec = atv->tv_sec; t.tv_nsec = atv->tv_usec * 1000; ksettimer(&t); /* Was -> settimer(TIMEOFDAY, &t); */ #elif defined(AFS_SUN55_ENV) @@ -373,42 +388,48 @@ void afs_osi_SetTime(osi_timeval_t *atv) #ifdef AFS_HPUX_ENV { #if !defined(AFS_HPUX1122_ENV) - /* drop the setting of the clock for now. spl7 is not - * known on hpux11.22 - */ + /* drop the setting of the clock for now. spl7 is not + * known on hpux11.22 + */ register ulong_t s; struct timeval t; t.tv_sec = atv->tv_sec; t.tv_usec = atv->tv_usec; - s = spl7(); time = t; (void) splx(s); + s = spl7(); + time = t; + (void)splx(s); resettodr(atv); #endif } #else { register int s; - s = splclock(); time = *atv; (void) splx(s); + s = splclock(); + time = *atv; + (void)splx(s); } resettodr(); #endif #ifdef AFS_AUX_ENV logtchg(atv->tv_sec); #endif -#endif /* AFS_DARWIN_ENV */ +#endif /* AFS_DARWIN_ENV */ AFS_STATCNT(osi_SetTime); } #endif /* AFS_LINUX20_ENV */ -void *afs_osi_Alloc(size_t x) +void * +afs_osi_Alloc(size_t x) { register struct osimem *tm = NULL; register int size; AFS_STATCNT(osi_Alloc); /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case - things so that NULL returned iff an error occurred */ - if (x == 0) return &memZero; + * things so that NULL returned iff an error occurred */ + if (x == 0) + return &memZero; AFS_STATS(afs_stats_cmperf.OutStandingAllocs++); AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x); @@ -416,41 +437,45 @@ void *afs_osi_Alloc(size_t x) return osi_linux_alloc(x, 1); #else size = x; - tm = (struct osimem *) AFS_KALLOC(size); + tm = (struct osimem *)AFS_KALLOC(size); #ifdef AFS_SUN_ENV if (!tm) osi_Panic("osi_Alloc: Couldn't allocate %d bytes; out of memory!\n", size); #endif - return (void *) tm; + return (void *)tm; #endif } #if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) -void *afs_osi_Alloc_NoSleep(size_t x) +void * +afs_osi_Alloc_NoSleep(size_t x) { register struct osimem *tm; register int size; AFS_STATCNT(osi_Alloc); /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case - things so that NULL returned iff an error occurred */ - if (x == 0) return &memZero; + * things so that NULL returned iff an error occurred */ + if (x == 0) + return &memZero; size = x; AFS_STATS(afs_stats_cmperf.OutStandingAllocs++); AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x); - tm = (struct osimem *) AFS_KALLOC_NOSLEEP(size); - return (void *) tm; + tm = (struct osimem *)AFS_KALLOC_NOSLEEP(size); + return (void *)tm; } -#endif /* SUN || SGI */ +#endif /* SUN || SGI */ -void afs_osi_Free(void *x, size_t asize) +void +afs_osi_Free(void *x, size_t asize) { AFS_STATCNT(osi_Free); - if (x == &memZero) return; /* check for putting memZero back */ + if (x == &memZero) + return; /* check for putting memZero back */ AFS_STATS(afs_stats_cmperf.OutStandingAllocs--); AFS_STATS(afs_stats_cmperf.OutStandingMemUsage -= asize); @@ -461,7 +486,8 @@ void afs_osi_Free(void *x, size_t asize) #endif } -void afs_osi_FreeStr(char *x) +void +afs_osi_FreeStr(char *x) { afs_osi_Free(x, strlen(x) + 1); } @@ -479,12 +505,13 @@ void afs_osi_FreeStr(char *x) * correctly (or at least, not to introduce worse bugs than already exist) */ #ifdef notdef -int osi_VMDirty_p(struct vcache *avc) +int +osi_VMDirty_p(struct vcache *avc) { int dirtyPages; if (avc->execsOrWriters <= 0) - return 0; /* can't be many dirty pages here, I guess */ + return 0; /* can't be many dirty pages here, I guess */ #if defined (AFS_AIX32_ENV) #ifdef notdef @@ -504,12 +531,12 @@ int osi_VMDirty_p(struct vcache *avc) unsigned int pagef, pri, index, next; index = VMHASH(avc->segid); - if (scb_valid(index)) { /* could almost be an ASSERT */ + if (scb_valid(index)) { /* could almost be an ASSERT */ pri = disable_ints(); for (pagef = scb_sidlist(index); pagef >= 0; pagef = next) { next = pft_sidfwd(pagef); - if (pft_modbit(pagef)) { /* has page frame been modified? */ + if (pft_modbit(pagef)) { /* has page frame been modified? */ enable_ints(pri); return 1; } @@ -523,8 +550,8 @@ int osi_VMDirty_p(struct vcache *avc) #if defined (AFS_SUN_ENV) if (avc->states & CMAPPED) { - struct page * pg; - for (pg = avc->v.v_s.v_Pages ; pg ; pg = pg->p_vpnext) { + struct page *pg; + for (pg = avc->v.v_s.v_Pages; pg; pg = pg->p_vpnext) { if (pg->p_mod) { return 1; } @@ -550,7 +577,8 @@ int osi_VMDirty_p(struct vcache *avc) * * Locking: the vcache entry lock is held. It is dropped and re-obtained. */ -void osi_ReleaseVM(struct vcache *avc, struct AFS_UCRED *acred) +void +osi_ReleaseVM(struct vcache *avc, struct AFS_UCRED *acred) { #ifdef AFS_SUN5_ENV AFS_GUNLOCK(); @@ -566,7 +594,8 @@ void osi_ReleaseVM(struct vcache *avc, struct AFS_UCRED *acred) } -void shutdown_osi(void) +void +shutdown_osi(void) { AFS_STATCNT(shutdown_osi); if (afs_cold_shutdown) { @@ -575,7 +604,8 @@ void shutdown_osi(void) } #ifndef AFS_OBSD_ENV -int afs_osi_suser(void *credp) +int +afs_osi_suser(void *credp) { #if defined(AFS_SUN5_ENV) return afs_suser(credp); @@ -592,7 +622,8 @@ int afs_osi_suser(void *credp) */ #if defined(AFS_SUN5_ENV) -void afs_osi_TraverseProcTable(void) +void +afs_osi_TraverseProcTable(void) { struct proc *prp; for (prp = practive; prp != NULL; prp = prp->p_next) { @@ -614,7 +645,8 @@ void afs_osi_TraverseProcTable(void) * changes. To be safe, we use both. */ -void afs_osi_TraverseProcTable(void) +void +afs_osi_TraverseProcTable(void) { register proc_t *p; int endchain = 0; @@ -632,7 +664,7 @@ void afs_osi_TraverseProcTable(void) * consistent view of the current set of creds. */ - for(p = proc; endchain == 0; p = &proc[p->p_fandx]) { + for (p = proc; endchain == 0; p = &proc[p->p_fandx]) { if (p->p_fandx == 0) { endchain = 1; } @@ -640,9 +672,9 @@ void afs_osi_TraverseProcTable(void) if (system_proc(p)) continue; - mp_mtproc_lock(p); + mp_mtproc_lock(p); afs_GCPAGs_perproc_func(p); - mp_mtproc_unlock(p); + mp_mtproc_unlock(p); } pcred_unlock(); @@ -655,37 +687,41 @@ void afs_osi_TraverseProcTable(void) #ifdef AFS_SGI65_ENV /* TODO: Fix this later. */ -static int SGI_ProcScanFunc(void *p, void *arg, int mode) +static int +SGI_ProcScanFunc(void *p, void *arg, int mode) { return 0; } -#else /* AFS_SGI65_ENV */ -static int SGI_ProcScanFunc(proc_t *p, void *arg, int mode) +#else /* AFS_SGI65_ENV */ +static int +SGI_ProcScanFunc(proc_t * p, void *arg, int mode) { - afs_int32 (*perproc_func)(struct proc *) = arg; - int code=0; + afs_int32(*perproc_func) (struct proc *) = arg; + int code = 0; /* we pass in the function pointer for arg, * mode ==0 for startup call, ==1 for each valid proc, * and ==2 for terminate call. */ - if(mode == 1) { + if (mode == 1) { code = perproc_func(p); } return code; } -#endif /* AFS_SGI65_ENV */ +#endif /* AFS_SGI65_ENV */ -void afs_osi_TraverseProcTable(void) +void +afs_osi_TraverseProcTable(void) { procscan(SGI_ProcScanFunc, afs_GCPAGs_perproc_func); } -#endif /* AFS_SGI_ENV */ +#endif /* AFS_SGI_ENV */ #if defined(AFS_AIX_ENV) #ifdef AFS_AIX51_ENV #define max_proc v.ve_proc #endif -void afs_osi_TraverseProcTable(void) +void +afs_osi_TraverseProcTable(void) { struct proc *p; int i; @@ -701,8 +737,7 @@ void afs_osi_TraverseProcTable(void) #ifndef AFS_AIX51_ENV simple_lock(&proc_tbl_lock); #endif - for (p = (struct proc *)v.vb_proc, i = 0; - p < max_proc; + for (p = (struct proc *)v.vb_proc, i = 0; p < max_proc; p = (struct proc *)((char *)p + afs_gcpags_procsize), i++) { #ifdef AFS_AIX51_ENV @@ -744,7 +779,8 @@ void afs_osi_TraverseProcTable(void) #endif #if defined(AFS_OSF_ENV) -void afs_osi_TraverseProcTable(void) +void +afs_osi_TraverseProcTable(void) { struct pid_entry *pe; #ifdef AFS_DUX50_ENV @@ -754,31 +790,33 @@ void afs_osi_TraverseProcTable(void) #endif PID_LOCK(); for (pe = pidtab; pe < pidNPID; ++pe) { - if (pe->pe_proc != PROC_NULL) - afs_GCPAGs_perproc_func(pe->pe_proc); + if (pe->pe_proc != PROC_NULL) + afs_GCPAGs_perproc_func(pe->pe_proc); } PID_UNLOCK(); } #endif #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) -void afs_osi_TraverseProcTable(void) +void +afs_osi_TraverseProcTable(void) { struct proc *p; LIST_FOREACH(p, &allproc, p_list) { - if (p->p_stat == SIDL) - continue; - if (p->p_stat == SZOMB) - continue; - if (p->p_flag & P_SYSTEM) - continue; - afs_GCPAGs_perproc_func(p); + if (p->p_stat == SIDL) + continue; + if (p->p_stat == SZOMB) + continue; + if (p->p_flag & P_SYSTEM) + continue; + afs_GCPAGs_perproc_func(p); } } #endif #if defined(AFS_LINUX22_ENV) -void afs_osi_TraverseProcTable() +void +afs_osi_TraverseProcTable() { struct task_struct *p; @@ -787,14 +825,14 @@ void afs_osi_TraverseProcTable() #endif #ifdef DEFINED_FOR_EACH_PROCESS for_each_process(p) if (p->pid) { - if (p->state & TASK_ZOMBIE) - continue; + if (p->state & TASK_ZOMBIE) + continue; afs_GCPAGs_perproc_func(p); } #else for_each_task(p) if (p->pid) { - if (p->state & TASK_ZOMBIE) - continue; + if (p->state & TASK_ZOMBIE) + continue; afs_GCPAGs_perproc_func(p); } #endif @@ -810,12 +848,14 @@ void afs_osi_TraverseProcTable() */ #if defined(AFS_SGI65_ENV) -const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *p) +const struct AFS_UCRED * +afs_osi_proc2cred(AFS_PROC * p) { return NULL; } #elif defined(AFS_HPUX_ENV) -const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *p) +const struct AFS_UCRED * +afs_osi_proc2cred(AFS_PROC * p) { if (!p) return; @@ -839,7 +879,8 @@ const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *p) * around calls to this function. */ -const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pproc) +const struct AFS_UCRED * +afs_osi_proc2cred(AFS_PROC * pproc) { struct AFS_UCRED *pcred = 0; @@ -861,7 +902,7 @@ const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pproc) int xm; /* xmem result */ if (!pproc) { - return pcred; + return pcred; } /* @@ -906,7 +947,7 @@ const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pproc) */ struct thread *pproc_thread = #ifdef AFS_AIX51_ENV - pproc->p_pvprocp->pv_threadlist; + pproc->p_pvprocp->pv_threadlist; #else pproc->p_threadlist; #endif @@ -915,21 +956,16 @@ const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pproc) * location of 'struct user' in pproc's * address space */ - struct user *pproc_userp = - pproc_thread->t_userp; + struct user *pproc_userp = pproc_thread->t_userp; /* * create a pointer valid in my own address space */ - xmem_userp = - (struct user *)vm_att(pproc->p_adspace, - pproc_userp); + xmem_userp = (struct user *)vm_att(pproc->p_adspace, pproc_userp); dp.aspace_id = XMEM_INVAL; - xm = xmattach(xmem_userp, - sizeof(*xmem_userp), - &dp, SYS_ADSPACE); + xm = xmattach(xmem_userp, sizeof(*xmem_userp), &dp, SYS_ADSPACE); } #ifdef AFS_AIX51_ENV @@ -941,7 +977,7 @@ const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pproc) /* simple_unlock(&proc_tbl_lock); */ if (xm == XMEM_SUCC) { - static struct AFS_UCRED cred; + static struct AFS_UCRED cred; /* * What locking should we use to protect access to the user @@ -962,63 +998,63 @@ const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pproc) } #elif defined(AFS_OSF_ENV) -const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr) +const struct AFS_UCRED * +afs_osi_proc2cred(AFS_PROC * pr) { - struct AFS_UCRED *rv=NULL; + struct AFS_UCRED *rv = NULL; - if(pr == NULL) { - return NULL; + if (pr == NULL) { + return NULL; } - if((pr->p_stat == SSLEEP) || - (pr->p_stat == SRUN) || - (pr->p_stat == SSTOP)) - rv = pr->p_rcred; + if ((pr->p_stat == SSLEEP) || (pr->p_stat == SRUN) + || (pr->p_stat == SSTOP)) + rv = pr->p_rcred; return rv; } #elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) -const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr) +const struct AFS_UCRED * +afs_osi_proc2cred(AFS_PROC * pr) { - struct AFS_UCRED *rv=NULL; + struct AFS_UCRED *rv = NULL; static struct AFS_UCRED cr; - if(pr == NULL) { - return NULL; + if (pr == NULL) { + return NULL; } - if((pr->p_stat == SSLEEP) || - (pr->p_stat == SRUN) || - (pr->p_stat == SSTOP)) { - pcred_readlock(pr); - cr.cr_ref=1; - cr.cr_uid=pr->p_cred->pc_ucred->cr_uid; - cr.cr_ngroups=pr->p_cred->pc_ucred->cr_ngroups; - memcpy(cr.cr_groups, pr->p_cred->pc_ucred->cr_groups, NGROUPS * - sizeof(gid_t)); - pcred_unlock(pr); - rv = &cr; + if ((pr->p_stat == SSLEEP) || (pr->p_stat == SRUN) + || (pr->p_stat == SSTOP)) { + pcred_readlock(pr); + cr.cr_ref = 1; + cr.cr_uid = pr->p_cred->pc_ucred->cr_uid; + cr.cr_ngroups = pr->p_cred->pc_ucred->cr_ngroups; + memcpy(cr.cr_groups, pr->p_cred->pc_ucred->cr_groups, + NGROUPS * sizeof(gid_t)); + pcred_unlock(pr); + rv = &cr; } return rv; } #elif defined(AFS_LINUX22_ENV) -const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr) +const struct AFS_UCRED * +afs_osi_proc2cred(AFS_PROC * pr) { - struct AFS_UCRED *rv=NULL; + struct AFS_UCRED *rv = NULL; static struct AFS_UCRED cr; - if(pr == NULL) { - return NULL; + if (pr == NULL) { + return NULL; } - if ((pr->state == TASK_RUNNING) || - (pr->state == TASK_INTERRUPTIBLE) || - (pr->state == TASK_UNINTERRUPTIBLE) || - (pr->state == TASK_STOPPED)) { - cr.cr_ref=1; - cr.cr_uid=pr->uid; - cr.cr_ngroups=pr->ngroups; + if ((pr->state == TASK_RUNNING) || (pr->state == TASK_INTERRUPTIBLE) + || (pr->state == TASK_UNINTERRUPTIBLE) + || (pr->state == TASK_STOPPED)) { + cr.cr_ref = 1; + cr.cr_uid = pr->uid; + cr.cr_ngroups = pr->ngroups; memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t)); rv = &cr; } @@ -1026,12 +1062,13 @@ const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr) return rv; } #else -const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr) +const struct AFS_UCRED * +afs_osi_proc2cred(AFS_PROC * pr) { - struct AFS_UCRED *rv=NULL; + struct AFS_UCRED *rv = NULL; - if(pr == NULL) { - return NULL; + if (pr == NULL) { + return NULL; } rv = pr->p_cred; @@ -1039,4 +1076,4 @@ const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr) } #endif -#endif /* AFS_GCPAGS */ +#endif /* AFS_GCPAGS */ diff --git a/src/afs/afs_osi.h b/src/afs/afs_osi.h index a0233f05a..5d1fc0263 100644 --- a/src/afs/afs_osi.h +++ b/src/afs/afs_osi.h @@ -17,11 +17,13 @@ #ifndef _LINUX_CODA_FS_I #define _LINUX_CODA_FS_I #define _CODA_HEADER_ -struct coda_inode_info {}; +struct coda_inode_info { +}; #endif #ifndef _LINUX_XFS_FS_I #define _LINUX_XFS_FS_I -struct xfs_inode_info {}; +struct xfs_inode_info { +}; #endif #include "h/fs.h" #include "h/mm.h" @@ -34,17 +36,17 @@ struct osi_socket { }; struct osi_stat { - afs_int32 size; /* file size in bytes */ - afs_int32 blksize; /* optimal transfer size in bytes */ - afs_int32 mtime; /* modification date */ - afs_int32 atime; /* access time */ + afs_int32 size; /* file size in bytes */ + afs_int32 blksize; /* optimal transfer size in bytes */ + afs_int32 mtime; /* modification date */ + afs_int32 atime; /* access time */ }; struct osi_file { - afs_int32 size; /* file size in bytes XXX Must be first field XXX */ + afs_int32 size; /* file size in bytes XXX Must be first field XXX */ #ifdef AFS_LINUX22_ENV - struct dentry dentry; /* merely to hold the pointer to the inode. */ - struct file file; /* May need this if we really open the file. */ + struct dentry dentry; /* merely to hold the pointer to the inode. */ + struct file file; /* May need this if we really open the file. */ #else struct vnode *vnode; #endif @@ -57,12 +59,12 @@ struct osi_file { afs_int32 offset; #endif #endif - int (*proc)(struct osi_file *afile, afs_int32 code); /* proc, which, if not null, is called on writes */ - char *rock; /* rock passed to proc */ - ino_t inum; /* guarantee validity of hint */ + int (*proc) (struct osi_file * afile, afs_int32 code); /* proc, which, if not null, is called on writes */ + char *rock; /* rock passed to proc */ + ino_t inum; /* guarantee validity of hint */ #if defined(UKERNEL) - int fd; /* file descriptor for user space files */ -#endif /* defined(UKERNEL) */ + int fd; /* file descriptor for user space files */ +#endif /* defined(UKERNEL) */ }; struct osi_dev { @@ -79,7 +81,7 @@ struct osi_dev { }; struct afs_osi_WaitHandle { - caddr_t proc; /* process waiting */ + caddr_t proc; /* process waiting */ }; #define osi_SetFileProc(x,p) ((x)->proc=(p)) @@ -95,12 +97,12 @@ struct afs_osi_WaitHandle { #endif -#define AFSOP_STOP_RXEVENT 214 /* stop rx event deamon */ -#define AFSOP_STOP_COMPLETE 215 /* afs has been shutdown */ -#define AFSOP_STOP_RXK_LISTENER 217 /* stop rx listener daemon */ +#define AFSOP_STOP_RXEVENT 214 /* stop rx event deamon */ +#define AFSOP_STOP_COMPLETE 215 /* afs has been shutdown */ +#define AFSOP_STOP_RXK_LISTENER 217 /* stop rx listener daemon */ -#define osi_NPACKETS 20 /* number of cluster pkts to alloc */ +#define osi_NPACKETS 20 /* number of cluster pkts to alloc */ /* * Alloc declarations. @@ -112,7 +114,7 @@ struct afs_osi_WaitHandle { */ #ifndef AFS_OBSD_ENV #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) -extern int (**afs_vnodeop_p)(); +extern int (**afs_vnodeop_p) (); #define IsAfsVnode(vc) ((vc)->v_op == afs_vnodeop_p) #define SetAfsVnode(vc) (vc)->v_op = afs_vnodeop_p #else @@ -147,7 +149,7 @@ extern struct vnodeops *afs_ops; */ #if !defined(AFS_SGI65_ENV) #ifndef DEBUG -#define DEBUG 1 /* Default is to enable debugging/logging */ +#define DEBUG 1 /* Default is to enable debugging/logging */ #endif #endif diff --git a/src/afs/afs_osi_alloc.c b/src/afs/afs_osi_alloc.c index f5ab69774..d2ef9f7f1 100644 --- a/src/afs/afs_osi_alloc.c +++ b/src/afs/afs_osi_alloc.c @@ -10,13 +10,14 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #ifdef AFS_AIX41_ENV #include "sys/lockl.h" @@ -37,23 +38,24 @@ afs_lock_t osi_flplock; afs_int32 afs_preallocs = 512; /* Reserve space for all small allocs! */ -void osi_AllocMoreSSpace(register afs_int32 preallocs) +void +osi_AllocMoreSSpace(register afs_int32 preallocs) { register int i; char *p; - p = (char *) afs_osi_Alloc(AFS_SMALLOCSIZ * preallocs); + p = (char *)afs_osi_Alloc(AFS_SMALLOCSIZ * preallocs); #ifdef KERNEL_HAVE_PIN pin(p, AFS_SMALLOCSIZ * preallocs); /* XXXX */ #endif - for (i=0; i < preallocs; i++, p += AFS_SMALLOCSIZ) { + for (i = 0; i < preallocs; i++, p += AFS_SMALLOCSIZ) { #ifdef AFS_AIX32_ENV - *p = '\0'; /* page fault it in. */ + *p = '\0'; /* page fault it in. */ #endif - osi_FreeSmallSpace((char *) p); + osi_FreeSmallSpace((char *)p); } afs_stats_cmperf.SmallBlocksAlloced += preallocs; - afs_stats_cmperf.SmallBlocksActive += preallocs; + afs_stats_cmperf.SmallBlocksActive += preallocs; } @@ -61,20 +63,22 @@ void osi_AllocMoreSSpace(register afs_int32 preallocs) /* free space allocated by AllocLargeSpace. Also called by mclput when freeing * a packet allocated by osi_NetReceive. */ -void osi_FreeLargeSpace(void *adata) +void +osi_FreeLargeSpace(void *adata) { AFS_ASSERT_GLOCK(); AFS_STATCNT(osi_FreeLargeSpace); afs_stats_cmperf.LargeBlocksActive--; - MObtainWriteLock(&osi_flplock,322); + MObtainWriteLock(&osi_flplock, 322); ((struct osi_packet *)adata)->next = freePacketList; freePacketList = adata; MReleaseWriteLock(&osi_flplock); } -void osi_FreeSmallSpace(void *adata) +void +osi_FreeSmallSpace(void *adata) { #if defined(AFS_AIX32_ENV) @@ -89,14 +93,14 @@ void osi_FreeSmallSpace(void *adata) AFS_STATCNT(osi_FreeSmallSpace); afs_stats_cmperf.SmallBlocksActive--; #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) - x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT);*/ + x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT); */ #else - MObtainWriteLock(&osi_fsplock,323); + MObtainWriteLock(&osi_fsplock, 323); #endif ((struct osi_packet *)adata)->next = freeSmallList; freeSmallList = adata; #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) - splx(x); /*unlockl(&osi_fsplock);*/ + splx(x); /*unlockl(&osi_fsplock); */ #else MReleaseWriteLock(&osi_fsplock); #endif @@ -110,22 +114,23 @@ osi_AllocMoreMSpace(register afs_int32 preallocs) register int i; char *p; - p = (char *) afs_osi_Alloc(AFS_MDALLOCSIZ * preallocs); + p = (char *)afs_osi_Alloc(AFS_MDALLOCSIZ * preallocs); #ifdef KERNEL_HAVE_PIN pin(p, AFS_MDALLOCSIZ * preallocs); /* XXXX */ #endif - for (i=0; i < preallocs; i++, p += AFS_MDALLOCSIZ) { + for (i = 0; i < preallocs; i++, p += AFS_MDALLOCSIZ) { #ifdef AFS_AIX32_ENV - *p = '\0'; /* page fault it in. */ + *p = '\0'; /* page fault it in. */ #endif - osi_FreeMediumSpace((char *) p); + osi_FreeMediumSpace((char *)p); } afs_stats_cmperf.MediumBlocksAlloced += preallocs; - afs_stats_cmperf.MediumBlocksActive += preallocs; + afs_stats_cmperf.MediumBlocksActive += preallocs; } -void *osi_AllocMediumSpace(size_t size) +void * +osi_AllocMediumSpace(size_t size) { register struct osi_packet *tp; #if defined(AFS_AIX32_ENV) @@ -136,19 +141,21 @@ void *osi_AllocMediumSpace(size_t size) #endif afs_stats_cmperf.MediumBlocksActive++; - retry: + retry: x = splnet(); tp = freeMediumList; - if ( tp ) freeMediumList = tp->next; + if (tp) + freeMediumList = tp->next; splx(x); if (!tp) { - osi_AllocMoreMSpace(AFS_MALLOC_LOW_WATER); + osi_AllocMoreMSpace(AFS_MALLOC_LOW_WATER); goto retry; } return tp; } -void osi_FreeMediumSpace(void *adata) +void +osi_FreeMediumSpace(void *adata) { #if defined(AFS_AIX32_ENV) @@ -168,7 +175,8 @@ void osi_FreeMediumSpace(void *adata) /* allocate space for sender */ -void *osi_AllocLargeSpace(size_t size) +void * +osi_AllocLargeSpace(size_t size) { register struct osi_packet *tp; @@ -182,22 +190,23 @@ void *osi_AllocLargeSpace(size_t size) char *p; afs_stats_cmperf.LargeBlocksAlloced++; - p = (char *) afs_osi_Alloc(AFS_LRALLOCSIZ); + p = (char *)afs_osi_Alloc(AFS_LRALLOCSIZ); #ifdef KERNEL_HAVE_PIN /* * Need to pin this memory since under heavy conditions this memory - * could be swapped out; the problem is that we could inside rx where - * interrupts are disabled and thus we would panic if we don't pin it. - */ - pin(p, AFS_LRALLOCSIZ); + * could be swapped out; the problem is that we could inside rx where + * interrupts are disabled and thus we would panic if we don't pin it. + */ + pin(p, AFS_LRALLOCSIZ); #endif return p; } - MObtainWriteLock(&osi_flplock,324); + MObtainWriteLock(&osi_flplock, 324); tp = freePacketList; - if ( tp ) freePacketList = tp->next; + if (tp) + freePacketList = tp->next; MReleaseWriteLock(&osi_flplock); - return (char *) tp; + return (char *)tp; } #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) @@ -206,7 +215,8 @@ void *osi_AllocLargeSpace(size_t size) * probably better like this so that we can remove this at some point. */ /* morespace 1 - means we called at splnet level */ -char *osi_AllocSmall(register afs_int32 size, register afs_int32 morespace) +char * +osi_AllocSmall(register afs_int32 size, register afs_int32 morespace) { register struct osi_packet *tp; #if defined(AFS_AIX32_ENV) @@ -219,31 +229,36 @@ char *osi_AllocSmall(register afs_int32 size, register afs_int32 morespace) AFS_ASSERT_GLOCK(); AFS_STATCNT(osi_AllocSmallSpace); - if (size > AFS_SMALLOCSIZ) osi_Panic("osi_AllocSmall, size=%d", size); - if ((!morespace && - ((afs_stats_cmperf.SmallBlocksAlloced - afs_stats_cmperf.SmallBlocksActive) - <= AFS_SALLOC_LOW_WATER)) + if (size > AFS_SMALLOCSIZ) + osi_Panic("osi_AllocSmall, size=%d", size); + if ((!morespace + && + ((afs_stats_cmperf.SmallBlocksAlloced - + afs_stats_cmperf.SmallBlocksActive) + <= AFS_SALLOC_LOW_WATER)) || !freeSmallList) { osi_AllocMoreSSpace(AFS_SALLOC_LOW_WATER * 2); } afs_stats_cmperf.SmallBlocksActive++; #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) - x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT);*/ + x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT); */ #else - MObtainWriteLock(&osi_fsplock,325); + MObtainWriteLock(&osi_fsplock, 325); #endif tp = freeSmallList; - if ( tp ) freeSmallList = tp->next; + if (tp) + freeSmallList = tp->next; #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) - splx(x); /*unlockl(&osi_fsplock);*/ + splx(x); /*unlockl(&osi_fsplock); */ #else MReleaseWriteLock(&osi_fsplock); #endif - return (char *) tp; + return (char *)tp; } -int osi_FreeSmall(register struct osi_packet *adata) +int +osi_FreeSmall(register struct osi_packet *adata) { #if defined(AFS_AIX32_ENV) int x; @@ -255,14 +270,14 @@ int osi_FreeSmall(register struct osi_packet *adata) AFS_STATCNT(osi_FreeSmallSpace); afs_stats_cmperf.SmallBlocksActive--; #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) - x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT);*/ + x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT); */ #else - MObtainWriteLock(&osi_fsplock,326); + MObtainWriteLock(&osi_fsplock, 326); #endif adata->next = freeSmallList; freeSmallList = adata; #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) - splx(x); /*unlockl(&osi_fsplock);*/ + splx(x); /*unlockl(&osi_fsplock); */ #else MReleaseWriteLock(&osi_fsplock); #endif @@ -271,7 +286,8 @@ int osi_FreeSmall(register struct osi_packet *adata) #endif /* AFS_AIX32_ENV || AFS_HPUX_ENV */ /* allocate space for sender */ -void *osi_AllocSmallSpace(size_t size) +void * +osi_AllocSmallSpace(size_t size) { register struct osi_packet *tp; #if defined(AFS_AIX32_ENV) @@ -282,15 +298,17 @@ void *osi_AllocSmallSpace(size_t size) #endif AFS_STATCNT(osi_AllocSmallSpace); - if (size > AFS_SMALLOCSIZ) osi_Panic("osi_AllocSmallS: size=%d\n", size); + if (size > AFS_SMALLOCSIZ) + osi_Panic("osi_AllocSmallS: size=%d\n", size); #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) /* * We're running out of free blocks (< 50); get some more ourselves so that * when we don't run out of them when called under splnet() (from rx); */ - if (((afs_stats_cmperf.SmallBlocksAlloced - afs_stats_cmperf.SmallBlocksActive) - <= AFS_SALLOC_LOW_WATER) || !freeSmallList) { + if (((afs_stats_cmperf.SmallBlocksAlloced - + afs_stats_cmperf.SmallBlocksActive) + <= AFS_SALLOC_LOW_WATER) || !freeSmallList) { osi_AllocMoreSSpace(AFS_SALLOC_LOW_WATER * 2); } #else @@ -302,50 +320,51 @@ void *osi_AllocSmallSpace(size_t size) #endif afs_stats_cmperf.SmallBlocksActive++; #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) - x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT);*/ + x = splnet(); /*lockl(&osi_fsplock, LOCK_SHORT); */ #else - MObtainWriteLock(&osi_fsplock,327); + MObtainWriteLock(&osi_fsplock, 327); #endif tp = freeSmallList; - if ( tp ) freeSmallList = tp->next; + if (tp) + freeSmallList = tp->next; #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) - splx(x); /*unlockl(&osi_fsplock);*/ + splx(x); /*unlockl(&osi_fsplock); */ #else MReleaseWriteLock(&osi_fsplock); #endif - return (char *) tp; + return (char *)tp; } -void shutdown_osinet(void) -{ - extern int afs_cold_shutdown; +void +shutdown_osinet(void) +{ + extern int afs_cold_shutdown; - AFS_STATCNT(shutdown_osinet); - if (afs_cold_shutdown) { - struct osi_packet *tp; + AFS_STATCNT(shutdown_osinet); + if (afs_cold_shutdown) { + struct osi_packet *tp; - while ((tp = freePacketList)) { - freePacketList = tp->next; - afs_osi_Free(tp, AFS_LRALLOCSIZ); + while ((tp = freePacketList)) { + freePacketList = tp->next; + afs_osi_Free(tp, AFS_LRALLOCSIZ); #ifdef KERNEL_HAVE_PIN - unpin(tp, AFS_LRALLOCSIZ); + unpin(tp, AFS_LRALLOCSIZ); #endif - } + } - while ((tp = freeSmallList)) { - freeSmallList = tp->next; - afs_osi_Free(tp, AFS_SMALLOCSIZ); + while ((tp = freeSmallList)) { + freeSmallList = tp->next; + afs_osi_Free(tp, AFS_SMALLOCSIZ); #ifdef KERNEL_HAVE_PIN - unpin(tp, AFS_SMALLOCSIZ); + unpin(tp, AFS_SMALLOCSIZ); #endif - } - afs_preallocs = 512; + } + afs_preallocs = 512; #ifndef AFS_AIX32_ENV - LOCK_INIT(&osi_fsplock, "osi_fsplock"); + LOCK_INIT(&osi_fsplock, "osi_fsplock"); #endif - LOCK_INIT(&osi_flplock, "osi_flplock"); - } + LOCK_INIT(&osi_flplock, "osi_flplock"); + } } - diff --git a/src/afs/afs_osi_pag.c b/src/afs/afs_osi_pag.c index 93785aa37..db1e7b45e 100644 --- a/src/afs/afs_osi_pag.c +++ b/src/afs/afs_osi_pag.c @@ -22,11 +22,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -70,7 +71,8 @@ afs_uint32 pagCounter = 0; * secure (although of course not absolutely secure). */ #if !defined(UKERNEL) || !defined(AFS_WEB_ENHANCEMENTS) -afs_uint32 genpag(void) +afs_uint32 +genpag(void) { AFS_STATCNT(genpag); #ifdef AFS_LINUX20_ENV @@ -81,7 +83,8 @@ afs_uint32 genpag(void) #endif /* AFS_LINUX20_ENV */ } -afs_uint32 getpag(void) +afs_uint32 +getpag(void) { AFS_STATCNT(getpag); #ifdef AFS_LINUX20_ENV @@ -97,7 +100,8 @@ afs_uint32 getpag(void) /* Web enhancement: we don't need to restrict pags to 41XXXXXX since * we are not sharing the space with anyone. So we use the full 32 bits. */ -afs_uint32 genpag(void) +afs_uint32 +genpag(void) { AFS_STATCNT(genpag); #ifdef AFS_LINUX20_ENV @@ -107,7 +111,8 @@ afs_uint32 genpag(void) #endif /* AFS_LINUX20_ENV */ } -afs_uint32 getpag(void) +afs_uint32 +getpag(void) { AFS_STATCNT(getpag); #ifdef AFS_LINUX20_ENV @@ -136,11 +141,11 @@ afs_uint32 getpag(void) int #if defined(AFS_SUN5_ENV) -afs_setpag (struct AFS_UCRED **credpp) +afs_setpag(struct AFS_UCRED **credpp) #elif defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) -afs_setpag (struct proc *p, void *args, int *retval) +afs_setpag(struct proc *p, void *args, int *retval) #else -afs_setpag (void) +afs_setpag(void) #endif { int code = 0; @@ -148,7 +153,7 @@ afs_setpag (void) #if defined(AFS_SGI53_ENV) && defined(MP) /* This is our first chance to get the global lock. */ AFS_GLOCK(); -#endif /* defined(AFS_SGI53_ENV) && defined(MP) */ +#endif /* defined(AFS_SGI53_ENV) && defined(MP) */ AFS_STATCNT(afs_setpag); #if defined(AFS_SUN5_ENV) @@ -159,11 +164,10 @@ afs_setpag (void) if (!afs_suser()) #endif { - while (osi_Time() - pag_epoch < pagCounter ) { - afs_osi_Wait(1000, (struct afs_osi_WaitHandle *) 0, 0); - } + while (osi_Time() - pag_epoch < pagCounter) { + afs_osi_Wait(1000, (struct afs_osi_WaitHandle *)0, 0); + } } - #if defined(AFS_SUN5_ENV) code = AddPag(genpag(), credpp); #elif defined(AFS_OSF_ENV) || defined(AFS_XBSD_ENV) @@ -172,7 +176,7 @@ afs_setpag (void) { struct ucred *credp; struct ucred *credp0; - + credp = crref(); credp0 = credp; code = AddPag(genpag(), &credp); @@ -200,9 +204,9 @@ afs_setpag (void) } #elif defined(AFS_DARWIN_ENV) { - struct ucred *credp = crdup(p->p_cred->pc_ucred); - code = AddPag(p, genpag(), &credp); - crfree(credp); + struct ucred *credp = crdup(p->p_cred->pc_ucred); + code = AddPag(p, genpag(), &credp); + crfree(credp); } #else code = AddPag(genpag(), &u.u_cred); @@ -229,11 +233,11 @@ afs_setpag (void) */ int #if defined(AFS_SUN5_ENV) -afs_setpag_val (struct AFS_UCRED **credpp, int pagval) +afs_setpag_val(struct AFS_UCRED **credpp, int pagval) #elif defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) -afs_setpag_val (struct proc *p, void *args, int *retval, int pagval) +afs_setpag_val(struct proc *p, void *args, int *retval, int pagval) #else -afs_setpag_val (int pagval) +afs_setpag_val(int pagval) #endif { int code = 0; @@ -241,7 +245,7 @@ afs_setpag_val (int pagval) #if defined(AFS_SGI53_ENV) && defined(MP) /* This is our first chance to get the global lock. */ AFS_GLOCK(); -#endif /* defined(AFS_SGI53_ENV) && defined(MP) */ +#endif /* defined(AFS_SGI53_ENV) && defined(MP) */ AFS_STATCNT(afs_setpag); #ifdef AFS_SUN5_ENV @@ -250,11 +254,10 @@ afs_setpag_val (int pagval) if (!afs_suser()) #endif { - while (osi_Time() - pag_epoch < pagCounter ) { - afs_osi_Wait(1000, (struct afs_osi_WaitHandle *) 0, 0); - } + while (osi_Time() - pag_epoch < pagCounter) { + afs_osi_Wait(1000, (struct afs_osi_WaitHandle *)0, 0); + } } - #if defined(AFS_SUN5_ENV) code = AddPag(pagval, credpp); #elif defined(AFS_OSF_ENV) || defined(AFS_XBSD_ENV) @@ -263,7 +266,7 @@ afs_setpag_val (int pagval) { struct ucred *credp; struct ucred *credp0; - + credp = crref(); credp0 = credp; code = AddPag(pagval, &credp); @@ -291,9 +294,9 @@ afs_setpag_val (int pagval) } #elif defined(AFS_DARWIN_ENV) { - struct ucred *credp = crdup(p->p_cred->pc_ucred); - code=AddPag(p, pagval, &credp); - crfree(credp); + struct ucred *credp = crdup(p->p_cred->pc_ucred); + code = AddPag(p, pagval, &credp); + crfree(credp); } #else code = AddPag(pagval, &u.u_cred); @@ -306,29 +309,32 @@ afs_setpag_val (int pagval) #endif #if defined(AFS_SGI53_ENV) && defined(MP) AFS_GUNLOCK(); -#endif /* defined(AFS_SGI53_ENV) && defined(MP) */ +#endif /* defined(AFS_SGI53_ENV) && defined(MP) */ return (code); } -int afs_getpag_val() +int +afs_getpag_val() { - int pagvalue; - struct AFS_UCRED *credp = u.u_cred; - int gidset0, gidset1; - - gidset0 = credp->cr_groups[0]; - gidset1 = credp->cr_groups[1]; - pagvalue=afs_get_pag_from_groups(gidset0, gidset1); - return pagvalue; + int pagvalue; + struct AFS_UCRED *credp = u.u_cred; + int gidset0, gidset1; + + gidset0 = credp->cr_groups[0]; + gidset1 = credp->cr_groups[1]; + pagvalue = afs_get_pag_from_groups(gidset0, gidset1); + return pagvalue; } #endif /* UKERNEL && AFS_WEB_ENHANCEMENTS */ /* Note - needs to be available on AIX, others can be static - rework this */ #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) -int AddPag(struct proc *p, afs_int32 aval, struct AFS_UCRED **credpp) +int +AddPag(struct proc *p, afs_int32 aval, struct AFS_UCRED **credpp) #else -int AddPag(afs_int32 aval, struct AFS_UCRED **credpp) +int +AddPag(afs_int32 aval, struct AFS_UCRED **credpp) #endif { afs_int32 newpag, code; @@ -348,24 +354,26 @@ int AddPag(afs_int32 aval, struct AFS_UCRED **credpp) } -int afs_InitReq(register struct vrequest *av, struct AFS_UCRED *acred) +int +afs_InitReq(register struct vrequest *av, struct AFS_UCRED *acred) { AFS_STATCNT(afs_InitReq); - if (afs_shuttingdown) return EIO; + if (afs_shuttingdown) + return EIO; av->uid = PagInCred(acred); if (av->uid == NOPAG) { /* Afs doesn't use the unix uid for anuthing except a handle * with which to find the actual authentication tokens so I * think it's ok to use the real uid to make setuid - * programs (without setpag) to work properly. - */ + * programs (without setpag) to work properly. + */ #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) if (acred == NOCRED) - av->uid = -2; /* XXX nobody... ?*/ + av->uid = -2; /* XXX nobody... ? */ else - av->uid = acred->cr_uid; /* bsd creds don't have ruid */ + av->uid = acred->cr_uid; /* bsd creds don't have ruid */ #else - av->uid = acred->cr_ruid; /* default when no pag is set */ + av->uid = acred->cr_ruid; /* default when no pag is set */ #endif } av->initd = 0; @@ -374,7 +382,8 @@ int afs_InitReq(register struct vrequest *av, struct AFS_UCRED *acred) -afs_uint32 afs_get_pag_from_groups(gid_t g0a, gid_t g1a) +afs_uint32 +afs_get_pag_from_groups(gid_t g0a, gid_t g1a) { afs_uint32 g0 = g0a; afs_uint32 g1 = g1a; @@ -402,7 +411,8 @@ afs_uint32 afs_get_pag_from_groups(gid_t g0a, gid_t g1a) } -void afs_get_groups_from_pag(afs_uint32 pag, gid_t *g0p, gid_t *g1p) +void +afs_get_groups_from_pag(afs_uint32 pag, gid_t * g0p, gid_t * g1p) { unsigned short g0, g1; @@ -420,7 +430,8 @@ void afs_get_groups_from_pag(afs_uint32 pag, gid_t *g0p, gid_t *g1p) } -afs_int32 PagInCred(const struct AFS_UCRED *cred) +afs_int32 +PagInCred(const struct AFS_UCRED *cred) { afs_int32 pag; gid_t g0, g1; @@ -431,9 +442,10 @@ afs_int32 PagInCred(const struct AFS_UCRED *cred) } #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) if (cred == NOCRED || cred == FSCRED) { - return NOPAG; + return NOPAG; } - if (cred->cr_ngroups < 3) return NOPAG; + if (cred->cr_ngroups < 3) + return NOPAG; /* gid is stored in cr_groups[0] */ g0 = cred->cr_groups[1]; g1 = cred->cr_groups[2]; @@ -450,7 +462,8 @@ afs_int32 PagInCred(const struct AFS_UCRED *cred) #endif #else #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DUX40_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_XBSD_ENV) - if (cred->cr_ngroups < 2) return NOPAG; + if (cred->cr_ngroups < 2) + return NOPAG; #endif #endif #ifdef AFS_AIX51_ENV @@ -461,6 +474,6 @@ afs_int32 PagInCred(const struct AFS_UCRED *cred) g1 = cred->cr_groups[1]; #endif #endif - pag = (afs_int32)afs_get_pag_from_groups(g0, g1); + pag = (afs_int32) afs_get_pag_from_groups(g0, g1); return pag; } diff --git a/src/afs/afs_osi_uio.c b/src/afs/afs_osi_uio.c index 2065755a1..b072dd5a5 100644 --- a/src/afs/afs_osi_uio.c +++ b/src/afs/afs_osi_uio.c @@ -10,11 +10,12 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" @@ -25,27 +26,30 @@ RCSID("$Header$"); */ /* routine to make copy of uio structure in ainuio, using aoutvec for space */ -int afsio_copy(struct uio *ainuio, struct uio *aoutuio, - register struct iovec *aoutvec) +int +afsio_copy(struct uio *ainuio, struct uio *aoutuio, + register struct iovec *aoutvec) { register int i; register struct iovec *tvec; AFS_STATCNT(afsio_copy); - if (ainuio->afsio_iovcnt > AFS_MAXIOVCNT) return EINVAL; + if (ainuio->afsio_iovcnt > AFS_MAXIOVCNT) + return EINVAL; memcpy((char *)aoutuio, (char *)ainuio, sizeof(struct uio)); tvec = ainuio->afsio_iov; aoutuio->afsio_iov = aoutvec; - for(i=0;iafsio_iovcnt;i++){ + for (i = 0; i < ainuio->afsio_iovcnt; i++) { memcpy((char *)aoutvec, (char *)tvec, sizeof(struct iovec)); - tvec++; /* too many compiler bugs to do this as one expr */ + tvec++; /* too many compiler bugs to do this as one expr */ aoutvec++; } return 0; } /* trim the uio structure to the specified size */ -int afsio_trim(register struct uio *auio, register afs_int32 asize) +int +afsio_trim(register struct uio *auio, register afs_int32 asize) { register int i; register struct iovec *tv; @@ -54,19 +58,19 @@ int afsio_trim(register struct uio *auio, register afs_int32 asize) auio->afsio_resid = asize; tv = auio->afsio_iov; /* It isn't clear that multiple iovecs work ok (hasn't been tested!) */ - for(i=0;;i++,tv++) { + for (i = 0;; i++, tv++) { if (i >= auio->afsio_iovcnt || asize <= 0) { /* we're done */ auio->afsio_iovcnt = i; break; } - if (tv->iov_len <= asize) + if (tv->iov_len <= asize) /* entire iovec is included */ - asize -= tv->iov_len; /* this many fewer bytes */ + asize -= tv->iov_len; /* this many fewer bytes */ else { /* this is the last one */ tv->iov_len = asize; - auio->afsio_iovcnt = i+1; + auio->afsio_iovcnt = i + 1; break; } } @@ -74,13 +78,14 @@ int afsio_trim(register struct uio *auio, register afs_int32 asize) } /* skip asize bytes in the current uio structure */ -int afsio_skip(register struct uio *auio, register afs_int32 asize) +int +afsio_skip(register struct uio *auio, register afs_int32 asize) { register struct iovec *tv; /* pointer to current iovec */ register int cnt; AFS_STATCNT(afsio_skip); - /* It isn't guaranteed that multiple iovecs work ok (hasn't been tested!) */ + /* It isn't guaranteed that multiple iovecs work ok (hasn't been tested!) */ while (asize > 0 && auio->afsio_resid) { tv = auio->afsio_iov; cnt = tv->iov_len; @@ -99,4 +104,3 @@ int afsio_skip(register struct uio *auio, register afs_int32 asize) } return 0; } - diff --git a/src/afs/afs_osi_vget.c b/src/afs/afs_osi_vget.c index 423d2fbc5..40e0a9bb6 100644 --- a/src/afs/afs_osi_vget.c +++ b/src/afs/afs_osi_vget.c @@ -14,18 +14,19 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* statistics stuff */ +#include "afs/afs_stats.h" /* statistics stuff */ #if !defined(AFS_LINUX20_ENV) /* This is the common part of the vget VFS call. */ -int afs_osi_vget(struct vcache **avcpp, struct fid *afidp, - struct vrequest *areqp) +int +afs_osi_vget(struct vcache **avcpp, struct fid *afidp, struct vrequest *areqp) { struct VenusFid vfid; struct SmallFid Sfid; @@ -62,12 +63,11 @@ int afs_osi_vget(struct vcache **avcpp, struct fid *afidp, if (ret > 1) { /* More than one entry matches. */ code = ENOENT; - } - else if (ret == 0) { + } else if (ret == 0) { /* didn't find an entry. */ *avcpp = afs_GetVCache(&vfid, &treq, NULL, NULL); } - if (! *avcpp) { + if (!*avcpp) { code = ENOENT; } diff --git a/src/afs/afs_osidnlc.c b/src/afs/afs_osidnlc.c index 69098ccab..919d2f2f0 100644 --- a/src/afs/afs_osidnlc.c +++ b/src/afs/afs_osidnlc.c @@ -10,10 +10,11 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /*Standard vendor system headers*/ -#include "afsincludes.h" /*AFS-based standard headers*/ +#include "afs/sysincludes.h" /*Standard vendor system headers */ +#include "afsincludes.h" /*AFS-based standard headers */ #include "afs/afs.h" #include "afs/lock.h" #include "afs/afs_stats.h" @@ -34,7 +35,7 @@ extern struct afs_lock afs_xvcache; dnlcstats_t dnlcstats; #define NCSIZE 300 -#define NHSIZE 256 /* must be power of 2. == NHASHENT in dir package */ +#define NHSIZE 256 /* must be power of 2. == NHASHENT in dir package */ struct nc *ncfreelist = NULL; static struct nc nameCache[NCSIZE]; struct nc *nameHash[NHSIZE]; @@ -43,438 +44,441 @@ struct nc *nameHash[NHSIZE]; * 2. A single element in a hash bucket has itself as prev and next. */ -typedef enum {osi_dnlc_enterT, InsertEntryT, osi_dnlc_lookupT, ScavengeEntryT, osi_dnlc_removeT, RemoveEntryT, osi_dnlc_purgedpT, osi_dnlc_purgevpT, osi_dnlc_purgeT } traceevt; +typedef enum { osi_dnlc_enterT, InsertEntryT, osi_dnlc_lookupT, + ScavengeEntryT, osi_dnlc_removeT, RemoveEntryT, osi_dnlc_purgedpT, + osi_dnlc_purgevpT, osi_dnlc_purgeT +} traceevt; -int afs_usednlc = 1; +int afs_usednlc = 1; struct dt { - traceevt event; - unsigned char slot; + traceevt event; + unsigned char slot; }; -struct dt dnlctracetable[256]; +struct dt dnlctracetable[256]; int dnlct; -#define TRACE(e,s) /* if (dnlct == 256) dnlct = 0; dnlctracetable[dnlct].event = e; dnlctracetable[dnlct++].slot = s; */ +#define TRACE(e,s) /* if (dnlct == 256) dnlct = 0; dnlctracetable[dnlct].event = e; dnlctracetable[dnlct++].slot = s; */ #define dnlcHash(ts, hval) for (hval=0; *ts; ts++) { hval *= 173; hval += *ts; } -static struct nc *GetMeAnEntry(void) +static struct nc * +GetMeAnEntry(void) { - static unsigned int nameptr = 0; /* next bucket to pull something from */ - struct nc *tnc; - int j; - - if (ncfreelist) { - tnc = ncfreelist; - ncfreelist = tnc->next; - return tnc; - } - - for (j=0; j= NHSIZE) - nameptr =0; - if (nameHash[nameptr]) - break; - } - - TRACE(ScavengeEntryT, nameptr); - tnc = nameHash[nameptr]; - if (!tnc) /* May want to consider changing this to return 0 */ - osi_Panic("null tnc in GetMeAnEntry"); - - if (tnc->prev == tnc) { /* only thing in list, don't screw around */ - nameHash[nameptr] = NULL; - return (tnc); - } + static unsigned int nameptr = 0; /* next bucket to pull something from */ + struct nc *tnc; + int j; + + if (ncfreelist) { + tnc = ncfreelist; + ncfreelist = tnc->next; + return tnc; + } + + for (j = 0; j < NHSIZE + 2; j++, nameptr++) { + if (nameptr >= NHSIZE) + nameptr = 0; + if (nameHash[nameptr]) + break; + } + + TRACE(ScavengeEntryT, nameptr); + tnc = nameHash[nameptr]; + if (!tnc) /* May want to consider changing this to return 0 */ + osi_Panic("null tnc in GetMeAnEntry"); - tnc = tnc->prev; /* grab oldest one in this bucket */ - /* remove it from list */ - tnc->next->prev = tnc->prev; - tnc->prev->next = tnc->next; + if (tnc->prev == tnc) { /* only thing in list, don't screw around */ + nameHash[nameptr] = NULL; + return (tnc); + } - return (tnc); + tnc = tnc->prev; /* grab oldest one in this bucket */ + /* remove it from list */ + tnc->next->prev = tnc->prev; + tnc->prev->next = tnc->next; + + return (tnc); } -static void InsertEntry(struct nc *tnc) +static void +InsertEntry(struct nc *tnc) { - unsigned int key; - key = tnc->key & (NHSIZE -1); - - TRACE(InsertEntryT, key); - if(!nameHash[key]) { - nameHash[key] = tnc; - tnc->next = tnc->prev = tnc; - } - else { - tnc->next = nameHash[key]; - tnc->prev = tnc->next->prev; - tnc->next->prev = tnc; - tnc->prev->next = tnc; - nameHash[key] = tnc; - } + unsigned int key; + key = tnc->key & (NHSIZE - 1); + + TRACE(InsertEntryT, key); + if (!nameHash[key]) { + nameHash[key] = tnc; + tnc->next = tnc->prev = tnc; + } else { + tnc->next = nameHash[key]; + tnc->prev = tnc->next->prev; + tnc->next->prev = tnc; + tnc->prev->next = tnc; + nameHash[key] = tnc; + } } -int osi_dnlc_enter (struct vcache *adp, char *aname, struct vcache *avc, afs_hyper_t *avno) +int +osi_dnlc_enter(struct vcache *adp, char *aname, struct vcache *avc, + afs_hyper_t * avno) { - struct nc *tnc; - unsigned int key, skey; - char *ts = aname; - int safety; - - if (!afs_usednlc) - return 0; - - TRACE(osi_dnlc_enterT, 0); - dnlcHash( ts, key ); /* leaves ts pointing at the NULL */ - if (ts - aname >= AFSNCNAMESIZE) { - return 0; - } - skey = key & (NHSIZE -1); - dnlcstats.enters++; + struct nc *tnc; + unsigned int key, skey; + char *ts = aname; + int safety; + + if (!afs_usednlc) + return 0; + + TRACE(osi_dnlc_enterT, 0); + dnlcHash(ts, key); /* leaves ts pointing at the NULL */ + if (ts - aname >= AFSNCNAMESIZE) { + return 0; + } + skey = key & (NHSIZE - 1); + dnlcstats.enters++; -retry: - ObtainWriteLock(&afs_xdnlc,222); + retry: + ObtainWriteLock(&afs_xdnlc, 222); - /* Only cache entries from the latest version of the directory */ - if (!(adp->states & CStatd) || !hsame(*avno, adp->m.DataVersion)) { - ReleaseWriteLock(&afs_xdnlc); - return 0; - } - - /* - * Make sure each directory entry gets cached no more than once. - */ - for (tnc = nameHash[skey], safety=0; tnc; tnc = tnc->next, safety++ ) { - if ((tnc->dirp == adp) && (!strcmp((char *)tnc->name, aname))) { - /* duplicate entry */ - break; - } - else if (tnc->next == nameHash[skey]) { /* end of list */ - tnc = NULL; - break; + /* Only cache entries from the latest version of the directory */ + if (!(adp->states & CStatd) || !hsame(*avno, adp->m.DataVersion)) { + ReleaseWriteLock(&afs_xdnlc); + return 0; } - else if (safety >NCSIZE) { - afs_warn("DNLC cycle"); - dnlcstats.cycles++; - ReleaseWriteLock(&afs_xdnlc); - osi_dnlc_purge(); - goto retry; + + /* + * Make sure each directory entry gets cached no more than once. + */ + for (tnc = nameHash[skey], safety = 0; tnc; tnc = tnc->next, safety++) { + if ((tnc->dirp == adp) && (!strcmp((char *)tnc->name, aname))) { + /* duplicate entry */ + break; + } else if (tnc->next == nameHash[skey]) { /* end of list */ + tnc = NULL; + break; + } else if (safety > NCSIZE) { + afs_warn("DNLC cycle"); + dnlcstats.cycles++; + ReleaseWriteLock(&afs_xdnlc); + osi_dnlc_purge(); + goto retry; + } } - } - if (tnc == NULL) { - tnc = GetMeAnEntry(); + if (tnc == NULL) { + tnc = GetMeAnEntry(); - tnc->dirp = adp; - tnc->vp = avc; - tnc->key = key; - memcpy((char *)tnc->name, aname, ts-aname+1); /* include the NULL */ + tnc->dirp = adp; + tnc->vp = avc; + tnc->key = key; + memcpy((char *)tnc->name, aname, ts - aname + 1); /* include the NULL */ - InsertEntry(tnc); - } else { - /* duplicate */ - tnc->vp = avc; - } - ReleaseWriteLock(&afs_xdnlc); + InsertEntry(tnc); + } else { + /* duplicate */ + tnc->vp = avc; + } + ReleaseWriteLock(&afs_xdnlc); -return 0; + return 0; } -struct vcache *osi_dnlc_lookup (struct vcache *adp, char *aname, int locktype ) +struct vcache * +osi_dnlc_lookup(struct vcache *adp, char *aname, int locktype) { - struct vcache * tvc; - int LRUme; - unsigned int key, skey; - char *ts = aname; - struct nc * tnc, *tnc1=0; - int safety; - - if (!afs_usednlc) - return 0; - - dnlcHash( ts, key ); /* leaves ts pointing at the NULL */ - if (ts - aname >= AFSNCNAMESIZE) { - return 0; - } - skey = key & (NHSIZE -1); - - TRACE(osi_dnlc_lookupT, skey); - dnlcstats.lookups++; - - ObtainReadLock(&afs_xvcache); - ObtainReadLock(&afs_xdnlc); - - for ( tvc = NULL, tnc = nameHash[skey], safety=0; - tnc; tnc = tnc->next, safety++ ) { - if ( /* (tnc->key == key) && */ (tnc->dirp == adp) - && (!strcmp((char *)tnc->name, aname))) { - tvc = tnc->vp; - tnc1 = tnc; - break; - } - else if (tnc->next == nameHash[skey]) { /* end of list */ - break; + struct vcache *tvc; + int LRUme; + unsigned int key, skey; + char *ts = aname; + struct nc *tnc, *tnc1 = 0; + int safety; + + if (!afs_usednlc) + return 0; + + dnlcHash(ts, key); /* leaves ts pointing at the NULL */ + if (ts - aname >= AFSNCNAMESIZE) { + return 0; } - else if (safety >NCSIZE) { - afs_warn("DNLC cycle"); - dnlcstats.cycles++; - ReleaseReadLock(&afs_xdnlc); - ReleaseReadLock(&afs_xvcache); - osi_dnlc_purge(); - return(0); + skey = key & (NHSIZE - 1); + + TRACE(osi_dnlc_lookupT, skey); + dnlcstats.lookups++; + + ObtainReadLock(&afs_xvcache); + ObtainReadLock(&afs_xdnlc); + + for (tvc = NULL, tnc = nameHash[skey], safety = 0; tnc; + tnc = tnc->next, safety++) { + if ( /* (tnc->key == key) && */ (tnc->dirp == adp) + && (!strcmp((char *)tnc->name, aname))) { + tvc = tnc->vp; + tnc1 = tnc; + break; + } else if (tnc->next == nameHash[skey]) { /* end of list */ + break; + } else if (safety > NCSIZE) { + afs_warn("DNLC cycle"); + dnlcstats.cycles++; + ReleaseReadLock(&afs_xdnlc); + ReleaseReadLock(&afs_xvcache); + osi_dnlc_purge(); + return (0); + } } - } - LRUme = 0; /* (tnc != nameHash[skey]); */ - ReleaseReadLock(&afs_xdnlc); + LRUme = 0; /* (tnc != nameHash[skey]); */ + ReleaseReadLock(&afs_xdnlc); - if (!tvc) { - ReleaseReadLock(&afs_xvcache); - dnlcstats.misses++; - } - else { + if (!tvc) { + ReleaseReadLock(&afs_xvcache); + dnlcstats.misses++; + } else { #ifdef AFS_OSF_ENV - VN_HOLD((vnode_t *)tvc); + VN_HOLD((vnode_t *) tvc); #else - osi_vnhold(tvc, 0); + osi_vnhold(tvc, 0); #endif - ReleaseReadLock(&afs_xvcache); + ReleaseReadLock(&afs_xvcache); #ifdef notdef - /* - * XX If LRUme ever is non-zero change the if statement around because - * aix's cc with optimizer on won't necessarily check things in order XX - */ - if (LRUme && (0 == NBObtainWriteLock(&afs_xdnlc))) { - /* don't block to do this */ - /* tnc might have been moved during race condition, */ - /* but it's always in a legit hash chain when a lock is granted, - * or else it's on the freelist so prev == NULL, - * so at worst this is redundant */ - /* Now that we've got it held, and a lock on the dnlc, we - * should check to be sure that there was no race, and - * bail out if there was. */ - if (tnc->prev) { - /* special case for only two elements on list - relative ordering - * doesn't change */ - if (tnc->prev != tnc->next) { - /* remove from old location */ - tnc->prev->next = tnc->next; - tnc->next->prev = tnc->prev; - /* insert into new location */ - tnc->next = nameHash[skey]; - tnc->prev = tnc->next->prev; - tnc->next->prev = tnc; - tnc->prev->next = tnc; + /* + * XX If LRUme ever is non-zero change the if statement around because + * aix's cc with optimizer on won't necessarily check things in order XX + */ + if (LRUme && (0 == NBObtainWriteLock(&afs_xdnlc))) { + /* don't block to do this */ + /* tnc might have been moved during race condition, */ + /* but it's always in a legit hash chain when a lock is granted, + * or else it's on the freelist so prev == NULL, + * so at worst this is redundant */ + /* Now that we've got it held, and a lock on the dnlc, we + * should check to be sure that there was no race, and + * bail out if there was. */ + if (tnc->prev) { + /* special case for only two elements on list - relative ordering + * doesn't change */ + if (tnc->prev != tnc->next) { + /* remove from old location */ + tnc->prev->next = tnc->next; + tnc->next->prev = tnc->prev; + /* insert into new location */ + tnc->next = nameHash[skey]; + tnc->prev = tnc->next->prev; + tnc->next->prev = tnc; + tnc->prev->next = tnc; + } + nameHash[skey] = tnc; + } + ReleaseWriteLock(&afs_xdnlc); } - nameHash[skey] = tnc; - } - ReleaseWriteLock(&afs_xdnlc); - } #endif - } + } -return tvc; + return tvc; } -static void RemoveEntry (struct nc *tnc, unsigned int key) +static void +RemoveEntry(struct nc *tnc, unsigned int key) { - if (!tnc->prev) /* things on freelist always have null prev ptrs */ - osi_Panic("bogus free list"); - - TRACE(RemoveEntryT, key); - if (tnc == tnc->next) { /* only one in list */ - nameHash[key] = NULL; - } - else { - if (tnc == nameHash[key]) - nameHash[key] = tnc->next; - tnc->prev->next = tnc->next; - tnc->next->prev = tnc->prev; - } + if (!tnc->prev) /* things on freelist always have null prev ptrs */ + osi_Panic("bogus free list"); + + TRACE(RemoveEntryT, key); + if (tnc == tnc->next) { /* only one in list */ + nameHash[key] = NULL; + } else { + if (tnc == nameHash[key]) + nameHash[key] = tnc->next; + tnc->prev->next = tnc->next; + tnc->next->prev = tnc->prev; + } - tnc->prev = NULL; /* everything not in hash table has 0 prev */ - tnc->key = 0; /* just for safety's sake */ + tnc->prev = NULL; /* everything not in hash table has 0 prev */ + tnc->key = 0; /* just for safety's sake */ } -int osi_dnlc_remove (struct vcache *adp, char *aname, struct vcache *avc ) +int +osi_dnlc_remove(struct vcache *adp, char *aname, struct vcache *avc) { - unsigned int key, skey; - char *ts = aname; - struct nc *tnc; - - if (!afs_usednlc) - return 0; + unsigned int key, skey; + char *ts = aname; + struct nc *tnc; - TRACE( osi_dnlc_removeT, skey); - dnlcHash( ts, key ); /* leaves ts pointing at the NULL */ - if (ts - aname >= AFSNCNAMESIZE) { - return 0; - } - skey = key & (NHSIZE -1); - TRACE( osi_dnlc_removeT, skey); - dnlcstats.removes++; - ObtainReadLock(&afs_xdnlc); - - for (tnc = nameHash[skey]; tnc; tnc = tnc->next) { - if ((tnc->dirp == adp) && (tnc->key == key) - && (!strcmp((char *)tnc->name, aname))) { - tnc->dirp = NULL; /* now it won't match anything */ - break; + if (!afs_usednlc) + return 0; + + TRACE(osi_dnlc_removeT, skey); + dnlcHash(ts, key); /* leaves ts pointing at the NULL */ + if (ts - aname >= AFSNCNAMESIZE) { + return 0; } - else if (tnc->next == nameHash[skey]) { /* end of list */ - tnc = NULL; - break; + skey = key & (NHSIZE - 1); + TRACE(osi_dnlc_removeT, skey); + dnlcstats.removes++; + ObtainReadLock(&afs_xdnlc); + + for (tnc = nameHash[skey]; tnc; tnc = tnc->next) { + if ((tnc->dirp == adp) && (tnc->key == key) + && (!strcmp((char *)tnc->name, aname))) { + tnc->dirp = NULL; /* now it won't match anything */ + break; + } else if (tnc->next == nameHash[skey]) { /* end of list */ + tnc = NULL; + break; + } } - } - ReleaseReadLock(&afs_xdnlc); + ReleaseReadLock(&afs_xdnlc); - if (!tnc) - return 0; + if (!tnc) + return 0; + + /* there is a little race condition here, but it's relatively + * harmless. At worst, I wind up removing a mapping that I just + * created. */ + if (EWOULDBLOCK == NBObtainWriteLock(&afs_xdnlc, 1)) { + return 0; /* no big deal, tnc will get recycled eventually */ + } + RemoveEntry(tnc, skey); + tnc->next = ncfreelist; + ncfreelist = tnc; + ReleaseWriteLock(&afs_xdnlc); - /* there is a little race condition here, but it's relatively - * harmless. At worst, I wind up removing a mapping that I just - * created. */ - if (EWOULDBLOCK == NBObtainWriteLock(&afs_xdnlc,1)) { - return 0; /* no big deal, tnc will get recycled eventually */ - } - RemoveEntry(tnc, skey); - tnc->next = ncfreelist; - ncfreelist = tnc; - ReleaseWriteLock(&afs_xdnlc); - -return 0; + return 0; } /* remove anything pertaining to this directory. I can invalidate * things without the lock, since I am just looking through the array, * but to move things off the lists or into the freelist, I need the * write lock */ -int osi_dnlc_purgedp (struct vcache *adp) +int +osi_dnlc_purgedp(struct vcache *adp) { - int i; - int writelocked; - - if (!afs_usednlc) - return 0; - - dnlcstats.purgeds++; - TRACE( osi_dnlc_purgedpT, 0); - writelocked = (0 == NBObtainWriteLock(&afs_xdnlc,2)); - - for (i=0; i #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #ifdef AFS_OBSD_ENV @@ -20,14 +21,14 @@ RCSID("$Header$"); #include "h/sysproto.h" #endif #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #include "afs/vice.h" #include "rx/rx_globals.h" struct VenusFid afs_rootFid; -afs_int32 afs_waitForever=0; +afs_int32 afs_waitForever = 0; short afs_waitForeverCount = 0; -afs_int32 afs_showflags = GAGUSER | GAGCONSOLE; /* show all messages */ +afs_int32 afs_showflags = GAGUSER | GAGCONSOLE; /* show all messages */ #define DECL_PIOCTL(x) static int x(struct vcache *avc, int afun, struct vrequest *areq, \ char *ain, char *aout, afs_int32 ainSize, afs_int32 *aoutSize, \ @@ -99,90 +100,94 @@ DECL_PIOCTL(PResidencyCmd); /* Prototypes for private routines */ #ifdef AFS_NEED_CLIENTCONTEXT static int HandleClientContext(struct afs_ioctl *ablob, int *com, - struct AFS_UCRED **acred, struct AFS_UCRED *credp); + struct AFS_UCRED **acred, + struct AFS_UCRED *credp); #endif -int HandleIoctl(register struct vcache *avc, register afs_int32 acom, struct afs_ioctl *adata); +int HandleIoctl(register struct vcache *avc, register afs_int32 acom, + struct afs_ioctl *adata); int afs_HandlePioctl(struct vnode *avp, afs_int32 acom, - register struct afs_ioctl *ablob, int afollow, struct AFS_UCRED **acred); -static int Prefetch(char *apath, struct afs_ioctl *adata, int afollow, struct AFS_UCRED *acred); - - -static int (*(VpioctlSw[]))() = { - PBogus, /* 0 */ - PSetAcl, /* 1 */ - PGetAcl, /* 2 */ - PSetTokens, /* 3 */ - PGetVolumeStatus, /* 4 */ - PSetVolumeStatus, /* 5 */ - PFlush, /* 6 */ - PBogus, /* 7 */ - PGetTokens, /* 8 */ - PUnlog, /* 9 */ - PCheckServers, /* 10 */ - PCheckVolNames, /* 11 */ - PCheckAuth, /* 12 */ - PBogus, /* 13 -- used to be quick check time */ - PFindVolume, /* 14*/ - PBogus, /* 15 -- prefetch is now special-cased; see pioctl code! */ - PBogus, /* 16 -- used to be testing code */ - PNoop, /* 17 -- used to be enable group */ - PNoop, /* 18 -- used to be disable group */ - PBogus, /* 19 -- used to be list group */ - PViceAccess, /* 20 */ - PUnlog, /* 21 -- unlog *is* unpag in this system */ - PGetFID, /* 22 -- get file ID */ - PBogus, /* 23 -- used to be waitforever */ - PSetCacheSize, /* 24 */ - PRemoveCallBack, /* 25 -- flush only the callback */ - PNewCell, /* 26 */ - PListCells, /* 27 */ - PRemoveMount, /* 28 -- delete mount point */ - PNewStatMount, /* 29 -- new style mount point stat */ - PGetFileCell, /* 30 -- get cell name for input file */ - PGetWSCell, /* 31 -- get cell name for workstation */ - PMariner, /* 32 - set/get mariner host */ - PGetUserCell, /* 33 -- get cell name for user */ - PVenusLogging, /* 34 -- Enable/Disable logging */ - PGetCellStatus, /* 35 */ - PSetCellStatus, /* 36 */ - PFlushVolumeData, /* 37 -- flush all data from a volume */ - PSetSysName, /* 38 - Set system name */ - PExportAfs, /* 39 - Export Afs to remote nfs clients */ - PGetCacheSize, /* 40 - get cache size and usage */ - PGetVnodeXStatus, /* 41 - get vcache's special status */ - PSetSPrefs33, /* 42 - Set CM Server preferences... */ - PGetSPrefs, /* 43 - Get CM Server preferences... */ - PGag, /* 44 - turn off/on all CM messages */ - PTwiddleRx, /* 45 - adjust some RX params */ - PSetSPrefs, /* 46 - Set CM Server preferences... */ - PStoreBehind, /* 47 - set degree of store behind to be done */ - PGCPAGs, /* 48 - disable automatic pag gc-ing */ - PGetInitParams, /* 49 - get initial cm params */ - PGetCPrefs, /* 50 - get client interface addresses */ - PSetCPrefs, /* 51 - set client interface addresses */ - PFlushMount, /* 52 - flush mount symlink data */ - PRxStatProc, /* 53 - control process RX statistics */ - PRxStatPeer, /* 54 - control peer RX statistics */ - PGetRxkcrypt, /* 55 -- Get rxkad encryption flag */ - PSetRxkcrypt, /* 56 -- Set rxkad encryption flag */ - PBogus, /* 57 -- arla: set file prio */ - PBogus, /* 58 -- arla: fallback getfh */ - PBogus, /* 59 -- arla: fallback fhopen */ - PBogus, /* 60 -- arla: controls xfsdebug */ - PBogus, /* 61 -- arla: controls arla debug */ - PBogus, /* 62 -- arla: debug interface */ - PBogus, /* 63 -- arla: print xfs status */ - PBogus, /* 64 -- arla: force cache check */ - PBogus, /* 65 -- arla: break callback */ - PPrefetchFromTape, /* 66 -- MR-AFS: prefetch file from tape */ - PResidencyCmd, /* 67 -- MR-AFS: generic commnd interface */ - PBogus, /* 68 -- arla: fetch stats */ + register struct afs_ioctl *ablob, int afollow, + struct AFS_UCRED **acred); +static int Prefetch(char *apath, struct afs_ioctl *adata, int afollow, + struct AFS_UCRED *acred); + + +static int (*(VpioctlSw[])) () = { + PBogus, /* 0 */ + PSetAcl, /* 1 */ + PGetAcl, /* 2 */ + PSetTokens, /* 3 */ + PGetVolumeStatus, /* 4 */ + PSetVolumeStatus, /* 5 */ + PFlush, /* 6 */ + PBogus, /* 7 */ + PGetTokens, /* 8 */ + PUnlog, /* 9 */ + PCheckServers, /* 10 */ + PCheckVolNames, /* 11 */ + PCheckAuth, /* 12 */ + PBogus, /* 13 -- used to be quick check time */ + PFindVolume, /* 14 */ + PBogus, /* 15 -- prefetch is now special-cased; see pioctl code! */ + PBogus, /* 16 -- used to be testing code */ + PNoop, /* 17 -- used to be enable group */ + PNoop, /* 18 -- used to be disable group */ + PBogus, /* 19 -- used to be list group */ + PViceAccess, /* 20 */ + PUnlog, /* 21 -- unlog *is* unpag in this system */ + PGetFID, /* 22 -- get file ID */ + PBogus, /* 23 -- used to be waitforever */ + PSetCacheSize, /* 24 */ + PRemoveCallBack, /* 25 -- flush only the callback */ + PNewCell, /* 26 */ + PListCells, /* 27 */ + PRemoveMount, /* 28 -- delete mount point */ + PNewStatMount, /* 29 -- new style mount point stat */ + PGetFileCell, /* 30 -- get cell name for input file */ + PGetWSCell, /* 31 -- get cell name for workstation */ + PMariner, /* 32 - set/get mariner host */ + PGetUserCell, /* 33 -- get cell name for user */ + PVenusLogging, /* 34 -- Enable/Disable logging */ + PGetCellStatus, /* 35 */ + PSetCellStatus, /* 36 */ + PFlushVolumeData, /* 37 -- flush all data from a volume */ + PSetSysName, /* 38 - Set system name */ + PExportAfs, /* 39 - Export Afs to remote nfs clients */ + PGetCacheSize, /* 40 - get cache size and usage */ + PGetVnodeXStatus, /* 41 - get vcache's special status */ + PSetSPrefs33, /* 42 - Set CM Server preferences... */ + PGetSPrefs, /* 43 - Get CM Server preferences... */ + PGag, /* 44 - turn off/on all CM messages */ + PTwiddleRx, /* 45 - adjust some RX params */ + PSetSPrefs, /* 46 - Set CM Server preferences... */ + PStoreBehind, /* 47 - set degree of store behind to be done */ + PGCPAGs, /* 48 - disable automatic pag gc-ing */ + PGetInitParams, /* 49 - get initial cm params */ + PGetCPrefs, /* 50 - get client interface addresses */ + PSetCPrefs, /* 51 - set client interface addresses */ + PFlushMount, /* 52 - flush mount symlink data */ + PRxStatProc, /* 53 - control process RX statistics */ + PRxStatPeer, /* 54 - control peer RX statistics */ + PGetRxkcrypt, /* 55 -- Get rxkad encryption flag */ + PSetRxkcrypt, /* 56 -- Set rxkad encryption flag */ + PBogus, /* 57 -- arla: set file prio */ + PBogus, /* 58 -- arla: fallback getfh */ + PBogus, /* 59 -- arla: fallback fhopen */ + PBogus, /* 60 -- arla: controls xfsdebug */ + PBogus, /* 61 -- arla: controls arla debug */ + PBogus, /* 62 -- arla: debug interface */ + PBogus, /* 63 -- arla: print xfs status */ + PBogus, /* 64 -- arla: force cache check */ + PBogus, /* 65 -- arla: break callback */ + PPrefetchFromTape, /* 66 -- MR-AFS: prefetch file from tape */ + PResidencyCmd, /* 67 -- MR-AFS: generic commnd interface */ + PBogus, /* 68 -- arla: fetch stats */ }; -static int (*(CpioctlSw[]))() = { - PBogus, /* 0 */ - PNewAlias, /* 1 -- create new cell alias */ - PListAliases, /* 2 -- list cell aliases */ +static int (*(CpioctlSw[])) () = { + PBogus, /* 0 */ + PNewAlias, /* 1 -- create new cell alias */ + PListAliases, /* 2 -- list cell aliases */ }; #define PSetClientContext 99 /* Special pioctl to setup caller's creds */ @@ -191,10 +196,10 @@ int afs_nobody = NFS_NOBODY; static void afs_ioctl32_to_afs_ioctl(const struct afs_ioctl32 *src, struct afs_ioctl *dst) { - dst->in = (char *)(unsigned long)src->in; - dst->out = (char *)(unsigned long)src->out; - dst->in_size = src->in_size; - dst->out_size = src->out_size; + dst->in = (char *)(unsigned long)src->in; + dst->out = (char *)(unsigned long)src->out; + dst->in_size = src->in_size; + dst->out_size = src->out_size; } /* @@ -205,138 +210,137 @@ afs_ioctl32_to_afs_ioctl(const struct afs_ioctl32 *src, struct afs_ioctl *dst) static int copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst) { - int code; + int code; #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) - struct afs_ioctl32 dst32; - - if (!(IS64U)) { - AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code); - if (!code) - afs_ioctl32_to_afs_ioctl(&dst32, dst); - return code; - } + struct afs_ioctl32 dst32; + + if (!(IS64U)) { + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + afs_ioctl32_to_afs_ioctl(&dst32, dst); + return code; + } #endif /* defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) */ #if defined(AFS_HPUX_64BIT_ENV) - struct afs_ioctl32 dst32; + struct afs_ioctl32 dst32; - if (is_32bit(u.u_procp)) /* is_32bit() in proc_iface.h */ - { - AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code); - if (!code) - afs_ioctl32_to_afs_ioctl(&dst32, dst); - return code; - } + if (is_32bit(u.u_procp)) { /* is_32bit() in proc_iface.h */ + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + afs_ioctl32_to_afs_ioctl(&dst32, dst); + return code; + } #endif /* defined(AFS_HPUX_64BIT_ENV) */ #if defined(AFS_SUN57_64BIT_ENV) - struct afs_ioctl32 dst32; + struct afs_ioctl32 dst32; - if (get_udatamodel() == DATAMODEL_ILP32) { - AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code); - if (!code) - afs_ioctl32_to_afs_ioctl(&dst32, dst); - return code; - } + if (get_udatamodel() == DATAMODEL_ILP32) { + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + afs_ioctl32_to_afs_ioctl(&dst32, dst); + return code; + } #endif /* defined(AFS_SUN57_64BIT_ENV) */ #if defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64) - struct afs_ioctl32 dst32; + struct afs_ioctl32 dst32; - if (!ABI_IS_64BIT(get_current_abi())) - { - AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code); - if (!code) - afs_ioctl32_to_afs_ioctl(&dst32, dst); - return code; - } + if (!ABI_IS_64BIT(get_current_abi())) { + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + afs_ioctl32_to_afs_ioctl(&dst32, dst); + return code; + } #endif /* defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64) */ #if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) - struct afs_ioctl32 dst32; + struct afs_ioctl32 dst32; #ifdef AFS_SPARC64_LINUX24_ENV - if (current->thread.flags & SPARC_FLAG_32BIT) + if (current->thread.flags & SPARC_FLAG_32BIT) #elif defined(AFS_SPARC64_LINUX20_ENV) - if (current->tss.flags & SPARC_FLAG_32BIT) + if (current->tss.flags & SPARC_FLAG_32BIT) #elif defined(AFS_AMD64_LINUX20_ENV) - if (current->thread.flags & THREAD_IA32) + if (current->thread.flags & THREAD_IA32) #else #error Not done for this linux type #endif - { - AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code); - if (!code) - afs_ioctl32_to_afs_ioctl(&dst32, dst); - return code; - } + { + AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code); + if (!code) + afs_ioctl32_to_afs_ioctl(&dst32, dst); + return code; + } #endif /* defined(AFS_LINUX_64BIT_KERNEL) */ - AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code); - return code; + AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code); + return code; } -int HandleIoctl(register struct vcache *avc, register afs_int32 acom, struct afs_ioctl *adata) -{ - register afs_int32 code; - - code = 0; - AFS_STATCNT(HandleIoctl); - - switch(acom & 0xff) { - case 1: - avc->states |= CSafeStore; - avc->asynchrony = 0; - break; - - /* case 2 used to be abort store, but this is no longer provided, - since it is impossible to implement under normal Unix. - */ - - case 3: { - /* return the name of the cell this file is open on */ - register struct cell *tcell; - register afs_int32 i; - - tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); - if (tcell) { - i = strlen(tcell->cellName) + 1; /* bytes to copy out */ - - if (i > adata->out_size) { - /* 0 means we're not interested in the output */ - if (adata->out_size != 0) code = EFAULT; - } - else { - /* do the copy */ - AFS_COPYOUT(tcell->cellName, adata->out, i, code); - } - afs_PutCell(tcell, READ_LOCK); - } - else code = ENOTTY; - } - break; - - case 49: /* VIOC_GETINITPARAMS */ - if (adata->out_size < sizeof(struct cm_initparams)) { - code = EFAULT; - } - else { - AFS_COPYOUT(&cm_initParams, adata->out, - sizeof(struct cm_initparams), code); - } - break; - - default: - - code = EINVAL; +int +HandleIoctl(register struct vcache *avc, register afs_int32 acom, + struct afs_ioctl *adata) +{ + register afs_int32 code; + + code = 0; + AFS_STATCNT(HandleIoctl); + + switch (acom & 0xff) { + case 1: + avc->states |= CSafeStore; + avc->asynchrony = 0; + break; + + /* case 2 used to be abort store, but this is no longer provided, + * since it is impossible to implement under normal Unix. + */ + + case 3:{ + /* return the name of the cell this file is open on */ + register struct cell *tcell; + register afs_int32 i; + + tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); + if (tcell) { + i = strlen(tcell->cellName) + 1; /* bytes to copy out */ + + if (i > adata->out_size) { + /* 0 means we're not interested in the output */ + if (adata->out_size != 0) + code = EFAULT; + } else { + /* do the copy */ + AFS_COPYOUT(tcell->cellName, adata->out, i, code); + } + afs_PutCell(tcell, READ_LOCK); + } else + code = ENOTTY; + } + break; + + case 49: /* VIOC_GETINITPARAMS */ + if (adata->out_size < sizeof(struct cm_initparams)) { + code = EFAULT; + } else { + AFS_COPYOUT(&cm_initParams, adata->out, + sizeof(struct cm_initparams), code); + } + break; + + default: + + code = EINVAL; #ifdef AFS_AIX51_ENV - code = ENOSYS; + code = ENOSYS; #endif - break; - } - return code; /* so far, none implemented */ - } + break; + } + return code; /* so far, none implemented */ +} #ifdef AFS_AIX_ENV @@ -344,56 +348,58 @@ int HandleIoctl(register struct vcache *avc, register afs_int32 acom, struct afs * thing directly in the vnode layer call, VNOP_IOCTL; thus afs_ioctl * is now called from afs_gn_ioctl. */ -int afs_ioctl(struct vcache *tvc, int cmd, int arg) -{ - struct afs_ioctl data; - int error = 0; - - AFS_STATCNT(afs_ioctl); - if (((cmd >> 8) & 0xff) == 'V') { - /* This is a VICEIOCTL call */ - AFS_COPYIN(arg, (caddr_t) &data, sizeof(data), error); - if (error) - return(error); - error = HandleIoctl(tvc, cmd, &data); - return(error); - } else { - /* No-op call; just return. */ - return(ENOTTY); - } +int +afs_ioctl(struct vcache *tvc, int cmd, int arg) +{ + struct afs_ioctl data; + int error = 0; + + AFS_STATCNT(afs_ioctl); + if (((cmd >> 8) & 0xff) == 'V') { + /* This is a VICEIOCTL call */ + AFS_COPYIN(arg, (caddr_t) & data, sizeof(data), error); + if (error) + return (error); + error = HandleIoctl(tvc, cmd, &data); + return (error); + } else { + /* No-op call; just return. */ + return (ENOTTY); + } } #endif /* AFS_AIX_ENV */ #if defined(AFS_SGI_ENV) -afs_ioctl(OSI_VN_DECL(tvc), int cmd, void * arg, int flag, cred_t *cr, rval_t *rvalp +afs_ioctl(OSI_VN_DECL(tvc), int cmd, void *arg, int flag, cred_t * cr, + rval_t * rvalp #ifdef AFS_SGI65_ENV - , struct vopbd *vbds + , struct vopbd * vbds #endif - ) + ) { - struct afs_ioctl data; - int error = 0; - int locked; - - OSI_VN_CONVERT(tvc); - - AFS_STATCNT(afs_ioctl); - if (((cmd >> 8) & 0xff) == 'V') { - /* This is a VICEIOCTL call */ - error = copyin_afs_ioctl(arg, &data); - if (error) - return(error); - locked = ISAFS_GLOCK(); - if (!locked) - AFS_GLOCK(); - error = HandleIoctl(tvc, cmd, &data); - if (!locked) - AFS_GUNLOCK(); - return(error); - } else { - /* No-op call; just return. */ - return(ENOTTY); - } + struct afs_ioctl data; + int error = 0; + int locked; + + OSI_VN_CONVERT(tvc); + + AFS_STATCNT(afs_ioctl); + if (((cmd >> 8) & 0xff) == 'V') { + /* This is a VICEIOCTL call */ + error = copyin_afs_ioctl(arg, &data); + if (error) + return (error); + locked = ISAFS_GLOCK(); + if (!locked) + AFS_GLOCK(); + error = HandleIoctl(tvc, cmd, &data); + if (!locked) + AFS_GUNLOCK(); + return (error); + } else { + /* No-op call; just return. */ + return (ENOTTY); + } } #endif /* AFS_SGI_ENV */ @@ -418,13 +424,13 @@ kioctl(fdes, com, arg, ext) int fdes, com; caddr_t arg, ext; { - struct a { - int fd, com; - caddr_t arg, ext; + struct a { + int fd, com; + caddr_t arg, ext; #ifdef AFS_AIX51_ENV - caddr_t arg2, arg3; + caddr_t arg2, arg3; #endif - } u_uap, *uap = &u_uap; + } u_uap, *uap = &u_uap; #else #if defined(AFS_SUN5_ENV) @@ -434,28 +440,28 @@ struct afs_ioctl_sys { int arg; }; -afs_xioctl (uap, rvp) - struct afs_ioctl_sys *uap; - rval_t *rvp; +afs_xioctl(uap, rvp) + struct afs_ioctl_sys *uap; + rval_t *rvp; { #elif defined(AFS_OSF_ENV) -afs_xioctl (p, args, retval) - struct proc *p; - void *args; - long *retval; +afs_xioctl(p, args, retval) + struct proc *p; + void *args; + long *retval; { struct a { - long fd; - u_long com; - caddr_t arg; + long fd; + u_long com; + caddr_t arg; } *uap = (struct a *)args; #elif defined(AFS_FBSD50_ENV) #define arg data int afs_xioctl(td, uap, retval) - struct thread *td; - register struct ioctl_args *uap; - register_t *retval; + struct thread *td; + register struct ioctl_args *uap; + register_t *retval; { struct proc *p = td->td_proc; #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) @@ -467,28 +473,30 @@ struct ioctl_args { int afs_xioctl(p, uap, retval) - struct proc *p; - register struct ioctl_args *uap; - register_t *retval; + struct proc *p; + register struct ioctl_args *uap; + register_t *retval; { #elif defined(AFS_LINUX22_ENV) struct afs_ioctl_sys { unsigned int com; unsigned long arg; }; -asmlinkage int afs_xioctl(struct inode *ip, struct file *fp, - unsigned int com, unsigned long arg) +asmlinkage int +afs_xioctl(struct inode *ip, struct file *fp, unsigned int com, + unsigned long arg) { struct afs_ioctl_sys ua, *uap = &ua; #else -int afs_xioctl (void) +int +afs_xioctl(void) { register struct a { int fd; int com; caddr_t arg; } *uap = (struct a *)u.u_ap; -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ #endif #if defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) struct file *fd; @@ -503,14 +511,14 @@ int afs_xioctl (void) AFS_STATCNT(afs_xioctl); #if defined(AFS_XBSD_ENV) - fdp=p->p_fd; - if ((u_int)uap->fd >= fdp->fd_nfiles || - (fd = fdp->fd_ofiles[uap->fd]) == NULL) + fdp = p->p_fd; + if ((u_int) uap->fd >= fdp->fd_nfiles + || (fd = fdp->fd_ofiles[uap->fd]) == NULL) return EBADF; if ((fd->f_flag & (FREAD | FWRITE)) == 0) return EBADF; #elif defined(AFS_DARWIN_ENV) - if ((code=fdgetf(p, uap->fd, &fd))) + if ((code = fdgetf(p, uap->fd, &fd))) return code; #elif defined(AFS_LINUX22_ENV) ua.com = com; @@ -529,22 +537,25 @@ int afs_xioctl (void) #elif defined(AFS_OSF_ENV) fd = NULL; if (code = getf(&fd, uap->fd, FILE_FLAGS_NULL, &u.u_file_state)) - return code; + return code; #elif defined(AFS_SUN5_ENV) # if defined(AFS_SUN57_ENV) fd = getf(uap->fd); - if (!fd) return(EBADF); + if (!fd) + return (EBADF); # elif defined(AFS_SUN54_ENV) fd = GETF(uap->fd); - if (!fd) return(EBADF); + if (!fd) + return (EBADF); # else if (code = getf(uap->fd, &fd)) { return (code); } -# endif /* AFS_SUN57_ENV */ +# endif /* AFS_SUN57_ENV */ #else fd = getf(uap->fd); - if (!fd) return(EBADF); + if (!fd) + return (EBADF); #endif /* first determine whether this is any sort of vnode */ #if defined(AFS_LINUX22_ENV) @@ -560,16 +571,17 @@ int afs_xioctl (void) #if defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV) tvc = VTOAFS(fd->f_vnode); /* valid, given a vnode */ #elif defined(AFS_OBSD_ENV) - tvc = IsAfsVnode((struct vnode *) fd->f_data) ? - VTOAFS((struct vnode *) fd->f_data) : NULL; + tvc = + IsAfsVnode((struct vnode *)fd-> + f_data) ? VTOAFS((struct vnode *)fd->f_data) : NULL; #else - tvc = VTOAFS((struct vnode*)fd->f_data); /* valid, given a vnode */ + tvc = VTOAFS((struct vnode *)fd->f_data); /* valid, given a vnode */ #endif #endif /* AFS_LINUX22_ENV */ if (tvc && IsAfsVnode(AFSTOV(tvc))) { #ifdef AFS_DEC_ENV - tvc = VTOAFS(afs_gntovn((struct gnode *) tvc)); - if (!tvc) { /* shouldn't happen with held gnodes */ + tvc = VTOAFS(afs_gntovn((struct gnode *)tvc)); + if (!tvc) { /* shouldn't happen with held gnodes */ u.u_error = ENOENT; return; } @@ -578,8 +590,10 @@ int afs_xioctl (void) if (((uap->com >> 8) & 0xff) == 'V') { register struct afs_ioctl *datap; AFS_GLOCK(); - datap = (struct afs_ioctl *) osi_AllocSmallSpace(AFS_SMALLOCSIZ); - AFS_COPYIN((char *)uap->arg, (caddr_t) datap, sizeof (struct afs_ioctl), code); + datap = + (struct afs_ioctl *)osi_AllocSmallSpace(AFS_SMALLOCSIZ); + AFS_COPYIN((char *)uap->arg, (caddr_t) datap, + sizeof(struct afs_ioctl), code); if (code) { osi_FreeSmallSpace(datap); AFS_GUNLOCK(); @@ -601,7 +615,7 @@ int afs_xioctl (void) FP_UNREF(fd); #endif return code; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ #ifdef AFS_AIX41_ENV ufdrele(uap->fd); #endif @@ -663,13 +677,13 @@ int afs_xioctl (void) #endif code = ioctl(uap, rvp); #elif defined(AFS_FBSD50_ENV) - return ioctl(td, uap); + return ioctl(td, uap); #elif defined(AFS_FBSD_ENV) - return ioctl(p, uap); + return ioctl(p, uap); #elif defined(AFS_OBSD_ENV) - code = sys_ioctl(p, uap, retval); + code = sys_ioctl(p, uap, retval); #elif defined(AFS_DARWIN_ENV) - return ioctl(p, uap, retval); + return ioctl(p, uap, retval); #elif defined(AFS_OSF_ENV) code = ioctl(p, args, retval); #ifdef AFS_OSF30_ENV @@ -699,13 +713,13 @@ int afs_xioctl (void) if (!getuerror()) setuerror(code); #if defined(AFS_AIX32_ENV) && !defined(AFS_AIX41_ENV) - return (getuerror() ? -1 : u.u_ioctlrv); + return (getuerror()? -1 : u.u_ioctlrv); #else - return getuerror() ? -1 : 0; + return getuerror()? -1 : 0; #endif #endif #endif /* AFS_LINUX22_ENV */ -#endif /* AFS_SUN5_ENV */ +#endif /* AFS_SUN5_ENV */ #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) return (code); #endif @@ -715,15 +729,15 @@ int afs_xioctl (void) #if defined(AFS_SGI_ENV) /* "pioctl" system call entry point; just pass argument to the parameterized - call below */ + * call below */ struct pioctlargs { - char *path; - sysarg_t cmd; - caddr_t cmarg; - sysarg_t follow; + char *path; + sysarg_t cmd; + caddr_t cmarg; + sysarg_t follow; }; int -afs_pioctl(struct pioctlargs *uap, rval_t *rvp) +afs_pioctl(struct pioctlargs *uap, rval_t * rvp) { int code; @@ -740,16 +754,16 @@ afs_pioctl(struct pioctlargs *uap, rval_t *rvp) #elif defined(AFS_OSF_ENV) afs_pioctl(p, args, retval) - struct proc *p; - void *args; - int *retval; + struct proc *p; + void *args; + int *retval; { struct a { - char *path; - int cmd; - caddr_t cmarg; - int follow; - } *uap = (struct a *) args; + char *path; + int cmd; + caddr_t cmarg; + int follow; + } *uap = (struct a *)args; AFS_STATCNT(afs_pioctl); return (afs_syscall_pioctl(uap->path, uap->cmd, uap->cmarg, uap->follow)); @@ -758,37 +772,40 @@ afs_pioctl(p, args, retval) #elif defined(AFS_FBSD50_ENV) int afs_pioctl(td, args, retval) - struct thread *td; - void *args; - int *retval; + struct thread *td; + void *args; + int *retval; { struct a { - char *path; - int cmd; - caddr_t cmarg; - int follow; - } *uap = (struct a *) args; + char *path; + int cmd; + caddr_t cmarg; + int follow; + } *uap = (struct a *)args; AFS_STATCNT(afs_pioctl); - return (afs_syscall_pioctl(uap->path, uap->cmd, uap->cmarg, uap->follow, td->td_ucred)); + return (afs_syscall_pioctl + (uap->path, uap->cmd, uap->cmarg, uap->follow, td->td_ucred)); } #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) int afs_pioctl(p, args, retval) - struct proc *p; - void *args; - int *retval; + struct proc *p; + void *args; + int *retval; { struct a { - char *path; - int cmd; - caddr_t cmarg; - int follow; - } *uap = (struct a *) args; + char *path; + int cmd; + caddr_t cmarg; + int follow; + } *uap = (struct a *)args; AFS_STATCNT(afs_pioctl); - return (afs_syscall_pioctl(uap->path, uap->cmd, uap->cmarg, uap->follow, p->p_cred->pc_ucred)); + return (afs_syscall_pioctl + (uap->path, uap->cmd, uap->cmarg, uap->follow, + p->p_cred->pc_ucred)); } #endif @@ -803,20 +820,20 @@ afs_pioctl(p, args, retval) int #ifdef AFS_SUN5_ENV afs_syscall_pioctl(path, com, cmarg, follow, rvp, credp) - rval_t *rvp; - struct AFS_UCRED *credp; + rval_t *rvp; + struct AFS_UCRED *credp; #else #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) afs_syscall_pioctl(path, com, cmarg, follow, credp) - struct AFS_UCRED *credp; + struct AFS_UCRED *credp; #else afs_syscall_pioctl(path, com, cmarg, follow) #endif #endif - char *path; - unsigned int com; - caddr_t cmarg; - int follow; + char *path; + unsigned int com; + caddr_t cmarg; + int follow; { struct afs_ioctl data; struct AFS_UCRED *tmpcred, *foreigncreds = NULL; @@ -826,7 +843,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) struct vnode *gp; #endif #ifdef AFS_AIX41_ENV - struct ucred *credp = crref(); /* don't free until done! */ + struct ucred *credp = crref(); /* don't free until done! */ #endif #ifdef AFS_LINUX22_ENV cred_t *credp = crref(); /* don't free until done! */ @@ -834,7 +851,8 @@ afs_syscall_pioctl(path, com, cmarg, follow) #endif AFS_STATCNT(afs_syscall_pioctl); - if (follow) follow = 1; /* compat. with old venus */ + if (follow) + follow = 1; /* compat. with old venus */ code = copyin_afs_ioctl(cmarg, &data); if (code) { PIOCTL_FREE_CRED(); @@ -885,22 +903,23 @@ afs_syscall_pioctl(path, com, cmarg, follow) tmpcred = p_cred(u.u_procp); set_p_cred(u.u_procp, foreigncreds); #elif defined(AFS_SGI_ENV) - tmpcred = OSI_GET_CURRENT_CRED(); - OSI_SET_CURRENT_CRED(foreigncreds); + tmpcred = OSI_GET_CURRENT_CRED(); + OSI_SET_CURRENT_CRED(foreigncreds); #else - tmpcred = u.u_cred; - u.u_cred = foreigncreds; + tmpcred = u.u_cred; + u.u_cred = foreigncreds; #endif } #endif /* AFS_NEED_CLIENTCONTEXT */ if ((com & 0xff) == 15) { /* special case prefetch so entire pathname eval occurs in helper process. - otherwise, the pioctl call is essentially useless */ + * otherwise, the pioctl call is essentially useless */ #if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) - code = Prefetch(path, &data, follow, - foreigncreds ? foreigncreds : credp); + code = + Prefetch(path, &data, follow, + foreigncreds ? foreigncreds : credp); #else - code = Prefetch(path, &data, follow, osi_curcred()); + code = Prefetch(path, &data, follow, osi_curcred()); #endif vp = NULL; #if defined(KERNEL_HAVE_UERROR) @@ -911,15 +930,16 @@ afs_syscall_pioctl(path, com, cmarg, follow) if (path) { AFS_GUNLOCK(); #ifdef AFS_AIX41_ENV - code = lookupname(path, USR, follow, NULL, &vp, - foreigncreds ? foreigncreds : credp); + code = + lookupname(path, USR, follow, NULL, &vp, + foreigncreds ? foreigncreds : credp); #else #ifdef AFS_LINUX22_ENV - code = gop_lookupname(path, AFS_UIOUSER, follow, NULL, &dp); + code = gop_lookupname(path, AFS_UIOUSER, follow, NULL, &dp); if (!code) vp = (struct vnode *)dp->d_inode; #else - code = gop_lookupname(path, AFS_UIOUSER, follow, NULL, &vp); + code = gop_lookupname(path, AFS_UIOUSER, follow, NULL, &vp); #endif /* AFS_LINUX22_ENV */ #endif /* AFS_AIX41_ENV */ AFS_GLOCK(); @@ -930,8 +950,8 @@ afs_syscall_pioctl(path, com, cmarg, follow) #endif goto rescred; } - } - else vp = NULL; + } else + vp = NULL; /* now make the call if we were passed no file, or were passed an AFS file */ if (!vp || IsAfsVnode(vp)) { @@ -943,9 +963,9 @@ afs_syscall_pioctl(path, com, cmarg, follow) */ if (vp) { gp = vp; /* remember for "put" */ - vp = (struct vnode *) afs_gntovn(vp); /* get vcache from gp */ - } - else gp = NULL; + vp = (struct vnode *)afs_gntovn(vp); /* get vcache from gp */ + } else + gp = NULL; #elif defined(AFS_SUN5_ENV) code = afs_HandlePioctl(vp, com, &data, follow, &credp); #elif defined(AFS_AIX41_ENV) @@ -993,16 +1013,16 @@ afs_syscall_pioctl(path, com, cmarg, follow) #endif } - rescred: + rescred: #if defined(AFS_NEED_CLIENTCONTEXT) if (foreigncreds) { #ifdef AFS_AIX41_ENV - crset(tmpcred); /* restore original credentials */ + crset(tmpcred); /* restore original credentials */ #else #if defined(AFS_HPUX101_ENV) - set_p_cred(u.u_procp, tmpcred); /* restore original credentials */ + set_p_cred(u.u_procp, tmpcred); /* restore original credentials */ #elif defined(AFS_SGI_ENV) - OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */ + OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */ #elif !defined(AFS_SUN5_ENV) osi_curcred() = tmpcred; /* restore original credentials */ #endif /* AFS_HPUX101_ENV */ @@ -1020,7 +1040,7 @@ afs_syscall_pioctl(path, com, cmarg, follow) PIOCTL_FREE_CRED(); #if defined(KERNEL_HAVE_UERROR) if (!getuerror()) - setuerror(code); + setuerror(code); return (getuerror()); #else return (code); @@ -1028,8 +1048,10 @@ afs_syscall_pioctl(path, com, cmarg, follow) } -int afs_HandlePioctl(struct vnode *avp, afs_int32 acom, - register struct afs_ioctl *ablob, int afollow, struct AFS_UCRED **acred) +int +afs_HandlePioctl(struct vnode *avp, afs_int32 acom, + register struct afs_ioctl *ablob, int afollow, + struct AFS_UCRED **acred) { struct vcache *avc; struct vrequest treq; @@ -1037,7 +1059,7 @@ int afs_HandlePioctl(struct vnode *avp, afs_int32 acom, register afs_int32 function, device; afs_int32 inSize, outSize; char *inData, *outData; - int (*(*pioctlSw))(); + int (*(*pioctlSw)) (); int pioctlSwSize; struct afs_fakestat_state fakestate; @@ -1045,7 +1067,8 @@ int afs_HandlePioctl(struct vnode *avp, afs_int32 acom, afs_Trace3(afs_iclSetp, CM_TRACE_PIOCTL, ICL_TYPE_INT32, acom & 0xff, ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, afollow); AFS_STATCNT(HandlePioctl); - if ((code = afs_InitReq(&treq, *acred))) return code; + if ((code = afs_InitReq(&treq, *acred))) + return code; afs_InitFakeStat(&fakestate); if (avc) { code = afs_EvalFakeStat(&avc, &fakestate, &treq); @@ -1082,9 +1105,9 @@ int afs_HandlePioctl(struct vnode *avp, afs_int32 acom, inData = osi_AllocLargeSpace(AFS_LRALLOCSIZ); if (inSize > 0) { AFS_COPYIN(ablob->in, inData, inSize, code); - inData[inSize]='\0'; - } - else code = 0; + inData[inSize] = '\0'; + } else + code = 0; if (code) { osi_FreeLargeSpace(inData); afs_PutFakeStat(&fakestate); @@ -1092,13 +1115,17 @@ int afs_HandlePioctl(struct vnode *avp, afs_int32 acom, } outData = osi_AllocLargeSpace(AFS_LRALLOCSIZ); outSize = 0; - code = (*pioctlSw[function])(avc, function, &treq, inData, outData, inSize, &outSize, acred); + code = + (*pioctlSw[function]) (avc, function, &treq, inData, outData, inSize, + &outSize, acred); osi_FreeLargeSpace(inData); if (code == 0 && ablob->out_size > 0) { - if (outSize > ablob->out_size) outSize = ablob->out_size; - if (outSize >= PIGGYSIZE) code = E2BIG; - else if (outSize) { - outData[outSize]='\0'; + if (outSize > ablob->out_size) + outSize = ablob->out_size; + if (outSize >= PIGGYSIZE) + code = E2BIG; + else if (outSize) { + outData[outSize] = '\0'; AFS_COPYOUT(outData, ablob->out, outSize, code); } } @@ -1110,7 +1137,8 @@ int afs_HandlePioctl(struct vnode *avp, afs_int32 acom, DECL_PIOCTL(PGetFID) { AFS_STATCNT(PGetFID); - if (!avc) return EINVAL; + if (!avc) + return EINVAL; memcpy(aout, (char *)&avc->fid, sizeof(struct VenusFid)); *aoutSize = sizeof(struct VenusFid); return 0; @@ -1127,25 +1155,26 @@ DECL_PIOCTL(PSetAcl) AFS_STATCNT(PSetAcl); if (!avc) - return EINVAL; - if ((acl.AFSOpaque_len = strlen(ain)+1) > 1000) - return EINVAL; + return EINVAL; + if ((acl.AFSOpaque_len = strlen(ain) + 1) > 1000) + return EINVAL; acl.AFSOpaque_val = ain; do { - tconn = afs_Conn(&avc->fid, areq, SHARED_LOCK); - if (tconn) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREACL); - RX_AFS_GUNLOCK(); - code = RXAFS_StoreACL(tconn->id, (struct AFSFid *) &avc->fid.Fid, - &acl, &OutStatus, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tconn, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_STOREACL, SHARED_LOCK, NULL)); + tconn = afs_Conn(&avc->fid, areq, SHARED_LOCK); + if (tconn) { + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREACL); + RX_AFS_GUNLOCK(); + code = + RXAFS_StoreACL(tconn->id, (struct AFSFid *)&avc->fid.Fid, + &acl, &OutStatus, &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STOREACL, + SHARED_LOCK, NULL)); /* now we've forgotten all of the access info */ ObtainWriteLock(&afs_xcbhash, 455); @@ -1156,46 +1185,48 @@ DECL_PIOCTL(PSetAcl) if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR)) osi_dnlc_purgedp(avc); return code; - } +} int afs_defaultAsynchrony = 0; DECL_PIOCTL(PStoreBehind) { - afs_int32 code = 0; - struct sbstruct *sbr; + afs_int32 code = 0; + struct sbstruct *sbr; - sbr = (struct sbstruct *)ain; - if (sbr->sb_default != -1) { - if (afs_osi_suser(*acred)) - afs_defaultAsynchrony = sbr->sb_default; - else code = EPERM; - } + sbr = (struct sbstruct *)ain; + if (sbr->sb_default != -1) { + if (afs_osi_suser(*acred)) + afs_defaultAsynchrony = sbr->sb_default; + else + code = EPERM; + } - if (avc && (sbr->sb_thisfile != -1)) { - if (afs_AccessOK(avc, PRSFS_WRITE | PRSFS_ADMINISTER, - areq, DONT_CHECK_MODE_BITS)) - avc->asynchrony = sbr->sb_thisfile; - else code = EACCES; - } + if (avc && (sbr->sb_thisfile != -1)) { + if (afs_AccessOK + (avc, PRSFS_WRITE | PRSFS_ADMINISTER, areq, DONT_CHECK_MODE_BITS)) + avc->asynchrony = sbr->sb_thisfile; + else + code = EACCES; + } - *aoutSize = sizeof(struct sbstruct); - sbr = (struct sbstruct *)aout; - sbr->sb_default = afs_defaultAsynchrony; - if (avc) { - sbr->sb_thisfile = avc->asynchrony; - } + *aoutSize = sizeof(struct sbstruct); + sbr = (struct sbstruct *)aout; + sbr->sb_default = afs_defaultAsynchrony; + if (avc) { + sbr->sb_thisfile = avc->asynchrony; + } - return code; + return code; } DECL_PIOCTL(PGCPAGs) { - if (!afs_osi_suser(*acred)) { - return EACCES; - } - afs_gcpags = AFS_GCPAGS_USERDISABLED; - return 0; + if (!afs_osi_suser(*acred)) { + return EACCES; + } + afs_gcpags = AFS_GCPAGS_USERDISABLED; + return 0; } DECL_PIOCTL(PGetAcl) @@ -1209,7 +1240,8 @@ DECL_PIOCTL(PGetAcl) XSTATS_DECLS; AFS_STATCNT(PGetAcl); - if (!avc) return EINVAL; + if (!avc) + return EINVAL; Fid.Volume = avc->fid.Fid.Volume; Fid.Vnode = avc->fid.Fid.Vnode; Fid.Unique = avc->fid.Fid.Unique; @@ -1220,31 +1252,29 @@ DECL_PIOCTL(PGetAcl) * we currently use the top 2-bytes (vals 0-4) to tell which * type of acl to bring back. Horrible hack but this will * cause the least number of changes to code size and interfaces. - */ + */ if (Fid.Vnode & 0xc0000000) return ERANGE; Fid.Vnode |= (ainSize << 30); } acl.AFSOpaque_val = aout; do { - tconn = afs_Conn(&avc->fid, areq, SHARED_LOCK); - if (tconn) { - *aout = 0; - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHACL); - RX_AFS_GUNLOCK(); - code = RXAFS_FetchACL(tconn->id, &Fid, - &acl, &OutStatus, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tconn, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_FETCHACL, - SHARED_LOCK, NULL)); + tconn = afs_Conn(&avc->fid, areq, SHARED_LOCK); + if (tconn) { + *aout = 0; + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHACL); + RX_AFS_GUNLOCK(); + code = RXAFS_FetchACL(tconn->id, &Fid, &acl, &OutStatus, &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_FETCHACL, + SHARED_LOCK, NULL)); if (code == 0) { - *aoutSize = (acl.AFSOpaque_len == 0 ? 1 : acl.AFSOpaque_len); + *aoutSize = (acl.AFSOpaque_len == 0 ? 1 : acl.AFSOpaque_len); } return code; } @@ -1266,31 +1296,33 @@ DECL_PIOCTL(PGetFileCell) register struct cell *tcell; AFS_STATCNT(PGetFileCell); - if (!avc) return EINVAL; + if (!avc) + return EINVAL; tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); - if (!tcell) return ESRCH; + if (!tcell) + return ESRCH; strcpy(aout, tcell->cellName); afs_PutCell(tcell, READ_LOCK); *aoutSize = strlen(aout) + 1; return 0; - } +} DECL_PIOCTL(PGetWSCell) { struct cell *tcell = NULL; AFS_STATCNT(PGetWSCell); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ tcell = afs_GetPrimaryCell(READ_LOCK); - if (!tcell) /* no primary cell? */ - return ESRCH; + if (!tcell) /* no primary cell? */ + return ESRCH; strcpy(aout, tcell->cellName); *aoutSize = strlen(aout) + 1; afs_PutCell(tcell, READ_LOCK); return 0; - } +} DECL_PIOCTL(PGetUserCell) { @@ -1299,36 +1331,36 @@ DECL_PIOCTL(PGetUserCell) register struct cell *tcell; AFS_STATCNT(PGetUserCell); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ /* return the cell name of the primary cell for this user */ i = UHash(areq->uid); - ObtainWriteLock(&afs_xuser,224); - for(tu = afs_users[i]; tu; tu = tu->next) { - if (tu->uid == areq->uid && (tu->states & UPrimary)) { - tu->refCount++; - ReleaseWriteLock(&afs_xuser); - break; - } + ObtainWriteLock(&afs_xuser, 224); + for (tu = afs_users[i]; tu; tu = tu->next) { + if (tu->uid == areq->uid && (tu->states & UPrimary)) { + tu->refCount++; + ReleaseWriteLock(&afs_xuser); + break; + } } if (tu) { - tcell = afs_GetCell(tu->cell, READ_LOCK); - afs_PutUser(tu, WRITE_LOCK); - if (!tcell) return ESRCH; - else { - strcpy(aout, tcell->cellName); - afs_PutCell(tcell, READ_LOCK); - *aoutSize = strlen(aout)+1; /* 1 for the null */ - } - } - else { - ReleaseWriteLock(&afs_xuser); - *aout = 0; - *aoutSize = 1; + tcell = afs_GetCell(tu->cell, READ_LOCK); + afs_PutUser(tu, WRITE_LOCK); + if (!tcell) + return ESRCH; + else { + strcpy(aout, tcell->cellName); + afs_PutCell(tcell, READ_LOCK); + *aoutSize = strlen(aout) + 1; /* 1 for the null */ + } + } else { + ReleaseWriteLock(&afs_xuser); + *aout = 0; + *aoutSize = 1; } return 0; - } +} DECL_PIOCTL(PSetTokens) { @@ -1343,41 +1375,45 @@ DECL_PIOCTL(PSetTokens) AFS_STATCNT(PSetTokens); if (!afs_resourceinit_flag) { - return EIO; + return EIO; } memcpy((char *)&i, ain, sizeof(afs_int32)); ain += sizeof(afs_int32); - stp = ain; /* remember where the ticket is */ - if (i < 0 || i > 2000) return EINVAL; /* malloc may fail */ - if (i > MAXKTCTICKETLEN) return EINVAL; + stp = ain; /* remember where the ticket is */ + if (i < 0 || i > 2000) + return EINVAL; /* malloc may fail */ + if (i > MAXKTCTICKETLEN) + return EINVAL; stLen = i; - ain += i; /* skip over ticket */ + ain += i; /* skip over ticket */ memcpy((char *)&i, ain, sizeof(afs_int32)); ain += sizeof(afs_int32); if (i != sizeof(struct ClearToken)) { - return EINVAL; + return EINVAL; } memcpy((char *)&clear, ain, sizeof(struct ClearToken)); - if (clear.AuthHandle == -1) clear.AuthHandle = 999; /* more rxvab compat stuff */ + if (clear.AuthHandle == -1) + clear.AuthHandle = 999; /* more rxvab compat stuff */ ain += sizeof(struct ClearToken); - if (ainSize != 2*sizeof(afs_int32) + stLen + sizeof(struct ClearToken)) { - /* still stuff left? we've got primary flag and cell name. Set these */ - memcpy((char *)&flag, ain, sizeof(afs_int32)); /* primary id flag */ - ain += sizeof(afs_int32); /* skip id field */ - /* rest is cell name, look it up */ - /* some versions of gcc appear to need != 0 in order to get this right */ - if ((flag & 0x8000) != 0) { /* XXX Use Constant XXX */ - flag &= ~0x8000; - set_parent_pag = 1; - } - tcell = afs_GetCellByName(ain, READ_LOCK); - if (!tcell) goto nocell; - } - else { - /* default to primary cell, primary id */ - flag = 1; /* primary id */ - tcell = afs_GetPrimaryCell(READ_LOCK); - if (!tcell) goto nocell; + if (ainSize != 2 * sizeof(afs_int32) + stLen + sizeof(struct ClearToken)) { + /* still stuff left? we've got primary flag and cell name. Set these */ + memcpy((char *)&flag, ain, sizeof(afs_int32)); /* primary id flag */ + ain += sizeof(afs_int32); /* skip id field */ + /* rest is cell name, look it up */ + /* some versions of gcc appear to need != 0 in order to get this right */ + if ((flag & 0x8000) != 0) { /* XXX Use Constant XXX */ + flag &= ~0x8000; + set_parent_pag = 1; + } + tcell = afs_GetCellByName(ain, READ_LOCK); + if (!tcell) + goto nocell; + } else { + /* default to primary cell, primary id */ + flag = 1; /* primary id */ + tcell = afs_GetPrimaryCell(READ_LOCK); + if (!tcell) + goto nocell; } i = tcell->cellNum; afs_PutCell(tcell, READ_LOCK); @@ -1385,13 +1421,13 @@ DECL_PIOCTL(PSetTokens) afs_int32 pag; #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) #if defined(AFS_DARWIN_ENV) - struct proc *p = current_proc(); /* XXX */ + struct proc *p = current_proc(); /* XXX */ #else - struct proc *p = curproc; /* XXX */ + struct proc *p = curproc; /* XXX */ #endif - uprintf("Process %d (%s) tried to change pags in PSetTokens\n", - p->p_pid, p->p_comm); - if (!setpag(p, acred, -1, &pag, 1)) { + uprintf("Process %d (%s) tried to change pags in PSetTokens\n", + p->p_pid, p->p_comm); + if (!setpag(p, acred, -1, &pag, 1)) { #else #ifdef AFS_OSF_ENV if (!setpag(u.u_procp, acred, -1, &pag, 1)) { /* XXX u.u_procp is a no-op XXX */ @@ -1404,12 +1440,12 @@ DECL_PIOCTL(PSetTokens) } } /* now we just set the tokens */ - tu = afs_GetUser(areq->uid, i, WRITE_LOCK); /* i has the cell # */ + tu = afs_GetUser(areq->uid, i, WRITE_LOCK); /* i has the cell # */ tu->vid = clear.ViceId; if (tu->stp != NULL) { - afs_osi_Free(tu->stp, tu->stLen); + afs_osi_Free(tu->stp, tu->stLen); } - tu->stp = (char *) afs_osi_Alloc(stLen); + tu->stp = (char *)afs_osi_Alloc(stLen); tu->stLen = stLen; memcpy(tu->stp, stp, stLen); tu->ct = clear; @@ -1420,7 +1456,7 @@ DECL_PIOCTL(PSetTokens) tu->states |= UHasTokens; tu->states &= ~UTokensBad; afs_SetPrimary(tu, flag); - tu->tokenTime =osi_Time(); + tu->tokenTime = osi_Time(); afs_ResetUserConns(tu); afs_PutUser(tu, WRITE_LOCK); @@ -1428,13 +1464,13 @@ DECL_PIOCTL(PSetTokens) nocell: { - int t1; - t1 = afs_initState; - if (t1 < 101) - return EIO; - else - return ESRCH; - } + int t1; + t1 = afs_initState; + if (t1 < 101) + return EIO; + else + return ESRCH; + } } DECL_PIOCTL(PGetVolumeStatus) @@ -1451,41 +1487,42 @@ DECL_PIOCTL(PGetVolumeStatus) AFS_STATCNT(PGetVolumeStatus); if (!avc) { - code = EINVAL; - goto out; + code = EINVAL; + goto out; } Name = volName; OfflineMsg = offLineMsg; MOTD = motd; do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); - if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS); - RX_AFS_GUNLOCK(); - code = RXAFS_GetVolumeStatus(tc->id, avc->fid.Fid.Volume, &volstat, - &Name, &OfflineMsg, &MOTD); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS, - SHARED_LOCK, NULL)); - - if (code) goto out; + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + if (tc) { + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS); + RX_AFS_GUNLOCK(); + code = + RXAFS_GetVolumeStatus(tc->id, avc->fid.Fid.Volume, &volstat, + &Name, &OfflineMsg, &MOTD); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS, + SHARED_LOCK, NULL)); + + if (code) + goto out; /* Copy all this junk into msg->im_data, keeping track of the lengths. */ cp = aout; memcpy(cp, (char *)&volstat, sizeof(VolumeStatus)); cp += sizeof(VolumeStatus); strcpy(cp, volName); - cp += strlen(volName)+1; + cp += strlen(volName) + 1; strcpy(cp, offLineMsg); - cp += strlen(offLineMsg)+1; + cp += strlen(offLineMsg) + 1; strcpy(cp, motd); - cp += strlen(motd)+1; + cp += strlen(motd) + 1; *aoutSize = (cp - aout); -out: + out: afs_osi_Free(offLineMsg, 256); afs_osi_Free(motd, 256); return code; @@ -1505,9 +1542,10 @@ DECL_PIOCTL(PSetVolumeStatus) XSTATS_DECLS; AFS_STATCNT(PSetVolumeStatus); - if (!avc) return EINVAL; + if (!avc) + return EINVAL; - tvp = afs_GetVolume(&avc->fid, areq, READ_LOCK); + tvp = afs_GetVolume(&avc->fid, areq, READ_LOCK); if (tvp) { if (tvp->states & (VRO | VBackup)) { afs_PutVolume(tvp, READ_LOCK); @@ -1523,11 +1561,11 @@ DECL_PIOCTL(PSetVolumeStatus) if (strlen(cp) >= sizeof(volName)) return E2BIG; strcpy(volName, cp); - cp += strlen(volName)+1; + cp += strlen(volName) + 1; if (strlen(cp) >= sizeof(offLineMsg)) return E2BIG; strcpy(offLineMsg, cp); - cp += strlen(offLineMsg)+1; + cp += strlen(offLineMsg) + 1; if (strlen(cp) >= sizeof(motd)) return E2BIG; strcpy(motd, cp); @@ -1543,33 +1581,34 @@ DECL_PIOCTL(PSetVolumeStatus) do { tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS); + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS); RX_AFS_GUNLOCK(); - code = RXAFS_SetVolumeStatus(tc->id, avc->fid.Fid.Volume, - &storeStat, volName, offLineMsg, motd); + code = + RXAFS_SetVolumeStatus(tc->id, avc->fid.Fid.Volume, &storeStat, + volName, offLineMsg, motd); RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS, - SHARED_LOCK, NULL)); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS, + SHARED_LOCK, NULL)); - if (code) goto out; + if (code) + goto out; /* we are sending parms back to make compat. with prev system. should - change interface later to not ask for current status, just set new status */ + * change interface later to not ask for current status, just set new status */ cp = aout; memcpy(cp, (char *)&volstat, sizeof(VolumeStatus)); cp += sizeof(VolumeStatus); strcpy(cp, volName); - cp += strlen(volName)+1; + cp += strlen(volName) + 1; strcpy(cp, offLineMsg); - cp += strlen(offLineMsg)+1; + cp += strlen(offLineMsg) + 1; strcpy(cp, motd); - cp += strlen(motd)+1; + cp += strlen(motd) + 1; *aoutSize = cp - aout; -out: + out: afs_osi_Free(offLineMsg, 256); afs_osi_Free(motd, 256); return code; @@ -1578,21 +1617,22 @@ out: DECL_PIOCTL(PFlush) { AFS_STATCNT(PFlush); - if (!avc) return EINVAL; + if (!avc) + return EINVAL; #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) afs_BozonLock(&avc->pvnLock, avc); /* Since afs_TryToSmush will do a pvn_vptrunc */ #endif - ObtainWriteLock(&avc->lock,225); + ObtainWriteLock(&avc->lock, 225); ObtainWriteLock(&afs_xcbhash, 456); afs_DequeueCallback(avc); - avc->states &= ~(CStatd | CDirty); /* next reference will re-stat cache entry */ + avc->states &= ~(CStatd | CDirty); /* next reference will re-stat cache entry */ ReleaseWriteLock(&afs_xcbhash); /* now find the disk cache entries */ afs_TryToSmush(avc, *acred, 1); osi_dnlc_purgedp(avc); afs_symhint_inval(avc); if (avc->linkData && !(avc->states & CCore)) { - afs_osi_Free(avc->linkData, strlen(avc->linkData)+1); + afs_osi_Free(avc->linkData, strlen(avc->linkData) + 1); avc->linkData = NULL; } ReleaseWriteLock(&avc->lock); @@ -1613,21 +1653,24 @@ DECL_PIOCTL(PNewStatMount) afs_size_t offset, len; AFS_STATCNT(PNewStatMount); - if (!avc) return EINVAL; + if (!avc) + return EINVAL; code = afs_VerifyVCache(avc, areq); - if (code) return code; + if (code) + return code; if (vType(avc) != VDIR) { return ENOTDIR; } tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1); - if (!tdc) return ENOENT; + if (!tdc) + return ENOENT; Check_AtSys(avc, ain, &sysState, areq); ObtainReadLock(&tdc->lock); do { - code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid); + code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid); } while (code == ENOENT && Next_AtSys(avc, areq, &sysState)); ReleaseReadLock(&tdc->lock); - afs_PutDCache(tdc); /* we're done with the data */ + afs_PutDCache(tdc); /* we're done with the data */ bufp = sysState.name; if (code) { goto out; @@ -1648,24 +1691,25 @@ DECL_PIOCTL(PNewStatMount) code = EINVAL; goto out; } - ObtainWriteLock(&tvc->lock,226); + ObtainWriteLock(&tvc->lock, 226); code = afs_HandleLink(tvc, areq); if (code == 0) { if (tvc->linkData) { if ((tvc->linkData[0] != '#') && (tvc->linkData[0] != '%')) - code = EINVAL; + code = EINVAL; else { /* we have the data */ strcpy(aout, tvc->linkData); - *aoutSize = strlen(tvc->linkData)+1; + *aoutSize = strlen(tvc->linkData) + 1; } } else code = EIO; } ReleaseWriteLock(&tvc->lock); afs_PutVCache(tvc); -out: - if (sysState.allocked) osi_FreeLargeSpace(bufp); + out: + if (sysState.allocked) + osi_FreeLargeSpace(bufp); return code; } @@ -1679,31 +1723,32 @@ DECL_PIOCTL(PGetTokens) int newStyle; AFS_STATCNT(PGetTokens); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ /* weird interface. If input parameter is present, it is an integer and - we're supposed to return the parm'th tokens for this unix uid. - If not present, we just return tokens for cell 1. - If counter out of bounds, return EDOM. - If no tokens for the particular cell, return ENOTCONN. - Also, if this mysterious parm is present, we return, along with the - tokens, the primary cell indicator (an afs_int32 0) and the cell name - at the end, in that order. - */ + * we're supposed to return the parm'th tokens for this unix uid. + * If not present, we just return tokens for cell 1. + * If counter out of bounds, return EDOM. + * If no tokens for the particular cell, return ENOTCONN. + * Also, if this mysterious parm is present, we return, along with the + * tokens, the primary cell indicator (an afs_int32 0) and the cell name + * at the end, in that order. + */ if ((newStyle = (ainSize > 0))) { memcpy((char *)&iterator, ain, sizeof(afs_int32)); } i = UHash(areq->uid); ObtainReadLock(&afs_xuser); - for(tu = afs_users[i]; tu; tu=tu->next) { + for (tu = afs_users[i]; tu; tu = tu->next) { if (newStyle) { if (tu->uid == areq->uid && (tu->states & UHasTokens)) { - if (iterator-- == 0) break; /* are we done yet? */ + if (iterator-- == 0) + break; /* are we done yet? */ } - } - else { - if (tu->uid == areq->uid && afs_IsPrimaryCellNum(tu->cell)) break; + } else { + if (tu->uid == areq->uid && afs_IsPrimaryCellNum(tu->cell)) + break; } } if (tu) { @@ -1717,7 +1762,8 @@ DECL_PIOCTL(PGetTokens) if (!tu) { return EDOM; } - if (((tu->states & UHasTokens) == 0) || (tu->ct.EndTimestamp < osi_Time())) { + if (((tu->states & UHasTokens) == 0) + || (tu->ct.EndTimestamp < osi_Time())) { tu->states |= (UTokensBad | UNeedsReset); afs_PutUser(tu, READ_LOCK); return ENOTCONN; @@ -1725,7 +1771,8 @@ DECL_PIOCTL(PGetTokens) /* use iterator for temp */ cp = aout; iterator = tu->stLen; /* for compat, we try to return 56 byte tix if they fit */ - if (iterator < 56) iterator = 56; /* # of bytes we're returning */ + if (iterator < 56) + iterator = 56; /* # of bytes we're returning */ memcpy(cp, (char *)&iterator, sizeof(afs_int32)); cp += sizeof(afs_int32); memcpy(cp, tu->stp, tu->stLen); /* copy out st */ @@ -1743,10 +1790,10 @@ DECL_PIOCTL(PGetTokens) tcell = afs_GetCell(tu->cell, READ_LOCK); if (tcell) { strcpy(cp, tcell->cellName); - cp += strlen(tcell->cellName)+1; + cp += strlen(tcell->cellName) + 1; afs_PutCell(tcell, READ_LOCK); - } - else *cp++ = 0; + } else + *cp++ = 0; } *aoutSize = cp - aout; afs_PutUser(tu, READ_LOCK); @@ -1759,12 +1806,12 @@ DECL_PIOCTL(PUnlog) register struct unixuser *tu; AFS_STATCNT(PUnlog); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ i = UHash(areq->uid); - ObtainWriteLock(&afs_xuser,227); - for(tu=afs_users[i]; tu; tu=tu->next) { + ObtainWriteLock(&afs_xuser, 227); + for (tu = afs_users[i]; tu; tu = tu->next) { if (tu->uid == areq->uid) { tu->vid = UNDEFVID; tu->states &= ~UHasTokens; @@ -1782,14 +1829,14 @@ DECL_PIOCTL(PUnlog) */ afs_ResetUserConns(tu); tu->refCount--; - ObtainWriteLock(&afs_xuser,228); + ObtainWriteLock(&afs_xuser, 228); #ifdef UKERNEL - /* set the expire times to 0, causes - * afs_GCUserData to remove this entry - */ - tu->ct.EndTimestamp = 0; - tu->tokenTime = 0; -#endif /* UKERNEL */ + /* set the expire times to 0, causes + * afs_GCUserData to remove this entry + */ + tu->ct.EndTimestamp = 0; + tu->tokenTime = 0; +#endif /* UKERNEL */ } } ReleaseWriteLock(&afs_xuser); @@ -1803,16 +1850,16 @@ DECL_PIOCTL(PMariner) AFS_STATCNT(PMariner); if (afs_mariner) - memcpy((char *)&oldHostAddr, (char *)&afs_marinerHost, sizeof(afs_int32)); + memcpy((char *)&oldHostAddr, (char *)&afs_marinerHost, + sizeof(afs_int32)); else - oldHostAddr = 0xffffffff; /* disabled */ + oldHostAddr = 0xffffffff; /* disabled */ memcpy((char *)&newHostAddr, ain, sizeof(afs_int32)); if (newHostAddr == 0xffffffff) { /* disable mariner operations */ afs_mariner = 0; - } - else if (newHostAddr) { + } else if (newHostAddr) { afs_mariner = 1; afs_marinerHost = newHostAddr; } @@ -1826,17 +1873,17 @@ DECL_PIOCTL(PCheckServers) register char *cp = 0; register int i; register struct server *ts; - afs_int32 temp, *lp = (afs_int32 *)ain, havecell=0; + afs_int32 temp, *lp = (afs_int32 *) ain, havecell = 0; struct cell *cellp; struct chservinfo *pcheck; AFS_STATCNT(PCheckServers); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ if (*lp == 0x12345678) { /* For afs3.3 version */ - pcheck=(struct chservinfo *)ain; + pcheck = (struct chservinfo *)ain; if (pcheck->tinterval >= 0) { cp = aout; memcpy(cp, (char *)&PROBE_INTERVAL, sizeof(afs_int32)); @@ -1844,17 +1891,17 @@ DECL_PIOCTL(PCheckServers) if (pcheck->tinterval > 0) { if (!afs_osi_suser(*acred)) return EACCES; - PROBE_INTERVAL=pcheck->tinterval; + PROBE_INTERVAL = pcheck->tinterval; } return 0; } if (pcheck->tsize) havecell = 1; - temp=pcheck->tflags; + temp = pcheck->tflags; cp = pcheck->tbuffer; - } else { /* For pre afs3.3 versions */ + } else { /* For pre afs3.3 versions */ memcpy((char *)&temp, ain, sizeof(afs_int32)); - cp = ain+sizeof(afs_int32); + cp = ain + sizeof(afs_int32); if (ainSize > sizeof(afs_int32)) havecell = 1; } @@ -1866,31 +1913,35 @@ DECL_PIOCTL(PCheckServers) if (havecell) { /* have cell name, too */ cellp = afs_GetCellByName(cp, READ_LOCK); - if (!cellp) return ENOENT; - } - else cellp = NULL; + if (!cellp) + return ENOENT; + } else + cellp = NULL; if (!cellp && (temp & 2)) { /* use local cell */ cellp = afs_GetPrimaryCell(READ_LOCK); } - if (!(temp & 1)) { /* if not fast, call server checker routine */ + if (!(temp & 1)) { /* if not fast, call server checker routine */ afs_CheckServers(1, cellp); /* check down servers */ afs_CheckServers(0, cellp); /* check up servers */ } /* now return the current down server list */ cp = aout; ObtainReadLock(&afs_xserver); - for(i=0;inext) { - if (cellp && ts->cell != cellp) continue; /* cell spec'd and wrong */ - if ((ts->flags & SRVR_ISDOWN) && ts->addr->sa_portal != ts->cell->vlport) { + for (i = 0; i < NSERVERS; i++) { + for (ts = afs_servers[i]; ts; ts = ts->next) { + if (cellp && ts->cell != cellp) + continue; /* cell spec'd and wrong */ + if ((ts->flags & SRVR_ISDOWN) + && ts->addr->sa_portal != ts->cell->vlport) { memcpy(cp, (char *)&ts->addr->sa_ip, sizeof(afs_int32)); cp += sizeof(afs_int32); } } } ReleaseReadLock(&afs_xserver); - if (cellp) afs_PutCell(cellp, READ_LOCK); + if (cellp) + afs_PutCell(cellp, READ_LOCK); *aoutSize = cp - aout; return 0; } @@ -1898,46 +1949,46 @@ DECL_PIOCTL(PCheckServers) DECL_PIOCTL(PCheckVolNames) { AFS_STATCNT(PCheckVolNames); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ afs_CheckRootVolume(); - afs_CheckVolumeNames(AFS_VOLCHECK_FORCE | - AFS_VOLCHECK_EXPIRED | - AFS_VOLCHECK_BUSY | - AFS_VOLCHECK_MTPTS); + afs_CheckVolumeNames(AFS_VOLCHECK_FORCE | AFS_VOLCHECK_EXPIRED | + AFS_VOLCHECK_BUSY | AFS_VOLCHECK_MTPTS); return 0; } DECL_PIOCTL(PCheckAuth) { - int i; - struct srvAddr *sa; - struct conn *tc; - struct unixuser *tu; - afs_int32 retValue; + int i; + struct srvAddr *sa; + struct conn *tc; + struct unixuser *tu; + afs_int32 retValue; AFS_STATCNT(PCheckAuth); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ retValue = 0; - tu = afs_GetUser(areq->uid, 1, READ_LOCK); /* check local cell authentication */ - if (!tu) retValue = EACCES; + tu = afs_GetUser(areq->uid, 1, READ_LOCK); /* check local cell authentication */ + if (!tu) + retValue = EACCES; else { /* we have a user */ ObtainReadLock(&afs_xsrvAddr); ObtainReadLock(&afs_xconn); /* any tokens set? */ - if ((tu->states & UHasTokens) == 0) retValue = EACCES; + if ((tu->states & UHasTokens) == 0) + retValue = EACCES; /* all connections in cell 1 working? */ - for(i=0;inext_bkt) { - for (tc = sa->conns; tc; tc=tc->next) { - if (tc->user == tu && (tu->states & UTokensBad)) - retValue = EACCES; - } + for (i = 0; i < NSERVERS; i++) { + for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) { + for (tc = sa->conns; tc; tc = tc->next) { + if (tc->user == tu && (tu->states & UTokensBad)) + retValue = EACCES; + } } } ReleaseReadLock(&afs_xsrvAddr); @@ -1949,7 +2000,9 @@ DECL_PIOCTL(PCheckAuth) return 0; } -static int Prefetch(char *apath, struct afs_ioctl *adata, int afollow, struct AFS_UCRED *acred) +static int +Prefetch(char *apath, struct afs_ioctl *adata, int afollow, + struct AFS_UCRED *acred) { register char *tp; register afs_int32 code; @@ -1960,19 +2013,20 @@ static int Prefetch(char *apath, struct afs_ioctl *adata, int afollow, struct AF #endif AFS_STATCNT(Prefetch); - if (!apath) return EINVAL; + if (!apath) + return EINVAL; tp = osi_AllocLargeSpace(1024); AFS_COPYINSTR(apath, tp, 1024, &bufferSize, code); if (code) { osi_FreeLargeSpace(tp); return code; } - if (afs_BBusy()) { /* do this as late as possible */ + if (afs_BBusy()) { /* do this as late as possible */ osi_FreeLargeSpace(tp); return EWOULDBLOCK; /* pretty close */ } - afs_BQueue(BOP_PATH, (struct vcache*)0, 0, 0, acred, - (afs_size_t) 0, (afs_size_t) 0, tp); + afs_BQueue(BOP_PATH, (struct vcache *)0, 0, 0, acred, (afs_size_t) 0, + (afs_size_t) 0, tp); return 0; } @@ -1984,17 +2038,19 @@ DECL_PIOCTL(PFindVolume) register char *cp; AFS_STATCNT(PFindVolume); - if (!avc) return EINVAL; + if (!avc) + return EINVAL; tvp = afs_GetVolume(&avc->fid, areq, READ_LOCK); if (tvp) { cp = aout; - for(i=0;iserverHost[i]; - if (!ts) break; + if (!ts) + break; memcpy(cp, (char *)&ts->addr->sa_ip, sizeof(afs_int32)); cp += sizeof(afs_int32); } - if (istates & CRO) return 0; /* read-only-ness can't change */ - ObtainWriteLock(&avc->lock,229); + if (!avc) + return EINVAL; + if (avc->states & CRO) + return 0; /* read-only-ness can't change */ + ObtainWriteLock(&avc->lock, 229); theFids.AFSCBFids_len = 1; theCBs.AFSCBs_len = 1; - theFids.AFSCBFids_val = (struct AFSFid *) &avc->fid.Fid; + theFids.AFSCBFids_val = (struct AFSFid *)&avc->fid.Fid; theCBs.AFSCBs_val = CallBacks_Array; CallBacks_Array[0].CallBackType = CB_DROPPED; if (avc->callback) { do { tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS); - RX_AFS_GUNLOCK(); - code = RXAFS_GiveUpCallBacks(tc->id, &theFids, &theCBs); - RX_AFS_GLOCK(); - XSTATS_END_TIME; + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS); + RX_AFS_GUNLOCK(); + code = RXAFS_GiveUpCallBacks(tc->id, &theFids, &theCBs); + RX_AFS_GLOCK(); + XSTATS_END_TIME; } /* don't set code on failure since we wouldn't use it */ - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS, - SHARED_LOCK, NULL)); + } while (afs_Analyze + (tc, code, &avc->fid, areq, + AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS, SHARED_LOCK, NULL)); ObtainWriteLock(&afs_xcbhash, 457); afs_DequeueCallback(avc); @@ -2113,15 +2176,15 @@ DECL_PIOCTL(PRemoveCallBack) DECL_PIOCTL(PNewCell) { /* create a new cell */ - afs_int32 cellHosts[MAXCELLHOSTS], *lp, magic=0; - char *newcell=0, *linkedcell=0, *tp= ain; - register afs_int32 code, linkedstate=0, ls; + afs_int32 cellHosts[MAXCELLHOSTS], *lp, magic = 0; + char *newcell = 0, *linkedcell = 0, *tp = ain; + register afs_int32 code, linkedstate = 0, ls; u_short fsport = 0, vlport = 0; afs_int32 scount; AFS_STATCNT(PNewCell); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ if (!afs_osi_suser(*acred)) return EACCES; @@ -2129,35 +2192,38 @@ DECL_PIOCTL(PNewCell) memcpy((char *)&magic, tp, sizeof(afs_int32)); tp += sizeof(afs_int32); if (magic != 0x12345678) - return EINVAL; + return EINVAL; /* A 3.4 fs newcell command will pass an array of MAXCELLHOSTS * server addresses while the 3.5 fs newcell command passes * MAXHOSTS. To figure out which is which, check if the cellname * is good. */ - newcell = tp + (MAXCELLHOSTS+3)*sizeof(afs_int32); + newcell = tp + (MAXCELLHOSTS + 3) * sizeof(afs_int32); scount = ((newcell[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS); /* MAXCELLHOSTS (=8) is less than MAXHOSTS (=13) */ memcpy((char *)cellHosts, tp, MAXCELLHOSTS * sizeof(afs_int32)); tp += (scount * sizeof(afs_int32)); - lp = (afs_int32 *)tp; + lp = (afs_int32 *) tp; fsport = *lp++; vlport = *lp++; - if (fsport < 1024) fsport = 0; /* Privileged ports not allowed */ - if (vlport < 1024) vlport = 0; /* Privileged ports not allowed */ + if (fsport < 1024) + fsport = 0; /* Privileged ports not allowed */ + if (vlport < 1024) + vlport = 0; /* Privileged ports not allowed */ tp += (3 * sizeof(afs_int32)); newcell = tp; if ((ls = *lp) & 1) { - linkedcell = tp + strlen(newcell)+1; - linkedstate |= CLinkedCell; + linkedcell = tp + strlen(newcell) + 1; + linkedstate |= CLinkedCell; } - linkedstate |= CNoSUID; /* setuid is disabled by default for fs newcell */ - code = afs_NewCell(newcell, cellHosts, linkedstate, linkedcell, fsport, - vlport, (int)0); + linkedstate |= CNoSUID; /* setuid is disabled by default for fs newcell */ + code = + afs_NewCell(newcell, cellHosts, linkedstate, linkedcell, fsport, + vlport, (int)0); return code; } @@ -2168,8 +2234,8 @@ DECL_PIOCTL(PNewAlias) register afs_int32 code; char *realName, *aliasName; - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ if (!afs_osi_suser(*acred)) return EACCES; @@ -2186,13 +2252,13 @@ DECL_PIOCTL(PNewAlias) DECL_PIOCTL(PListCells) { afs_int32 whichCell; - register struct cell *tcell=0; + register struct cell *tcell = 0; register afs_int32 i; register char *cp, *tp = ain; AFS_STATCNT(PListCells); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ memcpy((char *)&whichCell, tp, sizeof(afs_int32)); tp += sizeof(afs_int32); @@ -2200,29 +2266,33 @@ DECL_PIOCTL(PListCells) if (tcell) { cp = aout; memset(cp, 0, MAXCELLHOSTS * sizeof(afs_int32)); - for(i=0;icellHosts[i] == 0) break; - memcpy(cp, (char *)&tcell->cellHosts[i]->addr->sa_ip, sizeof(afs_int32)); + for (i = 0; i < MAXCELLHOSTS; i++) { + if (tcell->cellHosts[i] == 0) + break; + memcpy(cp, (char *)&tcell->cellHosts[i]->addr->sa_ip, + sizeof(afs_int32)); cp += sizeof(afs_int32); } cp = aout + MAXCELLHOSTS * sizeof(afs_int32); strcpy(cp, tcell->cellName); - cp += strlen(tcell->cellName)+1; + cp += strlen(tcell->cellName) + 1; *aoutSize = cp - aout; afs_PutCell(tcell, READ_LOCK); } - if (tcell) return 0; - else return EDOM; + if (tcell) + return 0; + else + return EDOM; } DECL_PIOCTL(PListAliases) { afs_int32 whichAlias; - register struct cell_alias *tcalias=0; + register struct cell_alias *tcalias = 0; register char *cp, *tp = ain; - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ if (ainSize < sizeof(afs_int32)) return EINVAL; @@ -2233,14 +2303,16 @@ DECL_PIOCTL(PListAliases) if (tcalias) { cp = aout; strcpy(cp, tcalias->alias); - cp += strlen(tcalias->alias)+1; + cp += strlen(tcalias->alias) + 1; strcpy(cp, tcalias->cell); - cp += strlen(tcalias->cell)+1; + cp += strlen(tcalias->cell) + 1; *aoutSize = cp - aout; afs_PutCellAlias(tcalias); } - if (tcalias) return 0; - else return EDOM; + if (tcalias) + return 0; + else + return EDOM; } DECL_PIOCTL(PRemoveMount) @@ -2261,17 +2333,21 @@ DECL_PIOCTL(PRemoveMount) /* "ain" is the name of the file in this dir to remove */ AFS_STATCNT(PRemoveMount); - if (!avc) return EINVAL; + if (!avc) + return EINVAL; code = afs_VerifyVCache(avc, areq); - if (code) return code; - if (vType(avc) != VDIR) return ENOTDIR; + if (code) + return code; + if (vType(avc) != VDIR) + return ENOTDIR; - tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1); /* test for error below */ - if (!tdc) return ENOENT; + tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1); /* test for error below */ + if (!tdc) + return ENOENT; Check_AtSys(avc, ain, &sysState, areq); ObtainReadLock(&tdc->lock); do { - code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid); + code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid); } while (code == ENOENT && Next_AtSys(avc, areq, &sysState)); ReleaseReadLock(&tdc->lock); bufp = sysState.name; @@ -2281,7 +2357,7 @@ DECL_PIOCTL(PRemoveMount) } tfid.Cell = avc->fid.Cell; tfid.Fid.Volume = avc->fid.Fid.Volume; - if (!tfid.Fid.Unique && (avc->states & CForeign)) { + if (!tfid.Fid.Unique && (avc->states & CForeign)) { tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp); } else { tvc = afs_GetVCache(&tfid, areq, NULL, NULL); @@ -2297,12 +2373,12 @@ DECL_PIOCTL(PRemoveMount) code = EINVAL; goto out; } - ObtainWriteLock(&tvc->lock,230); + ObtainWriteLock(&tvc->lock, 230); code = afs_HandleLink(tvc, areq); if (!code) { if (tvc->linkData) { if ((tvc->linkData[0] != '#') && (tvc->linkData[0] != '%')) - code = EINVAL; + code = EINVAL; } else code = EIO; } @@ -2313,26 +2389,27 @@ DECL_PIOCTL(PRemoveMount) afs_PutDCache(tdc); goto out; } - ObtainWriteLock(&avc->lock,231); + ObtainWriteLock(&avc->lock, 231); osi_dnlc_remove(avc, bufp, tvc); do { tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEFILE); - RX_AFS_GUNLOCK(); - code = RXAFS_RemoveFile(tc->id, (struct AFSFid *) &avc->fid.Fid, - bufp, &OutDirStatus, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_REMOVEFILE, - SHARED_LOCK, NULL)); + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEFILE); + RX_AFS_GUNLOCK(); + code = + RXAFS_RemoveFile(tc->id, (struct AFSFid *)&avc->fid.Fid, bufp, + &OutDirStatus, &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_REMOVEFILE, + SHARED_LOCK, NULL)); if (code) { - if (tdc) afs_PutDCache(tdc); + if (tdc) + afs_PutDCache(tdc); ReleaseWriteLock(&avc->lock); goto out; } @@ -2350,11 +2427,12 @@ DECL_PIOCTL(PRemoveMount) ReleaseWriteLock(&tdc->lock); afs_PutDCache(tdc); /* drop ref count */ } - avc->states &= ~CUnique; /* For the dfs xlator */ + avc->states &= ~CUnique; /* For the dfs xlator */ ReleaseWriteLock(&avc->lock); code = 0; -out: - if (sysState.allocked) osi_FreeLargeSpace(bufp); + out: + if (sysState.allocked) + osi_FreeLargeSpace(bufp); return code; } @@ -2369,11 +2447,12 @@ DECL_PIOCTL(PGetCellStatus) afs_int32 temp; AFS_STATCNT(PGetCellStatus); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ tcell = afs_GetCellByName(ain, READ_LOCK); - if (!tcell) return ENOENT; + if (!tcell) + return ENOENT; temp = tcell->states; afs_PutCell(tcell, READ_LOCK); memcpy(aout, (char *)&temp, sizeof(afs_int32)); @@ -2388,11 +2467,12 @@ DECL_PIOCTL(PSetCellStatus) if (!afs_osi_suser(*acred)) return EACCES; - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ - tcell = afs_GetCellByName(ain+2*sizeof(afs_int32), WRITE_LOCK); - if (!tcell) return ENOENT; + tcell = afs_GetCellByName(ain + 2 * sizeof(afs_int32), WRITE_LOCK); + if (!tcell) + return ENOENT; memcpy((char *)&temp, ain, sizeof(afs_int32)); if (temp & CNoSUID) tcell->states |= CNoSUID; @@ -2413,10 +2493,10 @@ DECL_PIOCTL(PFlushVolumeData) AFS_STATCNT(PFlushVolumeData); if (!avc) return EINVAL; - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ - volume = avc->fid.Fid.Volume; /* who to zap */ + volume = avc->fid.Fid.Volume; /* who to zap */ cell = avc->fid.Cell; /* @@ -2424,8 +2504,8 @@ DECL_PIOCTL(PFlushVolumeData) * the vcaches associated with the volume. */ ObtainReadLock(&afs_xvcache); - for(i = 0; i < VCSIZE; i++) { - for(tvc = afs_vhashT[i]; tvc; tvc=tvc->hnext) { + for (i = 0; i < VCSIZE; i++) { + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { if (tvc->fid.Fid.Volume == volume && tvc->fid.Cell == cell) { #if defined(AFS_SGI_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) VN_HOLD(AFSTOV(tvc)); @@ -2440,7 +2520,7 @@ DECL_PIOCTL(PFlushVolumeData) #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) afs_BozonLock(&tvc->pvnLock, tvc); /* Since afs_TryToSmush will do a pvn_vptrunc */ #endif - ObtainWriteLock(&tvc->lock,232); + ObtainWriteLock(&tvc->lock, 232); ObtainWriteLock(&afs_xcbhash, 458); afs_DequeueCallback(tvc); @@ -2462,22 +2542,23 @@ DECL_PIOCTL(PFlushVolumeData) ReleaseReadLock(&afs_xvcache); - MObtainWriteLock(&afs_xdcache,328); /* needed if you're going to flush any stuff */ - for(i=0;irefCount <= 1) { /* too high, in use by running sys call */ + if (tdc->refCount <= 1) { /* too high, in use by running sys call */ ReleaseReadLock(&tdc->tlock); if (tdc->f.fid.Fid.Volume == volume && tdc->f.fid.Cell == cell) { - if (! (afs_indexFlags[i] & IFDataMod)) { + if (!(afs_indexFlags[i] & IFDataMod)) { /* if the file is modified, but has a ref cnt of only 1, then - someone probably has the file open and is writing into it. - Better to skip flushing such a file, it will be brought back - immediately on the next write anyway. - - If we *must* flush, then this code has to be rearranged to call - afs_storeAllSegments() first */ - afs_FlushDCache(tdc); + * someone probably has the file open and is writing into it. + * Better to skip flushing such a file, it will be brought back + * immediately on the next write anyway. + * + * If we *must* flush, then this code has to be rearranged to call + * afs_storeAllSegments() first */ + afs_FlushDCache(tdc); } } } else { @@ -2488,8 +2569,8 @@ DECL_PIOCTL(PFlushVolumeData) MReleaseWriteLock(&afs_xdcache); ObtainReadLock(&afs_xvolume); - for (i=0;inext) { + for (i = 0; i < NVOLS; i++) { + for (tv = afs_volumes[i]; tv; tv = tv->next) { if (tv->volume == volume) { afs_ResetVolumeInfo(tv); break; @@ -2513,9 +2594,11 @@ DECL_PIOCTL(PGetVnodeXStatus) afs_int32 mode, i; /* AFS_STATCNT(PGetVnodeXStatus); */ - if (!avc) return EINVAL; + if (!avc) + return EINVAL; code = afs_VerifyVCache(avc, areq); - if (code) return code; + if (code) + return code; if (vType(avc) == VDIR) mode = PRSFS_LOOKUP; else @@ -2530,13 +2613,13 @@ DECL_PIOCTL(PGetVnodeXStatus) hset(stat.flushDV, avc->flushDV); hset(stat.mapDV, avc->mapDV); stat.truncPos = avc->truncPos; - { /* just grab the first two - won't break anything... */ - struct axscache *ac; + { /* just grab the first two - won't break anything... */ + struct axscache *ac; - for (i=0, ac=avc->Access; ac && i < CPSIZE; i++, ac=ac->next) { - stat.randomUid[i] = ac->uid; - stat.randomAccess[i] = ac->axess; - } + for (i = 0, ac = avc->Access; ac && i < CPSIZE; i++, ac = ac->next) { + stat.randomUid[i] = ac->uid; + stat.randomAccess[i] = ac->axess; + } } stat.callback = afs_data_pointer_to_int32(avc->callback); stat.cbExpires = avc->cbExpires; @@ -2559,7 +2642,7 @@ DECL_PIOCTL(PGetVnodeXStatus) DECL_PIOCTL(PSetSysName) { char *cp, inname[MAXSYSNAME], outname[MAXSYSNAME]; - int setsysname, foundname=0; + int setsysname, foundname = 0; register struct afs_exporter *exporter; register struct unixuser *au; register afs_int32 pag, error; @@ -2568,7 +2651,7 @@ DECL_PIOCTL(PSetSysName) AFS_STATCNT(PSetSysName); if (!afs_globalVFS) { - /* Afsd is NOT running; disable it */ + /* Afsd is NOT running; disable it */ #if defined(KERNEL_HAVE_UERROR) return (setuerror(EINVAL), EINVAL); #else @@ -2580,92 +2663,96 @@ DECL_PIOCTL(PSetSysName) ain += sizeof(afs_int32); if (setsysname) { - /* Check my args */ - if (setsysname < 0 || setsysname > MAXNUMSYSNAMES) - return EINVAL; - for(cp = ain,count = 0;count < setsysname;count++) { - /* won't go past end of ain since maxsysname*num < ain length */ - t = strlen(cp); - if (t >= MAXSYSNAME || t <= 0) - return EINVAL; - /* check for names that can shoot us in the foot */ - if (*cp == '.' && (cp[1] == 0 || (cp[1] == '.' && cp[2] == 0))) - return EINVAL; - cp += t+1; - } - /* args ok */ - - /* inname gets first entry in case we're being a translater */ - t = strlen(ain); - memcpy(inname, ain, t+1); /* include terminating null */ - ain += t + 1; - } - if ((*acred)->cr_gid == RMTUSER_REQ) { /* Handles all exporters */ + /* Check my args */ + if (setsysname < 0 || setsysname > MAXNUMSYSNAMES) + return EINVAL; + for (cp = ain, count = 0; count < setsysname; count++) { + /* won't go past end of ain since maxsysname*num < ain length */ + t = strlen(cp); + if (t >= MAXSYSNAME || t <= 0) + return EINVAL; + /* check for names that can shoot us in the foot */ + if (*cp == '.' && (cp[1] == 0 || (cp[1] == '.' && cp[2] == 0))) + return EINVAL; + cp += t + 1; + } + /* args ok */ + + /* inname gets first entry in case we're being a translater */ + t = strlen(ain); + memcpy(inname, ain, t + 1); /* include terminating null */ + ain += t + 1; + } + if ((*acred)->cr_gid == RMTUSER_REQ) { /* Handles all exporters */ pag = PagInCred(*acred); if (pag == NOPAG) { - return EINVAL; /* Better than panicing */ + return EINVAL; /* Better than panicing */ } if (!(au = afs_FindUser(pag, -1, READ_LOCK))) { - return EINVAL; /* Better than panicing */ + return EINVAL; /* Better than panicing */ } if (!(exporter = au->exporter)) { afs_PutUser(au, READ_LOCK); - return EINVAL; /* Better than panicing */ + return EINVAL; /* Better than panicing */ } - error = EXP_SYSNAME(exporter, (setsysname? inname : NULL), outname); + error = EXP_SYSNAME(exporter, (setsysname ? inname : NULL), outname); if (error) { - if (error == ENODEV) foundname = 0; /* sysname not set yet! */ + if (error == ENODEV) + foundname = 0; /* sysname not set yet! */ else { afs_PutUser(au, READ_LOCK); return error; } - } - else foundname = 1; + } else + foundname = 1; afs_PutUser(au, READ_LOCK); } else { - /* Not xlating, so local case */ - if (!afs_sysname) osi_Panic("PSetSysName: !afs_sysname\n"); + /* Not xlating, so local case */ + if (!afs_sysname) + osi_Panic("PSetSysName: !afs_sysname\n"); if (!setsysname) { /* user just wants the info */ strcpy(outname, afs_sysname); foundname = afs_sysnamecount; - } else { /* Local guy; only root can change sysname */ + } else { /* Local guy; only root can change sysname */ if (!afs_osi_suser(*acred)) return EACCES; /* clear @sys entries from the dnlc, once afs_lookup can - do lookups of @sys entries and thinks it can trust them */ + * do lookups of @sys entries and thinks it can trust them */ /* privs ok, store the entry, ... */ strcpy(afs_sysname, inname); - if (setsysname > 1) { /* ... or list */ - cp = ain; - for(count=1; count < setsysname;++count) { - if (!afs_sysnamelist[count]) - osi_Panic("PSetSysName: no afs_sysnamelist entry to write\n"); - t = strlen(cp); - memcpy(afs_sysnamelist[count], cp, t+1); /* include null */ - cp += t+1; - } + if (setsysname > 1) { /* ... or list */ + cp = ain; + for (count = 1; count < setsysname; ++count) { + if (!afs_sysnamelist[count]) + osi_Panic + ("PSetSysName: no afs_sysnamelist entry to write\n"); + t = strlen(cp); + memcpy(afs_sysnamelist[count], cp, t + 1); /* include null */ + cp += t + 1; + } } afs_sysnamecount = setsysname; } } if (!setsysname) { - cp = aout; /* not changing so report back the count and ... */ + cp = aout; /* not changing so report back the count and ... */ memcpy(cp, (char *)&foundname, sizeof(afs_int32)); cp += sizeof(afs_int32); if (foundname) { - strcpy(cp, outname); /* ... the entry, ... */ - cp += strlen(outname)+1; - for(count=1; count < foundname; ++count) { /* ... or list. */ - /* Note: we don't support @sys lists for exporters */ - if (!afs_sysnamelist[count]) - osi_Panic("PSetSysName: no afs_sysnamelist entry to read\n"); - t = strlen(afs_sysnamelist[count]); - if (t >= MAXSYSNAME) - osi_Panic("PSetSysName: sysname entry garbled\n"); - strcpy(cp, afs_sysnamelist[count]); - cp += t + 1; + strcpy(cp, outname); /* ... the entry, ... */ + cp += strlen(outname) + 1; + for (count = 1; count < foundname; ++count) { /* ... or list. */ + /* Note: we don't support @sys lists for exporters */ + if (!afs_sysnamelist[count]) + osi_Panic + ("PSetSysName: no afs_sysnamelist entry to read\n"); + t = strlen(afs_sysnamelist[count]); + if (t >= MAXSYSNAME) + osi_Panic("PSetSysName: sysname entry garbled\n"); + strcpy(cp, afs_sysnamelist[count]); + cp += t + 1; } } *aoutSize = cp - aout; @@ -2682,13 +2769,14 @@ DECL_PIOCTL(PSetSysName) * l - array of cell ids which have volumes that need to be sorted * vlonly - sort vl servers or file servers? */ -static void *ReSortCells_cb(struct cell *cell, void *arg) +static void * +ReSortCells_cb(struct cell *cell, void *arg) { afs_int32 *p = (afs_int32 *) arg; afs_int32 *l = p + 1; int i, s = p[0]; - for (i=0; icellNum) { ObtainWriteLock(&cell->lock, 690); afs_SortServers(cell->cellHosts, MAXCELLHOSTS); @@ -2699,28 +2787,29 @@ static void *ReSortCells_cb(struct cell *cell, void *arg) return NULL; } -static void ReSortCells(int s, afs_int32 *l, int vlonly) +static void +ReSortCells(int s, afs_int32 * l, int vlonly) { int i; struct volume *j; - register int k; + register int k; if (vlonly) { afs_int32 *p; - p = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * (s+1)); + p = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * (s + 1)); p[0] = s; - memcpy(p+1, l, s * sizeof(afs_int32)); + memcpy(p + 1, l, s * sizeof(afs_int32)); afs_TraverseCells(&ReSortCells_cb, p); - afs_osi_Free(p, sizeof(afs_int32) * (s+1)); + afs_osi_Free(p, sizeof(afs_int32) * (s + 1)); return; } ObtainReadLock(&afs_xvolume); - for (i= 0; i< NVOLS; i++) { - for (j=afs_volumes[i];j;j=j->next) { - for (k=0;knext) { + for (k = 0; k < s; k++) if (j->cell == l[k]) { - ObtainWriteLock(&j->lock,233); + ObtainWriteLock(&j->lock, 233); afs_SortServers(j->serverHost, MAXHOSTS); ReleaseWriteLock(&j->lock); break; @@ -2732,116 +2821,119 @@ static void ReSortCells(int s, afs_int32 *l, int vlonly) static int debugsetsp = 0; -static int afs_setsprefs(sp, num, vlonly) - struct spref *sp; - unsigned int num; - unsigned int vlonly; -{ - struct srvAddr *sa; - int i,j,k,matches,touchedSize; - struct server *srvr = NULL; - afs_int32 touched[34]; - int isfs; - - touchedSize=0; - for (k=0; k < num; sp++, k++) { - if (debugsetsp) { - printf ("sp host=%x, rank=%d\n",sp->host.s_addr, sp->rank); - } - matches=0; - ObtainReadLock(&afs_xserver); - - i = SHash(sp->host.s_addr); - for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) { - if (sa->sa_ip == sp->host.s_addr) { - srvr = sa->server; - isfs = (srvr->cell && (sa->sa_portal == srvr->cell->fsport)) - || (sa->sa_portal == AFS_FSPORT); - if ((!vlonly && isfs) || (vlonly && !isfs)) { - matches++; - break; +static int +afs_setsprefs(sp, num, vlonly) + struct spref *sp; + unsigned int num; + unsigned int vlonly; +{ + struct srvAddr *sa; + int i, j, k, matches, touchedSize; + struct server *srvr = NULL; + afs_int32 touched[34]; + int isfs; + + touchedSize = 0; + for (k = 0; k < num; sp++, k++) { + if (debugsetsp) { + printf("sp host=%x, rank=%d\n", sp->host.s_addr, sp->rank); + } + matches = 0; + ObtainReadLock(&afs_xserver); + + i = SHash(sp->host.s_addr); + for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) { + if (sa->sa_ip == sp->host.s_addr) { + srvr = sa->server; + isfs = (srvr->cell && (sa->sa_portal == srvr->cell->fsport)) + || (sa->sa_portal == AFS_FSPORT); + if ((!vlonly && isfs) || (vlonly && !isfs)) { + matches++; + break; + } + } + } + + if (sa && matches) { /* found one! */ + if (debugsetsp) { + printf("sa ip=%x, ip_rank=%d\n", sa->sa_ip, sa->sa_iprank); + } + sa->sa_iprank = sp->rank + afs_randomMod15(); + afs_SortOneServer(sa->server); + + if (srvr->cell) { + /* if we don't know yet what cell it's in, this is moot */ + for (j = touchedSize - 1; + j >= 0 && touched[j] != srvr->cell->cellNum; j--) + /* is it in our list of touched cells ? */ ; + if (j < 0) { /* no, it's not */ + touched[touchedSize++] = srvr->cell->cellNum; + if (touchedSize >= 32) { /* watch for ovrflow */ + ReleaseReadLock(&afs_xserver); + ReSortCells(touchedSize, touched, vlonly); + touchedSize = 0; + ObtainReadLock(&afs_xserver); + } + } } - } - } - - if (sa && matches) { /* found one! */ - if (debugsetsp) { - printf ("sa ip=%x, ip_rank=%d\n",sa->sa_ip, sa->sa_iprank); - } - sa->sa_iprank = sp->rank + afs_randomMod15(); - afs_SortOneServer(sa->server); - - if (srvr->cell) { - /* if we don't know yet what cell it's in, this is moot */ - for (j=touchedSize-1; j>=0 && touched[j] != srvr->cell->cellNum; j--) - /* is it in our list of touched cells ? */ ; - if (j < 0) { /* no, it's not */ - touched[touchedSize++] = srvr->cell->cellNum; - if (touchedSize >= 32) { /* watch for ovrflow */ - ReleaseReadLock(&afs_xserver); - ReSortCells(touchedSize, touched, vlonly); - touchedSize=0; - ObtainReadLock(&afs_xserver); - } - } - } - } - - ReleaseReadLock(&afs_xserver); - /* if we didn't find one, start to create one. */ - /* Note that it doesn't have a cell yet... */ - if (!matches) { - afs_uint32 temp = sp->host.s_addr; - srvr = afs_GetServer(&temp, 1, 0, (vlonly ? AFS_VLPORT : AFS_FSPORT), - WRITE_LOCK, (afsUUID *)0,0); - srvr->addr->sa_iprank = sp->rank + afs_randomMod15(); - afs_PutServer(srvr, WRITE_LOCK); - } - } /* for all cited preferences */ - - ReSortCells(touchedSize, touched, vlonly); - return 0; + } + + ReleaseReadLock(&afs_xserver); + /* if we didn't find one, start to create one. */ + /* Note that it doesn't have a cell yet... */ + if (!matches) { + afs_uint32 temp = sp->host.s_addr; + srvr = + afs_GetServer(&temp, 1, 0, (vlonly ? AFS_VLPORT : AFS_FSPORT), + WRITE_LOCK, (afsUUID *) 0, 0); + srvr->addr->sa_iprank = sp->rank + afs_randomMod15(); + afs_PutServer(srvr, WRITE_LOCK); + } + } /* for all cited preferences */ + + ReSortCells(touchedSize, touched, vlonly); + return 0; } /* Note that this may only be performed by the local root user. - */ + */ DECL_PIOCTL(PSetSPrefs) { - struct setspref *ssp; - AFS_STATCNT(PSetSPrefs); + struct setspref *ssp; + AFS_STATCNT(PSetSPrefs); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ - if (!afs_osi_suser(*acred)) - return EACCES; + if (!afs_osi_suser(*acred)) + return EACCES; - if (ainSize < sizeof(struct setspref)) - return EINVAL; + if (ainSize < sizeof(struct setspref)) + return EINVAL; - ssp = (struct setspref *)ain; - if (ainSize < sizeof(struct spref)*ssp->num_servers) - return EINVAL; + ssp = (struct setspref *)ain; + if (ainSize < sizeof(struct spref) * ssp->num_servers) + return EINVAL; - afs_setsprefs(&(ssp->servers[0]), ssp->num_servers, - (ssp->flags & DBservers)); - return 0; + afs_setsprefs(&(ssp->servers[0]), ssp->num_servers, + (ssp->flags & DBservers)); + return 0; } DECL_PIOCTL(PSetSPrefs33) { - struct spref *sp; - AFS_STATCNT(PSetSPrefs); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + struct spref *sp; + AFS_STATCNT(PSetSPrefs); + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ - if (!afs_osi_suser(*acred)) - return EACCES; + if (!afs_osi_suser(*acred)) + return EACCES; - sp = (struct spref *)ain; - afs_setsprefs(sp, ainSize/(sizeof(struct spref)), 0 /*!vlonly*/); - return 0; + sp = (struct spref *)ain; + afs_setsprefs(sp, ainSize / (sizeof(struct spref)), 0 /*!vlonly */ ); + return 0; } /* some notes on the following code... @@ -2853,81 +2945,81 @@ DECL_PIOCTL(PSetSPrefs33) */ DECL_PIOCTL(PGetSPrefs) { - struct sprefrequest *spin; /* input */ - struct sprefinfo *spout; /* output */ - struct spref *srvout; /* one output component */ - int i,j; /* counters for hash table traversal */ - struct server *srvr; /* one of CM's server structs */ - struct srvAddr *sa; - int vlonly; /* just return vlservers ? */ - int isfs; - - AFS_STATCNT(PGetSPrefs); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ - - - if (ainSize < sizeof (struct sprefrequest_33)) { - return ENOENT; - } - else { - spin = ((struct sprefrequest *) ain); - } - - if (ainSize > sizeof (struct sprefrequest_33)) { - vlonly = (spin->flags & DBservers); - } - else vlonly = 0; - - /* struct sprefinfo includes 1 server struct... that size gets added - * in during the loop that follows. - */ - *aoutSize = sizeof(struct sprefinfo) - sizeof (struct spref); - spout = (struct sprefinfo *) aout; - spout->next_offset = spin->offset; - spout->num_servers = 0; - srvout = spout->servers; - - ObtainReadLock(&afs_xserver); - for (i=0, j=0; j < NSERVERS; j++) { /* sift through hash table */ - for (sa = afs_srvAddrs[j]; sa; sa = sa->next_bkt, i++) { - if (spin->offset > (unsigned short)i) { - continue; /* catch up to where we left off */ - } + struct sprefrequest *spin; /* input */ + struct sprefinfo *spout; /* output */ + struct spref *srvout; /* one output component */ + int i, j; /* counters for hash table traversal */ + struct server *srvr; /* one of CM's server structs */ + struct srvAddr *sa; + int vlonly; /* just return vlservers ? */ + int isfs; + + AFS_STATCNT(PGetSPrefs); + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ + + + if (ainSize < sizeof(struct sprefrequest_33)) { + return ENOENT; + } else { + spin = ((struct sprefrequest *)ain); + } + + if (ainSize > sizeof(struct sprefrequest_33)) { + vlonly = (spin->flags & DBservers); + } else + vlonly = 0; + + /* struct sprefinfo includes 1 server struct... that size gets added + * in during the loop that follows. + */ + *aoutSize = sizeof(struct sprefinfo) - sizeof(struct spref); + spout = (struct sprefinfo *)aout; + spout->next_offset = spin->offset; + spout->num_servers = 0; + srvout = spout->servers; + + ObtainReadLock(&afs_xserver); + for (i = 0, j = 0; j < NSERVERS; j++) { /* sift through hash table */ + for (sa = afs_srvAddrs[j]; sa; sa = sa->next_bkt, i++) { + if (spin->offset > (unsigned short)i) { + continue; /* catch up to where we left off */ + } spout->next_offset++; srvr = sa->server; isfs = (srvr->cell && (sa->sa_portal == srvr->cell->fsport)) - || (sa->sa_portal == AFS_FSPORT); + || (sa->sa_portal == AFS_FSPORT); if ((vlonly && isfs) || (!vlonly && !isfs)) { - /* only report ranks for vl servers */ - continue; + /* only report ranks for vl servers */ + continue; } - srvout->host.s_addr = sa->sa_ip; - srvout->rank = sa->sa_iprank; - *aoutSize += sizeof(struct spref); - spout->num_servers++; - srvout++; + srvout->host.s_addr = sa->sa_ip; + srvout->rank = sa->sa_iprank; + *aoutSize += sizeof(struct spref); + spout->num_servers++; + srvout++; - if (*aoutSize > (PIGGYSIZE - sizeof(struct spref))) { - ReleaseReadLock(&afs_xserver); /* no more room! */ - return 0; - } - } - } - ReleaseReadLock(&afs_xserver); + if (*aoutSize > (PIGGYSIZE - sizeof(struct spref))) { + ReleaseReadLock(&afs_xserver); /* no more room! */ + return 0; + } + } + } + ReleaseReadLock(&afs_xserver); - spout->next_offset = 0; /* start over from the beginning next time */ - return 0; + spout->next_offset = 0; /* start over from the beginning next time */ + return 0; } /* Enable/Disable the specified exporter. Must be root to disable an exporter */ -int afs_NFSRootOnly = 1; +int afs_NFSRootOnly = 1; DECL_PIOCTL(PExportAfs) { - afs_int32 export, newint=0, type, changestate, handleValue, convmode, pwsync, smounts; + afs_int32 export, newint = + 0, type, changestate, handleValue, convmode, pwsync, smounts; register struct afs_exporter *exporter; AFS_STATCNT(PExportAfs); @@ -2935,7 +3027,7 @@ DECL_PIOCTL(PExportAfs) type = handleValue >> 24; if (type == 0x71) { newint = 1; - type = 1; /* nfs */ + type = 1; /* nfs */ } exporter = exporter_find(type); if (newint) { @@ -2961,7 +3053,7 @@ DECL_PIOCTL(PExportAfs) *aoutSize = sizeof(afs_int32); } else { if (!afs_osi_suser(*acred)) - return EACCES; /* Only superuser can do this */ + return EACCES; /* Only superuser can do this */ if (newint) { if (export & 2) { if (export & 1) @@ -3021,50 +3113,49 @@ DECL_PIOCTL(PExportAfs) DECL_PIOCTL(PGag) { -struct gaginfo *gagflags; + struct gaginfo *gagflags; - if (!afs_osi_suser(*acred)) - return EACCES; + if (!afs_osi_suser(*acred)) + return EACCES; - gagflags = (struct gaginfo *) ain; - afs_showflags = gagflags->showflags; + gagflags = (struct gaginfo *)ain; + afs_showflags = gagflags->showflags; - return 0; + return 0; } DECL_PIOCTL(PTwiddleRx) { - struct rxparams *rxp; - - if (!afs_osi_suser(*acred)) - return EACCES; - - rxp = (struct rxparams *) ain; - - if (rxp->rx_initReceiveWindow) - rx_initReceiveWindow = rxp->rx_initReceiveWindow; - if (rxp->rx_maxReceiveWindow) - rx_maxReceiveWindow = rxp->rx_maxReceiveWindow; - if (rxp->rx_initSendWindow) - rx_initSendWindow = rxp->rx_initSendWindow; - if (rxp->rx_maxSendWindow) - rx_maxSendWindow = rxp->rx_maxSendWindow; - if (rxp->rxi_nSendFrags) - rxi_nSendFrags = rxp->rxi_nSendFrags; - if (rxp->rxi_nRecvFrags) - rxi_nRecvFrags = rxp->rxi_nRecvFrags; - if (rxp->rxi_OrphanFragSize) - rxi_OrphanFragSize = rxp->rxi_OrphanFragSize; - if (rxp->rx_maxReceiveSize) - { - rx_maxReceiveSize = rxp->rx_maxReceiveSize; - rx_maxReceiveSizeUser = rxp->rx_maxReceiveSize; - } - if (rxp->rx_MyMaxSendSize) - rx_MyMaxSendSize = rxp->rx_MyMaxSendSize; - - return 0; + struct rxparams *rxp; + + if (!afs_osi_suser(*acred)) + return EACCES; + + rxp = (struct rxparams *)ain; + + if (rxp->rx_initReceiveWindow) + rx_initReceiveWindow = rxp->rx_initReceiveWindow; + if (rxp->rx_maxReceiveWindow) + rx_maxReceiveWindow = rxp->rx_maxReceiveWindow; + if (rxp->rx_initSendWindow) + rx_initSendWindow = rxp->rx_initSendWindow; + if (rxp->rx_maxSendWindow) + rx_maxSendWindow = rxp->rx_maxSendWindow; + if (rxp->rxi_nSendFrags) + rxi_nSendFrags = rxp->rxi_nSendFrags; + if (rxp->rxi_nRecvFrags) + rxi_nRecvFrags = rxp->rxi_nRecvFrags; + if (rxp->rxi_OrphanFragSize) + rxi_OrphanFragSize = rxp->rxi_OrphanFragSize; + if (rxp->rx_maxReceiveSize) { + rx_maxReceiveSize = rxp->rx_maxReceiveSize; + rx_maxReceiveSizeUser = rxp->rx_maxReceiveSize; + } + if (rxp->rx_MyMaxSendSize) + rx_MyMaxSendSize = rxp->rx_MyMaxSendSize; + + return 0; } DECL_PIOCTL(PGetInitParams) @@ -3072,18 +3163,19 @@ DECL_PIOCTL(PGetInitParams) if (sizeof(struct cm_initparams) > PIGGYSIZE) return E2BIG; - memcpy(aout, (char*)&cm_initParams, sizeof(struct cm_initparams)); + memcpy(aout, (char *)&cm_initParams, sizeof(struct cm_initparams)); *aoutSize = sizeof(struct cm_initparams); return 0; } #ifdef AFS_SGI65_ENV /* They took crget() from us, so fake it. */ -static cred_t *crget(void) +static cred_t * +crget(void) { cred_t *cr; cr = crdup(get_current_cred()); - memset((char*)cr, 0, sizeof(cred_t)); + memset((char *)cr, 0, sizeof(cred_t)); #if CELL || CELL_PREPARE cr->cr_id = -1; #endif @@ -3094,7 +3186,7 @@ static cred_t *crget(void) DECL_PIOCTL(PGetRxkcrypt) { memcpy(aout, (char *)&cryptall, sizeof(afs_int32)); - *aoutSize=sizeof(afs_int32); + *aoutSize = sizeof(afs_int32); return 0; } @@ -3103,13 +3195,13 @@ DECL_PIOCTL(PSetRxkcrypt) afs_int32 tmpval; if (!afs_osi_suser(*acred)) - return EPERM; + return EPERM; if (ainSize != sizeof(afs_int32) || ain == NULL) - return EINVAL; + return EINVAL; memcpy((char *)&tmpval, ain, sizeof(afs_int32)); /* if new mappings added later this will need to be changed */ if (tmpval != 0 && tmpval != 1) - return EINVAL; + return EINVAL; cryptall = tmpval; return 0; } @@ -3123,7 +3215,9 @@ DECL_PIOCTL(PSetRxkcrypt) */ #define PSETPAG 110 #define PIOCTL_HEADER 6 -static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCRED **acred, struct AFS_UCRED *credp) +static int +HandleClientContext(struct afs_ioctl *ablob, int *com, + struct AFS_UCRED **acred, struct AFS_UCRED *credp) { char *ain, *inData; afs_uint32 hostaddr; @@ -3136,29 +3230,29 @@ static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCR osi_Assert(ISAFS_GLOCK()); #endif AFS_STATCNT(HandleClientContext); - if (ablob->in_size < PIOCTL_HEADER*sizeof(afs_int32)) { + if (ablob->in_size < PIOCTL_HEADER * sizeof(afs_int32)) { /* Must at least include the PIOCTL_HEADER header words required by the protocol */ - return EINVAL; /* Too small to be good */ + return EINVAL; /* Too small to be good */ } ain = inData = osi_AllocLargeSpace(AFS_LRALLOCSIZ); - AFS_COPYIN(ablob->in, ain, PIOCTL_HEADER*sizeof(afs_int32), code); + AFS_COPYIN(ablob->in, ain, PIOCTL_HEADER * sizeof(afs_int32), code); if (code) { osi_FreeLargeSpace(inData); return code; } /* Extract information for remote user */ - hostaddr = *((afs_uint32 *)ain); + hostaddr = *((afs_uint32 *) ain); ain += sizeof(hostaddr); - uid = *((afs_uint32 *)ain); + uid = *((afs_uint32 *) ain); ain += sizeof(uid); - g0 = *((afs_uint32 *)ain); + g0 = *((afs_uint32 *) ain); ain += sizeof(g0); - g1 = *((afs_uint32 *)ain); + g1 = *((afs_uint32 *) ain); ain += sizeof(g1); - *com = *((afs_uint32 *)ain); + *com = *((afs_uint32 *) ain); ain += sizeof(afs_int32); - exporter_type = *((afs_uint32 *)ain); /* In case we support more than NFS */ + exporter_type = *((afs_uint32 *) ain); /* In case we support more than NFS */ /* * Of course, one must be root for most of these functions, but @@ -3174,21 +3268,21 @@ static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCR /* check for acceptable opcodes for normal folks, which are, so far, * set tokens and unlog. */ - if (i != 9 && i != 3 && i != 38 && i != 8) { + if (i != 9 && i != 3 && i != 38 && i != 8) { osi_FreeLargeSpace(inData); return EACCES; } } - ablob->in_size -= PIOCTL_HEADER*sizeof(afs_int32); - ablob->in += PIOCTL_HEADER*sizeof(afs_int32); + ablob->in_size -= PIOCTL_HEADER * sizeof(afs_int32); + ablob->in += PIOCTL_HEADER * sizeof(afs_int32); osi_FreeLargeSpace(inData); if (uid == 0) { - /* - * We map uid 0 to nobody to match the mapping that the nfs - * server does and to ensure that the suser() calls in the afs - * code fails for remote client roots. - */ + /* + * We map uid 0 to nobody to match the mapping that the nfs + * server does and to ensure that the suser() calls in the afs + * code fails for remote client roots. + */ uid = afs_nobody; /* NFS_NOBODY == -2 */ } newcred = crget(); @@ -3209,7 +3303,7 @@ static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCR #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) newcred->cr_ngroups = 2; #else - for (i=2; i < NGROUPS; i++) + for (i = 2; i < NGROUPS; i++) newcred->cr_groups[i] = NOGROUP; #endif #endif @@ -3218,8 +3312,8 @@ static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCR #endif if (!(exporter = exporter_find(exporter_type))) { /* Exporter wasn't initialized or an invalid exporter type */ - crfree(newcred); - return EINVAL; + crfree(newcred); + return EINVAL; } if (exporter->exp_states & EXP_PWSYNC) { if (uid != credp->cr_uid) { @@ -3227,7 +3321,7 @@ static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCR return ENOEXEC; /* XXX Find a better errno XXX */ } } - newcred->cr_uid = uid; /* Only temporary */ + newcred->cr_uid = uid; /* Only temporary */ code = EXP_REQHANDLER(exporter, &newcred, hostaddr, &pag, &outexporter); /* The client's pag is the only unique identifier for it */ newcred->cr_uid = pag; @@ -3236,17 +3330,19 @@ static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCR /* Special case for 'setpag' */ afs_uint32 pagvalue = genpag(); - au = afs_GetUser(pagvalue, -1, WRITE_LOCK); /* a new unixuser struct */ + au = afs_GetUser(pagvalue, -1, WRITE_LOCK); /* a new unixuser struct */ /* * Note that we leave the 'outexporter' struct held so it won't * dissappear on us */ au->exporter = outexporter; if (ablob->out_size >= 4) { - AFS_COPYOUT((char *)&pagvalue, ablob->out, sizeof(afs_int32), code); + AFS_COPYOUT((char *)&pagvalue, ablob->out, sizeof(afs_int32), + code); } afs_PutUser(au, WRITE_LOCK); - if (code) return code; + if (code) + return code; return PSETPAG; /* Special return for setpag */ } else if (!code) { EXP_RELE(outexporter); @@ -3259,73 +3355,73 @@ static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCR DECL_PIOCTL(PGetCPrefs) { - struct sprefrequest *spin; /* input */ - struct sprefinfo *spout; /* output */ - struct spref *srvout; /* one output component */ - int maxNumber; - int i,j; + struct sprefrequest *spin; /* input */ + struct sprefinfo *spout; /* output */ + struct spref *srvout; /* one output component */ + int maxNumber; + int i, j; - AFS_STATCNT(PGetCPrefs); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + AFS_STATCNT(PGetCPrefs); + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ - if ( ainSize < sizeof (struct sprefrequest )) - return EINVAL; + if (ainSize < sizeof(struct sprefrequest)) + return EINVAL; - spin = (struct sprefrequest *) ain; - spout = (struct sprefinfo *) aout; + spin = (struct sprefrequest *)ain; + spout = (struct sprefinfo *)aout; - maxNumber = spin->num_servers; /* max addrs this time */ - srvout = spout->servers; + maxNumber = spin->num_servers; /* max addrs this time */ + srvout = spout->servers; - ObtainReadLock(&afs_xinterface); + ObtainReadLock(&afs_xinterface); - /* copy out the client interface information from the - ** kernel data structure "interface" to the output buffer - */ - for ( i=spin->offset, j=0; (i < afs_cb_interface.numberOfInterfaces) - && ( j< maxNumber) ; i++, j++, srvout++) - srvout->host.s_addr = afs_cb_interface.addr_in[i]; + /* copy out the client interface information from the + ** kernel data structure "interface" to the output buffer + */ + for (i = spin->offset, j = 0; (i < afs_cb_interface.numberOfInterfaces) + && (j < maxNumber); i++, j++, srvout++) + srvout->host.s_addr = afs_cb_interface.addr_in[i]; - spout->num_servers = j; - *aoutSize = sizeof(struct sprefinfo) +(j-1)* sizeof (struct spref); + spout->num_servers = j; + *aoutSize = sizeof(struct sprefinfo) + (j - 1) * sizeof(struct spref); - if ( i >= afs_cb_interface.numberOfInterfaces ) - spout->next_offset = 0; /* start from beginning again */ - else - spout->next_offset = spin->offset + j; + if (i >= afs_cb_interface.numberOfInterfaces) + spout->next_offset = 0; /* start from beginning again */ + else + spout->next_offset = spin->offset + j; - ReleaseReadLock(&afs_xinterface); - return 0; + ReleaseReadLock(&afs_xinterface); + return 0; } DECL_PIOCTL(PSetCPrefs) { - struct setspref *sin; - int i; + struct setspref *sin; + int i; - AFS_STATCNT(PSetCPrefs); - if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */ - return EIO; /* Inappropriate ioctl for device */ + AFS_STATCNT(PSetCPrefs); + if (!afs_resourceinit_flag) /* afs daemons haven't started yet */ + return EIO; /* Inappropriate ioctl for device */ - sin = (struct setspref *)ain; + sin = (struct setspref *)ain; - if ( ainSize < sizeof(struct setspref) ) - return EINVAL; -#if 0 /* num_servers is unsigned */ - if ( sin->num_servers < 0 ) - return EINVAL; + if (ainSize < sizeof(struct setspref)) + return EINVAL; +#if 0 /* num_servers is unsigned */ + if (sin->num_servers < 0) + return EINVAL; #endif - if ( sin->num_servers > AFS_MAX_INTERFACE_ADDR) - return ENOMEM; + if (sin->num_servers > AFS_MAX_INTERFACE_ADDR) + return ENOMEM; - ObtainWriteLock(&afs_xinterface, 412); - afs_cb_interface.numberOfInterfaces = sin->num_servers; - for ( i=0; (unsigned short)i < sin->num_servers; i++) - afs_cb_interface.addr_in[i] = sin->servers[i].host.s_addr; + ObtainWriteLock(&afs_xinterface, 412); + afs_cb_interface.numberOfInterfaces = sin->num_servers; + for (i = 0; (unsigned short)i < sin->num_servers; i++) + afs_cb_interface.addr_in[i] = sin->servers[i].host.s_addr; - ReleaseWriteLock(&afs_xinterface); - return 0; + ReleaseWriteLock(&afs_xinterface); + return 0; } DECL_PIOCTL(PFlushMount) @@ -3339,21 +3435,24 @@ DECL_PIOCTL(PFlushMount) afs_size_t offset, len; AFS_STATCNT(PFlushMount); - if (!avc) return EINVAL; + if (!avc) + return EINVAL; code = afs_VerifyVCache(avc, areq); - if (code) return code; + if (code) + return code; if (vType(avc) != VDIR) { return ENOTDIR; } tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1); - if (!tdc) return ENOENT; + if (!tdc) + return ENOENT; Check_AtSys(avc, ain, &sysState, areq); ObtainReadLock(&tdc->lock); do { - code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid); + code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid); } while (code == ENOENT && Next_AtSys(avc, areq, &sysState)); ReleaseReadLock(&tdc->lock); - afs_PutDCache(tdc); /* we're done with the data */ + afs_PutDCache(tdc); /* we're done with the data */ bufp = sysState.name; if (code) { goto out; @@ -3377,17 +3476,17 @@ DECL_PIOCTL(PFlushMount) #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) afs_BozonLock(&tvc->pvnLock, tvc); /* Since afs_TryToSmush will do a pvn_vptrunc */ #endif - ObtainWriteLock(&tvc->lock,649); + ObtainWriteLock(&tvc->lock, 649); ObtainWriteLock(&afs_xcbhash, 650); afs_DequeueCallback(tvc); - tvc->states &= ~(CStatd | CDirty); /* next reference will re-stat cache entry */ + tvc->states &= ~(CStatd | CDirty); /* next reference will re-stat cache entry */ ReleaseWriteLock(&afs_xcbhash); /* now find the disk cache entries */ afs_TryToSmush(tvc, *acred, 1); osi_dnlc_purgedp(tvc); afs_symhint_inval(tvc); if (tvc->linkData && !(tvc->states & CCore)) { - afs_osi_Free(tvc->linkData, strlen(tvc->linkData)+1); + afs_osi_Free(tvc->linkData, strlen(tvc->linkData) + 1); tvc->linkData = NULL; } ReleaseWriteLock(&tvc->lock); @@ -3395,8 +3494,9 @@ DECL_PIOCTL(PFlushMount) afs_BozonUnlock(&tvc->pvnLock, tvc); #endif afs_PutVCache(tvc); -out: - if (sysState.allocked) osi_FreeLargeSpace(bufp); + out: + if (sysState.allocked) + osi_FreeLargeSpace(bufp); return code; } @@ -3427,7 +3527,7 @@ DECL_PIOCTL(PRxStatProc) if (flags & AFSCALL_RXSTATS_CLEAR) { rx_clearProcessRPCStats(AFS_RX_STATS_CLEAR_ALL); } -out: + out: *aoutSize = 0; return code; } @@ -3460,7 +3560,7 @@ DECL_PIOCTL(PRxStatPeer) if (flags & AFSCALL_RXSTATS_CLEAR) { rx_clearPeerRPCStats(AFS_RX_STATS_CLEAR_ALL); } -out: + out: *aoutSize = 0; return code; } @@ -3480,12 +3580,12 @@ DECL_PIOCTL(PPrefetchFromTape) AFS_STATCNT(PSetAcl); if (!avc) - return EINVAL; + return EINVAL; if (ain && (ainSize == 3 * sizeof(afs_int32))) - Fid = (struct AFSFid *) ain; + Fid = (struct AFSFid *)ain; else - Fid = &avc->fid.Fid; + Fid = &avc->fid.Fid; tfid.Cell = avc->fid.Cell; tfid.Fid.Volume = Fid->Volume; tfid.Fid.Vnode = Fid->Vnode; @@ -3493,43 +3593,40 @@ DECL_PIOCTL(PPrefetchFromTape) tvc = afs_GetVCache(&tfid, areq, NULL, NULL); if (!tvc) { - afs_Trace3(afs_iclSetp, CM_TRACE_PREFETCHCMD, - ICL_TYPE_POINTER, tvc, - ICL_TYPE_FID, &tfid, - ICL_TYPE_FID, &avc->fid); - return ENOENT; + afs_Trace3(afs_iclSetp, CM_TRACE_PREFETCHCMD, ICL_TYPE_POINTER, tvc, + ICL_TYPE_FID, &tfid, ICL_TYPE_FID, &avc->fid); + return ENOENT; } - afs_Trace3(afs_iclSetp, CM_TRACE_PREFETCHCMD, - ICL_TYPE_POINTER, tvc, - ICL_TYPE_FID, &tfid, - ICL_TYPE_FID, &tvc->fid); + afs_Trace3(afs_iclSetp, CM_TRACE_PREFETCHCMD, ICL_TYPE_POINTER, tvc, + ICL_TYPE_FID, &tfid, ICL_TYPE_FID, &tvc->fid); do { - tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK); - if (tc) { - - RX_AFS_GUNLOCK(); - tcall = rx_NewCall(tc->id); - code = StartRXAFS_FetchData(tcall, - (struct AFSFid *) &tvc->fid.Fid, 0, 0); - if (!code) { - bytes = rx_Read(tcall, (char *) aout, sizeof(afs_int32)); - code = EndRXAFS_FetchData(tcall, &OutStatus, &CallBack, &tsync); - } - code1 = rx_EndCall(tcall, code); - RX_AFS_GLOCK(); - } else - code = -1; - } while - (afs_Analyze(tc, code, &tvc->fid, areq, - AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, SHARED_LOCK, - NULL)); + tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK); + if (tc) { + + RX_AFS_GUNLOCK(); + tcall = rx_NewCall(tc->id); + code = + StartRXAFS_FetchData(tcall, (struct AFSFid *)&tvc->fid.Fid, 0, + 0); + if (!code) { + bytes = rx_Read(tcall, (char *)aout, sizeof(afs_int32)); + code = + EndRXAFS_FetchData(tcall, &OutStatus, &CallBack, &tsync); + } + code1 = rx_EndCall(tcall, code); + RX_AFS_GLOCK(); + } else + code = -1; + } while (afs_Analyze + (tc, code, &tvc->fid, areq, AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, + SHARED_LOCK, NULL)); /* This call is done only to have the callback things handled correctly */ afs_FetchStatus(tvc, &tfid, areq, &OutStatus); afs_PutVCache(tvc); if (!code) { - *aoutSize = sizeof(afs_int32); + *aoutSize = sizeof(afs_int32); } return code; } @@ -3544,14 +3641,16 @@ DECL_PIOCTL(PResidencyCmd) struct VenusFid tfid; struct AFSFid *Fid; - Inputs = (struct ResidencyCmdInputs *) ain; - Outputs = (struct ResidencyCmdOutputs *) aout; - if (!avc) return EINVAL; - if (!ain || ainSize != sizeof(struct ResidencyCmdInputs)) return EINVAL; + Inputs = (struct ResidencyCmdInputs *)ain; + Outputs = (struct ResidencyCmdOutputs *)aout; + if (!avc) + return EINVAL; + if (!ain || ainSize != sizeof(struct ResidencyCmdInputs)) + return EINVAL; Fid = &Inputs->fid; if (!Fid->Volume) - Fid = &avc->fid.Fid; + Fid = &avc->fid.Fid; tfid.Cell = avc->fid.Cell; tfid.Fid.Volume = Fid->Volume; @@ -3559,46 +3658,43 @@ DECL_PIOCTL(PResidencyCmd) tfid.Fid.Unique = Fid->Unique; tvc = afs_GetVCache(&tfid, areq, NULL, NULL); - afs_Trace3(afs_iclSetp, CM_TRACE_RESIDCMD, - ICL_TYPE_POINTER, tvc, - ICL_TYPE_INT32, Inputs->command, - ICL_TYPE_FID, &tfid); + afs_Trace3(afs_iclSetp, CM_TRACE_RESIDCMD, ICL_TYPE_POINTER, tvc, + ICL_TYPE_INT32, Inputs->command, ICL_TYPE_FID, &tfid); if (!tvc) - return ENOENT; + return ENOENT; if (Inputs->command) { - do { - tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK); - if (tc) { - RX_AFS_GUNLOCK(); - code = RXAFS_ResidencyCmd(tc->id, Fid, - Inputs, - (struct ResidencyCmdOutputs *) aout); - RX_AFS_GLOCK(); - } else - code = -1; - } while - (afs_Analyze(tc, code, &tvc->fid, areq, - AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, SHARED_LOCK, - NULL)); - /* This call is done to have the callback things handled correctly */ - afs_FetchStatus(tvc, &tfid, areq, &Outputs->status); - } else { /* just a status request, return also link data */ - code = 0; - Outputs->code = afs_FetchStatus(tvc, &tfid, areq, &Outputs->status); - Outputs->chars[0] = 0; - if (vType(tvc) == VLNK) { - ObtainWriteLock(&tvc->lock,555); - if (afs_HandleLink(tvc, areq) == 0) - strncpy((char *) &Outputs->chars, tvc->linkData, MAXCMDCHARS); - ReleaseWriteLock(&tvc->lock); - } + do { + tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK); + if (tc) { + RX_AFS_GUNLOCK(); + code = + RXAFS_ResidencyCmd(tc->id, Fid, Inputs, + (struct ResidencyCmdOutputs *)aout); + RX_AFS_GLOCK(); + } else + code = -1; + } while (afs_Analyze + (tc, code, &tvc->fid, areq, + AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, SHARED_LOCK, NULL)); + /* This call is done to have the callback things handled correctly */ + afs_FetchStatus(tvc, &tfid, areq, &Outputs->status); + } else { /* just a status request, return also link data */ + code = 0; + Outputs->code = afs_FetchStatus(tvc, &tfid, areq, &Outputs->status); + Outputs->chars[0] = 0; + if (vType(tvc) == VLNK) { + ObtainWriteLock(&tvc->lock, 555); + if (afs_HandleLink(tvc, areq) == 0) + strncpy((char *)&Outputs->chars, tvc->linkData, MAXCMDCHARS); + ReleaseWriteLock(&tvc->lock); + } } afs_PutVCache(tvc); if (!code) { - *aoutSize = sizeof(struct ResidencyCmdOutputs); + *aoutSize = sizeof(struct ResidencyCmdOutputs); } return code; } diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 60b81bbcf..7a9fd727e 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -14,27 +14,29 @@ extern void init_et_to_sys_error(void); extern void afs_FinalizeReq(struct vrequest *areq); extern int afs_Analyze(register struct conn *aconn, afs_int32 acode, - struct VenusFid *afid, register struct vrequest *areq, int op, - afs_int32 locktype, struct cell *cellp); + struct VenusFid *afid, register struct vrequest *areq, + int op, afs_int32 locktype, struct cell *cellp); extern int afs_CheckCode(afs_int32 acode, struct vrequest *areq, int where); -extern void afs_CopyError(register struct vrequest *afrom, register struct vrequest *ato); +extern void afs_CopyError(register struct vrequest *afrom, + register struct vrequest *ato); extern void init_sys_error_to_et(void); /* afs_axscache.c */ extern afs_rwlock_t afs_xaxs; -extern struct axscache *afs_SlowFindAxs(struct axscache **cachep, afs_int32 id); +extern struct axscache *afs_SlowFindAxs(struct axscache **cachep, + afs_int32 id); extern struct axscache *axs_Alloc(void); extern void afs_RemoveAxs(struct axscache **headp, struct axscache *axsp); extern void afs_FreeAllAxs(struct axscache **headp); /* afs_buffer.c */ -extern void DInit (int abuffers); -extern char *DRead(register afs_inode_t *fid, register int page); -extern void DRelease (register struct buffer *bp, int flag); -extern int DVOffset (register void *ap); -extern void DZap (afs_inode_t *fid); -extern void DFlush (void); -extern char *DNew (register afs_inode_t *fid, register int page); +extern void DInit(int abuffers); +extern char *DRead(register afs_inode_t * fid, register int page); +extern void DRelease(register struct buffer *bp, int flag); +extern int DVOffset(register void *ap); +extern void DZap(afs_inode_t * fid); +extern void DFlush(void); +extern char *DNew(register afs_inode_t * fid, register int page); extern void shutdown_bufferpackage(void); /* afs_call.c */ @@ -44,35 +46,53 @@ extern char afs_rootVolumeName[64]; extern void afs_shutdown(void); extern void afs_FlushCBs(void); extern struct afs_icl_set *afs_icl_allSets; -extern int afs_icl_CreateLog(char *name, afs_int32 logSize, struct afs_icl_log **outLogpp); -extern int afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags, - struct afs_icl_log **outLogpp); -extern int afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 *bufferp, - afs_int32 *bufSizep, afs_uint32 *cookiep, afs_int32 *flagsp); -extern int afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 *maxSizep, - afs_int32 *curSizep); +extern int afs_icl_CreateLog(char *name, afs_int32 logSize, + struct afs_icl_log **outLogpp); +extern int afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, + afs_uint32 flags, + struct afs_icl_log **outLogpp); +extern int afs_icl_CopyOut(register struct afs_icl_log *logp, + afs_int32 * bufferp, afs_int32 * bufSizep, + afs_uint32 * cookiep, afs_int32 * flagsp); +extern int afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 * maxSizep, + afs_int32 * curSizep); extern int afs_icl_LogHold(register struct afs_icl_log *logp); extern int afs_icl_LogHoldNL(register struct afs_icl_log *logp); extern int afs_icl_LogUse(register struct afs_icl_log *logp); extern int afs_icl_LogFreeUse(register struct afs_icl_log *logp); -extern int afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize); +extern int afs_icl_LogSetSize(register struct afs_icl_log *logp, + afs_int32 logSize); extern int afs_icl_ZapLog(register struct afs_icl_log *logp); extern int afs_icl_LogRele(register struct afs_icl_log *logp); extern int afs_icl_LogReleNL(register struct afs_icl_log *logp); extern int afs_icl_ZeroLog(register struct afs_icl_log *logp); extern int afs_icl_LogFree(register struct afs_icl_log *logp); extern struct afs_icl_log *afs_icl_FindLog(char *name); -extern int afs_icl_EnumerateLogs(int (*aproc)(char *name,char *arock,struct afs_icl_log *tp), char *arock); -extern int afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp, - struct afs_icl_log *fatalLogp, struct afs_icl_set **outSetpp); -extern int afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp, - struct afs_icl_log *fatalLogp, afs_uint32 flags, struct afs_icl_set **outSetpp); -extern int afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue); -extern int afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, - int *getValuep); +extern int + afs_icl_EnumerateLogs(int (*aproc) + + (char *name, char *arock, struct afs_icl_log * tp), + char *arock); +extern int afs_icl_CreateSet(char *name, struct afs_icl_log *baseLogp, + struct afs_icl_log *fatalLogp, + struct afs_icl_set **outSetpp); +extern int afs_icl_CreateSetWithFlags(char *name, + struct afs_icl_log *baseLogp, + struct afs_icl_log *fatalLogp, + afs_uint32 flags, + struct afs_icl_set **outSetpp); +extern int afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, + int setValue); +extern int afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, + int *getValuep); extern int afs_icl_ZeroSet(struct afs_icl_set *setp); -extern int afs_icl_EnumerateSets(int (*aproc)(char *name,char *arock,struct afs_icl_log *tp), char *arock); -extern int afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp); +extern int + afs_icl_EnumerateSets(int (*aproc) + + (char *name, char *arock, struct afs_icl_log * tp), + char *arock); +extern int afs_icl_AddLogToSet(struct afs_icl_set *setp, + struct afs_icl_log *newlogp); extern int afs_icl_SetSetStat(struct afs_icl_set *setp, int op); extern int afs_icl_SetHold(register struct afs_icl_set *setp); extern int afs_icl_ZapSet(register struct afs_icl_set *setp); @@ -80,18 +100,22 @@ extern int afs_icl_SetRele(register struct afs_icl_set *setp); extern int afs_icl_SetFree(register struct afs_icl_set *setp); extern struct afs_icl_set *afs_icl_FindSet(char *name); -extern int afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT, long p1, long p2, long p3, long p4); -extern int afs_icl_Event3(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT, long p1, long p2, long p3); -extern int afs_icl_Event2(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT, long p1, long p2); -extern int afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT, long p1); -extern int afs_icl_Event0(register struct afs_icl_set *setp, afs_int32 eventID, - afs_int32 lAndT); -extern void afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op, - afs_int32 types, long p1, long p2, long p3, long p4); +extern int afs_icl_Event4(register struct afs_icl_set *setp, + afs_int32 eventID, afs_int32 lAndT, long p1, + long p2, long p3, long p4); +extern int afs_icl_Event3(register struct afs_icl_set *setp, + afs_int32 eventID, afs_int32 lAndT, long p1, + long p2, long p3); +extern int afs_icl_Event2(register struct afs_icl_set *setp, + afs_int32 eventID, afs_int32 lAndT, long p1, + long p2); +extern int afs_icl_Event1(register struct afs_icl_set *setp, + afs_int32 eventID, afs_int32 lAndT, long p1); +extern int afs_icl_Event0(register struct afs_icl_set *setp, + afs_int32 eventID, afs_int32 lAndT); +extern void afs_icl_AppendRecord(register struct afs_icl_log *logp, + afs_int32 op, afs_int32 types, long p1, + long p2, long p3, long p4); extern int afs_CheckInit(void); extern void afs_shutdown(void); @@ -113,38 +137,56 @@ extern osi_timeval_t lastCallBack_time; extern struct interfaceAddr afs_cb_interface; extern int afs_RXCallBackServer(void); -extern int SRXAFSCB_GetCE(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCacheEntry *a_result); -extern int SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index, struct AFSDBCacheEntry64 *a_result); -extern int SRXAFSCB_GetLock (struct rx_call *a_call, afs_int32 a_index, struct AFSDBLock *a_result); -extern int SRXAFSCB_CallBack(struct rx_call *a_call, register struct AFSCBFids *a_fids, struct AFSCBs *a_callbacks); +extern int SRXAFSCB_GetCE(struct rx_call *a_call, afs_int32 a_index, + struct AFSDBCacheEntry *a_result); +extern int SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index, + struct AFSDBCacheEntry64 *a_result); +extern int SRXAFSCB_GetLock(struct rx_call *a_call, afs_int32 a_index, + struct AFSDBLock *a_result); +extern int SRXAFSCB_CallBack(struct rx_call *a_call, + register struct AFSCBFids *a_fids, + struct AFSCBs *a_callbacks); extern int SRXAFSCB_Probe(struct rx_call *a_call); extern int SRXAFSCB_InitCallBackState(struct rx_call *a_call); -extern int SRXAFSCB_XStatsVersion(struct rx_call *a_call, afs_int32 *a_versionP); -extern int SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum, - afs_int32 a_collectionNumber, afs_int32 *a_srvVersionNumP, - afs_int32 *a_timeP, AFSCB_CollData *a_dataP); +extern int SRXAFSCB_XStatsVersion(struct rx_call *a_call, + afs_int32 * a_versionP); +extern int SRXAFSCB_GetXStats(struct rx_call *a_call, + afs_int32 a_clientVersionNum, + afs_int32 a_collectionNumber, + afs_int32 * a_srvVersionNumP, + afs_int32 * a_timeP, AFSCB_CollData * a_dataP); extern int afs_RXCallBackServer(void); -extern int shutdown_CB(void) ; -extern int SRXAFSCB_InitCallBackState2(struct rx_call *a_call, struct interfaceAddr *addr); -extern int SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr); -extern int SRXAFSCB_InitCallBackState3(struct rx_call *a_call, afsUUID *a_uuid); -extern int SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID *a_uuid); +extern int shutdown_CB(void); +extern int SRXAFSCB_InitCallBackState2(struct rx_call *a_call, + struct interfaceAddr *addr); +extern int SRXAFSCB_WhoAreYou(struct rx_call *a_call, + struct interfaceAddr *addr); +extern int SRXAFSCB_InitCallBackState3(struct rx_call *a_call, + afsUUID * a_uuid); +extern int SRXAFSCB_ProbeUuid(struct rx_call *a_call, afsUUID * a_uuid); extern int SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index, - afs_int32 *a_srvr_addr, afs_int32 *a_srvr_rank); + afs_int32 * a_srvr_addr, + afs_int32 * a_srvr_rank); extern int SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index, - char **a_name, serverList *a_hosts); + char **a_name, serverList * a_hosts); extern int SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name); -extern int SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion, - afs_uint32 *serverVersion, afs_uint32 *configCount, cacheConfig *config); -extern int SRXAFSCB_FetchData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd, - afs_int64 Position, afs_int64 Length, afs_int64 *TotalLength); -extern int SRXAFSCB_StoreData(struct rx_call *rxcall, struct AFSFid *Fid, afs_int32 Fd, - afs_int64 Position, afs_int64 Length, afs_int64 *TotalLength); +extern int SRXAFSCB_GetCacheConfig(struct rx_call *a_call, + afs_uint32 callerVersion, + afs_uint32 * serverVersion, + afs_uint32 * configCount, + cacheConfig * config); +extern int SRXAFSCB_FetchData(struct rx_call *rxcall, struct AFSFid *Fid, + afs_int32 Fd, afs_int64 Position, + afs_int64 Length, afs_int64 * TotalLength); +extern int SRXAFSCB_StoreData(struct rx_call *rxcall, struct AFSFid *Fid, + afs_int32 Fd, afs_int64 Position, + afs_int64 Length, afs_int64 * TotalLength); /* afs_cbqueue.c */ extern afs_rwlock_t afs_xcbhash; -extern void afs_QueueCallback(struct vcache *avc, unsigned int atime, struct volume *avp); +extern void afs_QueueCallback(struct vcache *avc, unsigned int atime, + struct volume *avp); extern void afs_CheckCallbacks(unsigned int secs); extern void afs_FlushCBs(void); extern void afs_FlushServerCBs(struct server *srvp); @@ -158,9 +200,9 @@ extern void afs_CellInit(void); extern void shutdown_cell(void); extern int afs_cellname_init(ino_t inode, int lookupcode); extern int afs_cellname_write(void); -extern afs_int32 afs_NewCell(char *acellName, afs_int32 *acellHosts, - int aflags, char *linkedcname, u_short fsport, u_short vlport, - int timeout); +extern afs_int32 afs_NewCell(char *acellName, afs_int32 * acellHosts, + int aflags, char *linkedcname, u_short fsport, + u_short vlport, int timeout); extern afs_int32 afs_SetPrimaryCell(char *acellName); extern struct cell *afs_GetCell(afs_int32 acell, afs_int32 locktype); extern struct cell *afs_GetCellStale(afs_int32 acell, afs_int32 locktype); @@ -169,14 +211,15 @@ extern struct cell *afs_GetCellByName(char *acellName, afs_int32 locktype); extern struct cell *afs_GetPrimaryCell(afs_int32 locktype); extern int afs_IsPrimaryCellNum(afs_int32 cellnum); extern int afs_IsPrimaryCell(struct cell *cell); -extern void *afs_TraverseCells(void *(*cb)(struct cell *, void *), void *arg); +extern void *afs_TraverseCells(void *(*cb) (struct cell *, void *), + void *arg); extern int afs_CellOrAliasExists(char *aname); extern int afs_CellNumValid(afs_int32 cellnum); extern afs_int32 afs_NewCellAlias(char *alias, char *cell); extern struct cell_alias *afs_GetCellAlias(int index); extern void afs_PutCellAlias(struct cell_alias *a); extern int afs_AFSDBHandler(char *acellName, int acellNameLen, - afs_int32 *kernelMsg); + afs_int32 * kernelMsg); extern void afs_LookupAFSDB(char *acellName); extern void afs_StopAFSDB(void); extern void afs_RemoveCellEntry(struct server *srvp); @@ -196,14 +239,20 @@ extern afs_int32 cryptall; extern afs_rwlock_t afs_xinterface; extern afs_rwlock_t afs_xconn; extern struct conn *afs_Conn(register struct VenusFid *afid, - register struct vrequest *areq, afs_int32 locktype); + register struct vrequest *areq, + afs_int32 locktype); extern struct conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, - afs_int32 acell, struct unixuser *tu, - int force_if_down, afs_int32 create, afs_int32 locktype); -extern struct conn *afs_ConnByMHosts(struct server *ahosts[], unsigned short aport, - afs_int32 acell, register struct vrequest *areq, afs_int32 locktype); -extern struct conn *afs_ConnByHost(struct server *aserver, unsigned short aport, - afs_int32 acell, struct vrequest *areq, int aforce, afs_int32 locktype); + afs_int32 acell, struct unixuser *tu, + int force_if_down, afs_int32 create, + afs_int32 locktype); +extern struct conn *afs_ConnByMHosts(struct server *ahosts[], + unsigned short aport, afs_int32 acell, + register struct vrequest *areq, + afs_int32 locktype); +extern struct conn *afs_ConnByHost(struct server *aserver, + unsigned short aport, afs_int32 acell, + struct vrequest *areq, int aforce, + afs_int32 locktype); extern void afs_PutConn(register struct conn *ac, afs_int32 locktype); extern void ForceNewConnections(struct srvAddr *sap); @@ -220,14 +269,17 @@ extern afs_int32 afs_CheckServerDaemonStarted; extern afs_int32 PROBE_INTERVAL; extern void afs_Daemon(void); -extern struct brequest *afs_BQueue(register short aopcode, register struct vcache *avc, - afs_int32 dontwait, afs_int32 ause, struct AFS_UCRED *acred, - afs_size_t asparm0, afs_size_t asparm1, void *apparm0); +extern struct brequest *afs_BQueue(register short aopcode, + register struct vcache *avc, + afs_int32 dontwait, afs_int32 ause, + struct AFS_UCRED *acred, + afs_size_t asparm0, afs_size_t asparm1, + void *apparm0); extern void afs_CheckServerDaemon(void); -extern int afs_CheckRootVolume (void); +extern int afs_CheckRootVolume(void); extern void afs_BRelease(register struct brequest *ab); extern int afs_BBusy(void); -extern int afs_BioDaemon (afs_int32 nbiods); +extern int afs_BioDaemon(afs_int32 nbiods); extern void afs_BackgroundDaemon(void); extern void shutdown_daemons(void); extern int afs_sgidaemon(void); @@ -254,23 +306,31 @@ extern void afs_FlushDCache(register struct dcache *adc); extern void shutdown_dcache(void); extern void afs_CacheTruncateDaemon(void); extern afs_int32 afs_fsfragsize; -extern struct dcache *afs_MemGetDSlot(register afs_int32 aslot, register struct dcache *tmpdc); -extern struct dcache *afs_GetDCache(register struct vcache *avc, afs_size_t abyte, - register struct vrequest *areq, afs_size_t *aoffset, afs_size_t *alen, - int aflags); -extern struct dcache *afs_FindDCache(register struct vcache *avc, afs_size_t abyte); -extern void afs_StoreWarn(register afs_int32 acode, afs_int32 avolume, register afs_int32 aflags); +extern struct dcache *afs_MemGetDSlot(register afs_int32 aslot, + register struct dcache *tmpdc); +extern struct dcache *afs_GetDCache(register struct vcache *avc, + afs_size_t abyte, + register struct vrequest *areq, + afs_size_t * aoffset, afs_size_t * alen, + int aflags); +extern struct dcache *afs_FindDCache(register struct vcache *avc, + afs_size_t abyte); +extern void afs_StoreWarn(register afs_int32 acode, afs_int32 avolume, + register afs_int32 aflags); extern void afs_MaybeWakeupTruncateDaemon(void); extern void afs_CacheTruncateDaemon(void); -extern void afs_AdjustSize(register struct dcache *adc, register afs_int32 newSize); +extern void afs_AdjustSize(register struct dcache *adc, + register afs_int32 newSize); extern int afs_HashOutDCache(struct dcache *adc); extern int afs_MaybeFreeDiscardedDCache(void); extern int afs_RefDCache(struct dcache *adc); -extern void afs_TryToSmush(register struct vcache *avc, struct AFS_UCRED *acred, - int sync); -extern void updateV2DC(int lockVc, struct vcache *v, struct dcache *d, int src); +extern void afs_TryToSmush(register struct vcache *avc, + struct AFS_UCRED *acred, int sync); +extern void updateV2DC(int lockVc, struct vcache *v, struct dcache *d, + int src); extern void afs_WriteThroughDSlots(void); -extern struct dcache *afs_UFSGetDSlot(register afs_int32 aslot, register struct dcache *tmpdc); +extern struct dcache *afs_UFSGetDSlot(register afs_int32 aslot, + register struct dcache *tmpdc); extern int afs_WriteDCache(register struct dcache *adc, int atime); extern int afs_wakeup(register struct vcache *avc); extern int afs_InitCacheFile(char *afile, ino_t ainode); @@ -282,16 +342,16 @@ extern void afs_GetDynrootFid(struct VenusFid *fid); extern int afs_IsDynroot(struct vcache *avc); extern void afs_DynrootInvalidate(void); extern void afs_GetDynroot(char **dynrootDir, int *dynrootLen, - struct AFSFetchStatus *status); + struct AFSFetchStatus *status); extern void afs_PutDynroot(void); extern int afs_DynrootNewVnode(struct vcache *avc, - struct AFSFetchStatus *status); + struct AFSFetchStatus *status); extern int afs_SetDynrootEnable(int enable); extern int afs_GetDynrootEnable(void); extern int afs_DynrootVOPRemove(struct vcache *avc, struct AFS_UCRED *acred, - char *aname); -extern int afs_DynrootVOPSymlink(struct vcache *avc, struct AFS_UCRED *acred, - char *aname, char *atargetName); + char *aname); +extern int afs_DynrootVOPSymlink(struct vcache *avc, struct AFS_UCRED *acred, + char *aname, char *atargetName); /* afs_exporter.c */ extern struct afs_exporter *root_exported; @@ -305,9 +365,11 @@ extern char *afs_sysname; extern char *afs_sysnamelist[MAXNUMSYSNAMES]; extern int afs_sysnamecount; extern afs_int32 cacheInfoModTime; -extern int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 - ablocks, afs_int32 aDentries, afs_int32 aVolumes, afs_int32 achunk, - afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers); +extern int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, + afs_int32 ablocks, afs_int32 aDentries, + afs_int32 aVolumes, afs_int32 achunk, + afs_int32 aflags, afs_int32 ninodes, + afs_int32 nusers); extern void afs_ComputeCacheParms(void); extern int afs_InitCacheInfo(register char *afile); extern int afs_InitVolumeInfo(char *afile); @@ -319,16 +381,20 @@ extern void shutdown_AFS(void); /* afs_lock.c */ extern void Lock_Init(register struct afs_lock *lock); -extern void ObtainLock(register struct afs_lock *lock, int how, - unsigned int src_indicator); +extern void ObtainLock(register struct afs_lock *lock, int how, + unsigned int src_indicator); extern void ReleaseLock(register struct afs_lock *lock, int how); -extern int Afs_Lock_Trace(int op, struct afs_lock *alock, int type, char *file, int line); +extern int Afs_Lock_Trace(int op, struct afs_lock *alock, int type, + char *file, int line); extern void Afs_Lock_Obtain(register struct afs_lock *lock, int how); extern void Afs_Lock_ReleaseR(register struct afs_lock *lock); extern void Afs_Lock_ReleaseW(register struct afs_lock *lock); -extern void afs_osi_SleepR(register char *addr, register struct afs_lock *alock); -extern void afs_osi_SleepW(register char *addr, register struct afs_lock *alock); -extern void afs_osi_SleepS(register char *addr, register struct afs_lock *alock); +extern void afs_osi_SleepR(register char *addr, + register struct afs_lock *alock); +extern void afs_osi_SleepW(register char *addr, + register struct afs_lock *alock); +extern void afs_osi_SleepS(register char *addr, + register struct afs_lock *alock); #ifndef AFS_NOBOZO_LOCK extern void afs_BozonLock(struct afs_bozoLock *alock, struct vcache *avc); extern void afs_BozonUnlock(struct afs_bozoLock *alock, struct vcache *avc); @@ -344,11 +410,15 @@ extern int afs_CheckBozonLockBlocking(struct afs_bozoLock *alock); extern afs_int32 afs_mariner; extern afs_int32 afs_marinerHost; extern struct rx_service *afs_server; -extern int afs_AddMarinerName(register char *aname, register struct vcache *avc); +extern int afs_AddMarinerName(register char *aname, + register struct vcache *avc); extern char *afs_GetMariner(register struct vcache *avc); -extern void afs_MarinerLogFetch(register struct vcache *avc, register afs_int32 off, - register afs_int32 bytes, register afs_int32 idx); -extern void afs_MarinerLog(register char *astring, register struct vcache *avc); +extern void afs_MarinerLogFetch(register struct vcache *avc, + register afs_int32 off, + register afs_int32 bytes, + register afs_int32 idx); +extern void afs_MarinerLog(register char *astring, + register struct vcache *avc); extern void shutdown_mariner(void); @@ -356,19 +426,31 @@ extern void shutdown_mariner(void); extern int afs_InitMemCache(int blkCount, int blkSize, int flags); extern int afs_MemCacheClose(char *file); extern void *afs_MemCacheOpen(ino_t blkno); -extern int afs_MemReadBlk(register struct memCacheEntry *mceP, int offset, char *dest, int size); -extern int afs_MemReadvBlk(register struct memCacheEntry *mceP, int offset, struct iovec *iov, int nio, int size); +extern int afs_MemReadBlk(register struct memCacheEntry *mceP, int offset, + char *dest, int size); +extern int afs_MemReadvBlk(register struct memCacheEntry *mceP, int offset, + struct iovec *iov, int nio, int size); extern int afs_MemReadUIO(ino_t blkno, struct uio *uioP); -extern int afs_MemWriteBlk(register struct memCacheEntry *mceP, int offset, char *src, int size); -extern int afs_MemWritevBlk(register struct memCacheEntry *mceP, int offset, struct iovec *iov, int nio, int size); +extern int afs_MemWriteBlk(register struct memCacheEntry *mceP, int offset, + char *src, int size); +extern int afs_MemWritevBlk(register struct memCacheEntry *mceP, int offset, + struct iovec *iov, int nio, int size); extern int afs_MemWriteUIO(ino_t blkno, struct uio *uioP); -extern int afs_MemCacheTruncate(register struct memCacheEntry *mceP, int size); -extern int afs_MemCacheStoreProc(register struct rx_call *acall, register struct memCacheEntry *mceP, - register afs_int32 alen, struct vcache *avc, int *shouldWake, afs_size_t *abytesToXferP, - afs_size_t *abytesXferredP, afs_int32 length); -extern int afs_MemCacheFetchProc(register struct rx_call *acall, register struct memCacheEntry *mceP, - afs_size_t abase, struct dcache *adc, struct vcache *avc, afs_size_t *abytesToXferP, - afs_size_t *abytesXferredP, afs_int32 lengthFound); +extern int afs_MemCacheTruncate(register struct memCacheEntry *mceP, + int size); +extern int afs_MemCacheStoreProc(register struct rx_call *acall, + register struct memCacheEntry *mceP, + register afs_int32 alen, struct vcache *avc, + int *shouldWake, afs_size_t * abytesToXferP, + afs_size_t * abytesXferredP, + afs_int32 length); +extern int afs_MemCacheFetchProc(register struct rx_call *acall, + register struct memCacheEntry *mceP, + afs_size_t abase, struct dcache *adc, + struct vcache *avc, + afs_size_t * abytesToXferP, + afs_size_t * abytesXferredP, + afs_int32 lengthFound); extern void shutdown_memcache(void); @@ -388,7 +470,8 @@ extern void afs_osi_Free(void *x, size_t asize); extern void afs_osi_FreeStr(char *x); extern void osi_Init(void); extern int osi_Active(register struct vcache *avc); -extern void osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp); +extern void osi_FlushPages(register struct vcache *avc, + struct AFS_UCRED *credp); extern void osi_FlushText_really(register struct vcache *vp); extern void afs_osi_MaskSignals(void); extern void afs_osi_UnmaskRxkSignals(void); @@ -402,7 +485,7 @@ extern void shutdown_osi(void); extern int afs_osi_suser(void *credp); extern void afs_osi_TraverseProcTable(void); #if defined(KERNEL) && !defined(UKERNEL) && defined(AFS_PROC) -extern const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC *pr); +extern const struct AFS_UCRED *afs_osi_proc2cred(AFS_PROC * pr); #endif /* afs_osi_pag.c */ @@ -416,7 +499,7 @@ extern int AddPag(afs_int32 aval, struct AFS_UCRED **credpp); #endif extern int afs_InitReq(register struct vrequest *av, struct AFS_UCRED *acred); extern afs_uint32 afs_get_pag_from_groups(gid_t g0a, gid_t g1a); -extern void afs_get_groups_from_pag(afs_uint32 pag, gid_t *g0p, gid_t *g1p); +extern void afs_get_groups_from_pag(afs_uint32 pag, gid_t * g0p, gid_t * g1p); extern afs_int32 PagInCred(const struct AFS_UCRED *cred); /* afs_osi_alloc.c */ @@ -430,11 +513,13 @@ extern void *osi_AllocLargeSpace(size_t size); extern void *osi_AllocMediumSpace(size_t size); extern void *osi_AllocSmallSpace(size_t size); #ifndef osi_AllocSmall -extern char *osi_AllocSmall(register afs_int32 size, register afs_int32 morespace); +extern char *osi_AllocSmall(register afs_int32 size, + register afs_int32 morespace); #endif /* afs_osi_uio.c */ -extern int afsio_copy(struct uio *ainuio, struct uio *aoutuio, struct iovec *aoutvec); +extern int afsio_copy(struct uio *ainuio, struct uio *aoutuio, + struct iovec *aoutvec); extern int afsio_trim(struct uio *auio, afs_int32 asize); extern int afsio_skip(struct uio *auio, afs_int32 asize); @@ -442,21 +527,21 @@ extern int afsio_skip(struct uio *auio, afs_int32 asize); /* ARCH/osi_misc.c */ extern void osi_iput(struct inode *ip); -extern void afs_osi_SetTime(osi_timeval_t *atv); +extern void afs_osi_SetTime(osi_timeval_t * atv); /* LINUX/osi_misc.c */ #ifdef AFS_LINUX20_ENV #ifdef AFS_LINUX24_ENV extern int osi_lookupname(char *aname, uio_seg_t seg, int followlink, - vnode_t **dirvpp, struct dentry **dpp); + vnode_t ** dirvpp, struct dentry **dpp); extern int osi_InitCacheInfo(char *aname); -extern int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, size_t asize, - size_t *resid); -extern int osi_file_uio_rdwr(struct osi_file *osifile, uio_t *uiop, int rw); -extern void setup_uio(uio_t *uiop, struct iovec *iovecp, char *buf, - afs_offs_t pos, int count, uio_flag_t flag, - uio_seg_t seg); -extern int uiomove(char *dp, int length, uio_flag_t rw, uio_t *uiop); +extern int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp, + size_t asize, size_t * resid); +extern int osi_file_uio_rdwr(struct osi_file *osifile, uio_t * uiop, int rw); +extern void setup_uio(uio_t * uiop, struct iovec *iovecp, char *buf, + afs_offs_t pos, int count, uio_flag_t flag, + uio_seg_t seg); +extern int uiomove(char *dp, int length, uio_flag_t rw, uio_t * uiop); extern void osi_linux_free_inode_pages(void); extern void osi_clear_inode(struct inode *ip); extern void check_bad_parent(struct dentry *dp); @@ -464,14 +549,16 @@ extern void check_bad_parent(struct dentry *dp); extern void osi_linux_mask(void); extern void osi_linux_unmask(void); extern void osi_linux_rxkreg(void); -extern int setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, int change_parent); +extern int setpag(cred_t ** cr, afs_uint32 pagvalue, afs_uint32 * newpag, + int change_parent); #endif /* ARCH/osi_sleep.c */ extern void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle); extern void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle); -extern int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok); +extern int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, + int aintok); #ifndef afs_osi_Wakeup extern int afs_osi_Wakeup(void *event); #endif @@ -496,37 +583,43 @@ extern void *osi_UFSOpen(ino_t ainode); #else extern void *osi_UFSOpen(afs_int32 ainode); #endif -extern int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat); +extern int afs_osi_Stat(register struct osi_file *afile, + register struct osi_stat *astat); extern int osi_UFSClose(register struct osi_file *afile); extern int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize); extern void osi_DisableAtimes(struct vnode *avp); -extern int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize); -extern int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize); -extern int afs_osi_MapStrategy(int (*aproc)(struct buf *bp), register struct buf *bp); +extern int afs_osi_Read(register struct osi_file *afile, int offset, + void *aptr, afs_int32 asize); +extern int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, + void *aptr, afs_int32 asize); +extern int afs_osi_MapStrategy(int (*aproc) (struct buf * bp), + register struct buf *bp); extern void shutdown_osifile(void); /* ARCH/osi_groups.c */ #ifdef AFS_XBSD_ENV extern int setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue, - afs_uint32 *newpag, int change_parent); + afs_uint32 * newpag, int change_parent); #endif /* ARCH/osi_vm.c */ extern int osi_VM_FlushVCache(struct vcache *avc, int *slept); extern void osi_VM_StoreAllSegments(struct vcache *avc); -extern void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, - int sync); +extern void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, + int sync); extern void osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp); -extern void osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred); +extern void osi_VM_Truncate(struct vcache *avc, int alen, + struct AFS_UCRED *acred); extern void osi_VM_TryReclaim(struct vcache *avc, int *slept); extern void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size); extern int osi_VM_Setup(struct vcache *avc, int force); #ifdef AFS_SUN5_ENV extern int osi_VM_GetDownD(struct vcache *avc, struct dcache *adc); -extern void osi_VM_PreTruncate(struct vcache *avc, int alen, struct AFS_UCRED *acred); +extern void osi_VM_PreTruncate(struct vcache *avc, int alen, + struct AFS_UCRED *acred); #endif @@ -534,11 +627,11 @@ extern void osi_VM_PreTruncate(struct vcache *avc, int alen, struct AFS_UCRED *a extern struct vnodeops Afs_vnodeops; #if defined(AFS_OSF_ENV) #if defined(AFS_OSF30_ENV) -extern int max_vnodes; /* number of total system vnodes */ +extern int max_vnodes; /* number of total system vnodes */ #else -extern int nvnode; /* number of total system vnodes */ -extern int numvnodes; /* number vnodes in use now */ -#endif +extern int nvnode; /* number of total system vnodes */ +extern int numvnodes; /* number vnodes in use now */ +#endif #ifdef AFS_DUX40_ENV extern struct vfs_ubcops afs_ubcops; #endif @@ -571,11 +664,12 @@ extern int afs_syscall_pioctl(); /* afs_segments.c */ extern int afs_StoreMini(register struct vcache *avc, struct vrequest *areq); -extern int afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, - int sync); +extern int afs_StoreAllSegments(register struct vcache *avc, + struct vrequest *areq, int sync); extern int afs_InvalidateAllSegments(struct vcache *avc); -extern int afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, - struct vrequest *areq, struct AFS_UCRED *acred); +extern int afs_TruncateAllSegments(register struct vcache *avc, + afs_size_t alen, struct vrequest *areq, + struct AFS_UCRED *acred); /* afs_server.c */ extern afs_rwlock_t afs_xsrvAddr; @@ -585,11 +679,11 @@ extern struct srvAddr *afs_srvAddrs[NSERVERS]; extern struct server *afs_servers[NSERVERS]; extern int afs_totalServers; extern struct server *afs_setTimeHost; -extern struct server *afs_FindServer (afs_int32 aserver, ushort aport, - afsUUID *uuidp, afs_int32 locktype); -extern struct server *afs_GetServer(afs_uint32 *aserver, afs_int32 nservers, +extern struct server *afs_FindServer(afs_int32 aserver, ushort aport, + afsUUID * uuidp, afs_int32 locktype); +extern struct server *afs_GetServer(afs_uint32 * aserver, afs_int32 nservers, afs_int32 acell, u_short aport, - afs_int32 locktype, afsUUID *uuidp, + afs_int32 locktype, afsUUID * uuidp, afs_int32 addr_uniquifier); extern void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown); extern void afs_ServerDown(struct srvAddr *sa); @@ -604,7 +698,8 @@ extern void afs_FlushServer(struct server *srvp); extern void afs_RemoveSrvAddr(struct srvAddr *sap); extern void afs_ActivateServer(struct srvAddr *sap); #ifdef AFS_USERSPACE_IP_ADDR -extern int afsi_SetServerIPRank(struct srvAddr *sa, afs_int32 addr, afs_uint32 subnetmask); +extern int afsi_SetServerIPRank(struct srvAddr *sa, afs_int32 addr, + afs_uint32 subnetmask); #else #if (!defined(AFS_SUN5_ENV)) && defined(USEIFADDR) void afsi_SetServerIPRank(struct srvAddr *sa, struct in_ifaddr *ifa); @@ -614,9 +709,12 @@ void afsi_SetServerIPRank(struct srvAddr *sa, struct in_ifaddr *ifa); /* afs_osidnlc.c */ -extern int osi_dnlc_enter(struct vcache *adp, char *aname, struct vcache *avc, afs_hyper_t *avno); -extern struct vcache *osi_dnlc_lookup(struct vcache *adp, char *aname, int locktype); -extern int osi_dnlc_remove(struct vcache *adp, char *aname, struct vcache *avc ); +extern int osi_dnlc_enter(struct vcache *adp, char *aname, struct vcache *avc, + afs_hyper_t * avno); +extern struct vcache *osi_dnlc_lookup(struct vcache *adp, char *aname, + int locktype); +extern int osi_dnlc_remove(struct vcache *adp, char *aname, + struct vcache *avc); extern int osi_dnlc_purgedp(struct vcache *adp); extern int osi_dnlc_purgevp(struct vcache *avc); extern int osi_dnlc_purge(void); @@ -640,7 +738,8 @@ extern void afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue); /* UKERNEL/afs_usrops.c */ #ifdef UKERNEL extern void uafs_Shutdown(void); -extern void osi_ReleaseVM(struct vcache *avc, int len, struct usr_ucred *credp); +extern void osi_ReleaseVM(struct vcache *avc, int len, + struct usr_ucred *credp); extern int osi_GetTime(struct timeval *tv); #endif @@ -650,19 +749,20 @@ extern int osi_GetTime(struct timeval *tv); /* afs_user.c */ extern afs_rwlock_t afs_xuser; extern struct unixuser *afs_users[NUSERS]; -extern struct unixuser *afs_FindUser(afs_int32 auid, afs_int32 acell, afs_int32 locktype); -extern struct unixuser *afs_GetUser(register afs_int32 auid, - afs_int32 acell, afs_int32 locktype); +extern struct unixuser *afs_FindUser(afs_int32 auid, afs_int32 acell, + afs_int32 locktype); +extern struct unixuser *afs_GetUser(register afs_int32 auid, afs_int32 acell, + afs_int32 locktype); #if AFS_GCPAGS -extern afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount); -extern void afs_GCPAGs_perproc_func(AFS_PROC *pproc); +extern afs_int32 afs_GCPAGs(afs_int32 * ReleasedCount); +extern void afs_GCPAGs_perproc_func(AFS_PROC * pproc); #endif /* AFS_GCPAGS */ extern void afs_ComputePAGStats(void); extern void afs_PutUser(register struct unixuser *au, afs_int32 locktype); extern void afs_GCUserData(int aforce); extern void afs_CheckTokenCache(void); extern void afs_ResetAccessCache(afs_int32 uid, int alock); -extern void afs_ResetUserConns (register struct unixuser *auser); +extern void afs_ResetUserConns(register struct unixuser *auser); extern void afs_SetPrimary(register struct unixuser *au, register int aflag); @@ -684,15 +784,15 @@ extern char *afs_strchr(char *s, int c); #endif extern char *afs_strdup(char *s); extern void print_internet_address(char *preamble, struct srvAddr *sa, - char *postamble, int flag); + char *postamble, int flag); extern afs_int32 afs_data_pointer_to_int32(const void *p); -#if 0 /* problems - need to change to varargs, right now is incorrect usage - throughout code */ -extern void afs_warn(char *a, long b, long c, long d, long e, long f, long g, - long h, long i, long j); +#if 0 /* problems - need to change to varargs, right now is incorrect usage + * throughout code */ +extern void afs_warn(char *a, long b, long c, long d, long e, long f, long g, + long h, long i, long j); extern void afs_warnuser(char *a, long b, long c, long d, long e, long f, - long g, long h, long i, long j); + long g, long h, long i, long j); #else extern void afs_warn(); extern void afs_warnuser(); @@ -720,116 +820,148 @@ extern afs_int32 afs_bulkStatsLost; extern int afs_norefpanic; void afs_vcacheInit(int astatSize); -extern struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 *retry, afs_int32 flag); +extern struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, + afs_int32 flag); extern afs_int32 afs_FetchStatus(struct vcache *avc, struct VenusFid *afid, - struct vrequest *areq, - struct AFSFetchStatus *Outsp); + struct vrequest *areq, + struct AFSFetchStatus *Outsp); extern afs_int32 afs_FlushVCBs(afs_int32 lockit); extern void afs_InactiveVCache(struct vcache *avc, struct AFS_UCRED *acred); -extern struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, - afs_int32 *cached, struct vcache *adp, char *aname); +extern struct vcache *afs_LookupVCache(struct VenusFid *afid, + struct vrequest *areq, + afs_int32 * cached, struct vcache *adp, + char *aname); extern int afs_FlushVCache(struct vcache *avc, int *slept); extern struct vcache *afs_GetRootVCache(struct VenusFid *afid, - struct vrequest *areq, afs_int32 *cached, + struct vrequest *areq, + afs_int32 * cached, struct volume *tvolp); extern struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp); extern int afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq); -extern struct vcache *afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq, - afs_int32 *cached, struct vcache *avc); +extern struct vcache *afs_GetVCache(register struct VenusFid *afid, + struct vrequest *areq, afs_int32 * cached, + struct vcache *avc); extern void afs_PutVCache(register struct vcache *avc); -extern void afs_ProcessFS(register struct vcache *avc, register struct AFSFetchStatus *astat, - struct vrequest *areq); +extern void afs_ProcessFS(register struct vcache *avc, + register struct AFSFetchStatus *astat, + struct vrequest *areq); extern struct afs_cbr *afs_AllocCBR(void); extern int afs_FreeCBR(register struct afs_cbr *asp); extern int afs_RemoveVCB(register struct VenusFid *afid); extern void afs_FlushActiveVcaches(register afs_int32 doflocks); -extern int afs_WriteVCache(register struct vcache *avc, - register struct AFSStoreStatus *astatus, struct vrequest *areq); -extern int afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq, - char *name, struct VenusFid *nfid, struct AFSFetchStatus *OutStatusp, - struct AFSCallBack *CallBackp, struct server **serverp, struct AFSVolSync *tsyncp); -extern afs_int32 afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid); +extern int afs_WriteVCache(register struct vcache *avc, + register struct AFSStoreStatus *astatus, + struct vrequest *areq); +extern int afs_RemoteLookup(register struct VenusFid *afid, + struct vrequest *areq, char *name, + struct VenusFid *nfid, + struct AFSFetchStatus *OutStatusp, + struct AFSCallBack *CallBackp, + struct server **serverp, + struct AFSVolSync *tsyncp); +extern afs_int32 afs_NFSFindVCache(struct vcache **avcp, + struct VenusFid *afid); extern void afs_vcacheInit(int astatSize); extern void shutdown_vcache(void); /* VNOPS/afs_vnop_access.c */ -extern afs_int32 afs_GetAccessBits(register struct vcache *avc, register afs_int32 arights, - register struct vrequest *areq); -extern int afs_AccessOK(struct vcache *avc, afs_int32 arights, struct vrequest *areq, - afs_int32 check_mode_bits); +extern afs_int32 afs_GetAccessBits(register struct vcache *avc, + register afs_int32 arights, + register struct vrequest *areq); +extern int afs_AccessOK(struct vcache *avc, afs_int32 arights, + struct vrequest *areq, afs_int32 check_mode_bits); #if defined(AFS_SUN5_ENV) || (defined(AFS_SGI_ENV) && !defined(AFS_SGI65_ENV)) -extern int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, int flags, struct AFS_UCRED *acred); +extern int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, int flags, + struct AFS_UCRED *acred); #else -extern int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, struct AFS_UCRED *acred); +extern int afs_access(OSI_VC_DECL(avc), register afs_int32 amode, + struct AFS_UCRED *acred); #endif -extern int afs_getRights(OSI_VC_DECL(avc), register afs_int32 arights, struct AFS_UCRED *acred); +extern int afs_getRights(OSI_VC_DECL(avc), register afs_int32 arights, + struct AFS_UCRED *acred); /* VNOPS/afs_vnop_attrs.c */ -extern int afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs); +extern int afs_CopyOutAttrs(register struct vcache *avc, + register struct vattr *attrs); #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) -extern int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, int flags, struct AFS_UCRED *acred); +extern int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, int flags, + struct AFS_UCRED *acred); #else -extern int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred); +extern int afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, + struct AFS_UCRED *acred); #endif -extern int afs_VAttrToAS(register struct vcache *avc, register struct vattr *av, - register struct AFSStoreStatus *as); +extern int afs_VAttrToAS(register struct vcache *avc, + register struct vattr *av, + register struct AFSStoreStatus *as); #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) -extern int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, int flags, struct AFS_UCRED *acred); +extern int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, + int flags, struct AFS_UCRED *acred); #else -extern int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFS_UCRED *acred); +extern int afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, + struct AFS_UCRED *acred); #endif /* VNOPS/afs_vnop_create.c */ #ifdef AFS_OSF_ENV extern int afs_create(struct nameidata *ndp, struct vattr *attrs); -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ #ifdef AFS_SGI64_ENV -extern int afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, int flags, - int amode, struct vcache **avcp, struct AFS_UCRED *acred); +extern int afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, + int flags, int amode, struct vcache **avcp, + struct AFS_UCRED *acred); #else /* AFS_SGI64_ENV */ -extern int afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, enum vcexcl aexcl, - int amode, struct vcache **avcp, struct AFS_UCRED *acred); +extern int afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, + enum vcexcl aexcl, int amode, struct vcache **avcp, + struct AFS_UCRED *acred); #endif /* AFS_SGI64_ENV */ #endif /* AFS_OSF_ENV */ -extern int afs_LocalHero(register struct vcache *avc, register struct dcache *adc, - register AFSFetchStatus *astat, register int aincr); +extern int afs_LocalHero(register struct vcache *avc, + register struct dcache *adc, + register AFSFetchStatus * astat, register int aincr); /* VNOPS/afs_vnop_flock.c */ -extern void lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, int clid); +extern void lockIdSet(struct AFS_FLOCK *flock, struct SimpleLocks *slp, + int clid); extern int HandleFlock(register struct vcache *avc, int acom, - struct vrequest *areq, pid_t clid, int onlymine); + struct vrequest *areq, pid_t clid, int onlymine); /* VNOPS/afs_vnop_lookup.c */ extern int EvalMountPoint(register struct vcache *avc, struct vcache *advc, - struct volume **avolpp, register struct vrequest *areq); + struct volume **avolpp, + register struct vrequest *areq); extern void afs_InitFakeStat(struct afs_fakestat_state *state); -extern int afs_EvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state, - struct vrequest *areq); -extern int afs_TryEvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state, - struct vrequest *areq); +extern int afs_EvalFakeStat(struct vcache **avcp, + struct afs_fakestat_state *state, + struct vrequest *areq); +extern int afs_TryEvalFakeStat(struct vcache **avcp, + struct afs_fakestat_state *state, + struct vrequest *areq); extern void afs_PutFakeStat(struct afs_fakestat_state *state); extern int afs_ENameOK(register char *aname); -extern int afs_getsysname(register struct vrequest *areq, register struct vcache *adp, - register char *bufp); -extern void Check_AtSys(register struct vcache *avc, const char *aname, - struct sysname_info *state, struct vrequest *areq); -extern int Next_AtSys(register struct vcache *avc, struct vrequest *areq, - struct sysname_info *state); -extern int afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp); +extern int afs_getsysname(register struct vrequest *areq, + register struct vcache *adp, register char *bufp); +extern void Check_AtSys(register struct vcache *avc, const char *aname, + struct sysname_info *state, struct vrequest *areq); +extern int Next_AtSys(register struct vcache *avc, struct vrequest *areq, + struct sysname_info *state); +extern int afs_DoBulkStat(struct vcache *adp, long dirCookie, + struct vrequest *areqp); extern int afs_lookup(); /* VNOPS/afs_vnop_open.c */ #ifdef AFS_SGI64_ENV -extern int afs_open(bhv_desc_t *bhv, struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *acred); +extern int afs_open(bhv_desc_t * bhv, struct vcache **avcp, afs_int32 aflags, + struct AFS_UCRED *acred); #else -extern int afs_open(struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *acred); +extern int afs_open(struct vcache **avcp, afs_int32 aflags, + struct AFS_UCRED *acred); #endif @@ -837,10 +969,12 @@ extern int afs_open(struct vcache **avcp, afs_int32 aflags, struct AFS_UCRED *ac extern afs_int32 maxIHint; extern afs_int32 nihints; extern afs_int32 usedihint; -extern int afs_MemRead(register struct vcache *avc, struct uio *auio, struct AFS_UCRED *acred, - daddr_t albn, struct buf **abpp, int noLock); +extern int afs_MemRead(register struct vcache *avc, struct uio *auio, + struct AFS_UCRED *acred, daddr_t albn, + struct buf **abpp, int noLock); extern int afs_UFSRead(register struct vcache *avc, struct uio *auio, - struct AFS_UCRED *acred, daddr_t albn, struct buf **abpp, int noLock); + struct AFS_UCRED *acred, daddr_t albn, + struct buf **abpp, int noLock); /* VNOPS/afs_vnop_readdir.c */ @@ -848,31 +982,36 @@ extern int afs_rd_stash_i; /* VNOPS/afs_vnop_remove.c */ -extern int afsremove(register struct vcache *adp, register struct dcache *tdc, - register struct vcache *tvc, char *aname, struct AFS_UCRED *acred, - struct vrequest *treqp); +extern int afsremove(register struct vcache *adp, register struct dcache *tdc, + register struct vcache *tvc, char *aname, + struct AFS_UCRED *acred, struct vrequest *treqp); extern int afs_remunlink(register struct vcache *avc, register int doit); /* VNOPS/afs_vnop_rename.c */ -extern int afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, - char *aname2, struct AFS_UCRED *acred, struct vrequest *areq); +extern int afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, + char *aname2, struct AFS_UCRED *acred, + struct vrequest *areq); /* VNOPS/afs_vnop_symlink.c */ -extern int afs_MemHandleLink(register struct vcache *avc, struct vrequest *areq); -extern int afs_UFSHandleLink(register struct vcache *avc, struct vrequest *areq); +extern int afs_MemHandleLink(register struct vcache *avc, + struct vrequest *areq); +extern int afs_UFSHandleLink(register struct vcache *avc, + struct vrequest *areq); /* VNOPS/afs_vnop_flock.c */ extern afs_int32 lastWarnTime; /* VNOPS/afs_vnop_write.c */ -extern int afs_MemWrite(register struct vcache *avc, struct uio *auio, int aio, - struct AFS_UCRED *acred, int noLock); -extern int afs_StoreOnLastReference(register struct vcache *avc, register struct vrequest *treq); +extern int afs_MemWrite(register struct vcache *avc, struct uio *auio, + int aio, struct AFS_UCRED *acred, int noLock); +extern int afs_StoreOnLastReference(register struct vcache *avc, + register struct vrequest *treq); extern int afs_UFSWrite(register struct vcache *avc, struct uio *auio, - int aio, struct AFS_UCRED *acred, int noLock); -extern int afs_DoPartialWrite(register struct vcache *avc, struct vrequest *areq); + int aio, struct AFS_UCRED *acred, int noLock); +extern int afs_DoPartialWrite(register struct vcache *avc, + struct vrequest *areq); extern int afs_closex(register struct file *afd); /* other VNOPS (please fix these) */ @@ -897,22 +1036,27 @@ extern afs_int32 afs_volCounter; extern afs_rwlock_t afs_xvolume; extern struct volume *afs_volumes[NVOLS]; extern ino_t volumeInode; -extern struct volume *afs_FindVolume(struct VenusFid *afid, afs_int32 locktype); +extern struct volume *afs_FindVolume(struct VenusFid *afid, + afs_int32 locktype); extern struct volume *afs_freeVolList; extern afs_int32 fvTable[NFENTRIES]; extern void InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell); extern void InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, - int acell); + int acell); extern void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, - int acell, struct cell *tcell, struct vrequest *areq); + int acell, struct cell *tcell, + struct vrequest *areq); extern void afs_ResetVolumeInfo(struct volume *tv); extern struct volume *afs_MemGetVolSlot(void); extern void afs_ResetVolumes(struct server *srvp); -extern struct volume *afs_GetVolume(struct VenusFid *afid, struct vrequest *areq, - afs_int32 locktype); -extern struct volume *afs_GetVolumeByName(register char *aname, afs_int32 acell, - int agood, struct vrequest *areq, afs_int32 locktype); +extern struct volume *afs_GetVolume(struct VenusFid *afid, + struct vrequest *areq, + afs_int32 locktype); +extern struct volume *afs_GetVolumeByName(register char *aname, + afs_int32 acell, int agood, + struct vrequest *areq, + afs_int32 locktype); extern struct volume *afs_UFSGetVolSlot(void); extern void afs_CheckVolumeNames(int flags); @@ -920,12 +1064,12 @@ extern void afs_CheckVolumeNames(int flags); /* Prototypes for generated files that aren't really in src/afs/ */ /* afs_uuid.c */ -extern afs_int32 afs_uuid_equal(afsUUID *u1, afsUUID *u2); -extern afs_int32 afs_uuid_is_nil(afsUUID *u1); -extern void afs_htonuuid(afsUUID *uuidp); -extern void afs_ntohuuid(afsUUID *uuidp); -extern afs_int32 afs_uuid_create (afsUUID *uuid); -extern u_short afs_uuid_hash (afsUUID *uuid); +extern afs_int32 afs_uuid_equal(afsUUID * u1, afsUUID * u2); +extern afs_int32 afs_uuid_is_nil(afsUUID * u1); +extern void afs_htonuuid(afsUUID * uuidp); +extern void afs_ntohuuid(afsUUID * uuidp); +extern afs_int32 afs_uuid_create(afsUUID * uuid); +extern u_short afs_uuid_hash(afsUUID * uuid); /* MISC PROTOTYPES - THESE SHOULD NOT BE HERE */ diff --git a/src/afs/afs_segments.c b/src/afs/afs_segments.c index 6b8e075a0..72f51cc7c 100644 --- a/src/afs/afs_segments.c +++ b/src/afs/afs_segments.c @@ -13,15 +13,16 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /*Standard vendor system headers*/ -#include "afsincludes.h" /*AFS-based standard headers*/ -#include "afs/afs_stats.h" /* statistics */ +#include "afs/sysincludes.h" /*Standard vendor system headers */ +#include "afsincludes.h" /*AFS-based standard headers */ +#include "afs/afs_stats.h" /* statistics */ #include "afs/afs_cbqueue.h" #include "afs/afs_osidnlc.h" -afs_uint32 afs_stampValue=0; +afs_uint32 afs_stampValue = 0; /* * afs_StoreMini @@ -36,7 +37,8 @@ afs_uint32 afs_stampValue=0; * We're write-locked upon entry. */ -int afs_StoreMini(register struct vcache *avc, struct vrequest *areq) +int +afs_StoreMini(register struct vcache *avc, struct vrequest *areq) { register struct conn *tc; struct AFSStoreStatus InStatus; @@ -45,13 +47,12 @@ int afs_StoreMini(register struct vcache *avc, struct vrequest *areq) register afs_int32 code; register struct rx_call *tcall; afs_size_t tlen, xlen = 0; - XSTATS_DECLS - - AFS_STATCNT(afs_StoreMini); + XSTATS_DECLS AFS_STATCNT(afs_StoreMini); afs_Trace2(afs_iclSetp, CM_TRACE_STOREMINI, ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, avc->m.Length); tlen = avc->m.Length; - if (avc->truncPos < tlen) tlen = avc->truncPos; + if (avc->truncPos < tlen) + tlen = avc->truncPos; avc->truncPos = AFS_NOTRUNC; avc->states &= ~CExtendedFile; @@ -59,51 +60,53 @@ int afs_StoreMini(register struct vcache *avc, struct vrequest *areq) tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); if (tc) { RX_AFS_GUNLOCK(); -retry: + retry: tcall = rx_NewCall(tc->id); RX_AFS_GLOCK(); /* Set the client mod time since we always want the file - * to have the client's mod time and not the server's one - * (to avoid problems with make, etc.) It almost always - * works fine with standard afs because them server/client - * times are in sync and more importantly this storemini - * it's a special call that would typically be followed by - * the proper store-data or store-status calls. - */ + * to have the client's mod time and not the server's one + * (to avoid problems with make, etc.) It almost always + * works fine with standard afs because them server/client + * times are in sync and more importantly this storemini + * it's a special call that would typically be followed by + * the proper store-data or store-status calls. + */ InStatus.Mask = AFS_SETMODTIME; InStatus.ClientModTime = avc->m.Date; XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREDATA); - afs_Trace4(afs_iclSetp, CM_TRACE_STOREDATA64, - ICL_TYPE_FID, &avc->fid.Fid, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(xlen), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(tlen)); + afs_Trace4(afs_iclSetp, CM_TRACE_STOREDATA64, ICL_TYPE_FID, + &avc->fid.Fid, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(avc->m.Length), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(xlen), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(tlen)); RX_AFS_GUNLOCK(); #ifdef AFS_64BIT_CLIENT if (!afs_serverHasNo64Bit(tc)) { - code = StartRXAFS_StoreData64(tcall, - (struct AFSFid *)&avc->fid.Fid, - &InStatus, avc->m.Length, - (afs_size_t) 0, tlen); + code = + StartRXAFS_StoreData64(tcall, + (struct AFSFid *)&avc->fid.Fid, + &InStatus, avc->m.Length, + (afs_size_t) 0, tlen); } else { afs_int32 l1, l2; l1 = avc->m.Length; l2 = tlen; - code = StartRXAFS_StoreData(tcall, - (struct AFSFid *)&avc->fid.Fid, - &InStatus, l1, 0, l2); + code = + StartRXAFS_StoreData(tcall, + (struct AFSFid *)&avc->fid.Fid, + &InStatus, l1, 0, l2); } #else /* AFS_64BIT_CLIENT */ - code = StartRXAFS_StoreData(tcall, - (struct AFSFid *)&avc->fid.Fid, - &InStatus, avc->m.Length, 0, tlen); + code = + StartRXAFS_StoreData(tcall, (struct AFSFid *)&avc->fid.Fid, + &InStatus, avc->m.Length, 0, tlen); #endif /* AFS_64BIT_CLIENT */ if (code == 0) { code = EndRXAFS_StoreData(tcall, &OutStatus, &tsync); #ifdef AFS_64BIT_CLIENT - if (code == RXGEN_OPCODE) { + if (code == RXGEN_OPCODE) { afs_serverSetNo64Bit(tc); - code = rx_EndCall(tcall, code); + code = rx_EndCall(tcall, code); goto retry; } #endif /* AFS_64BIT_CLIENT */ @@ -111,23 +114,21 @@ retry: code = rx_EndCall(tcall, code); RX_AFS_GLOCK(); XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_STOREDATA, - SHARED_LOCK, NULL)); + } else + code = -1; + } while (afs_Analyze + (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STOREDATA, + SHARED_LOCK, NULL)); if (code == 0) { afs_ProcessFS(avc, &OutStatus, areq); - } - else { + } else { /* blew it away */ afs_InvalidateAllSegments(avc); } return code; -} /*afs_StoreMini*/ +} /*afs_StoreMini */ unsigned int storeallmissing = 0; #define lmin(a,b) (((a) < (b)) ? (a) : (b)) @@ -147,41 +148,42 @@ unsigned int storeallmissing = 0; #if defined (AFS_HPUX_ENV) || defined(AFS_ULTRIX_ENV) int NCHUNKSATONCE = 3; #else -int NCHUNKSATONCE = 64 ; +int NCHUNKSATONCE = 64; #endif -int afs_dvhack=0; +int afs_dvhack = 0; -int afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, - int sync) +int +afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, + int sync) { register struct dcache *tdc; - register afs_int32 code=0; + register afs_int32 code = 0; register afs_int32 index; - register afs_int32 origCBs, foreign=0; + register afs_int32 origCBs, foreign = 0; int hash, stored; afs_hyper_t newDV, oldDV; /* DV when we start, and finish, respectively */ struct dcache **dcList, **dclist; unsigned int i, j, minj, moredata, high, off; afs_size_t tlen; - afs_size_t maxStoredLength; /* highest offset we've written to server. */ + afs_size_t maxStoredLength; /* highest offset we've written to server. */ int safety; #ifndef AFS_NOSTATS struct afs_stats_xferData *xferP; /* Ptr to this op's xfer struct */ - osi_timeval_t xferStartTime, /*FS xfer start time*/ - xferStopTime; /*FS xfer stop time*/ - afs_size_t bytesToXfer; /* # bytes to xfer*/ - afs_size_t bytesXferred; /* # bytes actually xferred*/ + osi_timeval_t xferStartTime, /*FS xfer start time */ + xferStopTime; /*FS xfer stop time */ + afs_size_t bytesToXfer; /* # bytes to xfer */ + afs_size_t bytesXferred; /* # bytes actually xferred */ #endif /* AFS_NOSTATS */ AFS_STATCNT(afs_StoreAllSegments); - + hset(oldDV, avc->m.DataVersion); hset(newDV, avc->m.DataVersion); hash = DVHash(&avc->fid); foreign = (avc->states & CForeign); - dcList = (struct dcache **) osi_AllocLargeSpace(AFS_LRALLOCSIZ); + dcList = (struct dcache **)osi_AllocLargeSpace(AFS_LRALLOCSIZ); afs_Trace2(afs_iclSetp, CM_TRACE_STOREALL, ICL_TYPE_POINTER, avc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); #if !defined(AFS_AIX32_ENV) && !defined(AFS_SGI65_ENV) @@ -189,7 +191,7 @@ int afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, * on the memcache case since that's we adjust the file's size * and finish flushing partial vm pages. */ - if (cacheDiskType != AFS_FCACHE_TYPE_MEM) + if (cacheDiskType != AFS_FCACHE_TYPE_MEM) #endif /* !AFS_AIX32_ENV && !AFS_SGI65_ENV */ { /* If we're not diskless, reading a file may stress the VM @@ -203,516 +205,557 @@ int afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, * space. */ #if defined(AFS_SUN5_ENV) - if ( sync & AFS_VMSYNC_INVAL) /* invalidate VM pages */ - osi_VM_TryToSmush(avc, CRED() , 1 ); + if (sync & AFS_VMSYNC_INVAL) /* invalidate VM pages */ + osi_VM_TryToSmush(avc, CRED(), 1); else #endif osi_VM_StoreAllSegments(avc); } ConvertWToSLock(&avc->lock); - - /* - * Subsequent code expects a sorted list, and it expects all the - * chunks in the list to be contiguous, so we need a sort and a - * while loop in here, too - but this will work for a first pass... - * 92.10.05 - OK, there's a sort in here now. It's kind of a modified - * bin sort, I guess. Chunk numbers start with 0 - * - * - Have to get a write lock on xdcache because GetDSlot might need it (if - * the chunk doesn't have a dcache struct). - * This seems like overkill in most cases. - * - I'm not sure that it's safe to do "index = .hvNextp", then unlock - * xdcache, then relock xdcache and try to use index. It is done - * a lot elsewhere in the CM, but I'm not buying that argument. - * - should be able to check IFDataMod without doing the GetDSlot (just - * hold afs_xdcache). That way, it's easy to do this without the - * writelock on afs_xdcache, and we save unneccessary disk - * operations. I don't think that works, 'cuz the next pointers - * are still on disk. - */ + + /* + * Subsequent code expects a sorted list, and it expects all the + * chunks in the list to be contiguous, so we need a sort and a + * while loop in here, too - but this will work for a first pass... + * 92.10.05 - OK, there's a sort in here now. It's kind of a modified + * bin sort, I guess. Chunk numbers start with 0 + * + * - Have to get a write lock on xdcache because GetDSlot might need it (if + * the chunk doesn't have a dcache struct). + * This seems like overkill in most cases. + * - I'm not sure that it's safe to do "index = .hvNextp", then unlock + * xdcache, then relock xdcache and try to use index. It is done + * a lot elsewhere in the CM, but I'm not buying that argument. + * - should be able to check IFDataMod without doing the GetDSlot (just + * hold afs_xdcache). That way, it's easy to do this without the + * writelock on afs_xdcache, and we save unneccessary disk + * operations. I don't think that works, 'cuz the next pointers + * are still on disk. + */ origCBs = afs_allCBs; retry: maxStoredLength = 0; tlen = avc->m.Length; - minj = 0 ; + minj = 0; do { - memset((char *)dcList, 0, NCHUNKSATONCE * sizeof(struct dcache *)); - high = 0; - moredata = FALSE; - - /* lock and start over from beginning of hash chain - * in order to avoid a race condition. */ - MObtainWriteLock(&afs_xdcache,284); - index = afs_dvhashTbl[hash]; - - for(j=0; index != NULLIDX;) { - if ((afs_indexFlags[index] & IFDataMod) && - (afs_indexUnique[index] == avc->fid.Fid.Unique)) { - tdc = afs_GetDSlot(index, 0); /* refcount+1. */ - ReleaseReadLock(&tdc->tlock); - if (!FidCmp( &tdc->f.fid, &avc->fid ) && tdc->f.chunk >= minj ) { - off = tdc->f.chunk - minj; - if (off < NCHUNKSATONCE) { - if ( dcList[ off ] ) - osi_Panic("dclist slot already in use!"); - dcList[ off ] = tdc; - if (off > high) - high = off; - j++; - /* DCLOCKXXX: chunkBytes is protected by tdc->lock which we - * can't grab here, due to lock ordering with afs_xdcache. - * So, disable this shortcut for now. -- kolya 2001-10-13 - */ - /* shortcut: big win for little files */ - /* tlen -= tdc->f.chunkBytes; - * if (tlen <= 0) - * break; - */ - } - else { - moredata = TRUE; - afs_PutDCache(tdc); - if (j == NCHUNKSATONCE) - break; - } - } else { - afs_PutDCache(tdc); - } - } - index = afs_dvnextTbl[index]; - } - MReleaseWriteLock(&afs_xdcache); + memset((char *)dcList, 0, NCHUNKSATONCE * sizeof(struct dcache *)); + high = 0; + moredata = FALSE; - /* this guy writes chunks, puts back dcache structs, and bumps newDV */ - /* "moredata" just says "there are more dirty chunks yet to come". - */ - if (j) { -#ifdef AFS_NOSTATS - static afs_uint32 lp1 = 10000, lp2 = 10000; -#endif - struct AFSStoreStatus InStatus; - struct AFSFetchStatus OutStatus; - int doProcessFS = 0; - afs_size_t base, bytes; - afs_uint32 nchunks; - int nomore; - unsigned int first; - int *shouldwake; - struct conn * tc; - struct osi_file * tfile; - struct rx_call * tcall; - XSTATS_DECLS - - for (bytes = 0, j = 0; !code && j<=high; j++) { - if (dcList[j]) { - ObtainSharedLock(&(dcList[j]->lock), 629); - if (!bytes) - first = j; - bytes += dcList[j]->f.chunkBytes; - if ((dcList[j]->f.chunkBytes < afs_OtherCSize) - && (dcList[j]->f.chunk - minj < high) - && dcList[j+1]) { - int sbytes = afs_OtherCSize - dcList[j]->f.chunkBytes; - bytes += sbytes; - } - } - if (bytes && (j==high || !dcList[j+1])) { - /* base = AFS_CHUNKTOBASE(dcList[first]->f.chunk); */ - base = AFS_CHUNKTOBASE(first + minj) ; - /* - * - * take a list of dcache structs and send them all off to the server - * the list must be in order, and the chunks contiguous. - * Note - there is no locking done by this code currently. For - * safety's sake, xdcache could be locked over the entire call. - * However, that pretty well ties up all the threads. Meantime, all - * the chunks _MUST_ have their refcounts bumped. - * The writes done before a store back will clear setuid-ness - * in cache file. - * We can permit CacheStoreProc to wake up the user process IFF we - * are doing the last RPC for this close, ie, storing back the last - * set of contiguous chunks of a file. - */ + /* lock and start over from beginning of hash chain + * in order to avoid a race condition. */ + MObtainWriteLock(&afs_xdcache, 284); + index = afs_dvhashTbl[hash]; - dclist = &dcList[first]; - nchunks = 1+j-first; - nomore = !(moredata || (j!=high)); - InStatus.ClientModTime = avc->m.Date; - InStatus.Mask = AFS_SETMODTIME; - if (sync & AFS_SYNC) { - InStatus.Mask |= AFS_FSYNC; - } - tlen = lmin(avc->m.Length, avc->truncPos); - afs_Trace4(afs_iclSetp, CM_TRACE_STOREDATA64, - ICL_TYPE_FID, &avc->fid.Fid, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(base), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(bytes), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(tlen)); - - do { - stored = 0; - tc = afs_Conn(&avc->fid, areq, 0); - if (tc) { -restart: - RX_AFS_GUNLOCK(); - tcall = rx_NewCall(tc->id); -#ifdef AFS_64BIT_CLIENT - if (!afs_serverHasNo64Bit(tc)) { - code = StartRXAFS_StoreData64(tcall, - (struct AFSFid *) &avc->fid.Fid, - &InStatus, base, bytes, tlen); + for (j = 0; index != NULLIDX;) { + if ((afs_indexFlags[index] & IFDataMod) + && (afs_indexUnique[index] == avc->fid.Fid.Unique)) { + tdc = afs_GetDSlot(index, 0); /* refcount+1. */ + ReleaseReadLock(&tdc->tlock); + if (!FidCmp(&tdc->f.fid, &avc->fid) && tdc->f.chunk >= minj) { + off = tdc->f.chunk - minj; + if (off < NCHUNKSATONCE) { + if (dcList[off]) + osi_Panic("dclist slot already in use!"); + dcList[off] = tdc; + if (off > high) + high = off; + j++; + /* DCLOCKXXX: chunkBytes is protected by tdc->lock which we + * can't grab here, due to lock ordering with afs_xdcache. + * So, disable this shortcut for now. -- kolya 2001-10-13 + */ + /* shortcut: big win for little files */ + /* tlen -= tdc->f.chunkBytes; + * if (tlen <= 0) + * break; + */ } else { - if (tlen > 0xFFFFFFFF) { - code = EFBIG; - } else { - afs_int32 t1, t2, t3; - t1 = base; - t2 = bytes; - t3 = tlen; - code = StartRXAFS_StoreData(tcall, - (struct AFSFid *) &avc->fid.Fid, - &InStatus, t1, t2, t3); - } + moredata = TRUE; + afs_PutDCache(tdc); + if (j == NCHUNKSATONCE) + break; } -#else /* AFS_64BIT_CLIENT */ - code = StartRXAFS_StoreData(tcall, (struct AFSFid *) &avc->fid.Fid, - &InStatus, base, bytes, tlen); -#endif /* AFS_64BIT_CLIENT */ - RX_AFS_GLOCK(); } else { - code = -1; - tcall = NULL; + afs_PutDCache(tdc); } - if (!code) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREDATA); - avc->truncPos = AFS_NOTRUNC; + } + index = afs_dvnextTbl[index]; + } + MReleaseWriteLock(&afs_xdcache); + + /* this guy writes chunks, puts back dcache structs, and bumps newDV */ + /* "moredata" just says "there are more dirty chunks yet to come". + */ + if (j) { +#ifdef AFS_NOSTATS + static afs_uint32 lp1 = 10000, lp2 = 10000; +#endif + struct AFSStoreStatus InStatus; + struct AFSFetchStatus OutStatus; + int doProcessFS = 0; + afs_size_t base, bytes; + afs_uint32 nchunks; + int nomore; + unsigned int first; + int *shouldwake; + struct conn *tc; + struct osi_file *tfile; + struct rx_call *tcall; + XSTATS_DECLS for (bytes = 0, j = 0; !code && j <= high; j++) { + if (dcList[j]) { + ObtainSharedLock(&(dcList[j]->lock), 629); + if (!bytes) + first = j; + bytes += dcList[j]->f.chunkBytes; + if ((dcList[j]->f.chunkBytes < afs_OtherCSize) + && (dcList[j]->f.chunk - minj < high) + && dcList[j + 1]) { + int sbytes = afs_OtherCSize - dcList[j]->f.chunkBytes; + bytes += sbytes; + } } - for (i = 0; if.chunk); */ + base = AFS_CHUNKTOBASE(first + minj); + /* + * + * take a list of dcache structs and send them all off to the server + * the list must be in order, and the chunks contiguous. + * Note - there is no locking done by this code currently. For + * safety's sake, xdcache could be locked over the entire call. + * However, that pretty well ties up all the threads. Meantime, all + * the chunks _MUST_ have their refcounts bumped. + * The writes done before a store back will clear setuid-ness + * in cache file. + * We can permit CacheStoreProc to wake up the user process IFF we + * are doing the last RPC for this close, ie, storing back the last + * set of contiguous chunks of a file. + */ + + dclist = &dcList[first]; + nchunks = 1 + j - first; + nomore = !(moredata || (j != high)); + InStatus.ClientModTime = avc->m.Date; + InStatus.Mask = AFS_SETMODTIME; + if (sync & AFS_SYNC) { + InStatus.Mask |= AFS_FSYNC; } - afs_Trace4(afs_iclSetp, CM_TRACE_STOREALL2, - ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, tdc->f.chunk, - ICL_TYPE_INT32, tdc->index, - ICL_TYPE_INT32, tdc->f.inode); - shouldwake = 0; - if (nomore) { - if (avc->asynchrony == -1) { - if (afs_defaultAsynchrony > (bytes-stored)) { - shouldwake = &nomore; - } - } else if ((afs_uint32)avc->asynchrony >= (bytes-stored)) { - shouldwake = &nomore; - } - } - tfile = afs_CFileOpen(tdc->f.inode); + tlen = lmin(avc->m.Length, avc->truncPos); + afs_Trace4(afs_iclSetp, CM_TRACE_STOREDATA64, + ICL_TYPE_FID, &avc->fid.Fid, ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(base), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(bytes), ICL_TYPE_OFFSET, + ICL_HANDLE_OFFSET(tlen)); + + do { + stored = 0; + tc = afs_Conn(&avc->fid, areq, 0); + if (tc) { + restart: + RX_AFS_GUNLOCK(); + tcall = rx_NewCall(tc->id); +#ifdef AFS_64BIT_CLIENT + if (!afs_serverHasNo64Bit(tc)) { + code = + StartRXAFS_StoreData64(tcall, + (struct AFSFid *) + &avc->fid.Fid, + &InStatus, base, + bytes, tlen); + } else { + if (tlen > 0xFFFFFFFF) { + code = EFBIG; + } else { + afs_int32 t1, t2, t3; + t1 = base; + t2 = bytes; + t3 = tlen; + code = + StartRXAFS_StoreData(tcall, + (struct AFSFid *) + &avc->fid.Fid, + &InStatus, t1, + t2, t3); + } + } +#else /* AFS_64BIT_CLIENT */ + code = + StartRXAFS_StoreData(tcall, + (struct AFSFid *)&avc-> + fid.Fid, &InStatus, base, + bytes, tlen); +#endif /* AFS_64BIT_CLIENT */ + RX_AFS_GLOCK(); + } else { + code = -1; + tcall = NULL; + } + if (!code) { + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREDATA); + avc->truncPos = AFS_NOTRUNC; + } + for (i = 0; i < nchunks && !code; i++) { + tdc = dclist[i]; + if (!tdc) { + afs_warn("afs: missing dcache!\n"); + storeallmissing++; + continue; /* panic? */ + } + afs_Trace4(afs_iclSetp, CM_TRACE_STOREALL2, + ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, + tdc->f.chunk, ICL_TYPE_INT32, + tdc->index, ICL_TYPE_INT32, + tdc->f.inode); + shouldwake = 0; + if (nomore) { + if (avc->asynchrony == -1) { + if (afs_defaultAsynchrony > + (bytes - stored)) { + shouldwake = &nomore; + } + } else if ((afs_uint32) avc->asynchrony >= + (bytes - stored)) { + shouldwake = &nomore; + } + } + tfile = afs_CFileOpen(tdc->f.inode); #ifndef AFS_NOSTATS - xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[AFS_STATS_FS_XFERIDX_STOREDATA]); - osi_GetuTime(&xferStartTime); - - code = afs_CacheStoreProc(tcall, tfile, tdc->f.chunkBytes, - avc, shouldwake, &bytesToXfer, - &bytesXferred); - - osi_GetuTime(&xferStopTime); - (xferP->numXfers)++; - if (!code) { - (xferP->numSuccesses)++; - afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_STOREDATA] += bytesXferred; - (xferP->sumBytes) += (afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_STOREDATA] >> 10); - afs_stats_XferSumBytes[AFS_STATS_FS_XFERIDX_STOREDATA] &= 0x3FF; - if (bytesXferred < xferP->minBytes) - xferP->minBytes = bytesXferred; - if (bytesXferred > xferP->maxBytes) - xferP->maxBytes = bytesXferred; - - /* - * Tally the size of the object. Note: we tally the actual size, - * NOT the number of bytes that made it out over the wire. - */ - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0) - (xferP->count[0])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET1) - (xferP->count[1])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET2) - (xferP->count[2])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET3) - (xferP->count[3])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET4) - (xferP->count[4])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET5) - (xferP->count[5])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET6) - (xferP->count[6])++; - else - if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET7) - (xferP->count[7])++; - else - (xferP->count[8])++; - - afs_stats_GetDiff(elapsedTime, xferStartTime, xferStopTime); - afs_stats_AddTo((xferP->sumTime), elapsedTime); - afs_stats_SquareAddTo((xferP->sqrTime), elapsedTime); - if (afs_stats_TimeLessThan(elapsedTime, (xferP->minTime))) { - afs_stats_TimeAssign((xferP->minTime), elapsedTime); - } - if (afs_stats_TimeGreaterThan(elapsedTime, (xferP->maxTime))) { - afs_stats_TimeAssign((xferP->maxTime), elapsedTime); - } - } + xferP = + &(afs_stats_cmfullperf.rpc. + fsXferTimes + [AFS_STATS_FS_XFERIDX_STOREDATA]); + osi_GetuTime(&xferStartTime); + + code = + afs_CacheStoreProc(tcall, tfile, + tdc->f.chunkBytes, avc, + shouldwake, &bytesToXfer, + &bytesXferred); + + osi_GetuTime(&xferStopTime); + (xferP->numXfers)++; + if (!code) { + (xferP->numSuccesses)++; + afs_stats_XferSumBytes + [AFS_STATS_FS_XFERIDX_STOREDATA] += + bytesXferred; + (xferP->sumBytes) += + (afs_stats_XferSumBytes + [AFS_STATS_FS_XFERIDX_STOREDATA] >> 10); + afs_stats_XferSumBytes + [AFS_STATS_FS_XFERIDX_STOREDATA] &= 0x3FF; + if (bytesXferred < xferP->minBytes) + xferP->minBytes = bytesXferred; + if (bytesXferred > xferP->maxBytes) + xferP->maxBytes = bytesXferred; + + /* + * Tally the size of the object. Note: we tally the actual size, + * NOT the number of bytes that made it out over the wire. + */ + if (bytesToXfer <= AFS_STATS_MAXBYTES_BUCKET0) + (xferP->count[0])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET1) + (xferP->count[1])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET2) + (xferP->count[2])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET3) + (xferP->count[3])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET4) + (xferP->count[4])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET5) + (xferP->count[5])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET6) + (xferP->count[6])++; + else if (bytesToXfer <= + AFS_STATS_MAXBYTES_BUCKET7) + (xferP->count[7])++; + else + (xferP->count[8])++; + + afs_stats_GetDiff(elapsedTime, xferStartTime, + xferStopTime); + afs_stats_AddTo((xferP->sumTime), + elapsedTime); + afs_stats_SquareAddTo((xferP->sqrTime), + elapsedTime); + if (afs_stats_TimeLessThan + (elapsedTime, (xferP->minTime))) { + afs_stats_TimeAssign((xferP->minTime), + elapsedTime); + } + if (afs_stats_TimeGreaterThan + (elapsedTime, (xferP->maxTime))) { + afs_stats_TimeAssign((xferP->maxTime), + elapsedTime); + } + } #else - code = afs_CacheStoreProc(tcall, tfile, tdc->f.chunkBytes, - avc, shouldwake, &lp1, &lp2); + code = + afs_CacheStoreProc(tcall, tfile, + tdc->f.chunkBytes, avc, + shouldwake, &lp1, &lp2); #endif /* AFS_NOSTATS */ - afs_CFileClose(tfile); + afs_CFileClose(tfile); #ifdef AFS_64BIT_CLIENT - if (code == RXGEN_OPCODE) { - afs_serverSetNo64Bit(tc); - goto restart; - } + if (code == RXGEN_OPCODE) { + afs_serverSetNo64Bit(tc); + goto restart; + } #endif /* AFS_64BIT_CLIENT */ - if ((tdc->f.chunkBytes < afs_OtherCSize) && - (i < (nchunks-1))) { - int bsent, tlen, sbytes = afs_OtherCSize - tdc->f.chunkBytes; - char *tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ); - - while (sbytes > 0) { - tlen = (sbytes > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : sbytes); - memset(tbuffer, 0, tlen); - RX_AFS_GUNLOCK(); - bsent = rx_Write(tcall, tbuffer, tlen); - RX_AFS_GLOCK(); - - if (bsent != tlen) { - code = -33; /* XXX */ - break; - } - sbytes -= tlen; - } - osi_FreeLargeSpace(tbuffer); - } - stored += tdc->f.chunkBytes; - - /* ideally, I'd like to unlock the dcache and turn - * off the writing bit here, but that would - * require being able to retry StoreAllSegments in - * the event of a failure. It only really matters - * if user can't read from a 'locked' dcache or - * one which has the writing bit turned on. */ - } - if (!code) { - struct AFSVolSync tsync; - RX_AFS_GUNLOCK(); - code = EndRXAFS_StoreData(tcall, &OutStatus, &tsync); - RX_AFS_GLOCK(); - hadd32(newDV, 1); - XSTATS_END_TIME; - if (!code) doProcessFS = 1; /* Flag to run afs_ProcessFS() later on */ - } - if (tcall) { - afs_int32 code2; - RX_AFS_GUNLOCK(); - code2 = rx_EndCall(tcall, code); - RX_AFS_GLOCK(); - if (code2) code = code2; - } - } while (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_STOREDATA, - SHARED_LOCK, NULL)); - - /* put back all remaining locked dcache entries */ - for (i=0; iindex] & IFDataMod) { - /* - * LOCKXXX -- should hold afs_xdcache(W) when - * modifying afs_indexFlags. - */ - afs_indexFlags[tdc->index] &= ~IFDataMod; - afs_stats_cmperf.cacheCurrDirtyChunks--; - afs_indexFlags[tdc->index] &= ~IFDirtyPages; - if ( sync & AFS_VMSYNC_INVAL ) - { - /* since we have invalidated all the pages of this - ** vnode by calling osi_VM_TryToSmush, we can - ** safely mark this dcache entry as not having - ** any pages. This vnode now becomes eligible for - ** reclamation by getDownD. - */ - afs_indexFlags[tdc->index] &= ~IFAnyPages; - } + if ((tdc->f.chunkBytes < afs_OtherCSize) + && (i < (nchunks - 1))) { + int bsent, tlen, sbytes = + afs_OtherCSize - tdc->f.chunkBytes; + char *tbuffer = + osi_AllocLargeSpace(AFS_LRALLOCSIZ); + + while (sbytes > 0) { + tlen = + (sbytes > + AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : + sbytes); + memset(tbuffer, 0, tlen); + RX_AFS_GUNLOCK(); + bsent = rx_Write(tcall, tbuffer, tlen); + RX_AFS_GLOCK(); + + if (bsent != tlen) { + code = -33; /* XXX */ + break; + } + sbytes -= tlen; + } + osi_FreeLargeSpace(tbuffer); + } + stored += tdc->f.chunkBytes; + + /* ideally, I'd like to unlock the dcache and turn + * off the writing bit here, but that would + * require being able to retry StoreAllSegments in + * the event of a failure. It only really matters + * if user can't read from a 'locked' dcache or + * one which has the writing bit turned on. */ + } + if (!code) { + struct AFSVolSync tsync; + RX_AFS_GUNLOCK(); + code = + EndRXAFS_StoreData(tcall, &OutStatus, &tsync); + RX_AFS_GLOCK(); + hadd32(newDV, 1); + XSTATS_END_TIME; + if (!code) + doProcessFS = 1; /* Flag to run afs_ProcessFS() later on */ + } + if (tcall) { + afs_int32 code2; + RX_AFS_GUNLOCK(); + code2 = rx_EndCall(tcall, code); + RX_AFS_GLOCK(); + if (code2) + code = code2; + } + } while (afs_Analyze + (tc, code, &avc->fid, areq, + AFS_STATS_FS_RPCIDX_STOREDATA, SHARED_LOCK, + NULL)); + + /* put back all remaining locked dcache entries */ + for (i = 0; i < nchunks; i++) { + tdc = dclist[i]; + if (!code) { + if (afs_indexFlags[tdc->index] & IFDataMod) { + /* + * LOCKXXX -- should hold afs_xdcache(W) when + * modifying afs_indexFlags. + */ + afs_indexFlags[tdc->index] &= ~IFDataMod; + afs_stats_cmperf.cacheCurrDirtyChunks--; + afs_indexFlags[tdc->index] &= ~IFDirtyPages; + if (sync & AFS_VMSYNC_INVAL) { + /* since we have invalidated all the pages of this + ** vnode by calling osi_VM_TryToSmush, we can + ** safely mark this dcache entry as not having + ** any pages. This vnode now becomes eligible for + ** reclamation by getDownD. + */ + afs_indexFlags[tdc->index] &= ~IFAnyPages; + } + } + } + UpgradeSToWLock(&tdc->lock, 628); + tdc->f.states &= ~DWriting; /* correct? */ + tdc->dflags |= DFEntryMod; + ReleaseWriteLock(&tdc->lock); + afs_PutDCache(tdc); + /* Mark the entry as released */ + dclist[i] = NULL; } - } - UpgradeSToWLock(&tdc->lock, 628); - tdc->f.states &= ~DWriting; /* correct?*/ - tdc->dflags |= DFEntryMod; - ReleaseWriteLock(&tdc->lock); - afs_PutDCache(tdc); - /* Mark the entry as released */ - dclist[i] = NULL; - } - if (doProcessFS) { - /* Now copy out return params */ - UpgradeSToWLock(&avc->lock,28); /* keep out others for a while */ - afs_ProcessFS(avc, &OutStatus, areq); - /* Keep last (max) size of file on server to see if - * we need to call afs_StoreMini to extend the file. - */ - if (!moredata) - maxStoredLength = OutStatus.Length; - ConvertWToSLock(&avc->lock); - doProcessFS = 0; - } + if (doProcessFS) { + /* Now copy out return params */ + UpgradeSToWLock(&avc->lock, 28); /* keep out others for a while */ + afs_ProcessFS(avc, &OutStatus, areq); + /* Keep last (max) size of file on server to see if + * we need to call afs_StoreMini to extend the file. + */ + if (!moredata) + maxStoredLength = OutStatus.Length; + ConvertWToSLock(&avc->lock); + doProcessFS = 0; + } - if (code) { - for (j++; j<=high; j++) { - if ( dcList[j] ) { - ReleaseSharedLock(&(dcList[j]->lock)); - afs_PutDCache(dcList[j]); - /* Releasing entry */ - dcList[j] = NULL; + if (code) { + for (j++; j <= high; j++) { + if (dcList[j]) { + ReleaseSharedLock(&(dcList[j]->lock)); + afs_PutDCache(dcList[j]); + /* Releasing entry */ + dcList[j] = NULL; + } + } } + + afs_Trace2(afs_iclSetp, CM_TRACE_STOREALLDCDONE, + ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code); + bytes = 0; } } - afs_Trace2(afs_iclSetp, CM_TRACE_STOREALLDCDONE, - ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code); - bytes = 0; - } + /* Release any zero-length dcache entries in our interval + * that we locked but didn't store back above. + */ + for (j = 0; j <= high; j++) { + tdc = dcList[j]; + if (tdc) { + osi_Assert(tdc->f.chunkBytes == 0); + ReleaseSharedLock(&tdc->lock); + afs_PutDCache(tdc); + } + } } - - /* Release any zero-length dcache entries in our interval - * that we locked but didn't store back above. + /* if (j) */ + minj += NCHUNKSATONCE; + } while (!code && moredata); + + UpgradeSToWLock(&avc->lock, 29); + + /* send a trivial truncation store if did nothing else */ + if (code == 0) { + /* + * Call StoreMini if we haven't written enough data to extend the + * file at the fileserver to the client's notion of the file length. */ - for (j = 0; j<=high; j++) { - tdc = dcList[j]; - if (tdc) { - osi_Assert(tdc->f.chunkBytes == 0); - ReleaseSharedLock(&tdc->lock); - afs_PutDCache(tdc); - } + if ((avc->truncPos != AFS_NOTRUNC) || ((avc->states & CExtendedFile) + && (maxStoredLength < + avc->m.Length))) { + code = afs_StoreMini(avc, areq); + if (code == 0) + hadd32(newDV, 1); /* just bumped here, too */ } - } /* if (j) */ - - minj += NCHUNKSATONCE; - } while ( !code && moredata ); - - UpgradeSToWLock(&avc->lock,29); + avc->states &= ~CExtendedFile; + } - /* send a trivial truncation store if did nothing else */ - if (code == 0) { /* - * Call StoreMini if we haven't written enough data to extend the - * file at the fileserver to the client's notion of the file length. + * Finally, turn off DWriting, turn on DFEntryMod, + * update f.versionNo. + * A lot of this could be integrated into the loop above */ - if ((avc->truncPos != AFS_NOTRUNC) || - ((avc->states & CExtendedFile) && (maxStoredLength < avc->m.Length))) { - code = afs_StoreMini(avc, areq); - if (code == 0) - hadd32(newDV, 1); /* just bumped here, too */ - } - avc->states &= ~CExtendedFile; - } - - /* - * Finally, turn off DWriting, turn on DFEntryMod, - * update f.versionNo. - * A lot of this could be integrated into the loop above - */ if (!code) { - afs_hyper_t h_unset; - hones(h_unset); - - minj = 0; - - do { - moredata = FALSE; - memset((char *)dcList, 0, NCHUNKSATONCE * sizeof(struct dcache *)); - - /* overkill, but it gets the lock in case GetDSlot needs it */ - MObtainWriteLock(&afs_xdcache,285); - - for(j = 0, safety = 0, index = afs_dvhashTbl[hash]; - index != NULLIDX && safety < afs_cacheFiles+2;) { - - if (afs_indexUnique[index] == avc->fid.Fid.Unique) { - tdc = afs_GetDSlot(index, 0); - ReleaseReadLock(&tdc->tlock); - - if (!FidCmp(&tdc->f.fid, &avc->fid) && tdc->f.chunk >= minj) { - off = tdc->f.chunk - minj; - if (off < NCHUNKSATONCE) { - /* this is the file, and the correct chunk range */ - if (j >= NCHUNKSATONCE) - osi_Panic("Too many dcache entries in range\n"); - dcList[j++] = tdc; + afs_hyper_t h_unset; + hones(h_unset); + + minj = 0; + + do { + moredata = FALSE; + memset((char *)dcList, 0, + NCHUNKSATONCE * sizeof(struct dcache *)); + + /* overkill, but it gets the lock in case GetDSlot needs it */ + MObtainWriteLock(&afs_xdcache, 285); + + for (j = 0, safety = 0, index = afs_dvhashTbl[hash]; + index != NULLIDX && safety < afs_cacheFiles + 2;) { + + if (afs_indexUnique[index] == avc->fid.Fid.Unique) { + tdc = afs_GetDSlot(index, 0); + ReleaseReadLock(&tdc->tlock); + + if (!FidCmp(&tdc->f.fid, &avc->fid) + && tdc->f.chunk >= minj) { + off = tdc->f.chunk - minj; + if (off < NCHUNKSATONCE) { + /* this is the file, and the correct chunk range */ + if (j >= NCHUNKSATONCE) + osi_Panic + ("Too many dcache entries in range\n"); + dcList[j++] = tdc; + } else { + moredata = TRUE; + afs_PutDCache(tdc); + if (j == NCHUNKSATONCE) + break; + } } else { - moredata = TRUE; afs_PutDCache(tdc); - if (j == NCHUNKSATONCE) - break; } - } else { - afs_PutDCache(tdc); } - } - index = afs_dvnextTbl[index]; - } - MReleaseWriteLock(&afs_xdcache); + index = afs_dvnextTbl[index]; + } + MReleaseWriteLock(&afs_xdcache); - for (i=0; ilock, 677); + for (i = 0; i < j; i++) { + /* Iterate over the dcache entries we collected above */ + tdc = dcList[i]; + ObtainSharedLock(&tdc->lock, 677); - /* was code here to clear IFDataMod, but it should only be done - * in storedcache and storealldcache. - */ - /* Only increase DV if we had up-to-date data to start with. - * Otherwise, we could be falsely upgrading an old chunk - * (that we never read) into one labelled with the current - * DV #. Also note that we check that no intervening stores - * occurred, otherwise we might mislabel cache information - * for a chunk that we didn't store this time - */ - /* Don't update the version number if it's not yet set. */ - if (!hsame(tdc->f.versionNo, h_unset) && - hcmp(tdc->f.versionNo, oldDV) >= 0) { - - if ((!(afs_dvhack || foreign) && hsame(avc->m.DataVersion, newDV)) - || ((afs_dvhack || foreign) && (origCBs == afs_allCBs)) ) { - /* no error, this is the DV */ - - UpgradeSToWLock(&tdc->lock, 678); - hset(tdc->f.versionNo, avc->m.DataVersion); - tdc->dflags |= DFEntryMod; - ConvertWToSLock(&tdc->lock); + /* was code here to clear IFDataMod, but it should only be done + * in storedcache and storealldcache. + */ + /* Only increase DV if we had up-to-date data to start with. + * Otherwise, we could be falsely upgrading an old chunk + * (that we never read) into one labelled with the current + * DV #. Also note that we check that no intervening stores + * occurred, otherwise we might mislabel cache information + * for a chunk that we didn't store this time + */ + /* Don't update the version number if it's not yet set. */ + if (!hsame(tdc->f.versionNo, h_unset) + && hcmp(tdc->f.versionNo, oldDV) >= 0) { + + if ((!(afs_dvhack || foreign) + && hsame(avc->m.DataVersion, newDV)) + || ((afs_dvhack || foreign) + && (origCBs == afs_allCBs))) { + /* no error, this is the DV */ + + UpgradeSToWLock(&tdc->lock, 678); + hset(tdc->f.versionNo, avc->m.DataVersion); + tdc->dflags |= DFEntryMod; + ConvertWToSLock(&tdc->lock); + } } - } - ReleaseSharedLock(&tdc->lock); - afs_PutDCache(tdc); - } + ReleaseSharedLock(&tdc->lock); + afs_PutDCache(tdc); + } - minj += NCHUNKSATONCE; + minj += NCHUNKSATONCE; - } while (moredata); + } while (moredata); } if (code) { @@ -728,15 +771,15 @@ restart: } afs_Trace3(afs_iclSetp, CM_TRACE_STOREALLDONE, ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, avc->m.Length, ICL_TYPE_INT32, code); - /* would like a Trace5, but it doesn't exist...*/ + /* would like a Trace5, but it doesn't exist... */ afs_Trace3(afs_iclSetp, CM_TRACE_AVCLOCKER, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, avc->lock.wait_states, - ICL_TYPE_INT32, avc->lock.excl_locked); + ICL_TYPE_INT32, avc->lock.wait_states, ICL_TYPE_INT32, + avc->lock.excl_locked); afs_Trace4(afs_iclSetp, CM_TRACE_AVCLOCKEE, ICL_TYPE_POINTER, avc, - ICL_TYPE_INT32, avc->lock.wait_states, - ICL_TYPE_INT32, avc->lock.readers_reading, - ICL_TYPE_INT32, avc->lock.num_waiting ); - + ICL_TYPE_INT32, avc->lock.wait_states, ICL_TYPE_INT32, + avc->lock.readers_reading, ICL_TYPE_INT32, + avc->lock.num_waiting); + /* * Finally, if updated DataVersion matches newDV, we did all of the * stores. If mapDV indicates that the page cache was flushed up @@ -745,11 +788,11 @@ restart: * Turn off CDirty bit because the stored data is now in sync with server. */ if (code == 0 && hcmp(avc->mapDV, oldDV) >= 0) { - if ((!(afs_dvhack || foreign) && hsame(avc->m.DataVersion, newDV)) - || ((afs_dvhack || foreign) && (origCBs == afs_allCBs)) ) { - hset(avc->mapDV, newDV); - avc->states &= ~CDirty; - } + if ((!(afs_dvhack || foreign) && hsame(avc->m.DataVersion, newDV)) + || ((afs_dvhack || foreign) && (origCBs == afs_allCBs))) { + hset(avc->mapDV, newDV); + avc->states &= ~CDirty; + } } osi_FreeLargeSpace(dcList); @@ -758,8 +801,8 @@ restart: code = 0; return code; - -} /*afs_StoreAllSegments (new 03/02/94)*/ + +} /*afs_StoreAllSegments (new 03/02/94) */ /* @@ -775,8 +818,9 @@ restart: * For example, called after an error has been detected. Called * with avc write-locked, and afs_xdcache unheld. */ - -int afs_InvalidateAllSegments(struct vcache *avc) + +int +afs_InvalidateAllSegments(struct vcache *avc) { struct dcache *tdc; afs_int32 hash; @@ -788,11 +832,11 @@ int afs_InvalidateAllSegments(struct vcache *avc) afs_Trace2(afs_iclSetp, CM_TRACE_INVALL, ICL_TYPE_POINTER, avc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); hash = DVHash(&avc->fid); - avc->truncPos = AFS_NOTRUNC; /* don't truncate later */ - avc->states &= ~CExtendedFile; /* not any more */ + avc->truncPos = AFS_NOTRUNC; /* don't truncate later */ + avc->states &= ~CExtendedFile; /* not any more */ ObtainWriteLock(&afs_xcbhash, 459); afs_DequeueCallback(avc); - avc->states &= ~(CStatd|CDirty); /* mark status information as bad, too */ + avc->states &= ~(CStatd | CDirty); /* mark status information as bad, too */ ReleaseWriteLock(&afs_xcbhash); if (avc->fid.Fid.Vnode & 1 || (vType(avc) == VDIR)) osi_dnlc_purgedp(avc); @@ -805,10 +849,10 @@ int afs_InvalidateAllSegments(struct vcache *avc) * Block out others from screwing with this table; is a read lock * sufficient? */ - MObtainWriteLock(&afs_xdcache,286); + MObtainWriteLock(&afs_xdcache, 286); dcListMax = 0; - for(index = afs_dvhashTbl[hash]; index != NULLIDX;) { + for (index = afs_dvhashTbl[hash]; index != NULLIDX;) { if (afs_indexUnique[index] == avc->fid.Fid.Unique) { tdc = afs_GetDSlot(index, 0); ReleaseReadLock(&tdc->tlock); @@ -822,7 +866,7 @@ int afs_InvalidateAllSegments(struct vcache *avc) dcList = osi_Alloc(dcListMax * sizeof(struct dcache *)); dcListCount = 0; - for(index = afs_dvhashTbl[hash]; index != NULLIDX;) { + for (index = afs_dvhashTbl[hash]; index != NULLIDX;) { if (afs_indexUnique[index] == avc->fid.Fid.Unique) { tdc = afs_GetDSlot(index, 0); ReleaseReadLock(&tdc->tlock); @@ -846,7 +890,7 @@ int afs_InvalidateAllSegments(struct vcache *avc) } MReleaseWriteLock(&afs_xdcache); - for (i=0; ilock, 679); @@ -878,8 +922,9 @@ int afs_InvalidateAllSegments(struct vcache *avc) * Called with avc write-locked; in VFS40 systems, pvnLock is also * held. */ -int afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, - struct vrequest *areq, struct AFS_UCRED *acred) +int +afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, + struct vrequest *areq, struct AFS_UCRED *acred) { register struct dcache *tdc; register afs_int32 code; @@ -892,8 +937,8 @@ int afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, AFS_STATCNT(afs_TruncateAllSegments); avc->m.Date = osi_Time(); afs_Trace3(afs_iclSetp, CM_TRACE_TRUNCALL, ICL_TYPE_POINTER, avc, - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length), - ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(alen)); + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length), + ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(alen)); if (alen >= avc->m.Length) { /* * Special speedup since Sun's vm extends the file this way; @@ -908,7 +953,6 @@ int afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, avc->m.Length = alen; return 0; } - #if (defined(AFS_SUN5_ENV)) /* Zero unused portion of last page */ @@ -929,26 +973,27 @@ int afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, osi_VM_Truncate(avc, alen, acred); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,79); + ObtainWriteLock(&avc->lock, 79); avc->m.Length = alen; - - if (alen < avc->truncPos) avc->truncPos = alen; + + if (alen < avc->truncPos) + avc->truncPos = alen; code = DVHash(&avc->fid); /* block out others from screwing with this table */ - MObtainWriteLock(&afs_xdcache,287); + MObtainWriteLock(&afs_xdcache, 287); dcCount = 0; - for(index = afs_dvhashTbl[code]; index != NULLIDX;) { - if (afs_indexUnique[index] == avc->fid.Fid.Unique) { - tdc = afs_GetDSlot(index, 0); - ReleaseReadLock(&tdc->tlock); - if (!FidCmp(&tdc->f.fid, &avc->fid)) - dcCount++; - afs_PutDCache(tdc); - } - index = afs_dvnextTbl[index]; + for (index = afs_dvhashTbl[code]; index != NULLIDX;) { + if (afs_indexUnique[index] == avc->fid.Fid.Unique) { + tdc = afs_GetDSlot(index, 0); + ReleaseReadLock(&tdc->tlock); + if (!FidCmp(&tdc->f.fid, &avc->fid)) + dcCount++; + afs_PutDCache(tdc); + } + index = afs_dvnextTbl[index]; } /* Now allocate space where we can save those dcache entries, and @@ -958,22 +1003,22 @@ int afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, tdcArray = osi_Alloc(dcCount * sizeof(struct dcache *)); dcPos = 0; - for(index = afs_dvhashTbl[code]; index != NULLIDX;) { - if (afs_indexUnique[index] == avc->fid.Fid.Unique) { - tdc = afs_GetDSlot(index, 0); - ReleaseReadLock(&tdc->tlock); - if (!FidCmp(&tdc->f.fid, &avc->fid)) { - /* same file, and modified, we'll store it back */ - if (dcPos < dcCount) { - tdcArray[dcPos++] = tdc; + for (index = afs_dvhashTbl[code]; index != NULLIDX;) { + if (afs_indexUnique[index] == avc->fid.Fid.Unique) { + tdc = afs_GetDSlot(index, 0); + ReleaseReadLock(&tdc->tlock); + if (!FidCmp(&tdc->f.fid, &avc->fid)) { + /* same file, and modified, we'll store it back */ + if (dcPos < dcCount) { + tdcArray[dcPos++] = tdc; + } else { + afs_PutDCache(tdc); + } } else { afs_PutDCache(tdc); } - } else { - afs_PutDCache(tdc); } - } - index = afs_dvnextTbl[index]; + index = afs_dvnextTbl[index]; } MReleaseWriteLock(&afs_xdcache); @@ -985,7 +1030,8 @@ int afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, tdc = tdcArray[index]; newSize = alen - AFS_CHUNKTOBASE(tdc->f.chunk); - if (newSize < 0) newSize = 0; + if (newSize < 0) + newSize = 0; ObtainSharedLock(&tdc->lock, 672); if (newSize < tdc->f.chunkBytes) { UpgradeSToWLock(&tdc->lock, 673); diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index 184d6e7c6..0cbe00019 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -32,7 +32,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/stds.h" #include "afs/sysincludes.h" /* Standard vendor system headers */ @@ -55,7 +56,7 @@ RCSID("$Header$"); #endif /* !defined(UKERNEL) */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #if defined(AFS_SUN56_ENV) #include @@ -71,17 +72,17 @@ RCSID("$Header$"); #endif /* Exported variables */ -afs_rwlock_t afs_xserver; /* allocation lock for servers */ -struct server *afs_setTimeHost=0; /* last host we used for time */ -struct server *afs_servers[NSERVERS]; /* Hashed by server`s uuid & 1st ip */ -afs_rwlock_t afs_xsrvAddr; /* allocation lock for srvAddrs */ -struct srvAddr *afs_srvAddrs[NSERVERS]; /* Hashed by server's ip */ +afs_rwlock_t afs_xserver; /* allocation lock for servers */ +struct server *afs_setTimeHost = 0; /* last host we used for time */ +struct server *afs_servers[NSERVERS]; /* Hashed by server`s uuid & 1st ip */ +afs_rwlock_t afs_xsrvAddr; /* allocation lock for srvAddrs */ +struct srvAddr *afs_srvAddrs[NSERVERS]; /* Hashed by server's ip */ /* debugging aids - number of alloc'd server and srvAddr structs. */ -int afs_reuseServers = 0; +int afs_reuseServers = 0; int afs_reuseSrvAddrs = 0; -int afs_totalServers = 0; +int afs_totalServers = 0; int afs_totalSrvAddrs = 0; @@ -127,20 +128,21 @@ GetUpDownStats(struct server *srv) * As advertised. *------------------------------------------------------------------------*/ -void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown) +void +afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown) { register struct server *a_serverP = sa->server; register struct srvAddr *sap; - osi_timeval_t currTime, *currTimeP; /*Current time*/ - afs_int32 downTime; /*Computed downtime, in seconds*/ - struct afs_stats_SrvUpDownInfo *upDownP; /*Ptr to up/down info record*/ + osi_timeval_t currTime, *currTimeP; /*Current time */ + afs_int32 downTime; /*Computed downtime, in seconds */ + struct afs_stats_SrvUpDownInfo *upDownP; /*Ptr to up/down info record */ /* * If the server record is marked the same as the new status we've * been fed, then there isn't much to be done. */ - if (( a_isDown && (sa->sa_flags & SRVADDR_ISDOWN)) || - (!a_isDown && !(sa->sa_flags & SRVADDR_ISDOWN))) + if ((a_isDown && (sa->sa_flags & SRVADDR_ISDOWN)) + || (!a_isDown && !(sa->sa_flags & SRVADDR_ISDOWN))) return; if (a_isDown) { @@ -151,7 +153,7 @@ void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown) * server's up/down stats */ return; } - } + } /* * All ips are down we treat the whole server down */ @@ -163,7 +165,7 @@ void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown) afs_setTimeHost = 0; } else { sa->sa_flags &= ~SRVADDR_ISDOWN; - /* If any ips are up, the server is also marked up */ + /* If any ips are up, the server is also marked up */ a_serverP->flags &= ~SRVR_ISDOWN; for (sap = a_serverP->addr; sap; sap = sap->next_sa) { if (sap->sa_flags & SRVADDR_ISDOWN) { @@ -171,7 +173,7 @@ void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown) * server's up/down stats */ return; } - } + } } #ifndef AFS_NOSTATS /* @@ -192,7 +194,7 @@ void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown) (upDownP->numDownRecords)++; (upDownP->numUpRecords)--; - } /*Server being marked down*/ + } /*Server being marked down */ else { /* * Server going down -> up; remember everything about this @@ -208,40 +210,36 @@ void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown) if (a_serverP->numDowntimeIncidents == 1) (upDownP->numRecordsNeverDown)--; upDownP->sumOfDowntimes += downTime; - if ((upDownP->shortestDowntime == 0) || - (downTime < upDownP->shortestDowntime)) + if ((upDownP->shortestDowntime == 0) + || (downTime < upDownP->shortestDowntime)) upDownP->shortestDowntime = downTime; - if ((upDownP->longestDowntime == 0) || - (downTime > upDownP->longestDowntime)) + if ((upDownP->longestDowntime == 0) + || (downTime > upDownP->longestDowntime)) upDownP->longestDowntime = downTime; if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET0) (upDownP->downDurations[0])++; - else - if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET1) - (upDownP->downDurations[1])++; - else - if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET2) - (upDownP->downDurations[2])++; - else - if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET3) - (upDownP->downDurations[3])++; - else - if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET4) - (upDownP->downDurations[4])++; - else - if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET5) - (upDownP->downDurations[5])++; + else if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET1) + (upDownP->downDurations[1])++; + else if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET2) + (upDownP->downDurations[2])++; + else if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET3) + (upDownP->downDurations[3])++; + else if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET4) + (upDownP->downDurations[4])++; + else if (downTime <= AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET5) + (upDownP->downDurations[5])++; else (upDownP->downDurations[6])++; - } /*Server being marked up*/ + } /*Server being marked up */ #endif -} /*MarkServerUpOrDown*/ +} /*MarkServerUpOrDown */ -void afs_ServerDown(struct srvAddr *sa) +void +afs_ServerDown(struct srvAddr *sa) { register struct server *aserver = sa->server; @@ -250,25 +248,27 @@ void afs_ServerDown(struct srvAddr *sa) return; afs_MarkServerUpOrDown(sa, SRVR_ISDOWN); if (sa->sa_portal == aserver->cell->vlport) - print_internet_address("afs: Lost contact with volume location server ", - sa, "", 1); + print_internet_address + ("afs: Lost contact with volume location server ", sa, "", 1); else - print_internet_address("afs: Lost contact with file server ", sa, "", 1); + print_internet_address("afs: Lost contact with file server ", sa, "", + 1); -} /*ServerDown*/ +} /*ServerDown */ /* return true if we have any callback promises from this server */ -static int HaveCallBacksFrom(struct server *aserver) +static int +HaveCallBacksFrom(struct server *aserver) { register afs_int32 now; register int i; register struct vcache *tvc; AFS_STATCNT(HaveCallBacksFrom); - now = osi_Time(); /* for checking for expired callbacks */ - for(i=0;ihnext) { + now = osi_Time(); /* for checking for expired callbacks */ + for (i = 0; i < VCSIZE; i++) { /* for all guys in the hash table */ + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { /* * Check to see if this entry has an unexpired callback promise * from the required host @@ -280,10 +280,11 @@ static int HaveCallBacksFrom(struct server *aserver) } return 0; -} /*HaveCallBacksFrom*/ +} /*HaveCallBacksFrom */ -static void CheckVLServer(register struct srvAddr *sa, struct vrequest *areq) +static void +CheckVLServer(register struct srvAddr *sa, struct vrequest *areq) { register struct server *aserver = sa->server; register struct conn *tc; @@ -291,12 +292,13 @@ static void CheckVLServer(register struct srvAddr *sa, struct vrequest *areq) AFS_STATCNT(CheckVLServer); /* Ping dead servers to see if they're back */ - if (!((aserver->flags & SRVR_ISDOWN) || (sa->sa_flags & SRVADDR_ISDOWN)) || (aserver->flags & SRVR_ISGONE)) + if (!((aserver->flags & SRVR_ISDOWN) || (sa->sa_flags & SRVADDR_ISDOWN)) + || (aserver->flags & SRVR_ISGONE)) return; if (!aserver->cell) - return; /* can't do much */ + return; /* can't do much */ - tc = afs_ConnByHost(aserver, aserver->cell->vlport, + tc = afs_ConnByHost(aserver, aserver->cell->vlport, aserver->cell->cellNum, areq, 1, SHARED_LOCK); if (!tc) return; @@ -314,15 +316,15 @@ static void CheckVLServer(register struct srvAddr *sa, struct vrequest *areq) if (code == 0 || (code <= -450 && code >= -470)) { if (tc->srvr == sa) { afs_MarkServerUpOrDown(sa, 0); - print_internet_address("afs: volume location server ", - sa, " is back up", 2); + print_internet_address("afs: volume location server ", sa, + " is back up", 2); } } -} /*CheckVLServer*/ +} /*CheckVLServer */ -#ifndef AFS_MINCHANGE /* So that some can increase it in param.h */ +#ifndef AFS_MINCHANGE /* So that some can increase it in param.h */ #define AFS_MINCHANGE 2 /* min change we'll bother with */ #endif #ifndef AFS_MAXCHANGEBACK @@ -353,16 +355,17 @@ static void CheckVLServer(register struct srvAddr *sa, struct vrequest *areq) * entries. *------------------------------------------------------------------------*/ -void afs_CountServers(void) +void +afs_CountServers(void) { - int currIdx; /*Curr idx into srv table*/ - struct server *currSrvP; /*Ptr to curr server record*/ - afs_int32 currChainLen; /*Length of curr hash chain*/ - osi_timeval_t currTime; /*Current time*/ - osi_timeval_t *currTimeP; /*Ptr to above*/ - afs_int32 srvRecordAge; /*Age of server record, in secs*/ + int currIdx; /*Curr idx into srv table */ + struct server *currSrvP; /*Ptr to curr server record */ + afs_int32 currChainLen; /*Length of curr hash chain */ + osi_timeval_t currTime; /*Current time */ + osi_timeval_t *currTimeP; /*Ptr to above */ + afs_int32 srvRecordAge; /*Age of server record, in secs */ struct afs_stats_SrvUpDownInfo *upDownP; /*Ptr to current up/down - info being manipulated*/ + * info being manipulated */ /* * Write-lock the server table so we don't get any interference. @@ -376,25 +379,29 @@ void afs_CountServers(void) */ afs_stats_cmperf.srvMaxChainLength = 0; - afs_stats_cmperf.fs_UpDown[0].sumOfRecordAges = 0; + afs_stats_cmperf.fs_UpDown[0].sumOfRecordAges = 0; afs_stats_cmperf.fs_UpDown[0].ageOfYoungestRecord = 0; - afs_stats_cmperf.fs_UpDown[0].ageOfOldestRecord = 0; - memset((char *) afs_stats_cmperf.fs_UpDown[0].downIncidents, 0, AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS * sizeof(afs_int32)); + afs_stats_cmperf.fs_UpDown[0].ageOfOldestRecord = 0; + memset((char *)afs_stats_cmperf.fs_UpDown[0].downIncidents, 0, + AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS * sizeof(afs_int32)); - afs_stats_cmperf.fs_UpDown[1].sumOfRecordAges = 0; + afs_stats_cmperf.fs_UpDown[1].sumOfRecordAges = 0; afs_stats_cmperf.fs_UpDown[1].ageOfYoungestRecord = 0; - afs_stats_cmperf.fs_UpDown[1].ageOfOldestRecord = 0; - memset((char *) afs_stats_cmperf.fs_UpDown[1].downIncidents, 0, AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS * sizeof(afs_int32)); + afs_stats_cmperf.fs_UpDown[1].ageOfOldestRecord = 0; + memset((char *)afs_stats_cmperf.fs_UpDown[1].downIncidents, 0, + AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS * sizeof(afs_int32)); - afs_stats_cmperf.vl_UpDown[0].sumOfRecordAges = 0; + afs_stats_cmperf.vl_UpDown[0].sumOfRecordAges = 0; afs_stats_cmperf.vl_UpDown[0].ageOfYoungestRecord = 0; - afs_stats_cmperf.vl_UpDown[0].ageOfOldestRecord = 0; - memset((char *) afs_stats_cmperf.vl_UpDown[0].downIncidents, 0, AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS * sizeof(afs_int32)); + afs_stats_cmperf.vl_UpDown[0].ageOfOldestRecord = 0; + memset((char *)afs_stats_cmperf.vl_UpDown[0].downIncidents, 0, + AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS * sizeof(afs_int32)); - afs_stats_cmperf.vl_UpDown[1].sumOfRecordAges = 0; + afs_stats_cmperf.vl_UpDown[1].sumOfRecordAges = 0; afs_stats_cmperf.vl_UpDown[1].ageOfYoungestRecord = 0; - afs_stats_cmperf.vl_UpDown[1].ageOfOldestRecord = 0; - memset((char *) afs_stats_cmperf.vl_UpDown[1].downIncidents, 0, AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS * sizeof(afs_int32)); + afs_stats_cmperf.vl_UpDown[1].ageOfOldestRecord = 0; + memset((char *)afs_stats_cmperf.vl_UpDown[1].downIncidents, 0, + AFS_STATS_NUM_DOWNTIME_INCIDENTS_BUCKETS * sizeof(afs_int32)); /* * Compute the current time, used to figure out server record ages. @@ -407,7 +414,8 @@ void afs_CountServers(void) */ for (currIdx = 0; currIdx < NSERVERS; currIdx++) { currChainLen = 0; - for (currSrvP = afs_servers[currIdx]; currSrvP; currSrvP = currSrvP->next) { + for (currSrvP = afs_servers[currIdx]; currSrvP; + currSrvP = currSrvP->next) { /* * Bump the current chain length. */ @@ -417,8 +425,8 @@ void afs_CountServers(void) * Any further tallying for this record will only be done if it has * been activated. */ - if ( (currSrvP->flags & AFS_SERVER_FLAG_ACTIVATED) && - currSrvP->addr && currSrvP->cell ) { + if ((currSrvP->flags & AFS_SERVER_FLAG_ACTIVATED) + && currSrvP->addr && currSrvP->cell) { /* * Compute the current server record's age, then remember it @@ -427,38 +435,34 @@ void afs_CountServers(void) srvRecordAge = currTime.tv_sec - currSrvP->activationTime; upDownP = GetUpDownStats(currSrvP); upDownP->sumOfRecordAges += srvRecordAge; - if ((upDownP->ageOfYoungestRecord == 0) || - (srvRecordAge < upDownP->ageOfYoungestRecord)) + if ((upDownP->ageOfYoungestRecord == 0) + || (srvRecordAge < upDownP->ageOfYoungestRecord)) upDownP->ageOfYoungestRecord = srvRecordAge; - if ((upDownP->ageOfOldestRecord == 0) || - (srvRecordAge > upDownP->ageOfOldestRecord)) + if ((upDownP->ageOfOldestRecord == 0) + || (srvRecordAge > upDownP->ageOfOldestRecord)) upDownP->ageOfOldestRecord = srvRecordAge; - if (currSrvP->numDowntimeIncidents <= - AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET0) - (upDownP->downIncidents[0])++; - else - if (currSrvP->numDowntimeIncidents <= - AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET1) - (upDownP->downIncidents[1])++; - else - if (currSrvP->numDowntimeIncidents <= - AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET2) - (upDownP->downIncidents[2])++; - else - if (currSrvP->numDowntimeIncidents <= - AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET3) - (upDownP->downIncidents[3])++; - else - if (currSrvP->numDowntimeIncidents <= - AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET4) - (upDownP->downIncidents[4])++; - else - (upDownP->downIncidents[5])++; - - - } /*Current server has been active*/ - } /*Walk this chain*/ + if (currSrvP->numDowntimeIncidents <= + AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET0) + (upDownP->downIncidents[0])++; + else if (currSrvP->numDowntimeIncidents <= + AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET1) + (upDownP->downIncidents[1])++; + else if (currSrvP->numDowntimeIncidents <= + AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET2) + (upDownP->downIncidents[2])++; + else if (currSrvP->numDowntimeIncidents <= + AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET3) + (upDownP->downIncidents[3])++; + else if (currSrvP->numDowntimeIncidents <= + AFS_STATS_MAX_DOWNTIME_INCIDENTS_BUCKET4) + (upDownP->downIncidents[4])++; + else + (upDownP->downIncidents[5])++; + + + } /*Current server has been active */ + } /*Walk this chain */ /* * Before advancing to the next chain, remember facts about this one. @@ -472,19 +476,20 @@ void afs_CountServers(void) afs_stats_cmperf.srvMaxChainLength = currChainLen; if (currChainLen > afs_stats_cmperf.srvMaxChainLengthHWM) afs_stats_cmperf.srvMaxChainLengthHWM = currChainLen; - } /*Update chain length maximum*/ - } /*For each hash chain*/ + } /*Update chain length maximum */ + } /*For each hash chain */ /* * We're done. Unlock the server table before returning to our caller. */ ReleaseReadLock(&afs_xserver); -} /*afs_CountServers*/ +} /*afs_CountServers */ /* check down servers (if adown), or running servers (if !adown) */ -void afs_CheckServers(int adown, struct cell *acellp) +void +afs_CheckServers(int adown, struct cell *acellp) { struct vrequest treq; struct server *ts; @@ -502,30 +507,32 @@ void afs_CheckServers(int adown, struct cell *acellp) XSTATS_DECLS; AFS_STATCNT(afs_CheckServers); - if ((code = afs_InitReq(&treq, &afs_osi_cred))) return; - ObtainReadLock(&afs_xserver); /* Necessary? */ - ObtainReadLock(&afs_xsrvAddr); + if ((code = afs_InitReq(&treq, &afs_osi_cred))) + return; + ObtainReadLock(&afs_xserver); /* Necessary? */ + ObtainReadLock(&afs_xsrvAddr); srvAddrCount = 0; - for (i=0;inext_bkt) { + for (i = 0; i < NSERVERS; i++) { + for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) { srvAddrCount++; } } addrs = afs_osi_Alloc(srvAddrCount * sizeof(*addrs)); j = 0; - for (i=0;inext_bkt) { - if (j >= srvAddrCount) break; + for (i = 0; i < NSERVERS; i++) { + for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) { + if (j >= srvAddrCount) + break; addrs[j++] = sa; } } - ReleaseReadLock(&afs_xsrvAddr); + ReleaseReadLock(&afs_xsrvAddr); ReleaseReadLock(&afs_xserver); - for (i=0; iserver; if (!ts) @@ -537,8 +544,8 @@ void afs_CheckServers(int adown, struct cell *acellp) if (acellp && acellp != ts->cell) continue; - if ((!adown && (sa->sa_flags & SRVADDR_ISDOWN)) || - (adown && !(sa->sa_flags & SRVADDR_ISDOWN))) + if ((!adown && (sa->sa_flags & SRVADDR_ISDOWN)) + || (adown && !(sa->sa_flags & SRVADDR_ISDOWN))) continue; /* check vlserver with special code */ @@ -547,18 +554,19 @@ void afs_CheckServers(int adown, struct cell *acellp) continue; } - if (!ts->cell) /* not really an active server, anyway, it must */ - continue; /* have just been added by setsprefs */ + if (!ts->cell) /* not really an active server, anyway, it must */ + continue; /* have just been added by setsprefs */ /* get a connection, even if host is down; bumps conn ref count */ tu = afs_GetUser(treq.uid, ts->cell->cellNum, SHARED_LOCK); tc = afs_ConnBySA(sa, ts->cell->fsport, ts->cell->cellNum, tu, - 1/*force*/, 1/*create*/, SHARED_LOCK); + 1 /*force */ , 1 /*create */ , SHARED_LOCK); afs_PutUser(tu, SHARED_LOCK); - if (!tc) continue; + if (!tc) + continue; - if ((sa->sa_flags & SRVADDR_ISDOWN) || HaveCallBacksFrom(ts) || - (tc->srvr->server == afs_setTimeHost)) { + if ((sa->sa_flags & SRVADDR_ISDOWN) || HaveCallBacksFrom(ts) + || (tc->srvr->server == afs_setTimeHost)) { if (sa->sa_flags & SRVADDR_ISDOWN) { rx_SetConnDeadTime(tc->id, 3); setTimer = 1; @@ -567,9 +575,11 @@ void afs_CheckServers(int adown, struct cell *acellp) } XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GETTIME); - start = osi_Time(); /* time the gettimeofday call */ + start = osi_Time(); /* time the gettimeofday call */ RX_AFS_GUNLOCK(); - code = RXAFS_GetTime(tc->id, (afs_int32 *)&tv.tv_sec, (afs_int32 *)&tv.tv_usec); + code = + RXAFS_GetTime(tc->id, (afs_int32 *) & tv.tv_sec, + (afs_int32 *) & tv.tv_usec); RX_AFS_GLOCK(); end = osi_Time(); XSTATS_END_TIME; @@ -579,15 +589,15 @@ void afs_CheckServers(int adown, struct cell *acellp) * use for the time and the time is really different, then * really set the time */ - if (code == 0 && start == end && afs_setTime != 0 && - (tc->srvr->server == afs_setTimeHost || - /* Sync only to a server in the local cell */ - (afs_setTimeHost == (struct server *)0 && - afs_IsPrimaryCell(ts->cell)))) { + if (code == 0 && start == end && afs_setTime != 0 + && (tc->srvr->server == afs_setTimeHost || + /* Sync only to a server in the local cell */ + (afs_setTimeHost == (struct server *)0 + && afs_IsPrimaryCell(ts->cell)))) { - char msgbuf[90]; /* strlen("afs: setting clock...") + slop */ + char msgbuf[90]; /* strlen("afs: setting clock...") + slop */ /* set the time */ - delta = end - tv.tv_sec; /* how many secs fast we are */ + delta = end - tv.tv_sec; /* how many secs fast we are */ /* see if clock has changed enough to make it worthwhile */ if (delta >= AFS_MINCHANGE || delta <= -AFS_MINCHANGE) { if (delta > AFS_MAXCHANGEBACK) { @@ -598,19 +608,28 @@ void afs_CheckServers(int adown, struct cell *acellp) if (delta > 0) { strcpy(msgbuf, "afs: setting clock back "); if (delta > AFS_MAXCHANGEBACK) { - afs_strcat(msgbuf, afs_cv2string(&tbuffer[CVBS], AFS_MAXCHANGEBACK)); + afs_strcat(msgbuf, + afs_cv2string(&tbuffer[CVBS], + AFS_MAXCHANGEBACK)); afs_strcat(msgbuf, " seconds (of "); - afs_strcat(msgbuf, afs_cv2string(&tbuffer[CVBS], delta - AFS_MAXCHANGEBACK)); + afs_strcat(msgbuf, + afs_cv2string(&tbuffer[CVBS], + delta - + AFS_MAXCHANGEBACK)); afs_strcat(msgbuf, ", via "); - print_internet_address(msgbuf, sa, "); clock is still fast.", 0); + print_internet_address(msgbuf, sa, + "); clock is still fast.", + 0); } else { - afs_strcat(msgbuf, afs_cv2string(&tbuffer[CVBS], delta)); + afs_strcat(msgbuf, + afs_cv2string(&tbuffer[CVBS], delta)); afs_strcat(msgbuf, " seconds (via "); print_internet_address(msgbuf, sa, ").", 0); } } else { strcpy(msgbuf, "afs: setting clock ahead "); - afs_strcat(msgbuf, afs_cv2string(&tbuffer[CVBS], -delta)); + afs_strcat(msgbuf, + afs_cv2string(&tbuffer[CVBS], -delta)); afs_strcat(msgbuf, " seconds (via "); print_internet_address(msgbuf, sa, ").", 0); } @@ -619,12 +638,14 @@ void afs_CheckServers(int adown, struct cell *acellp) } if (setTimer) rx_SetConnDeadTime(tc->id, afs_rx_deadtime); - if (code >= 0 && (sa->sa_flags & SRVADDR_ISDOWN) && (tc->srvr == sa)) { + if (code >= 0 && (sa->sa_flags & SRVADDR_ISDOWN) + && (tc->srvr == sa)) { /* server back up */ - print_internet_address("afs: file server ", sa, " is back up", 2); + print_internet_address("afs: file server ", sa, " is back up", + 2); ObtainWriteLock(&afs_xserver, 244); - ObtainWriteLock(&afs_xsrvAddr, 245); + ObtainWriteLock(&afs_xsrvAddr, 245); afs_MarkServerUpOrDown(sa, 0); ReleaseWriteLock(&afs_xsrvAddr); ReleaseWriteLock(&afs_xserver); @@ -636,22 +657,23 @@ void afs_CheckServers(int adown, struct cell *acellp) if (code < 0) { /* server crashed */ afs_ServerDown(sa); - ForceNewConnections(sa); /* multi homed clients */ + ForceNewConnections(sa); /* multi homed clients */ } } } afs_PutConn(tc, SHARED_LOCK); /* done with it now */ - } /* Outer loop over addrs */ + } /* Outer loop over addrs */ afs_osi_Free(addrs, srvAddrCount * sizeof(*addrs)); -} /*afs_CheckServers*/ +} /*afs_CheckServers */ /* find a server structure given the host address */ -struct server *afs_FindServer (afs_int32 aserver, ushort aport, - afsUUID *uuidp, afs_int32 locktype) +struct server * +afs_FindServer(afs_int32 aserver, ushort aport, afsUUID * uuidp, + afs_int32 locktype) { struct server *ts; struct srvAddr *sa; @@ -661,22 +683,23 @@ struct server *afs_FindServer (afs_int32 aserver, ushort aport, if (uuidp) { i = afs_uuid_hash(uuidp) % NSERVERS; for (ts = afs_servers[i]; ts; ts = ts->next) { - if ( (ts->flags & SRVR_MULTIHOMED) && - (memcmp((char *)uuidp, (char *)&ts->sr_uuid, sizeof(*uuidp)) == 0) && - (!ts->addr || (ts->addr->sa_portal == aport)) ) + if ((ts->flags & SRVR_MULTIHOMED) + && + (memcmp((char *)uuidp, (char *)&ts->sr_uuid, sizeof(*uuidp)) + == 0) && (!ts->addr || (ts->addr->sa_portal == aport))) return ts; } } else { i = SHash(aserver); for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) { if ((sa->sa_ip == aserver) && (sa->sa_portal == aport)) { - return sa->server; + return sa->server; } } } return NULL; -} /*afs_FindServer*/ +} /*afs_FindServer */ /* some code for creating new server structs and setting preferences follows @@ -709,22 +732,23 @@ NB: Has to be unsigned, since shifts on signed quantities may preserve #define ranstage(x) (x)= (afs_uint32) (3141592621U*((afs_uint32)x)+1) -unsigned int afs_random(void) +unsigned int +afs_random(void) { static afs_int32 state = 0; register int i; AFS_STATCNT(afs_random); if (!state) { - osi_timeval_t t; + osi_timeval_t t; osi_GetTime(&t); /* * 0xfffffff0 was changed to (~0 << 4) since it works no matter how many * bits are in a tv_usec */ - state = (t.tv_usec & (~0 << 4) ) + (rxi_getaddr() & 0xff); + state = (t.tv_usec & (~0 << 4)) + (rxi_getaddr() & 0xff); state += (t.tv_sec & 0xff); - for (i=0;i<30;i++) { + for (i = 0; i < 30; i++) { ranstage(state); } } @@ -732,7 +756,7 @@ unsigned int afs_random(void) ranstage(state); return (state); -} /*afs_random*/ +} /*afs_random */ /* returns int 0..14 using the high bits of a pseudo-random number instead of the low bits, as the low bits are "less random" than the high ones... @@ -740,85 +764,90 @@ unsigned int afs_random(void) need to multiply by something with lots of ones in it, so multiply by 8 or 16 is right out. */ -int afs_randomMod15(void) +int +afs_randomMod15(void) { -afs_uint32 temp; + afs_uint32 temp; -temp = afs_random() >> 4; -temp = (temp *15) >> 28; + temp = afs_random() >> 4; + temp = (temp * 15) >> 28; -return temp; + return temp; } -int afs_randomMod127(void) +int +afs_randomMod127(void) { -afs_uint32 temp; + afs_uint32 temp; -temp = afs_random() >> 7; -temp = (temp *127) >> 25; + temp = afs_random() >> 7; + temp = (temp * 127) >> 25; -return temp; + return temp; } /* afs_SortOneServer() * Sort all of the srvAddrs, of a server struct, by rank from low to high. */ -void afs_SortOneServer(struct server *asp) +void +afs_SortOneServer(struct server *asp) { - struct srvAddr **rootsa, *lowsa, *tsa, *lowprev; - int lowrank, rank; - - for (rootsa=&(asp->addr); *rootsa; rootsa=&(lowsa->next_sa)) { - lowprev = NULL; - lowsa = *rootsa; /* lowest sa is the first one */ - lowrank = lowsa->sa_iprank; - - for (tsa=*rootsa; tsa->next_sa; tsa=tsa->next_sa) { - rank = tsa->next_sa->sa_iprank; - if (rank < lowrank) { - lowprev = tsa; - lowsa = tsa->next_sa; - lowrank = lowsa->sa_iprank; - } - } - if (lowprev) { /* found one lower, so rearrange them */ - lowprev->next_sa = lowsa->next_sa; - lowsa->next_sa = *rootsa; - *rootsa = lowsa; - } - } + struct srvAddr **rootsa, *lowsa, *tsa, *lowprev; + int lowrank, rank; + + for (rootsa = &(asp->addr); *rootsa; rootsa = &(lowsa->next_sa)) { + lowprev = NULL; + lowsa = *rootsa; /* lowest sa is the first one */ + lowrank = lowsa->sa_iprank; + + for (tsa = *rootsa; tsa->next_sa; tsa = tsa->next_sa) { + rank = tsa->next_sa->sa_iprank; + if (rank < lowrank) { + lowprev = tsa; + lowsa = tsa->next_sa; + lowrank = lowsa->sa_iprank; + } + } + if (lowprev) { /* found one lower, so rearrange them */ + lowprev->next_sa = lowsa->next_sa; + lowsa->next_sa = *rootsa; + *rootsa = lowsa; + } + } } - + /* afs_SortServer() * Sort the pointer to servers by the server's rank (its lowest rank). * It is assumed that the server already has its IP addrs sorted (the * first being its lowest rank: afs_GetServer() calls afs_SortOneServer()). */ -void afs_SortServers(struct server *aservers[], int count) +void +afs_SortServers(struct server *aservers[], int count) { struct server *ts; int i, j, low; AFS_STATCNT(afs_SortServers); - for (i=0; iaddr)) - break; - if ((!aservers[low]) || (!aservers[low]->addr)) - break; - if (aservers[j]->addr->sa_iprank < aservers[low]->addr->sa_iprank) { - low = j; - } - } - if (low != i) { - ts = aservers[i]; - aservers[i] = aservers[low]; - aservers[low] = ts; - } + for (i = 0; i < count; i++) { + if (!aservers[i]) + break; + for (low = i, j = i + 1; j <= count; j++) { + if ((!aservers[j]) || (!aservers[j]->addr)) + break; + if ((!aservers[low]) || (!aservers[low]->addr)) + break; + if (aservers[j]->addr->sa_iprank < aservers[low]->addr->sa_iprank) { + low = j; + } + } + if (low != i) { + ts = aservers[i]; + aservers[i] = aservers[low]; + aservers[low] = ts; + } } -} /*afs_SortServers*/ +} /*afs_SortServers */ /* afs_SetServerPrefs is rather system-dependent. It pokes around in kernel data structures to determine what the local IP addresses and subnet masks @@ -865,111 +894,105 @@ void afs_SortServers(struct server *aservers[], int count) #define USEIFADDR - + #if defined(AFS_SUN5_ENV) && ! defined(AFS_SUN56_ENV) #include /* IP interface structure, one per local address */ -typedef struct ipif_s { /**/ - struct ipif_s * ipif_next; - struct ill_s * ipif_ill; /* Back pointer to our ill */ - long ipif_id; /* Logical unit number */ - u_int ipif_mtu; /* Starts at ipif_ill->ill_max_frag */ - afs_int32 ipif_local_addr; /* Local IP address for this if. */ - afs_int32 ipif_net_mask; /* Net mask for this interface. */ - afs_int32 ipif_broadcast_addr; /* Broadcast addr for this interface. */ - afs_int32 ipif_pp_dst_addr; /* Point-to-point dest address. */ - u_int ipif_flags; /* Interface flags. */ - u_int ipif_metric; /* BSD if metric, for compatibility. */ - u_int ipif_ire_type; /* LOCAL or LOOPBACK */ - mblk_t * ipif_arp_down_mp; /* Allocated at time arp comes up to - * prevent awkward out of mem condition - * later - */ - mblk_t * ipif_saved_ire_mp; /* Allocated for each extra IRE_SUBNET/ - * RESOLVER on this interface so that - * they can survive ifconfig down. - */ - /* - * The packet counts in the ipif contain the sum of the - * packet counts in dead IREs that were affiliated with - * this ipif. - */ - u_long ipif_fo_pkt_count; /* Forwarded thru our dead IREs */ - u_long ipif_ib_pkt_count; /* Inbound packets for our dead IREs */ - u_long ipif_ob_pkt_count; /* Outbound packets to our dead IREs */ - unsigned int - ipif_multicast_up : 1, /* We have joined the allhosts group */ - : 0; +typedef struct ipif_s { + /**/ struct ipif_s *ipif_next; + struct ill_s *ipif_ill; /* Back pointer to our ill */ + long ipif_id; /* Logical unit number */ + u_int ipif_mtu; /* Starts at ipif_ill->ill_max_frag */ + afs_int32 ipif_local_addr; /* Local IP address for this if. */ + afs_int32 ipif_net_mask; /* Net mask for this interface. */ + afs_int32 ipif_broadcast_addr; /* Broadcast addr for this interface. */ + afs_int32 ipif_pp_dst_addr; /* Point-to-point dest address. */ + u_int ipif_flags; /* Interface flags. */ + u_int ipif_metric; /* BSD if metric, for compatibility. */ + u_int ipif_ire_type; /* LOCAL or LOOPBACK */ + mblk_t *ipif_arp_down_mp; /* Allocated at time arp comes up to + * prevent awkward out of mem condition + * later + */ + mblk_t *ipif_saved_ire_mp; /* Allocated for each extra IRE_SUBNET/ + * RESOLVER on this interface so that + * they can survive ifconfig down. + */ + /* + * The packet counts in the ipif contain the sum of the + * packet counts in dead IREs that were affiliated with + * this ipif. + */ + u_long ipif_fo_pkt_count; /* Forwarded thru our dead IREs */ + u_long ipif_ib_pkt_count; /* Inbound packets for our dead IREs */ + u_long ipif_ob_pkt_count; /* Outbound packets to our dead IREs */ + unsigned int + ipif_multicast_up:1, /* We have joined the allhosts group */ + : 0; } ipif_t; -typedef struct ipfb_s { /**/ - struct ipf_s * ipfb_ipf; /* List of ... */ - kmutex_t ipfb_lock; /* Protect all ipf in list */ +typedef struct ipfb_s { + /**/ struct ipf_s *ipfb_ipf; /* List of ... */ + kmutex_t ipfb_lock; /* Protect all ipf in list */ } ipfb_t; -typedef struct ilm_s { /**/ - afs_int32 ilm_addr; - int ilm_refcnt; - u_int ilm_timer; /* IGMP */ - struct ipif_s * ilm_ipif; /* Back pointer to ipif */ - struct ilm_s * ilm_next; /* Linked list for each ill */ +typedef struct ilm_s { + /**/ afs_int32 ilm_addr; + int ilm_refcnt; + u_int ilm_timer; /* IGMP */ + struct ipif_s *ilm_ipif; /* Back pointer to ipif */ + struct ilm_s *ilm_next; /* Linked list for each ill */ } ilm_t; -typedef struct ill_s { /**/ - struct ill_s * ill_next; /* Chained in at ill_g_head. */ - struct ill_s ** ill_ptpn; /* Pointer to previous next. */ - queue_t * ill_rq; /* Read queue. */ - queue_t * ill_wq; /* Write queue. */ - - int ill_error; /* Error value sent up by device. */ - - ipif_t * ill_ipif; /* Interface chain for this ILL. */ - u_int ill_ipif_up_count; /* Number of IPIFs currently up. */ - u_int ill_max_frag; /* Max IDU. */ - char * ill_name; /* Our name. */ - u_int ill_name_length; /* Name length, incl. terminator. */ - u_int ill_subnet_type; /* IRE_RESOLVER or IRE_SUBNET. */ - u_int ill_ppa; /* Physical Point of Attachment num. */ - u_long ill_sap; - int ill_sap_length; /* Including sign (for position) */ - u_int ill_phys_addr_length; /* Excluding the sap. */ - mblk_t * ill_frag_timer_mp; /* Reassembly timer state. */ - ipfb_t * ill_frag_hash_tbl; /* Fragment hash list head. */ - - queue_t * ill_bind_pending_q; /* Queue waiting for DL_BIND_ACK. */ - ipif_t * ill_ipif_pending; /* IPIF waiting for DL_BIND_ACK. */ - - /* ill_hdr_length and ill_hdr_mp will be non zero if - * the underlying device supports the M_DATA fastpath - */ - int ill_hdr_length; +typedef struct ill_s { + /**/ struct ill_s *ill_next; /* Chained in at ill_g_head. */ + struct ill_s **ill_ptpn; /* Pointer to previous next. */ + queue_t *ill_rq; /* Read queue. */ + queue_t *ill_wq; /* Write queue. */ + + int ill_error; /* Error value sent up by device. */ + + ipif_t *ill_ipif; /* Interface chain for this ILL. */ + u_int ill_ipif_up_count; /* Number of IPIFs currently up. */ + u_int ill_max_frag; /* Max IDU. */ + char *ill_name; /* Our name. */ + u_int ill_name_length; /* Name length, incl. terminator. */ + u_int ill_subnet_type; /* IRE_RESOLVER or IRE_SUBNET. */ + u_int ill_ppa; /* Physical Point of Attachment num. */ + u_long ill_sap; + int ill_sap_length; /* Including sign (for position) */ + u_int ill_phys_addr_length; /* Excluding the sap. */ + mblk_t *ill_frag_timer_mp; /* Reassembly timer state. */ + ipfb_t *ill_frag_hash_tbl; /* Fragment hash list head. */ + + queue_t *ill_bind_pending_q; /* Queue waiting for DL_BIND_ACK. */ + ipif_t *ill_ipif_pending; /* IPIF waiting for DL_BIND_ACK. */ + + /* ill_hdr_length and ill_hdr_mp will be non zero if + * the underlying device supports the M_DATA fastpath + */ + int ill_hdr_length; - ilm_t * ill_ilm; /* Multicast mebership for lower ill */ + ilm_t *ill_ilm; /* Multicast mebership for lower ill */ - /* All non-nil cells between 'ill_first_mp_to_free' and - * 'ill_last_mp_to_free' are freed in ill_delete. - */ + /* All non-nil cells between 'ill_first_mp_to_free' and + * 'ill_last_mp_to_free' are freed in ill_delete. + */ #define ill_first_mp_to_free ill_hdr_mp - mblk_t * ill_hdr_mp; /* Contains fastpath template */ - mblk_t * ill_bcast_mp; /* DLPI header for broadcasts. */ - mblk_t * ill_bind_pending; /* T_BIND_REQ awaiting completion. */ - mblk_t * ill_resolver_mp; /* Resolver template. */ - mblk_t * ill_attach_mp; - mblk_t * ill_bind_mp; - mblk_t * ill_unbind_mp; - mblk_t * ill_detach_mp; + mblk_t *ill_hdr_mp; /* Contains fastpath template */ + mblk_t *ill_bcast_mp; /* DLPI header for broadcasts. */ + mblk_t *ill_bind_pending; /* T_BIND_REQ awaiting completion. */ + mblk_t *ill_resolver_mp; /* Resolver template. */ + mblk_t *ill_attach_mp; + mblk_t *ill_bind_mp; + mblk_t *ill_unbind_mp; + mblk_t *ill_detach_mp; #define ill_last_mp_to_free ill_detach_mp - u_int - ill_frag_timer_running : 1, - ill_needs_attach : 1, - ill_is_ptp : 1, - ill_priv_stream : 1, - ill_unbind_pending : 1, - - ill_pad_to_bit_31 : 27; - MI_HRT_DCL(ill_rtime) - MI_HRT_DCL(ill_rtmp) + u_int ill_frag_timer_running:1, ill_needs_attach:1, ill_is_ptp:1, + ill_priv_stream:1, ill_unbind_pending:1, ill_pad_to_bit_31:27; + MI_HRT_DCL(ill_rtime) + MI_HRT_DCL(ill_rtmp) } ill_t; #endif @@ -988,168 +1011,181 @@ typedef struct ill_s { /**/ * afs_uint32 subnetmask; subnet mask of local addr in net order * */ -int afsi_SetServerIPRank(struct srvAddr *sa, afs_int32 addr, afs_uint32 subnetmask) +int +afsi_SetServerIPRank(struct srvAddr *sa, afs_int32 addr, + afs_uint32 subnetmask) { - afs_uint32 myAddr, myNet, mySubnet, netMask; - afs_uint32 serverAddr ; - - myAddr = ntohl(addr); /* one of my IP addr in host order */ - serverAddr = ntohl(sa->sa_ip); /* server's IP addr in host order */ - subnetmask = ntohl(subnetmask);/* subnet mask in host order */ - - if ( IN_CLASSA(myAddr) ) netMask = IN_CLASSA_NET; - else if ( IN_CLASSB(myAddr) ) netMask = IN_CLASSB_NET; - else if ( IN_CLASSC(myAddr) ) netMask = IN_CLASSC_NET; - else netMask = 0; - - myNet = myAddr & netMask; - mySubnet = myAddr & subnetmask; - - if ( (serverAddr & netMask ) == myNet ) { - if ( (serverAddr & subnetmask ) == mySubnet) { - if ( serverAddr == myAddr ) { /* same machine */ - sa->sa_iprank = afs_min(sa->sa_iprank, TOPR); - } else { /* same subnet */ - sa->sa_iprank = afs_min(sa->sa_iprank, HI); - } - } else { /* same net */ - sa->sa_iprank = afs_min(sa->sa_iprank, MED); - } - } + afs_uint32 myAddr, myNet, mySubnet, netMask; + afs_uint32 serverAddr; + + myAddr = ntohl(addr); /* one of my IP addr in host order */ + serverAddr = ntohl(sa->sa_ip); /* server's IP addr in host order */ + subnetmask = ntohl(subnetmask); /* subnet mask in host order */ + + if (IN_CLASSA(myAddr)) + netMask = IN_CLASSA_NET; + else if (IN_CLASSB(myAddr)) + netMask = IN_CLASSB_NET; + else if (IN_CLASSC(myAddr)) + netMask = IN_CLASSC_NET; + else + netMask = 0; + + myNet = myAddr & netMask; + mySubnet = myAddr & subnetmask; + + if ((serverAddr & netMask) == myNet) { + if ((serverAddr & subnetmask) == mySubnet) { + if (serverAddr == myAddr) { /* same machine */ + sa->sa_iprank = afs_min(sa->sa_iprank, TOPR); + } else { /* same subnet */ + sa->sa_iprank = afs_min(sa->sa_iprank, HI); + } + } else { /* same net */ + sa->sa_iprank = afs_min(sa->sa_iprank, MED); + } + } } #else /* AFS_USERSPACE_IP_ADDR */ #if (! defined(AFS_SUN5_ENV)) && !defined(AFS_DARWIN60_ENV) && defined(USEIFADDR) -void afsi_SetServerIPRank(struct srvAddr *sa, struct in_ifaddr *ifa) +void +afsi_SetServerIPRank(struct srvAddr *sa, struct in_ifaddr *ifa) { struct sockaddr_in *sin; int t; - + if ((ntohl(sa->sa_ip) & ifa->ia_netmask) == ifa->ia_net) { if ((ntohl(sa->sa_ip) & ifa->ia_subnetmask) == ifa->ia_subnet) { - sin=IA_SIN(ifa); - if ( SA2ULONG(sin) == ntohl(sa->sa_ip)) { /* ie, ME!!! */ + sin = IA_SIN(ifa); + if (SA2ULONG(sin) == ntohl(sa->sa_ip)) { /* ie, ME!!! */ sa->sa_iprank = TOPR; - } else { - t = HI + ifa->ia_ifp->if_metric; /* case #2 */ + } else { + t = HI + ifa->ia_ifp->if_metric; /* case #2 */ if (sa->sa_iprank > t) sa->sa_iprank = t; } } else { - t = MED + ifa->ia_ifp->if_metric;/* case #3 */ + t = MED + ifa->ia_ifp->if_metric; /* case #3 */ if (sa->sa_iprank > t) sa->sa_iprank = t; } } #ifdef IFF_POINTTOPOINT /* check for case #4 -- point-to-point link */ - if ((ifa->ia_ifp->if_flags & IFF_POINTOPOINT) && - (SA2ULONG(IA_DST(ifa)) == ntohl(sa->sa_ip))) { - if (ifa->ia_ifp->if_metric >= (MAXDEFRANK - MED)/PPWEIGHT) + if ((ifa->ia_ifp->if_flags & IFF_POINTOPOINT) + && (SA2ULONG(IA_DST(ifa)) == ntohl(sa->sa_ip))) { + if (ifa->ia_ifp->if_metric >= (MAXDEFRANK - MED) / PPWEIGHT) t = MAXDEFRANK; - else + else t = MED + (PPWEIGHT << ifa->ia_ifp->if_metric); if (sa->sa_iprank > t) sa->sa_iprank = t; } #endif /* IFF_POINTTOPOINT */ } -#endif /*(!defined(AFS_SUN5_ENV)) && defined(USEIFADDR)*/ +#endif /*(!defined(AFS_SUN5_ENV)) && defined(USEIFADDR) */ #if defined(AFS_DARWIN60_ENV) && defined(USEIFADDR) #ifndef afs_min #define afs_min(A,B) ((A)<(B)) ? (A) : (B) #endif void afsi_SetServerIPRank(sa, ifa) - struct srvAddr *sa; - struct ifaddr *ifa; + struct srvAddr *sa; + struct ifaddr *ifa; { struct sockaddr_in *sin; int t; - - afs_uint32 subnetmask, myAddr, myNet, myDstaddr, mySubnet, netMask; - afs_uint32 serverAddr ; - - if (ifa->ifa_addr->sa_family != AF_INET) - return; - sin=(struct sockaddr_in *)ifa->ifa_addr; - myAddr = ntohl(sin->sin_addr.s_addr); /* one of my IP addr in host order */ - serverAddr = ntohl(sa->sa_ip); /* server's IP addr in host order */ - sin=(struct sockaddr_in *)ifa->ifa_netmask; - subnetmask = ntohl(sin->sin_addr.s_addr);/* subnet mask in host order */ - sin=(struct sockaddr_in *)ifa->ifa_dstaddr; - if (sin) - myDstaddr=sin->sin_addr.s_addr; - - if ( IN_CLASSA(myAddr) ) netMask = IN_CLASSA_NET; - else if ( IN_CLASSB(myAddr) ) netMask = IN_CLASSB_NET; - else if ( IN_CLASSC(myAddr) ) netMask = IN_CLASSC_NET; - else netMask = 0; - - myNet = myAddr & netMask; - mySubnet = myAddr & subnetmask; - - if ( (serverAddr & netMask ) == myNet ) { - if ( (serverAddr & subnetmask ) == mySubnet) { - if ( serverAddr == myAddr ) { /* same machine */ - sa->sa_iprank = afs_min(sa->sa_iprank, TOPR); - } else { /* same subnet */ - sa->sa_iprank = afs_min(sa->sa_iprank, HI + ifa->ifa_metric); - } - } else { /* same net */ - sa->sa_iprank = afs_min(sa->sa_iprank, MED + ifa->ifa_metric); - } - } + + afs_uint32 subnetmask, myAddr, myNet, myDstaddr, mySubnet, netMask; + afs_uint32 serverAddr; + + if (ifa->ifa_addr->sa_family != AF_INET) + return; + sin = (struct sockaddr_in *)ifa->ifa_addr; + myAddr = ntohl(sin->sin_addr.s_addr); /* one of my IP addr in host order */ + serverAddr = ntohl(sa->sa_ip); /* server's IP addr in host order */ + sin = (struct sockaddr_in *)ifa->ifa_netmask; + subnetmask = ntohl(sin->sin_addr.s_addr); /* subnet mask in host order */ + sin = (struct sockaddr_in *)ifa->ifa_dstaddr; + if (sin) + myDstaddr = sin->sin_addr.s_addr; + + if (IN_CLASSA(myAddr)) + netMask = IN_CLASSA_NET; + else if (IN_CLASSB(myAddr)) + netMask = IN_CLASSB_NET; + else if (IN_CLASSC(myAddr)) + netMask = IN_CLASSC_NET; + else + netMask = 0; + + myNet = myAddr & netMask; + mySubnet = myAddr & subnetmask; + + if ((serverAddr & netMask) == myNet) { + if ((serverAddr & subnetmask) == mySubnet) { + if (serverAddr == myAddr) { /* same machine */ + sa->sa_iprank = afs_min(sa->sa_iprank, TOPR); + } else { /* same subnet */ + sa->sa_iprank = afs_min(sa->sa_iprank, HI + ifa->ifa_metric); + } + } else { /* same net */ + sa->sa_iprank = afs_min(sa->sa_iprank, MED + ifa->ifa_metric); + } + } #ifdef IFF_POINTTOPOINT /* check for case #4 -- point-to-point link */ - if ((ifa->ia_ifp->if_flags & IFF_POINTOPOINT) && - (myDstaddr == serverAddr))) { - if (ifa->ia_ifp->if_metric >= (MAXDEFRANK - MED)/PPWEIGHT) + if ((ifa->ia_ifp->if_flags & IFF_POINTOPOINT) + && (myDstaddr == serverAddr)) + ) { + if (ifa->ia_ifp->if_metric >= (MAXDEFRANK - MED) / PPWEIGHT) t = MAXDEFRANK; - else + else t = MED + (PPWEIGHT << ifa->->ifa_metric); if (sa->sa_iprank > t) sa->sa_iprank = t; - } + } #endif /* IFF_POINTTOPOINT */ } -#endif /*(!defined(AFS_SUN5_ENV)) && defined(USEIFADDR)*/ +#endif /*(!defined(AFS_SUN5_ENV)) && defined(USEIFADDR) */ #endif /* else AFS_USERSPACE_IP_ADDR */ #ifdef AFS_SGI62_ENV static int -afsi_enum_set_rank(struct hashbucket *h, caddr_t mkey, caddr_t arg1, - caddr_t arg2) -{ - afsi_SetServerIPRank((struct srvAddr *)arg1, (struct in_ifaddr*)h); - return 0; /* Never match, so we enumerate everyone */ -} -#endif /* AFS_SGI62_ENV */ -static int afs_SetServerPrefs(struct srvAddr *sa) -{ + afsi_enum_set_rank(struct hashbucket *h, caddr_t mkey, caddr_t arg1, + caddr_t arg2) { + afsi_SetServerIPRank((struct srvAddr *)arg1, (struct in_ifaddr *)h); + return 0; /* Never match, so we enumerate everyone */ +} +#endif /* AFS_SGI62_ENV */ +static int afs_SetServerPrefs(struct srvAddr *sa) { #if defined(AFS_USERSPACE_IP_ADDR) int i; - sa->sa_iprank = LO; - for (i=0; isa_iprank = LO; + for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) { + afsi_SetServerIPRank(sa, afs_cb_interface.addr_in[i], + afs_cb_interface.subnetmask[i]); } -#else /* AFS_USERSPACE_IP_ADDR */ +#else /* AFS_USERSPACE_IP_ADDR */ #if defined(AFS_SUN5_ENV) extern struct ill_s *ill_g_headp; ill_t *ill; - ipif_t * ipif; + ipif_t *ipif; int subnet, subnetmask, net, netmask; - long *addr = (long *) ill_g_headp; + long *addr = (long *)ill_g_headp; - if (sa) sa->sa_iprank= 0; - for (ill = (struct ill_s *)*addr /*ill_g_headp*/; ill; ill = ill->ill_next ) { + if (sa) + sa->sa_iprank = 0; + for (ill = (struct ill_s *)*addr /*ill_g_headp */ ; ill; + ill = ill->ill_next) { #ifdef AFS_SUN58_ENV /* Make sure this is an IPv4 ILL */ - if (ill->ill_isv6) continue; + if (ill->ill_isv6) + continue; #endif - for (ipif = ill->ill_ipif; ipif; ipif = ipif->ipif_next ) { + for (ipif = ill->ill_ipif; ipif; ipif = ipif->ipif_next) { subnet = ipif->ipif_local_addr & ipif->ipif_net_mask; subnetmask = ipif->ipif_net_mask; /* @@ -1166,37 +1202,38 @@ static int afs_SetServerPrefs(struct srvAddr *sa) netmask = 0; } net = ipif->ipif_local_addr & netmask; -#ifdef notdef +#ifdef notdef if (!s) { - if (ipif->ipif_local_addr != 0x7f000001) { /* ignore loopback */ + if (ipif->ipif_local_addr != 0x7f000001) { /* ignore loopback */ *cnt += 1; - if (*cnt > 16) return; + if (*cnt > 16) + return; *addrp++ = ipif->ipif_local_addr; } } else #endif /* notdef */ - { + { /* XXXXXX Do the individual ip ranking below XXXXX */ if ((sa->sa_ip & netmask) == net) { if ((sa->sa_ip & subnetmask) == subnet) { - if (ipif->ipif_local_addr == sa->sa_ip) { /* ie, ME! */ + if (ipif->ipif_local_addr == sa->sa_ip) { /* ie, ME! */ sa->sa_iprank = TOPR; - } else { - sa->sa_iprank = HI + ipif->ipif_metric; /* case #2 */ + } else { + sa->sa_iprank = HI + ipif->ipif_metric; /* case #2 */ } - } else { - sa->sa_iprank = MED + ipif->ipif_metric; /* case #3 */ + } else { + sa->sa_iprank = MED + ipif->ipif_metric; /* case #3 */ } } else { sa->sa_iprank = LO + ipif->ipif_metric; /* case #4 */ } /* check for case #5 -- point-to-point link */ - if ((ipif->ipif_flags & IFF_POINTOPOINT) && - (ipif->ipif_pp_dst_addr == sa->sa_ip )) { + if ((ipif->ipif_flags & IFF_POINTOPOINT) + && (ipif->ipif_pp_dst_addr == sa->sa_ip)) { - if (ipif->ipif_metric >= (MAXDEFRANK - MED)/PPWEIGHT) + if (ipif->ipif_metric >= (MAXDEFRANK - MED) / PPWEIGHT) sa->sa_iprank = MAXDEFRANK; - else + else sa->sa_iprank = MED + (PPWEIGHT << ipif->ipif_metric); } } @@ -1205,85 +1242,84 @@ static int afs_SetServerPrefs(struct srvAddr *sa) #else #ifndef USEIFADDR struct ifnet *ifn = NULL; - struct in_ifaddr *ifad = (struct in_ifaddr *) 0; + struct in_ifaddr *ifad = (struct in_ifaddr *)0; struct sockaddr_in *sin; if (!sa) { -#ifdef notdef /* clean up, remove this */ +#ifdef notdef /* clean up, remove this */ for (ifn = ifnet; ifn != NULL; ifn = ifn->if_next) { - for (ifad = ifn->if_addrlist; ifad != NULL; ifad = ifad->ifa_next){ - if ((IFADDR2SA(ifad)->sa_family == AF_INET) - && !(ifn->if_flags & IFF_LOOPBACK)) { - *cnt += 1; - if (*cnt > 16) return; - *addrp++ = ((struct sockaddr_in *) IFADDR2SA(ifad))->sin_addr.s_addr; + for (ifad = ifn->if_addrlist; ifad != NULL; ifad = ifad->ifa_next) { + if ((IFADDR2SA(ifad)->sa_family == AF_INET) + && !(ifn->if_flags & IFF_LOOPBACK)) { + *cnt += 1; + if (*cnt > 16) + return; + *addrp++ = + ((struct sockaddr_in *)IFADDR2SA(ifad))->sin_addr. + s_addr; } - } - } -#endif /* notdef */ + }} +#endif /* notdef */ return; } - sa->sa_iprank= 0; + sa->sa_iprank = 0; #ifdef ADAPT_MTU ifn = rxi_FindIfnet(sa->sa_ip, &ifad); #endif - if (ifn) { /* local, more or less */ + if (ifn) { /* local, more or less */ #ifdef IFF_LOOPBACK - if (ifn->if_flags & IFF_LOOPBACK) { - sa->sa_iprank = TOPR; - goto end; - } + if (ifn->if_flags & IFF_LOOPBACK) { + sa->sa_iprank = TOPR; + goto end; + } #endif /* IFF_LOOPBACK */ - sin = (struct sockaddr_in *) IA_SIN(ifad); - if (SA2ULONG(sin) == sa->sa_ip) { - sa->sa_iprank = TOPR; - goto end; - } -#ifdef IFF_BROADCAST - if (ifn->if_flags & IFF_BROADCAST) { - if (sa->sa_ip == (sa->sa_ip & SA2ULONG(IA_BROAD(ifad)))) { - sa->sa_iprank = HI; + sin = (struct sockaddr_in *)IA_SIN(ifad); + if (SA2ULONG(sin) == sa->sa_ip) { + sa->sa_iprank = TOPR; goto end; - } - } + } +#ifdef IFF_BROADCAST + if (ifn->if_flags & IFF_BROADCAST) { + if (sa->sa_ip == (sa->sa_ip & SA2ULONG(IA_BROAD(ifad)))) { + sa->sa_iprank = HI; + goto end; + } + } #endif /* IFF_BROADCAST */ #ifdef IFF_POINTOPOINT - if (ifn->if_flags & IFF_POINTOPOINT) { - if (sa->sa_ip == SA2ULONG(IA_DST(ifad))) { - if (ifn->if_metric > 4) { - sa->sa_iprank = LO; - goto end; - } - else sa->sa_iprank = ifn->if_metric; + if (ifn->if_flags & IFF_POINTOPOINT) { + if (sa->sa_ip == SA2ULONG(IA_DST(ifad))) { + if (ifn->if_metric > 4) { + sa->sa_iprank = LO; + goto end; + } else + sa->sa_iprank = ifn->if_metric; + } } - } #endif /* IFF_POINTOPOINT */ - sa->sa_iprank += MED + ifn->if_metric; /* couldn't find anything better */ + sa->sa_iprank += MED + ifn->if_metric; /* couldn't find anything better */ } - -#else /* USEIFADDR */ - - if (sa) sa->sa_iprank= LO; +#else /* USEIFADDR */ + + if (sa) + sa->sa_iprank = LO; #ifdef AFS_SGI62_ENV - (void) hash_enum(&hashinfo_inaddr, afsi_enum_set_rank, HTF_INET, NULL, - (caddr_t)sa, NULL); + (void)hash_enum(&hashinfo_inaddr, afsi_enum_set_rank, HTF_INET, NULL, + (caddr_t) sa, NULL); #elif defined(AFS_DARWIN60_ENV) { - struct ifnet *ifn; - struct ifaddr *ifa; - TAILQ_FOREACH(ifn , &ifnet, if_link) { - TAILQ_FOREACH(ifa , &ifn->if_addrhead, ifa_link) { - afsi_SetServerIPRank(sa, ifa); - } - } - } + struct ifnet *ifn; + struct ifaddr *ifa; + TAILQ_FOREACH(ifn, &ifnet, if_link) { + TAILQ_FOREACH(ifa, &ifn->if_addrhead, ifa_link) { + afsi_SetServerIPRank(sa, ifa); + }}} #elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) { - struct in_ifaddr *ifa; - TAILQ_FOREACH(ifa , &in_ifaddrhead, ia_link) { - afsi_SetServerIPRank(sa, ifa); - } - } + struct in_ifaddr *ifa; + TAILQ_FOREACH(ifa, &in_ifaddrhead, ia_link) { + afsi_SetServerIPRank(sa, ifa); + }} #elif defined(AFS_OBSD_ENV) { extern struct in_ifaddrhead in_ifaddr; @@ -1294,21 +1330,19 @@ static int afs_SetServerPrefs(struct srvAddr *sa) #else { struct in_ifaddr *ifa; - for ( ifa = in_ifaddr; ifa; ifa = ifa->ia_next ) { + for (ifa = in_ifaddr; ifa; ifa = ifa->ia_next) { afsi_SetServerIPRank(sa, ifa); - } - } + }} #endif - - end: -#endif /* USEIFADDR */ -#endif /* AFS_SUN5_ENV */ -#endif /* else AFS_USERSPACE_IP_ADDR */ - - if (sa) sa->sa_iprank += afs_randomMod15(); + end: +#endif /* USEIFADDR */ +#endif /* AFS_SUN5_ENV */ +#endif /* else AFS_USERSPACE_IP_ADDR */ + if (sa) + sa->sa_iprank += afs_randomMod15(); return 0; -} /* afs_SetServerPrefs */ +} /* afs_SetServerPrefs */ #undef TOPR #undef HI @@ -1321,50 +1355,51 @@ static int afs_SetServerPrefs(struct srvAddr *sa) * clean up all other structures that may reference it. * The afs_xserver and afs_xsrvAddr locks are assumed taken. */ -void afs_FlushServer(struct server *srvp) -{ - afs_int32 i; - struct server *ts, **pts; - - /* Find any volumes residing on this server and flush their state */ - afs_ResetVolumes(srvp); - - /* Flush all callbacks in the all vcaches for this specific server */ - afs_FlushServerCBs(srvp); - - /* Remove all the callbacks structs */ - if (srvp->cbrs) { - struct afs_cbr *cb, *cbnext; - - MObtainWriteLock(&afs_xvcb, 300); - for (cb=srvp->cbrs; cb; cb=cbnext) { - cbnext = cb->next; - afs_FreeCBR(cb); - } - srvp->cbrs = (struct afs_cbr *)0; - ReleaseWriteLock(&afs_xvcb); - } - - /* If no more srvAddr structs hanging off of this server struct, - * then clean it up. - */ - if (!srvp->addr) { - /* Remove the server structure from the cell list - if there */ - afs_RemoveCellEntry(srvp); - - /* Remove from the afs_servers hash chain */ - for (i=0; inext), ts=*pts) { - if (ts == srvp) break; +void afs_FlushServer(struct server *srvp) { + afs_int32 i; + struct server *ts, **pts; + + /* Find any volumes residing on this server and flush their state */ + afs_ResetVolumes(srvp); + + /* Flush all callbacks in the all vcaches for this specific server */ + afs_FlushServerCBs(srvp); + + /* Remove all the callbacks structs */ + if (srvp->cbrs) { + struct afs_cbr *cb, *cbnext; + + MObtainWriteLock(&afs_xvcb, 300); + for (cb = srvp->cbrs; cb; cb = cbnext) { + cbnext = cb->next; + afs_FreeCBR(cb); + } srvp->cbrs = (struct afs_cbr *)0; + ReleaseWriteLock(&afs_xvcb); + } + + /* If no more srvAddr structs hanging off of this server struct, + * then clean it up. + */ + if (!srvp->addr) { + /* Remove the server structure from the cell list - if there */ + afs_RemoveCellEntry(srvp); + + /* Remove from the afs_servers hash chain */ + for (i = 0; i < NSERVERS; i++) { + for (pts = &(afs_servers[i]), ts = *pts; ts; + pts = &(ts->next), ts = *pts) { + if (ts == srvp) + break; + } + if (ts) + break; } - if (ts) break; - } - if (ts) { - *pts = ts->next; /* Found it. Remove it */ - afs_osi_Free(ts, sizeof(struct server)); /* Free it */ - afs_totalServers--; - } - } + if (ts) { + *pts = ts->next; /* Found it. Remove it */ + afs_osi_Free(ts, sizeof(struct server)); /* Free it */ + afs_totalServers--; + } + } } /* afs_RemoveSrvAddr() @@ -1375,26 +1410,26 @@ void afs_FlushServer(struct server *srvp) * The afs_xserver and afs_xsrvAddr locks are assumed taken. * It is not removed from the afs_srvAddrs hash chain. */ -void afs_RemoveSrvAddr(struct srvAddr *sap) -{ - struct srvAddr **psa, *sa; - struct server *srv; - - if (!sap) return; - srv = sap->server; - - /* Find the srvAddr in the server's list and remove it */ - for (psa=&(srv->addr), sa=*psa; sa; psa=&(sa->next_sa), sa=*psa) { - if (sa == sap) break; - } - if (sa) { - *psa = sa->next_sa; - sa->next_sa = 0; - sa->server = 0; - - /* Flush the server struct since it's IP address has changed */ - afs_FlushServer(srv); - } +void afs_RemoveSrvAddr(struct srvAddr *sap) { + struct srvAddr **psa, *sa; + struct server *srv; + + if (!sap) + return; + srv = sap->server; + + /* Find the srvAddr in the server's list and remove it */ + for (psa = &(srv->addr), sa = *psa; sa; psa = &(sa->next_sa), sa = *psa) { + if (sa == sap) + break; + } if (sa) { + *psa = sa->next_sa; + sa->next_sa = 0; + sa->server = 0; + + /* Flush the server struct since it's IP address has changed */ + afs_FlushServer(srv); + } } /* afs_GetServer() @@ -1403,216 +1438,229 @@ void afs_RemoveSrvAddr(struct srvAddr *sap) * If one does not exist, then one will be created. * aserver and aport must be in NET byte order. */ -struct server *afs_GetServer(afs_uint32 *aserverp, afs_int32 nservers, +struct server *afs_GetServer(afs_uint32 * aserverp, afs_int32 nservers, afs_int32 acell, u_short aport, - afs_int32 locktype, afsUUID *uuidp, - afs_int32 addr_uniquifier) -{ - struct server *oldts=0, *ts, *newts, *orphts=0; + afs_int32 locktype, afsUUID * uuidp, + afs_int32 addr_uniquifier) { + struct server *oldts = 0, *ts, *newts, *orphts = 0; struct srvAddr *oldsa, *newsa, *nextsa, *orphsa; u_short fsport; - afs_int32 iphash, k, srvcount=0; + afs_int32 iphash, k, srvcount = 0; unsigned int srvhash; AFS_STATCNT(afs_GetServer); - ObtainSharedLock(&afs_xserver,13); + ObtainSharedLock(&afs_xserver, 13); /* Check if the server struct exists and is up to date */ if (!uuidp) { - if (nservers != 1) panic("afs_GetServer: incorect count of servers"); - ObtainReadLock(&afs_xsrvAddr); - ts = afs_FindServer(aserverp[0], aport, NULL, locktype); - ReleaseReadLock(&afs_xsrvAddr); - if (ts && !(ts->flags & SRVR_MULTIHOMED)) { - /* Found a server struct that is not multihomed and has the - * IP address associated with it. A correct match. - */ - ReleaseSharedLock(&afs_xserver); - return(ts); - } + if (nservers != 1) + panic("afs_GetServer: incorect count of servers"); + ObtainReadLock(&afs_xsrvAddr); + ts = afs_FindServer(aserverp[0], aport, NULL, locktype); + ReleaseReadLock(&afs_xsrvAddr); + if (ts && !(ts->flags & SRVR_MULTIHOMED)) { + /* Found a server struct that is not multihomed and has the + * IP address associated with it. A correct match. + */ + ReleaseSharedLock(&afs_xserver); + return (ts); + } } else { - if (nservers <= 0) panic("afs_GetServer: incorrect count of servers"); - ts = afs_FindServer(0, aport, uuidp, locktype); - if (ts && (ts->sr_addr_uniquifier == addr_uniquifier) && ts->addr) { - /* Found a server struct that is multihomed and same - * uniqufier (same IP addrs). The above if statement is the - * same as in InstallUVolumeEntry(). - */ - ReleaseSharedLock(&afs_xserver); - return ts; - } - if (ts) oldts = ts; /* Will reuse if same uuid */ + if (nservers <= 0) + panic("afs_GetServer: incorrect count of servers"); + ts = afs_FindServer(0, aport, uuidp, locktype); + if (ts && (ts->sr_addr_uniquifier == addr_uniquifier) && ts->addr) { + /* Found a server struct that is multihomed and same + * uniqufier (same IP addrs). The above if statement is the + * same as in InstallUVolumeEntry(). + */ + ReleaseSharedLock(&afs_xserver); + return ts; + } + if (ts) + oldts = ts; /* Will reuse if same uuid */ } - UpgradeSToWLock(&afs_xserver,36); - ObtainWriteLock(&afs_xsrvAddr,116); + UpgradeSToWLock(&afs_xserver, 36); + ObtainWriteLock(&afs_xsrvAddr, 116); srvcount = afs_totalServers; /* Reuse/allocate a new server structure */ if (oldts) { - newts = oldts; + newts = oldts; } else { - newts = (struct server *) afs_osi_Alloc(sizeof(struct server)); - if (!newts) panic("malloc of server struct"); - afs_totalServers++; - memset((char *)newts, 0, sizeof(struct server)); - - /* Add the server struct to the afs_servers[] hash chain */ - srvhash = (uuidp ? (afs_uuid_hash(uuidp)%NSERVERS) : SHash(aserverp[0])); - newts->next = afs_servers[srvhash]; - afs_servers[srvhash] = newts; + newts = (struct server *)afs_osi_Alloc(sizeof(struct server)); + if (!newts) + panic("malloc of server struct"); + afs_totalServers++; + memset((char *)newts, 0, sizeof(struct server)); + + /* Add the server struct to the afs_servers[] hash chain */ + srvhash = + (uuidp ? (afs_uuid_hash(uuidp) % NSERVERS) : SHash(aserverp[0])); + newts->next = afs_servers[srvhash]; + afs_servers[srvhash] = newts; } /* Initialize the server structure */ - if (uuidp) { /* Multihomed */ - newts->sr_uuid = *uuidp; - newts->sr_addr_uniquifier = addr_uniquifier; - newts->flags |= SRVR_MULTIHOMED; + if (uuidp) { /* Multihomed */ + newts->sr_uuid = *uuidp; + newts->sr_addr_uniquifier = addr_uniquifier; + newts->flags |= SRVR_MULTIHOMED; } - if (acell) newts->cell = afs_GetCell(acell, 0); + if (acell) + newts->cell = afs_GetCell(acell, 0); fsport = (newts->cell ? newts->cell->fsport : AFS_FSPORT); /* For each IP address we are registering */ - for (k=0; knext_bkt) { - if ( (oldsa->sa_ip == aserverp[k]) && (oldsa->sa_portal == aport) ) break; - } - if (oldsa && (oldsa->server != newts)) { - afs_RemoveSrvAddr(oldsa); /* Remove from its server struct */ - oldsa->next_sa = newts->addr; /* Add to the new server struct */ - newts->addr = oldsa; - } - - /* Reuse/allocate a new srvAddr structure */ - if (oldsa) { - newsa = oldsa; - } else { - newsa = (struct srvAddr *) afs_osi_Alloc(sizeof(struct srvAddr)); - if (!newsa) panic("malloc of srvAddr struct"); - afs_totalSrvAddrs++; - memset((char *)newsa, 0, sizeof(struct srvAddr)); - - /* Add the new srvAddr to the afs_srvAddrs[] hash chain */ - newsa->next_bkt = afs_srvAddrs[iphash]; - afs_srvAddrs[iphash] = newsa; - - /* Hang off of the server structure */ - newsa->next_sa = newts->addr; - newts->addr = newsa; - - /* Initialize the srvAddr Structure */ - newsa->sa_ip = aserverp[k]; - newsa->sa_portal = aport; - } - - /* Update the srvAddr Structure */ - newsa->server = newts; - if (newts->flags & SRVR_ISDOWN) - newsa->sa_flags |= SRVADDR_ISDOWN; - if (uuidp) newsa->sa_flags |= SRVADDR_MH; - else newsa->sa_flags &= ~SRVADDR_MH; - - /* Compute preference values and resort */ - if (!newsa->sa_iprank) { - if (aport == fsport) { - afs_SetServerPrefs(newsa); /* new fileserver rank */ - } else { - newsa->sa_iprank = 10000 + afs_randomMod127(); /* new vlserver rank */ - } - } + for (k = 0; k < nservers; k++) { + iphash = SHash(aserverp[k]); + + /* Check if the srvAddr structure already exists. If so, remove + * it from its server structure and add it to the new one. + */ + for (oldsa = afs_srvAddrs[iphash]; oldsa; oldsa = oldsa->next_bkt) { + if ((oldsa->sa_ip == aserverp[k]) && (oldsa->sa_portal == aport)) + break; + } + if (oldsa && (oldsa->server != newts)) { + afs_RemoveSrvAddr(oldsa); /* Remove from its server struct */ + oldsa->next_sa = newts->addr; /* Add to the new server struct */ + newts->addr = oldsa; + } + + /* Reuse/allocate a new srvAddr structure */ + if (oldsa) { + newsa = oldsa; + } else { + newsa = (struct srvAddr *)afs_osi_Alloc(sizeof(struct srvAddr)); + if (!newsa) + panic("malloc of srvAddr struct"); + afs_totalSrvAddrs++; + memset((char *)newsa, 0, sizeof(struct srvAddr)); + + /* Add the new srvAddr to the afs_srvAddrs[] hash chain */ + newsa->next_bkt = afs_srvAddrs[iphash]; + afs_srvAddrs[iphash] = newsa; + + /* Hang off of the server structure */ + newsa->next_sa = newts->addr; + newts->addr = newsa; + + /* Initialize the srvAddr Structure */ + newsa->sa_ip = aserverp[k]; + newsa->sa_portal = aport; + } + + /* Update the srvAddr Structure */ + newsa->server = newts; + if (newts->flags & SRVR_ISDOWN) + newsa->sa_flags |= SRVADDR_ISDOWN; + if (uuidp) + newsa->sa_flags |= SRVADDR_MH; + else + newsa->sa_flags &= ~SRVADDR_MH; + + /* Compute preference values and resort */ + if (!newsa->sa_iprank) { + if (aport == fsport) { + afs_SetServerPrefs(newsa); /* new fileserver rank */ + } else { + newsa->sa_iprank = 10000 + afs_randomMod127(); /* new vlserver rank */ + } + } } - afs_SortOneServer(newts); /* Sort by rank */ + afs_SortOneServer(newts); /* Sort by rank */ /* If we reused the server struct, remove any of its srvAddr * structs that will no longer be associated with this server. */ - if (oldts) { /* reused the server struct */ - for (orphsa=newts->addr; orphsa; orphsa=nextsa) { - nextsa = orphsa->next_sa; - for (k=0; ksa_ip == aserverp[k]) break; /* belongs */ - } - if (k < nservers) continue; /* belongs */ - - /* Have a srvAddr struct. Now get a server struct (if not already) */ - if (!orphts) { - orphts = (struct server *) afs_osi_Alloc(sizeof(struct server)); - if (!orphts) panic("malloc of lo server struct"); - memset((char *)orphts, 0, sizeof(struct server)); - afs_totalServers++; - - /* Add the orphaned server to the afs_servers[] hash chain. - * Its iphash does not matter since we never look up the server - * in the afs_servers table by its ip address (only by uuid - - * which this has none). - */ - iphash = SHash(aserverp[k]); - orphts->next = afs_servers[iphash]; - afs_servers[iphash] = orphts; - - if (acell) orphts->cell = afs_GetCell(acell, 0); - } - - /* Hang the srvAddr struct off of the server structure. The server - * may have multiple srvAddrs, but it won't be marked multihomed. - */ - afs_RemoveSrvAddr(orphsa); /* remove */ - orphsa->next_sa = orphts->addr; /* hang off server struct */ - orphts->addr = orphsa; - orphsa->server = orphts; - orphsa->sa_flags |= SRVADDR_NOUSE; /* flag indicating not in use */ - orphsa->sa_flags &= ~SRVADDR_MH; /* Not multihomed */ - } + if (oldts) { /* reused the server struct */ + for (orphsa = newts->addr; orphsa; orphsa = nextsa) { + nextsa = orphsa->next_sa; + for (k = 0; k < nservers; k++) { + if (orphsa->sa_ip == aserverp[k]) + break; /* belongs */ + } + if (k < nservers) + continue; /* belongs */ + + /* Have a srvAddr struct. Now get a server struct (if not already) */ + if (!orphts) { + orphts = + (struct server *)afs_osi_Alloc(sizeof(struct server)); + if (!orphts) + panic("malloc of lo server struct"); + memset((char *)orphts, 0, sizeof(struct server)); + afs_totalServers++; + + /* Add the orphaned server to the afs_servers[] hash chain. + * Its iphash does not matter since we never look up the server + * in the afs_servers table by its ip address (only by uuid - + * which this has none). + */ + iphash = SHash(aserverp[k]); + orphts->next = afs_servers[iphash]; + afs_servers[iphash] = orphts; + + if (acell) + orphts->cell = afs_GetCell(acell, 0); + } + + /* Hang the srvAddr struct off of the server structure. The server + * may have multiple srvAddrs, but it won't be marked multihomed. + */ + afs_RemoveSrvAddr(orphsa); /* remove */ + orphsa->next_sa = orphts->addr; /* hang off server struct */ + orphts->addr = orphsa; + orphsa->server = orphts; + orphsa->sa_flags |= SRVADDR_NOUSE; /* flag indicating not in use */ + orphsa->sa_flags &= ~SRVADDR_MH; /* Not multihomed */ + } } - srvcount = afs_totalServers - srvcount; /* # servers added and removed */ + srvcount = afs_totalServers - srvcount; /* # servers added and removed */ if (srvcount) { - struct afs_stats_SrvUpDownInfo *upDownP; - /* With the introduction of this new record, we need to adjust the - * proper individual & global server up/down info. - */ - upDownP = GetUpDownStats(newts); - upDownP->numTtlRecords += srvcount; - afs_stats_cmperf.srvRecords += srvcount; - if (afs_stats_cmperf.srvRecords > afs_stats_cmperf.srvRecordsHWM) - afs_stats_cmperf.srvRecordsHWM = afs_stats_cmperf.srvRecords; + struct afs_stats_SrvUpDownInfo *upDownP; + /* With the introduction of this new record, we need to adjust the + * proper individual & global server up/down info. + */ + upDownP = GetUpDownStats(newts); + upDownP->numTtlRecords += srvcount; + afs_stats_cmperf.srvRecords += srvcount; + if (afs_stats_cmperf.srvRecords > afs_stats_cmperf.srvRecordsHWM) + afs_stats_cmperf.srvRecordsHWM = afs_stats_cmperf.srvRecords; } - ReleaseWriteLock(&afs_xsrvAddr); + ReleaseWriteLock(&afs_xsrvAddr); ReleaseWriteLock(&afs_xserver); - return(newts); -} /* afs_GetServer */ + return (newts); +} /* afs_GetServer */ -void afs_ActivateServer(struct srvAddr *sap) -{ - osi_timeval_t currTime; /*Filled with current time*/ - osi_timeval_t *currTimeP; /*Ptr to above*/ - struct afs_stats_SrvUpDownInfo *upDownP; /*Ptr to up/down info record*/ - struct server *aserver = sap->server; - - if (!(aserver->flags & AFS_SERVER_FLAG_ACTIVATED)) { - /* - * This server record has not yet been activated. Go for it, - * recording its ``birth''. - */ - aserver->flags |= AFS_SERVER_FLAG_ACTIVATED; - currTimeP = &currTime; - osi_GetuTime(currTimeP); - aserver->activationTime = currTime.tv_sec; - upDownP = GetUpDownStats(aserver); - if (aserver->flags & SRVR_ISDOWN) { - upDownP->numDownRecords++; - } else { - upDownP->numUpRecords++; - upDownP->numRecordsNeverDown++; - } - } +void afs_ActivateServer(struct srvAddr *sap) { + osi_timeval_t currTime; /*Filled with current time */ + osi_timeval_t *currTimeP; /*Ptr to above */ + struct afs_stats_SrvUpDownInfo *upDownP; /*Ptr to up/down info record */ + struct server *aserver = sap->server; + + if (!(aserver->flags & AFS_SERVER_FLAG_ACTIVATED)) { + /* + * This server record has not yet been activated. Go for it, + * recording its ``birth''. + */ + aserver->flags |= AFS_SERVER_FLAG_ACTIVATED; + currTimeP = &currTime; + osi_GetuTime(currTimeP); + aserver->activationTime = currTime.tv_sec; + upDownP = GetUpDownStats(aserver); + if (aserver->flags & SRVR_ISDOWN) { + upDownP->numDownRecords++; + } else { + upDownP->numUpRecords++; + upDownP->numRecordsNeverDown++; + } + } } diff --git a/src/afs/afs_stat.c b/src/afs/afs_stat.c index 7398ea881..9b0996c5b 100644 --- a/src/afs/afs_stat.c +++ b/src/afs/afs_stat.c @@ -12,10 +12,11 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /*Standard vendor system headers*/ -#include "afsincludes.h" /*AFS-based standard headers*/ +#include "afs/sysincludes.h" /*Standard vendor system headers */ +#include "afsincludes.h" /*AFS-based standard headers */ #include "afs_stats.h" struct afs_CMStats afs_cmstats; @@ -37,18 +38,20 @@ afs_int32 afs_stats_XferSumBytes[AFS_STATS_NUM_FS_XFER_OPS]; * Environment: * This routine should only be called once, at initialization time. */ -void afs_InitStats(void) +void +afs_InitStats(void) { - struct afs_stats_opTimingData *opTimeP; /*Ptr to curr timing struct*/ - struct afs_stats_xferData *xferP; /*Ptr to curr xfer struct*/ - int currIdx; /*Current index*/ + struct afs_stats_opTimingData *opTimeP; /*Ptr to curr timing struct */ + struct afs_stats_xferData *xferP; /*Ptr to curr xfer struct */ + int currIdx; /*Current index */ /* * First step is to zero everything out. */ memset((char *)(&afs_cmstats), 0, sizeof(struct afs_CMStats)); memset((char *)(&afs_stats_cmperf), 0, sizeof(struct afs_stats_CMPerf)); - memset((char *)(&afs_stats_cmfullperf), 0, sizeof(struct afs_stats_CMFullPerf)); + memset((char *)(&afs_stats_cmfullperf), 0, + sizeof(struct afs_stats_CMFullPerf)); /* * Some fields really should be non-zero at the start, so set 'em up. @@ -56,11 +59,13 @@ void afs_InitStats(void) afs_stats_cmperf.srvNumBuckets = NSERVERS; opTimeP = &(afs_stats_cmfullperf.rpc.fsRPCTimes[0]); - for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++, opTimeP++) + for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; + currIdx++, opTimeP++) opTimeP->minTime.tv_sec = 999999; opTimeP = &(afs_stats_cmfullperf.rpc.cmRPCTimes[0]); - for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++, opTimeP++) + for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; + currIdx++, opTimeP++) opTimeP->minTime.tv_sec = 999999; xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[0]); @@ -70,7 +75,8 @@ void afs_InitStats(void) } } -void afs_GetCMStat(char **ptr, unsigned *size) +void +afs_GetCMStat(char **ptr, unsigned *size) { #ifndef AFS_NOSTATS AFS_STATCNT(afs_GetCMStat); @@ -79,7 +85,8 @@ void afs_GetCMStat(char **ptr, unsigned *size) #endif /* AFS_NOSTATS */ } -void afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue) +void +afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue) { AFS_STATCNT(afs_AddToMean); } diff --git a/src/afs/afs_stats.h b/src/afs/afs_stats.h index 685ed1f3a..35f6575a1 100644 --- a/src/afs/afs_stats.h +++ b/src/afs/afs_stats.h @@ -46,7 +46,7 @@ typedef struct timeval osi_timeval_t; #endif /* !KERNEL */ #define XSTATS_DECLS struct afs_stats_opTimingData *opP; \ - osi_timeval_t opStartTime, opStopTime, elapsedTime; + osi_timeval_t opStartTime, opStopTime, elapsedTime; #define XSTATS_START_TIME(arg) \ opP = &(afs_stats_cmfullperf.rpc.fsRPCTimes[arg]); \ @@ -82,567 +82,567 @@ struct afs_MeanStats { * function call. */ struct afs_CMCallStats { - afs_int32 C_afs_init; /* afs_aix_subr.c*/ - afs_int32 C_gop_rdwr; /* afs_aix_subr.c*/ - afs_int32 C_aix_gnode_rele; /* afs_aix_subr.c*/ - afs_int32 C_gettimeofday; /* afs_aix_subr.c*/ - afs_int32 C_m_cpytoc; /* afs_aix_subr.c*/ - afs_int32 C_aix_vattr_null; /* afs_aix_subr.c*/ - afs_int32 C_afs_gn_ftrunc; /* afs_aixops.c*/ - afs_int32 C_afs_gn_rdwr; /* afs_aixops.c*/ - afs_int32 C_afs_gn_ioctl; /* afs_aixops.c*/ - afs_int32 C_afs_gn_lockctl; /* afs_aixops.c*/ - afs_int32 C_afs_gn_readlink; /* afs_aixops.c*/ - afs_int32 C_afs_gn_readdir; /* afs_aixops.c*/ - afs_int32 C_afs_gn_select; /* afs_aixops.c*/ - afs_int32 C_afs_gn_strategy; /* afs_aixops.c*/ - afs_int32 C_afs_gn_symlink; /* afs_aixops.c*/ - afs_int32 C_afs_gn_revoke; /* afs_aixops.c*/ - afs_int32 C_afs_gn_link; /* afs_aixops.c*/ - afs_int32 C_afs_gn_mkdir; /* afs_aixops.c*/ - afs_int32 C_afs_gn_mknod; /* afs_aixops.c*/ - afs_int32 C_afs_gn_remove; /* afs_aixops.c*/ - afs_int32 C_afs_gn_rename; /* afs_aixops.c*/ - afs_int32 C_afs_gn_rmdir; /* afs_aixops.c*/ - afs_int32 C_afs_gn_fid; /* afs_aixops.c*/ - afs_int32 C_afs_gn_lookup; /* afs_aixops.c*/ - afs_int32 C_afs_gn_open; /* afs_aixops.c*/ - afs_int32 C_afs_gn_create; /* afs_aixops.c*/ - afs_int32 C_afs_gn_hold; /* afs_aixops.c*/ - afs_int32 C_afs_gn_close; /* afs_aixops.c*/ - afs_int32 C_afs_gn_map; /* afs_aixops.c*/ - afs_int32 C_afs_gn_rele; /* afs_aixops.c*/ - afs_int32 C_afs_gn_unmap; /* afs_aixops.c*/ - afs_int32 C_afs_gn_access; /* afs_aixops.c*/ - afs_int32 C_afs_gn_getattr; /* afs_aixops.c*/ - afs_int32 C_afs_gn_setattr; /* afs_aixops.c*/ - afs_int32 C_afs_gn_fclear; /* afs_aixops.c*/ - afs_int32 C_afs_gn_fsync; /* afs_aixops.c*/ - afs_int32 C_pHash; /* afs_buffer.c*/ - afs_int32 C_DInit; /* afs_buffer.c*/ - afs_int32 C_DRead; /* afs_buffer.c*/ - afs_int32 C_FixupBucket; /* afs_buffer.c*/ - afs_int32 C_afs_newslot; /* afs_buffer.c*/ - afs_int32 C_DRelease; /* afs_buffer.c*/ - afs_int32 C_DFlush; /* afs_buffer.c*/ - afs_int32 C_DFlushEntry; /* afs_buffer.c*/ - afs_int32 C_DVOffset; /* afs_buffer.c*/ - afs_int32 C_DZap; /* afs_buffer.c*/ - afs_int32 C_DNew; /* afs_buffer.c*/ - afs_int32 C_shutdown_bufferpackage; /* afs_buffer.c*/ - afs_int32 C_afs_CheckKnownBad; /* afs_cache.c*/ - afs_int32 C_afs_RemoveVCB; /* afs_cache.c*/ - afs_int32 C_afs_NewVCache; /* afs_cache.c*/ - afs_int32 C_afs_FlushActiveVcaches; /* afs_cache.c*/ - afs_int32 C_afs_VerifyVCache; /* afs_cache.c*/ - afs_int32 C_afs_WriteVCache; /* afs_cache.c*/ - afs_int32 C_afs_GetVCache; /* afs_cache.c*/ - afs_int32 C_afs_StuffVcache; /* afs_cache.c*/ - afs_int32 C_afs_FindVCache; /* afs_cache.c*/ - afs_int32 C_afs_PutDCache; /* afs_cache.c*/ - afs_int32 C_afs_PutVCache; /* afs_cache.c*/ - afs_int32 C_CacheStoreProc; /* afs_cache.c*/ - afs_int32 C_afs_FindDCache; /* afs_cache.c*/ - afs_int32 C_afs_TryToSmush; /* afs_cache.c*/ - afs_int32 C_afs_AdjustSize; /* afs_cache.c*/ - afs_int32 C_afs_CheckSize; /* afs_cache.c*/ - afs_int32 C_afs_StoreWarn; /* afs_cache.c*/ - afs_int32 C_CacheFetchProc; /* afs_cache.c*/ - afs_int32 C_UFS_CacheStoreProc; /* afs_cache.c*/ - afs_int32 C_UFS_CacheFetchProc; /* afs_cache.c*/ - afs_int32 C_afs_GetDCache; /* afs_cache.c*/ - afs_int32 C_afs_SimpleVStat; /* afs_cache.c*/ - afs_int32 C_afs_ProcessFS; /* afs_cache.c*/ - afs_int32 C_afs_InitCacheInfo; /* afs_cache.c*/ - afs_int32 C_afs_InitVolumeInfo; /* afs_cache.c*/ - afs_int32 C_afs_InitCacheFile; /* afs_cache.c*/ - afs_int32 C_afs_CacheInit; /* afs_cache.c*/ - afs_int32 C_afs_GetDSlot; /* afs_cache.c*/ - afs_int32 C_afs_WriteThroughDSlots; /* afs_cache.c*/ - afs_int32 C_afs_MemGetDSlot; /* afs_cache.c*/ - afs_int32 C_afs_UFSGetDSlot; /* afs_cache.c*/ - afs_int32 C_afs_StoreDCache; /* afs_cache.c*/ - afs_int32 C_afs_StoreMini; /* afs_cache.c*/ - afs_int32 C_shutdown_cache; /* afs_cache.c*/ - afs_int32 C_afs_StoreAllSegments; /* afs_cache.c*/ - afs_int32 C_afs_InvalidateAllSegments; /* afs_cache.c*/ - afs_int32 C_afs_TruncateAllSegments; /* afs_cache.c*/ - afs_int32 C_afs_CheckVolSync; /* afs_cache.c*/ - afs_int32 C_afs_wakeup; /* afs_cache.c*/ - afs_int32 C_afs_CFileOpen; /* afs_cache.c*/ - afs_int32 C_afs_CFileTruncate; /* afs_cache.c*/ - afs_int32 C_afs_GetDownD; /* afs_cache.c*/ - afs_int32 C_afs_WriteDCache; /* afs_cache.c*/ - afs_int32 C_afs_FlushDCache; /* afs_cache.c*/ - afs_int32 C_afs_GetDownDSlot; /* afs_cache.c*/ - afs_int32 C_afs_FlushVCache; /* afs_cache.c*/ - afs_int32 C_afs_GetDownV; /* afs_cache.c*/ - afs_int32 C_afs_QueueVCB; /* afs_cache.c*/ - afs_int32 C_afs_call; /* afs_call.c */ - afs_int32 C_afs_syscall_call; /* afs_call.c*/ - afs_int32 C_syscall; /* afs_call.c*/ - afs_int32 C_lpioctl; /* afs_call.c*/ - afs_int32 C_lsetpag; /* afs_call.c*/ - afs_int32 C_afs_syscall; /* afs_call.c*/ - afs_int32 C_afs_CheckInit; /* afs_call.c*/ - afs_int32 C_afs_shutdown; /* afs_call.c*/ - afs_int32 C_shutdown_BKG; /* afs_call.c*/ - afs_int32 C_shutdown_afstest; /* afs_call.c*/ - afs_int32 C_SRXAFSCB_GetCE; /* afs_callback.c*/ - afs_int32 C_ClearCallBack; /* afs_callback.c*/ - afs_int32 C_SRXAFSCB_GetLock; /* afs_callback.c*/ - afs_int32 C_SRXAFSCB_CallBack; /* afs_callback.c*/ - afs_int32 C_SRXAFSCB_InitCallBackState; /* afs_callback.c*/ - afs_int32 C_SRXAFSCB_Probe; /* afs_callback.c*/ - afs_int32 C_afs_RXCallBackServer; /* afs_callback.c*/ - afs_int32 C_shutdown_CB; /* afs_callback.c*/ - afs_int32 C_afs_Chunk; /* afs_chunk.c*/ - afs_int32 C_afs_ChunkBase; /* afs_chunk.c*/ - afs_int32 C_afs_ChunkOffset; /* afs_chunk.c*/ - afs_int32 C_afs_ChunkSize; /* afs_chunk.c*/ - afs_int32 C_afs_ChunkToBase; /* afs_chunk.c*/ - afs_int32 C_afs_ChunkToSize; /* afs_chunk.c*/ - afs_int32 C_afs_SetChunkSize; /* afs_chunk.c*/ - - afs_int32 C_afs_config; /* afs_config.c*/ - afs_int32 C_mem_freebytes; /* afs_config.c*/ - afs_int32 C_mem_getbytes; /* afs_config.c*/ - afs_int32 C_fpalloc; /* afs_config.c*/ - afs_int32 C_kluge_init; /* afs_config.c*/ - afs_int32 C_ufdalloc; /* afs_config.c*/ - afs_int32 C_ufdfree; /* afs_config.c*/ - afs_int32 C_commit; /* afs_config.c*/ - afs_int32 C_dev_ialloc; /* afs_config.c*/ - afs_int32 C_ffree; /* afs_config.c*/ - afs_int32 C_iget; /* afs_config.c*/ - afs_int32 C_iptovp; /* afs_config.c*/ - afs_int32 C_ilock; /* afs_config.c*/ - afs_int32 C_irele; /* afs_config.c*/ - afs_int32 C_iput; /* afs_config.c*/ - - afs_int32 C_afs_Daemon; /* afs_daemons.c*/ - afs_int32 C_afs_CheckRootVolume; /* afs_daemons.c*/ - afs_int32 C_BPath; /* afs_daemons.c*/ - afs_int32 C_BPrefetch; /* afs_daemons.c*/ - afs_int32 C_BStore; /* afs_daemons.c*/ - afs_int32 C_afs_BBusy; /* afs_daemons.c*/ - afs_int32 C_afs_BQueue; /* afs_daemons.c*/ - afs_int32 C_afs_BRelease; /* afs_daemons.c*/ - afs_int32 C_afs_BackgroundDaemon; /* afs_daemons.c*/ - afs_int32 C_shutdown_daemons; /* afs_daemons.c*/ - afs_int32 C_exporter_add; /* afs_exporter.c*/ - afs_int32 C_exporter_find; /* afs_exporter.c*/ - afs_int32 C_afs_gfs_kalloc; /* afs_gfs_subr.c*/ - afs_int32 C_IsAfsVnode; /* afs_gfs_subr.c*/ - afs_int32 C_SetAfsVnode; /* afs_gfs_subr.c*/ - afs_int32 C_afs_gfs_kfree; /* afs_gfs_subr.c*/ - afs_int32 C_gop_lookupname; /* afs_gfs_subr.c*/ - afs_int32 C_gfsvop_getattr; /* afs_gfs_subr.c*/ - afs_int32 C_gfsvop_rdwr; /* afs_gfs_subr.c*/ - afs_int32 C_afs_uniqtime; /* afs_gfs_subr.c*/ - afs_int32 C_gfs_vattr_null; /* afs_gfs_subr.c*/ - afs_int32 C_afs_lock; /* afs_gfsops.c*/ - afs_int32 C_afs_unlock; /* afs_gfsops.c*/ - afs_int32 C_afs_update; /* afs_gfsops.c*/ - afs_int32 C_afs_gclose; /* afs_gfsops.c*/ - afs_int32 C_afs_gopen; /* afs_gfsops.c*/ - afs_int32 C_afs_greadlink; /* afs_gfsops.c*/ - afs_int32 C_afs_select; /* afs_gfsops.c*/ - afs_int32 C_afs_gbmap; /* afs_gfsops.c*/ - afs_int32 C_afs_getfsdata; /* afs_gfsops.c*/ - afs_int32 C_afs_gsymlink; /* afs_gfsops.c*/ - afs_int32 C_afs_namei; /* afs_gfsops.c*/ - afs_int32 C_printgnode; /* afs_gfsops.c*/ - afs_int32 C_HaveGFSLock; /* afs_gfsops.c*/ - afs_int32 C_afs_gmount; /* afs_gfsops.c*/ - afs_int32 C_AddGFSLock; /* afs_gfsops.c*/ - afs_int32 C_RemoveGFSLock; /* afs_gfsops.c*/ - afs_int32 C_afs_grlock; /* afs_gfsops.c*/ - afs_int32 C_afs_gumount; /* afs_gfsops.c*/ - afs_int32 C_afs_gget; /* afs_gfsops.c*/ - afs_int32 C_afs_glink; /* afs_gfsops.c*/ - afs_int32 C_afs_gmkdir; /* afs_gfsops.c*/ - afs_int32 C_afs_sbupdate; /* afs_gfsops.c*/ - afs_int32 C_afs_unlink; /* afs_gfsops.c*/ - afs_int32 C_afs_grmdir; /* afs_gfsops.c*/ - afs_int32 C_afs_makenode; /* afs_gfsops.c*/ - afs_int32 C_afs_grename; /* afs_gfsops.c*/ - afs_int32 C_afs_rele; /* afs_gfsops.c*/ - afs_int32 C_afs_syncgp; /* afs_gfsops.c*/ - afs_int32 C_afs_getval; /* afs_gfsops.c*/ - afs_int32 C_afs_gfshack; /* afs_gfsops.c*/ - afs_int32 C_afs_trunc; /* afs_gfsops.c*/ - afs_int32 C_afs_rwgp; /* afs_gfsops.c*/ - afs_int32 C_afs_stat; /* afs_gfsops.c*/ - afs_int32 C_afsc_link; /* afs_hp_subr.c*/ - afs_int32 C_hpsobind; /* afs_hp_subr.c*/ - afs_int32 C_hpsoclose; /* afs_hp_subr.c*/ - afs_int32 C_hpsocreate; /* afs_hp_subr.c*/ - afs_int32 C_hpsoreserve; /* afs_hp_subr.c*/ - afs_int32 C_afs_vfs_mount; /* afs_hp_subr.c*/ - afs_int32 C_devtovfs; /* afs_istuff.c*/ - afs_int32 C_igetinode; /* afs_istuff.c*/ - afs_int32 C_afs_syscall_iopen; /* afs_istuff.c*/ - afs_int32 C_iopen; /* afs_istuff.c*/ - afs_int32 C_afs_syscall_iincdec; /* afs_istuff.c*/ - afs_int32 C_afs_syscall_ireadwrite; /* afs_istuff.c*/ - afs_int32 C_iincdec; /* afs_istuff.c*/ - afs_int32 C_ireadwrite; /* afs_istuff.c*/ - afs_int32 C_oiread; /* afs_istuff.c*/ - afs_int32 C_AHash; /* afs_istuff.c*/ - afs_int32 C_QTOA; /* afs_istuff.c*/ - afs_int32 C_afs_FindPartByDev; /* afs_istuff.c*/ - afs_int32 C_aux_init; /* afs_istuff.c*/ - afs_int32 C_afs_GetNewPart; /* afs_istuff.c*/ - afs_int32 C_afs_InitAuxVolFile; /* afs_istuff.c*/ - afs_int32 C_afs_CreateAuxEntry; /* afs_istuff.c*/ - afs_int32 C_afs_GetAuxSlot; /* afs_istuff.c*/ - afs_int32 C_afs_GetDownAux; /* afs_istuff.c*/ - afs_int32 C_afs_FlushAuxCache; /* afs_istuff.c*/ - afs_int32 C_afs_GetAuxInode; /* afs_istuff.c*/ - afs_int32 C_afs_PutAuxInode; /* afs_istuff.c*/ - afs_int32 C_afs_ReadAuxInode; /* afs_istuff.c*/ - afs_int32 C_afs_WriteAuxInode; /* afs_istuff.c*/ - afs_int32 C_afs_auxcall; /* afs_istuff.c*/ - afs_int32 C_tmpdbg_auxtbl; /* afs_istuff.c*/ - afs_int32 C_tmpdbg_parttbl; /* afs_istuff.c*/ - afs_int32 C_idec; /* afs_istuff.c*/ - afs_int32 C_iinc; /* afs_istuff.c*/ - afs_int32 C_iread; /* afs_istuff.c*/ - afs_int32 C_iwrite; /* afs_istuff.c*/ - afs_int32 C_getinode; /* afs_istuff.c*/ - afs_int32 C_trygetfs; /* afs_istuff.c*/ - afs_int32 C_iforget; /* afs_istuff.c*/ - afs_int32 C_afs_syscall_icreate; /* afs_istuff.c*/ - afs_int32 C_icreate; /* afs_istuff.c*/ - afs_int32 C_Lock_Init; /* afs_lock.c*/ - afs_int32 C_Lock_Obtain; /* afs_lock.c*/ - afs_int32 C_Lock_ReleaseR; /* afs_lock.c*/ - afs_int32 C_Lock_ReleaseW; /* afs_lock.c*/ - afs_int32 C_afs_BozonLock; /* afs_lock.c*/ - afs_int32 C_afs_BozonUnlock; /* afs_lock.c*/ - afs_int32 C_osi_SleepR; /* afs_lock.c*/ - afs_int32 C_osi_SleepS; /* afs_lock.c*/ - afs_int32 C_osi_SleepW; /* afs_lock.c*/ - afs_int32 C_osi_Sleep; /* afs_lock */ - afs_int32 C_afs_BozonInit; /* afs_lock.c*/ - afs_int32 C_afs_CheckBozonLock; /* afs_lock.c*/ - afs_int32 C_afs_CheckBozonLockBlocking; /* afs_lock.c*/ - afs_int32 C_xxxinit; /* afs_main.c*/ - afs_int32 C_KernelEntry; /* afs_main.c*/ - afs_int32 C_afs_InitMemCache; /* afs_memcache.c*/ - afs_int32 C_afs_LookupMCE; /* afs_memcache.c*/ - afs_int32 C_afs_MemReadBlk; /* afs_memcache.c*/ - afs_int32 C_afs_MemReadUIO; /* afs_memcache.c*/ - afs_int32 C_afs_MemWriteBlk; /* afs_memcache.c*/ - afs_int32 C_afs_MemCacheStoreProc; /* afs_memcache.c*/ - afs_int32 C_afs_MemCacheTruncate; /* afs_memcache.c*/ - afs_int32 C_afs_MemWriteUIO; /* afs_memcache.c*/ - afs_int32 C_afs_MemCacheFetchProc; /* afs_memcache.c*/ - afs_int32 C_afs_vnode_pager_create; /* afs_next_aux.c*/ - afs_int32 C_next_KernelEntry; /* afs_next_subr.c*/ - afs_int32 C_afs_GetNfsClientPag; /* afs_nfsclnt.c*/ - afs_int32 C_afs_FindNfsClientPag; /* afs_nfsclnt.c*/ - afs_int32 C_afs_PutNfsClientPag; /* afs_nfsclnt.c*/ - afs_int32 C_afs_nfsclient_reqhandler; /* afs_nfsclnt.c*/ - afs_int32 C_afs_nfsclient_GC; /* afs_nfsclnt.c*/ - afs_int32 C_afs_nfsclient_hold; /* afs_nfsclnt.c*/ - afs_int32 C_afs_nfsclient_stats; /* afs_nfsclnt.c*/ - afs_int32 C_afs_nfsclient_sysname; /* afs_nfsclnt.c*/ - afs_int32 C_afs_nfsclient_shutdown; /* afs_nfsclnt.c*/ + afs_int32 C_afs_init; /* afs_aix_subr.c */ + afs_int32 C_gop_rdwr; /* afs_aix_subr.c */ + afs_int32 C_aix_gnode_rele; /* afs_aix_subr.c */ + afs_int32 C_gettimeofday; /* afs_aix_subr.c */ + afs_int32 C_m_cpytoc; /* afs_aix_subr.c */ + afs_int32 C_aix_vattr_null; /* afs_aix_subr.c */ + afs_int32 C_afs_gn_ftrunc; /* afs_aixops.c */ + afs_int32 C_afs_gn_rdwr; /* afs_aixops.c */ + afs_int32 C_afs_gn_ioctl; /* afs_aixops.c */ + afs_int32 C_afs_gn_lockctl; /* afs_aixops.c */ + afs_int32 C_afs_gn_readlink; /* afs_aixops.c */ + afs_int32 C_afs_gn_readdir; /* afs_aixops.c */ + afs_int32 C_afs_gn_select; /* afs_aixops.c */ + afs_int32 C_afs_gn_strategy; /* afs_aixops.c */ + afs_int32 C_afs_gn_symlink; /* afs_aixops.c */ + afs_int32 C_afs_gn_revoke; /* afs_aixops.c */ + afs_int32 C_afs_gn_link; /* afs_aixops.c */ + afs_int32 C_afs_gn_mkdir; /* afs_aixops.c */ + afs_int32 C_afs_gn_mknod; /* afs_aixops.c */ + afs_int32 C_afs_gn_remove; /* afs_aixops.c */ + afs_int32 C_afs_gn_rename; /* afs_aixops.c */ + afs_int32 C_afs_gn_rmdir; /* afs_aixops.c */ + afs_int32 C_afs_gn_fid; /* afs_aixops.c */ + afs_int32 C_afs_gn_lookup; /* afs_aixops.c */ + afs_int32 C_afs_gn_open; /* afs_aixops.c */ + afs_int32 C_afs_gn_create; /* afs_aixops.c */ + afs_int32 C_afs_gn_hold; /* afs_aixops.c */ + afs_int32 C_afs_gn_close; /* afs_aixops.c */ + afs_int32 C_afs_gn_map; /* afs_aixops.c */ + afs_int32 C_afs_gn_rele; /* afs_aixops.c */ + afs_int32 C_afs_gn_unmap; /* afs_aixops.c */ + afs_int32 C_afs_gn_access; /* afs_aixops.c */ + afs_int32 C_afs_gn_getattr; /* afs_aixops.c */ + afs_int32 C_afs_gn_setattr; /* afs_aixops.c */ + afs_int32 C_afs_gn_fclear; /* afs_aixops.c */ + afs_int32 C_afs_gn_fsync; /* afs_aixops.c */ + afs_int32 C_pHash; /* afs_buffer.c */ + afs_int32 C_DInit; /* afs_buffer.c */ + afs_int32 C_DRead; /* afs_buffer.c */ + afs_int32 C_FixupBucket; /* afs_buffer.c */ + afs_int32 C_afs_newslot; /* afs_buffer.c */ + afs_int32 C_DRelease; /* afs_buffer.c */ + afs_int32 C_DFlush; /* afs_buffer.c */ + afs_int32 C_DFlushEntry; /* afs_buffer.c */ + afs_int32 C_DVOffset; /* afs_buffer.c */ + afs_int32 C_DZap; /* afs_buffer.c */ + afs_int32 C_DNew; /* afs_buffer.c */ + afs_int32 C_shutdown_bufferpackage; /* afs_buffer.c */ + afs_int32 C_afs_CheckKnownBad; /* afs_cache.c */ + afs_int32 C_afs_RemoveVCB; /* afs_cache.c */ + afs_int32 C_afs_NewVCache; /* afs_cache.c */ + afs_int32 C_afs_FlushActiveVcaches; /* afs_cache.c */ + afs_int32 C_afs_VerifyVCache; /* afs_cache.c */ + afs_int32 C_afs_WriteVCache; /* afs_cache.c */ + afs_int32 C_afs_GetVCache; /* afs_cache.c */ + afs_int32 C_afs_StuffVcache; /* afs_cache.c */ + afs_int32 C_afs_FindVCache; /* afs_cache.c */ + afs_int32 C_afs_PutDCache; /* afs_cache.c */ + afs_int32 C_afs_PutVCache; /* afs_cache.c */ + afs_int32 C_CacheStoreProc; /* afs_cache.c */ + afs_int32 C_afs_FindDCache; /* afs_cache.c */ + afs_int32 C_afs_TryToSmush; /* afs_cache.c */ + afs_int32 C_afs_AdjustSize; /* afs_cache.c */ + afs_int32 C_afs_CheckSize; /* afs_cache.c */ + afs_int32 C_afs_StoreWarn; /* afs_cache.c */ + afs_int32 C_CacheFetchProc; /* afs_cache.c */ + afs_int32 C_UFS_CacheStoreProc; /* afs_cache.c */ + afs_int32 C_UFS_CacheFetchProc; /* afs_cache.c */ + afs_int32 C_afs_GetDCache; /* afs_cache.c */ + afs_int32 C_afs_SimpleVStat; /* afs_cache.c */ + afs_int32 C_afs_ProcessFS; /* afs_cache.c */ + afs_int32 C_afs_InitCacheInfo; /* afs_cache.c */ + afs_int32 C_afs_InitVolumeInfo; /* afs_cache.c */ + afs_int32 C_afs_InitCacheFile; /* afs_cache.c */ + afs_int32 C_afs_CacheInit; /* afs_cache.c */ + afs_int32 C_afs_GetDSlot; /* afs_cache.c */ + afs_int32 C_afs_WriteThroughDSlots; /* afs_cache.c */ + afs_int32 C_afs_MemGetDSlot; /* afs_cache.c */ + afs_int32 C_afs_UFSGetDSlot; /* afs_cache.c */ + afs_int32 C_afs_StoreDCache; /* afs_cache.c */ + afs_int32 C_afs_StoreMini; /* afs_cache.c */ + afs_int32 C_shutdown_cache; /* afs_cache.c */ + afs_int32 C_afs_StoreAllSegments; /* afs_cache.c */ + afs_int32 C_afs_InvalidateAllSegments; /* afs_cache.c */ + afs_int32 C_afs_TruncateAllSegments; /* afs_cache.c */ + afs_int32 C_afs_CheckVolSync; /* afs_cache.c */ + afs_int32 C_afs_wakeup; /* afs_cache.c */ + afs_int32 C_afs_CFileOpen; /* afs_cache.c */ + afs_int32 C_afs_CFileTruncate; /* afs_cache.c */ + afs_int32 C_afs_GetDownD; /* afs_cache.c */ + afs_int32 C_afs_WriteDCache; /* afs_cache.c */ + afs_int32 C_afs_FlushDCache; /* afs_cache.c */ + afs_int32 C_afs_GetDownDSlot; /* afs_cache.c */ + afs_int32 C_afs_FlushVCache; /* afs_cache.c */ + afs_int32 C_afs_GetDownV; /* afs_cache.c */ + afs_int32 C_afs_QueueVCB; /* afs_cache.c */ + afs_int32 C_afs_call; /* afs_call.c */ + afs_int32 C_afs_syscall_call; /* afs_call.c */ + afs_int32 C_syscall; /* afs_call.c */ + afs_int32 C_lpioctl; /* afs_call.c */ + afs_int32 C_lsetpag; /* afs_call.c */ + afs_int32 C_afs_syscall; /* afs_call.c */ + afs_int32 C_afs_CheckInit; /* afs_call.c */ + afs_int32 C_afs_shutdown; /* afs_call.c */ + afs_int32 C_shutdown_BKG; /* afs_call.c */ + afs_int32 C_shutdown_afstest; /* afs_call.c */ + afs_int32 C_SRXAFSCB_GetCE; /* afs_callback.c */ + afs_int32 C_ClearCallBack; /* afs_callback.c */ + afs_int32 C_SRXAFSCB_GetLock; /* afs_callback.c */ + afs_int32 C_SRXAFSCB_CallBack; /* afs_callback.c */ + afs_int32 C_SRXAFSCB_InitCallBackState; /* afs_callback.c */ + afs_int32 C_SRXAFSCB_Probe; /* afs_callback.c */ + afs_int32 C_afs_RXCallBackServer; /* afs_callback.c */ + afs_int32 C_shutdown_CB; /* afs_callback.c */ + afs_int32 C_afs_Chunk; /* afs_chunk.c */ + afs_int32 C_afs_ChunkBase; /* afs_chunk.c */ + afs_int32 C_afs_ChunkOffset; /* afs_chunk.c */ + afs_int32 C_afs_ChunkSize; /* afs_chunk.c */ + afs_int32 C_afs_ChunkToBase; /* afs_chunk.c */ + afs_int32 C_afs_ChunkToSize; /* afs_chunk.c */ + afs_int32 C_afs_SetChunkSize; /* afs_chunk.c */ + + afs_int32 C_afs_config; /* afs_config.c */ + afs_int32 C_mem_freebytes; /* afs_config.c */ + afs_int32 C_mem_getbytes; /* afs_config.c */ + afs_int32 C_fpalloc; /* afs_config.c */ + afs_int32 C_kluge_init; /* afs_config.c */ + afs_int32 C_ufdalloc; /* afs_config.c */ + afs_int32 C_ufdfree; /* afs_config.c */ + afs_int32 C_commit; /* afs_config.c */ + afs_int32 C_dev_ialloc; /* afs_config.c */ + afs_int32 C_ffree; /* afs_config.c */ + afs_int32 C_iget; /* afs_config.c */ + afs_int32 C_iptovp; /* afs_config.c */ + afs_int32 C_ilock; /* afs_config.c */ + afs_int32 C_irele; /* afs_config.c */ + afs_int32 C_iput; /* afs_config.c */ + + afs_int32 C_afs_Daemon; /* afs_daemons.c */ + afs_int32 C_afs_CheckRootVolume; /* afs_daemons.c */ + afs_int32 C_BPath; /* afs_daemons.c */ + afs_int32 C_BPrefetch; /* afs_daemons.c */ + afs_int32 C_BStore; /* afs_daemons.c */ + afs_int32 C_afs_BBusy; /* afs_daemons.c */ + afs_int32 C_afs_BQueue; /* afs_daemons.c */ + afs_int32 C_afs_BRelease; /* afs_daemons.c */ + afs_int32 C_afs_BackgroundDaemon; /* afs_daemons.c */ + afs_int32 C_shutdown_daemons; /* afs_daemons.c */ + afs_int32 C_exporter_add; /* afs_exporter.c */ + afs_int32 C_exporter_find; /* afs_exporter.c */ + afs_int32 C_afs_gfs_kalloc; /* afs_gfs_subr.c */ + afs_int32 C_IsAfsVnode; /* afs_gfs_subr.c */ + afs_int32 C_SetAfsVnode; /* afs_gfs_subr.c */ + afs_int32 C_afs_gfs_kfree; /* afs_gfs_subr.c */ + afs_int32 C_gop_lookupname; /* afs_gfs_subr.c */ + afs_int32 C_gfsvop_getattr; /* afs_gfs_subr.c */ + afs_int32 C_gfsvop_rdwr; /* afs_gfs_subr.c */ + afs_int32 C_afs_uniqtime; /* afs_gfs_subr.c */ + afs_int32 C_gfs_vattr_null; /* afs_gfs_subr.c */ + afs_int32 C_afs_lock; /* afs_gfsops.c */ + afs_int32 C_afs_unlock; /* afs_gfsops.c */ + afs_int32 C_afs_update; /* afs_gfsops.c */ + afs_int32 C_afs_gclose; /* afs_gfsops.c */ + afs_int32 C_afs_gopen; /* afs_gfsops.c */ + afs_int32 C_afs_greadlink; /* afs_gfsops.c */ + afs_int32 C_afs_select; /* afs_gfsops.c */ + afs_int32 C_afs_gbmap; /* afs_gfsops.c */ + afs_int32 C_afs_getfsdata; /* afs_gfsops.c */ + afs_int32 C_afs_gsymlink; /* afs_gfsops.c */ + afs_int32 C_afs_namei; /* afs_gfsops.c */ + afs_int32 C_printgnode; /* afs_gfsops.c */ + afs_int32 C_HaveGFSLock; /* afs_gfsops.c */ + afs_int32 C_afs_gmount; /* afs_gfsops.c */ + afs_int32 C_AddGFSLock; /* afs_gfsops.c */ + afs_int32 C_RemoveGFSLock; /* afs_gfsops.c */ + afs_int32 C_afs_grlock; /* afs_gfsops.c */ + afs_int32 C_afs_gumount; /* afs_gfsops.c */ + afs_int32 C_afs_gget; /* afs_gfsops.c */ + afs_int32 C_afs_glink; /* afs_gfsops.c */ + afs_int32 C_afs_gmkdir; /* afs_gfsops.c */ + afs_int32 C_afs_sbupdate; /* afs_gfsops.c */ + afs_int32 C_afs_unlink; /* afs_gfsops.c */ + afs_int32 C_afs_grmdir; /* afs_gfsops.c */ + afs_int32 C_afs_makenode; /* afs_gfsops.c */ + afs_int32 C_afs_grename; /* afs_gfsops.c */ + afs_int32 C_afs_rele; /* afs_gfsops.c */ + afs_int32 C_afs_syncgp; /* afs_gfsops.c */ + afs_int32 C_afs_getval; /* afs_gfsops.c */ + afs_int32 C_afs_gfshack; /* afs_gfsops.c */ + afs_int32 C_afs_trunc; /* afs_gfsops.c */ + afs_int32 C_afs_rwgp; /* afs_gfsops.c */ + afs_int32 C_afs_stat; /* afs_gfsops.c */ + afs_int32 C_afsc_link; /* afs_hp_subr.c */ + afs_int32 C_hpsobind; /* afs_hp_subr.c */ + afs_int32 C_hpsoclose; /* afs_hp_subr.c */ + afs_int32 C_hpsocreate; /* afs_hp_subr.c */ + afs_int32 C_hpsoreserve; /* afs_hp_subr.c */ + afs_int32 C_afs_vfs_mount; /* afs_hp_subr.c */ + afs_int32 C_devtovfs; /* afs_istuff.c */ + afs_int32 C_igetinode; /* afs_istuff.c */ + afs_int32 C_afs_syscall_iopen; /* afs_istuff.c */ + afs_int32 C_iopen; /* afs_istuff.c */ + afs_int32 C_afs_syscall_iincdec; /* afs_istuff.c */ + afs_int32 C_afs_syscall_ireadwrite; /* afs_istuff.c */ + afs_int32 C_iincdec; /* afs_istuff.c */ + afs_int32 C_ireadwrite; /* afs_istuff.c */ + afs_int32 C_oiread; /* afs_istuff.c */ + afs_int32 C_AHash; /* afs_istuff.c */ + afs_int32 C_QTOA; /* afs_istuff.c */ + afs_int32 C_afs_FindPartByDev; /* afs_istuff.c */ + afs_int32 C_aux_init; /* afs_istuff.c */ + afs_int32 C_afs_GetNewPart; /* afs_istuff.c */ + afs_int32 C_afs_InitAuxVolFile; /* afs_istuff.c */ + afs_int32 C_afs_CreateAuxEntry; /* afs_istuff.c */ + afs_int32 C_afs_GetAuxSlot; /* afs_istuff.c */ + afs_int32 C_afs_GetDownAux; /* afs_istuff.c */ + afs_int32 C_afs_FlushAuxCache; /* afs_istuff.c */ + afs_int32 C_afs_GetAuxInode; /* afs_istuff.c */ + afs_int32 C_afs_PutAuxInode; /* afs_istuff.c */ + afs_int32 C_afs_ReadAuxInode; /* afs_istuff.c */ + afs_int32 C_afs_WriteAuxInode; /* afs_istuff.c */ + afs_int32 C_afs_auxcall; /* afs_istuff.c */ + afs_int32 C_tmpdbg_auxtbl; /* afs_istuff.c */ + afs_int32 C_tmpdbg_parttbl; /* afs_istuff.c */ + afs_int32 C_idec; /* afs_istuff.c */ + afs_int32 C_iinc; /* afs_istuff.c */ + afs_int32 C_iread; /* afs_istuff.c */ + afs_int32 C_iwrite; /* afs_istuff.c */ + afs_int32 C_getinode; /* afs_istuff.c */ + afs_int32 C_trygetfs; /* afs_istuff.c */ + afs_int32 C_iforget; /* afs_istuff.c */ + afs_int32 C_afs_syscall_icreate; /* afs_istuff.c */ + afs_int32 C_icreate; /* afs_istuff.c */ + afs_int32 C_Lock_Init; /* afs_lock.c */ + afs_int32 C_Lock_Obtain; /* afs_lock.c */ + afs_int32 C_Lock_ReleaseR; /* afs_lock.c */ + afs_int32 C_Lock_ReleaseW; /* afs_lock.c */ + afs_int32 C_afs_BozonLock; /* afs_lock.c */ + afs_int32 C_afs_BozonUnlock; /* afs_lock.c */ + afs_int32 C_osi_SleepR; /* afs_lock.c */ + afs_int32 C_osi_SleepS; /* afs_lock.c */ + afs_int32 C_osi_SleepW; /* afs_lock.c */ + afs_int32 C_osi_Sleep; /* afs_lock */ + afs_int32 C_afs_BozonInit; /* afs_lock.c */ + afs_int32 C_afs_CheckBozonLock; /* afs_lock.c */ + afs_int32 C_afs_CheckBozonLockBlocking; /* afs_lock.c */ + afs_int32 C_xxxinit; /* afs_main.c */ + afs_int32 C_KernelEntry; /* afs_main.c */ + afs_int32 C_afs_InitMemCache; /* afs_memcache.c */ + afs_int32 C_afs_LookupMCE; /* afs_memcache.c */ + afs_int32 C_afs_MemReadBlk; /* afs_memcache.c */ + afs_int32 C_afs_MemReadUIO; /* afs_memcache.c */ + afs_int32 C_afs_MemWriteBlk; /* afs_memcache.c */ + afs_int32 C_afs_MemCacheStoreProc; /* afs_memcache.c */ + afs_int32 C_afs_MemCacheTruncate; /* afs_memcache.c */ + afs_int32 C_afs_MemWriteUIO; /* afs_memcache.c */ + afs_int32 C_afs_MemCacheFetchProc; /* afs_memcache.c */ + afs_int32 C_afs_vnode_pager_create; /* afs_next_aux.c */ + afs_int32 C_next_KernelEntry; /* afs_next_subr.c */ + afs_int32 C_afs_GetNfsClientPag; /* afs_nfsclnt.c */ + afs_int32 C_afs_FindNfsClientPag; /* afs_nfsclnt.c */ + afs_int32 C_afs_PutNfsClientPag; /* afs_nfsclnt.c */ + afs_int32 C_afs_nfsclient_reqhandler; /* afs_nfsclnt.c */ + afs_int32 C_afs_nfsclient_GC; /* afs_nfsclnt.c */ + afs_int32 C_afs_nfsclient_hold; /* afs_nfsclnt.c */ + afs_int32 C_afs_nfsclient_stats; /* afs_nfsclnt.c */ + afs_int32 C_afs_nfsclient_sysname; /* afs_nfsclnt.c */ + afs_int32 C_afs_nfsclient_shutdown; /* afs_nfsclnt.c */ afs_int32 C_afs_rfs_readdir_fixup; /* afs_nfssrv.c */ - afs_int32 C_afs_rfs_dispatch; /* afs_nfssrv.c*/ - afs_int32 C_afs_xnfs_svc; /* afs_nfssrv.c*/ - afs_int32 C_afs_xdr_putrddirres; /* afs_nfssrv.c*/ - afs_int32 C_afs_rfs_readdir; /* afs_nfssrv.c*/ - afs_int32 C_afs_rfs_rddirfree; /* afs_nfssrv.c*/ - afs_int32 C_rfs_dupcreate; /* afs_nfssrv.c*/ - afs_int32 C_rfs_dupsetattr; /* afs_nfssrv.c*/ - afs_int32 C_Nfs2AfsCall; /* afs_nfssrv.c*/ - afs_int32 C_afs_sun_xuntext; /* afs_osi.c*/ - afs_int32 C_osi_Active; /* afs_osi.c*/ - afs_int32 C_osi_FlushPages; /* afs_osi.c*/ - afs_int32 C_osi_FlushText; /* afs_osi.c*/ - afs_int32 C_osi_CallProc; /* afs_osi.c*/ - afs_int32 C_osi_CancelProc; /* afs_osi.c*/ - afs_int32 C_osi_Invisible; /* afs_osi.c*/ - afs_int32 C_osi_Time; /* afs_osi.c*/ - afs_int32 C_osi_Alloc; /* afs_osi.c*/ - afs_int32 C_osi_SetTime; /* afs_osi.c*/ - afs_int32 C_osi_Dump; /* afs_osi.c*/ - afs_int32 C_osi_Free; /* afs_osi.c*/ - afs_int32 C_shutdown_osi; /* afs_osi.c*/ - afs_int32 C_osi_UFSOpen; /* afs_osifile.c*/ - afs_int32 C_osi_Close; /* afs_osifile.c*/ - afs_int32 C_osi_Stat; /* afs_osifile.c*/ - afs_int32 C_osi_Truncate; /* afs_osifile.c*/ - afs_int32 C_osi_Read; /* afs_osifile.c*/ - afs_int32 C_osi_Write; /* afs_osifile.c*/ - afs_int32 C_osi_MapStrategy; /* afs_osifile.c*/ - afs_int32 C_shutdown_osifile; /* afs_osifile.c*/ - afs_int32 C_osi_FreeLargeSpace; /* afs_osinet.c*/ - afs_int32 C_osi_FreeSmallSpace; /* afs_osinet.c*/ - afs_int32 C_pkt_iodone; /* afs_osinet.c*/ - afs_int32 C_shutdown_osinet; /* afs_osinet.c*/ - afs_int32 C_afs_cs; /* afs_osinet.c*/ - afs_int32 C_osi_AllocLargeSpace; /* afs_osinet.c*/ - afs_int32 C_osi_AllocSmallSpace; /* afs_osinet.c*/ - afs_int32 C_osi_CloseToTheEdge; /* afs_osinet.c*/ - afs_int32 C_osi_xgreedy; /* afs_osinet.c*/ - afs_int32 C_osi_FreeSocket; /* afs_osinet.c*/ - afs_int32 C_osi_NewSocket; /* afs_osinet.c*/ - afs_int32 C_trysblock; /* afs_osinet.c*/ - afs_int32 C_osi_NetSend; /* afs_osinet.c*/ - afs_int32 C_WaitHack; /* afs_osinet.c*/ - afs_int32 C_osi_CancelWait; /* afs_osinet.c*/ - afs_int32 C_osi_InitWaitHandle; /* afs_osinet.c*/ - afs_int32 C_osi_Wakeup; /* afs_osinet.c*/ - afs_int32 C_osi_Wait; /* afs_osinet.c*/ - afs_int32 C_dirp_Read; /* afs_physio.c*/ - afs_int32 C_dirp_SetCacheDev; /* afs_physio.c*/ - afs_int32 C_Die; /* afs_physio.c*/ - afs_int32 C_dirp_Cpy; /* afs_physio.c*/ - afs_int32 C_dirp_Eq; /* afs_physio.c*/ - afs_int32 C_dirp_Write; /* afs_physio.c*/ - afs_int32 C_dirp_Zap; /* afs_physio.c*/ - afs_int32 C_PSetVolumeStatus; /* afs_pioctl.c*/ - afs_int32 C_PFlush; /* afs_pioctl.c*/ - afs_int32 C_PNewStatMount; /* afs_pioctl.c*/ - afs_int32 C_PGetTokens; /* afs_pioctl.c*/ - afs_int32 C_PUnlog; /* afs_pioctl.c*/ - afs_int32 C_PCheckServers; /* afs_pioctl.c*/ - afs_int32 C_PMariner; /* afs_pioctl.c*/ - afs_int32 C_PCheckAuth; /* afs_pioctl.c*/ - afs_int32 C_PCheckVolNames; /* afs_pioctl.c*/ - afs_int32 C_PFindVolume; /* afs_pioctl.c*/ - afs_int32 C_Prefetch; /* afs_pioctl.c*/ - afs_int32 C_PGetCacheSize; /* afs_pioctl.c*/ - afs_int32 C_PRemoveCallBack; /* afs_pioctl.c*/ - afs_int32 C_PSetCacheSize; /* afs_pioctl.c*/ - afs_int32 C_PViceAccess; /* afs_pioctl.c*/ - afs_int32 C_PListCells; /* afs_pioctl.c*/ - afs_int32 C_PNewCell; /* afs_pioctl.c*/ - afs_int32 C_PRemoveMount; /* afs_pioctl.c*/ - afs_int32 C_HandleIoctl; /* afs_pioctl.c*/ - afs_int32 C__AFSIOCTL; /* afs_pioctl.c*/ - afs_int32 C__VALIDAFSIOCTL; /* afs_pioctl.c*/ - afs_int32 C_PGetCellStatus; /* afs_pioctl.c*/ - afs_int32 C_PSetCellStatus; /* afs_pioctl.c*/ - afs_int32 C_PVenusLogging; /* afs_pioctl.c*/ - afs_int32 C_PFlushVolumeData; /* afs_pioctl.c*/ - afs_int32 C_PSetSysName; /* afs_pioctl.c*/ - afs_int32 C_PExportAfs; /* afs_pioctl.c*/ - afs_int32 C_HandleClientContext; /* afs_pioctl.c*/ - afs_int32 C_afs_ioctl; /* afs_pioctl.c*/ - afs_int32 C_afs_xioctl; /* afs_pioctl.c*/ - afs_int32 C_afs_pioctl; /* afs_pioctl.c*/ - afs_int32 C_afs_syscall_pioctl; /* afs_pioctl.c*/ - afs_int32 C_HandlePioctl; /* afs_pioctl.c*/ - afs_int32 C_PGetAcl; /* afs_pioctl.c*/ - afs_int32 C_PGetFID; /* afs_pioctl.c*/ - afs_int32 C_PSetAcl; /* afs_pioctl.c*/ - afs_int32 C_PBogus; /* afs_pioctl.c*/ - afs_int32 C_PGetFileCell; /* afs_pioctl.c*/ - afs_int32 C_PGetWSCell; /* afs_pioctl.c*/ - afs_int32 C_PNoop; /* afs_pioctl.c*/ - afs_int32 C_PGetUserCell; /* afs_pioctl.c*/ - afs_int32 C_PSetTokens; /* afs_pioctl.c*/ - afs_int32 C_PGetVolumeStatus; /* afs_pioctl.c*/ - afs_int32 C_afs_ResetAccessCache; /* afs_resource.c*/ - afs_int32 C_afs_FindUser; /* afs_resource.c*/ - afs_int32 C_afs_ResetUserConns; /* afs_resource.c*/ - afs_int32 C_afs_ResourceInit; /* afs_resource.c*/ - afs_int32 C_afs_GetCell; /* afs_resource.c*/ - afs_int32 C_afs_GetCellByIndex; /* afs_resource.c*/ - afs_int32 C_afs_GetCellByName; /* afs_resource.c*/ - afs_int32 C_afs_GetRealCellByIndex; /* afs_resource.c*/ - afs_int32 C_afs_NewCell; /* afs_resource.c*/ - afs_int32 C_afs_GetUser; /* afs_resource.c*/ - afs_int32 C_afs_PutUser; /* afs_resource.c*/ - afs_int32 C_afs_SetPrimary; /* afs_resource.c*/ - afs_int32 C_CheckVLDB; /* afs_resource.c*/ - afs_int32 C_afs_GetVolume; /* afs_resource.c*/ - afs_int32 C_afs_GetVolumeByName; /* afs_resource.c*/ - afs_int32 C_InstallVolumeEntry; /* afs_resource.c*/ - afs_int32 C_InstallVolumeInfo; /* afs_resource.c*/ - afs_int32 C_afs_FindServer; /* afs_resource.c*/ - afs_int32 C_afs_PutVolume; /* afs_resource.c*/ - afs_int32 C_afs_random; /* afs_resource.c*/ - afs_int32 C_ranstage; /* afs_resource.c*/ - afs_int32 C_RemoveUserConns; /* afs_resource.c*/ - afs_int32 C_afs_MarinerLog; /* afs_resource.c*/ - afs_int32 C_afs_vtoi; /* afs_resource.c*/ - afs_int32 C_afs_GetServer; /* afs_resource.c*/ - afs_int32 C_afs_SortServers; /* afs_resource.c*/ - afs_int32 C_afs_Conn; /* afs_resource.c*/ - afs_int32 C_afs_ConnByHost; /* afs_resource.c*/ - afs_int32 C_afs_ConnByMHosts; /* afs_resource.c*/ - afs_int32 C_afs_Analyze; /* afs_resource.c*/ - afs_int32 C_afs_PutConn; /* afs_resource.c*/ - afs_int32 C_afs_ResetVolumeInfo; /* afs_resource.c*/ - afs_int32 C_StartLogFile; /* afs_resource.c*/ - afs_int32 C_afs_SetLogFile; /* afs_resource.c*/ - afs_int32 C_EndLogFile; /* afs_resource.c*/ - afs_int32 C_afs_dp; /* afs_resource.c*/ - afs_int32 C_fprf; /* afs_resource.c*/ - afs_int32 C_fprint; /* afs_resource.c*/ - afs_int32 C_fprintn; /* afs_resource.c*/ - afs_int32 C_afs_CheckLocks; /* afs_resource.c*/ - afs_int32 C_puttofile; /* afs_resource.c*/ - afs_int32 C_shutdown_AFS; /* afs_resource.c*/ - afs_int32 C_afs_CheckCacheResets; /* afs_resource.c*/ - afs_int32 C_afs_GCUserData; /* afs_resource.c*/ - afs_int32 C_VSleep; /* afs_resource.c*/ - afs_int32 C_afs_CheckCode; /* afs_resource.c*/ - afs_int32 C_afs_CopyError; /* afs_resource.c*/ - afs_int32 C_afs_FinalizeReq; /* afs_resource.c*/ - afs_int32 C_afs_cv2string; /* afs_resource.c*/ - afs_int32 C_afs_FindVolCache; /* afs_resource.c*/ - afs_int32 C_afs_GetVolCache; /* afs_resource.c*/ - afs_int32 C_afs_GetVolSlot; /* afs_resource.c*/ - afs_int32 C_afs_WriteVolCache; /* afs_resource.c*/ - afs_int32 C_afs_UFSGetVolSlot; /* afs_resource.c*/ - afs_int32 C_afs_CheckVolumeNames; /* afs_resource.c*/ - afs_int32 C_afs_MemGetVolSlot; /* afs_resource.c*/ - afs_int32 C_print_internet_address; /* afs_resource.c*/ - afs_int32 C_CheckVLServer; /* afs_resource.c*/ - afs_int32 C_HaveCallBacksFrom; /* afs_resource.c*/ - afs_int32 C_ServerDown; /* afs_resource.c*/ - afs_int32 C_afs_CheckServers; /* afs_resource.c*/ - afs_int32 C_afs_AddToMean; /* afs_stat.c*/ - afs_int32 C_afs_GetCMStat; /* afs_stat.c*/ - afs_int32 C_afs_getpage; /* afs_sun_subr.c*/ - afs_int32 C_afs_putpage; /* afs_sun_subr.c*/ - afs_int32 C_afs_nfsrdwr; /* afs_sun_subr.c*/ - afs_int32 C_afs_map; /* afs_sun_subr.c*/ - afs_int32 C_afs_cmp; /* afs_sun_subr.c*/ - afs_int32 C_afs_cntl; /* afs_sun_subr.c*/ - afs_int32 C_afs_dump; /* afs_sun_subr.c*/ - afs_int32 C_afs_realvp; /* afs_sun_subr.c*/ - afs_int32 C_afs_PageLeft; /* afs_sun_subr.c*/ - afs_int32 C_afsinit; /* afs_vfsops.c*/ - afs_int32 C_afs_mount; /* afs_vfsops.c*/ - afs_int32 C_afs_unmount; /* afs_vfsops.c*/ - afs_int32 C_afs_root; /* afs_vfsops.c*/ - afs_int32 C_afs_statfs; /* afs_vfsops.c*/ - afs_int32 C_afs_sync; /* afs_vfsops.c*/ - afs_int32 C_afs_vget; /* afs_vfsops.c*/ - afs_int32 C_afs_mountroot; /* afs_vfsops.c*/ - afs_int32 C_afs_swapvp; /* afs_vfsops.c*/ - afs_int32 C_afs_AddMarinerName; /* afs_vnodeops.c*/ - afs_int32 C_afs_setpag; /* afs_vnodeops.c*/ - afs_int32 C_genpag; /* afs_vnodeops.c*/ - afs_int32 C_getpag; /* afs_vnodeops.c*/ - afs_int32 C_afs_GetMariner; /* afs_vnodeops.c*/ - afs_int32 C_afs_badop; /* afs_vnodeops.c*/ - afs_int32 C_afs_index; /* afs_vnodeops.c*/ - afs_int32 C_afs_noop; /* afs_vnodeops.c*/ - afs_int32 C_afs_open; /* afs_vnodeops.c*/ - afs_int32 C_afs_closex; /* afs_vnodeops.c*/ - afs_int32 C_afs_close; /* afs_vnodeops.c*/ - afs_int32 C_afs_MemWrite; /* afs_vnodeops.c*/ - afs_int32 C_afs_write; /* afs_vnodeops.c*/ - afs_int32 C_afs_UFSWrite; /* afs_vnodeops.c*/ - afs_int32 C_afs_rdwr; /* afs_vnodeops.c*/ - afs_int32 C_afs_MemRead; /* afs_vnodeops.c*/ - afs_int32 C_afs_read; /* afs_vnodeops.c*/ - afs_int32 C_FIXUPSTUPIDINODE; /* afs_vnodeops.c*/ - afs_int32 C_afs_UFSRead; /* afs_vnodeops.c*/ - afs_int32 C_afs_CopyOutAttrs; /* afs_vnodeops.c*/ - afs_int32 C_afs_getattr; /* afs_vnodeops.c*/ - afs_int32 C_afs_VAttrToAS; /* afs_vnodeops.c*/ - afs_int32 C_afs_setattr; /* afs_vnodeops.c*/ - afs_int32 C_EvalMountPoint; /* afs_vnodeops.c*/ - afs_int32 C_afs_access; /* afs_vnodeops.c*/ - afs_int32 C_ENameOK; /* afs_vnodeops.c*/ - afs_int32 C_HandleAtName; /* afs_vnodeops.c*/ - afs_int32 C_getsysname; /* afs_vnodeops.c*/ - afs_int32 C_strcat; /* afs_vnodeops.c*/ - afs_int32 C_afs_lookup; /* afs_vnodeops.c*/ - afs_int32 C_afs_create; /* afs_vnodeops.c*/ - afs_int32 C_afs_LocalHero; /* afs_vnodeops.c*/ - afs_int32 C_FetchWholeEnchilada; /* afs_vnodeops.c*/ - afs_int32 C_afs_remove; /* afs_vnodeops.c*/ - afs_int32 C_afs_link; /* afs_vnodeops.c*/ - afs_int32 C_afs_rename; /* afs_vnodeops.c*/ - afs_int32 C_afs_InitReq; /* afs_vnodeops.c*/ - afs_int32 C_afs_mkdir; /* afs_vnodeops.c*/ - afs_int32 C_BlobScan; /* afs_vnodeops.c*/ - afs_int32 C_afs_rmdir; /* afs_vnodeops.c*/ - afs_int32 C_RecLen; /* afs_vnodeops.c*/ - afs_int32 C_RoundToInt; /* afs_vnodeops.c*/ - afs_int32 C_afs_readdir_with_offlist; /* afs_vnodeops.c*/ - afs_int32 C_DIRSIZ_LEN; /* afs_vnodeops.c*/ - afs_int32 C_afs_readdir_move; /* afs_vnodeops.c*/ - afs_int32 C_afs_readdir_iter; /* afs_vnodeops.c*/ - afs_int32 C_HandleFlock; /* afs_vnodeops.c*/ - afs_int32 C_afs_readdir; /* afs_vnodeops.c*/ - afs_int32 C_afs_symlink; /* afs_vnodeops.c*/ - afs_int32 C_afs_HandleLink; /* afs_vnodeops.c*/ - afs_int32 C_afs_MemHandleLink; /* afs_vnodeops.c*/ - afs_int32 C_afs_UFSHandleLink; /* afs_vnodeops.c*/ - afs_int32 C_afs_readlink; /* afs_vnodeops.c*/ - afs_int32 C_afs_fsync; /* afs_vnodeops.c*/ - afs_int32 C_afs_inactive; /* afs_vnodeops.c*/ - afs_int32 C_afs_ustrategy; /* afs_vnodeops.c*/ - afs_int32 C_afs_bread; /* afs_vnodeops.c*/ - afs_int32 C_afs_brelse; /* afs_vnodeops.c*/ - afs_int32 C_afs_bmap; /* afs_vnodeops.c*/ - afs_int32 C_afs_fid; /* afs_vnodeops.c*/ - afs_int32 C_afs_strategy; /* afs_vnodeops.c*/ - afs_int32 C_afs_FakeClose; /* afs_vnodeops.c*/ - afs_int32 C_afs_FakeOpen; /* afs_vnodeops.c*/ - afs_int32 C_afs_StoreOnLastReference; /* afs_vnodeops.c*/ - afs_int32 C_afs_GetAccessBits; /* afs_vnodeops.c*/ - afs_int32 C_afs_AccessOK; /* afs_vnodeops.c*/ - afs_int32 C_shutdown_vnodeops; /* afs_vnodeops.c*/ - afs_int32 C_afsio_copy; /* afs_vnodeops.c*/ - afs_int32 C_afsio_trim; /* afs_vnodeops.c*/ - afs_int32 C_afs_page_read; /* afs_vnodeops.c*/ - afs_int32 C_afs_page_write; /* afs_vnodeops.c*/ - afs_int32 C_afsio_skip; /* afs_vnodeops.c*/ - afs_int32 C_afs_read1dir; /* afs_vnodeops.c*/ - afs_int32 C_afs_get_groups_from_pag; /* afs_vnodeops.c*/ - afs_int32 C_afs_get_pag_from_groups; /* afs_vnodeops.c*/ - afs_int32 C_PagInCred; /* afs_vnodeops.c*/ - afs_int32 C_afs_getgroups; /* afs_vnodeops.c*/ - afs_int32 C_setpag; /* afs_vnodeops.c*/ - afs_int32 C_afs_setgroups; /* afs_vnodeops.c*/ - afs_int32 C_afs_page_in; /* afs_vnodeops.c*/ - afs_int32 C_afs_page_out; /* afs_vnodeops.c*/ - afs_int32 C_AddPag; /* afs_vnodeops.c*/ - afs_int32 C_afs_AdvanceFD; /* afs_vnodeops.c*/ - afs_int32 C_afs_lockf; /* afs_vnodeops.c*/ - afs_int32 C_afs_xsetgroups; /* afs_vnodeops.c*/ - afs_int32 C_afs_nlinks; /* afs_vnodeops.c*/ - afs_int32 C_DoLockWarning; /* afs_vnodeops.c*/ - afs_int32 C_afs_lockctl; /* afs_vnodeops.c*/ - afs_int32 C_afs_xflock; /* afs_vnodeops.c*/ - afs_int32 C_PSetSPrefs; /* afs_pioctl.c*/ - afs_int32 C_PGetSPrefs; /* afs_pioctl.c*/ - afs_int32 C_afs_warn; /* afs_resource.c */ - afs_int32 C_afs_warnuser; /* afs_resource.c */ - afs_int32 C_afs_pagein; /* afs_hp_subr.c*/ - afs_int32 C_afs_pageout; /* afs_hp_subr.c*/ - afs_int32 C_afs_hp_strategy; /* afs_hp_subr.c*/ - afs_int32 C_PGetCPrefs; /* afs_pioctl.c */ - afs_int32 C_PSetCPrefs; /* afs_pioctl.c */ - afs_int32 C_SRXAFSCB_WhoAreYou; /* afs_callback.c*/ - afs_int32 C_afs_DiscardDCache; /* afs_dcache.c*/ - afs_int32 C_afs_FreeDiscardedDCache; /* afs_dcache.c*/ - afs_int32 C_afs_MaybeFreeDiscardedDCache; /* afs_dcache.c*/ + afs_int32 C_afs_rfs_dispatch; /* afs_nfssrv.c */ + afs_int32 C_afs_xnfs_svc; /* afs_nfssrv.c */ + afs_int32 C_afs_xdr_putrddirres; /* afs_nfssrv.c */ + afs_int32 C_afs_rfs_readdir; /* afs_nfssrv.c */ + afs_int32 C_afs_rfs_rddirfree; /* afs_nfssrv.c */ + afs_int32 C_rfs_dupcreate; /* afs_nfssrv.c */ + afs_int32 C_rfs_dupsetattr; /* afs_nfssrv.c */ + afs_int32 C_Nfs2AfsCall; /* afs_nfssrv.c */ + afs_int32 C_afs_sun_xuntext; /* afs_osi.c */ + afs_int32 C_osi_Active; /* afs_osi.c */ + afs_int32 C_osi_FlushPages; /* afs_osi.c */ + afs_int32 C_osi_FlushText; /* afs_osi.c */ + afs_int32 C_osi_CallProc; /* afs_osi.c */ + afs_int32 C_osi_CancelProc; /* afs_osi.c */ + afs_int32 C_osi_Invisible; /* afs_osi.c */ + afs_int32 C_osi_Time; /* afs_osi.c */ + afs_int32 C_osi_Alloc; /* afs_osi.c */ + afs_int32 C_osi_SetTime; /* afs_osi.c */ + afs_int32 C_osi_Dump; /* afs_osi.c */ + afs_int32 C_osi_Free; /* afs_osi.c */ + afs_int32 C_shutdown_osi; /* afs_osi.c */ + afs_int32 C_osi_UFSOpen; /* afs_osifile.c */ + afs_int32 C_osi_Close; /* afs_osifile.c */ + afs_int32 C_osi_Stat; /* afs_osifile.c */ + afs_int32 C_osi_Truncate; /* afs_osifile.c */ + afs_int32 C_osi_Read; /* afs_osifile.c */ + afs_int32 C_osi_Write; /* afs_osifile.c */ + afs_int32 C_osi_MapStrategy; /* afs_osifile.c */ + afs_int32 C_shutdown_osifile; /* afs_osifile.c */ + afs_int32 C_osi_FreeLargeSpace; /* afs_osinet.c */ + afs_int32 C_osi_FreeSmallSpace; /* afs_osinet.c */ + afs_int32 C_pkt_iodone; /* afs_osinet.c */ + afs_int32 C_shutdown_osinet; /* afs_osinet.c */ + afs_int32 C_afs_cs; /* afs_osinet.c */ + afs_int32 C_osi_AllocLargeSpace; /* afs_osinet.c */ + afs_int32 C_osi_AllocSmallSpace; /* afs_osinet.c */ + afs_int32 C_osi_CloseToTheEdge; /* afs_osinet.c */ + afs_int32 C_osi_xgreedy; /* afs_osinet.c */ + afs_int32 C_osi_FreeSocket; /* afs_osinet.c */ + afs_int32 C_osi_NewSocket; /* afs_osinet.c */ + afs_int32 C_trysblock; /* afs_osinet.c */ + afs_int32 C_osi_NetSend; /* afs_osinet.c */ + afs_int32 C_WaitHack; /* afs_osinet.c */ + afs_int32 C_osi_CancelWait; /* afs_osinet.c */ + afs_int32 C_osi_InitWaitHandle; /* afs_osinet.c */ + afs_int32 C_osi_Wakeup; /* afs_osinet.c */ + afs_int32 C_osi_Wait; /* afs_osinet.c */ + afs_int32 C_dirp_Read; /* afs_physio.c */ + afs_int32 C_dirp_SetCacheDev; /* afs_physio.c */ + afs_int32 C_Die; /* afs_physio.c */ + afs_int32 C_dirp_Cpy; /* afs_physio.c */ + afs_int32 C_dirp_Eq; /* afs_physio.c */ + afs_int32 C_dirp_Write; /* afs_physio.c */ + afs_int32 C_dirp_Zap; /* afs_physio.c */ + afs_int32 C_PSetVolumeStatus; /* afs_pioctl.c */ + afs_int32 C_PFlush; /* afs_pioctl.c */ + afs_int32 C_PNewStatMount; /* afs_pioctl.c */ + afs_int32 C_PGetTokens; /* afs_pioctl.c */ + afs_int32 C_PUnlog; /* afs_pioctl.c */ + afs_int32 C_PCheckServers; /* afs_pioctl.c */ + afs_int32 C_PMariner; /* afs_pioctl.c */ + afs_int32 C_PCheckAuth; /* afs_pioctl.c */ + afs_int32 C_PCheckVolNames; /* afs_pioctl.c */ + afs_int32 C_PFindVolume; /* afs_pioctl.c */ + afs_int32 C_Prefetch; /* afs_pioctl.c */ + afs_int32 C_PGetCacheSize; /* afs_pioctl.c */ + afs_int32 C_PRemoveCallBack; /* afs_pioctl.c */ + afs_int32 C_PSetCacheSize; /* afs_pioctl.c */ + afs_int32 C_PViceAccess; /* afs_pioctl.c */ + afs_int32 C_PListCells; /* afs_pioctl.c */ + afs_int32 C_PNewCell; /* afs_pioctl.c */ + afs_int32 C_PRemoveMount; /* afs_pioctl.c */ + afs_int32 C_HandleIoctl; /* afs_pioctl.c */ + afs_int32 C__AFSIOCTL; /* afs_pioctl.c */ + afs_int32 C__VALIDAFSIOCTL; /* afs_pioctl.c */ + afs_int32 C_PGetCellStatus; /* afs_pioctl.c */ + afs_int32 C_PSetCellStatus; /* afs_pioctl.c */ + afs_int32 C_PVenusLogging; /* afs_pioctl.c */ + afs_int32 C_PFlushVolumeData; /* afs_pioctl.c */ + afs_int32 C_PSetSysName; /* afs_pioctl.c */ + afs_int32 C_PExportAfs; /* afs_pioctl.c */ + afs_int32 C_HandleClientContext; /* afs_pioctl.c */ + afs_int32 C_afs_ioctl; /* afs_pioctl.c */ + afs_int32 C_afs_xioctl; /* afs_pioctl.c */ + afs_int32 C_afs_pioctl; /* afs_pioctl.c */ + afs_int32 C_afs_syscall_pioctl; /* afs_pioctl.c */ + afs_int32 C_HandlePioctl; /* afs_pioctl.c */ + afs_int32 C_PGetAcl; /* afs_pioctl.c */ + afs_int32 C_PGetFID; /* afs_pioctl.c */ + afs_int32 C_PSetAcl; /* afs_pioctl.c */ + afs_int32 C_PBogus; /* afs_pioctl.c */ + afs_int32 C_PGetFileCell; /* afs_pioctl.c */ + afs_int32 C_PGetWSCell; /* afs_pioctl.c */ + afs_int32 C_PNoop; /* afs_pioctl.c */ + afs_int32 C_PGetUserCell; /* afs_pioctl.c */ + afs_int32 C_PSetTokens; /* afs_pioctl.c */ + afs_int32 C_PGetVolumeStatus; /* afs_pioctl.c */ + afs_int32 C_afs_ResetAccessCache; /* afs_resource.c */ + afs_int32 C_afs_FindUser; /* afs_resource.c */ + afs_int32 C_afs_ResetUserConns; /* afs_resource.c */ + afs_int32 C_afs_ResourceInit; /* afs_resource.c */ + afs_int32 C_afs_GetCell; /* afs_resource.c */ + afs_int32 C_afs_GetCellByIndex; /* afs_resource.c */ + afs_int32 C_afs_GetCellByName; /* afs_resource.c */ + afs_int32 C_afs_GetRealCellByIndex; /* afs_resource.c */ + afs_int32 C_afs_NewCell; /* afs_resource.c */ + afs_int32 C_afs_GetUser; /* afs_resource.c */ + afs_int32 C_afs_PutUser; /* afs_resource.c */ + afs_int32 C_afs_SetPrimary; /* afs_resource.c */ + afs_int32 C_CheckVLDB; /* afs_resource.c */ + afs_int32 C_afs_GetVolume; /* afs_resource.c */ + afs_int32 C_afs_GetVolumeByName; /* afs_resource.c */ + afs_int32 C_InstallVolumeEntry; /* afs_resource.c */ + afs_int32 C_InstallVolumeInfo; /* afs_resource.c */ + afs_int32 C_afs_FindServer; /* afs_resource.c */ + afs_int32 C_afs_PutVolume; /* afs_resource.c */ + afs_int32 C_afs_random; /* afs_resource.c */ + afs_int32 C_ranstage; /* afs_resource.c */ + afs_int32 C_RemoveUserConns; /* afs_resource.c */ + afs_int32 C_afs_MarinerLog; /* afs_resource.c */ + afs_int32 C_afs_vtoi; /* afs_resource.c */ + afs_int32 C_afs_GetServer; /* afs_resource.c */ + afs_int32 C_afs_SortServers; /* afs_resource.c */ + afs_int32 C_afs_Conn; /* afs_resource.c */ + afs_int32 C_afs_ConnByHost; /* afs_resource.c */ + afs_int32 C_afs_ConnByMHosts; /* afs_resource.c */ + afs_int32 C_afs_Analyze; /* afs_resource.c */ + afs_int32 C_afs_PutConn; /* afs_resource.c */ + afs_int32 C_afs_ResetVolumeInfo; /* afs_resource.c */ + afs_int32 C_StartLogFile; /* afs_resource.c */ + afs_int32 C_afs_SetLogFile; /* afs_resource.c */ + afs_int32 C_EndLogFile; /* afs_resource.c */ + afs_int32 C_afs_dp; /* afs_resource.c */ + afs_int32 C_fprf; /* afs_resource.c */ + afs_int32 C_fprint; /* afs_resource.c */ + afs_int32 C_fprintn; /* afs_resource.c */ + afs_int32 C_afs_CheckLocks; /* afs_resource.c */ + afs_int32 C_puttofile; /* afs_resource.c */ + afs_int32 C_shutdown_AFS; /* afs_resource.c */ + afs_int32 C_afs_CheckCacheResets; /* afs_resource.c */ + afs_int32 C_afs_GCUserData; /* afs_resource.c */ + afs_int32 C_VSleep; /* afs_resource.c */ + afs_int32 C_afs_CheckCode; /* afs_resource.c */ + afs_int32 C_afs_CopyError; /* afs_resource.c */ + afs_int32 C_afs_FinalizeReq; /* afs_resource.c */ + afs_int32 C_afs_cv2string; /* afs_resource.c */ + afs_int32 C_afs_FindVolCache; /* afs_resource.c */ + afs_int32 C_afs_GetVolCache; /* afs_resource.c */ + afs_int32 C_afs_GetVolSlot; /* afs_resource.c */ + afs_int32 C_afs_WriteVolCache; /* afs_resource.c */ + afs_int32 C_afs_UFSGetVolSlot; /* afs_resource.c */ + afs_int32 C_afs_CheckVolumeNames; /* afs_resource.c */ + afs_int32 C_afs_MemGetVolSlot; /* afs_resource.c */ + afs_int32 C_print_internet_address; /* afs_resource.c */ + afs_int32 C_CheckVLServer; /* afs_resource.c */ + afs_int32 C_HaveCallBacksFrom; /* afs_resource.c */ + afs_int32 C_ServerDown; /* afs_resource.c */ + afs_int32 C_afs_CheckServers; /* afs_resource.c */ + afs_int32 C_afs_AddToMean; /* afs_stat.c */ + afs_int32 C_afs_GetCMStat; /* afs_stat.c */ + afs_int32 C_afs_getpage; /* afs_sun_subr.c */ + afs_int32 C_afs_putpage; /* afs_sun_subr.c */ + afs_int32 C_afs_nfsrdwr; /* afs_sun_subr.c */ + afs_int32 C_afs_map; /* afs_sun_subr.c */ + afs_int32 C_afs_cmp; /* afs_sun_subr.c */ + afs_int32 C_afs_cntl; /* afs_sun_subr.c */ + afs_int32 C_afs_dump; /* afs_sun_subr.c */ + afs_int32 C_afs_realvp; /* afs_sun_subr.c */ + afs_int32 C_afs_PageLeft; /* afs_sun_subr.c */ + afs_int32 C_afsinit; /* afs_vfsops.c */ + afs_int32 C_afs_mount; /* afs_vfsops.c */ + afs_int32 C_afs_unmount; /* afs_vfsops.c */ + afs_int32 C_afs_root; /* afs_vfsops.c */ + afs_int32 C_afs_statfs; /* afs_vfsops.c */ + afs_int32 C_afs_sync; /* afs_vfsops.c */ + afs_int32 C_afs_vget; /* afs_vfsops.c */ + afs_int32 C_afs_mountroot; /* afs_vfsops.c */ + afs_int32 C_afs_swapvp; /* afs_vfsops.c */ + afs_int32 C_afs_AddMarinerName; /* afs_vnodeops.c */ + afs_int32 C_afs_setpag; /* afs_vnodeops.c */ + afs_int32 C_genpag; /* afs_vnodeops.c */ + afs_int32 C_getpag; /* afs_vnodeops.c */ + afs_int32 C_afs_GetMariner; /* afs_vnodeops.c */ + afs_int32 C_afs_badop; /* afs_vnodeops.c */ + afs_int32 C_afs_index; /* afs_vnodeops.c */ + afs_int32 C_afs_noop; /* afs_vnodeops.c */ + afs_int32 C_afs_open; /* afs_vnodeops.c */ + afs_int32 C_afs_closex; /* afs_vnodeops.c */ + afs_int32 C_afs_close; /* afs_vnodeops.c */ + afs_int32 C_afs_MemWrite; /* afs_vnodeops.c */ + afs_int32 C_afs_write; /* afs_vnodeops.c */ + afs_int32 C_afs_UFSWrite; /* afs_vnodeops.c */ + afs_int32 C_afs_rdwr; /* afs_vnodeops.c */ + afs_int32 C_afs_MemRead; /* afs_vnodeops.c */ + afs_int32 C_afs_read; /* afs_vnodeops.c */ + afs_int32 C_FIXUPSTUPIDINODE; /* afs_vnodeops.c */ + afs_int32 C_afs_UFSRead; /* afs_vnodeops.c */ + afs_int32 C_afs_CopyOutAttrs; /* afs_vnodeops.c */ + afs_int32 C_afs_getattr; /* afs_vnodeops.c */ + afs_int32 C_afs_VAttrToAS; /* afs_vnodeops.c */ + afs_int32 C_afs_setattr; /* afs_vnodeops.c */ + afs_int32 C_EvalMountPoint; /* afs_vnodeops.c */ + afs_int32 C_afs_access; /* afs_vnodeops.c */ + afs_int32 C_ENameOK; /* afs_vnodeops.c */ + afs_int32 C_HandleAtName; /* afs_vnodeops.c */ + afs_int32 C_getsysname; /* afs_vnodeops.c */ + afs_int32 C_strcat; /* afs_vnodeops.c */ + afs_int32 C_afs_lookup; /* afs_vnodeops.c */ + afs_int32 C_afs_create; /* afs_vnodeops.c */ + afs_int32 C_afs_LocalHero; /* afs_vnodeops.c */ + afs_int32 C_FetchWholeEnchilada; /* afs_vnodeops.c */ + afs_int32 C_afs_remove; /* afs_vnodeops.c */ + afs_int32 C_afs_link; /* afs_vnodeops.c */ + afs_int32 C_afs_rename; /* afs_vnodeops.c */ + afs_int32 C_afs_InitReq; /* afs_vnodeops.c */ + afs_int32 C_afs_mkdir; /* afs_vnodeops.c */ + afs_int32 C_BlobScan; /* afs_vnodeops.c */ + afs_int32 C_afs_rmdir; /* afs_vnodeops.c */ + afs_int32 C_RecLen; /* afs_vnodeops.c */ + afs_int32 C_RoundToInt; /* afs_vnodeops.c */ + afs_int32 C_afs_readdir_with_offlist; /* afs_vnodeops.c */ + afs_int32 C_DIRSIZ_LEN; /* afs_vnodeops.c */ + afs_int32 C_afs_readdir_move; /* afs_vnodeops.c */ + afs_int32 C_afs_readdir_iter; /* afs_vnodeops.c */ + afs_int32 C_HandleFlock; /* afs_vnodeops.c */ + afs_int32 C_afs_readdir; /* afs_vnodeops.c */ + afs_int32 C_afs_symlink; /* afs_vnodeops.c */ + afs_int32 C_afs_HandleLink; /* afs_vnodeops.c */ + afs_int32 C_afs_MemHandleLink; /* afs_vnodeops.c */ + afs_int32 C_afs_UFSHandleLink; /* afs_vnodeops.c */ + afs_int32 C_afs_readlink; /* afs_vnodeops.c */ + afs_int32 C_afs_fsync; /* afs_vnodeops.c */ + afs_int32 C_afs_inactive; /* afs_vnodeops.c */ + afs_int32 C_afs_ustrategy; /* afs_vnodeops.c */ + afs_int32 C_afs_bread; /* afs_vnodeops.c */ + afs_int32 C_afs_brelse; /* afs_vnodeops.c */ + afs_int32 C_afs_bmap; /* afs_vnodeops.c */ + afs_int32 C_afs_fid; /* afs_vnodeops.c */ + afs_int32 C_afs_strategy; /* afs_vnodeops.c */ + afs_int32 C_afs_FakeClose; /* afs_vnodeops.c */ + afs_int32 C_afs_FakeOpen; /* afs_vnodeops.c */ + afs_int32 C_afs_StoreOnLastReference; /* afs_vnodeops.c */ + afs_int32 C_afs_GetAccessBits; /* afs_vnodeops.c */ + afs_int32 C_afs_AccessOK; /* afs_vnodeops.c */ + afs_int32 C_shutdown_vnodeops; /* afs_vnodeops.c */ + afs_int32 C_afsio_copy; /* afs_vnodeops.c */ + afs_int32 C_afsio_trim; /* afs_vnodeops.c */ + afs_int32 C_afs_page_read; /* afs_vnodeops.c */ + afs_int32 C_afs_page_write; /* afs_vnodeops.c */ + afs_int32 C_afsio_skip; /* afs_vnodeops.c */ + afs_int32 C_afs_read1dir; /* afs_vnodeops.c */ + afs_int32 C_afs_get_groups_from_pag; /* afs_vnodeops.c */ + afs_int32 C_afs_get_pag_from_groups; /* afs_vnodeops.c */ + afs_int32 C_PagInCred; /* afs_vnodeops.c */ + afs_int32 C_afs_getgroups; /* afs_vnodeops.c */ + afs_int32 C_setpag; /* afs_vnodeops.c */ + afs_int32 C_afs_setgroups; /* afs_vnodeops.c */ + afs_int32 C_afs_page_in; /* afs_vnodeops.c */ + afs_int32 C_afs_page_out; /* afs_vnodeops.c */ + afs_int32 C_AddPag; /* afs_vnodeops.c */ + afs_int32 C_afs_AdvanceFD; /* afs_vnodeops.c */ + afs_int32 C_afs_lockf; /* afs_vnodeops.c */ + afs_int32 C_afs_xsetgroups; /* afs_vnodeops.c */ + afs_int32 C_afs_nlinks; /* afs_vnodeops.c */ + afs_int32 C_DoLockWarning; /* afs_vnodeops.c */ + afs_int32 C_afs_lockctl; /* afs_vnodeops.c */ + afs_int32 C_afs_xflock; /* afs_vnodeops.c */ + afs_int32 C_PSetSPrefs; /* afs_pioctl.c */ + afs_int32 C_PGetSPrefs; /* afs_pioctl.c */ + afs_int32 C_afs_warn; /* afs_resource.c */ + afs_int32 C_afs_warnuser; /* afs_resource.c */ + afs_int32 C_afs_pagein; /* afs_hp_subr.c */ + afs_int32 C_afs_pageout; /* afs_hp_subr.c */ + afs_int32 C_afs_hp_strategy; /* afs_hp_subr.c */ + afs_int32 C_PGetCPrefs; /* afs_pioctl.c */ + afs_int32 C_PSetCPrefs; /* afs_pioctl.c */ + afs_int32 C_SRXAFSCB_WhoAreYou; /* afs_callback.c */ + afs_int32 C_afs_DiscardDCache; /* afs_dcache.c */ + afs_int32 C_afs_FreeDiscardedDCache; /* afs_dcache.c */ + afs_int32 C_afs_MaybeFreeDiscardedDCache; /* afs_dcache.c */ afs_int32 C_PFlushMount; /* afs_pioctl.c */ - afs_int32 C_SRXAFSCB_GetServerPrefs; /* afs_callback.c*/ - afs_int32 C_SRXAFSCB_GetCellServDB; /* afs_callback.c*/ - afs_int32 C_SRXAFSCB_GetLocalCell; /* afs_callback.c*/ - afs_int32 C_afs_MarshallCacheConfig; /* afs_callback.c*/ - afs_int32 C_SRXAFSCB_GetCacheConfig; /* afs_callback.c*/ - afs_int32 C_SRXAFSCB_GetCE64; /* afs_callback.c*/ - afs_int32 C_SRXAFSCB_GetCellByNum; /* afs_callback.c*/ + afs_int32 C_SRXAFSCB_GetServerPrefs; /* afs_callback.c */ + afs_int32 C_SRXAFSCB_GetCellServDB; /* afs_callback.c */ + afs_int32 C_SRXAFSCB_GetLocalCell; /* afs_callback.c */ + afs_int32 C_afs_MarshallCacheConfig; /* afs_callback.c */ + afs_int32 C_SRXAFSCB_GetCacheConfig; /* afs_callback.c */ + afs_int32 C_SRXAFSCB_GetCE64; /* afs_callback.c */ + afs_int32 C_SRXAFSCB_GetCellByNum; /* afs_callback.c */ }; struct afs_CMMeanStats { - struct afs_MeanStats something; /* fill this in */ + struct afs_MeanStats something; /* fill this in */ }; struct afs_CMStats { @@ -668,12 +668,12 @@ extern struct afs_CMStats afs_cmstats; */ #define AFS_STATS_NUM_DOWNTIME_DURATION_BUCKETS 7 -#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET0 600 /*10 minutes*/ -#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET1 1800 /*30 minutes*/ -#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET2 3600 /*60 minutes*/ -#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET3 7200 /*2 hours*/ -#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET4 14400 /*4 hours*/ -#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET5 28800 /*8 hours*/ +#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET0 600 /*10 minutes */ +#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET1 1800 /*30 minutes */ +#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET2 3600 /*60 minutes */ +#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET3 7200 /*2 hours */ +#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET4 14400 /*4 hours */ +#define AFS_STATS_MAX_DOWNTIME_DURATION_BUCKET5 28800 /*8 hours */ /* * Constants to track downtime incidents: @@ -699,18 +699,18 @@ extern struct afs_CMStats afs_cmstats; * and those outside the client's cell. */ struct afs_stats_SrvUpDownInfo { - afs_int32 numTtlRecords; /*# records, active or inactive*/ - afs_int32 numUpRecords; /*# (active) records currently marked up*/ - afs_int32 numDownRecords; /*# (active) records currently marked down*/ - afs_int32 sumOfRecordAges; /*Sum of server record lifetimes*/ - afs_int32 ageOfYoungestRecord; /*Age of youngest server record*/ - afs_int32 ageOfOldestRecord; /*Age of oldest server record*/ - afs_int32 numDowntimeIncidents; /*Number of (completed) downtime incidents*/ - afs_int32 numRecordsNeverDown; /*Number of server records never marked down*/ - afs_int32 maxDowntimesInARecord; /*Max downtimes seen by any record*/ - afs_int32 sumOfDowntimes; /*Sum of all (completed) downtimes, in seconds*/ - afs_int32 shortestDowntime; /*Shortest downtime, in seconds*/ - afs_int32 longestDowntime; /*Longest downtime, in seconds*/ + afs_int32 numTtlRecords; /*# records, active or inactive */ + afs_int32 numUpRecords; /*# (active) records currently marked up */ + afs_int32 numDownRecords; /*# (active) records currently marked down */ + afs_int32 sumOfRecordAges; /*Sum of server record lifetimes */ + afs_int32 ageOfYoungestRecord; /*Age of youngest server record */ + afs_int32 ageOfOldestRecord; /*Age of oldest server record */ + afs_int32 numDowntimeIncidents; /*Number of (completed) downtime incidents */ + afs_int32 numRecordsNeverDown; /*Number of server records never marked down */ + afs_int32 maxDowntimesInARecord; /*Max downtimes seen by any record */ + afs_int32 sumOfDowntimes; /*Sum of all (completed) downtimes, in seconds */ + afs_int32 shortestDowntime; /*Shortest downtime, in seconds */ + afs_int32 longestDowntime; /*Longest downtime, in seconds */ /* * Arrays keeping distributions on downtime durations and number of * downtime incidents. @@ -729,39 +729,39 @@ struct afs_stats_SrvUpDownInfo { * Performance numbers for the Cache Manager. */ struct afs_stats_CMPerf { - afs_int32 numPerfCalls; /*# of performance calls rcvd*/ - - afs_int32 epoch; /*Cache Manager epoch time*/ - afs_int32 numCellsVisible; /*# cells we know about*/ - afs_int32 numCellsContacted; /*# cells corresponded with*/ - afs_int32 dlocalAccesses; /*# data accesses to files within cell*/ - afs_int32 vlocalAccesses; /*# stat accesses to files within cell*/ - afs_int32 dremoteAccesses; /*# data accesses to files outside of cell*/ - afs_int32 vremoteAccesses; /*# stat accesses to files outside of cell*/ - afs_int32 cacheNumEntries; /*# cache entries*/ - afs_int32 cacheBlocksTotal; /*# (1K) blocks configured for cache*/ - afs_int32 cacheBlocksInUse; /*# cache blocks actively in use*/ - afs_int32 cacheBlocksOrig; /*# cache blocks at bootup*/ - afs_int32 cacheMaxDirtyChunks; /*Max # dirty cache chunks tolerated*/ - afs_int32 cacheCurrDirtyChunks; /*Current # dirty cache chunks*/ - afs_int32 dcacheHits; /*# data files found in local cache*/ - afs_int32 vcacheHits; /*# stat entries found in local cache*/ - afs_int32 dcacheMisses; /*# data files NOT found in local cache*/ - afs_int32 vcacheMisses; /*# stat entries NOT found in local cache*/ - afs_int32 cacheFlushes; /*# files flushed from cache*/ - afs_int32 cacheFilesReused; /*# cache files reused*/ - afs_int32 ProtServerAddr; /*Addr of Protection Server used*/ - afs_int32 vcacheXAllocs; /* Additionally allocated vcaches */ - afs_int32 dcacheXAllocs; /* Additionally allocated dcaches */ + afs_int32 numPerfCalls; /*# of performance calls rcvd */ + + afs_int32 epoch; /*Cache Manager epoch time */ + afs_int32 numCellsVisible; /*# cells we know about */ + afs_int32 numCellsContacted; /*# cells corresponded with */ + afs_int32 dlocalAccesses; /*# data accesses to files within cell */ + afs_int32 vlocalAccesses; /*# stat accesses to files within cell */ + afs_int32 dremoteAccesses; /*# data accesses to files outside of cell */ + afs_int32 vremoteAccesses; /*# stat accesses to files outside of cell */ + afs_int32 cacheNumEntries; /*# cache entries */ + afs_int32 cacheBlocksTotal; /*# (1K) blocks configured for cache */ + afs_int32 cacheBlocksInUse; /*# cache blocks actively in use */ + afs_int32 cacheBlocksOrig; /*# cache blocks at bootup */ + afs_int32 cacheMaxDirtyChunks; /*Max # dirty cache chunks tolerated */ + afs_int32 cacheCurrDirtyChunks; /*Current # dirty cache chunks */ + afs_int32 dcacheHits; /*# data files found in local cache */ + afs_int32 vcacheHits; /*# stat entries found in local cache */ + afs_int32 dcacheMisses; /*# data files NOT found in local cache */ + afs_int32 vcacheMisses; /*# stat entries NOT found in local cache */ + afs_int32 cacheFlushes; /*# files flushed from cache */ + afs_int32 cacheFilesReused; /*# cache files reused */ + afs_int32 ProtServerAddr; /*Addr of Protection Server used */ + afs_int32 vcacheXAllocs; /* Additionally allocated vcaches */ + afs_int32 dcacheXAllocs; /* Additionally allocated dcaches */ /* * Some stats related to our buffer package */ - afs_int32 bufAlloced; /* # of buffers allocated by afs */ + afs_int32 bufAlloced; /* # of buffers allocated by afs */ afs_int32 bufHits; /* # of pages found on buffer cache */ - afs_int32 bufMisses; /* # of pages NOT found on buffer cache */ - afs_int32 bufFlushDirty; /* # of cached dirty bufs flushed because all busy */ - + afs_int32 bufMisses; /* # of pages NOT found on buffer cache */ + afs_int32 bufFlushDirty; /* # of cached dirty bufs flushed because all busy */ + /* * Stats that keep track of all allocated/used objects in CM */ @@ -779,9 +779,9 @@ struct afs_stats_CMPerf { /* * Accounting stats having to do with the server table & records. */ - afs_int32 srvRecords; /*# of servers currently on record*/ - afs_int32 srvRecordsHWM; /* Server record high water mark */ - afs_int32 srvNumBuckets; /* Num server hash chain buckets */ + afs_int32 srvRecords; /*# of servers currently on record */ + afs_int32 srvRecordsHWM; /* Server record high water mark */ + afs_int32 srvNumBuckets; /* Num server hash chain buckets */ afs_int32 srvMaxChainLength; /* Max server hash chain length */ afs_int32 srvMaxChainLengthHWM; /* Server hash chain high water mark */ @@ -789,7 +789,7 @@ struct afs_stats_CMPerf { * Stats having to do with the systype upon which the Cache Manager * is running. */ - afs_int32 sysName_ID; /*Sysname ID for host hardware*/ + afs_int32 sysName_ID; /*Sysname ID for host hardware */ /* * Stats recording downtime characteristics for each File Server and Volume @@ -805,7 +805,7 @@ struct afs_stats_CMPerf { /* * Spares for future expansion. */ - afs_int32 spare[13]; /*Spares*/ + afs_int32 spare[13]; /*Spares */ }; @@ -865,12 +865,12 @@ struct afs_stats_CMPerf { * Record to track timing numbers for each Cache Manager RPC operation. */ struct afs_stats_opTimingData { - afs_int32 numOps; /*Number of operations executed*/ - afs_int32 numSuccesses; /*Number of successful ops*/ - osi_timeval_t sumTime; /*Sum of sample timings*/ - osi_timeval_t sqrTime; /*Sum of squares of sample timings */ - osi_timeval_t minTime; /*Minimum timing value observed*/ - osi_timeval_t maxTime; /*Minimum timing value observed*/ + afs_int32 numOps; /*Number of operations executed */ + afs_int32 numSuccesses; /*Number of successful ops */ + osi_timeval_t sumTime; /*Sum of sample timings */ + osi_timeval_t sqrTime; /*Sum of squares of sample timings */ + osi_timeval_t minTime; /*Minimum timing value observed */ + osi_timeval_t maxTime; /*Minimum timing value observed */ }; /* @@ -891,16 +891,16 @@ struct afs_stats_opTimingData { * Record to track timings and byte sizes for data transfers. */ struct afs_stats_xferData { - afs_int32 numXfers; /*Number of successful xfers*/ - afs_int32 numSuccesses; /*Number of successful xfers*/ - osi_timeval_t sumTime; /*Sum of timing values*/ - osi_timeval_t sqrTime; /*Sum of squares of timing values */ - osi_timeval_t minTime; /*Minimum xfer time recorded*/ - osi_timeval_t maxTime; /*Maximum xfer time recorded*/ - afs_int32 sumBytes; /*Sum of KBytes transferred*/ - afs_int32 minBytes; /*Minimum value observed*/ - afs_int32 maxBytes; /*Maximum value observed*/ - afs_int32 count[AFS_STATS_NUM_XFER_BUCKETS]; /*Tally for each range of bytes*/ + afs_int32 numXfers; /*Number of successful xfers */ + afs_int32 numSuccesses; /*Number of successful xfers */ + osi_timeval_t sumTime; /*Sum of timing values */ + osi_timeval_t sqrTime; /*Sum of squares of timing values */ + osi_timeval_t minTime; /*Minimum xfer time recorded */ + osi_timeval_t maxTime; /*Maximum xfer time recorded */ + afs_int32 sumBytes; /*Sum of KBytes transferred */ + afs_int32 minBytes; /*Minimum value observed */ + afs_int32 maxBytes; /*Maximum value observed */ + afs_int32 count[AFS_STATS_NUM_XFER_BUCKETS]; /*Tally for each range of bytes */ }; /* @@ -1047,12 +1047,12 @@ struct afs_stats_xferData { * Structure recording RPC outcomes. */ struct afs_stats_RPCErrors { - afs_int32 err_Server; /*Server down error*/ - afs_int32 err_Network; /*Network error*/ - afs_int32 err_Protection; /*Protection violation*/ - afs_int32 err_Volume; /*Volume-related error*/ - afs_int32 err_VolumeBusies; /*"Volume busy conditions encountered*/ - afs_int32 err_Other; /*Misc other errors*/ + afs_int32 err_Server; /*Server down error */ + afs_int32 err_Network; /*Network error */ + afs_int32 err_Protection; /*Protection violation */ + afs_int32 err_Volume; /*Volume-related error */ + afs_int32 err_VolumeBusies; /*"Volume busy conditions encountered */ + afs_int32 err_Other; /*Misc other errors */ }; @@ -1061,13 +1061,13 @@ struct afs_stats_RPCErrors { */ struct afs_stats_RPCOpInfo { struct afs_stats_opTimingData - fsRPCTimes[AFS_STATS_NUM_FS_RPC_OPS]; /*Individual FS RPC op timings*/ + fsRPCTimes[AFS_STATS_NUM_FS_RPC_OPS]; /*Individual FS RPC op timings */ struct afs_stats_RPCErrors - fsRPCErrors[AFS_STATS_NUM_FS_RPC_OPS]; /*Individual FS RPC op errors*/ + fsRPCErrors[AFS_STATS_NUM_FS_RPC_OPS]; /*Individual FS RPC op errors */ struct afs_stats_xferData - fsXferTimes[AFS_STATS_NUM_FS_XFER_OPS]; /*Individual FS RPC xfer timings*/ + fsXferTimes[AFS_STATS_NUM_FS_XFER_OPS]; /*Individual FS RPC xfer timings */ struct afs_stats_opTimingData - cmRPCTimes[AFS_STATS_NUM_CM_RPC_OPS]; /*Individual CM RPC op timings*/ + cmRPCTimes[AFS_STATS_NUM_CM_RPC_OPS]; /*Individual CM RPC op timings */ }; /* @@ -1078,25 +1078,25 @@ struct afs_stats_AuthentInfo { * This first set of fields don't have any history - they are simply * snapshots of the system at the time of the probe. */ - afs_int32 curr_PAGs; /*Current number of PAGs*/ - afs_int32 curr_Records; /*Current # of records in table*/ + afs_int32 curr_PAGs; /*Current number of PAGs */ + afs_int32 curr_Records; /*Current # of records in table */ afs_int32 curr_AuthRecords; /*Current # of authenticated - records (w/valid ticket)*/ + * records (w/valid ticket) */ afs_int32 curr_UnauthRecords; /*Current # of unauthenticated - records (w/o any ticket at all)*/ - afs_int32 curr_MaxRecordsInPAG; /*Max records for a single PAG*/ - afs_int32 curr_LongestChain; /*Length of longest current hash chain*/ + * records (w/o any ticket at all) */ + afs_int32 curr_MaxRecordsInPAG; /*Max records for a single PAG */ + afs_int32 curr_LongestChain; /*Length of longest current hash chain */ /* * This second set of fields are values accumulated over the lifetme * of the current CM incarnation. */ - afs_int32 PAGCreations; /*# PAG creations*/ - afs_int32 TicketUpdates; /*# ticket additions/refreshes*/ - afs_int32 HWM_PAGs; /*High water mark - # PAGs*/ - afs_int32 HWM_Records; /* " - # records*/ - afs_int32 HWM_MaxRecordsInPAG; /* " - max records for a single PAG*/ - afs_int32 HWM_LongestChain; /* " - longest hash chain*/ + afs_int32 PAGCreations; /*# PAG creations */ + afs_int32 TicketUpdates; /*# ticket additions/refreshes */ + afs_int32 HWM_PAGs; /*High water mark - # PAGs */ + afs_int32 HWM_Records; /* " - # records */ + afs_int32 HWM_MaxRecordsInPAG; /* " - max records for a single PAG */ + afs_int32 HWM_LongestChain; /* " - longest hash chain */ }; /* @@ -1105,11 +1105,11 @@ struct afs_stats_AuthentInfo { * case of failure. */ struct afs_stats_AccessInfo { - afs_int32 unreplicatedRefs; /*# references to unreplicated data*/ - afs_int32 replicatedRefs; /*# references to replicated data*/ - afs_int32 numReplicasAccessed; /*# replicas accessed*/ - afs_int32 maxReplicasPerRef; /*Max # replicas accessed per ref*/ - afs_int32 refFirstReplicaOK; /*# references satisfied by 1st replica*/ + afs_int32 unreplicatedRefs; /*# references to unreplicated data */ + afs_int32 replicatedRefs; /*# references to replicated data */ + afs_int32 numReplicasAccessed; /*# replicas accessed */ + afs_int32 maxReplicasPerRef; /*Max # replicas accessed per ref */ + afs_int32 refFirstReplicaOK; /*# references satisfied by 1st replica */ }; /* @@ -1118,22 +1118,22 @@ struct afs_stats_AccessInfo { * Results cover all objects in the cache uniformly. */ struct afs_stats_AuthorInfo { - afs_int32 fileSameAuthor; /*File write by same author*/ - afs_int32 fileDiffAuthor; /*File write by diff author*/ - afs_int32 dirSameAuthor; /*Directory write by same author*/ - afs_int32 dirDiffAuthor; /*Directory write by diff author*/ + afs_int32 fileSameAuthor; /*File write by same author */ + afs_int32 fileDiffAuthor; /*File write by diff author */ + afs_int32 dirSameAuthor; /*Directory write by same author */ + afs_int32 dirDiffAuthor; /*Directory write by diff author */ }; /* * Structure holding ``full'' CM peformance measurements. */ struct afs_stats_CMFullPerf { - afs_int32 numFullPerfCalls; /*Number of accesses*/ - struct afs_stats_CMPerf perf; /*General performance stats*/ - struct afs_stats_RPCOpInfo rpc; /*RPC op stats*/ - struct afs_stats_AuthentInfo authent; /*Authentication stats*/ - struct afs_stats_AccessInfo accessinf; /*Access stats*/ - struct afs_stats_AuthorInfo author; /*Authorship stats*/ + afs_int32 numFullPerfCalls; /*Number of accesses */ + struct afs_stats_CMPerf perf; /*General performance stats */ + struct afs_stats_RPCOpInfo rpc; /*RPC op stats */ + struct afs_stats_AuthentInfo authent; /*Authentication stats */ + struct afs_stats_AccessInfo accessinf; /*Access stats */ + struct afs_stats_AuthorInfo author; /*Authorship stats */ }; /* diff --git a/src/afs/afs_user.c b/src/afs/afs_user.c index a0b7b973f..8d3e7dcd7 100644 --- a/src/afs/afs_user.c +++ b/src/afs/afs_user.c @@ -13,7 +13,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/stds.h" #include "afs/sysincludes.h" /* Standard vendor system headers */ @@ -33,7 +34,7 @@ RCSID("$Header$"); #endif /* !defined(UKERNEL) */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #if defined(AFS_SUN56_ENV) #include @@ -57,7 +58,8 @@ void afs_ResetAccessCache(afs_int32 uid, int alock); * Called with afs_xuser, afs_xserver and afs_xconn locks held, to delete * appropriate conn structures for au */ -static void RemoveUserConns(register struct unixuser *au) +static void +RemoveUserConns(register struct unixuser *au) { register int i; register struct server *ts; @@ -65,9 +67,9 @@ static void RemoveUserConns(register struct unixuser *au) register struct conn *tc, **lc; AFS_STATCNT(RemoveUserConns); - for (i=0;inext) { - for (sa = ts->addr; sa; sa = sa->next_sa) { + for (i = 0; i < NSERVERS; i++) { + for (ts = afs_servers[i]; ts; ts = ts->next) { + for (sa = ts->addr; sa; sa = sa->next_sa) { lc = &sa->conns; for (tc = *lc; tc; lc = &tc->next, tc = *lc) { if (tc->user == au && tc->refCount == 0) { @@ -76,14 +78,14 @@ static void RemoveUserConns(register struct unixuser *au) rx_DestroyConnection(tc->id); AFS_GLOCK(); afs_osi_Free(tc, sizeof(struct conn)); - break; /* at most one instance per server */ - } /*Found unreferenced connection for user*/ - } /*For each connection on the server*/ + break; /* at most one instance per server */ + } /*Found unreferenced connection for user */ + } /*For each connection on the server */ } - } /*For each server on chain*/ - } /*For each chain*/ + } /*For each server on chain */ + } /*For each chain */ -} /*RemoveUserConns*/ +} /*RemoveUserConns */ /* Called from afs_Daemon to garbage collect unixusers no longer using system, @@ -93,7 +95,8 @@ static void RemoveUserConns(register struct unixuser *au) * other epochs as soon as possible (old file servers act bizarrely when they * see epoch changes). */ -void afs_GCUserData(int aforce) +void +afs_GCUserData(int aforce) { register struct unixuser *tu, **lu, *nu; register int i; @@ -101,11 +104,11 @@ void afs_GCUserData(int aforce) AFS_STATCNT(afs_GCUserData); /* Obtain locks in valid order */ - ObtainWriteLock(&afs_xuser,95); + ObtainWriteLock(&afs_xuser, 95); ObtainReadLock(&afs_xserver); - ObtainWriteLock(&afs_xconn,96); + ObtainWriteLock(&afs_xconn, 96); now = osi_Time(); - for (i=0;ict.EndTimestamp < now - NOTOKTIMEOUT) delFlag = 1; - } - else { + } else { if (aforce || (tu->tokenTime < now - NOTOKTIMEOUT)) delFlag = 1; } @@ -132,8 +134,7 @@ void afs_GCUserData(int aforce) if (tu->exporter) EXP_RELE(tu->exporter); afs_osi_Free(tu, sizeof(struct unixuser)); - } - else { + } else { lu = &tu->next; } } @@ -142,7 +143,7 @@ void afs_GCUserData(int aforce) ReleaseWriteLock(&afs_xuser); ReleaseReadLock(&afs_xserver); -} /*afs_GCUserData*/ +} /*afs_GCUserData */ /* @@ -150,7 +151,8 @@ void afs_GCUserData(int aforce) * cache for these guys. Can't do this when token expiration detected, * since too many locks are set then. */ -void afs_CheckTokenCache(void) +void +afs_CheckTokenCache(void) { register int i; register struct unixuser *tu; @@ -160,8 +162,8 @@ void afs_CheckTokenCache(void) ObtainReadLock(&afs_xvcache); ObtainReadLock(&afs_xuser); now = osi_Time(); - for (i=0;inext) { + for (i = 0; i < NUSERS; i++) { + for (tu = afs_users[i]; tu; tu = tu->next) { register afs_int32 uid; /* @@ -176,8 +178,9 @@ void afs_CheckTokenCache(void) */ #ifdef notdef /* I really hate this message - MLK */ - afs_warn("afs: Tokens for user of AFS id %d for cell %s expired now\n", - tu->vid, afs_GetCell(tu->cell)->cellName); + afs_warn + ("afs: Tokens for user of AFS id %d for cell %s expired now\n", + tu->vid, afs_GetCell(tu->cell)->cellName); #endif tu->states |= (UTokensBad | UNeedsReset); } @@ -192,10 +195,11 @@ void afs_CheckTokenCache(void) ReleaseReadLock(&afs_xuser); ReleaseReadLock(&afs_xvcache); -} /*afs_CheckTokenCache*/ +} /*afs_CheckTokenCache */ -void afs_ResetAccessCache(afs_int32 uid, int alock) +void +afs_ResetAccessCache(afs_int32 uid, int alock) { register int i; register struct vcache *tvc; @@ -204,42 +208,43 @@ void afs_ResetAccessCache(afs_int32 uid, int alock) AFS_STATCNT(afs_ResetAccessCache); if (alock) ObtainReadLock(&afs_xvcache); - for(i=0;ihnext) { - /* really should do this under cache write lock, but that. - is hard to under locking hierarchy */ - if (tvc->Access && (ac = afs_FindAxs(tvc->Access, uid))) { - afs_RemoveAxs (&tvc->Access, ac); - } + for (i = 0; i < VCSIZE; i++) { + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { + /* really should do this under cache write lock, but that. + * is hard to under locking hierarchy */ + if (tvc->Access && (ac = afs_FindAxs(tvc->Access, uid))) { + afs_RemoveAxs(&tvc->Access, ac); + } } } if (alock) ReleaseReadLock(&afs_xvcache); -} /*afs_ResetAccessCache*/ +} /*afs_ResetAccessCache */ /* * Ensure all connections make use of new tokens. Discard incorrectly-cached * access info. */ -void afs_ResetUserConns (register struct unixuser *auser) +void +afs_ResetUserConns(register struct unixuser *auser) { int i; struct srvAddr *sa; struct conn *tc; - + AFS_STATCNT(afs_ResetUserConns); ObtainReadLock(&afs_xsrvAddr); - ObtainWriteLock(&afs_xconn,98); + ObtainWriteLock(&afs_xconn, 98); - for (i=0;inext_bkt) { - for (tc = sa->conns; tc; tc=tc->next) { - if (tc->user == auser) { - tc->forceConnectFS = 1; - } + for (i = 0; i < NSERVERS; i++) { + for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) { + for (tc = sa->conns; tc; tc = tc->next) { + if (tc->user == auser) { + tc->forceConnectFS = 1; } + } } } @@ -247,18 +252,19 @@ void afs_ResetUserConns (register struct unixuser *auser) ReleaseReadLock(&afs_xsrvAddr); afs_ResetAccessCache(auser->uid, 1); auser->states &= ~UNeedsReset; -} /*afs_ResetUserConns*/ +} /*afs_ResetUserConns */ -struct unixuser *afs_FindUser(afs_int32 auid, afs_int32 acell, afs_int32 locktype) +struct unixuser * +afs_FindUser(afs_int32 auid, afs_int32 acell, afs_int32 locktype) { register struct unixuser *tu; register afs_int32 i; AFS_STATCNT(afs_FindUser); i = UHash(auid); - ObtainWriteLock(&afs_xuser,99); - for(tu = afs_users[i]; tu; tu = tu->next) { + ObtainWriteLock(&afs_xuser, 99); + for (tu = afs_users[i]; tu; tu = tu->next) { if (tu->uid == auid && ((tu->cell == acell) || (acell == -1))) { tu->refCount++; ReleaseWriteLock(&afs_xuser); @@ -268,7 +274,7 @@ struct unixuser *afs_FindUser(afs_int32 auid, afs_int32 acell, afs_int32 locktyp ReleaseWriteLock(&afs_xuser); return NULL; -} /*afs_FindUser*/ +} /*afs_FindUser */ /*------------------------------------------------------------------------ @@ -293,15 +299,16 @@ struct unixuser *afs_FindUser(afs_int32 auid, afs_int32 acell, afs_int32 locktyp * As advertised. *------------------------------------------------------------------------*/ -void afs_ComputePAGStats(void) +void +afs_ComputePAGStats(void) { - register struct unixuser *currPAGP; /*Ptr to curr PAG*/ - register struct unixuser *cmpPAGP; /*Ptr to PAG being compared*/ - register struct afs_stats_AuthentInfo *authP; /*Ptr to stats area*/ - int curr_Record; /*Curr record */ - int currChain; /*Curr hash chain*/ - int currChainLen; /*Length of curr hash chain*/ - int currPAGRecords; /*# records in curr PAG*/ + register struct unixuser *currPAGP; /*Ptr to curr PAG */ + register struct unixuser *cmpPAGP; /*Ptr to PAG being compared */ + register struct afs_stats_AuthentInfo *authP; /*Ptr to stats area */ + int curr_Record; /*Curr record */ + int currChain; /*Curr hash chain */ + int currChainLen; /*Length of curr hash chain */ + int currPAGRecords; /*# records in curr PAG */ /* * Lock out everyone else from scribbling on the PAG entries. @@ -315,18 +322,17 @@ void afs_ComputePAGStats(void) */ curr_Record = 0; authP = &(afs_stats_cmfullperf.authent); - authP->curr_PAGs = 0; - authP->curr_Records = 0; - authP->curr_AuthRecords = 0; - authP->curr_UnauthRecords = 0; - authP->curr_MaxRecordsInPAG = 0; - authP->curr_LongestChain = 0; + authP->curr_PAGs = 0; + authP->curr_Records = 0; + authP->curr_AuthRecords = 0; + authP->curr_UnauthRecords = 0; + authP->curr_MaxRecordsInPAG = 0; + authP->curr_LongestChain = 0; for (currChain = 0; currChain < NUSERS; currChain++) { currChainLen = 0; for (currPAGP = afs_users[currChain]; currPAGP; - currPAGP = currPAGP->next) - { + currPAGP = currPAGP->next) { /* * Bump the number of records on this current chain, along with * the total number of records in existence. @@ -344,14 +350,15 @@ void afs_ComputePAGStats(void) * If this PAG record has already been ``counted', namely * associated with a PAG and tallied, clear its bit and move on. */ - (authP->curr_Records)++; + (authP->curr_Records)++; if (currPAGP->states & UPAGCounted) { currPAGP->states &= ~UPAGCounted; continue; - } /*We've counted this one already*/ + } + /*We've counted this one already */ /* * Jot initial info down, then sweep down the rest of the hash * chain, looking for matching PAG entries. Note: to properly @@ -370,13 +377,13 @@ void afs_ComputePAGStats(void) */ cmpPAGP->states |= UPAGCounted; currPAGRecords++; - if ((cmpPAGP->states & UHasTokens) && - !(cmpPAGP->states & UTokensBad)) + if ((cmpPAGP->states & UHasTokens) + && !(cmpPAGP->states & UTokensBad)) (authP->curr_AuthRecords)++; else (authP->curr_UnauthRecords)++; - } /*Records belong to same PAG*/ - } /*Compare to rest of PAG records in chain*/ + } /*Records belong to same PAG */ + } /*Compare to rest of PAG records in chain */ /* * In the above comparisons, the current PAG record has been @@ -396,7 +403,7 @@ void afs_ComputePAGStats(void) if (currPAGRecords > authP->HWM_MaxRecordsInPAG) authP->HWM_MaxRecordsInPAG = currPAGRecords; } - } /*Sweep a hash chain*/ + } /*Sweep a hash chain */ /* * If the chain we just finished zipping through is the longest we've @@ -408,7 +415,7 @@ void afs_ComputePAGStats(void) authP->HWM_LongestChain = currChainLen; } - } /*For each hash chain in afs_user*/ + } /*For each hash chain in afs_user */ /* * Now that we've counted everything up, we can consider all-time @@ -424,19 +431,19 @@ void afs_ComputePAGStats(void) */ ReleaseReadLock(&afs_xuser); -} /*afs_ComputePAGStats*/ +} /*afs_ComputePAGStats */ -struct unixuser *afs_GetUser(register afs_int32 auid, - afs_int32 acell, afs_int32 locktype) +struct unixuser * +afs_GetUser(register afs_int32 auid, afs_int32 acell, afs_int32 locktype) { - register struct unixuser *tu, *pu=0; + register struct unixuser *tu, *pu = 0; register afs_int32 i; register afs_int32 RmtUser = 0; AFS_STATCNT(afs_GetUser); i = UHash(auid); - ObtainWriteLock(&afs_xuser,104); + ObtainWriteLock(&afs_xuser, 104); for (tu = afs_users[i]; tu; tu = tu->next) { if (tu->uid == auid) { RmtUser = 0; @@ -451,15 +458,14 @@ struct unixuser *afs_GetUser(register afs_int32 auid, tu->refCount++; ReleaseWriteLock(&afs_xuser); return tu; - } else - if (tu->cell == acell || acell == -1) { - tu->refCount++; - ReleaseWriteLock(&afs_xuser); - return tu; - } + } else if (tu->cell == acell || acell == -1) { + tu->refCount++; + ReleaseWriteLock(&afs_xuser); + return tu; + } } } - tu = (struct unixuser *) afs_osi_Alloc(sizeof(struct unixuser)); + tu = (struct unixuser *)afs_osi_Alloc(sizeof(struct unixuser)); #ifndef AFS_NOSTATS afs_stats_cmfullperf.authent.PAGCreations++; #endif /* AFS_NOSTATS */ @@ -473,8 +479,8 @@ struct unixuser *afs_GetUser(register afs_int32 auid, * we simply rerecord relevant information from the original * structure */ - if (pu && pu->exporter) { - (void) EXP_HOLD(tu->exporter = pu->exporter); + if (pu && pu->exporter) { + (void)EXP_HOLD(tu->exporter = pu->exporter); } } tu->uid = auid; @@ -485,21 +491,23 @@ struct unixuser *afs_GetUser(register afs_int32 auid, ReleaseWriteLock(&afs_xuser); return tu; -} /*afs_GetUser*/ +} /*afs_GetUser */ -void afs_PutUser(register struct unixuser *au, afs_int32 locktype) +void +afs_PutUser(register struct unixuser *au, afs_int32 locktype) { AFS_STATCNT(afs_PutUser); --au->refCount; -} /*afs_PutUser*/ +} /*afs_PutUser */ /* * Set the primary flag on a unixuser structure, ensuring that exactly one * dude has the flag set at any time for a particular unix uid. */ -void afs_SetPrimary(register struct unixuser *au, register int aflag) +void +afs_SetPrimary(register struct unixuser *au, register int aflag) { register struct unixuser *tu; register int i; @@ -508,12 +516,12 @@ void afs_SetPrimary(register struct unixuser *au, register int aflag) AFS_STATCNT(afs_SetPrimary); i = UHash(au->uid); pu = NULL; - ObtainWriteLock(&afs_xuser,105); + ObtainWriteLock(&afs_xuser, 105); /* * See if anyone is this uid's primary cell yet; recording in pu the * corresponding user */ - for (tu=afs_users[i]; tu; tu=tu->next) { + for (tu = afs_users[i]; tu; tu = tu->next) { if (tu->uid == au->uid && (tu->states & UPrimary)) { pu = tu; } @@ -529,21 +537,19 @@ void afs_SetPrimary(register struct unixuser *au, register int aflag) } if (aflag == 1) { /* setting au to be primary */ - if (pu) pu->states &= ~UPrimary; + if (pu) + pu->states &= ~UPrimary; au->states |= UPrimary; - } - else - if (aflag == 0) { - /* we don't know if we're supposed to be primary or not */ - if (!pu || au == pu) { - au->states |= UPrimary; - } - else - au->states &= ~UPrimary; + } else if (aflag == 0) { + /* we don't know if we're supposed to be primary or not */ + if (!pu || au == pu) { + au->states |= UPrimary; + } else + au->states &= ~UPrimary; } ReleaseWriteLock(&afs_xuser); -} /*afs_SetPrimary*/ +} /*afs_SetPrimary */ #if AFS_GCPAGS @@ -561,7 +567,7 @@ void afs_SetPrimary(register struct unixuser *au, register int aflag) * the per process loop in GCPAGs doesn't have to * check processes without pags against the afs_users table. */ -static afs_int32 afs_GCPAGs_UIDBaseTokenCount=0; +static afs_int32 afs_GCPAGs_UIDBaseTokenCount = 0; /* * These variables keep track of the number of times @@ -569,13 +575,14 @@ static afs_int32 afs_GCPAGs_UIDBaseTokenCount=0; * walking the process table, there is something wrong and we should not * prematurely expire any tokens. */ -static size_t afs_GCPAGs_perproc_count=0; -static size_t afs_GCPAGs_cred_count=0; +static size_t afs_GCPAGs_perproc_count = 0; +static size_t afs_GCPAGs_cred_count = 0; /* * LOCKS: afs_GCPAGs_perproc_func requires write lock on afs_xuser */ -void afs_GCPAGs_perproc_func(AFS_PROC *pproc) +void +afs_GCPAGs_perproc_func(AFS_PROC * pproc) { afs_int32 pag, hash, uid; const struct AFS_UCRED *pcred; @@ -583,7 +590,7 @@ void afs_GCPAGs_perproc_func(AFS_PROC *pproc) afs_GCPAGs_perproc_count++; pcred = afs_osi_proc2cred(pproc); - if(!pcred) + if (!pcred) return; afs_GCPAGs_cred_count++; @@ -597,22 +604,22 @@ void afs_GCPAGs_perproc_func(AFS_PROC *pproc) hash = UHash(uid); /* if this token is PAG based, or it's UID based and - UID-based tokens exist */ - if((pag != NOPAG) || (afs_GCPAGs_UIDBaseTokenCount)) { + * UID-based tokens exist */ + if ((pag != NOPAG) || (afs_GCPAGs_UIDBaseTokenCount)) { /* find the entries for this uid in all cells and clear the not * referenced flag. Can't use afs_FindUser, because it just returns - * the specific cell asked for, or the first one found. - */ + * the specific cell asked for, or the first one found. + */ struct unixuser *pu; - for(pu = afs_users[hash]; pu; pu = pu->next) { + for (pu = afs_users[hash]; pu; pu = pu->next) { if (pu->uid == uid) { - if(pu->states & TMP_UPAGNotReferenced) { + if (pu->states & TMP_UPAGNotReferenced) { /* clear the 'deleteme' flag for this entry */ pu->states &= ~TMP_UPAGNotReferenced; - if(pag == NOPAG) { + if (pag == NOPAG) { /* This is a uid based token that hadn't - previously been cleared, so decrement the - outstanding uid based token count */ + * previously been cleared, so decrement the + * outstanding uid based token count */ afs_GCPAGs_UIDBaseTokenCount--; } } @@ -634,7 +641,8 @@ void afs_GCPAGs_perproc_func(AFS_PROC *pproc) * an entry in the login cache, so this routine is not needed. */ -afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount) +afs_int32 +afs_GCPAGs(afs_int32 * ReleasedCount) { struct unixuser *pu; int i; @@ -646,10 +654,10 @@ afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount) *ReleasedCount = 0; /* first, loop through afs_users, setting the temporary 'deleteme' flag */ - ObtainWriteLock(&afs_xuser,419); - afs_GCPAGs_UIDBaseTokenCount=0; - for(i=0; i < NUSERS; i++) { - for(pu = afs_users[i]; pu; pu = pu->next) { + ObtainWriteLock(&afs_xuser, 419); + afs_GCPAGs_UIDBaseTokenCount = 0; + for (i = 0; i < NUSERS; i++) { + for (pu = afs_users[i]; pu; pu = pu->next) { pu->states |= TMP_UPAGNotReferenced; if (((pu->uid >> 24) & 0xff) != 'A') { /* this is a uid-based token, */ @@ -663,8 +671,8 @@ afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount) * for each process, mark it's PAGs (if any) in use. * i.e. clear the temporary deleteme flag. */ - afs_GCPAGs_perproc_count=0; - afs_GCPAGs_cred_count=0; + afs_GCPAGs_perproc_count = 0; + afs_GCPAGs_cred_count = 0; afs_osi_TraverseProcTable(); @@ -684,24 +692,24 @@ afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount) * (temp deleteme flag still set) will be marked for later deletion, * by setting their expire times to 0. */ - for(i=0; i < NUSERS; i++) { - for(pu = afs_users[i]; pu; pu = pu->next) { - if(pu->states & TMP_UPAGNotReferenced) { - + for (i = 0; i < NUSERS; i++) { + for (pu = afs_users[i]; pu; pu = pu->next) { + if (pu->states & TMP_UPAGNotReferenced) { + /* clear the temp flag */ pu->states &= ~TMP_UPAGNotReferenced; - + /* Is this entry on behalf of a 'remote' user ? * i.e. nfs translator, etc. */ - if(!pu->exporter && afs_gcpags == AFS_GCPAGS_OK) { + if (!pu->exporter && afs_gcpags == AFS_GCPAGS_OK) { /* set the expire times to 0, causes * afs_GCUserData to remove this entry */ pu->ct.EndTimestamp = 0; pu->tokenTime = 0; - - (*ReleasedCount)++; /* remember how many we marked (info only) */ + + (*ReleasedCount)++; /* remember how many we marked (info only) */ } } } @@ -712,4 +720,4 @@ afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount) return 0; } -#endif /* AFS_GCPAGS */ +#endif /* AFS_GCPAGS */ diff --git a/src/afs/afs_util.c b/src/afs/afs_util.c index bd83a96a2..816927188 100644 --- a/src/afs/afs_util.c +++ b/src/afs/afs_util.c @@ -15,7 +15,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/stds.h" #include "afs/sysincludes.h" /* Standard vendor system headers */ @@ -35,7 +36,7 @@ RCSID("$Header$"); #endif /* !defined(UKERNEL) */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #if defined(AFS_SUN56_ENV) #include @@ -51,12 +52,13 @@ RCSID("$Header$"); #endif #ifndef afs_cv2string -char *afs_cv2string(char *ttp, afs_uint32 aval) +char * +afs_cv2string(char *ttp, afs_uint32 aval) { register char *tp = ttp; - register int i; + register int i; int any; - + AFS_STATCNT(afs_cv2string); any = 0; *(--tp) = 0; @@ -70,21 +72,24 @@ char *afs_cv2string(char *ttp, afs_uint32 aval) *(--tp) = '0'; return tp; -} /*afs_cv2string*/ +} /*afs_cv2string */ #endif #ifndef afs_strcasecmp -int afs_strcasecmp(char *s1, char *s2) +int +afs_strcasecmp(char *s1, char *s2) { while (*s1 && *s2) { char c1, c2; c1 = *s1++; c2 = *s2++; - if (c1 >= 'A' && c1 <= 'Z') c1 += 0x20; - if (c2 >= 'A' && c2 <= 'Z') c2 += 0x20; + if (c1 >= 'A' && c1 <= 'Z') + c1 += 0x20; + if (c2 >= 'A' && c2 <= 'Z') + c2 += 0x20; if (c1 != c2) - return c1-c2; + return c1 - c2; } return *s1 - *s2; @@ -92,34 +97,34 @@ int afs_strcasecmp(char *s1, char *s2) #endif #ifndef afs_strcat -char *afs_strcat(char *s1, char *s2) +char * +afs_strcat(char *s1, char *s2) { char *os1; os1 = s1; - while (*s1++) - ; + while (*s1++); --s1; - while ((*s1++ = *s2++)) - ; + while ((*s1++ = *s2++)); return (os1); } #endif #ifdef AFS_OBSD34_ENV -char *afs_strcpy(char *s1, char *s2) +char * +afs_strcpy(char *s1, char *s2) { char *os1; os1 = s1; - while ((*s1++ = *s2++) != '\0') - ; + while ((*s1++ = *s2++) != '\0'); return os1; } #endif #ifndef afs_strchr -char *afs_strchr(char *s, int c) +char * +afs_strchr(char *s, int c) { char *p; @@ -130,46 +135,50 @@ char *afs_strchr(char *s, int c) } #endif -char *afs_strdup(char *s) +char * +afs_strdup(char *s) { char *n; int cc; cc = strlen(s) + 1; - n = (char *) afs_osi_Alloc(cc); + n = (char *)afs_osi_Alloc(cc); if (n) memcpy(n, s, cc); return n; } -void print_internet_address(char *preamble, struct srvAddr *sa, - char *postamble, int flag) +void +print_internet_address(char *preamble, struct srvAddr *sa, char *postamble, + int flag) { register struct server *aserver = sa->server; char *ptr = "\n"; afs_uint32 address; - + AFS_STATCNT(print_internet_address); address = ntohl(sa->sa_ip); if (aserver->flags & SRVR_MULTIHOMED) { if (flag == 1) { /* server down mesg */ if (!(aserver->flags & SRVR_ISDOWN)) - ptr = " (multi-homed address; other same-host interfaces maybe up)\n"; + ptr = + " (multi-homed address; other same-host interfaces maybe up)\n"; else ptr = " (all multi-homed ip addresses down for the server)\n"; } else if (flag == 2) { /* server up mesg */ - ptr = " (multi-homed address; other same-host interfaces may still be down)\n"; + ptr = + " (multi-homed address; other same-host interfaces may still be down)\n"; } } - afs_warn("%s%d.%d.%d.%d in cell %s%s%s", - preamble, (address >> 24), (address >> 16) & 0xff, (address >> 8) & 0xff, (address) & 0xff, - aserver->cell->cellName, postamble, ptr); - afs_warnuser("%s%d.%d.%d.%d in cell %s%s%s", - preamble, (address >> 24), (address >> 16) & 0xff, (address >> 8) & 0xff, (address) & 0xff, - aserver->cell->cellName, postamble, ptr); + afs_warn("%s%d.%d.%d.%d in cell %s%s%s", preamble, (address >> 24), + (address >> 16) & 0xff, (address >> 8) & 0xff, (address) & 0xff, + aserver->cell->cellName, postamble, ptr); + afs_warnuser("%s%d.%d.%d.%d in cell %s%s%s", preamble, (address >> 24), + (address >> 16) & 0xff, (address >> 8) & 0xff, + (address) & 0xff, aserver->cell->cellName, postamble, ptr); -} /*print_internet_address*/ +} /*print_internet_address */ @@ -178,62 +187,65 @@ void print_internet_address(char *preamble, struct srvAddr *sa, * XXX */ #if 0 -void afs_warn(char *a, long b, long c, long d, long e, long f, - long g, long h, long i, long j) +void +afs_warn(char *a, long b, long c, long d, long e, long f, long g, long h, + long i, long j) #else -void afs_warn(a,b,c,d,e,f,g,h,i,j) -char *a; +void +afs_warn(a, b, c, d, e, f, g, h, i, j) + char *a; #if defined( AFS_USE_VOID_PTR) -void *b, *c, *d, *e, *f, *g, *h, *i, *j; + void *b, *c, *d, *e, *f, *g, *h, *i, *j; #else -long b,c,d,e,f,g,h,i,j; + long b, c, d, e, f, g, h, i, j; #endif #endif { AFS_STATCNT(afs_warn); - - if (afs_showflags & GAGCONSOLE) - { + + if (afs_showflags & GAGCONSOLE) { #if defined(AFS_AIX_ENV) struct file *fd; /* cf. console_printf() in oncplus/kernext/nfs/serv/shared.c */ - if (fp_open("/dev/console",O_WRONLY|O_NOCTTY|O_NDELAY, - 0666,0,FP_SYS,&fd) == 0) { + if (fp_open + ("/dev/console", O_WRONLY | O_NOCTTY | O_NDELAY, 0666, 0, FP_SYS, + &fd) == 0) { char buf[1024]; ssize_t len; ssize_t count; - sprintf(buf, a,b,c,d,e,f,g,h,i,j); + sprintf(buf, a, b, c, d, e, f, g, h, i, j); len = strlen(buf); fp_write(fd, buf, len, 0, UIO_SYSSPACE, &count); fp_close(fd); } #else - printf(a,b,c,d,e,f,g,h,i,j); + printf(a, b, c, d, e, f, g, h, i, j); #endif } } #if 0 -void afs_warnuser(char *a, long b, long c, long d, long e, long f, - long g, long h, long i, long j) +void +afs_warnuser(char *a, long b, long c, long d, long e, long f, long g, long h, + long i, long j) #else -void afs_warnuser(a,b,c,d,e,f,g,h,i,j) -char *a; -long b,c,d,e,f,g,h,i,j; +void +afs_warnuser(a, b, c, d, e, f, g, h, i, j) + char *a; + long b, c, d, e, f, g, h, i, j; #endif { AFS_STATCNT(afs_warnuser); - if (afs_showflags & GAGUSER) - { + if (afs_showflags & GAGUSER) { #ifdef AFS_GLOBAL_SUNLOCK int haveGlock = ISAFS_GLOCK(); if (haveGlock) AFS_GUNLOCK(); #endif /* AFS_GLOBAL_SUNLOCK */ - uprintf(a,b,c,d,e,f,g,h,i,j); + uprintf(a, b, c, d, e, f, g, h, i, j); #ifdef AFS_GLOBAL_SUNLOCK if (haveGlock) @@ -244,63 +256,66 @@ long b,c,d,e,f,g,h,i,j; /* run everywhere, checking locks */ -void afs_CheckLocks(void) +void +afs_CheckLocks(void) { register int i; afs_warn("Looking for locked data structures.\n"); - afs_warn("conn %x, volume %x, user %x, cell %x, server %x\n", - afs_xconn, afs_xvolume, afs_xuser, afs_xcell, afs_xserver); + afs_warn("conn %x, volume %x, user %x, cell %x, server %x\n", afs_xconn, + afs_xvolume, afs_xuser, afs_xcell, afs_xserver); { register struct vcache *tvc; AFS_STATCNT(afs_CheckLocks); - for(i=0;ihnext) { + for (i = 0; i < VCSIZE; i++) { + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { #ifdef AFS_OSF_ENV if (VREFCOUNT(tvc) > 1) -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ if (VREFCOUNT(tvc)) #endif afs_warn("Stat cache entry at %x is held\n", tvc); if (CheckLock(&tvc->lock)) - afs_warn("Stat entry at %x is locked\n", tvc); + afs_warn("Stat entry at %x is locked\n", tvc); } } } { register struct dcache *tdc; - for (i=0;irefCount) afs_warn("Disk entry %d at %x is held\n", i, tdc); } if (afs_indexFlags[i] & IFDataMod) - afs_warn("Disk entry %d at %x has IFDataMod flag set.\n", i, tdc); + afs_warn("Disk entry %d at %x has IFDataMod flag set.\n", i, + tdc); } } { - struct srvAddr *sa; - struct server *ts; - struct conn *tc; - for (i=0;inext) { + struct srvAddr *sa; + struct server *ts; + struct conn *tc; + for (i = 0; i < NSERVERS; i++) { + for (ts = afs_servers[i]; ts; ts = ts->next) { if (ts->flags & SRVR_ISDOWN) printf("Server entry %x is marked down\n", ts); - for (sa = ts->addr; sa; sa = sa->next_sa) { - for (tc = sa->conns; tc; tc=tc->next) { - if (tc->refCount) - afs_warn("conn at %x (server %x) is held\n", tc, sa->sa_ip); + for (sa = ts->addr; sa; sa = sa->next_sa) { + for (tc = sa->conns; tc; tc = tc->next) { + if (tc->refCount) + afs_warn("conn at %x (server %x) is held\n", tc, + sa->sa_ip); } } } } } { - struct volume *tv; - for (i=0;inext) { + struct volume *tv; + for (i = 0; i < NVOLS; i++) { + for (tv = afs_volumes[i]; tv; tv = tv->next) { if (CheckLock(&tv->lock)) afs_warn("volume at %x is locked\n", tv); if (tv->refCount) @@ -309,11 +324,12 @@ void afs_CheckLocks(void) } } { - struct unixuser *tu; + struct unixuser *tu; - for (i=0;inext) { - if (tu->refCount) printf("user at %x is held\n", tu); + for (i = 0; i < NUSERS; i++) { + for (tu = afs_users[i]; tu; tu = tu->next) { + if (tu->refCount) + printf("user at %x is held\n", tu); } } } @@ -321,7 +337,8 @@ void afs_CheckLocks(void) } -int afs_noop(void) +int +afs_noop(void) { AFS_STATCNT(afs_noop); #ifdef AFS_OSF30_ENV @@ -331,7 +348,8 @@ int afs_noop(void) #endif } -int afs_badop(void) +int +afs_badop(void) { AFS_STATCNT(afs_badop); osi_Panic("afs bad vnode op"); @@ -346,35 +364,36 @@ int afs_badop(void) * larger than an afs_int32. */ -afs_int32 afs_data_pointer_to_int32(const void *p) +afs_int32 +afs_data_pointer_to_int32(const void *p) { - union { - afs_int32 i32[sizeof(void *)/sizeof(afs_int32)]; - const void *p; - } ip; - - int i32_sub; /* subscript of least significant afs_int32 in ip.i32[] */ + union { + afs_int32 i32[sizeof(void *) / sizeof(afs_int32)]; + const void *p; + } ip; - /* set i32_sub */ + int i32_sub; /* subscript of least significant afs_int32 in ip.i32[] */ - { - /* used to determine the byte order of the system */ + /* set i32_sub */ - union { - char c[sizeof(int)/sizeof(char)]; - int i; - } ci; + { + /* used to determine the byte order of the system */ - ci.i = 1; - if (ci.c[0] == 1) { - /* little-endian system */ - i32_sub = 0; - } else { - /* big-endian system */ - i32_sub = (sizeof ip.i32 / sizeof ip.i32[0]) - 1; - } + union { + char c[sizeof(int) / sizeof(char)]; + int i; + } ci; + + ci.i = 1; + if (ci.c[0] == 1) { + /* little-endian system */ + i32_sub = 0; + } else { + /* big-endian system */ + i32_sub = (sizeof ip.i32 / sizeof ip.i32[0]) - 1; } + } - ip.p = p; - return ip.i32[i32_sub]; + ip.p = p; + return ip.i32[i32_sub]; } diff --git a/src/afs/afs_util.h b/src/afs/afs_util.h index d67fc5eb0..d5188df01 100644 --- a/src/afs/afs_util.h +++ b/src/afs/afs_util.h @@ -14,6 +14,6 @@ #define _AFS_UTIL_H_ /* Handy max length of a numeric string. */ -#define CVBS 12 /* max afs_int32 is 2^32 ~ 4*10^9, +1 for NULL, +luck */ +#define CVBS 12 /* max afs_int32 is 2^32 ~ 4*10^9, +1 for NULL, +luck */ #endif /* _AFS_UTIL_H_ */ diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 8103d5fd8..c1005fdc1 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -38,17 +38,18 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); -#include "afs/sysincludes.h" /*Standard vendor system headers*/ -#include "afsincludes.h" /*AFS-based standard headers*/ +#include "afs/sysincludes.h" /*Standard vendor system headers */ +#include "afsincludes.h" /*AFS-based standard headers */ #include "afs/afs_stats.h" #include "afs/afs_cbqueue.h" #include "afs/afs_osidnlc.h" #ifdef AFS_OSF_ENV -afs_int32 afs_maxvcount = 0; /* max number of vcache entries */ -afs_int32 afs_vcount = 0; /* number of vcache in use now */ +afs_int32 afs_maxvcount = 0; /* max number of vcache entries */ +afs_int32 afs_vcount = 0; /* number of vcache in use now */ #endif /* AFS_OSF_ENV */ #ifdef AFS_SGI_ENV @@ -60,11 +61,11 @@ char *makesname(); #endif /* AFS_SGI64_ENV */ /* Exported variables */ -afs_rwlock_t afs_xvcache; /*Lock: alloc new stat cache entries*/ -afs_lock_t afs_xvcb; /*Lock: fids on which there are callbacks*/ -struct vcache *freeVCList; /*Free list for stat cache entries*/ -struct vcache *Initial_freeVCList; /*Initial list for above*/ -struct afs_q VLRU; /*vcache LRU*/ +afs_rwlock_t afs_xvcache; /*Lock: alloc new stat cache entries */ +afs_lock_t afs_xvcb; /*Lock: fids on which there are callbacks */ +struct vcache *freeVCList; /*Free list for stat cache entries */ +struct vcache *Initial_freeVCList; /*Initial list for above */ +struct afs_q VLRU; /*vcache LRU */ afs_int32 vcachegen = 0; unsigned int afs_paniconwarn = 0; struct vcache *afs_vhashT[VCSIZE]; @@ -94,8 +95,9 @@ static afs_int32 afs_QueueVCB(struct vcache *avc); * RACE: lock is dropped and reobtained, permitting race in caller */ -int afs_FlushVCache(struct vcache *avc, int *slept) -{ /*afs_FlushVCache*/ +int +afs_FlushVCache(struct vcache *avc, int *slept) +{ /*afs_FlushVCache */ register afs_int32 i, code; register struct vcache **uvc, *wvc; @@ -118,13 +120,13 @@ int afs_FlushVCache(struct vcache *avc, int *slept) code = EBUSY; goto bad; } - if (avc->nextfree || !avc->vlruq.prev || !avc->vlruq.next) { /* qv afs.h */ - refpanic ("LRU vs. Free inconsistency"); + if (avc->nextfree || !avc->vlruq.prev || !avc->vlruq.next) { /* qv afs.h */ + refpanic("LRU vs. Free inconsistency"); } avc->states |= CVFlushed; /* pull the entry out of the lruq and put it on the free list */ QRemove(&avc->vlruq); - avc->vlruq.prev = avc->vlruq.next = (struct afs_q *) 0; + avc->vlruq.prev = avc->vlruq.next = (struct afs_q *)0; /* keep track of # of files that we bulk stat'd, but never used * before they got recycled. @@ -135,26 +137,28 @@ int afs_FlushVCache(struct vcache *avc, int *slept) /* remove entry from the hash chain */ i = VCHash(&avc->fid); uvc = &afs_vhashT[i]; - for(wvc = *uvc; wvc; uvc = &wvc->hnext, wvc = *uvc) { + for (wvc = *uvc; wvc; uvc = &wvc->hnext, wvc = *uvc) { if (avc == wvc) { *uvc = avc->hnext; - avc->hnext = (struct vcache *) NULL; + avc->hnext = (struct vcache *)NULL; break; } } - if (!wvc) osi_Panic("flushvcache"); /* not in correct hash bucket */ - if (avc->mvid) osi_FreeSmallSpace(avc->mvid); - avc->mvid = (struct VenusFid*)0; + if (!wvc) + osi_Panic("flushvcache"); /* not in correct hash bucket */ + if (avc->mvid) + osi_FreeSmallSpace(avc->mvid); + avc->mvid = (struct VenusFid *)0; if (avc->linkData) { - afs_osi_Free(avc->linkData, strlen(avc->linkData)+1); + afs_osi_Free(avc->linkData, strlen(avc->linkData) + 1); avc->linkData = NULL; } #if defined(AFS_OBSD_ENV) /* OK, there are no internal vrefCounts, so there shouldn't - be any more refs here. */ + * be any more refs here. */ if (avc->v) { - avc->v->v_data = NULL; /* remove from vnode */ - avc->v = NULL; /* also drop the ptr to vnode */ + avc->v->v_data = NULL; /* remove from vnode */ + avc->v = NULL; /* also drop the ptr to vnode */ } #endif afs_FreeAllAxs(&(avc->Access)); @@ -167,58 +171,60 @@ int afs_FlushVCache(struct vcache *avc, int *slept) afs_QueueVCB(avc); } ObtainWriteLock(&afs_xcbhash, 460); - afs_DequeueCallback(avc); /* remove it from queued callbacks list */ + afs_DequeueCallback(avc); /* remove it from queued callbacks list */ avc->states &= ~(CStatd | CUnique); ReleaseWriteLock(&afs_xcbhash); afs_symhint_inval(avc); if ((avc->states & CForeign) || (avc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (avc); /* if it (could be) a directory */ + osi_dnlc_purgedp(avc); /* if it (could be) a directory */ else - osi_dnlc_purgevp (avc); + osi_dnlc_purgevp(avc); /* * Next, keep track of which vnodes we've deleted for create's * optimistic synchronization algorithm */ afs_allZaps++; - if (avc->fid.Fid.Vnode & 1) afs_oddZaps++; - else afs_evenZaps++; + if (avc->fid.Fid.Vnode & 1) + afs_oddZaps++; + else + afs_evenZaps++; #if !defined(AFS_OSF_ENV) /* put the entry in the free list */ avc->nextfree = freeVCList; freeVCList = avc; if (avc->vlruq.prev || avc->vlruq.next) { - refpanic ("LRU vs. Free inconsistency"); + refpanic("LRU vs. Free inconsistency"); } #else /* This should put it back on the vnode free list since usecount is 1 */ afs_vcount--; vSetType(avc, VREG); if (VREFCOUNT(avc) > 0) { - VN_UNLOCK(AFSTOV(avc)); - AFS_RELE(AFSTOV(avc)); + VN_UNLOCK(AFSTOV(avc)); + AFS_RELE(AFSTOV(avc)); } else { - if (afs_norefpanic) { - printf ("flush vc refcnt < 1"); - afs_norefpanic++; - (void) vgone(avc, VX_NOSLEEP, NULL); - AFS_GLOCK(); - VN_UNLOCK(AFSTOV(avc)); - } - else osi_Panic ("flush vc refcnt < 1"); - } -#endif /* AFS_OSF_ENV */ + if (afs_norefpanic) { + printf("flush vc refcnt < 1"); + afs_norefpanic++; + (void)vgone(avc, VX_NOSLEEP, NULL); + AFS_GLOCK(); + VN_UNLOCK(AFSTOV(avc)); + } else + osi_Panic("flush vc refcnt < 1"); + } +#endif /* AFS_OSF_ENV */ avc->states |= CVFlushed; return 0; -bad: + bad: #ifdef AFS_OSF_ENV VN_UNLOCK(AFSTOV(avc)); #endif return code; -} /*afs_FlushVCache*/ +} /*afs_FlushVCache */ #ifndef AFS_SGI_ENV /* @@ -226,17 +232,18 @@ bad: * * The core of the inactive vnode op for all but IRIX. */ -void afs_InactiveVCache(struct vcache *avc, struct AFS_UCRED *acred) +void +afs_InactiveVCache(struct vcache *avc, struct AFS_UCRED *acred) { AFS_STATCNT(afs_inactive); if (avc->states & CDirty) { - /* we can't keep trying to push back dirty data forever. Give up. */ - afs_InvalidateAllSegments(avc); /* turns off dirty bit */ + /* we can't keep trying to push back dirty data forever. Give up. */ + afs_InvalidateAllSegments(avc); /* turns off dirty bit */ } - avc->states &= ~CMAPPED; /* mainly used by SunOS 4.0.x */ - avc->states &= ~CDirty; /* Turn it off */ + avc->states &= ~CMAPPED; /* mainly used by SunOS 4.0.x */ + avc->states &= ~CDirty; /* Turn it off */ if (avc->states & CUnlinked) { - if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) { + if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) { avc->states |= CUnlinkedDel; return; } @@ -256,7 +263,8 @@ void afs_InactiveVCache(struct vcache *avc, struct AFS_UCRED *acred) * held, so we don't have to worry about blocking in osi_Alloc. */ static struct afs_cbr *afs_cbrSpace = 0; -struct afs_cbr *afs_AllocCBR(void) +struct afs_cbr * +afs_AllocCBR(void) { register struct afs_cbr *tsp; int i; @@ -266,14 +274,15 @@ struct afs_cbr *afs_AllocCBR(void) /* don't allocate more than 2 * AFS_NCBRS for now */ afs_FlushVCBs(0); afs_stats_cmperf.CallBackFlushes++; - } - else { + } else { /* try allocating */ - tsp = (struct afs_cbr *) afs_osi_Alloc(AFS_NCBRS * sizeof(struct afs_cbr)); - for(i=0; i < AFS_NCBRS-1; i++) { - tsp[i].next = &tsp[i+1]; + tsp = + (struct afs_cbr *)afs_osi_Alloc(AFS_NCBRS * + sizeof(struct afs_cbr)); + for (i = 0; i < AFS_NCBRS - 1; i++) { + tsp[i].next = &tsp[i + 1]; } - tsp[AFS_NCBRS-1].next = 0; + tsp[AFS_NCBRS - 1].next = 0; afs_cbrSpace = tsp; afs_stats_cmperf.CallBackAlloced++; } @@ -293,7 +302,8 @@ struct afs_cbr *afs_AllocCBR(void) * * Environment: the xvcb lock is held over these calls. */ -int afs_FreeCBR(register struct afs_cbr *asp) +int +afs_FreeCBR(register struct afs_cbr *asp) { asp->next = afs_cbrSpace; afs_cbrSpace = asp; @@ -310,7 +320,8 @@ int afs_FreeCBR(register struct afs_cbr *asp) * Environment: holds xvcb lock over RPC to guard against race conditions * when a new callback is granted for the same file later on. */ -afs_int32 afs_FlushVCBs (afs_int32 lockit) +afs_int32 +afs_FlushVCBs(afs_int32 lockit) { struct AFSFid *tfids; struct AFSCallBack callBacks[1]; @@ -324,64 +335,71 @@ afs_int32 afs_FlushVCBs (afs_int32 lockit) struct vrequest treq; struct conn *tc; int safety1, safety2, safety3; - XSTATS_DECLS - - if ((code = afs_InitReq(&treq, &afs_osi_cred))) return code; + XSTATS_DECLS if ((code = afs_InitReq(&treq, &afs_osi_cred))) + return code; treq.flags |= O_NONBLOCK; tfids = afs_osi_Alloc(sizeof(struct AFSFid) * AFS_MAXCBRSCALL); - if (lockit) MObtainWriteLock(&afs_xvcb,273); + if (lockit) + MObtainWriteLock(&afs_xvcb, 273); ObtainReadLock(&afs_xserver); - for(i=0; inext, safety1++) { + for (i = 0; i < NSERVERS; i++) { + for (safety1 = 0, tsp = afs_servers[i]; + tsp && safety1 < afs_totalServers + 10; + tsp = tsp->next, safety1++) { /* don't have any */ - if (tsp->cbrs == (struct afs_cbr *) 0) continue; + if (tsp->cbrs == (struct afs_cbr *)0) + continue; /* otherwise, grab a block of AFS_MAXCBRSCALL from the list * and make an RPC, over and over again. */ - tcount = 0; /* number found so far */ - for (safety2 = 0; safety2 < afs_cacheStats ; safety2++) { + tcount = 0; /* number found so far */ + for (safety2 = 0; safety2 < afs_cacheStats; safety2++) { if (tcount >= AFS_MAXCBRSCALL || !tsp->cbrs) { /* if buffer is full, or we've queued all we're going * to from this server, we should flush out the * callbacks. */ fidArray.AFSCBFids_len = tcount; - fidArray.AFSCBFids_val = (struct AFSFid *) tfids; + fidArray.AFSCBFids_val = (struct AFSFid *)tfids; cbArray.AFSCBs_len = 1; cbArray.AFSCBs_val = callBacks; callBacks[0].CallBackType = CB_EXCLUSIVE; - for (safety3 = 0; safety3 < MAXHOSTS*2; safety3++) { + for (safety3 = 0; safety3 < MAXHOSTS * 2; safety3++) { tc = afs_ConnByHost(tsp, tsp->cell->fsport, tsp->cell->cellNum, &treq, 0, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS); - RX_AFS_GUNLOCK(); - code = RXAFS_GiveUpCallBacks(tc->id, &fidArray, - &cbArray); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - if (!afs_Analyze(tc, code, 0, &treq, - AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS, - SHARED_LOCK, tsp->cell)) { - break; + XSTATS_START_TIME + (AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS); + RX_AFS_GUNLOCK(); + code = + RXAFS_GiveUpCallBacks(tc->id, &fidArray, + &cbArray); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + if (!afs_Analyze + (tc, code, 0, &treq, + AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS, SHARED_LOCK, + tsp->cell)) { + break; } } /* ignore return code, since callbacks may have - * been returned anyway, we shouldn't leave them - * around to be returned again. - * - * Next, see if we are done with this server, and if so, - * break to deal with the next one. - */ - if (!tsp->cbrs) break; + * been returned anyway, we shouldn't leave them + * around to be returned again. + * + * Next, see if we are done with this server, and if so, + * break to deal with the next one. + */ + if (!tsp->cbrs) + break; tcount = 0; - } /* if to flush full buffer */ + } + /* if to flush full buffer */ /* if we make it here, we have an entry at the head of cbrs, * which we should copy to the file ID array and then free. */ @@ -389,20 +407,24 @@ afs_int32 afs_FlushVCBs (afs_int32 lockit) tfids[tcount++] = tcbrp->fid; tsp->cbrs = tcbrp->next; afs_FreeCBR(tcbrp); - } /* while loop for this one server */ + } /* while loop for this one server */ if (safety2 > afs_cacheStats) { - afs_warn("possible internal error afs_flushVCBs (%d)\n", safety2); + afs_warn("possible internal error afs_flushVCBs (%d)\n", + safety2); } - } /* for loop for this hash chain */ - } /* loop through all hash chains */ - if (safety1 > afs_totalServers+2) { - afs_warn("AFS internal error (afs_flushVCBs) (%d > %d), continuing...\n", safety1, afs_totalServers+2); - if (afs_paniconwarn) - osi_Panic("afs_flushVCBS safety1"); + } /* for loop for this hash chain */ + } /* loop through all hash chains */ + if (safety1 > afs_totalServers + 2) { + afs_warn + ("AFS internal error (afs_flushVCBs) (%d > %d), continuing...\n", + safety1, afs_totalServers + 2); + if (afs_paniconwarn) + osi_Panic("afs_flushVCBS safety1"); } ReleaseReadLock(&afs_xserver); - if (lockit) MReleaseWriteLock(&afs_xvcb); + if (lockit) + MReleaseWriteLock(&afs_xvcb); afs_osi_Free(tfids, sizeof(struct AFSFid) * AFS_MAXCBRSCALL); return 0; } @@ -421,7 +443,8 @@ afs_int32 afs_FlushVCBs (afs_int32 lockit) * Called when the xvcache lock is already held. */ -static afs_int32 afs_QueueVCB(struct vcache *avc) +static afs_int32 +afs_QueueVCB(struct vcache *avc) { register struct server *tsp; register struct afs_cbr *tcbp; @@ -433,7 +456,7 @@ static afs_int32 afs_QueueVCB(struct vcache *avc) /* we now have a pointer to the server, so we just allocate * a queue entry and queue it. */ - MObtainWriteLock(&afs_xvcb,274); + MObtainWriteLock(&afs_xvcb, 274); tcbp = afs_AllocCBR(); tcbp->fid = avc->fid.Fid; tcbp->next = tsp->cbrs; @@ -461,7 +484,8 @@ static afs_int32 afs_QueueVCB(struct vcache *avc) * entries locked. */ -int afs_RemoveVCB(struct VenusFid *afid) +int +afs_RemoveVCB(struct VenusFid *afid) { register int i; register struct server *tsp; @@ -469,22 +493,24 @@ int afs_RemoveVCB(struct VenusFid *afid) struct afs_cbr **lcbrpp; AFS_STATCNT(afs_RemoveVCB); - MObtainWriteLock(&afs_xvcb,275); + MObtainWriteLock(&afs_xvcb, 275); ObtainReadLock(&afs_xserver); - for(i=0;inext) { + for (i = 0; i < NSERVERS; i++) { + for (tsp = afs_servers[i]; tsp; tsp = tsp->next) { /* if cell is known, and is wrong, then skip this server */ - if (tsp->cell && tsp->cell->cellNum != afid->Cell) continue; + if (tsp->cell && tsp->cell->cellNum != afid->Cell) + continue; /* * Otherwise, iterate through file IDs we're sending to the * server. */ lcbrpp = &tsp->cbrs; /* first queued return callback */ - for(tcbrp = *lcbrpp; tcbrp; lcbrpp = &tcbrp->next, tcbrp = *lcbrpp) { - if (afid->Fid.Volume == tcbrp->fid.Volume && - afid->Fid.Unique == tcbrp->fid.Unique && - afid->Fid.Vnode == tcbrp->fid.Vnode) { + for (tcbrp = *lcbrpp; tcbrp; + lcbrpp = &tcbrp->next, tcbrp = *lcbrpp) { + if (afid->Fid.Volume == tcbrp->fid.Volume + && afid->Fid.Unique == tcbrp->fid.Unique + && afid->Fid.Vnode == tcbrp->fid.Vnode) { *lcbrpp = tcbrp->next; /* unthread from list */ afs_FreeCBR(tcbrp); goto done; @@ -500,76 +526,77 @@ int afs_RemoveVCB(struct VenusFid *afid) #ifdef AFS_LINUX22_ENV -static void __shrink_dcache_parent(struct dentry * parent) +static void +__shrink_dcache_parent(struct dentry *parent) { - struct dentry *this_parent = parent; - struct list_head *next; - int found = 0; - LIST_HEAD(afs_dentry_unused); - -repeat: - next = this_parent->d_subdirs.next; -resume: - while (next != &this_parent->d_subdirs) { - struct list_head *tmp = next; - struct dentry *dentry = list_entry(tmp, struct dentry, d_child); - next = tmp->next; - if (!DCOUNT(dentry)) { - list_del(&dentry->d_lru); - list_add(&dentry->d_lru, afs_dentry_unused.prev); - found++; - } - /* - * Descend a level if the d_subdirs list is non-empty. - */ - if (!list_empty(&dentry->d_subdirs)) { - this_parent = dentry; - goto repeat; - } + struct dentry *this_parent = parent; + struct list_head *next; + int found = 0; + LIST_HEAD(afs_dentry_unused); + + repeat: + next = this_parent->d_subdirs.next; + resume: + while (next != &this_parent->d_subdirs) { + struct list_head *tmp = next; + struct dentry *dentry = list_entry(tmp, struct dentry, d_child); + next = tmp->next; + if (!DCOUNT(dentry)) { + list_del(&dentry->d_lru); + list_add(&dentry->d_lru, afs_dentry_unused.prev); + found++; } /* - * All done at this level ... ascend and resume the search. + * Descend a level if the d_subdirs list is non-empty. */ - if (this_parent != parent) { - next = this_parent->d_child.next; - this_parent = this_parent->d_parent; - goto resume; + if (!list_empty(&dentry->d_subdirs)) { + this_parent = dentry; + goto repeat; } + } + /* + * All done at this level ... ascend and resume the search. + */ + if (this_parent != parent) { + next = this_parent->d_child.next; + this_parent = this_parent->d_parent; + goto resume; + } - for (;;) { - struct dentry *dentry; - struct list_head *tmp; + for (;;) { + struct dentry *dentry; + struct list_head *tmp; - tmp = afs_dentry_unused.prev; + tmp = afs_dentry_unused.prev; - if (tmp == &afs_dentry_unused) - break; + if (tmp == &afs_dentry_unused) + break; #ifdef AFS_LINUX24_ENV - list_del_init(tmp); + list_del_init(tmp); #else - list_del(tmp); - INIT_LIST_HEAD(tmp); + list_del(tmp); + INIT_LIST_HEAD(tmp); #endif /* AFS_LINUX24_ENV */ - dentry = list_entry(tmp, struct dentry, d_lru); + dentry = list_entry(tmp, struct dentry, d_lru); #ifdef AFS_LINUX24_ENV - /* Unused dentry with a count? */ - if (DCOUNT(dentry)) - BUG(); + /* Unused dentry with a count? */ + if (DCOUNT(dentry)) + BUG(); #endif - DGET(dentry); + DGET(dentry); #ifdef AFS_LINUX24_ENV - list_del_init(&dentry->d_hash); /* d_drop */ + list_del_init(&dentry->d_hash); /* d_drop */ #else - list_del(&dentry->d_hash); - INIT_LIST_HEAD(&dentry->d_hash); + list_del(&dentry->d_hash); + INIT_LIST_HEAD(&dentry->d_hash); #endif /* AFS_LINUX24_ENV */ - DUNLOCK(); - dput(dentry); - DLOCK(); - if (!--found) - break; - } + DUNLOCK(); + dput(dentry); + DLOCK(); + if (!--found) + break; + } } /* afs_TryFlushDcacheChildren -- Shakes loose vcache references held by @@ -581,7 +608,8 @@ resume: * * Tree traversal algorithm from fs/dcache.c: select_parent() */ -static void afs_TryFlushDcacheChildren(struct vcache *tvc) +static void +afs_TryFlushDcacheChildren(struct vcache *tvc) { struct inode *ip = AFSTOI(tvc); struct dentry *this_parent; @@ -591,25 +619,25 @@ static void afs_TryFlushDcacheChildren(struct vcache *tvc) struct dentry *dentry; AFS_GUNLOCK(); -restart: + restart: #ifndef old_vcache_scheme DLOCK(); cur = head; while ((cur = cur->next) != head) { dentry = list_entry(cur, struct dentry, d_alias); - afs_Trace3(afs_iclSetp, CM_TRACE_TRYFLUSHDCACHECHILDREN, - ICL_TYPE_POINTER, ip, - ICL_TYPE_STRING, dentry->d_parent->d_name.name, - ICL_TYPE_STRING, dentry->d_name.name); + afs_Trace3(afs_iclSetp, CM_TRACE_TRYFLUSHDCACHECHILDREN, + ICL_TYPE_POINTER, ip, ICL_TYPE_STRING, + dentry->d_parent->d_name.name, ICL_TYPE_STRING, + dentry->d_name.name); - if (!list_empty(&dentry->d_hash) && !list_empty(&dentry->d_subdirs)) + if (!list_empty(&dentry->d_hash) && !list_empty(&dentry->d_subdirs)) __shrink_dcache_parent(dentry); - if (!DCOUNT(dentry)) { + if (!DCOUNT(dentry)) { DGET(dentry); -#ifdef AFS_LINUX24_ENV - list_del_init(&dentry->d_hash); /* d_drop */ +#ifdef AFS_LINUX24_ENV + list_del_init(&dentry->d_hash); /* d_drop */ #else list_del(&dentry->d_hash); INIT_LIST_HEAD(&dentry->d_hash); @@ -617,21 +645,21 @@ restart: DUNLOCK(); dput(dentry); goto restart; - } + } } DUNLOCK(); AFS_GLOCK(); #else -restart: + restart: DLOCK(); cur = head; while ((cur = cur->next) != head) { dentry = list_entry(cur, struct dentry, d_alias); - afs_Trace3(afs_iclSetp, CM_TRACE_TRYFLUSHDCACHECHILDREN, - ICL_TYPE_POINTER, ip, - ICL_TYPE_STRING, dentry->d_parent->d_name.name, - ICL_TYPE_STRING, dentry->d_name.name); + afs_Trace3(afs_iclSetp, CM_TRACE_TRYFLUSHDCACHECHILDREN, + ICL_TYPE_POINTER, ip, ICL_TYPE_STRING, + dentry->d_parent->d_name.name, ICL_TYPE_STRING, + dentry->d_name.name); if (!DCOUNT(dentry)) { AFS_GUNLOCK(); @@ -663,7 +691,8 @@ restart: * created. */ /* LOCK: afs_NewVCache afs_xvcache W */ -struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) +struct vcache * +afs_NewVCache(struct VenusFid *afid, struct server *serverp) { struct vcache *tvc; afs_int32 i; @@ -672,11 +701,11 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) struct gnode *gnodepnt; #endif #ifdef AFS_MACH_ENV - struct vm_info * vm_info_ptr; + struct vm_info *vm_info_ptr; #endif /* AFS_MACH_ENV */ #ifdef AFS_OSF_ENV struct vcache *nvc; -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ struct afs_q *tq, *uq; int code, fv_slept; @@ -692,25 +721,26 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) * our usage is > afs_maxvcount, set elsewhere to 0.5*nvnode, * we _must_ free some -- no choice). */ - if ( (( 3 * afs_vcount ) > nvnode) || ( afs_vcount >= afs_maxvcount )) { + if (((3 * afs_vcount) > nvnode) || (afs_vcount >= afs_maxvcount)) { #endif struct afs_q *tq, *uq; - int i; char *panicstr; + int i; + char *panicstr; i = 0; for (tq = VLRU.prev; tq != &VLRU && anumber > 0; tq = uq) { tvc = QTOV(tq); uq = QPrev(tq); if (tvc->states & CVFlushed) - refpanic ("CVFlushed on VLRU"); + refpanic("CVFlushed on VLRU"); else if (i++ > afs_maxvcount) - refpanic ("Exceeded pool of AFS vnodes(VLRU cycle?)"); + refpanic("Exceeded pool of AFS vnodes(VLRU cycle?)"); else if (QNext(uq) != tq) - refpanic ("VLRU inconsistent"); + refpanic("VLRU inconsistent"); else if (VREFCOUNT(tvc) < 1) - refpanic ("refcnt 0 on VLRU"); + refpanic("refcnt 0 on VLRU"); - if ( VREFCOUNT(tvc) == 1 && tvc->opens == 0 + if (VREFCOUNT(tvc) == 1 && tvc->opens == 0 && (tvc->states & CUnlinkedDel) == 0) { code = afs_FlushVCache(tvc, &fv_slept); if (code == 0) { @@ -722,7 +752,8 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) continue; /* start over - may have raced. */ } } - if (tq == uq) break; + if (tq == uq) + break; } if (anumber == VCACHE_FREE) { printf("NewVCache: warning none freed, using %d of %d\n", @@ -730,22 +761,22 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) if (afs_vcount >= afs_maxvcount) { osi_Panic("NewVCache - none freed"); /* XXX instead of panicing, should do afs_maxvcount++ - and magic up another one */ + * and magic up another one */ } } } AFS_GUNLOCK(); if (getnewvnode(MOUNT_AFS, &Afs_vnodeops, &nvc)) { - /* What should we do ???? */ - osi_Panic("afs_NewVCache: no more vnodes"); + /* What should we do ???? */ + osi_Panic("afs_NewVCache: no more vnodes"); } AFS_GLOCK(); tvc = nvc; tvc->nextfree = NULL; afs_vcount++; -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ /* pull out a free cache entry */ if (!freeVCList) { i = 0; @@ -755,22 +786,21 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) if (tvc->states & CVFlushed) { refpanic("CVFlushed on VLRU"); - } else if (i++ > 2*afs_cacheStats) { /* even allowing for a few xallocs...*/ + } else if (i++ > 2 * afs_cacheStats) { /* even allowing for a few xallocs... */ refpanic("Increase -stat parameter of afsd(VLRU cycle?)"); } else if (QNext(uq) != tq) { refpanic("VLRU inconsistent"); } - #ifdef AFS_DARWIN_ENV - if (tvc->opens == 0 && ((tvc->states & CUnlinkedDel) == 0) && - VREFCOUNT(tvc) == 1 && UBCINFOEXISTS(&tvc->v)) { + if (tvc->opens == 0 && ((tvc->states & CUnlinkedDel) == 0) + && VREFCOUNT(tvc) == 1 && UBCINFOEXISTS(&tvc->v)) { osi_VM_TryReclaim(tvc, &fv_slept); if (fv_slept) { uq = VLRU.prev; i = 0; continue; /* start over - may have raced. */ } - } + } #elif defined(AFS_FBSD50_ENV) if (VREFCOUNT(tvc) == 1 && tvc->opens == 0 && (tvc->states & CUnlinkedDel) == 0) { @@ -778,7 +808,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) if (VREFCOUNT(tvc) == 1 && tvc->opens == 0 && (tvc->states & CUnlinkedDel) == 0) { VREFCOUNT_DEC(tvc); - AFS_GUNLOCK(); /* perhaps inline inactive for locking */ + AFS_GUNLOCK(); /* perhaps inline inactive for locking */ VOP_INACTIVE(&tvc->v, curthread); AFS_GLOCK(); } else { @@ -793,7 +823,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) if (VREFCOUNT(tvc) == 1 && tvc->opens == 0 && (tvc->states & CUnlinkedDel) == 0) { VREFCOUNT_DEC(tvc); - AFS_GUNLOCK(); /* perhaps inline inactive for locking */ + AFS_GUNLOCK(); /* perhaps inline inactive for locking */ VOP_INACTIVE(&tvc->v, curproc); AFS_GLOCK(); } else { @@ -829,13 +859,14 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) continue; /* start over - may have raced. */ } } - if (tq == uq ) break; + if (tq == uq) + break; } } if (!freeVCList) { /* none free, making one is better than a panic */ afs_stats_cmperf.vcacheXAllocs++; /* count in case we have a leak */ - tvc = (struct vcache *) afs_osi_Alloc(sizeof (struct vcache)); + tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache)); #ifdef KERNEL_HAVE_PIN pin((char *)tvc, sizeof(struct vcache)); /* XXX */ #endif @@ -848,26 +879,29 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) */ #endif /* AFS_MACH_ENV */ #if defined(AFS_SGI_ENV) - { char name[METER_NAMSZ]; - memset(tvc, 0, sizeof(struct vcache)); - tvc->v.v_number = ++afsvnumbers; - tvc->vc_rwlockid = OSI_NO_LOCKID; - initnsema(&tvc->vc_rwlock, 1, makesname(name, "vrw", tvc->v.v_number)); + { + char name[METER_NAMSZ]; + memset(tvc, 0, sizeof(struct vcache)); + tvc->v.v_number = ++afsvnumbers; + tvc->vc_rwlockid = OSI_NO_LOCKID; + initnsema(&tvc->vc_rwlock, 1, + makesname(name, "vrw", tvc->v.v_number)); #ifndef AFS_SGI53_ENV - initnsema(&tvc->v.v_sync, 0, makesname(name, "vsy", tvc->v.v_number)); + initnsema(&tvc->v.v_sync, 0, + makesname(name, "vsy", tvc->v.v_number)); #endif #ifndef AFS_SGI62_ENV - initnlock(&tvc->v.v_lock, makesname(name, "vlk", tvc->v.v_number)); + initnlock(&tvc->v.v_lock, + makesname(name, "vlk", tvc->v.v_number)); #endif } #endif /* AFS_SGI_ENV */ - } - else { - tvc = freeVCList; /* take from free list */ + } else { + tvc = freeVCList; /* take from free list */ freeVCList = tvc->nextfree; tvc->nextfree = NULL; } -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ #ifdef AFS_MACH_ENV vm_info_ptr = tvc->v.v_vm_info; @@ -894,7 +928,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) tvc->v.v_vm_info->pager = MEMORY_OBJECT_NULL; #endif /* AFS_MACH_ENV */ #ifdef AFS_OBSD_ENV - afs_nbsd_getnewvnode(tvc); /* includes one refcount */ + afs_nbsd_getnewvnode(tvc); /* includes one refcount */ lockinit(&tvc->rwlock, PINOD, "vcache", 0, 0); #endif tvc->parentVnode = 0; @@ -912,19 +946,19 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) tvc->vc_error = 0; afs_symhint_inval(tvc); #ifdef AFS_TEXT_ENV - tvc->flushDV.low = tvc->flushDV.high = AFS_MAXDV; + tvc->flushDV.low = tvc->flushDV.high = AFS_MAXDV; #endif hzero(tvc->mapDV); tvc->truncPos = AFS_NOTRUNC; /* don't truncate until we need to */ - hzero(tvc->m.DataVersion); /* in case we copy it into flushDV */ + hzero(tvc->m.DataVersion); /* in case we copy it into flushDV */ #ifdef AFS_OSF_ENV /* Hold it for the LRU (should make count 2) */ VN_HOLD(AFSTOV(tvc)); -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ #ifndef AFS_OBSD_ENV VREFCOUNT_SET(tvc, 1); /* us */ -#endif /* AFS_OBSD_ENV */ -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OBSD_ENV */ +#endif /* AFS_OSF_ENV */ #ifdef AFS_AIX32_ENV LOCK_INIT(&tvc->pvmlock, "vcache pvmlock"); tvc->vmh = tvc->segid = NULL; @@ -935,17 +969,17 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) rw_init(&tvc->rwlock, "vcache rwlock", RW_DEFAULT, NULL); #if defined(AFS_SUN55_ENV) - /* This is required if the kaio (kernel aynchronous io) - ** module is installed. Inside the kernel, the function - ** check_vp( common/os/aio.c) checks to see if the kernel has - ** to provide asynchronous io for this vnode. This - ** function extracts the device number by following the - ** v_data field of the vnode. If we do not set this field - ** then the system panics. The value of the v_data field - ** is not really important for AFS vnodes because the kernel - ** does not do asynchronous io for regular files. Hence, - ** for the time being, we fill up the v_data field with the - ** vnode pointer itself. */ + /* This is required if the kaio (kernel aynchronous io) + ** module is installed. Inside the kernel, the function + ** check_vp( common/os/aio.c) checks to see if the kernel has + ** to provide asynchronous io for this vnode. This + ** function extracts the device number by following the + ** v_data field of the vnode. If we do not set this field + ** then the system panics. The value of the v_data field + ** is not really important for AFS vnodes because the kernel + ** does not do asynchronous io for regular files. Hence, + ** for the time being, we fill up the v_data field with the + ** vnode pointer itself. */ tvc->v.v_data = (char *)tvc; #endif /* AFS_SUN55_ENV */ #endif @@ -954,15 +988,16 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) tvc->Access = NULL; tvc->callback = serverp; /* to minimize chance that clear - request is lost */ + * request is lost */ /* initialize vnode data, note vrefCount is v.v_count */ #ifdef AFS_AIX_ENV /* Don't forget to free the gnode space */ - tvc->v.v_gnode = gnodepnt = (struct gnode *) osi_AllocSmallSpace(sizeof(struct gnode)); + tvc->v.v_gnode = gnodepnt = + (struct gnode *)osi_AllocSmallSpace(sizeof(struct gnode)); memset((char *)gnodepnt, 0, sizeof(struct gnode)); #endif #ifdef AFS_SGI64_ENV - memset((void*)&(tvc->vc_bhv_desc), 0, sizeof(tvc->vc_bhv_desc)); + memset((void *)&(tvc->vc_bhv_desc), 0, sizeof(tvc->vc_bhv_desc)); bhv_desc_init(&(tvc->vc_bhv_desc), tvc, tvc, &Afs_vnodeops); #ifdef AFS_SGI65_ENV vn_bhv_head_init(&(tvc->v.v_bh), "afsvp"); @@ -972,7 +1007,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) bhv_insert_initial(&(tvc->v.v_bh), &(tvc->vc_bhv_desc)); #endif #ifdef AFS_SGI65_ENV - tvc->v.v_mreg = tvc->v.v_mregb = (struct pregion*)tvc; + tvc->v.v_mreg = tvc->v.v_mregb = (struct pregion *)tvc; #ifdef VNODE_TRACING tvc->v.v_trace = ktrace_alloc(VNODE_TRACE_SIZE, 0); #endif @@ -987,7 +1022,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) init_bitlock(&(tvc->v.v_flag, VLOCK, "vnode", tvc->v.v_number); #endif #ifdef INTR_KTHREADS - AFS_VN_INIT_BUF_LOCK(&(tvc->v)); + AFS_VN_INIT_BUF_LOCK(&(tvc->v)); #endif #else SetAfsVnode(AFSTOV(tvc)); @@ -996,20 +1031,20 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) tvc->v.v_ubcinfo = UBC_INFO_NULL; lockinit(&tvc->rwlock, PINOD, "vcache rwlock", 0, 0); cache_purge(AFSTOV(tvc)); - tvc->v.v_data=tvc; - tvc->v.v_tag=VT_AFS; + tvc->v.v_data = tvc; + tvc->v.v_tag = VT_AFS; /* VLISTNONE(&tvc->v); */ - tvc->v.v_freelist.tqe_next=0; - tvc->v.v_freelist.tqe_prev=(struct vnode **)0xdeadb; - /*tvc->vrefCount++;*/ + tvc->v.v_freelist.tqe_next = 0; + tvc->v.v_freelist.tqe_prev = (struct vnode **)0xdeadb; + /*tvc->vrefCount++; */ #endif #ifdef AFS_FBSD_ENV lockinit(&tvc->rwlock, PINOD, "vcache rwlock", 0, 0); cache_purge(AFSTOV(tvc)); - tvc->v.v_data=tvc; - tvc->v.v_tag=VT_AFS; - tvc->v.v_usecount++; /* steal an extra ref for now so vfree never happens */ - /* This extra ref is dealt with above... */ + tvc->v.v_data = tvc; + tvc->v.v_tag = VT_AFS; + tvc->v.v_usecount++; /* steal an extra ref for now so vfree never happens */ + /* This extra ref is dealt with above... */ #endif /* * The proper value for mvstat (for root fids) is setup by the caller. @@ -1017,16 +1052,17 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) tvc->mvstat = 0; if (afid->Fid.Vnode == 1 && afid->Fid.Unique == 1) tvc->mvstat = 2; - if (afs_globalVFS == 0) osi_Panic("afs globalvfs"); + if (afs_globalVFS == 0) + osi_Panic("afs globalvfs"); vSetVfsp(tvc, afs_globalVFS); vSetType(tvc, VREG); #ifdef AFS_AIX_ENV - tvc->v.v_vfsnext = afs_globalVFS->vfs_vnodes; /* link off vfs */ + tvc->v.v_vfsnext = afs_globalVFS->vfs_vnodes; /* link off vfs */ tvc->v.v_vfsprev = NULL; afs_globalVFS->vfs_vnodes = &tvc->v; if (tvc->v.v_vfsnext != NULL) tvc->v.v_vfsnext->v_vfsprev = &tvc->v; - tvc->v.v_next = gnodepnt->gn_vnode; /*Single vnode per gnode for us!*/ + tvc->v.v_next = gnodepnt->gn_vnode; /*Single vnode per gnode for us! */ gnodepnt->gn_vnode = &tvc->v; #endif #ifdef AFS_DEC_ENV @@ -1038,10 +1074,10 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) #ifdef AFS_OSF_ENV /* Is this needed??? */ insmntque(tvc, afs_globalVFS); -#endif /* AFS_OSF_ENV */ -#endif /* AFS_DUX40_ENV */ +#endif /* AFS_OSF_ENV */ +#endif /* AFS_DUX40_ENV */ #if defined(AFS_SGI_ENV) - VN_SET_DPAGES(&(tvc->v), (struct pfdat*)NULL); + VN_SET_DPAGES(&(tvc->v), (struct pfdat *)NULL); osi_Assert((tvc->v.v_flag & VINACT) == 0); tvc->v.v_flag = 0; osi_Assert(VN_GET_PGCNT(&(tvc->v)) == 0); @@ -1080,7 +1116,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) #ifdef STRUCT_INODE_HAS_I_DEVICES INIT_LIST_HEAD(&ip->i_devices); #endif - ip->i_data.host = (void*) ip; + ip->i_data.host = (void *)ip; #ifdef STRUCT_ADDRESS_SPACE_HAS_GFP_MASK ip->i_data.gfp_mask = GFP_HIGHUSER; #endif @@ -1101,10 +1137,10 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) ip->i_dev = afs_globalVFS->s_dev; ip->i_sb = afs_globalVFS; } - } + } #endif tvc->h1.dchint = 0; - osi_dnlc_purgedp(tvc); /* this may be overkill */ + osi_dnlc_purgedp(tvc); /* this may be overkill */ memset((char *)&(tvc->quick), 0, sizeof(struct vtodc)); memset((char *)&(tvc->callsort), 0, sizeof(struct afs_q)); tvc->slocks = NULL; @@ -1113,23 +1149,23 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) tvc->hnext = afs_vhashT[i]; afs_vhashT[i] = tvc; if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("NewVCache VLRU inconsistent"); + refpanic("NewVCache VLRU inconsistent"); } - QAdd(&VLRU, &tvc->vlruq); /* put in lruq */ + QAdd(&VLRU, &tvc->vlruq); /* put in lruq */ if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("NewVCache VLRU inconsistent2"); + refpanic("NewVCache VLRU inconsistent2"); } if (tvc->vlruq.next->prev != &(tvc->vlruq)) { - refpanic ("NewVCache VLRU inconsistent3"); + refpanic("NewVCache VLRU inconsistent3"); } if (tvc->vlruq.prev->next != &(tvc->vlruq)) { - refpanic ("NewVCache VLRU inconsistent4"); + refpanic("NewVCache VLRU inconsistent4"); } vcachegen++; return tvc; -} /*afs_NewVCache*/ +} /*afs_NewVCache */ /* @@ -1142,7 +1178,8 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp) * doflocks : Do we handle flocks? */ /* LOCK: afs_FlushActiveVcaches afs_xvcache N */ -void afs_FlushActiveVcaches(register afs_int32 doflocks) +void +afs_FlushActiveVcaches(register afs_int32 doflocks) { register struct vcache *tvc; register int i; @@ -1152,37 +1189,34 @@ void afs_FlushActiveVcaches(register afs_int32 doflocks) struct vrequest treq, ureq; struct AFSVolSync tsync; int didCore; - XSTATS_DECLS - - AFS_STATCNT(afs_FlushActiveVcaches); + XSTATS_DECLS AFS_STATCNT(afs_FlushActiveVcaches); ObtainReadLock(&afs_xvcache); - for(i=0;ihnext) { + for (i = 0; i < VCSIZE; i++) { + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { if (doflocks && tvc->flockCount != 0) { /* if this entry has an flock, send a keep-alive call out */ - osi_vnhold(tvc, 0); + osi_vnhold(tvc, 0); ReleaseReadLock(&afs_xvcache); - ObtainWriteLock(&tvc->lock,51); + ObtainWriteLock(&tvc->lock, 51); do { afs_InitReq(&treq, &afs_osi_cred); treq.flags |= O_NONBLOCK; tc = afs_Conn(&tvc->fid, &treq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_EXTENDLOCK); - RX_AFS_GUNLOCK(); - code = + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_EXTENDLOCK); + RX_AFS_GUNLOCK(); + code = RXAFS_ExtendLock(tc->id, - (struct AFSFid *) &tvc->fid.Fid, + (struct AFSFid *)&tvc->fid.Fid, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &tvc->fid, &treq, - AFS_STATS_FS_RPCIDX_EXTENDLOCK, - SHARED_LOCK, NULL)); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &tvc->fid, &treq, + AFS_STATS_FS_RPCIDX_EXTENDLOCK, SHARED_LOCK, NULL)); ReleaseWriteLock(&tvc->lock); ObtainReadLock(&afs_xvcache); @@ -1205,18 +1239,18 @@ void afs_FlushActiveVcaches(register afs_int32 doflocks) * That's because if we come in via the CUnlinkedDel bit state path we'll be have 0 refcnt */ osi_Assert(VREFCOUNT(tvc) > 0); - AFS_RWLOCK((vnode_t *)tvc, VRWLOCK_WRITE); + AFS_RWLOCK((vnode_t *) tvc, VRWLOCK_WRITE); #endif - ObtainWriteLock(&tvc->lock,52); + ObtainWriteLock(&tvc->lock, 52); if (tvc->states & CCore) { tvc->states &= ~CCore; /* XXXX Find better place-holder for cred XXXX */ - cred = (struct AFS_UCRED *) tvc->linkData; + cred = (struct AFS_UCRED *)tvc->linkData; tvc->linkData = NULL; /* XXX */ afs_InitReq(&ureq, cred); afs_Trace2(afs_iclSetp, CM_TRACE_ACTCCORE, - ICL_TYPE_POINTER, tvc, - ICL_TYPE_INT32, tvc->execsOrWriters); + ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, + tvc->execsOrWriters); code = afs_StoreOnLastReference(tvc, &ureq); ReleaseWriteLock(&tvc->lock); #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) @@ -1238,14 +1272,13 @@ void afs_FlushActiveVcaches(register afs_int32 doflocks) afs_BozonUnlock(&tvc->pvnLock, tvc); #endif #if defined(AFS_SGI_ENV) - AFS_RWUNLOCK((vnode_t *)tvc, VRWLOCK_WRITE); + AFS_RWUNLOCK((vnode_t *) tvc, VRWLOCK_WRITE); #endif afs_remunlink(tvc, 0); #if defined(AFS_SGI_ENV) - AFS_RWLOCK((vnode_t *)tvc, VRWLOCK_WRITE); + AFS_RWLOCK((vnode_t *) tvc, VRWLOCK_WRITE); #endif - } - else { + } else { /* lost (or won, perhaps) the race condition */ ReleaseWriteLock(&tvc->lock); #if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) @@ -1253,7 +1286,7 @@ void afs_FlushActiveVcaches(register afs_int32 doflocks) #endif } #if defined(AFS_SGI_ENV) - AFS_RWUNLOCK((vnode_t *)tvc, VRWLOCK_WRITE); + AFS_RWUNLOCK((vnode_t *) tvc, VRWLOCK_WRITE); #endif ObtainReadLock(&afs_xvcache); AFS_FAST_RELE(tvc); @@ -1268,9 +1301,10 @@ void afs_FlushActiveVcaches(register afs_int32 doflocks) } } #ifdef AFS_DARWIN_ENV - if (VREFCOUNT(tvc) == 1 && UBCINFOEXISTS(&tvc->v)) { - if (tvc->opens) panic("flushactive open, hasubc, but refcnt 1"); - osi_VM_TryReclaim(tvc,0); + if (VREFCOUNT(tvc) == 1 && UBCINFOEXISTS(&tvc->v)) { + if (tvc->opens) + panic("flushactive open, hasubc, but refcnt 1"); + osi_VM_TryReclaim(tvc, 0); } #endif } @@ -1297,7 +1331,8 @@ void afs_FlushActiveVcaches(register afs_int32 doflocks) * areq : ??? */ -int afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq) +int +afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq) { register struct vcache *tvc; @@ -1306,20 +1341,20 @@ int afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq) #if defined(AFS_OSF_ENV) ObtainReadLock(&avc->lock); if (afs_IsWired(avc)) { - ReleaseReadLock(&avc->lock); - return 0; + ReleaseReadLock(&avc->lock); + return 0; } ReleaseReadLock(&avc->lock); #endif /* AFS_OSF_ENV */ /* otherwise we must fetch the status info */ - ObtainWriteLock(&avc->lock,53); + ObtainWriteLock(&avc->lock, 53); if (avc->states & CStatd) { ReleaseWriteLock(&avc->lock); return 0; } ObtainWriteLock(&afs_xcbhash, 461); - avc->states &= ~( CStatd | CUnique ); + avc->states &= ~(CStatd | CUnique); avc->callback = NULL; afs_DequeueCallback(avc); ReleaseWriteLock(&afs_xcbhash); @@ -1330,18 +1365,19 @@ int afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq) * file's name have changed, thus invalidating the dnlc contents. */ if ((avc->states & CForeign) || (avc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (avc); + osi_dnlc_purgedp(avc); else - osi_dnlc_purgevp (avc); + osi_dnlc_purgevp(avc); /* fetch the status info */ tvc = afs_GetVCache(&avc->fid, areq, NULL, avc); - if (!tvc) return ENOENT; + if (!tvc) + return ENOENT; /* Put it back; caller has already incremented vrefCount */ afs_PutVCache(tvc); return 0; -} /*afs_VerifyVCache*/ +} /*afs_VerifyVCache */ /* @@ -1359,40 +1395,40 @@ int afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq) * * Callers: as of 1992-04-29, only called by WriteVCache */ -static void afs_SimpleVStat(register struct vcache *avc, - register struct AFSFetchStatus *astat, struct vrequest *areq) +static void +afs_SimpleVStat(register struct vcache *avc, + register struct AFSFetchStatus *astat, struct vrequest *areq) { afs_size_t length; AFS_STATCNT(afs_SimpleVStat); #ifdef AFS_SGI_ENV if ((avc->execsOrWriters <= 0) && !afs_DirtyPages(avc) - && !AFS_VN_MAPPED((vnode_t*)avc)) { + && !AFS_VN_MAPPED((vnode_t *) avc)) { #else if ((avc->execsOrWriters <= 0) && !afs_DirtyPages(avc)) { #endif #ifdef AFS_64BIT_ClIENT FillInt64(length, astat->Length_hi, astat->Length); -#else /* AFS_64BIT_CLIENT */ +#else /* AFS_64BIT_CLIENT */ length = astat->Length; #endif /* AFS_64BIT_CLIENT */ #if defined(AFS_SGI_ENV) - osi_Assert((valusema(&avc->vc_rwlock) <= 0) && - (OSI_GET_LOCKID() == avc->vc_rwlockid)); + osi_Assert((valusema(&avc->vc_rwlock) <= 0) + && (OSI_GET_LOCKID() == avc->vc_rwlockid)); if (length < avc->m.Length) { - vnode_t *vp = (vnode_t *)avc; + vnode_t *vp = (vnode_t *) avc; osi_Assert(WriteLocked(&avc->lock)); ReleaseWriteLock(&avc->lock); AFS_GUNLOCK(); - PTOSSVP(vp, (off_t)length, (off_t)MAXLONG); + PTOSSVP(vp, (off_t) length, (off_t) MAXLONG); AFS_GLOCK(); - ObtainWriteLock(&avc->lock,67); + ObtainWriteLock(&avc->lock, 67); } #endif /* if writing the file, don't fetch over this value */ - afs_Trace3(afs_iclSetp, CM_TRACE_SIMPLEVSTAT, - ICL_TYPE_POINTER, avc, + afs_Trace3(afs_iclSetp, CM_TRACE_SIMPLEVSTAT, ICL_TYPE_POINTER, avc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length), ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(length)); avc->m.Length = length; @@ -1403,42 +1439,41 @@ static void afs_SimpleVStat(register struct vcache *avc, avc->m.Mode = astat->UnixModeBits; if (vType(avc) == VREG) { avc->m.Mode |= S_IFREG; - } - else if (vType(avc) == VDIR) { + } else if (vType(avc) == VDIR) { avc->m.Mode |= S_IFDIR; - } - else if (vType(avc) == VLNK) { + } else if (vType(avc) == VLNK) { avc->m.Mode |= S_IFLNK; - if ((avc->m.Mode & 0111) == 0) avc->mvstat = 1; + if ((avc->m.Mode & 0111) == 0) + avc->mvstat = 1; } if (avc->states & CForeign) { - struct axscache *ac; + struct axscache *ac; avc->anyAccess = astat->AnonymousAccess; #ifdef badidea if ((astat->CallerAccess & ~astat->AnonymousAccess)) - /* USED TO SAY : - * Caller has at least one bit not covered by anonymous, and - * thus may have interesting rights. - * - * HOWEVER, this is a really bad idea, because any access query - * for bits which aren't covered by anonymous, on behalf of a user - * who doesn't have any special rights, will result in an answer of - * the form "I don't know, lets make a FetchStatus RPC and find out!" - * It's an especially bad idea under Ultrix, since (due to the lack of - * a proper access() call) it must perform several afs_access() calls - * in order to create magic mode bits that vary according to who makes - * the call. In other words, _every_ stat() generates a test for - * writeability... - */ + /* USED TO SAY : + * Caller has at least one bit not covered by anonymous, and + * thus may have interesting rights. + * + * HOWEVER, this is a really bad idea, because any access query + * for bits which aren't covered by anonymous, on behalf of a user + * who doesn't have any special rights, will result in an answer of + * the form "I don't know, lets make a FetchStatus RPC and find out!" + * It's an especially bad idea under Ultrix, since (due to the lack of + * a proper access() call) it must perform several afs_access() calls + * in order to create magic mode bits that vary according to who makes + * the call. In other words, _every_ stat() generates a test for + * writeability... + */ #endif /* badidea */ - if (avc->Access && (ac = afs_FindAxs(avc->Access, areq->uid))) - ac->axess = astat->CallerAccess; - else /* not found, add a new one if possible */ - afs_AddAxs(avc->Access, areq->uid, astat->CallerAccess); + if (avc->Access && (ac = afs_FindAxs(avc->Access, areq->uid))) + ac->axess = astat->CallerAccess; + else /* not found, add a new one if possible */ + afs_AddAxs(avc->Access, areq->uid, astat->CallerAccess); } -} /*afs_SimpleVStat*/ +} /*afs_SimpleVStat */ /* @@ -1457,37 +1492,36 @@ static void afs_SimpleVStat(register struct vcache *avc, * Must be called with a shared lock held on the vnode. */ -int afs_WriteVCache(register struct vcache *avc, - register struct AFSStoreStatus *astatus, struct vrequest *areq) +int +afs_WriteVCache(register struct vcache *avc, + register struct AFSStoreStatus *astatus, + struct vrequest *areq) { - afs_int32 code; - struct conn *tc; + afs_int32 code; + struct conn *tc; struct AFSFetchStatus OutStatus; struct AFSVolSync tsync; - XSTATS_DECLS - - AFS_STATCNT(afs_WriteVCache); + XSTATS_DECLS AFS_STATCNT(afs_WriteVCache); afs_Trace2(afs_iclSetp, CM_TRACE_WVCACHE, ICL_TYPE_POINTER, avc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); do { tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); if (tc) { - XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STORESTATUS); - RX_AFS_GUNLOCK(); - code = RXAFS_StoreStatus(tc->id, - (struct AFSFid *) &avc->fid.Fid, - astatus, &OutStatus, &tsync); - RX_AFS_GLOCK(); - XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, &avc->fid, areq, - AFS_STATS_FS_RPCIDX_STORESTATUS, - SHARED_LOCK, NULL)); + XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STORESTATUS); + RX_AFS_GUNLOCK(); + code = + RXAFS_StoreStatus(tc->id, (struct AFSFid *)&avc->fid.Fid, + astatus, &OutStatus, &tsync); + RX_AFS_GLOCK(); + XSTATS_END_TIME; + } else + code = -1; + } while (afs_Analyze + (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STORESTATUS, + SHARED_LOCK, NULL)); - UpgradeSToWLock(&avc->lock,20); + UpgradeSToWLock(&avc->lock, 20); if (code == 0) { /* success, do the changes locally */ afs_SimpleVStat(avc, &OutStatus, areq); @@ -1497,20 +1531,19 @@ int afs_WriteVCache(register struct vcache *avc, * over a file being written. */ avc->m.Date = OutStatus.ClientModTime; - } - else { + } else { /* failure, set up to check with server next time */ ObtainWriteLock(&afs_xcbhash, 462); - afs_DequeueCallback(avc); - avc->states &= ~( CStatd | CUnique); /* turn off stat valid flag */ + afs_DequeueCallback(avc); + avc->states &= ~(CStatd | CUnique); /* turn off stat valid flag */ ReleaseWriteLock(&afs_xcbhash); if ((avc->states & CForeign) || (avc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (avc); /* if it (could be) a directory */ + osi_dnlc_purgedp(avc); /* if it (could be) a directory */ } ConvertWToSLock(&avc->lock); return code; -} /*afs_WriteVCache*/ +} /*afs_WriteVCache */ /* * afs_ProcessFS @@ -1530,15 +1563,16 @@ int afs_WriteVCache(register struct vcache *avc, * been modified. This is less than ideal. I haven't thought about * it sufficiently to be certain that it is adequate. */ -void afs_ProcessFS(register struct vcache *avc, register struct AFSFetchStatus *astat, - struct vrequest *areq) +void +afs_ProcessFS(register struct vcache *avc, + register struct AFSFetchStatus *astat, struct vrequest *areq) { afs_size_t length; AFS_STATCNT(afs_ProcessFS); #ifdef AFS_64BIT_CLIENT FillInt64(length, astat->Length_hi, astat->Length); -#else /* AFS_64BIT_CLIENT */ +#else /* AFS_64BIT_CLIENT */ length = astat->Length; #endif /* AFS_64BIT_CLIENT */ /* WARNING: afs_DoBulkStat uses the Length field to store a sequence @@ -1549,7 +1583,7 @@ void afs_ProcessFS(register struct vcache *avc, register struct AFSFetchStatus * * also need to change the conditional in afs_DoBulkStat. */ #ifdef AFS_SGI_ENV if ((avc->execsOrWriters <= 0) && !afs_DirtyPages(avc) - && !AFS_VN_MAPPED((vnode_t*)avc)) { + && !AFS_VN_MAPPED((vnode_t *) avc)) { #else if ((avc->execsOrWriters <= 0) && !afs_DirtyPages(avc)) { #endif @@ -1570,12 +1604,10 @@ void afs_ProcessFS(register struct vcache *avc, register struct AFSFetchStatus * if (astat->FileType == File) { vSetType(avc, VREG); avc->m.Mode |= S_IFREG; - } - else if (astat->FileType == Directory) { + } else if (astat->FileType == Directory) { vSetType(avc, VDIR); avc->m.Mode |= S_IFDIR; - } - else if (astat->FileType == SymbolicLink) { + } else if (astat->FileType == SymbolicLink) { if (afs_fakestat_enable && (avc->m.Mode & 0111) == 0) { vSetType(avc, VDIR); avc->m.Mode |= S_IFDIR; @@ -1612,46 +1644,48 @@ void afs_ProcessFS(register struct vcache *avc, register struct AFSFetchStatus * else /* not found, add a new one if possible */ afs_AddAxs(avc->Access, areq->uid, astat->CallerAccess); } - #ifdef AFS_LINUX22_ENV vcache2inode(avc); /* Set the inode attr cache */ #endif #ifdef AFS_DARWIN_ENV - osi_VM_Setup(avc,1); + osi_VM_Setup(avc, 1); #endif -} /*afs_ProcessFS*/ +} /*afs_ProcessFS */ -int afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq, - char *name, struct VenusFid *nfid, struct AFSFetchStatus *OutStatusp, - struct AFSCallBack *CallBackp, struct server **serverp, struct AFSVolSync *tsyncp) +int +afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq, + char *name, struct VenusFid *nfid, + struct AFSFetchStatus *OutStatusp, + struct AFSCallBack *CallBackp, struct server **serverp, + struct AFSVolSync *tsyncp) { afs_int32 code; afs_uint32 start; register struct conn *tc; struct AFSFetchStatus OutDirStatus; - XSTATS_DECLS - - if (!name) name = ""; /* XXX */ + XSTATS_DECLS if (!name) + name = ""; /* XXX */ do { tc = afs_Conn(afid, areq, SHARED_LOCK); if (tc) { - if (serverp) *serverp = tc->srvr->server; + if (serverp) + *serverp = tc->srvr->server; start = osi_Time(); XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_XLOOKUP); RX_AFS_GUNLOCK(); - code = RXAFS_Lookup(tc->id, (struct AFSFid *) &afid->Fid, name, - (struct AFSFid *) &nfid->Fid, - OutStatusp, &OutDirStatus, CallBackp, tsyncp); + code = + RXAFS_Lookup(tc->id, (struct AFSFid *)&afid->Fid, name, + (struct AFSFid *)&nfid->Fid, OutStatusp, + &OutDirStatus, CallBackp, tsyncp); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; - } while - (afs_Analyze(tc, code, afid, areq, - AFS_STATS_FS_RPCIDX_XLOOKUP, - SHARED_LOCK, NULL)); + } while (afs_Analyze + (tc, code, afid, areq, AFS_STATS_FS_RPCIDX_XLOOKUP, SHARED_LOCK, + NULL)); return code; } @@ -1690,35 +1724,37 @@ int afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq, * NB. NewVCache -> FlushVCache presently (4/10/95) drops the xvcache lock. */ /* might have a vcache structure already, which must - * already be held by the caller */ + * already be held by the caller */ -struct vcache *afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq, - afs_int32 *cached, struct vcache *avc) +struct vcache * +afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq, + afs_int32 * cached, struct vcache *avc) { - afs_int32 code, newvcache=0; + afs_int32 code, newvcache = 0; register struct vcache *tvc; struct volume *tvp; afs_int32 retry; AFS_STATCNT(afs_GetVCache); - if (cached) *cached = 0; /* Init just in case */ + if (cached) + *cached = 0; /* Init just in case */ #if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV) -loop: + loop: #endif - ObtainSharedLock(&afs_xvcache,5); + ObtainSharedLock(&afs_xvcache, 5); - tvc = afs_FindVCache(afid, &retry, DO_STATS | DO_VLRU ); + tvc = afs_FindVCache(afid, &retry, DO_STATS | DO_VLRU); if (tvc && retry) { #if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV) ReleaseSharedLock(&afs_xvcache); spunlock_psema(tvc->v.v_lock, retry, &tvc->v.v_sync, PINOD); goto loop; #endif - } + } if (tvc) { if (cached) @@ -1727,9 +1763,8 @@ loop: ReleaseSharedLock(&afs_xvcache); return tvc; } - } - else { - UpgradeSToWLock(&afs_xvcache,21); + } else { + UpgradeSToWLock(&afs_xvcache, 21); /* no cache entry, better grab one */ tvc = afs_NewVCache(afid, NULL); @@ -1741,7 +1776,7 @@ loop: ReleaseSharedLock(&afs_xvcache); - ObtainWriteLock(&tvc->lock,54); + ObtainWriteLock(&tvc->lock, 54); if (tvc->states & CStatd) { #ifdef AFS_LINUX22_ENV @@ -1749,11 +1784,10 @@ loop: #endif ReleaseWriteLock(&tvc->lock); #ifdef AFS_DARWIN_ENV - osi_VM_Setup(tvc,0); + osi_VM_Setup(tvc, 0); #endif return tvc; } - #if defined(AFS_OSF_ENV) if (afs_IsWired(tvc)) { ReleaseWriteLock(&tvc->lock); @@ -1774,19 +1808,22 @@ loop: /* It is always appropriate to throw away all the access rights? */ afs_FreeAllAxs(&(tvc->Access)); - tvp = afs_GetVolume(afid, areq, READ_LOCK); /* copy useful per-volume info */ + tvp = afs_GetVolume(afid, areq, READ_LOCK); /* copy useful per-volume info */ if (tvp) { if ((tvp->states & VForeign)) { - if (newvcache) tvc->states |= CForeign; + if (newvcache) + tvc->states |= CForeign; if (newvcache && (tvp->rootVnode == afid->Fid.Vnode) && (tvp->rootUnique == afid->Fid.Unique)) { tvc->mvstat = 2; - } + } } - if (tvp->states & VRO) tvc->states |= CRO; - if (tvp->states & VBackup) tvc->states |= CBackup; + if (tvp->states & VRO) + tvc->states |= CRO; + if (tvp->states & VBackup) + tvc->states |= CBackup; /* now copy ".." entry back out of volume structure, if necessary */ - if (tvc->mvstat == 2 && tvp->dotdot.Fid.Volume != 0) { + if (tvc->mvstat == 2 && tvp->dotdot.Fid.Volume != 0) { if (!tvc->mvid) tvc->mvid = (struct VenusFid *) osi_AllocSmallSpace(sizeof(struct VenusFid)); @@ -1821,14 +1858,15 @@ loop: ReleaseWriteLock(&tvc->lock); return tvc; -} /*afs_GetVCache*/ +} /*afs_GetVCache */ -struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, - afs_int32 *cached, struct vcache *adp, char *aname) +struct vcache * +afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, + afs_int32 * cached, struct vcache *adp, char *aname) { - afs_int32 code, now, newvcache=0; + afs_int32 code, now, newvcache = 0; struct VenusFid nfid; register struct vcache *tvc; struct volume *tvp; @@ -1840,14 +1878,15 @@ struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, afs_int32 retry; AFS_STATCNT(afs_GetVCache); - if (cached) *cached = 0; /* Init just in case */ + if (cached) + *cached = 0; /* Init just in case */ #if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV) loop1: #endif ObtainReadLock(&afs_xvcache); - tvc = afs_FindVCache(afid, &retry, DO_STATS /* no vlru */); + tvc = afs_FindVCache(afid, &retry, DO_STATS /* no vlru */ ); if (tvc) { ReleaseReadLock(&afs_xvcache); @@ -1871,23 +1910,24 @@ struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, ReleaseReadLock(&tvc->lock); ObtainReadLock(&afs_xvcache); AFS_FAST_RELE(tvc); - } /* if (tvc) */ - + } + /* if (tvc) */ ReleaseReadLock(&afs_xvcache); /* lookup the file */ nfid = *afid; now = osi_Time(); origCBs = afs_allCBs; /* if anything changes, we don't have a cb */ - code = afs_RemoteLookup(&adp->fid, areq, aname, &nfid, &OutStatus, &CallBack, - &serverp, &tsync); + code = + afs_RemoteLookup(&adp->fid, areq, aname, &nfid, &OutStatus, &CallBack, + &serverp, &tsync); #if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV) loop2: #endif - ObtainSharedLock(&afs_xvcache,6); - tvc = afs_FindVCache(&nfid, &retry, DO_VLRU /* no xstats now*/); + ObtainSharedLock(&afs_xvcache, 6); + tvc = afs_FindVCache(&nfid, &retry, DO_VLRU /* no xstats now */ ); if (tvc && retry) { #if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV) ReleaseSharedLock(&afs_xvcache); @@ -1897,30 +1937,33 @@ struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, } if (!tvc) { - /* no cache entry, better grab one */ - UpgradeSToWLock(&afs_xvcache,22); - tvc = afs_NewVCache(&nfid, serverp); + /* no cache entry, better grab one */ + UpgradeSToWLock(&afs_xvcache, 22); + tvc = afs_NewVCache(&nfid, serverp); newvcache = 1; - ConvertWToSLock(&afs_xvcache); + ConvertWToSLock(&afs_xvcache); } ReleaseSharedLock(&afs_xvcache); - ObtainWriteLock(&tvc->lock,55); + ObtainWriteLock(&tvc->lock, 55); /* It is always appropriate to throw away all the access rights? */ afs_FreeAllAxs(&(tvc->Access)); - tvp = afs_GetVolume(afid, areq, READ_LOCK); /* copy useful per-vol info */ + tvp = afs_GetVolume(afid, areq, READ_LOCK); /* copy useful per-vol info */ if (tvp) { if ((tvp->states & VForeign)) { - if (newvcache) tvc->states |= CForeign; + if (newvcache) + tvc->states |= CForeign; if (newvcache && (tvp->rootVnode == afid->Fid.Vnode) && (tvp->rootUnique == afid->Fid.Unique)) tvc->mvstat = 2; } - if (tvp->states & VRO) tvc->states |= CRO; - if (tvp->states & VBackup) tvc->states |= CBackup; + if (tvp->states & VRO) + tvc->states |= CRO; + if (tvp->states & VBackup) + tvc->states |= CBackup; /* now copy ".." entry back out of volume structure, if necessary */ - if (tvc->mvstat == 2 && tvp->dotdot.Fid.Volume != 0) { + if (tvc->mvstat == 2 && tvp->dotdot.Fid.Volume != 0) { if (!tvc->mvid) tvc->mvid = (struct VenusFid *) osi_AllocSmallSpace(sizeof(struct VenusFid)); @@ -1931,12 +1974,12 @@ struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, if (code) { ObtainWriteLock(&afs_xcbhash, 465); afs_DequeueCallback(tvc); - tvc->states &= ~( CStatd | CUnique ); + tvc->states &= ~(CStatd | CUnique); ReleaseWriteLock(&afs_xcbhash); if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (tvc); /* if it (could be) a directory */ - if ( tvp ) - afs_PutVolume(tvp, READ_LOCK); + osi_dnlc_purgedp(tvc); /* if it (could be) a directory */ + if (tvp) + afs_PutVolume(tvp, READ_LOCK); ReleaseWriteLock(&tvc->lock); ObtainReadLock(&afs_xvcache); AFS_FAST_RELE(tvc); @@ -1948,14 +1991,14 @@ struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, if (origCBs == afs_allCBs) { if (CallBack.ExpirationTime) { tvc->callback = serverp; - tvc->cbExpires = CallBack.ExpirationTime+now; + tvc->cbExpires = CallBack.ExpirationTime + now; tvc->states |= CStatd | CUnique; tvc->states &= ~CBulkFetching; afs_QueueCallback(tvc, CBHash(CallBack.ExpirationTime), tvp); } else if (tvc->states & CRO) { /* adapt gives us an hour. */ - tvc->cbExpires = 3600+osi_Time(); /*XXX*/ - tvc->states |= CStatd | CUnique; + tvc->cbExpires = 3600 + osi_Time(); + /*XXX*/ tvc->states |= CStatd | CUnique; tvc->states &= ~CBulkFetching; afs_QueueCallback(tvc, CBHash(3600), tvp); } else { @@ -1963,7 +2006,7 @@ struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, afs_DequeueCallback(tvc); tvc->states &= ~(CStatd | CUnique); if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (tvc); /* if it (could be) a directory */ + osi_dnlc_purgedp(tvc); /* if it (could be) a directory */ } } else { afs_DequeueCallback(tvc); @@ -1971,10 +2014,10 @@ struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, tvc->states &= ~CUnique; tvc->callback = NULL; if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (tvc); /* if it (could be) a directory */ + osi_dnlc_purgedp(tvc); /* if it (could be) a directory */ } ReleaseWriteLock(&afs_xcbhash); - if ( tvp ) + if (tvp) afs_PutVolume(tvp, READ_LOCK); afs_ProcessFS(tvc, &OutStatus, areq); @@ -1983,9 +2026,9 @@ struct vcache *afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq, } -struct vcache *afs_GetRootVCache(struct VenusFid *afid, - struct vrequest *areq, afs_int32 *cached, - struct volume *tvolp) +struct vcache * +afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq, + afs_int32 * cached, struct volume *tvolp) { afs_int32 code = 0, i, newvcache = 0, haveStatus = 0; afs_int32 getNewFid = 0; @@ -2000,20 +2043,21 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid, start = osi_Time(); - newmtpt: + newmtpt: if (!tvolp->rootVnode || getNewFid) { struct VenusFid tfid; tfid = *afid; tfid.Fid.Vnode = 0; /* Means get rootfid of volume */ - origCBs = afs_allCBs; /* ignore InitCallBackState */ - code = afs_RemoteLookup(&tfid, areq, NULL, &nfid, - &OutStatus, &CallBack, &serverp, &tsync); + origCBs = afs_allCBs; /* ignore InitCallBackState */ + code = + afs_RemoteLookup(&tfid, areq, NULL, &nfid, &OutStatus, &CallBack, + &serverp, &tsync); if (code) { return NULL; } /* ReleaseReadLock(&tvolp->lock); */ - ObtainWriteLock(&tvolp->lock,56); + ObtainWriteLock(&tvolp->lock, 56); tvolp->rootVnode = afid->Fid.Vnode = nfid.Fid.Vnode; tvolp->rootUnique = afid->Fid.Unique = nfid.Fid.Unique; ReleaseWriteLock(&tvolp->lock); @@ -2024,10 +2068,10 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid, afid->Fid.Unique = tvolp->rootUnique; } - ObtainSharedLock(&afs_xvcache,7); + ObtainSharedLock(&afs_xvcache, 7); i = VCHash(afid); for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { - if (!FidCmp(&(tvc->fid), afid)) { + if (!FidCmp(&(tvc->fid), afid)) { #ifdef AFS_OSF_ENV /* Grab this vnode, possibly reactivating from the free list */ /* for the present (95.05.25) everything on the hash table is @@ -2035,11 +2079,11 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid, * can be safely implemented */ int vg; AFS_GUNLOCK(); - vg = vget(AFSTOV(tvc)); /* this bumps ref count */ + vg = vget(AFSTOV(tvc)); /* this bumps ref count */ AFS_GLOCK(); if (vg) - continue; -#endif /* AFS_OSF_ENV */ + continue; +#endif /* AFS_OSF_ENV */ break; } } @@ -2057,40 +2101,40 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid, } if (!tvc) { - UpgradeSToWLock(&afs_xvcache,23); + UpgradeSToWLock(&afs_xvcache, 23); /* no cache entry, better grab one */ tvc = afs_NewVCache(afid, NULL); newvcache = 1; afs_stats_cmperf.vcacheMisses++; - } - else { - if (cached) *cached = 1; + } else { + if (cached) + *cached = 1; afs_stats_cmperf.vcacheHits++; #ifdef AFS_OSF_ENV /* we already bumped the ref count in the for loop above */ -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ osi_vnhold(tvc, 0); #endif - UpgradeSToWLock(&afs_xvcache,24); + UpgradeSToWLock(&afs_xvcache, 24); if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("GRVC VLRU inconsistent0"); + refpanic("GRVC VLRU inconsistent0"); } if (tvc->vlruq.next->prev != &(tvc->vlruq)) { - refpanic ("GRVC VLRU inconsistent1"); + refpanic("GRVC VLRU inconsistent1"); } if (tvc->vlruq.prev->next != &(tvc->vlruq)) { - refpanic ("GRVC VLRU inconsistent2"); + refpanic("GRVC VLRU inconsistent2"); } - QRemove(&tvc->vlruq); /* move to lruq head */ + QRemove(&tvc->vlruq); /* move to lruq head */ QAdd(&VLRU, &tvc->vlruq); if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("GRVC VLRU inconsistent3"); + refpanic("GRVC VLRU inconsistent3"); } if (tvc->vlruq.next->prev != &(tvc->vlruq)) { - refpanic ("GRVC VLRU inconsistent4"); + refpanic("GRVC VLRU inconsistent4"); } if (tvc->vlruq.prev->next != &(tvc->vlruq)) { - refpanic ("GRVC VLRU inconsistent5"); + refpanic("GRVC VLRU inconsistent5"); } vcachegen++; } @@ -2107,22 +2151,26 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid, ReleaseReadLock(&tvc->lock); } - ObtainWriteLock(&tvc->lock,57); + ObtainWriteLock(&tvc->lock, 57); /* It is always appropriate to throw away all the access rights? */ afs_FreeAllAxs(&(tvc->Access)); - if (newvcache) tvc->states |= CForeign; - if (tvolp->states & VRO) tvc->states |= CRO; - if (tvolp->states & VBackup) tvc->states |= CBackup; + if (newvcache) + tvc->states |= CForeign; + if (tvolp->states & VRO) + tvc->states |= CRO; + if (tvolp->states & VBackup) + tvc->states |= CBackup; /* now copy ".." entry back out of volume structure, if necessary */ if (newvcache && (tvolp->rootVnode == afid->Fid.Vnode) && (tvolp->rootUnique == afid->Fid.Unique)) { tvc->mvstat = 2; } - if (tvc->mvstat == 2 && tvolp->dotdot.Fid.Volume != 0) { + if (tvc->mvstat == 2 && tvolp->dotdot.Fid.Volume != 0) { if (!tvc->mvid) - tvc->mvid = (struct VenusFid *)osi_AllocSmallSpace(sizeof(struct VenusFid)); + tvc->mvid = (struct VenusFid *) + osi_AllocSmallSpace(sizeof(struct VenusFid)); *tvc->mvid = tvolp->dotdot; } @@ -2134,19 +2182,20 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid, tfid = *afid; tfid.Fid.Vnode = 0; /* Means get rootfid of volume */ - origCBs = afs_allCBs; /* ignore InitCallBackState */ - code = afs_RemoteLookup(&tfid, areq, NULL, &nfid, &OutStatus, - &CallBack, &serverp, &tsync); + origCBs = afs_allCBs; /* ignore InitCallBackState */ + code = + afs_RemoteLookup(&tfid, areq, NULL, &nfid, &OutStatus, &CallBack, + &serverp, &tsync); } if (code) { ObtainWriteLock(&afs_xcbhash, 467); afs_DequeueCallback(tvc); tvc->callback = NULL; - tvc->states &= ~(CStatd|CUnique); + tvc->states &= ~(CStatd | CUnique); ReleaseWriteLock(&afs_xcbhash); if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (tvc); /* if it (could be) a directory */ + osi_dnlc_purgedp(tvc); /* if it (could be) a directory */ ReleaseWriteLock(&tvc->lock); ObtainReadLock(&afs_xvcache); AFS_FAST_RELE(tvc); @@ -2159,14 +2208,14 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid, tvc->states |= CTruth; tvc->callback = serverp; if (CallBack.ExpirationTime != 0) { - tvc->cbExpires = CallBack.ExpirationTime+start; + tvc->cbExpires = CallBack.ExpirationTime + start; tvc->states |= CStatd; tvc->states &= ~CBulkFetching; afs_QueueCallback(tvc, CBHash(CallBack.ExpirationTime), tvolp); } else if (tvc->states & CRO) { /* adapt gives us an hour. */ - tvc->cbExpires = 3600+osi_Time(); /*XXX*/ - tvc->states |= CStatd; + tvc->cbExpires = 3600 + osi_Time(); + /*XXX*/ tvc->states |= CStatd; tvc->states &= ~CBulkFetching; afs_QueueCallback(tvc, CBHash(3600), tvolp); } @@ -2175,7 +2224,7 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid, tvc->callback = NULL; tvc->states &= ~(CStatd | CUnique); if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (tvc); /* if it (could be) a directory */ + osi_dnlc_purgedp(tvc); /* if it (could be) a directory */ } ReleaseWriteLock(&afs_xcbhash); afs_ProcessFS(tvc, &OutStatus, areq); @@ -2191,78 +2240,73 @@ struct vcache *afs_GetRootVCache(struct VenusFid *afid, * don't absolutely have to invalidate the hint unless the dv has * changed, but be sure to get it right else there will be consistency bugs. */ -afs_int32 afs_FetchStatus(struct vcache *avc, struct VenusFid *afid, - struct vrequest *areq, struct AFSFetchStatus *Outsp) +afs_int32 +afs_FetchStatus(struct vcache * avc, struct VenusFid * afid, + struct vrequest * areq, struct AFSFetchStatus * Outsp) { int code; afs_uint32 start = 0; register struct conn *tc; struct AFSCallBack CallBack; struct AFSVolSync tsync; - struct volume* volp; + struct volume *volp; XSTATS_DECLS - do { tc = afs_Conn(afid, areq, SHARED_LOCK); - avc->quick.stamp = 0; avc->h1.dchint = NULL; /* invalidate hints */ + avc->quick.stamp = 0; + avc->h1.dchint = NULL; /* invalidate hints */ if (tc) { avc->callback = tc->srvr->server; start = osi_Time(); XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHSTATUS); RX_AFS_GUNLOCK(); - code = RXAFS_FetchStatus(tc->id, - (struct AFSFid *) &afid->Fid, - Outsp, &CallBack, &tsync); + code = + RXAFS_FetchStatus(tc->id, (struct AFSFid *)&afid->Fid, Outsp, + &CallBack, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; - } - else code = -1; - } while - (afs_Analyze(tc, code, afid, areq, - AFS_STATS_FS_RPCIDX_FETCHSTATUS, - SHARED_LOCK, NULL)); + } else + code = -1; + } while (afs_Analyze + (tc, code, afid, areq, AFS_STATS_FS_RPCIDX_FETCHSTATUS, + SHARED_LOCK, NULL)); if (!code) { afs_ProcessFS(avc, Outsp, areq); volp = afs_GetVolume(afid, areq, READ_LOCK); ObtainWriteLock(&afs_xcbhash, 469); avc->states |= CTruth; - if (avc->callback /* check for race */) { + if (avc->callback /* check for race */ ) { if (CallBack.ExpirationTime != 0) { - avc->cbExpires = CallBack.ExpirationTime+start; + avc->cbExpires = CallBack.ExpirationTime + start; avc->states |= CStatd; avc->states &= ~CBulkFetching; afs_QueueCallback(avc, CBHash(CallBack.ExpirationTime), volp); - } - else if (avc->states & CRO) - { /* ordinary callback on a read-only volume -- AFS 3.2 style */ - avc->cbExpires = 3600+start; + } else if (avc->states & CRO) { /* ordinary callback on a read-only volume -- AFS 3.2 style */ + avc->cbExpires = 3600 + start; avc->states |= CStatd; avc->states &= ~CBulkFetching; afs_QueueCallback(avc, CBHash(3600), volp); - } - else { + } else { afs_DequeueCallback(avc); avc->callback = NULL; - avc->states &= ~(CStatd|CUnique); + avc->states &= ~(CStatd | CUnique); if ((avc->states & CForeign) || (avc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (avc); /* if it (could be) a directory */ + osi_dnlc_purgedp(avc); /* if it (could be) a directory */ } - } - else { + } else { afs_DequeueCallback(avc); avc->callback = NULL; - avc->states &= ~(CStatd|CUnique); + avc->states &= ~(CStatd | CUnique); if ((avc->states & CForeign) || (avc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (avc); /* if it (could be) a directory */ + osi_dnlc_purgedp(avc); /* if it (could be) a directory */ } ReleaseWriteLock(&afs_xcbhash); - if ( volp ) + if (volp) afs_PutVolume(volp, READ_LOCK); - } - else { + } else { /* used to undo the local callback, but that's too extreme. * There are plenty of good reasons that fetchstatus might return * an error, such as EPERM. If we have the vnode cached, statd, @@ -2297,11 +2341,13 @@ afs_int32 afs_FetchStatus(struct vcache *avc, struct VenusFid *afid, * Environment: * Nothing interesting. */ -void afs_StuffVcache(register struct VenusFid *afid, - struct AFSFetchStatus *OutStatus, struct AFSCallBack *CallBack, - register struct conn *tc, struct vrequest *areq) +void +afs_StuffVcache(register struct VenusFid *afid, + struct AFSFetchStatus *OutStatus, + struct AFSCallBack *CallBack, register struct conn *tc, + struct vrequest *areq) { - register afs_int32 code, i, newvcache=0; + register afs_int32 code, i, newvcache = 0; register struct vcache *tvc; struct AFSVolSync tsync; struct volume *tvp; @@ -2314,48 +2360,52 @@ void afs_StuffVcache(register struct VenusFid *afid, #endif loop: - ObtainSharedLock(&afs_xvcache,8); + ObtainSharedLock(&afs_xvcache, 8); - tvc = afs_FindVCache(afid, &retry, DO_VLRU /* no stats */); + tvc = afs_FindVCache(afid, &retry, DO_VLRU /* no stats */ ); if (tvc && retry) { #if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV) ReleaseSharedLock(&afs_xvcache); spunlock_psema(tvc->v.v_lock, retry, &tvc->v.v_sync, PINOD); goto loop; #endif - } + } if (!tvc) { /* no cache entry, better grab one */ - UpgradeSToWLock(&afs_xvcache,25); + UpgradeSToWLock(&afs_xvcache, 25); tvc = afs_NewVCache(afid, NULL); newvcache = 1; ConvertWToSLock(&afs_xvcache); } ReleaseSharedLock(&afs_xvcache); - ObtainWriteLock(&tvc->lock,58); + ObtainWriteLock(&tvc->lock, 58); tvc->states &= ~CStatd; if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (tvc); /* if it (could be) a directory */ + osi_dnlc_purgedp(tvc); /* if it (could be) a directory */ /* Is it always appropriate to throw away all the access rights? */ afs_FreeAllAxs(&(tvc->Access)); - /*Copy useful per-volume info*/ - tvp = afs_GetVolume(afid, areq, READ_LOCK); + /*Copy useful per-volume info */ + tvp = afs_GetVolume(afid, areq, READ_LOCK); if (tvp) { - if (newvcache && (tvp->states & VForeign)) tvc->states |= CForeign; - if (tvp->states & VRO) tvc->states |= CRO; - if (tvp->states & VBackup) tvc->states |= CBackup; + if (newvcache && (tvp->states & VForeign)) + tvc->states |= CForeign; + if (tvp->states & VRO) + tvc->states |= CRO; + if (tvp->states & VBackup) + tvc->states |= CBackup; /* * Now, copy ".." entry back out of volume structure, if * necessary */ - if (tvc->mvstat == 2 && tvp->dotdot.Fid.Volume != 0) { - if (!tvc->mvid) tvc->mvid = - (struct VenusFid *) osi_AllocSmallSpace(sizeof(struct VenusFid)); + if (tvc->mvstat == 2 && tvp->dotdot.Fid.Volume != 0) { + if (!tvc->mvid) + tvc->mvid = (struct VenusFid *) + osi_AllocSmallSpace(sizeof(struct VenusFid)); *tvc->mvid = tvp->dotdot; } } @@ -2375,44 +2425,42 @@ void afs_StuffVcache(register struct VenusFid *afid, * timeout period becomes longer than the server's expiration padding. */ ObtainWriteLock(&afs_xcbhash, 470); if (CallBack->ExpirationTime != 0) { - tvc->cbExpires = CallBack->ExpirationTime+osi_Time()-1; + tvc->cbExpires = CallBack->ExpirationTime + osi_Time() - 1; tvc->states |= CStatd; tvc->states &= ~CBulkFetching; afs_QueueCallback(tvc, CBHash(CallBack->ExpirationTime), tvp); - } - else if (tvc->states & CRO) { - /* old-fashioned AFS 3.2 style */ - tvc->cbExpires = 3600+osi_Time(); /*XXX*/ - tvc->states |= CStatd; - tvc->states &= ~CBulkFetching; - afs_QueueCallback(tvc, CBHash(3600), tvp); - } - else { - afs_DequeueCallback(tvc); - tvc->callback = NULL; - tvc->states &= ~(CStatd|CUnique); - if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1)) - osi_dnlc_purgedp (tvc); /* if it (could be) a directory */ + } else if (tvc->states & CRO) { + /* old-fashioned AFS 3.2 style */ + tvc->cbExpires = 3600 + osi_Time(); + /*XXX*/ tvc->states |= CStatd; + tvc->states &= ~CBulkFetching; + afs_QueueCallback(tvc, CBHash(3600), tvp); + } else { + afs_DequeueCallback(tvc); + tvc->callback = NULL; + tvc->states &= ~(CStatd | CUnique); + if ((tvc->states & CForeign) || (tvc->fid.Fid.Vnode & 1)) + osi_dnlc_purgedp(tvc); /* if it (could be) a directory */ } ReleaseWriteLock(&afs_xcbhash); - if ( tvp ) + if (tvp) afs_PutVolume(tvp, READ_LOCK); /* look in per-pag cache */ - if (tvc->Access && (ac = afs_FindAxs(tvc->Access, areq->uid))) - ac->axess = OutStatus->CallerAccess; /* substitute pags */ - else /* not found, add a new one if possible */ - afs_AddAxs(tvc->Access, areq->uid, OutStatus->CallerAccess); + if (tvc->Access && (ac = afs_FindAxs(tvc->Access, areq->uid))) + ac->axess = OutStatus->CallerAccess; /* substitute pags */ + else /* not found, add a new one if possible */ + afs_AddAxs(tvc->Access, areq->uid, OutStatus->CallerAccess); ReleaseWriteLock(&tvc->lock); afs_Trace4(afs_iclSetp, CM_TRACE_STUFFVCACHE, ICL_TYPE_POINTER, tvc, - ICL_TYPE_POINTER, tvc->callback, ICL_TYPE_INT32, tvc->cbExpires, - ICL_TYPE_INT32, tvc->cbExpires-osi_Time()); + ICL_TYPE_POINTER, tvc->callback, ICL_TYPE_INT32, + tvc->cbExpires, ICL_TYPE_INT32, tvc->cbExpires - osi_Time()); /* * Release ref count... hope this guy stays around... */ afs_PutVCache(tvc); -} /*afs_StuffVcache*/ +} /*afs_StuffVcache */ #endif /* @@ -2427,7 +2475,8 @@ void afs_StuffVcache(register struct VenusFid *afid, * Environment: * Nothing interesting. */ -void afs_PutVCache(register struct vcache *avc) +void +afs_PutVCache(register struct vcache *avc) { AFS_STATCNT(afs_PutVCache); /* @@ -2436,7 +2485,7 @@ void afs_PutVCache(register struct vcache *avc) ObtainReadLock(&afs_xvcache); AFS_FAST_RELE(avc); ReleaseReadLock(&afs_xvcache); -} /*afs_PutVCache*/ +} /*afs_PutVCache */ /* * afs_FindVCache @@ -2457,7 +2506,8 @@ void afs_PutVCache(register struct vcache *avc) * must be shared-- we upgrade it here. */ -struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 *retry, afs_int32 flag) +struct vcache * +afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag) { register struct vcache *tvc; @@ -2466,16 +2516,16 @@ struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 *retry, afs_int32 AFS_STATCNT(afs_FindVCache); i = VCHash(afid); - for(tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { - if (FidMatches(afid, tvc)) { + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { + if (FidMatches(afid, tvc)) { #ifdef AFS_OSF_ENV - /* Grab this vnode, possibly reactivating from the free list */ + /* Grab this vnode, possibly reactivating from the free list */ int vg; AFS_GUNLOCK(); - vg = vget(AFSTOV(tvc)); + vg = vget(AFSTOV(tvc)); AFS_GLOCK(); if (vg) - continue; + continue; #endif /* AFS_OSF_ENV */ break; } @@ -2483,9 +2533,10 @@ struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 *retry, afs_int32 /* should I have a read lock on the vnode here? */ if (tvc) { - if (retry) *retry = 0; + if (retry) + *retry = 0; #if !defined(AFS_OSF_ENV) - osi_vnhold(tvc, retry); /* already held, above */ + osi_vnhold(tvc, retry); /* already held, above */ if (retry && *retry) return 0; #endif @@ -2494,26 +2545,26 @@ struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 *retry, afs_int32 */ if (flag & DO_VLRU) { if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("FindVC VLRU inconsistent1"); + refpanic("FindVC VLRU inconsistent1"); } if (tvc->vlruq.next->prev != &(tvc->vlruq)) { - refpanic ("FindVC VLRU inconsistent1"); + refpanic("FindVC VLRU inconsistent1"); } if (tvc->vlruq.prev->next != &(tvc->vlruq)) { - refpanic ("FindVC VLRU inconsistent2"); + refpanic("FindVC VLRU inconsistent2"); } - UpgradeSToWLock(&afs_xvcache,26); + UpgradeSToWLock(&afs_xvcache, 26); QRemove(&tvc->vlruq); QAdd(&VLRU, &tvc->vlruq); ConvertWToSLock(&afs_xvcache); if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("FindVC VLRU inconsistent1"); + refpanic("FindVC VLRU inconsistent1"); } if (tvc->vlruq.next->prev != &(tvc->vlruq)) { - refpanic ("FindVC VLRU inconsistent2"); + refpanic("FindVC VLRU inconsistent2"); } if (tvc->vlruq.prev->next != &(tvc->vlruq)) { - refpanic ("FindVC VLRU inconsistent3"); + refpanic("FindVC VLRU inconsistent3"); } } vcachegen++; @@ -2529,17 +2580,16 @@ struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 *retry, afs_int32 else afs_stats_cmperf.vremoteAccesses++; } - #ifdef AFS_LINUX22_ENV if (tvc && (tvc->states & CStatd)) - vcache2inode(tvc); /* mainly to reset i_nlink */ + vcache2inode(tvc); /* mainly to reset i_nlink */ #endif #ifdef AFS_DARWIN_ENV if (tvc) - osi_VM_Setup(tvc, 0); + osi_VM_Setup(tvc, 0); #endif return tvc; -} /*afs_FindVCache*/ +} /*afs_FindVCache */ /* * afs_NFSFindVCache @@ -2565,9 +2615,10 @@ struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 *retry, afs_int32 * number of matches found. */ -int afs_duplicate_nfs_fids=0; +int afs_duplicate_nfs_fids = 0; -afs_int32 afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid) +afs_int32 +afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid) { register struct vcache *tvc; afs_int32 i; @@ -2577,30 +2628,30 @@ afs_int32 afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid) AFS_STATCNT(afs_FindVCache); #if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV) - loop: + loop: #endif - ObtainSharedLock(&afs_xvcache,331); + ObtainSharedLock(&afs_xvcache, 331); i = VCHash(afid); - for(tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { /* Match only on what we have.... */ - if (((tvc->fid.Fid.Vnode & 0xffff) == afid->Fid.Vnode) + if (((tvc->fid.Fid.Vnode & 0xffff) == afid->Fid.Vnode) && (tvc->fid.Fid.Volume == afid->Fid.Volume) && ((tvc->fid.Fid.Unique & 0xffffff) == afid->Fid.Unique) && (tvc->fid.Cell == afid->Cell)) { #ifdef AFS_OSF_ENV - /* Grab this vnode, possibly reactivating from the free list */ + /* Grab this vnode, possibly reactivating from the free list */ int vg; AFS_GUNLOCK(); - vg = vget(AFSTOV(tvc)); + vg = vget(AFSTOV(tvc)); AFS_GLOCK(); if (vg) { /* This vnode no longer exists. */ - continue; + continue; } -#endif /* AFS_OSF_ENV */ - count ++; +#endif /* AFS_OSF_ENV */ + count++; if (found_tvc) { /* Duplicates */ #ifdef AFS_OSF_ENV @@ -2620,61 +2671,63 @@ afs_int32 afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid) /* should I have a read lock on the vnode here? */ if (tvc) { #if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV) - afs_int32 retry = 0; - osi_vnhold(tvc, &retry); + afs_int32 retry = 0; + osi_vnhold(tvc, &retry); if (retry) { count = 0; - found_tvc = (struct vcache*)0; + found_tvc = (struct vcache *)0; ReleaseSharedLock(&afs_xvcache); spunlock_psema(tvc->v.v_lock, retry, &tvc->v.v_sync, PINOD); goto loop; } #else #if !defined(AFS_OSF_ENV) - osi_vnhold(tvc, (int*)0); /* already held, above */ + osi_vnhold(tvc, (int *)0); /* already held, above */ #endif #endif /* * We obtained the xvcache lock above. */ if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("FindVC VLRU inconsistent1"); + refpanic("FindVC VLRU inconsistent1"); } if (tvc->vlruq.next->prev != &(tvc->vlruq)) { - refpanic ("FindVC VLRU inconsistent1"); + refpanic("FindVC VLRU inconsistent1"); } if (tvc->vlruq.prev->next != &(tvc->vlruq)) { - refpanic ("FindVC VLRU inconsistent2"); + refpanic("FindVC VLRU inconsistent2"); } - UpgradeSToWLock(&afs_xvcache,568); + UpgradeSToWLock(&afs_xvcache, 568); QRemove(&tvc->vlruq); QAdd(&VLRU, &tvc->vlruq); ConvertWToSLock(&afs_xvcache); if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) { - refpanic ("FindVC VLRU inconsistent1"); + refpanic("FindVC VLRU inconsistent1"); } if (tvc->vlruq.next->prev != &(tvc->vlruq)) { - refpanic ("FindVC VLRU inconsistent2"); + refpanic("FindVC VLRU inconsistent2"); } if (tvc->vlruq.prev->next != &(tvc->vlruq)) { - refpanic ("FindVC VLRU inconsistent3"); + refpanic("FindVC VLRU inconsistent3"); } } vcachegen++; - if (tvc) afs_stats_cmperf.vcacheHits++; - else afs_stats_cmperf.vcacheMisses++; + if (tvc) + afs_stats_cmperf.vcacheHits++; + else + afs_stats_cmperf.vcacheMisses++; if (afs_IsPrimaryCellNum(afid->Cell)) - afs_stats_cmperf.vlocalAccesses++; + afs_stats_cmperf.vlocalAccesses++; else - afs_stats_cmperf.vremoteAccesses++; + afs_stats_cmperf.vremoteAccesses++; - *avcp = tvc; /* May be null */ + *avcp = tvc; /* May be null */ ReleaseSharedLock(&afs_xvcache); return (tvc ? 1 : 0); -} /*afs_NFSFindVCache*/ +} /*afs_NFSFindVCache */ @@ -2684,22 +2737,23 @@ afs_int32 afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid) * * Initialize vcache related variables */ -void afs_vcacheInit(int astatSize) +void +afs_vcacheInit(int astatSize) { register struct vcache *tvp; int i; #if defined(AFS_OSF_ENV) if (!afs_maxvcount) { #if defined(AFS_OSF30_ENV) - afs_maxvcount = max_vnodes/2; /* limit ourselves to half the total */ + afs_maxvcount = max_vnodes / 2; /* limit ourselves to half the total */ #else - afs_maxvcount = nvnode/2; /* limit ourselves to half the total */ + afs_maxvcount = nvnode / 2; /* limit ourselves to half the total */ #endif - if (astatSize < afs_maxvcount) { - afs_maxvcount = astatSize; - } + if (astatSize < afs_maxvcount) { + afs_maxvcount = astatSize; + } } -#else /* AFS_OSF_ENV */ +#else /* AFS_OSF_ENV */ freeVCList = NULL; #endif @@ -2708,15 +2762,15 @@ void afs_vcacheInit(int astatSize) #if !defined(AFS_OSF_ENV) /* Allocate and thread the struct vcache entries */ - tvp = (struct vcache *) afs_osi_Alloc(astatSize * sizeof(struct vcache)); - memset((char *)tvp, 0, sizeof(struct vcache)*astatSize); + tvp = (struct vcache *)afs_osi_Alloc(astatSize * sizeof(struct vcache)); + memset((char *)tvp, 0, sizeof(struct vcache) * astatSize); Initial_freeVCList = tvp; freeVCList = &(tvp[0]); - for(i=0; i < astatSize-1; i++) { - tvp[i].nextfree = &(tvp[i+1]); + for (i = 0; i < astatSize - 1; i++) { + tvp[i].nextfree = &(tvp[i + 1]); } - tvp[astatSize-1].nextfree = NULL; + tvp[astatSize - 1].nextfree = NULL; #ifdef KERNEL_HAVE_PIN pin((char *)tvp, astatSize * sizeof(struct vcache)); /* XXX */ #endif @@ -2724,13 +2778,14 @@ void afs_vcacheInit(int astatSize) #if defined(AFS_SGI_ENV) - for(i=0; i < astatSize; i++) { + for (i = 0; i < astatSize; i++) { char name[METER_NAMSZ]; struct vcache *tvc = &tvp[i]; tvc->v.v_number = ++afsvnumbers; tvc->vc_rwlockid = OSI_NO_LOCKID; - initnsema(&tvc->vc_rwlock, 1, makesname(name, "vrw", tvc->v.v_number)); + initnsema(&tvc->vc_rwlock, 1, + makesname(name, "vrw", tvc->v.v_number)); #ifndef AFS_SGI53_ENV initnsema(&tvc->v.v_sync, 0, makesname(name, "vsy", tvc->v.v_number)); #endif @@ -2749,7 +2804,8 @@ void afs_vcacheInit(int astatSize) * shutdown_vcache * */ -void shutdown_vcache(void) +void +shutdown_vcache(void) { int i; struct afs_cbr *tsp, *nsp; @@ -2773,24 +2829,24 @@ void shutdown_vcache(void) uq = QPrev(tq); if (tvc->mvid) { osi_FreeSmallSpace(tvc->mvid); - tvc->mvid = (struct VenusFid*)0; + tvc->mvid = (struct VenusFid *)0; } #ifdef AFS_AIX_ENV aix_gnode_rele(AFSTOV(tvc)); #endif if (tvc->linkData) { - afs_osi_Free(tvc->linkData, strlen(tvc->linkData)+1); + afs_osi_Free(tvc->linkData, strlen(tvc->linkData) + 1); tvc->linkData = 0; } } /* * Also free the remaining ones in the Cache */ - for (i=0; i < VCSIZE; i++) { + for (i = 0; i < VCSIZE; i++) { for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { if (tvc->mvid) { osi_FreeSmallSpace(tvc->mvid); - tvc->mvid = (struct VenusFid*)0; + tvc->mvid = (struct VenusFid *)0; } #ifdef AFS_AIX_ENV if (tvc->v.v_gnode) @@ -2801,7 +2857,8 @@ void shutdown_vcache(void) vms_delete(tvc->segid); AFS_GLOCK(); tvc->segid = tvc->vmh = NULL; - if (VREFCOUNT(tvc)) osi_Panic("flushVcache: vm race"); + if (VREFCOUNT(tvc)) + osi_Panic("flushVcache: vm race"); } if (tvc->credp) { crfree(tvc->credp); @@ -2816,7 +2873,7 @@ void shutdown_vcache(void) } #endif if (tvc->linkData) { - afs_osi_Free(tvc->linkData, strlen(tvc->linkData)+1); + afs_osi_Free(tvc->linkData, strlen(tvc->linkData) + 1); tvc->linkData = 0; } @@ -2828,7 +2885,7 @@ void shutdown_vcache(void) /* * Free any leftover callback queue */ - for (tsp = afs_cbrSpace; tsp; tsp = nsp ) { + for (tsp = afs_cbrSpace; tsp; tsp = nsp) { nsp = tsp->next; afs_osi_Free((char *)tsp, AFS_NCBRS * sizeof(struct afs_cbr)); } diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index c50e0d81a..6020cc4cd 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -18,7 +18,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/stds.h" #include "afs/sysincludes.h" /* Standard vendor system headers */ @@ -38,7 +39,7 @@ RCSID("$Header$"); #endif /* !defined(UKERNEL) */ #include "afsincludes.h" /* Afs-based standard headers */ -#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_stats.h" /* afs statistics */ #if defined(AFS_SUN56_ENV) #include @@ -56,36 +57,39 @@ RCSID("$Header$"); #endif /* vlserver error base define */ /* Exported variables */ -ino_t volumeInode; /*Inode for VolumeItems file*/ -afs_rwlock_t afs_xvolume; /* allocation lock for volumes */ +ino_t volumeInode; /*Inode for VolumeItems file */ +afs_rwlock_t afs_xvolume; /* allocation lock for volumes */ struct volume *afs_freeVolList; struct volume *afs_volumes[NVOLS]; -afs_int32 afs_volCounter = 1; /* for allocating volume indices */ +afs_int32 afs_volCounter = 1; /* for allocating volume indices */ afs_int32 fvTable[NFENTRIES]; /* Forward declarations */ -static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, - struct vrequest *areq, afs_int32 locktype); +static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, + int agood, struct vrequest *areq, + afs_int32 locktype); static struct volume *afs_NewDynrootVolume(struct VenusFid *fid); -static int inVolList(struct VenusFid *fid, afs_int32 nvols, afs_int32 *vID, afs_int32 *cID); +static int inVolList(struct VenusFid *fid, afs_int32 nvols, afs_int32 * vID, + afs_int32 * cID); /* Convert a volume name to a #; return 0 if can't parse as a number */ -static int afs_vtoi(register char *aname) +static int +afs_vtoi(register char *aname) { register afs_int32 temp; register int tc; temp = 0; AFS_STATCNT(afs_vtoi); - while((tc = *aname++)) { - if (tc > '9' || tc < '0') - return 0; /* invalid name */ + while ((tc = *aname++)) { + if (tc > '9' || tc < '0') + return 0; /* invalid name */ temp *= 10; temp += tc - '0'; } return temp; -} /*afs_vtoi*/ +} /*afs_vtoi */ /* @@ -100,7 +104,8 @@ afs_int32 afs_FVIndex = -1; /* UFS specific version of afs_GetVolSlot */ -struct volume *afs_UFSGetVolSlot(void) +struct volume * +afs_UFSGetVolSlot(void) { register struct volume *tv, **lv; struct osi_file *tfile; @@ -114,11 +119,11 @@ struct volume *afs_UFSGetVolSlot(void) bestTime = 0x7fffffff; bestVp = 0; bestLp = 0; - for (i=0;inext, tv = *lv) { - if (tv->refCount == 0) { /* is this one available? */ - if (tv->accessTime < bestTime) { /* best one available? */ + if (tv->refCount == 0) { /* is this one available? */ + if (tv->accessTime < bestTime) { /* best one available? */ bestTime = tv->accessTime; bestLp = lv; bestVp = tv; @@ -131,7 +136,7 @@ struct volume *afs_UFSGetVolSlot(void) tv = bestVp; *bestLp = tv->next; if (tv->name) - afs_osi_Free(tv->name, strlen(tv->name)+1); + afs_osi_Free(tv->name, strlen(tv->name) + 1); tv->name = NULL; /* now write out volume structure to file */ if (tv->vtix < 0) { @@ -139,17 +144,17 @@ struct volume *afs_UFSGetVolSlot(void) /* now put on hash chain */ i = FVHash(tv->cell, tv->volume); staticFVolume.next = fvTable[i]; - fvTable[i]=tv->vtix; - } - else { + fvTable[i] = tv->vtix; + } else { /* * Haul the guy in from disk so we don't overwrite hash table * next chain */ if (afs_FVIndex != tv->vtix) { tfile = osi_UFSOpen(volumeInode); - code = afs_osi_Read(tfile, sizeof(struct fvolume) * tv->vtix, - &staticFVolume, sizeof(struct fvolume)); + code = + afs_osi_Read(tfile, sizeof(struct fvolume) * tv->vtix, + &staticFVolume, sizeof(struct fvolume)); if (code != sizeof(struct fvolume)) osi_Panic("read volumeinfo"); osi_UFSClose(tfile); @@ -164,22 +169,23 @@ struct volume *afs_UFSGetVolSlot(void) staticFVolume.rootVnode = tv->rootVnode; staticFVolume.rootUnique = tv->rootUnique; tfile = osi_UFSOpen(volumeInode); - code = afs_osi_Write(tfile, sizeof(struct fvolume) * afs_FVIndex, - &staticFVolume, sizeof(struct fvolume)); + code = + afs_osi_Write(tfile, sizeof(struct fvolume) * afs_FVIndex, + &staticFVolume, sizeof(struct fvolume)); if (code != sizeof(struct fvolume)) osi_Panic("write volumeinfo"); - osi_UFSClose(tfile); - } - else { + osi_UFSClose(tfile); + } else { tv = afs_freeVolList; afs_freeVolList = tv->next; } return tv; -} /*afs_UFSGetVolSlot*/ +} /*afs_UFSGetVolSlot */ -struct volume *afs_MemGetVolSlot(void) +struct volume * +afs_MemGetVolSlot(void) { register struct volume *tv; @@ -187,7 +193,7 @@ struct volume *afs_MemGetVolSlot(void) if (!afs_freeVolList) { struct volume *newVp; - newVp = (struct volume *) afs_osi_Alloc(sizeof(struct volume)); + newVp = (struct volume *)afs_osi_Alloc(sizeof(struct volume)); newVp->next = NULL; afs_freeVolList = newVp; @@ -196,36 +202,38 @@ struct volume *afs_MemGetVolSlot(void) afs_freeVolList = tv->next; return tv; -} /*afs_MemGetVolSlot*/ +} /*afs_MemGetVolSlot */ /* afs_ResetVolumes() * Reset volume inforamation for all volume structs that * point to a speicific server. */ -void afs_ResetVolumes(struct server *srvp) +void +afs_ResetVolumes(struct server *srvp) { - int j, k; - struct volume *vp; - - /* Find any volumes residing on this server and flush their state */ - for (j=0; jnext) { - for (k=0; kserverHost[k] == srvp)) { - vp->serverHost[k] = 0; - afs_ResetVolumeInfo(vp); - break; - } + int j, k; + struct volume *vp; + + /* Find any volumes residing on this server and flush their state */ + for (j = 0; j < NVOLS; j++) { + for (vp = afs_volumes[j]; vp; vp = vp->next) { + for (k = 0; k < MAXHOSTS; k++) { + if (!srvp || (vp->serverHost[k] == srvp)) { + vp->serverHost[k] = 0; + afs_ResetVolumeInfo(vp); + break; + } + } } - } - } + } } /* reset volume name to volume id mapping cache */ -void afs_CheckVolumeNames(int flags) +void +afs_CheckVolumeNames(int flags) { - afs_int32 i,j; + afs_int32 i, j; struct volume *tv; unsigned int now; struct vcache *tvc; @@ -234,38 +242,38 @@ void afs_CheckVolumeNames(int flags) nvols = 0; volumeID = cellID = NULL; - vsize=0; + vsize = 0; ObtainReadLock(&afs_xvolume); if (flags & AFS_VOLCHECK_EXPIRED) { /* * allocate space to hold the volumeIDs and cellIDs, only if * we will be invalidating the mountpoints later on */ - for (i=0; i< NVOLS; i++) - for (tv = afs_volumes[i]; tv; tv=tv->next) + for (i = 0; i < NVOLS; i++) + for (tv = afs_volumes[i]; tv; tv = tv->next) ++vsize; volumeID = (afs_int32 *) afs_osi_Alloc(2 * vsize * sizeof(*volumeID)); - cellID = (volumeID) ? volumeID + vsize : 0; + cellID = (volumeID) ? volumeID + vsize : 0; } now = osi_Time(); - for (i=0;inext) { + for (i = 0; i < NVOLS; i++) { + for (tv = afs_volumes[i]; tv; tv = tv->next) { if (flags & AFS_VOLCHECK_EXPIRED) { - if ( ((tv->expireTime<(now+10)) && (tv->states & VRO)) || - (flags & AFS_VOLCHECK_FORCE)){ - afs_ResetVolumeInfo(tv); /* also resets status */ + if (((tv->expireTime < (now + 10)) && (tv->states & VRO)) + || (flags & AFS_VOLCHECK_FORCE)) { + afs_ResetVolumeInfo(tv); /* also resets status */ if (volumeID) { volumeID[nvols] = tv->volume; - cellID[nvols] = tv->cell; + cellID[nvols] = tv->cell; } ++nvols; continue; } } if (flags & (AFS_VOLCHECK_BUSY | AFS_VOLCHECK_FORCE)) { - for (j=0; jstatus[j] = not_busy; } @@ -277,26 +285,26 @@ void afs_CheckVolumeNames(int flags) /* next ensure all mt points are re-evaluated */ if (nvols || (flags & (AFS_VOLCHECK_FORCE | AFS_VOLCHECK_MTPTS))) { ObtainReadLock(&afs_xvcache); - for(i=0;ihnext) { + for (i = 0; i < VCSIZE; i++) { + for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { /* if the volume of "mvid" of the vcache entry is among the - * ones we found earlier, then we re-evaluate it. Also, if the - * force bit is set or we explicitly asked to reevaluate the - * mt-pts, we clean the cmvalid bit */ + * ones we found earlier, then we re-evaluate it. Also, if the + * force bit is set or we explicitly asked to reevaluate the + * mt-pts, we clean the cmvalid bit */ - if ((flags & (AFS_VOLCHECK_FORCE | AFS_VOLCHECK_MTPTS)) || - (tvc->mvid && - inVolList(tvc->mvid, nvols, volumeID, cellID))) + if ((flags & (AFS_VOLCHECK_FORCE | AFS_VOLCHECK_MTPTS)) + || (tvc->mvid + && inVolList(tvc->mvid, nvols, volumeID, cellID))) tvc->states &= ~CMValid; /* If the volume that this file belongs to was reset earlier, * then we should remove its callback. * Again, if forced, always do it. */ - if ((tvc->states & CRO) && - (inVolList(&tvc->fid, nvols, volumeID, cellID) || - (flags & AFS_VOLCHECK_FORCE))) { + if ((tvc->states & CRO) + && (inVolList(&tvc->fid, nvols, volumeID, cellID) + || (flags & AFS_VOLCHECK_FORCE))) { AFS_FAST_HOLD(tvc); ReleaseReadLock(&afs_xvcache); @@ -316,25 +324,27 @@ void afs_CheckVolumeNames(int flags) } } } - osi_dnlc_purge (); /* definitely overkill, but it's safer this way. */ + osi_dnlc_purge(); /* definitely overkill, but it's safer this way. */ ReleaseReadLock(&afs_xvcache); } if (volumeID) afs_osi_Free(volumeID, 2 * vsize * sizeof(*volumeID)); -} /*afs_CheckVolumeNames*/ +} /*afs_CheckVolumeNames */ -static int inVolList(struct VenusFid *fid, afs_int32 nvols, afs_int32 *vID, afs_int32 *cID) +static int +inVolList(struct VenusFid *fid, afs_int32 nvols, afs_int32 * vID, + afs_int32 * cID) { afs_int32 i; /* if no arrays present, be conservative and return true */ - if ( nvols && (!vID || !cID)) + if (nvols && (!vID || !cID)) return 1; - for (i=0; i< nvols; ++i) { + for (i = 0; i < nvols; ++i) { if (fid->Fid.Volume == vID[i] && fid->Cell == cID[i]) return 1; } @@ -350,7 +360,8 @@ static int inVolList(struct VenusFid *fid, afs_int32 nvols, afs_int32 *vID, afs_ * * Environment: Must be called with afs_xvolume unlocked. */ -struct volume *afs_FindVolume(struct VenusFid *afid, afs_int32 locktype) +struct volume * +afs_FindVolume(struct VenusFid *afid, afs_int32 locktype) { struct volume *tv; afs_int32 i; @@ -359,17 +370,17 @@ struct volume *afs_FindVolume(struct VenusFid *afid, afs_int32 locktype) return NULL; i = VHash(afid->Fid.Volume); - ObtainWriteLock(&afs_xvolume,106); - for (tv = afs_volumes[i]; tv; tv=tv->next) { + ObtainWriteLock(&afs_xvolume, 106); + for (tv = afs_volumes[i]; tv; tv = tv->next) { if (tv->volume == afid->Fid.Volume && tv->cell == afid->Cell && (tv->states & VRecheck) == 0) { tv->refCount++; break; - } + } } ReleaseWriteLock(&afs_xvolume); - return tv; /* NULL if we didn't find it */ -} /*afs_FindVolume*/ + return tv; /* NULL if we didn't find it */ +} /*afs_FindVolume */ @@ -377,8 +388,9 @@ struct volume *afs_FindVolume(struct VenusFid *afid, afs_int32 locktype) * Note that areq may be null, in which case we don't bother to set any * request status information. */ -struct volume *afs_GetVolume(struct VenusFid *afid, struct vrequest *areq, - afs_int32 locktype) +struct volume * +afs_GetVolume(struct VenusFid *afid, struct vrequest *areq, + afs_int32 locktype) { struct volume *tv; char *bp, tbuf[CVBS]; @@ -386,38 +398,39 @@ struct volume *afs_GetVolume(struct VenusFid *afid, struct vrequest *areq, tv = afs_FindVolume(afid, locktype); if (!tv) { - if (afs_IsDynrootFid(afid)) { - tv = afs_NewDynrootVolume(afid); - } else { - bp = afs_cv2string(&tbuf[CVBS], afid->Fid.Volume); - tv = afs_NewVolumeByName(bp, afid->Cell, 0, areq, locktype); - } + if (afs_IsDynrootFid(afid)) { + tv = afs_NewDynrootVolume(afid); + } else { + bp = afs_cv2string(&tbuf[CVBS], afid->Fid.Volume); + tv = afs_NewVolumeByName(bp, afid->Cell, 0, areq, locktype); + } } return tv; -} /*afs_GetVolume*/ +} /*afs_GetVolume */ -static struct volume *afs_SetupVolume(afs_int32 volid, char *aname, - char *ve, struct cell *tcell, afs_int32 agood, afs_int32 type, struct vrequest *areq) +static struct volume * +afs_SetupVolume(afs_int32 volid, char *aname, char *ve, struct cell *tcell, + afs_int32 agood, afs_int32 type, struct vrequest *areq) { struct volume *tv; struct vldbentry *ove = (struct vldbentry *)ve; struct nvldbentry *nve = (struct nvldbentry *)ve; struct uvldbentry *uve = (struct uvldbentry *)ve; - int whichType; /* which type of volume to look for */ - int i, j, err=0; + int whichType; /* which type of volume to look for */ + int i, j, err = 0; if (!volid) { - int len; + int len; /* special hint from file server to use vlserver */ len = strlen(aname); - if (len >= 8 && strcmp(aname+len-7, ".backup") == 0) + if (len >= 8 && strcmp(aname + len - 7, ".backup") == 0) whichType = BACKVOL; - else if (len >= 10 && strcmp(aname+len-9, ".readonly")==0) + else if (len >= 10 && strcmp(aname + len - 9, ".readonly") == 0) whichType = ROVOL; - else + else whichType = RWVOL; /* figure out which one we're really interested in (a set is returned) */ @@ -425,26 +438,24 @@ static struct volume *afs_SetupVolume(afs_int32 volid, char *aname, if (volid == 0) { if (type == 2) { volid = uve->volumeId[whichType]; - } - else if (type == 1) { + } else if (type == 1) { volid = nve->volumeId[whichType]; - } - else { + } else { volid = ove->volumeId[whichType]; } } } - - ObtainWriteLock(&afs_xvolume,108); + + ObtainWriteLock(&afs_xvolume, 108); i = VHash(volid); - for (tv = afs_volumes[i]; tv; tv=tv->next) { + for (tv = afs_volumes[i]; tv; tv = tv->next) { if (tv->volume == volid && tv->cell == tcell->cellNum) { break; } } if (!tv) { - struct fvolume *tf=0; + struct fvolume *tf = 0; tv = afs_GetVolSlot(); memset((char *)tv, 0, sizeof(struct volume)); @@ -453,11 +464,13 @@ static struct volume *afs_SetupVolume(afs_int32 volid, char *aname, tv->next = afs_volumes[i]; /* thread into list */ afs_volumes[i] = tv; tv->volume = volid; - for (j=fvTable[FVHash(tv->cell,volid)]; j!=0; j=tf->next) { + for (j = fvTable[FVHash(tv->cell, volid)]; j != 0; j = tf->next) { if (afs_FVIndex != j) { struct osi_file *tfile; tfile = osi_UFSOpen(volumeInode); - err = afs_osi_Read(tfile, sizeof(struct fvolume) * j, &staticFVolume, sizeof(struct fvolume)); + err = + afs_osi_Read(tfile, sizeof(struct fvolume) * j, + &staticFVolume, sizeof(struct fvolume)); if (err != sizeof(struct fvolume)) osi_Panic("read volumeinfo2"); osi_UFSClose(tfile); @@ -471,22 +484,21 @@ static struct volume *afs_SetupVolume(afs_int32 volid, char *aname, tv->vtix = afs_FVIndex; tv->mtpoint = tf->mtpoint; tv->dotdot = tf->dotdot; - tv->rootVnode = tf->rootVnode; - tv->rootUnique = tf->rootUnique; + tv->rootVnode = tf->rootVnode; + tv->rootUnique = tf->rootUnique; } else { tv->vtix = -1; tv->rootVnode = tv->rootUnique = 0; } } tv->refCount++; - tv->states &= ~VRecheck; /* just checked it */ + tv->states &= ~VRecheck; /* just checked it */ tv->accessTime = osi_Time(); ReleaseWriteLock(&afs_xvolume); - ObtainWriteLock(&tv->lock,111); + ObtainWriteLock(&tv->lock, 111); if (type == 2) { InstallUVolumeEntry(tv, uve, tcell->cellNum, tcell, areq); - } - else if (type == 1) + } else if (type == 1) InstallNVolumeEntry(tv, nve, tcell->cellNum); else InstallVolumeEntry(tv, ove, tcell->cellNum); @@ -496,26 +508,27 @@ static struct volume *afs_SetupVolume(afs_int32 volid, char *aname, strcpy(tv->name, aname); } } - for (i=0; istatus[i] = not_busy; + for (i = 0; i < NMAXNSERVERS; i++) { + tv->status[i] = not_busy; } ReleaseWriteLock(&tv->lock); return tv; } -struct volume *afs_GetVolumeByName(register char *aname, afs_int32 acell, - int agood, struct vrequest *areq, afs_int32 locktype) +struct volume * +afs_GetVolumeByName(register char *aname, afs_int32 acell, int agood, + struct vrequest *areq, afs_int32 locktype) { - afs_int32 i; - struct volume *tv; + afs_int32 i; + struct volume *tv; AFS_STATCNT(afs_GetVolumeByName); - ObtainWriteLock(&afs_xvolume,112); - for (i=0;inext) { - if (tv->name && !strcmp(aname,tv->name) && tv->cell == acell - && (tv->states&VRecheck) == 0) { + ObtainWriteLock(&afs_xvolume, 112); + for (i = 0; i < NVOLS; i++) { + for (tv = afs_volumes[i]; tv; tv = tv->next) { + if (tv->name && !strcmp(aname, tv->name) && tv->cell == acell + && (tv->states & VRecheck) == 0) { tv->refCount++; ReleaseWriteLock(&afs_xvolume); return tv; @@ -525,11 +538,12 @@ struct volume *afs_GetVolumeByName(register char *aname, afs_int32 acell, ReleaseWriteLock(&afs_xvolume); - tv = afs_NewVolumeByName(aname, acell, agood, areq, locktype); - return(tv); + tv = afs_NewVolumeByName(aname, acell, agood, areq, locktype); + return (tv); } -static struct volume *afs_NewDynrootVolume(struct VenusFid *fid) +static struct volume * +afs_NewDynrootVolume(struct VenusFid *fid) { struct cell *tcell; struct volume *tv; @@ -556,10 +570,11 @@ static struct volume *afs_NewDynrootVolume(struct VenusFid *fid) } int lastnvcode; -static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, - struct vrequest *areq, afs_int32 locktype) +static struct volume * +afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, + struct vrequest *areq, afs_int32 locktype) { - afs_int32 code, type=0; + afs_int32 code, type = 0; struct volume *tv, *tv1; struct vldbentry *tve; struct nvldbentry *ntve; @@ -578,19 +593,21 @@ static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agoo } /* allow null request if we don't care about ENODEV/ETIMEDOUT distinction */ - if (!areq) areq = &treq; + if (!areq) + areq = &treq; afs_Trace2(afs_iclSetp, CM_TRACE_GETVOL, ICL_TYPE_STRING, aname, - ICL_TYPE_POINTER, aname); + ICL_TYPE_POINTER, aname); tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ); - tve = (struct vldbentry *) (tbuffer+1024); + tve = (struct vldbentry *)(tbuffer + 1024); ntve = (struct nvldbentry *)tve; utve = (struct uvldbentry *)tve; afs_InitReq(&treq, &afs_osi_cred); /* *must* be unauth for vldb */ do { - tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, - tcell->cellNum, &treq, SHARED_LOCK); + tconn = + afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum, + &treq, SHARED_LOCK); if (tconn) { if (tconn->srvr->server->flags & SNO_LHOSTS) { type = 0; @@ -611,7 +628,7 @@ static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agoo if (code == RXGEN_OPCODE) { type = 1; RX_AFS_GUNLOCK(); - code = VL_GetEntryByNameN(tconn->id, aname, ntve); + code = VL_GetEntryByNameN(tconn->id, aname, ntve); RX_AFS_GLOCK(); if (code == RXGEN_OPCODE) { type = 0; @@ -622,16 +639,14 @@ static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agoo } else if (!code) tconn->srvr->server->flags |= SYES_LHOSTS; } else if (!code) - tconn->srvr->server->flags |= SVLSRV_UUID; + tconn->srvr->server->flags |= SVLSRV_UUID; } lastnvcode = code; } } else code = -1; - } while - (afs_Analyze(tconn, code, NULL, &treq, - -1, /* no op code for this */ - SHARED_LOCK, tcell)); + } while (afs_Analyze(tconn, code, NULL, &treq, -1, /* no op code for this */ + SHARED_LOCK, tcell)); if (code) { /* If the client has yet to contact this cell and contact failed due @@ -643,8 +658,9 @@ static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agoo int i; struct server *sp; struct srvAddr *sap; - for (i=0; icellHosts[i]) == NULL) break; + for (i = 0; i < MAXCELLHOSTS; i++) { + if ((sp = tcell->cellHosts[i]) == NULL) + break; for (sap = sp->addr; sap; sap = sap->next_sa) afs_MarkServerUpOrDown(sap, 0); } @@ -663,8 +679,8 @@ static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agoo if (!(tcell->states & CHasVolRef)) { tcell->states |= CHasVolRef; afs_stats_cmperf.numCellsContacted++; - } /*First time a volume in this cell has been referenced*/ - + } + /*First time a volume in this cell has been referenced */ if (type == 2) ve = (char *)utve; else if (type == 1) @@ -684,12 +700,13 @@ static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agoo afs_PutCell(tcell, READ_LOCK); return tv; -} /*afs_NewVolumeByName*/ +} /*afs_NewVolumeByName */ /* call this with the volume structure locked; used for new-style vldb requests */ -void InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell) +void +InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell) { register struct server *ts; struct cell *cellp; @@ -701,24 +718,23 @@ void InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell) /* Determine the type of volume we want */ if ((ve->flags & VLF_RWEXISTS) && (av->volume == ve->volumeId[RWVOL])) { - mask = VLSF_RWVOL; - } - else if ((ve->flags & VLF_ROEXISTS) && (av->volume == ve->volumeId[ROVOL])) { - mask = VLSF_ROVOL; - av->states |= VRO; - } - else if ((ve->flags & VLF_BACKEXISTS) && (av->volume == ve->volumeId[BACKVOL])) { - /* backup always is on the same volume as parent */ - mask = VLSF_RWVOL; - av->states |= (VRO|VBackup); - } - else { - mask = 0; /* Can't find volume in vldb entry */ + mask = VLSF_RWVOL; + } else if ((ve->flags & VLF_ROEXISTS) + && (av->volume == ve->volumeId[ROVOL])) { + mask = VLSF_ROVOL; + av->states |= VRO; + } else if ((ve->flags & VLF_BACKEXISTS) + && (av->volume == ve->volumeId[BACKVOL])) { + /* backup always is on the same volume as parent */ + mask = VLSF_RWVOL; + av->states |= (VRO | VBackup); + } else { + mask = 0; /* Can't find volume in vldb entry */ } /* fill in volume types */ - av->rwVol = ((ve->flags & VLF_RWEXISTS) ? ve->volumeId[RWVOL] : 0); - av->roVol = ((ve->flags & VLF_ROEXISTS) ? ve->volumeId[ROVOL] : 0); + av->rwVol = ((ve->flags & VLF_RWEXISTS) ? ve->volumeId[RWVOL] : 0); + av->roVol = ((ve->flags & VLF_ROEXISTS) ? ve->volumeId[ROVOL] : 0); av->backVol = ((ve->flags & VLF_BACKEXISTS) ? ve->volumeId[BACKVOL] : 0); if (ve->flags & VLF_DFSFILESET) @@ -731,18 +747,20 @@ void InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell) * struct, we don't deadlock trying to afs_ResetVolumeInfo() * this volume. */ - for (j=0; jserverHost[j] = 0; + for (j = 0; j < MAXHOSTS; j++) { + av->serverHost[j] = 0; } /* Step through the VLDB entry making sure each server listed is there */ - for (i=0,j=0; inServers; i++) { - if ( ((ve->serverFlags[i] & mask) == 0) || (ve->serverFlags[i] & VLSF_DONTUSE) ) { - continue; /* wrong volume or don't use this volume */ + for (i = 0, j = 0; i < ve->nServers; i++) { + if (((ve->serverFlags[i] & mask) == 0) + || (ve->serverFlags[i] & VLSF_DONTUSE)) { + continue; /* wrong volume or don't use this volume */ } temp = htonl(ve->serverNumber[i]); - ts = afs_GetServer(&temp, 1, acell, cellp->fsport, WRITE_LOCK, (afsUUID *)0, 0); + ts = afs_GetServer(&temp, 1, acell, cellp->fsport, WRITE_LOCK, + (afsUUID *) 0, 0); av->serverHost[j] = ts; /* @@ -752,7 +770,7 @@ void InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell) * follows later on it will find the server entry thus it will * simply return without setting any fields, so we set the * field ourselves below. - */ + */ if (!ts->cell) ts->cell = cellp; afs_PutServer(ts, WRITE_LOCK); @@ -762,10 +780,11 @@ void InstallVolumeEntry(struct volume *av, struct vldbentry *ve, int acell) av->serverHost[j++] = 0; } afs_SortServers(av->serverHost, MAXHOSTS); -} /*InstallVolumeEntry*/ +} /*InstallVolumeEntry */ -void InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, int acell) +void +InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, int acell) { register struct server *ts; struct cell *cellp; @@ -777,24 +796,23 @@ void InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, int acell) /* Determine type of volume we want */ if ((ve->flags & VLF_RWEXISTS) && (av->volume == ve->volumeId[RWVOL])) { - mask = VLSF_RWVOL; - } - else if ((ve->flags & VLF_ROEXISTS) && (av->volume == ve->volumeId[ROVOL])) { - mask = VLSF_ROVOL; - av->states |= VRO; - } - else if ((ve->flags&VLF_BACKEXISTS) && (av->volume == ve->volumeId[BACKVOL])) { - /* backup always is on the same volume as parent */ - mask = VLSF_RWVOL; - av->states |= (VRO|VBackup); - } - else { - mask = 0; /* Can't find volume in vldb entry */ + mask = VLSF_RWVOL; + } else if ((ve->flags & VLF_ROEXISTS) + && (av->volume == ve->volumeId[ROVOL])) { + mask = VLSF_ROVOL; + av->states |= VRO; + } else if ((ve->flags & VLF_BACKEXISTS) + && (av->volume == ve->volumeId[BACKVOL])) { + /* backup always is on the same volume as parent */ + mask = VLSF_RWVOL; + av->states |= (VRO | VBackup); + } else { + mask = 0; /* Can't find volume in vldb entry */ } /* fill in volume types */ - av->rwVol = ((ve->flags & VLF_RWEXISTS) ? ve->volumeId[RWVOL] : 0); - av->roVol = ((ve->flags & VLF_ROEXISTS) ? ve->volumeId[ROVOL] : 0); + av->rwVol = ((ve->flags & VLF_RWEXISTS) ? ve->volumeId[RWVOL] : 0); + av->roVol = ((ve->flags & VLF_ROEXISTS) ? ve->volumeId[ROVOL] : 0); av->backVol = ((ve->flags & VLF_BACKEXISTS) ? ve->volumeId[BACKVOL] : 0); if (ve->flags & VLF_DFSFILESET) @@ -807,18 +825,20 @@ void InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, int acell) * struct, we don't deadlock trying to afs_ResetVolumeInfo() * this volume. */ - for (j=0; jserverHost[j] = 0; + for (j = 0; j < MAXHOSTS; j++) { + av->serverHost[j] = 0; } /* Step through the VLDB entry making sure each server listed is there */ - for (i=0,j=0; inServers; i++) { - if ( ((ve->serverFlags[i] & mask) == 0) || (ve->serverFlags[i] & VLSF_DONTUSE) ) { - continue; /* wrong volume or don't use this volume */ + for (i = 0, j = 0; i < ve->nServers; i++) { + if (((ve->serverFlags[i] & mask) == 0) + || (ve->serverFlags[i] & VLSF_DONTUSE)) { + continue; /* wrong volume or don't use this volume */ } temp = htonl(ve->serverNumber[i]); - ts = afs_GetServer(&temp, 1, acell, cellp->fsport, WRITE_LOCK, (afsUUID *)0,0); + ts = afs_GetServer(&temp, 1, acell, cellp->fsport, WRITE_LOCK, + (afsUUID *) 0, 0); av->serverHost[j] = ts; /* * The cell field could be 0 if the server entry was created @@ -827,7 +847,7 @@ void InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, int acell) * follows later on it will find the server entry thus it will * simply return without setting any fields, so we set the * field ourselves below. - */ + */ if (!ts->cell) ts->cell = cellp; afs_PutServer(ts, WRITE_LOCK); @@ -837,11 +857,12 @@ void InstallNVolumeEntry(struct volume *av, struct nvldbentry *ve, int acell) av->serverHost[j++] = 0; } afs_SortServers(av->serverHost, MAXHOSTS); -} /*InstallNVolumeEntry*/ +} /*InstallNVolumeEntry */ -void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, - int acell, struct cell *tcell, struct vrequest *areq) +void +InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell, + struct cell *tcell, struct vrequest *areq) { register struct server *ts; struct conn *tconn; @@ -855,24 +876,23 @@ void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, /* Determine type of volume we want */ if ((ve->flags & VLF_RWEXISTS) && (av->volume == ve->volumeId[RWVOL])) { - mask = VLSF_RWVOL; - } - else if ((ve->flags & VLF_ROEXISTS) && av->volume == ve->volumeId[ROVOL]) { - mask = VLSF_ROVOL; - av->states |= VRO; - } - else if ((ve->flags & VLF_BACKEXISTS) && (av->volume == ve->volumeId[BACKVOL])) { - /* backup always is on the same volume as parent */ - mask = VLSF_RWVOL; - av->states |= (VRO|VBackup); - } - else { - mask = 0; /* Can't find volume in vldb entry */ + mask = VLSF_RWVOL; + } else if ((ve->flags & VLF_ROEXISTS) + && av->volume == ve->volumeId[ROVOL]) { + mask = VLSF_ROVOL; + av->states |= VRO; + } else if ((ve->flags & VLF_BACKEXISTS) + && (av->volume == ve->volumeId[BACKVOL])) { + /* backup always is on the same volume as parent */ + mask = VLSF_RWVOL; + av->states |= (VRO | VBackup); + } else { + mask = 0; /* Can't find volume in vldb entry */ } /* fill in volume types */ - av->rwVol = ((ve->flags & VLF_RWEXISTS) ? ve->volumeId[RWVOL] : 0); - av->roVol = ((ve->flags & VLF_ROEXISTS) ? ve->volumeId[ROVOL] : 0); + av->rwVol = ((ve->flags & VLF_RWEXISTS) ? ve->volumeId[RWVOL] : 0); + av->roVol = ((ve->flags & VLF_ROEXISTS) ? ve->volumeId[ROVOL] : 0); av->backVol = ((ve->flags & VLF_BACKEXISTS) ? ve->volumeId[BACKVOL] : 0); if (ve->flags & VLF_DFSFILESET) @@ -885,8 +905,8 @@ void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, * struct, we don't deadlock trying to afs_ResetVolumeInfo() * this volume. */ - for (j=0; jserverHost[j] = 0; + for (j = 0; j < MAXHOSTS; j++) { + av->serverHost[j] = 0; } /* Gather the list of servers the VLDB says the volume is on @@ -894,19 +914,22 @@ void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, * is not found, then get the list of addresses for the * server, VL_GetAddrsU(), and create a server struct, afs_GetServer(). */ - for (i=0,j=0; inServers; i++) { - if ( ((ve->serverFlags[i] & mask) == 0) || (ve->serverFlags[i] & VLSF_DONTUSE) ) { - continue; /* wrong volume don't use this volume */ + for (i = 0, j = 0; i < ve->nServers; i++) { + if (((ve->serverFlags[i] & mask) == 0) + || (ve->serverFlags[i] & VLSF_DONTUSE)) { + continue; /* wrong volume don't use this volume */ } if (!(ve->serverFlags[i] & VLSERVER_FLAG_UUID)) { /* The server has no uuid */ serverid = htonl(ve->serverNumber[i].time_low); - ts = afs_GetServer(&serverid, 1, acell, cellp->fsport, WRITE_LOCK, (afsUUID *)0,0); + ts = afs_GetServer(&serverid, 1, acell, cellp->fsport, WRITE_LOCK, + (afsUUID *) 0, 0); } else { ts = afs_FindServer(0, cellp->fsport, &ve->serverNumber[i], 0); - if (ts && (ts->sr_addr_uniquifier == ve->serverUnique[i]) && ts->addr) { - /* uuid, uniquifier, and portal are the same */ + if (ts && (ts->sr_addr_uniquifier == ve->serverUnique[i]) + && ts->addr) { + /* uuid, uniquifier, and portal are the same */ } else { afs_uint32 *addrp, nentries, code, unique; bulkaddrs addrs; @@ -919,11 +942,14 @@ void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, memset((char *)&uuid, 0, sizeof(uuid)); memset((char *)&addrs, 0, sizeof(addrs)); do { - tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, - tcell->cellNum, areq, SHARED_LOCK); + tconn = + afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, + tcell->cellNum, areq, SHARED_LOCK); if (tconn) { RX_AFS_GUNLOCK(); - code = VL_GetAddrsU(tconn->id, &attrs, &uuid, &unique, &nentries, &addrs); + code = + VL_GetAddrsU(tconn->id, &attrs, &uuid, &unique, + &nentries, &addrs); RX_AFS_GLOCK(); } else { code = -1; @@ -933,8 +959,8 @@ void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, if (code == 0 && nentries == 0) code = VL_NOENT; - } while (afs_Analyze(tconn, code, NULL, areq, - -1, SHARED_LOCK, tcell)); + } while (afs_Analyze + (tconn, code, NULL, areq, -1, SHARED_LOCK, tcell)); if (code) { /* Better handing of such failures; for now we'll simply retry this call */ areq->volumeError = 1; @@ -943,12 +969,13 @@ void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, addrp = addrs.bulkaddrs_val; for (k = 0; k < nentries; k++) { - addrp[k] = htonl(addrp[k]); + addrp[k] = htonl(addrp[k]); } ts = afs_GetServer(addrp, nentries, acell, cellp->fsport, WRITE_LOCK, &ve->serverNumber[i], ve->serverUnique[i]); - afs_osi_Free(addrs.bulkaddrs_val, addrs.bulkaddrs_len*sizeof(*addrp)); + afs_osi_Free(addrs.bulkaddrs_val, + addrs.bulkaddrs_len * sizeof(*addrp)); } } av->serverHost[j] = ts; @@ -959,7 +986,7 @@ void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, * follows later on it will find the server entry thus it will * simply return without setting any fields, so we set the * field ourselves below. - */ + */ if (!ts->cell) ts->cell = cellp; afs_PutServer(ts, WRITE_LOCK); @@ -967,21 +994,22 @@ void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, } afs_SortServers(av->serverHost, MAXHOSTS); -} /*InstallVolumeEntry*/ +} /*InstallVolumeEntry */ -void afs_ResetVolumeInfo(struct volume *tv) +void +afs_ResetVolumeInfo(struct volume *tv) { int i; AFS_STATCNT(afs_ResetVolumeInfo); - ObtainWriteLock(&tv->lock,117); + ObtainWriteLock(&tv->lock, 117); tv->states |= VRecheck; - for (i=0; istatus[i] = not_busy; + for (i = 0; i < MAXHOSTS; i++) + tv->status[i] = not_busy; if (tv->name) { - afs_osi_Free(tv->name, strlen(tv->name)+1); + afs_osi_Free(tv->name, strlen(tv->name) + 1); tv->name = NULL; - } + } ReleaseWriteLock(&tv->lock); } diff --git a/src/afs/exporter.h b/src/afs/exporter.h index d0a8f2b2b..79409c894 100644 --- a/src/afs/exporter.h +++ b/src/afs/exporter.h @@ -34,7 +34,7 @@ */ #if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZPTR==64)) || defined(AFS_LINUX_64BIT_KERNEL) -#define AFS_XLATOR_MAGIC 0x8765 /* XXX */ +#define AFS_XLATOR_MAGIC 0x8765 /* XXX */ #else #define AFS_XLATOR_MAGIC 0x87654321 #endif @@ -49,34 +49,34 @@ #endif #endif -struct exporterops { - int (*export_reqhandler)(); - int (*export_hold)(); - int (*export_rele)(); - int (*export_sysname)(); - int (*export_garbagecollect)(); - int (*export_statistics)(); +struct exporterops { + int (*export_reqhandler) (); + int (*export_hold) (); + int (*export_rele) (); + int (*export_sysname) (); + int (*export_garbagecollect) (); + int (*export_statistics) (); }; struct exporterstats { - afs_int32 calls; /* # of calls to the exporter */ - afs_int32 rejectedcalls; /* # of afs rejected calls */ - afs_int32 nopag; /* # of unpagged remote calls */ - afs_int32 invalidpag; /* # of invalid pag calls */ + afs_int32 calls; /* # of calls to the exporter */ + afs_int32 rejectedcalls; /* # of afs rejected calls */ + afs_int32 nopag; /* # of unpagged remote calls */ + afs_int32 invalidpag; /* # of invalid pag calls */ }; struct afs_exporter { - struct afs_exporter *exp_next; - struct exporterops *exp_op; - afs_int32 exp_states; - afs_int32 exp_type; - struct exporterstats exp_stats; - char *exp_data; + struct afs_exporter *exp_next; + struct exporterops *exp_op; + afs_int32 exp_states; + afs_int32 exp_type; + struct exporterstats exp_stats; + char *exp_data; }; /* exp_type values */ -#define EXP_NULL 0 /* Undefined */ -#define EXP_NFS 1 /* Nfs/Afs translator */ +#define EXP_NULL 0 /* Undefined */ +#define EXP_NFS 1 /* Nfs/Afs translator */ /* exp_states values */ #define EXP_EXPORTED 1 diff --git a/src/afs/lock.h b/src/afs/lock.h index 203560b59..4b449d7e1 100644 --- a/src/afs/lock.h +++ b/src/afs/lock.h @@ -25,20 +25,20 @@ #if !defined(AFS_OSF20_ENV) || defined(AFS_OSF30_ENV) || defined(AFS_OSF32_ENV) /* We do not instrument locks on osf20 because the vcache structure - ** exceeds the maximim possible limit for a vnode. - */ + ** exceeds the maximim possible limit for a vnode. + */ #define INSTRUMENT_LOCKS /* This is the max lock number in use. Please update it if you add any new * lock numbers. */ #define MAX_LOCK_NUMBER 700 -#endif +#endif struct afs_bozoLock { - short count; /* count of excl locks */ - char flags; /* bit 1: is anyone waiting? */ - char spare; /* for later */ - char *proc; /* process holding the lock, really a struct proc * */ + short count; /* count of excl locks */ + char flags; /* bit 1: is anyone waiting? */ + char spare; /* for later */ + char *proc; /* process holding the lock, really a struct proc * */ }; #ifndef AFS_NOBOZO_LOCK typedef struct afs_bozoLock afs_bozoLock_t; @@ -55,7 +55,7 @@ typedef struct afs_bozoLock afs_bozoLock_t; #define afs_CheckBozonLockBlocking(lock) 0 #endif -#define AFS_BOZONWAITING 1 /* someone is waiting for this lock */ +#define AFS_BOZONWAITING 1 /* someone is waiting for this lock */ #undef MObtainWriteLock /* Defined also in ../rx/rx_machdep.h" */ #undef MReleaseWriteLock @@ -123,26 +123,26 @@ extern tid_t thread_self(); #endif /* AFS_SGI64_ENV */ #endif /* AFS_HPUX101_ENV */ #endif /* AFS_AIX41_ENV */ -#endif +#endif /* all locks wait on excl_locked except for READ_LOCK, which waits on readers_reading */ struct afs_lock { - unsigned char wait_states; /* type of lockers waiting */ - unsigned char excl_locked; /* anyone have boosted, shared or write lock? */ - unsigned short readers_reading;/* # readers actually with read locks */ - unsigned short num_waiting; /* probably need this soon */ - unsigned short spare; /* not used now */ - osi_timeval_t time_waiting; /* for statistics gathering */ + unsigned char wait_states; /* type of lockers waiting */ + unsigned char excl_locked; /* anyone have boosted, shared or write lock? */ + unsigned short readers_reading; /* # readers actually with read locks */ + unsigned short num_waiting; /* probably need this soon */ + unsigned short spare; /* not used now */ + osi_timeval_t time_waiting; /* for statistics gathering */ #if defined(INSTRUMENT_LOCKS) /* the following are useful for debugging - ** the field 'src_indicator' is updated only by ObtainLock() and - ** only for writes/shared locks. Hence, it indictes where in the - ** source code the shared/write lock was set. - */ - unsigned int pid_last_reader;/* proceess id of last reader */ - unsigned int pid_writer; /* process id of writer, else 0 */ - unsigned int src_indicator; /* third param to ObtainLock()*/ -#endif /* INSTRUMENT_LOCKS */ + ** the field 'src_indicator' is updated only by ObtainLock() and + ** only for writes/shared locks. Hence, it indictes where in the + ** source code the shared/write lock was set. + */ + unsigned int pid_last_reader; /* proceess id of last reader */ + unsigned int pid_writer; /* process id of writer, else 0 */ + unsigned int src_indicator; /* third param to ObtainLock() */ +#endif /* INSTRUMENT_LOCKS */ }; typedef struct afs_lock afs_lock_t; typedef struct afs_lock afs_rwlock_t; @@ -305,7 +305,7 @@ extern int afs_trclock; ENDMAC #define NBObtainSharedLock(lock, src) (((lock)->excl_locked) ? EWOULDBLOCK : (((lock) -> excl_locked = SHARED_LOCK), 0)) - + #define UpgradeSToWLock(lock, src)\ BEGINMAC \ AFS_LOCK_TRACE(CM_TRACE_LOCKOBTAIN, lock, BOOSTED_LOCK);\ diff --git a/src/afs/longc_procs.h b/src/afs/longc_procs.h index 758d7e94b..6f8d24212 100644 --- a/src/afs/longc_procs.h +++ b/src/afs/longc_procs.h @@ -35,12 +35,12 @@ struct afs_longcall_procs { int (*LC_strncpy) (); int (*LC_flock) (); int (*LC_setgroups) (); - struct ucred * (*LC_crcopy) (); - struct ucred * (*LC_crget) (); + struct ucred *(*LC_crcopy) (); + struct ucred *(*LC_crget) (); int (*LC_crhold) (); int (*LC_ip_stripoptions) (); int (*LC_in_cksum) (); - struct mbuf * (*LC_m_pullup) (); + struct mbuf *(*LC_m_pullup) (); int (*LC_resettodr) (); int (*LC_untimeout) (); int (*LC_timeout) (); @@ -52,13 +52,13 @@ struct afs_longcall_procs { int (*LC_m_freem) (); int (*LC_soclose) (); int (*LC_sobind) (); - struct mbuf * (*LC_m_get) (); + struct mbuf *(*LC_m_get) (); int (*LC_socreate) (); int (*LC_soreserve) (); #if defined(AFS_DECOSF_ENV) int (*LC_getf) (); -#else /* AFS_DECOSF_ENV */ - struct file * (*LC_getf) (); +#else /* AFS_DECOSF_ENV */ + struct file *(*LC_getf) (); #endif int (*LC_splx) (); int (*LC_microtime) (); @@ -72,7 +72,7 @@ struct afs_longcall_procs { int (*LC_gfs_unlock) (); int (*LC_gfs_lock) (); int (*LC_gput) (); - struct inode * (*LC_ufs_galloc) (); + struct inode *(*LC_ufs_galloc) (); int (*LC_gno_close) (); int (*LC_km_alloc) (); int (*LC_km_free) (); @@ -80,14 +80,14 @@ struct afs_longcall_procs { int (*LC_nuxi_l) (); int (*LC_nuxi_s) (); - struct inode * (*LC_gfs_gget) (); + struct inode *(*LC_gfs_gget) (); int (*LC_binval) (); int (*LC_splclock) (); int (*LC_xumount) (); int (*LC_bflush) (); int (*LC_blkclr) (); int (*LC_vmaccess) (); - struct gnode * (*LC_gfs_namei) (); + struct gnode *(*LC_gfs_namei) (); int (*LC_getpdev) (); int (*LC_check_mountp) (); int (*LC_access) (); @@ -96,7 +96,7 @@ struct afs_longcall_procs { int (*LC_imin) (); int (*LC_setjmp) (); - struct gnode * (*LC_gget) (); + struct gnode *(*LC_gget) (); void (*LC_grele) (); void (*LC_gref) (); int (*LC_xdr_char) (); @@ -107,13 +107,13 @@ struct afs_longcall_procs { int (*LC_smp_owner) (); int (*LC_xinval) (); int (*LC_cacheinvalall) (); - int (*LC_psignal)(); - int (*LC_ufs_rwgp_lock)(); + int (*LC_psignal) (); + int (*LC_ufs_rwgp_lock) (); #else int (*LC_iunlock) (); int (*LC_ilock) (); int (*LC_iput) (); - struct inode * (*LC_ialloc) (); + struct inode *(*LC_ialloc) (); int (*LC_vno_close) (); int (*LC_kmem_alloc) (); int (*LC_kmem_free) (); @@ -125,22 +125,22 @@ struct afs_longcall_procs { int (*LC_vn_rele) (); int (*LC_vn_rdwr) (); int (*LC_mapout) (); - struct mount * (*LC_getmp) (); - struct inode * (*LC_iget) (); - struct mbuf * (*LC_m_more) (); + struct mount *(*LC_getmp) (); + struct inode *(*LC_iget) (); + struct mbuf *(*LC_m_more) (); int (*LC__spl1) (); #endif int (*LC_rdwri) (); - struct file * (*LC_falloc) (); + struct file *(*LC_falloc) (); int (*LC_rmfree) (); int (*LC_mapin) (); long (*LC_rmalloc) (); - struct pte * (*LC_vtopte) (); + struct pte *(*LC_vtopte) (); int (*LC_vattr_null) (); int (*LC_strlen) (); int (*LC_bcopy) (); int (*LC_brelse) (); - struct buf * (*LC_geteblk) (); + struct buf *(*LC_geteblk) (); int (*LC_panic) (); int (*LC_strcpy) (); int (*LC_printf) (); @@ -159,16 +159,16 @@ struct afs_longcall_procs { int (*LC_closef) (); int (*LC_fake_inode_init) (); int (*LC_getnewvnode) (); - struct mount * (*LC_getvfs) (); + struct mount *(*LC_getvfs) (); int (*LC_idrop) (); int (*LC_insmntque) (); int (*LC_ioctl_base) (); - caddr_t (*LC_kalloc) (); + caddr_t(*LC_kalloc) (); void (*LC_kfree) (); void (*LC_lock_done) (); - struct mbuf * (*LC_m_getclr) (); - struct mbuf * (*LC_m_retry) (); - struct mbuf * (*LC_m_retryhdr) (); + struct mbuf *(*LC_m_getclr) (); + struct mbuf *(*LC_m_retry) (); + struct mbuf *(*LC_m_retryhdr) (); int (*LC_mpsleep) (); int (*LC_namei) (); unsigned int (*LC_nuxi_32) (); @@ -197,7 +197,7 @@ struct afs_longcall_procs { */ void (*LC_vrele) (); int (*LC_xdr_char) (); -#endif /* AFS_DECOSF_ENV */ +#endif /* AFS_DECOSF_ENV */ }; extern struct afs_longcall_procs afs_longcall_procs; @@ -206,7 +206,7 @@ extern struct afs_longcall_procs afs_longcall_procs; #if defined(AFS_DECOSF_ENV) #undef kmem_alloc #undef kmem_free -#endif /* AFS_DECOSF_ENV */ +#endif /* AFS_DECOSF_ENV */ #define crfree (*afs_longcall_procs.LC_crfree) #define suser (*afs_longcall_procs.LC_suser) @@ -398,7 +398,7 @@ extern struct afs_longcall_procs afs_longcall_procs; */ #define vrele (*afs_longcall_procs.LC_vrele) #define xdr_char (*afs_longcall_procs.LC_xdr_char) -#endif /* AFS_DECOSF_ENV */ +#endif /* AFS_DECOSF_ENV */ #endif /* LONGCALL_NO_MACROS */ diff --git a/src/afs/nfsclient.h b/src/afs/nfsclient.h index e4e4d1d22..9d7df833b 100644 --- a/src/afs/nfsclient.h +++ b/src/afs/nfsclient.h @@ -12,26 +12,25 @@ #define NNFSCLIENTS 32 /* Hash table size for afs_nfspags table */ #define NHash(host) ((host) & (NNFSCLIENTS-1)) -#define NFSCLIENTGC (24*3600) /* time after which to GC nfsclientpag structs */ +#define NFSCLIENTGC (24*3600) /* time after which to GC nfsclientpag structs */ #define NFSXLATOR_CRED 0xaaaa struct nfsclientpag { /* From here to .... */ - struct nfsclientpag *next; /* Next hash pointer */ - struct exporterops *nfs_ops; + struct nfsclientpag *next; /* Next hash pointer */ + struct exporterops *nfs_ops; afs_int32 states; afs_int32 type; struct exporterstats nfs_stats; /* .... here is also an overlay to the afs_exporter structure */ afs_int32 refCount; /* Ref count for packages using this */ - afs_int32 uid; /* search based on uid and ... */ - afs_int32 host; /* ... nfs client's host ip address */ - afs_int32 pag; /* active pag for all (uid, host) "unpaged" conns */ + afs_int32 uid; /* search based on uid and ... */ + afs_int32 host; /* ... nfs client's host ip address */ + afs_int32 pag; /* active pag for all (uid, host) "unpaged" conns */ char *sysname; /* user's "@sys" value; also kept in unixuser */ afs_int32 lastcall; /* Used for timing out nfsclientpag structs */ }; #endif /* __NFSCLIENT__ */ - diff --git a/src/afs/sysincludes.h b/src/afs/sysincludes.h index c1bef9f9d..fc1ceaa4a 100644 --- a/src/afs/sysincludes.h +++ b/src/afs/sysincludes.h @@ -46,7 +46,7 @@ #include #endif #include -#include +#include #include #else /* AFS_OBSD_ENV */ #ifdef AFS_LINUX22_ENV @@ -65,9 +65,11 @@ */ #define _LINUX_CODA_FS_I #define _CFS_HEADER_ -struct coda_inode_info {}; +struct coda_inode_info { +}; #define _LINUX_XFS_FS_I -struct xfs_inode_info {}; +struct xfs_inode_info { +}; #include #include #include @@ -85,8 +87,8 @@ struct xfs_inode_info {}; #else /* AFS_LINUX22_ENV */ #if defined(AFS_DARWIN_ENV) #ifndef _MACH_ETAP_H_ -#define _MACH_ETAP_H_ -typedef unsigned short etap_event_t; +#define _MACH_ETAP_H_ +typedef unsigned short etap_event_t; #endif #endif #if !defined(AFS_OSF_ENV) @@ -159,7 +161,7 @@ typedef unsigned short etap_event_t; #include "sys/sysmacros.h" #include "sys/fs_subr.h" #include "sys/siginfo.h" -#endif /* AFS_SGI_ENV */ +#endif /* AFS_SGI_ENV */ #if !defined(AFS_AIX_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_SGI_ENV) # include "h/kernel.h" @@ -171,8 +173,8 @@ typedef unsigned short etap_event_t; #if defined(AFS_SUN56_ENV) #include "h/vfs.h" /* stops SUN56 socketvar.h warnings */ -#include "h/stropts.h" /* stops SUN56 socketvar.h warnings */ -#include "h/stream.h" /* stops SUN56 socketvar.h errors */ +#include "h/stropts.h" /* stops SUN56 socketvar.h warnings */ +#include "h/stream.h" /* stops SUN56 socketvar.h errors */ #endif #include "h/socket.h" @@ -231,8 +233,8 @@ typedef unsigned short etap_event_t; # endif /* AFS_SUN5_ENV */ # ifdef AFS_HPUX_ENV struct vfspage; /* for vnode.h compiler warnings */ -# include "h/swap.h" /* for struct swpdbd, for vnode.h compiler warnings */ -# include "h/dbd.h" /* for union idbd, for vnode.h compiler warnings */ +# include "h/swap.h" /* for struct swpdbd, for vnode.h compiler warnings */ +# include "h/dbd.h" /* for union idbd, for vnode.h compiler warnings */ #ifdef AFS_HPUX110_ENV # include "h/resource.h" #endif @@ -242,10 +244,10 @@ struct vfspage; /* for vnode.h compiler warnings */ struct vop_getwritemount_args; # endif # include -# include +# include # include -# include -# include +# include +# include # include #ifndef AFS_FBSD_ENV # include @@ -286,7 +288,7 @@ MALLOC_DECLARE(M_AFS); /* These mainly deal with networking and rpc headers */ #include "netinet/in.h" -#undef MFREE /* defined at mount.h for AIX */ +#undef MFREE /* defined at mount.h for AIX */ #ifdef AFS_SUN5_ENV # include "h/time.h" #else @@ -321,11 +323,11 @@ MALLOC_DECLARE(M_AFS); #if !defined(AFS_SGI_ENV) && !defined(AFS_SUN_ENV) && !defined(AFS_MACH_ENV) && !defined(AFS_AIX32_ENV) && !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV) # include "h/text.h" -#endif +#endif #if defined(AFS_AIX_ENV) || defined(AFS_DEC_ENV) -# include "h/flock.h" /* fcntl.h is a user-level include in aix */ +# include "h/flock.h" /* fcntl.h is a user-level include in aix */ #else # include "h/fcntl.h" #endif /* AIX || DEC */ @@ -347,7 +349,7 @@ MALLOC_DECLARE(M_AFS); #include #endif -#else /* ! AFS_OSF_ENV */ +#else /* ! AFS_OSF_ENV */ /* All of the OSF/1 stuff is here */ #include #include @@ -389,13 +391,13 @@ MALLOC_DECLARE(M_AFS); #undef mem_alloc #undef mem_free #undef register -#endif /* AFS_ALPHA_ENV */ +#endif /* AFS_ALPHA_ENV */ #include #include #include -#endif /* AFS_OSF_ENV */ +#endif /* AFS_OSF_ENV */ #endif /* AFS_LINUX22_ENV */ #endif /* AFS_OBSD_ENV */ diff --git a/src/afs/voldefs.h b/src/afs/voldefs.h index 4b9c3f2f2..633cd952f 100644 --- a/src/afs/voldefs.h +++ b/src/afs/voldefs.h @@ -28,7 +28,7 @@ /* All volumes will have a volume header name in this format */ #define VFORMAT "V%010lu.vol" #define VMAXPATHLEN 64 /* Maximum length (including null) of a volume - external path name */ + * external path name */ /* Values for connect parameter to VInitVolumePackage */ #define CONNECT_FS 1 diff --git a/src/afs/volerrors.h b/src/afs/volerrors.h index de88fa377..ee804c4a9 100644 --- a/src/afs/volerrors.h +++ b/src/afs/volerrors.h @@ -31,23 +31,23 @@ #define VSALVAGE 101 /* Volume needs salvage */ #define VNOVNODE 102 /* Bad vnode number quoted */ #define VNOVOL 103 /* Volume not attached, doesn't exist, - not created or not online */ + * not created or not online */ #define VVOLEXISTS 104 /* Volume already exists */ #define VNOSERVICE 105 /* Volume is not in service (i.e. it's - is out of funds, is obsolete, or somesuch) */ + * is out of funds, is obsolete, or somesuch) */ #define VOFFLINE 106 /* Volume is off line, for the reason - given in the offline message */ + * given in the offline message */ #define VONLINE 107 /* Volume is already on line */ -#define VDISKFULL 108 /* ENOSPC - Partition is "full", i.e. rougly within - n% of full */ +#define VDISKFULL 108 /* ENOSPC - Partition is "full", i.e. rougly within + * n% of full */ #define VOVERQUOTA 109 /* EDQUOT - Volume max quota exceeded */ #define VBUSY 110 /* Volume temporarily unavailable; try again. - The volume should be available again shortly; if - it isn't something is wrong. Not normally to be - propagated to the application level */ + * The volume should be available again shortly; if + * it isn't something is wrong. Not normally to be + * propagated to the application level */ #define VMOVED 111 /* Volume has moved to another server; do a VGetVolumeInfo - to THIS server to find out where */ + * to THIS server to find out where */ -#define VRESTARTING -100 /* server is restarting, otherwise similar to - VBUSY above. This is negative so that old - cache managers treat it as "server is down"*/ +#define VRESTARTING -100 /* server is restarting, otherwise similar to + * VBUSY above. This is negative so that old + * cache managers treat it as "server is down" */ diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index 7b06b1dfa..2fcba1169 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -55,7 +55,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #define VFS 1 @@ -195,11 +196,15 @@ char LclCellName[64]; * version of , since it's still useful. */ struct in_addr_42 { - union { - struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; - struct { u_short s_w1,s_w2; } S_un_w; - afs_uint32 S_addr; - } S_un; + union { + struct { + u_char s_b1, s_b2, s_b3, s_b4; + } S_un_b; + struct { + u_short s_w1, s_w2; + } S_un_w; + afs_uint32 S_addr; + } S_un; #define s_host S_un.S_un_b.s_b2 /* host on imp */ #define s_net S_un.S_un_b.s_b1 /* network */ #define s_imp S_un.S_un_w.s_w2 /* imp */ @@ -217,58 +222,58 @@ struct in_addr_42 { * Global configuration variables. */ afs_int32 afs_shutdown = 0; -afs_int32 cacheBlocks; /*Num blocks in the cache*/ -afs_int32 cacheFiles = 1000; /*Optimal # of files in workstation cache*/ -afs_int32 cacheStatEntries = 300; /*Number of stat cache entries*/ -char cacheBaseDir[1024]; /*Where the workstation AFS cache lives*/ -char confDir[1024]; /*Where the workstation AFS configuration lives*/ -char fullpn_DCacheFile[1024]; /*Full pathname of DCACHEFILE*/ -char fullpn_VolInfoFile[1024]; /*Full pathname of VOLINFOFILE*/ -char fullpn_CellInfoFile[1024]; /*Full pathanem of CELLINFOFILE*/ -char fullpn_AFSLogFile[1024]; /*Full pathname of AFSLOGFILE*/ -char fullpn_CacheInfo[1024]; /*Full pathname of CACHEINFO*/ -char fullpn_VFile[1024]; /*Full pathname of data cache files*/ -char *vFilePtr; /*Ptr to the number part of above pathname*/ -int sawCacheMountDir = 0; /* from cmd line */ +afs_int32 cacheBlocks; /*Num blocks in the cache */ +afs_int32 cacheFiles = 1000; /*Optimal # of files in workstation cache */ +afs_int32 cacheStatEntries = 300; /*Number of stat cache entries */ +char cacheBaseDir[1024]; /*Where the workstation AFS cache lives */ +char confDir[1024]; /*Where the workstation AFS configuration lives */ +char fullpn_DCacheFile[1024]; /*Full pathname of DCACHEFILE */ +char fullpn_VolInfoFile[1024]; /*Full pathname of VOLINFOFILE */ +char fullpn_CellInfoFile[1024]; /*Full pathanem of CELLINFOFILE */ +char fullpn_AFSLogFile[1024]; /*Full pathname of AFSLOGFILE */ +char fullpn_CacheInfo[1024]; /*Full pathname of CACHEINFO */ +char fullpn_VFile[1024]; /*Full pathname of data cache files */ +char *vFilePtr; /*Ptr to the number part of above pathname */ +int sawCacheMountDir = 0; /* from cmd line */ int sawCacheBaseDir = 0; int sawCacheBlocks = 0; int sawDCacheSize = 0; int sawBiod = 0; -char cacheMountDir[1024]; /*Mount directory for AFS*/ -char rootVolume[64] = "root.afs"; /*AFS root volume name*/ -afs_int32 cacheSetTime = 1; /*Keep checking time to avoid drift?*/ -afs_int32 isHomeCell; /*Is current cell info for the home cell?*/ +char cacheMountDir[1024]; /*Mount directory for AFS */ +char rootVolume[64] = "root.afs"; /*AFS root volume name */ +afs_int32 cacheSetTime = 1; /*Keep checking time to avoid drift? */ +afs_int32 isHomeCell; /*Is current cell info for the home cell? */ #ifdef AFS_XBSD_ENV -int createAndTrunc = O_RDWR | O_CREAT | O_TRUNC; /*Create & truncate on open*/ +int createAndTrunc = O_RDWR | O_CREAT | O_TRUNC; /*Create & truncate on open */ #else -int createAndTrunc = O_CREAT | O_TRUNC; /*Create & truncate on open*/ +int createAndTrunc = O_CREAT | O_TRUNC; /*Create & truncate on open */ #endif -int ownerRWmode = 0600; /*Read/write OK by owner*/ -static int filesSet = 0; /*True if number of files explicitly set*/ -static int nFilesPerDir = 2048; /* # files per cache dir */ -static int nDaemons = 2; /* Number of background daemons */ -static int chunkSize = 0; /* 2^chunkSize bytes per chunk */ -static int dCacheSize = 300; /* # of dcache entries */ -static int vCacheSize = 50; /* # of volume cache entries */ -static int rootVolSet = 0; /*True if root volume name explicitly set*/ -int addrNum; /*Cell server address index being printed*/ -static int cacheFlags = 0; /*Flags to cache manager*/ -static int nBiods = 5; /* AIX3.1 only */ -static int preallocs = 400; /* Def # of allocated memory blocks */ +int ownerRWmode = 0600; /*Read/write OK by owner */ +static int filesSet = 0; /*True if number of files explicitly set */ +static int nFilesPerDir = 2048; /* # files per cache dir */ +static int nDaemons = 2; /* Number of background daemons */ +static int chunkSize = 0; /* 2^chunkSize bytes per chunk */ +static int dCacheSize = 300; /* # of dcache entries */ +static int vCacheSize = 50; /* # of volume cache entries */ +static int rootVolSet = 0; /*True if root volume name explicitly set */ +int addrNum; /*Cell server address index being printed */ +static int cacheFlags = 0; /*Flags to cache manager */ +static int nBiods = 5; /* AIX3.1 only */ +static int preallocs = 400; /* Def # of allocated memory blocks */ static int enable_peer_stats = 0; /* enable rx stats */ static int enable_process_stats = 0; /* enable rx stats */ #ifdef AFS_AFSDB_ENV -static int enable_afsdb = 0; /* enable AFSDB support */ +static int enable_afsdb = 0; /* enable AFSDB support */ #endif -static int enable_dynroot = 0; /* enable dynroot support */ -static int enable_fakestat = 0; /* enable fakestat support */ -static int enable_nomount = 0; /* do not mount */ +static int enable_dynroot = 0; /* enable dynroot support */ +static int enable_fakestat = 0; /* enable fakestat support */ +static int enable_nomount = 0; /* do not mount */ #ifdef notdef -static int inodes = 60; /* VERY conservative, but has to be */ +static int inodes = 60; /* VERY conservative, but has to be */ #endif -int afsd_verbose = 0; /*Are we being chatty?*/ -int afsd_debug = 0; /*Are we printing debugging info?*/ -int afsd_CloseSynch = 0; /*Are closes synchronous or not? */ +int afsd_verbose = 0; /*Are we being chatty? */ +int afsd_debug = 0; /*Are we printing debugging info? */ +int afsd_CloseSynch = 0; /*Are closes synchronous or not? */ #ifdef AFS_SGI62_ENV #define AFSD_INO_T ino64_t @@ -276,23 +281,23 @@ int afsd_CloseSynch = 0; /*Are closes synchronous or not? */ #define AFSD_INO_T afs_uint32 #endif struct afsd_file_list { - int fileNum; - struct afsd_file_list *next; + int fileNum; + struct afsd_file_list *next; }; struct afsd_file_list **cache_dir_filelist = NULL; -int *cache_dir_list = NULL; /* Array of cache subdirs */ -int *dir_for_V = NULL; /* Array: dir of each cache file. - * -1: file does not exist - * -2: file exists in top-level - * >=0: file exists in Dxxx - */ -AFSD_INO_T *inode_for_V; /* Array of inodes for desired - * cache files */ -int missing_DCacheFile = 1; /*Is the DCACHEFILE missing?*/ -int missing_VolInfoFile = 1; /*Is the VOLINFOFILE missing?*/ -int missing_CellInfoFile = 1; /*Is the CELLINFOFILE missing?*/ -int afsd_rmtsys = 0; /* Default: don't support rmtsys */ -struct afs_cacheParams cparams; /* params passed to cache manager */ +int *cache_dir_list = NULL; /* Array of cache subdirs */ +int *dir_for_V = NULL; /* Array: dir of each cache file. + * -1: file does not exist + * -2: file exists in top-level + * >=0: file exists in Dxxx + */ +AFSD_INO_T *inode_for_V; /* Array of inodes for desired + * cache files */ +int missing_DCacheFile = 1; /*Is the DCACHEFILE missing? */ +int missing_VolInfoFile = 1; /*Is the VOLINFOFILE missing? */ +int missing_CellInfoFile = 1; /*Is the CELLINFOFILE missing? */ +int afsd_rmtsys = 0; /* Default: don't support rmtsys */ +struct afs_cacheParams cparams; /* params passed to cache manager */ static int HandleMTab(); @@ -321,23 +326,22 @@ static int HandleMTab(); * Sets globals. *---------------------------------------------------------------------------*/ -int ParseCacheInfoFile() +int +ParseCacheInfoFile() { - static char rn[]="ParseCacheInfoFile"; /*This routine's name*/ - FILE *cachefd; /*Descriptor for cache info file*/ - int parseResult; /*Result of our fscanf()*/ + static char rn[] = "ParseCacheInfoFile"; /*This routine's name */ + FILE *cachefd; /*Descriptor for cache info file */ + int parseResult; /*Result of our fscanf() */ afs_int32 tCacheBlocks; char tCacheBaseDir[1024], *tbd, tCacheMountDir[1024], *tmd; if (afsd_debug) - printf("%s: Opening cache info file '%s'...\n", - rn, fullpn_CacheInfo); + printf("%s: Opening cache info file '%s'...\n", rn, fullpn_CacheInfo); cachefd = fopen(fullpn_CacheInfo, "r"); if (!cachefd) { - printf("%s: Can't read cache info file '%s'\n", - rn, fullpn_CacheInfo); - return(1); + printf("%s: Can't read cache info file '%s'\n", rn, fullpn_CacheInfo); + return (1); } /* @@ -347,9 +351,9 @@ int ParseCacheInfoFile() * represent the number of blocks in the cache. */ tCacheMountDir[0] = tCacheBaseDir[0] = '\0'; - parseResult = fscanf(cachefd, - "%1024[^:]:%1024[^:]:%d", - tCacheMountDir, tCacheBaseDir, &tCacheBlocks); + parseResult = + fscanf(cachefd, "%1024[^:]:%1024[^:]:%d", tCacheMountDir, + tCacheBaseDir, &tCacheBlocks); /* * Regardless of how the parse went, we close the cache info file. @@ -357,37 +361,38 @@ int ParseCacheInfoFile() fclose(cachefd); if (parseResult == EOF || parseResult < 3) { - printf("%s: Format error in cache info file!\n", - rn); + printf("%s: Format error in cache info file!\n", rn); if (parseResult == EOF) printf("\tEOF encountered before any field parsed.\n"); else printf("\t%d out of 3 fields successfully parsed.\n", parseResult); - return(1); + return (1); } - for (tmd = tCacheMountDir; *tmd == '\n' || *tmd == ' ' || *tmd == '\t'; tmd++) ; - for (tbd = tCacheBaseDir; *tbd == '\n' || *tbd == ' ' || *tbd == '\t'; tbd++) ; + for (tmd = tCacheMountDir; *tmd == '\n' || *tmd == ' ' || *tmd == '\t'; + tmd++); + for (tbd = tCacheBaseDir; *tbd == '\n' || *tbd == ' ' || *tbd == '\t'; + tbd++); /* now copy in the fields not explicitly overridden by cmd args */ - if (!sawCacheMountDir) + if (!sawCacheMountDir) strcpy(cacheMountDir, tmd); if (!sawCacheBaseDir) strcpy(cacheBaseDir, tbd); - if (!sawCacheBlocks) + if (!sawCacheBlocks) cacheBlocks = tCacheBlocks; if (afsd_debug) { - printf("%s: Cache info file successfully parsed:\n", - rn); - printf("\tcacheMountDir: '%s'\n\tcacheBaseDir: '%s'\n\tcacheBlocks: %d\n", - tmd, tbd, tCacheBlocks); + printf("%s: Cache info file successfully parsed:\n", rn); + printf + ("\tcacheMountDir: '%s'\n\tcacheBaseDir: '%s'\n\tcacheBlocks: %d\n", + tmd, tbd, tCacheBlocks); } - if (! (cacheFlags & AFSCALL_INIT_MEMCACHE)) + if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) PartSizeOverflow(tbd, cacheBlocks); - return(0); + return (0); } /* @@ -397,15 +402,18 @@ int ParseCacheInfoFile() * advisory. ODS with over 2G partition also gives warning message. */ PartSizeOverflow(path, cs) -char *path; -int cs; + char *path; + int cs; { - int bsize=-1, totalblks, mint; + int bsize = -1, totalblks, mint; #if AFS_HAVE_STATVFS struct statvfs statbuf; - if (statvfs(path, &statbuf) != 0) { - if (afsd_debug) printf("statvfs failed on %s; skip checking for adequate partition space\n", path); + if (statvfs(path, &statbuf) != 0) { + if (afsd_debug) + printf + ("statvfs failed on %s; skip checking for adequate partition space\n", + path); return 0; } totalblks = statbuf.f_blocks; @@ -414,26 +422,31 @@ int cs; struct statfs statbuf; if (statfs(path, &statbuf) < 0) { - if (afsd_debug) printf("statfs failed on %s; skip checking for adequate partition space\n", path); + if (afsd_debug) + printf + ("statfs failed on %s; skip checking for adequate partition space\n", + path); return 0; } totalblks = statbuf.f_blocks; bsize = statbuf.f_bsize; #endif - if (bsize == -1) return 0; /* sucess */ + if (bsize == -1) + return 0; /* sucess */ /* now free and totalblks are in fragment units, but we want them in 1K units */ if (bsize >= 1024) { totalblks *= (bsize / 1024); } else { - totalblks /= (1024/bsize); + totalblks /= (1024 / bsize); } mint = totalblks - ((totalblks * 5) / 100); if (cs > mint) { - printf("Cache size (%d) must be less than 95%% of partition size (which is %d). Lower cache size\n", - cs, mint); - } + printf + ("Cache size (%d) must be less than 95%% of partition size (which is %d). Lower cache size\n", + cs, mint); + } } /*----------------------------------------------------------------------------- @@ -460,14 +473,15 @@ int cs; * None. *---------------------------------------------------------------------------*/ -static int doGetXFileNumber(fname, filechar, maxNum) - char *fname; - char filechar; - int maxNum; +static int +doGetXFileNumber(fname, filechar, maxNum) + char *fname; + char filechar; + int maxNum; { - int computedVNumber; /*The computed file number we return*/ - int filenameLen; /*Number of chars in filename*/ - int currDigit; /*Current digit being processed*/ + int computedVNumber; /*The computed file number we return */ + int filenameLen; /*Number of chars in filename */ + int currDigit; /*Current digit being processed */ /* * The filename must have at least two characters, the first of which must be a ``filechar'' @@ -475,11 +489,11 @@ static int doGetXFileNumber(fname, filechar, maxNum) */ filenameLen = strlen(fname); if (filenameLen < 2) - return(-1); + return (-1); if (fname[0] != filechar) - return(-1); + return (-1); if ((filenameLen > 2) && (fname[1] == '0')) - return(-1); + return (-1); /* * Scan through the characters in the given filename, failing immediately if a non-digit @@ -487,7 +501,7 @@ static int doGetXFileNumber(fname, filechar, maxNum) */ for (currDigit = 1; currDigit < filenameLen; currDigit++) if (isdigit(fname[currDigit]) == 0) - return(-1); + return (-1); /* * All relevant characters are digits. Pull out the decimal number they represent. @@ -495,21 +509,23 @@ static int doGetXFileNumber(fname, filechar, maxNum) */ computedVNumber = atoi(++fname); if (computedVNumber < cacheFiles) - return(computedVNumber); + return (computedVNumber); else - return(-1); + return (-1); } -int GetVFileNumber(fname, maxFile) - char *fname; - int maxFile; +int +GetVFileNumber(fname, maxFile) + char *fname; + int maxFile; { return doGetXFileNumber(fname, 'V', maxFile); } -int GetDDirNumber(fname, maxDir) - char *fname; - int maxDir; +int +GetDDirNumber(fname, maxDir) + char *fname; + int maxDir; { return doGetXFileNumber(fname, 'D', maxDir); } @@ -538,25 +554,25 @@ int GetDDirNumber(fname, maxDir) * As described. *---------------------------------------------------------------------------*/ -static int CreateCacheSubDir (basename, dirNum) +static int +CreateCacheSubDir(basename, dirNum) char *basename; int dirNum; { - static char rn[] = "CreateCacheSubDir"; /* Routine Name */ + static char rn[] = "CreateCacheSubDir"; /* Routine Name */ char dir[1024]; int ret; /* Build the new cache subdirectory */ - sprintf (dir, "%s/D%d", basename, dirNum); + sprintf(dir, "%s/D%d", basename, dirNum); if (afsd_verbose) - printf("%s: Creating cache subdir '%s'\n", - rn, dir); + printf("%s: Creating cache subdir '%s'\n", rn, dir); if ((ret = mkdir(dir, 0700)) != 0) { - printf("%s: Can't create '%s', error return is %d (%d)\n", - rn, dir, ret, errno); - if (errno != EEXIST) + printf("%s: Can't create '%s', error return is %d (%d)\n", rn, dir, + ret, errno); + if (errno != EEXIST) return (-1); } @@ -567,85 +583,89 @@ static int CreateCacheSubDir (basename, dirNum) return (0); } -static int MoveCacheFile (basename, fromDir, toDir, cacheFile, maxDir) +static int +MoveCacheFile(basename, fromDir, toDir, cacheFile, maxDir) char *basename; int fromDir, toDir, cacheFile, maxDir; { - static char rn[] = "MoveCacheFile"; - char from[1024], to[1024]; - int ret; - - if (cache_dir_list[toDir] < 0 && - (ret = CreateCacheSubDir(basename, toDir))) { - printf("%s: Can't create directory '%s/D%d'\n", rn, basename, toDir); - return ret; - } - - /* Build the from,to dir */ - if (fromDir < 0) { - /* old-style location */ - snprintf (from, sizeof(from), "%s/V%d", basename, cacheFile); - } else { - snprintf (from, sizeof(from), "%s/D%d/V%d", basename, fromDir, cacheFile); - } - - snprintf (to, sizeof(from), "%s/D%d/V%d", basename, toDir, cacheFile); - - if (afsd_verbose) - printf("%s: Moving cacheFile from '%s' to '%s'\n", - rn, from, to); - - if ((ret = rename (from, to)) != 0) { - printf("%s: Can't rename '%s' to '%s', error return is %d (%d)\n", - rn, from, to, ret, errno); - return -1; - } - - /* Reset directory pointer; fix file counts */ - dir_for_V[cacheFile] = toDir; - cache_dir_list[toDir]++; - if (fromDir < maxDir && fromDir >= 0) - cache_dir_list[fromDir]--; - - return 0; + static char rn[] = "MoveCacheFile"; + char from[1024], to[1024]; + int ret; + + if (cache_dir_list[toDir] < 0 + && (ret = CreateCacheSubDir(basename, toDir))) { + printf("%s: Can't create directory '%s/D%d'\n", rn, basename, toDir); + return ret; + } + + /* Build the from,to dir */ + if (fromDir < 0) { + /* old-style location */ + snprintf(from, sizeof(from), "%s/V%d", basename, cacheFile); + } else { + snprintf(from, sizeof(from), "%s/D%d/V%d", basename, fromDir, + cacheFile); + } + + snprintf(to, sizeof(from), "%s/D%d/V%d", basename, toDir, cacheFile); + + if (afsd_verbose) + printf("%s: Moving cacheFile from '%s' to '%s'\n", rn, from, to); + + if ((ret = rename(from, to)) != 0) { + printf("%s: Can't rename '%s' to '%s', error return is %d (%d)\n", rn, + from, to, ret, errno); + return -1; + } + + /* Reset directory pointer; fix file counts */ + dir_for_V[cacheFile] = toDir; + cache_dir_list[toDir]++; + if (fromDir < maxDir && fromDir >= 0) + cache_dir_list[fromDir]--; + + return 0; } -int CreateCacheFile(fname, statp) - char *fname; - struct stat *statp; +int +CreateCacheFile(fname, statp) + char *fname; + struct stat *statp; { - static char rn[] = "CreateCacheFile"; /*Routine name*/ - int cfd; /*File descriptor to AFS cache file*/ - int closeResult; /*Result of close()*/ + static char rn[] = "CreateCacheFile"; /*Routine name */ + int cfd; /*File descriptor to AFS cache file */ + int closeResult; /*Result of close() */ if (afsd_verbose) - printf("%s: Creating cache file '%s'\n", - rn, fname); + printf("%s: Creating cache file '%s'\n", rn, fname); cfd = open(fname, createAndTrunc, ownerRWmode); - if (cfd <= 0) { - printf("%s: Can't create '%s', error return is %d (%d)\n", - rn, fname, cfd, errno); - return(-1); + if (cfd <= 0) { + printf("%s: Can't create '%s', error return is %d (%d)\n", rn, fname, + cfd, errno); + return (-1); } if (statp != NULL) { - closeResult = fstat (cfd, statp); + closeResult = fstat(cfd, statp); if (closeResult) { - printf("%s: Can't stat newly-created AFS cache file '%s' (code %d)\n", - rn, fname, errno); - return(-1); + printf + ("%s: Can't stat newly-created AFS cache file '%s' (code %d)\n", + rn, fname, errno); + return (-1); } } closeResult = close(cfd); - if (closeResult) { - printf("%s: Can't close newly-created AFS cache file '%s' (code %d)\n", - rn, fname, errno); - return(-1); + if (closeResult) { + printf + ("%s: Can't close newly-created AFS cache file '%s' (code %d)\n", + rn, fname, errno); + return (-1); } - return(0); + return (0); } -static void CreateFileIfMissing(char *fullpn, int missing) +static void +CreateFileIfMissing(char *fullpn, int missing) { if (missing) { if (afsd_verbose) @@ -684,36 +704,38 @@ static void CreateFileIfMissing(char *fullpn, int missing) *---------------------------------------------------------------------------*/ -static int doSweepAFSCache(vFilesFound,directory,dirNum,maxDir) +static int +doSweepAFSCache(vFilesFound, directory, dirNum, maxDir) int *vFilesFound; char *directory; /* /path/to/cache/directory */ int dirNum; /* current directory number */ int maxDir; /* maximum directory number */ { - static char rn[] = "doSweepAFSCache"; /* Routine Name */ - char fullpn_FileToDelete[1024]; /*File to be deleted from cache*/ - char *fileToDelete; /*Ptr to last component of above*/ - DIR *cdirp; /*Ptr to cache directory structure*/ + static char rn[] = "doSweepAFSCache"; /* Routine Name */ + char fullpn_FileToDelete[1024]; /*File to be deleted from cache */ + char *fileToDelete; /*Ptr to last component of above */ + DIR *cdirp; /*Ptr to cache directory structure */ #ifdef AFS_SGI62_ENV - struct dirent64 *currp; /*Current directory entry*/ + struct dirent64 *currp; /*Current directory entry */ #else - struct dirent *currp; /*Current directory entry*/ + struct dirent *currp; /*Current directory entry */ #endif - int vFileNum; /*Data cache file's associated number*/ - int thisDir; /* A directory number */ + int vFileNum; /*Data cache file's associated number */ + int thisDir; /* A directory number */ int highDir = 0; if (afsd_debug) printf("%s: Opening cache directory '%s'\n", rn, directory); - if (chmod(directory, 0700)) { /* force it to be 700 */ - printf("%s: Can't 'chmod 0700' the cache dir, '%s'.\n", rn, directory); + if (chmod(directory, 0700)) { /* force it to be 700 */ + printf("%s: Can't 'chmod 0700' the cache dir, '%s'.\n", rn, + directory); return (-1); } cdirp = opendir(directory); - if (cdirp == (DIR *)0) { + if (cdirp == (DIR *) 0) { printf("%s: Can't open AFS cache directory, '%s'.\n", rn, directory); - return(-1); + return (-1); } /* @@ -731,16 +753,15 @@ static int doSweepAFSCache(vFilesFound,directory,dirNum,maxDir) #else for (currp = readdir(cdirp); currp; currp = readdir(cdirp)) #endif - { + { if (afsd_debug) { - printf("%s: Current directory entry:\n", - rn); + printf("%s: Current directory entry:\n", rn); #ifdef AFS_SGI62_ENV - printf("\tinode=%lld, reclen=%d, name='%s'\n", - currp->d_ino, currp->d_reclen, currp->d_name); + printf("\tinode=%lld, reclen=%d, name='%s'\n", currp->d_ino, + currp->d_reclen, currp->d_name); #else - printf("\tinode=%d, reclen=%d, name='%s'\n", - currp->d_ino, currp->d_reclen, currp->d_name); + printf("\tinode=%d, reclen=%d, name='%s'\n", currp->d_ino, + currp->d_reclen, currp->d_name); #endif } @@ -751,126 +772,124 @@ static int doSweepAFSCache(vFilesFound,directory,dirNum,maxDir) * valid if dirNum < 0. */ - if (*(currp->d_name) == 'V' && - ((vFileNum = GetVFileNumber(currp->d_name, cacheFiles)) >= 0)) { + if (*(currp->d_name) == 'V' + && ((vFileNum = GetVFileNumber(currp->d_name, cacheFiles)) >= + 0)) { /* * Found a valid data cache filename. Remember this * file's inode, directory, and bump the number of files found * total and in this directory. */ inode_for_V[vFileNum] = currp->d_ino; - dir_for_V[vFileNum] = dirNum; /* remember this directory */ + dir_for_V[vFileNum] = dirNum; /* remember this directory */ if (!maxDir) { - /* If we're in a real subdir, mark this file to be moved - * if we've already got too many files in this directory - */ - assert(dirNum >= 0); - cache_dir_list[dirNum]++; /* keep directory's file count */ - if (cache_dir_list[dirNum] > nFilesPerDir) { - /* Too many files -- add to filelist */ - struct afsd_file_list *tmp = (struct afsd_file_list *) - malloc(sizeof(*tmp)); - if (!tmp) - printf ("%s: MALLOC FAILED allocating file_list entry\n", - rn); - else { - tmp->fileNum = vFileNum; - tmp->next = cache_dir_filelist[dirNum]; - cache_dir_filelist[dirNum] = tmp; + /* If we're in a real subdir, mark this file to be moved + * if we've already got too many files in this directory + */ + assert(dirNum >= 0); + cache_dir_list[dirNum]++; /* keep directory's file count */ + if (cache_dir_list[dirNum] > nFilesPerDir) { + /* Too many files -- add to filelist */ + struct afsd_file_list *tmp = (struct afsd_file_list *) + malloc(sizeof(*tmp)); + if (!tmp) + printf + ("%s: MALLOC FAILED allocating file_list entry\n", + rn); + else { + tmp->fileNum = vFileNum; + tmp->next = cache_dir_filelist[dirNum]; + cache_dir_filelist[dirNum] = tmp; + } } - } } (*vFilesFound)++; - } - else if (dirNum < 0 && (*(currp->d_name) == 'D') && - GetDDirNumber(currp->d_name, 1<<30) >= 0) { - int retval = 0; - if ((vFileNum = GetDDirNumber(currp->d_name, maxDir)) >= 0) { - /* Found a valid cachefile sub-Directory. Remember this number - * and recurse into it. Note that subdirs cannot have subdirs. - */ - retval = 1; - } else if ((vFileNum = GetDDirNumber(currp->d_name, 1<<30)) >= 0) { - /* This directory is going away, but figure out if there - * are any cachefiles in here that should be saved by - * moving them to other cache directories. This directory - * will be removed later. - */ - retval = 2; - } - - /* Save the highest directory number we've seen */ - if (vFileNum > highDir) - highDir = vFileNum; - - /* If this directory is staying, be sure to mark it as 'found' */ - if (retval == 1) cache_dir_list[vFileNum] = 0; - - /* Print the dirname for recursion */ - sprintf(fileToDelete, "%s", currp->d_name); - - /* Note: vFileNum is the directory number */ - retval = doSweepAFSCache(vFilesFound, fullpn_FileToDelete, - vFileNum, (retval == 1 ? 0 : -1)); - if (retval) { - printf ("%s: Recursive sweep failed on directory %s\n", - rn, currp->d_name); - return retval; - } - } - else if (dirNum < 0 && strcmp(currp->d_name, DCACHEFILE) == 0) { + } else if (dirNum < 0 && (*(currp->d_name) == 'D') + && GetDDirNumber(currp->d_name, 1 << 30) >= 0) { + int retval = 0; + if ((vFileNum = GetDDirNumber(currp->d_name, maxDir)) >= 0) { + /* Found a valid cachefile sub-Directory. Remember this number + * and recurse into it. Note that subdirs cannot have subdirs. + */ + retval = 1; + } else if ((vFileNum = GetDDirNumber(currp->d_name, 1 << 30)) >= + 0) { + /* This directory is going away, but figure out if there + * are any cachefiles in here that should be saved by + * moving them to other cache directories. This directory + * will be removed later. + */ + retval = 2; + } + + /* Save the highest directory number we've seen */ + if (vFileNum > highDir) + highDir = vFileNum; + + /* If this directory is staying, be sure to mark it as 'found' */ + if (retval == 1) + cache_dir_list[vFileNum] = 0; + + /* Print the dirname for recursion */ + sprintf(fileToDelete, "%s", currp->d_name); + + /* Note: vFileNum is the directory number */ + retval = + doSweepAFSCache(vFilesFound, fullpn_FileToDelete, vFileNum, + (retval == 1 ? 0 : -1)); + if (retval) { + printf("%s: Recursive sweep failed on directory %s\n", rn, + currp->d_name); + return retval; + } + } else if (dirNum < 0 && strcmp(currp->d_name, DCACHEFILE) == 0) { /* * Found the file holding the dcache entries. */ missing_DCacheFile = 0; - } - else if (dirNum < 0 && strcmp(currp->d_name, VOLINFOFILE) == 0) { + } else if (dirNum < 0 && strcmp(currp->d_name, VOLINFOFILE) == 0) { /* * Found the file holding the volume info. */ missing_VolInfoFile = 0; - } - else if (dirNum < 0 && strcmp(currp->d_name, CELLINFOFILE) == 0) { + } else if (dirNum < 0 && strcmp(currp->d_name, CELLINFOFILE) == 0) { /* * Found the file holding the cell info. */ missing_CellInfoFile = 0; - } - else if ((strcmp(currp->d_name, ".") == 0) || - (strcmp(currp->d_name, "..") == 0) || + } else if ((strcmp(currp->d_name, ".") == 0) + || (strcmp(currp->d_name, "..") == 0) || #ifdef AFS_DECOSF_ENV - /* these are magic AdvFS files */ - (strcmp(currp->d_name, ".tags") == 0) || - (strcmp(currp->d_name, "quota.user") == 0) || - (strcmp(currp->d_name, "quota.group") == 0) || + /* these are magic AdvFS files */ + (strcmp(currp->d_name, ".tags") == 0) + || (strcmp(currp->d_name, "quota.user") == 0) + || (strcmp(currp->d_name, "quota.group") == 0) || #endif #ifdef AFS_LINUX22_ENV - /* this is the ext3 journal file */ - (strcmp(currp->d_name, ".journal") == 0) || + /* this is the ext3 journal file */ + (strcmp(currp->d_name, ".journal") == 0) || #endif - (strcmp(currp->d_name, "lost+found") == 0)) { + (strcmp(currp->d_name, "lost+found") == 0)) { /* * Don't do anything - this file is legit, and is to be left alone. */ - } - else { + } else { /* * This file/directory doesn't belong in the cache. Nuke it. */ sprintf(fileToDelete, "%s", currp->d_name); if (afsd_verbose) - printf("%s: Deleting '%s'\n", - rn, fullpn_FileToDelete); + printf("%s: Deleting '%s'\n", rn, fullpn_FileToDelete); if (unlink(fullpn_FileToDelete)) { - if (errno == EISDIR && *fileToDelete == 'D') { + if (errno == EISDIR && *fileToDelete == 'D') { if (rmdir(fullpn_FileToDelete)) { - printf("%s: Can't rmdir '%s', errno is %d\n", - rn, fullpn_FileToDelete, errno); + printf("%s: Can't rmdir '%s', errno is %d\n", rn, + fullpn_FileToDelete, errno); } } else - printf("%s: Can't unlink '%s', errno is %d\n", - rn, fullpn_FileToDelete, errno); + printf("%s: Can't unlink '%s', errno is %d\n", rn, + fullpn_FileToDelete, errno); } } } @@ -895,53 +914,57 @@ static int doSweepAFSCache(vFilesFound,directory,dirNum,maxDir) thisDir = 0; /* Keep track of which subdir has space */ for (vFileNum = 0; vFileNum < cacheFiles; vFileNum++) { - if (dir_for_V[vFileNum] == -1) { - /* This file does not exist. Create it in the first - * subdir that still has extra space. - */ - while (thisDir < maxDir && - cache_dir_list[thisDir] >= nFilesPerDir) - thisDir++; - if (thisDir >= maxDir) - printf("%s: can't find directory to create V%d\n", rn, vFileNum); - else { - struct stat statb; - assert (inode_for_V[vFileNum] == (AFSD_INO_T)0); - sprintf(vFilePtr, "D%d/V%d", thisDir, vFileNum); - if (afsd_verbose) - printf("%s: Creating '%s'\n", rn, fullpn_VFile); - if (cache_dir_list[thisDir] < 0 && - CreateCacheSubDir(directory, thisDir)) - printf("%s: Can't create directory for '%s'\n", - rn, fullpn_VFile); - if (CreateCacheFile(fullpn_VFile, &statb)) - printf("%s: Can't create '%s'\n", rn, fullpn_VFile); - else { - inode_for_V[vFileNum] = statb.st_ino; - dir_for_V[vFileNum] = thisDir; - cache_dir_list[thisDir]++; - (*vFilesFound)++; - } - } + if (dir_for_V[vFileNum] == -1) { + /* This file does not exist. Create it in the first + * subdir that still has extra space. + */ + while (thisDir < maxDir + && cache_dir_list[thisDir] >= nFilesPerDir) + thisDir++; + if (thisDir >= maxDir) + printf("%s: can't find directory to create V%d\n", rn, + vFileNum); + else { + struct stat statb; + assert(inode_for_V[vFileNum] == (AFSD_INO_T) 0); + sprintf(vFilePtr, "D%d/V%d", thisDir, vFileNum); + if (afsd_verbose) + printf("%s: Creating '%s'\n", rn, fullpn_VFile); + if (cache_dir_list[thisDir] < 0 + && CreateCacheSubDir(directory, thisDir)) + printf("%s: Can't create directory for '%s'\n", rn, + fullpn_VFile); + if (CreateCacheFile(fullpn_VFile, &statb)) + printf("%s: Can't create '%s'\n", rn, fullpn_VFile); + else { + inode_for_V[vFileNum] = statb.st_ino; + dir_for_V[vFileNum] = thisDir; + cache_dir_list[thisDir]++; + (*vFilesFound)++; + } + } - } else if (dir_for_V[vFileNum] >= maxDir || - dir_for_V[vFileNum] == -2) { - /* This file needs to move; move it to the first subdir - * that has extra space. (-2 means it's in the toplevel) - */ - while (thisDir < maxDir && cache_dir_list[thisDir] >= nFilesPerDir) - thisDir++; - if (thisDir >= maxDir) - printf("%s: can't find directory to move V%d\n", rn, vFileNum); - else { - if (MoveCacheFile (directory, dir_for_V[vFileNum], thisDir, - vFileNum, maxDir)) { - /* Cannot move. Ignore this file??? */ - /* XXX */ - } + } else if (dir_for_V[vFileNum] >= maxDir + || dir_for_V[vFileNum] == -2) { + /* This file needs to move; move it to the first subdir + * that has extra space. (-2 means it's in the toplevel) + */ + while (thisDir < maxDir + && cache_dir_list[thisDir] >= nFilesPerDir) + thisDir++; + if (thisDir >= maxDir) + printf("%s: can't find directory to move V%d\n", rn, + vFileNum); + else { + if (MoveCacheFile + (directory, dir_for_V[vFileNum], thisDir, vFileNum, + maxDir)) { + /* Cannot move. Ignore this file??? */ + /* XXX */ + } + } } - } - } /* for */ + } /* for */ /* At this point, we've moved all of the valid cache files * into the valid subdirs, and created all the extra @@ -952,145 +975,149 @@ static int doSweepAFSCache(vFilesFound,directory,dirNum,maxDir) */ for (dirNum = 0; dirNum < maxDir; dirNum++) { - struct afsd_file_list *thisFile; - - for (thisFile = cache_dir_filelist[dirNum]; - thisFile && cache_dir_list[dirNum] >= nFilesPerDir; - thisFile = thisFile->next) { - while (thisDir < maxDir && cache_dir_list[thisDir] >= nFilesPerDir) - thisDir++; - if (thisDir >= maxDir) - printf("%s: can't find directory to move V%d\n", rn, vFileNum); - else { - if (MoveCacheFile (directory, dirNum, thisDir, - thisFile->fileNum, maxDir)) { - /* Cannot move. Ignore this file??? */ - /* XXX */ - } - } - } /* for each file to move */ - } /* for each directory */ + struct afsd_file_list *thisFile; + + for (thisFile = cache_dir_filelist[dirNum]; + thisFile && cache_dir_list[dirNum] >= nFilesPerDir; + thisFile = thisFile->next) { + while (thisDir < maxDir + && cache_dir_list[thisDir] >= nFilesPerDir) + thisDir++; + if (thisDir >= maxDir) + printf("%s: can't find directory to move V%d\n", rn, + vFileNum); + else { + if (MoveCacheFile + (directory, dirNum, thisDir, thisFile->fileNum, + maxDir)) { + /* Cannot move. Ignore this file??? */ + /* XXX */ + } + } + } /* for each file to move */ + } /* for each directory */ /* Remove any directories >= maxDir -- they should be empty */ for (; highDir >= maxDir; highDir--) { - sprintf(fileToDelete, "D%d", highDir); - if (unlink(fullpn_FileToDelete)) { - if (errno == EISDIR && *fileToDelete == 'D') { - if (rmdir(fullpn_FileToDelete)) { - printf("%s: Can't rmdir '%s', errno is %d\n", - rn, fullpn_FileToDelete, errno); - } - } else - printf("%s: Can't unlink '%s', errno is %d\n", - rn, fullpn_FileToDelete, errno); - } + sprintf(fileToDelete, "D%d", highDir); + if (unlink(fullpn_FileToDelete)) { + if (errno == EISDIR && *fileToDelete == 'D') { + if (rmdir(fullpn_FileToDelete)) { + printf("%s: Can't rmdir '%s', errno is %d\n", rn, + fullpn_FileToDelete, errno); + } + } else + printf("%s: Can't unlink '%s', errno is %d\n", rn, + fullpn_FileToDelete, errno); + } } - } /* dirNum < 0 */ - + } + + /* dirNum < 0 */ /* * Close the directory, return success. */ if (afsd_debug) - printf("%s: Closing cache directory.\n", - rn); + printf("%s: Closing cache directory.\n", rn); closedir(cdirp); - return(0); + return (0); } -char *CheckCacheBaseDir(char *dir) +char * +CheckCacheBaseDir(char *dir) { - struct stat statbuf; + struct stat statbuf; - if ( !dir ) { return "cache base dir not specified"; } - if ( stat(dir, &statbuf) != 0 ) { - return "unable to stat cache base directory"; - } + if (!dir) { + return "cache base dir not specified"; + } + if (stat(dir, &statbuf) != 0) { + return "unable to stat cache base directory"; + } - /* might want to check here for anything else goofy, like cache pointed at a non-dedicated directory, etc */ + /* might want to check here for anything else goofy, like cache pointed at a non-dedicated directory, etc */ #ifdef AFS_LINUX24_ENV - { - int res; - struct statfs statfsbuf; + { + int res; + struct statfs statfsbuf; - res = statfs(dir, &statfsbuf); - if ( res != 0 ) { - return "unable to statfs cache base directory"; - } - if ( statfsbuf.f_type == 0x52654973 ) /* REISERFS_SUPER_MAGIC */ - { - return "cannot use reiserfs as cache partition"; - } + res = statfs(dir, &statfsbuf); + if (res != 0) { + return "unable to statfs cache base directory"; } + if (statfsbuf.f_type == 0x52654973) { /* REISERFS_SUPER_MAGIC */ + return "cannot use reiserfs as cache partition"; + } + } #endif #ifdef AFS_HPUX_ENV - { - int res; - struct statfs statfsbuf; - char name[FSTYPSZ]; - - res = statfs(dir, &statfsbuf); - if ( res != 0 ) - { - return "unable to statfs cache base directory"; - } + { + int res; + struct statfs statfsbuf; + char name[FSTYPSZ]; - if (sysfs(GETFSTYP, statfsbuf.f_fsid, name) != 0 ) - { - return "unable to determine filesystem type for cache base dir"; - } + res = statfs(dir, &statfsbuf); + if (res != 0) { + return "unable to statfs cache base directory"; + } - if ( strcmp(name, "hfs") ) - { - return "can only use hfs filesystem for cache partition on hpux"; - } + if (sysfs(GETFSTYP, statfsbuf.f_fsid, name) != 0) { + return "unable to determine filesystem type for cache base dir"; } + + if (strcmp(name, "hfs")) { + return "can only use hfs filesystem for cache partition on hpux"; + } + } #endif #ifdef AFS_SUN5_ENV - { - FILE *vfstab; - struct mnttab mnt; - struct stat statmnt, statci; - - if ((stat(dir, &statci) == 0) && - ((vfstab = fopen(MNTTAB, "r")) != NULL)) - { - while (getmntent(vfstab, &mnt) == 0) { - if (strcmp(dir, mnt.mnt_mountp) != 0) - { - char *cp; - int rdev = 0; - - if (cp = hasmntopt(&mnt, "dev=")) - rdev=(int)strtol(cp+strlen("dev="), (char **)NULL, 16); - - if ((rdev == 0) && (stat(mnt.mnt_mountp, &statmnt) == 0)) - rdev=statmnt.st_dev; - - if ((rdev == statci.st_dev) && - (hasmntopt (&mnt, "logging") != NULL)) { - - fclose(vfstab); - return "mounting a multi-use partition which contains the AFS cache with the\n\"logging\" option may deadlock your system.\n\n"; - } - } - } - - fclose(vfstab); + { + FILE *vfstab; + struct mnttab mnt; + struct stat statmnt, statci; + + if ((stat(dir, &statci) == 0) + && ((vfstab = fopen(MNTTAB, "r")) != NULL)) { + while (getmntent(vfstab, &mnt) == 0) { + if (strcmp(dir, mnt.mnt_mountp) != 0) { + char *cp; + int rdev = 0; + + if (cp = hasmntopt(&mnt, "dev=")) + rdev = + (int)strtol(cp + strlen("dev="), (char **)NULL, + 16); + + if ((rdev == 0) && (stat(mnt.mnt_mountp, &statmnt) == 0)) + rdev = statmnt.st_dev; + + if ((rdev == statci.st_dev) + && (hasmntopt(&mnt, "logging") != NULL)) { + + fclose(vfstab); + return + "mounting a multi-use partition which contains the AFS cache with the\n\"logging\" option may deadlock your system.\n\n"; + } } + } + + fclose(vfstab); } + } #endif - return NULL; + return NULL; } -int SweepAFSCache(vFilesFound) - int *vFilesFound; +int +SweepAFSCache(vFilesFound) + int *vFilesFound; { - static char rn[] = "SweepAFSCache"; /*Routine name*/ - int maxDir = (cacheFiles + nFilesPerDir - 1 ) / nFilesPerDir; + static char rn[] = "SweepAFSCache"; /*Routine name */ + int maxDir = (cacheFiles + nFilesPerDir - 1) / nFilesPerDir; int i; *vFilesFound = 0; @@ -1102,33 +1129,33 @@ int SweepAFSCache(vFilesFound) } if (cache_dir_list == NULL) { - cache_dir_list = (int *) malloc (maxDir * sizeof(*cache_dir_list)); + cache_dir_list = (int *)malloc(maxDir * sizeof(*cache_dir_list)); if (cache_dir_list == NULL) { printf("%s: Malloc Failed!\n", rn); return (-1); } - for (i=0; i < maxDir; i++) - cache_dir_list[i] = -1; /* Does not exist */ + for (i = 0; i < maxDir; i++) + cache_dir_list[i] = -1; /* Does not exist */ } if (cache_dir_filelist == NULL) { - cache_dir_filelist = (struct afsd_file_list **) - malloc (maxDir * sizeof(*cache_dir_filelist)); + cache_dir_filelist = (struct afsd_file_list **) + malloc(maxDir * sizeof(*cache_dir_filelist)); if (cache_dir_filelist == NULL) { printf("%s: Malloc Failed!\n", rn); return (-1); } - memset (cache_dir_filelist, 0, maxDir * sizeof(*cache_dir_filelist)); + memset(cache_dir_filelist, 0, maxDir * sizeof(*cache_dir_filelist)); } if (dir_for_V == NULL) { - dir_for_V = (int *) malloc (cacheFiles * sizeof(*dir_for_V)); + dir_for_V = (int *)malloc(cacheFiles * sizeof(*dir_for_V)); if (dir_for_V == NULL) { printf("%s: Malloc Failed!\n", rn); return (-1); } - for (i=0; i < cacheFiles; i++) - dir_for_V[i] = -1; /* Does not exist */ + for (i = 0; i < cacheFiles; i++) + dir_for_V[i] = -1; /* Does not exist */ } /* Note, setting dirNum to -2 here will cause cachefiles found in @@ -1138,45 +1165,48 @@ int SweepAFSCache(vFilesFound) * file into a subdirectory, we know it's in the top-level instead * of some other cache subdir. */ - return doSweepAFSCache (vFilesFound, cacheBaseDir, -2, maxDir); + return doSweepAFSCache(vFilesFound, cacheBaseDir, -2, maxDir); } -static ConfigCell(aci, arock, adir) -register struct afsconf_cell *aci; -char *arock; -struct afsconf_dir *adir; { +static +ConfigCell(aci, arock, adir) + register struct afsconf_cell *aci; + char *arock; + struct afsconf_dir *adir; +{ register int isHomeCell; register int i, code; afs_int32 cellFlags = 0; afs_int32 hosts[MAXHOSTSPERCELL]; - + /* figure out if this is the home cell */ isHomeCell = (strcmp(aci->name, LclCellName) == 0); if (!isHomeCell) - cellFlags = 2; /* not home, suid is forbidden */ - + cellFlags = 2; /* not home, suid is forbidden */ + /* build address list */ - for(i=0;ihostAddr[i].sin_addr, sizeof(afs_int32)); - if (aci->linkedCell) cellFlags |= 4; /* Flag that linkedCell arg exists, - for upwards compatibility */ + if (aci->linkedCell) + cellFlags |= 4; /* Flag that linkedCell arg exists, + * for upwards compatibility */ /* configure one cell */ - code = call_syscall(AFSOP_ADDCELL2, - hosts, /* server addresses */ - aci->name, /* cell name */ - cellFlags, /* is this the home cell? */ - aci->linkedCell); /* Linked cell, if any */ + code = call_syscall(AFSOP_ADDCELL2, hosts, /* server addresses */ + aci->name, /* cell name */ + cellFlags, /* is this the home cell? */ + aci->linkedCell); /* Linked cell, if any */ if (code) printf("Adding cell '%s': error %d\n", aci->name, code); return 0; } -static ConfigCellAlias(aca, arock, adir) - register struct afsconf_cellalias *aca; - char *arock; - struct afsconf_dir *adir; +static +ConfigCellAlias(aca, arock, adir) + register struct afsconf_cellalias *aca; + char *arock; + struct afsconf_dir *adir; { /* push the alias into the kernel */ call_syscall(AFSOP_ADDCELLALIAS, aca->aliasName, aca->realName); @@ -1184,7 +1214,8 @@ static ConfigCellAlias(aca, arock, adir) } #ifdef AFS_AFSDB_ENV -static AfsdbLookupHandler() +static +AfsdbLookupHandler() { afs_int32 kernelMsg[64]; char acellName[128]; @@ -1199,7 +1230,8 @@ static AfsdbLookupHandler() while (1) { /* On some platforms you only get 4 args to an AFS call */ int sizeArg = ((sizeof acellName) << 16) | (sizeof kernelMsg); - code = call_syscall(AFSOP_AFSDB_HANDLER, acellName, kernelMsg, sizeArg); + code = + call_syscall(AFSOP_AFSDB_HANDLER, acellName, kernelMsg, sizeArg); if (code) { /* Something is wrong? */ sleep(1); continue; @@ -1218,11 +1250,11 @@ static AfsdbLookupHandler() kernelMsg[1] = acellInfo.timeout - time(0); else kernelMsg[1] = 0; - for (i=0; iparms[1].items) { /* -files */ cacheFiles = atoi(as->parms[1].items->data); - filesSet = 1; /* set when spec'd on cmd line */ + filesSet = 1; /* set when spec'd on cmd line */ } if (as->parms[2].items) { /* -rootvol */ @@ -1364,7 +1396,8 @@ mainproc(as, arock) if (as->parms[15].items) { /* -biods */ #ifndef AFS_AIX32_ENV - printf("afsd: [-biods] currently only enabled for aix3.x VM supported systems\n"); + printf + ("afsd: [-biods] currently only enabled for aix3.x VM supported systems\n"); #else nBiods = atoi(as->parms[15].items->data); sawBiod = 1; @@ -1374,7 +1407,7 @@ mainproc(as, arock) /* -prealloc */ preallocs = atoi(as->parms[16].items->data); } -#ifdef notdef +#ifdef notdef if (as->parms[17].items) { /* -pininodes */ inodes = atoi(as->parms[17].items->data); @@ -1385,15 +1418,15 @@ mainproc(as, arock) /* -confdir */ strcpy(confDir, as->parms[17].items->data); } - sprintf(fullpn_CacheInfo, "%s/%s", confDir, CACHEINFOFILE); - sprintf(fullpn_AFSLogFile, "%s/%s", confDir, AFSLOGFILE); + sprintf(fullpn_CacheInfo, "%s/%s", confDir, CACHEINFOFILE); + sprintf(fullpn_AFSLogFile, "%s/%s", confDir, AFSLOGFILE); if (as->parms[18].items) { /* -logfile */ strcpy(fullpn_AFSLogFile, as->parms[18].items->data); } if (as->parms[19].items) { - /* -waitclose */ - afsd_CloseSynch = 1; + /* -waitclose */ + afsd_CloseSynch = 1; } if (as->parms[20].items) { /* -shutdown */ @@ -1430,10 +1463,12 @@ mainproc(as, arock) #endif } if (as->parms[25].items) { - /* -files_per_subdir */ - int res = atoi(as->parms[25].items->data); - if ( res < 10 || res > 2^30) { - printf("afsd:invalid number of files per subdir, \"%s\". Ignored\n", as->parms[25].items->data); + /* -files_per_subdir */ + int res = atoi(as->parms[25].items->data); + if (res < 10 || res > 2 ^ 30) { + printf + ("afsd:invalid number of files per subdir, \"%s\". Ignored\n", + as->parms[25].items->data); } else { nFilesPerDir = res; } @@ -1465,15 +1500,14 @@ mainproc(as, arock) exit(1); } - lookupResult = afsconf_GetLocalCell(cdir, LclCellName, sizeof(LclCellName)); + lookupResult = + afsconf_GetLocalCell(cdir, LclCellName, sizeof(LclCellName)); if (lookupResult) { - printf("%s: Can't get my home cell name! [Error is %d]\n", - rn, lookupResult); - } - else { + printf("%s: Can't get my home cell name! [Error is %d]\n", rn, + lookupResult); + } else { if (afsd_verbose) - printf("%s: My home cell is '%s'\n", - rn, LclCellName); + printf("%s: My home cell is '%s'\n", rn, LclCellName); } /* parse cacheinfo file if this is a diskcache */ @@ -1481,10 +1515,13 @@ mainproc(as, arock) exit(1); } - if ((logfd = fopen(fullpn_AFSLogFile,"r+")) == 0) { - if (afsd_verbose) printf("%s: Creating '%s'\n", rn, fullpn_AFSLogFile); + if ((logfd = fopen(fullpn_AFSLogFile, "r+")) == 0) { + if (afsd_verbose) + printf("%s: Creating '%s'\n", rn, fullpn_AFSLogFile); if (CreateCacheFile(fullpn_AFSLogFile, NULL)) { - printf("%s: Can't create '%s' (You may want to use the -logfile option)\n", rn, fullpn_AFSLogFile); + printf + ("%s: Can't create '%s' (You may want to use the -logfile option)\n", + rn, fullpn_AFSLogFile); exit(1); } } else @@ -1499,23 +1536,24 @@ mainproc(as, arock) */ if (sawDCacheSize) { if (sawCacheBlocks) { - printf("%s: can't set cache blocks and dcache size simultaneously when diskless.\n", rn); + printf + ("%s: can't set cache blocks and dcache size simultaneously when diskless.\n", + rn); exit(1); } /* compute the cache size based on # of chunks times the chunk size */ - i = (chunkSize == 0? 13 : chunkSize); - i = (1< 10) { - dCacheSize = (cacheBlocks >> (i-10)); + dCacheSize = (cacheBlocks >> (i - 10)); } else if (i < 10) { - dCacheSize = (cacheBlocks << (10-i)); + dCacheSize = (cacheBlocks << (10 - i)); } else { dCacheSize = cacheBlocks; } @@ -1527,8 +1565,7 @@ mainproc(as, arock) * so we now make them equal. */ cacheFiles = dCacheSize; - } - else { + } else { /* Disk cache: * Compute the number of cache files based on cache size, * but only if -files isn't given on the command line. @@ -1537,13 +1574,15 @@ mainproc(as, arock) * average V-file is ~10K, according to tentative empirical studies. */ if (!filesSet) { - cacheFiles = cacheBlocks / 10; - if (cacheFiles < 100) cacheFiles = 100; + cacheFiles = cacheBlocks / 10; + if (cacheFiles < 100) + cacheFiles = 100; /* Always allow more files than chunks. Presume average V-file * is ~67% of a chunk... (another guess, perhaps Honeyman will * have a grad student write a paper). i is KILOBYTES. */ - i = 1 << (chunkSize == 0? 6 : (chunkSize<10 ? 0 : chunkSize -10)); + i = 1 << (chunkSize == + 0 ? 6 : (chunkSize < 10 ? 0 : chunkSize - 10)); cacheFiles = max(cacheFiles, 1.5 * (cacheBlocks / i)); /* never permit more files than blocks, while leaving space for * VolumeInfo and CacheItems files. VolumeInfo is usually 20K, @@ -1552,12 +1591,15 @@ mainproc(as, arock) #define VOLINFOSZ 20 #define CACHEITMSZ (cacheFiles / 20) #ifdef AFS_AIX_ENV - cacheFiles= min(cacheFiles,(cacheBlocks -VOLINFOSZ -CACHEITMSZ)/4); + cacheFiles = + min(cacheFiles, (cacheBlocks - VOLINFOSZ - CACHEITMSZ) / 4); #else - cacheFiles = min(cacheFiles, cacheBlocks - VOLINFOSZ - CACHEITMSZ); + cacheFiles = + min(cacheFiles, cacheBlocks - VOLINFOSZ - CACHEITMSZ); #endif - if (cacheFiles < 100) - fprintf (stderr, "%s: WARNING: cache probably too small!\n", rn); + if (cacheFiles < 100) + fprintf(stderr, "%s: WARNING: cache probably too small!\n", + rn); } if (!sawDCacheSize) { if ((cacheFiles / 2) > dCacheSize) @@ -1571,32 +1613,31 @@ mainproc(as, arock) * Create and zero the inode table for the desired cache files. */ inode_for_V = (AFSD_INO_T *) malloc(cacheFiles * sizeof(AFSD_INO_T)); - if (inode_for_V == (AFSD_INO_T *)0) { - printf("%s: malloc() failed for cache file inode table with %d entries.\n", - rn, cacheFiles); + if (inode_for_V == (AFSD_INO_T *) 0) { + printf + ("%s: malloc() failed for cache file inode table with %d entries.\n", + rn, cacheFiles); exit(1); } memset(inode_for_V, '\0', (cacheFiles * sizeof(AFSD_INO_T))); if (afsd_debug) - printf("%s: %d inode_for_V entries at 0x%x, %d bytes\n", - rn, cacheFiles, inode_for_V, - (cacheFiles * sizeof(AFSD_INO_T))); + printf("%s: %d inode_for_V entries at 0x%x, %d bytes\n", rn, + cacheFiles, inode_for_V, (cacheFiles * sizeof(AFSD_INO_T))); /* * Set up all the pathnames we'll need for later. */ - sprintf(fullpn_DCacheFile, "%s/%s", cacheBaseDir, DCACHEFILE); - sprintf(fullpn_VolInfoFile, "%s/%s", cacheBaseDir, VOLINFOFILE); + sprintf(fullpn_DCacheFile, "%s/%s", cacheBaseDir, DCACHEFILE); + sprintf(fullpn_VolInfoFile, "%s/%s", cacheBaseDir, VOLINFOFILE); sprintf(fullpn_CellInfoFile, "%s/%s", cacheBaseDir, CELLINFOFILE); - sprintf(fullpn_VFile, "%s/", cacheBaseDir); + sprintf(fullpn_VFile, "%s/", cacheBaseDir); vFilePtr = fullpn_VFile + strlen(fullpn_VFile); if ((fsTypeMsg = CheckCacheBaseDir(cacheBaseDir))) { - printf("%s: WARNING: Cache dir check failed (%s)\n", rn, fsTypeMsg); + printf("%s: WARNING: Cache dir check failed (%s)\n", rn, fsTypeMsg); } - #if 0 - fputs(AFS_GOVERNMENT_MESSAGE, stdout); + fputs(AFS_GOVERNMENT_MESSAGE, stdout); fflush(stdout); #endif @@ -1611,16 +1652,19 @@ mainproc(as, arock) /* initialize the rx random number generator from user space */ { - /* parse multihomed address files */ - afs_int32 addrbuf[MAXIPADDRS],maskbuf[MAXIPADDRS],mtubuf[MAXIPADDRS]; - char reason[1024]; - code=parseNetFiles(addrbuf,maskbuf,mtubuf,MAXIPADDRS,reason, - AFSDIR_CLIENT_NETINFO_FILEPATH, - AFSDIR_CLIENT_NETRESTRICT_FILEPATH); - if(code>0) - call_syscall(AFSOP_ADVISEADDR, code, addrbuf, maskbuf, mtubuf); - else - printf("ADVISEADDR: Error in specifying interface addresses:%s\n",reason); + /* parse multihomed address files */ + afs_int32 addrbuf[MAXIPADDRS], maskbuf[MAXIPADDRS], + mtubuf[MAXIPADDRS]; + char reason[1024]; + code = + parseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS, reason, + AFSDIR_CLIENT_NETINFO_FILEPATH, + AFSDIR_CLIENT_NETRESTRICT_FILEPATH); + if (code > 0) + call_syscall(AFSOP_ADVISEADDR, code, addrbuf, maskbuf, mtubuf); + else + printf("ADVISEADDR: Error in specifying interface addresses:%s\n", + reason); } /* Set realtime priority for most threads to same as for biod's. */ @@ -1642,18 +1686,16 @@ mainproc(as, arock) * preallocs are passed for both listener and callback server. Only * the one which actually does the initialization uses them though. */ - if (preallocs < cacheStatEntries+50) - preallocs = cacheStatEntries+50; + if (preallocs < cacheStatEntries + 50) + preallocs = cacheStatEntries + 50; #ifdef RXK_LISTENER_ENV if (afsd_verbose) printf("%s: Forking rx listener daemon.\n", rn); code = fork(); if (code == 0) { /* Child */ - SET_RX_RTPRI(); /* max advised for non-interrupts */ - call_syscall(AFSOP_RXLISTENER_DAEMON, - preallocs, - enable_peer_stats, + SET_RX_RTPRI(); /* max advised for non-interrupts */ + call_syscall(AFSOP_RXLISTENER_DAEMON, preallocs, enable_peer_stats, enable_process_stats); exit(1); } @@ -1672,7 +1714,7 @@ mainproc(as, arock) code = fork(); if (code == 0) { /* Child */ - SET_RX_RTPRI(); /* max advised for non-interrupts */ + SET_RX_RTPRI(); /* max advised for non-interrupts */ call_syscall(AFSOP_RXEVENT_DAEMON); exit(1); } @@ -1698,9 +1740,10 @@ mainproc(as, arock) * Tell the kernel some basic information about the workstation's cache. */ if (afsd_verbose) - printf("%s: Calling AFSOP_CACHEINIT: %d stat cache entries, %d optimum cache files, %d blocks in the cache, flags = 0x%x, dcache entries %d\n", - rn, cacheStatEntries, cacheFiles, cacheBlocks, cacheFlags, - dCacheSize); + printf + ("%s: Calling AFSOP_CACHEINIT: %d stat cache entries, %d optimum cache files, %d blocks in the cache, flags = 0x%x, dcache entries %d\n", + rn, cacheStatEntries, cacheFiles, cacheBlocks, cacheFlags, + dCacheSize); memset(&cparams, '\0', sizeof(cparams)); cparams.cacheScaches = cacheStatEntries; cparams.cacheFiles = cacheFiles; @@ -1711,10 +1754,10 @@ mainproc(as, arock) cparams.setTimeFlag = cacheSetTime; cparams.memCacheFlag = cacheFlags; #ifdef notdef - cparams.inodes = inodes; + cparams.inodes = inodes; #endif call_syscall(AFSOP_CACHEINIT, &cparams); - if (afsd_CloseSynch) + if (afsd_CloseSynch) call_syscall(AFSOP_CLOSEWAIT); /* @@ -1727,11 +1770,10 @@ mainproc(as, arock) * CellItems, and thus must be ran before those are sent to the kernel. */ if (afsd_verbose) - printf("%s: Sweeping workstation's AFS cache directory.\n", - rn); + printf("%s: Sweeping workstation's AFS cache directory.\n", rn); cacheIteration = 0; /* Memory-cache based system doesn't need any of this */ - if(!(cacheFlags & AFSCALL_INIT_MEMCACHE)) { + if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) { do { cacheIteration++; if (SweepAFSCache(&vFilesFound)) { @@ -1740,11 +1782,12 @@ mainproc(as, arock) exit(1); } if (afsd_verbose) - printf("%s: %d out of %d data cache files found in sweep %d.\n", - rn, vFilesFound, cacheFiles, cacheIteration); - } while ((vFilesFound < cacheFiles) && - (cacheIteration < MAX_CACHE_LOOPS)); - } else if(afsd_verbose) + printf + ("%s: %d out of %d data cache files found in sweep %d.\n", + rn, vFilesFound, cacheFiles, cacheIteration); + } while ((vFilesFound < cacheFiles) + && (cacheIteration < MAX_CACHE_LOOPS)); + } else if (afsd_verbose) printf("%s: Using memory cache, not swept\n", rn); /* @@ -1752,10 +1795,10 @@ mainproc(as, arock) * dcache entries. */ if (afsd_debug) - printf("%s: Calling AFSOP_CACHEINFO: dcache file is '%s'\n", - rn, fullpn_DCacheFile); + printf("%s: Calling AFSOP_CACHEINFO: dcache file is '%s'\n", rn, + fullpn_DCacheFile); /* once again, meaningless for a memory-based cache. */ - if(!(cacheFlags & AFSCALL_INIT_MEMCACHE)) + if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) call_syscall(AFSOP_CACHEINFO, fullpn_DCacheFile); /* @@ -1763,8 +1806,8 @@ mainproc(as, arock) * cell information. */ if (afsd_debug) - printf("%s: Calling AFSOP_CELLINFO: cell info file is '%s'\n", - rn, fullpn_CellInfoFile); + printf("%s: Calling AFSOP_CELLINFO: cell info file is '%s'\n", rn, + fullpn_CellInfoFile); call_syscall(AFSOP_CELLINFO, fullpn_CellInfoFile); if (enable_dynroot) { @@ -1823,7 +1866,7 @@ mainproc(as, arock) */ nDaemons++; #endif - for (i=0;iparms[18].items) #else - if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) /* ... nor this ... */ + if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) /* ... nor this ... */ #endif - call_syscall(AFSOP_AFSLOG,fullpn_AFSLogFile); + call_syscall(AFSOP_AFSLOG, fullpn_AFSLogFile); /* * Give the kernel the names of the AFS files cached on the workstation's * disk. */ if (afsd_debug) - printf("%s: Calling AFSOP_CACHEINODE for each of the %d files in '%s'\n", - rn, cacheFiles, cacheBaseDir); - if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) /* ... and again ... */ + printf + ("%s: Calling AFSOP_CACHEINODE for each of the %d files in '%s'\n", + rn, cacheFiles, cacheBaseDir); + if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) /* ... and again ... */ for (currVFile = 0; currVFile < cacheFiles; currVFile++) { #ifdef AFS_SGI62_ENV call_syscall(AFSOP_CACHEINODE, - (afs_uint32)(inode_for_V[currVFile]>>32), - (afs_uint32)(inode_for_V[currVFile] & 0xffffffff)); + (afs_uint32) (inode_for_V[currVFile] >> 32), + (afs_uint32) (inode_for_V[currVFile] & 0xffffffff)); #else call_syscall(AFSOP_CACHEINODE, inode_for_V[currVFile]); #endif - } /*end for*/ + } + /*end for */ /* * All the necessary info has been passed into the kernel to run an AFS * system. Give the kernel our go-ahead. */ if (afsd_debug) - printf("%s: Calling AFSOP_GO with cacheSetTime = %d\n", - rn, cacheSetTime); - call_syscall(AFSOP_GO, cacheSetTime); + printf("%s: Calling AFSOP_GO with cacheSetTime = %d\n", rn, + cacheSetTime); + call_syscall(AFSOP_GO, cacheSetTime); /* * At this point, we have finished passing the kernel all the info @@ -1928,12 +1973,12 @@ mainproc(as, arock) if (!enable_nomount) { - mountFlags = 0; /* Read/write file system, can do setuid() */ + mountFlags = 0; /* Read/write file system, can do setuid() */ #if defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV) #ifdef AFS_SUN5_ENV - mountFlags |= MS_DATA; + mountFlags |= MS_DATA; #else - mountFlags |= M_NEWTYPE; /* This searches by name in vfs_conf.c so don't need to recompile vfs.c because MOUNT_MAXTYPE has changed; it seems that Sun fixed this at last... */ + mountFlags |= M_NEWTYPE; /* This searches by name in vfs_conf.c so don't need to recompile vfs.c because MOUNT_MAXTYPE has changed; it seems that Sun fixed this at last... */ #endif #endif @@ -1941,59 +1986,63 @@ mainproc(as, arock) mountFlags |= MS_DATA; #endif - if (afsd_verbose) - printf("%s: Mounting the AFS root on '%s', flags: %d.\n", - rn, cacheMountDir, mountFlags); + if (afsd_verbose) + printf("%s: Mounting the AFS root on '%s', flags: %d.\n", rn, + cacheMountDir, mountFlags); #ifdef AFS_DEC_ENV - if ((mount("AFS",cacheMountDir,mountFlags,GT_AFS,(caddr_t) 0)) < 0) { + if ((mount("AFS", cacheMountDir, mountFlags, GT_AFS, (caddr_t) 0)) < + 0) { #else #ifdef AFS_FBSD_ENV - if ((mount("AFS",cacheMountDir,mountFlags,(caddr_t) 0)) < 0) { + if ((mount("AFS", cacheMountDir, mountFlags, (caddr_t) 0)) < 0) { #else #ifdef AFS_AUX_ENV - if ((fsmount(MOUNT_AFS,cacheMountDir,mountFlags,(caddr_t) 0)) < 0) { + if ((fsmount(MOUNT_AFS, cacheMountDir, mountFlags, (caddr_t) 0)) < 0) { #else #ifdef AFS_AIX_ENV - if (aix_vmount()) { + if (aix_vmount()) { #else #if defined(AFS_HPUX100_ENV) - if ((mount("",cacheMountDir,mountFlags,"afs", NULL, 0)) < 0) { + if ((mount("", cacheMountDir, mountFlags, "afs", NULL, 0)) < 0) { #else #ifdef AFS_HPUX_ENV #if defined(AFS_HPUX90_ENV) - { - char buffer[80]; - int code; - - strcpy(buffer, "afs"); - code = vfsmount(-1,cacheMountDir,mountFlags,(caddr_t) buffer); - sscanf(buffer, "%d", &vfs1_type); - if (code < 0) { - printf("Can't find 'afs' type in the registered filesystem table!\n"); - exit(1); + { + char buffer[80]; + int code; + + strcpy(buffer, "afs"); + code = vfsmount(-1, cacheMountDir, mountFlags, (caddr_t) buffer); + sscanf(buffer, "%d", &vfs1_type); + if (code < 0) { + printf + ("Can't find 'afs' type in the registered filesystem table!\n"); + exit(1); + } + sscanf(buffer, "%d", &vfs1_type); + if (afsd_verbose) + printf("AFS vfs slot number is %d\n", vfs1_type); } - sscanf(buffer, "%d", &vfs1_type); - if (afsd_verbose) - printf("AFS vfs slot number is %d\n", vfs1_type); - } - if ((vfsmount(vfs1_type,cacheMountDir,mountFlags,(caddr_t) 0)) < 0) { + if ((vfsmount(vfs1_type, cacheMountDir, mountFlags, (caddr_t) 0)) < 0) { #else - if (call_syscall(AFSOP_AFS_VFSMOUNT, MOUNT_AFS, cacheMountDir, - mountFlags, (caddr_t)NULL) < 0) { + if (call_syscall + (AFSOP_AFS_VFSMOUNT, MOUNT_AFS, cacheMountDir, mountFlags, + (caddr_t) NULL) < 0) { #endif #else #ifdef AFS_SUN5_ENV - if ((mount("AFS",cacheMountDir,mountFlags,"afs", NULL, 0)) < 0) { + if ((mount("AFS", cacheMountDir, mountFlags, "afs", NULL, 0)) < 0) { #else #if defined(AFS_SGI_ENV) - mountFlags = MS_FSS; - if ((mount(MOUNT_AFS,cacheMountDir,mountFlags,(caddr_t) MOUNT_AFS)) < 0) { + mountFlags = MS_FSS; + if ((mount(MOUNT_AFS, cacheMountDir, mountFlags, (caddr_t) MOUNT_AFS)) + < 0) { #else #ifdef AFS_LINUX20_ENV - if ((mount("AFS", cacheMountDir, MOUNT_AFS, 0, NULL))<0) { + if ((mount("AFS", cacheMountDir, MOUNT_AFS, 0, NULL)) < 0) { #else /* This is the standard mount used by the suns and rts */ - if ((mount(MOUNT_AFS,cacheMountDir,mountFlags,(caddr_t) 0)) < 0) { + if ((mount(MOUNT_AFS, cacheMountDir, mountFlags, (caddr_t) 0)) < 0) { #endif /* AFS_LINUX20_ENV */ #endif /* AFS_SGI_ENV */ #endif /* AFS_SUN5_ENV */ @@ -2003,12 +2052,12 @@ mainproc(as, arock) #endif /* AFS_AUX_ENV */ #endif /* AFS_FBSD_ENV */ #endif /* AFS_DEC_ENV */ - printf("%s: Can't mount AFS on %s(%d)\n", - rn, cacheMountDir, errno); - exit(1); - } + printf("%s: Can't mount AFS on %s(%d)\n", rn, cacheMountDir, + errno); + exit(1); + } - HandleMTab(); + HandleMTab(); } @@ -2033,48 +2082,74 @@ mainproc(as, arock) main(argc, argv) -int argc; -char **argv; { + int argc; + char **argv; +{ register struct cmd_syndesc *ts; ts = cmd_CreateSyntax(NULL, mainproc, NULL, "start AFS"); - cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL, "1024 byte blocks in cache"); + cmd_AddParm(ts, "-blocks", CMD_SINGLE, CMD_OPTIONAL, + "1024 byte blocks in cache"); cmd_AddParm(ts, "-files", CMD_SINGLE, CMD_OPTIONAL, "files in cache"); - cmd_AddParm(ts, "-rootvol", CMD_SINGLE, CMD_OPTIONAL, "name of AFS root volume"); - cmd_AddParm(ts, "-stat", CMD_SINGLE, CMD_OPTIONAL, "number of stat entries"); + cmd_AddParm(ts, "-rootvol", CMD_SINGLE, CMD_OPTIONAL, + "name of AFS root volume"); + cmd_AddParm(ts, "-stat", CMD_SINGLE, CMD_OPTIONAL, + "number of stat entries"); cmd_AddParm(ts, "-memcache", CMD_FLAG, CMD_OPTIONAL, "run diskless"); cmd_AddParm(ts, "-cachedir", CMD_SINGLE, CMD_OPTIONAL, "cache directory"); cmd_AddParm(ts, "-mountdir", CMD_SINGLE, CMD_OPTIONAL, "mount location"); - cmd_AddParm(ts, "-daemons", CMD_SINGLE, CMD_OPTIONAL, "number of daemons to use"); - cmd_AddParm(ts, "-nosettime", CMD_FLAG, CMD_OPTIONAL, "don't set the time"); - cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "display lots of information"); - cmd_AddParm(ts, "-rmtsys", CMD_FLAG, CMD_OPTIONAL, "start NFS rmtsysd program"); + cmd_AddParm(ts, "-daemons", CMD_SINGLE, CMD_OPTIONAL, + "number of daemons to use"); + cmd_AddParm(ts, "-nosettime", CMD_FLAG, CMD_OPTIONAL, + "don't set the time"); + cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, + "display lots of information"); + cmd_AddParm(ts, "-rmtsys", CMD_FLAG, CMD_OPTIONAL, + "start NFS rmtsysd program"); cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL, "display debug info"); - cmd_AddParm(ts, "-chunksize", CMD_SINGLE, CMD_OPTIONAL, "log(2) of chunk size"); - cmd_AddParm(ts, "-dcache", CMD_SINGLE, CMD_OPTIONAL, "number of dcache entries"); - cmd_AddParm(ts, "-volumes", CMD_SINGLE, CMD_OPTIONAL, "number of volume entries"); - cmd_AddParm(ts, "-biods", CMD_SINGLE, CMD_OPTIONAL, "number of bkg I/O daemons (aix vm)"); - - cmd_AddParm(ts, "-prealloc", CMD_SINGLE, CMD_OPTIONAL, "number of 'small' preallocated blocks"); + cmd_AddParm(ts, "-chunksize", CMD_SINGLE, CMD_OPTIONAL, + "log(2) of chunk size"); + cmd_AddParm(ts, "-dcache", CMD_SINGLE, CMD_OPTIONAL, + "number of dcache entries"); + cmd_AddParm(ts, "-volumes", CMD_SINGLE, CMD_OPTIONAL, + "number of volume entries"); + cmd_AddParm(ts, "-biods", CMD_SINGLE, CMD_OPTIONAL, + "number of bkg I/O daemons (aix vm)"); + + cmd_AddParm(ts, "-prealloc", CMD_SINGLE, CMD_OPTIONAL, + "number of 'small' preallocated blocks"); #ifdef notdef - cmd_AddParm(ts, "-pininodes", CMD_SINGLE, CMD_OPTIONAL, "number of inodes to hog"); + cmd_AddParm(ts, "-pininodes", CMD_SINGLE, CMD_OPTIONAL, + "number of inodes to hog"); #endif - cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL, "configuration directory"); - cmd_AddParm(ts, "-logfile", CMD_SINGLE, CMD_OPTIONAL, "Place to keep the CM log"); - cmd_AddParm(ts, "-waitclose", CMD_FLAG, CMD_OPTIONAL, "make close calls synchronous"); - cmd_AddParm(ts, "-shutdown", CMD_FLAG, CMD_OPTIONAL, "Shutdown all afs state"); - cmd_AddParm(ts, "-enable_peer_stats", CMD_FLAG, CMD_OPTIONAL|CMD_HIDE, "Collect rpc statistics by peer"); - cmd_AddParm(ts, "-enable_process_stats", CMD_FLAG, CMD_OPTIONAL|CMD_HIDE, "Collect rpc statistics for this process"); - cmd_AddParm(ts, "-mem_alloc_sleep", CMD_FLAG, (CMD_OPTIONAL | CMD_HIDE), "Allow sleeps when allocating memory cache"); + cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL, + "configuration directory"); + cmd_AddParm(ts, "-logfile", CMD_SINGLE, CMD_OPTIONAL, + "Place to keep the CM log"); + cmd_AddParm(ts, "-waitclose", CMD_FLAG, CMD_OPTIONAL, + "make close calls synchronous"); + cmd_AddParm(ts, "-shutdown", CMD_FLAG, CMD_OPTIONAL, + "Shutdown all afs state"); + cmd_AddParm(ts, "-enable_peer_stats", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, + "Collect rpc statistics by peer"); + cmd_AddParm(ts, "-enable_process_stats", CMD_FLAG, + CMD_OPTIONAL | CMD_HIDE, + "Collect rpc statistics for this process"); + cmd_AddParm(ts, "-mem_alloc_sleep", CMD_FLAG, (CMD_OPTIONAL | CMD_HIDE), + "Allow sleeps when allocating memory cache"); cmd_AddParm(ts, "-afsdb", CMD_FLAG, (CMD_OPTIONAL #ifndef AFS_AFSDB_ENV - | CMD_HIDE + | CMD_HIDE #endif ), "Enable AFSDB support"); - cmd_AddParm(ts, "-files_per_subdir", CMD_SINGLE, CMD_OPTIONAL, "log(2) of the number of cache files per cache subdirectory"); - cmd_AddParm(ts, "-dynroot", CMD_FLAG, CMD_OPTIONAL, "Enable dynroot support"); - cmd_AddParm(ts, "-fakestat", CMD_FLAG, CMD_OPTIONAL, "Enable fakestat support for cross-cell mounts"); - cmd_AddParm(ts, "-fakestat-all", CMD_FLAG, CMD_OPTIONAL, "Enable fakestat support for all mounts"); + cmd_AddParm(ts, "-files_per_subdir", CMD_SINGLE, CMD_OPTIONAL, + "log(2) of the number of cache files per cache subdirectory"); + cmd_AddParm(ts, "-dynroot", CMD_FLAG, CMD_OPTIONAL, + "Enable dynroot support"); + cmd_AddParm(ts, "-fakestat", CMD_FLAG, CMD_OPTIONAL, + "Enable fakestat support for cross-cell mounts"); + cmd_AddParm(ts, "-fakestat-all", CMD_FLAG, CMD_OPTIONAL, + "Enable fakestat support for all mounts"); cmd_AddParm(ts, "-nomount", CMD_FLAG, CMD_OPTIONAL, "Do not mount AFS"); return (cmd_Dispatch(argc, argv)); } @@ -2090,7 +2165,9 @@ char **argv; { #endif #endif -static int HandleMTab() { +static int +HandleMTab() +{ #if (defined (AFS_SUN_ENV) || defined (AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV)) && !defined(AFS_SUN58_ENV) FILE *tfilep; #ifdef AFS_SUN5_ENV @@ -2107,7 +2184,7 @@ static int HandleMTab() { tmntent.mnt_mountp = cacheMountDir; tmntent.mnt_fstype = "xx"; tmntent.mnt_mntopts = "rw"; - sprintf(tbuf, "%ld", (long)time((time_t *)0)); + sprintf(tbuf, "%ld", (long)time((time_t *) 0)); tmntent.mnt_time = tbuf; putmntent(tfilep, &tmntent); fclose(tfilep); @@ -2146,17 +2223,19 @@ static int HandleMTab() { #endif addmntent(tfilep, &tmntent); endmntent(tfilep); -#endif /* AFS_SGI_ENV */ -#endif /* AFS_SUN5_ENV */ -#endif /* unreasonable systems */ +#endif /* AFS_SGI_ENV */ +#endif /* AFS_SUN5_ENV */ +#endif /* unreasonable systems */ #ifdef AFS_DARWIN_ENV mach_port_t diskarb_port; kern_return_t status; status = DiskArbStart(&diskarb_port); if (status == KERN_SUCCESS) { - status = DiskArbDiskAppearedWithMountpointPing_auto("AFS", - DISK_ARB_NETWORK_DISK_FLAG, cacheMountDir); + status = + DiskArbDiskAppearedWithMountpointPing_auto("AFS", + DISK_ARB_NETWORK_DISK_FLAG, + cacheMountDir); } return status; @@ -2166,7 +2245,7 @@ static int HandleMTab() { #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV) call_syscall(param1, param2, param3, param4, param5, param6, param7) -long param1, param2, param3, param4, param5, param6, param7; + long param1, param2, param3, param4, param5, param6, param7; { int error; #ifdef AFS_LINUX20_ENV @@ -2177,32 +2256,39 @@ long param1, param2, param3, param4, param5, param6, param7; eparm[2] = param6; eparm[3] = param7; - param4 = (long) eparm; + param4 = (long)eparm; #endif - error = syscall(AFS_SYSCALL, AFSCALL_CALL, param1, param2, param3, param4, param5, param6, param7); - if (afsd_verbose) printf("SScall(%d, %d, %d)=%d ", AFS_SYSCALL, AFSCALL_CALL, param1, error); + error = + syscall(AFS_SYSCALL, AFSCALL_CALL, param1, param2, param3, param4, + param5, param6, param7); + if (afsd_verbose) + printf("SScall(%d, %d, %d)=%d ", AFS_SYSCALL, AFSCALL_CALL, param1, + error); return (error); } -#else /* AFS_AIX32_ENV */ +#else /* AFS_AIX32_ENV */ #if defined(AFS_SGI_ENV) call_syscall(call, parm0, parm1, parm2, parm3, parm4) { - int error; + int error; - error = afs_syscall(call, parm0, parm1, parm2, parm3, parm4); - if (afsd_verbose) printf("SScall(%d, %d)=%d ", call, parm0, error); + error = afs_syscall(call, parm0, parm1, parm2, parm3, parm4); + if (afsd_verbose) + printf("SScall(%d, %d)=%d ", call, parm0, error); - return error; + return error; } #else -call_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6) { +call_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6) +{ - return syscall(AFSCALL_CALL, call, parm0, parm1, parm2, parm3, parm4, parm5, parm6); + return syscall(AFSCALL_CALL, call, parm0, parm1, parm2, parm3, parm4, + parm5, parm6); } #endif /* AFS_SGI_ENV */ -#endif /* AFS_AIX32_ENV */ +#endif /* AFS_AIX32_ENV */ #ifdef AFS_AIX_ENV @@ -2211,88 +2297,89 @@ call_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6) { #define ROUNDUP(x) (((x) + 3) & ~3) -aix_vmount() { - struct vmount *vmountp; +aix_vmount() +{ + struct vmount *vmountp; int size, error; - size = sizeof(struct vmount) + ROUNDUP(strlen(cacheMountDir)+1) + 5*4; + size = sizeof(struct vmount) + ROUNDUP(strlen(cacheMountDir) + 1) + 5 * 4; /* Malloc the vmount structure */ if ((vmountp = (struct vmount *)malloc(size)) == (struct vmount *)NULL) { - printf("Can't allocate space for the vmount structure (AIX)\n"); - exit(1); + printf("Can't allocate space for the vmount structure (AIX)\n"); + exit(1); } /* zero out the vmount structure */ memset(vmountp, '\0', size); - + /* transfer info into the vmount structure */ vmountp->vmt_revision = VMT_REVISION; vmountp->vmt_length = size; vmountp->vmt_fsid.fsid_dev = 0; vmountp->vmt_fsid.fsid_type = AFS_MOUNT_AFS; vmountp->vmt_vfsnumber = 0; - vmountp->vmt_time = 0;/* We'll put the time soon! */ + vmountp->vmt_time = 0; /* We'll put the time soon! */ vmountp->vmt_flags = VFS_DEVMOUNT; /* read/write permission */ vmountp->vmt_gfstype = AFS_MOUNT_AFS; vmountdata(vmountp, "AFS", cacheMountDir, "", "", "", "rw"); - + /* Do the actual mount system call */ error = vmount(vmountp, size); free(vmountp); - return(error); + return (error); } vmountdata(vmtp, obj, stub, host, hostsname, info, args) -struct vmount *vmtp; -char *obj, *stub, *host, *hostsname, *info, *args; + struct vmount *vmtp; + char *obj, *stub, *host, *hostsname, *info, *args; { - register struct data { - short vmt_off; - short vmt_size; - } *vdp, *vdprev; - register int size; - - vdp = (struct data *)vmtp->vmt_data; - vdp->vmt_off = sizeof(struct vmount); - size = ROUNDUP(strlen(obj) + 1); - vdp->vmt_size = size; - strcpy(vmt2dataptr(vmtp, VMT_OBJECT), obj); - - vdprev = vdp; - vdp++; - vdp->vmt_off = vdprev->vmt_off + size; - size = ROUNDUP(strlen(stub) + 1); - vdp->vmt_size = size; - strcpy(vmt2dataptr(vmtp, VMT_STUB), stub); - - vdprev = vdp; - vdp++; - vdp->vmt_off = vdprev->vmt_off + size; - size = ROUNDUP(strlen(host) + 1); - vdp->vmt_size = size; - strcpy(vmt2dataptr(vmtp, VMT_HOST), host); - - vdprev = vdp; - vdp++; - vdp->vmt_off = vdprev->vmt_off + size; - size = ROUNDUP(strlen(hostsname) + 1); - vdp->vmt_size = size; - strcpy(vmt2dataptr(vmtp, VMT_HOSTNAME), hostsname); - - - vdprev = vdp; - vdp++; - vdp->vmt_off = vdprev->vmt_off + size; - size = ROUNDUP(strlen(info) + 1); - vdp->vmt_size = size; - strcpy(vmt2dataptr(vmtp, VMT_INFO), info); - - vdprev = vdp; - vdp++; - vdp->vmt_off = vdprev->vmt_off + size; - size = ROUNDUP(strlen(args) + 1); - vdp->vmt_size = size; - strcpy(vmt2dataptr(vmtp, VMT_ARGS), args); + register struct data { + short vmt_off; + short vmt_size; + } *vdp, *vdprev; + register int size; + + vdp = (struct data *)vmtp->vmt_data; + vdp->vmt_off = sizeof(struct vmount); + size = ROUNDUP(strlen(obj) + 1); + vdp->vmt_size = size; + strcpy(vmt2dataptr(vmtp, VMT_OBJECT), obj); + + vdprev = vdp; + vdp++; + vdp->vmt_off = vdprev->vmt_off + size; + size = ROUNDUP(strlen(stub) + 1); + vdp->vmt_size = size; + strcpy(vmt2dataptr(vmtp, VMT_STUB), stub); + + vdprev = vdp; + vdp++; + vdp->vmt_off = vdprev->vmt_off + size; + size = ROUNDUP(strlen(host) + 1); + vdp->vmt_size = size; + strcpy(vmt2dataptr(vmtp, VMT_HOST), host); + + vdprev = vdp; + vdp++; + vdp->vmt_off = vdprev->vmt_off + size; + size = ROUNDUP(strlen(hostsname) + 1); + vdp->vmt_size = size; + strcpy(vmt2dataptr(vmtp, VMT_HOSTNAME), hostsname); + + + vdprev = vdp; + vdp++; + vdp->vmt_off = vdprev->vmt_off + size; + size = ROUNDUP(strlen(info) + 1); + vdp->vmt_size = size; + strcpy(vmt2dataptr(vmtp, VMT_INFO), info); + + vdprev = vdp; + vdp++; + vdp->vmt_off = vdprev->vmt_off + size; + size = ROUNDUP(strlen(args) + 1); + vdp->vmt_size = size; + strcpy(vmt2dataptr(vmtp, VMT_ARGS), args); } #endif /* AFS_AIX_ENV */ @@ -2305,13 +2392,13 @@ char *obj, *stub, *host, *hostsname, *info, *args; /* Contains list of names to find in given file. */ typedef struct { - char *name; /* Name of variable or function. */ - afs_hyper_t addr; /* Address of function, undefined if not found. */ - Dwarf_Half type; /* DW_AT_location for vars, DW_AT_lowpc for func's */ - char found; /* set if found. */ + char *name; /* Name of variable or function. */ + afs_hyper_t addr; /* Address of function, undefined if not found. */ + Dwarf_Half type; /* DW_AT_location for vars, DW_AT_lowpc for func's */ + char found; /* set if found. */ } staticAddrList; -typedef struct { +typedef struct { char *file; /* Name of file containing vars or funcs */ staticAddrList *addrList; /* List of vars and/or funcs. */ int nAddrs; /* # of addrList's */ @@ -2335,11 +2422,13 @@ void getElfAddress(Dwarf_Debug, Dwarf_Die, staticAddrList *); -void set_staticaddrs(void) +void +set_staticaddrs(void) { staticNameList fileList[AFS_N_FILELISTS]; - fileList[0].addrList = (staticAddrList*)calloc(1, sizeof(staticAddrList)); + fileList[0].addrList = + (staticAddrList *) calloc(1, sizeof(staticAddrList)); if (!fileList[0].addrList) { printf("set_staticaddrs: Can't calloc fileList[0].addrList\n"); return; @@ -2352,7 +2441,8 @@ void set_staticaddrs(void) fileList[0].addrList[0].found = 0; #if defined(AFS_SGI62_ENV) && !defined(AFS_SGI65_ENV) - fileList[1].addrList = (staticAddrList*)calloc(2, sizeof(staticAddrList)); + fileList[1].addrList = + (staticAddrList *) calloc(2, sizeof(staticAddrList)); if (!fileList[1].addrList) { printf("set_staticaddrs: Can't malloc fileList[1].addrList\n"); return; @@ -2376,8 +2466,7 @@ void set_staticaddrs(void) if (fileList[0].addrList[0].found) { call_syscall(AFSOP_NFSSTATICADDR2, fileList[0].addrList[0].addr.high, fileList[0].addrList[0].addr.low); - } - else { + } else { if (afsd_verbose) printf("NFS V2 is not present in the kernel.\n"); } @@ -2389,8 +2478,7 @@ void set_staticaddrs(void) fileList[1].addrList[0].addr.low, fileList[1].addrList[1].addr.high, fileList[1].addrList[1].addr.low); - } - else { + } else { if (!fileList[1].addrList[0].found) printf("Can't find %s in kernel. Exiting.\n", fileList[1].addrList[0].name); @@ -2413,7 +2501,7 @@ findDwarfStaticAddresses(staticNameList * nameList, int nLists) int found = 0; int code; char *s; - char *hname = (char*)0; + char *hname = (char *)0; Dwarf_Unsigned dwarf_access = O_RDONLY; Dwarf_Debug dwarf_debug; Dwarf_Error dwarf_error; @@ -2430,12 +2518,12 @@ findDwarfStaticAddresses(staticNameList * nameList, int nLists) return; } - if ((fd=open("/unix", O_RDONLY,0))<0) { + if ((fd = open("/unix", O_RDONLY, 0)) < 0) { printf("findDwarfStaticAddresses: Failed to open /unix.\n"); return; } - code = dwarf_init(fd, dwarf_access, NULL, NULL, &dwarf_debug, - &dwarf_error); + code = + dwarf_init(fd, dwarf_access, NULL, NULL, &dwarf_debug, &dwarf_error); if (code != DW_DLV_OK) { /* Nope hope for the elves and dwarves, try intermediate code. */ close(fd); @@ -2447,16 +2535,13 @@ findDwarfStaticAddresses(staticNameList * nameList, int nLists) /* Run through the headers until we find ones for files we've * specified in nameList. */ - code = dwarf_next_cu_header(dwarf_debug, - &dwarf_cu_header_length, NULL, - &dwarf_abbrev_offset, - &dwarf_address_size, - &next_cu_header, - &dwarf_error); + code = + dwarf_next_cu_header(dwarf_debug, &dwarf_cu_header_length, NULL, + &dwarf_abbrev_offset, &dwarf_address_size, + &next_cu_header, &dwarf_error); if (code == DW_DLV_NO_ENTRY) { break; - } - else if (code == DW_DLV_ERROR) { + } else if (code == DW_DLV_ERROR) { printf("findDwarfStaticAddresses: Error reading headers: %s\n", dwarf_errmsg(dwarf_error)); break; @@ -2473,28 +2558,28 @@ findDwarfStaticAddresses(staticNameList * nameList, int nLists) code = dwarf_diename(dwarf_die, &hname, &dwarf_error); if (code == DW_DLV_OK) { s = strrchr(hname, '/'); - for (i=0; i= nLists) { /* we're done */ + hname = (char *)0; + if (found >= nLists) { /* we're done */ break; } } - /* Frees up all allocated space. */ - (void) dwarf_finish(dwarf_debug, &dwarf_error); + /* Frees up all allocated space. */ + (void)dwarf_finish(dwarf_debug, &dwarf_error); close(fd); } @@ -2507,10 +2592,10 @@ findElfAddresses(Dwarf_Debug dwarf_debug, Dwarf_Die dwarf_die, Dwarf_Die dwarf_next_die; Dwarf_Die dwarf_child_die; Dwarf_Attribute dwarf_return_attr; - char *vname = (char*)0; + char *vname = (char *)0; int found = 0; int code; - + /* Drop into this die to find names in addrList. */ code = dwarf_child(dwarf_die, &dwarf_child_die, &dwarf_error); if (code != DW_DLV_OK) { @@ -2520,18 +2605,17 @@ findElfAddresses(Dwarf_Debug dwarf_debug, Dwarf_Die dwarf_die, } /* Try to find names in each sibling. */ - dwarf_next_die = (Dwarf_Die)0; + dwarf_next_die = (Dwarf_Die) 0; do { - code = dwarf_diename(dwarf_child_die, &vname, - &dwarf_error); + code = dwarf_diename(dwarf_child_die, &vname, &dwarf_error); /* It's possible that some siblings don't have names. */ if (code == DW_DLV_OK) { - for (i=0; inAddrs; i++) { + for (i = 0; i < nameList->nAddrs; i++) { if (!nameList->addrList[i].found) { if (!strcmp(vname, nameList->addrList[i].name)) { getElfAddress(dwarf_debug, dwarf_child_die, - &(nameList->addrList[i])); - found ++; + &(nameList->addrList[i])); + found++; break; } } @@ -2540,22 +2624,22 @@ findElfAddresses(Dwarf_Debug dwarf_debug, Dwarf_Die dwarf_die, if (dwarf_next_die) dwarf_dealloc(dwarf_debug, dwarf_next_die, DW_DLA_DIE); - if (found >= nameList->nAddrs) { /* we're done. */ + if (found >= nameList->nAddrs) { /* we're done. */ break; } dwarf_next_die = dwarf_child_die; - code = dwarf_siblingof(dwarf_debug, dwarf_next_die, - &dwarf_child_die, - &dwarf_error); - - } while(code == DW_DLV_OK); + code = + dwarf_siblingof(dwarf_debug, dwarf_next_die, &dwarf_child_die, + &dwarf_error); + + } while (code == DW_DLV_OK); } /* Get address out of current die. */ void -getElfAddress(Dwarf_Debug dwarf_debug, - Dwarf_Die dwarf_child_die, staticAddrList *addrList) +getElfAddress(Dwarf_Debug dwarf_debug, Dwarf_Die dwarf_child_die, + staticAddrList * addrList) { int i; Dwarf_Error dwarf_error; @@ -2563,19 +2647,21 @@ getElfAddress(Dwarf_Debug dwarf_debug, Dwarf_Bool dwarf_return_bool; Dwarf_Locdesc *llbuf = NULL; Dwarf_Signed listlen; - off64_t addr = (off64_t)0; + off64_t addr = (off64_t) 0; int code; - code = dwarf_hasattr(dwarf_child_die, addrList->type, - &dwarf_return_bool, &dwarf_error); - if ((code != DW_DLV_OK) || (!dwarf_return_bool)) { - printf("getElfAddress: no address given for %s. %s\n", - addrList->name, (code == DW_DLV_ERROR) ? dwarf_errmsg(dwarf_error) : ""); + code = + dwarf_hasattr(dwarf_child_die, addrList->type, &dwarf_return_bool, + &dwarf_error); + if ((code != DW_DLV_OK) || (!dwarf_return_bool)) { + printf("getElfAddress: no address given for %s. %s\n", addrList->name, + (code == DW_DLV_ERROR) ? dwarf_errmsg(dwarf_error) : ""); return; } - code = dwarf_attr(dwarf_child_die, addrList->type, - &dwarf_return_attr, &dwarf_error); - if (code != DW_DLV_OK) { + code = + dwarf_attr(dwarf_child_die, addrList->type, &dwarf_return_attr, + &dwarf_error); + if (code != DW_DLV_OK) { printf("getElfAddress: Can't get attribute. %s\n", (code == DW_DLV_ERROR) ? dwarf_errmsg(dwarf_error) : ""); return; @@ -2583,9 +2669,9 @@ getElfAddress(Dwarf_Debug dwarf_debug, switch (addrList->type) { case DW_AT_location: - code = dwarf_loclist(dwarf_return_attr, &llbuf, - &listlen, &dwarf_error); - if (code != DW_DLV_OK) { + code = + dwarf_loclist(dwarf_return_attr, &llbuf, &listlen, &dwarf_error); + if (code != DW_DLV_OK) { printf("getElfAddress: Can't get location for %s. %s\n", addrList->name, (code == DW_DLV_ERROR) ? dwarf_errmsg(dwarf_error) : ""); @@ -2600,22 +2686,23 @@ getElfAddress(Dwarf_Debug dwarf_debug, break; case DW_AT_low_pc: - code = dwarf_lowpc(dwarf_child_die, (Dwarf_Addr*)&addr, &dwarf_error); - if ( code != DW_DLV_OK) { + code = + dwarf_lowpc(dwarf_child_die, (Dwarf_Addr *) & addr, &dwarf_error); + if (code != DW_DLV_OK) { printf("getElfAddress: Can't get lowpc for %s. %s\n", addrList->name, (code == DW_DLV_ERROR) ? dwarf_errmsg(dwarf_error) : ""); return; } break; - + default: printf("getElfAddress: Bad case %d in switch.\n", addrList->type); return; } - addrList->addr.high = (addr>>32) & 0xffffffff; - addrList->addr.low = addr & 0xffffffff; + addrList->addr.high = (addr >> 32) & 0xffffffff; + addrList->addr.low = addr & 0xffffffff; addrList->found = 1; } @@ -2631,12 +2718,13 @@ getElfAddress(Dwarf_Debug dwarf_debug, * If found, sets the found bit and the address and returns 1. * Not found returns 0. */ -int SearchNameList(char *name, afs_uint32 addr, staticNameList *nameList, - int nLists) +int +SearchNameList(char *name, afs_uint32 addr, staticNameList * nameList, + int nLists) { - int i, j; - for (i=0; id_buf); + long *buf = (long *)(elf_getdata(scnp, NULL)->d_buf); u_long addr, mdoff = shdrp->sh_offset; HDRR *hdrp; SYMR *symbase, *symp, *symend; @@ -2663,39 +2751,37 @@ SearchMDebug(Elf_Scn *scnp, Elf32_Shdr *shdrp, staticNameList * nameList, char *strbase, *str; int ifd; int nFound = 0; - + /* get header */ - addr = (__psunsigned_t)buf; - hdrp = (HDRR *)addr; - + addr = (__psunsigned_t) buf; + hdrp = (HDRR *) addr; + /* setup base addresses */ - addr = (u_long)buf + (u_long)(hdrp->cbFdOffset - mdoff); - fdrbase = (FDR *)addr; - addr = (u_long)buf + (u_long)(hdrp->cbSymOffset - mdoff); - symbase = (SYMR *)addr; - addr = (u_long)buf + (u_long)(hdrp->cbSsOffset - mdoff); + addr = (u_long) buf + (u_long) (hdrp->cbFdOffset - mdoff); + fdrbase = (FDR *) addr; + addr = (u_long) buf + (u_long) (hdrp->cbSymOffset - mdoff); + symbase = (SYMR *) addr; + addr = (u_long) buf + (u_long) (hdrp->cbSsOffset - mdoff); strbase = (char *)addr; - + #define KEEPER(a,b) ((a == stStaticProc && b == scText) || \ (a == stStatic && (b == scData || b == scBss || \ b == scSBss || b == scSData))) - + for (fdrp = fdrbase; fdrp < &fdrbase[hdrp->ifdMax]; fdrp++) { str = strbase + fdrp->issBase + fdrp->rss; - + /* local symbols for each fd */ for (symp = &symbase[fdrp->isymBase]; - symp < &symbase[fdrp->isymBase+fdrp->csym]; - symp++) { + symp < &symbase[fdrp->isymBase + fdrp->csym]; symp++) { if (KEEPER(symp->st, symp->sc)) { if (symp->value == 0) continue; - + str = strbase + fdrp->issBase + symp->iss; /* Look for AFS symbols of interest */ - if (SearchNameList(str, symp->value, - nameList, nLists)) { - nFound ++; + if (SearchNameList(str, symp->value, nameList, nLists)) { + nFound++; if (nFound >= needed) return; } @@ -2703,37 +2789,38 @@ SearchMDebug(Elf_Scn *scnp, Elf32_Shdr *shdrp, staticNameList * nameList, } } } - + /* * returns section with the name of scn_name, & puts its header in shdr64 or * shdr32 based on elf's file type * */ Elf_Scn * -findMDebugSection(Elf *elf, char *scn_name) +findMDebugSection(Elf * elf, char *scn_name) { - Elf64_Ehdr *ehdr64; - Elf32_Ehdr *ehdr32; - Elf_Scn *scn = NULL; - Elf64_Shdr *shdr64; - Elf32_Shdr *shdr32; - - if ((ehdr32 = elf32_getehdr(elf)) == NULL) - return(NULL); - do { - if ((scn = elf_nextscn(elf, scn)) == NULL) - break; - if ((shdr32 = elf32_getshdr(scn)) == NULL) - return(NULL); - } while (strcmp(scn_name, elf_strptr(elf, ehdr32->e_shstrndx, - shdr32->sh_name))); + Elf64_Ehdr *ehdr64; + Elf32_Ehdr *ehdr32; + Elf_Scn *scn = NULL; + Elf64_Shdr *shdr64; + Elf32_Shdr *shdr32; + + if ((ehdr32 = elf32_getehdr(elf)) == NULL) + return (NULL); + do { + if ((scn = elf_nextscn(elf, scn)) == NULL) + break; + if ((shdr32 = elf32_getshdr(scn)) == NULL) + return (NULL); + } while (strcmp + (scn_name, + elf_strptr(elf, ehdr32->e_shstrndx, shdr32->sh_name))); - return(scn); + return (scn); } -void findMDebugStaticAddresses(staticNameList * nameList, int nLists, - int needed) +void +findMDebugStaticAddresses(staticNameList * nameList, int nLists, int needed) { int fd; Elf *elf; @@ -2747,8 +2834,9 @@ void findMDebugStaticAddresses(staticNameList * nameList, int nLists, } (void)elf_version(EV_CURRENT); - if((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) { - printf("findMDebugStaticAddresses: /unix doesn't seem to be an elf file\n"); + if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) { + printf + ("findMDebugStaticAddresses: /unix doesn't seem to be an elf file\n"); close(fd); return; } @@ -2763,9 +2851,9 @@ void findMDebugStaticAddresses(staticNameList * nameList, int nLists, goto find_end; } - (void) SearchMDebug(mdebug_scn, mdebug_shdr, nameList, nLists, needed); + (void)SearchMDebug(mdebug_scn, mdebug_shdr, nameList, nLists, needed); - find_end: + find_end: elf_end(elf); close(fd); } @@ -2773,30 +2861,31 @@ void findMDebugStaticAddresses(staticNameList * nameList, int nLists, #else /* AFS_SGI61_ENV */ #include -struct nlist nlunix[] = { - { "rfsdisptab_v2" }, - { 0 }, +struct nlist nlunix[] = { + {"rfsdisptab_v2"}, + {0}, }; -get_nfsstaticaddr() { +get_nfsstaticaddr() +{ int i, j, kmem, count; if ((kmem = open("/dev/kmem", O_RDONLY)) < 0) { printf("Warning: can't open /dev/kmem\n"); - return 0; + return 0; } if ((j = nlist("/unix", nlunix)) < 0) { printf("Warning: can't nlist /unix\n"); return 0; } i = nlunix[0].n_value; - if (lseek(kmem, i, L_SET/*0*/) != i) { - printf("Warning: can't lseek to %x\n", i); - return 0; + if (lseek(kmem, i, L_SET /*0 */ ) != i) { + printf("Warning: can't lseek to %x\n", i); + return 0; } if ((j = read(kmem, &count, sizeof count)) != sizeof count) { printf("WARNING: kmem read at %x failed\n", i); - return 0; + return 0; } return i; } diff --git a/src/afsd/vsys.c b/src/afsd/vsys.c index 791b85ce8..424eb1b3c 100644 --- a/src/afsd/vsys.c +++ b/src/afsd/vsys.c @@ -23,41 +23,47 @@ #include #endif -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include "AFS_component_version_number.c" -main (argc, argv) - int argc; - char **argv; { +main(argc, argv) + int argc; + char **argv; +{ afs_int32 code; int i, counter; afs_int32 parms[6]; int numberFlag; - if (argc < 2) {printf("use: vsys \n"); exit(1); } + if (argc < 2) { + printf("use: vsys \n"); + exit(1); + } numberFlag = 1; counter = 0; - for(i=1;i #endif #endif - -RCSID("$Header$"); -#include +RCSID + ("$Header$"); + +#include #include @@ -42,8 +43,8 @@ extern char errMsg[256]; /* error message buffer */ extern int afsmon_Exit(); /* exit routine */ -static FILE *fs_outFD; /* fs output file descriptor */ -static FILE *cm_outFD; /* cm output file descriptor */ +static FILE *fs_outFD; /* fs output file descriptor */ +static FILE *cm_outFD; /* cm output file descriptor */ /* structures used by FS & CM stats print routines */ @@ -116,98 +117,127 @@ static char *xferOpNames[] = { * As advertised. *------------------------------------------------------------------------*/ -void Print_fs_OverallPerfInfo(a_ovP) - struct afs_PerfStats *a_ovP; +void +Print_fs_OverallPerfInfo(a_ovP) + struct afs_PerfStats *a_ovP; -{ /*Print_fs_OverallPerfInfo*/ +{ /*Print_fs_OverallPerfInfo */ - fprintf(fs_outFD,"\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls); + fprintf(fs_outFD, "\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls); /* * Vnode cache section. */ - fprintf(fs_outFD,"\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries); - fprintf(fs_outFD,"\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs); - fprintf(fs_outFD,"\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets); - fprintf(fs_outFD,"\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads); - fprintf(fs_outFD,"\t%10d vcache_L_Writes\n\n",a_ovP->vcache_L_Writes); - - fprintf(fs_outFD,"\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries); - fprintf(fs_outFD,"\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs); - fprintf(fs_outFD,"\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets); - fprintf(fs_outFD,"\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads); - fprintf(fs_outFD,"\t%10d vcache_S_Writes\n\n",a_ovP->vcache_S_Writes); - - fprintf(fs_outFD,"\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries); - fprintf(fs_outFD,"\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets); - fprintf(fs_outFD,"\t%10d vcache_H_Replacements\n\n",a_ovP->vcache_H_Replacements); + fprintf(fs_outFD, "\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries); + fprintf(fs_outFD, "\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs); + fprintf(fs_outFD, "\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets); + fprintf(fs_outFD, "\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads); + fprintf(fs_outFD, "\t%10d vcache_L_Writes\n\n", a_ovP->vcache_L_Writes); + + fprintf(fs_outFD, "\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries); + fprintf(fs_outFD, "\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs); + fprintf(fs_outFD, "\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets); + fprintf(fs_outFD, "\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads); + fprintf(fs_outFD, "\t%10d vcache_S_Writes\n\n", a_ovP->vcache_S_Writes); + + fprintf(fs_outFD, "\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries); + fprintf(fs_outFD, "\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets); + fprintf(fs_outFD, "\t%10d vcache_H_Replacements\n\n", + a_ovP->vcache_H_Replacements); /* * Directory package section. */ - fprintf(fs_outFD,"\t%10d dir_Buffers\n", a_ovP->dir_Buffers); - fprintf(fs_outFD,"\t%10d dir_Calls\n", a_ovP->dir_Calls); - fprintf(fs_outFD,"\t%10d dir_IOs\n\n", a_ovP->dir_IOs); + fprintf(fs_outFD, "\t%10d dir_Buffers\n", a_ovP->dir_Buffers); + fprintf(fs_outFD, "\t%10d dir_Calls\n", a_ovP->dir_Calls); + fprintf(fs_outFD, "\t%10d dir_IOs\n\n", a_ovP->dir_IOs); /* * Rx section. */ - fprintf(fs_outFD,"\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests); - fprintf(fs_outFD,"\t%10d rx_noPackets_RcvClass\n", a_ovP->rx_noPackets_RcvClass); - fprintf(fs_outFD,"\t%10d rx_noPackets_SendClass\n", a_ovP->rx_noPackets_SendClass); - fprintf(fs_outFD,"\t%10d rx_noPackets_SpecialClass\n", a_ovP->rx_noPackets_SpecialClass); - fprintf(fs_outFD,"\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy); - fprintf(fs_outFD,"\t%10d rx_bogusPacketOnRead\n", a_ovP->rx_bogusPacketOnRead); - fprintf(fs_outFD,"\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost); - fprintf(fs_outFD,"\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead); - fprintf(fs_outFD,"\t%10d rx_noPacketBuffersOnRead\n", a_ovP->rx_noPacketBuffersOnRead); - fprintf(fs_outFD,"\t%10d rx_selects\n", a_ovP->rx_selects); - fprintf(fs_outFD,"\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects); - fprintf(fs_outFD,"\t%10d rx_packetsRead_RcvClass\n", a_ovP->rx_packetsRead_RcvClass); - fprintf(fs_outFD,"\t%10d rx_packetsRead_SendClass\n", a_ovP->rx_packetsRead_SendClass); - fprintf(fs_outFD,"\t%10d rx_packetsRead_SpecialClass\n", a_ovP->rx_packetsRead_SpecialClass); - fprintf(fs_outFD,"\t%10d rx_dataPacketsRead\n", a_ovP->rx_dataPacketsRead); - fprintf(fs_outFD,"\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead); - fprintf(fs_outFD,"\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead); - fprintf(fs_outFD,"\t%10d rx_spuriousPacketsRead\n", a_ovP->rx_spuriousPacketsRead); - fprintf(fs_outFD,"\t%10d rx_packetsSent_RcvClass\n", a_ovP->rx_packetsSent_RcvClass); - fprintf(fs_outFD,"\t%10d rx_packetsSent_SendClass\n", a_ovP->rx_packetsSent_SendClass); - fprintf(fs_outFD,"\t%10d rx_packetsSent_SpecialClass\n", a_ovP->rx_packetsSent_SpecialClass); - fprintf(fs_outFD,"\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent); - fprintf(fs_outFD,"\t%10d rx_pingPacketsSent\n", a_ovP->rx_pingPacketsSent); - fprintf(fs_outFD,"\t%10d rx_abortPacketsSent\n",a_ovP->rx_abortPacketsSent); - fprintf(fs_outFD,"\t%10d rx_busyPacketsSent\n", a_ovP->rx_busyPacketsSent); - fprintf(fs_outFD,"\t%10d rx_dataPacketsSent\n", a_ovP->rx_dataPacketsSent); - fprintf(fs_outFD,"\t%10d rx_dataPacketsReSent\n", a_ovP->rx_dataPacketsReSent); - fprintf(fs_outFD,"\t%10d rx_dataPacketsPushed\n", a_ovP->rx_dataPacketsPushed); - fprintf(fs_outFD,"\t%10d rx_ignoreAckedPacket\n", a_ovP->rx_ignoreAckedPacket); - fprintf(fs_outFD,"\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec); - fprintf(fs_outFD,"\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec); - fprintf(fs_outFD,"\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec); - fprintf(fs_outFD,"\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec); - fprintf(fs_outFD,"\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec); - fprintf(fs_outFD,"\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec); - fprintf(fs_outFD,"\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples); - fprintf(fs_outFD,"\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns); - fprintf(fs_outFD,"\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns); - fprintf(fs_outFD,"\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs); - fprintf(fs_outFD,"\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs); - fprintf(fs_outFD,"\t%10d rx_nFreeCallStructs\n\n", a_ovP->rx_nFreeCallStructs); + fprintf(fs_outFD, "\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests); + fprintf(fs_outFD, "\t%10d rx_noPackets_RcvClass\n", + a_ovP->rx_noPackets_RcvClass); + fprintf(fs_outFD, "\t%10d rx_noPackets_SendClass\n", + a_ovP->rx_noPackets_SendClass); + fprintf(fs_outFD, "\t%10d rx_noPackets_SpecialClass\n", + a_ovP->rx_noPackets_SpecialClass); + fprintf(fs_outFD, "\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy); + fprintf(fs_outFD, "\t%10d rx_bogusPacketOnRead\n", + a_ovP->rx_bogusPacketOnRead); + fprintf(fs_outFD, "\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost); + fprintf(fs_outFD, "\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead); + fprintf(fs_outFD, "\t%10d rx_noPacketBuffersOnRead\n", + a_ovP->rx_noPacketBuffersOnRead); + fprintf(fs_outFD, "\t%10d rx_selects\n", a_ovP->rx_selects); + fprintf(fs_outFD, "\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects); + fprintf(fs_outFD, "\t%10d rx_packetsRead_RcvClass\n", + a_ovP->rx_packetsRead_RcvClass); + fprintf(fs_outFD, "\t%10d rx_packetsRead_SendClass\n", + a_ovP->rx_packetsRead_SendClass); + fprintf(fs_outFD, "\t%10d rx_packetsRead_SpecialClass\n", + a_ovP->rx_packetsRead_SpecialClass); + fprintf(fs_outFD, "\t%10d rx_dataPacketsRead\n", + a_ovP->rx_dataPacketsRead); + fprintf(fs_outFD, "\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead); + fprintf(fs_outFD, "\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead); + fprintf(fs_outFD, "\t%10d rx_spuriousPacketsRead\n", + a_ovP->rx_spuriousPacketsRead); + fprintf(fs_outFD, "\t%10d rx_packetsSent_RcvClass\n", + a_ovP->rx_packetsSent_RcvClass); + fprintf(fs_outFD, "\t%10d rx_packetsSent_SendClass\n", + a_ovP->rx_packetsSent_SendClass); + fprintf(fs_outFD, "\t%10d rx_packetsSent_SpecialClass\n", + a_ovP->rx_packetsSent_SpecialClass); + fprintf(fs_outFD, "\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent); + fprintf(fs_outFD, "\t%10d rx_pingPacketsSent\n", + a_ovP->rx_pingPacketsSent); + fprintf(fs_outFD, "\t%10d rx_abortPacketsSent\n", + a_ovP->rx_abortPacketsSent); + fprintf(fs_outFD, "\t%10d rx_busyPacketsSent\n", + a_ovP->rx_busyPacketsSent); + fprintf(fs_outFD, "\t%10d rx_dataPacketsSent\n", + a_ovP->rx_dataPacketsSent); + fprintf(fs_outFD, "\t%10d rx_dataPacketsReSent\n", + a_ovP->rx_dataPacketsReSent); + fprintf(fs_outFD, "\t%10d rx_dataPacketsPushed\n", + a_ovP->rx_dataPacketsPushed); + fprintf(fs_outFD, "\t%10d rx_ignoreAckedPacket\n", + a_ovP->rx_ignoreAckedPacket); + fprintf(fs_outFD, "\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec); + fprintf(fs_outFD, "\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec); + fprintf(fs_outFD, "\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec); + fprintf(fs_outFD, "\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec); + fprintf(fs_outFD, "\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec); + fprintf(fs_outFD, "\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec); + fprintf(fs_outFD, "\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples); + fprintf(fs_outFD, "\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns); + fprintf(fs_outFD, "\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns); + fprintf(fs_outFD, "\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs); + fprintf(fs_outFD, "\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs); + fprintf(fs_outFD, "\t%10d rx_nFreeCallStructs\n\n", + a_ovP->rx_nFreeCallStructs); /* * Host module fields. */ - fprintf(fs_outFD,"\t%10d host_NumHostEntries\n", a_ovP->host_NumHostEntries); - fprintf(fs_outFD,"\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks); - fprintf(fs_outFD,"\t%10d host_NonDeletedHosts\n", a_ovP->host_NonDeletedHosts); - fprintf(fs_outFD,"\t%10d host_HostsInSameNetOrSubnet\n", a_ovP->host_HostsInSameNetOrSubnet); - fprintf(fs_outFD,"\t%10d host_HostsInDiffSubnet\n", a_ovP->host_HostsInDiffSubnet); - fprintf(fs_outFD,"\t%10d host_HostsInDiffNetwork\n",a_ovP->host_HostsInDiffNetwork); - fprintf(fs_outFD,"\t%10d host_NumClients\n", a_ovP->host_NumClients); - fprintf(fs_outFD,"\t%10d host_ClientBlocks\n\n", a_ovP->host_ClientBlocks); - -} /*Print_fs_OverallPerfInfo*/ + fprintf(fs_outFD, "\t%10d host_NumHostEntries\n", + a_ovP->host_NumHostEntries); + fprintf(fs_outFD, "\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks); + fprintf(fs_outFD, "\t%10d host_NonDeletedHosts\n", + a_ovP->host_NonDeletedHosts); + fprintf(fs_outFD, "\t%10d host_HostsInSameNetOrSubnet\n", + a_ovP->host_HostsInSameNetOrSubnet); + fprintf(fs_outFD, "\t%10d host_HostsInDiffSubnet\n", + a_ovP->host_HostsInDiffSubnet); + fprintf(fs_outFD, "\t%10d host_HostsInDiffNetwork\n", + a_ovP->host_HostsInDiffNetwork); + fprintf(fs_outFD, "\t%10d host_NumClients\n", a_ovP->host_NumClients); + fprintf(fs_outFD, "\t%10d host_ClientBlocks\n\n", + a_ovP->host_ClientBlocks); + +} /*Print_fs_OverallPerfInfo */ /*------------------------------------------------------------------------ @@ -230,20 +260,21 @@ void Print_fs_OverallPerfInfo(a_ovP) * As advertised. *------------------------------------------------------------------------*/ -void Print_fs_OpTiming(a_opIdx, a_opTimeP) - int a_opIdx; - struct fs_stats_opTimingData *a_opTimeP; +void +Print_fs_OpTiming(a_opIdx, a_opTimeP) + int a_opIdx; + struct fs_stats_opTimingData *a_opTimeP; -{ /*Print_fs_OpTiming*/ +{ /*Print_fs_OpTiming */ - fprintf(fs_outFD,"%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", - fsOpNames[a_opIdx], - a_opTimeP->numOps, a_opTimeP->numSuccesses, - a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec, - a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec, - a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec); + fprintf(fs_outFD, + "%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", + fsOpNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses, + a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec, + a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec, + a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec); -} /*Print_fs_OpTiming*/ +} /*Print_fs_OpTiming */ /*------------------------------------------------------------------------ @@ -266,32 +297,28 @@ void Print_fs_OpTiming(a_opIdx, a_opTimeP) * As advertised. *------------------------------------------------------------------------*/ -void Print_fs_XferTiming(a_opIdx, a_xferP) - int a_opIdx; - struct fs_stats_xferData *a_xferP; - -{ /*Print_fs_XferTiming*/ - - fprintf(fs_outFD,"%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", - xferOpNames[a_opIdx], - a_xferP->numXfers, a_xferP->numSuccesses, - a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec, - a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec, - a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec); - fprintf(fs_outFD,"\t[bytes: sum=%d, min=%d, max=%d]\n", - a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes); - fprintf(fs_outFD,"\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n", - a_xferP->count[0], - a_xferP->count[1], - a_xferP->count[2], - a_xferP->count[3], - a_xferP->count[4], - a_xferP->count[5], - a_xferP->count[6], - a_xferP->count[7], - a_xferP->count[8]); - -} /*Print_fs_XferTiming*/ +void +Print_fs_XferTiming(a_opIdx, a_xferP) + int a_opIdx; + struct fs_stats_xferData *a_xferP; + +{ /*Print_fs_XferTiming */ + + fprintf(fs_outFD, + "%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", + xferOpNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses, + a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec, + a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec, + a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec); + fprintf(fs_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n", + a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes); + fprintf(fs_outFD, + "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n", + a_xferP->count[0], a_xferP->count[1], a_xferP->count[2], + a_xferP->count[3], a_xferP->count[4], a_xferP->count[5], + a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]); + +} /*Print_fs_XferTiming */ /*------------------------------------------------------------------------ @@ -313,14 +340,15 @@ void Print_fs_XferTiming(a_opIdx, a_xferP) * As advertised. *------------------------------------------------------------------------*/ -void Print_fs_DetailedPerfInfo(a_detP) - struct fs_stats_DetailedStats *a_detP; +void +Print_fs_DetailedPerfInfo(a_detP) + struct fs_stats_DetailedStats *a_detP; -{ /*Print_fs_DetailedPerfInfo*/ +{ /*Print_fs_DetailedPerfInfo */ - int currIdx; /*Loop variable*/ + int currIdx; /*Loop variable */ - fprintf(fs_outFD,"\t%10d epoch\n", a_detP->epoch); + fprintf(fs_outFD, "\t%10d epoch\n", a_detP->epoch); for (currIdx = 0; currIdx < FS_STATS_NUM_RPC_OPS; currIdx++) Print_fs_OpTiming(currIdx, &(a_detP->rpcOpTimes[currIdx])); @@ -328,7 +356,7 @@ void Print_fs_DetailedPerfInfo(a_detP) for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++) Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx])); -} /*Print_fs_DetailedPerfInfo*/ +} /*Print_fs_DetailedPerfInfo */ /*------------------------------------------------------------------------ @@ -351,40 +379,41 @@ void Print_fs_DetailedPerfInfo(a_detP) * As advertised. *------------------------------------------------------------------------*/ -void Print_fs_FullPerfInfo(a_fs_Results) -struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */ -{ /*Print_fs_FullPerfInfo*/ +void +Print_fs_FullPerfInfo(a_fs_Results) + struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */ +{ /*Print_fs_FullPerfInfo */ - static char rn[] = "Print_fs_FullPerfInfo"; /*Routine name*/ - static afs_int32 fullPerfLongs = - (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv*/ - afs_int32 numLongs; /*# longwords received*/ - struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats*/ - char *printableTime; /*Ptr to printable time string*/ + static char rn[] = "Print_fs_FullPerfInfo"; /*Routine name */ + static afs_int32 fullPerfLongs = (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv */ + afs_int32 numLongs; /*# longwords received */ + struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats */ + char *printableTime; /*Ptr to printable time string */ numLongs = a_fs_Results->data.AFS_CollData_len; if (numLongs != fullPerfLongs) { - fprintf(fs_outFD," ** Data size mismatch in full performance collection!\n"); - fprintf(fs_outFD," ** Expecting %d, got %d\n", fullPerfLongs, numLongs); + fprintf(fs_outFD, + " ** Data size mismatch in full performance collection!\n"); + fprintf(fs_outFD, " ** Expecting %d, got %d\n", fullPerfLongs, + numLongs); return; } - printableTime = ctime((time_t *)&(a_fs_Results->probeTime)); - printableTime[strlen(printableTime)-1] = '\0'; + printableTime = ctime((time_t *) & (a_fs_Results->probeTime)); + printableTime[strlen(printableTime) - 1] = '\0'; fullPerfP = (struct fs_stats_FullPerfStats *) (a_fs_Results->data.AFS_CollData_val); - fprintf(fs_outFD,"AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n", - a_fs_Results->collectionNumber, - a_fs_Results->connP->hostName, - a_fs_Results->probeNum, - printableTime); + fprintf(fs_outFD, + "AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n", + a_fs_Results->collectionNumber, a_fs_Results->connP->hostName, + a_fs_Results->probeNum, printableTime); Print_fs_OverallPerfInfo(&(fullPerfP->overall)); Print_fs_DetailedPerfInfo(&(fullPerfP->det)); -} /*Print_fs_FullPerfInfo*/ +} /*Print_fs_FullPerfInfo */ /*------------------------------------------------------------------------ @@ -409,69 +438,70 @@ struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */ * As advertised. *------------------------------------------------------------------------*/ int -afsmon_fsOutput(a_outfile, a_detOutput) -char *a_outfile; /* ptr to output file name */ -int a_detOutput; /* detailed output ? */ +afsmon_fsOutput(a_outfile, a_detOutput) + char *a_outfile; /* ptr to output file name */ + int a_detOutput; /* detailed output ? */ { - static char rn[] = "afsmon_fsOutput"; /* routine name */ - char *printTime; /* ptr to time string */ - char *hostname; /* fileserner name */ - afs_int32 numLongs; /* longwords in result */ - afs_int32 *currLong; /* ptr to longwords in result */ - int i; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_outfile= %s, a_detOutput= %d\n", + static char rn[] = "afsmon_fsOutput"; /* routine name */ + char *printTime; /* ptr to time string */ + char *hostname; /* fileserner name */ + afs_int32 numLongs; /* longwords in result */ + afs_int32 *currLong; /* ptr to longwords in result */ + int i; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n", rn, a_outfile, a_detOutput); fflush(debugFD); - } + } - fs_outFD = fopen(a_outfile,"a"); - if (fs_outFD == (FILE *)0) { - sprintf(errMsg,"[ %s ] failed to open output file %s",rn,a_outfile); + fs_outFD = fopen(a_outfile, "a"); + if (fs_outFD == (FILE *) 0) { + sprintf(errMsg, "[ %s ] failed to open output file %s", rn, + a_outfile); afsmon_Exit(1); - } - - /* get the probe time and strip the \n at the end */ - printTime = ctime((time_t *)&(xstat_fs_Results.probeTime)); - printTime[strlen(printTime) - 1] = '\0'; - hostname = xstat_fs_Results.connP->hostName; - - /* print "time hostname FS" */ - fprintf(fs_outFD,"\n%s %s FS ",printTime,hostname); - - /* if probe failed print -1 and return */ - if (xstat_fs_Results.probeOK) { - fprintf(fs_outFD,"-1\n"); + } + + /* get the probe time and strip the \n at the end */ + printTime = ctime((time_t *) & (xstat_fs_Results.probeTime)); + printTime[strlen(printTime) - 1] = '\0'; + hostname = xstat_fs_Results.connP->hostName; + + /* print "time hostname FS" */ + fprintf(fs_outFD, "\n%s %s FS ", printTime, hostname); + + /* if probe failed print -1 and return */ + if (xstat_fs_Results.probeOK) { + fprintf(fs_outFD, "-1\n"); fclose(fs_outFD); - return(0); - } + return (0); + } - /* print out the probe information as long words */ - numLongs = xstat_fs_Results.data.AFS_CollData_len; - currLong = (afs_int32 *)(xstat_fs_Results.data.AFS_CollData_val); + /* print out the probe information as long words */ + numLongs = xstat_fs_Results.data.AFS_CollData_len; + currLong = (afs_int32 *) (xstat_fs_Results.data.AFS_CollData_val); - for(i=0; inumTtlRecords); - fprintf(cm_outFD,"\t\t%10d numUpRecords\n", a_upDownP->numUpRecords); - fprintf(cm_outFD,"\t\t%10d numDownRecords\n", a_upDownP->numDownRecords); - fprintf(cm_outFD,"\t\t%10d sumOfRecordAges\n", a_upDownP->sumOfRecordAges); - fprintf(cm_outFD,"\t\t%10d ageOfYoungestRecord\n", a_upDownP->ageOfYoungestRecord); - fprintf(cm_outFD,"\t\t%10d ageOfOldestRecord\n", a_upDownP->ageOfOldestRecord); - fprintf(cm_outFD,"\t\t%10d numDowntimeIncidents\n", a_upDownP->numDowntimeIncidents); - fprintf(cm_outFD,"\t\t%10d numRecordsNeverDown\n", a_upDownP->numRecordsNeverDown); - fprintf(cm_outFD,"\t\t%10d maxDowntimesInARecord\n", a_upDownP->maxDowntimesInARecord); - fprintf(cm_outFD,"\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes); - fprintf(cm_outFD,"\t\t%10d shortestDowntime\n", a_upDownP->shortestDowntime); - fprintf(cm_outFD,"\t\t%10d longestDowntime\n", a_upDownP->longestDowntime); + fprintf(cm_outFD, "\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords); + fprintf(cm_outFD, "\t\t%10d numUpRecords\n", a_upDownP->numUpRecords); + fprintf(cm_outFD, "\t\t%10d numDownRecords\n", a_upDownP->numDownRecords); + fprintf(cm_outFD, "\t\t%10d sumOfRecordAges\n", + a_upDownP->sumOfRecordAges); + fprintf(cm_outFD, "\t\t%10d ageOfYoungestRecord\n", + a_upDownP->ageOfYoungestRecord); + fprintf(cm_outFD, "\t\t%10d ageOfOldestRecord\n", + a_upDownP->ageOfOldestRecord); + fprintf(cm_outFD, "\t\t%10d numDowntimeIncidents\n", + a_upDownP->numDowntimeIncidents); + fprintf(cm_outFD, "\t\t%10d numRecordsNeverDown\n", + a_upDownP->numRecordsNeverDown); + fprintf(cm_outFD, "\t\t%10d maxDowntimesInARecord\n", + a_upDownP->maxDowntimesInARecord); + fprintf(cm_outFD, "\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes); + fprintf(cm_outFD, "\t\t%10d shortestDowntime\n", + a_upDownP->shortestDowntime); + fprintf(cm_outFD, "\t\t%10d longestDowntime\n", + a_upDownP->longestDowntime); /* * Now, print the array values. */ - fprintf(cm_outFD,"\t\tDowntime duration distribution:\n"); - fprintf(cm_outFD,"\t\t\t%8d: 0 min .. 10 min\n", a_upDownP->downDurations[0]); - fprintf(cm_outFD,"\t\t\t%8d: 10 min .. 30 min\n", a_upDownP->downDurations[1]); - fprintf(cm_outFD,"\t\t\t%8d: 30 min .. 1 hr\n", a_upDownP->downDurations[2]); - fprintf(cm_outFD,"\t\t\t%8d: 1 hr .. 2 hr\n", a_upDownP->downDurations[3]); - fprintf(cm_outFD,"\t\t\t%8d: 2 hr .. 4 hr\n", a_upDownP->downDurations[4]); - fprintf(cm_outFD,"\t\t\t%8d: 4 hr .. 8 hr\n", a_upDownP->downDurations[5]); - fprintf(cm_outFD,"\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]); - - fprintf(cm_outFD,"\t\tDowntime incident distribution:\n"); - fprintf(cm_outFD,"\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]); - fprintf(cm_outFD,"\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]); - fprintf(cm_outFD,"\t\t\t%8d: 2 .. 5 times\n", a_upDownP->downIncidents[2]); - fprintf(cm_outFD,"\t\t\t%8d: 6 .. 10 times\n", a_upDownP->downIncidents[3]); - fprintf(cm_outFD,"\t\t\t%8d: 10 .. 50 times\n", a_upDownP->downIncidents[4]); - fprintf(cm_outFD,"\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]); - -} /*Print_cm_UpDownStats*/ + fprintf(cm_outFD, "\t\tDowntime duration distribution:\n"); + fprintf(cm_outFD, "\t\t\t%8d: 0 min .. 10 min\n", + a_upDownP->downDurations[0]); + fprintf(cm_outFD, "\t\t\t%8d: 10 min .. 30 min\n", + a_upDownP->downDurations[1]); + fprintf(cm_outFD, "\t\t\t%8d: 30 min .. 1 hr\n", + a_upDownP->downDurations[2]); + fprintf(cm_outFD, "\t\t\t%8d: 1 hr .. 2 hr\n", + a_upDownP->downDurations[3]); + fprintf(cm_outFD, "\t\t\t%8d: 2 hr .. 4 hr\n", + a_upDownP->downDurations[4]); + fprintf(cm_outFD, "\t\t\t%8d: 4 hr .. 8 hr\n", + a_upDownP->downDurations[5]); + fprintf(cm_outFD, "\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]); + + fprintf(cm_outFD, "\t\tDowntime incident distribution:\n"); + fprintf(cm_outFD, "\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]); + fprintf(cm_outFD, "\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]); + fprintf(cm_outFD, "\t\t\t%8d: 2 .. 5 times\n", + a_upDownP->downIncidents[2]); + fprintf(cm_outFD, "\t\t\t%8d: 6 .. 10 times\n", + a_upDownP->downIncidents[3]); + fprintf(cm_outFD, "\t\t\t%8d: 10 .. 50 times\n", + a_upDownP->downIncidents[4]); + fprintf(cm_outFD, "\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]); + +} /*Print_cm_UpDownStats */ /*------------------------------------------------------------------------ @@ -561,68 +609,75 @@ void Print_cm_UpDownStats(a_upDownP) * As advertised. *------------------------------------------------------------------------*/ -void Print_cm_OverallPerfInfo(a_ovP) - struct afs_stats_CMPerf *a_ovP; - -{ /*Print_cm_OverallPerfInfo*/ - - fprintf(cm_outFD,"\t%10d numPerfCalls\n", a_ovP->numPerfCalls); - - fprintf(cm_outFD,"\t%10d epoch\n", a_ovP->epoch); - fprintf(cm_outFD,"\t%10d numCellsVisible\n", a_ovP->numCellsVisible); - fprintf(cm_outFD,"\t%10d numCellsContacted\n", a_ovP->numCellsContacted); - fprintf(cm_outFD,"\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses); - fprintf(cm_outFD,"\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses); - fprintf(cm_outFD,"\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses); - fprintf(cm_outFD,"\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses); - fprintf(cm_outFD,"\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries); - fprintf(cm_outFD,"\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal); - fprintf(cm_outFD,"\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse); - fprintf(cm_outFD,"\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig); - fprintf(cm_outFD,"\t%10d cacheMaxDirtyChunks\n",a_ovP->cacheMaxDirtyChunks); - fprintf(cm_outFD,"\t%10d cacheCurrDirtyChunks\n", a_ovP->cacheCurrDirtyChunks); - fprintf(cm_outFD,"\t%10d dcacheHits\n", a_ovP->dcacheHits); - fprintf(cm_outFD,"\t%10d vcacheHits\n", a_ovP->vcacheHits); - fprintf(cm_outFD,"\t%10d dcacheMisses\n", a_ovP->dcacheMisses); - fprintf(cm_outFD,"\t%10d vcacheMisses\n", a_ovP->vcacheMisses); - fprintf(cm_outFD,"\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused); - fprintf(cm_outFD,"\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs); - - fprintf(cm_outFD,"\t%10d bufAlloced\n", a_ovP->bufAlloced); - fprintf(cm_outFD,"\t%10d bufHits\n", a_ovP->bufHits); - fprintf(cm_outFD,"\t%10d bufMisses\n", a_ovP->bufMisses); - fprintf(cm_outFD,"\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty); - - fprintf(cm_outFD,"\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive); - fprintf(cm_outFD,"\t%10d LargeBlocksAlloced\n", a_ovP->LargeBlocksAlloced); - fprintf(cm_outFD,"\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive); - fprintf(cm_outFD,"\t%10d SmallBlocksAlloced\n", a_ovP->SmallBlocksAlloced); - fprintf(cm_outFD,"\t%10d OutStandingMemUsage\n", a_ovP->OutStandingMemUsage); - fprintf(cm_outFD,"\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs); - fprintf(cm_outFD,"\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced); - fprintf(cm_outFD,"\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes); - - fprintf(cm_outFD,"\t%10d srvRecords\n", a_ovP->srvRecords); - fprintf(cm_outFD,"\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets); - fprintf(cm_outFD,"\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength); - fprintf(cm_outFD,"\t%10d srvMaxChainLengthHWM\n", a_ovP->srvMaxChainLengthHWM); - fprintf(cm_outFD,"\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM); - - fprintf(cm_outFD,"\t%10d sysName_ID\n", a_ovP->sysName_ID); - - fprintf(cm_outFD,"\tFile Server up/downtimes, same cell:\n"); +void +Print_cm_OverallPerfInfo(a_ovP) + struct afs_stats_CMPerf *a_ovP; + +{ /*Print_cm_OverallPerfInfo */ + + fprintf(cm_outFD, "\t%10d numPerfCalls\n", a_ovP->numPerfCalls); + + fprintf(cm_outFD, "\t%10d epoch\n", a_ovP->epoch); + fprintf(cm_outFD, "\t%10d numCellsVisible\n", a_ovP->numCellsVisible); + fprintf(cm_outFD, "\t%10d numCellsContacted\n", a_ovP->numCellsContacted); + fprintf(cm_outFD, "\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses); + fprintf(cm_outFD, "\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses); + fprintf(cm_outFD, "\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses); + fprintf(cm_outFD, "\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses); + fprintf(cm_outFD, "\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries); + fprintf(cm_outFD, "\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal); + fprintf(cm_outFD, "\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse); + fprintf(cm_outFD, "\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig); + fprintf(cm_outFD, "\t%10d cacheMaxDirtyChunks\n", + a_ovP->cacheMaxDirtyChunks); + fprintf(cm_outFD, "\t%10d cacheCurrDirtyChunks\n", + a_ovP->cacheCurrDirtyChunks); + fprintf(cm_outFD, "\t%10d dcacheHits\n", a_ovP->dcacheHits); + fprintf(cm_outFD, "\t%10d vcacheHits\n", a_ovP->vcacheHits); + fprintf(cm_outFD, "\t%10d dcacheMisses\n", a_ovP->dcacheMisses); + fprintf(cm_outFD, "\t%10d vcacheMisses\n", a_ovP->vcacheMisses); + fprintf(cm_outFD, "\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused); + fprintf(cm_outFD, "\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs); + + fprintf(cm_outFD, "\t%10d bufAlloced\n", a_ovP->bufAlloced); + fprintf(cm_outFD, "\t%10d bufHits\n", a_ovP->bufHits); + fprintf(cm_outFD, "\t%10d bufMisses\n", a_ovP->bufMisses); + fprintf(cm_outFD, "\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty); + + fprintf(cm_outFD, "\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive); + fprintf(cm_outFD, "\t%10d LargeBlocksAlloced\n", + a_ovP->LargeBlocksAlloced); + fprintf(cm_outFD, "\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive); + fprintf(cm_outFD, "\t%10d SmallBlocksAlloced\n", + a_ovP->SmallBlocksAlloced); + fprintf(cm_outFD, "\t%10d OutStandingMemUsage\n", + a_ovP->OutStandingMemUsage); + fprintf(cm_outFD, "\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs); + fprintf(cm_outFD, "\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced); + fprintf(cm_outFD, "\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes); + + fprintf(cm_outFD, "\t%10d srvRecords\n", a_ovP->srvRecords); + fprintf(cm_outFD, "\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets); + fprintf(cm_outFD, "\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength); + fprintf(cm_outFD, "\t%10d srvMaxChainLengthHWM\n", + a_ovP->srvMaxChainLengthHWM); + fprintf(cm_outFD, "\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM); + + fprintf(cm_outFD, "\t%10d sysName_ID\n", a_ovP->sysName_ID); + + fprintf(cm_outFD, "\tFile Server up/downtimes, same cell:\n"); Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0])); - fprintf(cm_outFD,"\tFile Server up/downtimes, diff cell:\n"); + fprintf(cm_outFD, "\tFile Server up/downtimes, diff cell:\n"); Print_cm_UpDownStats(&(a_ovP->fs_UpDown[1])); - fprintf(cm_outFD,"\tVL Server up/downtimes, same cell:\n"); + fprintf(cm_outFD, "\tVL Server up/downtimes, same cell:\n"); Print_cm_UpDownStats(&(a_ovP->vl_UpDown[0])); - fprintf(cm_outFD,"\tVL Server up/downtimes, diff cell:\n"); + fprintf(cm_outFD, "\tVL Server up/downtimes, diff cell:\n"); Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1])); -} /*Print_cm_OverallPerfInfo*/ +} /*Print_cm_OverallPerfInfo */ /*------------------------------------------------------------------------ @@ -645,38 +700,38 @@ void Print_cm_OverallPerfInfo(a_ovP) * As advertised. *------------------------------------------------------------------------*/ -void Print_cm_PerfInfo() +void +Print_cm_PerfInfo() +{ /*Print_cm_PerfInfo */ -{ /*Print_cm_PerfInfo*/ - - static char rn[] = "Print_cm_PerfInfo"; /*Routine name*/ - static afs_int32 perfLongs = - (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv*/ - afs_int32 numLongs; /*# longwords received*/ - struct afs_stats_CMPerf *perfP; /*Ptr to performance stats*/ - char *printableTime; /*Ptr to printable time string*/ + static char rn[] = "Print_cm_PerfInfo"; /*Routine name */ + static afs_int32 perfLongs = (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # longs to rcv */ + afs_int32 numLongs; /*# longwords received */ + struct afs_stats_CMPerf *perfP; /*Ptr to performance stats */ + char *printableTime; /*Ptr to printable time string */ numLongs = xstat_cm_Results.data.AFSCB_CollData_len; if (numLongs != perfLongs) { - fprintf(cm_outFD," ** Data size mismatch in performance collection!\n"); - fprintf(cm_outFD,"** Expecting %d, got %d\n", perfLongs, numLongs); + fprintf(cm_outFD, + " ** Data size mismatch in performance collection!\n"); + fprintf(cm_outFD, "** Expecting %d, got %d\n", perfLongs, numLongs); return; } - printableTime = ctime((time_t *)&(xstat_cm_Results.probeTime)); - printableTime[strlen(printableTime)-1] = '\0'; + printableTime = ctime((time_t *) & (xstat_cm_Results.probeTime)); + printableTime[strlen(printableTime) - 1] = '\0'; perfP = (struct afs_stats_CMPerf *) (xstat_cm_Results.data.AFSCB_CollData_val); - fprintf(cm_outFD,"AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n", - xstat_cm_Results.collectionNumber, - xstat_cm_Results.connP->hostName, - xstat_cm_Results.probeNum, - printableTime); + fprintf(cm_outFD, + "AFSCB_XSTATSCOLL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n", + xstat_cm_Results.collectionNumber, + xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum, + printableTime); Print_cm_OverallPerfInfo(perfP); -} /*Print_cm_PerfInfo*/ +} /*Print_cm_PerfInfo */ /*------------------------------------------------------------------------ @@ -700,21 +755,22 @@ void Print_cm_PerfInfo() * As advertised. *------------------------------------------------------------------------*/ -void Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP) - int a_opIdx; - char *a_opNames[]; - struct afs_stats_opTimingData *a_opTimeP; +void +Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP) + int a_opIdx; + char *a_opNames[]; + struct afs_stats_opTimingData *a_opTimeP; -{ /*Print_cm_OpTiming*/ +{ /*Print_cm_OpTiming */ - fprintf(cm_outFD,"%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", - a_opNames[a_opIdx], - a_opTimeP->numOps, a_opTimeP->numSuccesses, - a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec, - a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec, - a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec); + fprintf(cm_outFD, + "%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", + a_opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses, + a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec, + a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec, + a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec); -} /*Print_cm_OpTiming*/ +} /*Print_cm_OpTiming */ /*------------------------------------------------------------------------ @@ -737,33 +793,29 @@ void Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP) * As advertised. *------------------------------------------------------------------------*/ -void Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP) - int a_opIdx; - char *a_opNames[]; - struct afs_stats_xferData *a_xferP; - -{ /*Print_cm_XferTiming*/ - - fprintf(cm_outFD,"%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", - a_opNames[a_opIdx], - a_xferP->numXfers, a_xferP->numSuccesses, - a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec, - a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec, - a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec); - fprintf(cm_outFD,"\t[bytes: sum=%d, min=%d, max=%d]\n", - a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes); - fprintf(cm_outFD,"\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n", - a_xferP->count[0], - a_xferP->count[1], - a_xferP->count[2], - a_xferP->count[3], - a_xferP->count[4], - a_xferP->count[5], - a_xferP->count[6], - a_xferP->count[7], - a_xferP->count[8]); - -} /*Print_cm_XferTiming*/ +void +Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP) + int a_opIdx; + char *a_opNames[]; + struct afs_stats_xferData *a_xferP; + +{ /*Print_cm_XferTiming */ + + fprintf(cm_outFD, + "%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", + a_opNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses, + a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec, + a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec, + a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec); + fprintf(cm_outFD, "\t[bytes: sum=%d, min=%d, max=%d]\n", + a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes); + fprintf(cm_outFD, + "\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d, 7: %d, 8: %d]\n", + a_xferP->count[0], a_xferP->count[1], a_xferP->count[2], + a_xferP->count[3], a_xferP->count[4], a_xferP->count[5], + a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]); + +} /*Print_cm_XferTiming */ /*------------------------------------------------------------------------ @@ -787,23 +839,21 @@ void Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP) * As advertised. *------------------------------------------------------------------------*/ -void Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP) - int a_opIdx; - char *a_opNames[]; - struct afs_stats_RPCErrors *a_opErrP; +void +Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP) + int a_opIdx; + char *a_opNames[]; + struct afs_stats_RPCErrors *a_opErrP; -{ /*Print_cm_ErrInfo*/ +{ /*Print_cm_ErrInfo */ - fprintf(cm_outFD,"%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n", - a_opNames[a_opIdx], - a_opErrP->err_Server, - a_opErrP->err_Network, - a_opErrP->err_Protection, - a_opErrP->err_Volume, - a_opErrP->err_VolumeBusies, - a_opErrP->err_Other); + fprintf(cm_outFD, + "%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n", + a_opNames[a_opIdx], a_opErrP->err_Server, a_opErrP->err_Network, + a_opErrP->err_Protection, a_opErrP->err_Volume, + a_opErrP->err_VolumeBusies, a_opErrP->err_Other); -} /*Print_cm_ErrInfo*/ +} /*Print_cm_ErrInfo */ /*------------------------------------------------------------------------ @@ -825,33 +875,35 @@ void Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP) * As advertised. *------------------------------------------------------------------------*/ -void Print_cm_RPCPerfInfo(a_rpcP) - struct afs_stats_RPCOpInfo *a_rpcP; +void +Print_cm_RPCPerfInfo(a_rpcP) + struct afs_stats_RPCOpInfo *a_rpcP; -{ /*Print_cm_RPCPerfInfo*/ +{ /*Print_cm_RPCPerfInfo */ - int currIdx; /*Loop variable*/ + int currIdx; /*Loop variable */ /* * Print the contents of each of the opcode-related arrays. */ - fprintf(cm_outFD,"FS Operation Timings:\n---------------------\n"); + fprintf(cm_outFD, "FS Operation Timings:\n---------------------\n"); for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++) Print_cm_OpTiming(currIdx, fsOpNames, &(a_rpcP->fsRPCTimes[currIdx])); - fprintf(cm_outFD,"\nError Info:\n-----------\n"); + fprintf(cm_outFD, "\nError Info:\n-----------\n"); for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_RPC_OPS; currIdx++) Print_cm_ErrInfo(currIdx, fsOpNames, &(a_rpcP->fsRPCErrors[currIdx])); - fprintf(cm_outFD,"\nTransfer timings:\n-----------------\n"); + fprintf(cm_outFD, "\nTransfer timings:\n-----------------\n"); for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++) - Print_cm_XferTiming(currIdx, xferOpNames, &(a_rpcP->fsXferTimes[currIdx])); + Print_cm_XferTiming(currIdx, xferOpNames, + &(a_rpcP->fsXferTimes[currIdx])); - fprintf(cm_outFD,"\nCM Operation Timings:\n---------------------\n"); + fprintf(cm_outFD, "\nCM Operation Timings:\n---------------------\n"); for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++) Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx])); -} /*Print_cm_RPCPerfInfo*/ +} /*Print_cm_RPCPerfInfo */ /*------------------------------------------------------------------------ @@ -873,78 +925,76 @@ void Print_cm_RPCPerfInfo(a_rpcP) * As advertised. *------------------------------------------------------------------------*/ -void Print_cm_FullPerfInfo() - -{ /*Print_cm_FullPerfInfo*/ +void +Print_cm_FullPerfInfo() +{ /*Print_cm_FullPerfInfo */ - static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */ - struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats*/ - struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats*/ - static afs_int32 fullPerfLongs = - (sizeof (struct afs_stats_CMFullPerf) >> 2); /*Correct #longs*/ - afs_int32 numLongs; /*# longs actually received*/ - struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info*/ + static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */ + struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats */ + struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats */ + static afs_int32 fullPerfLongs = (sizeof(struct afs_stats_CMFullPerf) >> 2); /*Correct #longs */ + afs_int32 numLongs; /*# longs actually received */ + struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info */ - char *printableTime; /*Ptr to printable time string*/ + char *printableTime; /*Ptr to printable time string */ numLongs = xstat_cm_Results.data.AFSCB_CollData_len; if (numLongs != fullPerfLongs) { - fprintf(cm_outFD," ** Data size mismatch in performance collection!\n"); - fprintf(cm_outFD," ** Expecting %d, got %d\n",fullPerfLongs, numLongs); + fprintf(cm_outFD, + " ** Data size mismatch in performance collection!\n"); + fprintf(cm_outFD, " ** Expecting %d, got %d\n", fullPerfLongs, + numLongs); return; } - printableTime = ctime((time_t *)&(xstat_cm_Results.probeTime)); - printableTime[strlen(printableTime)-1] = '\0'; + printableTime = ctime((time_t *) & (xstat_cm_Results.probeTime)); + printableTime[strlen(printableTime) - 1] = '\0'; fullP = (struct afs_stats_CMFullPerf *) (xstat_cm_Results.data.AFSCB_CollData_val); - fprintf(cm_outFD,"AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n", - xstat_cm_Results.collectionNumber, - xstat_cm_Results.connP->hostName, - xstat_cm_Results.probeNum, - printableTime); + fprintf(cm_outFD, + "AFSCB_XSTATSCOLL_FULL_PERF_INFO (coll %d) for CM %s\n[Probe %d, %s]\n\n", + xstat_cm_Results.collectionNumber, + xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum, + printableTime); /* * Print the overall numbers first, followed by all of the RPC numbers, * then each of the other groupings. */ - fprintf(cm_outFD,"Overall Performance Info:\n-------------------------\n"); + fprintf(cm_outFD, + "Overall Performance Info:\n-------------------------\n"); Print_cm_OverallPerfInfo(&(fullP->perf)); - fprintf(cm_outFD,"\n"); + fprintf(cm_outFD, "\n"); Print_cm_RPCPerfInfo(&(fullP->rpc)); authentP = &(fullP->authent); - fprintf(cm_outFD,"\nAuthentication info:\n--------------------\n"); - fprintf(cm_outFD,"\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n", - authentP->curr_PAGs, - authentP->curr_Records, - authentP->curr_AuthRecords, - authentP->curr_UnauthRecords, - authentP->curr_MaxRecordsInPAG, - authentP->curr_LongestChain); - fprintf(cm_outFD,"\t%d PAG creations, %d tkt updates\n", - authentP->PAGCreations, - authentP->TicketUpdates); - fprintf(cm_outFD,"\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n", - authentP->HWM_PAGs, - authentP->HWM_Records, - authentP->HWM_MaxRecordsInPAG, - authentP->HWM_LongestChain); + fprintf(cm_outFD, "\nAuthentication info:\n--------------------\n"); + fprintf(cm_outFD, + "\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n", + authentP->curr_PAGs, authentP->curr_Records, + authentP->curr_AuthRecords, authentP->curr_UnauthRecords, + authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain); + fprintf(cm_outFD, "\t%d PAG creations, %d tkt updates\n", + authentP->PAGCreations, authentP->TicketUpdates); + fprintf(cm_outFD, + "\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n", + authentP->HWM_PAGs, authentP->HWM_Records, + authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain); accessinfP = &(fullP->accessinf); - fprintf(cm_outFD,"\n[Un]replicated accesses:\n------------------------\n"); - fprintf(cm_outFD,"\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n", - accessinfP->unreplicatedRefs, - accessinfP->replicatedRefs, - accessinfP->numReplicasAccessed, - accessinfP->maxReplicasPerRef, - accessinfP->refFirstReplicaOK); + fprintf(cm_outFD, + "\n[Un]replicated accesses:\n------------------------\n"); + fprintf(cm_outFD, + "\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n", + accessinfP->unreplicatedRefs, accessinfP->replicatedRefs, + accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef, + accessinfP->refFirstReplicaOK); /* There really isn't any authorship info - authorP = &(fullP->author); */ + * authorP = &(fullP->author); */ -} /*Print_cm_FullPerfInfo*/ +} /*Print_cm_FullPerfInfo */ /*------------------------------------------------------------------------ * afsmon_cmOutput() @@ -968,66 +1018,67 @@ void Print_cm_FullPerfInfo() * As advertised. *------------------------------------------------------------------------*/ int -afsmon_cmOutput(a_outfile, a_detOutput) -char *a_outfile; /* ptr to output file name */ -int a_detOutput; /* detailed output ? */ +afsmon_cmOutput(a_outfile, a_detOutput) + char *a_outfile; /* ptr to output file name */ + int a_detOutput; /* detailed output ? */ { - static char rn[] = "afsmon_cmOutput"; /* routine name */ - char *printTime; /* ptr to time string */ - char *hostname; /* fileserner name */ - afs_int32 numLongs; /* longwords in result */ - afs_int32 *currLong; /* ptr to longwords in result */ - int i; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_outfile= %s, a_detOutput= %d\n", + static char rn[] = "afsmon_cmOutput"; /* routine name */ + char *printTime; /* ptr to time string */ + char *hostname; /* fileserner name */ + afs_int32 numLongs; /* longwords in result */ + afs_int32 *currLong; /* ptr to longwords in result */ + int i; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_outfile= %s, a_detOutput= %d\n", rn, a_outfile, a_detOutput); fflush(debugFD); - } + } - /* need to lock this file before writing */ - cm_outFD = fopen(a_outfile,"a"); - if (cm_outFD == (FILE *)0) { - sprintf(errMsg,"[ %s ] failed to open output file %s",rn,a_outfile); + /* need to lock this file before writing */ + cm_outFD = fopen(a_outfile, "a"); + if (cm_outFD == (FILE *) 0) { + sprintf(errMsg, "[ %s ] failed to open output file %s", rn, + a_outfile); afsmon_Exit(1); - } - - /* get the probe time and strip the \n at the end */ - printTime = ctime((time_t *)&(xstat_cm_Results.probeTime)); - printTime[strlen(printTime) - 1] = '\0'; - hostname = xstat_cm_Results.connP->hostName; - - /* print "time hostname CM" prefix */ - fprintf(cm_outFD,"\n%s %s CM ",printTime,hostname); - - /* if probe failed print -1 and vanish */ - if (xstat_cm_Results.probeOK) { - fprintf(cm_outFD,"-1\n"); + } + + /* get the probe time and strip the \n at the end */ + printTime = ctime((time_t *) & (xstat_cm_Results.probeTime)); + printTime[strlen(printTime) - 1] = '\0'; + hostname = xstat_cm_Results.connP->hostName; + + /* print "time hostname CM" prefix */ + fprintf(cm_outFD, "\n%s %s CM ", printTime, hostname); + + /* if probe failed print -1 and vanish */ + if (xstat_cm_Results.probeOK) { + fprintf(cm_outFD, "-1\n"); fclose(cm_outFD); - return(0); - } + return (0); + } - /* print out the probe information as long words */ - numLongs = xstat_cm_Results.data.AFSCB_CollData_len; - currLong = (afs_int32 *)(xstat_cm_Results.data.AFSCB_CollData_val); + /* print out the probe information as long words */ + numLongs = xstat_cm_Results.data.AFSCB_CollData_len; + currLong = (afs_int32 *) (xstat_cm_Results.data.AFSCB_CollData_val); - for(i=0; i #include -RCSID("$Header$"); +RCSID + ("$Header$"); -#include +#include #include #include @@ -98,10 +99,11 @@ static char *xferOpNames[] = { * *------------------------------------------------------------------------*/ -void Print_fs_OverallPerfInfo(a_ovP) - struct afs_PerfStats *a_ovP; +void +Print_fs_OverallPerfInfo(a_ovP) + struct afs_PerfStats *a_ovP; -{ /*Print_fs_OverallPerfInfo*/ +{ /*Print_fs_OverallPerfInfo */ printf("\t%10d numPerfCalls\n\n", a_ovP->numPerfCalls); @@ -110,20 +112,20 @@ void Print_fs_OverallPerfInfo(a_ovP) * Vnode cache section. */ printf("\t%10d vcache_L_Entries\n", a_ovP->vcache_L_Entries); - printf("\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs); - printf("\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets); - printf("\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads); - printf("\t%10d vcache_L_Writes\n\n",a_ovP->vcache_L_Writes); + printf("\t%10d vcache_L_Allocs\n", a_ovP->vcache_L_Allocs); + printf("\t%10d vcache_L_Gets\n", a_ovP->vcache_L_Gets); + printf("\t%10d vcache_L_Reads\n", a_ovP->vcache_L_Reads); + printf("\t%10d vcache_L_Writes\n\n", a_ovP->vcache_L_Writes); printf("\t%10d vcache_S_Entries\n", a_ovP->vcache_S_Entries); - printf("\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs); - printf("\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets); - printf("\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads); - printf("\t%10d vcache_S_Writes\n\n",a_ovP->vcache_S_Writes); + printf("\t%10d vcache_S_Allocs\n", a_ovP->vcache_S_Allocs); + printf("\t%10d vcache_S_Gets\n", a_ovP->vcache_S_Gets); + printf("\t%10d vcache_S_Reads\n", a_ovP->vcache_S_Reads); + printf("\t%10d vcache_S_Writes\n\n", a_ovP->vcache_S_Writes); printf("\t%10d vcache_H_Entries\n", a_ovP->vcache_H_Entries); - printf("\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets); - printf("\t%10d vcache_H_Replacements\n\n",a_ovP->vcache_H_Replacements); + printf("\t%10d vcache_H_Gets\n", a_ovP->vcache_H_Gets); + printf("\t%10d vcache_H_Replacements\n\n", a_ovP->vcache_H_Replacements); /* * Directory package section. @@ -137,59 +139,69 @@ void Print_fs_OverallPerfInfo(a_ovP) */ printf("\t%10d rx_packetRequests\n", a_ovP->rx_packetRequests); printf("\t%10d rx_noPackets_RcvClass\n", a_ovP->rx_noPackets_RcvClass); - printf("\t%10d rx_noPackets_SendClass\n", a_ovP->rx_noPackets_SendClass); - printf("\t%10d rx_noPackets_SpecialClass\n", a_ovP->rx_noPackets_SpecialClass); + printf("\t%10d rx_noPackets_SendClass\n", a_ovP->rx_noPackets_SendClass); + printf("\t%10d rx_noPackets_SpecialClass\n", + a_ovP->rx_noPackets_SpecialClass); printf("\t%10d rx_socketGreedy\n", a_ovP->rx_socketGreedy); printf("\t%10d rx_bogusPacketOnRead\n", a_ovP->rx_bogusPacketOnRead); - printf("\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost); + printf("\t%10d rx_bogusHost\n", a_ovP->rx_bogusHost); printf("\t%10d rx_noPacketOnRead\n", a_ovP->rx_noPacketOnRead); - printf("\t%10d rx_noPacketBuffersOnRead\n", a_ovP->rx_noPacketBuffersOnRead); + printf("\t%10d rx_noPacketBuffersOnRead\n", + a_ovP->rx_noPacketBuffersOnRead); printf("\t%10d rx_selects\n", a_ovP->rx_selects); - printf("\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects); - printf("\t%10d rx_packetsRead_RcvClass\n", a_ovP->rx_packetsRead_RcvClass); - printf("\t%10d rx_packetsRead_SendClass\n", a_ovP->rx_packetsRead_SendClass); - printf("\t%10d rx_packetsRead_SpecialClass\n", a_ovP->rx_packetsRead_SpecialClass); + printf("\t%10d rx_sendSelects\n", a_ovP->rx_sendSelects); + printf("\t%10d rx_packetsRead_RcvClass\n", + a_ovP->rx_packetsRead_RcvClass); + printf("\t%10d rx_packetsRead_SendClass\n", + a_ovP->rx_packetsRead_SendClass); + printf("\t%10d rx_packetsRead_SpecialClass\n", + a_ovP->rx_packetsRead_SpecialClass); printf("\t%10d rx_dataPacketsRead\n", a_ovP->rx_dataPacketsRead); printf("\t%10d rx_ackPacketsRead\n", a_ovP->rx_ackPacketsRead); printf("\t%10d rx_dupPacketsRead\n", a_ovP->rx_dupPacketsRead); - printf("\t%10d rx_spuriousPacketsRead\n", a_ovP->rx_spuriousPacketsRead); - printf("\t%10d rx_packetsSent_RcvClass\n", a_ovP->rx_packetsSent_RcvClass); - printf("\t%10d rx_packetsSent_SendClass\n", a_ovP->rx_packetsSent_SendClass); - printf("\t%10d rx_packetsSent_SpecialClass\n", a_ovP->rx_packetsSent_SpecialClass); + printf("\t%10d rx_spuriousPacketsRead\n", a_ovP->rx_spuriousPacketsRead); + printf("\t%10d rx_packetsSent_RcvClass\n", + a_ovP->rx_packetsSent_RcvClass); + printf("\t%10d rx_packetsSent_SendClass\n", + a_ovP->rx_packetsSent_SendClass); + printf("\t%10d rx_packetsSent_SpecialClass\n", + a_ovP->rx_packetsSent_SpecialClass); printf("\t%10d rx_ackPacketsSent\n", a_ovP->rx_ackPacketsSent); printf("\t%10d rx_pingPacketsSent\n", a_ovP->rx_pingPacketsSent); - printf("\t%10d rx_abortPacketsSent\n",a_ovP->rx_abortPacketsSent); + printf("\t%10d rx_abortPacketsSent\n", a_ovP->rx_abortPacketsSent); printf("\t%10d rx_busyPacketsSent\n", a_ovP->rx_busyPacketsSent); printf("\t%10d rx_dataPacketsSent\n", a_ovP->rx_dataPacketsSent); printf("\t%10d rx_dataPacketsReSent\n", a_ovP->rx_dataPacketsReSent); - printf("\t%10d rx_dataPacketsPushed\n", a_ovP->rx_dataPacketsPushed); - printf("\t%10d rx_ignoreAckedPacket\n", a_ovP->rx_ignoreAckedPacket); + printf("\t%10d rx_dataPacketsPushed\n", a_ovP->rx_dataPacketsPushed); + printf("\t%10d rx_ignoreAckedPacket\n", a_ovP->rx_ignoreAckedPacket); printf("\t%10d rx_totalRtt_Sec\n", a_ovP->rx_totalRtt_Sec); printf("\t%10d rx_totalRtt_Usec\n", a_ovP->rx_totalRtt_Usec); - printf("\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec); - printf("\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec); - printf("\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec); - printf("\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec); - printf("\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples); - printf("\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns); - printf("\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns); - printf("\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs); - printf("\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs); - printf("\t%10d rx_nFreeCallStructs\n\n", a_ovP->rx_nFreeCallStructs); + printf("\t%10d rx_minRtt_Sec\n", a_ovP->rx_minRtt_Sec); + printf("\t%10d rx_minRtt_Usec\n", a_ovP->rx_minRtt_Usec); + printf("\t%10d rx_maxRtt_Sec\n", a_ovP->rx_maxRtt_Sec); + printf("\t%10d rx_maxRtt_Usec\n", a_ovP->rx_maxRtt_Usec); + printf("\t%10d rx_nRttSamples\n", a_ovP->rx_nRttSamples); + printf("\t%10d rx_nServerConns\n", a_ovP->rx_nServerConns); + printf("\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns); + printf("\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs); + printf("\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs); + printf("\t%10d rx_nFreeCallStructs\n\n", a_ovP->rx_nFreeCallStructs); /* * Host module fields. */ - printf("\t%10d host_NumHostEntries\n", a_ovP->host_NumHostEntries); - printf("\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks); - printf("\t%10d host_NonDeletedHosts\n", a_ovP->host_NonDeletedHosts); - printf("\t%10d host_HostsInSameNetOrSubnet\n", a_ovP->host_HostsInSameNetOrSubnet); - printf("\t%10d host_HostsInDiffSubnet\n", a_ovP->host_HostsInDiffSubnet); - printf("\t%10d host_HostsInDiffNetwork\n",a_ovP->host_HostsInDiffNetwork); - printf("\t%10d host_NumClients\n", a_ovP->host_NumClients); - printf("\t%10d host_ClientBlocks\n\n", a_ovP->host_ClientBlocks); + printf("\t%10d host_NumHostEntries\n", a_ovP->host_NumHostEntries); + printf("\t%10d host_HostBlocks\n", a_ovP->host_HostBlocks); + printf("\t%10d host_NonDeletedHosts\n", a_ovP->host_NonDeletedHosts); + printf("\t%10d host_HostsInSameNetOrSubnet\n", + a_ovP->host_HostsInSameNetOrSubnet); + printf("\t%10d host_HostsInDiffSubnet\n", a_ovP->host_HostsInDiffSubnet); + printf("\t%10d host_HostsInDiffNetwork\n", + a_ovP->host_HostsInDiffNetwork); + printf("\t%10d host_NumClients\n", a_ovP->host_NumClients); + printf("\t%10d host_ClientBlocks\n\n", a_ovP->host_ClientBlocks); -} /*Print_fs_OverallPerfInfo*/ +} /*Print_fs_OverallPerfInfo */ /*------------------------------------------------------------------------ @@ -204,20 +216,20 @@ void Print_fs_OverallPerfInfo(a_ovP) * *------------------------------------------------------------------------*/ -void Print_fs_OpTiming(a_opIdx, a_opTimeP) - int a_opIdx; - struct fs_stats_opTimingData *a_opTimeP; +void +Print_fs_OpTiming(a_opIdx, a_opTimeP) + int a_opIdx; + struct fs_stats_opTimingData *a_opTimeP; -{ /*Print_fs_OpTiming*/ +{ /*Print_fs_OpTiming */ printf("%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", - fsOpNames[a_opIdx], - a_opTimeP->numOps, a_opTimeP->numSuccesses, + fsOpNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses, a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec, a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec, a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec); -} /*Print_fs_OpTiming*/ +} /*Print_fs_OpTiming */ /*------------------------------------------------------------------------ @@ -232,32 +244,28 @@ void Print_fs_OpTiming(a_opIdx, a_opTimeP) * *------------------------------------------------------------------------*/ -void Print_fs_XferTiming(a_opIdx, a_xferP) - int a_opIdx; - struct fs_stats_xferData *a_xferP; - -{ /*Print_fs_XferTiming*/ - - printf("%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", - xferOpNames[a_opIdx], - a_xferP->numXfers, a_xferP->numSuccesses, - a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec, - a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec, - a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec); - printf("\t[bytes: sum=%d, min=%d, max=%d]\n", - a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes); - printf("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d 7:%d 8:%d]\n", - a_xferP->count[0], - a_xferP->count[1], - a_xferP->count[2], - a_xferP->count[3], - a_xferP->count[4], - a_xferP->count[5], - a_xferP->count[6], - a_xferP->count[7], - a_xferP->count[8]); - -} /*Print_fs_XferTiming*/ +void +Print_fs_XferTiming(a_opIdx, a_xferP) + int a_opIdx; + struct fs_stats_xferData *a_xferP; + +{ /*Print_fs_XferTiming */ + + printf + ("%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", + xferOpNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses, + a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec, + a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec, + a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec); + printf("\t[bytes: sum=%d, min=%d, max=%d]\n", a_xferP->sumBytes, + a_xferP->minBytes, a_xferP->maxBytes); + printf + ("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d 6: %d 7:%d 8:%d]\n", + a_xferP->count[0], a_xferP->count[1], a_xferP->count[2], + a_xferP->count[3], a_xferP->count[4], a_xferP->count[5], + a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]); + +} /*Print_fs_XferTiming */ /*------------------------------------------------------------------------ @@ -271,12 +279,13 @@ void Print_fs_XferTiming(a_opIdx, a_xferP) * *------------------------------------------------------------------------*/ -void Print_fs_DetailedPerfInfo(a_detP) - struct fs_stats_DetailedStats *a_detP; +void +Print_fs_DetailedPerfInfo(a_detP) + struct fs_stats_DetailedStats *a_detP; -{ /*Print_fs_DetailedPerfInfo*/ +{ /*Print_fs_DetailedPerfInfo */ - int currIdx; /*Loop variable*/ + int currIdx; /*Loop variable */ printf("\t%10d epoch\n", a_detP->epoch); @@ -286,7 +295,7 @@ void Print_fs_DetailedPerfInfo(a_detP) for (currIdx = 0; currIdx < FS_STATS_NUM_XFER_OPS; currIdx++) Print_fs_XferTiming(currIdx, &(a_detP->xferOpTimes[currIdx])); -} /*Print_fs_DetailedPerfInfo*/ +} /*Print_fs_DetailedPerfInfo */ /*------------------------------------------------------------------------ @@ -301,16 +310,16 @@ void Print_fs_DetailedPerfInfo(a_detP) * *------------------------------------------------------------------------*/ -void Print_fs_FullPerfInfo(a_fs_Results) -struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */ -{ /*Print_fs_FullPerfInfo*/ +void +Print_fs_FullPerfInfo(a_fs_Results) + struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */ +{ /*Print_fs_FullPerfInfo */ - static char rn[] = "Print_fs_FullPerfInfo"; /*Routine name*/ - static long fullPerfLongs = - (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv*/ - long numLongs; /*# longwords received*/ - struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats*/ - char *printableTime; /*Ptr to printable time string*/ + static char rn[] = "Print_fs_FullPerfInfo"; /*Routine name */ + static long fullPerfLongs = (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # longs to rcv */ + long numLongs; /*# longwords received */ + struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats */ + char *printableTime; /*Ptr to printable time string */ numLongs = a_fs_Results->data.AFS_CollData_len; @@ -321,23 +330,22 @@ struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */ } printableTime = ctime(&(a_fs_Results->probeTime)); - printableTime[strlen(printableTime)-1] = '\0'; + printableTime[strlen(printableTime) - 1] = '\0'; fullPerfP = (struct fs_stats_FullPerfStats *) (a_fs_Results->data.AFS_CollData_val); - printf("AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n", - a_fs_Results->collectionNumber, - a_fs_Results->connP->hostName, - a_fs_Results->probeNum, - printableTime); + printf + ("AFS_XSTATSCOLL_FULL_PERF_INFO (coll %d) for FS %s\n[Probe %d, %s]\n\n", + a_fs_Results->collectionNumber, a_fs_Results->connP->hostName, + a_fs_Results->probeNum, printableTime); Print_fs_OverallPerfInfo(&(fullPerfP->overall)); Print_fs_DetailedPerfInfo(&(fullPerfP->det)); -} /*Print_fs_FullPerfInfo*/ +} /*Print_fs_FullPerfInfo */ + - /*___________________________________________________________________________ CM STATS *__________________________________________________________________________*/ @@ -356,48 +364,51 @@ struct xstat_fs_ProbeResults *a_fs_Results; /* ptr to fs results */ * *------------------------------------------------------------------------*/ -void Print_cm_UpDownStats(a_upDownP) - struct afs_stats_SrvUpDownInfo *a_upDownP; /*Ptr to server up/down info*/ +void +Print_cm_UpDownStats(a_upDownP) + struct afs_stats_SrvUpDownInfo *a_upDownP; /*Ptr to server up/down info */ -{ /*Print_cm_UpDownStats*/ +{ /*Print_cm_UpDownStats */ /* * First, print the simple values. */ - printf("\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords); - printf("\t\t%10d numUpRecords\n", a_upDownP->numUpRecords); - printf("\t\t%10d numDownRecords\n", a_upDownP->numDownRecords); - printf("\t\t%10d sumOfRecordAges\n", a_upDownP->sumOfRecordAges); - printf("\t\t%10d ageOfYoungestRecord\n", a_upDownP->ageOfYoungestRecord); - printf("\t\t%10d ageOfOldestRecord\n", a_upDownP->ageOfOldestRecord); - printf("\t\t%10d numDowntimeIncidents\n", a_upDownP->numDowntimeIncidents); - printf("\t\t%10d numRecordsNeverDown\n", a_upDownP->numRecordsNeverDown); - printf("\t\t%10d maxDowntimesInARecord\n", a_upDownP->maxDowntimesInARecord); - printf("\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes); - printf("\t\t%10d shortestDowntime\n", a_upDownP->shortestDowntime); - printf("\t\t%10d longestDowntime\n", a_upDownP->longestDowntime); + printf("\t\t%10d numTtlRecords\n", a_upDownP->numTtlRecords); + printf("\t\t%10d numUpRecords\n", a_upDownP->numUpRecords); + printf("\t\t%10d numDownRecords\n", a_upDownP->numDownRecords); + printf("\t\t%10d sumOfRecordAges\n", a_upDownP->sumOfRecordAges); + printf("\t\t%10d ageOfYoungestRecord\n", a_upDownP->ageOfYoungestRecord); + printf("\t\t%10d ageOfOldestRecord\n", a_upDownP->ageOfOldestRecord); + printf("\t\t%10d numDowntimeIncidents\n", + a_upDownP->numDowntimeIncidents); + printf("\t\t%10d numRecordsNeverDown\n", a_upDownP->numRecordsNeverDown); + printf("\t\t%10d maxDowntimesInARecord\n", + a_upDownP->maxDowntimesInARecord); + printf("\t\t%10d sumOfDowntimes\n", a_upDownP->sumOfDowntimes); + printf("\t\t%10d shortestDowntime\n", a_upDownP->shortestDowntime); + printf("\t\t%10d longestDowntime\n", a_upDownP->longestDowntime); /* * Now, print the array values. */ printf("\t\tDowntime duration distribution:\n"); - printf("\t\t\t%8d: 0 min .. 10 min\n", a_upDownP->downDurations[0]); + printf("\t\t\t%8d: 0 min .. 10 min\n", a_upDownP->downDurations[0]); printf("\t\t\t%8d: 10 min .. 30 min\n", a_upDownP->downDurations[1]); - printf("\t\t\t%8d: 30 min .. 1 hr\n", a_upDownP->downDurations[2]); - printf("\t\t\t%8d: 1 hr .. 2 hr\n", a_upDownP->downDurations[3]); - printf("\t\t\t%8d: 2 hr .. 4 hr\n", a_upDownP->downDurations[4]); - printf("\t\t\t%8d: 4 hr .. 8 hr\n", a_upDownP->downDurations[5]); - printf("\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]); + printf("\t\t\t%8d: 30 min .. 1 hr\n", a_upDownP->downDurations[2]); + printf("\t\t\t%8d: 1 hr .. 2 hr\n", a_upDownP->downDurations[3]); + printf("\t\t\t%8d: 2 hr .. 4 hr\n", a_upDownP->downDurations[4]); + printf("\t\t\t%8d: 4 hr .. 8 hr\n", a_upDownP->downDurations[5]); + printf("\t\t\t%8d: > 8 hr\n", a_upDownP->downDurations[6]); printf("\t\tDowntime incident distribution:\n"); - printf("\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]); - printf("\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]); - printf("\t\t\t%8d: 2 .. 5 times\n", a_upDownP->downIncidents[2]); - printf("\t\t\t%8d: 6 .. 10 times\n", a_upDownP->downIncidents[3]); + printf("\t\t\t%8d: 0 times\n", a_upDownP->downIncidents[0]); + printf("\t\t\t%8d: 1 time\n", a_upDownP->downIncidents[1]); + printf("\t\t\t%8d: 2 .. 5 times\n", a_upDownP->downIncidents[2]); + printf("\t\t\t%8d: 6 .. 10 times\n", a_upDownP->downIncidents[3]); printf("\t\t\t%8d: 10 .. 50 times\n", a_upDownP->downIncidents[4]); - printf("\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]); + printf("\t\t\t%8d: > 50 times\n", a_upDownP->downIncidents[5]); -} /*Print_cm_UpDownStats*/ +} /*Print_cm_UpDownStats */ /*------------------------------------------------------------------------ @@ -411,54 +422,55 @@ void Print_cm_UpDownStats(a_upDownP) * *------------------------------------------------------------------------*/ -void Print_cm_OverallPerfInfo(a_ovP) - struct afs_stats_CMPerf *a_ovP; - -{ /*Print_cm_OverallPerfInfo*/ - - printf("\t%10d numPerfCalls\n", a_ovP->numPerfCalls); - - printf("\t%10d epoch\n", a_ovP->epoch); - printf("\t%10d numCellsVisible\n", a_ovP->numCellsVisible); - printf("\t%10d numCellsContacted\n", a_ovP->numCellsContacted); - printf("\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses); - printf("\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses); - printf("\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses); - printf("\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses); - printf("\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries); - printf("\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal); - printf("\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse); - printf("\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig); - printf("\t%10d cacheMaxDirtyChunks\n",a_ovP->cacheMaxDirtyChunks); - printf("\t%10d cacheCurrDirtyChunks\n", a_ovP->cacheCurrDirtyChunks); - printf("\t%10d dcacheHits\n", a_ovP->dcacheHits); - printf("\t%10d vcacheHits\n", a_ovP->vcacheHits); - printf("\t%10d dcacheMisses\n", a_ovP->dcacheMisses); - printf("\t%10d vcacheMisses\n", a_ovP->vcacheMisses); - printf("\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused); - printf("\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs); - - printf("\t%10d bufAlloced\n", a_ovP->bufAlloced); - printf("\t%10d bufHits\n", a_ovP->bufHits); - printf("\t%10d bufMisses\n", a_ovP->bufMisses); - printf("\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty); - - printf("\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive); - printf("\t%10d LargeBlocksAlloced\n", a_ovP->LargeBlocksAlloced); - printf("\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive); - printf("\t%10d SmallBlocksAlloced\n", a_ovP->SmallBlocksAlloced); - printf("\t%10d OutStandingMemUsage\n", a_ovP->OutStandingMemUsage); - printf("\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs); - printf("\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced); - printf("\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes); - - printf("\t%10d srvRecords\n", a_ovP->srvRecords); - printf("\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets); - printf("\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength); - printf("\t%10d srvMaxChainLengthHWM\n", a_ovP->srvMaxChainLengthHWM); - printf("\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM); - - printf("\t%10d sysName_ID\n", a_ovP->sysName_ID); +void +Print_cm_OverallPerfInfo(a_ovP) + struct afs_stats_CMPerf *a_ovP; + +{ /*Print_cm_OverallPerfInfo */ + + printf("\t%10d numPerfCalls\n", a_ovP->numPerfCalls); + + printf("\t%10d epoch\n", a_ovP->epoch); + printf("\t%10d numCellsVisible\n", a_ovP->numCellsVisible); + printf("\t%10d numCellsContacted\n", a_ovP->numCellsContacted); + printf("\t%10d dlocalAccesses\n", a_ovP->dlocalAccesses); + printf("\t%10d vlocalAccesses\n", a_ovP->vlocalAccesses); + printf("\t%10d dremoteAccesses\n", a_ovP->dremoteAccesses); + printf("\t%10d vremoteAccesses\n", a_ovP->vremoteAccesses); + printf("\t%10d cacheNumEntries\n", a_ovP->cacheNumEntries); + printf("\t%10d cacheBlocksTotal\n", a_ovP->cacheBlocksTotal); + printf("\t%10d cacheBlocksInUse\n", a_ovP->cacheBlocksInUse); + printf("\t%10d cacheBlocksOrig\n", a_ovP->cacheBlocksOrig); + printf("\t%10d cacheMaxDirtyChunks\n", a_ovP->cacheMaxDirtyChunks); + printf("\t%10d cacheCurrDirtyChunks\n", a_ovP->cacheCurrDirtyChunks); + printf("\t%10d dcacheHits\n", a_ovP->dcacheHits); + printf("\t%10d vcacheHits\n", a_ovP->vcacheHits); + printf("\t%10d dcacheMisses\n", a_ovP->dcacheMisses); + printf("\t%10d vcacheMisses\n", a_ovP->vcacheMisses); + printf("\t%10d cacheFilesReused\n", a_ovP->cacheFilesReused); + printf("\t%10d vcacheXAllocs\n", a_ovP->vcacheXAllocs); + + printf("\t%10d bufAlloced\n", a_ovP->bufAlloced); + printf("\t%10d bufHits\n", a_ovP->bufHits); + printf("\t%10d bufMisses\n", a_ovP->bufMisses); + printf("\t%10d bufFlushDirty\n", a_ovP->bufFlushDirty); + + printf("\t%10d LargeBlocksActive\n", a_ovP->LargeBlocksActive); + printf("\t%10d LargeBlocksAlloced\n", a_ovP->LargeBlocksAlloced); + printf("\t%10d SmallBlocksActive\n", a_ovP->SmallBlocksActive); + printf("\t%10d SmallBlocksAlloced\n", a_ovP->SmallBlocksAlloced); + printf("\t%10d OutStandingMemUsage\n", a_ovP->OutStandingMemUsage); + printf("\t%10d OutStandingAllocs\n", a_ovP->OutStandingAllocs); + printf("\t%10d CallBackAlloced\n", a_ovP->CallBackAlloced); + printf("\t%10d CallBackFlushes\n", a_ovP->CallBackFlushes); + + printf("\t%10d srvRecords\n", a_ovP->srvRecords); + printf("\t%10d srvNumBuckets\n", a_ovP->srvNumBuckets); + printf("\t%10d srvMaxChainLength\n", a_ovP->srvMaxChainLength); + printf("\t%10d srvMaxChainLengthHWM\n", a_ovP->srvMaxChainLengthHWM); + printf("\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM); + + printf("\t%10d sysName_ID\n", a_ovP->sysName_ID); printf("\tFile Server up/downtimes, same cell:\n"); Print_cm_UpDownStats(&(a_ovP->fs_UpDown[0])); @@ -472,7 +484,7 @@ void Print_cm_OverallPerfInfo(a_ovP) printf("\tVL Server up/downtimes, diff cell:\n"); Print_cm_UpDownStats(&(a_ovP->vl_UpDown[1])); -} /*Print_cm_OverallPerfInfo*/ +} /*Print_cm_OverallPerfInfo */ @@ -489,21 +501,21 @@ void Print_cm_OverallPerfInfo(a_ovP) * *------------------------------------------------------------------------*/ -void Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP) - int a_opIdx; - char *a_opNames[]; - struct afs_stats_opTimingData *a_opTimeP; +void +Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP) + int a_opIdx; + char *a_opNames[]; + struct afs_stats_opTimingData *a_opTimeP; -{ /*Print_cm_OpTiming*/ +{ /*Print_cm_OpTiming */ printf("%15s: %d ops (%d OK); sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", - a_opNames[a_opIdx], - a_opTimeP->numOps, a_opTimeP->numSuccesses, + a_opNames[a_opIdx], a_opTimeP->numOps, a_opTimeP->numSuccesses, a_opTimeP->sumTime.tv_sec, a_opTimeP->sumTime.tv_usec, a_opTimeP->minTime.tv_sec, a_opTimeP->minTime.tv_usec, a_opTimeP->maxTime.tv_sec, a_opTimeP->maxTime.tv_usec); -} /*Print_cm_OpTiming*/ +} /*Print_cm_OpTiming */ /*------------------------------------------------------------------------ @@ -518,33 +530,29 @@ void Print_cm_OpTiming(a_opIdx, a_opNames, a_opTimeP) * *------------------------------------------------------------------------*/ -void Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP) - int a_opIdx; - char *a_opNames[]; - struct afs_stats_xferData *a_xferP; - -{ /*Print_cm_XferTiming*/ - - printf("%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", - a_opNames[a_opIdx], - a_xferP->numXfers, a_xferP->numSuccesses, - a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec, - a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec, - a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec); - printf("\t[bytes: sum=%d, min=%d, max=%d]\n", - a_xferP->sumBytes, a_xferP->minBytes, a_xferP->maxBytes); - printf("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d, 6: %d, 7: %d, 8: %d]\n", - a_xferP->count[0], - a_xferP->count[1], - a_xferP->count[2], - a_xferP->count[3], - a_xferP->count[4], - a_xferP->count[5], - a_xferP->count[6], - a_xferP->count[7], - a_xferP->count[8]); - -} /*Print_cm_XferTiming*/ +void +Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP) + int a_opIdx; + char *a_opNames[]; + struct afs_stats_xferData *a_xferP; + +{ /*Print_cm_XferTiming */ + + printf + ("%s: %d xfers (%d OK), time sum=%d.%06d, min=%d.%06d, max=%d.%06d\n", + a_opNames[a_opIdx], a_xferP->numXfers, a_xferP->numSuccesses, + a_xferP->sumTime.tv_sec, a_xferP->sumTime.tv_usec, + a_xferP->minTime.tv_sec, a_xferP->minTime.tv_usec, + a_xferP->maxTime.tv_sec, a_xferP->maxTime.tv_usec); + printf("\t[bytes: sum=%d, min=%d, max=%d]\n", a_xferP->sumBytes, + a_xferP->minBytes, a_xferP->maxBytes); + printf + ("\t[buckets: 0: %d, 1: %d, 2: %d, 3: %d, 4: %d, 5: %d, 6: %d, 7: %d, 8: %d]\n", + a_xferP->count[0], a_xferP->count[1], a_xferP->count[2], + a_xferP->count[3], a_xferP->count[4], a_xferP->count[5], + a_xferP->count[6], a_xferP->count[7], a_xferP->count[8]); + +} /*Print_cm_XferTiming */ /*------------------------------------------------------------------------ @@ -560,23 +568,21 @@ void Print_cm_XferTiming(a_opIdx, a_opNames, a_xferP) * *------------------------------------------------------------------------*/ -void Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP) - int a_opIdx; - char *a_opNames[]; - struct afs_stats_RPCErrors *a_opErrP; +void +Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP) + int a_opIdx; + char *a_opNames[]; + struct afs_stats_RPCErrors *a_opErrP; -{ /*Print_cm_ErrInfo*/ +{ /*Print_cm_ErrInfo */ - printf("%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n", - a_opNames[a_opIdx], - a_opErrP->err_Server, - a_opErrP->err_Network, - a_opErrP->err_Protection, - a_opErrP->err_Volume, - a_opErrP->err_VolumeBusies, - a_opErrP->err_Other); + printf + ("%15s: %d server, %d network, %d prot, %d vol, %d busies, %d other\n", + a_opNames[a_opIdx], a_opErrP->err_Server, a_opErrP->err_Network, + a_opErrP->err_Protection, a_opErrP->err_Volume, + a_opErrP->err_VolumeBusies, a_opErrP->err_Other); -} /*Print_cm_ErrInfo*/ +} /*Print_cm_ErrInfo */ /*------------------------------------------------------------------------ @@ -590,12 +596,13 @@ void Print_cm_ErrInfo(a_opIdx, a_opNames, a_opErrP) * *------------------------------------------------------------------------*/ -void Print_cm_RPCPerfInfo(a_rpcP) - struct afs_stats_RPCOpInfo *a_rpcP; +void +Print_cm_RPCPerfInfo(a_rpcP) + struct afs_stats_RPCOpInfo *a_rpcP; -{ /*Print_cm_RPCPerfInfo*/ +{ /*Print_cm_RPCPerfInfo */ - int currIdx; /*Loop variable*/ + int currIdx; /*Loop variable */ /* * Print the contents of each of the opcode-related arrays. @@ -610,13 +617,14 @@ void Print_cm_RPCPerfInfo(a_rpcP) printf("\nTransfer timings:\n-----------------\n"); for (currIdx = 0; currIdx < AFS_STATS_NUM_FS_XFER_OPS; currIdx++) - Print_cm_XferTiming(currIdx, xferOpNames, &(a_rpcP->fsXferTimes[currIdx])); + Print_cm_XferTiming(currIdx, xferOpNames, + &(a_rpcP->fsXferTimes[currIdx])); printf("\nCM Operation Timings:\n---------------------\n"); for (currIdx = 0; currIdx < AFS_STATS_NUM_CM_RPC_OPS; currIdx++) Print_cm_OpTiming(currIdx, cmOpNames, &(a_rpcP->cmRPCTimes[currIdx])); -} /*Print_cm_RPCPerfInfo*/ +} /*Print_cm_RPCPerfInfo */ /*------------------------------------------------------------------------ @@ -630,17 +638,17 @@ void Print_cm_RPCPerfInfo(a_rpcP) * *------------------------------------------------------------------------*/ -void Print_cm_FullPerfInfo(a_fullP) -struct afs_stats_CMFullPerf *a_fullP; -{ /*Print_cm_FullPerfInfo*/ - - static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */ - struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats*/ - struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats*/ - struct afs_stats_AuthorInfo *authorP; /*Ptr to authorship stats*/ - static long fullPerfLongs = - (sizeof (struct afs_stats_CMFullPerf) >> 2); /*Correct #longs*/ - long numLongs; /*# longs actually received*/ +void +Print_cm_FullPerfInfo(a_fullP) + struct afs_stats_CMFullPerf *a_fullP; +{ /*Print_cm_FullPerfInfo */ + + static char rn[] = "Print_cm_FullPerfInfo"; /* routine name */ + struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats */ + struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats */ + struct afs_stats_AuthorInfo *authorP; /*Ptr to authorship stats */ + static long fullPerfLongs = (sizeof(struct afs_stats_CMFullPerf) >> 2); /*Correct #longs */ + long numLongs; /*# longs actually received */ struct afs_stats_CMFullPerf *fullP; fullP = a_fullP; @@ -656,160 +664,163 @@ struct afs_stats_CMFullPerf *a_fullP; authentP = &(fullP->authent); printf("\nAuthentication info:\n--------------------\n"); - printf("\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n", - authentP->curr_PAGs, - authentP->curr_Records, - authentP->curr_AuthRecords, - authentP->curr_UnauthRecords, - authentP->curr_MaxRecordsInPAG, - authentP->curr_LongestChain); - printf("\t%d PAG creations, %d tkt updates\n", - authentP->PAGCreations, + printf + ("\t%d PAGS, %d records (%d auth, %d unauth), %d max in PAG, chain max: %d\n", + authentP->curr_PAGs, authentP->curr_Records, + authentP->curr_AuthRecords, authentP->curr_UnauthRecords, + authentP->curr_MaxRecordsInPAG, authentP->curr_LongestChain); + printf("\t%d PAG creations, %d tkt updates\n", authentP->PAGCreations, authentP->TicketUpdates); printf("\t[HWMs: %d PAGS, %d records, %d max in PAG, chain max: %d]\n", - authentP->HWM_PAGs, - authentP->HWM_Records, - authentP->HWM_MaxRecordsInPAG, - authentP->HWM_LongestChain); + authentP->HWM_PAGs, authentP->HWM_Records, + authentP->HWM_MaxRecordsInPAG, authentP->HWM_LongestChain); accessinfP = &(fullP->accessinf); printf("\n[Un]replicated accesses:\n------------------------\n"); - printf("\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n", - accessinfP->unreplicatedRefs, - accessinfP->replicatedRefs, - accessinfP->numReplicasAccessed, - accessinfP->maxReplicasPerRef, - accessinfP->refFirstReplicaOK); + printf + ("\t%d unrep, %d rep, %d reps accessed, %d max reps/ref, %d first OK\n\n", + accessinfP->unreplicatedRefs, accessinfP->replicatedRefs, + accessinfP->numReplicasAccessed, accessinfP->maxReplicasPerRef, + accessinfP->refFirstReplicaOK); /* There really isn't any authorship info - authorP = &(fullP->author); */ + * authorP = &(fullP->author); */ -} /*Print_cm_FullPerfInfo*/ +} /*Print_cm_FullPerfInfo */ -main(argc,argv) -int argc; -char *argv[]; +main(argc, argv) + int argc; + char *argv[]; { - static char rn[] = "main"; - FILE *inFD; - char *line, *charPtr; - long *longs, *longPtr; - int block_size, exitcode, i, numLongs, counter; - char day[5],month[5],date[5],time[10],year[5],hostname[80],hosttype[5]; - struct afs_stats_CMFullPerf *cmPerfP; - struct fs_stats_FullPerfStats *fsPerfP; - char tmpstr[20]; - - - if ((argc < 2) || (strcasecmp(argv[1],"-h")==0) || - (strcasecmp(argv[1],"-help")==0) || (strcasecmp(argv[1],"help")==0) ) { - fprintf(stderr,"\nUsage: %s \n",argv[0]); - fprintf(stderr,"\twhere is the output generated by AFSMonitor\n\n"); - exit(1); - } - - - - inFD = fopen(argv[1],"r"); - if (inFD == (FILE *)0) { - fprintf(stderr,"\n[ %s ] Unable to open input file %s. \n",rn,argv[1]); - exit(5); - } - - block_size = XSTAT_CM_FULLPERF_RESULTS_LEN * sizeof(long); - - /* Malloc two blocks of data, one for reading each line from the data file - and the other for coverting data to longs */ - - if ( (line = malloc(block_size+256)) == (char *)NULL) { - fprintf(stderr,"[ %s ] malloc %d bytes failed\n",rn,block_size+256); - exit(10); - } - - if ( (longs = malloc(block_size)) == (long *) NULL) { - fprintf(stderr,"[ %s ] malloc %d bytes failed\n",rn,block_size); - exit(20); - } - - /* Parse the data file */ - while (1) { - if (fgets(line, block_size, inFD) == NULL) { - exitcode = 0; - goto FINISH; - } - if (strlen(line) < 5) - continue; - - /* Parse the date, hostname, and hosttype (FS or CM) */ - - charPtr = line; - sscanf(charPtr,"%s %s %s %s %s %s %s", day,month,date,time, - year,hostname,hosttype); - charPtr += strlen(day) + strlen(month) + strlen(date) + strlen(time) + - strlen(year) + strlen(hostname) + strlen(hosttype) + 8; - - printf("\n\n%s %s %s %s %s %s %s \n\n", - day,month,date,time,year,hostname, hosttype); - - /* Check the first datum. If it is -1 the probe had failed */ - - sscanf(charPtr,"%s",tmpstr); - if ( atoi(tmpstr) == -1) { - printf("Probe failed, no data to process.\n"); - continue; - } - - /* Convert the data to longs */ - - if (strcmp(hosttype,"FS") == 0) numLongs = XSTAT_FS_FULLPERF_RESULTS_LEN; - else if (strcmp(hosttype,"CM") == 0) numLongs=XSTAT_CM_FULLPERF_RESULTS_LEN; - else { - fprintf(stderr, "Cannot determine hosttype %s\n",hosttype); - fprintf(stderr,"Skipping this entry\n"); - continue; - } - - longPtr = longs; - counter = 0; - for (i = 0; i < numLongs; i++) { - sscanf(charPtr,"%ld",longPtr); - sscanf(charPtr,"%s",tmpstr); - longPtr++; - charPtr += strlen(tmpstr) + 1; - counter++; - } - - /* Verify that we read the correct number of longs and print them */ - - if (strcmp(hosttype,"CM") == 0) { - if (counter == XSTAT_CM_FULLPERF_RESULTS_LEN) - Print_cm_FullPerfInfo( (struct afs_stats_CMFullPerf *) longs); - else - fprintf(stderr,"Data size mismatch error. Expected %d longs, found %d longs\n",numLongs,counter); - } - else { - if (counter == XSTAT_FS_FULLPERF_RESULTS_LEN) { - fsPerfP = (struct fs_stats_FullPerfStats *) longs; - Print_fs_OverallPerfInfo (&(fsPerfP->overall)); - Print_fs_DetailedPerfInfo (&(fsPerfP->det)); + static char rn[] = "main"; + FILE *inFD; + char *line, *charPtr; + long *longs, *longPtr; + int block_size, exitcode, i, numLongs, counter; + char day[5], month[5], date[5], time[10], year[5], hostname[80], + hosttype[5]; + struct afs_stats_CMFullPerf *cmPerfP; + struct fs_stats_FullPerfStats *fsPerfP; + char tmpstr[20]; + + + if ((argc < 2) || (strcasecmp(argv[1], "-h") == 0) + || (strcasecmp(argv[1], "-help") == 0) + || (strcasecmp(argv[1], "help") == 0)) { + fprintf(stderr, "\nUsage: %s \n", argv[0]); + fprintf(stderr, + "\twhere is the output generated by AFSMonitor\n\n"); + exit(1); } - else - fprintf(stderr,"Data size mismatch error. Expected %d longs, found %d longs\n",numLongs,counter); - - } - printf("\n-------------------------------------------------------------------------\n"); - } /* while */ - exitcode = 0; -FINISH: - fclose(inFD); - free(line); - free(longs); -} - + inFD = fopen(argv[1], "r"); + if (inFD == (FILE *) 0) { + fprintf(stderr, "\n[ %s ] Unable to open input file %s. \n", rn, + argv[1]); + exit(5); + } + + block_size = XSTAT_CM_FULLPERF_RESULTS_LEN * sizeof(long); + + /* Malloc two blocks of data, one for reading each line from the data file + * and the other for coverting data to longs */ + if ((line = malloc(block_size + 256)) == (char *)NULL) { + fprintf(stderr, "[ %s ] malloc %d bytes failed\n", rn, + block_size + 256); + exit(10); + } + + if ((longs = malloc(block_size)) == (long *)NULL) { + fprintf(stderr, "[ %s ] malloc %d bytes failed\n", rn, block_size); + exit(20); + } + + /* Parse the data file */ + while (1) { + if (fgets(line, block_size, inFD) == NULL) { + exitcode = 0; + goto FINISH; + } + if (strlen(line) < 5) + continue; + + /* Parse the date, hostname, and hosttype (FS or CM) */ + + charPtr = line; + sscanf(charPtr, "%s %s %s %s %s %s %s", day, month, date, time, year, + hostname, hosttype); + charPtr += + strlen(day) + strlen(month) + strlen(date) + strlen(time) + + strlen(year) + strlen(hostname) + strlen(hosttype) + 8; + + printf("\n\n%s %s %s %s %s %s %s \n\n", day, month, date, time, year, + hostname, hosttype); + + /* Check the first datum. If it is -1 the probe had failed */ + + sscanf(charPtr, "%s", tmpstr); + if (atoi(tmpstr) == -1) { + printf("Probe failed, no data to process.\n"); + continue; + } + + /* Convert the data to longs */ + + if (strcmp(hosttype, "FS") == 0) + numLongs = XSTAT_FS_FULLPERF_RESULTS_LEN; + else if (strcmp(hosttype, "CM") == 0) + numLongs = XSTAT_CM_FULLPERF_RESULTS_LEN; + else { + fprintf(stderr, "Cannot determine hosttype %s\n", hosttype); + fprintf(stderr, "Skipping this entry\n"); + continue; + } + + longPtr = longs; + counter = 0; + for (i = 0; i < numLongs; i++) { + sscanf(charPtr, "%ld", longPtr); + sscanf(charPtr, "%s", tmpstr); + longPtr++; + charPtr += strlen(tmpstr) + 1; + counter++; + } + + /* Verify that we read the correct number of longs and print them */ + + if (strcmp(hosttype, "CM") == 0) { + if (counter == XSTAT_CM_FULLPERF_RESULTS_LEN) + Print_cm_FullPerfInfo((struct afs_stats_CMFullPerf *)longs); + else + fprintf(stderr, + "Data size mismatch error. Expected %d longs, found %d longs\n", + numLongs, counter); + } else { + if (counter == XSTAT_FS_FULLPERF_RESULTS_LEN) { + fsPerfP = (struct fs_stats_FullPerfStats *)longs; + Print_fs_OverallPerfInfo(&(fsPerfP->overall)); + Print_fs_DetailedPerfInfo(&(fsPerfP->det)); + } else + fprintf(stderr, + "Data size mismatch error. Expected %d longs, found %d longs\n", + numLongs, counter); + + } + + printf + ("\n-------------------------------------------------------------------------\n"); + } /* while */ + + exitcode = 0; + + FINISH: + fclose(inFD); + free(line); + free(longs); +} diff --git a/src/afsmonitor/afsmon-win.c b/src/afsmonitor/afsmon-win.c index 61438c4f4..e54d17f5c 100644 --- a/src/afsmonitor/afsmon-win.c +++ b/src/afsmonitor/afsmon-win.c @@ -15,7 +15,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -27,20 +28,20 @@ RCSID("$Header$"); #undef IN #include -#include /*Generic window package*/ -#include /*Object definitions*/ +#include /*Generic window package */ +#include /*Object definitions */ #if 0 -#include /*Text object circular buffer interface*/ -#include /*Text object interface*/ +#include /*Text object circular buffer interface */ +#include /*Text object interface */ #endif -#include /*Light object interface*/ -#include /*Curses window package*/ -#include /*Dumb terminal window package*/ -#include /*X11 window package*/ -#include /*Frame package*/ +#include /*Light object interface */ +#include /*Curses window package */ +#include /*Dumb terminal window package */ +#include /*X11 window package */ +#include /*Frame package */ -#include -#include +#include +#include #include "afsmonitor.h" @@ -54,8 +55,8 @@ static char afsmon_version[] = "1.0"; extern int afsmon_debug; /* debug info to file ? */ extern FILE *debugFD; /* debugging file descriptor */ -extern char errMsg[256]; /* buffers used to print error messages after*/ -extern char errMsg1[256]; /* gtx is initialized (stderr/stdout gone !) */ +extern char errMsg[256]; /* buffers used to print error messages after */ +extern char errMsg1[256]; /* gtx is initialized (stderr/stdout gone !) */ /* number of fileservers and cache managers to monitor */ extern int numFS; @@ -69,10 +70,10 @@ extern int numHosts_onfs_alerts; extern int num_cm_alerts; extern int numHosts_oncm_alerts; -/* ptr to array holding the results of FS probes in ascii format */ +/* ptr to array holding the results of FS probes in ascii format */ extern struct fs_Display_Data *prev_fsData; -/* ptr to array holding the results of CM probes in ascii format */ +/* ptr to array holding the results of CM probes in ascii format */ extern struct cm_Display_Data *prev_cmData; extern int afsmon_fs_curr_probeNum; /* current fs probe number */ @@ -80,17 +81,17 @@ extern int afsmon_fs_prev_probeNum; /* previous fs probe number */ extern int afsmon_cm_curr_probeNum; /* current cm probe number */ extern int afsmon_cm_prev_probeNum; /* previous cm probe number */ -extern int afsmon_probefreq; /* probe frequency */ +extern int afsmon_probefreq; /* probe frequency */ /* map of fs results items we must display. This array contains indices to the fs_varNames[] array corresponding to the stats we want to display. It is initialized while processing the config file */ extern short fs_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN]; -extern int fs_DisplayItems_count; /* number of items to display */ +extern int fs_DisplayItems_count; /* number of items to display */ extern short cm_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN]; -extern int cm_DisplayItems_count; /* number of items to display */ +extern int cm_DisplayItems_count; /* number of items to display */ /* GTX VARIABLES */ @@ -113,21 +114,21 @@ extern int cm_DisplayItems_count; /* number of items to display */ #define OVW_CMD_O_WIDTH (maxX/2) /* cmd line object */ #define OVW_NUMFS_O_WIDTH 40 /* num FSs monitored */ #define OVW_NUMCM_O_WIDTH 40 /* num CMs monitored */ -#define OVW_FSALERTS_O_WIDTH 40 /* num FS alerts */ -#define OVW_CMALERTS_O_WIDTH 40 /* num CM alerts */ -#define OVW_HOSTNAME_O_WIDTH (maxX / 2) /* FS & CM host names */ +#define OVW_FSALERTS_O_WIDTH 40 /* num FS alerts */ +#define OVW_CMALERTS_O_WIDTH 40 /* num CM alerts */ +#define OVW_HOSTNAME_O_WIDTH (maxX / 2) /* FS & CM host names */ #define OVW_HOSTNAME_O_WIDTH_HGL 30 /* cosmetic, atleast this many chars - will be highlightned */ + * will be highlightned */ /* widths of FS and CM frame objects */ #define FC_NUMHOSTS_O_WIDTH (maxX - 8) /* number of fs monitored. leave 4 - chars on either side for '<<','>>' */ + * chars on either side for '<<','>>' */ #define FC_PAGENUM_O_WIDTH 43 -#define FC_HOSTNAME_O_WIDTH 11 /* width of FS hostnames column */ -#define FC_CMD_O_WIDTH 55 /* width of cmd line */ -#define FC_PROBENUM_O_WIDTH 30 /* width of probe number object */ -#define FC_ARROWS_O_WIDTH 4 /* width of arrow indicators */ -#define FC_COLUMN_WIDTH 11 /* width of data columns */ +#define FC_HOSTNAME_O_WIDTH 11 /* width of FS hostnames column */ +#define FC_CMD_O_WIDTH 55 /* width of cmd line */ +#define FC_PROBENUM_O_WIDTH 30 /* width of probe number object */ +#define FC_ARROWS_O_WIDTH 4 /* width of arrow indicators */ +#define FC_COLUMN_WIDTH 11 /* width of data columns */ /* bit definitions for use in resolving command line */ /* these bits are set in the xx_pageType variables to indicate what commands @@ -141,13 +142,13 @@ are acceptable */ #define CMD_CM 32 /* cache managers frame exists ? */ -#define FC_NUM_FIXED_LINES 10 /* number of fixed lines */ -#define FC_FIRST_HOST_ROW 8 /* first host entry row number */ -#define FC_FIRST_LABEL_ROW 4 /* first label row number */ +#define FC_NUM_FIXED_LINES 10 /* number of fixed lines */ +#define FC_FIRST_HOST_ROW 8 /* first host entry row number */ +#define FC_FIRST_LABEL_ROW 4 /* first label row number */ /* number of fixed lines (that dont change) on the overview screen */ #define OVW_NUM_FIXED_LINES 7 -#define OVW_FIRST_HOST_ROW 5 /* row index of first host entry in ovw frame*/ +#define OVW_FIRST_HOST_ROW 5 /* row index of first host entry in ovw frame */ #define HIGHLIGHT 1 /* highlight object? */ @@ -162,20 +163,20 @@ int gtx_initialized = 0; /* Overview screen related definitions */ -struct gtx_frame *ovwFrame; /* overview screen frame */ +struct gtx_frame *ovwFrame; /* overview screen frame */ struct gwin_sizeparams frameDims; /* frame dimensions. all frames have - same dimensions */ + * same dimensions */ /* overview frame object names */ -struct onode *ovw_progName_o; /* program name object */ -struct onode *ovw_pageNum_o; /* page number onject */ -struct onode *ovw_cmd_o; /* command line object */ -struct onode *ovw_probeNum_o; /* probe number object */ -struct onode *ovw_numFS_o; /* num FS monitored */ -struct onode *ovw_numCM_o; /* num CM monitored */ -struct onode *ovw_FSalerts_o; /* nunber of FS alerts */ -struct onode *ovw_CMalerts_o; /* nunber of CM alerts */ -struct onode *initMsg_o; /* initialization message */ +struct onode *ovw_progName_o; /* program name object */ +struct onode *ovw_pageNum_o; /* page number onject */ +struct onode *ovw_cmd_o; /* command line object */ +struct onode *ovw_probeNum_o; /* probe number object */ +struct onode *ovw_numFS_o; /* num FS monitored */ +struct onode *ovw_numCM_o; /* num CM monitored */ +struct onode *ovw_FSalerts_o; /* nunber of FS alerts */ +struct onode *ovw_CMalerts_o; /* nunber of CM alerts */ +struct onode *initMsg_o; /* initialization message */ /* number of pages of data for the overview frame */ int ovw_numPages = 0; @@ -197,19 +198,19 @@ int ovw_update_info = 0; /* Variables needed to display an intialization message on startup */ static char *initMsg = "AFSMonitor Collecting Statistics ..."; -static int initMsg_on = 0; /* message on ? */ +static int initMsg_on = 0; /* message on ? */ /* FILE SERVER Screen related definitions */ -struct gtx_frame *fsFrame; /* File Server screen frame */ +struct gtx_frame *fsFrame; /* File Server screen frame */ -struct onode *fs_pageNum_o; /* fs page number object */ -struct onode *fs_cmd_o; /* fs command line object */ -struct onode *fs_probeNum_o; /* fs probe number object */ -struct onode *fs_numFS_o; /* fs number of FSs object */ -struct onode *fs_leftArrows_o; /* fs cols on left signal object */ -struct onode *fs_rightArrows_o; /* fs cols on right signal object */ -struct onode **fs_hostNames_o; /* ptr to host names objects */ +struct onode *fs_pageNum_o; /* fs page number object */ +struct onode *fs_cmd_o; /* fs command line object */ +struct onode *fs_probeNum_o; /* fs probe number object */ +struct onode *fs_numFS_o; /* fs number of FSs object */ +struct onode *fs_leftArrows_o; /* fs cols on left signal object */ +struct onode *fs_rightArrows_o; /* fs cols on right signal object */ +struct onode **fs_hostNames_o; /* ptr to host names objects */ /* bit-map to characterize page type and contents of command prompt */ static int fs_pageType = 0; @@ -220,19 +221,19 @@ static int fs_pageType = 0; numbers to navigate horizontally */ int fs_numHosts_perPage; /* number of file servers per page */ -int fs_cols_perPage; /* number of data columns per file server page*/ +int fs_cols_perPage; /* number of data columns per file server page */ int fs_currPage; /* current FS page number */ int fs_numPages; /* number of FS pages */ /* column numbers are index to the mapping structure fs_Display_map. this map contains the indices of datums that should be displayed */ -int fs_numCols; /* number of columns of FS data (excluding hostname)*/ +int fs_numCols; /* number of columns of FS data (excluding hostname) */ /* this is the same as fs_DisplayItems_count */ /* following column indices run from 1 to (fs_numCols -1) */ -int fs_curr_LCol = 0; /* column number of leftmost column on display */ -int fs_curr_RCol = 0; /* column number of rightmost column on display */ -int fs_Data_Available = 0; /* atleast one fs probe cycle completed ? */ +int fs_curr_LCol = 0; /* column number of leftmost column on display */ +int fs_curr_RCol = 0; /* column number of rightmost column on display */ +int fs_Data_Available = 0; /* atleast one fs probe cycle completed ? */ /* structure that defines a line of data in the fs/cm frames */ @@ -244,28 +245,28 @@ characters to be displayed - such fields may overflow to the second object placed below the first one. */ struct ServerInfo_line { - struct onode *host_o; /* hostname object */ - struct onode **data_o[2]; /* ptrs to two arrays of data objects.*/ - + struct onode *host_o; /* hostname object */ + struct onode **data_o[2]; /* ptrs to two arrays of data objects. */ + }; -struct ServerInfo_line *fs_lines; /* ptr to the file server data objects*/ +struct ServerInfo_line *fs_lines; /* ptr to the file server data objects */ /* file server label onodes - three rows of them */ struct onode **fsLabels_o[3]; /* CACHE MANAGER Screen related definitions */ -struct gtx_frame *cmFrame; /* Cache Manager screen frame */ +struct gtx_frame *cmFrame; /* Cache Manager screen frame */ -struct onode *cm_pageNum_o; /* cm page number object */ -struct onode *cm_cmd_o; /* cm command line object */ -struct onode *cm_probeNum_o; /* cm probe number object */ -struct onode *cm_numCM_o; /* cm number of FSs object */ -struct onode *cm_leftArrows_o; /* fs cols on left signal object */ -struct onode *cm_rightArrows_o; /* fs cols on right signal object */ +struct onode *cm_pageNum_o; /* cm page number object */ +struct onode *cm_cmd_o; /* cm command line object */ +struct onode *cm_probeNum_o; /* cm probe number object */ +struct onode *cm_numCM_o; /* cm number of FSs object */ +struct onode *cm_leftArrows_o; /* fs cols on left signal object */ +struct onode *cm_rightArrows_o; /* fs cols on right signal object */ -struct onode **cm_hostNames_o; /* ptr to host names objects */ +struct onode **cm_hostNames_o; /* ptr to host names objects */ /* bit-map to characterize page type and contents of command prompt */ static int cm_pageType = 0; @@ -276,23 +277,23 @@ static int cm_pageType = 0; numbers to navigate horizontally */ int cm_numHosts_perPage; /* number of cache managers per page */ -int cm_cols_perPage; /* number of data columns per file server page*/ +int cm_cols_perPage; /* number of data columns per file server page */ int cm_currPage; /* current CM page number */ int cm_numPages; /* number of CM pages */ /* column numbers are index to the mapping structure cm_Display_map. this map contains the indices of datums that should be displayed */ -int cm_numCols; /* number of columns of FS data (excluding hostname)*/ +int cm_numCols; /* number of columns of FS data (excluding hostname) */ /* this is the same as cm_DisplayItems_count */ /* following column indices run from 1 to (cm_numCols -1) */ -int cm_curr_LCol = 0; /* column number of leftmost column on display */ -int cm_curr_RCol = 0; /* column number of rightmost column on display */ -int cm_Data_Available = 0; /* atleast one cm probe cycle completed ? */ +int cm_curr_LCol = 0; /* column number of leftmost column on display */ +int cm_curr_RCol = 0; /* column number of rightmost column on display */ +int cm_Data_Available = 0; /* atleast one cm probe cycle completed ? */ /* structure that defines a line of data in the fs/cm frames */ -struct ServerInfo_line *cm_lines; /* ptr to the file server data objects*/ +struct ServerInfo_line *cm_lines; /* ptr to the file server data objects */ /* file server label onodes - three rows of them */ struct onode **cmLabels_o[3]; @@ -327,25 +328,26 @@ struct onode **cmLabels_o[3]; static struct onode * initLightObject(a_name, a_x, a_y, a_width, a_win) - char *a_name; - int a_x; - int a_y; - int a_width; - struct gwin *a_win; + char *a_name; + int a_x; + int a_y; + int a_width; + struct gwin *a_win; -{ /*initLightObject*/ +{ /*initLightObject */ - static char rn[] = "initLightObject"; /*Routine name*/ - struct onode *newlightp; /*Ptr to new light onode*/ - struct gator_light_crparams light_crparams; /*Light creation params*/ - char *truncname; /*Truncated name, if needed*/ - int name_len; /*True length of name*/ + static char rn[] = "initLightObject"; /*Routine name */ + struct onode *newlightp; /*Ptr to new light onode */ + struct gator_light_crparams light_crparams; /*Light creation params */ + char *truncname; /*Truncated name, if needed */ + int name_len; /*True length of name */ /* the following debug statement floods the debug file */ #ifdef DEBUG_DETAILED if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_name= %s, a_x= %d, a_y= %d, a_width= %d, a_win= %d\n", - rn, a_name, a_x, a_y, a_width, a_win); + fprintf(debugFD, + "[ %s ] Called, a_name= %s, a_x= %d, a_y= %d, a_width= %d, a_win= %d\n", + rn, a_name, a_x, a_y, a_width, a_win); fflush(debugFD); } #endif @@ -353,49 +355,49 @@ initLightObject(a_name, a_x, a_y, a_width, a_win) newlightp = NULL; /* - * Set up the creation parameters according to the information we've - * received. - */ + * Set up the creation parameters according to the information we've + * received. + */ light_crparams.onode_params.cr_type = GATOR_OBJ_LIGHT; name_len = strlen(a_name); if (name_len <= a_width) - sprintf(light_crparams.onode_params.cr_name, "%s", a_name); + sprintf(light_crparams.onode_params.cr_name, "%s", a_name); else { - /* - * We need to truncate the given name, leaving a `*' at the end to - * show us it's been truncated. - */ - truncname = light_crparams.onode_params.cr_name; - strncpy(truncname, a_name, a_width-1); - truncname[a_width-1] = '*'; - truncname[a_width] = 0; - } - light_crparams.onode_params.cr_x = a_x; - light_crparams.onode_params.cr_y = a_y; - light_crparams.onode_params.cr_width = a_width; - light_crparams.onode_params.cr_height = 1; - light_crparams.onode_params.cr_window = a_win; - light_crparams.onode_params.cr_home_obj = NULL; - light_crparams.onode_params.cr_prev_obj = NULL; + /* + * We need to truncate the given name, leaving a `*' at the end to + * show us it's been truncated. + */ + truncname = light_crparams.onode_params.cr_name; + strncpy(truncname, a_name, a_width - 1); + truncname[a_width - 1] = '*'; + truncname[a_width] = 0; + } + light_crparams.onode_params.cr_x = a_x; + light_crparams.onode_params.cr_y = a_y; + light_crparams.onode_params.cr_width = a_width; + light_crparams.onode_params.cr_height = 1; + light_crparams.onode_params.cr_window = a_win; + light_crparams.onode_params.cr_home_obj = NULL; + light_crparams.onode_params.cr_prev_obj = NULL; light_crparams.onode_params.cr_parent_obj = NULL; light_crparams.onode_params.cr_helpstring = NULL; light_crparams.appearance = 0; - light_crparams.flashfreq = 0; + light_crparams.flashfreq = 0; sprintf(light_crparams.label, "%s", a_name); light_crparams.label_x = 0; light_crparams.label_y = 0; newlightp = - gator_objects_create((struct onode_createparams *)(&light_crparams)); + gator_objects_create((struct onode_createparams *)(&light_crparams)); /* - * Return the news, happy or not. - */ - return(newlightp); + * Return the news, happy or not. + */ + return (newlightp); -} /*initLightObject*/ +} /*initLightObject */ @@ -426,28 +428,30 @@ initLightObject(a_name, a_x, a_y, a_width, a_win) * *------------------------------------------------------------------------*/ -int +int justify_light(a_srcbuff, a_dstbuff, a_dstwidth, a_justification, a_rightTrunc) - char *a_srcbuff; - char *a_dstbuff; - int a_dstwidth; - int a_justification; - int a_rightTrunc; + char *a_srcbuff; + char *a_dstbuff; + int a_dstwidth; + int a_justification; + int a_rightTrunc; -{ /*justify_light*/ +{ /*justify_light */ - static char rn[] = "justify_light"; /*Routine name*/ - int leftpad_chars; /*# of chars for left-padding*/ - int num_src_chars; /*# of chars in source*/ - int true_num_src_chars; /*# src chars before truncation*/ - int trunc_needed; /*Is truncation needed?*/ + static char rn[] = "justify_light"; /*Routine name */ + int leftpad_chars; /*# of chars for left-padding */ + int num_src_chars; /*# of chars in source */ + int true_num_src_chars; /*# src chars before truncation */ + int trunc_needed; /*Is truncation needed? */ /* the following debug statement floods the debug file */ #ifdef DEBUG_DETAILED if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_srcbuff= %s, a_dstbuff= %d, a_dstwidth= %d, a_justification= %d, a_rightTrunc= %d\n", - rn, a_srcbuff, a_dstbuff, a_dstwidth, a_justification, a_rightTrunc); + fprintf(debugFD, + "[ %s ] Called, a_srcbuff= %s, a_dstbuff= %d, a_dstwidth= %d, a_justification= %d, a_rightTrunc= %d\n", + rn, a_srcbuff, a_dstbuff, a_dstwidth, a_justification, + a_rightTrunc); fflush(debugFD); } #endif @@ -458,15 +462,15 @@ justify_light(a_srcbuff, a_dstbuff, a_dstwidth, a_justification, a_rightTrunc) * we automatically shorten up. */ if (a_dstwidth > GATOR_LABEL_CHARS) { - /* - if (afsmon_debug) { - fprintf(debugFD, - "[%s] Dest width (%d) > gtx buflen (%d), shrinking dest width\n", - rn, a_dstwidth, GATOR_LABEL_CHARS); - fflush(debugFD); - } - */ - a_dstwidth = GATOR_LABEL_CHARS; + /* + * if (afsmon_debug) { + * fprintf(debugFD, + * "[%s] Dest width (%d) > gtx buflen (%d), shrinking dest width\n", + * rn, a_dstwidth, GATOR_LABEL_CHARS); + * fflush(debugFD); + * } + */ + a_dstwidth = GATOR_LABEL_CHARS; } /* @@ -479,41 +483,40 @@ justify_light(a_srcbuff, a_dstbuff, a_dstwidth, a_justification, a_rightTrunc) leftpad_chars = 0; if (!a_rightTrunc) a_srcbuff += (true_num_src_chars - num_src_chars); - } - else { + } else { trunc_needed = 0; num_src_chars = true_num_src_chars; - + /* * Compute the necessary left-padding. */ switch (a_justification) { - - case RIGHT_JUSTIFY: + + case RIGHT_JUSTIFY: leftpad_chars = (a_dstwidth - 1) - num_src_chars; break; - - case LEFT_JUSTIFY: + + case LEFT_JUSTIFY: /* * This is the really easy one. */ leftpad_chars = 0; break; - - case CENTER: + + case CENTER: leftpad_chars = ((a_dstwidth - 1) - num_src_chars) / 2; break; - - default: + + default: if (afsmon_debug) { - fprintf(debugFD, "[%s] Illegal justification command: %d", - rn, a_justification); - fprintf(debugFD, "[%s] Called with '%s', dest width=%d\n", - rn, a_srcbuff, a_dstwidth); - fflush(debugFD); + fprintf(debugFD, "[%s] Illegal justification command: %d", rn, + a_justification); + fprintf(debugFD, "[%s] Called with '%s', dest width=%d\n", rn, + a_srcbuff, a_dstwidth); + fflush(debugFD); } - return(-1); - } /*Switch on justification type*/ + return (-1); + } /*Switch on justification type */ } /* @@ -524,22 +527,23 @@ justify_light(a_srcbuff, a_dstbuff, a_dstwidth, a_justification, a_rightTrunc) * the src buffer appropriately. */ strncpy(a_dstbuff, blankline, a_dstwidth); - strncpy(a_dstbuff+leftpad_chars, a_srcbuff, num_src_chars); - *(a_dstbuff+a_dstwidth-1) = '\0'; + strncpy(a_dstbuff + leftpad_chars, a_srcbuff, num_src_chars); + *(a_dstbuff + a_dstwidth - 1) = '\0'; if (trunc_needed) { if (a_rightTrunc) - *(a_dstbuff+a_dstwidth-2) = '*'; /*Truncate on the right*/ + *(a_dstbuff + a_dstwidth - 2) = '*'; /*Truncate on the right */ else { - *a_dstbuff = '*'; /*Truncate on the left, non-disk*/ + *a_dstbuff = '*'; /*Truncate on the left, non-disk */ } - } /*Handle truncations*/ + } + /*Handle truncations */ /* * Return the good news. */ - return(0); + return (0); -} /*justify_light*/ +} /*justify_light */ @@ -558,11 +562,11 @@ afsmonExit_gtx() static char rn[] = "afsmonExit_gtx"; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); } - afsmon_Exit(0); + afsmon_Exit(0); } @@ -583,303 +587,313 @@ afsmonExit_gtx() int ovw_refresh(a_pageNum, a_updateType) -int a_pageNum; /* page to refresh overview display */ -int a_updateType; /* OVW_UPDATE_FS = update fs column only, - OVW_UPDATE_CM = update cm column only, - OVW_UPDATE_BOTH = update fs & cm columns. Note that - we do not want to update a column until the - corresponding probe cycle has completed */ -{ /* ovw_refresh */ - - static char rn[] = "ovw_refresh"; /* routine name */ - struct onode **tmp_fsNames_o; /* ptr to fsNames onodes */ - struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */ - struct fs_Display_Data *fsDataP; /* ptr to FS display data array */ - struct onode **tmp_cmNames_o; /* ptr to fsNames onodes */ - struct cm_Display_Data *cmDataP; /* ptr to CM display data array */ - int fsIdx; /* for counting # of CM hosts */ - int cmIdx; /* for counting # of CM hosts */ - int next_page = 0; /* is there a next ovw page ? */ - int prev_page = 0; /* is there a previous ovw page */ - char cmdLine[80]; /* buffer for command line */ - char printBuf[256]; /* buffer to print to screen */ - int i; - int code; - int len; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_pageNum= %d, a_updateType= %d\n", + int a_pageNum; /* page to refresh overview display */ + int a_updateType; /* OVW_UPDATE_FS = update fs column only, + * OVW_UPDATE_CM = update cm column only, + * OVW_UPDATE_BOTH = update fs & cm columns. Note that + * we do not want to update a column until the + * corresponding probe cycle has completed */ +{ /* ovw_refresh */ + + static char rn[] = "ovw_refresh"; /* routine name */ + struct onode **tmp_fsNames_o; /* ptr to fsNames onodes */ + struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */ + struct fs_Display_Data *fsDataP; /* ptr to FS display data array */ + struct onode **tmp_cmNames_o; /* ptr to fsNames onodes */ + struct cm_Display_Data *cmDataP; /* ptr to CM display data array */ + int fsIdx; /* for counting # of CM hosts */ + int cmIdx; /* for counting # of CM hosts */ + int next_page = 0; /* is there a next ovw page ? */ + int prev_page = 0; /* is there a previous ovw page */ + char cmdLine[80]; /* buffer for command line */ + char printBuf[256]; /* buffer to print to screen */ + int i; + int code; + int len; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_updateType= %d\n", rn, a_pageNum, a_updateType); fflush(debugFD); - } + } + + /* if the data is not yet available ie., not one probe cycle has + * completed, do nothing */ - /* if the data is not yet available ie., not one probe cycle has - completed, do nothing */ + if ((a_updateType & OVW_UPDATE_FS) && !fs_Data_Available) + return (0); + if ((a_updateType & OVW_UPDATE_CM) && !cm_Data_Available) + return (0); - if ( (a_updateType & OVW_UPDATE_FS) && !fs_Data_Available) - return(0); - if ( (a_updateType & OVW_UPDATE_CM) && !cm_Data_Available) - return(0); - - /* validate page number */ - if (a_pageNum < 1 || a_pageNum > ovw_numPages) { - sprintf(errMsg,"[ %s ] called with incorrect page number %d\n", - rn,a_pageNum); + /* validate page number */ + if (a_pageNum < 1 || a_pageNum > ovw_numPages) { + sprintf(errMsg, "[ %s ] called with incorrect page number %d\n", rn, + a_pageNum); afsmon_Exit(235); - } + } - /* set the current page number */ - ovw_currPage = a_pageNum; + /* set the current page number */ + ovw_currPage = a_pageNum; - /* turn off init message */ - if (initMsg_on) { + /* turn off init message */ + if (initMsg_on) { initMsg_on = 0; gtxframe_RemoveFromList(ovwFrame, initMsg_o); - } - - /* update the labels */ - - /* version label */ - tmp_lightobj=(struct gator_lightobj *) ovw_progName_o->o_data; - sprintf(printBuf,"AFSMonitor [Version %s]",afsmon_version); - justify_light(printBuf,tmp_lightobj->label,strlen(printBuf)+1, - LEFT_JUSTIFY,1); - gator_light_set(ovw_progName_o,1); - - /* page number label */ - tmp_lightobj=(struct gator_lightobj *) ovw_pageNum_o->o_data; - sprintf(printBuf,"[System Overview, p. %d of %d]",ovw_currPage,ovw_numPages); - justify_light(printBuf,tmp_lightobj->label, OVW_PAGENUM_O_WIDTH, - RIGHT_JUSTIFY,1); - gator_light_set(ovw_pageNum_o,1); - - /* file servers monitored label */ - tmp_lightobj=(struct gator_lightobj *) ovw_numFS_o->o_data; - sprintf(printBuf," %d File Servers monitored",numFS); - justify_light(printBuf,tmp_lightobj->label, strlen(printBuf)+1, - LEFT_JUSTIFY,1); - - /* cache managers monitored label */ - tmp_lightobj=(struct gator_lightobj *) ovw_numCM_o->o_data; - sprintf(printBuf," %d Cache Managers monitored",numCM); - justify_light(printBuf,tmp_lightobj->label, strlen(printBuf)+1, - LEFT_JUSTIFY,1); - - - /* no. of fs alerts label */ - tmp_lightobj=(struct gator_lightobj *) ovw_FSalerts_o->o_data; - sprintf(printBuf," %d alerts on %d machines", - num_fs_alerts,numHosts_onfs_alerts); - justify_light(printBuf,tmp_lightobj->label, strlen(printBuf)+1, - LEFT_JUSTIFY,1); - - /* no. of cm alerts label */ - tmp_lightobj=(struct gator_lightobj *) ovw_CMalerts_o->o_data; - sprintf(printBuf," %d alerts on %d machines", - num_cm_alerts,numHosts_oncm_alerts); - justify_light(printBuf,tmp_lightobj->label, strlen(printBuf)+1, - LEFT_JUSTIFY,1); - - /* command line */ - /* determine if we have fs/cm, more/previous pages of data to display */ - - ovw_pageType = 0; - if (numFS && fs_Data_Available) - ovw_pageType |= CMD_FS; /* we have an fs frame & data avail. */ - if (numCM && cm_Data_Available) - ovw_pageType |= CMD_CM; /* we have a cm frame & data avail. */ - if (ovw_currPage > 1) + } + + /* update the labels */ + + /* version label */ + tmp_lightobj = (struct gator_lightobj *)ovw_progName_o->o_data; + sprintf(printBuf, "AFSMonitor [Version %s]", afsmon_version); + justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1, + LEFT_JUSTIFY, 1); + gator_light_set(ovw_progName_o, 1); + + /* page number label */ + tmp_lightobj = (struct gator_lightobj *)ovw_pageNum_o->o_data; + sprintf(printBuf, "[System Overview, p. %d of %d]", ovw_currPage, + ovw_numPages); + justify_light(printBuf, tmp_lightobj->label, OVW_PAGENUM_O_WIDTH, + RIGHT_JUSTIFY, 1); + gator_light_set(ovw_pageNum_o, 1); + + /* file servers monitored label */ + tmp_lightobj = (struct gator_lightobj *)ovw_numFS_o->o_data; + sprintf(printBuf, " %d File Servers monitored", numFS); + justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1, + LEFT_JUSTIFY, 1); + + /* cache managers monitored label */ + tmp_lightobj = (struct gator_lightobj *)ovw_numCM_o->o_data; + sprintf(printBuf, " %d Cache Managers monitored", numCM); + justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1, + LEFT_JUSTIFY, 1); + + + /* no. of fs alerts label */ + tmp_lightobj = (struct gator_lightobj *)ovw_FSalerts_o->o_data; + sprintf(printBuf, " %d alerts on %d machines", num_fs_alerts, + numHosts_onfs_alerts); + justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1, + LEFT_JUSTIFY, 1); + + /* no. of cm alerts label */ + tmp_lightobj = (struct gator_lightobj *)ovw_CMalerts_o->o_data; + sprintf(printBuf, " %d alerts on %d machines", num_cm_alerts, + numHosts_oncm_alerts); + justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1, + LEFT_JUSTIFY, 1); + + /* command line */ + /* determine if we have fs/cm, more/previous pages of data to display */ + + ovw_pageType = 0; + if (numFS && fs_Data_Available) + ovw_pageType |= CMD_FS; /* we have an fs frame & data avail. */ + if (numCM && cm_Data_Available) + ovw_pageType |= CMD_CM; /* we have a cm frame & data avail. */ + if (ovw_currPage > 1) ovw_pageType |= CMD_PREV; /* got a previous page */ - if (ovw_currPage < ovw_numPages) + if (ovw_currPage < ovw_numPages) ovw_pageType |= CMD_NEXT; /* got a next page */ - strcpy(cmdLine,"Command ["); - if ( (ovw_pageType & CMD_FS) && (ovw_pageType & CMD_CM) ) - strcat(cmdLine,"fs, cm"); - else if (ovw_pageType & CMD_FS) - strcat(cmdLine,"fs"); - else if (ovw_pageType & CMD_CM) - strcat(cmdLine,"cm"); - - if (ovw_pageType & CMD_PREV) - strcat(cmdLine,", prev"); - if (ovw_pageType & CMD_NEXT) - strcat(cmdLine,", next"); - - strcat(cmdLine,"]? "); - - - - - /* display the command line */ - tmp_lightobj=(struct gator_lightobj *) ovw_cmd_o->o_data; - sprintf(printBuf,"%s", cmdLine); - justify_light(printBuf,tmp_lightobj->label, strlen(printBuf)+1, - LEFT_JUSTIFY,1); - gator_light_set(ovw_cmd_o, 1); - - /* display probe numbers line */ - tmp_lightobj=(struct gator_lightobj *) ovw_probeNum_o->o_data; - sprintf(printBuf,"[probes %d(fs) %d(cm), freq=%d sec]", - afsmon_fs_prev_probeNum, afsmon_cm_prev_probeNum,afsmon_probefreq); - justify_light(printBuf,tmp_lightobj->label, OVW_PROBENUM_O_WIDTH, - RIGHT_JUSTIFY,1); - gator_light_set(ovw_probeNum_o, 1); - - - - /* update the file server names column if we are asked to */ - - if (numFS && (a_updateType & OVW_UPDATE_FS)) { - - /* move to the right spot in the FS display data array */ - fsDataP = prev_fsData; - fsIdx = 0; - for(i=0; i < ((a_pageNum-1) * ovw_numHosts_perPage); i++) { - fsDataP++; - fsIdx++; - } - - /* get the address to the first FS name */ - tmp_fsNames_o = ovw_fsNames_o; + strcpy(cmdLine, "Command ["); + if ((ovw_pageType & CMD_FS) && (ovw_pageType & CMD_CM)) + strcat(cmdLine, "fs, cm"); + else if (ovw_pageType & CMD_FS) + strcat(cmdLine, "fs"); + else if (ovw_pageType & CMD_CM) + strcat(cmdLine, "cm"); + + if (ovw_pageType & CMD_PREV) + strcat(cmdLine, ", prev"); + if (ovw_pageType & CMD_NEXT) + strcat(cmdLine, ", next"); - for (i=0; i < ovw_numHosts_perPage; i++) { - if (fsIdx < numFS) { /* this could be the last & partial page */ + strcat(cmdLine, "]? "); + + + + + /* display the command line */ + tmp_lightobj = (struct gator_lightobj *)ovw_cmd_o->o_data; + sprintf(printBuf, "%s", cmdLine); + justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1, + LEFT_JUSTIFY, 1); + gator_light_set(ovw_cmd_o, 1); + + /* display probe numbers line */ + tmp_lightobj = (struct gator_lightobj *)ovw_probeNum_o->o_data; + sprintf(printBuf, "[probes %d(fs) %d(cm), freq=%d sec]", + afsmon_fs_prev_probeNum, afsmon_cm_prev_probeNum, + afsmon_probefreq); + justify_light(printBuf, tmp_lightobj->label, OVW_PROBENUM_O_WIDTH, + RIGHT_JUSTIFY, 1); + gator_light_set(ovw_probeNum_o, 1); + + + + /* update the file server names column if we are asked to */ + + if (numFS && (a_updateType & OVW_UPDATE_FS)) { + + /* move to the right spot in the FS display data array */ + fsDataP = prev_fsData; + fsIdx = 0; + for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) { + fsDataP++; + fsIdx++; + } + + /* get the address to the first FS name */ + tmp_fsNames_o = ovw_fsNames_o; + + for (i = 0; i < ovw_numHosts_perPage; i++) { + if (fsIdx < numFS) { /* this could be the last & partial page */ if (fsDataP->hostName[0] == '\0') { - sprintf(errMsg,"[ %s ] empty fs display entry \n",rn); - afsmon_Exit(240); + sprintf(errMsg, "[ %s ] empty fs display entry \n", rn); + afsmon_Exit(240); } /* check if the probe succeeded. if it did check for thresholds - overflow. A failed probe is indicated by "PF" */ + * overflow. A failed probe is indicated by "PF" */ - if (! fsDataP->probeOK) { - sprintf(printBuf,"[ PF] %s", fsDataP->hostName); - } else if (fsDataP->ovfCount) /* thresholds overflow */ - sprintf(printBuf,"[%3d] %s", - fsDataP->ovfCount,fsDataP->hostName); + if (!fsDataP->probeOK) { + sprintf(printBuf, "[ PF] %s", fsDataP->hostName); + } else if (fsDataP->ovfCount) /* thresholds overflow */ + sprintf(printBuf, "[%3d] %s", fsDataP->ovfCount, + fsDataP->hostName); else { - sprintf(printBuf," %s",fsDataP->hostName); + sprintf(printBuf, " %s", fsDataP->hostName); } - if (afsmon_debug) - fprintf(debugFD,"[ %s ] to display %s\n",rn,printBuf); + if (afsmon_debug) + fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf); - tmp_lightobj=(struct gator_lightobj *) (*tmp_fsNames_o)->o_data; + tmp_lightobj = + (struct gator_lightobj *)(*tmp_fsNames_o)->o_data; - if (strlen(printBuf)+1 < OVW_HOSTNAME_O_WIDTH_HGL) - len = OVW_HOSTNAME_O_WIDTH_HGL; - else - len = strlen(printBuf)+1; + if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL) + len = OVW_HOSTNAME_O_WIDTH_HGL; + else + len = strlen(printBuf) + 1; - code = justify_light(printBuf,tmp_lightobj->label, - len, LEFT_JUSTIFY, 1); + code = + justify_light(printBuf, tmp_lightobj->label, len, + LEFT_JUSTIFY, 1); if (code) { - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] justify_code returned %d\n", - rn,code); - } + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] justify_code returned %d\n", + rn, code); + } } - + /* highlighten if overflowed or probe failed */ - if (fsDataP->ovfCount || ! fsDataP->probeOK) - code = gator_light_set(*tmp_fsNames_o,1); + if (fsDataP->ovfCount || !fsDataP->probeOK) + code = gator_light_set(*tmp_fsNames_o, 1); else - code = gator_light_set(*tmp_fsNames_o,0); + code = gator_light_set(*tmp_fsNames_o, 0); - } else { /* no more hosts, blank the rest of the entries */ - tmp_lightobj=(struct gator_lightobj *) (*tmp_fsNames_o)->o_data; - sprintf(tmp_lightobj->label,"%s",""); + } else { /* no more hosts, blank the rest of the entries */ + tmp_lightobj = + (struct gator_lightobj *)(*tmp_fsNames_o)->o_data; + sprintf(tmp_lightobj->label, "%s", ""); + } + + tmp_fsNames_o++; /* next onode */ + fsDataP++; /* next host's data */ + fsIdx++; /* host index */ } + } - tmp_fsNames_o++; /* next onode */ - fsDataP++; /* next host's data */ - fsIdx++; /* host index */ - } - } /* if numFS */ + /* if numFS */ + /* if we have any cache managers, update them if we are asked to */ + if (numCM && (a_updateType & OVW_UPDATE_CM)) { - /* if we have any cache managers, update them if we are asked to */ - if (numCM && (a_updateType & OVW_UPDATE_CM)){ + /* move to the right spot in the CM display data array */ + cmDataP = prev_cmData; + cmIdx = 0; + for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) { + cmDataP++; + cmIdx++; + } - /* move to the right spot in the CM display data array */ - cmDataP = prev_cmData; - cmIdx = 0; - for(i=0; i < ((a_pageNum-1) * ovw_numHosts_perPage); i++) { - cmDataP++; - cmIdx++; - } - - /* get the address to the first CM name */ - tmp_cmNames_o = ovw_cmNames_o; + /* get the address to the first CM name */ + tmp_cmNames_o = ovw_cmNames_o; - for (i=0; i < ovw_numHosts_perPage; i++) { - if (cmIdx < numCM) { /* this could be the last & partial page */ + for (i = 0; i < ovw_numHosts_perPage; i++) { + if (cmIdx < numCM) { /* this could be the last & partial page */ if (cmDataP->hostName[0] == '\0') { - sprintf(errMsg,"[ %s ] empty cm display entry \n",rn); - afsmon_Exit(245); + sprintf(errMsg, "[ %s ] empty cm display entry \n", rn); + afsmon_Exit(245); } /* check if the probe succeeded. if it did check for thresholds - overflow. A failed probe is indicated by "PF" */ + * overflow. A failed probe is indicated by "PF" */ - if (! cmDataP->probeOK) { - sprintf(printBuf,"[ PF] %s", cmDataP->hostName); + if (!cmDataP->probeOK) { + sprintf(printBuf, "[ PF] %s", cmDataP->hostName); } else if (cmDataP->ovfCount) { /* thresholds overflow */ - sprintf(printBuf,"[%3d] %s", - cmDataP->ovfCount,cmDataP->hostName); - } else - sprintf(printBuf," %s",cmDataP->hostName); - + sprintf(printBuf, "[%3d] %s", cmDataP->ovfCount, + cmDataP->hostName); + } else + sprintf(printBuf, " %s", cmDataP->hostName); + if (afsmon_debug) - fprintf(debugFD,"[ %s ] to display %s\n",rn,printBuf); + fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf); - tmp_lightobj=(struct gator_lightobj *) (*tmp_cmNames_o)->o_data; + tmp_lightobj = + (struct gator_lightobj *)(*tmp_cmNames_o)->o_data; - if (strlen(printBuf)+1 < OVW_HOSTNAME_O_WIDTH_HGL) - len = OVW_HOSTNAME_O_WIDTH_HGL; - else - len = strlen(printBuf)+1; + if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL) + len = OVW_HOSTNAME_O_WIDTH_HGL; + else + len = strlen(printBuf) + 1; - code = justify_light(printBuf,tmp_lightobj->label, - len, LEFT_JUSTIFY, 1); + code = + justify_light(printBuf, tmp_lightobj->label, len, + LEFT_JUSTIFY, 1); if (code) { - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] justify_code returned %d\n", - rn,code); - } + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] justify_code returned %d\n", + rn, code); + } } /* highlighten if overflow or if probe failed */ - if (cmDataP->ovfCount || ! cmDataP->probeOK) - code = gator_light_set(*tmp_cmNames_o,1); - else - code = gator_light_set(*tmp_cmNames_o,0); + if (cmDataP->ovfCount || !cmDataP->probeOK) + code = gator_light_set(*tmp_cmNames_o, 1); + else + code = gator_light_set(*tmp_cmNames_o, 0); + + } else { /* no more hosts, blank the rest of the entries */ + tmp_lightobj = + (struct gator_lightobj *)(*tmp_cmNames_o)->o_data; + sprintf(tmp_lightobj->label, "%s", ""); + } - } else { /* no more hosts, blank the rest of the entries */ - tmp_lightobj=(struct gator_lightobj *) (*tmp_cmNames_o)->o_data; - sprintf(tmp_lightobj->label,"%s",""); + tmp_cmNames_o++; /* next onode */ + cmDataP++; /* next host's data */ + cmIdx++; /* host index */ } + } - tmp_cmNames_o++; /* next onode */ - cmDataP++; /* next host's data */ - cmIdx++; /* host index */ - } - } /* if numCM */ + /* if numCM */ + /* redraw the display if the overview screen is currently displayed */ + if (afsmon_win->w_frame == ovwFrame) + WOP_DISPLAY(afsmon_win); - /* redraw the display if the overview screen is currently displayed */ - if (afsmon_win->w_frame == ovwFrame) - WOP_DISPLAY(afsmon_win); + return (0); - return(0); +} /* ovw_refresh */ -} /* ovw_refresh */ - /*----------------------------------------------------------------------- @@ -891,17 +905,17 @@ int a_updateType; /* OVW_UPDATE_FS = update fs column only, int Switch_ovw_2_fs() { - static char rn[] = "Switch_ovw_2_fs"; + static char rn[] = "Switch_ovw_2_fs"; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); } - /* bind the File Server frame to the window */ - if (ovw_pageType & CMD_FS) - gtxframe_SetFrame(afsmon_win,fsFrame); - return(0); + /* bind the File Server frame to the window */ + if (ovw_pageType & CMD_FS) + gtxframe_SetFrame(afsmon_win, fsFrame); + return (0); } /*----------------------------------------------------------------------- @@ -913,17 +927,17 @@ Switch_ovw_2_fs() int Switch_ovw_2_cm() { - static char rn[] = "Switch_ovw_2_cm"; + static char rn[] = "Switch_ovw_2_cm"; - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); - } + } - /* bind the Cache Managers frame to the window */ - if (ovw_pageType & CMD_CM) - gtxframe_SetFrame(afsmon_win,cmFrame); - return(0); + /* bind the Cache Managers frame to the window */ + if (ovw_pageType & CMD_CM) + gtxframe_SetFrame(afsmon_win, cmFrame); + return (0); } /*----------------------------------------------------------------------- @@ -935,19 +949,19 @@ Switch_ovw_2_cm() int Switch_ovw_next() { - static char rn[] = "Switch_ovw_next"; + static char rn[] = "Switch_ovw_next"; - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); - } + } - if (ovw_pageType & CMD_NEXT) { + if (ovw_pageType & CMD_NEXT) { /* call refresh with the next page number */ - ovw_refresh(ovw_currPage + 1,ovw_update_info); - } + ovw_refresh(ovw_currPage + 1, ovw_update_info); + } - return(0); + return (0); } /*----------------------------------------------------------------------- @@ -959,19 +973,19 @@ Switch_ovw_next() int Switch_ovw_last() { - static char rn[] = "Switch_ovw_last"; + static char rn[] = "Switch_ovw_last"; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); } - if (ovw_pageType & CMD_NEXT) { + if (ovw_pageType & CMD_NEXT) { /* call refresh with the last page number */ ovw_refresh(ovw_numPages, ovw_update_info); - } + } - return(0); + return (0); } /*----------------------------------------------------------------------- @@ -983,18 +997,18 @@ Switch_ovw_last() int Switch_ovw_prev() { - static char rn[] = "Switch_ovw_prev"; + static char rn[] = "Switch_ovw_prev"; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); } - if (ovw_pageType & CMD_PREV) { - /* call refresh with the previous page number */ - ovw_refresh(ovw_currPage - 1,ovw_update_info); - } - return(0); + if (ovw_pageType & CMD_PREV) { + /* call refresh with the previous page number */ + ovw_refresh(ovw_currPage - 1, ovw_update_info); + } + return (0); } /*----------------------------------------------------------------------- @@ -1006,18 +1020,18 @@ Switch_ovw_prev() int Switch_ovw_first() { - static char rn[] = "Switch_ovw_first"; + static char rn[] = "Switch_ovw_first"; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); } - if (ovw_pageType & CMD_PREV) { - /* refresh with the first page number */ + if (ovw_pageType & CMD_PREV) { + /* refresh with the first page number */ ovw_refresh(1, ovw_update_info); - } - return(0); + } + return (0); } /*----------------------------------------------------------------------- @@ -1038,226 +1052,235 @@ Switch_ovw_first() int create_ovwFrame_objects() -{ /* create_ovwFrame_objects */ +{ /* create_ovwFrame_objects */ - static char rn[] = "create_ovwFrame_objects"; - int hostLines; /* number of lines of host names to display */ - struct onode **ovw_fsNames_o_Ptr; /* index to list of fs names onodes */ - struct onode **ovw_cmNames_o_Ptr; /* index to list of cm names onodes */ - int code; - int i; + static char rn[] = "create_ovwFrame_objects"; + int hostLines; /* number of lines of host names to display */ + struct onode **ovw_fsNames_o_Ptr; /* index to list of fs names onodes */ + struct onode **ovw_cmNames_o_Ptr; /* index to list of cm names onodes */ + int code; + int i; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); } - /* get frame dimensions, it must be atleast MINXxMINY for any sensible output*/ - WOP_GETDIMENSIONS(ovwFrame->window,&frameDims); - maxX = frameDims.maxx; - maxY = frameDims.maxy; - if (maxX + 1 < MINX || maxY + 1 < MINY) { - sprintf(errMsg1,"[ %s ] Window size %dx%d; must be at least %dx%d\n", + /* get frame dimensions, it must be atleast MINXxMINY for any sensible output */ + WOP_GETDIMENSIONS(ovwFrame->window, &frameDims); + maxX = frameDims.maxx; + maxY = frameDims.maxy; + if (maxX + 1 < MINX || maxY + 1 < MINY) { + sprintf(errMsg1, "[ %s ] Window size %dx%d; must be at least %dx%d\n", rn, maxX + 1, maxY + 1, MINX, MINY); - return(-1); - } - if (afsmon_debug) - fprintf(debugFD,"maxX = %d maxY = %d\n",maxX,maxY); - - - /* Print an Intial message to the screen. The init message is 36 chars - long */ - initMsg_o = initLightObject(initMsg, - maxX/2 - 18,maxY/3,sizeof(initMsg),afsmon_win); - if (initMsg_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create initMsg_o onode\n",rn); + return (-1); + } + if (afsmon_debug) + fprintf(debugFD, "maxX = %d maxY = %d\n", maxX, maxY); + + + /* Print an Intial message to the screen. The init message is 36 chars + * long */ + initMsg_o = + initLightObject(initMsg, maxX / 2 - 18, maxY / 3, sizeof(initMsg), + afsmon_win); + if (initMsg_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create initMsg_o onode\n", rn); afsmon_Exit(250); - } - code = gtxframe_AddToList(ovwFrame,initMsg_o); - code = gator_light_set(initMsg_o,HIGHLIGHT); - initMsg_on = 1; + } + code = gtxframe_AddToList(ovwFrame, initMsg_o); + code = gator_light_set(initMsg_o, HIGHLIGHT); + initMsg_on = 1; - /* create the command line object */ + /* create the command line object */ - ovw_cmd_o = initLightObject("", - 0,maxY-1,OVW_CMD_O_WIDTH,afsmon_win); - if (ovw_cmd_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create command onode\n",rn); + ovw_cmd_o = initLightObject("", 0, maxY - 1, OVW_CMD_O_WIDTH, afsmon_win); + if (ovw_cmd_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create command onode\n", rn); afsmon_Exit(265); - } - code = gtxframe_AddToList(ovwFrame,ovw_cmd_o); - code = gator_light_set(ovw_cmd_o,HIGHLIGHT); + } + code = gtxframe_AddToList(ovwFrame, ovw_cmd_o); + code = gator_light_set(ovw_cmd_o, HIGHLIGHT); - /* create the program name object */ + /* create the program name object */ - ovw_progName_o = initLightObject("",0,0, - PROGNAME_O_WIDTH,afsmon_win); - if (ovw_progName_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create programName onode\n",rn); + ovw_progName_o = initLightObject("", 0, 0, PROGNAME_O_WIDTH, afsmon_win); + if (ovw_progName_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create programName onode\n", rn); afsmon_Exit(255); - } - code = gtxframe_AddToList(ovwFrame,ovw_progName_o); - code = gator_light_set(ovw_progName_o,HIGHLIGHT); + } + code = gtxframe_AddToList(ovwFrame, ovw_progName_o); + code = gator_light_set(ovw_progName_o, HIGHLIGHT); - /* create the page number object */ + /* create the page number object */ - ovw_pageNum_o = initLightObject("", - maxX-OVW_PAGENUM_O_WIDTH,0,OVW_PAGENUM_O_WIDTH,afsmon_win); - if (ovw_pageNum_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create pageNumber onode\n",rn); + ovw_pageNum_o = + initLightObject("", maxX - OVW_PAGENUM_O_WIDTH, 0, + OVW_PAGENUM_O_WIDTH, afsmon_win); + if (ovw_pageNum_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn); afsmon_Exit(260); - } - code = gtxframe_AddToList(ovwFrame,ovw_pageNum_o); - code = gator_light_set(ovw_pageNum_o,HIGHLIGHT); - - /* create the probe number object */ - ovw_probeNum_o = initLightObject("", - maxX-OVW_PROBENUM_O_WIDTH,maxY-1,OVW_PROBENUM_O_WIDTH,afsmon_win); - if (ovw_probeNum_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create probe number onode\n",rn); + } + code = gtxframe_AddToList(ovwFrame, ovw_pageNum_o); + code = gator_light_set(ovw_pageNum_o, HIGHLIGHT); + + /* create the probe number object */ + ovw_probeNum_o = + initLightObject("", maxX - OVW_PROBENUM_O_WIDTH, maxY - 1, + OVW_PROBENUM_O_WIDTH, afsmon_win); + if (ovw_probeNum_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create probe number onode\n", rn); afsmon_Exit(270); - } - code = gtxframe_AddToList(ovwFrame,ovw_probeNum_o); - code = gator_light_set(ovw_probeNum_o,HIGHLIGHT); - - /* create the numFS monitored object */ - ovw_numFS_o = initLightObject("", - 0,2,FC_NUMHOSTS_O_WIDTH,afsmon_win); - if (ovw_numFS_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create numFS onode\n",rn); + } + code = gtxframe_AddToList(ovwFrame, ovw_probeNum_o); + code = gator_light_set(ovw_probeNum_o, HIGHLIGHT); + + /* create the numFS monitored object */ + ovw_numFS_o = initLightObject("", 0, 2, FC_NUMHOSTS_O_WIDTH, afsmon_win); + if (ovw_numFS_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create numFS onode\n", rn); afsmon_Exit(275); - } - code = gtxframe_AddToList(ovwFrame,ovw_numFS_o); - - /* create the numCM monitored object */ - ovw_numCM_o = initLightObject("", - maxX/2,2,OVW_NUMCM_O_WIDTH,afsmon_win); - if (ovw_numCM_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create numCM_o onode\n",rn); + } + code = gtxframe_AddToList(ovwFrame, ovw_numFS_o); + + /* create the numCM monitored object */ + ovw_numCM_o = + initLightObject("", maxX / 2, 2, OVW_NUMCM_O_WIDTH, afsmon_win); + if (ovw_numCM_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create numCM_o onode\n", rn); afsmon_Exit(280); - } - code = gtxframe_AddToList(ovwFrame,ovw_numCM_o); - - /* create the number-of-FS-alerts object */ - ovw_FSalerts_o = initLightObject("", - 0,3,OVW_FSALERTS_O_WIDTH,afsmon_win); - if (ovw_FSalerts_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create FSalerts_o onode\n",rn); + } + code = gtxframe_AddToList(ovwFrame, ovw_numCM_o); + + /* create the number-of-FS-alerts object */ + ovw_FSalerts_o = + initLightObject("", 0, 3, OVW_FSALERTS_O_WIDTH, afsmon_win); + if (ovw_FSalerts_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create FSalerts_o onode\n", rn); afsmon_Exit(285); - } - code = gtxframe_AddToList(ovwFrame,ovw_FSalerts_o); - - /* create the number-of-CM-alerts object */ - ovw_CMalerts_o = initLightObject("", - maxX/2,3,OVW_CMALERTS_O_WIDTH,afsmon_win); - if (ovw_CMalerts_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create CMalerts_o onode\n",rn); + } + code = gtxframe_AddToList(ovwFrame, ovw_FSalerts_o); + + /* create the number-of-CM-alerts object */ + ovw_CMalerts_o = + initLightObject("", maxX / 2, 3, OVW_CMALERTS_O_WIDTH, afsmon_win); + if (ovw_CMalerts_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create CMalerts_o onode\n", rn); afsmon_Exit(290); - } - code = gtxframe_AddToList(ovwFrame,ovw_CMalerts_o); + } + code = gtxframe_AddToList(ovwFrame, ovw_CMalerts_o); - /* create file-server-name and cache-manager-names objects */ - ovw_numHosts_perPage = maxY - OVW_NUM_FIXED_LINES; + /* create file-server-name and cache-manager-names objects */ + ovw_numHosts_perPage = maxY - OVW_NUM_FIXED_LINES; - /* allocate memory for a list of onode pointers for file server names */ - ovw_fsNames_o = (struct onode **) malloc( - sizeof(struct onode *) * ovw_numHosts_perPage); - if (ovw_fsNames_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to allocate memory for FS onodes\n",rn); + /* allocate memory for a list of onode pointers for file server names */ + ovw_fsNames_o = + (struct onode **)malloc(sizeof(struct onode *) * + ovw_numHosts_perPage); + if (ovw_fsNames_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to allocate memory for FS onodes\n", + rn); afsmon_Exit(295); - } - - /* create file server name objects */ - ovw_fsNames_o_Ptr = ovw_fsNames_o; - for (i=0; i< ovw_numHosts_perPage; i++) { - *ovw_fsNames_o_Ptr = initLightObject("", - 0,OVW_FIRST_HOST_ROW+i,OVW_HOSTNAME_O_WIDTH,afsmon_win); - if (*ovw_fsNames_o_Ptr == NULL) { - sprintf(errMsg,"[ %s ] Failed to create an FS name onode\n",rn); - afsmon_Exit(300); - } - /* - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] fsName_o %d: %d\n", - rn,i,*ovw_fsNames_o_Ptr); - fflush(debugFD); + } + + /* create file server name objects */ + ovw_fsNames_o_Ptr = ovw_fsNames_o; + for (i = 0; i < ovw_numHosts_perPage; i++) { + *ovw_fsNames_o_Ptr = + initLightObject("", 0, OVW_FIRST_HOST_ROW + i, + OVW_HOSTNAME_O_WIDTH, afsmon_win); + if (*ovw_fsNames_o_Ptr == NULL) { + sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn); + afsmon_Exit(300); } - */ - code = gtxframe_AddToList(ovwFrame,*ovw_fsNames_o_Ptr); + /* + * if (afsmon_debug) { + * fprintf(debugFD,"[ %s ] fsName_o %d: %d\n", + * rn,i,*ovw_fsNames_o_Ptr); + * fflush(debugFD); + * } + */ + code = gtxframe_AddToList(ovwFrame, *ovw_fsNames_o_Ptr); ovw_fsNames_o_Ptr++; - } - - - /* allocate memory for a list of onode pointers for cache manager names */ - ovw_cmNames_o = (struct onode **) malloc( - sizeof(struct onode *) * ovw_numHosts_perPage); - if (ovw_cmNames_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to allocate memory for CM onodes\n",rn); + } + + + /* allocate memory for a list of onode pointers for cache manager names */ + ovw_cmNames_o = + (struct onode **)malloc(sizeof(struct onode *) * + ovw_numHosts_perPage); + if (ovw_cmNames_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to allocate memory for CM onodes\n", + rn); afsmon_Exit(305); - } - - /* create cache manager name objects */ - ovw_cmNames_o_Ptr = ovw_cmNames_o; - for (i=0; i< ovw_numHosts_perPage; i++) { - *ovw_cmNames_o_Ptr = initLightObject("", - maxX/2,OVW_FIRST_HOST_ROW+i,OVW_HOSTNAME_O_WIDTH,afsmon_win); - if (*ovw_cmNames_o_Ptr == NULL) { - sprintf(errMsg,"[ %s ] Failed to create a CM name onode\n",rn); - afsmon_Exit(310); - } - code = gtxframe_AddToList(ovwFrame,*ovw_cmNames_o_Ptr); + } + + /* create cache manager name objects */ + ovw_cmNames_o_Ptr = ovw_cmNames_o; + for (i = 0; i < ovw_numHosts_perPage; i++) { + *ovw_cmNames_o_Ptr = + initLightObject("", maxX / 2, OVW_FIRST_HOST_ROW + i, + OVW_HOSTNAME_O_WIDTH, afsmon_win); + if (*ovw_cmNames_o_Ptr == NULL) { + sprintf(errMsg, "[ %s ] Failed to create a CM name onode\n", rn); + afsmon_Exit(310); + } + code = gtxframe_AddToList(ovwFrame, *ovw_cmNames_o_Ptr); ovw_cmNames_o_Ptr++; - } + } - /* Calculate the number of pages of overview data to display */ - /* host information starts at the 6th line from top and stops at 3rd - line from bottom of screen */ + /* Calculate the number of pages of overview data to display */ + /* host information starts at the 6th line from top and stops at 3rd + * line from bottom of screen */ - if (numFS > numCM) hostLines = numFS; - else hostLines = numCM; + if (numFS > numCM) + hostLines = numFS; + else + hostLines = numCM; - ovw_numPages = hostLines / (maxY - OVW_NUM_FIXED_LINES); - if ( hostLines % (maxY - OVW_NUM_FIXED_LINES) ) + ovw_numPages = hostLines / (maxY - OVW_NUM_FIXED_LINES); + if (hostLines % (maxY - OVW_NUM_FIXED_LINES)) ovw_numPages++; - - if (afsmon_debug) - fprintf(debugFD,"[ %s ] number of ovw pages = %d\n",rn,ovw_numPages); - - /* When the ovw_refresh() routine is called by the keyboard handlers the - following variable is used to determine if fs/cm/fs&cm info must be - updated */ - ovw_update_info = 0; - if (numFS) - ovw_update_info |= OVW_UPDATE_FS; - if (numCM) - ovw_update_info |= OVW_UPDATE_CM; - - /* bind the overview frame to a keyboard input handler */ - - /* bind Q and  to exit */ - keymap_BindToString(ovwFrame->keymap,"Q",afsmonExit_gtx,NULL,NULL); - keymap_BindToString(ovwFrame->keymap,"",afsmonExit_gtx,NULL,NULL); - - /* f -> switch of fs frame */ - keymap_BindToString(ovwFrame->keymap,"f",Switch_ovw_2_fs,NULL,NULL); - /* c -> switch of cm frame */ - keymap_BindToString(ovwFrame->keymap,"c",Switch_ovw_2_cm,NULL,NULL); - /* n -> switch to next overview page */ - keymap_BindToString(ovwFrame->keymap,"n",Switch_ovw_next,NULL,NULL); - /* N -> switch to last overview page */ - keymap_BindToString(ovwFrame->keymap,"N",Switch_ovw_last,NULL,NULL); - /* p -> switch to previous overview page */ - keymap_BindToString(ovwFrame->keymap,"p",Switch_ovw_prev,NULL,NULL); - /* P -> switch to first overview page */ - keymap_BindToString(ovwFrame->keymap,"P",Switch_ovw_first,NULL,NULL); - - - return(0); -} /* create_ovwFrame_objects */ + + if (afsmon_debug) + fprintf(debugFD, "[ %s ] number of ovw pages = %d\n", rn, + ovw_numPages); + + /* When the ovw_refresh() routine is called by the keyboard handlers the + * following variable is used to determine if fs/cm/fs&cm info must be + * updated */ + ovw_update_info = 0; + if (numFS) + ovw_update_info |= OVW_UPDATE_FS; + if (numCM) + ovw_update_info |= OVW_UPDATE_CM; + + /* bind the overview frame to a keyboard input handler */ + + /* bind Q and  to exit */ + keymap_BindToString(ovwFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL); + keymap_BindToString(ovwFrame->keymap, "", afsmonExit_gtx, NULL, NULL); + + /* f -> switch of fs frame */ + keymap_BindToString(ovwFrame->keymap, "f", Switch_ovw_2_fs, NULL, NULL); + /* c -> switch of cm frame */ + keymap_BindToString(ovwFrame->keymap, "c", Switch_ovw_2_cm, NULL, NULL); + /* n -> switch to next overview page */ + keymap_BindToString(ovwFrame->keymap, "n", Switch_ovw_next, NULL, NULL); + /* N -> switch to last overview page */ + keymap_BindToString(ovwFrame->keymap, "N", Switch_ovw_last, NULL, NULL); + /* p -> switch to previous overview page */ + keymap_BindToString(ovwFrame->keymap, "p", Switch_ovw_prev, NULL, NULL); + /* P -> switch to first overview page */ + keymap_BindToString(ovwFrame->keymap, "P", Switch_ovw_first, NULL, NULL); + + + return (0); +} /* create_ovwFrame_objects */ /*----------------------------------------------------------------------- @@ -1276,77 +1299,80 @@ create_ovwFrame_objects() *----------------------------------------------------------------------*/ int -resolve_CmdLine(a_buffer, a_currFrame, a_currPage, a_numPages, - a_numCols, a_curr_LCol, a_cols_perPage, a_Data_Available) -char *a_buffer; /* buffer to copy command line */ -int a_currFrame; /* current frame ovw, fs or cm? */ -int a_currPage; /* current page number */ -int a_numPages; /* number of pages of data */ -int a_numCols; /* number of columns of data to display */ -int a_curr_LCol; /* current number of leftmost column */ -int a_cols_perPage; /* number of columns per page */ - -{ /* resolve_CmdLine */ - static char rn[] = "resolve_CmdLine"; - int pageType; +resolve_CmdLine(a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols, + a_curr_LCol, a_cols_perPage, a_Data_Available) + char *a_buffer; /* buffer to copy command line */ + int a_currFrame; /* current frame ovw, fs or cm? */ + int a_currPage; /* current page number */ + int a_numPages; /* number of pages of data */ + int a_numCols; /* number of columns of data to display */ + int a_curr_LCol; /* current number of leftmost column */ + int a_cols_perPage; /* number of columns per page */ + +{ /* resolve_CmdLine */ + static char rn[] = "resolve_CmdLine"; + int pageType; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_buffer= %d, a_currFrame= %d, a_currPage= %d, a_numPages= %d, a_numCols= %d, a_curr_LCol= %d, a_cols_perPage= %d\n", - rn, a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols, - a_curr_LCol, a_cols_perPage); + fprintf(debugFD, + "[ %s ] Called, a_buffer= %d, a_currFrame= %d, a_currPage= %d, a_numPages= %d, a_numCols= %d, a_curr_LCol= %d, a_cols_perPage= %d\n", + rn, a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols, + a_curr_LCol, a_cols_perPage); fflush(debugFD); } - pageType = 0; - - /* determine if we have fs/cm frames. If we do, note that we should not - let the user seen the initial junk we have there until the probe - results are available */ - if (a_currFrame == 1) { /* in the fs frame */ - if (numCM && cm_Data_Available) pageType |= CMD_CM; - } else if (a_currFrame == 2) { /* in the cm frame */ - if (numFS && fs_Data_Available) pageType |= CMD_FS; - } else { + pageType = 0; + + /* determine if we have fs/cm frames. If we do, note that we should not + * let the user seen the initial junk we have there until the probe + * results are available */ + if (a_currFrame == 1) { /* in the fs frame */ + if (numCM && cm_Data_Available) + pageType |= CMD_CM; + } else if (a_currFrame == 2) { /* in the cm frame */ + if (numFS && fs_Data_Available) + pageType |= CMD_FS; + } else { if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Wrong frame type %d\n",rn,a_currFrame); - fflush(debugFD); + fprintf(debugFD, "[ %s ] Wrong frame type %d\n", rn, a_currFrame); + fflush(debugFD); } - return(-1); - } + return (-1); + } - /* do we have next/previous pages */ - if ( a_currPage < a_numPages ) + /* do we have next/previous pages */ + if (a_currPage < a_numPages) pageType |= CMD_NEXT; /* have a next page */ - if ( a_currPage > 1 ) + if (a_currPage > 1) pageType |= CMD_PREV; /* have a previous page */ - - if ( a_numCols > a_cols_perPage ) { - if ( a_curr_LCol > 0 ) - pageType |= CMD_LEFT; /* have columns on left */ - if ( (a_curr_LCol + a_cols_perPage ) < a_numCols ) - pageType |= CMD_RIGHT; /* have columns on right */ - } - - /* now build the command line */ - - strcpy(a_buffer,"Command [oview"); - if ( pageType & CMD_FS) - strcat(a_buffer,", fs"); - if ( pageType & CMD_CM) - strcat(a_buffer,", cm"); - if ( pageType & CMD_PREV ) - strcat(a_buffer,", prev"); - if ( pageType & CMD_NEXT ) - strcat(a_buffer,", next"); - if ( pageType & CMD_LEFT ) - strcat(a_buffer,", left"); - if ( pageType & CMD_RIGHT ) - strcat(a_buffer,", right"); - strcat(a_buffer,"]? "); - - return(pageType); - -} /* resolve_CmdLine */ + + if (a_numCols > a_cols_perPage) { + if (a_curr_LCol > 0) + pageType |= CMD_LEFT; /* have columns on left */ + if ((a_curr_LCol + a_cols_perPage) < a_numCols) + pageType |= CMD_RIGHT; /* have columns on right */ + } + + /* now build the command line */ + + strcpy(a_buffer, "Command [oview"); + if (pageType & CMD_FS) + strcat(a_buffer, ", fs"); + if (pageType & CMD_CM) + strcat(a_buffer, ", cm"); + if (pageType & CMD_PREV) + strcat(a_buffer, ", prev"); + if (pageType & CMD_NEXT) + strcat(a_buffer, ", next"); + if (pageType & CMD_LEFT) + strcat(a_buffer, ", left"); + if (pageType & CMD_RIGHT) + strcat(a_buffer, ", right"); + strcat(a_buffer, "]? "); + + return (pageType); + +} /* resolve_CmdLine */ /*----------------------------------------------------------------------- * display_Server_datum() @@ -1365,96 +1391,101 @@ int a_cols_perPage; /* number of columns per page */ * 0 always *----------------------------------------------------------------------*/ int -display_Server_datum(a_srcBuf, a_firstObj_o, a_secondObj_o, - a_probeOK, a_just, a_highlight) +display_Server_datum(a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK, a_just, + a_highlight) -char *a_srcBuf; /* source buffer */ -struct onode *a_firstObj_o; /* first object */ -struct onode *a_secondObj_o; /* second object */ -int a_probeOK; /* probe OK ? */ -int a_just; /* justification */ -int a_highlight; /* highlight object ? */ + char *a_srcBuf; /* source buffer */ + struct onode *a_firstObj_o; /* first object */ + struct onode *a_secondObj_o; /* second object */ + int a_probeOK; /* probe OK ? */ + int a_just; /* justification */ + int a_highlight; /* highlight object ? */ -{ /* display_Server_datum */ +{ /* display_Server_datum */ static char rn[] = "display_Server_datum"; struct gator_lightobj *tmp_lightobj1; struct gator_lightobj *tmp_lightobj2; - char part1[FC_COLUMN_WIDTH+2]; - char part2[FC_COLUMN_WIDTH+2]; + char part1[FC_COLUMN_WIDTH + 2]; + char part2[FC_COLUMN_WIDTH + 2]; int code; if (afsmon_debug) { if (a_highlight) - fprintf(debugFD,"[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_probeOK= %d, a_just= %d, a_highlight= %d\n", rn, - a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK, a_just, a_highlight); + fprintf(debugFD, + "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_probeOK= %d, a_just= %d, a_highlight= %d\n", + rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK, + a_just, a_highlight); fflush(debugFD); } - tmp_lightobj1 = (struct gator_lightobj *) a_firstObj_o->o_data; - tmp_lightobj2 = (struct gator_lightobj *) a_secondObj_o->o_data; + tmp_lightobj1 = (struct gator_lightobj *)a_firstObj_o->o_data; + tmp_lightobj2 = (struct gator_lightobj *)a_secondObj_o->o_data; - if (a_probeOK) { /* probe is ok so fill in the data */ + if (a_probeOK) { /* probe is ok so fill in the data */ /* check if it would fit in one object */ if (strlen(a_srcBuf) < FC_COLUMN_WIDTH) { - strcpy(part1, a_srcBuf ); - strcpy(part2, ""); + strcpy(part1, a_srcBuf); + strcpy(part2, ""); } else { - /* break up the src string into 2 parts */ - /* note that column width includes terminator */ - strncpy(part1, a_srcBuf, FC_COLUMN_WIDTH-1); - part1[FC_COLUMN_WIDTH-1] = '\0'; - strncpy(part2, a_srcBuf+FC_COLUMN_WIDTH-1, FC_COLUMN_WIDTH-1); + /* break up the src string into 2 parts */ + /* note that column width includes terminator */ + strncpy(part1, a_srcBuf, FC_COLUMN_WIDTH - 1); + part1[FC_COLUMN_WIDTH - 1] = '\0'; + strncpy(part2, a_srcBuf + FC_COLUMN_WIDTH - 1, + FC_COLUMN_WIDTH - 1); } - } else { /* probe failed, enter "--"s */ - strcpy(part1,"--"); - strcpy(part2,""); - } + } else { /* probe failed, enter "--"s */ + strcpy(part1, "--"); + strcpy(part2, ""); + } - /* if (afsmon_debug) { - fprintf(debugFD,"[ %s ] %s split to %s & %s\n",rn,a_srcBuf,part1,part2); - fflush(debugFD); - } */ + /* if (afsmon_debug) { + * fprintf(debugFD,"[ %s ] %s split to %s & %s\n",rn,a_srcBuf,part1,part2); + * fflush(debugFD); + * } */ - /* initialize both the objects */ + /* initialize both the objects */ - code = justify_light(part1, tmp_lightobj1->label, - FC_COLUMN_WIDTH, a_just, 1); - if (code) { + code = + justify_light(part1, tmp_lightobj1->label, FC_COLUMN_WIDTH, a_just, + 1); + if (code) { if (afsmon_debug) { - fprintf(debugFD,"[ %s ] justify_light failed 1 \n",rn); - fflush(debugFD); + fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn); + fflush(debugFD); } - } + } - code = justify_light(part2, tmp_lightobj2->label, - FC_COLUMN_WIDTH, a_just, 1); - if (code) { + code = + justify_light(part2, tmp_lightobj2->label, FC_COLUMN_WIDTH, a_just, + 1); + if (code) { if (afsmon_debug) { - fprintf(debugFD,"[ %s ] justify_light failed 1 \n",rn); - fflush(debugFD); + fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn); + fflush(debugFD); } - } + } - /* highlight them */ - if (a_highlight && (part1[0] != '-')) + /* highlight them */ + if (a_highlight && (part1[0] != '-')) gator_light_set(a_firstObj_o, 1); - else + else gator_light_set(a_firstObj_o, 0); - if (a_highlight && (part2[0] != '\0')) + if (a_highlight && (part2[0] != '\0')) gator_light_set(a_secondObj_o, 1); - else + else gator_light_set(a_secondObj_o, 0); - - return(0); -} /* display_Server_datum */ + return (0); + +} /* display_Server_datum */ /*----------------------------------------------------------------------- @@ -1471,83 +1502,87 @@ int a_highlight; /* highlight object ? */ int display_Server_label(a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o) -char *a_srcBuf; -struct onode *a_firstObj_o; /* first object */ -struct onode *a_secondObj_o; /* second object */ -struct onode *a_thirdObj_o; /* third object */ - -{ /* display_Server_label */ - - static char rn[] = "display_Server_label"; - char part[3][20]; /* buffer for three parts of label */ - char *strPtr; - struct gator_lightobj *tmp_lightobj; - struct onode *objPtr_o[3]; - int code; - int strLen; - int len; - int i; - int j; + char *a_srcBuf; + struct onode *a_firstObj_o; /* first object */ + struct onode *a_secondObj_o; /* second object */ + struct onode *a_thirdObj_o; /* third object */ + +{ /* display_Server_label */ + + static char rn[] = "display_Server_label"; + char part[3][20]; /* buffer for three parts of label */ + char *strPtr; + struct gator_lightobj *tmp_lightobj; + struct onode *objPtr_o[3]; + int code; + int strLen; + int len; + int i; + int j; /* the following debug statement floods the debug file */ #ifdef DEBUG_DETAILED if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_thirdObj_o= %d\n", - rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o); + fprintf(debugFD, + "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_thirdObj_o= %d\n", + rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o); fflush(debugFD); } #endif - /* break the label string into three parts */ + /* break the label string into three parts */ - part[0][0] = '\0'; part[1][0] = '\0'; part[2][0] = '\0'; - /* now for a dumb precaution */ + part[0][0] = '\0'; + part[1][0] = '\0'; + part[2][0] = '\0'; + /* now for a dumb precaution */ - strLen = strlen(a_srcBuf); - len = 0; - strPtr = a_srcBuf; - for(i=0; i < 3; i++) { + strLen = strlen(a_srcBuf); + len = 0; + strPtr = a_srcBuf; + for (i = 0; i < 3; i++) { j = 0; while (*strPtr != '\0' && (len++ <= strLen)) { - if (*strPtr == '/') { - strPtr++; - break; - } - else part[i][j] = *strPtr; + if (*strPtr == '/') { strPtr++; - j++; + break; + } else + part[i][j] = *strPtr; + strPtr++; + j++; } part[i][j] = '\0'; - } - - /* - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] LABELS %s -> %s %s %s\n", - rn, a_srcBuf, part[0], part[1], part[2]); - fflush(debugFD); - } - */ - - objPtr_o[0] = a_firstObj_o; - objPtr_o[1] = a_secondObj_o; - objPtr_o[2] = a_thirdObj_o; - - /* display each label justified CENTER */ - - for (i = 0; i < 3; i++) { - tmp_lightobj = (struct gator_lightobj *) objPtr_o[i]->o_data; - code = justify_light(part[i], tmp_lightobj->label, - FC_COLUMN_WIDTH, CENTER, 1); - if (code) { - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] justify_light %d failed \n",rn,i); + } + + /* + * if (afsmon_debug) { + * fprintf(debugFD,"[ %s ] LABELS %s -> %s %s %s\n", + * rn, a_srcBuf, part[0], part[1], part[2]); + * fflush(debugFD); + * } + */ + + objPtr_o[0] = a_firstObj_o; + objPtr_o[1] = a_secondObj_o; + objPtr_o[2] = a_thirdObj_o; + + /* display each label justified CENTER */ + + for (i = 0; i < 3; i++) { + tmp_lightobj = (struct gator_lightobj *)objPtr_o[i]->o_data; + code = + justify_light(part[i], tmp_lightobj->label, FC_COLUMN_WIDTH, + CENTER, 1); + if (code) { + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] justify_light %d failed \n", rn, i); fflush(debugFD); - } - } - } + } + } + } -} /* display_Server_label */ +} /* display_Server_label */ @@ -1572,312 +1607,313 @@ struct onode *a_thirdObj_o; /* third object */ int fs_refresh(a_pageNum, a_LcolNum) -int a_pageNum; /* page to display */ -int a_LcolNum; /* starting (leftmost) column number */ - -{ /* fs_refresh */ - - static char rn[] = "fs_refresh"; /* routine name */ - struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */ - struct fs_Display_Data *fsDataP; /* ptr to FS display data array */ - struct ServerInfo_line *tmp_fs_lines_P; /* tmp ptr to fs_lines */ - struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */ - struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */ - struct onode **fsLabels_o_Ptr1; /* ptr to label row 0 */ - struct onode **fsLabels_o_Ptr2; /* ptr to label row 1 */ - struct onode **fsLabels_o_Ptr3; /* ptr to label row 2 */ - char cmdLine[80]; /* buffer for command line */ - char printBuf[256]; /* buffer to print to screen */ - int i; - int j; - int k; - int code; - int fsIdx; - int labelIdx; - int dataIndex; /* index to the data[] field of - struct fs_Display_Data */ - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called with row %d col %d \n", - rn, a_pageNum, a_LcolNum); + int a_pageNum; /* page to display */ + int a_LcolNum; /* starting (leftmost) column number */ + +{ /* fs_refresh */ + + static char rn[] = "fs_refresh"; /* routine name */ + struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */ + struct fs_Display_Data *fsDataP; /* ptr to FS display data array */ + struct ServerInfo_line *tmp_fs_lines_P; /* tmp ptr to fs_lines */ + struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */ + struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */ + struct onode **fsLabels_o_Ptr1; /* ptr to label row 0 */ + struct onode **fsLabels_o_Ptr2; /* ptr to label row 1 */ + struct onode **fsLabels_o_Ptr3; /* ptr to label row 2 */ + char cmdLine[80]; /* buffer for command line */ + char printBuf[256]; /* buffer to print to screen */ + int i; + int j; + int k; + int code; + int fsIdx; + int labelIdx; + int dataIndex; /* index to the data[] field of + * struct fs_Display_Data */ + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called with row %d col %d \n", rn, a_pageNum, + a_LcolNum); fflush(debugFD); - } + } - /* if the data is not yet available, ie., not one probe cycle has - completed, do nothing */ + /* if the data is not yet available, ie., not one probe cycle has + * completed, do nothing */ - if (! fs_Data_Available) - return(0); + if (!fs_Data_Available) + return (0); - /* validate the page number & column number */ - if (a_pageNum < 1 || a_pageNum > fs_numPages) { + /* validate the page number & column number */ + if (a_pageNum < 1 || a_pageNum > fs_numPages) { if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called with wrong page # %d \n",rn, a_pageNum); - fflush(debugFD); + fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn, + a_pageNum); + fflush(debugFD); } afsmon_Exit(315); - } - if (a_LcolNum < 0 || a_LcolNum > fs_numCols) { + } + if (a_LcolNum < 0 || a_LcolNum > fs_numCols) { if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called with wrong column #%d\n",rn, a_LcolNum); - fflush(debugFD); + fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn, + a_LcolNum); + fflush(debugFD); } afsmon_Exit(320); - } - - - - /* update the fixed labels */ - - /* we reuse the ovw version lable and hence do not have to do anything - for it here */ - - /* page number label */ - tmp_lightobj=(struct gator_lightobj *) fs_pageNum_o->o_data; - sprintf(printBuf,"[File Servers, p. %d of %d, c. %d of %d]", - a_pageNum, fs_numPages, a_LcolNum +1, fs_numCols); - justify_light(printBuf,tmp_lightobj->label, FC_PAGENUM_O_WIDTH, - RIGHT_JUSTIFY,1); - gator_light_set(fs_pageNum_o,1); - - /* file servers monitored label */ - tmp_lightobj=(struct gator_lightobj *) fs_numFS_o->o_data; - sprintf(printBuf,"%d File Servers monitored, %d alerts on %d machines", - numFS, num_fs_alerts, numHosts_onfs_alerts); - justify_light(printBuf,tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,1); - - - /* command line */ - - /* figure out what we need to show in the prompt & set the page type */ - /* the fs_pageType variable is in turn used by the keyboard handler - routines to call fs_refresh() with the correct parameters */ - - fs_pageType = resolve_CmdLine( cmdLine, 1 /* fs frame*/, a_pageNum, - fs_numPages, fs_numCols, a_LcolNum, fs_cols_perPage); - - /* display the command line */ - tmp_lightobj=(struct gator_lightobj *) fs_cmd_o->o_data; - sprintf(printBuf,"%s", cmdLine); - justify_light(printBuf,tmp_lightobj->label, strlen(printBuf)+1, - LEFT_JUSTIFY,1); - gator_light_set(fs_cmd_o, 1); - - /* update the probe number label */ - tmp_lightobj=(struct gator_lightobj *) fs_probeNum_o->o_data; - sprintf(printBuf,"[FS probes %d, freq=%d sec]", - afsmon_fs_prev_probeNum, afsmon_probefreq); - justify_light(printBuf,tmp_lightobj->label, FC_PROBENUM_O_WIDTH, - RIGHT_JUSTIFY,1); - gator_light_set(fs_probeNum_o, 1); - - /* update "columns on left" signal */ - tmp_lightobj=(struct gator_lightobj *) fs_leftArrows_o->o_data; - if (fs_pageType & CMD_LEFT) - strcpy(printBuf, "<<<"); - else - strcpy(printBuf,""); - justify_light(printBuf,tmp_lightobj->label, FC_ARROWS_O_WIDTH, - LEFT_JUSTIFY,1); - gator_light_set(fs_leftArrows_o, 0); - - /* update "columns on right" signal */ - tmp_lightobj=(struct gator_lightobj *) fs_rightArrows_o->o_data; - if (fs_pageType & CMD_RIGHT) - strcpy(printBuf, ">>>"); - else - strcpy(printBuf,""); - justify_light(printBuf,tmp_lightobj->label, FC_ARROWS_O_WIDTH, - RIGHT_JUSTIFY,1); - gator_light_set(fs_rightArrows_o, 0); - - - - /* UPDATE THE COLUMN LABELS */ - - /* the column index is also used to index the label arrays */ - labelIdx = a_LcolNum; - - /* get the pointers to the three arrays of label onodes */ - fsLabels_o_Ptr1 = fsLabels_o[0]; - fsLabels_o_Ptr2 = fsLabels_o[1]; - fsLabels_o_Ptr3 = fsLabels_o[2]; - - for(k=0; k < fs_cols_perPage; k++) { + } + + + + /* update the fixed labels */ + + /* we reuse the ovw version lable and hence do not have to do anything + * for it here */ + + /* page number label */ + tmp_lightobj = (struct gator_lightobj *)fs_pageNum_o->o_data; + sprintf(printBuf, "[File Servers, p. %d of %d, c. %d of %d]", a_pageNum, + fs_numPages, a_LcolNum + 1, fs_numCols); + justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH, + RIGHT_JUSTIFY, 1); + gator_light_set(fs_pageNum_o, 1); + + /* file servers monitored label */ + tmp_lightobj = (struct gator_lightobj *)fs_numFS_o->o_data; + sprintf(printBuf, "%d File Servers monitored, %d alerts on %d machines", + numFS, num_fs_alerts, numHosts_onfs_alerts); + justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER, + 1); + + + /* command line */ + + /* figure out what we need to show in the prompt & set the page type */ + /* the fs_pageType variable is in turn used by the keyboard handler + * routines to call fs_refresh() with the correct parameters */ + + fs_pageType = resolve_CmdLine(cmdLine, 1 /* fs frame */ , a_pageNum, + fs_numPages, fs_numCols, a_LcolNum, + fs_cols_perPage); + + /* display the command line */ + tmp_lightobj = (struct gator_lightobj *)fs_cmd_o->o_data; + sprintf(printBuf, "%s", cmdLine); + justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1, + LEFT_JUSTIFY, 1); + gator_light_set(fs_cmd_o, 1); + + /* update the probe number label */ + tmp_lightobj = (struct gator_lightobj *)fs_probeNum_o->o_data; + sprintf(printBuf, "[FS probes %d, freq=%d sec]", afsmon_fs_prev_probeNum, + afsmon_probefreq); + justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH, + RIGHT_JUSTIFY, 1); + gator_light_set(fs_probeNum_o, 1); + + /* update "columns on left" signal */ + tmp_lightobj = (struct gator_lightobj *)fs_leftArrows_o->o_data; + if (fs_pageType & CMD_LEFT) + strcpy(printBuf, "<<<"); + else + strcpy(printBuf, ""); + justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH, + LEFT_JUSTIFY, 1); + gator_light_set(fs_leftArrows_o, 0); + + /* update "columns on right" signal */ + tmp_lightobj = (struct gator_lightobj *)fs_rightArrows_o->o_data; + if (fs_pageType & CMD_RIGHT) + strcpy(printBuf, ">>>"); + else + strcpy(printBuf, ""); + justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH, + RIGHT_JUSTIFY, 1); + gator_light_set(fs_rightArrows_o, 0); + + + + /* UPDATE THE COLUMN LABELS */ + + /* the column index is also used to index the label arrays */ + labelIdx = a_LcolNum; + + /* get the pointers to the three arrays of label onodes */ + fsLabels_o_Ptr1 = fsLabels_o[0]; + fsLabels_o_Ptr2 = fsLabels_o[1]; + fsLabels_o_Ptr3 = fsLabels_o[2]; + + for (k = 0; k < fs_cols_perPage; k++) { if (labelIdx < fs_numCols) { - dataIndex = fs_Display_map[labelIdx]; - code = display_Server_label( fs_labels[dataIndex], - *fsLabels_o_Ptr1, - *fsLabels_o_Ptr2, - *fsLabels_o_Ptr3); + dataIndex = fs_Display_map[labelIdx]; + code = + display_Server_label(fs_labels[dataIndex], *fsLabels_o_Ptr1, + *fsLabels_o_Ptr2, *fsLabels_o_Ptr3); - labelIdx++; /* next label */ + labelIdx++; /* next label */ } else { - code = display_Server_label( "//", - *fsLabels_o_Ptr1, - *fsLabels_o_Ptr2, - *fsLabels_o_Ptr3); + code = + display_Server_label("//", *fsLabels_o_Ptr1, *fsLabels_o_Ptr2, + *fsLabels_o_Ptr3); } fsLabels_o_Ptr1++; /* next onode in label row 1 */ fsLabels_o_Ptr2++; /* next onode in label row 2 */ fsLabels_o_Ptr3++; /* next onode in label row 3 */ - } /* labels for each column */ + } /* labels for each column */ /* UPDATE THE FILE SERVER STATISTICS */ - /* move to the right spot in the FS display data array */ - fsDataP = prev_fsData; - fsIdx = 0; - for(i=0; i < ((a_pageNum-1) * fs_numHosts_perPage); i++) { + /* move to the right spot in the FS display data array */ + fsDataP = prev_fsData; + fsIdx = 0; + for (i = 0; i < ((a_pageNum - 1) * fs_numHosts_perPage); i++) { fsDataP++; fsIdx++; - } - - if (fsIdx >= numFS) { /* whoops! screwed up */ - sprintf(errMsg,"[ %s ] Programming error 1\n", rn); + } + + if (fsIdx >= numFS) { /* whoops! screwed up */ + sprintf(errMsg, "[ %s ] Programming error 1\n", rn); afsmon_Exit(325); - } + } - /* get the pointer to the first line of onodes of the file server frame */ - tmp_fs_lines_P = fs_lines; + /* get the pointer to the first line of onodes of the file server frame */ + tmp_fs_lines_P = fs_lines; - for (i=0; i < fs_numHosts_perPage; i++) { + for (i = 0; i < fs_numHosts_perPage; i++) { /* if this is the last page we may not have file servers to fill up - the page, so check the index */ - if (fsIdx < numFS) { + * the page, so check the index */ + if (fsIdx < numFS) { - if (fsDataP->hostName[0] == '\0') { - sprintf(errMsg,"[ %s ] empty fs display entry \n",rn); + if (fsDataP->hostName[0] == '\0') { + sprintf(errMsg, "[ %s ] empty fs display entry \n", rn); afsmon_Exit(330); - } + } - /* display the hostname , first names only please! */ - - sprintf(printBuf, fsDataP->hostName); - for(j=0; jhostName); + for (j = 0; j < strlen(printBuf); j++) { if (printBuf[j] == '.') { - printBuf[j] = '\0'; - break; + printBuf[j] = '\0'; + break; } - } + } - tmp_lightobj=(struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data; - code = justify_light(printBuf,tmp_lightobj->label, - FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1); - if (code) { - fprintf(debugFD,"[ %s ] justify_code returned %d\n",rn, code); + tmp_lightobj = + (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data; + code = + justify_light(printBuf, tmp_lightobj->label, + FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1); + if (code) { + fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn, + code); fflush(debugFD); - } - - /* use the current column value to index into the fs_Display_map - array to obtain the index of the item to display. check if its - overflow flag is set and highlight if so. if the probe had failed - enter "--" is all columns */ - - /* each host has two rows of slots for datums. get the pointers to - both the arrays */ - - firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0]; - secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1]; - fs_curr_RCol = a_LcolNum; /* starting column number from which - we are asked to display data */ - - for(j=0; j < fs_cols_perPage; j++) { /* for each column */ - - /* if there is another column of data */ - if (fs_curr_RCol < fs_numCols) { - - dataIndex = fs_Display_map[fs_curr_RCol]; - - code = display_Server_datum( fsDataP->data[dataIndex], - *firstSlot_o_Ptr, - *secondSlot_o_Ptr, - fsDataP->probeOK, - RIGHT_JUSTIFY, - fsDataP->threshOvf[dataIndex]); - - fs_curr_RCol++; - } else { /* no more data, blank out columns */ - code = display_Server_datum( "", - *firstSlot_o_Ptr, - *secondSlot_o_Ptr, - 1, /* probe ok */ - RIGHT_JUSTIFY, - 0); /* no overflow */ + } + + /* use the current column value to index into the fs_Display_map + * array to obtain the index of the item to display. check if its + * overflow flag is set and highlight if so. if the probe had failed + * enter "--" is all columns */ + + /* each host has two rows of slots for datums. get the pointers to + * both the arrays */ + + firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0]; + secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1]; + fs_curr_RCol = a_LcolNum; /* starting column number from which + * we are asked to display data */ + + for (j = 0; j < fs_cols_perPage; j++) { /* for each column */ + + /* if there is another column of data */ + if (fs_curr_RCol < fs_numCols) { + + dataIndex = fs_Display_map[fs_curr_RCol]; + + code = + display_Server_datum(fsDataP->data[dataIndex], + *firstSlot_o_Ptr, + *secondSlot_o_Ptr, + fsDataP->probeOK, RIGHT_JUSTIFY, + fsDataP->threshOvf[dataIndex]); + + fs_curr_RCol++; + } else { /* no more data, blank out columns */ + code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */ + RIGHT_JUSTIFY, 0); /* no overflow */ } - firstSlot_o_Ptr++; /* onode of next column */ - secondSlot_o_Ptr++; /* onode of next column */ + firstSlot_o_Ptr++; /* onode of next column */ + secondSlot_o_Ptr++; /* onode of next column */ - } /* for each column */ + } /* for each column */ - /* the loop could have taken the right-column-index one over, - adjust it now */ - if (fs_curr_RCol == fs_numCols) + /* the loop could have taken the right-column-index one over, + * adjust it now */ + if (fs_curr_RCol == fs_numCols) fs_curr_RCol--; - - } /* if fdIdx < numFS */ - - /* if fsIdx >= numFS , blank out all succeding rows */ + } + + + /* if fdIdx < numFS */ + /* if fsIdx >= numFS , blank out all succeding rows */ if (fsIdx >= numFS) { - - /* blank out host name object */ - tmp_lightobj=(struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data; - code = justify_light("",tmp_lightobj->label, - FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1); - if (code) { - fprintf(debugFD,"[ %s ] justify_code returned %d\n",rn, code); - fflush(debugFD); - } - firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0]; - secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1]; + /* blank out host name object */ + tmp_lightobj = + (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data; + code = + justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH, + LEFT_JUSTIFY, 1); + if (code) { + fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn, + code); + fflush(debugFD); + } - for (k=0; kdata_o[0]; + secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1]; - firstSlot_o_Ptr++; - secondSlot_o_Ptr++; - } + for (k = 0; k < fs_cols_perPage; k++) { + code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */ + RIGHT_JUSTIFY, 0); /* dont highlight */ - } /* fsIDx >= numFS */ + firstSlot_o_Ptr++; + secondSlot_o_Ptr++; + } + } - tmp_fs_lines_P++; /* pointer to next line in the frame */ - fsDataP++; /* next host's data */ - fsIdx++; /* host index */ + /* fsIDx >= numFS */ + tmp_fs_lines_P++; /* pointer to next line in the frame */ + fsDataP++; /* next host's data */ + fsIdx++; /* host index */ - } /* for each row in the File Servers frame */ + } /* for each row in the File Servers frame */ - /* redraw the display if the File Servers screen is currently displayed */ - if(afsmon_win->w_frame == fsFrame) + /* redraw the display if the File Servers screen is currently displayed */ + if (afsmon_win->w_frame == fsFrame) WOP_DISPLAY(afsmon_win); - /* update the global page & column numbers to reflect the changes */ - fs_currPage = a_pageNum; - fs_curr_LCol = a_LcolNum;; + /* update the global page & column numbers to reflect the changes */ + fs_currPage = a_pageNum; + fs_curr_LCol = a_LcolNum;; - return(0); + return (0); -} /* fs_refresh */ +} /* fs_refresh */ @@ -1891,9 +1927,9 @@ int a_LcolNum; /* starting (leftmost) column number */ int Switch_fs_2_ovw() { - /* bind the overview frame to the window */ - gtxframe_SetFrame(afsmon_win,ovwFrame); - return(0); + /* bind the overview frame to the window */ + gtxframe_SetFrame(afsmon_win, ovwFrame); + return (0); } /*----------------------------------------------------------------------- @@ -1905,11 +1941,11 @@ Switch_fs_2_ovw() int Switch_fs_2_cm() { - if (fs_pageType & CMD_CM) { - /* bind the overview Cache Managers to the window */ - gtxframe_SetFrame(afsmon_win,cmFrame); - } - return(0); + if (fs_pageType & CMD_CM) { + /* bind the overview Cache Managers to the window */ + gtxframe_SetFrame(afsmon_win, cmFrame); + } + return (0); } /*----------------------------------------------------------------------- @@ -1921,14 +1957,14 @@ Switch_fs_2_cm() int Switch_fs_next() { - static char rn[] = "Switch_fs_next"; + static char rn[] = "Switch_fs_next"; - if (fs_pageType & CMD_NEXT) { + if (fs_pageType & CMD_NEXT) { /* we have a next page, refresh with next page number */ - fs_refresh(fs_currPage+1, fs_curr_LCol); - } + fs_refresh(fs_currPage + 1, fs_curr_LCol); + } - return(0); + return (0); } /*----------------------------------------------------------------------- @@ -1940,15 +1976,15 @@ Switch_fs_next() int Switch_fs_last() { - static char rn[] = "Switch_fs_last"; + static char rn[] = "Switch_fs_last"; - if (fs_pageType & CMD_NEXT) { + if (fs_pageType & CMD_NEXT) { /* we have a next page, refresh with the last page number */ fs_refresh(fs_numPages, fs_curr_LCol); - } + } - return(0); + return (0); } /*----------------------------------------------------------------------- @@ -1960,13 +1996,13 @@ Switch_fs_last() int Switch_fs_prev() { - static char rn[] = "Switch_fs_prev"; + static char rn[] = "Switch_fs_prev"; - if (fs_pageType & CMD_PREV) { + if (fs_pageType & CMD_PREV) { /* we have a previous page, refresh with the rpevious page number */ - fs_refresh(fs_currPage -1, fs_curr_LCol); - } - return(0); + fs_refresh(fs_currPage - 1, fs_curr_LCol); + } + return (0); } /*----------------------------------------------------------------------- @@ -1978,13 +2014,13 @@ Switch_fs_prev() int Switch_fs_first() { - static char rn[] = "Switch_fs_first"; + static char rn[] = "Switch_fs_first"; - if (fs_pageType & CMD_PREV) { + if (fs_pageType & CMD_PREV) { /* we have a previous page, got to first page */ - fs_refresh(1 , fs_curr_LCol); - } - return(0); + fs_refresh(1, fs_curr_LCol); + } + return (0); } /*----------------------------------------------------------------------- @@ -1996,13 +2032,13 @@ Switch_fs_first() int Switch_fs_left() { - static char rn[] = "Switch_fs_left"; + static char rn[] = "Switch_fs_left"; - if (fs_pageType & CMD_LEFT) { + if (fs_pageType & CMD_LEFT) { /* we have columns on left, refresh with new column number */ fs_refresh(fs_currPage, fs_curr_LCol - fs_cols_perPage); - } - return(0); + } + return (0); } @@ -2015,13 +2051,13 @@ Switch_fs_left() int Switch_fs_leftmost() { - static char rn[] = "Switch_fs_leftmost"; + static char rn[] = "Switch_fs_leftmost"; - if (fs_pageType & CMD_LEFT) { + if (fs_pageType & CMD_LEFT) { /* we have columns on left, go to the first */ fs_refresh(fs_currPage, 0); - } - return(0); + } + return (0); } /*----------------------------------------------------------------------- @@ -2033,13 +2069,13 @@ Switch_fs_leftmost() int Switch_fs_right() { - static char rn[] = "Switch_fs_right"; + static char rn[] = "Switch_fs_right"; - if (fs_pageType & CMD_RIGHT) { + if (fs_pageType & CMD_RIGHT) { /* we have columns on right, refresh with new column number */ fs_refresh(fs_currPage, fs_curr_LCol + fs_cols_perPage); - } - return(0); + } + return (0); } /*----------------------------------------------------------------------- @@ -2051,20 +2087,21 @@ Switch_fs_right() int Switch_fs_rightmost() { - static char rn[] = "Switch_fs_rightmost"; - int curr_LCol; + static char rn[] = "Switch_fs_rightmost"; + int curr_LCol; - if (fs_pageType & CMD_RIGHT) { + if (fs_pageType & CMD_RIGHT) { /* we have columns on right, go to the last column */ if (fs_numCols % fs_cols_perPage) - curr_LCol = (fs_numCols / fs_cols_perPage) * fs_cols_perPage; + curr_LCol = (fs_numCols / fs_cols_perPage) * fs_cols_perPage; else - curr_LCol = ((fs_numCols / fs_cols_perPage)-1) * fs_cols_perPage; + curr_LCol = + ((fs_numCols / fs_cols_perPage) - 1) * fs_cols_perPage; fs_refresh(fs_currPage, curr_LCol); - } - return(0); + } + return (0); } @@ -2086,252 +2123,272 @@ Switch_fs_rightmost() int create_FSframe_objects() -{ /* create_FSframe_objects */ - static char rn[] = "create_FSframe_objects"; - struct ServerInfo_line *fs_lines_Ptr; - struct onode **fs_data_o_Ptr; - struct onode **fsLabels_o_Ptr; - int x_pos; - int y_pos; - int code; - int i; - int j; - int numBytes; - int arrIdx; +{ /* create_FSframe_objects */ + static char rn[] = "create_FSframe_objects"; + struct ServerInfo_line *fs_lines_Ptr; + struct onode **fs_data_o_Ptr; + struct onode **fsLabels_o_Ptr; + int x_pos; + int y_pos; + int code; + int i; + int j; + int numBytes; + int arrIdx; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); } - /* create the command line object */ - fs_cmd_o = initLightObject("Command [oview, cm, prev, next, left, right] ? ", - 0,maxY-1,FC_CMD_O_WIDTH,afsmon_win); - if (fs_cmd_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create fs command onode\n",rn); + /* create the command line object */ + fs_cmd_o = + initLightObject("Command [oview, cm, prev, next, left, right] ? ", 0, + maxY - 1, FC_CMD_O_WIDTH, afsmon_win); + if (fs_cmd_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create fs command onode\n", rn); afsmon_Exit(340); - } - code = gtxframe_AddToList(fsFrame,fs_cmd_o); - code = gator_light_set(fs_cmd_o,HIGHLIGHT); + } + code = gtxframe_AddToList(fsFrame, fs_cmd_o); + code = gator_light_set(fs_cmd_o, HIGHLIGHT); - /* we already have the dimensions for the frame - same as the ovw frame */ - /* use the ovw program name object for the fs screen too */ + /* we already have the dimensions for the frame - same as the ovw frame */ + /* use the ovw program name object for the fs screen too */ - code = gtxframe_AddToList(fsFrame, ovw_progName_o); + code = gtxframe_AddToList(fsFrame, ovw_progName_o); - /* create the page number object */ - fs_pageNum_o = initLightObject("[File Servers, p. X of X, c. Y of Y]", - maxX-FC_PAGENUM_O_WIDTH,0,FC_PAGENUM_O_WIDTH,afsmon_win); - if (fs_pageNum_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create pageNumber onode\n",rn); + /* create the page number object */ + fs_pageNum_o = + initLightObject("[File Servers, p. X of X, c. Y of Y]", + maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH, + afsmon_win); + if (fs_pageNum_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn); afsmon_Exit(335); - } - code = gtxframe_AddToList(fsFrame,fs_pageNum_o); - code = gator_light_set(fs_pageNum_o,HIGHLIGHT); - - /* create the probe number object */ - fs_probeNum_o = initLightObject("[FS probes 1, freq=30 sec]", - maxX-FC_PROBENUM_O_WIDTH ,maxY-1, FC_PROBENUM_O_WIDTH, afsmon_win); - if (fs_probeNum_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create fs probeNum onode\n",rn); + } + code = gtxframe_AddToList(fsFrame, fs_pageNum_o); + code = gator_light_set(fs_pageNum_o, HIGHLIGHT); + + /* create the probe number object */ + fs_probeNum_o = + initLightObject("[FS probes 1, freq=30 sec]", + maxX - FC_PROBENUM_O_WIDTH, maxY - 1, + FC_PROBENUM_O_WIDTH, afsmon_win); + if (fs_probeNum_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create fs probeNum onode\n", rn); afsmon_Exit(345); - } - code = gtxframe_AddToList(fsFrame,fs_probeNum_o); - code = gator_light_set(fs_probeNum_o,HIGHLIGHT); - - - /* create the numFS monitored object */ - fs_numFS_o = initLightObject( - " 0 File Servers monitored, 0 alerts on 0 machines", - 4,2,FC_NUMHOSTS_O_WIDTH,afsmon_win); - if (fs_numFS_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create numFS onode for the fs frame\n", - rn); + } + code = gtxframe_AddToList(fsFrame, fs_probeNum_o); + code = gator_light_set(fs_probeNum_o, HIGHLIGHT); + + + /* create the numFS monitored object */ + fs_numFS_o = + initLightObject + (" 0 File Servers monitored, 0 alerts on 0 machines", 4, 2, + FC_NUMHOSTS_O_WIDTH, afsmon_win); + if (fs_numFS_o == NULL) { + sprintf(errMsg, + "[ %s ] Failed to create numFS onode for the fs frame\n", rn); afsmon_Exit(350); - } - code = gtxframe_AddToList(fsFrame,fs_numFS_o); - - /* create the "more columns to left" indicator */ - fs_leftArrows_o = initLightObject("<<<", 0,2,FC_ARROWS_O_WIDTH, afsmon_win); - if (fs_leftArrows_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create leftArrows onode for the fs frame\n", rn); + } + code = gtxframe_AddToList(fsFrame, fs_numFS_o); + + /* create the "more columns to left" indicator */ + fs_leftArrows_o = + initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win); + if (fs_leftArrows_o == NULL) { + sprintf(errMsg, + "[ %s ] Failed to create leftArrows onode for the fs frame\n", + rn); afsmon_Exit(355); - } - code = gtxframe_AddToList(fsFrame,fs_leftArrows_o); - - /* create the "more columns to right" indicator */ - fs_rightArrows_o = initLightObject(">>>", maxX-FC_ARROWS_O_WIDTH, 2, - FC_ARROWS_O_WIDTH, afsmon_win); - if (fs_rightArrows_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create rightArrows onode for the fs frame\n", rn); + } + code = gtxframe_AddToList(fsFrame, fs_leftArrows_o); + + /* create the "more columns to right" indicator */ + fs_rightArrows_o = + initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH, + afsmon_win); + if (fs_rightArrows_o == NULL) { + sprintf(errMsg, + "[ %s ] Failed to create rightArrows onode for the fs frame\n", + rn); afsmon_Exit(360); - } - code = gtxframe_AddToList(fsFrame,fs_rightArrows_o); + } + code = gtxframe_AddToList(fsFrame, fs_rightArrows_o); - /* calculate the maximum number of hosts per page (2 rows per host) */ - fs_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2; + /* calculate the maximum number of hosts per page (2 rows per host) */ + fs_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2; - /* determine the number of data columns that can fit in a page */ - fs_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH ) / (FC_COLUMN_WIDTH); + /* determine the number of data columns that can fit in a page */ + fs_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH); - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] fs_numHosts_perPage=%d fs_cols_perPage=%d\n", - rn,fs_numHosts_perPage, fs_cols_perPage); + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] fs_numHosts_perPage=%d fs_cols_perPage=%d\n", + rn, fs_numHosts_perPage, fs_cols_perPage); fflush(debugFD); - } + } - /* the above two variables give us the information needed to create - the objects for displaying the file server information */ + /* the above two variables give us the information needed to create + * the objects for displaying the file server information */ - /* allocate memory for all the onode pointers required to display - the file server statistics */ + /* allocate memory for all the onode pointers required to display + * the file server statistics */ - numBytes = fs_numHosts_perPage * sizeof(struct ServerInfo_line); - fs_lines = (struct ServerInfo_line *) malloc(numBytes); - if (fs_lines == (struct ServerInfo_line *)0) { - sprintf(errMsg,"[ %s ] Failed to allocate %d bytes for FS data lines\n", - rn, numBytes); + numBytes = fs_numHosts_perPage * sizeof(struct ServerInfo_line); + fs_lines = (struct ServerInfo_line *)malloc(numBytes); + if (fs_lines == (struct ServerInfo_line *)0) { + sprintf(errMsg, + "[ %s ] Failed to allocate %d bytes for FS data lines\n", rn, + numBytes); afsmon_Exit(365); - } - - /* for each line of server statistics allocate memory to store two arrays - of data onodes */ - - fs_lines_Ptr = fs_lines; - for(i=0; idata_o[arrIdx] = (struct onode **) malloc(numBytes); - if (fs_lines_Ptr->data_o[arrIdx] == NULL) { - sprintf(errMsg,"[ %s ] Failed to allocate %d bytes for FS data onodes\n", - rn, numBytes); - afsmon_Exit(370); + } + + /* for each line of server statistics allocate memory to store two arrays + * of data onodes */ + + fs_lines_Ptr = fs_lines; + for (i = 0; i < fs_numHosts_perPage; i++) { + for (arrIdx = 0; arrIdx < 2; arrIdx++) { + numBytes = fs_cols_perPage * sizeof(struct onode *); + fs_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes); + if (fs_lines_Ptr->data_o[arrIdx] == NULL) { + sprintf(errMsg, + "[ %s ] Failed to allocate %d bytes for FS data onodes\n", + rn, numBytes); + afsmon_Exit(370); + } } - } - fs_lines_Ptr++; - } + fs_lines_Ptr++; + } - /* now allocate the onodes itself */ + /* now allocate the onodes itself */ - fs_lines_Ptr = fs_lines; - for(i=0; ihost_o = initLightObject("FSHostName", - 0,FC_FIRST_HOST_ROW + 2*i, FC_HOSTNAME_O_WIDTH, afsmon_win); - if (fs_lines_Ptr->host_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create an FS name onode\n",rn); - afsmon_Exit(375); - } - code = gtxframe_AddToList(fsFrame, fs_lines_Ptr->host_o); + fs_lines_Ptr->host_o = + initLightObject("FSHostName", 0, FC_FIRST_HOST_ROW + 2 * i, + FC_HOSTNAME_O_WIDTH, afsmon_win); + if (fs_lines_Ptr->host_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn); + afsmon_Exit(375); + } + code = gtxframe_AddToList(fsFrame, fs_lines_Ptr->host_o); /* if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n", - rn,fs_lines_Ptr->host_o,i); - fflush(debugFD); - } */ + * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n", + * rn,fs_lines_Ptr->host_o,i); + * fflush(debugFD); + * } */ /* initialize data onodes for this host */ - for(arrIdx=0; arrIdx<2; arrIdx++) { /* for each array index */ + for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */ - fs_data_o_Ptr = fs_lines_Ptr->data_o[arrIdx]; - for(j=0; jdata_o[arrIdx]; + for (j = 0; j < fs_cols_perPage; j++) { /* for each column */ char tmpBuf[20]; /* determine x & y coordinate for this data object */ /* the 1's are for leaving a blank after each column */ x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH)); - y_pos = FC_FIRST_HOST_ROW + 2*i + arrIdx; - - sprintf(tmpBuf,"-FSData %d-",arrIdx); - *fs_data_o_Ptr = initLightObject(tmpBuf, - x_pos, y_pos, FC_COLUMN_WIDTH, afsmon_win); - if (*fs_data_o_Ptr == NULL) { - sprintf(errMsg,"[ %s ] Failed to create an FS data onode\n",rn); - afsmon_Exit(380); + y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx; + + sprintf(tmpBuf, "-FSData %d-", arrIdx); + *fs_data_o_Ptr = + initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH, + afsmon_win); + if (*fs_data_o_Ptr == NULL) { + sprintf(errMsg, + "[ %s ] Failed to create an FS data onode\n", rn); + afsmon_Exit(380); } - code = gtxframe_AddToList(fsFrame, *fs_data_o_Ptr); + code = gtxframe_AddToList(fsFrame, *fs_data_o_Ptr); fs_data_o_Ptr++; - } /* for each column */ - } /* for each onode array index */ + } /* for each column */ + } /* for each onode array index */ - fs_lines_Ptr++; - } /* for each host slot */ + fs_lines_Ptr++; + } /* for each host slot */ - /* INITIALIZE COLUMN LABELS */ + /* INITIALIZE COLUMN LABELS */ - /* allocate memory for two arrays of onode pointers for file server column - labels */ - for( arrIdx=0; arrIdx < 3; arrIdx++) { + /* allocate memory for two arrays of onode pointers for file server column + * labels */ + for (arrIdx = 0; arrIdx < 3; arrIdx++) { - fsLabels_o[arrIdx] = (struct onode **) malloc( - sizeof(struct onode *) * fs_cols_perPage); - if (fsLabels_o[arrIdx] == NULL) { - sprintf(errMsg,"[ %s ] Failed to allocate memory for FS label onodes\n", - rn); - afsmon_Exit(385); - } - - /* create cache manager name objects */ - fsLabels_o_Ptr = fsLabels_o[arrIdx]; - for (i=0; i< fs_cols_perPage; i++) { - *fsLabels_o_Ptr = initLightObject("", - FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH, - FC_FIRST_LABEL_ROW + arrIdx, - FC_COLUMN_WIDTH,afsmon_win); - - if (*fsLabels_o_Ptr == NULL) { - sprintf(errMsg,"[ %s ] Failed to create a FS label onode\n",rn); + fsLabels_o[arrIdx] = + (struct onode **)malloc(sizeof(struct onode *) * fs_cols_perPage); + if (fsLabels_o[arrIdx] == NULL) { + sprintf(errMsg, + "[ %s ] Failed to allocate memory for FS label onodes\n", + rn); + afsmon_Exit(385); + } + + /* create cache manager name objects */ + fsLabels_o_Ptr = fsLabels_o[arrIdx]; + for (i = 0; i < fs_cols_perPage; i++) { + *fsLabels_o_Ptr = + initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH, + FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH, + afsmon_win); + + if (*fsLabels_o_Ptr == NULL) { + sprintf(errMsg, "[ %s ] Failed to create a FS label onode\n", + rn); afsmon_Exit(390); - } - code = gtxframe_AddToList(fsFrame,*fsLabels_o_Ptr); - fsLabels_o_Ptr++; - } + } + code = gtxframe_AddToList(fsFrame, *fsLabels_o_Ptr); + fsLabels_o_Ptr++; + } - } + } - /* initialize the column & page counters */ + /* initialize the column & page counters */ - fs_currPage = 1; - fs_numCols = fs_DisplayItems_count; - fs_numPages = numFS / fs_numHosts_perPage; - if (numFS % fs_numHosts_perPage) + fs_currPage = 1; + fs_numCols = fs_DisplayItems_count; + fs_numPages = numFS / fs_numHosts_perPage; + if (numFS % fs_numHosts_perPage) fs_numPages++; - fs_curr_LCol = 0; /* leftmost col */ - fs_curr_RCol = 0; /* rightmost col */ + fs_curr_LCol = 0; /* leftmost col */ + fs_curr_RCol = 0; /* rightmost col */ - /* create keyboard bindings */ - /* bind Q and  to exit */ - keymap_BindToString(fsFrame->keymap,"Q",afsmonExit_gtx,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"",afsmonExit_gtx,NULL,NULL); + /* create keyboard bindings */ + /* bind Q and  to exit */ + keymap_BindToString(fsFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "", afsmonExit_gtx, NULL, NULL); - /* o = overview, c = cm, n = next, p = prev, l = left, r = right - N = last page, P = first page, L = leftmost col, R = rightmost col */ + /* o = overview, c = cm, n = next, p = prev, l = left, r = right + * N = last page, P = first page, L = leftmost col, R = rightmost col */ - keymap_BindToString(fsFrame->keymap,"o",Switch_fs_2_ovw,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"c",Switch_fs_2_cm,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"n",Switch_fs_next,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"N",Switch_fs_last,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"p",Switch_fs_prev,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"P",Switch_fs_first,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"l",Switch_fs_left,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"L",Switch_fs_leftmost,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"r",Switch_fs_right,NULL,NULL); - keymap_BindToString(fsFrame->keymap,"R",Switch_fs_rightmost,NULL,NULL); + keymap_BindToString(fsFrame->keymap, "o", Switch_fs_2_ovw, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "c", Switch_fs_2_cm, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "n", Switch_fs_next, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "N", Switch_fs_last, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "p", Switch_fs_prev, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "P", Switch_fs_first, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "l", Switch_fs_left, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "L", Switch_fs_leftmost, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "r", Switch_fs_right, NULL, NULL); + keymap_BindToString(fsFrame->keymap, "R", Switch_fs_rightmost, NULL, + NULL); - return(0); -} /* create_FSframe_objects */ + return (0); +} /* create_FSframe_objects */ /*----------------------------------------------------------------------- @@ -2352,312 +2409,313 @@ create_FSframe_objects() int cm_refresh(a_pageNum, a_LcolNum) -int a_pageNum; /* page to display */ -int a_LcolNum; /* starting (leftmost) column number */ - -{ /* cm_refresh */ - - static char rn[] = "cm_refresh"; /* routine name */ - struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */ - struct cm_Display_Data *cmDataP; /* ptr to CM display data array */ - struct ServerInfo_line *tmp_cm_lines_P; /* tmp ptr to cm_lines */ - struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */ - struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */ - struct onode **cmLabels_o_Ptr1; /* ptr to label row 0 */ - struct onode **cmLabels_o_Ptr2; /* ptr to label row 1 */ - struct onode **cmLabels_o_Ptr3; /* ptr to label row 2 */ - char cmdLine[80]; /* buffer for command line */ - char printBuf[256]; /* buffer to print to screen */ - int i; - int j; - int k; - int code; - int cmIdx; - int labelIdx; - int dataIndex; /* index to the data[] field of - struct cm_Display_Data */ - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_pageNum= %d, a_LcolNum= %d \n", - rn, a_pageNum, a_LcolNum); + int a_pageNum; /* page to display */ + int a_LcolNum; /* starting (leftmost) column number */ + +{ /* cm_refresh */ + + static char rn[] = "cm_refresh"; /* routine name */ + struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */ + struct cm_Display_Data *cmDataP; /* ptr to CM display data array */ + struct ServerInfo_line *tmp_cm_lines_P; /* tmp ptr to cm_lines */ + struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */ + struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */ + struct onode **cmLabels_o_Ptr1; /* ptr to label row 0 */ + struct onode **cmLabels_o_Ptr2; /* ptr to label row 1 */ + struct onode **cmLabels_o_Ptr3; /* ptr to label row 2 */ + char cmdLine[80]; /* buffer for command line */ + char printBuf[256]; /* buffer to print to screen */ + int i; + int j; + int k; + int code; + int cmIdx; + int labelIdx; + int dataIndex; /* index to the data[] field of + * struct cm_Display_Data */ + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_LcolNum= %d \n", rn, + a_pageNum, a_LcolNum); fflush(debugFD); - } + } - /* if the data is not yet available, ie., not one probe cycle has - completed, do nothing */ + /* if the data is not yet available, ie., not one probe cycle has + * completed, do nothing */ - if (! cm_Data_Available) - return(0); + if (!cm_Data_Available) + return (0); - /* validate the page number & column number */ - if (a_pageNum < 1 || a_pageNum > cm_numPages) { + /* validate the page number & column number */ + if (a_pageNum < 1 || a_pageNum > cm_numPages) { if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called with wrong page # %d \n",rn, a_pageNum); - fflush(debugFD); + fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn, + a_pageNum); + fflush(debugFD); } afsmon_Exit(395); - } - if (a_LcolNum < 0 || a_LcolNum > cm_numCols) { + } + if (a_LcolNum < 0 || a_LcolNum > cm_numCols) { if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called with wrong column #%d\n",rn, a_LcolNum); - fflush(debugFD); + fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn, + a_LcolNum); + fflush(debugFD); } afsmon_Exit(400); - } - - - - /* update the fixed labels */ - - /* we reuse the ovw version lable and hence do not have to do anything - for it here */ - - /* page number label */ - tmp_lightobj=(struct gator_lightobj *) cm_pageNum_o->o_data; - sprintf(printBuf,"[Cache Managers, p.%d of %d, c.%d of %d]", - a_pageNum, cm_numPages, a_LcolNum +1, cm_numCols); - justify_light(printBuf,tmp_lightobj->label, FC_PAGENUM_O_WIDTH, - RIGHT_JUSTIFY,1); - gator_light_set(cm_pageNum_o,1); - - /* file servers monitored label */ - tmp_lightobj=(struct gator_lightobj *) cm_numCM_o->o_data; - sprintf(printBuf,"%d Cache Managers monitored, %d alerts on %d machines", - numCM, num_cm_alerts, numHosts_oncm_alerts); - justify_light(printBuf,tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,1); - - - /* command line */ - - /* figure out what we need to show in the prompt & set the page type */ - /* the cm_pageType variable is in turn used by the keyboard handler - routines to call cm_refresh() with the correct parameters */ - - cm_pageType = resolve_CmdLine( cmdLine, 2 /* cm frame */, a_pageNum, - cm_numPages, cm_numCols, a_LcolNum, cm_cols_perPage); - - /* display the command line */ - tmp_lightobj=(struct gator_lightobj *) cm_cmd_o->o_data; - sprintf(printBuf,"%s", cmdLine); - justify_light(printBuf,tmp_lightobj->label, strlen(printBuf)+1, - LEFT_JUSTIFY,1); - gator_light_set(cm_cmd_o, 1); - - /* update the probe number label */ - tmp_lightobj=(struct gator_lightobj *) cm_probeNum_o->o_data; - sprintf(printBuf,"[CM probes %d, freq=%d sec]", - afsmon_cm_prev_probeNum, afsmon_probefreq); - justify_light(printBuf,tmp_lightobj->label, FC_PROBENUM_O_WIDTH, - RIGHT_JUSTIFY,1); - gator_light_set(cm_cmd_o, 1); - - /* update "columns on left" signal */ - tmp_lightobj=(struct gator_lightobj *) cm_leftArrows_o->o_data; - if (cm_pageType & CMD_LEFT) - strcpy(printBuf, "<<<"); - else - strcpy(printBuf,""); - justify_light(printBuf,tmp_lightobj->label, FC_ARROWS_O_WIDTH, - LEFT_JUSTIFY,1); - gator_light_set(cm_leftArrows_o, 0); - - /* update "columns on right" signal */ - tmp_lightobj=(struct gator_lightobj *) cm_rightArrows_o->o_data; - if (cm_pageType & CMD_RIGHT) - strcpy(printBuf, ">>>"); - else - strcpy(printBuf,""); - justify_light(printBuf,tmp_lightobj->label, FC_ARROWS_O_WIDTH, - RIGHT_JUSTIFY,1); - gator_light_set(cm_rightArrows_o, 0); - - - - /* UPDATE THE COLUMN LABELS */ - - /* the column index is also used to index the label arrays */ - labelIdx = a_LcolNum; - - /* get the pointers to the three arrays of label onodes */ - cmLabels_o_Ptr1 = cmLabels_o[0]; - cmLabels_o_Ptr2 = cmLabels_o[1]; - cmLabels_o_Ptr3 = cmLabels_o[2]; - - for(k=0; k < cm_cols_perPage; k++) { + } + + + + /* update the fixed labels */ + + /* we reuse the ovw version lable and hence do not have to do anything + * for it here */ + + /* page number label */ + tmp_lightobj = (struct gator_lightobj *)cm_pageNum_o->o_data; + sprintf(printBuf, "[Cache Managers, p.%d of %d, c.%d of %d]", a_pageNum, + cm_numPages, a_LcolNum + 1, cm_numCols); + justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH, + RIGHT_JUSTIFY, 1); + gator_light_set(cm_pageNum_o, 1); + + /* file servers monitored label */ + tmp_lightobj = (struct gator_lightobj *)cm_numCM_o->o_data; + sprintf(printBuf, "%d Cache Managers monitored, %d alerts on %d machines", + numCM, num_cm_alerts, numHosts_oncm_alerts); + justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER, + 1); + + + /* command line */ + + /* figure out what we need to show in the prompt & set the page type */ + /* the cm_pageType variable is in turn used by the keyboard handler + * routines to call cm_refresh() with the correct parameters */ + + cm_pageType = resolve_CmdLine(cmdLine, 2 /* cm frame */ , a_pageNum, + cm_numPages, cm_numCols, a_LcolNum, + cm_cols_perPage); + + /* display the command line */ + tmp_lightobj = (struct gator_lightobj *)cm_cmd_o->o_data; + sprintf(printBuf, "%s", cmdLine); + justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1, + LEFT_JUSTIFY, 1); + gator_light_set(cm_cmd_o, 1); + + /* update the probe number label */ + tmp_lightobj = (struct gator_lightobj *)cm_probeNum_o->o_data; + sprintf(printBuf, "[CM probes %d, freq=%d sec]", afsmon_cm_prev_probeNum, + afsmon_probefreq); + justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH, + RIGHT_JUSTIFY, 1); + gator_light_set(cm_cmd_o, 1); + + /* update "columns on left" signal */ + tmp_lightobj = (struct gator_lightobj *)cm_leftArrows_o->o_data; + if (cm_pageType & CMD_LEFT) + strcpy(printBuf, "<<<"); + else + strcpy(printBuf, ""); + justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH, + LEFT_JUSTIFY, 1); + gator_light_set(cm_leftArrows_o, 0); + + /* update "columns on right" signal */ + tmp_lightobj = (struct gator_lightobj *)cm_rightArrows_o->o_data; + if (cm_pageType & CMD_RIGHT) + strcpy(printBuf, ">>>"); + else + strcpy(printBuf, ""); + justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH, + RIGHT_JUSTIFY, 1); + gator_light_set(cm_rightArrows_o, 0); + + + + /* UPDATE THE COLUMN LABELS */ + + /* the column index is also used to index the label arrays */ + labelIdx = a_LcolNum; + + /* get the pointers to the three arrays of label onodes */ + cmLabels_o_Ptr1 = cmLabels_o[0]; + cmLabels_o_Ptr2 = cmLabels_o[1]; + cmLabels_o_Ptr3 = cmLabels_o[2]; + + for (k = 0; k < cm_cols_perPage; k++) { if (labelIdx < cm_numCols) { - dataIndex = cm_Display_map[labelIdx]; - code = display_Server_label( cm_labels[dataIndex], - *cmLabels_o_Ptr1, - *cmLabels_o_Ptr2, - *cmLabels_o_Ptr3); + dataIndex = cm_Display_map[labelIdx]; + code = + display_Server_label(cm_labels[dataIndex], *cmLabels_o_Ptr1, + *cmLabels_o_Ptr2, *cmLabels_o_Ptr3); - labelIdx++; /* next label */ + labelIdx++; /* next label */ } else { - code = display_Server_label( "//", - *cmLabels_o_Ptr1, - *cmLabels_o_Ptr2, - *cmLabels_o_Ptr3); + code = + display_Server_label("//", *cmLabels_o_Ptr1, *cmLabels_o_Ptr2, + *cmLabels_o_Ptr3); } cmLabels_o_Ptr1++; /* next onode in label row 1 */ cmLabels_o_Ptr2++; /* next onode in label row 2 */ cmLabels_o_Ptr3++; /* next onode in label row 3 */ - } /* labels for each column */ + } /* labels for each column */ /* UPDATE THE FILE SERVER STATISTICS */ - /* move to the right spot in the CM display data array */ - cmDataP = prev_cmData; - cmIdx = 0; - for(i=0; i < ((a_pageNum-1) * cm_numHosts_perPage); i++) { + /* move to the right spot in the CM display data array */ + cmDataP = prev_cmData; + cmIdx = 0; + for (i = 0; i < ((a_pageNum - 1) * cm_numHosts_perPage); i++) { cmDataP++; cmIdx++; - } - - if (cmIdx >= numCM) { /* whoops! screwed up */ - sprintf(errMsg,"[ %s ] Programming error 1\n", rn); + } + + if (cmIdx >= numCM) { /* whoops! screwed up */ + sprintf(errMsg, "[ %s ] Programming error 1\n", rn); afsmon_Exit(405); - } + } - /* get the pointer to the first line of onodes of the file server frame */ - tmp_cm_lines_P = cm_lines; + /* get the pointer to the first line of onodes of the file server frame */ + tmp_cm_lines_P = cm_lines; - for (i=0; i < cm_numHosts_perPage; i++) { + for (i = 0; i < cm_numHosts_perPage; i++) { /* if this is the last page we may not have file servers to fill up - the page, so check the index */ - if (cmIdx < numCM) { + * the page, so check the index */ + if (cmIdx < numCM) { - if (cmDataP->hostName[0] == '\0') { - sprintf(errMsg,"[ %s ] empty cm display entry \n",rn); + if (cmDataP->hostName[0] == '\0') { + sprintf(errMsg, "[ %s ] empty cm display entry \n", rn); afsmon_Exit(410); - } + } - /* display the hostname , first names only please! */ - - sprintf(printBuf, cmDataP->hostName); - for(j=0; jhostName); + for (j = 0; j < strlen(printBuf); j++) { if (printBuf[j] == '.') { - printBuf[j] = '\0'; - break; + printBuf[j] = '\0'; + break; } - } + } - tmp_lightobj=(struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data; - code = justify_light(printBuf,tmp_lightobj->label, - FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1); - if (code) { - fprintf(debugFD,"[ %s ] justify_code returned %d\n",rn, code); + tmp_lightobj = + (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data; + code = + justify_light(printBuf, tmp_lightobj->label, + FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1); + if (code) { + fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn, + code); fflush(debugFD); - } - - /* use the current column value to index into the cm_Display_map - array to obtain the index of the item to display. check if its - overflow flag is set and highlight if so. if the probe had failed - enter "--" is all columns */ - - /* each host has two rows of slots for datums. get the pointers to - both the arrays */ - - firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0]; - secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1]; - cm_curr_RCol = a_LcolNum; /* starting column number from which - we are asked to display data */ - - for(j=0; j < cm_cols_perPage; j++) { /* for each column */ - - /* if there is another column of data */ - if (cm_curr_RCol < cm_numCols) { - - dataIndex = cm_Display_map[cm_curr_RCol]; - - code = display_Server_datum( cmDataP->data[dataIndex], - *firstSlot_o_Ptr, - *secondSlot_o_Ptr, - cmDataP->probeOK, - RIGHT_JUSTIFY, - cmDataP->threshOvf[dataIndex]); - - cm_curr_RCol++; - } else { /* no more data, blank out columns */ - code = display_Server_datum( "", - *firstSlot_o_Ptr, - *secondSlot_o_Ptr, - 1, /* probe ok */ - RIGHT_JUSTIFY, - 0); /* no overflow */ + } + + /* use the current column value to index into the cm_Display_map + * array to obtain the index of the item to display. check if its + * overflow flag is set and highlight if so. if the probe had failed + * enter "--" is all columns */ + + /* each host has two rows of slots for datums. get the pointers to + * both the arrays */ + + firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0]; + secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1]; + cm_curr_RCol = a_LcolNum; /* starting column number from which + * we are asked to display data */ + + for (j = 0; j < cm_cols_perPage; j++) { /* for each column */ + + /* if there is another column of data */ + if (cm_curr_RCol < cm_numCols) { + + dataIndex = cm_Display_map[cm_curr_RCol]; + + code = + display_Server_datum(cmDataP->data[dataIndex], + *firstSlot_o_Ptr, + *secondSlot_o_Ptr, + cmDataP->probeOK, RIGHT_JUSTIFY, + cmDataP->threshOvf[dataIndex]); + + cm_curr_RCol++; + } else { /* no more data, blank out columns */ + code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */ + RIGHT_JUSTIFY, 0); /* no overflow */ } - firstSlot_o_Ptr++; /* onode of next column */ - secondSlot_o_Ptr++; /* onode of next column */ + firstSlot_o_Ptr++; /* onode of next column */ + secondSlot_o_Ptr++; /* onode of next column */ - } /* for each column */ + } /* for each column */ - /* the loop could have taken the right-column-index one over, - adjust it now */ - if (cm_curr_RCol == cm_numCols) + /* the loop could have taken the right-column-index one over, + * adjust it now */ + if (cm_curr_RCol == cm_numCols) cm_curr_RCol--; - - } /* if fdIdx < numCM */ - - /* if cmIdx >= numCM , blank out all succeding rows */ + } + + + /* if fdIdx < numCM */ + /* if cmIdx >= numCM , blank out all succeding rows */ if (cmIdx >= numCM) { - - /* blank out host name object */ - tmp_lightobj=(struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data; - code = justify_light("",tmp_lightobj->label, - FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1); - if (code) { - fprintf(debugFD,"[ %s ] justify_code returned %d\n",rn, code); - fflush(debugFD); - } - firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0]; - secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1]; + /* blank out host name object */ + tmp_lightobj = + (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data; + code = + justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH, + LEFT_JUSTIFY, 1); + if (code) { + fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn, + code); + fflush(debugFD); + } - for (k=0; kdata_o[0]; + secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1]; - firstSlot_o_Ptr++; - secondSlot_o_Ptr++; - } + for (k = 0; k < cm_cols_perPage; k++) { + code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */ + RIGHT_JUSTIFY, 0); /* dont highlight */ - } /* cmIDx >= numCM */ + firstSlot_o_Ptr++; + secondSlot_o_Ptr++; + } + } - tmp_cm_lines_P++; /* pointer to next line in the frame */ - cmDataP++; /* next host's data */ - cmIdx++; /* host index */ + /* cmIDx >= numCM */ + tmp_cm_lines_P++; /* pointer to next line in the frame */ + cmDataP++; /* next host's data */ + cmIdx++; /* host index */ - } /* for each row in the Cache Manager frame */ + } /* for each row in the Cache Manager frame */ - /* redraw the display if the Cache Managers screen is currently displayed*/ - if(afsmon_win->w_frame == cmFrame) + /* redraw the display if the Cache Managers screen is currently displayed */ + if (afsmon_win->w_frame == cmFrame) WOP_DISPLAY(afsmon_win); - /* update the global page & column numbers to reflect the changes */ - cm_currPage = a_pageNum; - cm_curr_LCol = a_LcolNum;; + /* update the global page & column numbers to reflect the changes */ + cm_currPage = a_pageNum; + cm_curr_LCol = a_LcolNum;; - return(0); + return (0); -} /* cm_refresh */ +} /* cm_refresh */ @@ -2670,9 +2728,9 @@ int a_LcolNum; /* starting (leftmost) column number */ int Switch_cm_2_ovw() { - /* bind the overview frame to the window */ - gtxframe_SetFrame(afsmon_win,ovwFrame); - return(0); + /* bind the overview frame to the window */ + gtxframe_SetFrame(afsmon_win, ovwFrame); + return (0); } /*----------------------------------------------------------------------- @@ -2684,11 +2742,11 @@ Switch_cm_2_ovw() int Switch_cm_2_fs() { - if (cm_pageType & CMD_FS) { - /* bind the file servers frame to the window */ - gtxframe_SetFrame(afsmon_win,fsFrame); - } - return(0); + if (cm_pageType & CMD_FS) { + /* bind the file servers frame to the window */ + gtxframe_SetFrame(afsmon_win, fsFrame); + } + return (0); } /*----------------------------------------------------------------------- @@ -2700,14 +2758,14 @@ Switch_cm_2_fs() int Switch_cm_next() { - static char rn[] = "Switch_cm_next"; + static char rn[] = "Switch_cm_next"; - if (cm_pageType & CMD_NEXT) { + if (cm_pageType & CMD_NEXT) { /* we have a next page, refresh with next page number */ - cm_refresh(cm_currPage+1, cm_curr_LCol); - } + cm_refresh(cm_currPage + 1, cm_curr_LCol); + } - return(0); + return (0); } /*----------------------------------------------------------------------- @@ -2719,15 +2777,15 @@ Switch_cm_next() int Switch_cm_last() { - static char rn[] = "Switch_cm_last"; + static char rn[] = "Switch_cm_last"; - if (cm_pageType & CMD_NEXT) { + if (cm_pageType & CMD_NEXT) { /* we have a next page, refresh with last page number */ cm_refresh(cm_numPages, cm_curr_LCol); - } + } - return(0); + return (0); } /*----------------------------------------------------------------------- @@ -2739,13 +2797,13 @@ Switch_cm_last() int Switch_cm_prev() { - static char rn[] = "Switch_cm_prev"; + static char rn[] = "Switch_cm_prev"; - if (cm_pageType & CMD_PREV) { + if (cm_pageType & CMD_PREV) { /* we have a previous page, refresh to previous page */ - cm_refresh(cm_currPage-1, cm_curr_LCol); - } - return(0); + cm_refresh(cm_currPage - 1, cm_curr_LCol); + } + return (0); } /*----------------------------------------------------------------------- @@ -2757,13 +2815,13 @@ Switch_cm_prev() int Switch_cm_first() { - static char rn[] = "Switch_cm_first"; + static char rn[] = "Switch_cm_first"; - if (cm_pageType & CMD_PREV) { + if (cm_pageType & CMD_PREV) { /* we have a previous page, refresh to first page */ cm_refresh(1, cm_curr_LCol); - } - return(0); + } + return (0); } /*----------------------------------------------------------------------- @@ -2775,13 +2833,13 @@ Switch_cm_first() int Switch_cm_left() { - static char rn[] = "Switch_cm_left"; + static char rn[] = "Switch_cm_left"; - if (cm_pageType & CMD_LEFT) { + if (cm_pageType & CMD_LEFT) { /* we have columns on left, refresh with new column number */ cm_refresh(cm_currPage, cm_curr_LCol - cm_cols_perPage); - } - return(0); + } + return (0); } @@ -2794,13 +2852,13 @@ Switch_cm_left() int Switch_cm_leftmost() { - static char rn[] = "Switch_cm_leftmost"; + static char rn[] = "Switch_cm_leftmost"; - if (cm_pageType & CMD_LEFT) { + if (cm_pageType & CMD_LEFT) { /* we have columns on left, go to the first column */ cm_refresh(cm_currPage, 0); - } - return(0); + } + return (0); } /*----------------------------------------------------------------------- @@ -2812,13 +2870,13 @@ Switch_cm_leftmost() int Switch_cm_right() { - static char rn[] = "Switch_cm_right"; + static char rn[] = "Switch_cm_right"; - if (cm_pageType & CMD_RIGHT) { + if (cm_pageType & CMD_RIGHT) { /* we have columns on right, refresh with new column number */ cm_refresh(cm_currPage, cm_curr_LCol + cm_cols_perPage); - } - return(0); + } + return (0); } /*----------------------------------------------------------------------- @@ -2830,19 +2888,20 @@ Switch_cm_right() int Switch_cm_rightmost() { - static char rn[] = "Switch_cm_rightmost"; - int curr_LCol; + static char rn[] = "Switch_cm_rightmost"; + int curr_LCol; - if (cm_pageType & CMD_RIGHT) { + if (cm_pageType & CMD_RIGHT) { /* we have columns on right, go to the last column */ - if (cm_numCols % cm_cols_perPage) - curr_LCol = (cm_numCols / cm_cols_perPage) * cm_cols_perPage; - else - curr_LCol = ((cm_numCols / cm_cols_perPage)-1) * cm_cols_perPage; + if (cm_numCols % cm_cols_perPage) + curr_LCol = (cm_numCols / cm_cols_perPage) * cm_cols_perPage; + else + curr_LCol = + ((cm_numCols / cm_cols_perPage) - 1) * cm_cols_perPage; cm_refresh(cm_currPage, curr_LCol); - } - return(0); + } + return (0); } @@ -2864,258 +2923,278 @@ Switch_cm_rightmost() int create_CMframe_objects() -{ /* create_CMframe_objects */ - static char rn[] = "create_CMframe_objects"; - struct ServerInfo_line *cm_lines_Ptr; - struct onode **cm_data_o_Ptr; - struct onode **cmLabels_o_Ptr; - int x_pos; - int y_pos; - int code; - int i; - int j; - int numBytes; - int arrIdx; +{ /* create_CMframe_objects */ + static char rn[] = "create_CMframe_objects"; + struct ServerInfo_line *cm_lines_Ptr; + struct onode **cm_data_o_Ptr; + struct onode **cmLabels_o_Ptr; + int x_pos; + int y_pos; + int code; + int i; + int j; + int numBytes; + int arrIdx; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); } - /* create the command line object */ - cm_cmd_o = initLightObject("Command [oview, fs, prev, next, left, right] ? ", - 0,maxY-1,FC_CMD_O_WIDTH,afsmon_win); - if (cm_cmd_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create cm command onode\n",rn); + /* create the command line object */ + cm_cmd_o = + initLightObject("Command [oview, fs, prev, next, left, right] ? ", 0, + maxY - 1, FC_CMD_O_WIDTH, afsmon_win); + if (cm_cmd_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create cm command onode\n", rn); afsmon_Exit(420); - } - code = gtxframe_AddToList(cmFrame,cm_cmd_o); - code = gator_light_set(cm_cmd_o,HIGHLIGHT); + } + code = gtxframe_AddToList(cmFrame, cm_cmd_o); + code = gator_light_set(cm_cmd_o, HIGHLIGHT); - /* we already have the dimensions for the frame - same as the ovw frame */ - /* use the ovw program name object for the cm screen too */ + /* we already have the dimensions for the frame - same as the ovw frame */ + /* use the ovw program name object for the cm screen too */ - code = gtxframe_AddToList(cmFrame, ovw_progName_o); + code = gtxframe_AddToList(cmFrame, ovw_progName_o); - /* create the page number object */ - cm_pageNum_o = initLightObject("[Cache Managers, p. X of X, c. Y of Y]", - maxX-FC_PAGENUM_O_WIDTH,0,FC_PAGENUM_O_WIDTH,afsmon_win); - if (cm_pageNum_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create pageNumber onode\n",rn); + /* create the page number object */ + cm_pageNum_o = + initLightObject("[Cache Managers, p. X of X, c. Y of Y]", + maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH, + afsmon_win); + if (cm_pageNum_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn); afsmon_Exit(415); - } - code = gtxframe_AddToList(cmFrame,cm_pageNum_o); - code = gator_light_set(cm_pageNum_o,HIGHLIGHT); - - /* create the probe number object */ - cm_probeNum_o = initLightObject("[CM probes 1, freq=30 sec]", - maxX-FC_PROBENUM_O_WIDTH ,maxY-1, FC_PROBENUM_O_WIDTH, afsmon_win); - if (cm_probeNum_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create cm probeNum onode\n",rn); + } + code = gtxframe_AddToList(cmFrame, cm_pageNum_o); + code = gator_light_set(cm_pageNum_o, HIGHLIGHT); + + /* create the probe number object */ + cm_probeNum_o = + initLightObject("[CM probes 1, freq=30 sec]", + maxX - FC_PROBENUM_O_WIDTH, maxY - 1, + FC_PROBENUM_O_WIDTH, afsmon_win); + if (cm_probeNum_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create cm probeNum onode\n", rn); afsmon_Exit(425); - } - code = gtxframe_AddToList(cmFrame,cm_probeNum_o); - code = gator_light_set(cm_probeNum_o,HIGHLIGHT); - - - /* create the numCM monitored object */ - cm_numCM_o = initLightObject( - " 0 Cache Mangers monitored, 0 alerts on 0 machines", - 4,2,FC_NUMHOSTS_O_WIDTH,afsmon_win); - if (cm_numCM_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create numCM onode for the cm frame\n", - rn); + } + code = gtxframe_AddToList(cmFrame, cm_probeNum_o); + code = gator_light_set(cm_probeNum_o, HIGHLIGHT); + + + /* create the numCM monitored object */ + cm_numCM_o = + initLightObject + (" 0 Cache Mangers monitored, 0 alerts on 0 machines", 4, 2, + FC_NUMHOSTS_O_WIDTH, afsmon_win); + if (cm_numCM_o == NULL) { + sprintf(errMsg, + "[ %s ] Failed to create numCM onode for the cm frame\n", rn); afsmon_Exit(430); - } - code = gtxframe_AddToList(cmFrame,cm_numCM_o); - - /* create the "more columns to left" indicator */ - cm_leftArrows_o = initLightObject("<<<", 0,2,FC_ARROWS_O_WIDTH, afsmon_win); - if (cm_leftArrows_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create leftArrows onode for the cm frame\n", rn); + } + code = gtxframe_AddToList(cmFrame, cm_numCM_o); + + /* create the "more columns to left" indicator */ + cm_leftArrows_o = + initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win); + if (cm_leftArrows_o == NULL) { + sprintf(errMsg, + "[ %s ] Failed to create leftArrows onode for the cm frame\n", + rn); afsmon_Exit(435); - } - code = gtxframe_AddToList(cmFrame,cm_leftArrows_o); - - /* create the "more columns to right" indicator */ - cm_rightArrows_o = initLightObject(">>>", maxX-FC_ARROWS_O_WIDTH, 2, - FC_ARROWS_O_WIDTH, afsmon_win); - if (cm_rightArrows_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create rightArrows onode for the cm frame\n", rn); + } + code = gtxframe_AddToList(cmFrame, cm_leftArrows_o); + + /* create the "more columns to right" indicator */ + cm_rightArrows_o = + initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH, + afsmon_win); + if (cm_rightArrows_o == NULL) { + sprintf(errMsg, + "[ %s ] Failed to create rightArrows onode for the cm frame\n", + rn); afsmon_Exit(440); - } - code = gtxframe_AddToList(cmFrame,cm_rightArrows_o); + } + code = gtxframe_AddToList(cmFrame, cm_rightArrows_o); - /* calculate the maximum number of hosts per page (2 rows per host) */ - cm_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2; + /* calculate the maximum number of hosts per page (2 rows per host) */ + cm_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2; - /* determine the number of data columns that can fit in a page */ - cm_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH ) / (FC_COLUMN_WIDTH); + /* determine the number of data columns that can fit in a page */ + cm_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH); - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] cm_numHosts_perPage=%d cm_cols_perPage=%d\n", - rn,cm_numHosts_perPage, cm_cols_perPage); + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] cm_numHosts_perPage=%d cm_cols_perPage=%d\n", + rn, cm_numHosts_perPage, cm_cols_perPage); fflush(debugFD); - } + } - /* the above two variables give us the information needed to create - the objects for displaying the file server information */ + /* the above two variables give us the information needed to create + * the objects for displaying the file server information */ - /* allocate memory for all the onode pointers required to display - the file server statistics */ + /* allocate memory for all the onode pointers required to display + * the file server statistics */ - numBytes = cm_numHosts_perPage * sizeof(struct ServerInfo_line); - cm_lines = (struct ServerInfo_line *) malloc(numBytes); - if (cm_lines == (struct ServerInfo_line *)0) { - sprintf(errMsg,"[ %s ] Failed to allocate %d bytes for CM data lines\n", - rn, numBytes); + numBytes = cm_numHosts_perPage * sizeof(struct ServerInfo_line); + cm_lines = (struct ServerInfo_line *)malloc(numBytes); + if (cm_lines == (struct ServerInfo_line *)0) { + sprintf(errMsg, + "[ %s ] Failed to allocate %d bytes for CM data lines\n", rn, + numBytes); afsmon_Exit(445); - } - - /* for each line of server statistics allocate memory to store two arrays - of data onodes */ - - cm_lines_Ptr = cm_lines; - for(i=0; idata_o[arrIdx] = (struct onode **) malloc(numBytes); - if (cm_lines_Ptr->data_o[arrIdx] == NULL) { - sprintf(errMsg,"[ %s ] Failed to allocate %d bytes for CM data onodes\n", - rn, numBytes); - afsmon_Exit(450); + } + + /* for each line of server statistics allocate memory to store two arrays + * of data onodes */ + + cm_lines_Ptr = cm_lines; + for (i = 0; i < cm_numHosts_perPage; i++) { + for (arrIdx = 0; arrIdx < 2; arrIdx++) { + numBytes = cm_cols_perPage * sizeof(struct onode *); + cm_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes); + if (cm_lines_Ptr->data_o[arrIdx] == NULL) { + sprintf(errMsg, + "[ %s ] Failed to allocate %d bytes for CM data onodes\n", + rn, numBytes); + afsmon_Exit(450); + } } - } - cm_lines_Ptr++; - } + cm_lines_Ptr++; + } - /* now allocate the onodes itself */ + /* now allocate the onodes itself */ - cm_lines_Ptr = cm_lines; - for(i=0; ihost_o = initLightObject("CMHostName", - 0,FC_FIRST_HOST_ROW + 2*i, FC_HOSTNAME_O_WIDTH, afsmon_win); - if (cm_lines_Ptr->host_o == NULL) { - sprintf(errMsg,"[ %s ] Failed to create an CM name onode\n",rn); - afsmon_Exit(455); - } - code = gtxframe_AddToList(cmFrame, cm_lines_Ptr->host_o); + cm_lines_Ptr->host_o = + initLightObject("CMHostName", 0, FC_FIRST_HOST_ROW + 2 * i, + FC_HOSTNAME_O_WIDTH, afsmon_win); + if (cm_lines_Ptr->host_o == NULL) { + sprintf(errMsg, "[ %s ] Failed to create an CM name onode\n", rn); + afsmon_Exit(455); + } + code = gtxframe_AddToList(cmFrame, cm_lines_Ptr->host_o); /* if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n", - rn,cm_lines_Ptr->host_o,i); - fflush(debugFD); - } */ + * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n", + * rn,cm_lines_Ptr->host_o,i); + * fflush(debugFD); + * } */ /* initialize data onodes for this host */ - for(arrIdx=0; arrIdx<2; arrIdx++) { /* for each array index */ + for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */ - cm_data_o_Ptr = cm_lines_Ptr->data_o[arrIdx]; - for(j=0; jdata_o[arrIdx]; + for (j = 0; j < cm_cols_perPage; j++) { /* for each column */ char tmpBuf[20]; /* determine x & y coordinate for this data object */ /* the 1's are for leaving a blank after each column */ x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH)); - y_pos = FC_FIRST_HOST_ROW + 2*i + arrIdx; - - sprintf(tmpBuf,"-CMData %d-",arrIdx); - *cm_data_o_Ptr = initLightObject(tmpBuf, - x_pos, y_pos, FC_COLUMN_WIDTH, afsmon_win); - if (*cm_data_o_Ptr == NULL) { - sprintf(errMsg,"[ %s ] Failed to create an CM data onode\n",rn); - afsmon_Exit(460); + y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx; + + sprintf(tmpBuf, "-CMData %d-", arrIdx); + *cm_data_o_Ptr = + initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH, + afsmon_win); + if (*cm_data_o_Ptr == NULL) { + sprintf(errMsg, + "[ %s ] Failed to create an CM data onode\n", rn); + afsmon_Exit(460); } - code = gtxframe_AddToList(cmFrame, *cm_data_o_Ptr); + code = gtxframe_AddToList(cmFrame, *cm_data_o_Ptr); cm_data_o_Ptr++; - } /* for each column */ - } /* for each onode array index */ + } /* for each column */ + } /* for each onode array index */ - cm_lines_Ptr++; - } /* for each host slot */ + cm_lines_Ptr++; + } /* for each host slot */ - /* INITIALIZE COLUMN LABELS */ + /* INITIALIZE COLUMN LABELS */ - /* allocate memory for two arrays of onode pointers for file server column - labels */ - for( arrIdx=0; arrIdx < 3; arrIdx++) { + /* allocate memory for two arrays of onode pointers for file server column + * labels */ + for (arrIdx = 0; arrIdx < 3; arrIdx++) { - cmLabels_o[arrIdx] = (struct onode **) malloc( - sizeof(struct onode *) * cm_cols_perPage); - if (cmLabels_o[arrIdx] == NULL) { - sprintf(errMsg,"[ %s ] Failed to allocate memory for CM label onodes\n", - rn); - afsmon_Exit(465); - } - - /* create cache manager name objects */ - cmLabels_o_Ptr = cmLabels_o[arrIdx]; - for (i=0; i< cm_cols_perPage; i++) { - *cmLabels_o_Ptr = initLightObject("", - FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH, - FC_FIRST_LABEL_ROW + arrIdx, - FC_COLUMN_WIDTH,afsmon_win); - - if (*cmLabels_o_Ptr == NULL) { - sprintf(errMsg,"[ %s ] Failed to create a CM label onode\n",rn); + cmLabels_o[arrIdx] = + (struct onode **)malloc(sizeof(struct onode *) * cm_cols_perPage); + if (cmLabels_o[arrIdx] == NULL) { + sprintf(errMsg, + "[ %s ] Failed to allocate memory for CM label onodes\n", + rn); + afsmon_Exit(465); + } + + /* create cache manager name objects */ + cmLabels_o_Ptr = cmLabels_o[arrIdx]; + for (i = 0; i < cm_cols_perPage; i++) { + *cmLabels_o_Ptr = + initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH, + FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH, + afsmon_win); + + if (*cmLabels_o_Ptr == NULL) { + sprintf(errMsg, "[ %s ] Failed to create a CM label onode\n", + rn); afsmon_Exit(470); - } - code = gtxframe_AddToList(cmFrame,*cmLabels_o_Ptr); - cmLabels_o_Ptr++; - } + } + code = gtxframe_AddToList(cmFrame, *cmLabels_o_Ptr); + cmLabels_o_Ptr++; + } - } + } - /* initialize the column & page counters */ + /* initialize the column & page counters */ - cm_currPage = 1; - cm_numCols = cm_DisplayItems_count; - cm_numPages = numCM / cm_numHosts_perPage; - if (numCM % cm_numHosts_perPage) + cm_currPage = 1; + cm_numCols = cm_DisplayItems_count; + cm_numPages = numCM / cm_numHosts_perPage; + if (numCM % cm_numHosts_perPage) cm_numPages++; - cm_curr_LCol = 0; /* leftmost col */ - cm_curr_RCol = 0; /* rightmost col */ + cm_curr_LCol = 0; /* leftmost col */ + cm_curr_RCol = 0; /* rightmost col */ - /* create keyboard bindings */ - /* bind Q and  to exit */ - keymap_BindToString(cmFrame->keymap,"Q",afsmonExit_gtx,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"",afsmonExit_gtx,NULL,NULL); + /* create keyboard bindings */ + /* bind Q and  to exit */ + keymap_BindToString(cmFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "", afsmonExit_gtx, NULL, NULL); - /* o = overview, c = cm, n = next, p = prev, l = left, r = right - N = last page, P = first page, L = leftmost col, R = rightmost col */ + /* o = overview, c = cm, n = next, p = prev, l = left, r = right + * N = last page, P = first page, L = leftmost col, R = rightmost col */ - keymap_BindToString(cmFrame->keymap,"o",Switch_cm_2_ovw,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"f",Switch_cm_2_fs,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"n",Switch_cm_next,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"N",Switch_cm_last,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"p",Switch_cm_prev,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"P",Switch_cm_first,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"l",Switch_cm_left,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"L",Switch_cm_leftmost,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"r",Switch_cm_right,NULL,NULL); - keymap_BindToString(cmFrame->keymap,"R",Switch_cm_rightmost,NULL,NULL); + keymap_BindToString(cmFrame->keymap, "o", Switch_cm_2_ovw, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "f", Switch_cm_2_fs, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "n", Switch_cm_next, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "N", Switch_cm_last, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "p", Switch_cm_prev, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "P", Switch_cm_first, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "l", Switch_cm_left, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "L", Switch_cm_leftmost, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "r", Switch_cm_right, NULL, NULL); + keymap_BindToString(cmFrame->keymap, "R", Switch_cm_rightmost, NULL, + NULL); - return(0); -} /* create_CMframe_objects */ + return (0); +} /* create_CMframe_objects */ @@ -3127,75 +3206,74 @@ create_CMframe_objects() * for the overview, File Servers & Cache Managers screens. *----------------------------------------------------------------------*/ int -gtx_initialize() -{ /* gtx_initialize */ - static char rn[] = "gtx_initialize"; /* routine name */ - int code; +gtx_initialize() +{ /* gtx_initialize */ + static char rn[] = "gtx_initialize"; /* routine name */ + int code; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); } - afsmon_win = gtx_Init(0,-1); /* 0 => dont start input server, - 1 => use curses */ - if(afsmon_win == NULL) { - sprintf(errMsg,"[ %s ] gtx initialization failed\n",rn); + afsmon_win = gtx_Init(0, -1); /* 0 => dont start input server, + * 1 => use curses */ + if (afsmon_win == NULL) { + sprintf(errMsg, "[ %s ] gtx initialization failed\n", rn); afsmon_Exit(475); - } - gtx_initialized = 1; + } + gtx_initialized = 1; - /* Create the Overview frame */ + /* Create the Overview frame */ - ovwFrame = gtxframe_Create(); - if (ovwFrame == (struct gtx_frame *)0) { - sprintf(errMsg,"[ %s ] Failed to create overview frame\n",rn); + ovwFrame = gtxframe_Create(); + if (ovwFrame == (struct gtx_frame *)0) { + sprintf(errMsg, "[ %s ] Failed to create overview frame\n", rn); afsmon_Exit(480); - } + } - /* bind the overview frame to the window */ - gtxframe_SetFrame(afsmon_win,ovwFrame); + /* bind the overview frame to the window */ + gtxframe_SetFrame(afsmon_win, ovwFrame); - /* create overview frame objects */ - code = create_ovwFrame_objects(); - if (code) { - sprintf(errMsg,"[ %s ] Error in creating ovw frame objects\n",rn); + /* create overview frame objects */ + code = create_ovwFrame_objects(); + if (code) { + sprintf(errMsg, "[ %s ] Error in creating ovw frame objects\n", rn); afsmon_Exit(485); - } + } - /* Create the File Server frame */ - fsFrame = gtxframe_Create(); - if (fsFrame == (struct gtx_frame *)0) { - sprintf(errMsg,"[ %s ] Failed to create file server frame\n",rn); + /* Create the File Server frame */ + fsFrame = gtxframe_Create(); + if (fsFrame == (struct gtx_frame *)0) { + sprintf(errMsg, "[ %s ] Failed to create file server frame\n", rn); afsmon_Exit(490); - } + } - /* Create File Server frame objects */ - code = create_FSframe_objects(); - if (code) { - sprintf(errMsg,"[ %s ] Error in creating FS frame objects\n",rn); + /* Create File Server frame objects */ + code = create_FSframe_objects(); + if (code) { + sprintf(errMsg, "[ %s ] Error in creating FS frame objects\n", rn); afsmon_Exit(495); - } + } - /* Create the Cache Managers frame */ - cmFrame = gtxframe_Create(); - if (cmFrame == (struct gtx_frame *)0) { - sprintf(errMsg,"[ %s ] Failed to create Cache Managers frame\n",rn); + /* Create the Cache Managers frame */ + cmFrame = gtxframe_Create(); + if (cmFrame == (struct gtx_frame *)0) { + sprintf(errMsg, "[ %s ] Failed to create Cache Managers frame\n", rn); afsmon_Exit(500); - } + } - /* Create Cache Managers frame objects */ - code = create_CMframe_objects(); - if (code) { - sprintf(errMsg,"[ %s ] Error in creating CM frame objects\n",rn); + /* Create Cache Managers frame objects */ + code = create_CMframe_objects(); + if (code) { + sprintf(errMsg, "[ %s ] Error in creating CM frame objects\n", rn); afsmon_Exit(505); - } - - /* misc initializations */ - sprintf(blankline,"%255s"," "); + } - return (0); -} /* gtx_initialize */ + /* misc initializations */ + sprintf(blankline, "%255s", " "); + return (0); +} /* gtx_initialize */ diff --git a/src/afsmonitor/afsmonitor.c b/src/afsmonitor/afsmonitor.c index 8c3c8e302..252e91d7f 100644 --- a/src/afsmonitor/afsmonitor.c +++ b/src/afsmonitor/afsmonitor.c @@ -16,7 +16,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -33,21 +34,21 @@ RCSID("$Header$"); #endif #include -#include /*Generic window package*/ -#include /*Object definitions*/ +#include /*Generic window package */ +#include /*Object definitions */ #if 0 -#include /*Text object interface*/ +#include /*Text object interface */ #endif -#include /*Light object interface*/ -#include /*Curses window package*/ -#include /*Dumb terminal window package*/ -#include /*X11 window package*/ -#include /*Frame package*/ +#include /*Light object interface */ +#include /*Curses window package */ +#include /*Dumb terminal window package */ +#include /*X11 window package */ +#include /*Frame package */ -#include -#include +#include +#include #include "afsmonitor.h" @@ -69,14 +70,14 @@ RCSID("$Header$"); int afsmon_debug = 0; /* debug info to file ? */ FILE *debugFD; /* debugging file descriptor */ static int afsmon_output = 0; /* output to file ? */ -static int afsmon_detOutput = 0; /* detailed output ? */ +static int afsmon_detOutput = 0; /* detailed output ? */ static int afsmon_onceOnly = 0; /* probe once only ? (not implemented) */ int afsmon_probefreq; /* probe frequency */ static int wpkg_to_use; /* graphics package to use */ -static char output_filename[80];/* output filename */ -char errMsg[256]; /* buffers used to print error messages after*/ -char errMsg1[256]; /* gtx is initialized (stderr/stdout gone !) */ -int num_bufSlots = 0; /* number of slots in fs & cm circular buffers*/ +static char output_filename[80]; /* output filename */ +char errMsg[256]; /* buffers used to print error messages after */ +char errMsg1[256]; /* gtx is initialized (stderr/stdout gone !) */ +int num_bufSlots = 0; /* number of slots in fs & cm circular buffers */ /* Flags used to process "show" directives in config file */ short fs_showFlags[NUM_FS_STAT_ENTRIES]; @@ -93,11 +94,11 @@ short cm_showFlags[NUM_CM_STAT_ENTRIES]; #define NUM_XSTAT_FS_AFS_PERFSTATS_LONGS 66 /* number of fields (longs) in struct afs_PerfStats that we display */ -#define NUM_AFS_STATS_CMPERF_LONGS 40 /* number of longs in struct afs_stats_CMPerf excluding up/down stats and fields we dont display */ - +#define NUM_AFS_STATS_CMPERF_LONGS 40 /* number of longs in struct afs_stats_CMPerf excluding up/down stats and fields we dont display */ + /* variables used for exec'ing user provided threshold handlers */ -char *fsHandler_argv[20]; /* *argv[] for the handler */ +char *fsHandler_argv[20]; /* *argv[] for the handler */ char fsHandler_args[20][256]; /* buffer space for arguments */ int exec_fsThreshHandler = 0; /* execute fs threshold handler ? */ @@ -128,28 +129,28 @@ static struct afsmon_hostEntry *last_hostEntry; /* names of the last host processed in the config file */ static char last_fsHost[HOST_NAME_LEN]; static char last_cmHost[HOST_NAME_LEN]; -static lastHostType = 0; /* 0 = no host entries processed - 1 = last host was file server - 2 = last host was cache manager. */ +static lastHostType = 0; /* 0 = no host entries processed + * 1 = last host was file server + * 2 = last host was cache manager. */ /* FILE SERVER CIRCULAR BUFFER VARIABLES */ struct afsmon_fs_Results_list { - struct xstat_fs_ProbeResults *fsResults; /* ptr to results struct*/ - int empty; /* fsResults empty ? */ - struct afsmon_fs_Results_list *next; + struct xstat_fs_ProbeResults *fsResults; /* ptr to results struct */ + int empty; /* fsResults empty ? */ + struct afsmon_fs_Results_list *next; }; struct afsmon_fs_Results_CBuffer { - int probeNum; /* probe number of entries in this slot */ - struct afsmon_fs_Results_list *list; /* ptr to list of results */ + int probeNum; /* probe number of entries in this slot */ + struct afsmon_fs_Results_list *list; /* ptr to list of results */ }; /* buffer for FS probe results */ struct afsmon_fs_Results_CBuffer *afsmon_fs_ResultsCB; -int afsmon_fs_curr_CBindex = 0; /* current fs CB slot */ +int afsmon_fs_curr_CBindex = 0; /* current fs CB slot */ /* Probe number variables. The current probe number is incremented when the first probe from a new probe cycle is received. The prev probe @@ -164,20 +165,20 @@ int afsmon_fs_prev_probeNum = 0; /* previous fs probe number */ /* CACHE MANAGER CIRCULAR BUFFER VARIABLES */ struct afsmon_cm_Results_list { - struct xstat_cm_ProbeResults *cmResults; /* ptr to results struct*/ - int empty; /* cmResults empty ? */ - struct afsmon_cm_Results_list *next; + struct xstat_cm_ProbeResults *cmResults; /* ptr to results struct */ + int empty; /* cmResults empty ? */ + struct afsmon_cm_Results_list *next; }; struct afsmon_cm_Results_CBuffer { - int probeNum; /* probe number of entries in this slot */ - struct afsmon_cm_Results_list *list; /* ptr to list of results */ + int probeNum; /* probe number of entries in this slot */ + struct afsmon_cm_Results_list *list; /* ptr to list of results */ }; /* buffer for CM probe results */ struct afsmon_cm_Results_CBuffer *afsmon_cm_ResultsCB; -int afsmon_cm_curr_CBindex = 0; /* current cm CB slot */ +int afsmon_cm_curr_CBindex = 0; /* current cm CB slot */ /* Probe number variables. The current probe number is incremented @@ -186,29 +187,29 @@ number is incremented when the last probe of the current cycle is received. This difference is because of the purpose for which these counters are used */ -int afsmon_cm_curr_probeNum = 1; /* current cm probe number */ -int afsmon_cm_prev_probeNum = 0; /* previous cm probe number */ +int afsmon_cm_curr_probeNum = 1; /* current cm probe number */ +int afsmon_cm_prev_probeNum = 0; /* previous cm probe number */ /* Structures to hold FS & CM results in string format(suitable for display ) */ -/* ptr to array holding the results of FS probes in ascii format */ +/* ptr to array holding the results of FS probes in ascii format */ /* for current probe cycle */ struct fs_Display_Data *curr_fsData = (struct fs_Display_Data *)0; /* for previous probe cycle */ struct fs_Display_Data *prev_fsData = (struct fs_Display_Data *)0; -/* ptr to array holding the results of CM probes in ascii format */ +/* ptr to array holding the results of CM probes in ascii format */ /* for current probe cycle */ struct cm_Display_Data *curr_cmData = (struct cm_Display_Data *)0; /* for previous probe cycle */ -struct cm_Display_Data *prev_cmData = (struct cm_Display_Data *)0; +struct cm_Display_Data *prev_cmData = (struct cm_Display_Data *)0; /* EXTERN DEFINITIONS */ -extern struct hostent *hostutil_GetHostByName(); +extern struct hostent *hostutil_GetHostByName(); @@ -241,7 +242,7 @@ data is available for updating the display */ extern fs_Data_Available; extern cm_Data_Available; -extern int gtx_initialized; /* gtx initialized ? */ +extern int gtx_initialized; /* gtx initialized ? */ /* This array contains the indices of the file server data items that are to be displayed on the File Servers screen. For example, suppose the @@ -253,24 +254,24 @@ items in the fs_varNames[] array */ short fs_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN]; int fs_DisplayItems_count = 0; /* number of items to display */ -int fs_showDefault = 1; /* show all of FS data ? */ +int fs_showDefault = 1; /* show all of FS data ? */ /* same use as above for Cache Managers */ short cm_Display_map[XSTAT_CM_FULLPERF_RESULTS_LEN]; int cm_DisplayItems_count = 0; /* number of items to display */ -int cm_showDefault = 1; /* show all of CM data ? */ +int cm_showDefault = 1; /* show all of CM data ? */ -extern int fs_currPage; /* current page number in the File Servers frame */ -extern int fs_curr_LCol; /* current leftmost column on display on FS frame */ +extern int fs_currPage; /* current page number in the File Servers frame */ +extern int fs_curr_LCol; /* current leftmost column on display on FS frame */ -extern int cm_currPage; /* current page number in the Cache Managers frame */ -extern int cm_curr_LCol; /* current leftmost column on display on CM frame */ +extern int cm_currPage; /* current page number in the Cache Managers frame */ +extern int cm_curr_LCol; /* current leftmost column on display on CM frame */ /* File server and Cache manager data is classified into sections & groups to help the user choose what he wants displayed */ -extern char *fs_categories[]; /* file server data category names */ -extern char *cm_categories[]; /* cache manager data category names */ +extern char *fs_categories[]; /* file server data category names */ +extern char *cm_categories[]; /* cache manager data category names */ @@ -283,48 +284,50 @@ extern char *cm_categories[]; /* cache manager data category names */ config file to be case insensitive. */ -char *strcasestr(s1,s2) -char *s1; -char *s2; +char * +strcasestr(s1, s2) + char *s1; + char *s2; { - char *ptr; - int len1,len2; + char *ptr; + int len1, len2; - len1 = strlen(s1); - len2 = strlen(s2); + len1 = strlen(s1); + len2 = strlen(s2); - if ( len1 < len2) - return ((char *)NULL); + if (len1 < len2) + return ((char *)NULL); - ptr = s1; + ptr = s1; - while( len1 >= len2 && len1 > 0 ) { - if ( (strncasecmp(ptr,s2,len2)) == 0) - return (ptr); - ptr++; - len1--; - } - return ((char *)NULL); + while (len1 >= len2 && len1 > 0) { + if ((strncasecmp(ptr, s2, len2)) == 0) + return (ptr); + ptr++; + len1--; + } + return ((char *)NULL); } #endif -struct hostent *GetHostByName(name) -char *name; +struct hostent * +GetHostByName(name) + char *name; { - struct hostent *he; + struct hostent *he; #ifdef AFS_SUN5_ENV - char ip_addr[32]; + char ip_addr[32]; #endif - - he = gethostbyname(name); + + he = gethostbyname(name); #ifdef AFS_SUN5_ENV - /* On solaris the above does not resolve hostnames to full names */ - if (he != NULL) { - memcpy(ip_addr, he->h_addr, he->h_length); - he = gethostbyaddr(ip_addr, he->h_length, he->h_addrtype); - } + /* On solaris the above does not resolve hostnames to full names */ + if (he != NULL) { + memcpy(ip_addr, he->h_addr, he->h_length); + he = gethostbyaddr(ip_addr, he->h_length, he->h_addrtype); + } #endif - return(he); + return (he); } @@ -346,203 +349,205 @@ char *name; * *----------------------------------------------------------------------*/ -int -afsmon_Exit(a_exitVal) -int a_exitVal; /* exit code */ -{ /* afsmon_Exit */ - static char rn[] = "afsmon_Exit"; - struct afsmon_fs_Results_list *tmp_fslist; - struct afsmon_fs_Results_list *next_fslist; - struct xstat_fs_ProbeResults *tmp_xstat_fsPR; - struct afsmon_cm_Results_list *tmp_cmlist; - struct afsmon_cm_Results_list *next_cmlist; - struct xstat_cm_ProbeResults *tmp_xstat_cmPR; - struct afsmon_hostEntry *curr_hostEntry; - struct afsmon_hostEntry *prev_hostEntry; - int i; - int j; - int bufslot; - int code; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called with exit code %d\n",rn, a_exitVal); +int +afsmon_Exit(a_exitVal) + int a_exitVal; /* exit code */ +{ /* afsmon_Exit */ + static char rn[] = "afsmon_Exit"; + struct afsmon_fs_Results_list *tmp_fslist; + struct afsmon_fs_Results_list *next_fslist; + struct xstat_fs_ProbeResults *tmp_xstat_fsPR; + struct afsmon_cm_Results_list *tmp_cmlist; + struct afsmon_cm_Results_list *next_cmlist; + struct xstat_cm_ProbeResults *tmp_xstat_cmPR; + struct afsmon_hostEntry *curr_hostEntry; + struct afsmon_hostEntry *prev_hostEntry; + int i; + int j; + int bufslot; + int code; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called with exit code %d\n", rn, a_exitVal); fflush(debugFD); - } - - /* get out of curses first, but not if we are here to exec a threshold - handler. If we do, the screen gets messed up */ - if (gtx_initialized && ! exec_fsThreshHandler) + } + + /* get out of curses first, but not if we are here to exec a threshold + * handler. If we do, the screen gets messed up */ + if (gtx_initialized && !exec_fsThreshHandler) gator_cursesgwin_cleanup(afsmon_win); - - /* print the error message buffer */ - if (errMsg[0] != '\0') - fprintf(stderr,"%s",errMsg); - if (errMsg1[0] != '\0') - fprintf(stderr,"%s",errMsg1); - - /* deallocate file server circular buffers */ - if (numFS && num_bufSlots) { - if(afsmon_debug) { - fprintf(debugFD,"freeing FS circular buffers "); - fflush(debugFD); - } - - for (bufslot=0; bufslotnext; - tmp_xstat_fsPR = tmp_fslist->fsResults; + } + next_fslist = tmp_fslist->next; + tmp_xstat_fsPR = tmp_fslist->fsResults; - if (afsmon_debug) - fprintf(debugFD,"%d ",numFS-j); - - /* free xstat_fs_Results data */ - free(tmp_xstat_fsPR->data.AFS_CollData_val); - free(tmp_xstat_fsPR->connP); - free(tmp_xstat_fsPR); - - /* free the fs list item */ - free(tmp_fslist); - tmp_fslist = next_fslist; - - } /* while fs list items in this slot */ - } /* if entries in this buffer slot */ - } /* for each fs buffer slot */ - if (afsmon_debug) - fprintf(debugFD,"\n"); - } - - if (afsmon_debug) + if (afsmon_debug) + fprintf(debugFD, "%d ", numFS - j); + + /* free xstat_fs_Results data */ + free(tmp_xstat_fsPR->data.AFS_CollData_val); + free(tmp_xstat_fsPR->connP); + free(tmp_xstat_fsPR); + + /* free the fs list item */ + free(tmp_fslist); + tmp_fslist = next_fslist; + + } /* while fs list items in this slot */ + } /* if entries in this buffer slot */ + } /* for each fs buffer slot */ + if (afsmon_debug) + fprintf(debugFD, "\n"); + } + + if (afsmon_debug) fflush(debugFD); - /* deallocate cache manager curcular buffers */ - if (numCM && num_bufSlots) { - if (afsmon_debug) - fprintf(debugFD,"freeing CM curcular buffers "); - for (bufslot=0; bufslotnext; - tmp_xstat_cmPR = tmp_cmlist->cmResults; - - if (afsmon_debug) - fprintf(debugFD,"%d ",numCM-j); - /* make sure data is ok */ - /* Print_cm_FullPerfInfo(tmp_xstat_cmPR); */ - - /* free xstat_cm_Results data */ - free(tmp_xstat_cmPR->data.AFSCB_CollData_val); - free(tmp_xstat_cmPR->connP); - free(tmp_xstat_cmPR); - - /* free the cm list item */ - free(tmp_cmlist); - tmp_cmlist = next_cmlist; - - } /* while cm list items in this slot */ - } /* if entries in this buffer slot */ - } /* for each cm buffer slot */ - if (afsmon_debug) - fprintf(debugFD,"\n"); - } - - - /* deallocate FS & CM Print buffers */ - if (curr_fsData != (struct fs_Display_Data *)0) { - if (afsmon_debug) - fprintf(debugFD,"Deallocating FS Print Buffers .... curr"); + } + next_cmlist = tmp_cmlist->next; + tmp_xstat_cmPR = tmp_cmlist->cmResults; + + if (afsmon_debug) + fprintf(debugFD, "%d ", numCM - j); + /* make sure data is ok */ + /* Print_cm_FullPerfInfo(tmp_xstat_cmPR); */ + + /* free xstat_cm_Results data */ + free(tmp_xstat_cmPR->data.AFSCB_CollData_val); + free(tmp_xstat_cmPR->connP); + free(tmp_xstat_cmPR); + + /* free the cm list item */ + free(tmp_cmlist); + tmp_cmlist = next_cmlist; + + } /* while cm list items in this slot */ + } /* if entries in this buffer slot */ + } /* for each cm buffer slot */ + if (afsmon_debug) + fprintf(debugFD, "\n"); + } + + + /* deallocate FS & CM Print buffers */ + if (curr_fsData != (struct fs_Display_Data *)0) { + if (afsmon_debug) + fprintf(debugFD, "Deallocating FS Print Buffers .... curr"); free(curr_fsData); - } - if (prev_fsData != (struct fs_Display_Data *)0) { - if (afsmon_debug) - fprintf(debugFD,", prev \n"); + } + if (prev_fsData != (struct fs_Display_Data *)0) { + if (afsmon_debug) + fprintf(debugFD, ", prev \n"); free(prev_fsData); - } - if (prev_cmData != (struct cm_Display_Data *)0) { - if (afsmon_debug) - fprintf(debugFD,"Deallocating CM Print Buffers .... curr"); + } + if (prev_cmData != (struct cm_Display_Data *)0) { + if (afsmon_debug) + fprintf(debugFD, "Deallocating CM Print Buffers .... curr"); free(curr_cmData); - } - if (prev_cmData != (struct cm_Display_Data *)0) { - if (afsmon_debug) - fprintf(debugFD,", prev \n"); + } + if (prev_cmData != (struct cm_Display_Data *)0) { + if (afsmon_debug) + fprintf(debugFD, ", prev \n"); free(prev_cmData); - } - - /* deallocate hostEntry lists */ - if (numFS) { - if (afsmon_debug) - fprintf(debugFD,"Deallocating FS hostEntries .."); + } + + /* deallocate hostEntry lists */ + if (numFS) { + if (afsmon_debug) + fprintf(debugFD, "Deallocating FS hostEntries .."); curr_hostEntry = FSnameList; - for(i=0; ithresh != NULL) - free(curr_hostEntry->thresh); - free(curr_hostEntry); - if (afsmon_debug) - fprintf(debugFD," %d",i); - curr_hostEntry = prev_hostEntry->next; - } - if (afsmon_debug) - fprintf(debugFD,"\n"); - } - if (numCM) { - if (afsmon_debug) - fprintf(debugFD,"Deallocating CM hostEntries .."); + for (i = 0; i < numFS; i++) { + prev_hostEntry = curr_hostEntry; + if (curr_hostEntry->thresh != NULL) + free(curr_hostEntry->thresh); + free(curr_hostEntry); + if (afsmon_debug) + fprintf(debugFD, " %d", i); + curr_hostEntry = prev_hostEntry->next; + } + if (afsmon_debug) + fprintf(debugFD, "\n"); + } + if (numCM) { + if (afsmon_debug) + fprintf(debugFD, "Deallocating CM hostEntries .."); curr_hostEntry = CMnameList; - for(i=0; ithresh != NULL) - free(curr_hostEntry->thresh); - free(curr_hostEntry); - if (afsmon_debug) - fprintf(debugFD," %d",i); - curr_hostEntry = prev_hostEntry->next; - } - if (afsmon_debug) - fprintf(debugFD,"\n"); - } - - /* close debug file */ - if (afsmon_debug) { + for (i = 0; i < numCM; i++) { + prev_hostEntry = curr_hostEntry; + if (curr_hostEntry->thresh != NULL) + free(curr_hostEntry->thresh); + free(curr_hostEntry); + if (afsmon_debug) + fprintf(debugFD, " %d", i); + curr_hostEntry = prev_hostEntry->next; + } + if (afsmon_debug) + fprintf(debugFD, "\n"); + } + + /* close debug file */ + if (afsmon_debug) { fflush(debugFD); fclose(debugFD); - } + } - if (exec_fsThreshHandler) { - code = execvp(fsHandler_argv[0],fsHandler_argv); - if (code == -1) { - fprintf(stderr,"execvp() of %s returned %d, errno %d\n", - fsHandler_argv[0], code, errno); - exit(-1); - } - } + if (exec_fsThreshHandler) { + code = execvp(fsHandler_argv[0], fsHandler_argv); + if (code == -1) { + fprintf(stderr, "execvp() of %s returned %d, errno %d\n", + fsHandler_argv[0], code, errno); + exit(-1); + } + } - exit(a_exitVal); -} /* afsmon_Exit */ + exit(a_exitVal); +} /* afsmon_Exit */ /*----------------------------------------------------------------------- * insert_FS() @@ -555,41 +560,41 @@ int a_exitVal; /* exit code */ * Failure: -1 *----------------------------------------------------------------------*/ -int -insert_FS( a_hostName ) -char *a_hostName; /* name of cache manager to be inserted in list */ -{ /* insert_FS() */ - static char rn[] = "insert_FS"; /* routine name */ - static struct afsmon_hostEntry *curr_item; - static struct afsmon_hostEntry *prev_item; - - if ( *a_hostName == '\0') - return(-1); - curr_item = (struct afsmon_hostEntry *) - malloc(sizeof(struct afsmon_hostEntry)); - if (curr_item == (struct afsmon_hostEntry *)0) { - fprintf(stderr,"Failed to allocate space for FS nameList\n"); - return(-1); - } - - strncpy(curr_item->hostName,a_hostName,CFG_STR_LEN); - curr_item->next = (struct afsmon_hostEntry *)0; - curr_item->numThresh = 0; - curr_item->thresh = NULL; - - if (FSnameList == (struct afsmon_hostEntry *)0) +int +insert_FS(a_hostName) + char *a_hostName; /* name of cache manager to be inserted in list */ +{ /* insert_FS() */ + static char rn[] = "insert_FS"; /* routine name */ + static struct afsmon_hostEntry *curr_item; + static struct afsmon_hostEntry *prev_item; + + if (*a_hostName == '\0') + return (-1); + curr_item = (struct afsmon_hostEntry *) + malloc(sizeof(struct afsmon_hostEntry)); + if (curr_item == (struct afsmon_hostEntry *)0) { + fprintf(stderr, "Failed to allocate space for FS nameList\n"); + return (-1); + } + + strncpy(curr_item->hostName, a_hostName, CFG_STR_LEN); + curr_item->next = (struct afsmon_hostEntry *)0; + curr_item->numThresh = 0; + curr_item->thresh = NULL; + + if (FSnameList == (struct afsmon_hostEntry *)0) FSnameList = curr_item; - else - prev_item->next = curr_item; + else + prev_item->next = curr_item; - prev_item = curr_item; - /* record the address of this entry so that its threshold - count can be incremented during the first pass of the config file */ - last_hostEntry = curr_item; + prev_item = curr_item; + /* record the address of this entry so that its threshold + * count can be incremented during the first pass of the config file */ + last_hostEntry = curr_item; - return(0); + return (0); } - + /*----------------------------------------------------------------------- * print_FS() * @@ -602,34 +607,34 @@ char *a_hostName; /* name of cache manager to be inserted in list */ *----------------------------------------------------------------------*/ void print_FS() -{ /* print_FS() */ - static char rn[] = "print_FS"; - struct afsmon_hostEntry *tempFS; - struct Threshold *threshP; - int i; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); +{ /* print_FS() */ + static char rn[] = "print_FS"; + struct afsmon_hostEntry *tempFS; + struct Threshold *threshP; + int i; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); - } - - if (afsmon_debug) { - tempFS = FSnameList; - fprintf(debugFD,"No of File Servers: %d\n",numFS); - if (numFS) { - do { - fprintf(debugFD,"\t %s threshCount = %d\n", - tempFS->hostName,tempFS->numThresh); + } + + if (afsmon_debug) { + tempFS = FSnameList; + fprintf(debugFD, "No of File Servers: %d\n", numFS); + if (numFS) { + do { + fprintf(debugFD, "\t %s threshCount = %d\n", tempFS->hostName, + tempFS->numThresh); threshP = tempFS->thresh; - for(i=0; inumThresh; i++,threshP++) - fprintf(debugFD,"\t thresh (%2d) %s %s %s\n", - threshP->index, threshP->itemName, - threshP->threshVal,threshP->handler); - } while ( (tempFS = tempFS->next) != (struct afsmon_hostEntry *)0); - } - fprintf(debugFD,"\t\t-----End of List-----\n"); - fflush(debugFD); - } + for (i = 0; i < tempFS->numThresh; i++, threshP++) + fprintf(debugFD, "\t thresh (%2d) %s %s %s\n", + threshP->index, threshP->itemName, + threshP->threshVal, threshP->handler); + } while ((tempFS = tempFS->next) != (struct afsmon_hostEntry *)0); + } + fprintf(debugFD, "\t\t-----End of List-----\n"); + fflush(debugFD); + } } @@ -644,41 +649,41 @@ print_FS() * Failure: -1 *----------------------------------------------------------------------*/ -int -insert_CM( a_hostName ) -char *a_hostName; /* name of cache manager to be inserted in list */ -{ /* insert_CM */ - static char rn[] = "insert_CM"; /* routine name */ - static struct afsmon_hostEntry *curr_item; - static struct afsmon_hostEntry *prev_item; - - if ( *a_hostName == '\0') - return(-1); - curr_item = (struct afsmon_hostEntry *) - malloc(sizeof(struct afsmon_hostEntry)); - if (curr_item == (struct afsmon_hostEntry *)0) { - fprintf(stderr,"Failed to allocate space for CM nameList\n"); - return(-1); - } - - strncpy(curr_item->hostName,a_hostName,CFG_STR_LEN); - curr_item->next = (struct afsmon_hostEntry *)0; - curr_item->numThresh = 0; - curr_item->thresh = NULL; - - if (CMnameList == (struct afsmon_hostEntry *)0) +int +insert_CM(a_hostName) + char *a_hostName; /* name of cache manager to be inserted in list */ +{ /* insert_CM */ + static char rn[] = "insert_CM"; /* routine name */ + static struct afsmon_hostEntry *curr_item; + static struct afsmon_hostEntry *prev_item; + + if (*a_hostName == '\0') + return (-1); + curr_item = (struct afsmon_hostEntry *) + malloc(sizeof(struct afsmon_hostEntry)); + if (curr_item == (struct afsmon_hostEntry *)0) { + fprintf(stderr, "Failed to allocate space for CM nameList\n"); + return (-1); + } + + strncpy(curr_item->hostName, a_hostName, CFG_STR_LEN); + curr_item->next = (struct afsmon_hostEntry *)0; + curr_item->numThresh = 0; + curr_item->thresh = NULL; + + if (CMnameList == (struct afsmon_hostEntry *)0) CMnameList = curr_item; - else - prev_item->next = curr_item; + else + prev_item->next = curr_item; - prev_item = curr_item; - /* side effect. note the address of this entry so that its threshold - count can be incremented during the first pass of the config file */ - last_hostEntry = curr_item; + prev_item = curr_item; + /* side effect. note the address of this entry so that its threshold + * count can be incremented during the first pass of the config file */ + last_hostEntry = curr_item; - return(0); + return (0); } - + /*----------------------------------------------------------------------- * print_CM() @@ -692,35 +697,35 @@ char *a_hostName; /* name of cache manager to be inserted in list */ *----------------------------------------------------------------------*/ int print_CM() -{ /* print_CM() */ - static char rn[] = "print_CM"; - struct afsmon_hostEntry *tempCM; - struct Threshold *threshP; - int i; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); +{ /* print_CM() */ + static char rn[] = "print_CM"; + struct afsmon_hostEntry *tempCM; + struct Threshold *threshP; + int i; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); - } - - if (afsmon_debug) { - tempCM = CMnameList; - fprintf(debugFD,"No of Cache Managers: %d\n",numCM); - if (numCM) { - do { - fprintf(debugFD,"\t %s threshCount = %d\n", - tempCM->hostName,tempCM->numThresh); + } + + if (afsmon_debug) { + tempCM = CMnameList; + fprintf(debugFD, "No of Cache Managers: %d\n", numCM); + if (numCM) { + do { + fprintf(debugFD, "\t %s threshCount = %d\n", tempCM->hostName, + tempCM->numThresh); threshP = tempCM->thresh; - for(i=0; inumThresh; i++,threshP++) - fprintf(debugFD,"\t thresh (%2d) %s %s %s\n", - threshP->index, threshP->itemName, - threshP->threshVal,threshP->handler); - } while ( (tempCM = tempCM->next) != (struct afsmon_hostEntry *)0); - } - fprintf(debugFD,"\t\t-----End of List-----\n"); - } - return(0); -} /* print_CM() */ + for (i = 0; i < tempCM->numThresh; i++, threshP++) + fprintf(debugFD, "\t thresh (%2d) %s %s %s\n", + threshP->index, threshP->itemName, + threshP->threshVal, threshP->handler); + } while ((tempCM = tempCM->next) != (struct afsmon_hostEntry *)0); + } + fprintf(debugFD, "\t\t-----End of List-----\n"); + } + return (0); +} /* print_CM() */ @@ -744,61 +749,64 @@ print_CM() int parse_hostEntry(a_line) -char *a_line; -{ /* parse_hostEntry */ - - static char rn[] = "parse_hostEntry"; /* routine name */ - char opcode[CFG_STR_LEN]; /* specifies type of config entry */ - char arg1[CFG_STR_LEN]; /* hostname or qualifier (fs/cm?) */ - char arg2[CFG_STR_LEN]; /* threshold variable */ - char arg3[CFG_STR_LEN]; /* threshold value */ - char arg4[CFG_STR_LEN]; /* user's handler */ - struct hostent *he; /* host entry */ - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_line = %s\n",rn, a_line); + char *a_line; +{ /* parse_hostEntry */ + + static char rn[] = "parse_hostEntry"; /* routine name */ + char opcode[CFG_STR_LEN]; /* specifies type of config entry */ + char arg1[CFG_STR_LEN]; /* hostname or qualifier (fs/cm?) */ + char arg2[CFG_STR_LEN]; /* threshold variable */ + char arg3[CFG_STR_LEN]; /* threshold value */ + char arg4[CFG_STR_LEN]; /* user's handler */ + struct hostent *he; /* host entry */ + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_line = %s\n", rn, a_line); fflush(debugFD); - } - - /* break it up */ - opcode[0] = 0;arg1[0] = 0;arg2[0] = 0;arg3[0] = 0;arg4[0] = 0; - sscanf(a_line,"%s %s %s %s %s",opcode,arg1,arg2,arg3,arg4); - /* syntax is "opcode hostname" */ - if ((strlen(arg2)) != 0) { - fprintf(stderr,"[ %s ] Extraneous characters at end of line\n", rn); - return(-1); - } - - /* good host ? */ - he = GetHostByName(arg1); - if ( he == NULL) { - fprintf(stderr,"[ %s ] Unable to resolve hostname %s\n", - rn,arg1); - return(-1); - } - - if ((strcasecmp(opcode,"fs")) == 0) { + } + + /* break it up */ + opcode[0] = 0; + arg1[0] = 0; + arg2[0] = 0; + arg3[0] = 0; + arg4[0] = 0; + sscanf(a_line, "%s %s %s %s %s", opcode, arg1, arg2, arg3, arg4); + /* syntax is "opcode hostname" */ + if ((strlen(arg2)) != 0) { + fprintf(stderr, "[ %s ] Extraneous characters at end of line\n", rn); + return (-1); + } + + /* good host ? */ + he = GetHostByName(arg1); + if (he == NULL) { + fprintf(stderr, "[ %s ] Unable to resolve hostname %s\n", rn, arg1); + return (-1); + } + + if ((strcasecmp(opcode, "fs")) == 0) { /* use the complete host name to insert in the file server names list */ - insert_FS(he->h_name); + insert_FS(he->h_name); /* note that last host entry in the config file was fs */ - lastHostType = 1; - numFS++; + lastHostType = 1; + numFS++; /* threholds are not global anymore */ - if (global_ThreshFlag) global_ThreshFlag = 0; - } - else if ((strcasecmp(opcode,"cm")) == 0) { + if (global_ThreshFlag) + global_ThreshFlag = 0; + } else if ((strcasecmp(opcode, "cm")) == 0) { /* use the complete host name to insert in the CM names list */ - insert_CM(he->h_name); + insert_CM(he->h_name); /* last host entry in the config file was cm */ - lastHostType = 2; + lastHostType = 2; numCM++; /* threholds are not global anymore */ - if (global_ThreshFlag) global_ThreshFlag = 0; - } - else - return(-1); + if (global_ThreshFlag) + global_ThreshFlag = 0; + } else + return (-1); - return(0); + return (0); } /*----------------------------------------------------------------------- @@ -819,72 +827,84 @@ char *a_line; int parse_threshEntry(a_line) -char *a_line; -{ /* parse_threshEntry */ - static char rn[] = "parse_threshEntry"; /* routine name */ - char opcode[CFG_STR_LEN]; /* specifies type of config entry */ - char arg1[CFG_STR_LEN]; /* hostname or qualifier (fs/cm?) */ - char arg2[CFG_STR_LEN]; /* threshold variable */ - char arg3[CFG_STR_LEN]; /* threshold value */ - char arg4[CFG_STR_LEN]; /* user's handler */ - char arg5[CFG_STR_LEN]; /* junk characters */ - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_line = %s\n",rn, a_line); + char *a_line; +{ /* parse_threshEntry */ + static char rn[] = "parse_threshEntry"; /* routine name */ + char opcode[CFG_STR_LEN]; /* specifies type of config entry */ + char arg1[CFG_STR_LEN]; /* hostname or qualifier (fs/cm?) */ + char arg2[CFG_STR_LEN]; /* threshold variable */ + char arg3[CFG_STR_LEN]; /* threshold value */ + char arg4[CFG_STR_LEN]; /* user's handler */ + char arg5[CFG_STR_LEN]; /* junk characters */ + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_line = %s\n", rn, a_line); fflush(debugFD); - } - - /* break it up */ - opcode[0] = 0;arg1[0] = 0;arg2[0] = 0;arg3[0] = 0;arg4[0] = 0;arg5[0] = 0; - sscanf(a_line,"%s %s %s %s %s %s",opcode,arg1,arg2,arg3,arg4,arg5); - - /* syntax is "thresh fs/cm variable_name threshold_value [handler] " */ - if (((strlen(arg1)) == 0)||((strlen(arg2)) == 0)||((strlen(arg3)) == 0)) { - fprintf(stderr,"[ %s ] Incomplete line\n", rn); - return(-1); - } - if (strlen(arg3) > THRESH_VAR_LEN-2) { - fprintf(stderr,"[%s ] threshold value too long\n", rn); - return(-1); - } - - if ((strcasecmp(arg1,"fs")) == 0) { + } + + /* break it up */ + opcode[0] = 0; + arg1[0] = 0; + arg2[0] = 0; + arg3[0] = 0; + arg4[0] = 0; + arg5[0] = 0; + sscanf(a_line, "%s %s %s %s %s %s", opcode, arg1, arg2, arg3, arg4, arg5); + + /* syntax is "thresh fs/cm variable_name threshold_value [handler] " */ + if (((strlen(arg1)) == 0) || ((strlen(arg2)) == 0) + || ((strlen(arg3)) == 0)) { + fprintf(stderr, "[ %s ] Incomplete line\n", rn); + return (-1); + } + if (strlen(arg3) > THRESH_VAR_LEN - 2) { + fprintf(stderr, "[%s ] threshold value too long\n", rn); + return (-1); + } + + if ((strcasecmp(arg1, "fs")) == 0) { switch (lastHostType) { - case 0: /* its a global threshold */ - global_fsThreshCount++; - break; - case 1: /* inc thresh count of last file server */ - last_hostEntry->numThresh++; - break; + case 0: /* its a global threshold */ + global_fsThreshCount++; + break; + case 1: /* inc thresh count of last file server */ + last_hostEntry->numThresh++; + break; case 2: - fprintf(stderr,"[ %s ] A threshold for a File Server cannot be placed after a Cache Manager host entry in the config file \n",rn); - return(-1); + fprintf(stderr, + "[ %s ] A threshold for a File Server cannot be placed after a Cache Manager host entry in the config file \n", + rn); + return (-1); default: - fprintf(stderr,"[ %s ] Programming error 1\n",rn); - return(-1); + fprintf(stderr, "[ %s ] Programming error 1\n", rn); + return (-1); } - } else if ((strcasecmp(arg1,"cm")) == 0) { + } else if ((strcasecmp(arg1, "cm")) == 0) { switch (lastHostType) { - case 0: /* its a global threshold */ - global_cmThreshCount++; - break; - case 2: /* inc thresh count of last cache manager */ - last_hostEntry->numThresh++; - break; + case 0: /* its a global threshold */ + global_cmThreshCount++; + break; + case 2: /* inc thresh count of last cache manager */ + last_hostEntry->numThresh++; + break; case 1: - fprintf(stderr,"[ %s ] A threshold for a Cache Manager cannot be placed after a File Server host entry in the config file \n",rn); - return(-1); + fprintf(stderr, + "[ %s ] A threshold for a Cache Manager cannot be placed after a File Server host entry in the config file \n", + rn); + return (-1); default: - fprintf(stderr,"[ %s ] Programming error 2\n",rn); - return(-1); + fprintf(stderr, "[ %s ] Programming error 2\n", rn); + return (-1); } - } else if ((strcasecmp(arg1,"cm")) != 0 && (strcasecmp(arg1,"cm")) != 0 ) { - fprintf(stderr,"[ %s ] Syntax error. Second argument should be \"fs\" or \"cm\" \n",rn); - return(-1); - } + } else if ((strcasecmp(arg1, "cm")) != 0 && (strcasecmp(arg1, "cm")) != 0) { + fprintf(stderr, + "[ %s ] Syntax error. Second argument should be \"fs\" or \"cm\" \n", + rn); + return (-1); + } - return(0); -} /* parse_threshEntry */ + return (0); +} /* parse_threshEntry */ /*----------------------------------------------------------------------- @@ -911,153 +931,158 @@ char *a_line; *----------------------------------------------------------------------*/ int -store_threshold(a_type,a_varName,a_value,a_handler) -int a_type; /* 1 = fs , 2 = cm */ -char *a_varName; /* threshold name */ -char *a_value; /* threshold value */ -char *a_handler; /* threshold overflow handler */ - -{ /* store_thresholds */ - - static char rn[] = "store_thresholds"; /* routine name */ - struct afsmon_hostEntry *tmp_host; /* tmp ptr to hostEntry */ - struct afsmon_hostEntry *Header; /* tmp ptr to hostEntry list header*/ - struct Threshold *threshP; /* tmp ptr to threshold list */ - char *hostname; - int index; /* index to fs_varNames or cm_varNames */ - int found; - int done; - int srvCount; /* tmp count of host names */ - int *global_TC; /* ptr to global_xxThreshCount */ - int i,j; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_type= %d, a_varName= %s, a_value= %s, a_handler=%s\n",rn, a_type, a_varName, a_value, a_handler); +store_threshold(a_type, a_varName, a_value, a_handler) + int a_type; /* 1 = fs , 2 = cm */ + char *a_varName; /* threshold name */ + char *a_value; /* threshold value */ + char *a_handler; /* threshold overflow handler */ + +{ /* store_thresholds */ + + static char rn[] = "store_thresholds"; /* routine name */ + struct afsmon_hostEntry *tmp_host; /* tmp ptr to hostEntry */ + struct afsmon_hostEntry *Header; /* tmp ptr to hostEntry list header */ + struct Threshold *threshP; /* tmp ptr to threshold list */ + char *hostname; + int index; /* index to fs_varNames or cm_varNames */ + int found; + int done; + int srvCount; /* tmp count of host names */ + int *global_TC; /* ptr to global_xxThreshCount */ + int i, j; + + if (afsmon_debug) { + fprintf(debugFD, + "[ %s ] Called, a_type= %d, a_varName= %s, a_value= %s, a_handler=%s\n", + rn, a_type, a_varName, a_value, a_handler); fflush(debugFD); - } - - /* resolve the threshold variable name */ - found = 0; - if (a_type == 1) { /* fs threshold */ - for(index=0; index < NUM_FS_STAT_ENTRIES ; index++) { - if (strcasecmp(a_varName,fs_varNames[index]) == 0) { - found = 1; - break; - } + } + + /* resolve the threshold variable name */ + found = 0; + if (a_type == 1) { /* fs threshold */ + for (index = 0; index < NUM_FS_STAT_ENTRIES; index++) { + if (strcasecmp(a_varName, fs_varNames[index]) == 0) { + found = 1; + break; + } } if (!found) { - fprintf(stderr,"[ %s ] Unknown FS threshold variable name %s\n", - rn,a_varName); - return(-1); + fprintf(stderr, "[ %s ] Unknown FS threshold variable name %s\n", + rn, a_varName); + return (-1); } Header = FSnameList; srvCount = numFS; hostname = last_fsHost; global_TC = &global_fsThreshCount; - } else if (a_type == 2) { /* cm threshold */ - for(index=0; index < NUM_CM_STAT_ENTRIES; index++) { - if (strcasecmp(a_varName,cm_varNames[index]) == 0) { - found = 1; - break; - } + } else if (a_type == 2) { /* cm threshold */ + for (index = 0; index < NUM_CM_STAT_ENTRIES; index++) { + if (strcasecmp(a_varName, cm_varNames[index]) == 0) { + found = 1; + break; + } } if (!found) { - fprintf(stderr,"[ %s ] Unknown CM threshold variable name %s\n", - rn,a_varName); - return(-1); + fprintf(stderr, "[ %s ] Unknown CM threshold variable name %s\n", + rn, a_varName); + return (-1); } Header = CMnameList; srvCount = numCM; hostname = last_cmHost; global_TC = &global_cmThreshCount; - } else - return(-1); + } else + return (-1); - /* if the global thresh count is not zero, place this threshold on - all the host entries */ + /* if the global thresh count is not zero, place this threshold on + * all the host entries */ - if (*global_TC) { + if (*global_TC) { tmp_host = Header; - for(i=0; ithresh; - done = 0; - for(j=0; jnumThresh; j++) { - if ( (threshP->itemName[0] == '\0') || - (strcasecmp(threshP->itemName,a_varName) == 0) ) { - strncpy(threshP->itemName,a_varName,THRESH_VAR_NAME_LEN); - strncpy(threshP->threshVal,a_value,THRESH_VAR_LEN); - strcpy(threshP->handler,a_handler); - threshP->index = index; - done = 1; - break; - } - threshP++; - } - if (!done) { - fprintf(stderr,"[ %s ] Could not insert threshold entry",rn); - fprintf(stderr,"for %s in thresh list of host %s \n", - a_varName,tmp_host->hostName); - return(-1); + for (i = 0; i < srvCount; i++) { + threshP = tmp_host->thresh; + done = 0; + for (j = 0; j < tmp_host->numThresh; j++) { + if ((threshP->itemName[0] == '\0') + || (strcasecmp(threshP->itemName, a_varName) == 0)) { + strncpy(threshP->itemName, a_varName, + THRESH_VAR_NAME_LEN); + strncpy(threshP->threshVal, a_value, THRESH_VAR_LEN); + strcpy(threshP->handler, a_handler); + threshP->index = index; + done = 1; + break; } - tmp_host = tmp_host->next; + threshP++; + } + if (!done) { + fprintf(stderr, "[ %s ] Could not insert threshold entry", + rn); + fprintf(stderr, "for %s in thresh list of host %s \n", + a_varName, tmp_host->hostName); + return (-1); + } + tmp_host = tmp_host->next; } (*global_TC)--; - return(0); - } - - /* it is not a global threshold, insert it in the thresh list of this - host only. We overwrite the global threshold if it was alread set */ - - if (*hostname == '\0') { - fprintf(stderr,"[ %s ] Programming error 3\n",rn); - return(-1); - } - - /* get the hostEntry that this threshold belongs to */ - tmp_host = Header; - found = 0; - for(i=0; i < srvCount; i++) { - if (strcasecmp(tmp_host->hostName,hostname) == 0) { - found = 1; - break; + return (0); + } + + /* it is not a global threshold, insert it in the thresh list of this + * host only. We overwrite the global threshold if it was alread set */ + + if (*hostname == '\0') { + fprintf(stderr, "[ %s ] Programming error 3\n", rn); + return (-1); + } + + /* get the hostEntry that this threshold belongs to */ + tmp_host = Header; + found = 0; + for (i = 0; i < srvCount; i++) { + if (strcasecmp(tmp_host->hostName, hostname) == 0) { + found = 1; + break; } tmp_host = tmp_host->next; - } - if (!found) { - fprintf(stderr,"[ %s ] Unable to find host %s in %s hostEntry list", - rn,hostname,(a_type-1)?"CM":"FS"); - return(-1); - } - - /* put this entry on the thresh list of this host, overwrite global value - if needed */ - - threshP = tmp_host->thresh; - done = 0; - for(i=0; i < tmp_host->numThresh; i++) { - if ( (threshP->itemName[0] == '\0') || - (strcasecmp(threshP->itemName,a_varName) == 0) ) { - strncpy(threshP->itemName,a_varName,THRESH_VAR_NAME_LEN); - strncpy(threshP->threshVal,a_value,THRESH_VAR_LEN); - strcpy(threshP->handler,a_handler); - threshP->index = index; - done = 1; - break; - } - threshP++; - } - - if (!done) { - fprintf(stderr,"[ %s ] Unable to insert threshold %s for %s host %s\n", - rn, a_varName, (a_type -1)?"CM":"FS", tmp_host->hostName); - return(-1); - } - - return(0); - -} /* store_thresholds */ + } + if (!found) { + fprintf(stderr, "[ %s ] Unable to find host %s in %s hostEntry list", + rn, hostname, (a_type - 1) ? "CM" : "FS"); + return (-1); + } + + /* put this entry on the thresh list of this host, overwrite global value + * if needed */ + + threshP = tmp_host->thresh; + done = 0; + for (i = 0; i < tmp_host->numThresh; i++) { + if ((threshP->itemName[0] == '\0') + || (strcasecmp(threshP->itemName, a_varName) == 0)) { + strncpy(threshP->itemName, a_varName, THRESH_VAR_NAME_LEN); + strncpy(threshP->threshVal, a_value, THRESH_VAR_LEN); + strcpy(threshP->handler, a_handler); + threshP->index = index; + done = 1; + break; + } + threshP++; + } + + if (!done) { + fprintf(stderr, + "[ %s ] Unable to insert threshold %s for %s host %s\n", rn, + a_varName, (a_type - 1) ? "CM" : "FS", tmp_host->hostName); + return (-1); + } + + return (0); + +} /* store_thresholds */ /*----------------------------------------------------------------------- @@ -1086,270 +1111,291 @@ char *a_handler; /* threshold overflow handler */ int parse_showEntry(a_line) -char *a_line; -{ /* parse_showEntry */ - static char rn[] = "parse_showEntry"; - char opcode[CFG_STR_LEN]; /* specifies type of config entry */ - char arg1[CFG_STR_LEN]; /* show fs or cm entry ? */ - char arg2[CFG_STR_LEN]; /* what we gotta show */ - char arg3[CFG_STR_LEN]; /* junk */ - char catName[CFG_STR_LEN]; /* for category names */ - int numGroups; /* number of groups in a section */ - int fromIdx; - int toIdx; - int found; - int idx = 0; /* index to fs_categories[] */ - int i; - int j; - - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_line= %s\n",rn, a_line); + char *a_line; +{ /* parse_showEntry */ + static char rn[] = "parse_showEntry"; + char opcode[CFG_STR_LEN]; /* specifies type of config entry */ + char arg1[CFG_STR_LEN]; /* show fs or cm entry ? */ + char arg2[CFG_STR_LEN]; /* what we gotta show */ + char arg3[CFG_STR_LEN]; /* junk */ + char catName[CFG_STR_LEN]; /* for category names */ + int numGroups; /* number of groups in a section */ + int fromIdx; + int toIdx; + int found; + int idx = 0; /* index to fs_categories[] */ + int i; + int j; + + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_line= %s\n", rn, a_line); fflush(debugFD); - } - opcode[0] = 0; arg1[0] = 0; arg2[0] = 0; arg3[0] = 0; - sscanf(a_line,"%s %s %s %s", opcode, arg1, arg2, arg3); - - if (arg3[0] != '\0') { - fprintf(stderr,"[ %s ] Extraneous characters at end of line\n",rn); - return(-1); - } - - if ((strcasecmp(arg1,"fs") != 0) && (strcasecmp(arg1,"cm") != 0)) { - fprintf(stderr,"[ %s ] Second argument of \"show\" directive should be \"fs\" or \"cm\" \n",rn); - return(-1); - } - - /* Each entry can either be a variable name or a section/group name. Variable - names are listed in xx_varNames[] and section/group names in xx_categories[]. - The section/group names in xx_categiries[] also give the starting/ending - indices of the variables belonging to that section/group. These indices - are stored in order in xx_Display_map[] and displayed to the screen in that - order. */ - - /* To handle duplicate "show" entries we keep track of what what we have - already marked to show in the xx_showFlags[] */ - - if (strcasecmp(arg1,"fs") == 0) { /* its a File Server entry */ - - /* mark that we have to show only what the user wants */ - fs_showDefault = 0; - - /* if it is a section/group name, find it in the fs_categories[] array */ - - found = 0; - if ( strcasestr(arg2,"_section") != (char *)NULL || - strcasestr(arg2,"_group") != (char *)NULL ) { - idx = 0; - while(idx NUM_FS_STAT_ENTRIES || - toIdx > NUM_FS_STAT_ENTRIES) - return(-2); - for(j=fromIdx; j<=toIdx; j++) { - if (! fs_showFlags[j]) { - fs_Display_map[fs_DisplayItems_count] = j; - fs_DisplayItems_count++; - fs_showFlags[j] = 1; + if (fromIdx < 0 || toIdx < 0 || fromIdx > NUM_FS_STAT_ENTRIES + || toIdx > NUM_FS_STAT_ENTRIES) + return (-2); + for (j = fromIdx; j <= toIdx; j++) { + if (!fs_showFlags[j]) { + fs_Display_map[fs_DisplayItems_count] = j; + fs_DisplayItems_count++; + fs_showFlags[j] = 1; } if (fs_DisplayItems_count > NUM_FS_STAT_ENTRIES) { - fprintf(stderr,"[ %s ] fs_DisplayItems_count ovf\n",rn); - return(-3); - } - } - } else - - /* if it is a section name, get the count of number of groups in it and - for each group fill in the start/end indices in the fs_Display_map[] */ - - if (strcasestr(arg2,"_section") != (char *)NULL ) { - /* fromIdx is actually the number of groups in thi section */ - numGroups = fromIdx; - /* for each group in section */ - while(idx < FS_NUM_DATA_CATEGORIES && numGroups) { - sscanf(fs_categories[idx],"%s %d %d",catName, &fromIdx, &toIdx); - - if (strcasestr(catName,"_group") != NULL) { - if (fromIdx < 0 || toIdx < 0 || fromIdx > NUM_FS_STAT_ENTRIES || - toIdx > NUM_FS_STAT_ENTRIES) - return(-4); - for(j=fromIdx; j<=toIdx; j++) { - if (! fs_showFlags[j]) { - fs_Display_map[fs_DisplayItems_count] = j; - fs_DisplayItems_count++; - fs_showFlags[j] = 1; + fprintf(stderr, "[ %s ] fs_DisplayItems_count ovf\n", rn); + return (-3); } - if (fs_DisplayItems_count > NUM_FS_STAT_ENTRIES) { - fprintf(stderr,"[ %s ] fs_DisplayItems_count ovf\n",rn); - return(-5); + } + } else + /* if it is a section name, get the count of number of groups in it and + * for each group fill in the start/end indices in the fs_Display_map[] */ + + if (strcasestr(arg2, "_section") != (char *)NULL) { + /* fromIdx is actually the number of groups in thi section */ + numGroups = fromIdx; + /* for each group in section */ + while (idx < FS_NUM_DATA_CATEGORIES && numGroups) { + sscanf(fs_categories[idx], "%s %d %d", catName, &fromIdx, + &toIdx); + + if (strcasestr(catName, "_group") != NULL) { + if (fromIdx < 0 || toIdx < 0 + || fromIdx > NUM_FS_STAT_ENTRIES + || toIdx > NUM_FS_STAT_ENTRIES) + return (-4); + for (j = fromIdx; j <= toIdx; j++) { + if (!fs_showFlags[j]) { + fs_Display_map[fs_DisplayItems_count] = j; + fs_DisplayItems_count++; + fs_showFlags[j] = 1; + } + if (fs_DisplayItems_count > NUM_FS_STAT_ENTRIES) { + fprintf(stderr, + "[ %s ] fs_DisplayItems_count ovf\n", rn); + return (-5); + } + } + } else { + fprintf(stderr, "[ %s ] Error parsing groups for %s\n", + rn, arg2); + return (-6); } - } - } else { - fprintf(stderr,"[ %s ] Error parsing groups for %s\n",rn,arg2); - return(-6); - } - idx++; - numGroups--; - } /* for each group in section */ + idx++; + numGroups--; + } /* for each group in section */ - } else { /* it is a variable name */ + } else { /* it is a variable name */ - for(i=0; i= NUM_FS_STAT_ENTRIES) { - fprintf(stderr,"[ %s ] fs_DisplayItems_count ovf\n",rn); - return(-25); - } - found = 1; + } + if (fs_DisplayItems_count >= NUM_FS_STAT_ENTRIES) { + fprintf(stderr, "[ %s ] fs_DisplayItems_count ovf\n", + rn); + return (-25); + } + found = 1; } - } - if (! found) { /* typo in section/group name */ - fprintf(stderr,"[ %s ] Could not find variable name %s\n",rn,arg2); - return(-1); - } - } /* its a variable name */ - - } /* it is an fs entry */ + } + if (!found) { /* typo in section/group name */ + fprintf(stderr, "[ %s ] Could not find variable name %s\n", + rn, arg2); + return (-1); + } + } /* its a variable name */ + } - if (strcasecmp(arg1,"cm") == 0) { /* its a Cache Manager entry */ + /* it is an fs entry */ + if (strcasecmp(arg1, "cm") == 0) { /* its a Cache Manager entry */ - /* mark that we have to show only what the user wants */ - cm_showDefault = 0; + /* mark that we have to show only what the user wants */ + cm_showDefault = 0; - /* if it is a section/group name, find it in the cm_categories[] array */ + /* if it is a section/group name, find it in the cm_categories[] array */ - found = 0; - if ( strcasestr(arg2,"_section") != (char *)NULL || - strcasestr(arg2,"_group") != (char *)NULL ) { - idx = 0; - while(idx NUM_CM_STAT_ENTRIES || - toIdx > NUM_CM_STAT_ENTRIES) - return(-10); - for(j=fromIdx; j<=toIdx; j++) { - if (! cm_showFlags[j]) { - cm_Display_map[cm_DisplayItems_count] = j; - cm_DisplayItems_count++; - cm_showFlags[j] = 1; + if (fromIdx < 0 || toIdx < 0 || fromIdx > NUM_CM_STAT_ENTRIES + || toIdx > NUM_CM_STAT_ENTRIES) + return (-10); + for (j = fromIdx; j <= toIdx; j++) { + if (!cm_showFlags[j]) { + cm_Display_map[cm_DisplayItems_count] = j; + cm_DisplayItems_count++; + cm_showFlags[j] = 1; } if (cm_DisplayItems_count > NUM_CM_STAT_ENTRIES) { - fprintf(stderr,"[ %s ] cm_DisplayItems_count ovf\n",rn); - return(-11); + fprintf(stderr, "[ %s ] cm_DisplayItems_count ovf\n", rn); + return (-11); } - } - } else - - /* if it is a section name, get the count of number of groups in it and - for each group fill in the start/end indices in the cm_Display_map[] */ - - if (strcasestr(arg2,"_section") != (char *)NULL ) { - /* fromIdx is actually the number of groups in thi section */ - numGroups = fromIdx; - /* for each group in section */ - while(idx < CM_NUM_DATA_CATEGORIES && numGroups) { - sscanf(cm_categories[idx],"%s %d %d",catName, &fromIdx, &toIdx); - - if (strcasestr(catName,"_group") != NULL) { - if (fromIdx < 0 || toIdx < 0 || fromIdx > NUM_CM_STAT_ENTRIES || - toIdx > NUM_CM_STAT_ENTRIES) - return(-12); - for(j=fromIdx; j<=toIdx; j++) { - if (! cm_showFlags[j]) { - cm_Display_map[cm_DisplayItems_count] = j; - cm_DisplayItems_count++; - cm_showFlags[j] = 1; - } - if (cm_DisplayItems_count > NUM_CM_STAT_ENTRIES) { - fprintf(stderr,"[ %s ] cm_DisplayItems_count ovf\n",rn); - return(-13); + } + } else + /* if it is a section name, get the count of number of groups in it and + * for each group fill in the start/end indices in the cm_Display_map[] */ + + if (strcasestr(arg2, "_section") != (char *)NULL) { + /* fromIdx is actually the number of groups in thi section */ + numGroups = fromIdx; + /* for each group in section */ + while (idx < CM_NUM_DATA_CATEGORIES && numGroups) { + sscanf(cm_categories[idx], "%s %d %d", catName, &fromIdx, + &toIdx); + + if (strcasestr(catName, "_group") != NULL) { + if (fromIdx < 0 || toIdx < 0 + || fromIdx > NUM_CM_STAT_ENTRIES + || toIdx > NUM_CM_STAT_ENTRIES) + return (-12); + for (j = fromIdx; j <= toIdx; j++) { + if (!cm_showFlags[j]) { + cm_Display_map[cm_DisplayItems_count] = j; + cm_DisplayItems_count++; + cm_showFlags[j] = 1; + } + if (cm_DisplayItems_count > NUM_CM_STAT_ENTRIES) { + fprintf(stderr, + "[ %s ] cm_DisplayItems_count ovf\n", rn); + return (-13); + } + } + } else { + fprintf(stderr, "[ %s ] Error parsing groups for %s\n", + rn, arg2); + return (-15); } - } - } else { - fprintf(stderr,"[ %s ] Error parsing groups for %s\n",rn,arg2); - return(-15); - } - idx++; - numGroups--; - } /* for each group in section */ + idx++; + numGroups--; + } /* for each group in section */ - } else { /* it is a variable name */ + } else { /* it is a variable name */ - for(i=0; i= NUM_CM_STAT_ENTRIES) { - fprintf(stderr,"[ %s ] cm_DisplayItems_count ovf\n",rn); - return(-20); - } - found = 1; + } + if (cm_DisplayItems_count >= NUM_CM_STAT_ENTRIES) { + fprintf(stderr, "[ %s ] cm_DisplayItems_count ovf\n", + rn); + return (-20); + } + found = 1; } - } - if (! found) { /* typo in section/group name */ - fprintf(stderr,"[ %s ] Could not find variable name %s\n",rn,arg2); - return(-1); - } - } /* its a variable name */ + } + if (!found) { /* typo in section/group name */ + fprintf(stderr, "[ %s ] Could not find variable name %s\n", + rn, arg2); + return (-1); + } + } /* its a variable name */ - } /* it is an cm entry */ + } + /* it is an cm entry */ + return (0); - return(0); - -} /* parse_showEntry */ +} /* parse_showEntry */ /*----------------------------------------------------------------------- @@ -1373,230 +1419,244 @@ char *a_line; int process_config_file(a_config_filename) -char *a_config_filename; -{ /* process_config_file() */ - static char rn[] = "process_config_file"; /* routine name */ - FILE *configFD; /* config file descriptor */ - char line[4*CFG_STR_LEN]; /* a line of config file */ - char opcode[CFG_STR_LEN]; /* specifies type of config entry */ - char arg1[CFG_STR_LEN]; /* hostname or qualifier (fs/cm?) */ - char arg2[CFG_STR_LEN]; /* threshold variable */ - char arg3[CFG_STR_LEN]; /* threshold value */ - char arg4[CFG_STR_LEN]; /* user's handler */ - struct afsmon_hostEntry *curr_host; - struct hostent *he; /* hostentry to resolve host name*/ - char *handlerPtr; /* ptr to pass theresh handler string */ - int code = 0; /* error code */ - int linenum = 0; /* config file line number */ - int threshCount; /* count of thresholds for each server */ - int error_in_config; /* syntax errors in config file ?? */ - int i; - int numBytes; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_config_filename= %s\n", - rn, a_config_filename); + char *a_config_filename; +{ /* process_config_file() */ + static char rn[] = "process_config_file"; /* routine name */ + FILE *configFD; /* config file descriptor */ + char line[4 * CFG_STR_LEN]; /* a line of config file */ + char opcode[CFG_STR_LEN]; /* specifies type of config entry */ + char arg1[CFG_STR_LEN]; /* hostname or qualifier (fs/cm?) */ + char arg2[CFG_STR_LEN]; /* threshold variable */ + char arg3[CFG_STR_LEN]; /* threshold value */ + char arg4[CFG_STR_LEN]; /* user's handler */ + struct afsmon_hostEntry *curr_host; + struct hostent *he; /* hostentry to resolve host name */ + char *handlerPtr; /* ptr to pass theresh handler string */ + int code = 0; /* error code */ + int linenum = 0; /* config file line number */ + int threshCount; /* count of thresholds for each server */ + int error_in_config; /* syntax errors in config file ?? */ + int i; + int numBytes; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_config_filename= %s\n", rn, + a_config_filename); fflush(debugFD); - } + } - /* open config file */ + /* open config file */ - configFD = fopen(a_config_filename,"r"); - if (configFD == (FILE *)0) { - fprintf(stderr,"Failed to open config file %s \n",a_config_filename); + configFD = fopen(a_config_filename, "r"); + if (configFD == (FILE *) 0) { + fprintf(stderr, "Failed to open config file %s \n", + a_config_filename); if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Failed to open config file %s \n", - rn, a_config_filename); + fprintf(debugFD, "[ %s ] Failed to open config file %s \n", rn, + a_config_filename); } afsmon_Exit(5); - } + } - /* parse config file */ + /* parse config file */ - /* We process the config file in two passes. In the first pass we check - for correct syntax and for valid entries and also keep count of the - number of servers and thresholds to monitor. This the data strctures - can be arrays instead of link lists since we would know their sizes.*/ + /* We process the config file in two passes. In the first pass we check + * for correct syntax and for valid entries and also keep count of the + * number of servers and thresholds to monitor. This the data strctures + * can be arrays instead of link lists since we would know their sizes. */ - /* First Pass */ + /* First Pass */ - numFS = 0; - numCM = 0; - threshCount = 0; - error_in_config = 0; /* flag to note if config file has syntax errors*/ + numFS = 0; + numCM = 0; + threshCount = 0; + error_in_config = 0; /* flag to note if config file has syntax errors */ - while ( (fgets(line,CFG_STR_LEN,configFD)) != NULL) - { - opcode[0] = 0; arg1[0] = 0; arg2[0] = 0; arg3[0] = 0; arg4[0] = 0; - sscanf(line,"%s %s %s %s %s", opcode, arg1, arg2, arg3, arg4); + while ((fgets(line, CFG_STR_LEN, configFD)) != NULL) { + opcode[0] = 0; + arg1[0] = 0; + arg2[0] = 0; + arg3[0] = 0; + arg4[0] = 0; + sscanf(line, "%s %s %s %s %s", opcode, arg1, arg2, arg3, arg4); linenum++; /* skip blank lines and comment lines */ - if ( (strlen(opcode) == 0) || line[0] == '#' ) continue; - - if ( (strcasecmp(opcode,"fs") == 0) || (strcasecmp(opcode,"cm")) == 0) { - code = parse_hostEntry(line); - } else if ((strcasecmp(opcode,"thresh")) == 0) { - code = parse_threshEntry(line); - } else if ((strcasecmp(opcode,"show")) == 0) { - code = parse_showEntry(line); + if ((strlen(opcode) == 0) || line[0] == '#') + continue; + + if ((strcasecmp(opcode, "fs") == 0) + || (strcasecmp(opcode, "cm")) == 0) { + code = parse_hostEntry(line); + } else if ((strcasecmp(opcode, "thresh")) == 0) { + code = parse_threshEntry(line); + } else if ((strcasecmp(opcode, "show")) == 0) { + code = parse_showEntry(line); } else { - fprintf(stderr,"[ %s ] Unknown opcode %s\n",rn,opcode); - code = 1; + fprintf(stderr, "[ %s ] Unknown opcode %s\n", rn, opcode); + code = 1; } - + if (code) { - fprintf(stderr,"[ %s ] Error in line:\n %d: %s\n", - rn,linenum,line); - error_in_config = 1; - } - } - - if (error_in_config) - afsmon_Exit(10); - - if (afsmon_debug) { - fprintf(debugFD,"Global FS thresholds count = %d\n",global_fsThreshCount); - fprintf(debugFD,"Global CM thresholds count = %d\n",global_cmThreshCount); - fflush(debugFD); - } - - /* the threshold count of all hosts in increased by 1 for each global - threshold. If one of the hosts has a local threshold for the same - variable it would end up being counted twice. whats a few bytes of memory - wasted anyway ? */ - - if (global_fsThreshCount) { - curr_host = FSnameList; - for(i=0; inumThresh += global_fsThreshCount; - curr_host = curr_host->next; - } - } - if (global_cmThreshCount) { - curr_host = CMnameList; - for(i=0; inumThresh += global_cmThreshCount; - curr_host = curr_host->next; - } - } - - - /* make sure we have something to monitor */ - if (numFS == 0 && numCM == 0) { - fprintf(stderr,"\nConfig file must specify atleast one File Server or Cache Manager host to monitor.\n"); - fclose(configFD); + fprintf(stderr, "[ %s ] Error in line:\n %d: %s\n", rn, linenum, + line); + error_in_config = 1; + } + } + + if (error_in_config) + afsmon_Exit(10); + + if (afsmon_debug) { + fprintf(debugFD, "Global FS thresholds count = %d\n", + global_fsThreshCount); + fprintf(debugFD, "Global CM thresholds count = %d\n", + global_cmThreshCount); + fflush(debugFD); + } + + /* the threshold count of all hosts in increased by 1 for each global + * threshold. If one of the hosts has a local threshold for the same + * variable it would end up being counted twice. whats a few bytes of memory + * wasted anyway ? */ + + if (global_fsThreshCount) { + curr_host = FSnameList; + for (i = 0; i < numFS; i++) { + curr_host->numThresh += global_fsThreshCount; + curr_host = curr_host->next; + } + } + if (global_cmThreshCount) { + curr_host = CMnameList; + for (i = 0; i < numCM; i++) { + curr_host->numThresh += global_cmThreshCount; + curr_host = curr_host->next; + } + } + + + /* make sure we have something to monitor */ + if (numFS == 0 && numCM == 0) { + fprintf(stderr, + "\nConfig file must specify atleast one File Server or Cache Manager host to monitor.\n"); + fclose(configFD); afsmon_Exit(15); - } + } - /* Second Pass */ + /* Second Pass */ - fseek(configFD,0,0); /* seek to the beginning */ + fseek(configFD, 0, 0); /* seek to the beginning */ - /* allocate memory for threshold lists */ - curr_host = FSnameList; - for(i=0; ihostName[0] == '\0') { - fprintf(stderr,"[ %s ] Programming error 4\n",rn); - afsmon_Exit(20); + fprintf(stderr, "[ %s ] Programming error 4\n", rn); + afsmon_Exit(20); } if (curr_host->numThresh) { - numBytes = curr_host->numThresh * sizeof(struct Threshold); - curr_host->thresh = (struct Threshold *) malloc(numBytes); - if (curr_host->thresh == NULL) { - fprintf(stderr,"[ %s ] Memory Allocation error 1",rn); - afsmon_Exit(25); - } - memset(curr_host->thresh, 0, numBytes); - } + numBytes = curr_host->numThresh * sizeof(struct Threshold); + curr_host->thresh = (struct Threshold *)malloc(numBytes); + if (curr_host->thresh == NULL) { + fprintf(stderr, "[ %s ] Memory Allocation error 1", rn); + afsmon_Exit(25); + } + memset(curr_host->thresh, 0, numBytes); + } curr_host = curr_host->next;; - } + } - curr_host = CMnameList; - for(i=0; ihostName[0] == '\0') { - fprintf(stderr,"[ %s ] Programming error 5\n",rn); - afsmon_Exit(30); + fprintf(stderr, "[ %s ] Programming error 5\n", rn); + afsmon_Exit(30); } if (curr_host->numThresh) { - numBytes = curr_host->numThresh * sizeof(struct Threshold); - curr_host->thresh = (struct Threshold *) malloc(numBytes); - if (curr_host->thresh == NULL) { - fprintf(stderr,"[ %s ] Memory Allocation error 2",rn); - afsmon_Exit(35); - } - memset(curr_host->thresh, 0, numBytes); - } + numBytes = curr_host->numThresh * sizeof(struct Threshold); + curr_host->thresh = (struct Threshold *)malloc(numBytes); + if (curr_host->thresh == NULL) { + fprintf(stderr, "[ %s ] Memory Allocation error 2", rn); + afsmon_Exit(35); + } + memset(curr_host->thresh, 0, numBytes); + } curr_host = curr_host->next;; - } + } - opcode[0] = 0; arg1[0] = 0; arg2[0] = 0; arg3[0] = 0; arg4[0] = 0; - last_fsHost[0] = '\0'; - last_cmHost[0] = '\0'; - linenum = 0; - while ( (fgets(line,CFG_STR_LEN,configFD)) != NULL) { - opcode[0] = 0; arg1[0] = 0; arg2[0] = 0; arg3[0] = 0; arg4[0] = 0; - sscanf(line,"%s %s %s %s %s", opcode, arg1, arg2, arg3, arg4); + opcode[0] = 0; + arg1[0] = 0; + arg2[0] = 0; + arg3[0] = 0; + arg4[0] = 0; + last_fsHost[0] = '\0'; + last_cmHost[0] = '\0'; + linenum = 0; + while ((fgets(line, CFG_STR_LEN, configFD)) != NULL) { + opcode[0] = 0; + arg1[0] = 0; + arg2[0] = 0; + arg3[0] = 0; + arg4[0] = 0; + sscanf(line, "%s %s %s %s %s", opcode, arg1, arg2, arg3, arg4); linenum++; /* if we have a host entry, remember the host name */ - if (strcasecmp(opcode,"fs") == 0) { - he = GetHostByName(arg1); - strncpy(last_fsHost,he->h_name,HOST_NAME_LEN); - } - else if (strcasecmp(opcode,"cm") == 0) { - he = GetHostByName(arg1); - strncpy(last_cmHost,he->h_name,HOST_NAME_LEN); - } - else if (strcasecmp(opcode,"thresh") == 0) { - /* if we have a threshold handler it may have arguments - and the sscanf() above would not get them, so do the - following */ - if (strlen(arg4)) { - handlerPtr = line; - /* now skip over 4 words - this is done by first - skipping leading blanks then skipping a word */ - for(i=0; i<4; i++) { - while( isspace(*handlerPtr) ) - handlerPtr++; - while(! isspace(*handlerPtr) ) - handlerPtr++; - } - while( isspace(*handlerPtr) ) - handlerPtr++; - /* we how have a pointer to the start of the handler - name & args */ - } else - handlerPtr = arg4; /* empty string */ - - - if (strcasecmp(arg1,"fs") == 0) - code = store_threshold(1, /* 1 = fs*/ - arg2,arg3,handlerPtr); - - else if (strcasecmp(arg1,"cm") == 0) - code = store_threshold(2, /* 2 = fs*/ - arg2,arg3,handlerPtr); - - else { - fprintf(stderr,"[ %s ] Programming error 6\n", rn); - afsmon_Exit(40); - } - if (code) { - fprintf(stderr,"[ %s ] Failed to store threshold\n", - rn); - fprintf(stderr,"[ %s ] Error processing line:\n%d: %s", - rn,linenum,line); - afsmon_Exit(45); + if (strcasecmp(opcode, "fs") == 0) { + he = GetHostByName(arg1); + strncpy(last_fsHost, he->h_name, HOST_NAME_LEN); + } else if (strcasecmp(opcode, "cm") == 0) { + he = GetHostByName(arg1); + strncpy(last_cmHost, he->h_name, HOST_NAME_LEN); + } else if (strcasecmp(opcode, "thresh") == 0) { + /* if we have a threshold handler it may have arguments + * and the sscanf() above would not get them, so do the + * following */ + if (strlen(arg4)) { + handlerPtr = line; + /* now skip over 4 words - this is done by first + * skipping leading blanks then skipping a word */ + for (i = 0; i < 4; i++) { + while (isspace(*handlerPtr)) + handlerPtr++; + while (!isspace(*handlerPtr)) + handlerPtr++; } + while (isspace(*handlerPtr)) + handlerPtr++; + /* we how have a pointer to the start of the handler + * name & args */ + } else + handlerPtr = arg4; /* empty string */ + + + if (strcasecmp(arg1, "fs") == 0) + code = store_threshold(1, /* 1 = fs */ + arg2, arg3, handlerPtr); + + else if (strcasecmp(arg1, "cm") == 0) + code = store_threshold(2, /* 2 = fs */ + arg2, arg3, handlerPtr); + + else { + fprintf(stderr, "[ %s ] Programming error 6\n", rn); + afsmon_Exit(40); + } + if (code) { + fprintf(stderr, "[ %s ] Failed to store threshold\n", rn); + fprintf(stderr, "[ %s ] Error processing line:\n%d: %s", rn, + linenum, line); + afsmon_Exit(45); + } } - } + } - fclose(configFD); - return(0); + fclose(configFD); + return (0); } /*----------------------------------------------------------------------- @@ -1610,42 +1670,47 @@ char *a_config_filename; * Nothing. *----------------------------------------------------------------------*/ -void +void Print_FS_CB() -{ /* Print_FS_CB() */ - - struct afsmon_fs_Results_list *fslist; - int i; - int j; - - /* print valid info in the fs CB */ - - if (afsmon_debug) { - fprintf(debugFD,"==================== FS Buffer ========================\n"); - fprintf(debugFD,"afsmon_fs_curr_CBindex = %d\n",afsmon_fs_curr_CBindex); - fprintf(debugFD,"afsmon_fs_curr_probeNum = %d\n\n",afsmon_fs_curr_probeNum); - - for(i=0; iempty) { - fprintf(debugFD,"\t %d) probeNum = %d host = %s", - j,fslist->fsResults->probeNum, - fslist-> fsResults->connP->hostName); - if (fslist->fsResults->probeOK) fprintf(debugFD," NOTOK\n"); - else fprintf(debugFD," OK\n"); +{ /* Print_FS_CB() */ + + struct afsmon_fs_Results_list *fslist; + int i; + int j; + + /* print valid info in the fs CB */ + + if (afsmon_debug) { + fprintf(debugFD, + "==================== FS Buffer ========================\n"); + fprintf(debugFD, "afsmon_fs_curr_CBindex = %d\n", + afsmon_fs_curr_CBindex); + fprintf(debugFD, "afsmon_fs_curr_probeNum = %d\n\n", + afsmon_fs_curr_probeNum); + + for (i = 0; i < num_bufSlots; i++) { + fprintf(debugFD, "\t--------- slot %d ----------\n", i); + fslist = afsmon_fs_ResultsCB[i].list; + j = 0; + while (j < numFS) { + if (!fslist->empty) { + fprintf(debugFD, "\t %d) probeNum = %d host = %s", j, + fslist->fsResults->probeNum, + fslist->fsResults->connP->hostName); + if (fslist->fsResults->probeOK) + fprintf(debugFD, " NOTOK\n"); + else + fprintf(debugFD, " OK\n"); } else - fprintf(debugFD,"\t %d) -- empty --\n",j); + fprintf(debugFD, "\t %d) -- empty --\n", j); fslist = fslist->next; j++; + } + if (fslist != (struct afsmon_fs_Results_list *)0) + fprintf(debugFD, "dangling last next ptr fs CB\n"); } - if (fslist != (struct afsmon_fs_Results_list *)0 ) - fprintf(debugFD,"dangling last next ptr fs CB\n"); - } - } -} /* Print_FS_CB() */ + } +} /* Print_FS_CB() */ /*----------------------------------------------------------------------- * save_FS_results_inCB() @@ -1665,81 +1730,89 @@ Print_FS_CB() *----------------------------------------------------------------------*/ int save_FS_results_inCB(a_newProbeCycle) -int a_newProbeCycle; /* start of a new probe cycle ? */ + int a_newProbeCycle; /* start of a new probe cycle ? */ -{ /* save_FS_results_inCB() */ - static char rn[] = "save_FS_results_inCB"; /* routine name */ - struct afsmon_fs_Results_list *tmp_fslist_item; /* temp fs list item */ - struct xstat_fs_ProbeResults *tmp_fsPR; /* temp ptr */ - int i; +{ /* save_FS_results_inCB() */ + static char rn[] = "save_FS_results_inCB"; /* routine name */ + struct afsmon_fs_Results_list *tmp_fslist_item; /* temp fs list item */ + struct xstat_fs_ProbeResults *tmp_fsPR; /* temp ptr */ + int i; - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_newProbeCycle= %d\n", - rn, a_newProbeCycle); + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_newProbeCycle= %d\n", rn, + a_newProbeCycle); fflush(debugFD); - } + } - /* If a new probe cycle started, mark the list in the current buffer - slot empty for resuse. Note that afsmon_fs_curr_CBindex was appropriately - incremented in afsmon_FS_Handler() */ + /* If a new probe cycle started, mark the list in the current buffer + * slot empty for resuse. Note that afsmon_fs_curr_CBindex was appropriately + * incremented in afsmon_FS_Handler() */ - if (a_newProbeCycle) { - tmp_fslist_item = afsmon_fs_ResultsCB[afsmon_fs_curr_CBindex].list; - for(i=0; iempty = 1; - tmp_fslist_item = tmp_fslist_item->next; - } - } + if (a_newProbeCycle) { + tmp_fslist_item = afsmon_fs_ResultsCB[afsmon_fs_curr_CBindex].list; + for (i = 0; i < numFS; i++) { + tmp_fslist_item->empty = 1; + tmp_fslist_item = tmp_fslist_item->next; + } + } - /* locate last unused item in list */ - tmp_fslist_item = afsmon_fs_ResultsCB[afsmon_fs_curr_CBindex].list; - for(i=0; iempty) break; + /* locate last unused item in list */ + tmp_fslist_item = afsmon_fs_ResultsCB[afsmon_fs_curr_CBindex].list; + for (i = 0; i < numFS; i++) { + if (tmp_fslist_item->empty) + break; tmp_fslist_item = tmp_fslist_item->next; - } - - /* if we could not find one we have an inconsistent list */ - if ( ! tmp_fslist_item->empty ) { - fprintf(stderr,"[ %s ] list inconsistency 1. unable to find an empty slot to store results of probenum %d of %s\n",rn, - xstat_fs_Results.probeNum,xstat_fs_Results.connP->hostName); + } + + /* if we could not find one we have an inconsistent list */ + if (!tmp_fslist_item->empty) { + fprintf(stderr, + "[ %s ] list inconsistency 1. unable to find an empty slot to store results of probenum %d of %s\n", + rn, xstat_fs_Results.probeNum, + xstat_fs_Results.connP->hostName); afsmon_Exit(50); - } + } - tmp_fsPR = tmp_fslist_item->fsResults; + tmp_fsPR = tmp_fslist_item->fsResults; - /* copy hostname and probe number and probe time and probe status. - if the probe failed return now */ + /* copy hostname and probe number and probe time and probe status. + * if the probe failed return now */ - memcpy(tmp_fsPR->connP->hostName, xstat_fs_Results.connP->hostName, sizeof(xstat_fs_Results.connP->hostName)); - tmp_fsPR->probeNum = xstat_fs_Results.probeNum; - tmp_fsPR->probeTime = xstat_fs_Results.probeTime; - tmp_fsPR->probeOK = xstat_fs_Results.probeOK; - if (xstat_fs_Results.probeOK) { /* probeOK = 1 => notOK */ - /* we have a nonempty results structure so mark the list item used */ - tmp_fslist_item->empty = 0; - return(0); - } + memcpy(tmp_fsPR->connP->hostName, xstat_fs_Results.connP->hostName, + sizeof(xstat_fs_Results.connP->hostName)); + tmp_fsPR->probeNum = xstat_fs_Results.probeNum; + tmp_fsPR->probeTime = xstat_fs_Results.probeTime; + tmp_fsPR->probeOK = xstat_fs_Results.probeOK; + if (xstat_fs_Results.probeOK) { /* probeOK = 1 => notOK */ + /* we have a nonempty results structure so mark the list item used */ + tmp_fslist_item->empty = 0; + return (0); + } + + /* copy connection information */ + memcpy(&(tmp_fsPR->connP->skt), &(xstat_fs_Results.connP->skt), + sizeof(struct sockaddr_in)); - /* copy connection information */ - memcpy(&(tmp_fsPR->connP->skt), &(xstat_fs_Results.connP->skt), sizeof(struct sockaddr_in)); + memcpy(tmp_fsPR->connP->hostName, xstat_fs_Results.connP->hostName, + sizeof(xstat_fs_Results.connP->hostName)); + tmp_fsPR->collectionNumber = xstat_fs_Results.collectionNumber; - memcpy(tmp_fsPR->connP->hostName, xstat_fs_Results.connP->hostName, sizeof(xstat_fs_Results.connP->hostName)); - tmp_fsPR->collectionNumber = xstat_fs_Results.collectionNumber; + /* copy the probe data information */ + tmp_fsPR->data.AFS_CollData_len = xstat_fs_Results.data.AFS_CollData_len; + memcpy(tmp_fsPR->data.AFS_CollData_val, + xstat_fs_Results.data.AFS_CollData_val, + xstat_fs_Results.data.AFS_CollData_len * sizeof(afs_int32)); - /* copy the probe data information */ - tmp_fsPR->data.AFS_CollData_len = xstat_fs_Results.data.AFS_CollData_len; - memcpy(tmp_fsPR->data.AFS_CollData_val, xstat_fs_Results.data.AFS_CollData_val, xstat_fs_Results.data.AFS_CollData_len * sizeof(afs_int32)); - - /* we have a valid results structure so mark the list item used */ - tmp_fslist_item->empty = 0; + /* we have a valid results structure so mark the list item used */ + tmp_fslist_item->empty = 0; - /* Print the fs circular buffer */ - Print_FS_CB(); - - return(0); -} /* save_FS_results_inCB() */ + /* Print the fs circular buffer */ + Print_FS_CB(); + + return (0); +} /* save_FS_results_inCB() */ /*----------------------------------------------------------------------- @@ -1759,103 +1832,119 @@ int a_newProbeCycle; /* start of a new probe cycle ? */ *----------------------------------------------------------------------*/ int -fs_Results_ltoa(a_fsData,a_fsResults) -struct fs_Display_Data *a_fsData; /* target buffer */ -struct xstat_fs_ProbeResults *a_fsResults; /* ptr to xstat fs Results */ -{ /* fs_Results_ltoa */ - - static char rn[] = "fs_Results_ltoa"; /* routine name */ - afs_int32 *srcbuf; - struct fs_stats_FullPerfStats *fullPerfP; - int idx; - int i,j; - afs_int32 *tmpbuf; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_fsData= %d, a_fsResults= %d\n", - rn, a_fsData, a_fsResults); +fs_Results_ltoa(a_fsData, a_fsResults) + struct fs_Display_Data *a_fsData; /* target buffer */ + struct xstat_fs_ProbeResults *a_fsResults; /* ptr to xstat fs Results */ +{ /* fs_Results_ltoa */ + + static char rn[] = "fs_Results_ltoa"; /* routine name */ + afs_int32 *srcbuf; + struct fs_stats_FullPerfStats *fullPerfP; + int idx; + int i, j; + afs_int32 *tmpbuf; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_fsData= %d, a_fsResults= %d\n", rn, + a_fsData, a_fsResults); fflush(debugFD); - } + } - fullPerfP = (struct fs_stats_FullPerfStats *) - (a_fsResults->data.AFS_CollData_val); + fullPerfP = (struct fs_stats_FullPerfStats *) + (a_fsResults->data.AFS_CollData_val); - /* there are two parts to the xstat FS statistics - - fullPerfP->overall which give the overall performance statistics, and - - fullPerfP->det which gives detailed info about file server operation - execution times */ + /* there are two parts to the xstat FS statistics + * - fullPerfP->overall which give the overall performance statistics, and + * - fullPerfP->det which gives detailed info about file server operation + * execution times */ - /* copy overall performance statistics */ - srcbuf = (afs_int32 *) &(fullPerfP->overall); - idx = 0; - for(i=0; i< NUM_XSTAT_FS_AFS_PERFSTATS_LONGS; i++) { - sprintf(a_fsData->data[idx],"%d",*srcbuf); + /* copy overall performance statistics */ + srcbuf = (afs_int32 *) & (fullPerfP->overall); + idx = 0; + for (i = 0; i < NUM_XSTAT_FS_AFS_PERFSTATS_LONGS; i++) { + sprintf(a_fsData->data[idx], "%d", *srcbuf); idx++; srcbuf++; - } + } + + /* copy epoch */ + srcbuf = (afs_int32 *) & (fullPerfP->det.epoch); + sprintf(a_fsData->data[idx], "%d", *srcbuf); /* epoch */ + idx++; - /* copy epoch */ - srcbuf = (afs_int32 *) &(fullPerfP->det.epoch); - sprintf(a_fsData->data[idx], "%d", *srcbuf); /* epoch */ - idx++; + /* copy fs operation timing */ - /* copy fs operation timing */ + srcbuf = (afs_int32 *) (fullPerfP->det.rpcOpTimes); - srcbuf = (afs_int32 *) (fullPerfP->det.rpcOpTimes); - - for(i=0; idata[idx], "%d", *srcbuf); /* numOps*/ - idx++; srcbuf++; + for (i = 0; i < FS_STATS_NUM_RPC_OPS; i++) { + sprintf(a_fsData->data[idx], "%d", *srcbuf); /* numOps */ + idx++; + srcbuf++; sprintf(a_fsData->data[idx], "%d", *srcbuf); /* numSuccesses */ - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sum time */ - sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sqr time */ - sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* min time */ - sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* max time */ - sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - } - - /* copy fs transfer timings */ - - srcbuf = (afs_int32 *) (fullPerfP->det.xferOpTimes); - for(i=0; idata[idx], "%d", *srcbuf); /* numOps*/ - idx++; srcbuf++; + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* sum time */ + sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* sqr time */ + sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* min time */ + sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* max time */ + sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + } + + /* copy fs transfer timings */ + + srcbuf = (afs_int32 *) (fullPerfP->det.xferOpTimes); + for (i = 0; i < FS_STATS_NUM_XFER_OPS; i++) { + sprintf(a_fsData->data[idx], "%d", *srcbuf); /* numOps */ + idx++; + srcbuf++; sprintf(a_fsData->data[idx], "%d", *srcbuf); /* numSuccesses */ - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sum time */ - sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sqr time */ - sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* min time */ - sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* max time */ - sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* sum time */ + sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* sqr time */ + sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* min time */ + sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* max time */ + sprintf(a_fsData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; sprintf(a_fsData->data[idx], "%d", *srcbuf); /* sum bytes */ - idx++; srcbuf++; + idx++; + srcbuf++; sprintf(a_fsData->data[idx], "%d", *srcbuf); /* min bytes */ - idx++; srcbuf++; + idx++; + srcbuf++; sprintf(a_fsData->data[idx], "%d", *srcbuf); /* max bytes */ - idx++; srcbuf++; - for(j=0; jdata[idx], "%d", *srcbuf); /* bucket[j] */ - idx++; srcbuf++; + idx++; + srcbuf++; + for (j = 0; j < FS_STATS_NUM_XFER_BUCKETS; j++) { + sprintf(a_fsData->data[idx], "%d", *srcbuf); /* bucket[j] */ + idx++; + srcbuf++; } - } + } - return(0); -} /* fs_Results_ltoa */ + return (0); +} /* fs_Results_ltoa */ @@ -1874,88 +1963,91 @@ struct xstat_fs_ProbeResults *a_fsResults; /* ptr to xstat fs Results */ *----------------------------------------------------------------------*/ int -execute_thresh_handler(a_handler, a_hostName, a_hostType, - a_threshName,a_threshValue, a_actValue) -char *a_handler; /* ptr to handler function + args */ -char *a_hostName; /* host name for which threshold crossed */ -int a_hostType; /* fs or cm ? */ -char *a_threshName; /* threshold variable name */ -char *a_threshValue; /* threshold value */ -char *a_actValue; /* actual value */ - -{ /* execute_thresh_handler */ - - static char rn[] = "execute_thresh_handler"; - char fileName[256]; /* file name to execute */ - int i; - char *ch; - int code; - int argNum; - int anotherArg; /* boolean used to flag if another arg is available */ - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_handler= %s, a_hostName= %s, a_hostType= %d, a_threshName= %s, a_threshValue= %s, a_actValue= %s\n", - rn, a_handler, a_hostName, a_hostType, a_threshName, a_threshValue, - a_actValue); +execute_thresh_handler(a_handler, a_hostName, a_hostType, a_threshName, + a_threshValue, a_actValue) + char *a_handler; /* ptr to handler function + args */ + char *a_hostName; /* host name for which threshold crossed */ + int a_hostType; /* fs or cm ? */ + char *a_threshName; /* threshold variable name */ + char *a_threshValue; /* threshold value */ + char *a_actValue; /* actual value */ + +{ /* execute_thresh_handler */ + + static char rn[] = "execute_thresh_handler"; + char fileName[256]; /* file name to execute */ + int i; + char *ch; + int code; + int argNum; + int anotherArg; /* boolean used to flag if another arg is available */ + + if (afsmon_debug) { + fprintf(debugFD, + "[ %s ] Called, a_handler= %s, a_hostName= %s, a_hostType= %d, a_threshName= %s, a_threshValue= %s, a_actValue= %s\n", + rn, a_handler, a_hostName, a_hostType, a_threshName, + a_threshValue, a_actValue); fflush(debugFD); - } + } - /* get the filename to execute - the first argument */ - sscanf(a_handler,"%s",fileName); + /* get the filename to execute - the first argument */ + sscanf(a_handler, "%s", fileName); - /* construct the contents of *argv[] */ + /* construct the contents of *argv[] */ - strncpy(fsHandler_args[0], fileName,256); - strncpy(fsHandler_args[1], a_hostName, HOST_NAME_LEN); - if (a_hostType == FS) strcpy(fsHandler_args[2], "fs"); - else strcpy(fsHandler_args[2], "cm"); - strncpy(fsHandler_args[3], a_threshName, THRESH_VAR_NAME_LEN); - strncpy(fsHandler_args[4], a_threshValue, THRESH_VAR_LEN); - strncpy(fsHandler_args[5], a_actValue, THRESH_VAR_LEN); + strncpy(fsHandler_args[0], fileName, 256); + strncpy(fsHandler_args[1], a_hostName, HOST_NAME_LEN); + if (a_hostType == FS) + strcpy(fsHandler_args[2], "fs"); + else + strcpy(fsHandler_args[2], "cm"); + strncpy(fsHandler_args[3], a_threshName, THRESH_VAR_NAME_LEN); + strncpy(fsHandler_args[4], a_threshValue, THRESH_VAR_LEN); + strncpy(fsHandler_args[5], a_actValue, THRESH_VAR_LEN); - argNum = 6; - anotherArg = 1; - ch = a_handler; + argNum = 6; + anotherArg = 1; + ch = a_handler; - /* we have already extracted the file name so skip to the 1st arg */ - while (isspace(*ch)) /* leading blanks */ + /* we have already extracted the file name so skip to the 1st arg */ + while (isspace(*ch)) /* leading blanks */ ch++; - while (! isspace(*ch) && *ch != '\0') /* handler filename */ + while (!isspace(*ch) && *ch != '\0') /* handler filename */ ch++; - while( *ch != '\0' ) { + while (*ch != '\0') { if (isspace(*ch)) { - anotherArg = 1; - } else if (anotherArg) { - anotherArg = 0; - sscanf(ch,"%s",fsHandler_args[argNum]); - argNum++; + anotherArg = 1; + } else if (anotherArg) { + anotherArg = 0; + sscanf(ch, "%s", fsHandler_args[argNum]); + argNum++; } ch++; if (argNum >= 20) { - sprintf(errMsg, - "Threshold handlers cannot have more than 20 arguments\n"); - afsmon_Exit(55); + sprintf(errMsg, + "Threshold handlers cannot have more than 20 arguments\n"); + afsmon_Exit(55); } - } + } - fsHandler_argv[argNum] = NULL; - for(i=0; inumThresh == 0) { + if (a_hostEntry->numThresh == 0) { /* store in ovf count ?? */ - return(0); - } + return (0); + } - count = 0; - threshP = a_hostEntry->thresh; - for(i=0; i < a_hostEntry->numThresh; i++) { + count = 0; + threshP = a_hostEntry->thresh; + for (i = 0; i < a_hostEntry->numThresh; i++) { if (threshP->itemName[0] == '\0') { - threshP++; continue; + threshP++; + continue; } idx = threshP->index; /* positional index to the data array */ - tValue = atof(threshP->threshVal); /* threshold value */ - pValue = atof(a_Data->data[idx]); /* probe value */ + tValue = atof(threshP->threshVal); /* threshold value */ + pValue = atof(a_Data->data[idx]); /* probe value */ if (pValue > tValue) { - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] fs = %s, thresh ovf for %s, threshold= %s, probevalue= %s\n", - rn, a_hostEntry->hostName, threshP->itemName, threshP->threshVal, a_Data->data[idx]); + if (afsmon_debug) { + fprintf(debugFD, + "[ %s ] fs = %s, thresh ovf for %s, threshold= %s, probevalue= %s\n", + rn, a_hostEntry->hostName, threshP->itemName, + threshP->threshVal, a_Data->data[idx]); fflush(debugFD); - } - /* if the threshold is crossed, call the handler function - only if this was a transition -ie, if the threshold was - crossed in the last probe too just count & keep quite! */ + } + /* if the threshold is crossed, call the handler function + * only if this was a transition -ie, if the threshold was + * crossed in the last probe too just count & keep quite! */ - if (! a_Data->threshOvf[idx]) { + if (!a_Data->threshOvf[idx]) { a_Data->threshOvf[idx] = 1; /* call the threshold handler if provided */ if (threshP->handler[0] != '\0') { - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Calling ovf handler %s\n", + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Calling ovf handler %s\n", rn, threshP->handler); fflush(debugFD); - } - execute_thresh_handler(threshP->handler, - a_Data->hostName, FS, threshP->itemName, - threshP->threshVal, a_Data->data[idx]); - } + } + execute_thresh_handler(threshP->handler, a_Data->hostName, + FS, threshP->itemName, + threshP->threshVal, + a_Data->data[idx]); } + } - count++; + count++; } else - /* in case threshold was previously crossed, blank it out */ - a_Data->threshOvf[idx] = 0; + /* in case threshold was previously crossed, blank it out */ + a_Data->threshOvf[idx] = 0; threshP++; - } + } /* store the overflow count */ - a_Data->ovfCount = count; + a_Data->ovfCount = count; - return(0); -} /* check_fs_thresholds */ + return (0); +} /* check_fs_thresholds */ /*----------------------------------------------------------------------- @@ -2070,176 +2166,185 @@ struct fs_Display_Data *a_Data; /* ptr to fs data to be displayed */ int save_FS_data_forDisplay(a_fsResults) -struct xstat_fs_ProbeResults *a_fsResults; -{ /* save_FS_data_forDisplay */ - - static char rn[] = "save_FS_data_forDisplay"; /* routine name */ - struct fs_Display_Data *curr_fsDataP; /* tmp ptr to curr_fsData*/ - struct fs_Display_Data *prev_fsDataP; /* tmp ptr to prev_fsData*/ - struct afsmon_hostEntry *curr_host; - static int probes_Received = 0; /* number of probes reveived in - the current cycle. If this is equal to numFS we got all - the data we want in this cycle and can now display it */ - int numBytes; - int okay; - int i; - int code; - int done; - - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_fsResults= %d\n",rn, a_fsResults); + struct xstat_fs_ProbeResults *a_fsResults; +{ /* save_FS_data_forDisplay */ + + static char rn[] = "save_FS_data_forDisplay"; /* routine name */ + struct fs_Display_Data *curr_fsDataP; /* tmp ptr to curr_fsData */ + struct fs_Display_Data *prev_fsDataP; /* tmp ptr to prev_fsData */ + struct afsmon_hostEntry *curr_host; + static int probes_Received = 0; /* number of probes reveived in + * the current cycle. If this is equal to numFS we got all + * the data we want in this cycle and can now display it */ + int numBytes; + int okay; + int i; + int code; + int done; + + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_fsResults= %d\n", rn, a_fsResults); fflush(debugFD); - } + } - /* store results in the display array */ + /* store results in the display array */ - okay = 0; - curr_fsDataP = curr_fsData; - for (i=0; ihostName,a_fsResults->connP->hostName)) == 0) { - okay = 1; - break; + okay = 0; + curr_fsDataP = curr_fsData; + for (i = 0; i < numFS; i++) { + if ((strcasecmp(curr_fsDataP->hostName, a_fsResults->connP->hostName)) + == 0) { + okay = 1; + break; } curr_fsDataP++; - } - - if (!okay) { - fprintf(stderr,"[ %s ] Could not insert FS probe results for host %s in fs display array\n",rn, a_fsResults->connP->hostName); - afsmon_Exit(65); - } + } - /* Check the status of the probe. If it succeeded, we store its - results in the display data structure. If it failed we only mark - the failed status in the display data structure. */ + if (!okay) { + fprintf(stderr, + "[ %s ] Could not insert FS probe results for host %s in fs display array\n", + rn, a_fsResults->connP->hostName); + afsmon_Exit(65); + } - if (a_fsResults->probeOK) { /* 1 => notOK the xstat results */ + /* Check the status of the probe. If it succeeded, we store its + * results in the display data structure. If it failed we only mark + * the failed status in the display data structure. */ + + if (a_fsResults->probeOK) { /* 1 => notOK the xstat results */ curr_fsDataP->probeOK = 0; /* print the probe status */ - if (afsmon_debug) { - fprintf(debugFD,"\n\t\t ----- fs display data ------\n"); - fprintf(debugFD,"HostName = %s PROBE FAILED \n",curr_fsDataP->hostName); - fflush(debugFD); + if (afsmon_debug) { + fprintf(debugFD, "\n\t\t ----- fs display data ------\n"); + fprintf(debugFD, "HostName = %s PROBE FAILED \n", + curr_fsDataP->hostName); + fflush(debugFD); } - } else { /* probe succeeded, update display data structures */ + } else { /* probe succeeded, update display data structures */ curr_fsDataP->probeOK = 1; - /* covert longs to strings and place them in curr_fsDataP */ - fs_Results_ltoa(curr_fsDataP, a_fsResults); + /* covert longs to strings and place them in curr_fsDataP */ + fs_Results_ltoa(curr_fsDataP, a_fsResults); - /* compare with thresholds and set the overflow flags. - note that the threshold information is in the hostEntry structure and - each threshold item has a positional index associated with it */ + /* compare with thresholds and set the overflow flags. + * note that the threshold information is in the hostEntry structure and + * each threshold item has a positional index associated with it */ - /* locate the hostEntry for this host */ - done = 0; - curr_host = FSnameList; - for(i=0; ihostName,a_fsResults->connP->hostName) == 0) { - done = 1; - break; - } - curr_host = curr_host->next;; - } - if (!done) afsmon_Exit(70); + /* locate the hostEntry for this host */ + done = 0; + curr_host = FSnameList; + for (i = 0; i < numFS; i++) { + if (strcasecmp(curr_host->hostName, a_fsResults->connP->hostName) + == 0) { + done = 1; + break; + } + curr_host = curr_host->next;; + } + if (!done) + afsmon_Exit(70); - code = check_fs_thresholds(curr_host, curr_fsDataP); - if (code) { - fprintf(stderr,"[ %s ] Error in checking thresholds\n",rn); - afsmon_Exit(75); - } + code = check_fs_thresholds(curr_host, curr_fsDataP); + if (code) { + fprintf(stderr, "[ %s ] Error in checking thresholds\n", rn); + afsmon_Exit(75); + } - - /* print the info we just saved */ - if (afsmon_debug) { - fprintf(debugFD,"\n\t\t ----- fs display data ------\n"); - fprintf(debugFD,"HostName = %s\n",curr_fsDataP->hostName); - for(i=0; idata[i], - fs_varNames[i], curr_fsDataP->threshOvf[i] ? "(ovf)":"" ); + /* print the info we just saved */ - fprintf(debugFD,"\t\t--------------------------------\n\n"); - fflush(debugFD); - } + if (afsmon_debug) { + fprintf(debugFD, "\n\t\t ----- fs display data ------\n"); + fprintf(debugFD, "HostName = %s\n", curr_fsDataP->hostName); + for (i = 0; i < NUM_FS_STAT_ENTRIES; i++) + fprintf(debugFD, "%20s %30s %s\n", curr_fsDataP->data[i], + fs_varNames[i], + curr_fsDataP->threshOvf[i] ? "(ovf)" : ""); + + fprintf(debugFD, "\t\t--------------------------------\n\n"); + fflush(debugFD); + } - } /* the probe succeeded, so we store the data in the display structure */ + } /* the probe succeeded, so we store the data in the display structure */ /* if we have received a reply from all the hosts for this probe cycle, - it is time to display the data */ + * it is time to display the data */ - probes_Received++; - if (probes_Received == numFS) { + probes_Received++; + if (probes_Received == numFS) { probes_Received = 0; if (afsmon_fs_curr_probeNum != afsmon_fs_prev_probeNum + 1) { - sprintf(errMsg,"[ %s ] Probe number %d missed! \n", - rn, afsmon_fs_prev_probeNum +1); - afsmon_Exit(80); + sprintf(errMsg, "[ %s ] Probe number %d missed! \n", rn, + afsmon_fs_prev_probeNum + 1); + afsmon_Exit(80); } else - afsmon_fs_prev_probeNum++; + afsmon_fs_prev_probeNum++; /* backup the display data of the probe cycle that just completed - - ie., store curr_fsData in prev_fsData */ + * ie., store curr_fsData in prev_fsData */ - memcpy((char *)prev_fsData, (char *)curr_fsData, (numFS * sizeof(struct fs_Display_Data)) ); + memcpy((char *)prev_fsData, (char *)curr_fsData, + (numFS * sizeof(struct fs_Display_Data))); /* initialize curr_fsData but retain the threshold flag information. - The previous state of threshold flags is used in check_fs_thresholds()*/ + * The previous state of threshold flags is used in check_fs_thresholds() */ numBytes = NUM_FS_STAT_ENTRIES * CM_STAT_STRING_LEN; curr_fsDataP = curr_fsData; - for(i=0; iprobeOK = 0; - curr_fsDataP->ovfCount = 0; - memset((char *)curr_fsDataP->data, 0, numBytes); - curr_fsDataP++; + for (i = 0; i < numFS; i++) { + curr_fsDataP->probeOK = 0; + curr_fsDataP->ovfCount = 0; + memset((char *)curr_fsDataP->data, 0, numBytes); + curr_fsDataP++; } - + /* prev_fsData now contains all the information for the probe cycle - that just completed. Now count the number of threshold overflows for - use in the overview screen */ + * that just completed. Now count the number of threshold overflows for + * use in the overview screen */ prev_fsDataP = prev_fsData; num_fs_alerts = 0; numHosts_onfs_alerts = 0; - for(i=0; iprobeOK ) { /* if probe failed */ - num_fs_alerts++; - numHosts_onfs_alerts++; - } if (prev_fsDataP->ovfCount) { /* overflows ?? */ - num_fs_alerts += prev_fsDataP->ovfCount; - numHosts_onfs_alerts++; - } - prev_fsDataP++; + for (i = 0; i < numFS; i++) { + if (!prev_fsDataP->probeOK) { /* if probe failed */ + num_fs_alerts++; + numHosts_onfs_alerts++; + } + if (prev_fsDataP->ovfCount) { /* overflows ?? */ + num_fs_alerts += prev_fsDataP->ovfCount; + numHosts_onfs_alerts++; + } + prev_fsDataP++; } if (afsmon_debug) - fprintf(debugFD,"Number of FS alerts = %d (on %d hosts)\n", - num_fs_alerts, numHosts_onfs_alerts); + fprintf(debugFD, "Number of FS alerts = %d (on %d hosts)\n", + num_fs_alerts, numHosts_onfs_alerts); /* flag that the data is now ready to be displayed */ fs_Data_Available = 1; - /* call the Overview frame update routine (update only FS info)*/ + /* call the Overview frame update routine (update only FS info) */ ovw_refresh(ovw_currPage, OVW_UPDATE_FS); /* call the File Servers frame update routine */ fs_refresh(fs_currPage, fs_curr_LCol); - } /* display data */ + } + /* display data */ + return (0); +} /* save_FS_data_forDisplay */ - return(0); -} /* save_FS_data_forDisplay */ - @@ -2257,65 +2362,64 @@ struct xstat_fs_ProbeResults *a_fsResults; *----------------------------------------------------------------------*/ int -afsmon_FS_Handler() -{ /* afsmon_FS_Handler() */ - static char rn[] = "afsmon_FS_Handler"; /* routine name */ - int newProbeCycle; /* start of new probe cycle ? */ - int code; /* return status */ - - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, hostName= %s, probeNum= %d, status=%s\n", - rn, - xstat_fs_Results.connP->hostName, - xstat_fs_Results.probeNum, - xstat_fs_Results.probeOK? "FAILED":"OK"); - fflush(debugFD); - } - - - /* print the probe results to output file */ - if (afsmon_output) { +afsmon_FS_Handler() +{ /* afsmon_FS_Handler() */ + static char rn[] = "afsmon_FS_Handler"; /* routine name */ + int newProbeCycle; /* start of new probe cycle ? */ + int code; /* return status */ + + + if (afsmon_debug) { + fprintf(debugFD, + "[ %s ] Called, hostName= %s, probeNum= %d, status=%s\n", rn, + xstat_fs_Results.connP->hostName, xstat_fs_Results.probeNum, + xstat_fs_Results.probeOK ? "FAILED" : "OK"); + fflush(debugFD); + } + + + /* print the probe results to output file */ + if (afsmon_output) { code = afsmon_fsOutput(output_filename, afsmon_detOutput); - if (code) { - fprintf(stderr,"[ %s ] output to file %s returned error code=%d\n", - rn,output_filename,code); - } - } - - /* Update current probe number and circular buffer index. if current - probenum changed make sure it is only by 1 */ - - newProbeCycle = 0; - if (xstat_fs_Results.probeNum != afsmon_fs_curr_probeNum) { - if (xstat_fs_Results.probeNum == afsmon_fs_curr_probeNum + 1) { - afsmon_fs_curr_probeNum++; - newProbeCycle = 1; - if (num_bufSlots) - afsmon_fs_curr_CBindex= - (afsmon_fs_curr_probeNum - 1) % num_bufSlots; + if (code) { + fprintf(stderr, + "[ %s ] output to file %s returned error code=%d\n", rn, + output_filename, code); } - else { - fprintf(stderr,"[ %s ] probe number %d-1 missed\n", - rn,xstat_fs_Results.probeNum); - afsmon_Exit(85); + } + + /* Update current probe number and circular buffer index. if current + * probenum changed make sure it is only by 1 */ + + newProbeCycle = 0; + if (xstat_fs_Results.probeNum != afsmon_fs_curr_probeNum) { + if (xstat_fs_Results.probeNum == afsmon_fs_curr_probeNum + 1) { + afsmon_fs_curr_probeNum++; + newProbeCycle = 1; + if (num_bufSlots) + afsmon_fs_curr_CBindex = + (afsmon_fs_curr_probeNum - 1) % num_bufSlots; + } else { + fprintf(stderr, "[ %s ] probe number %d-1 missed\n", rn, + xstat_fs_Results.probeNum); + afsmon_Exit(85); } - } + } - /* store the results of this probe in the FS circular buffer */ - if (num_bufSlots) - save_FS_results_inCB(newProbeCycle); + /* store the results of this probe in the FS circular buffer */ + if (num_bufSlots) + save_FS_results_inCB(newProbeCycle); - /* store the results of the current probe in the fs data display structure. - if the current probe number changed, swap the current and previous display - structures. note that the display screen is updated from these structures - and should start showing the data of the just completed probe cycle */ + /* store the results of the current probe in the fs data display structure. + * if the current probe number changed, swap the current and previous display + * structures. note that the display screen is updated from these structures + * and should start showing the data of the just completed probe cycle */ - save_FS_data_forDisplay(&xstat_fs_Results); + save_FS_data_forDisplay(&xstat_fs_Results); - return(0); -} + return (0); +} @@ -2327,41 +2431,46 @@ afsmon_FS_Handler() * Prints the Cache Manager circular buffer *----------------------------------------------------------------------*/ -void +void Print_CM_CB() -{ /* Print_CM_CB() */ - - struct afsmon_cm_Results_list *cmlist; - int i; - int j; - - /* print valid info in the cm CB */ - - if (afsmon_debug) { - fprintf(debugFD,"==================== CM Buffer ========================\n"); - fprintf(debugFD,"afsmon_cm_curr_CBindex = %d\n",afsmon_cm_curr_CBindex); - fprintf(debugFD,"afsmon_cm_curr_probeNum = %d\n\n",afsmon_cm_curr_probeNum); - - for(i=0; iempty) { - fprintf(debugFD,"\t %d) probeNum = %d host = %s", - j,cmlist->cmResults->probeNum, - cmlist-> cmResults->connP->hostName); - if (cmlist->cmResults->probeOK) fprintf(debugFD," NOTOK\n"); - else fprintf(debugFD," OK\n"); +{ /* Print_CM_CB() */ + + struct afsmon_cm_Results_list *cmlist; + int i; + int j; + + /* print valid info in the cm CB */ + + if (afsmon_debug) { + fprintf(debugFD, + "==================== CM Buffer ========================\n"); + fprintf(debugFD, "afsmon_cm_curr_CBindex = %d\n", + afsmon_cm_curr_CBindex); + fprintf(debugFD, "afsmon_cm_curr_probeNum = %d\n\n", + afsmon_cm_curr_probeNum); + + for (i = 0; i < num_bufSlots; i++) { + fprintf(debugFD, "\t--------- slot %d ----------\n", i); + cmlist = afsmon_cm_ResultsCB[i].list; + j = 0; + while (j < numCM) { + if (!cmlist->empty) { + fprintf(debugFD, "\t %d) probeNum = %d host = %s", j, + cmlist->cmResults->probeNum, + cmlist->cmResults->connP->hostName); + if (cmlist->cmResults->probeOK) + fprintf(debugFD, " NOTOK\n"); + else + fprintf(debugFD, " OK\n"); } else - fprintf(debugFD,"\t %d) -- empty --\n",j); + fprintf(debugFD, "\t %d) -- empty --\n", j); cmlist = cmlist->next; j++; + } + if (cmlist != (struct afsmon_cm_Results_list *)0) + fprintf(debugFD, "dangling last next ptr cm CB\n"); } - if (cmlist != (struct afsmon_cm_Results_list *)0 ) - fprintf(debugFD,"dangling last next ptr cm CB\n"); - } - } + } } @@ -2384,84 +2493,94 @@ Print_CM_CB() int save_CM_results_inCB(a_newProbeCycle) -int a_newProbeCycle; /* start of new probe cycle ? */ + int a_newProbeCycle; /* start of new probe cycle ? */ -{ /* save_CM_results_inCB() */ - static char rn[] = "save_CM_results_inCB"; /* routine name */ - struct afsmon_cm_Results_list *tmp_cmlist_item; /* temp cm list item */ - struct xstat_cm_ProbeResults *tmp_cmPR; /* temp ptr */ - int i; +{ /* save_CM_results_inCB() */ + static char rn[] = "save_CM_results_inCB"; /* routine name */ + struct afsmon_cm_Results_list *tmp_cmlist_item; /* temp cm list item */ + struct xstat_cm_ProbeResults *tmp_cmPR; /* temp ptr */ + int i; - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_newProbeCycle= %d\n",rn, a_newProbeCycle); + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_newProbeCycle= %d\n", rn, + a_newProbeCycle); fflush(debugFD); - } - - /* If a new probe cycle started, mark the list in the current buffer - slot empty for resuse. Note that afsmon_cm_curr_CBindex was appropriately - incremented in afsmon_CM_Handler() */ - - if (a_newProbeCycle) { - tmp_cmlist_item = afsmon_cm_ResultsCB[afsmon_cm_curr_CBindex].list; - for(i=0; iempty = 1; - tmp_cmlist_item = tmp_cmlist_item->next; - } - } - - /* locate last unused item in list */ - tmp_cmlist_item = afsmon_cm_ResultsCB[afsmon_cm_curr_CBindex].list; - for(i=0; iempty) break; + } + + /* If a new probe cycle started, mark the list in the current buffer + * slot empty for resuse. Note that afsmon_cm_curr_CBindex was appropriately + * incremented in afsmon_CM_Handler() */ + + if (a_newProbeCycle) { + tmp_cmlist_item = afsmon_cm_ResultsCB[afsmon_cm_curr_CBindex].list; + for (i = 0; i < numCM; i++) { + tmp_cmlist_item->empty = 1; + tmp_cmlist_item = tmp_cmlist_item->next; + } + } + + /* locate last unused item in list */ + tmp_cmlist_item = afsmon_cm_ResultsCB[afsmon_cm_curr_CBindex].list; + for (i = 0; i < numCM; i++) { + if (tmp_cmlist_item->empty) + break; tmp_cmlist_item = tmp_cmlist_item->next; - } - - /* if we could not find one we have an inconsistent list */ - if ( ! tmp_cmlist_item->empty ) { - fprintf(stderr,"[ %s ] list inconsistency 1. unable to find an empty slot to store results of probenum %d of %s\n",rn, - xstat_cm_Results.probeNum,xstat_cm_Results.connP->hostName); + } + + /* if we could not find one we have an inconsistent list */ + if (!tmp_cmlist_item->empty) { + fprintf(stderr, + "[ %s ] list inconsistency 1. unable to find an empty slot to store results of probenum %d of %s\n", + rn, xstat_cm_Results.probeNum, + xstat_cm_Results.connP->hostName); afsmon_Exit(90); - } + } - tmp_cmPR = tmp_cmlist_item->cmResults; + tmp_cmPR = tmp_cmlist_item->cmResults; - /* copy hostname and probe number and probe time and probe status. - if the probe failed return now */ + /* copy hostname and probe number and probe time and probe status. + * if the probe failed return now */ - memcpy(tmp_cmPR->connP->hostName, xstat_cm_Results.connP->hostName, sizeof(xstat_cm_Results.connP->hostName)); - tmp_cmPR->probeNum = xstat_cm_Results.probeNum; - tmp_cmPR->probeTime = xstat_cm_Results.probeTime; - tmp_cmPR->probeOK = xstat_cm_Results.probeOK; - if (xstat_cm_Results.probeOK) { /* probeOK = 1 => notOK */ - /* we have a nonempty results structure so mark the list item used */ - tmp_cmlist_item->empty = 0; - return(0); - } + memcpy(tmp_cmPR->connP->hostName, xstat_cm_Results.connP->hostName, + sizeof(xstat_cm_Results.connP->hostName)); + tmp_cmPR->probeNum = xstat_cm_Results.probeNum; + tmp_cmPR->probeTime = xstat_cm_Results.probeTime; + tmp_cmPR->probeOK = xstat_cm_Results.probeOK; + if (xstat_cm_Results.probeOK) { /* probeOK = 1 => notOK */ + /* we have a nonempty results structure so mark the list item used */ + tmp_cmlist_item->empty = 0; + return (0); + } - /* copy connection information */ - memcpy(&(tmp_cmPR->connP->skt), &(xstat_cm_Results.connP->skt), sizeof(struct sockaddr_in)); + /* copy connection information */ + memcpy(&(tmp_cmPR->connP->skt), &(xstat_cm_Results.connP->skt), + sizeof(struct sockaddr_in)); /**** NEED TO COPY rx_connection INFORMATION HERE ******/ - memcpy(tmp_cmPR->connP->hostName, xstat_cm_Results.connP->hostName, sizeof(xstat_cm_Results.connP->hostName)); - tmp_cmPR->collectionNumber = xstat_cm_Results.collectionNumber; + memcpy(tmp_cmPR->connP->hostName, xstat_cm_Results.connP->hostName, + sizeof(xstat_cm_Results.connP->hostName)); + tmp_cmPR->collectionNumber = xstat_cm_Results.collectionNumber; - /* copy the probe data information */ - tmp_cmPR->data.AFSCB_CollData_len = xstat_cm_Results.data.AFSCB_CollData_len; - memcpy(tmp_cmPR->data.AFSCB_CollData_val, xstat_cm_Results.data.AFSCB_CollData_val, xstat_cm_Results.data.AFSCB_CollData_len * sizeof(afs_int32)); + /* copy the probe data information */ + tmp_cmPR->data.AFSCB_CollData_len = + xstat_cm_Results.data.AFSCB_CollData_len; + memcpy(tmp_cmPR->data.AFSCB_CollData_val, + xstat_cm_Results.data.AFSCB_CollData_val, + xstat_cm_Results.data.AFSCB_CollData_len * sizeof(afs_int32)); - - /* we have a valid results structure so mark the list item used */ - tmp_cmlist_item->empty = 0; - /* print the stored info - to make sure we copied it right */ - /* Print_cm_FullPerfInfo(tmp_cmPR); */ - /* Print the cm circular buffer */ - Print_CM_CB(); - return(0); -} /* save_CM_results_inCB */ + /* we have a valid results structure so mark the list item used */ + tmp_cmlist_item->empty = 0; + + /* print the stored info - to make sure we copied it right */ + /* Print_cm_FullPerfInfo(tmp_cmPR); */ + /* Print the cm circular buffer */ + Print_CM_CB(); + return (0); +} /* save_CM_results_inCB */ @@ -2482,202 +2601,234 @@ int a_newProbeCycle; /* start of new probe cycle ? */ *----------------------------------------------------------------------*/ int -cm_Results_ltoa(a_cmData,a_cmResults) -struct cm_Display_Data *a_cmData; /* target buffer */ -struct xstat_cm_ProbeResults *a_cmResults; /* ptr to xstat cm Results */ -{ /* cm_Results_ltoa */ - - static char rn[] = "cm_Results_ltoa"; /* routine name */ - struct afs_stats_CMFullPerf *fullP; /* ptr to complete CM stats */ - afs_int32 *srcbuf; - afs_int32 *tmpbuf; - int i,j; - int idx; - afs_int32 numLongs; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_cmData= %d, a_cmResults= %d\n", - rn, a_cmData, a_cmResults); +cm_Results_ltoa(a_cmData, a_cmResults) + struct cm_Display_Data *a_cmData; /* target buffer */ + struct xstat_cm_ProbeResults *a_cmResults; /* ptr to xstat cm Results */ +{ /* cm_Results_ltoa */ + + static char rn[] = "cm_Results_ltoa"; /* routine name */ + struct afs_stats_CMFullPerf *fullP; /* ptr to complete CM stats */ + afs_int32 *srcbuf; + afs_int32 *tmpbuf; + int i, j; + int idx; + afs_int32 numLongs; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_cmData= %d, a_cmResults= %d\n", rn, + a_cmData, a_cmResults); fflush(debugFD); - } - - - fullP = (struct afs_stats_CMFullPerf *) - (xstat_cm_Results.data.AFSCB_CollData_val); - - /* There are 4 parts to CM statistics - - Overall performance statistics (including up/down statistics) - - This CMs FS RPC operations info - - This CMs FS RPC errors info - - This CMs FS transfers info - - Authentication info - - [Un]Replicated access info - */ - - /* copy overall performance statistics */ - srcbuf = (afs_int32 *) &(fullP->perf); - idx = 0; - /* we skip the 19 entry, ProtServAddr, so the index must account for this */ - for(i=0 ; iperf); + idx = 0; + /* we skip the 19 entry, ProtServAddr, so the index must account for this */ + for (i = 0; i < NUM_AFS_STATS_CMPERF_LONGS + 1; i++) { if (i == 19) { - srcbuf++; - continue; /* skip ProtServerAddr */ + srcbuf++; + continue; /* skip ProtServerAddr */ } sprintf(a_cmData->data[idx], "%d", *srcbuf); idx++; srcbuf++; - } - - /*printf("Ending index value = %d\n",idx-1);*/ - - /* server up/down statistics */ - /* copy file server up/down stats */ - srcbuf = (afs_int32 *) (fullP->perf.fs_UpDown); - numLongs = 2 * (sizeof(struct afs_stats_SrvUpDownInfo) / sizeof(afs_int32)); - for(i=0 ; iperf.fs_UpDown); + numLongs = + 2 * (sizeof(struct afs_stats_SrvUpDownInfo) / sizeof(afs_int32)); + for (i = 0; i < numLongs; i++) { sprintf(a_cmData->data[idx], "%d", *srcbuf); idx++; srcbuf++; - } - - /*printf("Ending index value = %d\n",idx-1);*/ - - /* copy volume location server up/down stats */ - srcbuf = (afs_int32 *) (fullP->perf.vl_UpDown); - numLongs = 2 * (sizeof(struct afs_stats_SrvUpDownInfo) / sizeof(afs_int32)); - for(i=0 ; iperf.vl_UpDown); + numLongs = + 2 * (sizeof(struct afs_stats_SrvUpDownInfo) / sizeof(afs_int32)); + for (i = 0; i < numLongs; i++) { sprintf(a_cmData->data[idx], "%d", *srcbuf); idx++; srcbuf++; - } - - /*printf("Ending index value = %d\n",idx-1);*/ - - /* copy CMs individual FS RPC operations info */ - srcbuf = (afs_int32 *) (fullP->rpc.fsRPCTimes); - for(i=0; idata[idx], "%d", *srcbuf); /* numOps*/ - idx++; srcbuf++; + } + + /*printf("Ending index value = %d\n",idx-1); */ + + /* copy CMs individual FS RPC operations info */ + srcbuf = (afs_int32 *) (fullP->rpc.fsRPCTimes); + for (i = 0; i < AFS_STATS_NUM_FS_RPC_OPS; i++) { + sprintf(a_cmData->data[idx], "%d", *srcbuf); /* numOps */ + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* numSuccesses */ - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sum time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sqr time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* min time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* max time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - } - - /*printf("Ending index value = %d\n",idx-1);*/ - - /* copy CMs individual FS RPC errors info */ - - srcbuf = (afs_int32 *) (fullP->rpc.fsRPCErrors); - for(i=0; idata[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* sqr time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* min time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* max time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + } + + /*printf("Ending index value = %d\n",idx-1); */ + + /* copy CMs individual FS RPC errors info */ + + srcbuf = (afs_int32 *) (fullP->rpc.fsRPCErrors); + for (i = 0; i < AFS_STATS_NUM_FS_RPC_OPS; i++) { sprintf(a_cmData->data[idx], "%d", *srcbuf); /* server */ - idx++; srcbuf++; + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* network */ - idx++; srcbuf++; + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* prot */ - idx++; srcbuf++; + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* vol */ - idx++; srcbuf++; + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* busies */ - idx++; srcbuf++; + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* other */ - idx++; srcbuf++; - } + idx++; + srcbuf++; + } - /*printf("Ending index value = %d\n",idx-1);*/ + /*printf("Ending index value = %d\n",idx-1); */ - /* copy CMs individual RPC transfers info */ + /* copy CMs individual RPC transfers info */ - srcbuf = (afs_int32 *) (fullP->rpc.fsXferTimes); - for(i=0; idata[idx], "%d", *srcbuf); /* numOps*/ - idx++; srcbuf++; + srcbuf = (afs_int32 *) (fullP->rpc.fsXferTimes); + for (i = 0; i < AFS_STATS_NUM_FS_XFER_OPS; i++) { + sprintf(a_cmData->data[idx], "%d", *srcbuf); /* numOps */ + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* numSuccesses */ - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sum time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sqr time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* min time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* max time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* sum time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* sqr time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* min time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* max time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* sum bytes */ - idx++; srcbuf++; + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* min bytes */ - idx++; srcbuf++; + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* max bytes */ - idx++; srcbuf++; - for(j=0; jdata[idx], "%d", *srcbuf); /* bucket[j] */ - idx++; srcbuf++; + idx++; + srcbuf++; + for (j = 0; j < AFS_STATS_NUM_XFER_BUCKETS; j++) { + sprintf(a_cmData->data[idx], "%d", *srcbuf); /* bucket[j] */ + idx++; + srcbuf++; } } - /*printf("Ending index value = %d\n",idx-1);*/ + /*printf("Ending index value = %d\n",idx-1); */ - /* copy CM operations timings */ + /* copy CM operations timings */ - srcbuf = (afs_int32 *) (fullP->rpc.cmRPCTimes); - for(i=0; idata[idx], "%d", *srcbuf); /* numOps*/ - idx++; srcbuf++; + srcbuf = (afs_int32 *) (fullP->rpc.cmRPCTimes); + for (i = 0; i < AFS_STATS_NUM_CM_RPC_OPS; i++) { + sprintf(a_cmData->data[idx], "%d", *srcbuf); /* numOps */ + idx++; + srcbuf++; sprintf(a_cmData->data[idx], "%d", *srcbuf); /* numSuccesses */ - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sum time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* sqr time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* min time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - tmpbuf = srcbuf++; /* max time */ - sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); - idx++; srcbuf++; - } - - /*printf("Ending index value = %d\n",idx-1);*/ - - /* copy authentication info */ - - srcbuf = (afs_int32 *) &(fullP->authent); - numLongs = sizeof(struct afs_stats_AuthentInfo) / sizeof(afs_int32); - for(i=0; idata[idx], "%d", *srcbuf); - idx++; srcbuf++; - } - - /*printf("Ending index value = %d\n",idx-1);*/ - - /* copy CM [un]replicated access info */ - - srcbuf = (afs_int32 *) &(fullP->accessinf); - numLongs = sizeof(struct afs_stats_AccessInfo) / sizeof(afs_int32); - for(i=0; idata[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* sqr time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* min time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + tmpbuf = srcbuf++; /* max time */ + sprintf(a_cmData->data[idx], "%d.%06d", *tmpbuf, *srcbuf); + idx++; + srcbuf++; + } + + /*printf("Ending index value = %d\n",idx-1); */ + + /* copy authentication info */ + + srcbuf = (afs_int32 *) & (fullP->authent); + numLongs = sizeof(struct afs_stats_AuthentInfo) / sizeof(afs_int32); + for (i = 0; i < numLongs; i++) { sprintf(a_cmData->data[idx], "%d", *srcbuf); - idx++; srcbuf++; - } + idx++; + srcbuf++; + } - /*printf("Ending index value = %d\n",idx-1);*/ - return(0); + /*printf("Ending index value = %d\n",idx-1); */ -} /* cm_Results_ltoa */ + /* copy CM [un]replicated access info */ + + srcbuf = (afs_int32 *) & (fullP->accessinf); + numLongs = sizeof(struct afs_stats_AccessInfo) / sizeof(afs_int32); + for (i = 0; i < numLongs; i++) { + sprintf(a_cmData->data[idx], "%d", *srcbuf); + idx++; + srcbuf++; + } + + /*printf("Ending index value = %d\n",idx-1); */ + return (0); + +} /* cm_Results_ltoa */ /*----------------------------------------------------------------------- @@ -2700,77 +2851,81 @@ struct xstat_cm_ProbeResults *a_cmResults; /* ptr to xstat cm Results */ int check_cm_thresholds(a_hostEntry, a_Data) -struct afsmon_hostEntry *a_hostEntry; /* ptr to hostEntry */ -struct cm_Display_Data *a_Data; /* ptr to cm data to be displayed */ - -{ /* check_cm_thresholds */ - - static char rn[] = "check_cm_thresholds"; - struct Threshold *threshP; - double tValue; /* threshold value */ - double pValue; /* probe value */ - int i; - int idx; - int count; /* number of thresholds exceeded */ - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_hostEntry= %d, a_Data= %d\n", - rn, a_hostEntry, a_Data); + struct afsmon_hostEntry *a_hostEntry; /* ptr to hostEntry */ + struct cm_Display_Data *a_Data; /* ptr to cm data to be displayed */ + +{ /* check_cm_thresholds */ + + static char rn[] = "check_cm_thresholds"; + struct Threshold *threshP; + double tValue; /* threshold value */ + double pValue; /* probe value */ + int i; + int idx; + int count; /* number of thresholds exceeded */ + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_hostEntry= %d, a_Data= %d\n", rn, + a_hostEntry, a_Data); fflush(debugFD); - } + } - if (a_hostEntry->numThresh == 0) { + if (a_hostEntry->numThresh == 0) { /* store in ovf count ?? */ - return(0); - } + return (0); + } - count = 0; - threshP = a_hostEntry->thresh; - for(i=0; i < a_hostEntry->numThresh; i++) { + count = 0; + threshP = a_hostEntry->thresh; + for (i = 0; i < a_hostEntry->numThresh; i++) { if (threshP->itemName[0] == '\0') { - threshP++; continue; + threshP++; + continue; } idx = threshP->index; /* positional index to the data array */ - tValue = atof(threshP->threshVal); /* threshold value */ - pValue = atof(a_Data->data[idx]); /* probe value */ + tValue = atof(threshP->threshVal); /* threshold value */ + pValue = atof(a_Data->data[idx]); /* probe value */ if (pValue > tValue) { - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] cm = %s, thresh ovf for %s, threshold= %s, probevalue= %s\n", - rn, a_hostEntry->hostName, threshP->itemName, threshP->threshVal , a_Data->data[idx]); - fflush(debugFD); - } + if (afsmon_debug) { + fprintf(debugFD, + "[ %s ] cm = %s, thresh ovf for %s, threshold= %s, probevalue= %s\n", + rn, a_hostEntry->hostName, threshP->itemName, + threshP->threshVal, a_Data->data[idx]); + fflush(debugFD); + } - /* if the threshold is crossed, call the handler function - only if this was a transition -ie, if the threshold was - crossed in the last probe too just count & keep quite! */ + /* if the threshold is crossed, call the handler function + * only if this was a transition -ie, if the threshold was + * crossed in the last probe too just count & keep quite! */ - if (! a_Data->threshOvf[idx]) { + if (!a_Data->threshOvf[idx]) { a_Data->threshOvf[idx] = 1; /* call the threshold handler if provided */ if (threshP->handler[0] != '\0') { - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Calling ovf handler %s\n", + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Calling ovf handler %s\n", rn, threshP->handler); fflush(debugFD); - } - execute_thresh_handler(threshP->handler, - a_Data->hostName, CM, threshP->itemName, - threshP->threshVal, a_Data->data[idx]); - } + } + execute_thresh_handler(threshP->handler, a_Data->hostName, + CM, threshP->itemName, + threshP->threshVal, + a_Data->data[idx]); } + } - count++; + count++; } else - /* in case threshold was previously crossed, blank it out */ - a_Data->threshOvf[idx] = 0; + /* in case threshold was previously crossed, blank it out */ + a_Data->threshOvf[idx] = 0; threshP++; - } + } /* store the overflow count */ - a_Data->ovfCount = count; + a_Data->ovfCount = count; - return(0); -} /* check_cm_thresholds */ + return (0); +} /* check_cm_thresholds */ /*----------------------------------------------------------------------- @@ -2793,198 +2948,222 @@ struct cm_Display_Data *a_Data; /* ptr to cm data to be displayed */ int save_CM_data_forDisplay(a_cmResults) -struct xstat_cm_ProbeResults *a_cmResults; -{ /* save_CM_data_forDisplay */ - - static char rn[] = "save_CM_data_forDisplay"; /* routine name */ - struct cm_Display_Data *curr_cmDataP; - struct cm_Display_Data *prev_cmDataP; - struct afsmon_hostEntry *curr_host; - static int probes_Received = 0; /* number of probes reveived in - the current cycle. If this is equal to numFS we got all - the data we want in this cycle and can now display it */ - int numBytes; - int done; - int code; - int okay; - int i; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, a_cmResults= %d\n",rn, a_cmResults); + struct xstat_cm_ProbeResults *a_cmResults; +{ /* save_CM_data_forDisplay */ + + static char rn[] = "save_CM_data_forDisplay"; /* routine name */ + struct cm_Display_Data *curr_cmDataP; + struct cm_Display_Data *prev_cmDataP; + struct afsmon_hostEntry *curr_host; + static int probes_Received = 0; /* number of probes reveived in + * the current cycle. If this is equal to numFS we got all + * the data we want in this cycle and can now display it */ + int numBytes; + int done; + int code; + int okay; + int i; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, a_cmResults= %d\n", rn, a_cmResults); fflush(debugFD); - } + } - /* store results in the display array */ + /* store results in the display array */ - okay = 0; - curr_cmDataP = curr_cmData; - for (i=0; ihostName,a_cmResults->connP->hostName)) == 0) { - okay = 1; - break; + okay = 0; + curr_cmDataP = curr_cmData; + for (i = 0; i < numCM; i++) { + if ((strcasecmp(curr_cmDataP->hostName, a_cmResults->connP->hostName)) + == 0) { + okay = 1; + break; } curr_cmDataP++; - } + } - if (!okay) { - fprintf(stderr,"[ %s ] Could not insert CM probe results for host %s in cm display array\n",rn, a_cmResults->connP->hostName); + if (!okay) { + fprintf(stderr, + "[ %s ] Could not insert CM probe results for host %s in cm display array\n", + rn, a_cmResults->connP->hostName); afsmon_Exit(95); - } + } - /* Check the status of the probe. If it succeeded, we store its - results in the display data structure. If it failed we only mark - the failed status in the display data structure. */ + /* Check the status of the probe. If it succeeded, we store its + * results in the display data structure. If it failed we only mark + * the failed status in the display data structure. */ - if (a_cmResults->probeOK) { /* 1 => notOK the xstat results */ + if (a_cmResults->probeOK) { /* 1 => notOK the xstat results */ curr_cmDataP->probeOK = 0; /* print the probe status */ - if (afsmon_debug) { - fprintf(debugFD,"\n\t\t ----- cm display data ------\n"); - fprintf(debugFD,"HostName = %s PROBE FAILED \n",curr_cmDataP->hostName); - fflush(debugFD); + if (afsmon_debug) { + fprintf(debugFD, "\n\t\t ----- cm display data ------\n"); + fprintf(debugFD, "HostName = %s PROBE FAILED \n", + curr_cmDataP->hostName); + fflush(debugFD); } - } else { /* probe succeeded, update display data structures */ + } else { /* probe succeeded, update display data structures */ curr_cmDataP->probeOK = 1; - /* covert longs to strings and place them in curr_cmDataP */ - cm_Results_ltoa(curr_cmDataP, a_cmResults); + /* covert longs to strings and place them in curr_cmDataP */ + cm_Results_ltoa(curr_cmDataP, a_cmResults); - /* compare with thresholds and set the overflow flags. - note that the threshold information is in the hostEntry structure and - each threshold item has a positional index associated with it */ + /* compare with thresholds and set the overflow flags. + * note that the threshold information is in the hostEntry structure and + * each threshold item has a positional index associated with it */ - /* locate the hostEntry for this host */ - done = 0; - curr_host = CMnameList; - for(i=0; ihostName,a_cmResults->connP->hostName) == 0) { + /* locate the hostEntry for this host */ + done = 0; + curr_host = CMnameList; + for (i = 0; i < numCM; i++) { + if (strcasecmp(curr_host->hostName, a_cmResults->connP->hostName) + == 0) { done = 1; break; - } - curr_host = curr_host->next; - } - if (!done) afsmon_Exit(100); - - code = check_cm_thresholds(curr_host, curr_cmDataP); - if (code) { - fprintf(stderr,"[ %s ] Error in checking thresholds\n",rn); - afsmon_Exit(105); - } - - - /* print the info we just saved */ - if (afsmon_debug) { - fprintf(debugFD,"\n\t\t ----- CM display data ------\n"); - fprintf(debugFD,"HostName = %s\n",curr_cmDataP->hostName); - for(i=0; inext; + } + if (!done) + afsmon_Exit(100); + + code = check_cm_thresholds(curr_host, curr_cmDataP); + if (code) { + fprintf(stderr, "[ %s ] Error in checking thresholds\n", rn); + afsmon_Exit(105); + } + + + /* print the info we just saved */ + if (afsmon_debug) { + fprintf(debugFD, "\n\t\t ----- CM display data ------\n"); + fprintf(debugFD, "HostName = %s\n", curr_cmDataP->hostName); + for (i = 0; i < NUM_CM_STAT_ENTRIES; i++) { switch (i) { - case 0: fprintf(debugFD,"\t -- Overall Perf Info --\n"); - break; - case 39: fprintf(debugFD,"\t -- File Server up/down stats - same cell --\n"); - break; - case 64: fprintf(debugFD,"\t -- File Server up/down stats - diff cell --\n"); - break; - case 89: fprintf(debugFD,"\t -- VL server up/down stats - same cell --\n"); - break; - case 114: fprintf(debugFD,"\t -- VL server up/down stats - diff cell --\n"); - break; - case 139: fprintf(debugFD,"\t -- FS Operation Timings --\n"); - break; - case 279: fprintf(debugFD,"\t -- FS Error Info --\n"); - break; - case 447: fprintf(debugFD,"\t -- FS Transfer Timings --\n"); - break; - case 475: fprintf(debugFD,"\t -- CM Operations Timings --\n"); - break; - case 510: fprintf(debugFD,"\t -- Authentication Info --\n"); - break; - case 522: fprintf(debugFD,"\t -- Access Info --\n"); - break; - default: break; + case 0: + fprintf(debugFD, "\t -- Overall Perf Info --\n"); + break; + case 39: + fprintf(debugFD, + "\t -- File Server up/down stats - same cell --\n"); + break; + case 64: + fprintf(debugFD, + "\t -- File Server up/down stats - diff cell --\n"); + break; + case 89: + fprintf(debugFD, + "\t -- VL server up/down stats - same cell --\n"); + break; + case 114: + fprintf(debugFD, + "\t -- VL server up/down stats - diff cell --\n"); + break; + case 139: + fprintf(debugFD, "\t -- FS Operation Timings --\n"); + break; + case 279: + fprintf(debugFD, "\t -- FS Error Info --\n"); + break; + case 447: + fprintf(debugFD, "\t -- FS Transfer Timings --\n"); + break; + case 475: + fprintf(debugFD, "\t -- CM Operations Timings --\n"); + break; + case 510: + fprintf(debugFD, "\t -- Authentication Info --\n"); + break; + case 522: + fprintf(debugFD, "\t -- Access Info --\n"); + break; + default: + break; } - fprintf(debugFD,"%20s %30s %s\n", curr_cmDataP->data[i], - cm_varNames[i],curr_cmDataP->threshOvf[i] ? "(ovf)":"" ); - } - fprintf(debugFD,"\t\t--------------------------------\n\n"); - } + fprintf(debugFD, "%20s %30s %s\n", curr_cmDataP->data[i], + cm_varNames[i], + curr_cmDataP->threshOvf[i] ? "(ovf)" : ""); + } + fprintf(debugFD, "\t\t--------------------------------\n\n"); + } - } /* if the probe succeeded, update the display data structures */ + } /* if the probe succeeded, update the display data structures */ - /* if we have received a reply from all the hosts for this probe cycle, - it is time to display the data */ + /* if we have received a reply from all the hosts for this probe cycle, + * it is time to display the data */ - probes_Received++; - if (probes_Received == numCM) { + probes_Received++; + if (probes_Received == numCM) { probes_Received = 0; if (afsmon_cm_curr_probeNum != afsmon_cm_prev_probeNum + 1) { - sprintf(errMsg,"[ %s ] Probe number %d missed! \n", - rn, afsmon_cm_prev_probeNum +1); - afsmon_Exit(110); + sprintf(errMsg, "[ %s ] Probe number %d missed! \n", rn, + afsmon_cm_prev_probeNum + 1); + afsmon_Exit(110); } else - afsmon_cm_prev_probeNum++; + afsmon_cm_prev_probeNum++; /* backup the display data of the probe cycle that just completed - - ie., store curr_cmData in prev_cmData */ + * ie., store curr_cmData in prev_cmData */ - memcpy((char *)prev_cmData, (char *)curr_cmData, (numCM * sizeof(struct cm_Display_Data)) ); + memcpy((char *)prev_cmData, (char *)curr_cmData, + (numCM * sizeof(struct cm_Display_Data))); /* initialize curr_cmData but retain the threshold flag information. - The previous state of threshold flags is used in check_cm_thresholds()*/ + * The previous state of threshold flags is used in check_cm_thresholds() */ curr_cmDataP = curr_cmData; numBytes = NUM_CM_STAT_ENTRIES * CM_STAT_STRING_LEN; - for(i=0; iprobeOK = 0; - curr_cmDataP->ovfCount = 0; - memset((char *)curr_cmDataP->data, 0, numBytes); - curr_cmDataP++; + for (i = 0; i < numCM; i++) { + curr_cmDataP->probeOK = 0; + curr_cmDataP->ovfCount = 0; + memset((char *)curr_cmDataP->data, 0, numBytes); + curr_cmDataP++; } /* prev_cmData now contains all the information for the probe cycle - that just completed. Now count the number of threshold overflows for - use in the overview screen */ + * that just completed. Now count the number of threshold overflows for + * use in the overview screen */ prev_cmDataP = prev_cmData; num_cm_alerts = 0; numHosts_oncm_alerts = 0; - for(i=0; iprobeOK) { /* if probe failed */ - num_cm_alerts++; - numHosts_oncm_alerts++; - } else if (prev_cmDataP->ovfCount) { /* overflows ?? */ - num_cm_alerts += prev_cmDataP->ovfCount; - numHosts_oncm_alerts++; - } - prev_cmDataP++; + for (i = 0; i < numCM; i++) { + if (!prev_cmDataP->probeOK) { /* if probe failed */ + num_cm_alerts++; + numHosts_oncm_alerts++; + } else if (prev_cmDataP->ovfCount) { /* overflows ?? */ + num_cm_alerts += prev_cmDataP->ovfCount; + numHosts_oncm_alerts++; + } + prev_cmDataP++; } if (afsmon_debug) - fprintf(debugFD,"Number of CM alerts = %d (on %d hosts)\n", - num_cm_alerts, numHosts_oncm_alerts); + fprintf(debugFD, "Number of CM alerts = %d (on %d hosts)\n", + num_cm_alerts, numHosts_oncm_alerts); /* flag that the data is now ready to be displayed */ cm_Data_Available = 1; - /* update the Overview frame (only CM info)*/ + /* update the Overview frame (only CM info) */ ovw_refresh(ovw_currPage, OVW_UPDATE_CM); /* update the Cache Managers frame */ cm_refresh(cm_currPage, cm_curr_LCol); - } + } - return(0); -} /* save_CM_data_forDisplay */ - + return (0); +} /* save_CM_data_forDisplay */ + /*----------------------------------------------------------------------- @@ -3001,62 +3180,61 @@ struct xstat_cm_ProbeResults *a_cmResults; *----------------------------------------------------------------------*/ int -afsmon_CM_Handler() -{ /* afsmon_CM_Handler() */ - static char rn[] = "afsmon_CM_Handler"; /* routine name */ - int code; /* return status */ - int newProbeCycle; /* start of new probe cycle ? */ - - if (afsmon_debug) { - fprintf(debugFD, - "[ %s ] Called, hostName= %s, probeNum= %d, status= %s\n", rn, - xstat_cm_Results.connP->hostName, - xstat_cm_Results.probeNum, - xstat_cm_Results.probeOK? "FAILED":"OK"); - fflush(debugFD); - } - - - /* print the probe results to output file */ - if (afsmon_output) { +afsmon_CM_Handler() +{ /* afsmon_CM_Handler() */ + static char rn[] = "afsmon_CM_Handler"; /* routine name */ + int code; /* return status */ + int newProbeCycle; /* start of new probe cycle ? */ + + if (afsmon_debug) { + fprintf(debugFD, + "[ %s ] Called, hostName= %s, probeNum= %d, status= %s\n", rn, + xstat_cm_Results.connP->hostName, xstat_cm_Results.probeNum, + xstat_cm_Results.probeOK ? "FAILED" : "OK"); + fflush(debugFD); + } + + + /* print the probe results to output file */ + if (afsmon_output) { code = afsmon_cmOutput(output_filename, afsmon_detOutput); - if (code) { - fprintf(stderr,"[ %s ] output to file %s returned error code=%d\n", - rn,output_filename,code); - } - } - - /* Update current probe number and circular buffer index. if current - probenum changed make sure it is only by 1 */ - - newProbeCycle = 0; - if (xstat_cm_Results.probeNum != afsmon_cm_curr_probeNum) { - if (xstat_cm_Results.probeNum == afsmon_cm_curr_probeNum + 1) { - afsmon_cm_curr_probeNum++; - newProbeCycle = 1; - if (num_bufSlots) - afsmon_cm_curr_CBindex= - (afsmon_cm_curr_probeNum - 1) % num_bufSlots; + if (code) { + fprintf(stderr, + "[ %s ] output to file %s returned error code=%d\n", rn, + output_filename, code); } - else { - fprintf(stderr,"[ %s ] probe number %d-1 missed\n", - rn,xstat_cm_Results.probeNum); - afsmon_Exit(115); + } + + /* Update current probe number and circular buffer index. if current + * probenum changed make sure it is only by 1 */ + + newProbeCycle = 0; + if (xstat_cm_Results.probeNum != afsmon_cm_curr_probeNum) { + if (xstat_cm_Results.probeNum == afsmon_cm_curr_probeNum + 1) { + afsmon_cm_curr_probeNum++; + newProbeCycle = 1; + if (num_bufSlots) + afsmon_cm_curr_CBindex = + (afsmon_cm_curr_probeNum - 1) % num_bufSlots; + } else { + fprintf(stderr, "[ %s ] probe number %d-1 missed\n", rn, + xstat_cm_Results.probeNum); + afsmon_Exit(115); } - } + } - /* save the results of this probe in the CM buffer */ - if (num_bufSlots) - save_CM_results_inCB(newProbeCycle); + /* save the results of this probe in the CM buffer */ + if (num_bufSlots) + save_CM_results_inCB(newProbeCycle); - /* store the results of the current probe in the cm data display structure. - if the current probe number changed, swap the current and previous display - structures. note that the display screen is updated from these structures - and should start showing the data of the just completed probe cycle */ + /* store the results of the current probe in the cm data display structure. + * if the current probe number changed, swap the current and previous display + * structures. note that the display screen is updated from these structures + * and should start showing the data of the just completed probe cycle */ - save_CM_data_forDisplay(&xstat_cm_Results); + save_CM_data_forDisplay(&xstat_cm_Results); - return(0); + return (0); } /*----------------------------------------------------------------------- @@ -3072,106 +3250,109 @@ afsmon_CM_Handler() int init_fs_buffers() -{ /* init_fs_buffers() */ - static char rn[] = "init_fs_buffers"; /* routine name */ - struct afsmon_fs_Results_list *new_fslist_item; /* ptr for new struct */ - struct afsmon_fs_Results_list *tmp_fslist_item; /* temp ptr */ - struct xstat_fs_ProbeResults *new_fsPR; /* ptr for new struct */ - int i,j; - int bufslot; - int numfs; - - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); +{ /* init_fs_buffers() */ + static char rn[] = "init_fs_buffers"; /* routine name */ + struct afsmon_fs_Results_list *new_fslist_item; /* ptr for new struct */ + struct afsmon_fs_Results_list *tmp_fslist_item; /* temp ptr */ + struct xstat_fs_ProbeResults *new_fsPR; /* ptr for new struct */ + int i, j; + int bufslot; + int numfs; + + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); - } - - /* allocate memory for the circular buffer of pointers */ - - afsmon_fs_ResultsCB = (struct afsmon_fs_Results_CBuffer *) malloc( - sizeof(struct afsmon_fs_Results_CBuffer) * num_bufSlots); - - /* initialize the fs circular buffer */ - for (i=0; iconnP = (struct xstat_fs_ConnectionInfo *) malloc( - sizeof(struct xstat_fs_ConnectionInfo)); - if (new_fsPR->connP == (struct xstat_fs_ConnectionInfo *)0 ) { - free(new_fslist_item); - free(new_fsPR); - return(-1); + new_fsPR->connP = (struct xstat_fs_ConnectionInfo *) + malloc(sizeof(struct xstat_fs_ConnectionInfo)); + if (new_fsPR->connP == (struct xstat_fs_ConnectionInfo *)0) { + free(new_fslist_item); + free(new_fsPR); + return (-1); } - /* >>> need to allocate rx connection info structure here <<< */ + /* >>> need to allocate rx connection info structure here <<< */ - new_fsPR->data.AFS_CollData_val = (afs_int32 *) malloc( - XSTAT_FS_FULLPERF_RESULTS_LEN * sizeof(afs_int32)); - if (new_fsPR->data.AFS_CollData_val == NULL) { - free(new_fslist_item); - free(new_fsPR->connP); - free(new_fsPR); - return(-1); + new_fsPR->data.AFS_CollData_val = + (afs_int32 *) malloc(XSTAT_FS_FULLPERF_RESULTS_LEN * + sizeof(afs_int32)); + if (new_fsPR->data.AFS_CollData_val == NULL) { + free(new_fslist_item); + free(new_fsPR->connP); + free(new_fsPR); + return (-1); } - /* initialize this list entry */ - new_fslist_item->fsResults = new_fsPR; - new_fslist_item->empty = 1; - new_fslist_item->next = (struct afsmon_fs_Results_list *)0; - - /* store it at the end of the fs list in the current CB slot */ - if (afsmon_fs_ResultsCB[bufslot].list == (struct afsmon_fs_Results_list *)0) - afsmon_fs_ResultsCB[ bufslot ].list = new_fslist_item; - else { - tmp_fslist_item = afsmon_fs_ResultsCB[ bufslot ].list; - j=0; - while(tmp_fslist_item != (struct afsmon_fs_Results_list *)0) - { - if (tmp_fslist_item->next == (struct afsmon_fs_Results_list *)0) - break; - tmp_fslist_item = tmp_fslist_item->next; - if (++j > numFS) - { - /* something goofed. exit */ - fprintf(stderr,"[ %s ] list creation error\n",rn); - return(-1); - } - } - tmp_fslist_item->next = new_fslist_item; - } - - } /* while servers */ - } /* for each buffer slot */ - } /* if we have file servers to monitor */ - return(0); + /* initialize this list entry */ + new_fslist_item->fsResults = new_fsPR; + new_fslist_item->empty = 1; + new_fslist_item->next = (struct afsmon_fs_Results_list *)0; + + /* store it at the end of the fs list in the current CB slot */ + if (afsmon_fs_ResultsCB[bufslot].list == + (struct afsmon_fs_Results_list *)0) + afsmon_fs_ResultsCB[bufslot].list = new_fslist_item; + else { + tmp_fslist_item = afsmon_fs_ResultsCB[bufslot].list; + j = 0; + while (tmp_fslist_item != + (struct afsmon_fs_Results_list *)0) { + if (tmp_fslist_item->next == + (struct afsmon_fs_Results_list *)0) + break; + tmp_fslist_item = tmp_fslist_item->next; + if (++j > numFS) { + /* something goofed. exit */ + fprintf(stderr, "[ %s ] list creation error\n", + rn); + return (-1); + } + } + tmp_fslist_item->next = new_fslist_item; + } + + } /* while servers */ + } /* for each buffer slot */ + } /* if we have file servers to monitor */ + return (0); } /*----------------------------------------------------------------------- @@ -3187,108 +3368,112 @@ init_fs_buffers() int init_cm_buffers() -{ /* init_cm_buffers() */ - static char rn[] = "init_cm_buffers"; /* routine name */ - struct afsmon_cm_Results_list *new_cmlist_item; /* ptr for new struct */ - struct afsmon_cm_Results_list *tmp_cmlist_item; /* temp ptr */ - struct xstat_cm_ProbeResults *new_cmPR; /* ptr for new struct */ - int i,j; - int bufslot; - int numcm; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); +{ /* init_cm_buffers() */ + static char rn[] = "init_cm_buffers"; /* routine name */ + struct afsmon_cm_Results_list *new_cmlist_item; /* ptr for new struct */ + struct afsmon_cm_Results_list *tmp_cmlist_item; /* temp ptr */ + struct xstat_cm_ProbeResults *new_cmPR; /* ptr for new struct */ + int i, j; + int bufslot; + int numcm; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); - } - - /* allocate memory for the circular buffer of pointers */ - afsmon_cm_ResultsCB = (struct afsmon_cm_Results_CBuffer *) malloc( - sizeof(struct afsmon_cm_Results_CBuffer) * num_bufSlots); - - /* initialize the fs circular buffer */ - for (i=0; iconnP = (struct xstat_cm_ConnectionInfo *) malloc( - sizeof(struct xstat_cm_ConnectionInfo)); - if (new_cmPR->connP == (struct xstat_cm_ConnectionInfo *)0 ) { - free(new_cmlist_item); - free(new_cmPR); - return(-1); + new_cmPR->connP = (struct xstat_cm_ConnectionInfo *) + malloc(sizeof(struct xstat_cm_ConnectionInfo)); + if (new_cmPR->connP == (struct xstat_cm_ConnectionInfo *)0) { + free(new_cmlist_item); + free(new_cmPR); + return (-1); } - /* >>> need to allocate rx connection info structure here <<< */ + /* >>> need to allocate rx connection info structure here <<< */ - new_cmPR->data.AFSCB_CollData_val = (afs_int32 *) malloc( - XSTAT_CM_FULLPERF_RESULTS_LEN * sizeof(afs_int32)); - if (new_cmPR->data.AFSCB_CollData_val == NULL) { - free(new_cmlist_item); - free(new_cmPR->connP); - free(new_cmPR); - return(-1); + new_cmPR->data.AFSCB_CollData_val = + (afs_int32 *) malloc(XSTAT_CM_FULLPERF_RESULTS_LEN * + sizeof(afs_int32)); + if (new_cmPR->data.AFSCB_CollData_val == NULL) { + free(new_cmlist_item); + free(new_cmPR->connP); + free(new_cmPR); + return (-1); } - /* initialize this list entry */ - new_cmlist_item->cmResults = new_cmPR; - new_cmlist_item->empty = 1; - new_cmlist_item->next = (struct afsmon_cm_Results_list *)0; - - /* store it at the end of the cm list in the current CB slot */ - if (afsmon_cm_ResultsCB[bufslot].list == (struct afsmon_cm_Results_list *)0) - afsmon_cm_ResultsCB[ bufslot ].list = new_cmlist_item; - else { - tmp_cmlist_item = afsmon_cm_ResultsCB[ bufslot ].list; - j=0; - while(tmp_cmlist_item != (struct afsmon_cm_Results_list *)0) - { - if (tmp_cmlist_item->next == (struct afsmon_cm_Results_list *)0) - break; - tmp_cmlist_item = tmp_cmlist_item->next; - if (++j > numCM) - { - /* something goofed. exit */ - fprintf(stderr,"[ %s ] list creation error\n",rn); - return(-1); - } - } - tmp_cmlist_item->next = new_cmlist_item; - } - - } /* while servers */ - } /* for each buffer slot */ - } /* if we have file servers to monitor */ - /* print the CB to make sure it is right */ - Print_CM_CB(); - - return(0); -} /* init_cm_buffers() */ + /* initialize this list entry */ + new_cmlist_item->cmResults = new_cmPR; + new_cmlist_item->empty = 1; + new_cmlist_item->next = (struct afsmon_cm_Results_list *)0; + + /* store it at the end of the cm list in the current CB slot */ + if (afsmon_cm_ResultsCB[bufslot].list == + (struct afsmon_cm_Results_list *)0) + afsmon_cm_ResultsCB[bufslot].list = new_cmlist_item; + else { + tmp_cmlist_item = afsmon_cm_ResultsCB[bufslot].list; + j = 0; + while (tmp_cmlist_item != + (struct afsmon_cm_Results_list *)0) { + if (tmp_cmlist_item->next == + (struct afsmon_cm_Results_list *)0) + break; + tmp_cmlist_item = tmp_cmlist_item->next; + if (++j > numCM) { + /* something goofed. exit */ + fprintf(stderr, "[ %s ] list creation error\n", + rn); + return (-1); + } + } + tmp_cmlist_item->next = new_cmlist_item; + } + + } /* while servers */ + } /* for each buffer slot */ + } + /* if we have file servers to monitor */ + /* print the CB to make sure it is right */ + Print_CM_CB(); + + return (0); +} /* init_cm_buffers() */ /*------------------------------------------------------------------------- @@ -3306,100 +3491,106 @@ init_cm_buffers() int init_print_buffers() -{ /* init_print_buffers */ - - static char rn[] = "init_print_buffers"; /* routine name */ - struct fs_Display_Data *tmp_fsData1; /* temp pointers */ - struct fs_Display_Data *tmp_fsData2; - struct cm_Display_Data *tmp_cmData1; - struct cm_Display_Data *tmp_cmData2; - struct afsmon_hostEntry *tmp_fsNames; - struct afsmon_hostEntry *tmp_cmNames; - int i; - int numBytes; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); +{ /* init_print_buffers */ + + static char rn[] = "init_print_buffers"; /* routine name */ + struct fs_Display_Data *tmp_fsData1; /* temp pointers */ + struct fs_Display_Data *tmp_fsData2; + struct cm_Display_Data *tmp_cmData1; + struct cm_Display_Data *tmp_cmData2; + struct afsmon_hostEntry *tmp_fsNames; + struct afsmon_hostEntry *tmp_cmNames; + int i; + int numBytes; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); - } - - /* allocate numFS blocks of the FS print structure. */ - - /* we need two instances of this structure - one (curr_fsData) for storing - the results of the fs probes currently in progress and another (prev_fsData) - for the last completed probe. The display is updated from the contents of - prev_fsData. The pointers curr_fsData & prev_fsData are switched whenever - the probe number changes */ - - if (numFS) { - numBytes = numFS * sizeof(struct fs_Display_Data); - curr_fsData = (struct fs_Display_Data *) malloc(numBytes); - if (curr_fsData == (struct fs_Display_Data *)0) { - fprintf(stderr,"[ %s ] Memory allocation failure\n",rn); - return(-1); - } - memset(curr_fsData, 0, numBytes); - - numBytes = numFS * sizeof(struct fs_Display_Data); - prev_fsData = (struct fs_Display_Data *) malloc(numBytes); - if (prev_fsData == (struct fs_Display_Data *)0) { - fprintf(stderr,"[ %s ] Memory allocation failure\n",rn); - return(-5); - } - memset(prev_fsData, 0, numBytes); - - /* fill in the host names */ - tmp_fsData1 = curr_fsData; - tmp_fsData2 = curr_fsData; - tmp_fsNames = FSnameList; - for(i=0; ihostName, tmp_fsNames->hostName, HOST_NAME_LEN); - strncpy(tmp_fsData2->hostName, tmp_fsNames->hostName, HOST_NAME_LEN); - tmp_fsData1++; - tmp_fsData2++; - tmp_fsNames = tmp_fsNames->next;; - } - - } /* if file servers to monitor */ - - /* allocate numCM blocks of the CM print structure */ - /* we need two instances of this structure for the same reasons as above*/ - - if (numCM) { - numBytes = numCM * sizeof(struct cm_Display_Data); - - curr_cmData = (struct cm_Display_Data *) malloc(numBytes); - if (curr_cmData == (struct cm_Display_Data *)0) { - fprintf(stderr,"[ %s ] Memory allocation failure\n",rn); - return(-10); - } - memset(curr_cmData, 0, numBytes); - - numBytes = numCM * sizeof(struct cm_Display_Data); - prev_cmData = (struct cm_Display_Data *) malloc(numBytes); - if (prev_cmData == (struct cm_Display_Data *)0) { - fprintf(stderr,"[ %s ] Memory allocation failure\n",rn); - return(-15); - } - memset(prev_cmData, 0, numBytes); - - /* fill in the host names */ - tmp_cmData1 = curr_cmData; - tmp_cmData2 = curr_cmData; - tmp_cmNames = CMnameList; - for(i=0; ihostName, tmp_cmNames->hostName, HOST_NAME_LEN); - strncpy(tmp_cmData2->hostName, tmp_cmNames->hostName, HOST_NAME_LEN); - tmp_cmData1++; - tmp_cmData2++; - tmp_cmNames = tmp_cmNames->next;; - } - - } /* if cache managers to monitor */ - - return(0); - -} /* init_print_buffers */ + } + + /* allocate numFS blocks of the FS print structure. */ + + /* we need two instances of this structure - one (curr_fsData) for storing + * the results of the fs probes currently in progress and another (prev_fsData) + * for the last completed probe. The display is updated from the contents of + * prev_fsData. The pointers curr_fsData & prev_fsData are switched whenever + * the probe number changes */ + + if (numFS) { + numBytes = numFS * sizeof(struct fs_Display_Data); + curr_fsData = (struct fs_Display_Data *)malloc(numBytes); + if (curr_fsData == (struct fs_Display_Data *)0) { + fprintf(stderr, "[ %s ] Memory allocation failure\n", rn); + return (-1); + } + memset(curr_fsData, 0, numBytes); + + numBytes = numFS * sizeof(struct fs_Display_Data); + prev_fsData = (struct fs_Display_Data *)malloc(numBytes); + if (prev_fsData == (struct fs_Display_Data *)0) { + fprintf(stderr, "[ %s ] Memory allocation failure\n", rn); + return (-5); + } + memset(prev_fsData, 0, numBytes); + + /* fill in the host names */ + tmp_fsData1 = curr_fsData; + tmp_fsData2 = curr_fsData; + tmp_fsNames = FSnameList; + for (i = 0; i < numFS; i++) { + strncpy(tmp_fsData1->hostName, tmp_fsNames->hostName, + HOST_NAME_LEN); + strncpy(tmp_fsData2->hostName, tmp_fsNames->hostName, + HOST_NAME_LEN); + tmp_fsData1++; + tmp_fsData2++; + tmp_fsNames = tmp_fsNames->next;; + } + + } + + + + /* if file servers to monitor */ + /* allocate numCM blocks of the CM print structure */ + /* we need two instances of this structure for the same reasons as above */ + if (numCM) { + numBytes = numCM * sizeof(struct cm_Display_Data); + + curr_cmData = (struct cm_Display_Data *)malloc(numBytes); + if (curr_cmData == (struct cm_Display_Data *)0) { + fprintf(stderr, "[ %s ] Memory allocation failure\n", rn); + return (-10); + } + memset(curr_cmData, 0, numBytes); + + numBytes = numCM * sizeof(struct cm_Display_Data); + prev_cmData = (struct cm_Display_Data *)malloc(numBytes); + if (prev_cmData == (struct cm_Display_Data *)0) { + fprintf(stderr, "[ %s ] Memory allocation failure\n", rn); + return (-15); + } + memset(prev_cmData, 0, numBytes); + + /* fill in the host names */ + tmp_cmData1 = curr_cmData; + tmp_cmData2 = curr_cmData; + tmp_cmNames = CMnameList; + for (i = 0; i < numCM; i++) { + strncpy(tmp_cmData1->hostName, tmp_cmNames->hostName, + HOST_NAME_LEN); + strncpy(tmp_cmData2->hostName, tmp_cmNames->hostName, + HOST_NAME_LEN); + tmp_cmData1++; + tmp_cmData2++; + tmp_cmNames = tmp_cmNames->next;; + } + + } + /* if cache managers to monitor */ + return (0); + +} /* init_print_buffers */ /*----------------------------------------------------------------------- * quit_signal() @@ -3411,13 +3602,13 @@ init_print_buffers() void quit_signal(sig) -int sig; -{ /* quit_signal */ - static char *rn = "quit_signal"; /* routine name */ + int sig; +{ /* quit_signal */ + static char *rn = "quit_signal"; /* routine name */ - fprintf(stderr,"Received signal %d \n",sig); - afsmon_Exit(120); -} /* quit_signal */ + fprintf(stderr, "Received signal %d \n", sig); + afsmon_Exit(120); +} /* quit_signal */ @@ -3439,219 +3630,231 @@ int sig; int afsmon_execute() -{ /* afsmon_execute() */ - static char rn[] = "afsmon_execute"; /* routine name */ - static char fullhostname[128]; /* full host name */ - struct sockaddr_in *FSSktArray; /* fs socket array */ - int FSsktbytes; /* num bytes in above */ - struct sockaddr_in *CMSktArray; /* cm socket array */ - int CMsktbytes; /* num bytes in above */ - struct sockaddr_in *curr_skt; /* ptr to current socket*/ - struct afsmon_hostEntry *curr_FS; /* ptr to FS name list */ - struct afsmon_hostEntry *curr_CM; /* ptr to CM name list */ - struct hostent *he; /* host entry */ - afs_int32 *collIDP; /* ptr to collection ID */ - int numCollIDs; /* number of collection IDs */ - int FSinitFlags = 0; /* flags for xstat_fs_Init */ - int CMinitFlags = 0; /* flags for xstat_cm_Init */ - int code; /* function return code */ - struct timeval tv; /* time structure */ - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n",rn); +{ /* afsmon_execute() */ + static char rn[] = "afsmon_execute"; /* routine name */ + static char fullhostname[128]; /* full host name */ + struct sockaddr_in *FSSktArray; /* fs socket array */ + int FSsktbytes; /* num bytes in above */ + struct sockaddr_in *CMSktArray; /* cm socket array */ + int CMsktbytes; /* num bytes in above */ + struct sockaddr_in *curr_skt; /* ptr to current socket */ + struct afsmon_hostEntry *curr_FS; /* ptr to FS name list */ + struct afsmon_hostEntry *curr_CM; /* ptr to CM name list */ + struct hostent *he; /* host entry */ + afs_int32 *collIDP; /* ptr to collection ID */ + int numCollIDs; /* number of collection IDs */ + int FSinitFlags = 0; /* flags for xstat_fs_Init */ + int CMinitFlags = 0; /* flags for xstat_cm_Init */ + int code; /* function return code */ + struct timeval tv; /* time structure */ + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called\n", rn); fflush(debugFD); - } - - - /* process file server entries */ - if (numFS) { - /* Allocate an array of sockets for each fileserver we monitor */ - - FSsktbytes = numFS * sizeof(struct sockaddr_in); - FSSktArray = (struct sockaddr_in *) malloc(FSsktbytes); - if (FSSktArray == (struct sockaddr_in *)0) { - fprintf(stderr,"[ %s ] cannot malloc %d sockaddr_ins for fileservers\n", - rn,numFS); - return(-1); - } - - memset(FSSktArray, 0, FSsktbytes); - - /* Fill in the socket information for each fileserve */ - - curr_skt = FSSktArray; - curr_FS = FSnameList; /* FS name list header */ - while (curr_FS) { - strncpy(fullhostname,curr_FS->hostName,sizeof(fullhostname)); - he = GetHostByName(fullhostname); - if (he == NULL) { - fprintf(stderr,"[ %s ] Cannot get host info for %s\n",rn, fullhostname); - return(-1); - } - strncpy(curr_FS->hostName,he->h_name,HOST_NAME_LEN); /* complete name*/ - memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4); - curr_skt->sin_family = htons(AF_INET); /*Internet family*/ - curr_skt->sin_port = htons(7000); /*FileServer port*/ + } + + + /* process file server entries */ + if (numFS) { + /* Allocate an array of sockets for each fileserver we monitor */ + + FSsktbytes = numFS * sizeof(struct sockaddr_in); + FSSktArray = (struct sockaddr_in *)malloc(FSsktbytes); + if (FSSktArray == (struct sockaddr_in *)0) { + fprintf(stderr, + "[ %s ] cannot malloc %d sockaddr_ins for fileservers\n", + rn, numFS); + return (-1); + } + + memset(FSSktArray, 0, FSsktbytes); + + /* Fill in the socket information for each fileserve */ + + curr_skt = FSSktArray; + curr_FS = FSnameList; /* FS name list header */ + while (curr_FS) { + strncpy(fullhostname, curr_FS->hostName, sizeof(fullhostname)); + he = GetHostByName(fullhostname); + if (he == NULL) { + fprintf(stderr, "[ %s ] Cannot get host info for %s\n", rn, + fullhostname); + return (-1); + } + strncpy(curr_FS->hostName, he->h_name, HOST_NAME_LEN); /* complete name */ + memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4); + curr_skt->sin_family = htons(AF_INET); /*Internet family */ + curr_skt->sin_port = htons(7000); /*FileServer port */ #ifdef STRUCT_SOCKADDR_HAS_SA_LEN - curr_skt->sin_len = sizeof(struct sockaddr_in); + curr_skt->sin_len = sizeof(struct sockaddr_in); #endif - /* get the next dude */ - curr_skt++; - curr_FS = curr_FS->next; - } - - /* initialize collection IDs. We need only one entry since we collect - all the information from xstat */ - - numCollIDs = 1; - collIDP = (afs_int32 *) malloc (sizeof (afs_int32)); - if (collIDP == NULL) { - fprintf(stderr,"[ %s ] failed to allocate a measely afs_int32 word.Argh!\n", rn); - return(-1); - } - *collIDP = 2; /* USE A macro for this */ - - FSinitFlags = 0; - if (afsmon_onceOnly) /* option not provided at this time */ - FSinitFlags |= XSTAT_FS_INITFLAG_ONE_SHOT; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Calling xstat_fs_Init \n",rn); - fflush(debugFD); - } - - code = xstat_fs_Init(numFS, /*Num servers*/ - FSSktArray, /*File Server socket array*/ - afsmon_probefreq, /*probe frequency*/ - afsmon_FS_Handler, /*Handler routine*/ - FSinitFlags, /*Initialization flags*/ - numCollIDs, /*Number of collection IDs*/ - collIDP); /*Ptr to collection ID */ - - if (code) { - fprintf(stderr,"[ %s ] xstat_fs_init returned error\n",rn); - afsmon_Exit(125); - } - - } /* end of process fileserver entries */ - - /* process cache manager entries */ - - if (numCM) { - /* Allocate an array of sockets for each cache manager we monitor */ - - CMsktbytes = numCM * sizeof(struct sockaddr_in); - CMSktArray = (struct sockaddr_in *) malloc(CMsktbytes); - if (CMSktArray == (struct sockaddr_in *)0) { - fprintf(stderr,"[ %s ] cannot malloc %d sockaddr_ins for CM entries\n", - rn,numCM); - return(-1); - } - - memset(CMSktArray, 0, CMsktbytes); - - /* Fill in the socket information for each CM */ - - curr_skt = CMSktArray; - curr_CM = CMnameList; /* CM name list header */ - while (curr_CM) { - strncpy(fullhostname,curr_CM->hostName,sizeof(fullhostname)); - he = GetHostByName(fullhostname); - if (he == NULL) { - fprintf(stderr,"[ %s ] Cannot get host info for %s\n",rn, fullhostname); - return(-1); - } - strncpy(curr_CM->hostName,he->h_name,HOST_NAME_LEN); /* complete name*/ - memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4); - curr_skt->sin_family = htons(AF_INET); /*Internet family*/ - curr_skt->sin_port = htons(7001); /*Cache Manager port*/ + /* get the next dude */ + curr_skt++; + curr_FS = curr_FS->next; + } + + /* initialize collection IDs. We need only one entry since we collect + * all the information from xstat */ + + numCollIDs = 1; + collIDP = (afs_int32 *) malloc(sizeof(afs_int32)); + if (collIDP == NULL) { + fprintf(stderr, + "[ %s ] failed to allocate a measely afs_int32 word.Argh!\n", + rn); + return (-1); + } + *collIDP = 2; /* USE A macro for this */ + + FSinitFlags = 0; + if (afsmon_onceOnly) /* option not provided at this time */ + FSinitFlags |= XSTAT_FS_INITFLAG_ONE_SHOT; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Calling xstat_fs_Init \n", rn); + fflush(debugFD); + } + + code = xstat_fs_Init(numFS, /*Num servers */ + FSSktArray, /*File Server socket array */ + afsmon_probefreq, /*probe frequency */ + afsmon_FS_Handler, /*Handler routine */ + FSinitFlags, /*Initialization flags */ + numCollIDs, /*Number of collection IDs */ + collIDP); /*Ptr to collection ID */ + + if (code) { + fprintf(stderr, "[ %s ] xstat_fs_init returned error\n", rn); + afsmon_Exit(125); + } + + } + + + /* end of process fileserver entries */ + /* process cache manager entries */ + if (numCM) { + /* Allocate an array of sockets for each cache manager we monitor */ + + CMsktbytes = numCM * sizeof(struct sockaddr_in); + CMSktArray = (struct sockaddr_in *)malloc(CMsktbytes); + if (CMSktArray == (struct sockaddr_in *)0) { + fprintf(stderr, + "[ %s ] cannot malloc %d sockaddr_ins for CM entries\n", + rn, numCM); + return (-1); + } + + memset(CMSktArray, 0, CMsktbytes); + + /* Fill in the socket information for each CM */ + + curr_skt = CMSktArray; + curr_CM = CMnameList; /* CM name list header */ + while (curr_CM) { + strncpy(fullhostname, curr_CM->hostName, sizeof(fullhostname)); + he = GetHostByName(fullhostname); + if (he == NULL) { + fprintf(stderr, "[ %s ] Cannot get host info for %s\n", rn, + fullhostname); + return (-1); + } + strncpy(curr_CM->hostName, he->h_name, HOST_NAME_LEN); /* complete name */ + memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4); + curr_skt->sin_family = htons(AF_INET); /*Internet family */ + curr_skt->sin_port = htons(7001); /*Cache Manager port */ #ifdef STRUCT_SOCKADDR_HAS_SA_LEN - curr_skt->sin_len = sizeof(struct sockaddr_in); + curr_skt->sin_len = sizeof(struct sockaddr_in); #endif - /* get the next dude */ - curr_skt++; - curr_CM = curr_CM->next; - } - - /* initialize collection IDs. We need only one entry since we collect - all the information from xstat */ - - numCollIDs = 1; - collIDP = (afs_int32 *) malloc (sizeof (afs_int32)); - if (collIDP == NULL) { - fprintf(stderr,"[ %s ] failed to allocate a measely long word.Argh!\n", rn); - return(-1); - } - *collIDP = 2; /* USE A macro for this */ - - CMinitFlags = 0; - if (afsmon_onceOnly) /* once only ? */ - CMinitFlags |= XSTAT_CM_INITFLAG_ONE_SHOT; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Calling xstat_cm_Init \n",rn); - fflush(debugFD); - } + /* get the next dude */ + curr_skt++; + curr_CM = curr_CM->next; + } - code = xstat_cm_Init(numCM, /*Num servers*/ - CMSktArray, /*Cache Manager socket array*/ - afsmon_probefreq, /*probe frequency*/ - afsmon_CM_Handler, /*Handler routine*/ - CMinitFlags, /*Initialization flags*/ - numCollIDs, /*Number of collection IDs*/ - collIDP); /*Ptr to collection ID */ + /* initialize collection IDs. We need only one entry since we collect + * all the information from xstat */ + + numCollIDs = 1; + collIDP = (afs_int32 *) malloc(sizeof(afs_int32)); + if (collIDP == NULL) { + fprintf(stderr, + "[ %s ] failed to allocate a measely long word.Argh!\n", + rn); + return (-1); + } + *collIDP = 2; /* USE A macro for this */ - if (code) { - fprintf(stderr,"[ %s ] xstat_cm_init returned error\n",rn); - afsmon_Exit(130); - } - } /* end of process cache manager entries */ + CMinitFlags = 0; + if (afsmon_onceOnly) /* once only ? */ + CMinitFlags |= XSTAT_CM_INITFLAG_ONE_SHOT; + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Calling xstat_cm_Init \n", rn); + fflush(debugFD); + } - /* if only one probe was required setup a waiting process for the - termination signal */ + code = xstat_cm_Init(numCM, /*Num servers */ + CMSktArray, /*Cache Manager socket array */ + afsmon_probefreq, /*probe frequency */ + afsmon_CM_Handler, /*Handler routine */ + CMinitFlags, /*Initialization flags */ + numCollIDs, /*Number of collection IDs */ + collIDP); /*Ptr to collection ID */ - if (afsmon_onceOnly) { + if (code) { + fprintf(stderr, "[ %s ] xstat_cm_init returned error\n", rn); + afsmon_Exit(130); + } + } + + + + /* end of process cache manager entries */ + /* if only one probe was required setup a waiting process for the + * termination signal */ + if (afsmon_onceOnly) { code = LWP_WaitProcess(&terminationEvent); if (code) { - if (afsmon_debug) { - fprintf(debugFD,"LWP_WaitProcess() returned error %d\n",code); + if (afsmon_debug) { + fprintf(debugFD, "LWP_WaitProcess() returned error %d\n", + code); fflush(debugFD); - } - afsmon_Exit(135); + } + afsmon_Exit(135); } - } + } - /* start the gtx input server */ - code = gtx_InputServer(afsmon_win); - if (code) { - fprintf(stderr,"[ %s ] Failed to start input server \n",rn); + /* start the gtx input server */ + code = gtx_InputServer(afsmon_win); + if (code) { + fprintf(stderr, "[ %s ] Failed to start input server \n", rn); afsmon_Exit(140); - } - - /* This part of the code is reached only if the input server is not started - for debugging purposes */ - - /* sleep forever */ - tv.tv_sec = 24*60; - tv.tv_usec = 0; - fprintf(stderr,"[ %s ] going to sleep ...\n",rn); - while(1) { - code = IOMGR_Select( 0, /*Num fds*/ - 0, /*Descriptors ready for reading*/ - 0, /*Descriptors ready for writing*/ - 0, /*Descriptors with exceptional conditions*/ - &tv); /*Timeout structure*/ - if (code) { - fprintf(stderr,"[ %s ] IOMGR_Select() returned non-zero value %d\n", - rn,code); - afsmon_Exit(145); - } - } /* while sleep */ + } + + /* This part of the code is reached only if the input server is not started + * for debugging purposes */ + + /* sleep forever */ + tv.tv_sec = 24 * 60; + tv.tv_usec = 0; + fprintf(stderr, "[ %s ] going to sleep ...\n", rn); + while (1) { + code = IOMGR_Select(0, /*Num fds */ + 0, /*Descriptors ready for reading */ + 0, /*Descriptors ready for writing */ + 0, /*Descriptors with exceptional conditions */ + &tv); /*Timeout structure */ + if (code) { + fprintf(stderr, + "[ %s ] IOMGR_Select() returned non-zero value %d\n", rn, + code); + afsmon_Exit(145); + } + } /* while sleep */ } - + /*----------------------------------------------------------------------- * afsmonInit() @@ -3671,266 +3874,276 @@ afsmon_execute() * Failure: Exits afsmonitor. *----------------------------------------------------------------------*/ -int -afsmonInit(as) -struct cmd_syndesc *as; -{ /* afsmonInit() */ - - static char rn[] = "afsmonInit"; /* Routine name */ - char *debug_filename; /* pointer to debug filename */ - FILE *outputFD; /* output file descriptor */ - struct cmd_item *hostPtr; /* ptr to parse command line args */ - char buf[256]; /* buffer for processing hostnames */ - int code; - int i; - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called, as= %d\n",rn, as); +int +afsmonInit(as) + struct cmd_syndesc *as; +{ /* afsmonInit() */ + + static char rn[] = "afsmonInit"; /* Routine name */ + char *debug_filename; /* pointer to debug filename */ + FILE *outputFD; /* output file descriptor */ + struct cmd_item *hostPtr; /* ptr to parse command line args */ + char buf[256]; /* buffer for processing hostnames */ + int code; + int i; + + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called, as= %d\n", rn, as); fflush(debugFD); - } + } - /* Open the debug file if -debug option is specified */ - if (as->parms[P_DEBUG].items != 0) { + /* Open the debug file if -debug option is specified */ + if (as->parms[P_DEBUG].items != 0) { afsmon_debug = 1; debug_filename = as->parms[P_DEBUG].items->data; - debugFD = fopen(debug_filename, "w"); - if (debugFD == (FILE *)0) { - printf("[ %s ] Failed to open debugging file %s for writing\n", - rn,"log"); - afsmon_debug = 0; - afsmon_Exit(150); - } - } - - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Called\n", rn); - } - - - /* use curses always until we support other packages */ -#ifdef notdef - wpkg_to_use = atoi(as->parms[P_PACKAGE].items->data); + debugFD = fopen(debug_filename, "w"); + if (debugFD == (FILE *) 0) { + printf("[ %s ] Failed to open debugging file %s for writing\n", + rn, "log"); + afsmon_debug = 0; + afsmon_Exit(150); + } + } - switch (wpkg_to_use) { - case GATOR_WIN_CURSES: - fprintf(stderr, "curses\n"); - break; - case GATOR_WIN_DUMB: - fprintf(stderr, "dumb terminal\n"); - break; - case GATOR_WIN_X11: - fprintf(stderr, "X11\n"); - break; - default: - fprintf(stderr, "Illegal graphics package: %d\n", wpkg_to_use); - afsmon_Exit(155); - } /*end switch (wpkg_to_use)*/ + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Called\n", rn); + } + + + /* use curses always until we support other packages */ +#ifdef notdef + wpkg_to_use = atoi(as->parms[P_PACKAGE].items->data); + + switch (wpkg_to_use) { + case GATOR_WIN_CURSES: + fprintf(stderr, "curses\n"); + break; + case GATOR_WIN_DUMB: + fprintf(stderr, "dumb terminal\n"); + break; + case GATOR_WIN_X11: + fprintf(stderr, "X11\n"); + break; + default: + fprintf(stderr, "Illegal graphics package: %d\n", wpkg_to_use); + afsmon_Exit(155); + } /*end switch (wpkg_to_use) */ #endif - wpkg_to_use = GATOR_WIN_CURSES; - - /* get probe frequency . We check for meaningful bounds on the frequency - and reset to the default value if needed. The upper bound of 24 - hours looks ridiculous though! */ + wpkg_to_use = GATOR_WIN_CURSES; + + /* get probe frequency . We check for meaningful bounds on the frequency + * and reset to the default value if needed. The upper bound of 24 + * hours looks ridiculous though! */ - afsmon_probefreq = 0; - if (as->parms[P_FREQUENCY].items != 0) + afsmon_probefreq = 0; + if (as->parms[P_FREQUENCY].items != 0) afsmon_probefreq = atoi(as->parms[P_FREQUENCY].items->data); - else + else afsmon_probefreq = DEFAULT_FREQUENCY; - if (afsmon_probefreq <= 0 || afsmon_probefreq > 24*60*60) { + if (afsmon_probefreq <= 0 || afsmon_probefreq > 24 * 60 * 60) { afsmon_probefreq = DEFAULT_FREQUENCY; if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Invalid probe frequency %s specified, resetting to default value %d seconds\n", - rn, as->parms[P_FREQUENCY].items->data, afsmon_probefreq); - fflush(debugFD); + fprintf(debugFD, + "[ %s ] Invalid probe frequency %s specified, resetting to default value %d seconds\n", + rn, as->parms[P_FREQUENCY].items->data, afsmon_probefreq); + fflush(debugFD); } - fprintf(stderr,"Invalid probe frequency %s specified, resetting to default value %d seconds\n", + fprintf(stderr, + "Invalid probe frequency %s specified, resetting to default value %d seconds\n", as->parms[P_FREQUENCY].items->data, afsmon_probefreq); sleep(3); - } + } - /* make sure output file is writable, else complain now */ - /* we will open and close it as needed after probes */ + /* make sure output file is writable, else complain now */ + /* we will open and close it as needed after probes */ - if (as->parms[P_OUTPUT].items != 0) { + if (as->parms[P_OUTPUT].items != 0) { afsmon_output = 1; /* output flag */ - strncpy (output_filename, as->parms[P_OUTPUT].items->data,80); - outputFD = fopen(output_filename,"a"); - if (outputFD == (FILE *)0) { - fprintf(stderr,"Failed to open output file %s \n", - output_filename); - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] Failed to open output file %s \n", + strncpy(output_filename, as->parms[P_OUTPUT].items->data, 80); + outputFD = fopen(output_filename, "a"); + if (outputFD == (FILE *) 0) { + fprintf(stderr, "Failed to open output file %s \n", + output_filename); + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] Failed to open output file %s \n", rn, output_filename); afsmon_Exit(160); - } + } + } + if (afsmon_debug) { + fprintf(debugFD, "[ %s ] output file is %s\n", rn, + output_filename); } - if (afsmon_debug) { - fprintf(debugFD,"[ %s ] output file is %s\n",rn,output_filename); - } - fclose (outputFD); - } + fclose(outputFD); + } - /* detailed statistics to storage file */ - if (as->parms[P_DETAILED].items !=0) { + /* detailed statistics to storage file */ + if (as->parms[P_DETAILED].items != 0) { if (as->parms[P_OUTPUT].items == 0) { - fprintf(stderr,"-detailed switch can be used only with -output\n"); + fprintf(stderr, + "-detailed switch can be used only with -output\n"); afsmon_Exit(165); } afsmon_detOutput = 1; - } + } - /* Initialize host list headers */ - FSnameList = (struct afsmon_hostEntry *)0; - CMnameList = (struct afsmon_hostEntry *)0; + /* Initialize host list headers */ + FSnameList = (struct afsmon_hostEntry *)0; + CMnameList = (struct afsmon_hostEntry *)0; - /* The -config option is mutually exclusive with the -fshosts,-cmhosts - options */ + /* The -config option is mutually exclusive with the -fshosts,-cmhosts + * options */ - if (as->parms[P_CONFIG].items) { + if (as->parms[P_CONFIG].items) { if (as->parms[P_FSHOSTS].items || as->parms[P_CMHOSTS].items) { - fprintf(stderr,"Cannot use -config option with -fshosts or -cmhosts\n"); - afsmon_Exit(170); + fprintf(stderr, + "Cannot use -config option with -fshosts or -cmhosts\n"); + afsmon_Exit(170); } - } else { - if (! as->parms[P_FSHOSTS].items && ! as->parms[P_CMHOSTS].items) { - fprintf(stderr,"Must specify either -config or (-fshosts and/or -cmhosts) options \n"); - afsmon_Exit(175); + } else { + if (!as->parms[P_FSHOSTS].items && !as->parms[P_CMHOSTS].items) { + fprintf(stderr, + "Must specify either -config or (-fshosts and/or -cmhosts) options \n"); + afsmon_Exit(175); } - } + } - /* If a file server host is specified on the command line we reuse - parse_hostEntry() function . Just the pass the info as if it were - read off the config file */ + /* If a file server host is specified on the command line we reuse + * parse_hostEntry() function . Just the pass the info as if it were + * read off the config file */ - if (as->parms[P_FSHOSTS].items) { + if (as->parms[P_FSHOSTS].items) { hostPtr = as->parms[P_FSHOSTS].items; - while( hostPtr != (struct cmd_item *)0) { - sprintf(buf,"fs %s",hostPtr->data); - code = parse_hostEntry(buf); - if (code) { - fprintf(stderr,"Could not parse %s\n",hostPtr->data); + while (hostPtr != (struct cmd_item *)0) { + sprintf(buf, "fs %s", hostPtr->data); + code = parse_hostEntry(buf); + if (code) { + fprintf(stderr, "Could not parse %s\n", hostPtr->data); afsmon_Exit(180); - } + } - hostPtr = hostPtr->next; + hostPtr = hostPtr->next; } - } + } - /* same as above for -cmhosts */ - if (as->parms[P_CMHOSTS].items) { + /* same as above for -cmhosts */ + if (as->parms[P_CMHOSTS].items) { hostPtr = as->parms[P_CMHOSTS].items; - while( hostPtr != (struct cmd_item *)0) { - sprintf(buf,"cm %s",hostPtr->data); - code = parse_hostEntry(buf); - if (code) { - fprintf(stderr,"Could not parse %s\n",hostPtr->data); + while (hostPtr != (struct cmd_item *)0) { + sprintf(buf, "cm %s", hostPtr->data); + code = parse_hostEntry(buf); + if (code) { + fprintf(stderr, "Could not parse %s\n", hostPtr->data); afsmon_Exit(185); - } + } - hostPtr = hostPtr->next; + hostPtr = hostPtr->next; } - } + } - /* number of slots in circular buffers */ - if (as->parms[P_BUFFERS].items) + /* number of slots in circular buffers */ + if (as->parms[P_BUFFERS].items) num_bufSlots = atoi(as->parms[P_BUFFERS].items->data); - else + else num_bufSlots = DEFAULT_BUFSLOTS; - /* Initialize xx_showFlags[]. This array is used solely for processing the - "show" directives in the config file in parse_showEntries() */ - for(i=0; iparms[P_CONFIG].items) - process_config_file(as->parms[P_CONFIG].items->data); + if (as->parms[P_CONFIG].items) + process_config_file(as->parms[P_CONFIG].items->data); - /* print out the FS and CM lists */ - print_FS(); print_CM(); + /* print out the FS and CM lists */ + print_FS(); + print_CM(); - /* Initialize the FS results-to-screen map array if there were no "show fs" - directives in the config file */ - if (fs_showDefault) { - for(i=0; i < NUM_FS_STAT_ENTRIES; i++) - fs_Display_map[i] = i; - fs_DisplayItems_count = NUM_FS_STAT_ENTRIES; - } + /* Initialize the FS results-to-screen map array if there were no "show fs" + * directives in the config file */ + if (fs_showDefault) { + for (i = 0; i < NUM_FS_STAT_ENTRIES; i++) + fs_Display_map[i] = i; + fs_DisplayItems_count = NUM_FS_STAT_ENTRIES; + } - /* Initialize the CM results-to-screen map array if there were no "show cm" - directives in the config file */ - if (cm_showDefault) { - for(i=0; i < NUM_CM_STAT_ENTRIES; i++) - cm_Display_map[i] = i; - cm_DisplayItems_count = NUM_CM_STAT_ENTRIES; - } + /* Initialize the CM results-to-screen map array if there were no "show cm" + * directives in the config file */ + if (cm_showDefault) { + for (i = 0; i < NUM_CM_STAT_ENTRIES; i++) + cm_Display_map[i] = i; + cm_DisplayItems_count = NUM_CM_STAT_ENTRIES; + } - /* setup an interrupt signal handler; we ain't wanna leak core */ - /* this binding is useful only until gtx is initialized after which the - keyboard input server takes over. */ - if ( (signal(SIGINT,quit_signal)) == SIG_ERR ) { + /* setup an interrupt signal handler; we ain't wanna leak core */ + /* this binding is useful only until gtx is initialized after which the + * keyboard input server takes over. */ + if ((signal(SIGINT, quit_signal)) == SIG_ERR) { perror("signal() failed."); afsmon_Exit(190); - } + } - /* init error message buffers. these will be used to print error messages - once gtx is initialized and there is no access to stderr/stdout */ - errMsg[0] = '\0'; errMsg1[0] = '\0'; + /* init error message buffers. these will be used to print error messages + * once gtx is initialized and there is no access to stderr/stdout */ + errMsg[0] = '\0'; + errMsg1[0] = '\0'; - if (num_bufSlots) { + if (num_bufSlots) { - /* initialize fs and cm circular buffers before initiating probes */ - if (numFS) { - code = init_fs_buffers(); - if (code) { - fprintf(stderr,"[ %s ] init_fs_buffers returned %d\n",rn,code); + /* initialize fs and cm circular buffers before initiating probes */ + if (numFS) { + code = init_fs_buffers(); + if (code) { + fprintf(stderr, "[ %s ] init_fs_buffers returned %d\n", rn, + code); afsmon_Exit(195); - } - } + } + } - if (numCM) { - code = init_cm_buffers(); - if (code) { - fprintf(stderr,"[ %s ] init_cm_buffers returned %d\n",rn,code); + if (numCM) { + code = init_cm_buffers(); + if (code) { + fprintf(stderr, "[ %s ] init_cm_buffers returned %d\n", rn, + code); afsmon_Exit(200); - } - } - } - - /* allocate and initialize buffers for holding fs & cm results in ascii - format suitable for updating the screen */ - code = init_print_buffers(); - if (code) { - fprintf(stderr,"[ %s ] init_print_buffers returned %d\n",rn,code); + } + } + } + + /* allocate and initialize buffers for holding fs & cm results in ascii + * format suitable for updating the screen */ + code = init_print_buffers(); + if (code) { + fprintf(stderr, "[ %s ] init_print_buffers returned %d\n", rn, code); afsmon_Exit(205); - } - - /* perform gtx initializations */ - code = gtx_initialize(); - if (code) { - fprintf(stderr,"[ %s ] gtx_initialize returned %d\n",rn,code); + } + + /* perform gtx initializations */ + code = gtx_initialize(); + if (code) { + fprintf(stderr, "[ %s ] gtx_initialize returned %d\n", rn, code); afsmon_Exit(210); - } + } - /* start xstat probes */ - afsmon_execute(); + /* start xstat probes */ + afsmon_execute(); - return(0); /* will not return from the call to afsmon_execute() */ + return (0); /* will not return from the call to afsmon_execute() */ -} /* afsmonInit() */ +} /* afsmonInit() */ /*----------------------------------------------------------------------- @@ -3939,14 +4152,15 @@ struct cmd_syndesc *as; #include "AFS_component_version_number.c" -int main(argc, argv) -int argc; -char **argv; -{ /* main() */ +int +main(argc, argv) + int argc; + char **argv; +{ /* main() */ - static char rn[] = "main"; /* routine name */ - afs_int32 code; /*Return code*/ - struct cmd_syndesc *ts; /*Ptr to cmd line syntax descriptor*/ + static char rn[] = "main"; /* routine name */ + afs_int32 code; /*Return code */ + struct cmd_syndesc *ts; /*Ptr to cmd line syntax descriptor */ #ifdef AFS_AIX32_ENV /* @@ -3966,28 +4180,26 @@ char **argv; /* * Set up the commands we understand. */ - ts = cmd_CreateSyntax("initcmd", afsmonInit, 0, - "initialize the program"); - cmd_AddParm(ts, "-config", CMD_SINGLE, CMD_OPTIONAL, + ts = cmd_CreateSyntax("initcmd", afsmonInit, 0, "initialize the program"); + cmd_AddParm(ts, "-config", CMD_SINGLE, CMD_OPTIONAL, "configuration file"); - cmd_AddParm(ts, "-frequency", CMD_SINGLE, CMD_OPTIONAL, + cmd_AddParm(ts, "-frequency", CMD_SINGLE, CMD_OPTIONAL, "poll frequency, in seconds"); - cmd_AddParm(ts, "-output", CMD_SINGLE, CMD_OPTIONAL, - "storage file name"); - cmd_AddParm(ts, "-detailed", CMD_FLAG, CMD_OPTIONAL, + cmd_AddParm(ts, "-output", CMD_SINGLE, CMD_OPTIONAL, "storage file name"); + cmd_AddParm(ts, "-detailed", CMD_FLAG, CMD_OPTIONAL, "output detailed statistics to storage file"); #ifdef notdef - /* we hope to use this .... eventually! */ - cmd_AddParm(ts,"-package", CMD_SINGLE, CMD_REQUIRED, + /* we hope to use this .... eventually! */ + cmd_AddParm(ts, "-package", CMD_SINGLE, CMD_REQUIRED, "Graphics Package to use"); #endif - cmd_AddParm(ts, "-debug", CMD_SINGLE, CMD_OPTIONAL, + cmd_AddParm(ts, "-debug", CMD_SINGLE, CMD_OPTIONAL, "turn debugging output on to the named file"); - cmd_AddParm(ts, "-fshosts", CMD_LIST, CMD_OPTIONAL, + cmd_AddParm(ts, "-fshosts", CMD_LIST, CMD_OPTIONAL, "list of file servers to monitor"); - cmd_AddParm(ts, "-cmhosts", CMD_LIST, CMD_OPTIONAL, + cmd_AddParm(ts, "-cmhosts", CMD_LIST, CMD_OPTIONAL, "list of cache managers to monitor"); - cmd_AddParm(ts,"-buffers", CMD_SINGLE, CMD_OPTIONAL, + cmd_AddParm(ts, "-buffers", CMD_SINGLE, CMD_OPTIONAL, "number of buffer slots"); /* @@ -3995,11 +4207,10 @@ char **argv; */ code = cmd_Dispatch(argc, argv); - if (code) - afsmon_Exit(1); + if (code) + afsmon_Exit(1); else - afsmon_Exit(2); - - exit(0); /* redundant, but gets rid of warning */ -} /*main*/ + afsmon_Exit(2); + exit(0); /* redundant, but gets rid of warning */ +} /*main */ diff --git a/src/afsmonitor/afsmonitor.h b/src/afsmonitor/afsmonitor.h index 2a78c68e5..3561432d8 100644 --- a/src/afsmonitor/afsmonitor.h +++ b/src/afsmonitor/afsmonitor.h @@ -12,9 +12,9 @@ #define HOST_NAME_LEN 80 /* length of server/cm names */ -#define XSTAT_FS_FULLPERF_RESULTS_LEN 424 /* value of xstat_fs_Results.data.AFS_COllData_len. We use this value before making any xstat calls and hence need this definition. Remember to change this value appropriately if the size of any of the fs related data structures change. Need to find a better way of doing this */ +#define XSTAT_FS_FULLPERF_RESULTS_LEN 424 /* value of xstat_fs_Results.data.AFS_COllData_len. We use this value before making any xstat calls and hence need this definition. Remember to change this value appropriately if the size of any of the fs related data structures change. Need to find a better way of doing this */ -#define XSTAT_CM_FULLPERF_RESULTS_LEN 740 /* value of xstat_cm_Results.data.AFS_COllData_len. We use this value before making any xstat calls and hence need this definition. Remember to change this value appropriately if the size of any of the cm related data structures change. Need to find a better way of doing this */ +#define XSTAT_CM_FULLPERF_RESULTS_LEN 740 /* value of xstat_cm_Results.data.AFS_COllData_len. We use this value before making any xstat calls and hence need this definition. Remember to change this value appropriately if the size of any of the cm related data structures change. Need to find a better way of doing this */ /* THRESHOLD STRUCTURE DEFINITIONS */ @@ -23,47 +23,47 @@ /* structure of each threshold item */ struct Threshold { - char itemName[THRESH_VAR_NAME_LEN]; /* field name */ - int index; /* positional index */ - char threshVal[THRESH_VAR_LEN]; /* user provided threshold value */ - char handler[256]; /* user provided ovf handler */ + char itemName[THRESH_VAR_NAME_LEN]; /* field name */ + int index; /* positional index */ + char threshVal[THRESH_VAR_LEN]; /* user provided threshold value */ + char handler[256]; /* user provided ovf handler */ }; /* structures to store info of hosts to be monitored */ struct afsmon_hostEntry { - char hostName[HOST_NAME_LEN]; /* fs or cm host name */ - int numThresh; /* number of thresholds for this host */ - struct Threshold *thresh; /* ptr to threshold entries */ - struct afsmon_hostEntry *next; + char hostName[HOST_NAME_LEN]; /* fs or cm host name */ + int numThresh; /* number of thresholds for this host */ + struct Threshold *thresh; /* ptr to threshold entries */ + struct afsmon_hostEntry *next; }; -#define NUM_FS_STAT_ENTRIES 271 /* number of file server statistics - entries to display */ -#define FS_STAT_STRING_LEN 14 /* max length of each string above */ -#define NUM_CM_STAT_ENTRIES 571 /* number of cache manager statistics - entries to display */ -#define CM_STAT_STRING_LEN 14 /* max length of each string above */ +#define NUM_FS_STAT_ENTRIES 271 /* number of file server statistics + * entries to display */ +#define FS_STAT_STRING_LEN 14 /* max length of each string above */ +#define NUM_CM_STAT_ENTRIES 571 /* number of cache manager statistics + * entries to display */ +#define CM_STAT_STRING_LEN 14 /* max length of each string above */ /* structures to store statistics in a format convenient to dump to the screen */ /* for file servers */ struct fs_Display_Data { - char hostName[HOST_NAME_LEN]; - int probeOK; /* 0 => probe failed */ - char data[ NUM_FS_STAT_ENTRIES ][ FS_STAT_STRING_LEN ]; - short threshOvf[ NUM_FS_STAT_ENTRIES ]; /* overflow flags */ - int ovfCount; /* overflow count */ + char hostName[HOST_NAME_LEN]; + int probeOK; /* 0 => probe failed */ + char data[NUM_FS_STAT_ENTRIES][FS_STAT_STRING_LEN]; + short threshOvf[NUM_FS_STAT_ENTRIES]; /* overflow flags */ + int ovfCount; /* overflow count */ }; /* for cache managers */ struct cm_Display_Data { - char hostName[HOST_NAME_LEN]; - int probeOK; /* 0 => probe failed */ - char data[ NUM_CM_STAT_ENTRIES ][ CM_STAT_STRING_LEN ]; - short threshOvf[ NUM_CM_STAT_ENTRIES ]; /* overflow flags */ - int ovfCount; /* overflow count */ + char hostName[HOST_NAME_LEN]; + int probeOK; /* 0 => probe failed */ + char data[NUM_CM_STAT_ENTRIES][CM_STAT_STRING_LEN]; + short threshOvf[NUM_CM_STAT_ENTRIES]; /* overflow flags */ + int ovfCount; /* overflow count */ }; /* GTX related definitions */ diff --git a/src/afsweb/apache_afs_cache.c b/src/afsweb/apache_afs_cache.c index 70fc42f30..7260bb45e 100644 --- a/src/afsweb/apache_afs_cache.c +++ b/src/afsweb/apache_afs_cache.c @@ -12,7 +12,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include "apache_afs_cache.h" @@ -48,15 +49,17 @@ static const sha_int hashinit[] = { #define ROTL(n, x) (((x) << (n)) | ((x) >> (SHA_BITS_PER_INT - (n)))) #ifdef DISABLED_CODE_HERE -static sha_int f(int t, sha_int x, sha_int y, sha_int z) +static sha_int +f(int t, sha_int x, sha_int y, sha_int z) { - if (t < 0 || t >= SHA_ROUNDS) return 0; + if (t < 0 || t >= SHA_ROUNDS) + return 0; if (t < 20) - return (z ^ (x & (y ^ z))); + return (z ^ (x & (y ^ z))); if (t < 40) - return (x ^ y ^ z); + return (x ^ y ^ z); if (t < 60) - return ((x & y) | (z & (x | y))); /* saves 1 boolean op */ + return ((x & y) | (z & (x | y))); /* saves 1 boolean op */ return (x ^ y ^ z); /* 60-79 same as 40-59 */ } #endif @@ -93,14 +96,16 @@ static sha_int f(int t, sha_int x, sha_int y, sha_int z) /* This macro/function supplies the "magic" constant for each round. */ /* The function call version preserved above until stable */ -static const sha_int k_vals[] = { 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6}; +static const sha_int k_vals[] = + { 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 }; #define K(t) ( (t < 0 || t >= SHA_ROUNDS) ? 0 : k_vals[ t/20 ] ) /* * Update the internal state based on the given chunk. */ -static void transform(shaState *shaStateP, sha_int *chunk) +static void +transform(shaState * shaStateP, sha_int * chunk) { sha_int A = shaStateP->digest[0]; sha_int B = shaStateP->digest[1]; @@ -115,13 +120,17 @@ static void transform(shaState *shaStateP, sha_int *chunk) for (t = 0; t < SHA_CHUNK_INTS; t++) W[t] = chunk[t]; for (; t < SHA_ROUNDS; t++) { - TEMP = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]; + TEMP = W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16]; W[t] = ROTL(1, TEMP); } for (t = 0; t < SHA_ROUNDS; t++) { TEMP = ROTL(5, A) + f(t, B, C, D) + E + W[t] + K(t); - E = D; D = C; C = ROTL(30, B); B = A; A = TEMP; + E = D; + D = C; + C = ROTL(30, B); + B = A; + A = TEMP; } shaStateP->digest[0] += A; @@ -137,7 +146,8 @@ static void transform(shaState *shaStateP, sha_int *chunk) * as input and produces an output array of ints that is * SHA_CHUNK_INTS long. */ -static void buildInts(const char *data, sha_int *chunk) +static void +buildInts(const char *data, sha_int * chunk) { /* * Need to copy the data because we can't be certain that @@ -159,7 +169,8 @@ static void buildInts(const char *data, sha_int *chunk) * buildInts to break the input up into chunks and repeatedly passing * these chunks to transform(). */ -void sha_update(shaState *shaStateP, const char *buffer, int bufferLen) +void +sha_update(shaState * shaStateP, const char *buffer, int bufferLen) { int i; sha_int chunk[SHA_CHUNK_INTS]; @@ -173,7 +184,7 @@ void sha_update(shaState *shaStateP, const char *buffer, int bufferLen) shaStateP->bitcountHi++; shaStateP->bitcountLo = newLo; shaStateP->bitcountHi += ((bufferLen >> (SHA_BITS_PER_INT - 3)) & 0x07); - + /* * If we won't have enough for a full chunk, just tack this * buffer onto the leftover piece and return. @@ -204,9 +215,9 @@ void sha_update(shaState *shaStateP, const char *buffer, int bufferLen) bufferLen -= SHA_CHUNK_BYTES; } /* assert((bufferLen >= 0) && (bufferLen < SHA_CHUNK_BYTES)); */ - if ((bufferLen < 0) || (bufferLen > SHA_CHUNK_BYTES) ) { - fprintf(stderr, "apache_afs_cache: ASSERTION FAILED...exiting\n"); - exit(-1); + if ((bufferLen < 0) || (bufferLen > SHA_CHUNK_BYTES)) { + fprintf(stderr, "apache_afs_cache: ASSERTION FAILED...exiting\n"); + exit(-1); } if (bufferLen > 0) { @@ -222,7 +233,8 @@ void sha_update(shaState *shaStateP, const char *buffer, int bufferLen) * of the hash bitcount to finish the hash. The hash value * is not valid until finish() has been called. */ -void sha_finish(shaState *shaStateP) +void +sha_finish(shaState * shaStateP) { sha_int chunk[SHA_CHUNK_INTS]; int i; @@ -253,11 +265,13 @@ void sha_finish(shaState *shaStateP) * SHS standard, and clear out the bitcount and leftover vars. * This should be used to initialize an shaState. */ -void sha_clear(shaState *shaStateP) +void +sha_clear(shaState * shaStateP) { big_endian = (0x01020304 == htonl(0x01020304)); - memcpy((void *)&shaStateP->digest[0], (void *)&hashinit[0], SHA_HASH_BYTES); + memcpy((void *)&shaStateP->digest[0], (void *)&hashinit[0], + SHA_HASH_BYTES); shaStateP->bitcountLo = shaStateP->bitcountHi = 0; shaStateP->leftoverLen = 0; } @@ -266,7 +280,8 @@ void sha_clear(shaState *shaStateP) /* * Hash the buffer and place the result in *shaStateP. */ -void sha_hash(shaState *shaStateP, const char *buffer, int bufferLen) +void +sha_hash(shaState * shaStateP, const char *buffer, int bufferLen) { sha_clear(shaStateP); sha_update(shaStateP, buffer, bufferLen); @@ -278,10 +293,11 @@ void sha_hash(shaState *shaStateP, const char *buffer, int bufferLen) * Returns the current state of the hash as an array of 20 bytes. * This will be an interim result if finish() has not yet been called. */ -void sha_bytes(const shaState *shaStateP, char *bytes) +void +sha_bytes(const shaState * shaStateP, char *bytes) { sha_int temp[SHA_HASH_INTS]; - int i; + int i; for (i = 0; i < SHA_HASH_INTS; i++) temp[i] = htonl(shaStateP->digest[i]); @@ -292,54 +308,53 @@ void sha_bytes(const shaState *shaStateP, char *bytes) /* * Hash function for the AFS login cache */ -int weblog_login_hash(char *name, char *cell) +int +weblog_login_hash(char *name, char *cell) { char *p; afs_uint32 val; - for (val = *name , p = name ; *p != '\0' ; p++) { - val = (val << 2) ^ val ^ (afs_uint32)(*p); + for (val = *name, p = name; *p != '\0'; p++) { + val = (val << 2) ^ val ^ (afs_uint32) (*p); } - for (p = cell ; *p != '\0' ; p++) { - val = (val << 2) ^ val ^ (afs_uint32)(*p); + for (p = cell; *p != '\0'; p++) { + val = (val << 2) ^ val ^ (afs_uint32) (*p); } - return val & (WEBLOG_LOGIN_HASH_SIZE-1); + return val & (WEBLOG_LOGIN_HASH_SIZE - 1); } /* * Compute a SHA checksum on the username, cellname, and password */ -void weblog_login_checksum( - char *user, - char *cell, - char *passwd, - char *cksum) +void +weblog_login_checksum(char *user, char *cell, char *passwd, char *cksum) { - int passwdLen; - int userLen; - int cellLen; - char *shaBuffer; - shaState state; - - /* - * Compute SHA(username,SHA(password,pad)) - */ - passwdLen = strlen(passwd); - userLen = strlen(user); - cellLen = strlen(cell); - shaBuffer = (char *) malloc(MAX(userLen+cellLen,passwdLen)+SHA_HASH_BYTES); - strcpy(shaBuffer, passwd); - memcpy((void *)(shaBuffer + passwdLen), (void *)(&weblog_login_pad[0]), - SHA_HASH_BYTES); - sha_clear(&state); - sha_hash(&state, shaBuffer, passwdLen+SHA_HASH_BYTES); - memcpy(shaBuffer, user, userLen); - memcpy(shaBuffer+userLen, cell, cellLen); - sha_bytes(&state, shaBuffer+userLen+cellLen); - sha_clear(&state); - sha_hash(&state, shaBuffer, userLen+cellLen+SHA_HASH_BYTES); - sha_bytes(&state, &cksum[0]); - memset(shaBuffer, 0, MAX(userLen+cellLen,passwdLen)+SHA_HASH_BYTES); - free(shaBuffer); + int passwdLen; + int userLen; + int cellLen; + char *shaBuffer; + shaState state; + + /* + * Compute SHA(username,SHA(password,pad)) + */ + passwdLen = strlen(passwd); + userLen = strlen(user); + cellLen = strlen(cell); + shaBuffer = + (char *)malloc(MAX(userLen + cellLen, passwdLen) + SHA_HASH_BYTES); + strcpy(shaBuffer, passwd); + memcpy((void *)(shaBuffer + passwdLen), (void *)(&weblog_login_pad[0]), + SHA_HASH_BYTES); + sha_clear(&state); + sha_hash(&state, shaBuffer, passwdLen + SHA_HASH_BYTES); + memcpy(shaBuffer, user, userLen); + memcpy(shaBuffer + userLen, cell, cellLen); + sha_bytes(&state, shaBuffer + userLen + cellLen); + sha_clear(&state); + sha_hash(&state, shaBuffer, userLen + cellLen + SHA_HASH_BYTES); + sha_bytes(&state, &cksum[0]); + memset(shaBuffer, 0, MAX(userLen + cellLen, passwdLen) + SHA_HASH_BYTES); + free(shaBuffer); } /* @@ -347,179 +362,175 @@ void weblog_login_checksum( * given username, and the SHA checksums match, then * set the token parameter and return 1, otherwise return 0. */ -int weblog_login_lookup( - char *user, - char *cell, - char *cksum, - char *token) +int +weblog_login_lookup(char *user, char *cell, char *cksum, char *token) { - int index; - long curTime; - struct weblog_login *loginP, *tmpP, loginTmp; - - /* - * Search the hash chain for a matching entry, free - * expired entries as we search - */ - index = weblog_login_hash(user, cell); - curTime = time(NULL); - - loginP = weblog_login_cache[index].head; - while (loginP != NULL) { - if (loginP->expiration < curTime) { - tmpP = loginP; - loginP = tmpP->next; - - DLL_DELETE(tmpP, weblog_login_cache[index].head, - weblog_login_cache[index].tail, next, prev); - free(tmpP); - continue; - } - if (strcmp(loginP->username, user) == 0 && - strcmp(loginP->cellname, cell) == 0 && - memcmp((void *)&loginP->cksum[0], (void *)cksum,SHA_HASH_BYTES) == 0) { - - memcpy((void *)token, (void *) &loginP->token[0], MAXBUFF); - return loginP->tokenLen; + int index; + long curTime; + struct weblog_login *loginP, *tmpP, loginTmp; + + /* + * Search the hash chain for a matching entry, free + * expired entries as we search + */ + index = weblog_login_hash(user, cell); + curTime = time(NULL); + + loginP = weblog_login_cache[index].head; + while (loginP != NULL) { + if (loginP->expiration < curTime) { + tmpP = loginP; + loginP = tmpP->next; + + DLL_DELETE(tmpP, weblog_login_cache[index].head, + weblog_login_cache[index].tail, next, prev); + free(tmpP); + continue; + } + if (strcmp(loginP->username, user) == 0 + && strcmp(loginP->cellname, cell) == 0 + && memcmp((void *)&loginP->cksum[0], (void *)cksum, + SHA_HASH_BYTES) == 0) { + + memcpy((void *)token, (void *)&loginP->token[0], MAXBUFF); + return loginP->tokenLen; + } + loginP = loginP->next; } - loginP = loginP->next; - } - return 0; + return 0; } /* * Insert a login token into the cache. If the user already has an entry, * then overwrite the old entry. */ -int weblog_login_store( - char *user, - char *cell, - char *cksum, - char *token, - int tokenLen, - afs_uint32 expiration) +int +weblog_login_store(char *user, char *cell, char *cksum, char *token, + int tokenLen, afs_uint32 expiration) { - int index; - long curTime; - struct weblog_login *loginP, *tmpP, loginTmp; - - int parseToken(char *tokenBuf); - - /* - * Search the hash chain for a matching entry, free - * expired entries as we search - */ - index = weblog_login_hash(user, cell); - curTime = time(NULL); - loginP = weblog_login_cache[index].head; - - while (loginP != NULL) { - if (strcmp(loginP->username, user) == 0 && - strcmp(loginP->cellname, cell) == 0) { - break; + int index; + long curTime; + struct weblog_login *loginP, *tmpP, loginTmp; + + int parseToken(char *tokenBuf); + + /* + * Search the hash chain for a matching entry, free + * expired entries as we search + */ + index = weblog_login_hash(user, cell); + curTime = time(NULL); + loginP = weblog_login_cache[index].head; + + while (loginP != NULL) { + if (strcmp(loginP->username, user) == 0 + && strcmp(loginP->cellname, cell) == 0) { + break; + } + if (loginP->expiration < curTime) { + tmpP = loginP; + loginP = tmpP->next; + + DLL_DELETE(tmpP, weblog_login_cache[index].head, + weblog_login_cache[index].tail, next, prev); + free(tmpP); + continue; + } + loginP = loginP->next; } - if (loginP->expiration < curTime) { - tmpP = loginP; - loginP = tmpP->next; - - DLL_DELETE(tmpP, weblog_login_cache[index].head, - weblog_login_cache[index].tail, next, prev); - free(tmpP); - continue; + if (loginP == NULL) { + loginP = (struct weblog_login *)malloc(sizeof(struct weblog_login)); + strcpy(&loginP->username[0], user); + strcpy(&loginP->cellname[0], cell); + } else { + DLL_DELETE(loginP, weblog_login_cache[index].head, + weblog_login_cache[index].tail, next, prev); } - loginP = loginP->next; - } - if (loginP == NULL) { - loginP = (struct weblog_login *)malloc(sizeof(struct weblog_login)); - strcpy(&loginP->username[0], user); - strcpy(&loginP->cellname[0], cell); - } - else { - DLL_DELETE(loginP, weblog_login_cache[index].head, - weblog_login_cache[index].tail, next, prev); - } - - memcpy((void *)&loginP->cksum[0], (void *)cksum, SHA_HASH_BYTES); - loginP->expiration = expiration; - loginP->tokenLen=getTokenLen(token); - memcpy((void *)&loginP->token[0], (void *)token, MAXBUFF); - - DLL_INSERT_TAIL(loginP, weblog_login_cache[index].head, - weblog_login_cache[index].tail, next, prev); - return 0; + + memcpy((void *)&loginP->cksum[0], (void *)cksum, SHA_HASH_BYTES); + loginP->expiration = expiration; + loginP->tokenLen = getTokenLen(token); + memcpy((void *)&loginP->token[0], (void *)token, MAXBUFF); + + DLL_INSERT_TAIL(loginP, weblog_login_cache[index].head, + weblog_login_cache[index].tail, next, prev); + return 0; } token_cache_init() { - int i; - for (i = 0 ; i < WEBLOG_LOGIN_HASH_SIZE ; i++) { - DLL_INIT_LIST(weblog_login_cache[i].head, - weblog_login_cache[i].tail); - } + int i; + for (i = 0; i < WEBLOG_LOGIN_HASH_SIZE; i++) { + DLL_INIT_LIST(weblog_login_cache[i].head, weblog_login_cache[i].tail); + } } -int getTokenLen(char *buf) +int +getTokenLen(char *buf) { - afs_int32 len=0; - afs_int32 rc=0; - char cellName[WEBLOG_CELLNAME_MAX]; - register char *tp; - int n = sizeof(afs_int32); - struct ClearToken { - afs_int32 AuthHandle; - char HandShakeKey[8]; - afs_int32 ViceId; - afs_int32 BeginTimestamp; - afs_int32 EndTimestamp; - } token; - tp=buf; - memcpy(&len, tp, sizeof(afs_int32)); /* get size of secret token */ - rc=(len+sizeof(afs_int32)); - tp += (sizeof(afs_int32) + len); /* skip secret token and its length */ - memcpy(&len, tp, sizeof(afs_int32)); /* get size of clear token */ - if (len != sizeof(struct ClearToken)) { + afs_int32 len = 0; + afs_int32 rc = 0; + char cellName[WEBLOG_CELLNAME_MAX]; + register char *tp; + int n = sizeof(afs_int32); + struct ClearToken { + afs_int32 AuthHandle; + char HandShakeKey[8]; + afs_int32 ViceId; + afs_int32 BeginTimestamp; + afs_int32 EndTimestamp; + } token; + tp = buf; + memcpy(&len, tp, sizeof(afs_int32)); /* get size of secret token */ + rc = (len + sizeof(afs_int32)); + tp += (sizeof(afs_int32) + len); /* skip secret token and its length */ + memcpy(&len, tp, sizeof(afs_int32)); /* get size of clear token */ + if (len != sizeof(struct ClearToken)) { #ifdef DEBUG - fprintf(stderr, "apache_afs_cache.c:getExpiration:" - "something's wrong with the length of ClearToken:%d\n", len); + fprintf(stderr, + "apache_afs_cache.c:getExpiration:" + "something's wrong with the length of ClearToken:%d\n", len); #endif - return -1; - } - rc+=(sizeof(afs_int32)+len); /* length of clear token + length itself */ - tp+=(sizeof(afs_int32)+len); /* skip clear token and its length */ - rc+=sizeof(afs_int32); /* length of primary flag */ - tp+=sizeof(afs_int32); /* skip over primary flag */ - strcpy(cellName, tp); - if (cellName != NULL) - rc+=strlen(cellName); - return rc; + return -1; + } + rc += (sizeof(afs_int32) + len); /* length of clear token + length itself */ + tp += (sizeof(afs_int32) + len); /* skip clear token and its length */ + rc += sizeof(afs_int32); /* length of primary flag */ + tp += sizeof(afs_int32); /* skip over primary flag */ + strcpy(cellName, tp); + if (cellName != NULL) + rc += strlen(cellName); + return rc; } -long getExpiration(char *buf) +long +getExpiration(char *buf) { - afs_int32 len=0; - register char *tp; - int n = sizeof(afs_int32); - struct ClearToken { - afs_int32 AuthHandle; - char HandShakeKey[8]; - afs_int32 ViceId; - afs_int32 BeginTimestamp; - afs_int32 EndTimestamp; - } token; - - tp = buf; - memcpy(&len, tp, sizeof(afs_int32)); /* get size of secret token */ - tp += (sizeof(afs_int32) + len); /* skip secret token and its length */ - memcpy(&len, tp, sizeof(afs_int32)); /* get size of clear token */ - if (len != sizeof(struct ClearToken)) { + afs_int32 len = 0; + register char *tp; + int n = sizeof(afs_int32); + struct ClearToken { + afs_int32 AuthHandle; + char HandShakeKey[8]; + afs_int32 ViceId; + afs_int32 BeginTimestamp; + afs_int32 EndTimestamp; + } token; + + tp = buf; + memcpy(&len, tp, sizeof(afs_int32)); /* get size of secret token */ + tp += (sizeof(afs_int32) + len); /* skip secret token and its length */ + memcpy(&len, tp, sizeof(afs_int32)); /* get size of clear token */ + if (len != sizeof(struct ClearToken)) { #ifdef DEBUG - fprintf(stderr, "apache_afs_cache.c:getExpiration:" - "something's wrong with the length of ClearToken:%d\n", len); + fprintf(stderr, + "apache_afs_cache.c:getExpiration:" + "something's wrong with the length of ClearToken:%d\n", len); #endif - return -1; - } - - tp += sizeof(afs_int32); /* skip length of clear token */ - memcpy(&token, tp, sizeof(struct ClearToken)); /* copy the token */ - return token.EndTimestamp; + return -1; + } + + tp += sizeof(afs_int32); /* skip length of clear token */ + memcpy(&token, tp, sizeof(struct ClearToken)); /* copy the token */ + return token.EndTimestamp; } diff --git a/src/afsweb/apache_afs_cache.h b/src/afsweb/apache_afs_cache.h index 307b5dfc3..824480ccb 100644 --- a/src/afsweb/apache_afs_cache.h +++ b/src/afsweb/apache_afs_cache.h @@ -68,11 +68,11 @@ #define WEBLOG_MAX_PATH 1024 /* Maximum path length */ #define WEBLOG_USERNAME_MAX 64 /* Maximum username length */ #define WEBLOG_CELLNAME_MAX 64 /* Maximum password length */ -#define WEBLOG_PASSWORD_MAX 64 +#define WEBLOG_PASSWORD_MAX 64 #define WEBLOG_LOGIN_HASH_SIZE 1024 /* MUST be power of two */ -#define TEN_MINUTES 600 /* 10 minutes = 600 seconds */ +#define TEN_MINUTES 600 /* 10 minutes = 600 seconds */ -#define MAXBUFF 1024 /* CHECK THIS - size of token */ +#define MAXBUFF 1024 /* CHECK THIS - size of token */ /* * Structure user to store entries in AFS login cache */ @@ -90,9 +90,13 @@ struct weblog_login { extern int weblog_login_hash(char *name, char *cell); -extern void weblog_login_checksum(char *user,char *cell,char *passwd,char *cksum); -extern int weblog_login_lookup(char *user,char *cell,char *cksum,char *token); -extern int weblog_login_store(char *user,char *cell,char *cksum,char *token,int tokenLen, afs_uint32 expiration); +extern void weblog_login_checksum(char *user, char *cell, char *passwd, + char *cksum); +extern int weblog_login_lookup(char *user, char *cell, char *cksum, + char *token); +extern int weblog_login_store(char *user, char *cell, char *cksum, + char *token, int tokenLen, + afs_uint32 expiration); extern int getTokenLen(char *token); #endif /* _APACHE_AFS_CACHE_H_INCLUDED_ */ diff --git a/src/afsweb/apache_afs_client.c b/src/afsweb/apache_afs_client.c index eda7e7c9f..8cc3e633d 100644 --- a/src/afsweb/apache_afs_client.c +++ b/src/afsweb/apache_afs_client.c @@ -22,13 +22,13 @@ #define afsassert(str) if(!(str)) { fprintf(stderr, "afs module: assertion failed:%s\t%d\n",__FILE__,__LINE__) ; return SERVER_ERROR; } -#define MAXBUFF 1024 +#define MAXBUFF 1024 #define APACHEAFS_MAX_PATH 1024 /* Maximum path length */ -#define APACHEAFS_USERNAME_MAX 64 /* Maximum username length */ -#define APACHEAFS_PASSWORD_MAX 64 /* Maximum password length */ -#define APACHEAFS_CELLNAME_MAX 64 /* Maximum cellname length */ -#define APACHEAFS_MOUNTPTLEN_MAX 64 /* Max mountpoint length */ +#define APACHEAFS_USERNAME_MAX 64 /* Maximum username length */ +#define APACHEAFS_PASSWORD_MAX 64 /* Maximum password length */ +#define APACHEAFS_CELLNAME_MAX 64 /* Maximum cellname length */ +#define APACHEAFS_MOUNTPTLEN_MAX 64 /* Max mountpoint length */ #ifndef MAX #define MAX(A,B) ((A)>(B)?(A):(B)) @@ -38,7 +38,7 @@ #endif /* !MAX */ /* */ -static int setCellAuthHeader(request_rec *r); +static int setCellAuthHeader(request_rec * r); /* Module name for logging stuff */ extern const char module_name[]; @@ -67,172 +67,177 @@ static char lastCell[APACHEAFS_CELLNAME_MAX]; static char lastCksum[SHA_HASH_BYTES]; /* do I have my own PAG */ -static int doneSETPAG=0; +static int doneSETPAG = 0; /* * Parse the authorization header for username and password */ -static int parse_authhdr(request_rec *r, - char *user, - char *passwd, - char *cell, - char *defaultCell) +static int +parse_authhdr(request_rec * r, char *user, char *passwd, char *cell, + char *defaultCell) { - int i; - char *p, *t; - const char *auth_line = TABLE_GET (r->headers_in, "Authorization"); - - if ((r == NULL) || (auth_line == NULL) || (user == NULL) || - (passwd == NULL) || (cell == NULL)) { - LOG_REASON ("AFSAUTH_CLIENT: NULL request record, auth_line, cell," - "user or passwd while parsing authentication header", - r->uri, r); - return SERVER_ERROR; - } - - user[0] = '\0'; - passwd[0] = '\0'; - cell[0] = '\0'; - - /* - * check for basic authentication - */ - if (strncasecmp(GETWORD(r->pool,(const char **)&auth_line,' '), - "basic",6) != 0) { - /* Client tried to authenticate using some other auth scheme */ - LOG_REASON ("AFSAUTH_CLIENT:client used other than Basic authentication" - "scheme", r->uri, r); - return SERVER_ERROR; - } - - /* - * Username and password are base64 encoded - */ - t = UUDECODE (r->pool, auth_line); - - if (t == NULL) { - LOG_REASON ("AFSAUTH_CLIENT:uudecode failed", r->uri, r); - return SERVER_ERROR; - } - - /* - * Format is user@cell:passwd. The user, cell or passwd may be missing - */ - r->connection->user = GETWORD_NULLS (r->pool, (const char **)&t, ':'); - r->connection->auth_type = "Basic"; - strcpy(passwd,t); - - p = r->connection->user; - - for ( i = 0 ; *p != '@' && *p != '\0' ; p++ , i++) { - user[i] = *p; - } - user[i] = '\0'; - if (*p == '@') { - for (i = 0 , p++ ; *p != '\0' ; p++ , i++) { - cell[i] = *p; - } - cell[i] = '\0'; - } - - if (cell[0] == '\0') { - strcpy(cell, defaultCell); - } - return OK; + int i; + char *p, *t; + const char *auth_line = TABLE_GET(r->headers_in, "Authorization"); + + if ((r == NULL) || (auth_line == NULL) || (user == NULL) + || (passwd == NULL) || (cell == NULL)) { + LOG_REASON("AFSAUTH_CLIENT: NULL request record, auth_line, cell," + "user or passwd while parsing authentication header", + r->uri, r); + return SERVER_ERROR; + } + + user[0] = '\0'; + passwd[0] = '\0'; + cell[0] = '\0'; + + /* + * check for basic authentication + */ + if (strncasecmp + (GETWORD(r->pool, (const char **)&auth_line, ' '), "basic", 6) != 0) { + /* Client tried to authenticate using some other auth scheme */ + LOG_REASON + ("AFSAUTH_CLIENT:client used other than Basic authentication" + "scheme", r->uri, r); + return SERVER_ERROR; + } + + /* + * Username and password are base64 encoded + */ + t = UUDECODE(r->pool, auth_line); + + if (t == NULL) { + LOG_REASON("AFSAUTH_CLIENT:uudecode failed", r->uri, r); + return SERVER_ERROR; + } + + /* + * Format is user@cell:passwd. The user, cell or passwd may be missing + */ + r->connection->user = GETWORD_NULLS(r->pool, (const char **)&t, ':'); + r->connection->auth_type = "Basic"; + strcpy(passwd, t); + + p = r->connection->user; + + for (i = 0; *p != '@' && *p != '\0'; p++, i++) { + user[i] = *p; + } + user[i] = '\0'; + if (*p == '@') { + for (i = 0, p++; *p != '\0'; p++, i++) { + cell[i] = *p; + } + cell[i] = '\0'; + } + + if (cell[0] == '\0') { + strcpy(cell, defaultCell); + } + return OK; } /* * send a buffer to the weblog process over the pipe. Used for sending * authentication credentials to weblog */ -static int sendBuffer(char *buf, int len) +static int +sendBuffer(char *buf, int len) { - afsassert(buf); - if (write(writePipe, buf, len) != len) { - afslog(5, ("%s: Error writing to pipe - %s", module_name, strerror(errno))); - return -1; - } - return 0; + afsassert(buf); + if (write(writePipe, buf, len) != len) { + afslog(5, + ("%s: Error writing to pipe - %s", module_name, + strerror(errno))); + return -1; + } + return 0; } /* * packs user credentials into a buffer seperated by newlines and * sends them to weblog */ -static int sendTo_afsAuthenticator(char *user, char *passwd, - char *cell, char *type) +static int +sendTo_afsAuthenticator(char *user, char *passwd, char *cell, char *type) { - char buf[MAXBUFF]; + char buf[MAXBUFF]; - afsassert(user); - afsassert(passwd); - afsassert(cell); - afsassert(type); + afsassert(user); + afsassert(passwd); + afsassert(cell); + afsassert(type); - sprintf(buf, "%s\n%s\n%s\n%s", type, user, cell, passwd); - return sendBuffer(buf, strlen(buf)); + sprintf(buf, "%s\n%s\n%s\n%s", type, user, cell, passwd); + return sendBuffer(buf, strlen(buf)); } /* * reads the response from weblog over the pipe */ -static int recvFrom_afsAuthenticator(char *buf) +static int +recvFrom_afsAuthenticator(char *buf) { - int n; - - afsassert(buf); - n = read(readPipe, buf, MAXBUFF); - if(n < 0) { - afslog(5, ("%s: Error reading from pipe - %s", module_name, strerror(errno))); - return -1; - } - return n; + int n; + + afsassert(buf); + n = read(readPipe, buf, MAXBUFF); + if (n < 0) { + afslog(5, + ("%s: Error reading from pipe - %s", module_name, + strerror(errno))); + return -1; + } + return n; } #ifndef NO_AFSAPACHE_CACHE /* * check local cache for the token associated with user crds. */ -static int check_Cache(char *user, char *passwd, char *cell, char *tokenBuf) +static int +check_Cache(char *user, char *passwd, char *cell, char *tokenBuf) { - char cksum[SHA_HASH_BYTES]; /* for sha checksum for caching */ + char cksum[SHA_HASH_BYTES]; /* for sha checksum for caching */ - /* look up local cache - function in apache_afs_cach.c */ - weblog_login_checksum(user, cell, passwd, cksum); - return weblog_login_lookup(user, cell, cksum, &tokenBuf[0]); + /* look up local cache - function in apache_afs_cach.c */ + weblog_login_checksum(user, cell, passwd, cksum); + return weblog_login_lookup(user, cell, cksum, &tokenBuf[0]); } /* * put the token and the user credentials in the local cache */ -static int updateCache(char *user, - char *passwd, - char *cell, - char *tokenBuf, - int cacheExpiration) +static int +updateCache(char *user, char *passwd, char *cell, char *tokenBuf, + int cacheExpiration) { - long expires = 0, testExpires = 0; - char cksum[SHA_HASH_BYTES]; /* for sha checksum for caching */ - - /* put the token in local cache with the expiration date */ - expires = getExpiration(tokenBuf); - if (expires < 0 ) { - afslog(5, ("%s: Error getting expiration time for cache. Expires %d", - module_name, expires)); - return -1; - } - - weblog_login_checksum(user, cell, passwd, cksum); - - if (cacheExpiration == 0) { - weblog_login_store(user, cell, cksum, &tokenBuf[0], sizeof(tokenBuf),expires); - } - else { - testExpires=cacheExpiration+time(NULL); - weblog_login_store(user, cell, cksum, &tokenBuf[0],sizeof(tokenBuf), - MIN(expires,testExpires)); - } - return 0; + long expires = 0, testExpires = 0; + char cksum[SHA_HASH_BYTES]; /* for sha checksum for caching */ + + /* put the token in local cache with the expiration date */ + expires = getExpiration(tokenBuf); + if (expires < 0) { + afslog(5, + ("%s: Error getting expiration time for cache. Expires %d", + module_name, expires)); + return -1; + } + + weblog_login_checksum(user, cell, passwd, cksum); + + if (cacheExpiration == 0) { + weblog_login_store(user, cell, cksum, &tokenBuf[0], sizeof(tokenBuf), + expires); + } else { + testExpires = cacheExpiration + time(NULL); + weblog_login_store(user, cell, cksum, &tokenBuf[0], sizeof(tokenBuf), + MIN(expires, testExpires)); + } + return 0; } #endif /* NO_APACHEAFS_CACHE */ @@ -240,31 +245,33 @@ static int updateCache(char *user, /* * locking routines to provide exclusive access to the pipes */ -static int start_lock(int fd, int cmd, int type) +static int +start_lock(int fd, int cmd, int type) { - struct flock lock; - lock.l_type=type; - lock.l_start = 0; - lock.l_whence = SEEK_SET; - lock.l_len = 0; - return (fcntl(fd, cmd, &lock)); + struct flock lock; + lock.l_type = type; + lock.l_start = 0; + lock.l_whence = SEEK_SET; + lock.l_len = 0; + return (fcntl(fd, cmd, &lock)); } -static int test_lock(int fd, int type) +static int +test_lock(int fd, int type) { - struct flock lock; - lock.l_type=type; - lock.l_start = 0; - lock.l_whence = SEEK_SET; - lock.l_len = 0; - - if (fcntl(fd, F_GETLK, &lock) < 0) { - return -1; - } - if (lock.l_type == F_UNLCK) { - return 0; /* not locked */ - } - return (lock.l_pid); /* return pid of locking process */ + struct flock lock; + lock.l_type = type; + lock.l_start = 0; + lock.l_whence = SEEK_SET; + lock.l_len = 0; + + if (fcntl(fd, F_GETLK, &lock) < 0) { + return -1; + } + if (lock.l_type == F_UNLCK) { + return 0; /* not locked */ + } + return (lock.l_pid); /* return pid of locking process */ } @@ -288,20 +295,20 @@ static int test_lock(int fd, int type) * over a shared pipe (mutex provided using locks) and recieves either a * token or an error message */ -static int request_Authentication(char *user, char *passwd, - char *cell, char *type, - char *tokenbuf, char *reason) +static int +request_Authentication(char *user, char *passwd, char *cell, char *type, + char *tokenbuf, char *reason) { - int len = 0; - int pid; - char *temp; - int lockfd = 0; + int len = 0; + int pid; + char *temp; + int lockfd = 0; - afsassert(user); - afsassert(passwd); - afsassert(cell); - afsassert(type); - afsassert(tokenbuf); + afsassert(user); + afsassert(passwd); + afsassert(cell); + afsassert(type); + afsassert(tokenbuf); /* * lock the pipe before beginning communication or in case of AIX it is an @@ -309,115 +316,123 @@ static int request_Authentication(char *user, char *passwd, * a temporary file and use that fd instead */ #ifdef AIX - lockfd = tempfd; + lockfd = tempfd; #else - lockfd = writePipe; + lockfd = writePipe; #endif - while ((pid = Is_writelock(lockfd)) != 0) { - if (pid < 0) { - afslog(5, ("%s: pid:%d Error locking pipe - %s", - module_name, getpid(), strerror(errno))); - return -1; + while ((pid = Is_writelock(lockfd)) != 0) { + if (pid < 0) { + afslog(5, + ("%s: pid:%d Error locking pipe - %s", module_name, + getpid(), strerror(errno))); + return -1; + } + afslog(40, + ("%s: pid %d waiting for lock held by pid %d", module_name, + getpid(), pid)); } - afslog(40, ("%s: pid %d waiting for lock held by pid %d", - module_name, getpid(), pid)); - } - if(Write_lock(lockfd) == -1) { - afslog(5, ("%s: pid:%d Error write lock - %s. Retrying with WriteW", - module_name, getpid(), strerror(errno))); - if (Writew_lock(lockfd) == -1) { - afslog(5, ("%s: pid:%d Error write lock - %s", - module_name, getpid(), strerror(errno))); - return -1; + if (Write_lock(lockfd) == -1) { + afslog(5, + ("%s: pid:%d Error write lock - %s. Retrying with WriteW", + module_name, getpid(), strerror(errno))); + if (Writew_lock(lockfd) == -1) { + afslog(5, + ("%s: pid:%d Error write lock - %s", module_name, getpid(), + strerror(errno))); + return -1; + } } - } - if (sendTo_afsAuthenticator(user, passwd, cell, type) == -1) { - Unlock(lockfd); - afslog(5, ("%s: Error sending authentication info", module_name)); - return -1; - } + if (sendTo_afsAuthenticator(user, passwd, cell, type) == -1) { + Unlock(lockfd); + afslog(5, ("%s: Error sending authentication info", module_name)); + return -1; + } - len = recvFrom_afsAuthenticator(tokenbuf); + len = recvFrom_afsAuthenticator(tokenbuf); /* release the lock */ - if (Unlock(lockfd)) { - afslog(5, ("%s: pid:%d Error unlocking", module_name, getpid())); - return -1; - } - - if (len > 0) { - if (strncmp(tokenbuf,"FAILURE",7)==0) { - temp = &tokenbuf[7]; - strncpy(reason, temp, len); - return -2; - } - } - return len; + if (Unlock(lockfd)) { + afslog(5, ("%s: pid:%d Error unlocking", module_name, getpid())); + return -1; + } + + if (len > 0) { + if (strncmp(tokenbuf, "FAILURE", 7) == 0) { + temp = &tokenbuf[7]; + strncpy(reason, temp, len); + return -2; + } + } + return len; } /* * pioctl setting token */ -static int setToken(char *tokenBuf, int tokenLen) +static int +setToken(char *tokenBuf, int tokenLen) { - register char *temp; - afs_int32 i=0; + register char *temp; + afs_int32 i = 0; - afsassert(tokenBuf); + afsassert(tokenBuf); - /* - * set the primary flag only if we haven't done a SETPAG previoulsy - * by flipping this bit - */ - if (!doneSETPAG) { + /* + * set the primary flag only if we haven't done a SETPAG previoulsy + * by flipping this bit + */ + if (!doneSETPAG) { #ifdef OLDSETPAG - /* skip over the secret token */ - temp = tokenBuf; - memcpy(&i, temp, sizeof(afs_int32)); - temp += (i + sizeof(afs_int32)); - - /* skip over the clear token */ - memcpy(&i, temp, sizeof(afs_int32)); - temp += (i + sizeof(afs_int32)); - - doneSETPAG = 1; - memcpy(&i, temp, sizeof(afs_int32)); - i |= 0x8000; - memcpy(temp, &i, sizeof(afs_int32)); - temp += sizeof(afs_int32); + /* skip over the secret token */ + temp = tokenBuf; + memcpy(&i, temp, sizeof(afs_int32)); + temp += (i + sizeof(afs_int32)); + + /* skip over the clear token */ + memcpy(&i, temp, sizeof(afs_int32)); + temp += (i + sizeof(afs_int32)); + + doneSETPAG = 1; + memcpy(&i, temp, sizeof(afs_int32)); + i |= 0x8000; + memcpy(temp, &i, sizeof(afs_int32)); + temp += sizeof(afs_int32); #endif - if(do_setpag()) { - return -1; + if (do_setpag()) { + return -1; + } + doneSETPAG = 1; } - doneSETPAG=1; - } - return do_pioctl(tokenBuf, tokenLen, tokenBuf, tokenLen, VIOCSETTOK, NULL, 0); + return do_pioctl(tokenBuf, tokenLen, tokenBuf, tokenLen, VIOCSETTOK, NULL, + 0); } /* * Get the token for the primary cell from the cache manager for this * process. Primary cell is the cell at the first index (index 0) */ -static int getToken(char *buf, int bufsize) +static int +getToken(char *buf, int bufsize) { - /* get just the ONE token for this PAG from cache manager */ - afs_int32 i = 0; - memcpy((void *)buf, (void *)&i, sizeof(afs_int32)); - return do_pioctl(buf, sizeof(afs_int32), buf, bufsize, - VIOCGETTOK, NULL,0); + /* get just the ONE token for this PAG from cache manager */ + afs_int32 i = 0; + memcpy((void *)buf, (void *)&i, sizeof(afs_int32)); + return do_pioctl(buf, sizeof(afs_int32), buf, bufsize, VIOCGETTOK, NULL, + 0); } - + /* * discard all authentication information for this PAG ie. this process */ -int unlog() +int +unlog() { - return do_pioctl(0, 0, 0,0, VIOCUNPAG, NULL, 0); + return do_pioctl(0, 0, 0, 0, VIOCUNPAG, NULL, 0); } @@ -429,287 +444,303 @@ int unlog() * - sets the token and returns appropriate return code * Return values: OK, SERVER_ERROR, AUTH_REQUIRED, FORBIDDEN */ -int authenticateUser(request_rec *r, char *defaultCell, - int cacheExpiration, char *type) +int +authenticateUser(request_rec * r, char *defaultCell, int cacheExpiration, + char *type) { - char user[APACHEAFS_USERNAME_MAX]; - char passwd[APACHEAFS_PASSWORD_MAX]; - char cell[APACHEAFS_CELLNAME_MAX]; - char tokenbuf[MAXBUFF]; - char cksum[SHA_HASH_BYTES]; - int rc = 0; - int i = 0; - const char *auth_line; - char reason[MAXBUFF]; /* if authentication failed - this is why */ - char err_msg[MAXBUFF]; - int userChanged = 0; - - afsassert(r); - afsassert(r->uri); - afsassert(defaultCell); - afsassert(type); - - auth_line = TABLE_GET (r->headers_in, "Authorization"); - - if (strcmp(global_default_cell, defaultCell)) { - strcpy(global_default_cell, defaultCell); - } - - memset(user, 0, APACHEAFS_USERNAME_MAX); - memset(passwd, 0, APACHEAFS_PASSWORD_MAX); - memset(cell, 0, APACHEAFS_CELLNAME_MAX); - - if (auth_line == NULL) { /* No Authorization field - we don't do anything */ + char user[APACHEAFS_USERNAME_MAX]; + char passwd[APACHEAFS_PASSWORD_MAX]; + char cell[APACHEAFS_CELLNAME_MAX]; + char tokenbuf[MAXBUFF]; + char cksum[SHA_HASH_BYTES]; + int rc = 0; + int i = 0; + const char *auth_line; + char reason[MAXBUFF]; /* if authentication failed - this is why */ + char err_msg[MAXBUFF]; + int userChanged = 0; + + afsassert(r); + afsassert(r->uri); + afsassert(defaultCell); + afsassert(type); + + auth_line = TABLE_GET(r->headers_in, "Authorization"); + + if (strcmp(global_default_cell, defaultCell)) { + strcpy(global_default_cell, defaultCell); + } + + memset(user, 0, APACHEAFS_USERNAME_MAX); + memset(passwd, 0, APACHEAFS_PASSWORD_MAX); + memset(cell, 0, APACHEAFS_CELLNAME_MAX); + + if (auth_line == NULL) { /* No Authorization field - we don't do anything */ + /* + * No Authorization field recieved - that's fine by us. + * go ahead and attempt to service the request and if we get + * back FORBIDDEN then we'll take care of it then + */ + afslog(15, ("%s: No authline recieved", module_name)); + haveAuth = 0; + userChanged = 1; + memset(lastUser, 0, APACHEAFS_USERNAME_MAX); + memset(lastCell, 0, APACHEAFS_CELLNAME_MAX); + memset(lastCksum, 0, SHA_HASH_BYTES); + rc = unlog(); + afslog(25, + ("%s: pid:%d No Authorization field. Unlogging ...", + module_name, getpid())); + if (rc) { + sprintf(err_msg, + "%s: Error unlogging from AFS cell - rc: %d, errno:%d", + module_name, rc, errno); + LOG_REASON(err_msg, r->uri, r); + return SERVER_ERROR; + } + return OK; + } + /* - * No Authorization field recieved - that's fine by us. - * go ahead and attempt to service the request and if we get - * back FORBIDDEN then we'll take care of it then + * We should get here only if there IS an Authorization field */ - afslog(15, ("%s: No authline recieved", module_name)); - haveAuth = 0; - userChanged=1; - memset(lastUser, 0, APACHEAFS_USERNAME_MAX); - memset(lastCell, 0, APACHEAFS_CELLNAME_MAX); - memset(lastCksum, 0, SHA_HASH_BYTES); - rc = unlog(); - afslog(25, ("%s: pid:%d No Authorization field. Unlogging ...", - module_name, getpid())); - if (rc) { - sprintf(err_msg, "%s: Error unlogging from AFS cell - rc: %d, errno:%d", - module_name, rc, errno); - LOG_REASON(err_msg, r->uri, r); - return SERVER_ERROR; + + if ((rc = parse_authhdr(r, user, passwd, cell, defaultCell)) != 0) { + sprintf(err_msg, "%s: Error parsing Authorization Header rc:%d", + module_name, rc); + LOG_REASON(err_msg, r->uri, r); + return rc; /* SERVER ERROR */ } - return OK; - } - - /* - * We should get here only if there IS an Authorization field - */ - - if ((rc = parse_authhdr(r, user, passwd, cell, defaultCell)) != 0) { - sprintf(err_msg, "%s: Error parsing Authorization Header rc:%d", - module_name, rc); - LOG_REASON(err_msg, r->uri, r); - return rc; /* SERVER ERROR */ - } - - /* - * should get here only after obtaining the username and password and cell - * check to make sure anyway - */ - if ((user[0] =='\0') || (cell[0] == '\0') || (passwd[0] =='\0')) { - afslog(15, ("%s: pid:%d No username or password or cell. Unlogging.", + + /* + * should get here only after obtaining the username and password and cell + * check to make sure anyway + */ + if ((user[0] == '\0') || (cell[0] == '\0') || (passwd[0] == '\0')) { + afslog(15, + ("%s: pid:%d No username or password or cell. Unlogging.", module_name, getpid())); - haveAuth = 0; - userChanged = 1; - memset(lastUser, 0, APACHEAFS_USERNAME_MAX); - memset(lastCell, 0, APACHEAFS_CELLNAME_MAX); - memset(lastCksum, 0, SHA_HASH_BYTES); - rc = unlog(); - if (rc) { - sprintf(err_msg, "%s: Error unlogging from AFS cell - rc: %d, errno:%d", - module_name, rc, errno); - LOG_REASON(err_msg, r->uri, r); - return SERVER_ERROR; + haveAuth = 0; + userChanged = 1; + memset(lastUser, 0, APACHEAFS_USERNAME_MAX); + memset(lastCell, 0, APACHEAFS_CELLNAME_MAX); + memset(lastCksum, 0, SHA_HASH_BYTES); + rc = unlog(); + if (rc) { + sprintf(err_msg, + "%s: Error unlogging from AFS cell - rc: %d, errno:%d", + module_name, rc, errno); + LOG_REASON(err_msg, r->uri, r); + return SERVER_ERROR; + } + setCellAuthHeader(r); + return AUTH_REQUIRED; } - setCellAuthHeader(r); - return AUTH_REQUIRED; - } - #ifdef DEBUG - fprintf(stderr, "Cell:%s\tUser:%s\tPasswd:%s\n", cell, user, passwd); + fprintf(stderr, "Cell:%s\tUser:%s\tPasswd:%s\n", cell, user, passwd); #endif - /* - * compare with previous username/cell/cksum - update it - * unlog if required - */ - - weblog_login_checksum(user, cell, passwd, cksum); - if (!haveAuth) { - haveAuth = 1; - strcpy(lastUser, user); - strcpy (lastCksum, cksum); - strcpy(lastCell, cell); - } - if (strcmp(user, lastUser) || - strcmp(cell, lastCell) || - strcmp(cksum, lastCksum)) { /* - * unlog the old user from the cell if a new username/passwd is recievd - */ - - userChanged = 1; - afslog(25, ("%s: pid:%d\tUnlogging user %s from cell%s", - module_name, getpid(), lastUser, lastCell)); - afslog(25, ("%s:New user:%s\t New Cell:%s", module_name, user, cell)); - afslog(25, ("%s:Trying to get URL:%s", module_name, r->uri)); - afslog(25, ("%s: Unlogging ....", module_name)); - - if (unlog()) { - sprintf(err_msg, "%s: Error unlogging from AFS cell - rc: %d, errno:%d", - module_name, rc, errno); - LOG_REASON(err_msg, r->uri, r); - return SERVER_ERROR; - } - /* change lastUser to this user */ - strcpy(lastUser, user); - strcpy (lastCksum, cksum); - strcpy(lastCell, cell); - } /* strcmp checksums - ie. did the user change */ - - -#ifndef NO_AFSAPACHE_CACHE - if (!cache_initialized) { - token_cache_init(); - cache_initialized = 1; - } - - /* have to check local cache for this name/passwd */ - - rc = check_Cache(user, passwd, cell, tokenbuf); - if (rc) { - /* if found then just send the request without going through - * weblog - this means the user has already been authenticated - * once and we have a valid token just need to set it - - * only if it is different from the token already set. No need to - * even unlog because this token is set for the entire PAG which - * of course consists of just this child process + * compare with previous username/cell/cksum - update it + * unlog if required */ - afslog(35, ("%s: pid:%d found user %s's token (expires:%d) in cache", - module_name, getpid(), user, (getExpiration(tokenbuf)-time(NULL)))); - - /* if the user changed then set this token else leave it since it should - be set */ - if (userChanged) { - /* set this token obtained from the local cache */ - afslog(15,("%s:pid:%d\t Setting cached token", module_name, getpid())); - if(setToken(tokenbuf, rc)) { - afslog(5, ("%s: pid:%d Failed to set token obtained from cache." - "rc:%d errno:%d Token Expiration:%d", module_name, getpid(), - rc, errno, (getExpiration(tokenbuf)-time(NULL)))); -#ifdef DEBUG_CACHE - parseToken(tokenbuf); -#endif + + weblog_login_checksum(user, cell, passwd, cksum); + if (!haveAuth) { + haveAuth = 1; + strcpy(lastUser, user); + strcpy(lastCksum, cksum); + strcpy(lastCell, cell); + } + if (strcmp(user, lastUser) || strcmp(cell, lastCell) + || strcmp(cksum, lastCksum)) { /* - * BUG WORKAROUND: sometimes we fail while setting token - * with errno ESRCH indicating the named cell - * in the last field of the token is not recognized - but that's - * not quite true according to parseToken()!! Possibly corrupted - * tokens from the cache? - * Anyway we just get a new token from weblog + * unlog the old user from the cell if a new username/passwd is recievd */ - goto reqAuth; - } - } /* if userChanged */ - else { - /* if this is a child process getting the request for the first time - * then there's no way this guy's got a token for us in which case - * getToken should fail with EDOM and that means we should set the token - * first and maybe set a static variable saying we have set a token? - */ - char temp[MAXBUFF]; - if(getToken(temp, sizeof(temp))) { - if (errno == EDOM) { - /* try setting the cached token */ - if(setToken(tokenbuf,rc)) { - /* - * same bug workaround here. ie. go to weblog if setting - * the cached token fails. - */ - sprintf(err_msg,"%s: pid:%d Failed to set cached token." - "errno:%d rc:%d", module_name, getpid(), errno, rc); - LOG_REASON(err_msg, r->uri, r); - goto reqAuth; - } + + userChanged = 1; + afslog(25, + ("%s: pid:%d\tUnlogging user %s from cell%s", module_name, + getpid(), lastUser, lastCell)); + afslog(25, ("%s:New user:%s\t New Cell:%s", module_name, user, cell)); + afslog(25, ("%s:Trying to get URL:%s", module_name, r->uri)); + afslog(25, ("%s: Unlogging ....", module_name)); + + if (unlog()) { + sprintf(err_msg, + "%s: Error unlogging from AFS cell - rc: %d, errno:%d", + module_name, rc, errno); + LOG_REASON(err_msg, r->uri, r); + return SERVER_ERROR; } + /* change lastUser to this user */ + strcpy(lastUser, user); + strcpy(lastCksum, cksum); + strcpy(lastCell, cell); + } + + /* strcmp checksums - ie. did the user change */ +#ifndef NO_AFSAPACHE_CACHE + if (!cache_initialized) { + token_cache_init(); + cache_initialized = 1; + } + + /* have to check local cache for this name/passwd */ + + rc = check_Cache(user, passwd, cell, tokenbuf); + if (rc) { + /* if found then just send the request without going through + * weblog - this means the user has already been authenticated + * once and we have a valid token just need to set it - + * only if it is different from the token already set. No need to + * even unlog because this token is set for the entire PAG which + * of course consists of just this child process + */ + afslog(35, + ("%s: pid:%d found user %s's token (expires:%d) in cache", + module_name, getpid(), user, + (getExpiration(tokenbuf) - time(NULL)))); + + /* if the user changed then set this token else leave it since it should + * be set */ + if (userChanged) { + /* set this token obtained from the local cache */ + afslog(15, + ("%s:pid:%d\t Setting cached token", module_name, + getpid())); + if (setToken(tokenbuf, rc)) { + afslog(5, + ("%s: pid:%d Failed to set token obtained from cache." + "rc:%d errno:%d Token Expiration:%d", module_name, + getpid(), rc, errno, + (getExpiration(tokenbuf) - time(NULL)))); +#ifdef DEBUG_CACHE + parseToken(tokenbuf); +#endif + /* + * BUG WORKAROUND: sometimes we fail while setting token + * with errno ESRCH indicating the named cell + * in the last field of the token is not recognized - but that's + * not quite true according to parseToken()!! Possibly corrupted + * tokens from the cache? + * Anyway we just get a new token from weblog + */ + goto reqAuth; + } + } /* if userChanged */ else { - /* and again for any getToken failure other than EDOM */ - sprintf(err_msg,"%s: Failed to get token: errno:%d rc:%d", - module_name, errno, rc); - LOG_REASON(err_msg, r->uri, r); - goto reqAuth; + /* if this is a child process getting the request for the first time + * then there's no way this guy's got a token for us in which case + * getToken should fail with EDOM and that means we should set the token + * first and maybe set a static variable saying we have set a token? + */ + char temp[MAXBUFF]; + if (getToken(temp, sizeof(temp))) { + if (errno == EDOM) { + /* try setting the cached token */ + if (setToken(tokenbuf, rc)) { + /* + * same bug workaround here. ie. go to weblog if setting + * the cached token fails. + */ + sprintf(err_msg, + "%s: pid:%d Failed to set cached token." + "errno:%d rc:%d", module_name, getpid(), + errno, rc); + LOG_REASON(err_msg, r->uri, r); + goto reqAuth; + } + } else { + /* and again for any getToken failure other than EDOM */ + sprintf(err_msg, + "%s: Failed to get token: errno:%d rc:%d", + module_name, errno, rc); + LOG_REASON(err_msg, r->uri, r); + goto reqAuth; + } + } /* so we already have a token set since the gettoken succeeded */ } - } /* so we already have a token set since the gettoken succeeded */ - } - /* to set the REMOTE_USER environment variable */ - strcpy(r->connection->user,user); - return OK; - } - /* - * else - request afs_Authenticator's for it and update local cache - * then go about serving the request URI - */ - else { - reqAuth: + /* to set the REMOTE_USER environment variable */ + strcpy(r->connection->user, user); + return OK; + } + /* + * else - request afs_Authenticator's for it and update local cache + * then go about serving the request URI + */ + else { + reqAuth: #endif /* NO_AFSAPACHE_CACHE */ - rc = request_Authentication(user, passwd, cell, type, tokenbuf,reason); - if (rc > 0) { - /* we got back a token from weblog */ - /* set the token with setToken */ - if(setToken(tokenbuf, rc)) { - sprintf(err_msg, "%s: Failed to set token given by weblog. errno:%d", - module_name, errno); - LOG_REASON(err_msg, r->uri, r); - return SERVER_ERROR; - } - -#ifdef DEBUG_TOKENS - system("/usr/afsws/bin/tokens"); + rc = request_Authentication(user, passwd, cell, type, tokenbuf, + reason); + if (rc > 0) { + /* we got back a token from weblog */ + /* set the token with setToken */ + if (setToken(tokenbuf, rc)) { + sprintf(err_msg, + "%s: Failed to set token given by weblog. errno:%d", + module_name, errno); + LOG_REASON(err_msg, r->uri, r); + return SERVER_ERROR; + } +#ifdef DEBUG_TOKENS + system("/usr/afsws/bin/tokens"); #endif #ifndef NO_AFSAPACHE_CACHE - /* update local cache */ - if (updateCache(user, passwd, cell, tokenbuf,cacheExpiration)) { - sprintf(err_msg, "%s: Error updating cache", module_name); - LOG_REASON(err_msg, r->uri, r); - return SERVER_ERROR; - } - afslog(15, ("%s: pid:%d\t put user:%s tokens in cache", - module_name, getpid(), user)); + /* update local cache */ + if (updateCache(user, passwd, cell, tokenbuf, cacheExpiration)) { + sprintf(err_msg, "%s: Error updating cache", module_name); + LOG_REASON(err_msg, r->uri, r); + return SERVER_ERROR; + } + afslog(15, + ("%s: pid:%d\t put user:%s tokens in cache", module_name, + getpid(), user)); #endif /* NO_AFSAPACHE_CACHE */ - /* now we've got a token, updated the cache and set it so we should - * have no problems accessing AFS files - however if we do then - * we handle it in afs_accessCheck() when the error comes back - */ + /* now we've got a token, updated the cache and set it so we should + * have no problems accessing AFS files - however if we do then + * we handle it in afs_accessCheck() when the error comes back + */ - /* to set the REMOTE_USER environment variable to the username */ - strcpy(r->connection->user,user); - return OK; - } - else if (rc == -2) { - sprintf(err_msg, ":%s: AFS authentication failed for %s@%s because %s", - module_name, user, cell, reason); - LOG_REASON(err_msg, r->uri, r); - setCellAuthHeader(r); - return AUTH_REQUIRED; - } - else if (rc == -1) { - sprintf(err_msg, "%s: Error readiong from pipe. errno:%d", module_name, errno); - LOG_REASON(err_msg, r->uri, r); - return SERVER_ERROR; - } - - else { - /* - * unknown error from weblog - this should not occur - * if afs_Authenticator can't authenticate you, then return FORBIDDEN - */ - sprintf(err_msg, "%s: AFS could not authenticate user %s in cell %s." - "Returning FORBIDDEN", module_name, user, cell); - LOG_REASON(err_msg, r->uri, r); - return FORBIDDEN; - } + /* to set the REMOTE_USER environment variable to the username */ + strcpy(r->connection->user, user); + return OK; + } else if (rc == -2) { + sprintf(err_msg, + ":%s: AFS authentication failed for %s@%s because %s", + module_name, user, cell, reason); + LOG_REASON(err_msg, r->uri, r); + setCellAuthHeader(r); + return AUTH_REQUIRED; + } else if (rc == -1) { + sprintf(err_msg, "%s: Error readiong from pipe. errno:%d", + module_name, errno); + LOG_REASON(err_msg, r->uri, r); + return SERVER_ERROR; + } + + else { + /* + * unknown error from weblog - this should not occur + * if afs_Authenticator can't authenticate you, then return FORBIDDEN + */ + sprintf(err_msg, + "%s: AFS could not authenticate user %s in cell %s." + "Returning FORBIDDEN", module_name, user, cell); + LOG_REASON(err_msg, r->uri, r); + return FORBIDDEN; + } #ifndef NO_AFSAPACHE_CACHE - } + } #endif - /* should never get here */ - LOG_REASON("AFS Authentication: WE SHOULD NEVER GET HERE", r->uri, r ); - return SERVER_ERROR; + /* should never get here */ + LOG_REASON("AFS Authentication: WE SHOULD NEVER GET HERE", r->uri, r); + return SERVER_ERROR; } @@ -718,22 +749,26 @@ int authenticateUser(request_rec *r, char *defaultCell, * returns 0 if successful -1 if failure. Assumes memory has been allocated * for cell. Used to set the www-authenticate header. */ -static int get_cellname_from_path(char *apath, char *cell) +static int +get_cellname_from_path(char *apath, char *cell) { - int rc; + int rc; - afsassert(apath); - afsassert(cell); + afsassert(apath); + afsassert(cell); - rc = do_pioctl(NULL, 0, cell, APACHEAFS_CELLNAME_MAX, - VIOC_FILE_CELL_NAME, apath, 1); - if (rc) - afslog(30, ("%s: Error getting cell from path %s. errno:%d rc:%d", + rc = do_pioctl(NULL, 0, cell, APACHEAFS_CELLNAME_MAX, VIOC_FILE_CELL_NAME, + apath, 1); + if (rc) + afslog(30, + ("%s: Error getting cell from path %s. errno:%d rc:%d", module_name, apath, errno, rc)); - else - afslog(30, ("%s: Obtained cell %s from path %s", module_name, cell, apath)); + else + afslog(30, + ("%s: Obtained cell %s from path %s", module_name, cell, + apath)); - return rc; + return rc; } /* @@ -741,65 +776,66 @@ static int get_cellname_from_path(char *apath, char *cell) * call get_cell_by_name. * TODO: These could well be combined into one single function. */ -static int getcellname(request_rec *r, char *buf) +static int +getcellname(request_rec * r, char *buf) { - int rc = 0; - - afsassert(r); - afsassert(buf); - - if (r->filename) { - rc = get_cellname_from_path(r->filename, buf); - } - else { - char path[1024]; - sprintf(path,"%s/%s",DOCUMENT_ROOT(r), r->uri); - rc = get_cellname_from_path(path, buf); - } - return rc; + int rc = 0; + + afsassert(r); + afsassert(buf); + + if (r->filename) { + rc = get_cellname_from_path(r->filename, buf); + } else { + char path[1024]; + sprintf(path, "%s/%s", DOCUMENT_ROOT(r), r->uri); + rc = get_cellname_from_path(path, buf); + } + return rc; } /* * Returns a part of the url upto the second slash in the buf */ -static int geturi(request_rec *r, char *buf) +static int +geturi(request_rec * r, char *buf) { - int rc = 0; - char *pos; - char *end; - int i = 0; - int max = 2; - - afsassert(r); - afsassert(buf); - - memset(buf, 0, APACHEAFS_CELLNAME_MAX); - pos = strchr(r->uri,'/'); - if (pos != NULL) { - pos++; - for (i=0; iuri, '/'); + if (pos != NULL) { + pos++; + for (i = 0; i < max; i++) { + end = strchr(pos, '/'); + if (end != NULL) { + int len = strlen(pos) - strlen(end); + strcat(buf, "/"); + strncat(buf, pos, len); + afslog(35, + ("%s: Getting URI upto second slash buf:%s", + module_name, buf)); + pos += (len + 1); + end = strchr(pos, '/'); + if (end == NULL) { + break; + } + } else { + strcat(buf, pos); + break; + } } - } - else { - strcat(buf,pos); - break; - } - } - } - else { - strcpy(buf," "); - } - return rc; + } else { + strcpy(buf, " "); + } + return rc; } /* @@ -808,139 +844,147 @@ static int geturi(request_rec *r, char *buf) * resides in, failing which the first part of the uri failing which the * string Unknown */ -static int parseAuthName_int(request_rec *r, char *buf, char *msg) +static int +parseAuthName_int(request_rec * r, char *buf, char *msg) { - char *pos; - char *end; - int len = 0; - int rc = 0; - char blank[APACHEAFS_CELLNAME_MAX]; - - afsassert(r); - afsassert(buf); - afsassert(msg); - - memset(blank, 0, sizeof(blank)); - afslog(50, ("%s: Parsing Authorization Required reply. buf:%s", module_name, buf)); - - pos = strchr(buf, '<'); - if (pos) { - len = strlen(pos); - pos++; - end = strchr(pos, '>'); - if (end == NULL) { - afslog(0,("%s:Parse error for AUTH_REQUIRED reply - mismatched <", module_name)); - fprintf(stderr,"Parse Error: mismatched <\n"); - strncpy(msg, buf, strlen(buf)-len); - afslog(0, ("%s: msg:%s", msg)); - return -1; - } - end++; - if (pos[0] == '%') { - pos++; - switch(pos[0]) { - case 'c': - rc = getcellname(r, blank); - if (!rc) { - strncpy(msg, buf, strlen(buf)-len); - strcat(msg, blank); - strcat(msg, end); - return 0; - } - break; - - case 'u': - rc = geturi(r, blank); - if (!rc) { - strncpy(msg, buf, strlen(buf)-len); - strcat(msg, blank); - strcat(msg, end); - return 0; + char *pos; + char *end; + int len = 0; + int rc = 0; + char blank[APACHEAFS_CELLNAME_MAX]; + + afsassert(r); + afsassert(buf); + afsassert(msg); + + memset(blank, 0, sizeof(blank)); + afslog(50, + ("%s: Parsing Authorization Required reply. buf:%s", module_name, + buf)); + + pos = strchr(buf, '<'); + if (pos) { + len = strlen(pos); + pos++; + end = strchr(pos, '>'); + if (end == NULL) { + afslog(0, + ("%s:Parse error for AUTH_REQUIRED reply - mismatched <", + module_name)); + fprintf(stderr, "Parse Error: mismatched <\n"); + strncpy(msg, buf, strlen(buf) - len); + afslog(0, ("%s: msg:%s", msg)); + return -1; } - break; - - case 'd': - if (global_default_cell != NULL) { - strncpy(msg, buf, strlen(buf)-len); - strcat(msg, global_default_cell); - strcat(msg, end); - return 0; + end++; + if (pos[0] == '%') { + pos++; + switch (pos[0]) { + case 'c': + rc = getcellname(r, blank); + if (!rc) { + strncpy(msg, buf, strlen(buf) - len); + strcat(msg, blank); + strcat(msg, end); + return 0; + } + break; + + case 'u': + rc = geturi(r, blank); + if (!rc) { + strncpy(msg, buf, strlen(buf) - len); + strcat(msg, blank); + strcat(msg, end); + return 0; + } + break; + + case 'd': + if (global_default_cell != NULL) { + strncpy(msg, buf, strlen(buf) - len); + strcat(msg, global_default_cell); + strcat(msg, end); + return 0; + } + break; + } + strncpy(msg, buf, strlen(buf) - len); + strcat(msg, "<"); + pos++; + strcat(msg, pos); + strcpy(buf, msg); + memset(msg, 0, 1024); + parseAuthName_int(r, buf, msg); + return 0; + } else { + strncpy(msg, buf, strlen(buf) - len); + strncat(msg, pos, strlen(pos) - strlen(end) - 1); + strcat(msg, end); + return 0; } - break; - } - strncpy(msg, buf, strlen(buf)-len); - strcat(msg,"<"); - pos++; - strcat(msg, pos); - strcpy(buf, msg); - memset(msg, 0, 1024); - parseAuthName_int(r, buf, msg); - return 0; - } - else { - strncpy(msg, buf, strlen(buf)-len); - strncat(msg, pos, strlen(pos)-strlen(end)-1); - strcat(msg, end); - return 0; } - } } /* * Parses the entire auth_name string - ie. takes care of multiple * <%...> <%...> */ -static int parseAuthName(request_rec *r, char *buf) +static int +parseAuthName(request_rec * r, char *buf) { - char *pos; - int rc; - char msg[1024]; + char *pos; + int rc; + char msg[1024]; - afsassert(r); - afsassert(buf); + afsassert(r); + afsassert(buf); - memset(msg, 0, sizeof(msg)); - - pos=strchr(buf,'<'); - while (pos != NULL) { - rc = parseAuthName_int(r, buf, msg); - if (rc) { - strcpy(buf, msg); - afslog(35, ("%s: Failed to parse Auth Name. buf:%s", module_name, buf)); - return -1; - } - strcpy(buf, msg); memset(msg, 0, sizeof(msg)); + pos = strchr(buf, '<'); - } - afslog(50, ("%s: Parsing WWW Auth required reply. final message:%s", - module_name, buf)); - return 0; + while (pos != NULL) { + rc = parseAuthName_int(r, buf, msg); + if (rc) { + strcpy(buf, msg); + afslog(35, + ("%s: Failed to parse Auth Name. buf:%s", module_name, + buf)); + return -1; + } + strcpy(buf, msg); + memset(msg, 0, sizeof(msg)); + pos = strchr(buf, '<'); + } + afslog(50, + ("%s: Parsing WWW Auth required reply. final message:%s", + module_name, buf)); + return 0; } /* * Set the www-authenticate header - this is the login prompt the users see */ -static int setCellAuthHeader(request_rec *r) +static int +setCellAuthHeader(request_rec * r) { - char *name; - char buf[1024]; - int rc = 0; - - afsassert(r); - - name = (char *)get_afs_authprompt(r); - if (name != NULL) { - strcpy(buf, name); - rc = parseAuthName(r, buf); - } - else { - strcpy(buf, " "); - } - TABLE_SET (r->err_headers_out, "WWW-Authenticate", - PSTRCAT(r->pool, "Basic realm=\"", buf, "\"", NULL)); - return rc; + char *name; + char buf[1024]; + int rc = 0; + + afsassert(r); + + name = (char *)get_afs_authprompt(r); + if (name != NULL) { + strcpy(buf, name); + rc = parseAuthName(r, buf); + } else { + strcpy(buf, " "); + } + TABLE_SET(r->err_headers_out, "WWW-Authenticate", + PSTRCAT(r->pool, "Basic realm=\"", buf, "\"", NULL)); + return rc; } @@ -950,13 +994,13 @@ static int setCellAuthHeader(request_rec *r) * www-authenticate header. Should be called if we can't access a file because * permission is denied. */ -int forbToAuthReqd(request_rec *r) +int +forbToAuthReqd(request_rec * r) { - if (haveAuth) { - return FORBIDDEN; - } - else { - setCellAuthHeader(r); - return AUTH_REQUIRED; - } + if (haveAuth) { + return FORBIDDEN; + } else { + setCellAuthHeader(r); + return AUTH_REQUIRED; + } } diff --git a/src/afsweb/apache_afs_module.c b/src/afsweb/apache_afs_module.c index bdd2d4759..ab4e90fb8 100644 --- a/src/afsweb/apache_afs_module.c +++ b/src/afsweb/apache_afs_module.c @@ -39,10 +39,10 @@ * these are used */ #define DEFAULT_WEBLOG_PATH "./weblog_starter" -#define DEFAULT_CACHE_EXPIRATION 300 /* 5 minutes */ -#define DEFAULT_TOKEN_EXPIRATION 600 /* 10 minutes */ +#define DEFAULT_CACHE_EXPIRATION 300 /* 5 minutes */ +#define DEFAULT_TOKEN_EXPIRATION 600 /* 10 minutes */ #define DEFAULT_DEBUG_LEVEL 0 -#define null ((void*)0) +#define null ((void*)0) extern u_long afsDebugLevel; @@ -50,23 +50,21 @@ extern u_long afsDebugLevel; module afs_module; /* Data type for server configuration */ -typedef struct -{ - char *afs_defaultCell; - u_long afs_cacheExpiration; - u_long afs_tokenExpiration; - char *afs_weblogPath; - char *afs_accessLog; - u_long afs_debugLevel; +typedef struct { + char *afs_defaultCell; + u_long afs_cacheExpiration; + u_long afs_tokenExpiration; + char *afs_weblogPath; + char *afs_accessLog; + u_long afs_debugLevel; } afs_server_config_rec; /* Data type for per directory configuration */ -typedef struct -{ - char *afs_authtype; - char *afs_prompt; - char *afs_cell; +typedef struct { + char *afs_authtype; + char *afs_prompt; + char *afs_cell; } afs_dir_config_rec; @@ -77,135 +75,142 @@ static u_long cacheExpiration; int logAccessErrors = 0; int logfd = -1; -static int afsAccessFile_flags = ( O_WRONLY | O_APPEND | O_CREAT ); +static int afsAccessFile_flags = (O_WRONLY | O_APPEND | O_CREAT); #ifdef __EMX__ /* OS/2 dosen't support users and groups */ -static mode_t afsAccessFile_mode = ( S_IREAD | S_IWRITE ); +static mode_t afsAccessFile_mode = (S_IREAD | S_IWRITE); #else -static mode_t afsAccessFile_mode = ( S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ); +static mode_t afsAccessFile_mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); #endif -void afs_init(server_rec *s, pool *p) +void +afs_init(server_rec * s, pool * p) { - if (!initialized) { - char *weblogPath; - afs_server_config_rec *src = get_module_config(s->module_config, &afs_module); - int tokenExpiration = src->afs_tokenExpiration; - - initialized = 1; - if (src->afs_weblogPath) - weblogPath = pstrdup(p, src->afs_weblogPath); - else - weblogPath = pstrdup(p, DEFAULT_WEBLOG_PATH); - - if (src->afs_defaultCell) - strcpy(defaultCell,src->afs_defaultCell); - else { - fprintf(stderr, "AFS Module: SetAFSDEfaultCell " - "is a required directive for module to work. Exiting\n"); - exit(1); - } - tokenExpiration = src->afs_tokenExpiration; - cacheExpiration = src->afs_cacheExpiration; - afsDebugLevel = src->afs_debugLevel; - - if ((src->afs_accessLog == NULL) || (src->afs_accessLog == "")) { - logAccessErrors = 0; - } - else { - char *filename = server_root_relative(p, src->afs_accessLog); - logfd = open(filename,afsAccessFile_flags, afsAccessFile_mode); - if (logfd < 0) { - fprintf(stderr, "afs_module:Error opening afs access log file:%s\n" - "Error:%s,Exiting\n",strerror(errno),filename); - exit(-1); - } - logAccessErrors = 1; - } - - if (cacheExpiration < 0) { - cacheExpiration = DEFAULT_CACHE_EXPIRATION; - } - if (tokenExpiration < 0) { - tokenExpiration = DEFAULT_TOKEN_EXPIRATION; - } - - if (afsDebugLevel < 0) { - afsDebugLevel = DEFAULT_DEBUG_LEVEL; - } - - if (cacheExpiration > tokenExpiration) { - fprintf(stderr, "tokenExpiration:%d is less than cacheExpiration:%d\n", - tokenExpiration, cacheExpiration); - fprintf(stderr, "\n\n"); - fprintf(stderr, "Ensure that this does not happen, since you will " - "not be allowed access to files if the cached token has expired " - "because the token lifetime is less than the cache expiration " - "time. Restart the server after editing the config file\n"); - exit(1); - } - - if (!cacheExpiration && tokenExpiration) { - fprintf(stderr, "cacheExpiration is set to infinity (0), but " - "tokenExpiration:%d is finite\n",tokenExpiration); - fprintf(stderr, "\n\n"); - fprintf(stderr, "Ensure that this does not happen, since you will " - "not be allowed access to files if the cached token has expired " - "because the token lifetime is less than the cache expiration " - "time (infinite). " - "Restart the server after editing the config file\n"); - } + if (!initialized) { + char *weblogPath; + afs_server_config_rec *src = + get_module_config(s->module_config, &afs_module); + int tokenExpiration = src->afs_tokenExpiration; + + initialized = 1; + if (src->afs_weblogPath) + weblogPath = pstrdup(p, src->afs_weblogPath); + else + weblogPath = pstrdup(p, DEFAULT_WEBLOG_PATH); + + if (src->afs_defaultCell) + strcpy(defaultCell, src->afs_defaultCell); + else { + fprintf(stderr, + "AFS Module: SetAFSDEfaultCell " + "is a required directive for module to work. Exiting\n"); + exit(1); + } + tokenExpiration = src->afs_tokenExpiration; + cacheExpiration = src->afs_cacheExpiration; + afsDebugLevel = src->afs_debugLevel; + + if ((src->afs_accessLog == NULL) || (src->afs_accessLog == "")) { + logAccessErrors = 0; + } else { + char *filename = server_root_relative(p, src->afs_accessLog); + logfd = open(filename, afsAccessFile_flags, afsAccessFile_mode); + if (logfd < 0) { + fprintf(stderr, + "afs_module:Error opening afs access log file:%s\n" + "Error:%s,Exiting\n", strerror(errno), filename); + exit(-1); + } + logAccessErrors = 1; + } + + if (cacheExpiration < 0) { + cacheExpiration = DEFAULT_CACHE_EXPIRATION; + } + if (tokenExpiration < 0) { + tokenExpiration = DEFAULT_TOKEN_EXPIRATION; + } + + if (afsDebugLevel < 0) { + afsDebugLevel = DEFAULT_DEBUG_LEVEL; + } + + if (cacheExpiration > tokenExpiration) { + fprintf(stderr, + "tokenExpiration:%d is less than cacheExpiration:%d\n", + tokenExpiration, cacheExpiration); + fprintf(stderr, "\n\n"); + fprintf(stderr, + "Ensure that this does not happen, since you will " + "not be allowed access to files if the cached token has expired " + "because the token lifetime is less than the cache expiration " + "time. Restart the server after editing the config file\n"); + exit(1); + } + + if (!cacheExpiration && tokenExpiration) { + fprintf(stderr, + "cacheExpiration is set to infinity (0), but " + "tokenExpiration:%d is finite\n", tokenExpiration); + fprintf(stderr, "\n\n"); + fprintf(stderr, + "Ensure that this does not happen, since you will " + "not be allowed access to files if the cached token has expired " + "because the token lifetime is less than the cache expiration " + "time (infinite). " + "Restart the server after editing the config file\n"); + } #ifdef SHUTDOWN_IF_AFS_FAILS - afs_plugin_init(tokenExpiration, - server_root_relative(p, weblogPath), - server_root_relative(p, s->error_fname), - server_root_relative(p, pid_fname), - defaultCell, NULL, cacheExpiration, NULL, - 1); + afs_plugin_init(tokenExpiration, server_root_relative(p, weblogPath), + server_root_relative(p, s->error_fname), + server_root_relative(p, pid_fname), defaultCell, NULL, + cacheExpiration, NULL, 1); #else - afs_plugin_init(tokenExpiration, - server_root_relative(p, weblogPath), - server_root_relative(p, s->error_fname), - server_root_relative(p, pid_fname), - defaultCell, NULL, cacheExpiration, NULL, - 0); + afs_plugin_init(tokenExpiration, server_root_relative(p, weblogPath), + server_root_relative(p, s->error_fname), + server_root_relative(p, pid_fname), defaultCell, NULL, + cacheExpiration, NULL, 0); #endif - } + } } -static int check_weblog(char *path) +static int +check_weblog(char *path) { - struct stat fs; - int rc = stat(path, &fs); - if (rc) - return rc; - - if (!((fs.st_mode & S_IXUSR) || (fs.st_mode & S_IXGRP) || (fs.st_mode & S_IXOTH))) - return 2; - return 0; + struct stat fs; + int rc = stat(path, &fs); + if (rc) + return rc; + + if (!((fs.st_mode & S_IXUSR) || (fs.st_mode & S_IXGRP) + || (fs.st_mode & S_IXOTH))) + return 2; + return 0; } /* * per-server configuration creator */ -void *create_afs_server_config (pool *p, server_rec *s) +void * +create_afs_server_config(pool * p, server_rec * s) { - afs_server_config_rec *scr = - (afs_server_config_rec *) pcalloc(p, sizeof(afs_server_config_rec)); - scr->afs_cacheExpiration = 0; - scr->afs_tokenExpiration = 0; - scr->afs_debugLevel = 0; - return (void *)scr; + afs_server_config_rec *scr = + (afs_server_config_rec *) pcalloc(p, sizeof(afs_server_config_rec)); + scr->afs_cacheExpiration = 0; + scr->afs_tokenExpiration = 0; + scr->afs_debugLevel = 0; + return (void *)scr; } /* * per-dir configuration record creator */ -void *create_afs_dir_config (pool *p, char *dummy) +void * +create_afs_dir_config(pool * p, char *dummy) { - afs_dir_config_rec *new = - (afs_dir_config_rec *)pcalloc(p,sizeof(afs_dir_config_rec)); - return (void *)new; + afs_dir_config_rec *new = + (afs_dir_config_rec *) pcalloc(p, sizeof(afs_dir_config_rec)); + return (void *)new; } /* @@ -213,168 +218,186 @@ void *create_afs_dir_config (pool *p, char *dummy) * token and cache expiration time to the server configuration. As well as per-dir * configs like AFSAuthentication. */ -const char *set_afscell(cmd_parms *cmd, void *dummy, char *arg) +const char * +set_afscell(cmd_parms * cmd, void *dummy, char *arg) { - void *sc = cmd->server->module_config; - afs_server_config_rec *sr = get_module_config(sc, &afs_module); - - if ((arg == NULL)||(arg[0] == '\0')) - return "AFS Default cell is a required directive"; + void *sc = cmd->server->module_config; + afs_server_config_rec *sr = get_module_config(sc, &afs_module); + + if ((arg == NULL) || (arg[0] == '\0')) + return "AFS Default cell is a required directive"; sr->afs_defaultCell = arg; return NULL; } -const char *set_afsweblogpath(cmd_parms *cmd, void *dummy, char *arg) +const char * +set_afsweblogpath(cmd_parms * cmd, void *dummy, char *arg) { - void *sc = cmd->server->module_config; - afs_server_config_rec *sr = get_module_config(sc, &afs_module); - int rc = check_weblog(arg); - if (rc) { - switch (rc) { - case 1: - return "Weblog Path should be the full path to the weblog_starter binary"; - case 2: - return "weblog_starter not executable"; + void *sc = cmd->server->module_config; + afs_server_config_rec *sr = get_module_config(sc, &afs_module); + int rc = check_weblog(arg); + if (rc) { + switch (rc) { + case 1: + return + "Weblog Path should be the full path to the weblog_starter binary"; + case 2: + return "weblog_starter not executable"; + } } - } - sr->afs_weblogPath = arg; - return NULL; + sr->afs_weblogPath = arg; + return NULL; } -const char *set_afsacceslog(cmd_parms *cmd, void *dummy, char *arg) +const char * +set_afsacceslog(cmd_parms * cmd, void *dummy, char *arg) { - void *sc = cmd->server->module_config; - afs_server_config_rec *sr = get_module_config(sc,&afs_module); - sr->afs_accessLog = arg; - return NULL; + void *sc = cmd->server->module_config; + afs_server_config_rec *sr = get_module_config(sc, &afs_module); + sr->afs_accessLog = arg; + return NULL; } -static const char *set_afs_CacheExpiration(cmd_parms *cmd, void *dummy, char *expTime) +static const char * +set_afs_CacheExpiration(cmd_parms * cmd, void *dummy, char *expTime) { - afs_server_config_rec *sr = - get_module_config(cmd->server->module_config, &afs_module); - sr->afs_cacheExpiration = atol(expTime); - return NULL; + afs_server_config_rec *sr = + get_module_config(cmd->server->module_config, &afs_module); + sr->afs_cacheExpiration = atol(expTime); + return NULL; } -static const char *set_afs_TokenExpiration(cmd_parms *cmd, void *dummy, char *expTime) +static const char * +set_afs_TokenExpiration(cmd_parms * cmd, void *dummy, char *expTime) { - afs_server_config_rec *sr = - get_module_config(cmd->server->module_config, &afs_module); - sr->afs_tokenExpiration = atol(expTime); - return NULL; + afs_server_config_rec *sr = + get_module_config(cmd->server->module_config, &afs_module); + sr->afs_tokenExpiration = atol(expTime); + return NULL; } -static const char *set_afs_DebugLevel(cmd_parms *cmd, void *dummy, char *debugLevel) +static const char * +set_afs_DebugLevel(cmd_parms * cmd, void *dummy, char *debugLevel) { - afs_server_config_rec *sr = get_module_config(cmd->server->module_config, - &afs_module); - sr->afs_debugLevel = atol(debugLevel); - return NULL; + afs_server_config_rec *sr = get_module_config(cmd->server->module_config, + &afs_module); + sr->afs_debugLevel = atol(debugLevel); + return NULL; } /* Commands this module needs to handle */ command_rec afs_cmds[] = { - { "SetAFSDefaultCell", set_afscell, NULL, - RSRC_CONF, TAKE1,"the AFS cell you want to access by default" }, - - { "SetAFSCacheExpiration", set_afs_CacheExpiration, NULL, RSRC_CONF, TAKE1, - "time for tokens in the client cache to live" }, - - { "SetAFSWeblogPath",set_afsweblogpath, NULL, RSRC_CONF, TAKE1, - "full or relative to ServerRoot path to the weblog_starter binary" }, - - { "SetAFSTokenExpiration", set_afs_TokenExpiration, NULL, RSRC_CONF, TAKE1, - "time for tokens in the kernel cache to live" }, - - { "SetAFSAccessLog", set_afsacceslog, NULL, RSRC_CONF, TAKE1, - "log afs access errors to this file" }, - - { "SetAFSDebugLevel", set_afs_DebugLevel, NULL, RSRC_CONF, TAKE1, - "Set Verbosity level for logging stuff to the error log" }, - - { "AFSLoginPrompt", set_string_slot, - (void *)XtOffsetOf(afs_dir_config_rec, afs_prompt), ACCESS_CONF, TAKE1, - "Prompt to show on Authenticating Window - similar to AuthName"}, - - { "AFSAuthType", set_string_slot, - (void*)XtOffsetOf(afs_dir_config_rec, afs_authtype), ACCESS_CONF, TAKE1, - "Authentication type for AFS" }, - - { "AFSDefaultCell", set_string_slot, - (void*)XtOffsetOf(afs_dir_config_rec, afs_cell), ACCESS_CONF, TAKE1, - "Default AFS cell for this location" }, - - { NULL } + {"SetAFSDefaultCell", set_afscell, NULL, + RSRC_CONF, TAKE1, "the AFS cell you want to access by default"} + , + + {"SetAFSCacheExpiration", set_afs_CacheExpiration, NULL, RSRC_CONF, TAKE1, + "time for tokens in the client cache to live"} + , + + {"SetAFSWeblogPath", set_afsweblogpath, NULL, RSRC_CONF, TAKE1, + "full or relative to ServerRoot path to the weblog_starter binary"} + , + + {"SetAFSTokenExpiration", set_afs_TokenExpiration, NULL, RSRC_CONF, TAKE1, + "time for tokens in the kernel cache to live"} + , + + {"SetAFSAccessLog", set_afsacceslog, NULL, RSRC_CONF, TAKE1, + "log afs access errors to this file"} + , + + {"SetAFSDebugLevel", set_afs_DebugLevel, NULL, RSRC_CONF, TAKE1, + "Set Verbosity level for logging stuff to the error log"} + , + + {"AFSLoginPrompt", set_string_slot, + (void *)XtOffsetOf(afs_dir_config_rec, afs_prompt), ACCESS_CONF, TAKE1, + "Prompt to show on Authenticating Window - similar to AuthName"}, + + {"AFSAuthType", set_string_slot, + (void *)XtOffsetOf(afs_dir_config_rec, afs_authtype), ACCESS_CONF, TAKE1, + "Authentication type for AFS"}, + + {"AFSDefaultCell", set_string_slot, + (void *)XtOffsetOf(afs_dir_config_rec, afs_cell), ACCESS_CONF, TAKE1, + "Default AFS cell for this location"}, + + {NULL} }; -char *get_afsauthtype(request_rec *r) +char * +get_afsauthtype(request_rec * r) { - afs_dir_config_rec *dr = (afs_dir_config_rec *) - get_module_config(r->per_dir_config, &afs_module); - if (!dr->afs_authtype) { - /* Try to unite CGI subprocess configuration info */ - if (r->main) { - dr = (afs_dir_config_rec *) - get_module_config(r->main->per_dir_config, &afs_module); - } - } - return dr->afs_authtype; + afs_dir_config_rec *dr = (afs_dir_config_rec *) + get_module_config(r->per_dir_config, &afs_module); + if (!dr->afs_authtype) { + /* Try to unite CGI subprocess configuration info */ + if (r->main) { + dr = (afs_dir_config_rec *) + get_module_config(r->main->per_dir_config, &afs_module); + } + } + return dr->afs_authtype; } -char *get_afs_authprompt(request_rec *r) +char * +get_afs_authprompt(request_rec * r) { - afs_dir_config_rec *dr = - (afs_dir_config_rec *)get_module_config(r->per_dir_config, &afs_module); - if (!dr->afs_prompt) { - /* Try to unite CGI subprocess configuration info */ - if (r->main) { - dr = (afs_dir_config_rec *) - get_module_config(r->main->per_dir_config, &afs_module); - } - } - return dr->afs_prompt; + afs_dir_config_rec *dr = + (afs_dir_config_rec *) get_module_config(r->per_dir_config, + &afs_module); + if (!dr->afs_prompt) { + /* Try to unite CGI subprocess configuration info */ + if (r->main) { + dr = (afs_dir_config_rec *) + get_module_config(r->main->per_dir_config, &afs_module); + } + } + return dr->afs_prompt; } -static char *get_afs_cell(request_rec *r) +static char * +get_afs_cell(request_rec * r) { - afs_dir_config_rec *dr = - (afs_dir_config_rec *)get_module_config(r->per_dir_config, &afs_module); - if (!dr->afs_cell) { - /* Try to unite CGI subprocess configuration info */ - if (r->main) { - dr = (afs_dir_config_rec *) - get_module_config(r->main->per_dir_config, &afs_module); - } - } - return dr->afs_cell; + afs_dir_config_rec *dr = + (afs_dir_config_rec *) get_module_config(r->per_dir_config, + &afs_module); + if (!dr->afs_cell) { + /* Try to unite CGI subprocess configuration info */ + if (r->main) { + dr = (afs_dir_config_rec *) + get_module_config(r->main->per_dir_config, &afs_module); + } + } + return dr->afs_cell; } -int afs_auth(request_rec *r) +int +afs_auth(request_rec * r) { - char *cell = get_afs_cell(r); - return afs_auth_internal(r, cell ? cell : defaultCell, cacheExpiration); + char *cell = get_afs_cell(r); + return afs_auth_internal(r, cell ? cell : defaultCell, cacheExpiration); } -module afs_module = -{ - STANDARD_MODULE_STUFF, - afs_init, - create_afs_dir_config, - NULL, - create_afs_server_config, - NULL, - afs_cmds, - NULL, - afs_auth, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, +module afs_module = { + STANDARD_MODULE_STUFF, + afs_init, + create_afs_dir_config, + NULL, + create_afs_server_config, + NULL, + afs_cmds, + NULL, + afs_auth, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, }; diff --git a/src/afsweb/apache_afs_plugin.c b/src/afsweb/apache_afs_plugin.c index 463316c28..094112b07 100644 --- a/src/afsweb/apache_afs_plugin.c +++ b/src/afsweb/apache_afs_plugin.c @@ -36,8 +36,8 @@ u_long afsDebugLevel; const char module_name[] = "AFS Authentication Module"; typedef struct { - char defaultCell[64]; - u_long cacheExpiration; + char defaultCell[64]; + u_long cacheExpiration; } apache_afs_glob; static apache_afs_glob *afs_str; @@ -54,21 +54,22 @@ int tempfd; * as a means of synchronization for providing exclusive access to the pipe * for communicating with the weblog process */ -static int create_temp_file() +static int +create_temp_file() { - char tmpFileName[L_tmpnam]; - int lockfd=0; + char tmpFileName[L_tmpnam]; + int lockfd = 0; - tmpnam(tmpFileName); - unlink(tmpFileName); + tmpnam(tmpFileName); + unlink(tmpFileName); - lockfd = open(tmpFileName, O_RDWR | O_CREAT); - if (lockfd < 0) { - perror("afs_plugin:Error creating temp file:"); + lockfd = open(tmpFileName, O_RDWR | O_CREAT); + if (lockfd < 0) { + perror("afs_plugin:Error creating temp file:"); + return lockfd; + } + unlink(tmpFileName); return lockfd; - } - unlink(tmpFileName); - return lockfd; } #endif @@ -76,185 +77,193 @@ static int create_temp_file() * Initialization: start up the weblog process. Open the pipes and pass their * file descriptors to the weblog process */ -void afs_plugin_init(int tokenExpiration, char *weblogPath,char *error_fname, char *pf, - char *cell,char *dir,int exp,char *loc,int shutdown) +void +afs_plugin_init(int tokenExpiration, char *weblogPath, char *error_fname, + char *pf, char *cell, char *dir, int exp, char *loc, + int shutdown) { - int childpid; - int pipe1[2], pipe2[2]; - char weblogarg1[32]; - char weblogarg2[32]; - char weblogarg3[32]; - char weblogarg4[32]; - - FILE *fp; /* for pid_fname */ - char *afs_weblog_pidfile; - char *httpd_pid_fname=(char *) malloc(strlen(pf)+1); - if (httpd_pid_fname == NULL) { - fprintf(stderr, "%s: malloc failed - out of memory while allocating space for httpd_pid_fname\n", module_name); - exit(-1); - } - strcpy(httpd_pid_fname, pf); - afs_weblog_pidfile=(char *) malloc(strlen(httpd_pid_fname)+5); - if (httpd_pid_fname == NULL) { - fprintf(stderr, "%s: malloc failed - out of memory while allocating space for afs_weblog_pidfile\n", module_name); - exit(-1); - } - sprintf(afs_weblog_pidfile,"%s.afs", httpd_pid_fname); - - if(do_setpag()){ - fprintf(stderr, "%s:Failed to set pag Error:%d\n", - module_name,errno); - exit(-1); - } - - afs_str = (apache_afs_glob *) malloc(sizeof(apache_afs_glob)); - if (afs_str == NULL) { - fprintf(stderr, "%s:malloc failed for afs_str\n",module_name); - exit(-1); - } - - if (cell) - strcpy(afs_str->defaultCell, cell); - else { - fprintf(stderr, "%s: NULL argument in cell\n",module_name); - exit(-1); - } - afs_str->cacheExpiration = exp; - - afslog(5, ("Default Cell:%s\nCache Expiration:%d\nDebugLevel:%d", - afs_str->defaultCell, afs_str->cacheExpiration,afsDebugLevel)); + int childpid; + int pipe1[2], pipe2[2]; + char weblogarg1[32]; + char weblogarg2[32]; + char weblogarg3[32]; + char weblogarg4[32]; + + FILE *fp; /* for pid_fname */ + char *afs_weblog_pidfile; + char *httpd_pid_fname = (char *)malloc(strlen(pf) + 1); + if (httpd_pid_fname == NULL) { + fprintf(stderr, + "%s: malloc failed - out of memory while allocating space for httpd_pid_fname\n", + module_name); + exit(-1); + } + strcpy(httpd_pid_fname, pf); + afs_weblog_pidfile = (char *)malloc(strlen(httpd_pid_fname) + 5); + if (httpd_pid_fname == NULL) { + fprintf(stderr, + "%s: malloc failed - out of memory while allocating space for afs_weblog_pidfile\n", + module_name); + exit(-1); + } + sprintf(afs_weblog_pidfile, "%s.afs", httpd_pid_fname); + + if (do_setpag()) { + fprintf(stderr, "%s:Failed to set pag Error:%d\n", module_name, + errno); + exit(-1); + } + + afs_str = (apache_afs_glob *) malloc(sizeof(apache_afs_glob)); + if (afs_str == NULL) { + fprintf(stderr, "%s:malloc failed for afs_str\n", module_name); + exit(-1); + } + + if (cell) + strcpy(afs_str->defaultCell, cell); + else { + fprintf(stderr, "%s: NULL argument in cell\n", module_name); + exit(-1); + } + afs_str->cacheExpiration = exp; + + afslog(5, + ("Default Cell:%s\nCache Expiration:%d\nDebugLevel:%d", + afs_str->defaultCell, afs_str->cacheExpiration, afsDebugLevel)); #ifdef AIX - /* Get a temp file fd for locking */ - tempfd=create_temp_file(); - if (tempfd < 0) { - fprintf(stderr, "%s: Error creating temp file", module_name); - exit(-1); - } + /* Get a temp file fd for locking */ + tempfd = create_temp_file(); + if (tempfd < 0) { + fprintf(stderr, "%s: Error creating temp file", module_name); + exit(-1); + } #endif - if (pipe(pipe1) < 0 || pipe(pipe2) < 0) { - fprintf(stderr, "%s: Error creating pipes - %s",module_name, strerror(errno)); - exit(-1); - } - if ((childpid = fork()) < 0) { - fprintf(stderr,"%s: Error forking - %s",module_name, strerror(errno)); - exit(-1); - } - else if (childpid > 0) { /* parent */ - close(pipe1[0]); - close(pipe2[1]); - readPipe = pipe2[0]; - writePipe = pipe1[1]; - } - else { /* child */ - close(pipe1[1]); - close(pipe2[0]); - fp=fopen(afs_weblog_pidfile, "w"); - if (fp == NULL) { - perror("fopen"); - fprintf(stderr, "%s: Error opening pidfile:%s - %s\n", - module_name, afs_weblog_pidfile, strerror(errno)); - close(pipe1[0]); - close(pipe2[1]); - exit(-1); + if (pipe(pipe1) < 0 || pipe(pipe2) < 0) { + fprintf(stderr, "%s: Error creating pipes - %s", module_name, + strerror(errno)); + exit(-1); } - fprintf(fp,"%ld\n", (long)getpid()); - fclose(fp); - free(afs_weblog_pidfile); - sprintf(weblogarg1, "%d", pipe1[0]); - sprintf(weblogarg2, "%d", pipe2[1]); - sprintf(weblogarg3, "%d", afs_str->cacheExpiration); - sprintf(weblogarg4, "%d", tokenExpiration); - sleep(5); - execlp(weblogPath,"weblog_starter", weblogPath, error_fname, - weblogarg1,weblogarg2,weblogarg3,weblogarg4, - NULL); - fprintf(stderr, "%s: Error executing %s - %s\n", - module_name, weblogPath, strerror(errno)); - perror("execlp"); - close(pipe1[0]); - close(pipe2[1]); - fclose(fp); - - /* exit by sending a SIGTERM to the httpd process (how to get the pid?) - * since at this point the pid file is outdated and only if we sleep for - * a while to allow httpd_main to put it's pid in the pidfile can we - * attempt to send it a SIGTERM for graceful shuttdown) - * so that everything is brought down - if you want to bring everything - * down!! Else continue with httpd without AFS authentication. - */ + if ((childpid = fork()) < 0) { + fprintf(stderr, "%s: Error forking - %s", module_name, + strerror(errno)); + exit(-1); + } else if (childpid > 0) { /* parent */ + close(pipe1[0]); + close(pipe2[1]); + readPipe = pipe2[0]; + writePipe = pipe1[1]; + } else { /* child */ + close(pipe1[1]); + close(pipe2[0]); + fp = fopen(afs_weblog_pidfile, "w"); + if (fp == NULL) { + perror("fopen"); + fprintf(stderr, "%s: Error opening pidfile:%s - %s\n", + module_name, afs_weblog_pidfile, strerror(errno)); + close(pipe1[0]); + close(pipe2[1]); + exit(-1); + } + fprintf(fp, "%ld\n", (long)getpid()); + fclose(fp); + free(afs_weblog_pidfile); + sprintf(weblogarg1, "%d", pipe1[0]); + sprintf(weblogarg2, "%d", pipe2[1]); + sprintf(weblogarg3, "%d", afs_str->cacheExpiration); + sprintf(weblogarg4, "%d", tokenExpiration); + sleep(5); + execlp(weblogPath, "weblog_starter", weblogPath, error_fname, + weblogarg1, weblogarg2, weblogarg3, weblogarg4, NULL); + fprintf(stderr, "%s: Error executing %s - %s\n", module_name, + weblogPath, strerror(errno)); + perror("execlp"); + close(pipe1[0]); + close(pipe2[1]); + fclose(fp); + + /* exit by sending a SIGTERM to the httpd process (how to get the pid?) + * since at this point the pid file is outdated and only if we sleep for + * a while to allow httpd_main to put it's pid in the pidfile can we + * attempt to send it a SIGTERM for graceful shuttdown) + * so that everything is brought down - if you want to bring everything + * down!! Else continue with httpd without AFS authentication. + */ /*#ifdef SHUTDOWN_IF_AFS_FAILS in afs_module.c */ - if (shutdown) { + if (shutdown) { #define KILL_TIME_WAIT 1 #define MAX_KILL_ATTEMPTS 3 - int attempts=0; - fp=fopen(httpd_pid_fname,"r"); - fscanf(fp,"%d", &childpid); - fclose(fp); - killagain: - sleep(KILL_TIME_WAIT); - if (kill(childpid,SIGTERM) == -1) { - if ((errno == ESRCH) && (attempts < MAX_KILL_ATTEMPTS)) { - attempts++; - fprintf(stderr, "%s:SIGTERM to process:%d FAILED attempt:%d\nRetrying " - " for %d more attempts every %d seconds\n", - module_name,childpid,attempts, - (MAX_KILL_ATTEMPTS-attempts), KILL_TIME_WAIT); - goto killagain; + int attempts = 0; + fp = fopen(httpd_pid_fname, "r"); + fscanf(fp, "%d", &childpid); + fclose(fp); + killagain: + sleep(KILL_TIME_WAIT); + if (kill(childpid, SIGTERM) == -1) { + if ((errno == ESRCH) && (attempts < MAX_KILL_ATTEMPTS)) { + attempts++; + fprintf(stderr, + "%s:SIGTERM to process:%d FAILED attempt:%d\nRetrying " + " for %d more attempts every %d seconds\n", + module_name, childpid, attempts, + (MAX_KILL_ATTEMPTS - attempts), KILL_TIME_WAIT); + goto killagain; + } + } else { + fprintf(stderr, "%s:Shutdown complete ...\n", module_name); + } + if (attempts >= MAX_KILL_ATTEMPTS) { + fprintf(stderr, + "%s:httpd is still running-AFS authentication will fail " + "because weblog startup failed\n", module_name); + } + exit(0); + } else { + fprintf(stderr, + "%s:httpd running - AFS Authentication will not work! " + "Weblog startup failure", module_name); + exit(-1); } - } - else { - fprintf(stderr, "%s:Shutdown complete ...\n", module_name); - } - if (attempts >= MAX_KILL_ATTEMPTS) { - fprintf(stderr, - "%s:httpd is still running-AFS authentication will fail " - "because weblog startup failed\n",module_name); - } - exit(0); } - else { - fprintf(stderr, "%s:httpd running - AFS Authentication will not work! " - "Weblog startup failure", module_name); - exit(-1); - } - } } /* * Returns HTTP error codes based on the result of a stat error */ -static int sort_stat_error(request_rec *r) +static int +sort_stat_error(request_rec * r) { - int status = 0; - switch(errno) { - case ENOENT: - status = HTTP_NOT_FOUND; - break; - - case EACCES: - status = FORBIDDEN; - break; - - case ENOLINK: - status = HTTP_NOT_FOUND; - break; - - case ENODEV: - status = HTTP_NOT_FOUND; - break; - - default: - { - char error[ERRSTRLEN]; - sprintf(error,"%s: stat error: %s",module_name, strerror(errno)); - status = SERVER_ERROR; - LOG_REASON(error,r->uri, r); - break; + int status = 0; + switch (errno) { + case ENOENT: + status = HTTP_NOT_FOUND; + break; + + case EACCES: + status = FORBIDDEN; + break; + + case ENOLINK: + status = HTTP_NOT_FOUND; + break; + + case ENODEV: + status = HTTP_NOT_FOUND; + break; + + default: + { + char error[ERRSTRLEN]; + sprintf(error, "%s: stat error: %s", module_name, + strerror(errno)); + status = SERVER_ERROR; + LOG_REASON(error, r->uri, r); + break; + } } - } - return status; + return status; } /* @@ -268,197 +277,205 @@ static int sort_stat_error(request_rec *r) - sets the filename field - sets the path_info field */ -static int remove_path_info(request_rec *r, char *path, struct stat *buf) +static int +remove_path_info(request_rec * r, char *path, struct stat *buf) { - char *cp; - char *end; - char *last_cp = NULL; - int rc = 0; - - afsassert(r); - afsassert(path); - afsassert(buf); - - end = &path[strlen(path)]; - - /* Advance over trailing slashes ... NOT part of filename */ - for (cp = end; cp > path && cp[-1] == '/'; --cp) - continue; - - while (cp > path) { - /* See if the pathname ending here exists... */ - *cp = '\0'; - errno = 0; - rc = stat(path, buf); - if (cp != end) - *cp = '/'; - - if (!rc) { - if (S_ISDIR(buf->st_mode) && last_cp) { - buf->st_mode = 0; /* No such file... */ - cp = last_cp; - } - r->path_info = pstrdup(r->pool, cp); - *cp = '\0'; - return OK; - } - - else if (errno == ENOENT || errno == ENOTDIR) { - last_cp = cp; - while (--cp > path && *cp != '/') - continue; - while (cp > path && cp[-1] == '/') - --cp; - } - else if (errno != EACCES) { - /* - * this would be really bad since we checked the entire path - * earlier and got ENOTDIR instead of EACCES - so why are we getting - * it now? Anyway, we ought to return FORBIDDEN - */ - return HTTP_FORBIDDEN; + char *cp; + char *end; + char *last_cp = NULL; + int rc = 0; + + afsassert(r); + afsassert(path); + afsassert(buf); + + end = &path[strlen(path)]; + + /* Advance over trailing slashes ... NOT part of filename */ + for (cp = end; cp > path && cp[-1] == '/'; --cp) + continue; + + while (cp > path) { + /* See if the pathname ending here exists... */ + *cp = '\0'; + errno = 0; + rc = stat(path, buf); + if (cp != end) + *cp = '/'; + + if (!rc) { + if (S_ISDIR(buf->st_mode) && last_cp) { + buf->st_mode = 0; /* No such file... */ + cp = last_cp; + } + r->path_info = pstrdup(r->pool, cp); + *cp = '\0'; + return OK; + } + + else if (errno == ENOENT || errno == ENOTDIR) { + last_cp = cp; + while (--cp > path && *cp != '/') + continue; + while (cp > path && cp[-1] == '/') + --cp; + } else if (errno != EACCES) { + /* + * this would be really bad since we checked the entire path + * earlier and got ENOTDIR instead of EACCES - so why are we getting + * it now? Anyway, we ought to return FORBIDDEN + */ + return HTTP_FORBIDDEN; + } } - } - r->filename = pstrdup(r->pool, path); - return OK; + r->filename = pstrdup(r->pool, path); + return OK; } - + /* * Checks to see if actual access to the URL is permitted or not * stats the URI first, if failure returns FORBIDDEN, if allowed then * checks to see if it is a file, dir or LINK (TEST), and accordingly does more */ -static int can_access(request_rec *r) +static int +can_access(request_rec * r) { - int rc; - char *doc_root = (char *)DOCUMENT_ROOT(r); - struct stat buf; - char path[MAX_STRING_LEN]; - - afsassert(r->uri); - afsassert(doc_root); - - if (r->filename) { - afslog(10, ("%s: Found r->filename:%s", module_name, r->filename)); - sprintf(path,"%s",r->filename); - } - else { - afslog(10, ("%s: Composing path from doc_root:%s and r->uri:%s", + int rc; + char *doc_root = (char *)DOCUMENT_ROOT(r); + struct stat buf; + char path[MAX_STRING_LEN]; + + afsassert(r->uri); + afsassert(doc_root); + + if (r->filename) { + afslog(10, ("%s: Found r->filename:%s", module_name, r->filename)); + sprintf(path, "%s", r->filename); + } else { + afslog(10, + ("%s: Composing path from doc_root:%s and r->uri:%s", module_name, doc_root, r->uri)); - sprintf(path,"%s/%s",doc_root,r->uri); - afslog(10, ("%s: Path:%s", module_name, path)); - } - rc = stat(path, &buf); - if (rc == -1) { - afslog(2, ("%s: pid:%d\tpath:%s\tstat error:%s", - module_name, getpid(), path, strerror(errno))); - - /* - * if the requested method is an HTTP PUT and the file does not - * exist then well, we'll get a stat error but we shouldn't return - * an error - we should try and open the file in append mode and then - * see if we get a permission denied error - */ - if ((strncmp(r->method,"PUT",3) == 0) && (errno == ENOENT)) { - FILE *f=fopen(path,"a"); - if (f == NULL) { - if (errno == EACCES) { - afslog(2, ("%s: Either AFS acls or other permissions forbid write" - " access to file %s for user %s", module_name, path, - r->connection->user ? r->connection->user : "UNKNOWN")); - return FORBIDDEN; - } - else { - log_reason("afs_module: Error checking file for PUT method",r->uri,r); - return SERVER_ERROR; - } - } + sprintf(path, "%s/%s", doc_root, r->uri); + afslog(10, ("%s: Path:%s", module_name, path)); } - else if (errno == ENOTDIR) { - /* - * maybe the special case of CGI PATH_INFO to be translated to - * PATH_TRANSLATED - check each component of this path - * and stat it to see what portion of the url is actually - * the path and discard the rest for our purposes. - */ - rc = remove_path_info(r, path, &buf); - afslog(10,("%s:remove_path_info returned %d path:%s", - module_name, rc, path)); - if (rc) - return rc; - } - else { - return sort_stat_error(r); - } - } - /* - * If we get here then we have something - either a file or a directory - */ - else { - if (S_IFREG == (buf.st_mode & S_IFMT)) { - /* regular file */ - FILE *f; - char permissions[] = { 'r', '\0', '\0', '\0' }; /* room for +, etc... */ - - if ((strncmp(r->method, "PUT",3) == 0)) { - strcpy(permissions,"a"); - } - if(!(f = fopen(path,permissions))) { - if (errno == EACCES) { - afslog(2, ("%s: Either AFS acls or other permissions" - " forbid access to file %s for user %s", module_name, path, - r->connection->user ? r->connection->user : "UNKNOWN")); - return FORBIDDEN; - } - else { - char error[ERRSTRLEN]; - sprintf(error,"%s: Error checking file %s for permissions:%s", - module_name, path, strerror(errno)); - log_reason(error, r->uri, r); - return SERVER_ERROR; + rc = stat(path, &buf); + if (rc == -1) { + afslog(2, + ("%s: pid:%d\tpath:%s\tstat error:%s", module_name, getpid(), + path, strerror(errno))); + + /* + * if the requested method is an HTTP PUT and the file does not + * exist then well, we'll get a stat error but we shouldn't return + * an error - we should try and open the file in append mode and then + * see if we get a permission denied error + */ + if ((strncmp(r->method, "PUT", 3) == 0) && (errno == ENOENT)) { + FILE *f = fopen(path, "a"); + if (f == NULL) { + if (errno == EACCES) { + afslog(2, + ("%s: Either AFS acls or other permissions forbid write" + " access to file %s for user %s", module_name, + path, + r->connection->user ? r->connection-> + user : "UNKNOWN")); + return FORBIDDEN; + } else { + log_reason + ("afs_module: Error checking file for PUT method", + r->uri, r); + return SERVER_ERROR; + } + } + } else if (errno == ENOTDIR) { + /* + * maybe the special case of CGI PATH_INFO to be translated to + * PATH_TRANSLATED - check each component of this path + * and stat it to see what portion of the url is actually + * the path and discard the rest for our purposes. + */ + rc = remove_path_info(r, path, &buf); + afslog(10, + ("%s:remove_path_info returned %d path:%s", module_name, + rc, path)); + if (rc) + return rc; + } else { + return sort_stat_error(r); } - } - fclose(f); - return OK; } - if (S_IFDIR == (buf.st_mode&S_IFMT)) { - /* path is a directory */ - - if (r->uri[strlen(r->uri)-1] != '/'){ - /* if we don't have a trailing slash, return REDIRECT */ - char *ifile; - if (r->args != NULL) { - ifile = PSTRCAT (r->pool, escape_uri(r->pool, r->uri), - "/", "?", r->args, NULL); - } - else { - ifile = PSTRCAT (r->pool, escape_uri(r->pool, r->uri), - "/", NULL); + /* + * If we get here then we have something - either a file or a directory + */ + else { + if (S_IFREG == (buf.st_mode & S_IFMT)) { + /* regular file */ + FILE *f; + char permissions[] = { 'r', '\0', '\0', '\0' }; /* room for +, etc... */ + + if ((strncmp(r->method, "PUT", 3) == 0)) { + strcpy(permissions, "a"); + } + if (!(f = fopen(path, permissions))) { + if (errno == EACCES) { + afslog(2, + ("%s: Either AFS acls or other permissions" + " forbid access to file %s for user %s", + module_name, path, + r->connection->user ? r->connection-> + user : "UNKNOWN")); + return FORBIDDEN; + } else { + char error[ERRSTRLEN]; + sprintf(error, + "%s: Error checking file %s for permissions:%s", + module_name, path, strerror(errno)); + log_reason(error, r->uri, r); + return SERVER_ERROR; + } + } + fclose(f); + return OK; } - TABLE_SET (r->headers_out, "Location",ifile); - return REDIRECT; - } - else { - DIR *d; - if(!(d = opendir(path))) { - if (errno == EACCES) { - afslog(2, ("%s: Error accessing dir %s - %s", - module_name, path, strerror(errno))); - return FORBIDDEN; - } - else { - char error[ERRSTRLEN]; - sprintf(error,"%s: opendir failed with Error:%s", - module_name, strerror(errno)); - log_reason(error,r,r->uri); - return SERVER_ERROR; - } + if (S_IFDIR == (buf.st_mode & S_IFMT)) { + /* path is a directory */ + + if (r->uri[strlen(r->uri) - 1] != '/') { + /* if we don't have a trailing slash, return REDIRECT */ + char *ifile; + if (r->args != NULL) { + ifile = + PSTRCAT(r->pool, escape_uri(r->pool, r->uri), "/", + "?", r->args, NULL); + } else { + ifile = + PSTRCAT(r->pool, escape_uri(r->pool, r->uri), "/", + NULL); + } + TABLE_SET(r->headers_out, "Location", ifile); + return REDIRECT; + } else { + DIR *d; + if (!(d = opendir(path))) { + if (errno == EACCES) { + afslog(2, + ("%s: Error accessing dir %s - %s", + module_name, path, strerror(errno))); + return FORBIDDEN; + } else { + char error[ERRSTRLEN]; + sprintf(error, "%s: opendir failed with Error:%s", + module_name, strerror(errno)); + log_reason(error, r, r->uri); + return SERVER_ERROR; + } + } + closedir(d); + return OK; + } } - closedir(d); - return OK; - } } - } } @@ -466,117 +483,129 @@ static int can_access(request_rec *r) * Logs requests which led to a FORBIDDEN return code provided a token * existed. Added feature (SetAFSAccessLog) in beta2 */ -static int log_Access_Error(request_rec *r) +static int +log_Access_Error(request_rec * r) { - if(FIND_LINKED_MODULE("afs_module.c") != NULL) { - char err_msg[1024]; - int rc = 0; - int len = 0; - extern int logfd; - - if (r->connection->user) - sprintf(err_msg, "[%s] AFS ACL's deny permission to " - "user: %s for URI:%s\n",GET_TIME(), r->connection->user, r->uri); - else - sprintf(err_msg,"[%s] AFS ACL's deny permission to user - for URI:%s\n", - GET_TIME(), r->uri); - - len=strlen(err_msg); - rc=write(logfd, err_msg, len); - - if(rc != len){ - afslog(0, ("%s: Error logging message:%s - %s", - module_name, err_msg, strerror(errno))); - return -1; + if (FIND_LINKED_MODULE("afs_module.c") != NULL) { + char err_msg[1024]; + int rc = 0; + int len = 0; + extern int logfd; + + if (r->connection->user) + sprintf(err_msg, + "[%s] AFS ACL's deny permission to " + "user: %s for URI:%s\n", GET_TIME(), r->connection->user, + r->uri); + else + sprintf(err_msg, + "[%s] AFS ACL's deny permission to user - for URI:%s\n", + GET_TIME(), r->uri); + + len = strlen(err_msg); + rc = write(logfd, err_msg, len); + + if (rc != len) { + afslog(0, + ("%s: Error logging message:%s - %s", module_name, err_msg, + strerror(errno))); + return -1; + } + return rc; } - return rc; - } } /* * The interface - hook to obtain an AFS token if needed based on the * result of a stat (returned by can_access) or an open file */ -int afs_auth_internal(request_rec *r, char *cell) +int +afs_auth_internal(request_rec * r, char *cell) { - afsassert(r); - afsassert(r->uri); - afsassert(cell); - if(FIND_LINKED_MODULE("afs_module.c") != NULL) { - int rc, status; - char *type; - static int haveToken = 1; /* assume that we always have a token */ - extern int logAccessErrors; - - /* - * Get afs_authtype directive value for that directory or location - */ - type = (char *) get_afsauthtype(r); - - /* - * UserDir (tilde) support - */ + afsassert(r); + afsassert(r->uri); + afsassert(cell); + if (FIND_LINKED_MODULE("afs_module.c") != NULL) { + int rc, status; + char *type; + static int haveToken = 1; /* assume that we always have a token */ + extern int logAccessErrors; + + /* + * Get afs_authtype directive value for that directory or location + */ + type = (char *)get_afsauthtype(r); + + /* + * UserDir (tilde) support + */ #ifndef APACHE_1_3 - if (FIND_LINKED_MODULE("mod_userdir.c") != NULL) { - rc=translate_userdir(r); - if ((rc != OK) && (rc != DECLINED)) { - LOG_REASON("afs_module: Failure while translating userdir", r->uri,r); - return rc; - } - } + if (FIND_LINKED_MODULE("mod_userdir.c") != NULL) { + rc = translate_userdir(r); + if ((rc != OK) && (rc != DECLINED)) { + LOG_REASON("afs_module: Failure while translating userdir", + r->uri, r); + return rc; + } + } #endif - afslog(20, ("%s: pid:%d r->uri:%s", module_name, getpid(), r->uri)); - if (type) - afslog(20, ("%s: AFSAuthType: %s", module_name, type)); - else - afslog(20, ("%s: AFSAuthType NULL", module_name)); - - /* if AuthType is not AFS, then unlog any existing tokens and DECLINE */ - if (type == NULL) { - if (haveToken) - unlog(); - return DECLINED; - } + afslog(20, ("%s: pid:%d r->uri:%s", module_name, getpid(), r->uri)); + if (type) + afslog(20, ("%s: AFSAuthType: %s", module_name, type)); + else + afslog(20, ("%s: AFSAuthType NULL", module_name)); + + /* if AuthType is not AFS, then unlog any existing tokens and DECLINE */ + if (type == NULL) { + if (haveToken) + unlog(); + return DECLINED; + } - if((strcasecmp(type, AFS_AUTHTYPE)) && (strcasecmp(type,AFS_DFS_AUTHTYPE))) { - if (haveToken) - unlog(); - afslog(10, ("%s: Error unknown AFSAuthType:%s returning DECLINED", - module_name, type)); - return DECLINED; - } - - if (cell) - status=authenticateUser(r, cell, afs_str->cacheExpiration, type); - else - status=authenticateUser(r, afs_str->defaultCell, afs_str->cacheExpiration, type); - - if (status != OK ) { - afslog(10, ("%s: Returning status %d", module_name, status)); - return status; - } - - /* can we access this URL? */ - rc = can_access(r); - - if (rc == OK) { - return DECLINED; - } - - if (rc == REDIRECT) { - return REDIRECT; - } - - if (rc == FORBIDDEN) { - rc = forbToAuthReqd(r); - if (rc == FORBIDDEN) { - if (logAccessErrors) { - log_Access_Error(r); + if ((strcasecmp(type, AFS_AUTHTYPE)) + && (strcasecmp(type, AFS_DFS_AUTHTYPE))) { + if (haveToken) + unlog(); + afslog(10, + ("%s: Error unknown AFSAuthType:%s returning DECLINED", + module_name, type)); + return DECLINED; + } + + if (cell) + status = + authenticateUser(r, cell, afs_str->cacheExpiration, type); + else + status = + authenticateUser(r, afs_str->defaultCell, + afs_str->cacheExpiration, type); + + if (status != OK) { + afslog(10, ("%s: Returning status %d", module_name, status)); + return status; + } + + /* can we access this URL? */ + rc = can_access(r); + + if (rc == OK) { + return DECLINED; + } + + if (rc == REDIRECT) { + return REDIRECT; + } + + if (rc == FORBIDDEN) { + rc = forbToAuthReqd(r); + if (rc == FORBIDDEN) { + if (logAccessErrors) { + log_Access_Error(r); + } + } + return rc; } - } - return rc; + return DECLINED; } - return DECLINED; - } } diff --git a/src/afsweb/apache_afs_utils.c b/src/afsweb/apache_afs_utils.c index aa12df4fc..8ae4501e3 100644 --- a/src/afsweb/apache_afs_utils.c +++ b/src/afsweb/apache_afs_utils.c @@ -23,44 +23,48 @@ * sets up the ViceIoctl buffer with all the parameters required * NOTE: in_buffer and out_buffer may point to the same memory buffer */ -int do_pioctl(char *in_buffer, int in_size, - char *out_buffer, int out_size, - int opcode, char *path, int followSymLinks) +int +do_pioctl(char *in_buffer, int in_size, char *out_buffer, int out_size, + int opcode, char *path, int followSymLinks) { - struct ViceIoctl iob; - iob.in = in_buffer; - iob.in_size = in_size; - iob.out = out_buffer; - iob.out_size = out_size; - + struct ViceIoctl iob; + iob.in = in_buffer; + iob.in_size = in_size; + iob.out = out_buffer; + iob.out_size = out_size; + #ifdef AFS_USR_SUN5_ENV - return syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, _VICEIOCTL(opcode), &iob, - followSymLinks); + return syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, _VICEIOCTL(opcode), + &iob, followSymLinks); #else /* AFS_USR_SUN5_ENV */ - return lpioctl(path, _VICEIOCTL(opcode), &iob, followSymLinks); + return lpioctl(path, _VICEIOCTL(opcode), &iob, followSymLinks); #endif /* AFS_USR_SUN5_ENV */ } -int do_setpag() +int +do_setpag() { - return lsetpag(); + return lsetpag(); } /* * Return 1 if we have a token, 0 if we don't */ -int haveToken() +int +haveToken() { - char temp[1024]; - afs_int32 i = 0; - int code; + char temp[1024]; + afs_int32 i = 0; + int code; - memcpy((void *)temp, (void *)&i, sizeof(afs_int32)); - code = do_pioctl(temp, sizeof(afs_int32), temp, sizeof(temp),VIOCGETTOK, NULL,0); - if (code) - return 0; - else - return 1; + memcpy((void *)temp, (void *)&i, sizeof(afs_int32)); + code = + do_pioctl(temp, sizeof(afs_int32), temp, sizeof(temp), VIOCGETTOK, + NULL, 0); + if (code) + return 0; + else + return 1; } @@ -70,66 +74,69 @@ int haveToken() */ flipPrimary(char *tokenBuf) { - afs_int32 i; - char * temp = tokenBuf; - - /* skip over the secret token */ - memcpy(&i, temp, sizeof(afs_int32)); - temp += (i + sizeof(afs_int32)); - - /* skip over the clear token */ - memcpy(&i, temp, sizeof(afs_int32)); - temp += (i + sizeof(afs_int32)); - - /* set the primary flag */ - memcpy(&i, temp, sizeof(afs_int32)); - i |= 0x8000; - memcpy(temp, &i, sizeof(afs_int32)); - temp += sizeof(afs_int32); - return 0; + afs_int32 i; + char *temp = tokenBuf; + + /* skip over the secret token */ + memcpy(&i, temp, sizeof(afs_int32)); + temp += (i + sizeof(afs_int32)); + + /* skip over the clear token */ + memcpy(&i, temp, sizeof(afs_int32)); + temp += (i + sizeof(afs_int32)); + + /* set the primary flag */ + memcpy(&i, temp, sizeof(afs_int32)); + i |= 0x8000; + memcpy(temp, &i, sizeof(afs_int32)); + temp += sizeof(afs_int32); + return 0; } -/* get the current AFS pag for the calling process */ -static afs_int32 curpag() +/* get the current AFS pag for the calling process */ +static afs_int32 +curpag() { - gid_t groups[30]; - afs_uint32 g0, g1; - afs_uint32 h, l, ret; - - if (getgroups(sizeof groups/sizeof groups[0], groups) < 2) return 0; - - g0 = groups[0] & 0xffff; - g1 = groups[1] & 0xffff; - g0 -= 0x3f00; - g1 -= 0x3f00; - if (g0 < 0xc000 && g1 < 0xc000) { - l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff); - h = (g0 >> 14); - h = (g1 >> 14) + h + h + h; - ret = ((h << 28) | l); - /* Additional testing */ - if (((ret >> 24) & 0xff) == 'A') - return ret; - else - return -1; - } - return -1; + gid_t groups[30]; + afs_uint32 g0, g1; + afs_uint32 h, l, ret; + + if (getgroups(sizeof groups / sizeof groups[0], groups) < 2) + return 0; + + g0 = groups[0] & 0xffff; + g1 = groups[1] & 0xffff; + g0 -= 0x3f00; + g1 -= 0x3f00; + if (g0 < 0xc000 && g1 < 0xc000) { + l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff); + h = (g0 >> 14); + h = (g1 >> 14) + h + h + h; + ret = ((h << 28) | l); + /* Additional testing */ + if (((ret >> 24) & 0xff) == 'A') + return ret; + else + return -1; + } + return -1; } /* Returns the AFS pag number, if any, otherwise return -1 */ -afs_int32 getPAG() +afs_int32 +getPAG() { - afs_int32 pag; + afs_int32 pag; - assert(sizeof(afs_uint32) == 4); - assert(sizeof(afs_int32) == 4); + assert(sizeof(afs_uint32) == 4); + assert(sizeof(afs_int32) == 4); - pag = curpag(); - if (pag == 0 || pag == -1) - return -1; + pag = curpag(); + if (pag == 0 || pag == -1) + return -1; - /* high order byte is always 'A'; actual pag value is low 24 bits */ - return (pag & 0xFFFFFF); + /* high order byte is always 'A'; actual pag value is low 24 bits */ + return (pag & 0xFFFFFF); } /* @@ -138,46 +145,48 @@ afs_int32 getPAG() * the directive SetAFSDebugLevel in the httpd.conf file */ /* VARARGS1 */ -void afsLogError (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -char * a; -char * b; -char * c; -char * d; -char * e; -char * f; -char * g; -char * h; -char * i; -char * j; -char * k; -char * l; -char * m; -char * n; +void +afsLogError(a, b, c, d, e, f, g, h, i, j, k, l, m, n) + char *a; + char *b; + char *c; + char *d; + char *e; + char *f; + char *g; + char *h; + char *i; + char *j; + char *k; + char *l; + char *m; + char *n; { - char reason[1024]; - - sprintf (reason, a,b,c,d,e,f,g,h,i,j,k,l,m,n); - /* LOG_REASON(reason,r->uri,r); */ - strcat(reason,"\n"); - fprintf(stderr, reason); + char reason[1024]; + + sprintf(reason, a, b, c, d, e, f, g, h, i, j, k, l, m, n); + /* LOG_REASON(reason,r->uri,r); */ + strcat(reason, "\n"); + fprintf(stderr, reason); } - + /* the following are debug utilities */ -void hexDump(char *tbuffer, int len) +void +hexDump(char *tbuffer, int len) { - int i; - int byte; - char *temp = tbuffer; - - fprintf(stderr, "HEXDUMP:\n"); - for (i=0; i < len; i++) { - byte = *temp; - temp++; - fprintf(stderr, "%x",byte); - } - fprintf(stderr, "\n"); + int i; + int byte; + char *temp = tbuffer; + + fprintf(stderr, "HEXDUMP:\n"); + for (i = 0; i < len; i++) { + byte = *temp; + temp++; + fprintf(stderr, "%x", byte); + } + fprintf(stderr, "\n"); } /* @@ -185,67 +194,71 @@ void hexDump(char *tbuffer, int len) * call this before and after the routine to dosetpag and verify results */ -int printGroups() +int +printGroups() { - int numGroups,i; - gid_t grouplist[NGROUPS_MAX]; + int numGroups, i; + gid_t grouplist[NGROUPS_MAX]; - numGroups = getgroups(NGROUPS_MAX, &grouplist[0]); - if (numGroups == -1) { - perror("getgroups:"); - return -1; - } - for (i=0; i #include @@ -16,8 +16,8 @@ #include #include -#include /* had to put this for in_addr used in venus.h */ -#include /* for pioctl opcode defines */ +#include /* had to put this for in_addr used in venus.h */ +#include /* for pioctl opcode defines */ #include "assert.h" @@ -29,9 +29,9 @@ #endif /* !MAX */ -extern int do_pioctl(char *in_buffer, int in_size, - char *out_buffer, int out_size, - int opcode, char *path, int followSymLinks); +extern int do_pioctl(char *in_buffer, int in_size, char *out_buffer, + int out_size, int opcode, char *path, + int followSymLinks); extern int flipPrimary(char *tokenBuf); extern afs_int32 getPAG(); diff --git a/src/afsweb/apache_afs_weblog.c b/src/afsweb/apache_afs_weblog.c index accca8ef1..8468e05f3 100644 --- a/src/afsweb/apache_afs_weblog.c +++ b/src/afsweb/apache_afs_weblog.c @@ -31,224 +31,229 @@ #define WEBLOG_BIN "weblog" /* TODO - set restart_attempts to 0 if not within certain time period */ -#define MAX_RESTARTS 3 /* after this many restarts just die */ -static int restart_attempts=0; +#define MAX_RESTARTS 3 /* after this many restarts just die */ +static int restart_attempts = 0; -int error_fd; /* error file descriptor */ +int error_fd; /* error file descriptor */ -void sig_term() { +void +sig_term() +{ #ifdef AIX - pid_t pgrp=getpgrp(); + pid_t pgrp = getpgrp(); #else - pid_t pgrp=getpgrp(0); + pid_t pgrp = getpgrp(0); #endif - int n; + int n; #ifdef DEBUG - write(2, "weblog_starter: caught SIGTERM, shutting down",43); + write(2, "weblog_starter: caught SIGTERM, shutting down", 43); #endif - log_error("weblog_starter: caught SIGTERM, shutting down"); + log_error("weblog_starter: caught SIGTERM, shutting down"); - if (pgrp == (pid_t)-1) { - log_error("getpgrp failed - kill weblog manually"); - write(2,"getpgrp failed - kill weblog manually",38); + if (pgrp == (pid_t) - 1) { + log_error("getpgrp failed - kill weblog manually"); + write(2, "getpgrp failed - kill weblog manually", 38); + exit(1); + } + kill(-pgrp, SIGKILL); exit(1); - } - kill(-pgrp,SIGKILL); - exit(1); } /* strip out this binary and replace it with the weblog binary's name */ -getpath(char *this, char *path) { - char *temp=&this[0]; - int len=strlen(this); - int pos=0,i=0,j=0; - char bin_name[]=WEBLOG_BIN; - int len1=strlen(bin_name); - - strcpy(path,this); - temp+=(len); - pos=len; - while(*temp != '/') { - temp--; - pos--; - } - for (i=(pos+1);i=len1) - break; - } +getpath(char *this, char *path) +{ + char *temp = &this[0]; + int len = strlen(this); + int pos = 0, i = 0, j = 0; + char bin_name[] = WEBLOG_BIN; + int len1 = strlen(bin_name); + + strcpy(path, this); + temp += (len); + pos = len; + while (*temp != '/') { + temp--; + pos--; + } + for (i = (pos + 1); i < len; i++, j++) { + path[i] = bin_name[j]; + if (j >= len1) + break; + } } -char *get_time() { +char * +get_time() +{ time_t t; char *time_string; - t=time(NULL); - time_string = (char *) ctime((time_t *) &t); + t = time(NULL); + time_string = (char *)ctime((time_t *) & t); time_string[strlen(time_string) - 1] = '\0'; return (time_string); } log_error(char *msg) { - char err_msg[1024]; + char err_msg[1024]; - sprintf(err_msg,"[%s] weblog:%s\n",get_time(), msg); - write(error_fd,(void *) err_msg, strlen(err_msg)); + sprintf(err_msg, "[%s] weblog:%s\n", get_time(), msg); + write(error_fd, (void *)err_msg, strlen(err_msg)); } -int main(int argc, char **argv) +int +main(int argc, char **argv) { - pid_t weblog_pid; - int stat=-1; - int exitstatus=0; - char rn[]="weblog_starter"; - char path[1024]; - char error_fname[1024]; - - struct sigaction sa; - - memset(&sa,0,sizeof sa); - sa.sa_handler=(void (*)())sig_term; - if(sigaction(SIGTERM,&sa,NULL) < 0) { - perror("sigaction(SIGTERM)"); - } - - getpath(argv[1], path); - strcpy(error_fname,argv[2]); - - error_fd=open(error_fname,O_WRONLY|O_APPEND|O_CREAT); - if (error_fd < 0) { - fprintf(stderr, "%s:Error opening log file:%s\nExiting\n",rn,error_fname); - perror("open"); - exit(-1); - } - - log_error("weblog_starter resuming normal operation"); - - while(restart_attempts < MAX_RESTARTS) { - /* fork the weblog process and wait till it exits */ - if((weblog_pid=fork()) < 0) { - log_error("Could not fork process"); + pid_t weblog_pid; + int stat = -1; + int exitstatus = 0; + char rn[] = "weblog_starter"; + char path[1024]; + char error_fname[1024]; + + struct sigaction sa; + + memset(&sa, 0, sizeof sa); + sa.sa_handler = (void (*)())sig_term; + if (sigaction(SIGTERM, &sa, NULL) < 0) { + perror("sigaction(SIGTERM)"); + } + + getpath(argv[1], path); + strcpy(error_fname, argv[2]); + + error_fd = open(error_fname, O_WRONLY | O_APPEND | O_CREAT); + if (error_fd < 0) { + fprintf(stderr, "%s:Error opening log file:%s\nExiting\n", rn, + error_fname); + perror("open"); + exit(-1); + } + + log_error("weblog_starter resuming normal operation"); + + while (restart_attempts < MAX_RESTARTS) { + /* fork the weblog process and wait till it exits */ + if ((weblog_pid = fork()) < 0) { + log_error("Could not fork process"); #ifdef DEBUG - perror("apache_afs_weblog:Could not fork process"); + perror("apache_afs_weblog:Could not fork process"); #endif - exit(-1); - } - switch (weblog_pid) { - case 0: - /* the child process - in this case weblog */ - execlp(path, "weblog", argv[3],argv[4],argv[5],argv[6],NULL); + exit(-1); + } + switch (weblog_pid) { + case 0: + /* the child process - in this case weblog */ + execlp(path, "weblog", argv[3], argv[4], argv[5], argv[6], NULL); #ifdef DEBUG - perror("apache_afs_weblog:Could not execute weblog"); -#endif - exit(RESTARTERROR); - - default: - /* parent: just wait for the child */ - weblog_pid=waitpid((pid_t) -1, &stat,0); - - if (weblog_pid == -1) { + perror("apache_afs_weblog:Could not execute weblog"); +#endif + exit(RESTARTERROR); + + default: + /* parent: just wait for the child */ + weblog_pid = waitpid((pid_t) - 1, &stat, 0); + + if (weblog_pid == -1) { #ifdef DEBUG - perror("apache_Afs_weblog: wait error"); -#endif - log_error("wait error"); - kill(getpid(),SIGTERM); - } - - if (WIFEXITED(stat)) { - exitstatus=WEXITSTATUS(stat); - switch(exitstatus) { - case 0: + perror("apache_Afs_weblog: wait error"); +#endif + log_error("wait error"); + kill(getpid(), SIGTERM); + } + + if (WIFEXITED(stat)) { + exitstatus = WEXITSTATUS(stat); + switch (exitstatus) { + case 0: #ifdef DEBUG - fprintf(stderr, "%s:No error ... restarting\n",rn); + fprintf(stderr, "%s:No error ... restarting\n", rn); #endif - break; - - case RESTART: + break; + + case RESTART: #ifdef DEBUG - fprintf(stderr, "%s:%s...Exiting\n", rn, RESTARTMSG); + fprintf(stderr, "%s:%s...Exiting\n", rn, RESTARTMSG); #endif - log_error(RESTARTMSG); - exit(-1); - - case NULLARGS: + log_error(RESTARTMSG); + exit(-1); + + case NULLARGS: #ifdef DEBUG - fprintf(stderr, "%s:%s...Exiting\n", rn, NULLARGSMSG); - log_error(NULLARGSMSG); + fprintf(stderr, "%s:%s...Exiting\n", rn, NULLARGSMSG); + log_error(NULLARGSMSG); #endif - exit(-1); - - case PIPESEND: + exit(-1); + + case PIPESEND: #ifdef DEBUG - fprintf(stderr, "%s:%s...Restarting\n", rn, PIPESENDMSG); + fprintf(stderr, "%s:%s...Restarting\n", rn, PIPESENDMSG); #endif - log_error(PIPESENDMSG); - break; - - case PIPEREAD: + log_error(PIPESENDMSG); + break; + + case PIPEREAD: #ifdef DEBUG - fprintf(stderr, "%s:%s...Exiting\n", rn, PIPEREADMSG); + fprintf(stderr, "%s:%s...Exiting\n", rn, PIPEREADMSG); #endif - log_error(PIPEREADMSG); - exit(-1); - - case PARSE: + log_error(PIPEREADMSG); + exit(-1); + + case PARSE: #ifdef DEBUG - fprintf(stderr, "%s:%s...Exiting\n", rn, PARSEMSG); + fprintf(stderr, "%s:%s...Exiting\n", rn, PARSEMSG); #endif - log_error(PARSEMSG); - exit(-1); - - case KA: + log_error(PARSEMSG); + exit(-1); + + case KA: #ifdef DEBUG - fprintf(stderr, "%s:%s...Exiting\n", rn, KAMSG); + fprintf(stderr, "%s:%s...Exiting\n", rn, KAMSG); #endif - log_error(KAMSG); - exit(-1); - - default: + log_error(KAMSG); + exit(-1); + + default: #ifdef DEBUG - fprintf(stderr, "%s:Unknown error...Exiting\n", rn); -#endif - log_error("Unknown error"); - exit(-1); - } /* switch (exitstatus) */ - } /* if weblog exited */ - - else { /* weblog terminated abnormally */ - if (WIFSIGNALED(stat)) { + fprintf(stderr, "%s:Unknown error...Exiting\n", rn); +#endif + log_error("Unknown error"); + exit(-1); + } /* switch (exitstatus) */ + } + /* if weblog exited */ + else { /* weblog terminated abnormally */ + if (WIFSIGNALED(stat)) { #ifdef DEBUG - fprintf(stderr, "%s:The signal that terminated weblog:%d\n" - "Restarting weblog ...\n",rn,WTERMSIG(stat)); + fprintf(stderr, + "%s:The signal that terminated weblog:%d\n" + "Restarting weblog ...\n", rn, WTERMSIG(stat)); #endif - } + } #ifndef AIX - else if (WCOREDUMP(stat)){ + else if (WCOREDUMP(stat)) { #ifdef DEBUG - fprintf(stderr, "%s: weblog dumped core" - "Exiting ...\n",rn); + fprintf(stderr, "%s: weblog dumped core" "Exiting ...\n", + rn); #endif - log_error("Core dump"); - exit(-1); - } + log_error("Core dump"); + exit(-1); + } #endif - else { + else { #ifdef DEBUG - fprintf(stderr, "%s: weblog died under STRANGE circumstances..." - "restarting weblog\n",rn); + fprintf(stderr, + "%s: weblog died under STRANGE circumstances..." + "restarting weblog\n", rn); #endif - } - } - break; - } /* switch(weblog_pid) */ - restart_attempts++; - } /* while */ + } + } + break; + } /* switch(weblog_pid) */ + restart_attempts++; + } /* while */ } - - - - diff --git a/src/afsweb/apache_api.h b/src/afsweb/apache_api.h index b6e1b02c0..f6ebd583b 100644 --- a/src/afsweb/apache_api.h +++ b/src/afsweb/apache_api.h @@ -42,7 +42,7 @@ #define FIND_LINKED_MODULE ap_find_linked_module #else #include "1.2/httpd.h" -#include "1.2/http_conf_globals.h" /* for pid_fname */ +#include "1.2/http_conf_globals.h" /* for pid_fname */ #define OS_ESCAPE_PATH os_escape_path #define TABLE_SET table_set diff --git a/src/afsweb/apache_includes/1.2/alloc.h b/src/afsweb/apache_includes/1.2/alloc.h index 858bf2cb5..d7bc76d60 100644 --- a/src/afsweb/apache_includes/1.2/alloc.h +++ b/src/afsweb/apache_includes/1.2/alloc.h @@ -76,18 +76,18 @@ typedef struct pool pool; extern pool *permanent_pool; void init_alloc(); /* Set up everything */ -pool *make_sub_pool (pool *); /* All pools are subpools of permanent_pool */ -void destroy_pool (pool *); +pool *make_sub_pool(pool *); /* All pools are subpools of permanent_pool */ +void destroy_pool(pool *); /* Clearing out EVERYTHING in an pool... destroys any sub-pools */ -void clear_pool (struct pool *); +void clear_pool(struct pool *); /* Preparing for exec() --- close files, etc., but *don't* flush I/O * buffers, *don't* wait for subprocesses, and *don't* free any memory. */ -void cleanup_for_exec (); +void cleanup_for_exec(); /* routines to allocate memory from an pool... */ @@ -95,7 +95,7 @@ void *palloc(struct pool *, int nbytes); void *pcalloc(struct pool *, int nbytes); extern char *pstrdup(struct pool *, const char *s); extern char *pstrndup(struct pool *, const char *s, int n); -char *pstrcat(struct pool *, ...); /* all '...' must be char* */ +char *pstrcat(struct pool *, ...); /* all '...' must be char* */ /* array and alist management... keeping lists of things. * Common enough to want common support code ... @@ -109,20 +109,20 @@ typedef struct { char *elts; } array_header; -array_header *make_array (pool *p, int nelts, int elt_size); -void *push_array (array_header *); -void array_cat (array_header *dst, const array_header *src); -array_header *append_arrays (pool *, const array_header *, - const array_header *); +array_header *make_array(pool * p, int nelts, int elt_size); +void *push_array(array_header *); +void array_cat(array_header * dst, const array_header * src); +array_header *append_arrays(pool *, const array_header *, + const array_header *); /* copy_array copies the *entire* array. copy_array_hdr just copies * the header, and arranges for the elements to be copied if (and only * if) the code subsequently does a push or arraycat. */ - -array_header *copy_array (pool *p, const array_header *src); -array_header *copy_array_hdr (pool *p, const array_header *src); - + +array_header *copy_array(pool * p, const array_header * src); +array_header *copy_array_hdr(pool * p, const array_header * src); + /* Tables. Implemented alist style, for now, though we try to keep * it so that imposing a hash table structure on top in the future @@ -133,8 +133,8 @@ array_header *copy_array_hdr (pool *p, const array_header *src); * currently being used... */ -typedef array_header table; - +typedef array_header table; + typedef struct { char *key; /* maybe NULL in future; * check when iterating thru table_elts @@ -142,20 +142,20 @@ typedef struct { char *val; } table_entry; -table *make_table (pool *p, int nelts); -table *copy_table (pool *p, const table *); -void clear_table (table *); -char *table_get (const table *, const char *); -void table_set (table *, const char *name, const char *val); -void table_merge (table *, const char *name, const char *more_val); -void table_unset (table *, const char *key); -void table_add (table *, const char *name, const char *val); -void table_do (int (*comp)(void *, const char *, const char *), void *rec, - const table *t, ...); +table *make_table(pool * p, int nelts); +table *copy_table(pool * p, const table *); +void clear_table(table *); +char *table_get(const table *, const char *); +void table_set(table *, const char *name, const char *val); +void table_merge(table *, const char *name, const char *more_val); +void table_unset(table *, const char *key); +void table_add(table *, const char *name, const char *val); +void table_do(int (*comp) (void *, const char *, const char *), void *rec, + const table * t, ...); -table *overlay_tables (pool *p, const table *overlay, const table *base); +table *overlay_tables(pool * p, const table * overlay, const table * base); -array_header *table_elts (table *); +array_header *table_elts(table *); #define is_empty_table(t) (((t) == NULL)||((t)->nelts == 0)) @@ -181,12 +181,11 @@ array_header *table_elts (table *); * unblock_alarms() below... */ -void register_cleanup (pool *p, void *data, - void (*plain_cleanup)(void *), - void (*child_cleanup)(void *)); +void register_cleanup(pool * p, void *data, void (*plain_cleanup) (void *), + void (*child_cleanup) (void *)); -void kill_cleanup (pool *p, void *data, void (*plain_cleanup)(void *)); -void run_cleanup (pool *p, void *data, void (*cleanup)(void *)); +void kill_cleanup(pool * p, void *data, void (*plain_cleanup) (void *)); +void run_cleanup(pool * p, void *data, void (*cleanup) (void *)); /* The time between when a resource is actually allocated, and when it * its cleanup is registered is a critical section, during which the @@ -207,14 +206,14 @@ extern void unblock_alarms(); FILE *pfopen(struct pool *, const char *name, const char *fmode); FILE *pfdopen(struct pool *, int fd, const char *fmode); -int popenf(struct pool *, const char *name, int flg, int mode); +int popenf(struct pool *, const char *name, int flg, int mode); -void note_cleanups_for_file (pool *, FILE *); -void note_cleanups_for_fd (pool *, int); -void kill_cleanups_for_fd (pool *p, int fd); +void note_cleanups_for_file(pool *, FILE *); +void note_cleanups_for_fd(pool *, int); +void kill_cleanups_for_fd(pool * p, int fd); -regex_t *pregcomp (pool *p, const char *pattern, int cflags); -void pregfree (pool *p, regex_t *reg); +regex_t *pregcomp(pool * p, const char *pattern, int cflags); +void pregfree(pool * p, regex_t * reg); /* routines to note closes... file descriptors are constrained enough * on some systems that we want to support this. @@ -232,12 +231,13 @@ int pclosef(struct pool *, int fd); * set the associated args to NULL). It takes as args a function * to call in the child, and an argument to be passed to the function. */ - -enum kill_conditions { kill_never, kill_always, kill_after_timeout, just_wait}; -int spawn_child_err (pool *, void (*)(void *), void *, - enum kill_conditions, FILE **pipe_in, FILE **pipe_out, - FILE **pipe_err); +enum kill_conditions { kill_never, kill_always, kill_after_timeout, + just_wait +}; + +int spawn_child_err(pool *, void (*)(void *), void *, enum kill_conditions, + FILE ** pipe_in, FILE ** pipe_out, FILE ** pipe_err); #define spawn_child(p,f,v,k,in,out) spawn_child_err(p,f,v,k,in,out,NULL) /* magic numbers --- min free bytes to consider a free pool block useable, @@ -248,5 +248,5 @@ int spawn_child_err (pool *, void (*)(void *), void *, /* Finally, some accounting */ -long bytes_in_pool(pool *p); +long bytes_in_pool(pool * p); long bytes_in_free_blocks(); diff --git a/src/afsweb/apache_includes/1.2/buff.h b/src/afsweb/apache_includes/1.2/buff.h index aa1926723..aae3e446c 100644 --- a/src/afsweb/apache_includes/1.2/buff.h +++ b/src/afsweb/apache_includes/1.2/buff.h @@ -65,8 +65,8 @@ #define B_RDERR (16) /* A write error has occurred */ #define B_WRERR (32) -#ifdef B_ERROR /* in SVR4: sometimes defined in /usr/include/sys/buf.h */ -#undef B_ERROR /* avoid "warning: `B_ERROR' redefined" */ +#ifdef B_ERROR /* in SVR4: sometimes defined in /usr/include/sys/buf.h */ +#undef B_ERROR /* avoid "warning: `B_ERROR' redefined" */ #endif #define B_ERROR (48) /* Use chunked writing */ @@ -76,60 +76,59 @@ typedef struct buff_struct BUFF; -struct buff_struct -{ - int flags; /* flags */ - unsigned char *inptr; /* pointer to next location to read */ - int incnt; /* number of bytes left to read from input buffer; - * always 0 if had a read error */ - int outchunk; /* location of chunk header when chunking */ - int outcnt; /* number of byte put in output buffer */ +struct buff_struct { + int flags; /* flags */ + unsigned char *inptr; /* pointer to next location to read */ + int incnt; /* number of bytes left to read from input buffer; + * always 0 if had a read error */ + int outchunk; /* location of chunk header when chunking */ + int outcnt; /* number of byte put in output buffer */ unsigned char *inbase; unsigned char *outbase; int bufsiz; - void (*error)(BUFF *fb, int op, void *data); + void (*error) (BUFF * fb, int op, void *data); void *error_data; - long int bytes_sent; /* number of bytes actually written */ + long int bytes_sent; /* number of bytes actually written */ pool *pool; /* could also put pointers to the basic I/O routines here */ - int fd; /* the file descriptor */ - int fd_in; /* input file descriptor, if different */ + int fd; /* the file descriptor */ + int fd_in; /* input file descriptor, if different */ }; /* Options to bset/getopt */ #define BO_BYTECT (1) /* Stream creation and modification */ -extern BUFF *bcreate(pool *p, int flags); -extern void bpushfd(BUFF *fb, int fd_in, int fd_out); -extern int bsetopt(BUFF *fb, int optname, const void *optval); -extern int bgetopt(BUFF *fb, int optname, void *optval); -extern int bsetflag(BUFF *fb, int flag, int value); -extern int bclose(BUFF *fb); +extern BUFF *bcreate(pool * p, int flags); +extern void bpushfd(BUFF * fb, int fd_in, int fd_out); +extern int bsetopt(BUFF * fb, int optname, const void *optval); +extern int bgetopt(BUFF * fb, int optname, void *optval); +extern int bsetflag(BUFF * fb, int flag, int value); +extern int bclose(BUFF * fb); #define bgetflag(fb, flag) ((fb)->flags & (flag)) /* Error handling */ -extern void bonerror(BUFF *fb, void (*error)(BUFF *, int, void *), +extern void bonerror(BUFF * fb, void (*error) (BUFF *, int, void *), void *data); /* I/O */ -extern int bread(BUFF *fb, void *buf, int nbyte); -extern int bgets(char *s, int n, BUFF *fb); -extern int blookc(char *buff, BUFF *fb); -extern int bskiplf(BUFF *fb); -extern int bwrite(BUFF *fb, const void *buf, int nbyte); -extern int bflush(BUFF *fb); -extern int bputs(const char *x, BUFF *fb); -extern int bvputs(BUFF *fb, ...); -extern int bprintf(BUFF *fb,const char *fmt,...); -extern int vbprintf(BUFF *fb,const char *fmt,va_list vlist); +extern int bread(BUFF * fb, void *buf, int nbyte); +extern int bgets(char *s, int n, BUFF * fb); +extern int blookc(char *buff, BUFF * fb); +extern int bskiplf(BUFF * fb); +extern int bwrite(BUFF * fb, const void *buf, int nbyte); +extern int bflush(BUFF * fb); +extern int bputs(const char *x, BUFF * fb); +extern int bvputs(BUFF * fb, ...); +extern int bprintf(BUFF * fb, const char *fmt, ...); +extern int vbprintf(BUFF * fb, const char *fmt, va_list vlist); /* Internal routines */ -extern int bflsbuf(int c, BUFF *fb); -extern int bfilbuf(BUFF *fb); +extern int bflsbuf(int c, BUFF * fb); +extern int bfilbuf(BUFF * fb); #define bgetc(fb) ( ((fb)->incnt == 0) ? bfilbuf(fb) : \ ((fb)->incnt--, *((fb)->inptr++)) ) diff --git a/src/afsweb/apache_includes/1.2/conf.h b/src/afsweb/apache_includes/1.2/conf.h index ee6f0be2a..771988fd7 100644 --- a/src/afsweb/apache_includes/1.2/conf.h +++ b/src/afsweb/apache_includes/1.2/conf.h @@ -84,7 +84,7 @@ char *crypt(const char *pw, const char *salt); char *mktemp(char *template); #define JMP_BUF sigjmp_buf #define HAVE_MMAP -#include +#include #define NEED_STRERROR typedef int rlim_t; #ifndef HAVE_MEMMOVE @@ -167,8 +167,8 @@ typedef int rlim_t; #define ULTRIX_BRAIN_DEATH #define NEED_STRDUP /* If you have Ultrix 4.3, and are using cc, const is broken */ -#ifndef __ultrix__ /* Hack to check for pre-Ultrix 4.4 cc */ -#define const /* Not implemented */ +#ifndef __ultrix__ /* Hack to check for pre-Ultrix 4.4 cc */ +#define const /* Not implemented */ #endif #define JMP_BUF sigjmp_buf @@ -245,7 +245,7 @@ typedef unsigned short mode_t; #ifndef rlim_t typedef int rlim_t; #endif -typedef u_long n_long; +typedef u_long n_long; #endif #define STDIN_FILENO 0 @@ -269,7 +269,7 @@ typedef int rlim_t; #undef NO_SETSID #undef NEED_STRDUP #define JMP_BUF sigjmp_buf -#include +#include #elif defined(SCO) #undef HAVE_GMTOFF @@ -278,8 +278,8 @@ typedef int rlim_t; #define NEED_INITGROUPS #define NO_WRITEV #define JMP_BUF sigjmp_buf -#define SIGURG SIGUSR1 /* but note, this signal will be sent to a process group if enabled (for OOB data). It is not currently enabled. */ -#include +#define SIGURG SIGUSR1 /* but note, this signal will be sent to a process group if enabled (for OOB data). It is not currently enabled. */ +#include #elif defined(SCO5) @@ -293,21 +293,21 @@ typedef int rlim_t; /* Although SCO 5 defines these in (note the "s") they don't have consts. Sigh. */ -extern int strcasecmp(const char *,const char *); -extern int strncasecmp(const char *,const char *,unsigned); +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, unsigned); #elif defined(AUX) /* These are to let -Wall compile more cleanly */ extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *,const char *,unsigned); +extern int strncasecmp(const char *, const char *, unsigned); extern int set42sig(), getopt(), getpeername(); extern int listen(), bind(), socket(), getsockname(); extern int accept(), gethostname(), connect(), lstat(); extern int select(), killpg(), shutdown(); extern int initgroups(), setsockopt(); extern char *shmat(); -extern int shmctl(); -extern int shmget(); +extern int shmctl(); +extern int shmget(); extern char *sbrk(); extern char *crypt(); #include @@ -415,7 +415,7 @@ typedef quad_t rlim_t; char *crypt(const char *pw, const char *salt); #endif #ifndef initgroups -int initgroups (char *, int); +int initgroups(char *, int); #endif #ifndef strncasecmp #define strncasecmp strnicmp @@ -449,7 +449,7 @@ int initgroups (char *, int); #define USE_FCNTL_SERIALIZED_ACCEPT #define HAVE_MMAP #define HAVE_CRYPT_H - + #elif defined(__EMX__) /* Defines required for EMX OS/2 port. */ #define JMP_BUF sigjmp_buf @@ -459,10 +459,10 @@ int initgroups (char *, int); #define NO_SETSID /* Add some drive name support */ #define chdir _chdir2 -#include +#include #define MAXSOCKETS 4096 #define HAVE_MMAP - + #elif defined(__MACHTEN__) typedef int rlim_t; #define JMP_BUF sigjmp_buf @@ -497,7 +497,7 @@ typedef int rlim_t; typedef int rlim_t; #elif defined(ISC) -#include +#include #define NO_KILLPG #undef NO_SETSID #define HAVE_SHMGET @@ -546,7 +546,7 @@ typedef int rlim_t; #define ap_snprintf snprintf #define ap_vsnprintf vsnprintf #else -int ap_snprintf(char *buf, size_t len, const char *format,...); +int ap_snprintf(char *buf, size_t len, const char *format, ...); int ap_vsnprintf(char *buf, size_t len, const char *format, va_list ap); #endif @@ -574,9 +574,9 @@ int ap_vsnprintf(char *buf, size_t len, const char *format, va_list ap); #include #include #ifndef MPE -#include /* for inet_ntoa */ +#include /* for inet_ntoa */ #endif -#include /* for ctime */ +#include /* for ctime */ #include #include #include @@ -596,8 +596,8 @@ int ap_vsnprintf(char *buf, size_t len, const char *format, va_list ap); #ifdef HAVE_SYS_RESOURCE_H #include #ifdef SUNOS4 -int getrlimit( int, struct rlimit *); -int setrlimit( int, struct rlimit *); +int getrlimit(int, struct rlimit *); +int setrlimit(int, struct rlimit *); #endif #endif #ifdef HAVE_MMAP @@ -654,7 +654,7 @@ typedef void Sigfunc(int); #undef signal #endif #define signal(s,f) ap_signal(s,f) -Sigfunc *signal(int signo, Sigfunc *func); +Sigfunc *signal(int signo, Sigfunc * func); #endif #include @@ -680,13 +680,13 @@ Sigfunc *signal(int signo, Sigfunc *func); #define XtOffset(p_type,field) \ (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) -#else /* !CRAY2 */ +#else /* !CRAY2 */ #define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field)) -#endif /* !CRAY2 */ -#endif /* __STDC__ */ -#else /* ! (CRAY || __arm) */ +#endif /* !CRAY2 */ +#endif /* __STDC__ */ +#else /* ! (CRAY || __arm) */ #define XtOffset(p_type,field) \ ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) @@ -706,52 +706,52 @@ Sigfunc *signal(int signo, Sigfunc *func); * Sun Quality Software. Gotta love it. */ -int getopt (int, char **, char *); +int getopt(int, char **, char *); -int strcasecmp (char *, char *); -int strncasecmp (char *, char *, int); +int strcasecmp(char *, char *); +int strncasecmp(char *, char *, int); int toupper(int); -int tolower(int); - -int printf (char *, ...); -int fprintf (FILE *, char *, ...); -int fputs (char *, FILE *); -int fread (char *, int, int, FILE *); -int fwrite (char *, int, int, FILE *); -int fflush (FILE *); -int fclose (FILE *); -int ungetc (int, FILE *); -int _filbuf (FILE *); /* !!! */ -int _flsbuf (unsigned char, FILE *); /* !!! */ -int sscanf (char *, char *, ...); -void setbuf (FILE *, char *); -void perror (char *); - -time_t time (time_t *); -int strftime (char *, int, char *, struct tm *); - -int initgroups (char *, int); -int wait3 (int *, int, void*); /* Close enough for us... */ -int lstat (const char *, struct stat *); -int stat (const char *, struct stat *); -int flock (int, int); +int tolower(int); + +int printf(char *, ...); +int fprintf(FILE *, char *, ...); +int fputs(char *, FILE *); +int fread(char *, int, int, FILE *); +int fwrite(char *, int, int, FILE *); +int fflush(FILE *); +int fclose(FILE *); +int ungetc(int, FILE *); +int _filbuf(FILE *); /* !!! */ +int _flsbuf(unsigned char, FILE *); /* !!! */ +int sscanf(char *, char *, ...); +void setbuf(FILE *, char *); +void perror(char *); + +time_t time(time_t *); +int strftime(char *, int, char *, struct tm *); + +int initgroups(char *, int); +int wait3(int *, int, void *); /* Close enough for us... */ +int lstat(const char *, struct stat *); +int stat(const char *, struct stat *); +int flock(int, int); #ifndef NO_KILLPG int killpg(int, int); #endif -int socket (int, int, int); -int setsockopt (int, int, int, const char*, int); -int listen (int, int); -int bind (int, struct sockaddr *, int); -int connect (int, struct sockaddr *, int); -int accept (int, struct sockaddr *, int *); -int shutdown (int, int); - -int getsockname (int s, struct sockaddr *name, int *namelen); -int getpeername (int s, struct sockaddr *name, int *namelen); -int gethostname (char *name, int namelen); -void syslog (int, char *, ...); -char *mktemp (char *); - -long vfprintf (FILE *, char *, va_list); - +int socket(int, int, int); +int setsockopt(int, int, int, const char *, int); +int listen(int, int); +int bind(int, struct sockaddr *, int); +int connect(int, struct sockaddr *, int); +int accept(int, struct sockaddr *, int *); +int shutdown(int, int); + +int getsockname(int s, struct sockaddr *name, int *namelen); +int getpeername(int s, struct sockaddr *name, int *namelen); +int gethostname(char *name, int namelen); +void syslog(int, char *, ...); +char *mktemp(char *); + +long vfprintf(FILE *, char *, va_list); + #endif diff --git a/src/afsweb/apache_includes/1.2/http_conf_globals.h b/src/afsweb/apache_includes/1.2/http_conf_globals.h index 3a60e7db7..b87733fc4 100644 --- a/src/afsweb/apache_includes/1.2/http_conf_globals.h +++ b/src/afsweb/apache_includes/1.2/http_conf_globals.h @@ -83,4 +83,3 @@ extern char *server_argv0; extern char server_root[MAX_STRING_LEN]; extern char server_confname[MAX_STRING_LEN]; - diff --git a/src/afsweb/apache_includes/1.2/httpd.h b/src/afsweb/apache_includes/1.2/httpd.h index abee73506..7481bc7ba 100644 --- a/src/afsweb/apache_includes/1.2/httpd.h +++ b/src/afsweb/apache_includes/1.2/httpd.h @@ -67,7 +67,7 @@ */ #ifndef HTTPD_ROOT #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define HTTPD_ROOT "/os2httpd" #else #define HTTPD_ROOT "/usr/local/etc/httpd" @@ -77,7 +77,7 @@ #ifndef DOCUMENT_LOCATION /* Root of server */ #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define DOCUMENT_LOCATION "/os2httpd/docs" #else #define DOCUMENT_LOCATION "/usr/local/etc/httpd/htdocs" @@ -116,7 +116,7 @@ /* The name of the log files */ #ifndef DEFAULT_XFERLOG #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define DEFAULT_XFERLOG "logs/access.log" #else #define DEFAULT_XFERLOG "logs/access_log" @@ -124,7 +124,7 @@ #endif /* DEFAULT_XFERLOG */ #ifndef DEFAULT_ERRORLOG #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define DEFAULT_ERRORLOG "logs/error.log" #else #define DEFAULT_ERRORLOG "logs/error_log" @@ -152,7 +152,7 @@ /* Define this to be what your per-directory security files are called */ #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define DEFAULT_ACCESS_FNAME "htaccess" #else #define DEFAULT_ACCESS_FNAME ".htaccess" @@ -191,7 +191,7 @@ /* The path to the Bourne shell, for parsed docs */ #ifndef SHELL_PATH #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define SHELL_PATH "CMD.EXE" #else #define SHELL_PATH "/bin/sh" @@ -274,7 +274,7 @@ * Example: "Apache/1.1.0 MrWidget/0.1-alpha" */ -#define SERVER_BASEVERSION "Apache/1.2.6" /* SEE COMMENTS ABOVE */ +#define SERVER_BASEVERSION "Apache/1.2.6" /* SEE COMMENTS ABOVE */ #ifdef SERVER_SUBVERSION #define SERVER_VERSION SERVER_BASEVERSION " " SERVER_SUBVERSION #else @@ -420,11 +420,10 @@ /* This represents the result of calling htaccess; these are cached for * each request. */ -struct htaccess_result -{ - char *dir; /* the directory to which this applies */ - int override; /* the overrides allowed for the .htaccess file */ - void *htaccess; /* the configuration directives */ +struct htaccess_result { + char *dir; /* the directory to which this applies */ + int override; /* the overrides allowed for the .htaccess file */ + void *htaccess; /* the configuration directives */ /* the next one, or NULL if no more; N.B. never change this */ const struct htaccess_result *next; }; @@ -437,109 +436,109 @@ typedef struct listen_rec listen_rec; struct request_rec { - pool *pool; - conn_rec *connection; - server_rec *server; + pool *pool; + conn_rec *connection; + server_rec *server; - request_rec *next; /* If we wind up getting redirected, + request_rec *next; /* If we wind up getting redirected, * pointer to the request we redirected to. */ - request_rec *prev; /* If this is an internal redirect, + request_rec *prev; /* If this is an internal redirect, * pointer to where we redirected *from*. */ - - request_rec *main; /* If this is a sub_request (see request.h) + + request_rec *main; /* If this is a sub_request (see request.h) * pointer back to the main request. */ - /* Info about the request itself... we begin with stuff that only - * protocol.c should ever touch... - */ - - char *the_request; /* First line of request, so we can log it */ - int assbackwards; /* HTTP/0.9, "simple" request */ - int proxyreq; /* A proxy request */ - int header_only; /* HEAD request, as opposed to GET */ - char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ - int proto_num; /* Number version of protocol; 1.1 = 1001 */ - char *hostname; /* Host, as set by full URI or Host: */ - int hostlen; /* Length of http://host:port in full URI */ - - time_t request_time; /* When the request started */ - - char *status_line; /* Status line, if set by script */ - int status; /* In any case */ - - /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, - * look, but don't touch. - */ - - char *method; /* GET, HEAD, POST, etc. */ - int method_number; /* M_GET, M_POST, etc. */ - int allowed; /* Allowed methods - for 405, OPTIONS, etc */ - - int sent_bodyct; /* byte count in stream is for body */ - long bytes_sent; /* body byte count, for easy access */ - - /* HTTP/1.1 connection-level features */ - - int chunked; /* sending chunked transfer-coding */ - int byterange; /* number of byte ranges */ - char *boundary; /* multipart/byteranges boundary */ - char *range; /* The Range: header */ - long clength; /* The "real" content length */ - - long remaining; /* bytes left to read */ - long read_length; /* bytes that have been read */ - int read_body; /* how the request body should be read */ - int read_chunked; /* reading chunked transfer-coding */ - - /* MIME header environments, in and out. Also, an array containing - * environment variables to be passed to subprocesses, so people can - * write modules to add to that environment. - * - * The difference between headers_out and err_headers_out is that the - * latter are printed even on error, and persist across internal redirects - * (so the headers printed for ErrorDocument handlers will have them). - * - * The 'notes' table is for notes from one module to another, with no - * other set purpose in mind... - */ - - table *headers_in; - table *headers_out; - table *err_headers_out; - table *subprocess_env; - table *notes; - - char *content_type; /* Break these out --- we dispatch on 'em */ - char *handler; /* What we *really* dispatch on */ - - char *content_encoding; - char *content_language; /* for back-compat. only -- do not use */ - array_header *content_languages; /* array of (char*) */ - - int no_cache; - int no_local_copy; - - /* What object is being requested (either directly, or via include - * or content-negotiation mapping). - */ - - char *uri; /* complete URI for a proxy req, or - URL path for a non-proxy req */ - char *filename; - char *path_info; - char *args; /* QUERY_ARGS, if any */ - struct stat finfo; /* ST_MODE set to zero if no such file */ - - /* Various other config info which may change with .htaccess files - * These are config vectors, with one void* pointer for each module - * (the thing pointed to being the module's business). - */ - - void *per_dir_config; /* Options set in config files, etc. */ - void *request_config; /* Notes on *this* request */ + /* Info about the request itself... we begin with stuff that only + * protocol.c should ever touch... + */ + + char *the_request; /* First line of request, so we can log it */ + int assbackwards; /* HTTP/0.9, "simple" request */ + int proxyreq; /* A proxy request */ + int header_only; /* HEAD request, as opposed to GET */ + char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ + int proto_num; /* Number version of protocol; 1.1 = 1001 */ + char *hostname; /* Host, as set by full URI or Host: */ + int hostlen; /* Length of http://host:port in full URI */ + + time_t request_time; /* When the request started */ + + char *status_line; /* Status line, if set by script */ + int status; /* In any case */ + + /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, + * look, but don't touch. + */ + + char *method; /* GET, HEAD, POST, etc. */ + int method_number; /* M_GET, M_POST, etc. */ + int allowed; /* Allowed methods - for 405, OPTIONS, etc */ + + int sent_bodyct; /* byte count in stream is for body */ + long bytes_sent; /* body byte count, for easy access */ + + /* HTTP/1.1 connection-level features */ + + int chunked; /* sending chunked transfer-coding */ + int byterange; /* number of byte ranges */ + char *boundary; /* multipart/byteranges boundary */ + char *range; /* The Range: header */ + long clength; /* The "real" content length */ + + long remaining; /* bytes left to read */ + long read_length; /* bytes that have been read */ + int read_body; /* how the request body should be read */ + int read_chunked; /* reading chunked transfer-coding */ + + /* MIME header environments, in and out. Also, an array containing + * environment variables to be passed to subprocesses, so people can + * write modules to add to that environment. + * + * The difference between headers_out and err_headers_out is that the + * latter are printed even on error, and persist across internal redirects + * (so the headers printed for ErrorDocument handlers will have them). + * + * The 'notes' table is for notes from one module to another, with no + * other set purpose in mind... + */ + + table *headers_in; + table *headers_out; + table *err_headers_out; + table *subprocess_env; + table *notes; + + char *content_type; /* Break these out --- we dispatch on 'em */ + char *handler; /* What we *really* dispatch on */ + + char *content_encoding; + char *content_language; /* for back-compat. only -- do not use */ + array_header *content_languages; /* array of (char*) */ + + int no_cache; + int no_local_copy; + + /* What object is being requested (either directly, or via include + * or content-negotiation mapping). + */ + + char *uri; /* complete URI for a proxy req, or + * URL path for a non-proxy req */ + char *filename; + char *path_info; + char *args; /* QUERY_ARGS, if any */ + struct stat finfo; /* ST_MODE set to zero if no such file */ + + /* Various other config info which may change with .htaccess files + * These are config vectors, with one void* pointer for each module + * (the thing pointed to being the module's business). + */ + + void *per_dir_config; /* Options set in config files, etc. */ + void *request_config; /* Notes on *this* request */ /* * a linked list of the configuration directives in the .htaccess files @@ -547,7 +546,7 @@ struct request_rec { * N.B. always add to the head of the list, _never_ to the end. * that way, a sub request's list can (temporarily) point to a parent's list */ - const struct htaccess_result *htaccess; + const struct htaccess_result *htaccess; }; @@ -555,39 +554,39 @@ struct request_rec { */ struct conn_rec { - - pool *pool; - server_rec *server; - server_rec *base_server; /* Physical vhost this conn come in on */ - - /* Information about the connection itself */ - - int child_num; /* The number of the child handling conn_rec */ - BUFF *client; /* Connetion to the guy */ - int aborted; /* Are we still talking? */ - - /* Who is the client? */ - - struct sockaddr_in local_addr; /* local address */ - struct sockaddr_in remote_addr;/* remote address */ - char *remote_ip; /* Client's IP address */ - char *remote_host; /* Client's DNS name, if known. - * NULL if DNS hasn't been checked, - * "" if it has and no address was found. - * N.B. Only access this though + + pool *pool; + server_rec *server; + server_rec *base_server; /* Physical vhost this conn come in on */ + + /* Information about the connection itself */ + + int child_num; /* The number of the child handling conn_rec */ + BUFF *client; /* Connetion to the guy */ + int aborted; /* Are we still talking? */ + + /* Who is the client? */ + + struct sockaddr_in local_addr; /* local address */ + struct sockaddr_in remote_addr; /* remote address */ + char *remote_ip; /* Client's IP address */ + char *remote_host; /* Client's DNS name, if known. + * NULL if DNS hasn't been checked, + * "" if it has and no address was found. + * N.B. Only access this though * get_remote_host() */ - char *remote_logname; /* Only ever set if doing rfc1413 lookups. - * N.B. Only access this through + char *remote_logname; /* Only ever set if doing rfc1413 lookups. + * N.B. Only access this through * get_remote_logname() */ char *user; /* If an authentication check was made, * this gets set to the user name. We assume * that there's only one user per connection(!) */ - char *auth_type; /* Ditto. */ + char *auth_type; /* Ditto. */ - int keepalive; /* Are we using HTTP Keep-Alive? */ - int keptalive; /* Did we use HTTP Keep-Alive? */ - int keepalives; /* How many times have we used it? */ + int keepalive; /* Are we using HTTP Keep-Alive? */ + int keptalive; /* Did we use HTTP Keep-Alive? */ + int keepalives; /* How many times have we used it? */ }; /* Per-vhost config... */ @@ -601,7 +600,7 @@ typedef struct server_addr_rec server_addr_rec; struct server_addr_rec { server_addr_rec *next; struct in_addr host_addr; /* The bound address, for this server */ - unsigned short host_port; /* The bound port, for this server */ + unsigned short host_port; /* The bound port, for this server */ char *virthost; /* The name given in */ }; @@ -609,26 +608,26 @@ struct server_addr_rec { struct server_rec { server_rec *next; - + /* Full locations of server config info */ - + char *srm_confname; char *access_confname; - + /* Contact information */ - + char *server_admin; char *server_hostname; - unsigned short port; /* for redirects, etc. */ - + unsigned short port; /* for redirects, etc. */ + /* Log files --- note that transfer log is now in the modules... */ - + char *error_fname; FILE *error_log; - + /* Module-specific configuration for server, and defaults... */ - int is_virtual; /* true if this is the virtual server */ + int is_virtual; /* true if this is the virtual server */ void *module_config; /* Config vector containing pointers to * modules' per-server config structures. */ @@ -642,7 +641,7 @@ struct server_rec { int keep_alive_timeout; /* Seconds we'll wait for another request */ int keep_alive_max; /* Maximum requests per connection */ int keep_alive; /* Use persistent connections? */ - int send_buffer_size; /* size of TCP send buffer (in bytes) */ + int send_buffer_size; /* size of TCP send buffer (in bytes) */ char *path; /* Pathname for ServerPath */ int pathlen; /* Length of path */ @@ -656,9 +655,9 @@ struct server_rec { /* These are more like real hosts than virtual hosts */ struct listen_rec { listen_rec *next; - struct sockaddr_in local_addr; /* local IP address and port */ + struct sockaddr_in local_addr; /* local IP address and port */ int fd; - int used; /* Only used during restart */ + int used; /* Only used during restart */ /* more stuff here, like which protocol is bound to the port */ }; @@ -670,70 +669,70 @@ extern const char month_snames[12][4]; struct tm *get_gmtoff(int *tz); char *get_time(); -char *ht_time (pool *p, time_t t, const char *fmt, int gmt); -char *gm_timestr_822(pool *p, time_t t); - +char *ht_time(pool * p, time_t t, const char *fmt, int gmt); +char *gm_timestr_822(pool * p, time_t t); + /* String handling. The *_nc variants allow you to use non-const char **s as arguments (unfortunately C won't automatically convert a char ** to a const -char **) */ - -char *getword(pool *p, const char **line, char stop); -char *getword_nc(pool *p, char **line, char stop); -char *getword_white(pool *p, const char **line); -char *getword_white_nc(pool *p, char **line); -char *getword_nulls (pool *p, const char **line, char stop); -char *getword_nulls_nc (pool *p, char **line, char stop); -char *getword_conf (pool *p, const char **line); -char *getword_conf_nc (pool *p, char **line); - -char *get_token (pool *p, char **accept_line, int accept_white); -int find_token (pool *p, const char *line, const char *tok); -int find_last_token (pool *p, const char *line, const char *tok); - +char **) */ + +char *getword(pool * p, const char **line, char stop); +char *getword_nc(pool * p, char **line, char stop); +char *getword_white(pool * p, const char **line); +char *getword_white_nc(pool * p, char **line); +char *getword_nulls(pool * p, const char **line, char stop); +char *getword_nulls_nc(pool * p, char **line, char stop); +char *getword_conf(pool * p, const char **line); +char *getword_conf_nc(pool * p, char **line); + +char *get_token(pool * p, char **accept_line, int accept_white); +int find_token(pool * p, const char *line, const char *tok); +int find_last_token(pool * p, const char *line, const char *tok); + int is_url(const char *u); extern int unescape_url(char *url); void no2slash(char *name); void getparents(char *name); -char *escape_path_segment(pool *p, const char *s); -char *os_escape_path(pool *p,const char *path,int partial); +char *escape_path_segment(pool * p, const char *s); +char *os_escape_path(pool * p, const char *path, int partial); #define escape_uri(ppool,path) os_escape_path(ppool,path,1) -extern char *escape_html(pool *p, const char *s); -char *construct_server(pool *p, const char *hostname, unsigned port); -char *construct_url (pool *p, const char *path, const server_rec *s); -char *escape_shell_cmd (pool *p, const char *s); - +extern char *escape_html(pool * p, const char *s); +char *construct_server(pool * p, const char *hostname, unsigned port); +char *construct_url(pool * p, const char *path, const server_rec * s); +char *escape_shell_cmd(pool * p, const char *s); + int count_dirs(const char *path); -char *make_dirstr(pool *a, const char *s, int n); -char *make_full_path(pool *a, const char *dir, const char *f); - +char *make_dirstr(pool * a, const char *s, int n); +char *make_full_path(pool * a, const char *dir, const char *f); + int is_matchexp(const char *str); int strcmp_match(const char *str, const char *exp); int strcasecmp_match(const char *str, const char *exp); -char *uudecode (pool *, const char *); +char *uudecode(pool *, const char *); -char *pregsub(pool *p, const char *input, const char *source, - size_t nmatch, regmatch_t pmatch[]); +char *pregsub(pool * p, const char *input, const char *source, size_t nmatch, + regmatch_t pmatch[]); -void str_tolower (char *); -int ind (const char *, char); /* Sigh... */ -int rind (const char *, char); +void str_tolower(char *); +int ind(const char *, char); /* Sigh... */ +int rind(const char *, char); -int cfg_getline(char *s, int n, FILE *f); +int cfg_getline(char *s, int n, FILE * f); #ifdef NEED_STRERROR -char *strerror (int err); +char *strerror(int err); #endif /* Misc system hackery */ - + uid_t uname2id(const char *name); gid_t gname2id(const char *name); int is_directory(const char *name); -int can_exec(const struct stat *); +int can_exec(const struct stat *); void chdir_file(const char *file); - + char *get_local_host(pool *); -unsigned long get_virthost_addr (const char *hostname, unsigned short *port); +unsigned long get_virthost_addr(const char *hostname, unsigned short *port); extern time_t restart_time; @@ -761,6 +760,6 @@ extern time_t restart_time; * never fails. If the high line was requested and it fails it will also try * the low line. */ -int ap_slack (int fd, int line); +int ap_slack(int fd, int line); #define AP_SLACK_LOW 1 #define AP_SLACK_HIGH 2 diff --git a/src/afsweb/apache_includes/1.3.1/alloc.h b/src/afsweb/apache_includes/1.3.1/alloc.h index 715b8acea..31de7e672 100644 --- a/src/afsweb/apache_includes/1.3.1/alloc.h +++ b/src/afsweb/apache_includes/1.3.1/alloc.h @@ -83,17 +83,17 @@ extern "C" { * alloc.c. */ - /* Need declaration of DIR on Win32 */ + /* Need declaration of DIR on Win32 */ #ifdef WIN32 #include "os/win32/readdir.h" #endif -typedef struct pool pool; -typedef struct pool ap_pool; + typedef struct pool pool; + typedef struct pool ap_pool; -pool * ap_init_alloc(void); /* Set up everything */ -API_EXPORT(pool *) ap_make_sub_pool(pool *); /* All pools are subpools of permanent_pool */ -API_EXPORT(void) ap_destroy_pool(pool *); + pool *ap_init_alloc(void); /* Set up everything */ + API_EXPORT(pool *) ap_make_sub_pool(pool *); /* All pools are subpools of permanent_pool */ + API_EXPORT(void) ap_destroy_pool(pool *); /* used to guarantee to the pool debugging code that the sub pool will not be * destroyed before the parent pool @@ -104,58 +104,65 @@ API_EXPORT(void) ap_destroy_pool(pool *); #endif #define ap_pool_join(a,b) #else -API_EXPORT(void) ap_pool_join(pool *p, pool *sub); -API_EXPORT(pool *) ap_find_pool(const void *ts); -API_EXPORT(int) ap_pool_is_ancestor(pool *a, pool *b); + API_EXPORT(void) ap_pool_join(pool * p, pool * sub); + API_EXPORT(pool *) ap_find_pool(const void *ts); + API_EXPORT(int) ap_pool_is_ancestor(pool * a, pool * b); #endif /* Clearing out EVERYTHING in an pool... destroys any sub-pools */ -API_EXPORT(void) ap_clear_pool(struct pool *); + API_EXPORT(void) ap_clear_pool(struct pool *); /* Preparing for exec() --- close files, etc., but *don't* flush I/O * buffers, *don't* wait for subprocesses, and *don't* free any memory. */ -API_EXPORT(void) ap_cleanup_for_exec(void); + API_EXPORT(void) ap_cleanup_for_exec(void); /* routines to allocate memory from an pool... */ -API_EXPORT(void *) ap_palloc(struct pool *, int nbytes); -API_EXPORT(void *) ap_pcalloc(struct pool *, int nbytes); -API_EXPORT(char *) ap_pstrdup(struct pool *, const char *s); + API_EXPORT(void *) ap_palloc(struct pool *, int nbytes); + API_EXPORT(void *) ap_pcalloc(struct pool *, int nbytes); + API_EXPORT(char *) ap_pstrdup(struct pool *, const char *s); /* make a nul terminated copy of the n characters starting with s */ -API_EXPORT(char *) ap_pstrndup(struct pool *, const char *s, int n); -API_EXPORT_NONSTD(char *) ap_pstrcat(struct pool *,...); /* all '...' must be char* */ -API_EXPORT_NONSTD(char *) ap_psprintf(struct pool *, const char *fmt, ...) - __attribute__((format(printf,2,3))); -API_EXPORT(char *) ap_pvsprintf(struct pool *, const char *fmt, va_list); + API_EXPORT(char *) ap_pstrndup(struct pool *, const char *s, int n); + API_EXPORT_NONSTD(char *) ap_pstrcat(struct pool *, ...); /* all '...' must be char* */ + API_EXPORT_NONSTD(char *) ap_psprintf(struct pool *, const char *fmt, + ...) + __attribute__ ((format(printf, 2, 3))); + API_EXPORT(char *) ap_pvsprintf(struct pool *, const char *fmt, + va_list); /* array and alist management... keeping lists of things. * Common enough to want common support code ... */ -typedef struct { - ap_pool *pool; - int elt_size; - int nelts; - int nalloc; - char *elts; -} array_header; - -API_EXPORT(array_header *) ap_make_array(pool *p, int nelts, int elt_size); -API_EXPORT(void *) ap_push_array(array_header *); -API_EXPORT(void) ap_array_cat(array_header *dst, const array_header *src); -API_EXPORT(array_header *) ap_append_arrays(pool *, const array_header *, - const array_header *); + typedef struct { + ap_pool *pool; + int elt_size; + int nelts; + int nalloc; + char *elts; + } array_header; + + API_EXPORT(array_header *) ap_make_array(pool * p, int nelts, + int elt_size); + API_EXPORT(void *) ap_push_array(array_header *); + API_EXPORT(void) ap_array_cat(array_header * dst, + const array_header * src); + API_EXPORT(array_header *) ap_append_arrays(pool *, + const array_header *, + const array_header *); /* copy_array copies the *entire* array. copy_array_hdr just copies * the header, and arranges for the elements to be copied if (and only * if) the code subsequently does a push or arraycat. */ -API_EXPORT(array_header *) ap_copy_array(pool *p, const array_header *src); -API_EXPORT(array_header *) ap_copy_array_hdr(pool *p, const array_header *src); + API_EXPORT(array_header *) ap_copy_array(pool * p, + const array_header * src); + API_EXPORT(array_header *) ap_copy_array_hdr(pool * p, + const array_header * src); /* Tables. Implemented alist style, for now, though we try to keep @@ -167,30 +174,38 @@ API_EXPORT(array_header *) ap_copy_array_hdr(pool *p, const array_header *src); * currently being used... */ -typedef struct table table; - -typedef struct { - char *key; /* maybe NULL in future; - * check when iterating thru table_elts - */ - char *val; -} table_entry; - -API_EXPORT(table *) ap_make_table(pool *p, int nelts); -API_EXPORT(table *) ap_copy_table(pool *p, const table *); -API_EXPORT(void) ap_clear_table(table *); -API_EXPORT(const char *) ap_table_get(const table *, const char *); -API_EXPORT(void) ap_table_set(table *, const char *name, const char *val); -API_EXPORT(void) ap_table_setn(table *, const char *name, const char *val); -API_EXPORT(void) ap_table_merge(table *, const char *name, const char *more_val); -API_EXPORT(void) ap_table_mergen(table *, const char *name, const char *more_val); -API_EXPORT(void) ap_table_unset(table *, const char *key); -API_EXPORT(void) ap_table_add(table *, const char *name, const char *val); -API_EXPORT(void) ap_table_addn(table *, const char *name, const char *val); -API_EXPORT(void) ap_table_do(int (*comp) (void *, const char *, const char *), void *rec, - const table *t,...); - -API_EXPORT(table *) ap_overlay_tables(pool *p, const table *overlay, const table *base); + typedef struct table table; + + typedef struct { + char *key; /* maybe NULL in future; + * check when iterating thru table_elts + */ + char *val; + } table_entry; + + API_EXPORT(table *) ap_make_table(pool * p, int nelts); + API_EXPORT(table *) ap_copy_table(pool * p, const table *); + API_EXPORT(void) ap_clear_table(table *); + API_EXPORT(const char *) ap_table_get(const table *, const char *); + API_EXPORT(void) ap_table_set(table *, const char *name, + const char *val); + API_EXPORT(void) ap_table_setn(table *, const char *name, + const char *val); + API_EXPORT(void) ap_table_merge(table *, const char *name, + const char *more_val); + API_EXPORT(void) ap_table_mergen(table *, const char *name, + const char *more_val); + API_EXPORT(void) ap_table_unset(table *, const char *key); + API_EXPORT(void) ap_table_add(table *, const char *name, + const char *val); + API_EXPORT(void) ap_table_addn(table *, const char *name, + const char *val); + API_EXPORT(void) + ap_table_do(int (*comp) (void *, const char *, const char *), void *rec, + const table * t, ...); + + API_EXPORT(table *) ap_overlay_tables(pool * p, const table * overlay, + const table * base); /* XXX: these know about the definition of struct table in alloc.c. That * definition is not here because it is supposed to be private, and by not @@ -222,16 +237,18 @@ API_EXPORT(table *) ap_overlay_tables(pool *p, const table *overlay, const table * unblock_alarms() below... */ -API_EXPORT(void) ap_register_cleanup(pool *p, void *data, - void (*plain_cleanup) (void *), - void (*child_cleanup) (void *)); + API_EXPORT(void) ap_register_cleanup(pool * p, void *data, + void (*plain_cleanup) (void *), + void (*child_cleanup) (void *)); -API_EXPORT(void) ap_kill_cleanup(pool *p, void *data, void (*plain_cleanup) (void *)); -API_EXPORT(void) ap_run_cleanup(pool *p, void *data, void (*cleanup) (void *)); + API_EXPORT(void) ap_kill_cleanup(pool * p, void *data, + void (*plain_cleanup) (void *)); + API_EXPORT(void) ap_run_cleanup(pool * p, void *data, + void (*cleanup) (void *)); /* A "do-nothing" cleanup, for register_cleanup; it's faster to do * things this way than to test for NULL. */ -API_EXPORT_NONSTD(void) ap_null_cleanup(void *data); + API_EXPORT_NONSTD(void) ap_null_cleanup(void *data); /* The time between when a resource is actually allocated, and when it * its cleanup is registered is a critical section, during which the @@ -243,45 +260,48 @@ API_EXPORT_NONSTD(void) ap_null_cleanup(void *data); * up with timeout handling in general... */ -API_EXPORT(void) ap_block_alarms(void); -API_EXPORT(void) ap_unblock_alarms(void); + API_EXPORT(void) ap_block_alarms(void); + API_EXPORT(void) ap_unblock_alarms(void); /* Common cases which want utility support.. * the note_cleanups_for_foo routines are for */ -API_EXPORT(FILE *) ap_pfopen(struct pool *, const char *name, const char *fmode); -API_EXPORT(FILE *) ap_pfdopen(struct pool *, int fd, const char *fmode); -API_EXPORT(int) ap_popenf(struct pool *, const char *name, int flg, int mode); + API_EXPORT(FILE *) ap_pfopen(struct pool *, const char *name, + const char *fmode); + API_EXPORT(FILE *) ap_pfdopen(struct pool *, int fd, const char *fmode); + API_EXPORT(int) ap_popenf(struct pool *, const char *name, int flg, + int mode); -API_EXPORT(void) ap_note_cleanups_for_file(pool *, FILE *); -API_EXPORT(void) ap_note_cleanups_for_fd(pool *, int); + API_EXPORT(void) ap_note_cleanups_for_file(pool *, FILE *); + API_EXPORT(void) ap_note_cleanups_for_fd(pool *, int); #ifdef WIN32 -API_EXPORT(void) ap_note_cleanups_for_h(pool *, HANDLE); + API_EXPORT(void) ap_note_cleanups_for_h(pool *, HANDLE); #endif -API_EXPORT(void) ap_kill_cleanups_for_fd(pool *p, int fd); + API_EXPORT(void) ap_kill_cleanups_for_fd(pool * p, int fd); -API_EXPORT(void) ap_note_cleanups_for_socket(pool *, int); -API_EXPORT(void) ap_kill_cleanups_for_socket(pool *p, int sock); -API_EXPORT(int) ap_psocket(pool *p, int, int, int); -API_EXPORT(int) ap_pclosesocket(pool *a, int sock); + API_EXPORT(void) ap_note_cleanups_for_socket(pool *, int); + API_EXPORT(void) ap_kill_cleanups_for_socket(pool * p, int sock); + API_EXPORT(int) ap_psocket(pool * p, int, int, int); + API_EXPORT(int) ap_pclosesocket(pool * a, int sock); -API_EXPORT(regex_t *) ap_pregcomp(pool *p, const char *pattern, int cflags); -API_EXPORT(void) ap_pregfree(pool *p, regex_t * reg); + API_EXPORT(regex_t *) ap_pregcomp(pool * p, const char *pattern, + int cflags); + API_EXPORT(void) ap_pregfree(pool * p, regex_t * reg); /* routines to note closes... file descriptors are constrained enough * on some systems that we want to support this. */ -API_EXPORT(int) ap_pfclose(struct pool *, FILE *); -API_EXPORT(int) ap_pclosef(struct pool *, int fd); + API_EXPORT(int) ap_pfclose(struct pool *, FILE *); + API_EXPORT(int) ap_pclosef(struct pool *, int fd); #ifdef WIN32 -API_EXPORT(int) ap_pcloseh(struct pool *, HANDLE hDevice); + API_EXPORT(int) ap_pcloseh(struct pool *, HANDLE hDevice); #endif /* routines to deal with directories */ -API_EXPORT(DIR *) ap_popendir(pool *p, const char *name); -API_EXPORT(void) ap_pclosedir(pool *p, DIR * d); + API_EXPORT(DIR *) ap_popendir(pool * p, const char *name); + API_EXPORT(void) ap_pclosedir(pool * p, DIR * d); /* ... even child processes (which we may want to wait for, * or to kill outright, on unexpected termination). @@ -293,21 +313,21 @@ API_EXPORT(void) ap_pclosedir(pool *p, DIR * d); * to call in the child, and an argument to be passed to the function. */ -enum kill_conditions { - kill_never, /* process is never sent any signals */ - kill_always, /* process is sent SIGKILL on pool cleanup */ - kill_after_timeout, /* SIGTERM, wait 3 seconds, SIGKILL */ - just_wait, /* wait forever for the process to complete */ - kill_only_once /* send SIGTERM and then wait */ -}; - -typedef struct child_info child_info; -API_EXPORT(void) ap_note_subprocess(pool *a, int pid, - enum kill_conditions how); -API_EXPORT(int) ap_spawn_child(pool *, int (*)(void *, child_info *), - void *, enum kill_conditions, - FILE **pipe_in, FILE **pipe_out, - FILE **pipe_err); + enum kill_conditions { + kill_never, /* process is never sent any signals */ + kill_always, /* process is sent SIGKILL on pool cleanup */ + kill_after_timeout, /* SIGTERM, wait 3 seconds, SIGKILL */ + just_wait, /* wait forever for the process to complete */ + kill_only_once /* send SIGTERM and then wait */ + }; + + typedef struct child_info child_info; + API_EXPORT(void) ap_note_subprocess(pool * a, int pid, + enum kill_conditions how); + API_EXPORT(int) ap_spawn_child(pool *, int (*)(void *, child_info *), + void *, enum kill_conditions, + FILE ** pipe_in, FILE ** pipe_out, + FILE ** pipe_err); /* magic numbers --- min free bytes to consider a free pool block useable, * and the min amount to allocate if we have to go to malloc() */ @@ -321,11 +341,10 @@ API_EXPORT(int) ap_spawn_child(pool *, int (*)(void *, child_info *), /* Finally, some accounting */ -API_EXPORT(long) ap_bytes_in_pool(pool *p); -API_EXPORT(long) ap_bytes_in_free_blocks(void); + API_EXPORT(long) ap_bytes_in_pool(pool * p); + API_EXPORT(long) ap_bytes_in_free_blocks(void); #ifdef __cplusplus } #endif - -#endif /* !APACHE_ALLOC_H */ +#endif /* !APACHE_ALLOC_H */ diff --git a/src/afsweb/apache_includes/1.3.1/ap.h b/src/afsweb/apache_includes/1.3.1/ap.h index b1bcdc5bc..b5b34d81a 100644 --- a/src/afsweb/apache_includes/1.3.1/ap.h +++ b/src/afsweb/apache_includes/1.3.1/ap.h @@ -65,12 +65,12 @@ extern "C" { #endif -API_EXPORT(char *) ap_cpystrn(char *, const char *, size_t); -int ap_slack(int, int); -API_EXPORT(int) ap_snprintf(char *, size_t, const char *, ...); -API_EXPORT(int) ap_vsnprintf(char *, size_t, const char *, va_list ap); -int ap_execle(const char *, const char *, ...); -int ap_execve(const char *, const char *argv[], const char *envp[]); + API_EXPORT(char *) ap_cpystrn(char *, const char *, size_t); + int ap_slack(int, int); + API_EXPORT(int) ap_snprintf(char *, size_t, const char *, ...); + API_EXPORT(int) ap_vsnprintf(char *, size_t, const char *, va_list ap); + int ap_execle(const char *, const char *, ...); + int ap_execve(const char *, const char *argv[], const char *envp[]); /* small utility macros to make things easier to read */ @@ -82,7 +82,7 @@ int ap_execve(const char *, const char *argv[], const char *envp[]); #else #define ap_killpg(x, y) (killpg ((x), (y))) #endif -#endif /* WIN32 */ +#endif /* WIN32 */ /* ap_vformatter() is a generic printf-style formatting routine * with some extensions. The extensions are: @@ -133,13 +133,14 @@ int ap_execve(const char *, const char *argv[], const char *envp[]); * or until ap_vformatter returns. */ -typedef struct { - char *curpos; - char *endpos; -} ap_vformatter_buff; + typedef struct { + char *curpos; + char *endpos; + } ap_vformatter_buff; -API_EXPORT(int) ap_vformatter(int (*flush_func)(ap_vformatter_buff *), - ap_vformatter_buff *, const char *fmt, va_list ap); + API_EXPORT(int) ap_vformatter(int (*flush_func) (ap_vformatter_buff *), + ap_vformatter_buff *, const char *fmt, + va_list ap); /* These are snprintf implementations based on ap_vformatter(). * @@ -156,13 +157,13 @@ API_EXPORT(int) ap_vformatter(int (*flush_func)(ap_vformatter_buff *), * to distinguish between an output which was truncated, and an output which * exactly filled the buffer. */ -API_EXPORT(int) ap_snprintf(char *buf, size_t len, const char *format,...) - __attribute__((format(printf,3,4))); -API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format, - va_list ap); + API_EXPORT(int) ap_snprintf(char *buf, size_t len, const char *format, + ...) + __attribute__ ((format(printf, 3, 4))); + API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format, + va_list ap); #ifdef __cplusplus } #endif - -#endif /* !APACHE_AP_H */ +#endif /* !APACHE_AP_H */ diff --git a/src/afsweb/apache_includes/1.3.1/ap_compat.h b/src/afsweb/apache_includes/1.3.1/ap_compat.h index 23c8b04da..b08484234 100644 --- a/src/afsweb/apache_includes/1.3.1/ap_compat.h +++ b/src/afsweb/apache_includes/1.3.1/ap_compat.h @@ -415,6 +415,4 @@ extern "C" { #ifdef __cplusplus } #endif - -#endif /* !AP_COMPAT_H */ - +#endif /* !AP_COMPAT_H */ diff --git a/src/afsweb/apache_includes/1.3.1/ap_config.h b/src/afsweb/apache_includes/1.3.1/ap_config.h index 7a223cc54..7bcad2ce4 100644 --- a/src/afsweb/apache_includes/1.3.1/ap_config.h +++ b/src/afsweb/apache_includes/1.3.1/ap_config.h @@ -96,15 +96,15 @@ stat() properly */ /* Define one of these according to your system. */ #if defined(MINT) -typedef int rlim_t; + typedef int rlim_t; #define JMP_BUF sigjmp_buf #define NO_LONG_DOUBLE #define USE_FLOCK_SERIALIZED_ACCEPT #define _BSD_SOURCE #define EAGAIN EWOULDBLOCK -int initgroups (char *, int); -char *crypt (const char *pw, const char *salt); -int gethostname (char *name, int namelen); + int initgroups(char *, int); + char *crypt(const char *pw, const char *salt); + int gethostname(char *name, int namelen); #elif defined(MPE) #include @@ -113,15 +113,15 @@ int gethostname (char *name, int namelen); #define NO_WRITEV #define HAVE_SHMGET 1 #define USE_SHMGET_SCOREBOARD -#define SHM_R 0400 /* Read permission */ -#define SHM_W 0200 /* Write permission */ +#define SHM_R 0400 /* Read permission */ +#define SHM_W 0200 /* Write permission */ #define NEED_INITGROUPS #define NEED_STRCASECMP #define NEED_STRDUP #define NEED_STRNCASECMP -extern void GETPRIVMODE(); -extern void GETUSERMODE(); -extern char *inet_ntoa(); + extern void GETPRIVMODE(); + extern void GETUSERMODE(); + extern char *inet_ntoa(); #define NO_SLACK #define NO_GETTIMEOFDAY #define S_IEXEC S_IXUSR @@ -133,14 +133,14 @@ extern char *inet_ntoa(); #define HAVE_GMTOFF 1 #undef NO_KILLPG #undef NO_SETSID -char *crypt(const char *pw, const char *salt); -char *mktemp(char *template); + char *crypt(const char *pw, const char *salt); + char *mktemp(char *template); #define HAVE_MMAP 1 #define USE_MMAP_SCOREBOARD #define USE_MMAP_FILES #include #define NEED_STRERROR -typedef int rlim_t; + typedef int rlim_t; #ifndef HAVE_MEMMOVE #define memmove(a,b,c) memcpy(a, b, c) #endif @@ -164,8 +164,8 @@ typedef int rlim_t; /* AFS Websecure tweak to compile on Linux */ #if ! defined(AIX) && ! defined(HAVE_UNISTD_H) -int gethostname(char *name, int namelen); -#endif /* ! defined(AIX) && ! defined(HAVE_UNISTD_H) */ + int gethostname(char *name, int namelen); +#endif /* ! defined(AIX) && ! defined(HAVE_UNISTD_H) */ #define HAVE_SYSLOG 1 #define SYS_SIGLIST _sys_siglist @@ -212,7 +212,7 @@ int gethostname(char *name, int namelen); #define HAVE_SYSLOG 1 #ifndef HPUX10 #define SELECT_NEEDS_CAST -typedef int rlim_t; + typedef int rlim_t; #endif #elif defined(HPUX11) @@ -249,7 +249,7 @@ typedef int rlim_t; #define DEFAULT_USER "nobody" #endif #ifdef NEED_RLIM_T -typedef int rlim_t; + typedef int rlim_t; #endif #define USE_FCNTL_SERIALIZED_ACCEPT #ifdef USEBCOPY @@ -291,7 +291,7 @@ typedef int rlim_t; #define USE_MMAP_FILES #define NO_LONG_DOUBLE #define HAVE_SYSLOG 1 -typedef int rlim_t; + typedef int rlim_t; #elif defined(SEQUENT) #define HAVE_GMTOFF 1 @@ -301,7 +301,7 @@ typedef int rlim_t; #define HAVE_SYSLOG 1 #elif defined(NEXT) -typedef unsigned short mode_t; + typedef unsigned short mode_t; #define HAVE_GMTOFF 1 #undef NO_KILLPG #define NO_SETSID @@ -344,9 +344,9 @@ typedef unsigned short mode_t; #ifndef S_IWOTH #define S_IWOTH 000002 #ifndef rlim_t -typedef int rlim_t; + typedef int rlim_t; #endif -typedef u_long n_long; + typedef u_long n_long; #endif #define STDIN_FILENO 0 @@ -359,7 +359,7 @@ typedef u_long n_long; #define WEXITSTATUS(status) (int)( WIFEXITED(status) ? ( (status).w_retcode ) : -1) #define WTERMSIG(status) (int)( (status).w_termsig ) -typedef int pid_t; + typedef int pid_t; #define USE_LONGJMP #define NO_USE_SIGACTION #define HAVE_SYSLOG 1 @@ -401,7 +401,7 @@ typedef int pid_t; /* glibc 2.1 and later finally define rlim_t */ #if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) -typedef int rlim_t; + typedef int rlim_t; #endif /* flock is faster ... but hasn't been tested on 1.x systems */ @@ -440,23 +440,23 @@ typedef int rlim_t; /* Although SCO 5 defines these in (note the "s") they don't have consts. Sigh. */ -extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, unsigned); + extern int strcasecmp(const char *, const char *); + extern int strncasecmp(const char *, const char *, unsigned); #elif defined(AUX3) /* These are to let -Wall compile more cleanly */ -extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, unsigned); -extern int set42sig(), getopt(), getpeername(); -extern int listen(), bind(), socket(), getsockname(); -extern int accept(), gethostname(), connect(), lstat(); -extern int select(), killpg(), shutdown(); -extern int initgroups(), setsockopt(); -extern char *shmat(); -extern int shmctl(); -extern int shmget(); -extern char *sbrk(); -extern char *crypt(); + extern int strcasecmp(const char *, const char *); + extern int strncasecmp(const char *, const char *, unsigned); + extern int set42sig(), getopt(), getpeername(); + extern int listen(), bind(), socket(), getsockname(); + extern int accept(), gethostname(), connect(), lstat(); + extern int select(), killpg(), shutdown(); + extern int initgroups(), setsockopt(); + extern char *shmat(); + extern int shmctl(); + extern int shmget(); + extern char *sbrk(); + extern char *crypt(); #include #undef HAVE_GMTOFF #undef NO_KILLPG @@ -488,8 +488,8 @@ extern char *crypt(); #define NEED_STRCASECMP #ifndef ENCORE #define NEED_STRNCASECMP -#endif /* ENCORE */ -#endif /* MPRAS */ +#endif /* ENCORE */ +#endif /* MPRAS */ /* A lot of SVR4 systems need this */ #ifndef USE_SYSVSEM_SERIALIZED_ACCEPT #define USE_FCNTL_SERIALIZED_ACCEPT @@ -498,9 +498,9 @@ extern char *crypt(); #define NET_SIZE_T size_t #define HAVE_SHMGET 1 #define USE_SHMGET_SCOREBOARD -#ifdef _OSD_POSIX /* BS2000-POSIX mainframe needs initgroups */ +#ifdef _OSD_POSIX /* BS2000-POSIX mainframe needs initgroups */ #define NEED_INITGROUPS -#define NEED_HASHBANG_EMUL /* execve() doesn't start shell scripts by default */ +#define NEED_HASHBANG_EMUL /* execve() doesn't start shell scripts by default */ #undef HAVE_SHMGET #undef USE_SHMGET_SCOREBOARD #undef bzero @@ -575,7 +575,7 @@ extern char *crypt(); #define WTERMSIG(status) (int)((status).w_termsig) #define strftime(buf,bufsize,fmt,tm) ascftime(buf,fmt,tm) #include -#include +#include #elif defined(APOLLO) #undef HAVE_GMTOFF @@ -601,7 +601,7 @@ extern char *crypt(); #endif #if defined(__bsdi__) || \ (defined(__FreeBSD_version) && (__FreeBSD_version < 220000)) -typedef quad_t rlim_t; + typedef quad_t rlim_t; #endif #define USE_FLOCK_SERIALIZED_ACCEPT #define HAVE_SYSLOG 1 @@ -609,10 +609,10 @@ typedef quad_t rlim_t; #elif defined(QNX) #ifndef crypt -char *crypt(const char *pw, const char *salt); + char *crypt(const char *pw, const char *salt); #endif #ifndef initgroups -int initgroups(char *, int); + int initgroups(char *, int); #endif #ifndef strncasecmp #define strncasecmp strnicmp @@ -640,8 +640,8 @@ int initgroups(char *, int); #undef NO_SETSID #undef NO_USE_SIGACTION #undef NO_LINGCLOSE -extern char *crypt(char *pw, char *salt); -typedef int rlim_t; + extern char *crypt(char *pw, char *salt); + typedef int rlim_t; #define HAVE_SYSLOG 1 #elif defined(UXPDS) @@ -675,7 +675,7 @@ typedef int rlim_t; #define NO_RELIABLE_PIPED_LOGS #elif defined(__MACHTEN__) -typedef int rlim_t; + typedef int rlim_t; #undef NO_KILLPG #define NO_SETSID #define HAVE_GMTOFF 1 @@ -708,7 +708,7 @@ typedef int rlim_t; #define NO_TIMEZONE #include #include -typedef int rlim_t; + typedef int rlim_t; #elif defined(ISC) #include @@ -731,13 +731,13 @@ typedef int rlim_t; #include #include #include -typedef int pid_t; -typedef int rlim_t; -typedef int mode_t; + typedef int pid_t; + typedef int rlim_t; + typedef int mode_t; #elif defined(RISCIX) #include -typedef int rlim_t; + typedef int rlim_t; #define NO_USE_SIGACTION #define USE_LONGJMP #define NEED_STRCASECMP @@ -856,7 +856,7 @@ typedef int rlim_t; #include #ifdef HAVE_SYS_SELECT_H #include -#endif /* HAVE_SYS_SELECT_H */ +#endif /* HAVE_SYS_SELECT_H */ #include #include #include @@ -873,12 +873,12 @@ typedef int rlim_t; #define O_BINARY (0) #endif -#else /* WIN32 */ +#else /* WIN32 */ #include #include #include #include -#endif /* ndef WIN32 */ +#endif /* ndef WIN32 */ #include /* for ctime */ #include @@ -902,8 +902,8 @@ typedef int rlim_t; #ifdef HAVE_SYS_RESOURCE_H #include #ifdef SUNOS4 -int getrlimit(int, struct rlimit *); -int setrlimit(int, struct rlimit *); + int getrlimit(int, struct rlimit *); + int setrlimit(int, struct rlimit *); #endif #endif #ifdef USE_MMAP_SCOREBOARD @@ -952,7 +952,7 @@ int setrlimit(int, struct rlimit *); * Replace signal function with sigaction equivalent */ #ifndef NO_USE_SIGACTION -typedef void Sigfunc(int); + typedef void Sigfunc(int); #if defined(SIG_IGN) && !defined(SIG_ERR) #define SIG_ERR ((Sigfunc *)-1) @@ -965,7 +965,7 @@ typedef void Sigfunc(int); #undef signal #endif #define signal(s,f) ap_signal(s,f) -Sigfunc *signal(int signo, Sigfunc * func); + Sigfunc *signal(int signo, Sigfunc * func); #endif #include @@ -1009,9 +1009,9 @@ Sigfunc *signal(int signo, Sigfunc * func); * with a HASHBANG (#!) followed by interpreter name and args, define this. */ #ifdef NEED_HASHBANG_EMUL -extern int ap_execle(const char *filename, const char *arg,...); -extern int ap_execve(const char *filename, const char *argv[], - const char *envp[]); + extern int ap_execle(const char *filename, const char *arg, ...); + extern int ap_execve(const char *filename, const char *argv[], + const char *envp[]); /* ap_execle() is a wrapper function around ap_execve(). */ #define execle ap_execle #define execve(path,argv,envp) ap_execve(path,argv,envp) @@ -1030,18 +1030,18 @@ extern int ap_execve(const char *filename, const char *argv[], #define XtOffset(p_type,field) \ (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) -#else /* !CRAY2 */ +#else /* !CRAY2 */ #define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field)) -#endif /* !CRAY2 */ -#endif /* __STDC__ */ -#else /* ! (CRAY || __arm) */ +#endif /* !CRAY2 */ +#endif /* __STDC__ */ +#else /* ! (CRAY || __arm) */ #define XtOffset(p_type,field) \ ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) -#endif /* !CRAY */ +#endif /* !CRAY */ #ifdef offsetof #define XtOffsetOf(s_type,field) offsetof(s_type,field) @@ -1088,82 +1088,82 @@ extern int ap_execve(const char *filename, const char *argv[], * currently (13Nov97) used. */ -int getopt(int, char **, char *); - -int strcasecmp(const char *, const char *); -int strncasecmp(const char *, const char *, int); -int toupper(int); -int tolower(int); - -int printf(char *,...); -int fprintf(FILE *, char *,...); -int fputs(char *, FILE *); -int fread(char *, int, int, FILE *); -int fwrite(char *, int, int, FILE *); -int fgetc(FILE *); -char *fgets(char *s, int, FILE*); -int fflush(FILE *); -int fclose(FILE *); -int ungetc(int, FILE *); -int _filbuf(FILE *); /* !!! */ -int _flsbuf(unsigned char, FILE *); /* !!! */ -int sscanf(char *, char *,...); -void setbuf(FILE *, char *); -void perror(char *); - -time_t time(time_t *); -int strftime(char *, int, const char *, struct tm *); - -int initgroups(char *, int); -int wait3(int *, int, void *); /* Close enough for us... */ -int lstat(const char *, struct stat *); -int stat(const char *, struct stat *); -int flock(int, int); + int getopt(int, char **, char *); + + int strcasecmp(const char *, const char *); + int strncasecmp(const char *, const char *, int); + int toupper(int); + int tolower(int); + + int printf(char *, ...); + int fprintf(FILE *, char *, ...); + int fputs(char *, FILE *); + int fread(char *, int, int, FILE *); + int fwrite(char *, int, int, FILE *); + int fgetc(FILE *); + char *fgets(char *s, int, FILE *); + int fflush(FILE *); + int fclose(FILE *); + int ungetc(int, FILE *); + int _filbuf(FILE *); /* !!! */ + int _flsbuf(unsigned char, FILE *); /* !!! */ + int sscanf(char *, char *, ...); + void setbuf(FILE *, char *); + void perror(char *); + + time_t time(time_t *); + int strftime(char *, int, const char *, struct tm *); + + int initgroups(char *, int); + int wait3(int *, int, void *); /* Close enough for us... */ + int lstat(const char *, struct stat *); + int stat(const char *, struct stat *); + int flock(int, int); #ifndef NO_KILLPG -int killpg(int, int); + int killpg(int, int); #endif -int socket(int, int, int); -int setsockopt(int, int, int, const char *, int); -int listen(int, int); -int bind(int, struct sockaddr *, int); -int connect(int, struct sockaddr *, int); -int accept(int, struct sockaddr *, int *); -int shutdown(int, int); + int socket(int, int, int); + int setsockopt(int, int, int, const char *, int); + int listen(int, int); + int bind(int, struct sockaddr *, int); + int connect(int, struct sockaddr *, int); + int accept(int, struct sockaddr *, int *); + int shutdown(int, int); -int getsockname(int s, struct sockaddr *name, int *namelen); -int getpeername(int s, struct sockaddr *name, int *namelen); -int gethostname(char *name, int namelen); -void syslog(int, char *,...); -char *mktemp(char *); + int getsockname(int s, struct sockaddr *name, int *namelen); + int getpeername(int s, struct sockaddr *name, int *namelen); + int gethostname(char *name, int namelen); + void syslog(int, char *, ...); + char *mktemp(char *); -long vfprintf(FILE *, const char *, va_list); + long vfprintf(FILE *, const char *, va_list); -#endif /* SUNOS_LIB_PROTOTYPES */ +#endif /* SUNOS_LIB_PROTOTYPES */ /* The assumption is that when the functions are missing, * then there's no matching prototype available either. * Declare what is needed exactly as the replacement routines implement it. */ #ifdef NEED_STRDUP -extern char *strdup (const char *str); + extern char *strdup(const char *str); #endif #ifdef NEED_STRCASECMP -extern int strcasecmp (const char *a, const char *b); + extern int strcasecmp(const char *a, const char *b); #endif #ifdef NEED_STRNCASECMP -extern int strncasecmp (const char *a, const char *b, int n); + extern int strncasecmp(const char *a, const char *b, int n); #endif #ifdef NEED_INITGROUPS -extern int initgroups(const char *name, gid_t basegid); + extern int initgroups(const char *name, gid_t basegid); #endif #ifdef NEED_WAITPID -extern int waitpid(pid_t pid, int *statusp, int options); + extern int waitpid(pid_t pid, int *statusp, int options); #endif #ifdef NEED_STRERROR -extern char *strerror (int err); + extern char *strerror(int err); #endif #ifdef NEED_DIFFTIME -extern double difftime(time_t time1, time_t time0); + extern double difftime(time_t time1, time_t time0); #endif #ifndef ap_wait_t @@ -1173,5 +1173,4 @@ extern double difftime(time_t time1, time_t time0); #ifdef __cplusplus } #endif - -#endif /* !AP_CONFIG_H */ +#endif /* !AP_CONFIG_H */ diff --git a/src/afsweb/apache_includes/1.3.1/ap_ctype.h b/src/afsweb/apache_includes/1.3.1/ap_ctype.h index bba58b45d..af5c34878 100644 --- a/src/afsweb/apache_includes/1.3.1/ap_ctype.h +++ b/src/afsweb/apache_includes/1.3.1/ap_ctype.h @@ -85,5 +85,4 @@ extern "C" { #ifdef __cplusplus } #endif - -#endif /* !AP_CTYPE_H */ +#endif /* !AP_CTYPE_H */ diff --git a/src/afsweb/apache_includes/1.3.1/buff.h b/src/afsweb/apache_includes/1.3.1/buff.h index a20338fa6..908186c4c 100644 --- a/src/afsweb/apache_includes/1.3.1/buff.h +++ b/src/afsweb/apache_includes/1.3.1/buff.h @@ -81,7 +81,7 @@ extern "C" { #define B_RDERR (16) /* A write error has occurred */ #define B_WRERR (32) -#ifdef B_ERROR /* in SVR4: sometimes defined in /usr/include/sys/buf.h */ +#ifdef B_ERROR /* in SVR4: sometimes defined in /usr/include/sys/buf.h */ #undef B_ERROR #endif #define B_ERROR (48) @@ -92,89 +92,90 @@ extern "C" { /* buffer is a socket */ #define B_SOCKET (256) #ifdef CHARSET_EBCDIC -#define B_ASCII2EBCDIC 0x40000000 /* Enable conversion for this buffer */ -#define B_EBCDIC2ASCII 0x80000000 /* Enable conversion for this buffer */ -#endif /*CHARSET_EBCDIC*/ +#define B_ASCII2EBCDIC 0x40000000 /* Enable conversion for this buffer */ +#define B_EBCDIC2ASCII 0x80000000 /* Enable conversion for this buffer */ +#endif /*CHARSET_EBCDIC */ -typedef struct buff_struct BUFF; + typedef struct buff_struct BUFF; -struct buff_struct { - int flags; /* flags */ - unsigned char *inptr; /* pointer to next location to read */ - int incnt; /* number of bytes left to read from input buffer; + struct buff_struct { + int flags; /* flags */ + unsigned char *inptr; /* pointer to next location to read */ + int incnt; /* number of bytes left to read from input buffer; * always 0 if had a read error */ - int outchunk; /* location of chunk header when chunking */ - int outcnt; /* number of byte put in output buffer */ - unsigned char *inbase; - unsigned char *outbase; - int bufsiz; - void (*error) (BUFF *fb, int op, void *data); - void *error_data; - long int bytes_sent; /* number of bytes actually written */ + int outchunk; /* location of chunk header when chunking */ + int outcnt; /* number of byte put in output buffer */ + unsigned char *inbase; + unsigned char *outbase; + int bufsiz; + void (*error) (BUFF * fb, int op, void *data); + void *error_data; + long int bytes_sent; /* number of bytes actually written */ - ap_pool *pool; + ap_pool *pool; /* could also put pointers to the basic I/O routines here */ - int fd; /* the file descriptor */ - int fd_in; /* input file descriptor, if different */ + int fd; /* the file descriptor */ + int fd_in; /* input file descriptor, if different */ #ifdef WIN32 - HANDLE hFH; /* Windows filehandle */ + HANDLE hFH; /* Windows filehandle */ #endif - /* transport handle, for RPC binding handle or some such */ - void *t_handle; + /* transport handle, for RPC binding handle or some such */ + void *t_handle; #ifdef B_SFIO - Sfio_t *sf_in; - Sfio_t *sf_out; + Sfio_t *sf_in; + Sfio_t *sf_out; #endif -}; + }; #ifdef B_SFIO -typedef struct { - Sfdisc_t disc; - BUFF *buff; -} apache_sfio; + typedef struct { + Sfdisc_t disc; + BUFF *buff; + } apache_sfio; -extern Sfdisc_t *bsfio_new(pool *p, BUFF *b); + extern Sfdisc_t *bsfio_new(pool * p, BUFF * b); #endif /* Options to bset/getopt */ #define BO_BYTECT (1) /* Stream creation and modification */ -API_EXPORT(BUFF *) ap_bcreate(pool *p, int flags); -API_EXPORT(void) ap_bpushfd(BUFF *fb, int fd_in, int fd_out); + API_EXPORT(BUFF *) ap_bcreate(pool * p, int flags); + API_EXPORT(void) ap_bpushfd(BUFF * fb, int fd_in, int fd_out); #ifdef WIN32 -API_EXPORT(void) ap_bpushh(BUFF *fb, HANDLE hFH); + API_EXPORT(void) ap_bpushh(BUFF * fb, HANDLE hFH); #endif -API_EXPORT(int) ap_bsetopt(BUFF *fb, int optname, const void *optval); -API_EXPORT(int) ap_bgetopt(BUFF *fb, int optname, void *optval); -API_EXPORT(int) ap_bsetflag(BUFF *fb, int flag, int value); -API_EXPORT(int) ap_bclose(BUFF *fb); + API_EXPORT(int) ap_bsetopt(BUFF * fb, int optname, const void *optval); + API_EXPORT(int) ap_bgetopt(BUFF * fb, int optname, void *optval); + API_EXPORT(int) ap_bsetflag(BUFF * fb, int flag, int value); + API_EXPORT(int) ap_bclose(BUFF * fb); #define ap_bgetflag(fb, flag) ((fb)->flags & (flag)) /* Error handling */ -API_EXPORT(void) ap_bonerror(BUFF *fb, void (*error) (BUFF *, int, void *), - void *data); + API_EXPORT(void) ap_bonerror(BUFF * fb, + void (*error) (BUFF *, int, void *), + void *data); /* I/O */ -API_EXPORT(int) ap_bread(BUFF *fb, void *buf, int nbyte); -API_EXPORT(int) ap_bgets(char *s, int n, BUFF *fb); -API_EXPORT(int) ap_blookc(char *buff, BUFF *fb); -API_EXPORT(int) ap_bskiplf(BUFF *fb); -API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte); -API_EXPORT(int) ap_bflush(BUFF *fb); -API_EXPORT(int) ap_bputs(const char *x, BUFF *fb); -API_EXPORT(int) ap_bvputs(BUFF *fb,...); -API_EXPORT_NONSTD(int) ap_bprintf(BUFF *fb, const char *fmt,...) - __attribute__((format(printf,2,3))); -API_EXPORT(int) ap_vbprintf(BUFF *fb, const char *fmt, va_list vlist); + API_EXPORT(int) ap_bread(BUFF * fb, void *buf, int nbyte); + API_EXPORT(int) ap_bgets(char *s, int n, BUFF * fb); + API_EXPORT(int) ap_blookc(char *buff, BUFF * fb); + API_EXPORT(int) ap_bskiplf(BUFF * fb); + API_EXPORT(int) ap_bwrite(BUFF * fb, const void *buf, int nbyte); + API_EXPORT(int) ap_bflush(BUFF * fb); + API_EXPORT(int) ap_bputs(const char *x, BUFF * fb); + API_EXPORT(int) ap_bvputs(BUFF * fb, ...); + API_EXPORT_NONSTD(int) ap_bprintf(BUFF * fb, const char *fmt, ...) + __attribute__ ((format(printf, 2, 3))); + API_EXPORT(int) ap_vbprintf(BUFF * fb, const char *fmt, va_list vlist); /* Internal routines */ -API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb); -API_EXPORT(int) ap_bfilbuf(BUFF *fb); + API_EXPORT(int) ap_bflsbuf(int c, BUFF * fb); + API_EXPORT(int) ap_bfilbuf(BUFF * fb); #ifndef CHARSET_EBCDIC @@ -185,7 +186,7 @@ API_EXPORT(int) ap_bfilbuf(BUFF *fb); (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \ ((fb)->outbase[(fb)->outcnt++] = (c), 0)) -#else /*CHARSET_EBCDIC*/ +#else /*CHARSET_EBCDIC */ #define ap_bgetc(fb) ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \ ((fb)->incnt--, (fb->flags & B_ASCII2EBCDIC)\ @@ -196,41 +197,41 @@ API_EXPORT(int) ap_bfilbuf(BUFF *fb); ((fb)->outbase[(fb)->outcnt++] = (fb->flags & B_EBCDIC2ASCII)\ ?os_toascii[(unsigned char)c]:(c), 0)) -#endif /*CHARSET_EBCDIC*/ -struct child_info { +#endif /*CHARSET_EBCDIC */ + struct child_info { #ifdef WIN32 - /* - * These handles are used by ap_call_exec to call - * create process with pipe handles. - */ - HANDLE hPipeInputRead; - HANDLE hPipeOutputWrite; - HANDLE hPipeErrorWrite; + /* + * These handles are used by ap_call_exec to call + * create process with pipe handles. + */ + HANDLE hPipeInputRead; + HANDLE hPipeOutputWrite; + HANDLE hPipeErrorWrite; #else - /* - * We need to put a dummy member in here to avoid compilation - * errors under certain Unix compilers, like SGI's and HPUX's, - * which fail to compile a zero-sized struct. Of course - * it would be much nicer if there was actually a use for this - * structure under Unix. Aah the joys of x-platform code. - */ - int dummy; + /* + * We need to put a dummy member in here to avoid compilation + * errors under certain Unix compilers, like SGI's and HPUX's, + * which fail to compile a zero-sized struct. Of course + * it would be much nicer if there was actually a use for this + * structure under Unix. Aah the joys of x-platform code. + */ + int dummy; #endif -}; -API_EXPORT(int) ap_bspawn_child(pool *, int (*)(void *, child_info *), void *, - enum kill_conditions, BUFF **pipe_in, BUFF **pipe_out, - BUFF **pipe_err); + }; + API_EXPORT(int) ap_bspawn_child(pool *, int (*)(void *, child_info *), + void *, enum kill_conditions, + BUFF ** pipe_in, BUFF ** pipe_out, + BUFF ** pipe_err); /* enable non-blocking operations */ -API_EXPORT(int) ap_bnonblock(BUFF *fb, int direction); + API_EXPORT(int) ap_bnonblock(BUFF * fb, int direction); /* and get an fd to select() on */ -API_EXPORT(int) ap_bfileno(BUFF *fb, int direction); + API_EXPORT(int) ap_bfileno(BUFF * fb, int direction); /* bflush() if a read now would block, but don't actually read anything */ -API_EXPORT(void) ap_bhalfduplex(BUFF *fb); + API_EXPORT(void) ap_bhalfduplex(BUFF * fb); #ifdef __cplusplus } #endif - -#endif /* !APACHE_BUFF_H */ +#endif /* !APACHE_BUFF_H */ diff --git a/src/afsweb/apache_includes/1.3.1/http_conf_globals.h b/src/afsweb/apache_includes/1.3.1/http_conf_globals.h index 0763e6b9e..4a738b509 100644 --- a/src/afsweb/apache_includes/1.3.1/http_conf_globals.h +++ b/src/afsweb/apache_includes/1.3.1/http_conf_globals.h @@ -66,32 +66,32 @@ extern "C" { * Process config --- what the process ITSELF is doing */ -extern int ap_standalone; -extern uid_t ap_user_id; -extern char *ap_user_name; -extern gid_t ap_group_id; + extern int ap_standalone; + extern uid_t ap_user_id; + extern char *ap_user_name; + extern gid_t ap_group_id; #ifdef MULTIPLE_GROUPS -extern gid_t group_id_list[NGROUPS_MAX]; + extern gid_t group_id_list[NGROUPS_MAX]; #endif -extern int ap_max_requests_per_child; -extern int ap_threads_per_child; -extern int ap_excess_requests_per_child; -extern struct in_addr ap_bind_address; -extern listen_rec *ap_listeners; -extern int ap_daemons_to_start; -extern int ap_daemons_min_free; -extern int ap_daemons_max_free; -extern int ap_daemons_limit; -extern MODULE_VAR_EXPORT int ap_suexec_enabled; -extern int ap_listenbacklog; -extern int ap_dump_settings; + extern int ap_max_requests_per_child; + extern int ap_threads_per_child; + extern int ap_excess_requests_per_child; + extern struct in_addr ap_bind_address; + extern listen_rec *ap_listeners; + extern int ap_daemons_to_start; + extern int ap_daemons_min_free; + extern int ap_daemons_max_free; + extern int ap_daemons_limit; + extern MODULE_VAR_EXPORT int ap_suexec_enabled; + extern int ap_listenbacklog; + extern int ap_dump_settings; -extern char *ap_pid_fname; -extern char *ap_scoreboard_fname; -extern char *ap_lock_fname; -extern MODULE_VAR_EXPORT char *ap_server_argv0; + extern char *ap_pid_fname; + extern char *ap_scoreboard_fname; + extern char *ap_lock_fname; + extern MODULE_VAR_EXPORT char *ap_server_argv0; -extern enum server_token_type ap_server_tokens; + extern enum server_token_type ap_server_tokens; /* Trying to allocate these in the config pool gets us into some *nasty* * chicken-and-egg problems in http_main.c --- where do you stick them @@ -99,21 +99,20 @@ extern enum server_token_type ap_server_tokens; * statically... */ -extern API_VAR_EXPORT char ap_server_root[MAX_STRING_LEN]; -extern char ap_server_confname[MAX_STRING_LEN]; + extern API_VAR_EXPORT char ap_server_root[MAX_STRING_LEN]; + extern char ap_server_confname[MAX_STRING_LEN]; /* for -C, -c and -D switches */ -extern array_header *ap_server_pre_read_config; -extern array_header *ap_server_post_read_config; -extern array_header *ap_server_config_defines; + extern array_header *ap_server_pre_read_config; + extern array_header *ap_server_post_read_config; + extern array_header *ap_server_config_defines; /* We want this to have the least chance of being corrupted if there * is some memory corruption, so we allocate it statically. */ -extern char ap_coredump_dir[MAX_STRING_LEN]; + extern char ap_coredump_dir[MAX_STRING_LEN]; #ifdef __cplusplus } #endif - -#endif /* !APACHE_HTTP_CONF_GLOBALS_H */ +#endif /* !APACHE_HTTP_CONF_GLOBALS_H */ diff --git a/src/afsweb/apache_includes/1.3.1/httpd.h b/src/afsweb/apache_includes/1.3.1/httpd.h index 6fd0db466..ed87ca790 100644 --- a/src/afsweb/apache_includes/1.3.1/httpd.h +++ b/src/afsweb/apache_includes/1.3.1/httpd.h @@ -88,7 +88,7 @@ extern "C" { #else #define HTTPD_ROOT "/usr/local/apache" #endif -#endif /* HTTPD_ROOT */ +#endif /* HTTPD_ROOT */ /* Default location of documents. Can be overridden by the DocumentRoot * directive. @@ -100,7 +100,7 @@ extern "C" { #else #define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs" #endif -#endif /* DOCUMENT_LOCATION */ +#endif /* DOCUMENT_LOCATION */ /* Max. number of dynamically loaded modules */ #ifndef DYNAMIC_MODULE_LIMIT @@ -150,7 +150,7 @@ extern "C" { #else #define DEFAULT_XFERLOG "logs/access_log" #endif -#endif /* DEFAULT_XFERLOG */ +#endif /* DEFAULT_XFERLOG */ #ifndef DEFAULT_ERRORLOG #ifdef __EMX__ @@ -159,7 +159,7 @@ extern "C" { #else #define DEFAULT_ERRORLOG "logs/error_log" #endif -#endif /* DEFAULT_ERRORLOG */ +#endif /* DEFAULT_ERRORLOG */ #ifndef DEFAULT_PIDLOG #define DEFAULT_PIDLOG "logs/httpd.pid" @@ -195,7 +195,7 @@ extern "C" { #else #define DEFAULT_ACCESS_FNAME ".htaccess" #endif -#endif /* DEFAULT_ACCESS_FNAME */ +#endif /* DEFAULT_ACCESS_FNAME */ /* The name of the server config file */ #ifndef SERVER_CONFIG_FILE @@ -239,7 +239,7 @@ extern "C" { #else #define SHELL_PATH "/bin/sh" #endif -#endif /* SHELL_PATH */ +#endif /* SHELL_PATH */ /* The path to the suExec wrapper, can be overridden in Configuration */ #ifndef SUEXEC_BIN @@ -384,15 +384,15 @@ extern "C" { #define SERVER_BASEVERSION "Apache/1.3.1" /* SEE COMMENTS ABOVE */ #define SERVER_VERSION SERVER_BASEVERSION -enum server_token_type { - SrvTk_MIN, /* eg: Apache/1.3.0 */ - SrvTk_OS, /* eg: Apache/1.3.0 (UNIX) */ - SrvTk_FULL /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */ -}; + enum server_token_type { + SrvTk_MIN, /* eg: Apache/1.3.0 */ + SrvTk_OS, /* eg: Apache/1.3.0 (UNIX) */ + SrvTk_FULL /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */ + }; -API_EXPORT(const char *) ap_get_server_version(void); -API_EXPORT(void) ap_add_version_component(const char *component); -API_EXPORT(const char *) ap_get_server_built(void); + API_EXPORT(const char *) ap_get_server_version(void); + API_EXPORT(void) ap_add_version_component(const char *component); + API_EXPORT(const char *) ap_get_server_built(void); /* Numeric release version identifier: major minor bugfix betaseq * Always increases along the same track as the source branch. @@ -506,8 +506,8 @@ API_EXPORT(const char *) ap_get_server_built(void); #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html" #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3" #ifdef CHARSET_EBCDIC -#define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */ -#endif /*CHARSET_EBCDIC*/ +#define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */ +#endif /*CHARSET_EBCDIC */ #define MAP_FILE_MAGIC_TYPE "application/x-type-map" #define ASIS_MAGIC_TYPE "httpd/send-as-is" #define DIR_MAGIC_TYPE "httpd/unix-directory" @@ -517,7 +517,7 @@ API_EXPORT(const char *) ap_get_server_built(void); #ifndef CHARSET_EBCDIC #define LF 10 #define CR 13 -#else /* CHARSET_EBCDIC */ +#else /* CHARSET_EBCDIC */ #include "ebcdic.h" /* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in * the buff package (bread/bputs/bwrite), so everywhere else, we use @@ -528,7 +528,7 @@ API_EXPORT(const char *) ap_get_server_built(void); */ #define CR '\r' #define LF '\n' -#endif /* CHARSET_EBCDIC */ +#endif /* CHARSET_EBCDIC */ /* Possible values for request_rec.read_body (set by handling module): * REQUEST_NO_BODY Send 413 error if message has any body @@ -557,153 +557,153 @@ API_EXPORT(const char *) ap_get_server_built(void); /* This represents the result of calling htaccess; these are cached for * each request. */ -struct htaccess_result { - char *dir; /* the directory to which this applies */ - int override; /* the overrides allowed for the .htaccess file */ - void *htaccess; /* the configuration directives */ + struct htaccess_result { + char *dir; /* the directory to which this applies */ + int override; /* the overrides allowed for the .htaccess file */ + void *htaccess; /* the configuration directives */ /* the next one, or NULL if no more; N.B. never change this */ - const struct htaccess_result *next; -}; + const struct htaccess_result *next; + }; -typedef struct conn_rec conn_rec; -typedef struct server_rec server_rec; -typedef struct request_rec request_rec; -typedef struct listen_rec listen_rec; + typedef struct conn_rec conn_rec; + typedef struct server_rec server_rec; + typedef struct request_rec request_rec; + typedef struct listen_rec listen_rec; #include "util_uri.h" -struct request_rec { + struct request_rec { - ap_pool *pool; - conn_rec *connection; - server_rec *server; + ap_pool *pool; + conn_rec *connection; + server_rec *server; - request_rec *next; /* If we wind up getting redirected, + request_rec *next; /* If we wind up getting redirected, * pointer to the request we redirected to. */ - request_rec *prev; /* If this is an internal redirect, + request_rec *prev; /* If this is an internal redirect, * pointer to where we redirected *from*. */ - request_rec *main; /* If this is a sub_request (see request.h) + request_rec *main; /* If this is a sub_request (see request.h) * pointer back to the main request. */ - /* Info about the request itself... we begin with stuff that only - * protocol.c should ever touch... - */ + /* Info about the request itself... we begin with stuff that only + * protocol.c should ever touch... + */ - char *the_request; /* First line of request, so we can log it */ - int assbackwards; /* HTTP/0.9, "simple" request */ - int proxyreq; /* A proxy request (calculated during + char *the_request; /* First line of request, so we can log it */ + int assbackwards; /* HTTP/0.9, "simple" request */ + int proxyreq; /* A proxy request (calculated during * post_read_request or translate_name) */ - int header_only; /* HEAD request, as opposed to GET */ - char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ - int proto_num; /* Number version of protocol; 1.1 = 1001 */ - const char *hostname; /* Host, as set by full URI or Host: */ - - time_t request_time; /* When the request started */ - - char *status_line; /* Status line, if set by script */ - int status; /* In any case */ - - /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, - * look, but don't touch. - */ - - char *method; /* GET, HEAD, POST, etc. */ - int method_number; /* M_GET, M_POST, etc. */ - - /* - allowed is a bitvector of the allowed methods. - - A handler must ensure that the request method is one that - it is capable of handling. Generally modules should DECLINE - any request methods they do not handle. Prior to aborting the - handler like this the handler should set r->allowed to the list - of methods that it is willing to handle. This bitvector is used - to construct the "Allow:" header required for OPTIONS requests, - and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes. - - Since the default_handler deals with OPTIONS, all modules can - usually decline to deal with OPTIONS. TRACE is always allowed, - modules don't need to set it explicitly. - - Since the default_handler will always handle a GET, a - module which does *not* implement GET should probably return - METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET - handler can't be installed by mod_actions. - */ - int allowed; /* Allowed methods - for 405, OPTIONS, etc */ - - int sent_bodyct; /* byte count in stream is for body */ - long bytes_sent; /* body byte count, for easy access */ - time_t mtime; /* Time the resource was last modified */ - - /* HTTP/1.1 connection-level features */ - - int chunked; /* sending chunked transfer-coding */ - int byterange; /* number of byte ranges */ - char *boundary; /* multipart/byteranges boundary */ - const char *range; /* The Range: header */ - long clength; /* The "real" content length */ - - long remaining; /* bytes left to read */ - long read_length; /* bytes that have been read */ - int read_body; /* how the request body should be read */ - int read_chunked; /* reading chunked transfer-coding */ - - /* MIME header environments, in and out. Also, an array containing - * environment variables to be passed to subprocesses, so people can - * write modules to add to that environment. - * - * The difference between headers_out and err_headers_out is that the - * latter are printed even on error, and persist across internal redirects - * (so the headers printed for ErrorDocument handlers will have them). - * - * The 'notes' table is for notes from one module to another, with no - * other set purpose in mind... - */ - - table *headers_in; - table *headers_out; - table *err_headers_out; - table *subprocess_env; - table *notes; - - /* content_type, handler, content_encoding, content_language, and all - * content_languages MUST be lowercased strings. They may be pointers - * to static strings; they should not be modified in place. - */ - const char *content_type; /* Break these out --- we dispatch on 'em */ - const char *handler; /* What we *really* dispatch on */ - - const char *content_encoding; - const char *content_language; /* for back-compat. only -- do not use */ - array_header *content_languages; /* array of (char*) */ - - int no_cache; - int no_local_copy; - - /* What object is being requested (either directly, or via include - * or content-negotiation mapping). - */ - - char *unparsed_uri; /* the uri without any parsing performed */ - char *uri; /* the path portion of the URI */ - char *filename; - char *path_info; - char *args; /* QUERY_ARGS, if any */ - struct stat finfo; /* ST_MODE set to zero if no such file */ - uri_components parsed_uri; /* components of uri, dismantled */ - - /* Various other config info which may change with .htaccess files - * These are config vectors, with one void* pointer for each module - * (the thing pointed to being the module's business). - */ - - void *per_dir_config; /* Options set in config files, etc. */ - void *request_config; /* Notes on *this* request */ + int header_only; /* HEAD request, as opposed to GET */ + char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ + int proto_num; /* Number version of protocol; 1.1 = 1001 */ + const char *hostname; /* Host, as set by full URI or Host: */ + + time_t request_time; /* When the request started */ + + char *status_line; /* Status line, if set by script */ + int status; /* In any case */ + + /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, + * look, but don't touch. + */ + + char *method; /* GET, HEAD, POST, etc. */ + int method_number; /* M_GET, M_POST, etc. */ + + /* + * allowed is a bitvector of the allowed methods. + * + * A handler must ensure that the request method is one that + * it is capable of handling. Generally modules should DECLINE + * any request methods they do not handle. Prior to aborting the + * handler like this the handler should set r->allowed to the list + * of methods that it is willing to handle. This bitvector is used + * to construct the "Allow:" header required for OPTIONS requests, + * and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes. + * + * Since the default_handler deals with OPTIONS, all modules can + * usually decline to deal with OPTIONS. TRACE is always allowed, + * modules don't need to set it explicitly. + * + * Since the default_handler will always handle a GET, a + * module which does *not* implement GET should probably return + * METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET + * handler can't be installed by mod_actions. + */ + int allowed; /* Allowed methods - for 405, OPTIONS, etc */ + + int sent_bodyct; /* byte count in stream is for body */ + long bytes_sent; /* body byte count, for easy access */ + time_t mtime; /* Time the resource was last modified */ + + /* HTTP/1.1 connection-level features */ + + int chunked; /* sending chunked transfer-coding */ + int byterange; /* number of byte ranges */ + char *boundary; /* multipart/byteranges boundary */ + const char *range; /* The Range: header */ + long clength; /* The "real" content length */ + + long remaining; /* bytes left to read */ + long read_length; /* bytes that have been read */ + int read_body; /* how the request body should be read */ + int read_chunked; /* reading chunked transfer-coding */ + + /* MIME header environments, in and out. Also, an array containing + * environment variables to be passed to subprocesses, so people can + * write modules to add to that environment. + * + * The difference between headers_out and err_headers_out is that the + * latter are printed even on error, and persist across internal redirects + * (so the headers printed for ErrorDocument handlers will have them). + * + * The 'notes' table is for notes from one module to another, with no + * other set purpose in mind... + */ + + table *headers_in; + table *headers_out; + table *err_headers_out; + table *subprocess_env; + table *notes; + + /* content_type, handler, content_encoding, content_language, and all + * content_languages MUST be lowercased strings. They may be pointers + * to static strings; they should not be modified in place. + */ + const char *content_type; /* Break these out --- we dispatch on 'em */ + const char *handler; /* What we *really* dispatch on */ + + const char *content_encoding; + const char *content_language; /* for back-compat. only -- do not use */ + array_header *content_languages; /* array of (char*) */ + + int no_cache; + int no_local_copy; + + /* What object is being requested (either directly, or via include + * or content-negotiation mapping). + */ + + char *unparsed_uri; /* the uri without any parsing performed */ + char *uri; /* the path portion of the URI */ + char *filename; + char *path_info; + char *args; /* QUERY_ARGS, if any */ + struct stat finfo; /* ST_MODE set to zero if no such file */ + uri_components parsed_uri; /* components of uri, dismantled */ + + /* Various other config info which may change with .htaccess files + * These are config vectors, with one void* pointer for each module + * (the thing pointed to being the module's business). + */ + + void *per_dir_config; /* Options set in config files, etc. */ + void *request_config; /* Notes on *this* request */ /* * a linked list of the configuration directives in the .htaccess files @@ -711,52 +711,52 @@ struct request_rec { * N.B. always add to the head of the list, _never_ to the end. * that way, a sub request's list can (temporarily) point to a parent's list */ - const struct htaccess_result *htaccess; -}; + const struct htaccess_result *htaccess; + }; /* Things which are per connection */ -struct conn_rec { + struct conn_rec { - ap_pool *pool; - server_rec *server; - server_rec *base_server; /* Physical vhost this conn come in on */ - void *vhost_lookup_data; /* used by http_vhost.c */ + ap_pool *pool; + server_rec *server; + server_rec *base_server; /* Physical vhost this conn come in on */ + void *vhost_lookup_data; /* used by http_vhost.c */ - /* Information about the connection itself */ + /* Information about the connection itself */ - int child_num; /* The number of the child handling conn_rec */ - BUFF *client; /* Connection to the guy */ + int child_num; /* The number of the child handling conn_rec */ + BUFF *client; /* Connection to the guy */ - /* Who is the client? */ + /* Who is the client? */ - struct sockaddr_in local_addr; /* local address */ - struct sockaddr_in remote_addr; /* remote address */ - char *remote_ip; /* Client's IP address */ - char *remote_host; /* Client's DNS name, if known. + struct sockaddr_in local_addr; /* local address */ + struct sockaddr_in remote_addr; /* remote address */ + char *remote_ip; /* Client's IP address */ + char *remote_host; /* Client's DNS name, if known. * NULL if DNS hasn't been checked, * "" if it has and no address was found. * N.B. Only access this though * get_remote_host() */ - char *remote_logname; /* Only ever set if doing rfc1413 lookups. + char *remote_logname; /* Only ever set if doing rfc1413 lookups. * N.B. Only access this through * get_remote_logname() */ - char *user; /* If an authentication check was made, + char *user; /* If an authentication check was made, * this gets set to the user name. We assume * that there's only one user per connection(!) */ - char *ap_auth_type; /* Ditto. */ + char *ap_auth_type; /* Ditto. */ - unsigned aborted:1; /* Are we still talking? */ - signed int keepalive:2; /* Are we using HTTP Keep-Alive? + unsigned aborted:1; /* Are we still talking? */ + signed int keepalive:2; /* Are we using HTTP Keep-Alive? * -1 fatal error, 0 undecided, 1 yes */ - unsigned keptalive:1; /* Did we use HTTP Keep-Alive? */ - signed int double_reverse:2;/* have we done double-reverse DNS? - * -1 yes/failure, 0 not yet, 1 yes/success */ - int keepalives; /* How many times have we used it? */ -}; + unsigned keptalive:1; /* Did we use HTTP Keep-Alive? */ + signed int double_reverse:2; /* have we done double-reverse DNS? + * -1 yes/failure, 0 not yet, 1 yes/success */ + int keepalives; /* How many times have we used it? */ + }; /* Per-vhost config... */ @@ -765,200 +765,220 @@ struct conn_rec { */ #define DEFAULT_VHOST_ADDR 0xfffffffful -typedef struct server_addr_rec server_addr_rec; -struct server_addr_rec { - server_addr_rec *next; - struct in_addr host_addr; /* The bound address, for this server */ - unsigned short host_port; /* The bound port, for this server */ - char *virthost; /* The name given in */ -}; + typedef struct server_addr_rec server_addr_rec; + struct server_addr_rec { + server_addr_rec *next; + struct in_addr host_addr; /* The bound address, for this server */ + unsigned short host_port; /* The bound port, for this server */ + char *virthost; /* The name given in */ + }; -struct server_rec { + struct server_rec { - server_rec *next; + server_rec *next; - /* description of where the definition came from */ - const char *defn_name; - unsigned defn_line_number; + /* description of where the definition came from */ + const char *defn_name; + unsigned defn_line_number; - /* Full locations of server config info */ + /* Full locations of server config info */ - char *srm_confname; - char *access_confname; + char *srm_confname; + char *access_confname; - /* Contact information */ + /* Contact information */ - char *server_admin; - char *server_hostname; - unsigned short port; /* for redirects, etc. */ + char *server_admin; + char *server_hostname; + unsigned short port; /* for redirects, etc. */ - /* Log files --- note that transfer log is now in the modules... */ + /* Log files --- note that transfer log is now in the modules... */ - char *error_fname; - FILE *error_log; - int loglevel; + char *error_fname; + FILE *error_log; + int loglevel; - /* Module-specific configuration for server, and defaults... */ + /* Module-specific configuration for server, and defaults... */ - int is_virtual; /* true if this is the virtual server */ - void *module_config; /* Config vector containing pointers to + int is_virtual; /* true if this is the virtual server */ + void *module_config; /* Config vector containing pointers to * modules' per-server config structures. */ - void *lookup_defaults; /* MIME type info, etc., before we start + void *lookup_defaults; /* MIME type info, etc., before we start * checking per-directory info. */ - /* Transaction handling */ + /* Transaction handling */ - server_addr_rec *addrs; - int timeout; /* Timeout, in seconds, before we give up */ - int keep_alive_timeout; /* Seconds we'll wait for another request */ - int keep_alive_max; /* Maximum requests per connection */ - int keep_alive; /* Use persistent connections? */ - int send_buffer_size; /* size of TCP send buffer (in bytes) */ + server_addr_rec *addrs; + int timeout; /* Timeout, in seconds, before we give up */ + int keep_alive_timeout; /* Seconds we'll wait for another request */ + int keep_alive_max; /* Maximum requests per connection */ + int keep_alive; /* Use persistent connections? */ + int send_buffer_size; /* size of TCP send buffer (in bytes) */ - char *path; /* Pathname for ServerPath */ - int pathlen; /* Length of path */ + char *path; /* Pathname for ServerPath */ + int pathlen; /* Length of path */ - array_header *names; /* Normal names for ServerAlias servers */ - array_header *wild_names; /* Wildcarded names for ServerAlias servers */ + array_header *names; /* Normal names for ServerAlias servers */ + array_header *wild_names; /* Wildcarded names for ServerAlias servers */ - uid_t server_uid; /* effective user id when calling exec wrapper */ - gid_t server_gid; /* effective group id when calling exec wrapper */ -}; + uid_t server_uid; /* effective user id when calling exec wrapper */ + gid_t server_gid; /* effective group id when calling exec wrapper */ + }; /* These are more like real hosts than virtual hosts */ -struct listen_rec { - listen_rec *next; - struct sockaddr_in local_addr; /* local IP address and port */ - int fd; - int used; /* Only used during restart */ + struct listen_rec { + listen_rec *next; + struct sockaddr_in local_addr; /* local IP address and port */ + int fd; + int used; /* Only used during restart */ /* more stuff here, like which protocol is bound to the port */ -}; + }; /* Prototypes for utilities... util.c. */ -extern void ap_util_init(void); + extern void ap_util_init(void); /* Time */ -extern API_VAR_EXPORT const char ap_month_snames[12][4]; -extern API_VAR_EXPORT const char ap_day_snames[7][4]; + extern API_VAR_EXPORT const char ap_month_snames[12][4]; + extern API_VAR_EXPORT const char ap_day_snames[7][4]; -API_EXPORT(struct tm *) ap_get_gmtoff(int *tz); -API_EXPORT(char *) ap_get_time(void); -API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt); -API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t t); + API_EXPORT(struct tm *) ap_get_gmtoff(int *tz); + API_EXPORT(char *) ap_get_time(void); + API_EXPORT(char *) ap_ht_time(pool * p, time_t t, const char *fmt, + int gmt); + API_EXPORT(char *) ap_gm_timestr_822(pool * p, time_t t); /* String handling. The *_nc variants allow you to use non-const char **s as arguments (unfortunately C won't automatically convert a char ** to a const char **) */ -API_EXPORT(char *) ap_getword(pool *p, const char **line, char stop); -API_EXPORT(char *) ap_getword_nc(pool *p, char **line, char stop); -API_EXPORT(char *) ap_getword_white(pool *p, const char **line); -API_EXPORT(char *) ap_getword_white_nc(pool *p, char **line); -API_EXPORT(char *) ap_getword_nulls(pool *p, const char **line, char stop); -API_EXPORT(char *) ap_getword_nulls_nc(pool *p, char **line, char stop); -API_EXPORT(char *) ap_getword_conf(pool *p, const char **line); -API_EXPORT(char *) ap_getword_conf_nc(pool *p, char **line); - -API_EXPORT(char *) ap_get_token(pool *p, const char **accept_line, int accept_white); -API_EXPORT(int) ap_find_token(pool *p, const char *line, const char *tok); -API_EXPORT(int) ap_find_last_token(pool *p, const char *line, const char *tok); - -API_EXPORT(int) ap_is_url(const char *u); -API_EXPORT(int) ap_unescape_url(char *url); -API_EXPORT(void) ap_no2slash(char *name); -API_EXPORT(void) ap_getparents(char *name); -API_EXPORT(char *) ap_escape_path_segment(pool *p, const char *s); -API_EXPORT(char *) ap_os_escape_path(pool *p, const char *path, int partial); + API_EXPORT(char *) ap_getword(pool * p, const char **line, char stop); + API_EXPORT(char *) ap_getword_nc(pool * p, char **line, char stop); + API_EXPORT(char *) ap_getword_white(pool * p, const char **line); + API_EXPORT(char *) ap_getword_white_nc(pool * p, char **line); + API_EXPORT(char *) ap_getword_nulls(pool * p, const char **line, + char stop); + API_EXPORT(char *) ap_getword_nulls_nc(pool * p, char **line, + char stop); + API_EXPORT(char *) ap_getword_conf(pool * p, const char **line); + API_EXPORT(char *) ap_getword_conf_nc(pool * p, char **line); + + API_EXPORT(char *) ap_get_token(pool * p, const char **accept_line, + int accept_white); + API_EXPORT(int) ap_find_token(pool * p, const char *line, + const char *tok); + API_EXPORT(int) ap_find_last_token(pool * p, const char *line, + const char *tok); + + API_EXPORT(int) ap_is_url(const char *u); + API_EXPORT(int) ap_unescape_url(char *url); + API_EXPORT(void) ap_no2slash(char *name); + API_EXPORT(void) ap_getparents(char *name); + API_EXPORT(char *) ap_escape_path_segment(pool * p, const char *s); + API_EXPORT(char *) ap_os_escape_path(pool * p, const char *path, + int partial); #define escape_uri(ppool,path) ap_os_escape_path(ppool,path,1) -API_EXPORT(char *) ap_escape_html(pool *p, const char *s); -API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname, - unsigned port, const request_rec *r); -API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s); - -API_EXPORT(int) ap_count_dirs(const char *path); -API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n); -API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s); + API_EXPORT(char *) ap_escape_html(pool * p, const char *s); + API_EXPORT(char *) ap_construct_server(pool * p, const char *hostname, + unsigned port, + const request_rec * r); + API_EXPORT(char *) ap_escape_shell_cmd(pool * p, const char *s); + + API_EXPORT(int) ap_count_dirs(const char *path); + API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n); + API_EXPORT(char *) ap_make_dirstr_parent(pool * p, const char *s); /* deprecated. The previous two routines are preferred. */ -API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n); -API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f); - -API_EXPORT(int) ap_is_matchexp(const char *str); -API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp); -API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp); -API_EXPORT(char *) ap_uudecode(pool *, const char *); + API_EXPORT(char *) ap_make_dirstr(pool * a, const char *s, int n); + API_EXPORT(char *) ap_make_full_path(pool * a, const char *dir, + const char *f); + + API_EXPORT(int) ap_is_matchexp(const char *str); + API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp); + API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp); + API_EXPORT(char *) ap_uudecode(pool *, const char *); #ifdef __EMX__ -void os2pathname(char *path); + void os2pathname(char *path); #endif -API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source, - size_t nmatch, regmatch_t pmatch[]); + API_EXPORT(char *) ap_pregsub(pool * p, const char *input, + const char *source, size_t nmatch, + regmatch_t pmatch[]); -API_EXPORT(void) ap_content_type_tolower(char *); -API_EXPORT(void) ap_str_tolower(char *); -API_EXPORT(int) ap_ind(const char *, char); /* Sigh... */ -API_EXPORT(int) ap_rind(const char *, char); + API_EXPORT(void) ap_content_type_tolower(char *); + API_EXPORT(void) ap_str_tolower(char *); + API_EXPORT(int) ap_ind(const char *, char); /* Sigh... */ + API_EXPORT(int) ap_rind(const char *, char); -API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring); + API_EXPORT(char *) ap_escape_quotes(pool * p, const char *instring); /* Common structure for reading of config files / passwd files etc. */ -typedef struct { - int (*getch) (void *param); /* a getc()-like function */ - void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */ - int (*close) (void *param); /* a close hander function */ - void *param; /* the argument passed to getch/getstr/close */ - const char *name; /* the filename / description */ - unsigned line_number; /* current line number, starting at 1 */ -} configfile_t; + typedef struct { + int (*getch) (void *param); /* a getc()-like function */ + void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */ + int (*close) (void *param); /* a close hander function */ + void *param; /* the argument passed to getch/getstr/close */ + const char *name; /* the filename / description */ + unsigned line_number; /* current line number, starting at 1 */ + } configfile_t; /* Open a configfile_t as FILE, return open configfile_t struct pointer */ -API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name); + API_EXPORT(configfile_t *) ap_pcfg_openfile(pool * p, const char *name); /* Allocate a configfile_t handle with user defined functions and params */ -API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr, - void *param, - int(*getc_func)(void*), - void *(*gets_func) (void *buf, size_t bufsiz, void *param), - int(*close_func)(void *param)); + API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool * p, + const char *descr, + void *param, + int (*getc_func) (void + *), + void *(*gets_func) (void + *buf, + size_t + bufsiz, + void + *param), + int (*close_func) (void + *param)); /* Read one line from open configfile_t, strip LF, increase line number */ -API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp); + API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, + configfile_t * cfp); /* Read one char from open configfile_t, increase line number upon LF */ -API_EXPORT(int) ap_cfg_getc(configfile_t *cfp); + API_EXPORT(int) ap_cfg_getc(configfile_t * cfp); /* Detach from open configfile_t, calling the close handler */ -API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp); + API_EXPORT(int) ap_cfg_closefile(configfile_t * cfp); #ifdef NEED_STRERROR -char *strerror(int err); + char *strerror(int err); #endif /* Misc system hackery */ -API_EXPORT(uid_t) ap_uname2id(const char *name); -API_EXPORT(gid_t) ap_gname2id(const char *name); -API_EXPORT(int) ap_is_directory(const char *name); -API_EXPORT(int) ap_can_exec(const struct stat *); -API_EXPORT(void) ap_chdir_file(const char *file); + API_EXPORT(uid_t) ap_uname2id(const char *name); + API_EXPORT(gid_t) ap_gname2id(const char *name); + API_EXPORT(int) ap_is_directory(const char *name); + API_EXPORT(int) ap_can_exec(const struct stat *); + API_EXPORT(void) ap_chdir_file(const char *file); #ifndef HAVE_CANONICAL_FILENAME #define ap_os_canonical_filename(p,f) (f) #else -API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file); + API_EXPORT(char *) ap_os_canonical_filename(pool * p, const char *file); #endif #ifdef _OSD_POSIX -extern const char *os_set_authfile(pool *p, const char *filename); -extern int os_init_job_environment(server_rec *s, const char *user_name); -#endif /* _OSD_POSIX */ + extern const char *os_set_authfile(pool * p, const char *filename); + extern int os_init_job_environment(server_rec * s, const char *user_name); +#endif /* _OSD_POSIX */ -char *ap_get_local_host(pool *); -unsigned long ap_get_virthost_addr(const char *hostname, unsigned short *port); + char *ap_get_local_host(pool *); + unsigned long ap_get_virthost_addr(const char *hostname, + unsigned short *port); -extern API_VAR_EXPORT time_t ap_restart_time; + extern API_VAR_EXPORT time_t ap_restart_time; /* * Apache tries to keep all of its long term filehandles (such as log files, @@ -987,18 +1007,19 @@ extern API_VAR_EXPORT time_t ap_restart_time; #ifdef NO_SLACK #define ap_slack(fd,line) (fd) #else -int ap_slack(int fd, int line); + int ap_slack(int fd, int line); #define AP_SLACK_LOW 1 #define AP_SLACK_HIGH 2 #endif -API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr); + API_EXPORT(char *) ap_escape_quotes(pool * p, const char *instr); /* * Redefine assert() to something more useful for an Apache... */ -API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) - __attribute__((noreturn)); + API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, + int nLine) + __attribute__ ((noreturn)); #define ap_assert(exp) (void)( (exp) || (ap_log_assert(#exp, __FILE__, __LINE__), 0) ) /* The optimized timeout code only works if we're not MULTITHREAD and we're @@ -1021,7 +1042,7 @@ API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) #define SIGSTOP_CGI_CHILD 16 #ifdef DEBUG_SIGSTOP -extern int raise_sigstop_flags; + extern int raise_sigstop_flags; #define RAISE_SIGSTOP(x) do { \ if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\ } while (0) @@ -1029,7 +1050,8 @@ extern int raise_sigstop_flags; #define RAISE_SIGSTOP(x) #endif -API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r); + API_EXPORT(extern const char *) ap_psignature(const char *prefix, + request_rec * r); /* strtoul does not exist on sunos4. */ #ifdef strtoul @@ -1040,5 +1062,4 @@ API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r #ifdef __cplusplus } #endif - -#endif /* !APACHE_HTTPD_H */ +#endif /* !APACHE_HTTPD_H */ diff --git a/src/afsweb/apache_includes/1.3.1/os.h b/src/afsweb/apache_includes/1.3.1/os.h index a9f8df961..224620018 100644 --- a/src/afsweb/apache_includes/1.3.1/os.h +++ b/src/afsweb/apache_includes/1.3.1/os.h @@ -119,9 +119,9 @@ const char *dlerror(void); #endif #define ap_os_dso_handle_t void * -void * ap_os_dso_load(const char *); -void ap_os_dso_unload(void *); -void * ap_os_dso_sym(void *, const char *); +void *ap_os_dso_load(const char *); +void ap_os_dso_unload(void *); +void *ap_os_dso_sym(void *, const char *); const char *ap_os_dso_error(void); -#endif /* !APACHE_OS_H */ +#endif /* !APACHE_OS_H */ diff --git a/src/afsweb/apache_includes/1.3.1/util_uri.h b/src/afsweb/apache_includes/1.3.1/util_uri.h index 6309a4792..118f98a16 100644 --- a/src/afsweb/apache_includes/1.3.1/util_uri.h +++ b/src/afsweb/apache_includes/1.3.1/util_uri.h @@ -65,10 +65,10 @@ extern "C" { #endif -typedef struct { - const char *name; - unsigned short default_port; -} schemes_t; + typedef struct { + const char *name; + unsigned short default_port; + } schemes_t; #define DEFAULT_FTP_DATA_PORT 20 #define DEFAULT_FTP_PORT 21 @@ -87,42 +87,49 @@ typedef struct { #define UNP_OMITPATHINFO (1U<<4) /* Show "scheme://user@site:port" only */ #define UNP_OMITQUERY (1U<<5) /* Omit the "?queryarg" from the path */ -typedef struct { - char *scheme; /* scheme ("http"/"ftp"/...) */ - char *hostinfo; /* combined [user[:password]@]host[:port] */ - char *user; /* user name, as in http://user:passwd@host:port/ */ - char *password; /* password, as in http://user:passwd@host:port/ */ - char *hostname; /* hostname from URI (or from Host: header) */ - char *port_str; /* port string (integer representation is in "port") */ - char *path; /* the request path (or "/" if only scheme://host was given) */ - char *query; /* Everything after a '?' in the path, if present */ - char *fragment; /* Trailing "#fragment" string, if present */ + typedef struct { + char *scheme; /* scheme ("http"/"ftp"/...) */ + char *hostinfo; /* combined [user[:password]@]host[:port] */ + char *user; /* user name, as in http://user:passwd@host:port/ */ + char *password; /* password, as in http://user:passwd@host:port/ */ + char *hostname; /* hostname from URI (or from Host: header) */ + char *port_str; /* port string (integer representation is in "port") */ + char *path; /* the request path (or "/" if only scheme://host was given) */ + char *query; /* Everything after a '?' in the path, if present */ + char *fragment; /* Trailing "#fragment" string, if present */ - struct hostent *hostent; + struct hostent *hostent; - unsigned short port; /* The port number, numeric, valid only if port_str != NULL */ - - unsigned is_initialized:1; + unsigned short port; /* The port number, numeric, valid only if port_str != NULL */ - unsigned dns_looked_up:1; - unsigned dns_resolved:1; + unsigned is_initialized:1; -} uri_components; + unsigned dns_looked_up:1; + unsigned dns_resolved:1; + + } uri_components; /* util_uri.c */ -API_EXPORT(unsigned short) ap_default_port_for_scheme(const char *scheme_str); -API_EXPORT(unsigned short) ap_default_port_for_request(const request_rec *r); -API_EXPORT(struct hostent *) ap_pduphostent(pool *p, const struct hostent *hp); -API_EXPORT(struct hostent *) ap_pgethostbyname(pool *p, const char *hostname); -API_EXPORT(char *) ap_unparse_uri_components(pool *p, const uri_components *uptr, - unsigned flags); -API_EXPORT(int) ap_parse_uri_components(pool *p, const char *uri, uri_components *uptr); -API_EXPORT(int) ap_parse_hostinfo_components(pool *p, const char *hostinfo, uri_components *uptr); + API_EXPORT(unsigned short) ap_default_port_for_scheme(const char + *scheme_str); + API_EXPORT(unsigned short) ap_default_port_for_request(const request_rec + * r); + API_EXPORT(struct hostent *) ap_pduphostent(pool * p, + const struct hostent *hp); + API_EXPORT(struct hostent *) ap_pgethostbyname(pool * p, + const char *hostname); + API_EXPORT(char *) ap_unparse_uri_components(pool * p, + const uri_components * + uptr, unsigned flags); + API_EXPORT(int) ap_parse_uri_components(pool * p, const char *uri, + uri_components * uptr); + API_EXPORT(int) ap_parse_hostinfo_components(pool * p, + const char *hostinfo, + uri_components * uptr); /* called by the core in main() */ -extern void ap_util_uri_init(void); + extern void ap_util_uri_init(void); #ifdef __cplusplus } #endif - -#endif /*UTIL_URI_H*/ +#endif /*UTIL_URI_H */ diff --git a/src/afsweb/apache_includes/1.3.6/alloc.h b/src/afsweb/apache_includes/1.3.6/alloc.h index 1faab62d0..915cafdc9 100644 --- a/src/afsweb/apache_includes/1.3.6/alloc.h +++ b/src/afsweb/apache_includes/1.3.6/alloc.h @@ -83,17 +83,17 @@ extern "C" { * alloc.c. */ - /* Need declaration of DIR on Win32 */ + /* Need declaration of DIR on Win32 */ #ifdef WIN32 #include "os/win32/readdir.h" #endif -typedef struct pool pool; -typedef struct pool ap_pool; + typedef struct pool pool; + typedef struct pool ap_pool; -pool * ap_init_alloc(void); /* Set up everything */ -API_EXPORT(pool *) ap_make_sub_pool(pool *); /* All pools are subpools of permanent_pool */ -API_EXPORT(void) ap_destroy_pool(pool *); + pool *ap_init_alloc(void); /* Set up everything */ + API_EXPORT(pool *) ap_make_sub_pool(pool *); /* All pools are subpools of permanent_pool */ + API_EXPORT(void) ap_destroy_pool(pool *); /* used to guarantee to the pool debugging code that the sub pool will not be * destroyed before the parent pool @@ -104,50 +104,55 @@ API_EXPORT(void) ap_destroy_pool(pool *); #endif #define ap_pool_join(a,b) #else -API_EXPORT(void) ap_pool_join(pool *p, pool *sub); -API_EXPORT(pool *) ap_find_pool(const void *ts); -API_EXPORT(int) ap_pool_is_ancestor(pool *a, pool *b); + API_EXPORT(void) ap_pool_join(pool * p, pool * sub); + API_EXPORT(pool *) ap_find_pool(const void *ts); + API_EXPORT(int) ap_pool_is_ancestor(pool * a, pool * b); #endif /* Clearing out EVERYTHING in an pool... destroys any sub-pools */ -API_EXPORT(void) ap_clear_pool(struct pool *); + API_EXPORT(void) ap_clear_pool(struct pool *); /* Preparing for exec() --- close files, etc., but *don't* flush I/O * buffers, *don't* wait for subprocesses, and *don't* free any memory. */ -API_EXPORT(void) ap_cleanup_for_exec(void); + API_EXPORT(void) ap_cleanup_for_exec(void); /* routines to allocate memory from an pool... */ -API_EXPORT(void *) ap_palloc(struct pool *, int nbytes); -API_EXPORT(void *) ap_pcalloc(struct pool *, int nbytes); -API_EXPORT(char *) ap_pstrdup(struct pool *, const char *s); + API_EXPORT(void *) ap_palloc(struct pool *, int nbytes); + API_EXPORT(void *) ap_pcalloc(struct pool *, int nbytes); + API_EXPORT(char *) ap_pstrdup(struct pool *, const char *s); /* make a nul terminated copy of the n characters starting with s */ -API_EXPORT(char *) ap_pstrndup(struct pool *, const char *s, int n); -API_EXPORT_NONSTD(char *) ap_pstrcat(struct pool *,...); /* all '...' must be char* */ -API_EXPORT_NONSTD(char *) ap_psprintf(struct pool *, const char *fmt, ...) - __attribute__((format(printf,2,3))); -API_EXPORT(char *) ap_pvsprintf(struct pool *, const char *fmt, va_list); + API_EXPORT(char *) ap_pstrndup(struct pool *, const char *s, int n); + API_EXPORT_NONSTD(char *) ap_pstrcat(struct pool *, ...); /* all '...' must be char* */ + API_EXPORT_NONSTD(char *) ap_psprintf(struct pool *, const char *fmt, + ...) + __attribute__ ((format(printf, 2, 3))); + API_EXPORT(char *) ap_pvsprintf(struct pool *, const char *fmt, + va_list); /* array and alist management... keeping lists of things. * Common enough to want common support code ... */ -typedef struct { - ap_pool *pool; - int elt_size; - int nelts; - int nalloc; - char *elts; -} array_header; - -API_EXPORT(array_header *) ap_make_array(pool *p, int nelts, int elt_size); -API_EXPORT(void *) ap_push_array(array_header *); -API_EXPORT(void) ap_array_cat(array_header *dst, const array_header *src); -API_EXPORT(array_header *) ap_append_arrays(pool *, const array_header *, - const array_header *); + typedef struct { + ap_pool *pool; + int elt_size; + int nelts; + int nalloc; + char *elts; + } array_header; + + API_EXPORT(array_header *) ap_make_array(pool * p, int nelts, + int elt_size); + API_EXPORT(void *) ap_push_array(array_header *); + API_EXPORT(void) ap_array_cat(array_header * dst, + const array_header * src); + API_EXPORT(array_header *) ap_append_arrays(pool *, + const array_header *, + const array_header *); /* ap_array_pstrcat generates a new string from the pool containing * the concatenated sequence of substrings referenced as elements within @@ -155,16 +160,18 @@ API_EXPORT(array_header *) ap_append_arrays(pool *, const array_header *, * or if there are no elements in the array. * If sep is non-NUL, it will be inserted between elements as a separator. */ -API_EXPORT(char *) ap_array_pstrcat(pool *p, const array_header *arr, - const char sep); + API_EXPORT(char *) ap_array_pstrcat(pool * p, const array_header * arr, + const char sep); /* copy_array copies the *entire* array. copy_array_hdr just copies * the header, and arranges for the elements to be copied if (and only * if) the code subsequently does a push or arraycat. */ -API_EXPORT(array_header *) ap_copy_array(pool *p, const array_header *src); -API_EXPORT(array_header *) ap_copy_array_hdr(pool *p, const array_header *src); + API_EXPORT(array_header *) ap_copy_array(pool * p, + const array_header * src); + API_EXPORT(array_header *) ap_copy_array_hdr(pool * p, + const array_header * src); /* Tables. Implemented alist style, for now, though we try to keep @@ -176,30 +183,38 @@ API_EXPORT(array_header *) ap_copy_array_hdr(pool *p, const array_header *src); * currently being used... */ -typedef struct table table; - -typedef struct { - char *key; /* maybe NULL in future; - * check when iterating thru table_elts - */ - char *val; -} table_entry; - -API_EXPORT(table *) ap_make_table(pool *p, int nelts); -API_EXPORT(table *) ap_copy_table(pool *p, const table *); -API_EXPORT(void) ap_clear_table(table *); -API_EXPORT(const char *) ap_table_get(const table *, const char *); -API_EXPORT(void) ap_table_set(table *, const char *name, const char *val); -API_EXPORT(void) ap_table_setn(table *, const char *name, const char *val); -API_EXPORT(void) ap_table_merge(table *, const char *name, const char *more_val); -API_EXPORT(void) ap_table_mergen(table *, const char *name, const char *more_val); -API_EXPORT(void) ap_table_unset(table *, const char *key); -API_EXPORT(void) ap_table_add(table *, const char *name, const char *val); -API_EXPORT(void) ap_table_addn(table *, const char *name, const char *val); -API_EXPORT(void) ap_table_do(int (*comp) (void *, const char *, const char *), void *rec, - const table *t,...); - -API_EXPORT(table *) ap_overlay_tables(pool *p, const table *overlay, const table *base); + typedef struct table table; + + typedef struct { + char *key; /* maybe NULL in future; + * check when iterating thru table_elts + */ + char *val; + } table_entry; + + API_EXPORT(table *) ap_make_table(pool * p, int nelts); + API_EXPORT(table *) ap_copy_table(pool * p, const table *); + API_EXPORT(void) ap_clear_table(table *); + API_EXPORT(const char *) ap_table_get(const table *, const char *); + API_EXPORT(void) ap_table_set(table *, const char *name, + const char *val); + API_EXPORT(void) ap_table_setn(table *, const char *name, + const char *val); + API_EXPORT(void) ap_table_merge(table *, const char *name, + const char *more_val); + API_EXPORT(void) ap_table_mergen(table *, const char *name, + const char *more_val); + API_EXPORT(void) ap_table_unset(table *, const char *key); + API_EXPORT(void) ap_table_add(table *, const char *name, + const char *val); + API_EXPORT(void) ap_table_addn(table *, const char *name, + const char *val); + API_EXPORT(void) + ap_table_do(int (*comp) (void *, const char *, const char *), void *rec, + const table * t, ...); + + API_EXPORT(table *) ap_overlay_tables(pool * p, const table * overlay, + const table * base); /* Conceptually, ap_overlap_tables does this: @@ -225,7 +240,8 @@ API_EXPORT(table *) ap_overlay_tables(pool *p, const table *overlay, const table */ #define AP_OVERLAP_TABLES_SET (0) #define AP_OVERLAP_TABLES_MERGE (1) -API_EXPORT(void) ap_overlap_tables(table *a, const table *b, unsigned flags); + API_EXPORT(void) ap_overlap_tables(table * a, const table * b, + unsigned flags); /* XXX: these know about the definition of struct table in alloc.c. That * definition is not here because it is supposed to be private, and by not @@ -257,16 +273,18 @@ API_EXPORT(void) ap_overlap_tables(table *a, const table *b, unsigned flags); * unblock_alarms() below... */ -API_EXPORT(void) ap_register_cleanup(pool *p, void *data, - void (*plain_cleanup) (void *), - void (*child_cleanup) (void *)); + API_EXPORT(void) ap_register_cleanup(pool * p, void *data, + void (*plain_cleanup) (void *), + void (*child_cleanup) (void *)); -API_EXPORT(void) ap_kill_cleanup(pool *p, void *data, void (*plain_cleanup) (void *)); -API_EXPORT(void) ap_run_cleanup(pool *p, void *data, void (*cleanup) (void *)); + API_EXPORT(void) ap_kill_cleanup(pool * p, void *data, + void (*plain_cleanup) (void *)); + API_EXPORT(void) ap_run_cleanup(pool * p, void *data, + void (*cleanup) (void *)); /* A "do-nothing" cleanup, for register_cleanup; it's faster to do * things this way than to test for NULL. */ -API_EXPORT_NONSTD(void) ap_null_cleanup(void *data); + API_EXPORT_NONSTD(void) ap_null_cleanup(void *data); /* The time between when a resource is actually allocated, and when it * its cleanup is registered is a critical section, during which the @@ -282,46 +300,49 @@ API_EXPORT_NONSTD(void) ap_null_cleanup(void *data); #define ap_block_alarms() (0) #define ap_unblock_alarms() (0) #else -API_EXPORT(void) ap_block_alarms(void); -API_EXPORT(void) ap_unblock_alarms(void); -#endif /* TPF */ + API_EXPORT(void) ap_block_alarms(void); + API_EXPORT(void) ap_unblock_alarms(void); +#endif /* TPF */ /* Common cases which want utility support.. * the note_cleanups_for_foo routines are for */ -API_EXPORT(FILE *) ap_pfopen(struct pool *, const char *name, const char *fmode); -API_EXPORT(FILE *) ap_pfdopen(struct pool *, int fd, const char *fmode); -API_EXPORT(int) ap_popenf(struct pool *, const char *name, int flg, int mode); + API_EXPORT(FILE *) ap_pfopen(struct pool *, const char *name, + const char *fmode); + API_EXPORT(FILE *) ap_pfdopen(struct pool *, int fd, const char *fmode); + API_EXPORT(int) ap_popenf(struct pool *, const char *name, int flg, + int mode); -API_EXPORT(void) ap_note_cleanups_for_file(pool *, FILE *); -API_EXPORT(void) ap_note_cleanups_for_fd(pool *, int); + API_EXPORT(void) ap_note_cleanups_for_file(pool *, FILE *); + API_EXPORT(void) ap_note_cleanups_for_fd(pool *, int); #ifdef WIN32 -API_EXPORT(void) ap_note_cleanups_for_h(pool *, HANDLE); + API_EXPORT(void) ap_note_cleanups_for_h(pool *, HANDLE); #endif -API_EXPORT(void) ap_kill_cleanups_for_fd(pool *p, int fd); + API_EXPORT(void) ap_kill_cleanups_for_fd(pool * p, int fd); -API_EXPORT(void) ap_note_cleanups_for_socket(pool *, int); -API_EXPORT(void) ap_kill_cleanups_for_socket(pool *p, int sock); -API_EXPORT(int) ap_psocket(pool *p, int, int, int); -API_EXPORT(int) ap_pclosesocket(pool *a, int sock); + API_EXPORT(void) ap_note_cleanups_for_socket(pool *, int); + API_EXPORT(void) ap_kill_cleanups_for_socket(pool * p, int sock); + API_EXPORT(int) ap_psocket(pool * p, int, int, int); + API_EXPORT(int) ap_pclosesocket(pool * a, int sock); -API_EXPORT(regex_t *) ap_pregcomp(pool *p, const char *pattern, int cflags); -API_EXPORT(void) ap_pregfree(pool *p, regex_t * reg); + API_EXPORT(regex_t *) ap_pregcomp(pool * p, const char *pattern, + int cflags); + API_EXPORT(void) ap_pregfree(pool * p, regex_t * reg); /* routines to note closes... file descriptors are constrained enough * on some systems that we want to support this. */ -API_EXPORT(int) ap_pfclose(struct pool *, FILE *); -API_EXPORT(int) ap_pclosef(struct pool *, int fd); + API_EXPORT(int) ap_pfclose(struct pool *, FILE *); + API_EXPORT(int) ap_pclosef(struct pool *, int fd); #ifdef WIN32 -API_EXPORT(int) ap_pcloseh(struct pool *, HANDLE hDevice); + API_EXPORT(int) ap_pcloseh(struct pool *, HANDLE hDevice); #endif /* routines to deal with directories */ -API_EXPORT(DIR *) ap_popendir(pool *p, const char *name); -API_EXPORT(void) ap_pclosedir(pool *p, DIR * d); + API_EXPORT(DIR *) ap_popendir(pool * p, const char *name); + API_EXPORT(void) ap_pclosedir(pool * p, DIR * d); /* ... even child processes (which we may want to wait for, * or to kill outright, on unexpected termination). @@ -333,21 +354,21 @@ API_EXPORT(void) ap_pclosedir(pool *p, DIR * d); * to call in the child, and an argument to be passed to the function. */ -enum kill_conditions { - kill_never, /* process is never sent any signals */ - kill_always, /* process is sent SIGKILL on pool cleanup */ - kill_after_timeout, /* SIGTERM, wait 3 seconds, SIGKILL */ - just_wait, /* wait forever for the process to complete */ - kill_only_once /* send SIGTERM and then wait */ -}; - -typedef struct child_info child_info; -API_EXPORT(void) ap_note_subprocess(pool *a, pid_t pid, - enum kill_conditions how); -API_EXPORT(int) ap_spawn_child(pool *, int (*)(void *, child_info *), - void *, enum kill_conditions, - FILE **pipe_in, FILE **pipe_out, - FILE **pipe_err); + enum kill_conditions { + kill_never, /* process is never sent any signals */ + kill_always, /* process is sent SIGKILL on pool cleanup */ + kill_after_timeout, /* SIGTERM, wait 3 seconds, SIGKILL */ + just_wait, /* wait forever for the process to complete */ + kill_only_once /* send SIGTERM and then wait */ + }; + + typedef struct child_info child_info; + API_EXPORT(void) ap_note_subprocess(pool * a, pid_t pid, + enum kill_conditions how); + API_EXPORT(int) ap_spawn_child(pool *, int (*)(void *, child_info *), + void *, enum kill_conditions, + FILE ** pipe_in, FILE ** pipe_out, + FILE ** pipe_err); /* magic numbers --- min free bytes to consider a free pool block useable, * and the min amount to allocate if we have to go to malloc() */ @@ -361,11 +382,10 @@ API_EXPORT(int) ap_spawn_child(pool *, int (*)(void *, child_info *), /* Finally, some accounting */ -API_EXPORT(long) ap_bytes_in_pool(pool *p); -API_EXPORT(long) ap_bytes_in_free_blocks(void); + API_EXPORT(long) ap_bytes_in_pool(pool * p); + API_EXPORT(long) ap_bytes_in_free_blocks(void); #ifdef __cplusplus } #endif - -#endif /* !APACHE_ALLOC_H */ +#endif /* !APACHE_ALLOC_H */ diff --git a/src/afsweb/apache_includes/1.3.6/ap.h b/src/afsweb/apache_includes/1.3.6/ap.h index ed18dbd00..a93df892f 100644 --- a/src/afsweb/apache_includes/1.3.6/ap.h +++ b/src/afsweb/apache_includes/1.3.6/ap.h @@ -65,10 +65,10 @@ extern "C" { #endif -API_EXPORT(char *) ap_cpystrn(char *, const char *, size_t); -int ap_slack(int, int); -int ap_execle(const char *, const char *, ...); -int ap_execve(const char *, const char *argv[], const char *envp[]); + API_EXPORT(char *) ap_cpystrn(char *, const char *, size_t); + int ap_slack(int, int); + int ap_execle(const char *, const char *, ...); + int ap_execve(const char *, const char *argv[], const char *envp[]); /* small utility macros to make things easier to read */ @@ -80,7 +80,7 @@ int ap_execve(const char *, const char *argv[], const char *envp[]); #else #define ap_killpg(x, y) (killpg ((x), (y))) #endif -#endif /* WIN32 */ +#endif /* WIN32 */ /* ap_vformatter() is a generic printf-style formatting routine * with some extensions. The extensions are: @@ -131,13 +131,14 @@ int ap_execve(const char *, const char *argv[], const char *envp[]); * or until ap_vformatter returns. */ -typedef struct { - char *curpos; - char *endpos; -} ap_vformatter_buff; + typedef struct { + char *curpos; + char *endpos; + } ap_vformatter_buff; -API_EXPORT(int) ap_vformatter(int (*flush_func)(ap_vformatter_buff *), - ap_vformatter_buff *, const char *fmt, va_list ap); + API_EXPORT(int) ap_vformatter(int (*flush_func) (ap_vformatter_buff *), + ap_vformatter_buff *, const char *fmt, + va_list ap); /* These are snprintf implementations based on ap_vformatter(). * @@ -154,13 +155,13 @@ API_EXPORT(int) ap_vformatter(int (*flush_func)(ap_vformatter_buff *), * to distinguish between an output which was truncated, and an output which * exactly filled the buffer. */ -API_EXPORT(int) ap_snprintf(char *buf, size_t len, const char *format,...) - __attribute__((format(printf,3,4))); -API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format, - va_list ap); + API_EXPORT(int) ap_snprintf(char *buf, size_t len, const char *format, + ...) + __attribute__ ((format(printf, 3, 4))); + API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format, + va_list ap); #ifdef __cplusplus } #endif - -#endif /* !APACHE_AP_H */ +#endif /* !APACHE_AP_H */ diff --git a/src/afsweb/apache_includes/1.3.6/ap_compat.h b/src/afsweb/apache_includes/1.3.6/ap_compat.h index 4d706e8d8..3e80bafab 100644 --- a/src/afsweb/apache_includes/1.3.6/ap_compat.h +++ b/src/afsweb/apache_includes/1.3.6/ap_compat.h @@ -420,5 +420,4 @@ extern "C" { #ifdef __cplusplus } #endif - -#endif /* !AP_COMPAT_H */ +#endif /* !AP_COMPAT_H */ diff --git a/src/afsweb/apache_includes/1.3.6/ap_config.h b/src/afsweb/apache_includes/1.3.6/ap_config.h index a63043450..e921d448c 100644 --- a/src/afsweb/apache_includes/1.3.6/ap_config.h +++ b/src/afsweb/apache_includes/1.3.6/ap_config.h @@ -121,15 +121,15 @@ stat() properly */ /* Define one of these according to your system. */ #if defined(MINT) -typedef int rlim_t; + typedef int rlim_t; #define JMP_BUF sigjmp_buf #define NO_LONG_DOUBLE #define USE_FLOCK_SERIALIZED_ACCEPT #define _BSD_SOURCE #define EAGAIN EWOULDBLOCK -int initgroups (char *, int); -char *crypt (const char *pw, const char *salt); -int gethostname (char *name, int namelen); + int initgroups(char *, int); + char *crypt(const char *pw, const char *salt); + int gethostname(char *name, int namelen); #elif defined(MPE) #include @@ -138,15 +138,15 @@ int gethostname (char *name, int namelen); #define NO_WRITEV #define HAVE_SHMGET 1 #define USE_SHMGET_SCOREBOARD -#define SHM_R 0400 /* Read permission */ -#define SHM_W 0200 /* Write permission */ +#define SHM_R 0400 /* Read permission */ +#define SHM_W 0200 /* Write permission */ #define NEED_INITGROUPS #define NEED_STRCASECMP #define NEED_STRDUP #define NEED_STRNCASECMP -extern void GETPRIVMODE(); -extern void GETUSERMODE(); -extern char *inet_ntoa(); + extern void GETPRIVMODE(); + extern void GETUSERMODE(); + extern char *inet_ntoa(); #define NO_SLACK #define NO_GETTIMEOFDAY #define S_IEXEC S_IXUSR @@ -158,14 +158,14 @@ extern char *inet_ntoa(); #define HAVE_GMTOFF 1 #undef NO_KILLPG #undef NO_SETSID -char *crypt(const char *pw, const char *salt); -char *mktemp(char *template); + char *crypt(const char *pw, const char *salt); + char *mktemp(char *template); #define HAVE_MMAP 1 #define USE_MMAP_SCOREBOARD #define USE_MMAP_FILES #include #define NEED_STRERROR -typedef int rlim_t; + typedef int rlim_t; #ifndef HAVE_MEMMOVE #define memmove(a,b,c) memcpy(a, b, c) #endif @@ -188,8 +188,8 @@ typedef int rlim_t; #define USE_MMAP_FILES /* Transarc hack to get AIX to build */ #if ! defined(AIX) && ! defined(linux) -int gethostname(char *name, int namelen); -#endif /* ! AIX && ! linux */ + int gethostname(char *name, int namelen); +#endif /* ! AIX && ! linux */ #define HAVE_SYSLOG 1 #define SYS_SIGLIST _sys_siglist @@ -237,7 +237,7 @@ int gethostname(char *name, int namelen); #define HAVE_SYSLOG 1 #ifndef HPUX10 #define SELECT_NEEDS_CAST -typedef int rlim_t; + typedef int rlim_t; #endif #elif defined(HPUX11) @@ -274,7 +274,7 @@ typedef int rlim_t; #define DEFAULT_USER "nobody" #endif #ifdef NEED_RLIM_T -typedef int rlim_t; + typedef int rlim_t; #endif #define USE_FCNTL_SERIALIZED_ACCEPT #ifdef USEBCOPY @@ -319,7 +319,7 @@ typedef int rlim_t; #define USE_MMAP_FILES #define NO_LONG_DOUBLE #define HAVE_SYSLOG 1 -typedef int rlim_t; + typedef int rlim_t; #elif defined(SEQUENT) #define HAVE_GMTOFF 1 @@ -329,7 +329,7 @@ typedef int rlim_t; #define HAVE_SYSLOG 1 #elif defined(NEXT) -typedef unsigned short mode_t; + typedef unsigned short mode_t; #define HAVE_GMTOFF 1 #undef NO_KILLPG #define NO_SETSID @@ -372,9 +372,9 @@ typedef unsigned short mode_t; #ifndef S_IWOTH #define S_IWOTH 000002 #ifndef rlim_t -typedef int rlim_t; + typedef int rlim_t; #endif -typedef u_long n_long; + typedef u_long n_long; #endif #define STDIN_FILENO 0 @@ -387,12 +387,12 @@ typedef u_long n_long; #define WEXITSTATUS(status) (int)( WIFEXITED(status) ? ( (status).w_retcode ) : -1) #define WTERMSIG(status) (int)( (status).w_termsig ) -typedef int pid_t; + typedef int pid_t; #define USE_LONGJMP #define NO_USE_SIGACTION #define HAVE_SYSLOG 1 -#elif defined(RHAPSODY) /* Mac OS X Server */ +#elif defined(RHAPSODY) /* Mac OS X Server */ #define HAVE_GMTOFF #define HAVE_MMAP #define USE_MMAP_FILES @@ -487,7 +487,7 @@ typedef int pid_t; /* glibc 2.1 and later finally define rlim_t */ #if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) -typedef int rlim_t; + typedef int rlim_t; #endif #elif defined(SCO) @@ -511,23 +511,23 @@ typedef int rlim_t; /* Although SCO 5 defines these in (note the "s") they don't have consts. Sigh. */ -extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, unsigned); + extern int strcasecmp(const char *, const char *); + extern int strncasecmp(const char *, const char *, unsigned); #elif defined(AUX3) /* These are to let -Wall compile more cleanly */ -extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *, const char *, unsigned); -extern int set42sig(), getopt(), getpeername(); -extern int listen(), bind(), socket(), getsockname(); -extern int accept(), gethostname(), connect(), lstat(); -extern int select(), killpg(), shutdown(); -extern int initgroups(), setsockopt(); -extern char *shmat(); -extern int shmctl(); -extern int shmget(); -extern char *sbrk(); -extern char *crypt(); + extern int strcasecmp(const char *, const char *); + extern int strncasecmp(const char *, const char *, unsigned); + extern int set42sig(), getopt(), getpeername(); + extern int listen(), bind(), socket(), getsockname(); + extern int accept(), gethostname(), connect(), lstat(); + extern int select(), killpg(), shutdown(); + extern int initgroups(), setsockopt(); + extern char *shmat(); + extern int shmctl(); + extern int shmget(); + extern char *sbrk(); + extern char *crypt(); #include #undef HAVE_GMTOFF #undef NO_KILLPG @@ -559,8 +559,8 @@ extern char *crypt(); #define NEED_STRCASECMP #ifndef ENCORE #define NEED_STRNCASECMP -#endif /* ENCORE */ -#endif /* MPRAS */ +#endif /* ENCORE */ +#endif /* MPRAS */ /* A lot of SVR4 systems need this */ #ifndef USE_SYSVSEM_SERIALIZED_ACCEPT #define USE_FCNTL_SERIALIZED_ACCEPT @@ -569,9 +569,9 @@ extern char *crypt(); #define NET_SIZE_T size_t #define HAVE_SHMGET 1 #define USE_SHMGET_SCOREBOARD -#ifdef _OSD_POSIX /* BS2000-POSIX mainframe needs initgroups */ +#ifdef _OSD_POSIX /* BS2000-POSIX mainframe needs initgroups */ #define NEED_INITGROUPS -#define NEED_HASHBANG_EMUL /* execve() doesn't start shell scripts by default */ +#define NEED_HASHBANG_EMUL /* execve() doesn't start shell scripts by default */ #undef HAVE_SHMGET #undef NEED_STRCASECMP #undef NEED_STRNCASECMP @@ -656,9 +656,9 @@ extern char *crypt(); #define WEXITSTATUS(status) (int)((status).w_retcode) #define WTERMSIG(status) (int)((status).w_termsig) #define strftime(buf,bufsize,fmt,tm) ascftime(buf,fmt,tm) -#undef HAVE_SYS_RESOURCE_H /* exists but does not provide *rlimit funcs */ +#undef HAVE_SYS_RESOURCE_H /* exists but does not provide *rlimit funcs */ #include -#include +#include #elif defined(APOLLO) #undef HAVE_GMTOFF @@ -684,7 +684,7 @@ extern char *crypt(); #endif #if defined(__bsdi__) || \ (defined(__FreeBSD_version) && (__FreeBSD_version < 220000)) -typedef quad_t rlim_t; + typedef quad_t rlim_t; #endif #define USE_FLOCK_SERIALIZED_ACCEPT #define SINGLE_LISTEN_UNSERIALIZED_ACCEPT @@ -693,10 +693,10 @@ typedef quad_t rlim_t; #elif defined(QNX) #ifndef crypt -char *crypt(const char *pw, const char *salt); + char *crypt(const char *pw, const char *salt); #endif #ifndef initgroups -int initgroups(char *, int); + int initgroups(char *, int); #endif #ifndef strncasecmp #define strncasecmp strnicmp @@ -724,8 +724,8 @@ int initgroups(char *, int); #undef NO_SETSID #undef NO_USE_SIGACTION #undef NO_LINGCLOSE -extern char *crypt(char *pw, char *salt); -typedef int rlim_t; + extern char *crypt(char *pw, char *salt); + typedef int rlim_t; #define HAVE_SYSLOG 1 #elif defined(UXPDS) @@ -759,7 +759,7 @@ typedef int rlim_t; #define SINGLE_LISTEN_UNSERIALIZED_ACCEPT #elif defined(__MACHTEN__) -typedef int rlim_t; + typedef int rlim_t; #undef NO_KILLPG #define NO_SETSID #define HAVE_GMTOFF 1 @@ -792,7 +792,7 @@ typedef int rlim_t; #define NO_TIMEZONE #include #include -typedef int rlim_t; + typedef int rlim_t; #elif defined(ISC) #include @@ -815,13 +815,13 @@ typedef int rlim_t; #include #include #include -typedef int pid_t; -typedef int rlim_t; -typedef int mode_t; + typedef int pid_t; + typedef int rlim_t; + typedef int mode_t; #elif defined(RISCIX) #include -typedef int rlim_t; + typedef int rlim_t; #define NO_USE_SIGACTION #define USE_LONGJMP #define NEED_STRCASECMP @@ -844,7 +844,7 @@ typedef int rlim_t; /* All windows stuff is now in os/win32/os.h */ -#elif defined(TPF) /* IBM Transaction Processing Facility operating system */ +#elif defined(TPF) /* IBM Transaction Processing Facility operating system */ #include #include @@ -965,10 +965,10 @@ typedef int rlim_t; #include #ifdef HAVE_SYS_SELECT_H #include -#endif /* HAVE_SYS_SELECT_H */ +#endif /* HAVE_SYS_SELECT_H */ #ifndef TPF #include -#endif /* TPF */ +#endif /* TPF */ #include #include #if !defined(MPE) && !defined(BEOS) && !defined(TPF) @@ -984,12 +984,12 @@ typedef int rlim_t; #define O_BINARY (0) #endif -#else /* WIN32 */ +#else /* WIN32 */ #include #include #include #include -#endif /* ndef WIN32 */ +#endif /* ndef WIN32 */ #include /* for ctime */ #ifdef WIN32 @@ -1016,8 +1016,8 @@ typedef int rlim_t; #ifdef HAVE_SYS_RESOURCE_H #include #ifdef SUNOS4 -int getrlimit(int, struct rlimit *); -int setrlimit(int, struct rlimit *); + int getrlimit(int, struct rlimit *); + int setrlimit(int, struct rlimit *); #endif #endif #ifdef USE_MMAP_SCOREBOARD @@ -1066,7 +1066,7 @@ int setrlimit(int, struct rlimit *); * Replace signal function with sigaction equivalent */ #ifndef NO_USE_SIGACTION -typedef void Sigfunc(int); + typedef void Sigfunc(int); #if defined(SIG_IGN) && !defined(SIG_ERR) #define SIG_ERR ((Sigfunc *)-1) @@ -1079,7 +1079,7 @@ typedef void Sigfunc(int); #undef signal #endif #define signal(s,f) ap_signal(s,f) -Sigfunc *signal(int signo, Sigfunc * func); + Sigfunc *signal(int signo, Sigfunc * func); #endif #include @@ -1125,9 +1125,9 @@ Sigfunc *signal(int signo, Sigfunc * func); * with a HASHBANG (#!) followed by interpreter name and args, define this. */ #ifdef NEED_HASHBANG_EMUL -extern int ap_execle(const char *filename, const char *arg,...); -extern int ap_execve(const char *filename, const char *argv[], - const char *envp[]); + extern int ap_execle(const char *filename, const char *arg, ...); + extern int ap_execve(const char *filename, const char *argv[], + const char *envp[]); /* ap_execle() is a wrapper function around ap_execve(). */ #define execle ap_execle #define execve(path,argv,envp) ap_execve(path,argv,envp) @@ -1146,18 +1146,18 @@ extern int ap_execve(const char *filename, const char *argv[], #define XtOffset(p_type,field) \ (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) -#else /* !CRAY2 */ +#else /* !CRAY2 */ #define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field)) -#endif /* !CRAY2 */ -#endif /* __STDC__ */ -#else /* ! (CRAY || __arm) */ +#endif /* !CRAY2 */ +#endif /* __STDC__ */ +#else /* ! (CRAY || __arm) */ #define XtOffset(p_type,field) \ ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) -#endif /* !CRAY */ +#endif /* !CRAY */ #ifdef offsetof #define XtOffsetOf(s_type,field) offsetof(s_type,field) @@ -1204,82 +1204,82 @@ extern int ap_execve(const char *filename, const char *argv[], * currently (13Nov97) used. */ -int getopt(int, char **, char *); - -int strcasecmp(const char *, const char *); -int strncasecmp(const char *, const char *, int); -int toupper(int); -int tolower(int); - -int printf(char *,...); -int fprintf(FILE *, char *,...); -int fputs(char *, FILE *); -int fread(char *, int, int, FILE *); -int fwrite(char *, int, int, FILE *); -int fgetc(FILE *); -char *fgets(char *s, int, FILE*); -int fflush(FILE *); -int fclose(FILE *); -int ungetc(int, FILE *); -int _filbuf(FILE *); /* !!! */ -int _flsbuf(unsigned char, FILE *); /* !!! */ -int sscanf(char *, char *,...); -void setbuf(FILE *, char *); -void perror(char *); - -time_t time(time_t *); -int strftime(char *, int, const char *, struct tm *); - -int initgroups(char *, int); -int wait3(int *, int, void *); /* Close enough for us... */ -int lstat(const char *, struct stat *); -int stat(const char *, struct stat *); -int flock(int, int); + int getopt(int, char **, char *); + + int strcasecmp(const char *, const char *); + int strncasecmp(const char *, const char *, int); + int toupper(int); + int tolower(int); + + int printf(char *, ...); + int fprintf(FILE *, char *, ...); + int fputs(char *, FILE *); + int fread(char *, int, int, FILE *); + int fwrite(char *, int, int, FILE *); + int fgetc(FILE *); + char *fgets(char *s, int, FILE *); + int fflush(FILE *); + int fclose(FILE *); + int ungetc(int, FILE *); + int _filbuf(FILE *); /* !!! */ + int _flsbuf(unsigned char, FILE *); /* !!! */ + int sscanf(char *, char *, ...); + void setbuf(FILE *, char *); + void perror(char *); + + time_t time(time_t *); + int strftime(char *, int, const char *, struct tm *); + + int initgroups(char *, int); + int wait3(int *, int, void *); /* Close enough for us... */ + int lstat(const char *, struct stat *); + int stat(const char *, struct stat *); + int flock(int, int); #ifndef NO_KILLPG -int killpg(int, int); + int killpg(int, int); #endif -int socket(int, int, int); -int setsockopt(int, int, int, const char *, int); -int listen(int, int); -int bind(int, struct sockaddr *, int); -int connect(int, struct sockaddr *, int); -int accept(int, struct sockaddr *, int *); -int shutdown(int, int); + int socket(int, int, int); + int setsockopt(int, int, int, const char *, int); + int listen(int, int); + int bind(int, struct sockaddr *, int); + int connect(int, struct sockaddr *, int); + int accept(int, struct sockaddr *, int *); + int shutdown(int, int); -int getsockname(int s, struct sockaddr *name, int *namelen); -int getpeername(int s, struct sockaddr *name, int *namelen); -int gethostname(char *name, int namelen); -void syslog(int, char *,...); -char *mktemp(char *); + int getsockname(int s, struct sockaddr *name, int *namelen); + int getpeername(int s, struct sockaddr *name, int *namelen); + int gethostname(char *name, int namelen); + void syslog(int, char *, ...); + char *mktemp(char *); -long vfprintf(FILE *, const char *, va_list); + long vfprintf(FILE *, const char *, va_list); -#endif /* SUNOS_LIB_PROTOTYPES */ +#endif /* SUNOS_LIB_PROTOTYPES */ /* The assumption is that when the functions are missing, * then there's no matching prototype available either. * Declare what is needed exactly as the replacement routines implement it. */ #ifdef NEED_STRDUP -extern char *strdup (const char *str); + extern char *strdup(const char *str); #endif #ifdef NEED_STRCASECMP -extern int strcasecmp (const char *a, const char *b); + extern int strcasecmp(const char *a, const char *b); #endif #ifdef NEED_STRNCASECMP -extern int strncasecmp (const char *a, const char *b, int n); + extern int strncasecmp(const char *a, const char *b, int n); #endif #ifdef NEED_INITGROUPS -extern int initgroups(const char *name, gid_t basegid); + extern int initgroups(const char *name, gid_t basegid); #endif #ifdef NEED_WAITPID -extern int waitpid(pid_t pid, int *statusp, int options); + extern int waitpid(pid_t pid, int *statusp, int options); #endif #ifdef NEED_STRERROR -extern char *strerror (int err); + extern char *strerror(int err); #endif #ifdef NEED_DIFFTIME -extern double difftime(time_t time1, time_t time0); + extern double difftime(time_t time1, time_t time0); #endif #ifndef ap_wait_t @@ -1289,5 +1289,4 @@ extern double difftime(time_t time1, time_t time0); #ifdef __cplusplus } #endif - -#endif /* !AP_CONFIG_H */ +#endif /* !AP_CONFIG_H */ diff --git a/src/afsweb/apache_includes/1.3.6/ap_ctype.h b/src/afsweb/apache_includes/1.3.6/ap_ctype.h index e0a6abcaa..f45bffec1 100644 --- a/src/afsweb/apache_includes/1.3.6/ap_ctype.h +++ b/src/afsweb/apache_includes/1.3.6/ap_ctype.h @@ -86,5 +86,4 @@ extern "C" { #ifdef __cplusplus } #endif - -#endif /* !AP_CTYPE_H */ +#endif /* !AP_CTYPE_H */ diff --git a/src/afsweb/apache_includes/1.3.6/ap_mmn.h b/src/afsweb/apache_includes/1.3.6/ap_mmn.h index f844ec2f7..628d13dfb 100644 --- a/src/afsweb/apache_includes/1.3.6/ap_mmn.h +++ b/src/afsweb/apache_includes/1.3.6/ap_mmn.h @@ -216,12 +216,12 @@ * 19990320 - METHODS and M_INVALID symbol values modified */ -#define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */ +#define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 19990320 #endif -#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ #define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR /* backward compat */ /* Useful for testing for features. */ diff --git a/src/afsweb/apache_includes/1.3.6/buff.h b/src/afsweb/apache_includes/1.3.6/buff.h index 27ccd1537..74ef89af0 100644 --- a/src/afsweb/apache_includes/1.3.6/buff.h +++ b/src/afsweb/apache_includes/1.3.6/buff.h @@ -81,7 +81,7 @@ extern "C" { #define B_RDERR (16) /* A write error has occurred */ #define B_WRERR (32) -#ifdef B_ERROR /* in SVR4: sometimes defined in /usr/include/sys/buf.h */ +#ifdef B_ERROR /* in SVR4: sometimes defined in /usr/include/sys/buf.h */ #undef B_ERROR #endif #define B_ERROR (48) @@ -92,89 +92,90 @@ extern "C" { /* buffer is a socket */ #define B_SOCKET (256) #ifdef CHARSET_EBCDIC -#define B_ASCII2EBCDIC 0x40000000 /* Enable conversion for this buffer */ -#define B_EBCDIC2ASCII 0x80000000 /* Enable conversion for this buffer */ -#endif /*CHARSET_EBCDIC*/ +#define B_ASCII2EBCDIC 0x40000000 /* Enable conversion for this buffer */ +#define B_EBCDIC2ASCII 0x80000000 /* Enable conversion for this buffer */ +#endif /*CHARSET_EBCDIC */ -typedef struct buff_struct BUFF; + typedef struct buff_struct BUFF; -struct buff_struct { - int flags; /* flags */ - unsigned char *inptr; /* pointer to next location to read */ - int incnt; /* number of bytes left to read from input buffer; + struct buff_struct { + int flags; /* flags */ + unsigned char *inptr; /* pointer to next location to read */ + int incnt; /* number of bytes left to read from input buffer; * always 0 if had a read error */ - int outchunk; /* location of chunk header when chunking */ - int outcnt; /* number of byte put in output buffer */ - unsigned char *inbase; - unsigned char *outbase; - int bufsiz; - void (*error) (BUFF *fb, int op, void *data); - void *error_data; - long int bytes_sent; /* number of bytes actually written */ + int outchunk; /* location of chunk header when chunking */ + int outcnt; /* number of byte put in output buffer */ + unsigned char *inbase; + unsigned char *outbase; + int bufsiz; + void (*error) (BUFF * fb, int op, void *data); + void *error_data; + long int bytes_sent; /* number of bytes actually written */ - ap_pool *pool; + ap_pool *pool; /* could also put pointers to the basic I/O routines here */ - int fd; /* the file descriptor */ - int fd_in; /* input file descriptor, if different */ + int fd; /* the file descriptor */ + int fd_in; /* input file descriptor, if different */ #ifdef WIN32 - HANDLE hFH; /* Windows filehandle */ + HANDLE hFH; /* Windows filehandle */ #endif - /* transport handle, for RPC binding handle or some such */ - void *t_handle; + /* transport handle, for RPC binding handle or some such */ + void *t_handle; #ifdef B_SFIO - Sfio_t *sf_in; - Sfio_t *sf_out; + Sfio_t *sf_in; + Sfio_t *sf_out; #endif -}; + }; #ifdef B_SFIO -typedef struct { - Sfdisc_t disc; - BUFF *buff; -} apache_sfio; + typedef struct { + Sfdisc_t disc; + BUFF *buff; + } apache_sfio; -extern Sfdisc_t *bsfio_new(pool *p, BUFF *b); + extern Sfdisc_t *bsfio_new(pool * p, BUFF * b); #endif /* Options to bset/getopt */ #define BO_BYTECT (1) /* Stream creation and modification */ -API_EXPORT(BUFF *) ap_bcreate(pool *p, int flags); -API_EXPORT(void) ap_bpushfd(BUFF *fb, int fd_in, int fd_out); + API_EXPORT(BUFF *) ap_bcreate(pool * p, int flags); + API_EXPORT(void) ap_bpushfd(BUFF * fb, int fd_in, int fd_out); #ifdef WIN32 -API_EXPORT(void) ap_bpushh(BUFF *fb, HANDLE hFH); + API_EXPORT(void) ap_bpushh(BUFF * fb, HANDLE hFH); #endif -API_EXPORT(int) ap_bsetopt(BUFF *fb, int optname, const void *optval); -API_EXPORT(int) ap_bgetopt(BUFF *fb, int optname, void *optval); -API_EXPORT(int) ap_bsetflag(BUFF *fb, int flag, int value); -API_EXPORT(int) ap_bclose(BUFF *fb); + API_EXPORT(int) ap_bsetopt(BUFF * fb, int optname, const void *optval); + API_EXPORT(int) ap_bgetopt(BUFF * fb, int optname, void *optval); + API_EXPORT(int) ap_bsetflag(BUFF * fb, int flag, int value); + API_EXPORT(int) ap_bclose(BUFF * fb); #define ap_bgetflag(fb, flag) ((fb)->flags & (flag)) /* Error handling */ -API_EXPORT(void) ap_bonerror(BUFF *fb, void (*error) (BUFF *, int, void *), - void *data); + API_EXPORT(void) ap_bonerror(BUFF * fb, + void (*error) (BUFF *, int, void *), + void *data); /* I/O */ -API_EXPORT(int) ap_bread(BUFF *fb, void *buf, int nbyte); -API_EXPORT(int) ap_bgets(char *s, int n, BUFF *fb); -API_EXPORT(int) ap_blookc(char *buff, BUFF *fb); -API_EXPORT(int) ap_bskiplf(BUFF *fb); -API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte); -API_EXPORT(int) ap_bflush(BUFF *fb); -API_EXPORT(int) ap_bputs(const char *x, BUFF *fb); -API_EXPORT(int) ap_bvputs(BUFF *fb,...); -API_EXPORT_NONSTD(int) ap_bprintf(BUFF *fb, const char *fmt,...) - __attribute__((format(printf,2,3))); -API_EXPORT(int) ap_vbprintf(BUFF *fb, const char *fmt, va_list vlist); + API_EXPORT(int) ap_bread(BUFF * fb, void *buf, int nbyte); + API_EXPORT(int) ap_bgets(char *s, int n, BUFF * fb); + API_EXPORT(int) ap_blookc(char *buff, BUFF * fb); + API_EXPORT(int) ap_bskiplf(BUFF * fb); + API_EXPORT(int) ap_bwrite(BUFF * fb, const void *buf, int nbyte); + API_EXPORT(int) ap_bflush(BUFF * fb); + API_EXPORT(int) ap_bputs(const char *x, BUFF * fb); + API_EXPORT(int) ap_bvputs(BUFF * fb, ...); + API_EXPORT_NONSTD(int) ap_bprintf(BUFF * fb, const char *fmt, ...) + __attribute__ ((format(printf, 2, 3))); + API_EXPORT(int) ap_vbprintf(BUFF * fb, const char *fmt, va_list vlist); /* Internal routines */ -API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb); -API_EXPORT(int) ap_bfilbuf(BUFF *fb); + API_EXPORT(int) ap_bflsbuf(int c, BUFF * fb); + API_EXPORT(int) ap_bfilbuf(BUFF * fb); #ifndef CHARSET_EBCDIC @@ -185,7 +186,7 @@ API_EXPORT(int) ap_bfilbuf(BUFF *fb); (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \ ((fb)->outbase[(fb)->outcnt++] = (c), 0)) -#else /*CHARSET_EBCDIC*/ +#else /*CHARSET_EBCDIC */ #define ap_bgetc(fb) ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \ ((fb)->incnt--, (fb->flags & B_ASCII2EBCDIC)\ @@ -196,41 +197,41 @@ API_EXPORT(int) ap_bfilbuf(BUFF *fb); ((fb)->outbase[(fb)->outcnt++] = (fb->flags & B_EBCDIC2ASCII)\ ?os_toascii[(unsigned char)c]:(c), 0)) -#endif /*CHARSET_EBCDIC*/ -struct child_info { +#endif /*CHARSET_EBCDIC */ + struct child_info { #ifdef WIN32 - /* - * These handles are used by ap_call_exec to call - * create process with pipe handles. - */ - HANDLE hPipeInputRead; - HANDLE hPipeOutputWrite; - HANDLE hPipeErrorWrite; + /* + * These handles are used by ap_call_exec to call + * create process with pipe handles. + */ + HANDLE hPipeInputRead; + HANDLE hPipeOutputWrite; + HANDLE hPipeErrorWrite; #else - /* - * We need to put a dummy member in here to avoid compilation - * errors under certain Unix compilers, like SGI's and HPUX's, - * which fail to compile a zero-sized struct. Of course - * it would be much nicer if there was actually a use for this - * structure under Unix. Aah the joys of x-platform code. - */ - int dummy; + /* + * We need to put a dummy member in here to avoid compilation + * errors under certain Unix compilers, like SGI's and HPUX's, + * which fail to compile a zero-sized struct. Of course + * it would be much nicer if there was actually a use for this + * structure under Unix. Aah the joys of x-platform code. + */ + int dummy; #endif -}; -API_EXPORT(int) ap_bspawn_child(pool *, int (*)(void *, child_info *), void *, - enum kill_conditions, BUFF **pipe_in, BUFF **pipe_out, - BUFF **pipe_err); + }; + API_EXPORT(int) ap_bspawn_child(pool *, int (*)(void *, child_info *), + void *, enum kill_conditions, + BUFF ** pipe_in, BUFF ** pipe_out, + BUFF ** pipe_err); /* enable non-blocking operations */ -API_EXPORT(int) ap_bnonblock(BUFF *fb, int direction); + API_EXPORT(int) ap_bnonblock(BUFF * fb, int direction); /* and get an fd to select() on */ -API_EXPORT(int) ap_bfileno(BUFF *fb, int direction); + API_EXPORT(int) ap_bfileno(BUFF * fb, int direction); /* bflush() if a read now would block, but don't actually read anything */ -API_EXPORT(void) ap_bhalfduplex(BUFF *fb); + API_EXPORT(void) ap_bhalfduplex(BUFF * fb); #ifdef __cplusplus } #endif - -#endif /* !APACHE_BUFF_H */ +#endif /* !APACHE_BUFF_H */ diff --git a/src/afsweb/apache_includes/1.3.6/http_conf_globals.h b/src/afsweb/apache_includes/1.3.6/http_conf_globals.h index c540c4e0a..ca1d965b6 100644 --- a/src/afsweb/apache_includes/1.3.6/http_conf_globals.h +++ b/src/afsweb/apache_includes/1.3.6/http_conf_globals.h @@ -66,33 +66,33 @@ extern "C" { * Process config --- what the process ITSELF is doing */ -extern int ap_standalone; -extern uid_t ap_user_id; -extern char *ap_user_name; -extern gid_t ap_group_id; + extern int ap_standalone; + extern uid_t ap_user_id; + extern char *ap_user_name; + extern gid_t ap_group_id; #ifdef MULTIPLE_GROUPS -extern gid_t group_id_list[NGROUPS_MAX]; + extern gid_t group_id_list[NGROUPS_MAX]; #endif -extern int ap_max_requests_per_child; -extern int ap_threads_per_child; -extern int ap_excess_requests_per_child; -extern struct in_addr ap_bind_address; -extern listen_rec *ap_listeners; -extern int ap_daemons_to_start; -extern int ap_daemons_min_free; -extern int ap_daemons_max_free; -extern int ap_daemons_limit; -extern MODULE_VAR_EXPORT int ap_suexec_enabled; -extern int ap_listenbacklog; -extern int ap_dump_settings; -extern API_VAR_EXPORT int ap_extended_status; + extern int ap_max_requests_per_child; + extern int ap_threads_per_child; + extern int ap_excess_requests_per_child; + extern struct in_addr ap_bind_address; + extern listen_rec *ap_listeners; + extern int ap_daemons_to_start; + extern int ap_daemons_min_free; + extern int ap_daemons_max_free; + extern int ap_daemons_limit; + extern MODULE_VAR_EXPORT int ap_suexec_enabled; + extern int ap_listenbacklog; + extern int ap_dump_settings; + extern API_VAR_EXPORT int ap_extended_status; -extern char *ap_pid_fname; -extern char *ap_scoreboard_fname; -extern char *ap_lock_fname; -extern MODULE_VAR_EXPORT char *ap_server_argv0; + extern char *ap_pid_fname; + extern char *ap_scoreboard_fname; + extern char *ap_lock_fname; + extern MODULE_VAR_EXPORT char *ap_server_argv0; -extern enum server_token_type ap_server_tokens; + extern enum server_token_type ap_server_tokens; /* Trying to allocate these in the config pool gets us into some *nasty* * chicken-and-egg problems in http_main.c --- where do you stick them @@ -100,21 +100,20 @@ extern enum server_token_type ap_server_tokens; * statically... */ -extern API_VAR_EXPORT char ap_server_root[MAX_STRING_LEN]; -extern char ap_server_confname[MAX_STRING_LEN]; + extern API_VAR_EXPORT char ap_server_root[MAX_STRING_LEN]; + extern char ap_server_confname[MAX_STRING_LEN]; /* for -C, -c and -D switches */ -extern array_header *ap_server_pre_read_config; -extern array_header *ap_server_post_read_config; -extern array_header *ap_server_config_defines; + extern array_header *ap_server_pre_read_config; + extern array_header *ap_server_post_read_config; + extern array_header *ap_server_config_defines; /* We want this to have the least chance of being corrupted if there * is some memory corruption, so we allocate it statically. */ -extern char ap_coredump_dir[MAX_STRING_LEN]; + extern char ap_coredump_dir[MAX_STRING_LEN]; #ifdef __cplusplus } #endif - -#endif /* !APACHE_HTTP_CONF_GLOBALS_H */ +#endif /* !APACHE_HTTP_CONF_GLOBALS_H */ diff --git a/src/afsweb/apache_includes/1.3.6/httpd.h b/src/afsweb/apache_includes/1.3.6/httpd.h index 60d3582dc..b92580537 100644 --- a/src/afsweb/apache_includes/1.3.6/httpd.h +++ b/src/afsweb/apache_includes/1.3.6/httpd.h @@ -88,7 +88,7 @@ extern "C" { #else #define HTTPD_ROOT "/usr/local/apache" #endif -#endif /* HTTPD_ROOT */ +#endif /* HTTPD_ROOT */ /* Default location of documents. Can be overridden by the DocumentRoot * directive. @@ -100,7 +100,7 @@ extern "C" { #else #define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs" #endif -#endif /* DOCUMENT_LOCATION */ +#endif /* DOCUMENT_LOCATION */ /* Max. number of dynamically loaded modules */ #ifndef DYNAMIC_MODULE_LIMIT @@ -156,7 +156,7 @@ extern "C" { #else #define DEFAULT_XFERLOG "logs/access_log" #endif -#endif /* DEFAULT_XFERLOG */ +#endif /* DEFAULT_XFERLOG */ #ifndef DEFAULT_ERRORLOG #if defined(OS2) || defined(WIN32) @@ -164,7 +164,7 @@ extern "C" { #else #define DEFAULT_ERRORLOG "logs/error_log" #endif -#endif /* DEFAULT_ERRORLOG */ +#endif /* DEFAULT_ERRORLOG */ #ifndef DEFAULT_PIDLOG #define DEFAULT_PIDLOG "logs/httpd.pid" @@ -200,7 +200,7 @@ extern "C" { #else #define DEFAULT_ACCESS_FNAME ".htaccess" #endif -#endif /* DEFAULT_ACCESS_FNAME */ +#endif /* DEFAULT_ACCESS_FNAME */ /* The name of the server config file */ #ifndef SERVER_CONFIG_FILE @@ -244,7 +244,7 @@ extern "C" { #else #define SHELL_PATH "/bin/sh" #endif -#endif /* SHELL_PATH */ +#endif /* SHELL_PATH */ /* The path to the suExec wrapper, can be overridden in Configuration */ #ifndef SUEXEC_BIN @@ -392,13 +392,13 @@ extern "C" { */ #ifndef DEFAULT_LIMIT_REQUEST_LINE #define DEFAULT_LIMIT_REQUEST_LINE 8190 -#endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */ +#endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */ #ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE #define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190 -#endif /* default limit on bytes in any one header field */ +#endif /* default limit on bytes in any one header field */ #ifndef DEFAULT_LIMIT_REQUEST_FIELDS #define DEFAULT_LIMIT_REQUEST_FIELDS 100 -#endif /* default limit on number of request header fields */ +#endif /* default limit on number of request header fields */ /* * The below defines the base string of the Server: header. Additional @@ -415,15 +415,15 @@ extern "C" { #define SERVER_BASEVERSION "Apache/1.3.6" /* SEE COMMENTS ABOVE */ #define SERVER_VERSION SERVER_BASEVERSION -enum server_token_type { - SrvTk_MIN, /* eg: Apache/1.3.0 */ - SrvTk_OS, /* eg: Apache/1.3.0 (UNIX) */ - SrvTk_FULL /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */ -}; + enum server_token_type { + SrvTk_MIN, /* eg: Apache/1.3.0 */ + SrvTk_OS, /* eg: Apache/1.3.0 (UNIX) */ + SrvTk_FULL /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */ + }; -API_EXPORT(const char *) ap_get_server_version(void); -API_EXPORT(void) ap_add_version_component(const char *component); -API_EXPORT(const char *) ap_get_server_built(void); + API_EXPORT(const char *) ap_get_server_version(void); + API_EXPORT(void) ap_add_version_component(const char *component); + API_EXPORT(const char *) ap_get_server_built(void); /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta * Always increases along the same track as the source branch. @@ -563,8 +563,8 @@ API_EXPORT(const char *) ap_get_server_built(void); #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html" #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3" #ifdef CHARSET_EBCDIC -#define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */ -#endif /*CHARSET_EBCDIC*/ +#define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */ +#endif /*CHARSET_EBCDIC */ #define MAP_FILE_MAGIC_TYPE "application/x-type-map" #define ASIS_MAGIC_TYPE "httpd/send-as-is" #define DIR_MAGIC_TYPE "httpd/unix-directory" @@ -574,7 +574,7 @@ API_EXPORT(const char *) ap_get_server_built(void); #ifndef CHARSET_EBCDIC #define LF 10 #define CR 13 -#else /* CHARSET_EBCDIC */ +#else /* CHARSET_EBCDIC */ #include "ebcdic.h" /* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in * the buff package (bread/bputs/bwrite), so everywhere else, we use @@ -585,7 +585,7 @@ API_EXPORT(const char *) ap_get_server_built(void); */ #define CR '\r' #define LF '\n' -#endif /* CHARSET_EBCDIC */ +#endif /* CHARSET_EBCDIC */ /* Possible values for request_rec.read_body (set by handling module): * REQUEST_NO_BODY Send 413 error if message has any body @@ -614,156 +614,156 @@ API_EXPORT(const char *) ap_get_server_built(void); /* This represents the result of calling htaccess; these are cached for * each request. */ -struct htaccess_result { - char *dir; /* the directory to which this applies */ - int override; /* the overrides allowed for the .htaccess file */ - void *htaccess; /* the configuration directives */ + struct htaccess_result { + char *dir; /* the directory to which this applies */ + int override; /* the overrides allowed for the .htaccess file */ + void *htaccess; /* the configuration directives */ /* the next one, or NULL if no more; N.B. never change this */ - const struct htaccess_result *next; -}; + const struct htaccess_result *next; + }; -typedef struct conn_rec conn_rec; -typedef struct server_rec server_rec; -typedef struct request_rec request_rec; -typedef struct listen_rec listen_rec; + typedef struct conn_rec conn_rec; + typedef struct server_rec server_rec; + typedef struct request_rec request_rec; + typedef struct listen_rec listen_rec; #include "util_uri.h" -struct request_rec { + struct request_rec { - ap_pool *pool; - conn_rec *connection; - server_rec *server; + ap_pool *pool; + conn_rec *connection; + server_rec *server; - request_rec *next; /* If we wind up getting redirected, + request_rec *next; /* If we wind up getting redirected, * pointer to the request we redirected to. */ - request_rec *prev; /* If this is an internal redirect, + request_rec *prev; /* If this is an internal redirect, * pointer to where we redirected *from*. */ - request_rec *main; /* If this is a sub_request (see request.h) + request_rec *main; /* If this is a sub_request (see request.h) * pointer back to the main request. */ - /* Info about the request itself... we begin with stuff that only - * protocol.c should ever touch... - */ + /* Info about the request itself... we begin with stuff that only + * protocol.c should ever touch... + */ - char *the_request; /* First line of request, so we can log it */ - int assbackwards; /* HTTP/0.9, "simple" request */ - int proxyreq; /* A proxy request (calculated during + char *the_request; /* First line of request, so we can log it */ + int assbackwards; /* HTTP/0.9, "simple" request */ + int proxyreq; /* A proxy request (calculated during * post_read_request or translate_name) */ - int header_only; /* HEAD request, as opposed to GET */ - char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ - int proto_num; /* Number version of protocol; 1.1 = 1001 */ - const char *hostname; /* Host, as set by full URI or Host: */ - - time_t request_time; /* When the request started */ - - const char *status_line; /* Status line, if set by script */ - int status; /* In any case */ - - /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, - * look, but don't touch. - */ - - const char *method; /* GET, HEAD, POST, etc. */ - int method_number; /* M_GET, M_POST, etc. */ - - /* - allowed is a bitvector of the allowed methods. - - A handler must ensure that the request method is one that - it is capable of handling. Generally modules should DECLINE - any request methods they do not handle. Prior to aborting the - handler like this the handler should set r->allowed to the list - of methods that it is willing to handle. This bitvector is used - to construct the "Allow:" header required for OPTIONS requests, - and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes. - - Since the default_handler deals with OPTIONS, all modules can - usually decline to deal with OPTIONS. TRACE is always allowed, - modules don't need to set it explicitly. - - Since the default_handler will always handle a GET, a - module which does *not* implement GET should probably return - METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET - handler can't be installed by mod_actions. - */ - int allowed; /* Allowed methods - for 405, OPTIONS, etc */ - - int sent_bodyct; /* byte count in stream is for body */ - long bytes_sent; /* body byte count, for easy access */ - time_t mtime; /* Time the resource was last modified */ - - /* HTTP/1.1 connection-level features */ - - int chunked; /* sending chunked transfer-coding */ - int byterange; /* number of byte ranges */ - char *boundary; /* multipart/byteranges boundary */ - const char *range; /* The Range: header */ - long clength; /* The "real" content length */ - - long remaining; /* bytes left to read */ - long read_length; /* bytes that have been read */ - int read_body; /* how the request body should be read */ - int read_chunked; /* reading chunked transfer-coding */ - unsigned expecting_100; /* is client waiting for a 100 response? */ - - /* MIME header environments, in and out. Also, an array containing - * environment variables to be passed to subprocesses, so people can - * write modules to add to that environment. - * - * The difference between headers_out and err_headers_out is that the - * latter are printed even on error, and persist across internal redirects - * (so the headers printed for ErrorDocument handlers will have them). - * - * The 'notes' table is for notes from one module to another, with no - * other set purpose in mind... - */ - - table *headers_in; - table *headers_out; - table *err_headers_out; - table *subprocess_env; - table *notes; - - /* content_type, handler, content_encoding, content_language, and all - * content_languages MUST be lowercased strings. They may be pointers - * to static strings; they should not be modified in place. - */ - const char *content_type; /* Break these out --- we dispatch on 'em */ - const char *handler; /* What we *really* dispatch on */ - - const char *content_encoding; - const char *content_language; /* for back-compat. only -- do not use */ - array_header *content_languages; /* array of (char*) */ - - char *vlist_validator; /* variant list validator (if negotiated) */ - - int no_cache; - int no_local_copy; - - /* What object is being requested (either directly, or via include - * or content-negotiation mapping). - */ - - char *unparsed_uri; /* the uri without any parsing performed */ - char *uri; /* the path portion of the URI */ - char *filename; - char *path_info; - char *args; /* QUERY_ARGS, if any */ - struct stat finfo; /* ST_MODE set to zero if no such file */ - uri_components parsed_uri; /* components of uri, dismantled */ - - /* Various other config info which may change with .htaccess files - * These are config vectors, with one void* pointer for each module - * (the thing pointed to being the module's business). - */ - - void *per_dir_config; /* Options set in config files, etc. */ - void *request_config; /* Notes on *this* request */ + int header_only; /* HEAD request, as opposed to GET */ + char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ + int proto_num; /* Number version of protocol; 1.1 = 1001 */ + const char *hostname; /* Host, as set by full URI or Host: */ + + time_t request_time; /* When the request started */ + + const char *status_line; /* Status line, if set by script */ + int status; /* In any case */ + + /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, + * look, but don't touch. + */ + + const char *method; /* GET, HEAD, POST, etc. */ + int method_number; /* M_GET, M_POST, etc. */ + + /* + * allowed is a bitvector of the allowed methods. + * + * A handler must ensure that the request method is one that + * it is capable of handling. Generally modules should DECLINE + * any request methods they do not handle. Prior to aborting the + * handler like this the handler should set r->allowed to the list + * of methods that it is willing to handle. This bitvector is used + * to construct the "Allow:" header required for OPTIONS requests, + * and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes. + * + * Since the default_handler deals with OPTIONS, all modules can + * usually decline to deal with OPTIONS. TRACE is always allowed, + * modules don't need to set it explicitly. + * + * Since the default_handler will always handle a GET, a + * module which does *not* implement GET should probably return + * METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET + * handler can't be installed by mod_actions. + */ + int allowed; /* Allowed methods - for 405, OPTIONS, etc */ + + int sent_bodyct; /* byte count in stream is for body */ + long bytes_sent; /* body byte count, for easy access */ + time_t mtime; /* Time the resource was last modified */ + + /* HTTP/1.1 connection-level features */ + + int chunked; /* sending chunked transfer-coding */ + int byterange; /* number of byte ranges */ + char *boundary; /* multipart/byteranges boundary */ + const char *range; /* The Range: header */ + long clength; /* The "real" content length */ + + long remaining; /* bytes left to read */ + long read_length; /* bytes that have been read */ + int read_body; /* how the request body should be read */ + int read_chunked; /* reading chunked transfer-coding */ + unsigned expecting_100; /* is client waiting for a 100 response? */ + + /* MIME header environments, in and out. Also, an array containing + * environment variables to be passed to subprocesses, so people can + * write modules to add to that environment. + * + * The difference between headers_out and err_headers_out is that the + * latter are printed even on error, and persist across internal redirects + * (so the headers printed for ErrorDocument handlers will have them). + * + * The 'notes' table is for notes from one module to another, with no + * other set purpose in mind... + */ + + table *headers_in; + table *headers_out; + table *err_headers_out; + table *subprocess_env; + table *notes; + + /* content_type, handler, content_encoding, content_language, and all + * content_languages MUST be lowercased strings. They may be pointers + * to static strings; they should not be modified in place. + */ + const char *content_type; /* Break these out --- we dispatch on 'em */ + const char *handler; /* What we *really* dispatch on */ + + const char *content_encoding; + const char *content_language; /* for back-compat. only -- do not use */ + array_header *content_languages; /* array of (char*) */ + + char *vlist_validator; /* variant list validator (if negotiated) */ + + int no_cache; + int no_local_copy; + + /* What object is being requested (either directly, or via include + * or content-negotiation mapping). + */ + + char *unparsed_uri; /* the uri without any parsing performed */ + char *uri; /* the path portion of the URI */ + char *filename; + char *path_info; + char *args; /* QUERY_ARGS, if any */ + struct stat finfo; /* ST_MODE set to zero if no such file */ + uri_components parsed_uri; /* components of uri, dismantled */ + + /* Various other config info which may change with .htaccess files + * These are config vectors, with one void* pointer for each module + * (the thing pointed to being the module's business). + */ + + void *per_dir_config; /* Options set in config files, etc. */ + void *request_config; /* Notes on *this* request */ /* * a linked list of the configuration directives in the .htaccess files @@ -771,58 +771,58 @@ struct request_rec { * N.B. always add to the head of the list, _never_ to the end. * that way, a sub request's list can (temporarily) point to a parent's list */ - const struct htaccess_result *htaccess; + const struct htaccess_result *htaccess; /* Things placed at the end of the record to avoid breaking binary * compatibility. It would be nice to remember to reorder the entire * record to improve 64bit alignment the next time we need to break * binary compatibility for some other reason. */ -}; + }; /* Things which are per connection */ -struct conn_rec { + struct conn_rec { - ap_pool *pool; - server_rec *server; - server_rec *base_server; /* Physical vhost this conn come in on */ - void *vhost_lookup_data; /* used by http_vhost.c */ + ap_pool *pool; + server_rec *server; + server_rec *base_server; /* Physical vhost this conn come in on */ + void *vhost_lookup_data; /* used by http_vhost.c */ - /* Information about the connection itself */ + /* Information about the connection itself */ - int child_num; /* The number of the child handling conn_rec */ - BUFF *client; /* Connection to the guy */ + int child_num; /* The number of the child handling conn_rec */ + BUFF *client; /* Connection to the guy */ - /* Who is the client? */ + /* Who is the client? */ - struct sockaddr_in local_addr; /* local address */ - struct sockaddr_in remote_addr; /* remote address */ - char *remote_ip; /* Client's IP address */ - char *remote_host; /* Client's DNS name, if known. + struct sockaddr_in local_addr; /* local address */ + struct sockaddr_in remote_addr; /* remote address */ + char *remote_ip; /* Client's IP address */ + char *remote_host; /* Client's DNS name, if known. * NULL if DNS hasn't been checked, * "" if it has and no address was found. * N.B. Only access this though * get_remote_host() */ - char *remote_logname; /* Only ever set if doing rfc1413 lookups. + char *remote_logname; /* Only ever set if doing rfc1413 lookups. * N.B. Only access this through * get_remote_logname() */ - char *user; /* If an authentication check was made, + char *user; /* If an authentication check was made, * this gets set to the user name. We assume * that there's only one user per connection(!) */ - char *ap_auth_type; /* Ditto. */ + char *ap_auth_type; /* Ditto. */ - unsigned aborted:1; /* Are we still talking? */ - signed int keepalive:2; /* Are we using HTTP Keep-Alive? + unsigned aborted:1; /* Are we still talking? */ + signed int keepalive:2; /* Are we using HTTP Keep-Alive? * -1 fatal error, 0 undecided, 1 yes */ - unsigned keptalive:1; /* Did we use HTTP Keep-Alive? */ - signed int double_reverse:2;/* have we done double-reverse DNS? - * -1 yes/failure, 0 not yet, 1 yes/success */ - int keepalives; /* How many times have we used it? */ -}; + unsigned keptalive:1; /* Did we use HTTP Keep-Alive? */ + signed int double_reverse:2; /* have we done double-reverse DNS? + * -1 yes/failure, 0 not yet, 1 yes/success */ + int keepalives; /* How many times have we used it? */ + }; /* Per-vhost config... */ @@ -831,193 +831,214 @@ struct conn_rec { */ #define DEFAULT_VHOST_ADDR 0xfffffffful -typedef struct server_addr_rec server_addr_rec; -struct server_addr_rec { - server_addr_rec *next; - struct in_addr host_addr; /* The bound address, for this server */ - unsigned short host_port; /* The bound port, for this server */ - char *virthost; /* The name given in */ -}; + typedef struct server_addr_rec server_addr_rec; + struct server_addr_rec { + server_addr_rec *next; + struct in_addr host_addr; /* The bound address, for this server */ + unsigned short host_port; /* The bound port, for this server */ + char *virthost; /* The name given in */ + }; -struct server_rec { + struct server_rec { - server_rec *next; + server_rec *next; - /* description of where the definition came from */ - const char *defn_name; - unsigned defn_line_number; + /* description of where the definition came from */ + const char *defn_name; + unsigned defn_line_number; - /* Full locations of server config info */ + /* Full locations of server config info */ - char *srm_confname; - char *access_confname; + char *srm_confname; + char *access_confname; - /* Contact information */ + /* Contact information */ - char *server_admin; - char *server_hostname; - unsigned short port; /* for redirects, etc. */ + char *server_admin; + char *server_hostname; + unsigned short port; /* for redirects, etc. */ - /* Log files --- note that transfer log is now in the modules... */ + /* Log files --- note that transfer log is now in the modules... */ - char *error_fname; - FILE *error_log; - int loglevel; + char *error_fname; + FILE *error_log; + int loglevel; - /* Module-specific configuration for server, and defaults... */ + /* Module-specific configuration for server, and defaults... */ - int is_virtual; /* true if this is the virtual server */ - void *module_config; /* Config vector containing pointers to + int is_virtual; /* true if this is the virtual server */ + void *module_config; /* Config vector containing pointers to * modules' per-server config structures. */ - void *lookup_defaults; /* MIME type info, etc., before we start + void *lookup_defaults; /* MIME type info, etc., before we start * checking per-directory info. */ - /* Transaction handling */ + /* Transaction handling */ - server_addr_rec *addrs; - int timeout; /* Timeout, in seconds, before we give up */ - int keep_alive_timeout; /* Seconds we'll wait for another request */ - int keep_alive_max; /* Maximum requests per connection */ - int keep_alive; /* Use persistent connections? */ - int send_buffer_size; /* size of TCP send buffer (in bytes) */ + server_addr_rec *addrs; + int timeout; /* Timeout, in seconds, before we give up */ + int keep_alive_timeout; /* Seconds we'll wait for another request */ + int keep_alive_max; /* Maximum requests per connection */ + int keep_alive; /* Use persistent connections? */ + int send_buffer_size; /* size of TCP send buffer (in bytes) */ - char *path; /* Pathname for ServerPath */ - int pathlen; /* Length of path */ + char *path; /* Pathname for ServerPath */ + int pathlen; /* Length of path */ - array_header *names; /* Normal names for ServerAlias servers */ - array_header *wild_names; /* Wildcarded names for ServerAlias servers */ + array_header *names; /* Normal names for ServerAlias servers */ + array_header *wild_names; /* Wildcarded names for ServerAlias servers */ - uid_t server_uid; /* effective user id when calling exec wrapper */ - gid_t server_gid; /* effective group id when calling exec wrapper */ + uid_t server_uid; /* effective user id when calling exec wrapper */ + gid_t server_gid; /* effective group id when calling exec wrapper */ - int limit_req_line; /* limit on size of the HTTP request line */ - int limit_req_fieldsize; /* limit on size of any request header field */ - int limit_req_fields; /* limit on number of request header fields */ -}; + int limit_req_line; /* limit on size of the HTTP request line */ + int limit_req_fieldsize; /* limit on size of any request header field */ + int limit_req_fields; /* limit on number of request header fields */ + }; /* These are more like real hosts than virtual hosts */ -struct listen_rec { - listen_rec *next; - struct sockaddr_in local_addr; /* local IP address and port */ - int fd; - int used; /* Only used during restart */ + struct listen_rec { + listen_rec *next; + struct sockaddr_in local_addr; /* local IP address and port */ + int fd; + int used; /* Only used during restart */ /* more stuff here, like which protocol is bound to the port */ -}; + }; /* Prototypes for utilities... util.c. */ -extern void ap_util_init(void); + extern void ap_util_init(void); /* Time */ -extern API_VAR_EXPORT const char ap_month_snames[12][4]; -extern API_VAR_EXPORT const char ap_day_snames[7][4]; + extern API_VAR_EXPORT const char ap_month_snames[12][4]; + extern API_VAR_EXPORT const char ap_day_snames[7][4]; -API_EXPORT(struct tm *) ap_get_gmtoff(int *tz); -API_EXPORT(char *) ap_get_time(void); -API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt); -API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t t); + API_EXPORT(struct tm *) ap_get_gmtoff(int *tz); + API_EXPORT(char *) ap_get_time(void); + API_EXPORT(char *) ap_ht_time(pool * p, time_t t, const char *fmt, + int gmt); + API_EXPORT(char *) ap_gm_timestr_822(pool * p, time_t t); /* String handling. The *_nc variants allow you to use non-const char **s as arguments (unfortunately C won't automatically convert a char ** to a const char **) */ -API_EXPORT(char *) ap_getword(pool *p, const char **line, char stop); -API_EXPORT(char *) ap_getword_nc(pool *p, char **line, char stop); -API_EXPORT(char *) ap_getword_white(pool *p, const char **line); -API_EXPORT(char *) ap_getword_white_nc(pool *p, char **line); -API_EXPORT(char *) ap_getword_nulls(pool *p, const char **line, char stop); -API_EXPORT(char *) ap_getword_nulls_nc(pool *p, char **line, char stop); -API_EXPORT(char *) ap_getword_conf(pool *p, const char **line); -API_EXPORT(char *) ap_getword_conf_nc(pool *p, char **line); - -API_EXPORT(const char *) ap_size_list_item(const char **field, int *len); -API_EXPORT(char *) ap_get_list_item(pool *p, const char **field); -API_EXPORT(int) ap_find_list_item(pool *p, const char *line, const char *tok); - -API_EXPORT(char *) ap_get_token(pool *p, const char **accept_line, int accept_white); -API_EXPORT(int) ap_find_token(pool *p, const char *line, const char *tok); -API_EXPORT(int) ap_find_last_token(pool *p, const char *line, const char *tok); - -API_EXPORT(int) ap_is_url(const char *u); -API_EXPORT(int) ap_unescape_url(char *url); -API_EXPORT(void) ap_no2slash(char *name); -API_EXPORT(void) ap_getparents(char *name); -API_EXPORT(char *) ap_escape_path_segment(pool *p, const char *s); -API_EXPORT(char *) ap_os_escape_path(pool *p, const char *path, int partial); + API_EXPORT(char *) ap_getword(pool * p, const char **line, char stop); + API_EXPORT(char *) ap_getword_nc(pool * p, char **line, char stop); + API_EXPORT(char *) ap_getword_white(pool * p, const char **line); + API_EXPORT(char *) ap_getword_white_nc(pool * p, char **line); + API_EXPORT(char *) ap_getword_nulls(pool * p, const char **line, + char stop); + API_EXPORT(char *) ap_getword_nulls_nc(pool * p, char **line, + char stop); + API_EXPORT(char *) ap_getword_conf(pool * p, const char **line); + API_EXPORT(char *) ap_getword_conf_nc(pool * p, char **line); + + API_EXPORT(const char *) ap_size_list_item(const char **field, + int *len); + API_EXPORT(char *) ap_get_list_item(pool * p, const char **field); + API_EXPORT(int) ap_find_list_item(pool * p, const char *line, + const char *tok); + + API_EXPORT(char *) ap_get_token(pool * p, const char **accept_line, + int accept_white); + API_EXPORT(int) ap_find_token(pool * p, const char *line, + const char *tok); + API_EXPORT(int) ap_find_last_token(pool * p, const char *line, + const char *tok); + + API_EXPORT(int) ap_is_url(const char *u); + API_EXPORT(int) ap_unescape_url(char *url); + API_EXPORT(void) ap_no2slash(char *name); + API_EXPORT(void) ap_getparents(char *name); + API_EXPORT(char *) ap_escape_path_segment(pool * p, const char *s); + API_EXPORT(char *) ap_os_escape_path(pool * p, const char *path, + int partial); #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1) -API_EXPORT(char *) ap_escape_html(pool *p, const char *s); -API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname, - unsigned port, const request_rec *r); -API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s); - -API_EXPORT(int) ap_count_dirs(const char *path); -API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n); -API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s); + API_EXPORT(char *) ap_escape_html(pool * p, const char *s); + API_EXPORT(char *) ap_construct_server(pool * p, const char *hostname, + unsigned port, + const request_rec * r); + API_EXPORT(char *) ap_escape_shell_cmd(pool * p, const char *s); + + API_EXPORT(int) ap_count_dirs(const char *path); + API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n); + API_EXPORT(char *) ap_make_dirstr_parent(pool * p, const char *s); /* deprecated. The previous two routines are preferred. */ -API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n); -API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f); - -API_EXPORT(int) ap_is_matchexp(const char *str); -API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp); -API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp); -API_EXPORT(char *) ap_uudecode(pool *, const char *); -API_EXPORT(char *) ap_uuencode(pool *p, char *string); + API_EXPORT(char *) ap_make_dirstr(pool * a, const char *s, int n); + API_EXPORT(char *) ap_make_full_path(pool * a, const char *dir, + const char *f); + + API_EXPORT(int) ap_is_matchexp(const char *str); + API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp); + API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp); + API_EXPORT(char *) ap_uudecode(pool *, const char *); + API_EXPORT(char *) ap_uuencode(pool * p, char *string); #ifdef OS2 -void os2pathname(char *path); + void os2pathname(char *path); #endif -API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source, - size_t nmatch, regmatch_t pmatch[]); + API_EXPORT(char *) ap_pregsub(pool * p, const char *input, + const char *source, size_t nmatch, + regmatch_t pmatch[]); -API_EXPORT(void) ap_content_type_tolower(char *); -API_EXPORT(void) ap_str_tolower(char *); -API_EXPORT(int) ap_ind(const char *, char); /* Sigh... */ -API_EXPORT(int) ap_rind(const char *, char); + API_EXPORT(void) ap_content_type_tolower(char *); + API_EXPORT(void) ap_str_tolower(char *); + API_EXPORT(int) ap_ind(const char *, char); /* Sigh... */ + API_EXPORT(int) ap_rind(const char *, char); -API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring); + API_EXPORT(char *) ap_escape_quotes(pool * p, const char *instring); /* Common structure for reading of config files / passwd files etc. */ -typedef struct { - int (*getch) (void *param); /* a getc()-like function */ - void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */ - int (*close) (void *param); /* a close hander function */ - void *param; /* the argument passed to getch/getstr/close */ - const char *name; /* the filename / description */ - unsigned line_number; /* current line number, starting at 1 */ -} configfile_t; + typedef struct { + int (*getch) (void *param); /* a getc()-like function */ + void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */ + int (*close) (void *param); /* a close hander function */ + void *param; /* the argument passed to getch/getstr/close */ + const char *name; /* the filename / description */ + unsigned line_number; /* current line number, starting at 1 */ + } configfile_t; /* Open a configfile_t as FILE, return open configfile_t struct pointer */ -API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name); + API_EXPORT(configfile_t *) ap_pcfg_openfile(pool * p, const char *name); /* Allocate a configfile_t handle with user defined functions and params */ -API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr, - void *param, - int(*getc_func)(void*), - void *(*gets_func) (void *buf, size_t bufsiz, void *param), - int(*close_func)(void *param)); + API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool * p, + const char *descr, + void *param, + int (*getc_func) (void + *), + void *(*gets_func) (void + *buf, + size_t + bufsiz, + void + *param), + int (*close_func) (void + *param)); /* Read one line from open configfile_t, strip LF, increase line number */ -API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp); + API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, + configfile_t * cfp); /* Read one char from open configfile_t, increase line number upon LF */ -API_EXPORT(int) ap_cfg_getc(configfile_t *cfp); + API_EXPORT(int) ap_cfg_getc(configfile_t * cfp); /* Detach from open configfile_t, calling the close handler */ -API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp); + API_EXPORT(int) ap_cfg_closefile(configfile_t * cfp); #ifdef NEED_STRERROR -char *strerror(int err); + char *strerror(int err); #endif /* Misc system hackery */ -API_EXPORT(uid_t) ap_uname2id(const char *name); -API_EXPORT(gid_t) ap_gname2id(const char *name); -API_EXPORT(int) ap_is_directory(const char *name); -API_EXPORT(int) ap_can_exec(const struct stat *); -API_EXPORT(void) ap_chdir_file(const char *file); + API_EXPORT(uid_t) ap_uname2id(const char *name); + API_EXPORT(gid_t) ap_gname2id(const char *name); + API_EXPORT(int) ap_is_directory(const char *name); + API_EXPORT(int) ap_can_exec(const struct stat *); + API_EXPORT(void) ap_chdir_file(const char *file); #ifndef HAVE_CANONICAL_FILENAME /* @@ -1027,10 +1048,12 @@ API_EXPORT(void) ap_chdir_file(const char *file); #define ap_os_case_canonical_filename(p,f) (f) #define ap_os_systemcase_filename(p,f) (f) #else -API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file); + API_EXPORT(char *) ap_os_canonical_filename(pool * p, const char *file); #ifdef WIN32 -API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); -API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); + API_EXPORT(char *) ap_os_case_canonical_filename(pool * pPool, + const char *szFile); + API_EXPORT(char *) ap_os_systemcase_filename(pool * pPool, + const char *szFile); #else #define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f) #define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f) @@ -1038,14 +1061,15 @@ API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); #endif #ifdef _OSD_POSIX -extern const char *os_set_account(pool *p, const char *account); -extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process); -#endif /* _OSD_POSIX */ + extern const char *os_set_account(pool * p, const char *account); + extern int os_init_job_environment(server_rec * s, const char *user_name, + int one_process); +#endif /* _OSD_POSIX */ -char *ap_get_local_host(pool *); -unsigned long ap_get_virthost_addr(char *hostname, unsigned short *port); + char *ap_get_local_host(pool *); + unsigned long ap_get_virthost_addr(char *hostname, unsigned short *port); -extern API_VAR_EXPORT time_t ap_restart_time; + extern API_VAR_EXPORT time_t ap_restart_time; /* * Apache tries to keep all of its long term filehandles (such as log files, @@ -1074,18 +1098,19 @@ extern API_VAR_EXPORT time_t ap_restart_time; #ifdef NO_SLACK #define ap_slack(fd,line) (fd) #else -int ap_slack(int fd, int line); + int ap_slack(int fd, int line); #define AP_SLACK_LOW 1 #define AP_SLACK_HIGH 2 #endif -API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr); + API_EXPORT(char *) ap_escape_quotes(pool * p, const char *instr); /* * Redefine assert() to something more useful for an Apache... */ -API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) - __attribute__((noreturn)); + API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, + int nLine) + __attribute__ ((noreturn)); #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__)) /* The optimized timeout code only works if we're not MULTITHREAD and we're @@ -1108,7 +1133,7 @@ API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) #define SIGSTOP_CGI_CHILD 16 #ifdef DEBUG_SIGSTOP -extern int raise_sigstop_flags; + extern int raise_sigstop_flags; #define RAISE_SIGSTOP(x) do { \ if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\ } while (0) @@ -1116,7 +1141,8 @@ extern int raise_sigstop_flags; #define RAISE_SIGSTOP(x) #endif -API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r); + API_EXPORT(extern const char *) ap_psignature(const char *prefix, + request_rec * r); /* strtoul does not exist on sunos4. */ #ifdef strtoul @@ -1127,5 +1153,4 @@ API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r #ifdef __cplusplus } #endif - -#endif /* !APACHE_HTTPD_H */ +#endif /* !APACHE_HTTPD_H */ diff --git a/src/afsweb/apache_includes/1.3.6/os-inline.c b/src/afsweb/apache_includes/1.3.6/os-inline.c index 54ff49a63..10c035e77 100644 --- a/src/afsweb/apache_includes/1.3.6/os-inline.c +++ b/src/afsweb/apache_includes/1.3.6/os-inline.c @@ -25,7 +25,8 @@ #endif -INLINE int ap_os_is_path_absolute(const char *file) +INLINE int +ap_os_is_path_absolute(const char *file) { - return file[0] == '/'; + return file[0] == '/'; } diff --git a/src/afsweb/apache_includes/1.3.6/os.h b/src/afsweb/apache_includes/1.3.6/os.h index 496cfa9f9..191d8ea36 100644 --- a/src/afsweb/apache_includes/1.3.6/os.h +++ b/src/afsweb/apache_includes/1.3.6/os.h @@ -135,10 +135,10 @@ const char *dlerror(void); #endif #define ap_os_dso_handle_t void * -void ap_os_dso_init(void); -void * ap_os_dso_load(const char *); -void ap_os_dso_unload(void *); -void * ap_os_dso_sym(void *, const char *); +void ap_os_dso_init(void); +void *ap_os_dso_load(const char *); +void ap_os_dso_unload(void *); +void *ap_os_dso_sym(void *, const char *); const char *ap_os_dso_error(void); -#endif /* !APACHE_OS_H */ +#endif /* !APACHE_OS_H */ diff --git a/src/afsweb/apache_includes/1.3.6/util_uri.h b/src/afsweb/apache_includes/1.3.6/util_uri.h index d5a67593f..1ecd4214a 100644 --- a/src/afsweb/apache_includes/1.3.6/util_uri.h +++ b/src/afsweb/apache_includes/1.3.6/util_uri.h @@ -65,10 +65,10 @@ extern "C" { #endif -typedef struct { - const char *name; - unsigned short default_port; -} schemes_t; + typedef struct { + const char *name; + unsigned short default_port; + } schemes_t; #define DEFAULT_FTP_DATA_PORT 20 #define DEFAULT_FTP_PORT 21 @@ -87,42 +87,49 @@ typedef struct { #define UNP_OMITPATHINFO (1U<<4) /* Show "scheme://user@site:port" only */ #define UNP_OMITQUERY (1U<<5) /* Omit the "?queryarg" from the path */ -typedef struct { - char *scheme; /* scheme ("http"/"ftp"/...) */ - char *hostinfo; /* combined [user[:password]@]host[:port] */ - char *user; /* user name, as in http://user:passwd@host:port/ */ - char *password; /* password, as in http://user:passwd@host:port/ */ - char *hostname; /* hostname from URI (or from Host: header) */ - char *port_str; /* port string (integer representation is in "port") */ - char *path; /* the request path (or "/" if only scheme://host was given) */ - char *query; /* Everything after a '?' in the path, if present */ - char *fragment; /* Trailing "#fragment" string, if present */ + typedef struct { + char *scheme; /* scheme ("http"/"ftp"/...) */ + char *hostinfo; /* combined [user[:password]@]host[:port] */ + char *user; /* user name, as in http://user:passwd@host:port/ */ + char *password; /* password, as in http://user:passwd@host:port/ */ + char *hostname; /* hostname from URI (or from Host: header) */ + char *port_str; /* port string (integer representation is in "port") */ + char *path; /* the request path (or "/" if only scheme://host was given) */ + char *query; /* Everything after a '?' in the path, if present */ + char *fragment; /* Trailing "#fragment" string, if present */ - struct hostent *hostent; + struct hostent *hostent; - unsigned short port; /* The port number, numeric, valid only if port_str != NULL */ - - unsigned is_initialized:1; + unsigned short port; /* The port number, numeric, valid only if port_str != NULL */ - unsigned dns_looked_up:1; - unsigned dns_resolved:1; + unsigned is_initialized:1; -} uri_components; + unsigned dns_looked_up:1; + unsigned dns_resolved:1; + + } uri_components; /* util_uri.c */ -API_EXPORT(unsigned short) ap_default_port_for_scheme(const char *scheme_str); -API_EXPORT(unsigned short) ap_default_port_for_request(const request_rec *r); -API_EXPORT(struct hostent *) ap_pduphostent(pool *p, const struct hostent *hp); -API_EXPORT(struct hostent *) ap_pgethostbyname(pool *p, const char *hostname); -API_EXPORT(char *) ap_unparse_uri_components(pool *p, const uri_components *uptr, - unsigned flags); -API_EXPORT(int) ap_parse_uri_components(pool *p, const char *uri, uri_components *uptr); -API_EXPORT(int) ap_parse_hostinfo_components(pool *p, const char *hostinfo, uri_components *uptr); + API_EXPORT(unsigned short) ap_default_port_for_scheme(const char + *scheme_str); + API_EXPORT(unsigned short) ap_default_port_for_request(const request_rec + * r); + API_EXPORT(struct hostent *) ap_pduphostent(pool * p, + const struct hostent *hp); + API_EXPORT(struct hostent *) ap_pgethostbyname(pool * p, + const char *hostname); + API_EXPORT(char *) ap_unparse_uri_components(pool * p, + const uri_components * + uptr, unsigned flags); + API_EXPORT(int) ap_parse_uri_components(pool * p, const char *uri, + uri_components * uptr); + API_EXPORT(int) ap_parse_hostinfo_components(pool * p, + const char *hostinfo, + uri_components * uptr); /* called by the core in main() */ -extern void ap_util_uri_init(void); + extern void ap_util_uri_init(void); #ifdef __cplusplus } #endif - -#endif /*UTIL_URI_H*/ +#endif /*UTIL_URI_H */ diff --git a/src/afsweb/apache_includes/alloc.h b/src/afsweb/apache_includes/alloc.h index 858bf2cb5..d7bc76d60 100644 --- a/src/afsweb/apache_includes/alloc.h +++ b/src/afsweb/apache_includes/alloc.h @@ -76,18 +76,18 @@ typedef struct pool pool; extern pool *permanent_pool; void init_alloc(); /* Set up everything */ -pool *make_sub_pool (pool *); /* All pools are subpools of permanent_pool */ -void destroy_pool (pool *); +pool *make_sub_pool(pool *); /* All pools are subpools of permanent_pool */ +void destroy_pool(pool *); /* Clearing out EVERYTHING in an pool... destroys any sub-pools */ -void clear_pool (struct pool *); +void clear_pool(struct pool *); /* Preparing for exec() --- close files, etc., but *don't* flush I/O * buffers, *don't* wait for subprocesses, and *don't* free any memory. */ -void cleanup_for_exec (); +void cleanup_for_exec(); /* routines to allocate memory from an pool... */ @@ -95,7 +95,7 @@ void *palloc(struct pool *, int nbytes); void *pcalloc(struct pool *, int nbytes); extern char *pstrdup(struct pool *, const char *s); extern char *pstrndup(struct pool *, const char *s, int n); -char *pstrcat(struct pool *, ...); /* all '...' must be char* */ +char *pstrcat(struct pool *, ...); /* all '...' must be char* */ /* array and alist management... keeping lists of things. * Common enough to want common support code ... @@ -109,20 +109,20 @@ typedef struct { char *elts; } array_header; -array_header *make_array (pool *p, int nelts, int elt_size); -void *push_array (array_header *); -void array_cat (array_header *dst, const array_header *src); -array_header *append_arrays (pool *, const array_header *, - const array_header *); +array_header *make_array(pool * p, int nelts, int elt_size); +void *push_array(array_header *); +void array_cat(array_header * dst, const array_header * src); +array_header *append_arrays(pool *, const array_header *, + const array_header *); /* copy_array copies the *entire* array. copy_array_hdr just copies * the header, and arranges for the elements to be copied if (and only * if) the code subsequently does a push or arraycat. */ - -array_header *copy_array (pool *p, const array_header *src); -array_header *copy_array_hdr (pool *p, const array_header *src); - + +array_header *copy_array(pool * p, const array_header * src); +array_header *copy_array_hdr(pool * p, const array_header * src); + /* Tables. Implemented alist style, for now, though we try to keep * it so that imposing a hash table structure on top in the future @@ -133,8 +133,8 @@ array_header *copy_array_hdr (pool *p, const array_header *src); * currently being used... */ -typedef array_header table; - +typedef array_header table; + typedef struct { char *key; /* maybe NULL in future; * check when iterating thru table_elts @@ -142,20 +142,20 @@ typedef struct { char *val; } table_entry; -table *make_table (pool *p, int nelts); -table *copy_table (pool *p, const table *); -void clear_table (table *); -char *table_get (const table *, const char *); -void table_set (table *, const char *name, const char *val); -void table_merge (table *, const char *name, const char *more_val); -void table_unset (table *, const char *key); -void table_add (table *, const char *name, const char *val); -void table_do (int (*comp)(void *, const char *, const char *), void *rec, - const table *t, ...); +table *make_table(pool * p, int nelts); +table *copy_table(pool * p, const table *); +void clear_table(table *); +char *table_get(const table *, const char *); +void table_set(table *, const char *name, const char *val); +void table_merge(table *, const char *name, const char *more_val); +void table_unset(table *, const char *key); +void table_add(table *, const char *name, const char *val); +void table_do(int (*comp) (void *, const char *, const char *), void *rec, + const table * t, ...); -table *overlay_tables (pool *p, const table *overlay, const table *base); +table *overlay_tables(pool * p, const table * overlay, const table * base); -array_header *table_elts (table *); +array_header *table_elts(table *); #define is_empty_table(t) (((t) == NULL)||((t)->nelts == 0)) @@ -181,12 +181,11 @@ array_header *table_elts (table *); * unblock_alarms() below... */ -void register_cleanup (pool *p, void *data, - void (*plain_cleanup)(void *), - void (*child_cleanup)(void *)); +void register_cleanup(pool * p, void *data, void (*plain_cleanup) (void *), + void (*child_cleanup) (void *)); -void kill_cleanup (pool *p, void *data, void (*plain_cleanup)(void *)); -void run_cleanup (pool *p, void *data, void (*cleanup)(void *)); +void kill_cleanup(pool * p, void *data, void (*plain_cleanup) (void *)); +void run_cleanup(pool * p, void *data, void (*cleanup) (void *)); /* The time between when a resource is actually allocated, and when it * its cleanup is registered is a critical section, during which the @@ -207,14 +206,14 @@ extern void unblock_alarms(); FILE *pfopen(struct pool *, const char *name, const char *fmode); FILE *pfdopen(struct pool *, int fd, const char *fmode); -int popenf(struct pool *, const char *name, int flg, int mode); +int popenf(struct pool *, const char *name, int flg, int mode); -void note_cleanups_for_file (pool *, FILE *); -void note_cleanups_for_fd (pool *, int); -void kill_cleanups_for_fd (pool *p, int fd); +void note_cleanups_for_file(pool *, FILE *); +void note_cleanups_for_fd(pool *, int); +void kill_cleanups_for_fd(pool * p, int fd); -regex_t *pregcomp (pool *p, const char *pattern, int cflags); -void pregfree (pool *p, regex_t *reg); +regex_t *pregcomp(pool * p, const char *pattern, int cflags); +void pregfree(pool * p, regex_t * reg); /* routines to note closes... file descriptors are constrained enough * on some systems that we want to support this. @@ -232,12 +231,13 @@ int pclosef(struct pool *, int fd); * set the associated args to NULL). It takes as args a function * to call in the child, and an argument to be passed to the function. */ - -enum kill_conditions { kill_never, kill_always, kill_after_timeout, just_wait}; -int spawn_child_err (pool *, void (*)(void *), void *, - enum kill_conditions, FILE **pipe_in, FILE **pipe_out, - FILE **pipe_err); +enum kill_conditions { kill_never, kill_always, kill_after_timeout, + just_wait +}; + +int spawn_child_err(pool *, void (*)(void *), void *, enum kill_conditions, + FILE ** pipe_in, FILE ** pipe_out, FILE ** pipe_err); #define spawn_child(p,f,v,k,in,out) spawn_child_err(p,f,v,k,in,out,NULL) /* magic numbers --- min free bytes to consider a free pool block useable, @@ -248,5 +248,5 @@ int spawn_child_err (pool *, void (*)(void *), void *, /* Finally, some accounting */ -long bytes_in_pool(pool *p); +long bytes_in_pool(pool * p); long bytes_in_free_blocks(); diff --git a/src/afsweb/apache_includes/buff.h b/src/afsweb/apache_includes/buff.h index aa1926723..aae3e446c 100644 --- a/src/afsweb/apache_includes/buff.h +++ b/src/afsweb/apache_includes/buff.h @@ -65,8 +65,8 @@ #define B_RDERR (16) /* A write error has occurred */ #define B_WRERR (32) -#ifdef B_ERROR /* in SVR4: sometimes defined in /usr/include/sys/buf.h */ -#undef B_ERROR /* avoid "warning: `B_ERROR' redefined" */ +#ifdef B_ERROR /* in SVR4: sometimes defined in /usr/include/sys/buf.h */ +#undef B_ERROR /* avoid "warning: `B_ERROR' redefined" */ #endif #define B_ERROR (48) /* Use chunked writing */ @@ -76,60 +76,59 @@ typedef struct buff_struct BUFF; -struct buff_struct -{ - int flags; /* flags */ - unsigned char *inptr; /* pointer to next location to read */ - int incnt; /* number of bytes left to read from input buffer; - * always 0 if had a read error */ - int outchunk; /* location of chunk header when chunking */ - int outcnt; /* number of byte put in output buffer */ +struct buff_struct { + int flags; /* flags */ + unsigned char *inptr; /* pointer to next location to read */ + int incnt; /* number of bytes left to read from input buffer; + * always 0 if had a read error */ + int outchunk; /* location of chunk header when chunking */ + int outcnt; /* number of byte put in output buffer */ unsigned char *inbase; unsigned char *outbase; int bufsiz; - void (*error)(BUFF *fb, int op, void *data); + void (*error) (BUFF * fb, int op, void *data); void *error_data; - long int bytes_sent; /* number of bytes actually written */ + long int bytes_sent; /* number of bytes actually written */ pool *pool; /* could also put pointers to the basic I/O routines here */ - int fd; /* the file descriptor */ - int fd_in; /* input file descriptor, if different */ + int fd; /* the file descriptor */ + int fd_in; /* input file descriptor, if different */ }; /* Options to bset/getopt */ #define BO_BYTECT (1) /* Stream creation and modification */ -extern BUFF *bcreate(pool *p, int flags); -extern void bpushfd(BUFF *fb, int fd_in, int fd_out); -extern int bsetopt(BUFF *fb, int optname, const void *optval); -extern int bgetopt(BUFF *fb, int optname, void *optval); -extern int bsetflag(BUFF *fb, int flag, int value); -extern int bclose(BUFF *fb); +extern BUFF *bcreate(pool * p, int flags); +extern void bpushfd(BUFF * fb, int fd_in, int fd_out); +extern int bsetopt(BUFF * fb, int optname, const void *optval); +extern int bgetopt(BUFF * fb, int optname, void *optval); +extern int bsetflag(BUFF * fb, int flag, int value); +extern int bclose(BUFF * fb); #define bgetflag(fb, flag) ((fb)->flags & (flag)) /* Error handling */ -extern void bonerror(BUFF *fb, void (*error)(BUFF *, int, void *), +extern void bonerror(BUFF * fb, void (*error) (BUFF *, int, void *), void *data); /* I/O */ -extern int bread(BUFF *fb, void *buf, int nbyte); -extern int bgets(char *s, int n, BUFF *fb); -extern int blookc(char *buff, BUFF *fb); -extern int bskiplf(BUFF *fb); -extern int bwrite(BUFF *fb, const void *buf, int nbyte); -extern int bflush(BUFF *fb); -extern int bputs(const char *x, BUFF *fb); -extern int bvputs(BUFF *fb, ...); -extern int bprintf(BUFF *fb,const char *fmt,...); -extern int vbprintf(BUFF *fb,const char *fmt,va_list vlist); +extern int bread(BUFF * fb, void *buf, int nbyte); +extern int bgets(char *s, int n, BUFF * fb); +extern int blookc(char *buff, BUFF * fb); +extern int bskiplf(BUFF * fb); +extern int bwrite(BUFF * fb, const void *buf, int nbyte); +extern int bflush(BUFF * fb); +extern int bputs(const char *x, BUFF * fb); +extern int bvputs(BUFF * fb, ...); +extern int bprintf(BUFF * fb, const char *fmt, ...); +extern int vbprintf(BUFF * fb, const char *fmt, va_list vlist); /* Internal routines */ -extern int bflsbuf(int c, BUFF *fb); -extern int bfilbuf(BUFF *fb); +extern int bflsbuf(int c, BUFF * fb); +extern int bfilbuf(BUFF * fb); #define bgetc(fb) ( ((fb)->incnt == 0) ? bfilbuf(fb) : \ ((fb)->incnt--, *((fb)->inptr++)) ) diff --git a/src/afsweb/apache_includes/conf.h b/src/afsweb/apache_includes/conf.h index ee6f0be2a..771988fd7 100644 --- a/src/afsweb/apache_includes/conf.h +++ b/src/afsweb/apache_includes/conf.h @@ -84,7 +84,7 @@ char *crypt(const char *pw, const char *salt); char *mktemp(char *template); #define JMP_BUF sigjmp_buf #define HAVE_MMAP -#include +#include #define NEED_STRERROR typedef int rlim_t; #ifndef HAVE_MEMMOVE @@ -167,8 +167,8 @@ typedef int rlim_t; #define ULTRIX_BRAIN_DEATH #define NEED_STRDUP /* If you have Ultrix 4.3, and are using cc, const is broken */ -#ifndef __ultrix__ /* Hack to check for pre-Ultrix 4.4 cc */ -#define const /* Not implemented */ +#ifndef __ultrix__ /* Hack to check for pre-Ultrix 4.4 cc */ +#define const /* Not implemented */ #endif #define JMP_BUF sigjmp_buf @@ -245,7 +245,7 @@ typedef unsigned short mode_t; #ifndef rlim_t typedef int rlim_t; #endif -typedef u_long n_long; +typedef u_long n_long; #endif #define STDIN_FILENO 0 @@ -269,7 +269,7 @@ typedef int rlim_t; #undef NO_SETSID #undef NEED_STRDUP #define JMP_BUF sigjmp_buf -#include +#include #elif defined(SCO) #undef HAVE_GMTOFF @@ -278,8 +278,8 @@ typedef int rlim_t; #define NEED_INITGROUPS #define NO_WRITEV #define JMP_BUF sigjmp_buf -#define SIGURG SIGUSR1 /* but note, this signal will be sent to a process group if enabled (for OOB data). It is not currently enabled. */ -#include +#define SIGURG SIGUSR1 /* but note, this signal will be sent to a process group if enabled (for OOB data). It is not currently enabled. */ +#include #elif defined(SCO5) @@ -293,21 +293,21 @@ typedef int rlim_t; /* Although SCO 5 defines these in (note the "s") they don't have consts. Sigh. */ -extern int strcasecmp(const char *,const char *); -extern int strncasecmp(const char *,const char *,unsigned); +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, unsigned); #elif defined(AUX) /* These are to let -Wall compile more cleanly */ extern int strcasecmp(const char *, const char *); -extern int strncasecmp(const char *,const char *,unsigned); +extern int strncasecmp(const char *, const char *, unsigned); extern int set42sig(), getopt(), getpeername(); extern int listen(), bind(), socket(), getsockname(); extern int accept(), gethostname(), connect(), lstat(); extern int select(), killpg(), shutdown(); extern int initgroups(), setsockopt(); extern char *shmat(); -extern int shmctl(); -extern int shmget(); +extern int shmctl(); +extern int shmget(); extern char *sbrk(); extern char *crypt(); #include @@ -415,7 +415,7 @@ typedef quad_t rlim_t; char *crypt(const char *pw, const char *salt); #endif #ifndef initgroups -int initgroups (char *, int); +int initgroups(char *, int); #endif #ifndef strncasecmp #define strncasecmp strnicmp @@ -449,7 +449,7 @@ int initgroups (char *, int); #define USE_FCNTL_SERIALIZED_ACCEPT #define HAVE_MMAP #define HAVE_CRYPT_H - + #elif defined(__EMX__) /* Defines required for EMX OS/2 port. */ #define JMP_BUF sigjmp_buf @@ -459,10 +459,10 @@ int initgroups (char *, int); #define NO_SETSID /* Add some drive name support */ #define chdir _chdir2 -#include +#include #define MAXSOCKETS 4096 #define HAVE_MMAP - + #elif defined(__MACHTEN__) typedef int rlim_t; #define JMP_BUF sigjmp_buf @@ -497,7 +497,7 @@ typedef int rlim_t; typedef int rlim_t; #elif defined(ISC) -#include +#include #define NO_KILLPG #undef NO_SETSID #define HAVE_SHMGET @@ -546,7 +546,7 @@ typedef int rlim_t; #define ap_snprintf snprintf #define ap_vsnprintf vsnprintf #else -int ap_snprintf(char *buf, size_t len, const char *format,...); +int ap_snprintf(char *buf, size_t len, const char *format, ...); int ap_vsnprintf(char *buf, size_t len, const char *format, va_list ap); #endif @@ -574,9 +574,9 @@ int ap_vsnprintf(char *buf, size_t len, const char *format, va_list ap); #include #include #ifndef MPE -#include /* for inet_ntoa */ +#include /* for inet_ntoa */ #endif -#include /* for ctime */ +#include /* for ctime */ #include #include #include @@ -596,8 +596,8 @@ int ap_vsnprintf(char *buf, size_t len, const char *format, va_list ap); #ifdef HAVE_SYS_RESOURCE_H #include #ifdef SUNOS4 -int getrlimit( int, struct rlimit *); -int setrlimit( int, struct rlimit *); +int getrlimit(int, struct rlimit *); +int setrlimit(int, struct rlimit *); #endif #endif #ifdef HAVE_MMAP @@ -654,7 +654,7 @@ typedef void Sigfunc(int); #undef signal #endif #define signal(s,f) ap_signal(s,f) -Sigfunc *signal(int signo, Sigfunc *func); +Sigfunc *signal(int signo, Sigfunc * func); #endif #include @@ -680,13 +680,13 @@ Sigfunc *signal(int signo, Sigfunc *func); #define XtOffset(p_type,field) \ (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) -#else /* !CRAY2 */ +#else /* !CRAY2 */ #define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field)) -#endif /* !CRAY2 */ -#endif /* __STDC__ */ -#else /* ! (CRAY || __arm) */ +#endif /* !CRAY2 */ +#endif /* __STDC__ */ +#else /* ! (CRAY || __arm) */ #define XtOffset(p_type,field) \ ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) @@ -706,52 +706,52 @@ Sigfunc *signal(int signo, Sigfunc *func); * Sun Quality Software. Gotta love it. */ -int getopt (int, char **, char *); +int getopt(int, char **, char *); -int strcasecmp (char *, char *); -int strncasecmp (char *, char *, int); +int strcasecmp(char *, char *); +int strncasecmp(char *, char *, int); int toupper(int); -int tolower(int); - -int printf (char *, ...); -int fprintf (FILE *, char *, ...); -int fputs (char *, FILE *); -int fread (char *, int, int, FILE *); -int fwrite (char *, int, int, FILE *); -int fflush (FILE *); -int fclose (FILE *); -int ungetc (int, FILE *); -int _filbuf (FILE *); /* !!! */ -int _flsbuf (unsigned char, FILE *); /* !!! */ -int sscanf (char *, char *, ...); -void setbuf (FILE *, char *); -void perror (char *); - -time_t time (time_t *); -int strftime (char *, int, char *, struct tm *); - -int initgroups (char *, int); -int wait3 (int *, int, void*); /* Close enough for us... */ -int lstat (const char *, struct stat *); -int stat (const char *, struct stat *); -int flock (int, int); +int tolower(int); + +int printf(char *, ...); +int fprintf(FILE *, char *, ...); +int fputs(char *, FILE *); +int fread(char *, int, int, FILE *); +int fwrite(char *, int, int, FILE *); +int fflush(FILE *); +int fclose(FILE *); +int ungetc(int, FILE *); +int _filbuf(FILE *); /* !!! */ +int _flsbuf(unsigned char, FILE *); /* !!! */ +int sscanf(char *, char *, ...); +void setbuf(FILE *, char *); +void perror(char *); + +time_t time(time_t *); +int strftime(char *, int, char *, struct tm *); + +int initgroups(char *, int); +int wait3(int *, int, void *); /* Close enough for us... */ +int lstat(const char *, struct stat *); +int stat(const char *, struct stat *); +int flock(int, int); #ifndef NO_KILLPG int killpg(int, int); #endif -int socket (int, int, int); -int setsockopt (int, int, int, const char*, int); -int listen (int, int); -int bind (int, struct sockaddr *, int); -int connect (int, struct sockaddr *, int); -int accept (int, struct sockaddr *, int *); -int shutdown (int, int); - -int getsockname (int s, struct sockaddr *name, int *namelen); -int getpeername (int s, struct sockaddr *name, int *namelen); -int gethostname (char *name, int namelen); -void syslog (int, char *, ...); -char *mktemp (char *); - -long vfprintf (FILE *, char *, va_list); - +int socket(int, int, int); +int setsockopt(int, int, int, const char *, int); +int listen(int, int); +int bind(int, struct sockaddr *, int); +int connect(int, struct sockaddr *, int); +int accept(int, struct sockaddr *, int *); +int shutdown(int, int); + +int getsockname(int s, struct sockaddr *name, int *namelen); +int getpeername(int s, struct sockaddr *name, int *namelen); +int gethostname(char *name, int namelen); +void syslog(int, char *, ...); +char *mktemp(char *); + +long vfprintf(FILE *, char *, va_list); + #endif diff --git a/src/afsweb/apache_includes/http_conf_globals.h b/src/afsweb/apache_includes/http_conf_globals.h index 3a60e7db7..b87733fc4 100644 --- a/src/afsweb/apache_includes/http_conf_globals.h +++ b/src/afsweb/apache_includes/http_conf_globals.h @@ -83,4 +83,3 @@ extern char *server_argv0; extern char server_root[MAX_STRING_LEN]; extern char server_confname[MAX_STRING_LEN]; - diff --git a/src/afsweb/apache_includes/httpd.h b/src/afsweb/apache_includes/httpd.h index abee73506..7481bc7ba 100644 --- a/src/afsweb/apache_includes/httpd.h +++ b/src/afsweb/apache_includes/httpd.h @@ -67,7 +67,7 @@ */ #ifndef HTTPD_ROOT #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define HTTPD_ROOT "/os2httpd" #else #define HTTPD_ROOT "/usr/local/etc/httpd" @@ -77,7 +77,7 @@ #ifndef DOCUMENT_LOCATION /* Root of server */ #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define DOCUMENT_LOCATION "/os2httpd/docs" #else #define DOCUMENT_LOCATION "/usr/local/etc/httpd/htdocs" @@ -116,7 +116,7 @@ /* The name of the log files */ #ifndef DEFAULT_XFERLOG #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define DEFAULT_XFERLOG "logs/access.log" #else #define DEFAULT_XFERLOG "logs/access_log" @@ -124,7 +124,7 @@ #endif /* DEFAULT_XFERLOG */ #ifndef DEFAULT_ERRORLOG #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define DEFAULT_ERRORLOG "logs/error.log" #else #define DEFAULT_ERRORLOG "logs/error_log" @@ -152,7 +152,7 @@ /* Define this to be what your per-directory security files are called */ #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define DEFAULT_ACCESS_FNAME "htaccess" #else #define DEFAULT_ACCESS_FNAME ".htaccess" @@ -191,7 +191,7 @@ /* The path to the Bourne shell, for parsed docs */ #ifndef SHELL_PATH #ifdef __EMX__ -/* Set default for OS/2 file system */ +/* Set default for OS/2 file system */ #define SHELL_PATH "CMD.EXE" #else #define SHELL_PATH "/bin/sh" @@ -274,7 +274,7 @@ * Example: "Apache/1.1.0 MrWidget/0.1-alpha" */ -#define SERVER_BASEVERSION "Apache/1.2.6" /* SEE COMMENTS ABOVE */ +#define SERVER_BASEVERSION "Apache/1.2.6" /* SEE COMMENTS ABOVE */ #ifdef SERVER_SUBVERSION #define SERVER_VERSION SERVER_BASEVERSION " " SERVER_SUBVERSION #else @@ -420,11 +420,10 @@ /* This represents the result of calling htaccess; these are cached for * each request. */ -struct htaccess_result -{ - char *dir; /* the directory to which this applies */ - int override; /* the overrides allowed for the .htaccess file */ - void *htaccess; /* the configuration directives */ +struct htaccess_result { + char *dir; /* the directory to which this applies */ + int override; /* the overrides allowed for the .htaccess file */ + void *htaccess; /* the configuration directives */ /* the next one, or NULL if no more; N.B. never change this */ const struct htaccess_result *next; }; @@ -437,109 +436,109 @@ typedef struct listen_rec listen_rec; struct request_rec { - pool *pool; - conn_rec *connection; - server_rec *server; + pool *pool; + conn_rec *connection; + server_rec *server; - request_rec *next; /* If we wind up getting redirected, + request_rec *next; /* If we wind up getting redirected, * pointer to the request we redirected to. */ - request_rec *prev; /* If this is an internal redirect, + request_rec *prev; /* If this is an internal redirect, * pointer to where we redirected *from*. */ - - request_rec *main; /* If this is a sub_request (see request.h) + + request_rec *main; /* If this is a sub_request (see request.h) * pointer back to the main request. */ - /* Info about the request itself... we begin with stuff that only - * protocol.c should ever touch... - */ - - char *the_request; /* First line of request, so we can log it */ - int assbackwards; /* HTTP/0.9, "simple" request */ - int proxyreq; /* A proxy request */ - int header_only; /* HEAD request, as opposed to GET */ - char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ - int proto_num; /* Number version of protocol; 1.1 = 1001 */ - char *hostname; /* Host, as set by full URI or Host: */ - int hostlen; /* Length of http://host:port in full URI */ - - time_t request_time; /* When the request started */ - - char *status_line; /* Status line, if set by script */ - int status; /* In any case */ - - /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, - * look, but don't touch. - */ - - char *method; /* GET, HEAD, POST, etc. */ - int method_number; /* M_GET, M_POST, etc. */ - int allowed; /* Allowed methods - for 405, OPTIONS, etc */ - - int sent_bodyct; /* byte count in stream is for body */ - long bytes_sent; /* body byte count, for easy access */ - - /* HTTP/1.1 connection-level features */ - - int chunked; /* sending chunked transfer-coding */ - int byterange; /* number of byte ranges */ - char *boundary; /* multipart/byteranges boundary */ - char *range; /* The Range: header */ - long clength; /* The "real" content length */ - - long remaining; /* bytes left to read */ - long read_length; /* bytes that have been read */ - int read_body; /* how the request body should be read */ - int read_chunked; /* reading chunked transfer-coding */ - - /* MIME header environments, in and out. Also, an array containing - * environment variables to be passed to subprocesses, so people can - * write modules to add to that environment. - * - * The difference between headers_out and err_headers_out is that the - * latter are printed even on error, and persist across internal redirects - * (so the headers printed for ErrorDocument handlers will have them). - * - * The 'notes' table is for notes from one module to another, with no - * other set purpose in mind... - */ - - table *headers_in; - table *headers_out; - table *err_headers_out; - table *subprocess_env; - table *notes; - - char *content_type; /* Break these out --- we dispatch on 'em */ - char *handler; /* What we *really* dispatch on */ - - char *content_encoding; - char *content_language; /* for back-compat. only -- do not use */ - array_header *content_languages; /* array of (char*) */ - - int no_cache; - int no_local_copy; - - /* What object is being requested (either directly, or via include - * or content-negotiation mapping). - */ - - char *uri; /* complete URI for a proxy req, or - URL path for a non-proxy req */ - char *filename; - char *path_info; - char *args; /* QUERY_ARGS, if any */ - struct stat finfo; /* ST_MODE set to zero if no such file */ - - /* Various other config info which may change with .htaccess files - * These are config vectors, with one void* pointer for each module - * (the thing pointed to being the module's business). - */ - - void *per_dir_config; /* Options set in config files, etc. */ - void *request_config; /* Notes on *this* request */ + /* Info about the request itself... we begin with stuff that only + * protocol.c should ever touch... + */ + + char *the_request; /* First line of request, so we can log it */ + int assbackwards; /* HTTP/0.9, "simple" request */ + int proxyreq; /* A proxy request */ + int header_only; /* HEAD request, as opposed to GET */ + char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ + int proto_num; /* Number version of protocol; 1.1 = 1001 */ + char *hostname; /* Host, as set by full URI or Host: */ + int hostlen; /* Length of http://host:port in full URI */ + + time_t request_time; /* When the request started */ + + char *status_line; /* Status line, if set by script */ + int status; /* In any case */ + + /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, + * look, but don't touch. + */ + + char *method; /* GET, HEAD, POST, etc. */ + int method_number; /* M_GET, M_POST, etc. */ + int allowed; /* Allowed methods - for 405, OPTIONS, etc */ + + int sent_bodyct; /* byte count in stream is for body */ + long bytes_sent; /* body byte count, for easy access */ + + /* HTTP/1.1 connection-level features */ + + int chunked; /* sending chunked transfer-coding */ + int byterange; /* number of byte ranges */ + char *boundary; /* multipart/byteranges boundary */ + char *range; /* The Range: header */ + long clength; /* The "real" content length */ + + long remaining; /* bytes left to read */ + long read_length; /* bytes that have been read */ + int read_body; /* how the request body should be read */ + int read_chunked; /* reading chunked transfer-coding */ + + /* MIME header environments, in and out. Also, an array containing + * environment variables to be passed to subprocesses, so people can + * write modules to add to that environment. + * + * The difference between headers_out and err_headers_out is that the + * latter are printed even on error, and persist across internal redirects + * (so the headers printed for ErrorDocument handlers will have them). + * + * The 'notes' table is for notes from one module to another, with no + * other set purpose in mind... + */ + + table *headers_in; + table *headers_out; + table *err_headers_out; + table *subprocess_env; + table *notes; + + char *content_type; /* Break these out --- we dispatch on 'em */ + char *handler; /* What we *really* dispatch on */ + + char *content_encoding; + char *content_language; /* for back-compat. only -- do not use */ + array_header *content_languages; /* array of (char*) */ + + int no_cache; + int no_local_copy; + + /* What object is being requested (either directly, or via include + * or content-negotiation mapping). + */ + + char *uri; /* complete URI for a proxy req, or + * URL path for a non-proxy req */ + char *filename; + char *path_info; + char *args; /* QUERY_ARGS, if any */ + struct stat finfo; /* ST_MODE set to zero if no such file */ + + /* Various other config info which may change with .htaccess files + * These are config vectors, with one void* pointer for each module + * (the thing pointed to being the module's business). + */ + + void *per_dir_config; /* Options set in config files, etc. */ + void *request_config; /* Notes on *this* request */ /* * a linked list of the configuration directives in the .htaccess files @@ -547,7 +546,7 @@ struct request_rec { * N.B. always add to the head of the list, _never_ to the end. * that way, a sub request's list can (temporarily) point to a parent's list */ - const struct htaccess_result *htaccess; + const struct htaccess_result *htaccess; }; @@ -555,39 +554,39 @@ struct request_rec { */ struct conn_rec { - - pool *pool; - server_rec *server; - server_rec *base_server; /* Physical vhost this conn come in on */ - - /* Information about the connection itself */ - - int child_num; /* The number of the child handling conn_rec */ - BUFF *client; /* Connetion to the guy */ - int aborted; /* Are we still talking? */ - - /* Who is the client? */ - - struct sockaddr_in local_addr; /* local address */ - struct sockaddr_in remote_addr;/* remote address */ - char *remote_ip; /* Client's IP address */ - char *remote_host; /* Client's DNS name, if known. - * NULL if DNS hasn't been checked, - * "" if it has and no address was found. - * N.B. Only access this though + + pool *pool; + server_rec *server; + server_rec *base_server; /* Physical vhost this conn come in on */ + + /* Information about the connection itself */ + + int child_num; /* The number of the child handling conn_rec */ + BUFF *client; /* Connetion to the guy */ + int aborted; /* Are we still talking? */ + + /* Who is the client? */ + + struct sockaddr_in local_addr; /* local address */ + struct sockaddr_in remote_addr; /* remote address */ + char *remote_ip; /* Client's IP address */ + char *remote_host; /* Client's DNS name, if known. + * NULL if DNS hasn't been checked, + * "" if it has and no address was found. + * N.B. Only access this though * get_remote_host() */ - char *remote_logname; /* Only ever set if doing rfc1413 lookups. - * N.B. Only access this through + char *remote_logname; /* Only ever set if doing rfc1413 lookups. + * N.B. Only access this through * get_remote_logname() */ char *user; /* If an authentication check was made, * this gets set to the user name. We assume * that there's only one user per connection(!) */ - char *auth_type; /* Ditto. */ + char *auth_type; /* Ditto. */ - int keepalive; /* Are we using HTTP Keep-Alive? */ - int keptalive; /* Did we use HTTP Keep-Alive? */ - int keepalives; /* How many times have we used it? */ + int keepalive; /* Are we using HTTP Keep-Alive? */ + int keptalive; /* Did we use HTTP Keep-Alive? */ + int keepalives; /* How many times have we used it? */ }; /* Per-vhost config... */ @@ -601,7 +600,7 @@ typedef struct server_addr_rec server_addr_rec; struct server_addr_rec { server_addr_rec *next; struct in_addr host_addr; /* The bound address, for this server */ - unsigned short host_port; /* The bound port, for this server */ + unsigned short host_port; /* The bound port, for this server */ char *virthost; /* The name given in */ }; @@ -609,26 +608,26 @@ struct server_addr_rec { struct server_rec { server_rec *next; - + /* Full locations of server config info */ - + char *srm_confname; char *access_confname; - + /* Contact information */ - + char *server_admin; char *server_hostname; - unsigned short port; /* for redirects, etc. */ - + unsigned short port; /* for redirects, etc. */ + /* Log files --- note that transfer log is now in the modules... */ - + char *error_fname; FILE *error_log; - + /* Module-specific configuration for server, and defaults... */ - int is_virtual; /* true if this is the virtual server */ + int is_virtual; /* true if this is the virtual server */ void *module_config; /* Config vector containing pointers to * modules' per-server config structures. */ @@ -642,7 +641,7 @@ struct server_rec { int keep_alive_timeout; /* Seconds we'll wait for another request */ int keep_alive_max; /* Maximum requests per connection */ int keep_alive; /* Use persistent connections? */ - int send_buffer_size; /* size of TCP send buffer (in bytes) */ + int send_buffer_size; /* size of TCP send buffer (in bytes) */ char *path; /* Pathname for ServerPath */ int pathlen; /* Length of path */ @@ -656,9 +655,9 @@ struct server_rec { /* These are more like real hosts than virtual hosts */ struct listen_rec { listen_rec *next; - struct sockaddr_in local_addr; /* local IP address and port */ + struct sockaddr_in local_addr; /* local IP address and port */ int fd; - int used; /* Only used during restart */ + int used; /* Only used during restart */ /* more stuff here, like which protocol is bound to the port */ }; @@ -670,70 +669,70 @@ extern const char month_snames[12][4]; struct tm *get_gmtoff(int *tz); char *get_time(); -char *ht_time (pool *p, time_t t, const char *fmt, int gmt); -char *gm_timestr_822(pool *p, time_t t); - +char *ht_time(pool * p, time_t t, const char *fmt, int gmt); +char *gm_timestr_822(pool * p, time_t t); + /* String handling. The *_nc variants allow you to use non-const char **s as arguments (unfortunately C won't automatically convert a char ** to a const -char **) */ - -char *getword(pool *p, const char **line, char stop); -char *getword_nc(pool *p, char **line, char stop); -char *getword_white(pool *p, const char **line); -char *getword_white_nc(pool *p, char **line); -char *getword_nulls (pool *p, const char **line, char stop); -char *getword_nulls_nc (pool *p, char **line, char stop); -char *getword_conf (pool *p, const char **line); -char *getword_conf_nc (pool *p, char **line); - -char *get_token (pool *p, char **accept_line, int accept_white); -int find_token (pool *p, const char *line, const char *tok); -int find_last_token (pool *p, const char *line, const char *tok); - +char **) */ + +char *getword(pool * p, const char **line, char stop); +char *getword_nc(pool * p, char **line, char stop); +char *getword_white(pool * p, const char **line); +char *getword_white_nc(pool * p, char **line); +char *getword_nulls(pool * p, const char **line, char stop); +char *getword_nulls_nc(pool * p, char **line, char stop); +char *getword_conf(pool * p, const char **line); +char *getword_conf_nc(pool * p, char **line); + +char *get_token(pool * p, char **accept_line, int accept_white); +int find_token(pool * p, const char *line, const char *tok); +int find_last_token(pool * p, const char *line, const char *tok); + int is_url(const char *u); extern int unescape_url(char *url); void no2slash(char *name); void getparents(char *name); -char *escape_path_segment(pool *p, const char *s); -char *os_escape_path(pool *p,const char *path,int partial); +char *escape_path_segment(pool * p, const char *s); +char *os_escape_path(pool * p, const char *path, int partial); #define escape_uri(ppool,path) os_escape_path(ppool,path,1) -extern char *escape_html(pool *p, const char *s); -char *construct_server(pool *p, const char *hostname, unsigned port); -char *construct_url (pool *p, const char *path, const server_rec *s); -char *escape_shell_cmd (pool *p, const char *s); - +extern char *escape_html(pool * p, const char *s); +char *construct_server(pool * p, const char *hostname, unsigned port); +char *construct_url(pool * p, const char *path, const server_rec * s); +char *escape_shell_cmd(pool * p, const char *s); + int count_dirs(const char *path); -char *make_dirstr(pool *a, const char *s, int n); -char *make_full_path(pool *a, const char *dir, const char *f); - +char *make_dirstr(pool * a, const char *s, int n); +char *make_full_path(pool * a, const char *dir, const char *f); + int is_matchexp(const char *str); int strcmp_match(const char *str, const char *exp); int strcasecmp_match(const char *str, const char *exp); -char *uudecode (pool *, const char *); +char *uudecode(pool *, const char *); -char *pregsub(pool *p, const char *input, const char *source, - size_t nmatch, regmatch_t pmatch[]); +char *pregsub(pool * p, const char *input, const char *source, size_t nmatch, + regmatch_t pmatch[]); -void str_tolower (char *); -int ind (const char *, char); /* Sigh... */ -int rind (const char *, char); +void str_tolower(char *); +int ind(const char *, char); /* Sigh... */ +int rind(const char *, char); -int cfg_getline(char *s, int n, FILE *f); +int cfg_getline(char *s, int n, FILE * f); #ifdef NEED_STRERROR -char *strerror (int err); +char *strerror(int err); #endif /* Misc system hackery */ - + uid_t uname2id(const char *name); gid_t gname2id(const char *name); int is_directory(const char *name); -int can_exec(const struct stat *); +int can_exec(const struct stat *); void chdir_file(const char *file); - + char *get_local_host(pool *); -unsigned long get_virthost_addr (const char *hostname, unsigned short *port); +unsigned long get_virthost_addr(const char *hostname, unsigned short *port); extern time_t restart_time; @@ -761,6 +760,6 @@ extern time_t restart_time; * never fails. If the high line was requested and it fails it will also try * the low line. */ -int ap_slack (int fd, int line); +int ap_slack(int fd, int line); #define AP_SLACK_LOW 1 #define AP_SLACK_HIGH 2 diff --git a/src/afsweb/nsafs.c b/src/afsweb/nsafs.c index 6bd69e8f3..17e41d74a 100644 --- a/src/afsweb/nsafs.c +++ b/src/afsweb/nsafs.c @@ -14,7 +14,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include @@ -33,7 +34,7 @@ RCSID("$Header$"); #define NSAFS_USERNAME_MAX 64 /* Maximum username length */ #define NSAFS_PASSWORD_MAX 64 /* Maximum password length */ #define NSAFS_LOGIN_HASH_SIZE 1024 /* MUST be power of two */ -#define TEN_MINUTES 600 /* 10 minutes = 600 seconds */ +#define TEN_MINUTES 600 /* 10 minutes = 600 seconds */ #define NSAFS_DIR_ALLOW "GET,HEAD,MOVE,INDEX,RMDIR" #define NSAFS_LINK_ALLOW "GET,HEAD,MOVE,DELETE" @@ -145,9 +146,10 @@ static int base64_to_value[256] = { /* * Decode a base64 encoded buffer in place */ -void nsafs_decode64(char *buf) +void +nsafs_decode64(char *buf) { - int i,j; + int i, j; int len; int val1; int val2; @@ -157,7 +159,7 @@ void nsafs_decode64(char *buf) /* * Allow trailing blanks */ - for (len = strlen(buf) ; buf[len-1] == ' ' && len > 0 ; len--); + for (len = strlen(buf); buf[len - 1] == ' ' && len > 0; len--); /* * Valid encodings are multiples of four characters @@ -167,14 +169,14 @@ void nsafs_decode64(char *buf) return; } - for (i = 0, j = 0 ; i < len ; i += 4, j += 3) { + for (i = 0, j = 0; i < len; i += 4, j += 3) { val1 = base64_to_value[buf[i]]; - val2 = base64_to_value[buf[i+1]]; - val3 = base64_to_value[buf[i+2]]; - val4 = base64_to_value[buf[i+3]]; - buf[j] = ((val1<<2)&0xfc) | ((val2>>4)&0x3); - buf[j+1] = ((val2<<4)&0xf0) | ((val3>>2)&0xf); - buf[j+2] = ((val3<<6)&0xc0) | (val4&0x3f); + val2 = base64_to_value[buf[i + 1]]; + val3 = base64_to_value[buf[i + 2]]; + val4 = base64_to_value[buf[i + 3]]; + buf[j] = ((val1 << 2) & 0xfc) | ((val2 >> 4) & 0x3); + buf[j + 1] = ((val2 << 4) & 0xf0) | ((val3 >> 2) & 0xf); + buf[j + 2] = ((val3 << 6) & 0xc0) | (val4 & 0x3f); } buf[j] = '\0'; } @@ -184,21 +186,21 @@ void nsafs_decode64(char *buf) * Interface for pioctls - used for unlogging */ #include "afs/venus.h" -int do_pioctl(char *in_buffer, int in_size, - char *out_buffer, int out_size, - int opcode, char *path, int followSymLinks) +int +do_pioctl(char *in_buffer, int in_size, char *out_buffer, int out_size, + int opcode, char *path, int followSymLinks) { - struct ViceIoctl iob; - iob.in = in_buffer; - iob.in_size = in_size; - iob.out = out_buffer; - iob.out_size = out_size; - + struct ViceIoctl iob; + iob.in = in_buffer; + iob.in_size = in_size; + iob.out = out_buffer; + iob.out_size = out_size; + #ifdef AFS_USR_SUN5_ENV - return syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, _VICEIOCTL(opcode), &iob, - followSymLinks); + return syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, _VICEIOCTL(opcode), + &iob, followSymLinks); #else /* AFS_USR_SUN5_ENV */ - return lpioctl(path, _VICEIOCTL(opcode), &iob, followSymLinks); + return lpioctl(path, _VICEIOCTL(opcode), &iob, followSymLinks); #endif /* AFS_USR_SUN5_ENV */ } @@ -206,30 +208,32 @@ int do_pioctl(char *in_buffer, int in_size, * unlog - invalidate any existing AFS tokens with the kernel cache * manager. In case the server is started up with tokens */ -int unlog() +int +unlog() { - return do_pioctl(NULL, 0, NULL, 0, VIOCUNPAG, NULL, 0); + return do_pioctl(NULL, 0, NULL, 0, VIOCUNPAG, NULL, 0); } /* * Initialize the AFS client and the login cache */ -void nsafs_init_once() +void +nsafs_init_once() { int i; crit_enter(nsafs_init_lock); if (nsafs_init_done == 0) { - i=unlog(); - if (i) { + i = unlog(); + if (i) { /* printf("unlog from AFS failed: errno:%d\n", errno); */ - } - uafs_Init("nsafs-init", mountDirParam, confDirParam, + } + uafs_Init("nsafs-init", mountDirParam, confDirParam, cacheBaseDirParam, cacheBlocksParam, cacheFilesParam, cacheStatEntriesParam, dCacheSizeParam, vCacheSizeParam, chunkSizeParam, 0, debugParam, nDaemonsParam, -1, logFileParam); nsafs_login_lock = crit_init(); - for (i = 0 ; i < NSAFS_LOGIN_HASH_SIZE ; i++) { + for (i = 0; i < NSAFS_LOGIN_HASH_SIZE; i++) { DLL_INIT_LIST(nsafs_login_cache[i].head, nsafs_login_cache[i].tail); } @@ -242,27 +246,25 @@ void nsafs_init_once() /* * Hash function for the AFS login cache */ -int nsafs_login_hash(char *name, char *cell) +int +nsafs_login_hash(char *name, char *cell) { char *p; afs_uint32 val; - for (val = *name , p = name ; *p != '\0' ; p++) { - val = (val << 2) ^ val ^ (afs_uint32)(*p); + for (val = *name, p = name; *p != '\0'; p++) { + val = (val << 2) ^ val ^ (afs_uint32) (*p); } - for (p = cell ; *p != '\0' ; p++) { - val = (val << 2) ^ val ^ (afs_uint32)(*p); + for (p = cell; *p != '\0'; p++) { + val = (val << 2) ^ val ^ (afs_uint32) (*p); } - return val & (NSAFS_LOGIN_HASH_SIZE-1); + return val & (NSAFS_LOGIN_HASH_SIZE - 1); } /* * Compute a SHA checksum on the username, cellname, and password */ -void nsafs_login_checksum( - char *user, - char *cell, - char *passwd, - char *cksum) +void +nsafs_login_checksum(char *user, char *cell, char *passwd, char *cksum) { int passwdLen; int userLen; @@ -276,26 +278,29 @@ void nsafs_login_checksum( passwdLen = strlen(passwd); userLen = strlen(user); cellLen = strlen(cell); - shaBuffer = afs_osi_Alloc(MAX(userLen+cellLen,passwdLen)+SHA_HASH_BYTES); + shaBuffer = + afs_osi_Alloc(MAX(userLen + cellLen, passwdLen) + SHA_HASH_BYTES); strcpy(shaBuffer, passwd); memcpy((void *)(shaBuffer + passwdLen), (void *)(&nsafs_login_pad[0]), SHA_HASH_BYTES); sha_clear(&state); - sha_hash(&state, shaBuffer, passwdLen+SHA_HASH_BYTES); + sha_hash(&state, shaBuffer, passwdLen + SHA_HASH_BYTES); memcpy(shaBuffer, user, userLen); - memcpy(shaBuffer+userLen, cell, cellLen); - sha_bytes(&state, shaBuffer+userLen+cellLen); + memcpy(shaBuffer + userLen, cell, cellLen); + sha_bytes(&state, shaBuffer + userLen + cellLen); sha_clear(&state); - sha_hash(&state, shaBuffer, userLen+cellLen+SHA_HASH_BYTES); + sha_hash(&state, shaBuffer, userLen + cellLen + SHA_HASH_BYTES); sha_bytes(&state, &cksum[0]); - memset(shaBuffer, 0, MAX(userLen+cellLen,passwdLen)+SHA_HASH_BYTES); - afs_osi_Free(shaBuffer, MAX(userLen+cellLen,passwdLen)+SHA_HASH_BYTES); + memset(shaBuffer, 0, MAX(userLen + cellLen, passwdLen) + SHA_HASH_BYTES); + afs_osi_Free(shaBuffer, + MAX(userLen + cellLen, passwdLen) + SHA_HASH_BYTES); } /* * Set the AFS identity given from the group0 and group1 strings */ -void nsafs_set_id_from_ints(int viceid, int group0, int group1) +void +nsafs_set_id_from_ints(int viceid, int group0, int group1) { int i; struct usr_ucred *crp; @@ -309,7 +314,7 @@ void nsafs_set_id_from_ints(int viceid, int group0, int group1) crp->cr_groups[1] = group1; crp->cr_groups[2] = getgid(); crp->cr_ngroups = 1; - for (i = 3 ; i < NGROUPS ; i++) { + for (i = 3; i < NGROUPS; i++) { crp->cr_groups[i] = NOGROUP; } } @@ -317,7 +322,8 @@ void nsafs_set_id_from_ints(int viceid, int group0, int group1) /* * Set the AFS identity given from the viceid, group0 and group1 strings */ -void nsafs_set_id_from_strings(char *viceid, char *group0, char *group1) +void +nsafs_set_id_from_strings(char *viceid, char *group0, char *group1) { int i; struct usr_ucred *crp; @@ -332,7 +338,7 @@ void nsafs_set_id_from_strings(char *viceid, char *group0, char *group1) crp->cr_suid = getuid(); crp->cr_groups[0] = getgid(); crp->cr_ngroups = 1; - for (i = 1 ; i < NGROUPS ; i++) { + for (i = 1; i < NGROUPS; i++) { crp->cr_groups[i] = NOGROUP; } } @@ -343,13 +349,9 @@ void nsafs_set_id_from_strings(char *viceid, char *group0, char *group1) * given username, and the SHA checksums match, then set the group0 * and group1 parameters and return 1, otherwise return 0. */ -int nsafs_login_lookup( - char *user, - char *cell, - char *cksum, - int *viceid, - int *group0, - int *group1) +int +nsafs_login_lookup(char *user, char *cell, char *cksum, int *viceid, + int *group0, int *group1) { int index; long curTime; @@ -373,11 +375,11 @@ int nsafs_login_lookup( nsafs_login_cache[index].tail, next, prev); afs_osi_Free(tmpP, sizeof(struct nsafs_login)); continue; - } - if (strcmp(loginP->username, user) == 0 && - strcmp(loginP->cellname, cell) == 0 && - memcmp((void *)&loginP->cksum[0], (void *)cksum, - SHA_HASH_BYTES) == 0) { + } + if (strcmp(loginP->username, user) == 0 + && strcmp(loginP->cellname, cell) == 0 + && memcmp((void *)&loginP->cksum[0], (void *)cksum, + SHA_HASH_BYTES) == 0) { *viceid = loginP->viceid; *group0 = loginP->group0; *group1 = loginP->group1; @@ -394,14 +396,9 @@ int nsafs_login_lookup( * Insert a login ID into the cache. If the user already has an entry, * then overwrite the old entry. */ -int nsafs_login_store( - char *user, - char *cell, - char *cksum, - int viceid, - int group0, - int group1, - afs_uint32 expiration) +int +nsafs_login_store(char *user, char *cell, char *cksum, int viceid, int group0, + int group1, afs_uint32 expiration) { int index; long curTime; @@ -416,8 +413,8 @@ int nsafs_login_store( crit_enter(nsafs_login_lock); loginP = nsafs_login_cache[index].head; while (loginP != NULL) { - if (strcmp(loginP->username, user) == 0 && - strcmp(loginP->cellname, cell) == 0) { + if (strcmp(loginP->username, user) == 0 + && strcmp(loginP->cellname, cell) == 0) { break; } if (loginP->expiration < curTime) { @@ -429,18 +426,19 @@ int nsafs_login_store( nsafs_login_cache[index].tail, next, prev); afs_osi_Free(tmpP, sizeof(struct nsafs_login)); continue; - } + } loginP = loginP->next; } if (loginP == NULL) { loginP = (struct nsafs_login *) - afs_osi_Alloc(sizeof(struct nsafs_login)); + afs_osi_Alloc(sizeof(struct nsafs_login)); strcpy(&loginP->username[0], user); strcpy(&loginP->cellname[0], cell); } else { DLL_DELETE(loginP, nsafs_login_cache[index].head, nsafs_login_cache[index].tail, next, prev); - nsafs_set_id_from_ints(loginP->viceid, loginP->group0, loginP->group1); + nsafs_set_id_from_ints(loginP->viceid, loginP->group0, + loginP->group1); uafs_unlog(); } nsafs_set_id_from_ints(viceid, group0, group1); @@ -458,19 +456,15 @@ int nsafs_login_store( /* * Extract a string parameter from the parameter block */ -int nsafs_get_string( - char **paramP, - char *dflt, - char *name, - pblock *pb, - Session *sn, - Request *rq) +int +nsafs_get_string(char **paramP, char *dflt, char *name, pblock * pb, + Session * sn, Request * rq) { char *tmpPtr; char error[128]; tmpPtr = pblock_findval(name, pb); - if(tmpPtr == NULL) { + if (tmpPtr == NULL) { if (dflt == NULL) { log_error(LOG_MISCONFIG, "nsafs", sn, rq, "nsafs_init: please supply a %s parameter", name); @@ -479,7 +473,7 @@ int nsafs_get_string( tmpPtr = dflt; } } - *paramP = afs_osi_Alloc(strlen(tmpPtr)+1); + *paramP = afs_osi_Alloc(strlen(tmpPtr) + 1); strcpy(*paramP, tmpPtr); return REQ_PROCEED; } @@ -487,19 +481,15 @@ int nsafs_get_string( /* * Extract a long integer parameter from the parameter block */ -int nsafs_get_long( - long *paramP, - long dflt, - char *name, - pblock *pb, - Session *sn, - Request *rq) +int +nsafs_get_long(long *paramP, long dflt, char *name, pblock * pb, Session * sn, + Request * rq) { char *start, *end; long val; start = pblock_findval(name, pb); - if(start == NULL) { + if (start == NULL) { if (dflt < 0) { log_error(LOG_MISCONFIG, "nsafs", sn, rq, "nsafs_init: please supply a %s parameter", name); @@ -522,13 +512,9 @@ int nsafs_get_long( /* * Extract an integer parameter from the parameter block */ -int nsafs_get_int( - int *paramP, - int dflt, - char *name, - pblock *pb, - Session *sn, - Request *rq) +int +nsafs_get_int(int *paramP, int dflt, char *name, pblock * pb, Session * sn, + Request * rq) { int code; long val; @@ -543,11 +529,8 @@ int nsafs_get_int( /* * Parse the authorization header for username and password */ -void nsafs_parse_authhdr( - char *authHdr, - char *user, - char *cell, - char *passwd) +void +nsafs_parse_authhdr(char *authHdr, char *user, char *cell, char *passwd) { int i; char *p; @@ -559,11 +542,11 @@ void nsafs_parse_authhdr( /* * Skip leading blanks, check for basic authentication */ - for (p = authHdr ; *p == ' ' && *p != '\0' ; p++); + for (p = authHdr; *p == ' ' && *p != '\0'; p++); if (strncasecmp(p, "basic ", 6) != 0) { return; } - for (p += 6 ; *p == ' ' ; p++); + for (p += 6; *p == ' '; p++); /* * Username and password are base64 encoded @@ -573,18 +556,18 @@ void nsafs_parse_authhdr( /* * Format is user@cell:passwd. The user, cell or passwd may be missing */ - for ( i = 0 ; *p != '@' && *p != ':' && *p != '\0' ; p++ , i++) { + for (i = 0; *p != '@' && *p != ':' && *p != '\0'; p++, i++) { user[i] = *p; } user[i] = '\0'; if (*p == '@') { - for (i = 0 , p++ ; *p != ':' && *p != '\0' ; p++ , i++) { + for (i = 0, p++; *p != ':' && *p != '\0'; p++, i++) { cell[i] = *p; } cell[i] = '\0'; } if (*p == ':') { - for (i = 0 , p++ ; *p != '\0' ; p++ , i++) { + for (i = 0, p++; *p != '\0'; p++, i++) { passwd[i] = *p; } passwd[i] = '\0'; @@ -594,12 +577,9 @@ void nsafs_parse_authhdr( /* * Return an appropriate error given a system errno */ -int nsafs_error_check( - int code, - char *text, - pblock *pb, - Session *sn, - Request *rq) +int +nsafs_error_check(int code, char *text, pblock * pb, Session * sn, + Request * rq) { char txtbuf[256]; char *realmBuf; @@ -618,21 +598,20 @@ int nsafs_error_check( * nsafs_nocheck is set. If nsafs_nocheck is set then change * EPERM to EACCES */ - if (code == EACCES && - pblock_findval("nsafs_nocheck", rq->vars) == NULL && - (pblock_findval("nsafs_viceid", rq->vars) == NULL || - pblock_findval("nsafs_group0", rq->vars) == NULL || - pblock_findval("nsafs_group1", rq->vars) == NULL)) { + if (code == EACCES && pblock_findval("nsafs_nocheck", rq->vars) == NULL + && (pblock_findval("nsafs_viceid", rq->vars) == NULL + || pblock_findval("nsafs_group0", rq->vars) == NULL + || pblock_findval("nsafs_group1", rq->vars) == NULL)) { code = EPERM; - } else if (code == EPERM && - pblock_findval("nsafs_nocheck", rq->vars) == NULL) { - char *status=pblock_findval("status",rq->vars); - if (strcmp(status,"Login Failed")) - code = EACCES; + } else if (code == EPERM + && pblock_findval("nsafs_nocheck", rq->vars) == NULL) { + char *status = pblock_findval("status", rq->vars); + if (strcmp(status, "Login Failed")) + code = EACCES; } switch (code) { - case EPERM: + case EPERM: /* * We overload EPERM (not super-user) to mean unauthenticated. * We use the first subdirectory beneath the AFS mount point @@ -642,7 +621,7 @@ int nsafs_error_check( protocol_status(sn, rq, PROTOCOL_UNAUTHORIZED, NULL); path = pblock_findval("path", rq->vars); realmBuf = NULL; - if(path != NULL) { + if (path != NULL) { path = uafs_afsPathName(path); } if (path != NULL && *path != '\0') { @@ -660,16 +639,16 @@ int nsafs_error_check( } pblock_nvinsert("WWW-authenticate", txtbuf, rq->srvhdrs); break; - case EACCES: + case EACCES: log_error(LOG_SECURITY, "nsafs", sn, rq, txtbuf); protocol_status(sn, rq, PROTOCOL_FORBIDDEN, NULL); break; - case ENOENT: - case ENOTDIR: + case ENOENT: + case ENOTDIR: log_error(LOG_INFORM, "nsafs", sn, rq, txtbuf); protocol_status(sn, rq, PROTOCOL_NOT_FOUND, NULL); break; - default: + default: log_error(LOG_FAILURE, "nsafs", sn, rq, txtbuf); protocol_status(sn, rq, PROTOCOL_SERVER_ERROR, NULL); break; @@ -682,11 +661,9 @@ int nsafs_error_check( * if the preconditions are met. Any other return value means * that the request has been aborted. */ -int nsafs_check_preconditions( - struct stat *stp, - pblock *pb, - Session *sn, - Request *rq) +int +nsafs_check_preconditions(struct stat *stp, pblock * pb, Session * sn, + Request * rq) { int code; time_t mtime; @@ -717,26 +694,24 @@ int nsafs_check_preconditions( * We used to call protocol_set_finfo, but it wasn't handling * if-unmodified-since headers correctly. */ -int nsafs_set_finfo( - Session *sn, - Request *rq, - struct stat *stp) +int +nsafs_set_finfo(Session * sn, Request * rq, struct stat *stp) { int code; time_t mtime; struct tm tms, *tmsp; char *reqhdr; char dateStr[128]; - char *days[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; - char *months[] = {"Jan","Feb","Mar","Apr","May","Jun", - "Jul","Aug","Sep","Oct","Nov","Dec"}; + char *days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; mtime = stp->st_mtime; tmsp = system_gmtime(&mtime, &tms); - sprintf(&dateStr[0],"%s, %02d %s %d %02d:%02d:%02d GMT", - days[tmsp->tm_wday], tmsp->tm_mday, - months[tmsp->tm_mon], tmsp->tm_year+1900, - tmsp->tm_hour, tmsp->tm_min, tmsp->tm_sec); + sprintf(&dateStr[0], "%s, %02d %s %d %02d:%02d:%02d GMT", + days[tmsp->tm_wday], tmsp->tm_mday, months[tmsp->tm_mon], + tmsp->tm_year + 1900, tmsp->tm_hour, tmsp->tm_min, tmsp->tm_sec); pblock_nvinsert("Last-Modified", &dateStr[0], rq->srvhdrs); pblock_nninsert("Content-Length", stp->st_size, rq->srvhdrs); @@ -748,7 +723,8 @@ int nsafs_set_finfo( * here because we are still in the parent process. We don't * initialize AFS until we get the first service request. */ -NSAPI_PUBLIC int nsafs_init(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_init(pblock * pb, Session * sn, Request * rq) { int code; @@ -810,7 +786,8 @@ NSAPI_PUBLIC int nsafs_init(pblock *pb, Session *sn, Request *rq) if (code != REQ_PROCEED) { return code; } - code = nsafs_get_long(&maxExpirationParam, LONG_MAX, "exp-max", pb, sn, rq); + code = + nsafs_get_long(&maxExpirationParam, LONG_MAX, "exp-max", pb, sn, rq); if (code != REQ_PROCEED) { return code; } @@ -821,7 +798,8 @@ NSAPI_PUBLIC int nsafs_init(pblock *pb, Session *sn, Request *rq) /* * Extract name strings from a comma separated list */ -char *nsafs_NameFromNames(char *last, char *list, int *pos) +char * +nsafs_NameFromNames(char *last, char *list, int *pos) { int len; char *start; @@ -830,18 +808,18 @@ char *nsafs_NameFromNames(char *last, char *list, int *pos) if (last == NULL) { *pos = 0; } else { - afs_osi_Free(last, strlen(last)+1); + afs_osi_Free(last, strlen(last) + 1); } start = &list[*pos]; if (*start == '\0') { return NULL; } - for (len = 0 ; start[len] != ',' && start[len] != '\0' ; len++); + for (len = 0; start[len] != ',' && start[len] != '\0'; len++); *pos += len; if (list[*pos] == ',') { *pos += 1; } - retVal = afs_osi_Alloc(len+1); + retVal = afs_osi_Alloc(len + 1); memcpy(retVal, start, len); retVal[len] = '\0'; return retVal; @@ -856,7 +834,8 @@ char *nsafs_NameFromNames(char *last, char *list, int *pos) * Send an Unauthorized response if login fails to prompt the user * to reenter the username and password. */ -NSAPI_PUBLIC int nsafs_basic(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_basic(pblock * pb, Session * sn, Request * rq) { int i; int rc; @@ -896,7 +875,7 @@ NSAPI_PUBLIC int nsafs_basic(pblock *pb, Session *sn, Request *rq) nsafs_parse_authhdr(authHdr, &user[0], &cell[0], &passwd[0]); if (user[0] == '\0' || passwd[0] == '\0') { memset((void *)&passwd[0], 0, NSAFS_PASSWORD_MAX); - pblock_nvinsert("status","Login Failed",rq->vars); + pblock_nvinsert("status", "Login Failed", rq->vars); return nsafs_error_check(EPERM, "Invalid auth header", pb, sn, rq); } if (cell[0] == '\0') { @@ -929,10 +908,10 @@ NSAPI_PUBLIC int nsafs_basic(pblock *pb, Session *sn, Request *rq) } if (cellP == NULL) { memset((void *)&passwd[0], 0, NSAFS_PASSWORD_MAX); - pblock_nvinsert("status","Login Failed",rq->vars); + pblock_nvinsert("status", "Login Failed", rq->vars); return nsafs_error_check(EPERM, "Invalid cell", pb, sn, rq); } - afs_osi_Free(cellP, strlen(cellP)+1); + afs_osi_Free(cellP, strlen(cellP) + 1); u.u_expiration = 0; nsafs_set_id_from_strings(NULL, NULL, NULL); @@ -941,15 +920,16 @@ NSAPI_PUBLIC int nsafs_basic(pblock *pb, Session *sn, Request *rq) if (code != 0) { #if 0 sprintf(txtbuf, "%s@%s: %s\n", user, cell, reason); - pblock_nvinsert("status","Login Failed",rq->vars); + pblock_nvinsert("status", "Login Failed", rq->vars); return nsafs_error_check(EPERM, txtbuf, pb, sn, rq); #else /* 0 */ - return REQ_PROCEED; + return REQ_PROCEED; #endif /* 0 */ } expiration = u.u_expiration; usr_assert(expiration != 0); - expiration = MIN(expiration, (afs_uint32)(time(NULL) + maxExpirationParam)); + expiration = + MIN(expiration, (afs_uint32) (time(NULL) + maxExpirationParam)); /* * Insert the credentials into the login cache @@ -971,7 +951,8 @@ NSAPI_PUBLIC int nsafs_basic(pblock *pb, Session *sn, Request *rq) * Terminates the name translation step for files in AFS. * Puts the AFS pathname into path and into ppath request vars. */ -NSAPI_PUBLIC int nsafs_mount(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_mount(pblock * pb, Session * sn, Request * rq) { char *reqUri; char *newReqUri; @@ -1034,7 +1015,8 @@ NSAPI_PUBLIC int nsafs_mount(pblock *pb, Session *sn, Request *rq) /* * Allow unauthorized users to access a specific directory in AFS */ -NSAPI_PUBLIC int nsafs_public(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_public(pblock * pb, Session * sn, Request * rq) { char *path; char *public; @@ -1062,13 +1044,13 @@ NSAPI_PUBLIC int nsafs_public(pblock *pb, Session *sn, Request *rq) util_uri_parse(public); } pubLen = strlen(public); - if (strncmp(path, public, pubLen) != 0 || - (path[pubLen] != '/' && path[pubLen] != '\0')) { + if (strncmp(path, public, pubLen) != 0 + || (path[pubLen] != '/' && path[pubLen] != '\0')) { return REQ_NOACTION; } - if (pblock_findval("nsafs_viceid", rq->vars) == NULL || - pblock_findval("nsafs_group0", rq->vars) == NULL || - pblock_findval("nsafs_group1", rq->vars) == NULL) { + if (pblock_findval("nsafs_viceid", rq->vars) == NULL + || pblock_findval("nsafs_group0", rq->vars) == NULL + || pblock_findval("nsafs_group1", rq->vars) == NULL) { pblock_nvinsert("nsafs_public", "TRUE", rq->vars); } return REQ_PROCEED; @@ -1077,7 +1059,8 @@ NSAPI_PUBLIC int nsafs_public(pblock *pb, Session *sn, Request *rq) /* * Identify a path that should be an authentication realm. */ -NSAPI_PUBLIC int nsafs_realm(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_realm(pblock * pb, Session * sn, Request * rq) { char *path; char *realm; @@ -1112,8 +1095,8 @@ NSAPI_PUBLIC int nsafs_realm(pblock *pb, Session *sn, Request *rq) } pathLen = strlen(realm); - if (strncmp(path, realm, pathLen) != 0 || - (path[pathLen] != '/' && path[pathLen] != '\0')) { + if (strncmp(path, realm, pathLen) != 0 + || (path[pathLen] != '/' && path[pathLen] != '\0')) { return REQ_NOACTION; } pblock_nvinsert("nsafs_realm", realm, rq->vars); @@ -1124,12 +1107,9 @@ NSAPI_PUBLIC int nsafs_realm(pblock *pb, Session *sn, Request *rq) * Check whether any path elements beneath the nolinks directory * are symbolic links. Return REQ_PROCEED if no links are found. */ -int nsafs_check_for_links( - char *path, - char *nolinks, - pblock *pb, - Session *sn, - Request *rq) +int +nsafs_check_for_links(char *path, char *nolinks, pblock * pb, Session * sn, + Request * rq) { int rc; int code; @@ -1144,19 +1124,18 @@ int nsafs_check_for_links( */ dirLen = strlen(nolinks); pathLen = strlen(path); - if (pathLen < dirLen || - strncmp(path, nolinks, dirLen) != 0 || - (path[dirLen] != '/' && path[dirLen] != '\0')) { + if (pathLen < dirLen || strncmp(path, nolinks, dirLen) != 0 + || (path[dirLen] != '/' && path[dirLen] != '\0')) { return REQ_PROCEED; } if (path[dirLen] == '/') { dirLen++; } - allocSize = pathLen+1; + allocSize = pathLen + 1; tmpPath = (char *)afs_osi_Alloc(allocSize); strcpy(tmpPath, path); - while(tmpPath[pathLen] == '/' && pathLen > dirLen) { + while (tmpPath[pathLen] == '/' && pathLen > dirLen) { tmpPath[pathLen] = '\0'; pathLen--; } @@ -1171,11 +1150,11 @@ int nsafs_check_for_links( afs_osi_Free(tmpPath, allocSize); return nsafs_error_check(ENOENT, NULL, pb, sn, rq); } - while(tmpPath[pathLen] != '/' && pathLen > dirLen) { + while (tmpPath[pathLen] != '/' && pathLen > dirLen) { tmpPath[pathLen] = '\0'; pathLen--; } - while(tmpPath[pathLen] == '/' && pathLen > dirLen) { + while (tmpPath[pathLen] == '/' && pathLen > dirLen) { tmpPath[pathLen] = '\0'; pathLen--; } @@ -1187,7 +1166,8 @@ int nsafs_check_for_links( /* * Deny access to symbolic links in a directory or its descendents. */ -NSAPI_PUBLIC int nsafs_nolinks(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_nolinks(pblock * pb, Session * sn, Request * rq) { int code; char *path; @@ -1254,7 +1234,8 @@ NSAPI_PUBLIC int nsafs_nolinks(pblock *pb, Session *sn, Request *rq) /* * Set the MIME type for files in AFS. */ -NSAPI_PUBLIC int nsafs_force_type(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_force_type(pblock * pb, Session * sn, Request * rq) { char *path; char *dflt; @@ -1291,7 +1272,8 @@ NSAPI_PUBLIC int nsafs_force_type(pblock *pb, Session *sn, Request *rq) * Disable the Unauthorized response message so users never get * prompted for their name and password. */ -NSAPI_PUBLIC int nsafs_nocheck(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_nocheck(pblock * pb, Session * sn, Request * rq) { char *path; @@ -1331,7 +1313,8 @@ NSAPI_PUBLIC int nsafs_nocheck(pblock *pb, Session *sn, Request *rq) * Require all requests for AFS files that are not explicitly made * public to be authenticated. */ -NSAPI_PUBLIC int nsafs_check(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_check(pblock * pb, Session * sn, Request * rq) { char *path; @@ -1357,9 +1340,9 @@ NSAPI_PUBLIC int nsafs_check(pblock *pb, Session *sn, Request *rq) return REQ_PROCEED; } - if (pblock_findval("nsafs_viceid", rq->vars) == NULL || - pblock_findval("nsafs_group0", rq->vars) == NULL || - pblock_findval("nsafs_group1", rq->vars) == NULL) { + if (pblock_findval("nsafs_viceid", rq->vars) == NULL + || pblock_findval("nsafs_group0", rq->vars) == NULL + || pblock_findval("nsafs_group1", rq->vars) == NULL) { return nsafs_error_check(EPERM, NULL, pb, sn, rq); } @@ -1369,7 +1352,8 @@ NSAPI_PUBLIC int nsafs_check(pblock *pb, Session *sn, Request *rq) /* * Find index files for directories */ -NSAPI_PUBLIC int nsafs_find_index(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_find_index(pblock * pb, Session * sn, Request * rq) { char *path; char *indexNames; @@ -1396,7 +1380,7 @@ NSAPI_PUBLIC int nsafs_find_index(pblock *pb, Session *sn, Request *rq) /* * Skip pathnames that don't end in a slash */ - if (*path == '\0' || path[strlen(path)-1] != '/') { + if (*path == '\0' || path[strlen(path) - 1] != '/') { return REQ_NOACTION; } @@ -1423,17 +1407,17 @@ NSAPI_PUBLIC int nsafs_find_index(pblock *pb, Session *sn, Request *rq) indexP = nsafs_NameFromNames(NULL, indexNames, &pos); while (indexP != NULL) { - nameP = afs_osi_Alloc(strlen(path)+strlen(indexP)+2); + nameP = afs_osi_Alloc(strlen(path) + strlen(indexP) + 2); sprintf(nameP, "%s/%s", path, indexP); rc = stat(nameP, &st); if (rc == 0 && (st.st_mode & S_IFMT) != S_IFDIR) { param_free(pblock_remove("path", rq->vars)); pblock_nvinsert("path", nameP, rq->vars); - afs_osi_Free(nameP, strlen(path)+strlen(indexP)+2); - afs_osi_Free(indexP, strlen(indexP)+1); + afs_osi_Free(nameP, strlen(path) + strlen(indexP) + 2); + afs_osi_Free(indexP, strlen(indexP) + 1); return REQ_PROCEED; } - afs_osi_Free(nameP, strlen(path)+strlen(indexP)+2); + afs_osi_Free(nameP, strlen(path) + strlen(indexP) + 2); indexP = nsafs_NameFromNames(indexP, indexNames, &pos); } } else { @@ -1461,17 +1445,17 @@ NSAPI_PUBLIC int nsafs_find_index(pblock *pb, Session *sn, Request *rq) indexP = nsafs_NameFromNames(NULL, indexNames, &pos); while (indexP != NULL) { - nameP = afs_osi_Alloc(strlen(path)+strlen(indexP)+2); + nameP = afs_osi_Alloc(strlen(path) + strlen(indexP) + 2); sprintf(nameP, "%s/%s", path, indexP); rc = uafs_stat(nameP, &st); if (rc == 0 && (st.st_mode & S_IFMT) != S_IFDIR) { param_free(pblock_remove("path", rq->vars)); pblock_nvinsert("path", nameP, rq->vars); - afs_osi_Free(nameP, strlen(path)+strlen(indexP)+2); - afs_osi_Free(indexP, strlen(indexP)+1); + afs_osi_Free(nameP, strlen(path) + strlen(indexP) + 2); + afs_osi_Free(indexP, strlen(indexP) + 1); return REQ_PROCEED; } - afs_osi_Free(nameP, strlen(path)+strlen(indexP)+2); + afs_osi_Free(nameP, strlen(path) + strlen(indexP) + 2); indexP = nsafs_NameFromNames(indexP, indexNames, &pos); } } @@ -1495,7 +1479,8 @@ struct nsafs_tree { /* * Validate that the given tree is a valid balanced binary tree */ -int nsafs_tree_check(struct nsafs_tree *root) +int +nsafs_tree_check(struct nsafs_tree *root) { int leftDepth; int rightDepth; @@ -1517,7 +1502,7 @@ int nsafs_tree_check(struct nsafs_tree *root) assert(balance == root->balance); assert(balance >= -1); assert(balance <= 1); - return (MAX(leftDepth, rightDepth)+1); + return (MAX(leftDepth, rightDepth) + 1); } #endif /* NSAFS_TREE_DEBUG */ @@ -1526,9 +1511,8 @@ int nsafs_tree_check(struct nsafs_tree *root) * rootP is the address of the parent's pointer to this node. * Returns the change in depth of this tree (0 or 1) */ -int nsafs_node_insert( - struct nsafs_tree *newNode, - struct nsafs_tree **rootP) +int +nsafs_node_insert(struct nsafs_tree *newNode, struct nsafs_tree **rootP) { struct nsafs_tree *thisNode; int delta; @@ -1536,7 +1520,7 @@ int nsafs_node_insert( thisNode = *rootP; if (strcmp(newNode->name, thisNode->name) < 0) { /* - * Insert left + * Insert left */ if (thisNode->left == NULL) { thisNode->left = newNode; @@ -1594,7 +1578,7 @@ int nsafs_node_insert( } } else { /* - * Insert right + * Insert right */ if (thisNode->right == NULL) { thisNode->right = newNode; @@ -1657,10 +1641,8 @@ int nsafs_node_insert( * Allocate storage for a new directory entry, copy in the name and * text, and insert the entry into the balanced binary tree. */ -void nsafs_tree_insert( - char *name, - char *text, - struct nsafs_tree **rootP) +void +nsafs_tree_insert(char *name, char *text, struct nsafs_tree **rootP) { int nameLen; int textLen; @@ -1675,7 +1657,7 @@ void nsafs_tree_insert( allocLen = sizeof(struct nsafs_tree) + nameLen + textLen + 2; newNode = (struct nsafs_tree *)afs_osi_Alloc(allocLen); usr_assert(newNode != NULL); - newNode->name = (char *)(newNode+1); + newNode->name = (char *)(newNode + 1); newNode->text = newNode->name + nameLen + 1; newNode->textLen = textLen; newNode->allocLen = allocLen; @@ -1703,19 +1685,16 @@ void nsafs_tree_insert( /* * Transmit the contents of the tree */ -int nsafs_tree_send( - SYS_NETFD sd, - struct nsafs_tree *root, - char *outbuf, - int *buflen, - int bufsize) +int +nsafs_tree_send(SYS_NETFD sd, struct nsafs_tree *root, char *outbuf, + int *buflen, int bufsize) { int code; struct nsafs_tree *node; char *txtBuf; int txtLen; int len; - + /* * Recurse left, iterate right */ @@ -1751,11 +1730,11 @@ int nsafs_tree_send( /* * Free the binary tree and all data within */ -void nsafs_tree_free( - struct nsafs_tree *root) +void +nsafs_tree_free(struct nsafs_tree *root) { struct nsafs_tree *node, *next; - + /* * Iterate left, recurse right */ @@ -1765,7 +1744,8 @@ void nsafs_tree_free( nsafs_tree_free(node->right); } next = node->left; - afs_osi_Free(node, sizeof(struct nsafs_tree) + strlen(node->name) + + afs_osi_Free(node, + sizeof(struct nsafs_tree) + strlen(node->name) + strlen(node->text) + 2); node = next; } @@ -1774,12 +1754,9 @@ void nsafs_tree_free( /* * Send the contents of an AFS directory, Simple directory format */ -int nsafs_send_directory( - char *path, - struct stat *stp, - pblock *pb, - Session *sn, - Request *rq) +int +nsafs_send_directory(char *path, struct stat *stp, pblock * pb, Session * sn, + Request * rq) { char *dirbuf; int buflen; @@ -1789,10 +1766,9 @@ int nsafs_send_directory( int contentLength; int rc; int code; - char *htmlHdr = "\r\n\r\n" - "Index of %s\r\n" - "

Index of %s

\r\n" - "

\r\n"; + char *htmlHdr = + "\r\n\r\n" "Index of %s\r\n" + "

Index of %s

\r\n" "

\r\n"; char *htmlTrl = "
\r\n"; struct nsafs_tree *root; @@ -1822,9 +1798,8 @@ int nsafs_send_directory( } else { filename = enp->d_name; } - sprintf(dirbuf, - " %s\r\n", - path, enp->d_name, filename, filename); + sprintf(dirbuf, " %s\r\n", path, + enp->d_name, filename, filename); contentLength += strlen(dirbuf); nsafs_tree_insert(enp->d_name, dirbuf, &root); } @@ -1902,12 +1877,9 @@ int nsafs_send_directory( /* * Send the contents of an AFS file */ -int nsafs_send_file( - char *path, - struct stat *stp, - pblock *pb, - Session *sn, - Request *rq) +int +nsafs_send_file(char *path, struct stat *stp, pblock * pb, Session * sn, + Request * rq) { char *filebuf; int i; @@ -1918,7 +1890,7 @@ int nsafs_send_file( /* * Make sure we can open the file before we send the response header */ - fd = uafs_open(path, O_RDONLY, 0); + fd = uafs_open(path, O_RDONLY, 0); if (fd < 0) { code = errno; return nsafs_error_check(code, NULL, pb, sn, rq); @@ -1971,7 +1943,8 @@ int nsafs_send_file( /* * Service function for AFS files and directories */ -NSAPI_PUBLIC int nsafs_send(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_send(pblock * pb, Session * sn, Request * rq) { char *path; char *dirPath; @@ -2040,17 +2013,17 @@ NSAPI_PUBLIC int nsafs_send(pblock *pb, Session *sn, Request *rq) */ if ((st.st_mode & S_IFMT) == S_IFDIR) { len = strlen(path); - dirPath = afs_osi_Alloc(len+2); + dirPath = afs_osi_Alloc(len + 2); strcpy(dirPath, path); - if (dirPath[len-1] != '/') { + if (dirPath[len - 1] != '/') { dirPath[len] = '/'; - dirPath[len+1] = '\0'; + dirPath[len + 1] = '\0'; } if (util_uri_is_evil(dirPath)) { util_uri_parse(dirPath); } code = nsafs_send_directory(dirPath, &st, pb, sn, rq); - afs_osi_Free(dirPath, len+2); + afs_osi_Free(dirPath, len + 2); } else { code = nsafs_send_file(path, &st, pb, sn, rq); } @@ -2060,7 +2033,8 @@ NSAPI_PUBLIC int nsafs_send(pblock *pb, Session *sn, Request *rq) /* * Service function to create new AFS files */ -NSAPI_PUBLIC int nsafs_put(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_put(pblock * pb, Session * sn, Request * rq) { char *path; char *viceid; @@ -2141,7 +2115,7 @@ NSAPI_PUBLIC int nsafs_put(pblock *pb, Session *sn, Request *rq) rspStatus = PROTOCOL_OK; } - fd = uafs_open(path, O_WRONLY|O_CREAT|O_TRUNC, 0644); + fd = uafs_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd < 0) { code = errno; return nsafs_error_check(code, NULL, pb, sn, rq); @@ -2161,7 +2135,7 @@ NSAPI_PUBLIC int nsafs_put(pblock *pb, Session *sn, Request *rq) eof = 1; } } - for (bytesRead = 0 ; !eof && bytesRead < bytesToRead ; bytesRead++) { + for (bytesRead = 0; !eof && bytesRead < bytesToRead; bytesRead++) { rc = netbuf_getc(sn->inbuf); if (rc == IO_EOF) { eof = 1; @@ -2197,7 +2171,7 @@ NSAPI_PUBLIC int nsafs_put(pblock *pb, Session *sn, Request *rq) log_error(LOG_FAILURE, "nsafs", sn, rq, "received partial contents"); return REQ_EXIT; } - + pblock_nninsert("Content-Length", 0, rq->srvhdrs); protocol_status(sn, rq, rspStatus, NULL); code = protocol_start_response(sn, rq); @@ -2207,7 +2181,8 @@ NSAPI_PUBLIC int nsafs_put(pblock *pb, Session *sn, Request *rq) /* * Service function to delete AFS files */ -NSAPI_PUBLIC int nsafs_delete(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_delete(pblock * pb, Session * sn, Request * rq) { char *path; char *viceid; @@ -2255,7 +2230,7 @@ NSAPI_PUBLIC int nsafs_delete(pblock *pb, Session *sn, Request *rq) return REQ_ABORTED; } - rc = uafs_unlink(path); + rc = uafs_unlink(path); if (rc < 0) { code = errno; return nsafs_error_check(code, NULL, pb, sn, rq); @@ -2270,7 +2245,8 @@ NSAPI_PUBLIC int nsafs_delete(pblock *pb, Session *sn, Request *rq) /* * Service function to create AFS directories */ -NSAPI_PUBLIC int nsafs_mkdir(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_mkdir(pblock * pb, Session * sn, Request * rq) { char *path; char *viceid; @@ -2307,7 +2283,7 @@ NSAPI_PUBLIC int nsafs_mkdir(pblock *pb, Session *sn, Request *rq) /* * Create the directory */ - rc = uafs_mkdir(path, 0755); + rc = uafs_mkdir(path, 0755); if (rc < 0) { code = errno; return nsafs_error_check(code, NULL, pb, sn, rq); @@ -2322,7 +2298,8 @@ NSAPI_PUBLIC int nsafs_mkdir(pblock *pb, Session *sn, Request *rq) /* * Service function to delete AFS directories */ -NSAPI_PUBLIC int nsafs_rmdir(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_rmdir(pblock * pb, Session * sn, Request * rq) { char *path; char *viceid; @@ -2370,7 +2347,7 @@ NSAPI_PUBLIC int nsafs_rmdir(pblock *pb, Session *sn, Request *rq) * to to delete directories. */ if ((st.st_mode & S_IFMT) == S_IFDIR) { - rc = uafs_rmdir(path); + rc = uafs_rmdir(path); } else if ((st.st_mode & S_IFMT) == S_IFLNK) { log_error(LOG_INFORM, "nsafs", sn, rq, "Cannot RMDIR links"); protocol_status(sn, rq, PROTOCOL_METHOD_NOT_ALLOWED, NULL); @@ -2396,7 +2373,8 @@ NSAPI_PUBLIC int nsafs_rmdir(pblock *pb, Session *sn, Request *rq) /* * Service function to rename AFS files and directories */ -NSAPI_PUBLIC int nsafs_move(pblock *pb, Session *sn, Request *rq) +NSAPI_PUBLIC int +nsafs_move(pblock * pb, Session * sn, Request * rq) { char *path; char *newPath; @@ -2441,7 +2419,7 @@ NSAPI_PUBLIC int nsafs_move(pblock *pb, Session *sn, Request *rq) /* * Rename the object */ - rc = uafs_rename(path, newPath); + rc = uafs_rename(path, newPath); if (rc < 0) { code = errno; return nsafs_error_check(code, NULL, pb, sn, rq); @@ -2456,10 +2434,8 @@ NSAPI_PUBLIC int nsafs_move(pblock *pb, Session *sn, Request *rq) /* * Send the index of an AFS directory */ -int nsafs_index( - pblock *pb, - Session *sn, - Request *rq) +int +nsafs_index(pblock * pb, Session * sn, Request * rq) { char *path; char *viceid; @@ -2545,14 +2521,14 @@ int nsafs_index( if (rc < 0) { continue; } else if ((st.st_mode & S_IFMT) == S_IFDIR) { - sprintf(dirbuf, "%s directory %u %u\r\n", - enp->d_name, st.st_size, st.st_mtime); + sprintf(dirbuf, "%s directory %u %u\r\n", enp->d_name, st.st_size, + st.st_mtime); } else if ((st.st_mode & S_IFMT) == S_IFLNK) { - sprintf(dirbuf, "%s link %u %u\r\n", - enp->d_name, st.st_size, st.st_mtime); + sprintf(dirbuf, "%s link %u %u\r\n", enp->d_name, st.st_size, + st.st_mtime); } else { - sprintf(dirbuf, "%s unknown %u %u\r\n", - enp->d_name, st.st_size, st.st_mtime); + sprintf(dirbuf, "%s unknown %u %u\r\n", enp->d_name, st.st_size, + st.st_mtime); } contentLength += strlen(dirbuf); nsafs_tree_insert(enp->d_name, dirbuf, &root); diff --git a/src/afsweb/nsafs.h b/src/afsweb/nsafs.h index 1880d55a1..dce94f75f 100644 --- a/src/afsweb/nsafs.h +++ b/src/afsweb/nsafs.h @@ -41,16 +41,15 @@ typedef struct shaState { } shaState; -void sha_clear(shaState *shaStateP); -void sha_update(shaState *shaStateP, const char *buffer, int bufferLen); -void sha_finish(shaState *shaStateP); -void sha_hash(shaState *shaStateP, const char *buffer, int bufferLen); -void sha_bytes(const shaState *shaStateP, char *bytes); - -extern afs_int32 nsafs_SetToken ( - struct ktc_principal *aserver, - struct ktc_token *atoken, - struct ktc_principal *aclient, - afs_int32 flags); +void sha_clear(shaState * shaStateP); +void sha_update(shaState * shaStateP, const char *buffer, int bufferLen); +void sha_finish(shaState * shaStateP); +void sha_hash(shaState * shaStateP, const char *buffer, int bufferLen); +void sha_bytes(const shaState * shaStateP, char *bytes); + +extern afs_int32 nsafs_SetToken(struct ktc_principal *aserver, + struct ktc_token *atoken, + struct ktc_principal *aclient, + afs_int32 flags); #endif /* _NSAFS_H_ */ diff --git a/src/afsweb/securehash.c b/src/afsweb/securehash.c index 12df11448..6c1450320 100644 --- a/src/afsweb/securehash.c +++ b/src/afsweb/securehash.c @@ -21,7 +21,8 @@ #include #include "afs/param.h" -RCSID("$Header$"); +RCSID + ("$Header$"); #include "afs/sysincludes.h" /* Standard vendor system headers */ #include @@ -42,15 +43,17 @@ static const sha_int hashinit[] = { #define ROTL(n, x) (((x) << (n)) | ((x) >> (SHA_BITS_PER_INT - (n)))) #ifdef DISABLED_CODE_HERE -static sha_int f(int t, sha_int x, sha_int y, sha_int z) +static sha_int +f(int t, sha_int x, sha_int y, sha_int z) { - if (t < 0 || t >= SHA_ROUNDS) return 0; + if (t < 0 || t >= SHA_ROUNDS) + return 0; if (t < 20) - return (z ^ (x & (y ^ z))); + return (z ^ (x & (y ^ z))); if (t < 40) - return (x ^ y ^ z); + return (x ^ y ^ z); if (t < 60) - return ((x & y) | (z & (x | y))); /* saves 1 boolean op */ + return ((x & y) | (z & (x | y))); /* saves 1 boolean op */ return (x ^ y ^ z); /* 60-79 same as 40-59 */ } #endif @@ -87,14 +90,16 @@ static sha_int f(int t, sha_int x, sha_int y, sha_int z) /* This macro/function supplies the "magic" constant for each round. */ /* The function call version preserved above until stable */ -static const sha_int k_vals[] = { 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6}; +static const sha_int k_vals[] = + { 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 }; #define K(t) ( (t < 0 || t >= SHA_ROUNDS) ? 0 : k_vals[ t/20 ] ) /* * Update the internal state based on the given chunk. */ -static void transform(shaState *shaStateP, sha_int *chunk) +static void +transform(shaState * shaStateP, sha_int * chunk) { sha_int A = shaStateP->digest[0]; sha_int B = shaStateP->digest[1]; @@ -109,13 +114,17 @@ static void transform(shaState *shaStateP, sha_int *chunk) for (t = 0; t < SHA_CHUNK_INTS; t++) W[t] = chunk[t]; for (; t < SHA_ROUNDS; t++) { - TEMP = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]; + TEMP = W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16]; W[t] = ROTL(1, TEMP); } for (t = 0; t < SHA_ROUNDS; t++) { TEMP = ROTL(5, A) + f(t, B, C, D) + E + W[t] + K(t); - E = D; D = C; C = ROTL(30, B); B = A; A = TEMP; + E = D; + D = C; + C = ROTL(30, B); + B = A; + A = TEMP; } shaStateP->digest[0] += A; @@ -131,7 +140,8 @@ static void transform(shaState *shaStateP, sha_int *chunk) * as input and produces an output array of ints that is * SHA_CHUNK_INTS long. */ -static void buildInts(const char *data, sha_int *chunk) +static void +buildInts(const char *data, sha_int * chunk) { /* * Need to copy the data because we can't be certain that @@ -153,7 +163,8 @@ static void buildInts(const char *data, sha_int *chunk) * buildInts to break the input up into chunks and repeatedly passing * these chunks to transform(). */ -void sha_update(shaState *shaStateP, const char *buffer, int bufferLen) +void +sha_update(shaState * shaStateP, const char *buffer, int bufferLen) { int i; sha_int chunk[SHA_CHUNK_INTS]; @@ -167,7 +178,7 @@ void sha_update(shaState *shaStateP, const char *buffer, int bufferLen) shaStateP->bitcountHi++; shaStateP->bitcountLo = newLo; shaStateP->bitcountHi += ((bufferLen >> (SHA_BITS_PER_INT - 3)) & 0x07); - + /* * If we won't have enough for a full chunk, just tack this * buffer onto the leftover piece and return. @@ -212,7 +223,8 @@ void sha_update(shaState *shaStateP, const char *buffer, int bufferLen) * of the hash bitcount to finish the hash. The hash value * is not valid until finish() has been called. */ -void sha_finish(shaState *shaStateP) +void +sha_finish(shaState * shaStateP) { sha_int chunk[SHA_CHUNK_INTS]; int i; @@ -243,11 +255,13 @@ void sha_finish(shaState *shaStateP) * SHS standard, and clear out the bitcount and leftover vars. * This should be used to initialize an shaState. */ -void sha_clear(shaState *shaStateP) +void +sha_clear(shaState * shaStateP) { big_endian = (0x01020304 == htonl(0x01020304)); - memcpy((void *)&shaStateP->digest[0], (void *)&hashinit[0], SHA_HASH_BYTES); + memcpy((void *)&shaStateP->digest[0], (void *)&hashinit[0], + SHA_HASH_BYTES); shaStateP->bitcountLo = shaStateP->bitcountHi = 0; shaStateP->leftoverLen = 0; } @@ -256,7 +270,8 @@ void sha_clear(shaState *shaStateP) /* * Hash the buffer and place the result in *shaStateP. */ -void sha_hash(shaState *shaStateP, const char *buffer, int bufferLen) +void +sha_hash(shaState * shaStateP, const char *buffer, int bufferLen) { sha_clear(shaStateP); sha_update(shaStateP, buffer, bufferLen); @@ -268,10 +283,11 @@ void sha_hash(shaState *shaStateP, const char *buffer, int bufferLen) * Returns the current state of the hash as an array of 20 bytes. * This will be an interim result if finish() has not yet been called. */ -void sha_bytes(const shaState *shaStateP, char *bytes) +void +sha_bytes(const shaState * shaStateP, char *bytes) { sha_int temp[SHA_HASH_INTS]; - int i; + int i; for (i = 0; i < SHA_HASH_INTS; i++) temp[i] = htonl(shaStateP->digest[i]); diff --git a/src/afsweb/weblog.c b/src/afsweb/weblog.c index 8a5e18d74..f366aec50 100644 --- a/src/afsweb/weblog.c +++ b/src/afsweb/weblog.c @@ -24,7 +24,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -60,7 +61,7 @@ RCSID("$Header$"); #define MAXBUFF 1024 /* For caching */ -#include "apache_afs_cache.h" +#include "apache_afs_cache.h" /* the actual function that does all the work! */ int CommandProc(); @@ -78,88 +79,90 @@ static int writePipe; * now I know why this was necessary! - it's a hokie thing - * the call to ka_UserAuthenticateGeneral doesn't compile otherwise */ -int osi_audit() +int +osi_audit() { - return 0; + return 0; } -main (int argc, char **argv) -{ - struct cmd_syndesc *ts; - afs_int32 code; +main(int argc, char **argv) +{ + struct cmd_syndesc *ts; + afs_int32 code; #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 - * in the core dump. Unfortunately, by default, only a partial core is - * generated which, in many cases, isn't too useful. - */ - struct sigaction nsa; - - sigemptyset(&nsa.sa_mask); - nsa.sa_handler = SIG_DFL; - nsa.sa_flags = SA_FULLDUMP; - sigaction(SIGABRT, &nsa, NULL); - sigaction(SIGSEGV, &nsa, NULL); + /* + * 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. + */ + struct sigaction nsa; + + sigemptyset(&nsa.sa_mask); + nsa.sa_handler = SIG_DFL; + nsa.sa_flags = SA_FULLDUMP; + sigaction(SIGABRT, &nsa, NULL); + sigaction(SIGSEGV, &nsa, NULL); #endif - + /* * we ignore SIGPIPE so that EPIPE is returned if there is no one reading * data being written to the pipe */ -#ifdef AIX - /* TODO - for AIX? */ +#ifdef AIX + /* TODO - for AIX? */ #else - struct sigaction sa; - sa.sa_handler = SIG_IGN; - sigaction(SIGPIPE, &sa, NULL); + struct sigaction sa; + sa.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &sa, NULL); #endif - zero_argc = argc; - zero_argv = argv; - - ts = cmd_CreateSyntax(NULL, CommandProc, 0, - "obtain Kerberos authentication for web servers"); + zero_argc = argc; + zero_argv = argv; -/* define the command line arguments */ + ts = cmd_CreateSyntax(NULL, CommandProc, 0, + "obtain Kerberos authentication for web servers"); + +/* define the command line arguments */ #define aREADPIPE 0 #define aWRITEPIPE 1 #define aCACHEEXPIRATION 2 #define aTOKENEXPIRATION 3 #define aSILENT 4 - cmd_AddParm(ts, "-readPipe", CMD_SINGLE, CMD_OPTIONAL, "inPipefd"); - cmd_AddParm(ts, "-writePipe", CMD_SINGLE, CMD_OPTIONAL, "outPipefd"); - cmd_AddParm(ts, "-cacheExpiration", CMD_SINGLE, CMD_OPTIONAL, - "local cache expiration times for tokens"); - cmd_AddParm(ts, "-tokenExpiration", CMD_SINGLE, CMD_OPTIONAL, - "cache manager expiration time for tokens"); - cmd_AddParm(ts, "-silent", CMD_FLAG, CMD_OPTIONAL, "silent operation"); - - code = cmd_Dispatch(argc, argv); - - WEBLOGEXIT(code); + cmd_AddParm(ts, "-readPipe", CMD_SINGLE, CMD_OPTIONAL, "inPipefd"); + cmd_AddParm(ts, "-writePipe", CMD_SINGLE, CMD_OPTIONAL, "outPipefd"); + cmd_AddParm(ts, "-cacheExpiration", CMD_SINGLE, CMD_OPTIONAL, + "local cache expiration times for tokens"); + cmd_AddParm(ts, "-tokenExpiration", CMD_SINGLE, CMD_OPTIONAL, + "cache manager expiration time for tokens"); + cmd_AddParm(ts, "-silent", CMD_FLAG, CMD_OPTIONAL, "silent operation"); + + code = cmd_Dispatch(argc, argv); + + WEBLOGEXIT(code); } /* * send a buffer over the pipe */ -static int sendToken(int len, void *buf) +static int +sendToken(int len, void *buf) { - if(buf == NULL) { - WEBLOGEXIT(NULLARGSERROR); - } - if (write(writePipe, buf, len) != len) { + if (buf == NULL) { + WEBLOGEXIT(NULLARGSERROR); + } + if (write(writePipe, buf, len) != len) { #ifdef DEBUG - perror("weblog: write to pipe error"); + perror("weblog: write to pipe error"); #endif - return -1; - } - return 0; + return -1; + } + return 0; } @@ -167,26 +170,27 @@ static int sendToken(int len, void *buf) * read the incoming buffer from the pipe */ -static int readFromClient(char *buf) +static int +readFromClient(char *buf) { - int n; - if(buf == NULL) { - WEBLOGEXIT(NULLARGSERROR); - } - n = read(readPipe, buf, MAXBUFF); - if(n < 0) { + int n; + if (buf == NULL) { + WEBLOGEXIT(NULLARGSERROR); + } + n = read(readPipe, buf, MAXBUFF); + if (n < 0) { #ifdef DEBUG - perror("weblog: pipe read error"); + perror("weblog: pipe read error"); #endif - return -1; - } - if (n == 0) { + return -1; + } + if (n == 0) { #ifdef DEBUG - perror("weblog: zero bytes read from pipe"); + perror("weblog: zero bytes read from pipe"); #endif - return -1; - } - return n; + return -1; + } + return n; } /* @@ -199,24 +203,25 @@ static int readFromClient(char *buf) * NOTE - the space seperated credentials failed for passwds with spaces, thus * we use newline for seperators instead */ -static int getNullSepWord(char *buf, char sep, char *retBuf, int start) +static int +getNullSepWord(char *buf, char sep, char *retBuf, int start) { - int ret=0; - int len=strlen(buf)-start; - - /* error checks */ - if ((buf == NULL) || (retBuf == NULL) || (start < 0)) { - fprintf(stderr, "weblog (getWordSep):NULL args\n"); - return -1; - } - - while ((buf[start] != sep) && (ret<=len)) { - retBuf[ret]=buf[start]; - ret++; - start++; - } - retBuf[ret]='\0'; - return (ret+1); + int ret = 0; + int len = strlen(buf) - start; + + /* error checks */ + if ((buf == NULL) || (retBuf == NULL) || (start < 0)) { + fprintf(stderr, "weblog (getWordSep):NULL args\n"); + return -1; + } + + while ((buf[start] != sep) && (ret <= len)) { + retBuf[ret] = buf[start]; + ret++; + start++; + } + retBuf[ret] = '\0'; + return (ret + 1); } @@ -224,34 +229,35 @@ static int getNullSepWord(char *buf, char sep, char *retBuf, int start) * parses the NEWLINE seperated buffer giving the username, passwd and cell * coming over the pipe from the clients and sets the variables accordingly */ -static int parseBuf(char *buf, char *user, char *pass, char *cell, char *type) +static int +parseBuf(char *buf, char *user, char *pass, char *cell, char *type) { - char *temp; - int start=0, ret = 0; + char *temp; + int start = 0, ret = 0; - if ((buf == NULL) || (user == NULL) || (pass == NULL) || (cell == NULL) - || (type == NULL)) { + if ((buf == NULL) || (user == NULL) || (pass == NULL) || (cell == NULL) + || (type == NULL)) { #ifdef DEBUG - fprintf(stderr, "afs_Authenticator:parseBuf-an arg was NULL\n"); + fprintf(stderr, "afs_Authenticator:parseBuf-an arg was NULL\n"); #endif - return -1; - } - if ((ret = getNullSepWord(buf, '\n', type, start)) < 0) { - return -1; - } - start += ret; - if ((ret = getNullSepWord(buf, '\n', user, start)) < 0) { - return -1; - } - start += ret; - if ((ret = getNullSepWord(buf, '\n', cell, start)) < 0) { - return -1; - } - start += ret; - if ((ret = getNullSepWord(buf, '\n', pass, start)) < 0) { - return -1; - } - return 0; + return -1; + } + if ((ret = getNullSepWord(buf, '\n', type, start)) < 0) { + return -1; + } + start += ret; + if ((ret = getNullSepWord(buf, '\n', user, start)) < 0) { + return -1; + } + start += ret; + if ((ret = getNullSepWord(buf, '\n', cell, start)) < 0) { + return -1; + } + start += ret; + if ((ret = getNullSepWord(buf, '\n', pass, start)) < 0) { + return -1; + } + return 0; } @@ -259,16 +265,18 @@ static int parseBuf(char *buf, char *user, char *pass, char *cell, char *type) * Discard any authentication information held in trust by the Cache Manager * for the calling process and all other processes in the same PAG */ -static int unlog() +static int +unlog() { - return do_pioctl(NULL, 0, NULL, 0, VIOCUNPAG, NULL, 0); + return do_pioctl(NULL, 0, NULL, 0, VIOCUNPAG, NULL, 0); } /* we can obtain a PAG by calling this system call */ -static int makeNewPAG() +static int +makeNewPAG() { - return do_setpag(); + return do_setpag(); } #ifdef ENABLE_DCE_DLOG @@ -294,59 +302,63 @@ typedef struct kdc_as_reply { char *realm; } kdc_as_reply_t; -static char *makeString(char *sp) +static char * +makeString(char *sp) { - int len; - char *new_string; - - if (sp == NULL) { - fprintf(stderr, "weblog: makeString - NULL argument\n"); - return NULL; - } - len=strlen(sp); - if (len < 0) { - fprintf(stderr, "weblog: makeString. strlen error\n"); - return NULL; - } - new_string=(char *) malloc(len+1); - if (new_string==NULL) { - fprintf(stderr, "weblog: Out of memory - malloc failed\n"); - return NULL; - } - strncpy(new_string,sp,len); - return new_string; + int len; + char *new_string; + + if (sp == NULL) { + fprintf(stderr, "weblog: makeString - NULL argument\n"); + return NULL; + } + len = strlen(sp); + if (len < 0) { + fprintf(stderr, "weblog: makeString. strlen error\n"); + return NULL; + } + new_string = (char *)malloc(len + 1); + if (new_string == NULL) { + fprintf(stderr, "weblog: Out of memory - malloc failed\n"); + return NULL; + } + strncpy(new_string, sp, len); + return new_string; } /* * Store the returned credentials as an AFS "token" for the user * "AFS ID ". */ -static int store_afs_token(unix_id, realm_p, tkt_type, ticket_p, ticket_len, - session_key, starttime, endtime, set_pag) - afs_int32 unix_id; - char *realm_p; - afs_int32 tkt_type; - unsigned char *ticket_p; - int ticket_len; - des_cblock session_key; - afs_int32 starttime; - afs_int32 endtime; - int set_pag; +static int +store_afs_token(unix_id, realm_p, tkt_type, ticket_p, ticket_len, session_key, + starttime, endtime, set_pag) + afs_int32 unix_id; + char *realm_p; + afs_int32 tkt_type; + unsigned char *ticket_p; + int ticket_len; + des_cblock session_key; + afs_int32 starttime; + afs_int32 endtime; + int set_pag; { struct ktc_token token; struct ktc_principal client, server; token.startTime = starttime; token.endTime = endtime; - memcpy((char *) &token.sessionKey, session_key, sizeof(token.sessionKey)); + memcpy((char *)&token.sessionKey, session_key, sizeof(token.sessionKey)); token.kvno = tkt_type; token.ticketLen = ticket_len; if (ticket_len > MAXKTCTICKETLEN) { - fprintf(stderr, "weblog: DCE ticket is too long (length %d)." - "Maximum length accepted by AFS cache manager is %d\n", MAXKTCTICKETLEN); + fprintf(stderr, + "weblog: DCE ticket is too long (length %d)." + "Maximum length accepted by AFS cache manager is %d\n", + MAXKTCTICKETLEN); return -1; } - memcpy((char *) token.ticket, (char *) ticket_p, ticket_len); + memcpy((char *)token.ticket, (char *)ticket_p, ticket_len); sprintf(client.name, "AFS ID %d", unix_id); strcpy(client.instance, ""); @@ -356,16 +368,17 @@ static int store_afs_token(unix_id, realm_p, tkt_type, ticket_p, ticket_len, strcpy(server.instance, ""); strcpy(server.cell, realm_p); - return (ktc_SetToken(&server, &token, &client, - set_pag ? AFS_SETTOK_SETPAG : 0)); + return (ktc_SetToken + (&server, &token, &client, set_pag ? AFS_SETTOK_SETPAG : 0)); } -static char *make_string(s_p, length) - char *s_p; - int length; +static char * +make_string(s_p, length) + char *s_p; + int length; { - char *new_p = (char *) malloc(length + 1); + char *new_p = (char *)malloc(length + 1); if (new_p == NULL) { fprintf(stderr, "dlog: out of memory\n"); exit(1); @@ -381,28 +394,30 @@ static char *make_string(s_p, length) * * NOTE: A test for this procedure is included at the end of this file. */ -static int decode_asn_time(buf, buflen, utime) - char *buf; - int buflen; - afs_int32 *utime; +static int +decode_asn_time(buf, buflen, utime) + char *buf; + int buflen; + afs_int32 *utime; { int year, month, day, hour, mina, sec; int leapyear, days; - static mdays[11] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30}; + static mdays[11] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 }; int m; - if (buflen != 15 || - sscanf(buf, "%4d%2d%2d%2d%2d%2dZ", - &year, &month, &day, &hour, &mina, &sec) != 6) { + if (buflen != 15 + || sscanf(buf, "%4d%2d%2d%2d%2d%2dZ", &year, &month, &day, &hour, + &mina, &sec) != 6) { return 1; } leapyear = month > 2 ? (year + 1) : year; /* Account for feb 29 if - current year is a leap year */ - for (days = 0, m = 0; m < month - 1; m++) days += mdays[m]; + * current year is a leap year */ + for (days = 0, m = 0; m < month - 1; m++) + days += mdays[m]; *utime = - ((((((year - 1970) * 365 + (leapyear - 1970 + 1)/4 - + days + day - 1) * 24) + hour) * 60 + mina) * 60) + sec; + ((((((year - 1970) * 365 + (leapyear - 1970 + 1) / 4 + days + day - + 1) * 24) + hour) * 60 + mina) * 60) + sec; return 0; } @@ -428,10 +443,11 @@ static int decode_asn_time(buf, buflen, utime) #define ASN_GENERAL_STRING 0x1b #define KDC_REP 0x7a -static int decode_reply(buf, buflen, reply_p) - unsigned char *buf; /* encoded ASN.1 string */ - int buflen; /* length of encoded string */ - kdc_as_reply_t *reply_p; /* result */ +static int +decode_reply(buf, buflen, reply_p) + unsigned char *buf; /* encoded ASN.1 string */ + int buflen; /* length of encoded string */ + kdc_as_reply_t *reply_p; /* result */ { unsigned char *limit = buf + buflen; @@ -444,7 +460,7 @@ static int decode_reply(buf, buflen, reply_p) char saw_realm = 0; int context = -1; /* Initialize with invalid context */ - + reply_p->starttime = 0; /* This is optionally provided by kdc */ while (buf < limit) { @@ -456,7 +472,7 @@ static int decode_reply(buf, buflen, reply_p) if ((op & 0x20) == 0) { /* Primitive encoding */ if (len & 0x80) { - return 1; /* Forget about long unspecified lengths */ + return 1; /* Forget about long unspecified lengths */ } /* Bounds check */ if (buf + len > limit) @@ -464,11 +480,11 @@ static int decode_reply(buf, buflen, reply_p) } switch (op) { - case KDC_REP: + case KDC_REP: saw_kdc_rep++; break; - case ASN_INTEGER: + case ASN_INTEGER: { /* * Since non ANSI C doesn't recognize the "signed" @@ -490,7 +506,7 @@ static int decode_reply(buf, buflen, reply_p) } break; - case ASN_OCTET_STRING: + case ASN_OCTET_STRING: if (context == 1 && len == sizeof(reply_p->session_key)) { saw_session_key++; memcpy(reply_p->session_key, buf, len); @@ -498,10 +514,10 @@ static int decode_reply(buf, buflen, reply_p) buf += len; break; - case ASN_GENERAL_STRING: + case ASN_GENERAL_STRING: if (context == 9) { saw_realm = 1; - reply_p->realm = make_string(buf,len); + reply_p->realm = make_string(buf, len); goto out; /* Best to terminate now, rather than * continue--we don't know if the entire * request is padded with zeroes, and if @@ -515,21 +531,21 @@ static int decode_reply(buf, buflen, reply_p) buf += len; break; - case ASN_TIME: + case ASN_TIME: switch (context) { - case 5: + case 5: saw_authtime++; - if (decode_asn_time(buf, len, &reply_p->authtime)) + if (decode_asn_time(buf, len, &reply_p->authtime)) return 1; break; - case 6: + case 6: saw_starttime++; if (decode_asn_time(buf, len, &reply_p->starttime)) return 1; break; - - case 7: + + case 7: saw_endtime++; if (decode_asn_time(buf, len, &reply_p->endtime)) return 1; @@ -538,7 +554,7 @@ static int decode_reply(buf, buflen, reply_p) buf += len; break; - default: + default: if ((op & 0xe0) == 0xa0) { /* Remember last context label */ context = op & 0x1f; @@ -550,228 +566,234 @@ static int decode_reply(buf, buflen, reply_p) } out: - return ! (saw_kdc_rep == 1 && saw_nonce == 1 && saw_session_key == 1 && - saw_authtime == 1 && (saw_starttime == 1 || saw_starttime == 0) && - saw_endtime == 1 && saw_realm == 1); + return !(saw_kdc_rep == 1 && saw_nonce == 1 && saw_session_key == 1 + && saw_authtime == 1 && (saw_starttime == 1 + || saw_starttime == 0) + && saw_endtime == 1 && saw_realm == 1); } - + /* * Attempt to obtain a DFS ticket */ -static int getDFScreds(char *name, char *realm, char *passwd, - afs_uint32 lifetime, char **reason) +static int +getDFScreds(char *name, char *realm, char *passwd, afs_uint32 lifetime, + char **reason) { - extern ADK_GetTicket(); - afs_int32 serverList[MAXSERVERS]; - struct rx_connection *serverconns[MAXSERVERS]; - struct ubik_client *ubik_handle=0; - struct timeval now; /* current time */ - afs_int32 nonce; /* Kerberos V5 "nonce" */ - adk_error_ptr error_p; /* Error code from ktc intermediary */ - adk_reply_ptr reply_p; /* reply from ktc intermediary */ - des_cblock passwd_key; /* des key from user password */ - des_key_schedule schedule; /* Key schedule from key */ - kdc_as_reply_t kdcrep; /* Our own decoded version of - ciphertext portion of kdc reply */ - int code; - struct afsconf_dir *cdir; /* Open configuration structure */ - int i; - struct afsconf_cell cellinfo; /* Info for specified cell */ - - if ((name==NULL)||(realm==NULL)||(passwd==NULL)) { - *reason=makeString("weblog: NULL Arguments to getDCEcreds"); - return -1; - } - - cdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH); - if (!cdir) { - *reason=makeString("weblog: unable to read or open AFS client " - "configuration file"); - return -1; - } - - /* - * Resolve full name of cell and get server list. - */ - code = afsconf_GetCellInfo(cdir, realm, 0, &cellinfo); - if (code) { - *reason=makeString("-- unable to get cell info"); - return -1; - } - - if (strcmp(realm, cellinfo.name)) { - strncpy(realm, cellinfo.name, sizeof(realm) - 1); - realm[sizeof(realm) - 1] = '\0'; - } - - for (i = 0; i < cellinfo.numServers && i < MAXSERVERS; i++) { - serverList[i] = cellinfo.hostAddr[i].sin_addr.s_addr; - } - if (i < MAXSERVERS) serverList[i] = 0; - - /* - * Make connections to all the servers. - */ - rx_Init(0); - for (i = 0; i < MAXSERVERS; i++) { - if (! serverList[i]) { - serverconns[i] = 0; - break; + extern ADK_GetTicket(); + afs_int32 serverList[MAXSERVERS]; + struct rx_connection *serverconns[MAXSERVERS]; + struct ubik_client *ubik_handle = 0; + struct timeval now; /* current time */ + afs_int32 nonce; /* Kerberos V5 "nonce" */ + adk_error_ptr error_p; /* Error code from ktc intermediary */ + adk_reply_ptr reply_p; /* reply from ktc intermediary */ + des_cblock passwd_key; /* des key from user password */ + des_key_schedule schedule; /* Key schedule from key */ + kdc_as_reply_t kdcrep; /* Our own decoded version of + * ciphertext portion of kdc reply */ + int code; + struct afsconf_dir *cdir; /* Open configuration structure */ + int i; + struct afsconf_cell cellinfo; /* Info for specified cell */ + + if ((name == NULL) || (realm == NULL) || (passwd == NULL)) { + *reason = makeString("weblog: NULL Arguments to getDCEcreds"); + return -1; + } + + cdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH); + if (!cdir) { + *reason = + makeString("weblog: unable to read or open AFS client " + "configuration file"); + return -1; + } + + /* + * Resolve full name of cell and get server list. + */ + code = afsconf_GetCellInfo(cdir, realm, 0, &cellinfo); + if (code) { + *reason = makeString("-- unable to get cell info"); + return -1; + } + + if (strcmp(realm, cellinfo.name)) { + strncpy(realm, cellinfo.name, sizeof(realm) - 1); + realm[sizeof(realm) - 1] = '\0'; + } + + for (i = 0; i < cellinfo.numServers && i < MAXSERVERS; i++) { + serverList[i] = cellinfo.hostAddr[i].sin_addr.s_addr; + } + if (i < MAXSERVERS) + serverList[i] = 0; + + /* + * Make connections to all the servers. + */ + rx_Init(0); + for (i = 0; i < MAXSERVERS; i++) { + if (!serverList[i]) { + serverconns[i] = 0; + break; + } + serverconns[i] = + rx_NewConnection(serverList[i], htons(ADK_PORT), ADK_SERVICE, + rxnull_NewClientSecurityObject(), 0); + } + + /* + * Initialize ubik client gizmo to randomize the calls for us. + */ + ubik_ClientInit(serverconns, &ubik_handle); + /* + * Come up with an acceptable nonce. V5 doc says that we just need + * time of day. Actually, for this app, I don't think anything + * is really needed. Better safe than sorry (although I wonder if + * it might have been better to encode the AFS ID in the nonce + * reply field--that's the one field that the intermediate server + * has total control over, and which can be securely transmitted + * back to the client). + */ + gettimeofday(&now, 0); + nonce = now.tv_sec; + + + /* + * Ask our agent to get us a Kerberos V5 ticket. + */ + reply_p = (adk_reply_ptr) 0; + error_p = (adk_error_ptr) 0; + code = ubik_Call(ADK_GetTicket, ubik_handle, 0, /* Ubik flags */ + name, /* IN: Principal: must be exact DCE principal */ + nonce, /* IN: Input nonce */ + lifetime, /* IN: lifetime */ + &error_p, /* OUT: Error, if any */ + &reply_p); /* OUT: KTC reply, if no error */ + + /* + * Destroy Rx connections on the off-chance this will allow less state + * to be preserved at the server. + */ + ubik_ClientDestroy(ubik_handle); + + /* + * Finalize Rx. This may allow connections at the server to wind down + * faster. + */ + rx_Finalize(); + + + /* + * Check for simple communication failures. + */ + if (code) { + *reason = makeString("-- failed to contact authentication service"); + return -1; + } + + /* + * Also check for DCE errors, which are interpreted for us by + * the translator. + */ + if (error_p && error_p->code) { + *reason = (char *)makeString(error_p->data); + fprintf(stderr, "weblog error:error_p->data:%s\n", error_p->data); + return -1; + } + + + /* + * Make sure the reply was filled in. + */ + if (!reply_p) { + *reason = (char *) + makeString + ("weblog: unexpected error in server response; aborted"); + return -1; } - serverconns[i] = rx_NewConnection - (serverList[i], htons(ADK_PORT), ADK_SERVICE, - rxnull_NewClientSecurityObject(), 0); - } - - /* - * Initialize ubik client gizmo to randomize the calls for us. - */ - ubik_ClientInit(serverconns, &ubik_handle); - /* - * Come up with an acceptable nonce. V5 doc says that we just need - * time of day. Actually, for this app, I don't think anything - * is really needed. Better safe than sorry (although I wonder if - * it might have been better to encode the AFS ID in the nonce - * reply field--that's the one field that the intermediate server - * has total control over, and which can be securely transmitted - * back to the client). - */ - gettimeofday(&now, 0); - nonce = now.tv_sec; - - - /* - * Ask our agent to get us a Kerberos V5 ticket. - */ - reply_p = (adk_reply_ptr) 0; - error_p = (adk_error_ptr) 0; - code = ubik_Call - (ADK_GetTicket, - ubik_handle, - 0, /* Ubik flags */ - name, /* IN: Principal: must be exact DCE principal */ - nonce, /* IN: Input nonce */ - lifetime, /* IN: lifetime */ - &error_p, /* OUT: Error, if any */ - &reply_p); /* OUT: KTC reply, if no error */ - - /* - * Destroy Rx connections on the off-chance this will allow less state - * to be preserved at the server. - */ - ubik_ClientDestroy(ubik_handle); - - /* - * Finalize Rx. This may allow connections at the server to wind down - * faster. - */ - rx_Finalize(); - - - /* - * Check for simple communication failures. - */ - if (code) { - *reason=makeString("-- failed to contact authentication service"); - return -1; - } - - /* - * Also check for DCE errors, which are interpreted for us by - * the translator. - */ - if (error_p && error_p->code) { - *reason=( char *) makeString(error_p->data); - fprintf(stderr,"weblog error:error_p->data:%s\n", error_p->data); - return -1; - } - - - /* - * Make sure the reply was filled in. - */ - if (!reply_p) { - *reason=(char *) makeString("weblog: unexpected error in server response; aborted"); - return -1; - } - - - /* - * Convert the password into the appropriate key block, given - * the salt passed back from the ADK_GetTicket call, above. Destroy - * the password. - */ - if (strlen(passwd) + strlen(reply_p->salt) + 1 > BUFSIZ) { - *reason=(char *) makeString("weblog: unexpectedly long passwd/salt combination"); - return -1; - } - strcat(passwd, reply_p->salt); - des_string_to_key(passwd, passwd_key); - - /* Destroy the password. */ - memset(passwd, 0, strlen(passwd)); - - - /* - * Decrypt the private data returned by the DCE KDC, and forwarded - * to us by the translator. - */ - code = des_key_sched (passwd_key, schedule); - if (!code) { - code = des_cbc_encrypt - (reply_p->private.adk_code_val, reply_p->private.adk_code_val, - reply_p->private.adk_code_len, schedule, passwd_key, DECRYPT); - } - if (code) { - *reason=(char *) makeString("-- unable to decrypt reply from the DCE KDC"); - return -1; - } - - /* - * Destroy the key block: it's no longer needed. - */ - memset(schedule, 0, sizeof(schedule)); - memset(passwd_key, 0, sizeof(passwd_key)); - - - /* - * Do a very quick and dirty ASN.1 decode of the relevant parts - * of the private data. - * - * The decrypted data contains a 12-byte header (confounder and CRC-32 - * checksum). We choose to ignore this. - */ - code = decode_reply(reply_p->private.adk_code_val + 12, /* Skip header */ - reply_p->private.adk_code_len - 12, /* ditto */ - &kdcrep); - - if (code || kdcrep.nonce != nonce) { - *reason=(char *)makeString("weblog: DCE authentication failed -- " - "password is probably incorrect"); - return -1; - } - - - /* - * Make an AFS token out of the ticket and session key, and install it - * in the cache manager. - */ - code = store_afs_token(reply_p->unix_id, - realm, - reply_p->tktype, - reply_p->ticket.adk_code_val, - reply_p->ticket.adk_code_len, - kdcrep.session_key, - kdcrep.starttime? kdcrep.starttime : kdcrep.authtime, - kdcrep.endtime, - 0); - - if (code) { - *reason=(char *)makeString("weblog -- getDCEcreds:failed to store tickets"); - return -1; - } - return 0; + + + /* + * Convert the password into the appropriate key block, given + * the salt passed back from the ADK_GetTicket call, above. Destroy + * the password. + */ + if (strlen(passwd) + strlen(reply_p->salt) + 1 > BUFSIZ) { + *reason = (char *) + makeString("weblog: unexpectedly long passwd/salt combination"); + return -1; + } + strcat(passwd, reply_p->salt); + des_string_to_key(passwd, passwd_key); + + /* Destroy the password. */ + memset(passwd, 0, strlen(passwd)); + + + /* + * Decrypt the private data returned by the DCE KDC, and forwarded + * to us by the translator. + */ + code = des_key_sched(passwd_key, schedule); + if (!code) { + code = + des_cbc_encrypt(reply_p->private.adk_code_val, + reply_p->private.adk_code_val, + reply_p->private.adk_code_len, schedule, + passwd_key, DECRYPT); + } + if (code) { + *reason = + (char *)makeString("-- unable to decrypt reply from the DCE KDC"); + return -1; + } + + /* + * Destroy the key block: it's no longer needed. + */ + memset(schedule, 0, sizeof(schedule)); + memset(passwd_key, 0, sizeof(passwd_key)); + + + /* + * Do a very quick and dirty ASN.1 decode of the relevant parts + * of the private data. + * + * The decrypted data contains a 12-byte header (confounder and CRC-32 + * checksum). We choose to ignore this. + */ + code = decode_reply(reply_p->private.adk_code_val + 12, /* Skip header */ + reply_p->private.adk_code_len - 12, /* ditto */ + &kdcrep); + + if (code || kdcrep.nonce != nonce) { + *reason = + (char *)makeString("weblog: DCE authentication failed -- " + "password is probably incorrect"); + return -1; + } + + + /* + * Make an AFS token out of the ticket and session key, and install it + * in the cache manager. + */ + code = + store_afs_token(reply_p->unix_id, realm, reply_p->tktype, + reply_p->ticket.adk_code_val, + reply_p->ticket.adk_code_len, kdcrep.session_key, + kdcrep.starttime ? kdcrep.starttime : kdcrep.authtime, + kdcrep.endtime, 0); + + if (code) { + *reason = (char *) + makeString("weblog -- getDCEcreds:failed to store tickets"); + return -1; + } + return 0; } #endif /* ENABLE_DCE_DLOG */ @@ -781,257 +803,260 @@ static int getDFScreds(char *name, char *realm, char *passwd, * arrive through a pipe from the httpds, authenticates the user and * returns a token (or a failure message) over the pipe */ -CommandProc (as, arock) +CommandProc(as, arock) char *arock; struct cmd_syndesc *as; - + { - char name[MAXKTCNAMELEN]; - char cell[MAXKTCREALMLEN]; - char passwd[BUFSIZ]; + char name[MAXKTCNAMELEN]; + char cell[MAXKTCREALMLEN]; + char passwd[BUFSIZ]; /* All the constant sizes for these arrays are taken from the code for klog */ - - char cksum[SHA_HASH_BYTES]; /* for sha checksum for caching */ - afs_int32 expires=0; /* for cache expiration */ - afs_int32 cacheExpiration=0; /* configurable cmd line parameter */ - afs_int32 testExpires=0; /* cacheExpiration + current time */ - - int authtype = 0; /* AFS or AFS-DFS Authentication */ - int code; - int shutdown = 0; /* on getting shutdown from the pipe we GO */ - int gotToken = 0; /* did we get a token from the cache manager */ - afs_int32 i=0; /* for getting primary token held by CM */ - int dosetpag=1; /* not used */ - Date lifetime; /* requested ticket lifetime */ - char tbuffer[MAXBUFF]; /* for pioctl ops + pipe transfers */ - static char rn[] = "weblog"; /* Routine name */ - static int Silent = 0; /* Don't want error messages */ - afs_int32 password_expires = -1; - char *reason; /* string describing errors */ - char type[10]; /* authentication type AFS or DFS */ - - /* blow away command line arguments */ - for (i=1; iparms[aSILENT].items ? 1 : 0); - - code = ka_Init(0); - if (code) { - if (!Silent) { - fprintf(stderr, "%s:ka_Init FAILED\n", rn); + + char cksum[SHA_HASH_BYTES]; /* for sha checksum for caching */ + afs_int32 expires = 0; /* for cache expiration */ + afs_int32 cacheExpiration = 0; /* configurable cmd line parameter */ + afs_int32 testExpires = 0; /* cacheExpiration + current time */ + + int authtype = 0; /* AFS or AFS-DFS Authentication */ + int code; + int shutdown = 0; /* on getting shutdown from the pipe we GO */ + int gotToken = 0; /* did we get a token from the cache manager */ + afs_int32 i = 0; /* for getting primary token held by CM */ + int dosetpag = 1; /* not used */ + Date lifetime; /* requested ticket lifetime */ + char tbuffer[MAXBUFF]; /* for pioctl ops + pipe transfers */ + static char rn[] = "weblog"; /* Routine name */ + static int Silent = 0; /* Don't want error messages */ + afs_int32 password_expires = -1; + char *reason; /* string describing errors */ + char type[10]; /* authentication type AFS or DFS */ + + /* blow away command line arguments */ + for (i = 1; i < zero_argc; i++) + memset(zero_argv[i], 0, strlen(zero_argv[i])); + zero_argc = 0; + + /* first determine quiet flag based on -silent switch */ + Silent = (as->parms[aSILENT].items ? 1 : 0); + + code = ka_Init(0); + if (code) { + if (!Silent) { + fprintf(stderr, "%s:ka_Init FAILED\n", rn); + } + WEBLOGEXIT(KAERROR); } - WEBLOGEXIT(KAERROR); - } - - /* Parse our arguments. */ - if (as->parms[aREADPIPE].items) - /* there is a file descriptor instead of stdin */ - readPipe = atoi(as->parms[aREADPIPE].items->data); - else - readPipe = stdin; - - if (as->parms[aWRITEPIPE].items) - /* there is a file descriptor instead of stdout */ - writePipe = atoi(as->parms[aWRITEPIPE].items->data); - else - writePipe = stdout; - - if (as->parms[aCACHEEXPIRATION].items) - /* set configurable cache expiration time */ - cacheExpiration=atoi(as->parms[aCACHEEXPIRATION].items->data); - - if (as->parms[aTOKENEXPIRATION].items) - /* set configurable token lifetime */ - lifetime = atoi(as->parms[aTOKENEXPIRATION].items->data); - - /* - * Initialize the cache for tokens - */ - token_cache_init(); - - /* - * discard any tokens held for this PAG - - * should we create a seperate PAG for weblog first? makeNewPAG does that - */ + + /* Parse our arguments. */ + if (as->parms[aREADPIPE].items) + /* there is a file descriptor instead of stdin */ + readPipe = atoi(as->parms[aREADPIPE].items->data); + else + readPipe = stdin; + + if (as->parms[aWRITEPIPE].items) + /* there is a file descriptor instead of stdout */ + writePipe = atoi(as->parms[aWRITEPIPE].items->data); + else + writePipe = stdout; + + if (as->parms[aCACHEEXPIRATION].items) + /* set configurable cache expiration time */ + cacheExpiration = atoi(as->parms[aCACHEEXPIRATION].items->data); + + if (as->parms[aTOKENEXPIRATION].items) + /* set configurable token lifetime */ + lifetime = atoi(as->parms[aTOKENEXPIRATION].items->data); + + /* + * Initialize the cache for tokens + */ + token_cache_init(); + + /* + * discard any tokens held for this PAG - + * should we create a seperate PAG for weblog first? makeNewPAG does that + */ #ifdef DEBUG - fprintf(stderr, "%s:Before MAKENEWPAG\n", rn); - printGroups(); - fprintf(stderr,"\nWEBLOG: before PAG:\t"); - printPAG(); + fprintf(stderr, "%s:Before MAKENEWPAG\n", rn); + printGroups(); + fprintf(stderr, "\nWEBLOG: before PAG:\t"); + printPAG(); #endif - if (makeNewPAG()) { - fprintf(stderr, "WEBLOG: MakeNewPAG failed\n"); - } + if (makeNewPAG()) { + fprintf(stderr, "WEBLOG: MakeNewPAG failed\n"); + } #ifdef DEBUG - fprintf(stderr,"weblog:AFTER do_setpag,PAG:\t"); - printPAG(); - fprintf(stderr, "%s:After MAKENEWPAG\n", rn); - printGroups(); + fprintf(stderr, "weblog:AFTER do_setpag,PAG:\t"); + printPAG(); + fprintf(stderr, "%s:After MAKENEWPAG\n", rn); + printGroups(); #endif - - if (unlog()) { + + if (unlog()) { #ifdef DEBUG - fprintf(stderr, "WEBLOG: UNLOG FAILED\n"); + fprintf(stderr, "WEBLOG: UNLOG FAILED\n"); #endif - } - - while (!shutdown) { - gotToken = 0; - code = readFromClient(tbuffer); - if (code > 0) { - tbuffer[code]='\0'; - code =parseBuf(tbuffer, name, passwd, cell, type); - if (code) { - fprintf(stderr, "weblog: parseBuf FAILED\n"); - WEBLOGEXIT(PARSEERROR); - } } - else { + + while (!shutdown) { + gotToken = 0; + code = readFromClient(tbuffer); + if (code > 0) { + tbuffer[code] = '\0'; + code = parseBuf(tbuffer, name, passwd, cell, type); + if (code) { + fprintf(stderr, "weblog: parseBuf FAILED\n"); + WEBLOGEXIT(PARSEERROR); + } + } else { #ifdef DEBUG - fprintf(stderr, "%s: readFromClient FAILED:%d...exiting\n",rn,code); + fprintf(stderr, "%s: readFromClient FAILED:%d...exiting\n", rn, + code); #endif - WEBLOGEXIT(PIPEREADERROR); - } + WEBLOGEXIT(PIPEREADERROR); + } - if (strcasecmp(type, "AFS") == 0) { - authtype=1; - } + if (strcasecmp(type, "AFS") == 0) { + authtype = 1; + } #ifdef ENABLE_DCE_DLOG - else if (strcasecmp(type, "AFS-DFS")==0) { - authtype=2; - } + else if (strcasecmp(type, "AFS-DFS") == 0) { + authtype = 2; + } #endif /* ENABLE_DCE_DLOG */ - else { - authtype=0; - } + else { + authtype = 0; + } - if(!authtype) { - reason=(char *)malloc(sizeof(tbuffer)); - sprintf(reason, "weblog: Unknown Authentication type:%s. AFS-DFS login " - "may not be enabled - check compile flags for ENABLE_DCE_DLOG", type); - goto reply_failure; - } + if (!authtype) { + reason = (char *)malloc(sizeof(tbuffer)); + sprintf(reason, + "weblog: Unknown Authentication type:%s. AFS-DFS login " + "may not be enabled - check compile flags for ENABLE_DCE_DLOG", + type); + goto reply_failure; + } - memset((void *)&tbuffer, 0, sizeof(tbuffer)); + memset((void *)&tbuffer, 0, sizeof(tbuffer)); - /* look up local cache */ - weblog_login_checksum(name, cell, passwd, cksum); - code = weblog_login_lookup(name, cell, cksum, &tbuffer[0]); + /* look up local cache */ + weblog_login_checksum(name, cell, passwd, cksum); + code = weblog_login_lookup(name, cell, cksum, &tbuffer[0]); - if (!code) { /* local cache lookup failed */ - /* authenticate user */ + if (!code) { /* local cache lookup failed */ + /* authenticate user */ #ifdef DEBUG - fprintf(stderr, "WEBLOG GROUPCHECK BEFORE KA_AUTH\n"); - printGroups(); + fprintf(stderr, "WEBLOG GROUPCHECK BEFORE KA_AUTH\n"); + printGroups(); #endif - - if (authtype==1) { - code=ka_UserAuthenticateGeneral - ( - KA_USERAUTH_VERSION+0, name, NULL, cell, - passwd, lifetime, &password_expires,0,&reason - ); - } + + if (authtype == 1) { + code = + ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION + 0, name, + NULL, cell, passwd, lifetime, + &password_expires, 0, &reason); + } #ifdef ENABLE_DCE_DLOG - else if (authtype == 2) { - unlog(); - code=getDFScreds(name,cell,passwd, lifetime, &reason); - } + else if (authtype == 2) { + unlog(); + code = getDFScreds(name, cell, passwd, lifetime, &reason); + } #ifdef DEBUG_DCE - printf("Code:%d\n",code); - if (code) { - if (reason) { - printf("FAILURE:Reason:%s\n",reason); - } - } + printf("Code:%d\n", code); + if (code) { + if (reason) { + printf("FAILURE:Reason:%s\n", reason); + } + } #endif #endif /* ENABLE_DCE_DLOG */ - if (code) { + if (code) { #ifdef DEBUG - if (!Silent) { - fprintf(stderr,"weblog:Unable to authenticate to AFS because " - "%s\n", reason); - } + if (!Silent) { + fprintf(stderr, + "weblog:Unable to authenticate to AFS because " + "%s\n", reason); + } #endif - goto reply_failure; - } - else { + goto reply_failure; + } else { #ifdef DEBUG - fprintf(stderr,"WEBLOG:After ka_UserAuthenticateGeneral GroupCheck\n"); - printGroups(); + fprintf(stderr, + "WEBLOG:After ka_UserAuthenticateGeneral GroupCheck\n"); + printGroups(); #endif - /* get just the ONE token for this PAG from cache manager */ - i=0; - memcpy((void *)&tbuffer[0], (void *)&i, sizeof(afs_int32)); - code = do_pioctl(tbuffer, sizeof(afs_int32), tbuffer, sizeof(tbuffer), - VIOCGETTOK, NULL,0); - if(code) { - fprintf(stderr, "weblog: failed to get token:%d\n", code); - strcpy(reason, "FAILED TO GET TOKEN FROM CACHE MANAGER\n"); - } - else { - gotToken = 1; + /* get just the ONE token for this PAG from cache manager */ + i = 0; + memcpy((void *)&tbuffer[0], (void *)&i, sizeof(afs_int32)); + code = + do_pioctl(tbuffer, sizeof(afs_int32), tbuffer, + sizeof(tbuffer), VIOCGETTOK, NULL, 0); + if (code) { + fprintf(stderr, "weblog: failed to get token:%d\n", code); + strcpy(reason, + "FAILED TO GET TOKEN FROM CACHE MANAGER\n"); + } else { + gotToken = 1; #ifdef DEBUG - hexDump(tbuffer, sizeof(tbuffer)); - parseToken(tbuffer); + hexDump(tbuffer, sizeof(tbuffer)); + parseToken(tbuffer); #endif /* _DEBUG */ - /* put the token in local cache with the expiration date/time */ - expires = getExpiration(tbuffer); - if (expires < 0 ) { + /* put the token in local cache with the expiration date/time */ + expires = getExpiration(tbuffer); + if (expires < 0) { #ifdef DEBUG - fprintf(stderr, "Error getting expiration time\n"); + fprintf(stderr, "Error getting expiration time\n"); #endif - } - else { - weblog_login_checksum(name, cell, passwd, cksum); - if (cacheExpiration == 0) { - weblog_login_store(name, cell, cksum, &tbuffer[0],sizeof(tbuffer),expires); - } - else { - testExpires = cacheExpiration+time(NULL); - weblog_login_store(name, cell, cksum, &tbuffer[0],sizeof(tbuffer), - MIN(expires,testExpires)); + } else { + weblog_login_checksum(name, cell, passwd, cksum); + if (cacheExpiration == 0) { + weblog_login_store(name, cell, cksum, &tbuffer[0], + sizeof(tbuffer), expires); + } else { + testExpires = cacheExpiration + time(NULL); + weblog_login_store(name, cell, cksum, &tbuffer[0], + sizeof(tbuffer), MIN(expires, + testExpires)); + } + } + } } - } - } - } - } - else { - /* cache lookup succesful */ + } else { + /* cache lookup succesful */ #ifdef DEBUG - fprintf(stderr, "WEBLOG: Cache lookup succesful\n"); + fprintf(stderr, "WEBLOG: Cache lookup succesful\n"); #endif - gotToken = 1; - } + gotToken = 1; + } - /* prepare the reply buffer with this token */ - if (!gotToken) { + /* prepare the reply buffer with this token */ + if (!gotToken) { -reply_failure: - /* respond with a reason why authentication failed */ - sprintf(tbuffer,"FAILURE:%s",reason); - } + reply_failure: + /* respond with a reason why authentication failed */ + sprintf(tbuffer, "FAILURE:%s", reason); + } - /* send response to client */ - code = sendToken(sizeof(tbuffer), tbuffer); - if (code) { + /* send response to client */ + code = sendToken(sizeof(tbuffer), tbuffer); + if (code) { #ifdef DEBUG - fprintf(stderr,"sendToken FAILED\n"); + fprintf(stderr, "sendToken FAILED\n"); #endif - WEBLOGEXIT(PIPESENDERROR); - } - /* unlog after every request unconditionally */ - if (unlog()) { + WEBLOGEXIT(PIPESENDERROR); + } + /* unlog after every request unconditionally */ + if (unlog()) { #ifdef DEBUG - fprintf(stderr, "WEBLOG: UNLOG FAILED\n"); + fprintf(stderr, "WEBLOG: UNLOG FAILED\n"); #endif - } - } /* end - while */ - return 0; + } + } /* end - while */ + return 0; } diff --git a/src/afsweb/weblog_errors.h b/src/afsweb/weblog_errors.h index 1d5d4d706..07cc402c4 100644 --- a/src/afsweb/weblog_errors.h +++ b/src/afsweb/weblog_errors.h @@ -11,7 +11,7 @@ #define _WEBLOG_ERRORS_H_INCLUDED_ /* error code definitions */ -#define PIPEREAD 1 +#define PIPEREAD 1 #define PIPESEND 2 #define KA 3 #define PARSE 4 @@ -20,7 +20,7 @@ #define WEBLOGMINERROR ((10<<16)) #define PIPEREADERROR (WEBLOGMINERROR + PIPEREAD) -#define PIPESENDERROR (WEBLOGMINERROR + PIPESEND) +#define PIPESENDERROR (WEBLOGMINERROR + PIPESEND) #define KAERROR (WEBLOGMINERROR + KA) #define NULLARGSERROR (WEBLOGMINERROR + PARSE) #define PARSEERROR (WEBLOGMINERROR + NULLARGS) @@ -39,4 +39,3 @@ rx_Finalize(); \ (!code ? exit(0) : exit((code)-WEBLOGMINERROR)) #endif /* _WEBLOG_ERRORS_H_INCLUDED_ */ - diff --git a/src/audit/audit.c b/src/audit/audit.c index 7b5679874..b5e1084d7 100644 --- a/src/audit/audit.c +++ b/src/audit/audit.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -29,10 +30,10 @@ RCSID("$Header$"); #endif #include -char *bufferPtr; -int bufferLen; -int osi_audit_all = (-1); /* Not determined yet */ -int osi_echo_trail = (-1); +char *bufferPtr; +int bufferLen; +int osi_audit_all = (-1); /* Not determined yet */ +int osi_echo_trail = (-1); #ifdef AFS_AIX_ENV /** all these functions are only defined for AIX */ @@ -44,180 +45,186 @@ int osi_echo_trail = (-1); /* AIX requires a buffer filled with values to record with each audit event. * aixmakebuf creates that buffer from the variable list of values we are given. * ************************************************************************** */ -static aixmakebuf (audEvent, vaList) +static +aixmakebuf(audEvent, vaList) char *audEvent; char *vaList; { - int code; - int vaEntry; - int vaInt; - afs_int32 vaLong; - char *vaStr; - char *vaLst; - char hname[20]; - struct AFSFid *vaFid; - - vaEntry = va_arg(vaList, int); - while ( vaEntry != AUD_END ) - { - switch (vaEntry) - { - case AUD_STR : /* String */ - vaStr = (char *) va_arg(vaList, int); - if ( vaStr ) - { - strcpy (bufferPtr, vaStr); - bufferPtr += strlen(vaStr) + 1; - } - else - { - strcpy (bufferPtr, ""); - bufferPtr++; - } - break; - case AUD_INT : /* Integer */ - vaInt = va_arg(vaList, int); - *(int *)bufferPtr = vaInt; - bufferPtr += sizeof(vaInt); - break; - case AUD_DATE : /* Date */ - case AUD_HOST : /* Host ID */ - case AUD_LONG : /* long */ - vaLong = va_arg(vaList, afs_int32); - *(afs_int32 *)bufferPtr = vaLong; - bufferPtr += sizeof(vaLong); - break; - case AUD_LST : /* Ptr to another list */ - vaLst = (char *) va_arg(vaList, int); - aixmakebuf(audEvent, vaLst); - break; - case AUD_FID : /* AFSFid - contains 3 entries */ - vaFid = (struct AFSFid *) va_arg(vaList, int); - if (vaFid) { - memcpy(bufferPtr, vaFid, sizeof(struct AFSFid)); - } - else { - memset(bufferPtr, 0, sizeof(struct AFSFid)); - } - bufferPtr += sizeof(struct AFSFid); - break; - - /* Whole array of fids-- don't know how to handle variable length audit - * data with AIX audit package, so for now we just store the first fid. - * Better one than none. */ - case AUD_FIDS : - { - struct AFSCBFids *Fids; - - Fids = (struct AFSCBFids *) va_arg(vaList, int); - if (Fids && Fids->AFSCBFids_len) { - *((u_int *)bufferPtr) = Fids->AFSCBFids_len; - bufferPtr += sizeof(u_int); - memcpy(bufferPtr, Fids->AFSCBFids_val, sizeof(struct AFSFid)); - } - else { - struct AFSFid dummy; - *((u_int *)bufferPtr) = 0; - bufferPtr += sizeof(u_int); - memset(bufferPtr, 0, sizeof(struct AFSFid)); - } - bufferPtr += sizeof(struct AFSFid); - break; - } - default: + int code; + int vaEntry; + int vaInt; + afs_int32 vaLong; + char *vaStr; + char *vaLst; + char hname[20]; + struct AFSFid *vaFid; + + vaEntry = va_arg(vaList, int); + while (vaEntry != AUD_END) { + switch (vaEntry) { + case AUD_STR: /* String */ + vaStr = (char *)va_arg(vaList, int); + if (vaStr) { + strcpy(bufferPtr, vaStr); + bufferPtr += strlen(vaStr) + 1; + } else { + strcpy(bufferPtr, ""); + bufferPtr++; + } + break; + case AUD_INT: /* Integer */ + vaInt = va_arg(vaList, int); + *(int *)bufferPtr = vaInt; + bufferPtr += sizeof(vaInt); + break; + case AUD_DATE: /* Date */ + case AUD_HOST: /* Host ID */ + case AUD_LONG: /* long */ + vaLong = va_arg(vaList, afs_int32); + *(afs_int32 *) bufferPtr = vaLong; + bufferPtr += sizeof(vaLong); + break; + case AUD_LST: /* Ptr to another list */ + vaLst = (char *)va_arg(vaList, int); + aixmakebuf(audEvent, vaLst); + break; + case AUD_FID: /* AFSFid - contains 3 entries */ + vaFid = (struct AFSFid *)va_arg(vaList, int); + if (vaFid) { + memcpy(bufferPtr, vaFid, sizeof(struct AFSFid)); + } else { + memset(bufferPtr, 0, sizeof(struct AFSFid)); + } + bufferPtr += sizeof(struct AFSFid); + break; + + /* Whole array of fids-- don't know how to handle variable length audit + * data with AIX audit package, so for now we just store the first fid. + * Better one than none. */ + case AUD_FIDS: + { + struct AFSCBFids *Fids; + + Fids = (struct AFSCBFids *)va_arg(vaList, int); + if (Fids && Fids->AFSCBFids_len) { + *((u_int *) bufferPtr) = Fids->AFSCBFids_len; + bufferPtr += sizeof(u_int); + memcpy(bufferPtr, Fids->AFSCBFids_val, + sizeof(struct AFSFid)); + } else { + struct AFSFid dummy; + *((u_int *) bufferPtr) = 0; + bufferPtr += sizeof(u_int); + memset(bufferPtr, 0, sizeof(struct AFSFid)); + } + bufferPtr += sizeof(struct AFSFid); + break; + } + default: #ifdef AFS_AIX32_ENV - code = auditlog("AFS_Aud_EINVAL", (-1), audEvent, (strlen(audEvent)+1)); + code = + auditlog("AFS_Aud_EINVAL", (-1), audEvent, + (strlen(audEvent) + 1)); #endif - return; - break; - } /* end switch */ + return; + break; + } /* end switch */ - vaEntry = va_arg(vaList, int); - } /* end while */ + vaEntry = va_arg(vaList, int); + } /* end while */ } -static printbuf (audEvent, errCode, vaList) +static +printbuf(audEvent, errCode, vaList) char *audEvent; afs_int32 errCode; char *vaList; { - int vaEntry; - int vaInt; - afs_int32 vaLong; - char *vaStr; - char *vaLst; - char hname[20]; - struct AFSFid *vaFid; - struct AFSCBFids *vaFids; - - if ( osi_echo_trail < 0 ) osi_audit_check(); - if ( ! osi_echo_trail ) return; - - if ( strcmp(audEvent,"VALST") != 0 ) - printf ("%s %d ", audEvent, errCode); - - vaEntry = va_arg(vaList, int); - while ( vaEntry != AUD_END ) - { - switch (vaEntry) - { - case AUD_STR : /* String */ - vaStr = (char *) va_arg(vaList, int); - if ( vaStr ) printf("%s ", vaStr); - else printf("", vaStr); - break; - case AUD_INT : /* Integer */ - vaInt = va_arg(vaList, int); - printf("%d ", vaInt); - break; - case AUD_DATE : /* Date */ - case AUD_HOST : /* Host ID */ - vaLong = va_arg(vaList, afs_int32); - printf("%u ", vaLong); - break; - case AUD_LONG : /* afs_int32 */ - vaLong = va_arg(vaList, afs_int32); - printf("%d ", vaLong); - break; - case AUD_LST : /* Ptr to another list */ - vaLst = (char *) va_arg(vaList, int); - printbuf("VALST", 0, vaLst); - break; - case AUD_FID : /* AFSFid - contains 3 entries */ - vaFid = (struct AFSFid *) va_arg(vaList, int); - if (vaFid) printf ("%u:%u:%u ", vaFid->Volume, vaFid->Vnode, vaFid->Unique); - else printf ("%u:%u:%u ", 0, 0, 0); - break; - case AUD_FIDS : /* array of Fids */ - vaFids = (struct AFSCBFids *) va_arg(vaList, int); - vaFid = NULL; - - if (vaFids) - vaFid = vaFids->AFSCBFids_val; - if (vaFid) - printf ("%u %u:%u:%u ", vaFids->AFSCBFids_len, vaFid->Volume, - vaFid->Vnode, vaFid->Unique); - else printf ("0 0:0:0 "); - break; - default: - printf ("--badval-- "); - break; - } /* end switch */ - vaEntry = va_arg(vaList, int); - } /* end while */ + int vaEntry; + int vaInt; + afs_int32 vaLong; + char *vaStr; + char *vaLst; + char hname[20]; + struct AFSFid *vaFid; + struct AFSCBFids *vaFids; + + if (osi_echo_trail < 0) + osi_audit_check(); + if (!osi_echo_trail) + return; - if ( strcmp(audEvent,"VALST") != 0 ) - printf ("\n"); + if (strcmp(audEvent, "VALST") != 0) + printf("%s %d ", audEvent, errCode); + + vaEntry = va_arg(vaList, int); + while (vaEntry != AUD_END) { + switch (vaEntry) { + case AUD_STR: /* String */ + vaStr = (char *)va_arg(vaList, int); + if (vaStr) + printf("%s ", vaStr); + else + printf("", vaStr); + break; + case AUD_INT: /* Integer */ + vaInt = va_arg(vaList, int); + printf("%d ", vaInt); + break; + case AUD_DATE: /* Date */ + case AUD_HOST: /* Host ID */ + vaLong = va_arg(vaList, afs_int32); + printf("%u ", vaLong); + break; + case AUD_LONG: /* afs_int32 */ + vaLong = va_arg(vaList, afs_int32); + printf("%d ", vaLong); + break; + case AUD_LST: /* Ptr to another list */ + vaLst = (char *)va_arg(vaList, int); + printbuf("VALST", 0, vaLst); + break; + case AUD_FID: /* AFSFid - contains 3 entries */ + vaFid = (struct AFSFid *)va_arg(vaList, int); + if (vaFid) + printf("%u:%u:%u ", vaFid->Volume, vaFid->Vnode, + vaFid->Unique); + else + printf("%u:%u:%u ", 0, 0, 0); + break; + case AUD_FIDS: /* array of Fids */ + vaFids = (struct AFSCBFids *)va_arg(vaList, int); + vaFid = NULL; + + if (vaFids) + vaFid = vaFids->AFSCBFids_val; + if (vaFid) + printf("%u %u:%u:%u ", vaFids->AFSCBFids_len, vaFid->Volume, + vaFid->Vnode, vaFid->Unique); + else + printf("0 0:0:0 "); + break; + default: + printf("--badval-- "); + break; + } /* end switch */ + vaEntry = va_arg(vaList, int); + } /* end while */ + + if (strcmp(audEvent, "VALST") != 0) + printf("\n"); } #else -static aixmakebuf (audEvent, vaList) +static +aixmakebuf(audEvent, vaList) char *audEvent; va_list vaList; { return; } -static printbuf (audEvent, errCode, vaList) +static +printbuf(audEvent, errCode, vaList) char *audEvent; long errCode; va_list vaList; @@ -231,79 +238,80 @@ static printbuf (audEvent, errCode, vaList) /* ************************************************************************** */ /* The routine that acually does the audit call. * ************************************************************************** */ -int osi_audit (char *audEvent, /* Event name (15 chars or less) */ - afs_int32 errCode, /* The error code */ - ...) +int +osi_audit(char *audEvent, /* Event name (15 chars or less) */ + afs_int32 errCode, /* The error code */ + ...) { #ifdef AFS_AIX32_ENV - afs_int32 code; - afs_int32 err; - int result; + afs_int32 code; + afs_int32 err; + int result; - va_list vaList; - static struct Lock audbuflock = {0,0,0,0, + va_list vaList; + static struct Lock audbuflock = { 0, 0, 0, 0, #ifdef AFS_PTHREAD_ENV - PTHREAD_MUTEX_INITIALIZER, - PTHREAD_COND_INITIALIZER, - PTHREAD_COND_INITIALIZER + PTHREAD_MUTEX_INITIALIZER, + PTHREAD_COND_INITIALIZER, + PTHREAD_COND_INITIALIZER #endif /* AFS_PTHREAD_ENV */ - }; - static char BUFFER[32768]; - - if ( osi_audit_all < 0 ) osi_audit_check(); - if ( ! osi_audit_all ) return; - - switch (errCode) - { - case 0 : - result = AUDIT_OK; - break; - case KANOAUTH : /* kautils.h */ - case RXKADNOAUTH : /* rxkad.h */ - result = AUDIT_FAIL_AUTH; - break; - case EPERM : /* errno.h */ - case EACCES : /* errno.h */ - case PRPERM : /* pterror.h */ - result = AUDIT_FAIL_ACCESS; - break; - case VL_PERM : /* vlserver.h */ - case BUDB_NOTPERMITTED : /* budb_errs.h */ + }; + static char BUFFER[32768]; + + if (osi_audit_all < 0) + osi_audit_check(); + if (!osi_audit_all) + return; + + switch (errCode) { + case 0: + result = AUDIT_OK; + break; + case KANOAUTH: /* kautils.h */ + case RXKADNOAUTH: /* rxkad.h */ + result = AUDIT_FAIL_AUTH; + break; + case EPERM: /* errno.h */ + case EACCES: /* errno.h */ + case PRPERM: /* pterror.h */ + result = AUDIT_FAIL_ACCESS; + break; + case VL_PERM: /* vlserver.h */ + case BUDB_NOTPERMITTED: /* budb_errs.h */ /* case KRB_RD_AP_UNAUTHOR : */ - case BZACCESS : /* bnode.h */ - case VOLSERBAD_ACCESS : /* volser.h */ - result = AUDIT_FAIL_PRIV; - break; + case BZACCESS: /* bnode.h */ + case VOLSERBAD_ACCESS: /* volser.h */ + result = AUDIT_FAIL_PRIV; + break; default: - result = AUDIT_FAIL; - break; - } + result = AUDIT_FAIL; + break; + } - ObtainWriteLock(&audbuflock); - bufferPtr = BUFFER; + ObtainWriteLock(&audbuflock); + bufferPtr = BUFFER; - /* Put the error code into the buffer list */ - *(int *)bufferPtr = errCode; - bufferPtr += sizeof(errCode); + /* Put the error code into the buffer list */ + *(int *)bufferPtr = errCode; + bufferPtr += sizeof(errCode); - va_start(vaList, errCode); - aixmakebuf(audEvent, vaList); + va_start(vaList, errCode); + aixmakebuf(audEvent, vaList); - va_start(vaList, errCode); - printbuf(audEvent, errCode, vaList); - - bufferLen = (int)((afs_int32)bufferPtr - (afs_int32)&BUFFER[0]); - code = auditlog (audEvent, result, BUFFER, bufferLen); + va_start(vaList, errCode); + printbuf(audEvent, errCode, vaList); + + bufferLen = (int)((afs_int32) bufferPtr - (afs_int32) & BUFFER[0]); + code = auditlog(audEvent, result, BUFFER, bufferLen); #ifdef notdef - if (code) - { - err = errno; - code = auditlog ("AFS_Aud_Fail", result, &err, sizeof(err)); - if (code) - printf("Error while writing audit entry: %d.\n", errno); - } + if (code) { + err = errno; + code = auditlog("AFS_Aud_Fail", result, &err, sizeof(err)); + if (code) + printf("Error while writing audit entry: %d.\n", errno); + } #endif /* notdef */ - ReleaseWriteLock(&audbuflock); + ReleaseWriteLock(&audbuflock); #endif } @@ -311,73 +319,65 @@ int osi_audit (char *audEvent, /* Event name (15 chars or less) */ /* Given a RPC call structure, this routine extracts the name and host id from the * call and includes it within the audit information. * ************************************************************************** */ -int osi_auditU (struct rx_call *call, - char *audEvent, - int errCode, - ...) +int +osi_auditU(struct rx_call *call, char *audEvent, int errCode, ...) { - struct rx_connection *conn; - struct rx_peer *peer; - afs_int32 secClass; - afs_int32 code; - char afsName[MAXKTCNAMELEN]; - afs_int32 hostId; - va_list vaList; - - - if ( osi_audit_all < 0 ) osi_audit_check(); - if ( !osi_audit_all ) return; - - strcpy (afsName, "--Unknown--"); - hostId = 0; - - if ( call ) - { - conn = rx_ConnectionOf(call); /* call -> conn) */ - if (conn) - { - secClass = rx_SecurityClassOf(conn); /* conn -> securityIndex */ - if (secClass == 0) /* unauthenticated */ - { - osi_audit ("AFS_Aud_Unauth", (-1), AUD_STR, audEvent, AUD_END); - strcpy (afsName, "--UnAuth--"); - } - else if (secClass == 2) /* authenticated */ - { - code = rxkad_GetServerInfo(conn, NULL, NULL, afsName, - NULL, NULL, NULL); - if (code) - { - osi_audit ("AFS_Aud_NoAFSId", (-1), AUD_STR, audEvent, AUD_END); - strcpy (afsName, "--NoName--"); + struct rx_connection *conn; + struct rx_peer *peer; + afs_int32 secClass; + afs_int32 code; + char afsName[MAXKTCNAMELEN]; + afs_int32 hostId; + va_list vaList; + + + if (osi_audit_all < 0) + osi_audit_check(); + if (!osi_audit_all) + return; + + strcpy(afsName, "--Unknown--"); + hostId = 0; + + if (call) { + conn = rx_ConnectionOf(call); /* call -> conn) */ + if (conn) { + secClass = rx_SecurityClassOf(conn); /* conn -> securityIndex */ + if (secClass == 0) { /* unauthenticated */ + osi_audit("AFS_Aud_Unauth", (-1), AUD_STR, audEvent, AUD_END); + strcpy(afsName, "--UnAuth--"); + } else if (secClass == 2) { /* authenticated */ + code = + rxkad_GetServerInfo(conn, NULL, NULL, afsName, NULL, NULL, + NULL); + if (code) { + osi_audit("AFS_Aud_NoAFSId", (-1), AUD_STR, audEvent, + AUD_END); + strcpy(afsName, "--NoName--"); + } + } else { /* Unauthenticated & unknown */ + + osi_audit("AFS_Aud_UnknSec", (-1), AUD_STR, audEvent, + AUD_END); + } + + peer = rx_PeerOf(conn); /* conn -> peer */ + if (peer) + hostId = rx_HostOf(peer); /* peer -> host */ + else + osi_audit("AFS_Aud_NoHost", (-1), AUD_STR, audEvent, AUD_END); + } else { /* null conn */ + + osi_audit("AFS_Aud_NoConn", (-1), AUD_STR, audEvent, AUD_END); } - } - else /* Unauthenticated & unknown */ - { - osi_audit ("AFS_Aud_UnknSec", (-1), AUD_STR, audEvent, AUD_END); - } - - peer = rx_PeerOf(conn); /* conn -> peer */ - if ( peer ) - hostId = rx_HostOf(peer); /* peer -> host */ - else - osi_audit ("AFS_Aud_NoHost", (-1), AUD_STR, audEvent, AUD_END); - } - else /* null conn */ - { - osi_audit ("AFS_Aud_NoConn", (-1), AUD_STR, audEvent, AUD_END); + } else { /* null call */ + + osi_audit("AFS_Aud_NoCall", (-1), AUD_STR, audEvent, AUD_END); } - } - else /* null call */ - { - osi_audit ("AFS_Aud_NoCall", (-1), AUD_STR, audEvent, AUD_END); - } - - va_start(vaList, errCode); - osi_audit (audEvent, errCode, AUD_STR, afsName, - AUD_HOST, hostId, - AUD_LST, vaList, - AUD_END); + + va_start(vaList, errCode); + osi_audit(audEvent, errCode, AUD_STR, afsName, AUD_HOST, hostId, AUD_LST, + vaList, AUD_END); } /* ************************************************************************** */ @@ -386,47 +386,53 @@ int osi_auditU (struct rx_call *call, * enabled. * ************************************************************************** */ -int osi_audit_check () +int +osi_audit_check() { - FILE *fds; - int onoff; - char event[257]; - - osi_audit_all = 1; /* say we made check (>= 0) */ - /* and assume audit all events (for now) */ - onoff = 0; /* assume we will turn auditing off */ - osi_echo_trail = 0; /* assume no echoing */ - - fds = fopen(AFSDIR_SERVER_AUDIT_FILEPATH, "r"); - if (fds) - { - while ( fscanf(fds, "%256s", event) > 0) - { - if ( strcmp(event,"AFS_AUDIT_AllEvents") == 0 ) - onoff = 1; - - if ( strcmp(event,"Echo_Trail") == 0 ) - osi_echo_trail = 1; - } - fclose(fds); - } - - /* Audit this event all of the time */ - if (onoff) osi_audit("AFS_Aud_On", 0, AUD_END); - else osi_audit("AFS_Aud_Off", 0, AUD_END); - - /* Now set whether we audit all events from here on out */ - osi_audit_all = onoff; + FILE *fds; + int onoff; + char event[257]; + + osi_audit_all = 1; /* say we made check (>= 0) */ + /* and assume audit all events (for now) */ + onoff = 0; /* assume we will turn auditing off */ + osi_echo_trail = 0; /* assume no echoing */ + + fds = fopen(AFSDIR_SERVER_AUDIT_FILEPATH, "r"); + if (fds) { + while (fscanf(fds, "%256s", event) > 0) { + if (strcmp(event, "AFS_AUDIT_AllEvents") == 0) + onoff = 1; + + if (strcmp(event, "Echo_Trail") == 0) + osi_echo_trail = 1; + } + fclose(fds); + } + + /* Audit this event all of the time */ + if (onoff) + osi_audit("AFS_Aud_On", 0, AUD_END); + else + osi_audit("AFS_Aud_Off", 0, AUD_END); + + /* Now set whether we audit all events from here on out */ + osi_audit_all = onoff; } #else /* ! AFS_AIX_ENV */ -int osi_audit (char *audEvent, afs_int32 errCode, ...) -{ return 0; } +int +osi_audit(char *audEvent, afs_int32 errCode, ...) +{ + return 0; +} -int osi_auditU (struct rx_call *call, char *audEvent, int errCode, ...) -{ return 0; } +int +osi_auditU(struct rx_call *call, char *audEvent, int errCode, ...) +{ + return 0; +} #endif - diff --git a/src/audit/audit.h b/src/audit/audit.h index fe6bb2f24..664b62884 100644 --- a/src/audit/audit.h +++ b/src/audit/audit.h @@ -7,19 +7,19 @@ * directory or online at http://www.openafs.org/dl/license10.html */ -#define AUD_END 0 /* End of veriable list */ -#define AUD_STR 1 /* String in variable list */ -#define AUD_INT 2 /* int in variable list */ -#define AUD_LST 3 /* Variable list in a variable list */ -#define AUD_HOST 4 /* A host # to be changed to string */ -#define AUD_LONG 5 /* long in variable list */ -#define AUD_DATE 6 /* date (unsigned long) */ -#define AUD_FID 7 /* File ID */ -#define AUD_FIDS 8 /* array of Fids */ +#define AUD_END 0 /* End of veriable list */ +#define AUD_STR 1 /* String in variable list */ +#define AUD_INT 2 /* int in variable list */ +#define AUD_LST 3 /* Variable list in a variable list */ +#define AUD_HOST 4 /* A host # to be changed to string */ +#define AUD_LONG 5 /* long in variable list */ +#define AUD_DATE 6 /* date (unsigned long) */ +#define AUD_FID 7 /* File ID */ +#define AUD_FIDS 8 /* array of Fids */ /* next 3 lines on behalf of MR-AFS */ -#define AUD_RESID 20 /* resid in variable list */ -#define AUD_RSSIZERANGE 21 /* rssizerange in variable list */ -#define AUD_LOOKUPINFO 22 /* LookupInfo in variable list */ +#define AUD_RESID 20 /* resid in variable list */ +#define AUD_RSSIZERANGE 21 /* rssizerange in variable list */ +#define AUD_LOOKUPINFO 22 /* LookupInfo in variable list */ /* * Note: the master definitions of these error codes come from *.et @@ -27,13 +27,13 @@ * simple way to avoid circular dependence problems in the build. */ -#define KANOAUTH (180488L) /* kauth/kaerrors.et */ -#define RXKADNOAUTH (19270405L) /* rxkad/rxkad_errs.et */ -#define PRPERM (267269L) /* ptserver/pterror.et */ -#define VL_PERM (363546L) /* vlserver/vl_errors.et */ -#define BUDB_NOTPERMITTED (156303880L) /* budb/budb_errs.et */ -#define BZACCESS (39430L) /* bozo/boserr.et */ -#define VOLSERBAD_ACCESS (1492325127L) /* volser/volerr.et */ +#define KANOAUTH (180488L) /* kauth/kaerrors.et */ +#define RXKADNOAUTH (19270405L) /* rxkad/rxkad_errs.et */ +#define PRPERM (267269L) /* ptserver/pterror.et */ +#define VL_PERM (363546L) /* vlserver/vl_errors.et */ +#define BUDB_NOTPERMITTED (156303880L) /* budb/budb_errs.et */ +#define BZACCESS (39430L) /* bozo/boserr.et */ +#define VOLSERBAD_ACCESS (1492325127L) /* volser/volerr.et */ #define VS_StartEvent "AFS_VS_Start" @@ -281,6 +281,5 @@ /* prototypes for audit functions */ -int osi_audit (char *audEvent, afs_int32 errCode, ...); -int osi_auditU (struct rx_call *call, char *audEvent, int errCode, ...); - +int osi_audit(char *audEvent, afs_int32 errCode, ...); +int osi_auditU(struct rx_call *call, char *audEvent, int errCode, ...); diff --git a/src/auth/auth.p.h b/src/auth/auth.p.h index 96a10f22a..0a9d93257 100644 --- a/src/auth/auth.p.h +++ b/src/auth/auth.p.h @@ -10,7 +10,7 @@ #ifndef __AUTH_AFS_INCL_ #define __AUTH_AFS_INCL_ 1 -#include /* to get ticket parameters/contents */ +#include /* to get ticket parameters/contents */ /* super-user pincipal used by servers when talking to other servers */ #define AUTH_SUPERUSER "afs" @@ -19,35 +19,22 @@ struct ktc_token { afs_int32 startTime; afs_int32 endTime; struct ktc_encryptionKey sessionKey; - short kvno; /* XXX UNALIGNED */ + short kvno; /* XXX UNALIGNED */ int ticketLen; char ticket[MAXKTCTICKETLEN]; }; #ifdef AFS_NT40_ENV -extern int ktc_SetToken( - struct ktc_principal *server, - struct ktc_token *token, - struct ktc_principal *client, - afs_int32 flags -); - -extern int ktc_GetToken( - struct ktc_principal *server, - struct ktc_token *token, - int tokenLen, - struct ktc_principal *client -); - -extern int ktc_ListTokens( - int cellNum, - int *cellNumP, - struct ktc_principal *serverName -); - -extern int ktc_ForgetToken( - struct ktc_principal *server -); +extern int ktc_SetToken(struct ktc_principal *server, struct ktc_token *token, + struct ktc_principal *client, afs_int32 flags); + +extern int ktc_GetToken(struct ktc_principal *server, struct ktc_token *token, + int tokenLen, struct ktc_principal *client); + +extern int ktc_ListTokens(int cellNum, int *cellNumP, + struct ktc_principal *serverName); + +extern int ktc_ForgetToken(struct ktc_principal *server); extern int ktc_ForgetAllTokens(void); diff --git a/src/auth/authcon.c b/src/auth/authcon.c index 2935863d1..029464730 100644 --- a/src/auth/authcon.c +++ b/src/auth/authcon.c @@ -14,7 +14,8 @@ #include #endif -RCSID("$Header$"); +RCSID + ("$Header$"); #if defined(UKERNEL) #include "afs/sysincludes.h" @@ -49,9 +50,11 @@ RCSID("$Header$"); #endif /* defined(UKERNEL) */ /* return a null security object if nothing else can be done */ -static afs_int32 QuickAuth(astr, aindex) -struct rx_securityClass **astr; -afs_int32 *aindex; { +static afs_int32 +QuickAuth(astr, aindex) + struct rx_securityClass **astr; + afs_int32 *aindex; +{ register struct rx_securityClass *tc; tc = rxnull_NewClientSecurityObject(); *astr = tc; @@ -61,61 +64,62 @@ afs_int32 *aindex; { #if !defined(UKERNEL) /* Return an appropriate security class and index */ -afs_int32 afsconf_ServerAuth(adir, astr, aindex) -register struct afsconf_dir *adir; -struct rx_securityClass **astr; -afs_int32 *aindex; { +afs_int32 +afsconf_ServerAuth(adir, astr, aindex) + register struct afsconf_dir *adir; + struct rx_securityClass **astr; + afs_int32 *aindex; +{ register struct rx_securityClass *tclass; - - LOCK_GLOBAL_MUTEX - tclass = (struct rx_securityClass *) + + LOCK_GLOBAL_MUTEX tclass = (struct rx_securityClass *) rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, NULL); if (tclass) { *astr = tclass; - *aindex = 2; /* kerberos security index */ - UNLOCK_GLOBAL_MUTEX - return 0; - } - else { - UNLOCK_GLOBAL_MUTEX - return 2; + *aindex = 2; /* kerberos security index */ + UNLOCK_GLOBAL_MUTEX return 0; + } else { + UNLOCK_GLOBAL_MUTEX return 2; } } #endif /* !defined(UKERNEL) */ -static afs_int32 GenericAuth(adir, astr, aindex, enclevel) -struct afsconf_dir *adir; -struct rx_securityClass **astr; -afs_int32 *aindex; -rxkad_level enclevel; { +static afs_int32 +GenericAuth(adir, astr, aindex, enclevel) + struct afsconf_dir *adir; + struct rx_securityClass **astr; + afs_int32 *aindex; + rxkad_level enclevel; +{ char tbuffer[256]; struct ktc_encryptionKey key, session; struct rx_securityClass *tclass; afs_int32 kvno; afs_int32 ticketLen; register afs_int32 code; - + /* first, find the right key and kvno to use */ code = afsconf_GetLatestKey(adir, &kvno, &key); if (code) { return QuickAuth(astr, aindex); } - + /* next create random session key, using key for seed to good random */ - des_init_random_number_generator (&key); - code = des_random_key (&session); + des_init_random_number_generator(&key); + code = des_random_key(&session); if (code) { return QuickAuth(astr, aindex); } - + /* now create the actual ticket */ ticketLen = sizeof(tbuffer); memset(tbuffer, '\0', sizeof(tbuffer)); - code = tkt_MakeTicket(tbuffer, &ticketLen, &key, AUTH_SUPERUSER, "", "", 0, - 0xffffffff, &session, 0, "afs", ""); + code = + tkt_MakeTicket(tbuffer, &ticketLen, &key, AUTH_SUPERUSER, "", "", 0, + 0xffffffff, &session, 0, "afs", ""); /* parms were buffer, ticketlen, key to seal ticket with, principal - name, instance and cell, start time, end time, session key to seal - in ticket, inet host, server name and server instance */ + * name, instance and cell, start time, end time, session key to seal + * in ticket, inet host, server name and server instance */ if (code) { return QuickAuth(astr, aindex); } @@ -125,40 +129,38 @@ rxkad_level enclevel; { * order when compiling the system from scratch (rx/rxkad.h isn't installed * yet). */ tclass = (struct rx_securityClass *) - rxkad_NewClientSecurityObject(enclevel, &session, kvno, - ticketLen, tbuffer); + rxkad_NewClientSecurityObject(enclevel, &session, kvno, ticketLen, + tbuffer); *astr = tclass; - *aindex = 2; /* kerberos security index */ + *aindex = 2; /* kerberos security index */ return 0; } /* build a fake ticket for 'afs' using keys from adir, returning an * appropriate security class and index */ -afs_int32 afsconf_ClientAuth(struct afsconf_dir *adir, - struct rx_securityClass **astr, afs_int32 *aindex) +afs_int32 +afsconf_ClientAuth(struct afsconf_dir * adir, struct rx_securityClass ** astr, + afs_int32 * aindex) { afs_int32 rc; - LOCK_GLOBAL_MUTEX - rc = GenericAuth(adir, astr, aindex, rxkad_clear); - UNLOCK_GLOBAL_MUTEX - return rc; + LOCK_GLOBAL_MUTEX rc = GenericAuth(adir, astr, aindex, rxkad_clear); + UNLOCK_GLOBAL_MUTEX return rc; } /* build a fake ticket for 'afs' using keys from adir, returning an * appropriate security class and index. This one, unlike the above, * tells rxkad to encrypt the data, too. */ -afs_int32 afsconf_ClientAuthSecure(adir, astr, aindex) -struct afsconf_dir *adir; -struct rx_securityClass **astr; -afs_int32 *aindex; { +afs_int32 +afsconf_ClientAuthSecure(adir, astr, aindex) + struct afsconf_dir *adir; + struct rx_securityClass **astr; + afs_int32 *aindex; +{ afs_int32 rc; - LOCK_GLOBAL_MUTEX - rc = GenericAuth(adir, astr, aindex, rxkad_crypt); - UNLOCK_GLOBAL_MUTEX - return rc; + LOCK_GLOBAL_MUTEX rc = GenericAuth(adir, astr, aindex, rxkad_crypt); + UNLOCK_GLOBAL_MUTEX return rc; } - diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c index 31a691023..e277325cb 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -61,20 +62,20 @@ RCSID("$Header$"); #include "cellconfig.h" #include "keys.h" -static struct afsconf_servPair serviceTable [] = { - { "afs", 7000, }, - { "afscb", 7001, }, - { "afsprot", 7002, }, - { "afsvldb", 7003, }, - { "afskauth", 7004, }, - { "afsvol", 7005, }, - { "afserror", 7006, }, - { "afsnanny", 7007, }, - { "afsupdate", 7008, }, - { "afsrmtsys", 7009, }, - { "afsres", 7010, }, /* residency database for MR-AFS */ - { "afsremio", 7011, }, /* remote I/O interface for MR-AFS */ - { 0, 0 } /* insert new services before this spot */ +static struct afsconf_servPair serviceTable[] = { + {"afs", 7000,}, + {"afscb", 7001,}, + {"afsprot", 7002,}, + {"afsvldb", 7003,}, + {"afskauth", 7004,}, + {"afsvol", 7005,}, + {"afserror", 7006,}, + {"afsnanny", 7007,}, + {"afsupdate", 7008,}, + {"afsrmtsys", 7009,}, + {"afsres", 7010,}, /* residency database for MR-AFS */ + {"afsremio", 7011,}, /* remote I/O interface for MR-AFS */ + {0, 0} /* insert new services before this spot */ }; /* Prototypes */ @@ -87,18 +88,18 @@ static int GetCellNT(struct afsconf_dir *adir); static int afsconf_Check(register struct afsconf_dir *adir); static int afsconf_Touch(register struct afsconf_dir *adir); static int GetCellUnix(struct afsconf_dir *adir); -static int afsconf_OpenInternal(register struct afsconf_dir *adir, - char *cell, char clones[]); +static int afsconf_OpenInternal(register struct afsconf_dir *adir, char *cell, + char clones[]); static int ParseHostLine(char *aline, register struct sockaddr_in *addr, - char *aname, char *aclone); + char *aname, char *aclone); static int ParseCellLine(register char *aline, register char *aname, - register char *alname); + register char *alname); static int afsconf_CloseInternal(register struct afsconf_dir *adir); static int afsconf_Reopen(register struct afsconf_dir *adir); static int SaveKeys(struct afsconf_dir *adir); #ifndef T_AFSDB -#define T_AFSDB 18 /* per RFC1183 section 1 */ +#define T_AFSDB 18 /* per RFC1183 section 1 */ #endif /* @@ -109,7 +110,8 @@ static int SaveKeys(struct afsconf_dir *adir); */ /* return port number in network byte order in the low 16 bits of a long; return -1 if not found */ -static afs_int32 afsconf_FindService(register const char *aname) +static afs_int32 +afsconf_FindService(register const char *aname) { /* lookup a service name */ struct servent *ts; @@ -122,17 +124,20 @@ static afs_int32 afsconf_FindService(register const char *aname) #endif if (ts) { /* we found it in /etc/services, so we use this value */ - return ts->s_port; /* already in network byte order */ + return ts->s_port; /* already in network byte order */ } /* not found in /etc/services, see if it is one of ours */ - for(tsp = serviceTable;; tsp++) { - if (tsp->name == NULL) return -1; - if (!strcmp(tsp->name, aname)) return htons(tsp->port); + for (tsp = serviceTable;; tsp++) { + if (tsp->name == NULL) + return -1; + if (!strcmp(tsp->name, aname)) + return htons(tsp->port); } } -static int TrimLine(char *abuffer) +static int +TrimLine(char *abuffer) { char tbuffer[256]; register char *tp; @@ -140,7 +145,8 @@ static int TrimLine(char *abuffer) tp = abuffer; while ((tc = *tp)) { - if (!isspace(tc)) break; + if (!isspace(tc)) + break; tp++; } strcpy(tbuffer, tp); @@ -153,7 +159,8 @@ static int TrimLine(char *abuffer) * IsClientConfigDirectory() -- determine if path matches well-known * client configuration directory. */ -static int IsClientConfigDirectory(const char *path) +static int +IsClientConfigDirectory(const char *path) { const char *cdir = AFSDIR_CLIENT_ETC_DIRPATH; int i; @@ -189,7 +196,8 @@ static int IsClientConfigDirectory(const char *path) #endif /* AFS_NT40_ENV */ -static int afsconf_Check(register struct afsconf_dir *adir) +static int +afsconf_Check(register struct afsconf_dir *adir) { char tbuffer[256]; struct stat tstat; @@ -198,11 +206,11 @@ static int afsconf_Check(register struct afsconf_dir *adir) #ifdef AFS_NT40_ENV /* NT client CellServDB has different file name than NT server or Unix */ if (IsClientConfigDirectory(adir->name)) { - strcompose(tbuffer, 256, - adir->name, "/", AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); + strcompose(tbuffer, 256, adir->name, "/", + AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); } else { - strcompose(tbuffer, 256, - adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL); + strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, + NULL); } #else strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL); @@ -221,24 +229,25 @@ static int afsconf_Check(register struct afsconf_dir *adir) } /* set modtime on file */ -static int afsconf_Touch(register struct afsconf_dir *adir) +static int +afsconf_Touch(register struct afsconf_dir *adir) { char tbuffer[256]; #ifndef AFS_NT40_ENV struct timeval tvp[2]; #endif - adir->timeRead = 0; /* just in case */ + adir->timeRead = 0; /* just in case */ #ifdef AFS_NT40_ENV /* NT client CellServDB has different file name than NT server or Unix */ if (IsClientConfigDirectory(adir->name)) { - strcompose(tbuffer, 256, - adir->name, "/", AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); + strcompose(tbuffer, 256, adir->name, "/", + AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); } else { - strcompose(tbuffer, 256, - adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL); + strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, + NULL); } return _utime(tbuffer, NULL); @@ -248,19 +257,20 @@ static int afsconf_Touch(register struct afsconf_dir *adir) gettimeofday(&tvp[0], NULL); tvp[1] = tvp[0]; return utimes(tbuffer, tvp); -#endif /* AFS_NT40_ENV */ +#endif /* AFS_NT40_ENV */ } -struct afsconf_dir *afsconf_Open(register const char *adir) +struct afsconf_dir * +afsconf_Open(register const char *adir) { register struct afsconf_dir *tdir; register afs_int32 code; LOCK_GLOBAL_MUTEX - /* zero structure and fill in name; rest is done by internal routine */ - tdir = (struct afsconf_dir *) malloc(sizeof(struct afsconf_dir)); + /* zero structure and fill in name; rest is done by internal routine */ + tdir = (struct afsconf_dir *)malloc(sizeof(struct afsconf_dir)); memset(tdir, 0, sizeof(struct afsconf_dir)); - tdir->name = (char *) malloc(strlen(adir)+1); + tdir->name = (char *)malloc(strlen(adir) + 1); strcpy(tdir->name, adir); code = afsconf_OpenInternal(tdir, 0, 0); @@ -280,8 +290,7 @@ struct afsconf_dir *afsconf_Open(register const char *adir) fp = fopen("/.AFSCONF", "r"); if (fp == 0) { free(tdir); - UNLOCK_GLOBAL_MUTEX - return (struct afsconf_dir *) 0; + UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0; } fgets(afs_confdir, 128, fp); fclose(fp); @@ -295,42 +304,39 @@ struct afsconf_dir *afsconf_Open(register const char *adir) fp = fopen("/.AFSCONF", "r"); if (fp == 0) { free(tdir); - UNLOCK_GLOBAL_MUTEX - return (struct afsconf_dir *) 0; + UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0; } fgets(afs_confdir, 128, fp); fclose(fp); } fgets(afs_confdir, 128, fp); - fclose(fp); + fclose(fp); } len = strlen(afs_confdir); if (len == 0) { free(tdir); - UNLOCK_GLOBAL_MUTEX - return (struct afsconf_dir *) 0; + UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0; } - if (afs_confdir[len-1] == '\n') { - afs_confdir[len-1] = 0; + if (afs_confdir[len - 1] == '\n') { + afs_confdir[len - 1] = 0; } afsconf_path = afs_confdir; } - tdir->name = (char *) malloc(strlen(afsconf_path)+1); + tdir->name = (char *)malloc(strlen(afsconf_path) + 1); strcpy(tdir->name, afsconf_path); code = afsconf_OpenInternal(tdir, 0, 0); if (code) { free(tdir->name); free(tdir); - UNLOCK_GLOBAL_MUTEX - return (struct afsconf_dir *) 0; + UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0; } } - UNLOCK_GLOBAL_MUTEX - return tdir; + UNLOCK_GLOBAL_MUTEX return tdir; } -static int GetCellUnix(struct afsconf_dir *adir) +static int +GetCellUnix(struct afsconf_dir *adir) { int rc; char tbuffer[256]; @@ -341,12 +347,11 @@ static int GetCellUnix(struct afsconf_dir *adir) if (tf) { rc = fscanf(tf, "%s", tbuffer); if (rc == 1) { - adir->cellName = (char *) malloc(strlen(tbuffer)+1); + adir->cellName = (char *)malloc(strlen(tbuffer) + 1); strcpy(adir->cellName, tbuffer); } fclose(tf); - } - else { + } else { return -1; } return 0; @@ -354,7 +359,8 @@ static int GetCellUnix(struct afsconf_dir *adir) #ifdef AFS_NT40_ENV -static int GetCellNT(struct afsconf_dir *adir) +static int +GetCellNT(struct afsconf_dir *adir) { if (IsClientConfigDirectory(adir->name)) { /* NT client config dir; ThisCell is in registry (no file). */ @@ -367,8 +373,9 @@ static int GetCellNT(struct afsconf_dir *adir) #endif /* AFS_NT40_ENV */ -static int afsconf_OpenInternal(register struct afsconf_dir *adir, - char *cell, char clones[]) +static int +afsconf_OpenInternal(register struct afsconf_dir *adir, char *cell, + char clones[]) { FILE *tf; register char *tp, *bp; @@ -386,7 +393,7 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, i = GetCellUnix(adir); #endif -#ifndef AFS_FREELANCE_CLIENT /* no local cell not fatal in freelance */ +#ifndef AFS_FREELANCE_CLIENT /* no local cell not fatal in freelance */ if (i) { return i; } @@ -401,16 +408,16 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, */ if (IsClientConfigDirectory(adir->name)) { /* NT client config dir */ - strcompose(tbuffer, 256, - adir->name, "/", AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); + strcompose(tbuffer, 256, adir->name, "/", + AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); } else { /* NT server config dir */ - strcompose(tbuffer, 256, - adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL); + strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, + NULL); } #else strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL); -#endif /* AFS_NT40_ENV */ +#endif /* AFS_NT40_ENV */ if (!stat(tbuffer, &tstat)) { adir->timeRead = tstat.st_mtime; @@ -425,9 +432,11 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, } while (1) { tp = fgets(tbuffer, sizeof(tbuffer), tf); - if (!tp) break; - TrimLine(tbuffer); /* remove white space */ - if (tbuffer[0] == 0 || tbuffer[0] == '\n') continue; /* empty line */ + if (!tp) + break; + TrimLine(tbuffer); /* remove white space */ + if (tbuffer[0] == 0 || tbuffer[0] == '\n') + continue; /* empty line */ if (tbuffer[0] == '>') { char linkedcell[MAXCELLCHARS]; /* start new cell item */ @@ -437,9 +446,11 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, adir->entries = curEntry; curEntry = 0; } - curEntry = (struct afsconf_entry *) malloc(sizeof(struct afsconf_entry)); + curEntry = + (struct afsconf_entry *)malloc(sizeof(struct afsconf_entry)); memset(curEntry, 0, sizeof(struct afsconf_entry)); - code = ParseCellLine(tbuffer, curEntry->cellInfo.name, linkedcell); + code = + ParseCellLine(tbuffer, curEntry->cellInfo.name, linkedcell); if (code) { afsconf_CloseInternal(adir); fclose(tf); @@ -447,11 +458,10 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, } if (linkedcell[0] != '\0') { curEntry->cellInfo.linkedCell = - (char *) malloc(strlen(linkedcell) + 1); + (char *)malloc(strlen(linkedcell) + 1); strcpy(curEntry->cellInfo.linkedCell, linkedcell); } - } - else { + } else { /* new host in the current cell */ if (!curEntry) { afsconf_CloseInternal(adir); @@ -459,17 +469,24 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, return -1; } i = curEntry->cellInfo.numServers; - if (cell && !strcmp(cell, curEntry->cellInfo.name)) - code = ParseHostLine(tbuffer, &curEntry->cellInfo.hostAddr[i], curEntry->cellInfo.hostName[i], &clones[i]); - else - code = ParseHostLine(tbuffer, &curEntry->cellInfo.hostAddr[i], curEntry->cellInfo.hostName[i], 0); + if (cell && !strcmp(cell, curEntry->cellInfo.name)) + code = + ParseHostLine(tbuffer, &curEntry->cellInfo.hostAddr[i], + curEntry->cellInfo.hostName[i], &clones[i]); + else + code = + ParseHostLine(tbuffer, &curEntry->cellInfo.hostAddr[i], + curEntry->cellInfo.hostName[i], 0); if (code) { if (code == AFSCONF_SYNTAX) { - for (bp=tbuffer; *bp != '\n'; bp++) { /* Take out the from the buffer */ - if (!*bp) break; + for (bp = tbuffer; *bp != '\n'; bp++) { /* Take out the from the buffer */ + if (!*bp) + break; } - *bp= '\0'; - fprintf(stderr, "Can't properly parse host line \"%s\" in configuration file %s\n", tbuffer, tbuf1); + *bp = '\0'; + fprintf(stderr, + "Can't properly parse host line \"%s\" in configuration file %s\n", + tbuffer, tbuf1); } free(curEntry); fclose(tf); @@ -479,7 +496,7 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, curEntry->cellInfo.numServers = ++i; } } - fclose(tf); /* close the file now */ + fclose(tf); /* close the file now */ /* end the last partially-completed cell */ if (curEntry) { @@ -495,23 +512,28 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, char *aliasPtr; tp = fgets(tbuffer, sizeof(tbuffer), tf); - if (!tp) break; - TrimLine(tbuffer); /* remove white space */ + if (!tp) + break; + TrimLine(tbuffer); /* remove white space */ - if (tbuffer[0] == '\0' || - tbuffer[0] == '\n' || - tbuffer[0] == '#') continue; /* empty line */ + if (tbuffer[0] == '\0' || tbuffer[0] == '\n' || tbuffer[0] == '#') + continue; /* empty line */ tp = tbuffer; - while (tp[0] != '\0' && tp[0] != ' ' && tp[0] != '\t') tp++; - if (tp[0] == '\0') continue; /* invalid line */ + while (tp[0] != '\0' && tp[0] != ' ' && tp[0] != '\t') + tp++; + if (tp[0] == '\0') + continue; /* invalid line */ - while (tp[0] != '\0' && (tp[0] == ' ' || tp[0] == '\t')) 0[tp++] = '\0'; - if (tp[0] == '\0') continue; /* invalid line */ + while (tp[0] != '\0' && (tp[0] == ' ' || tp[0] == '\t')) + 0[tp++] = '\0'; + if (tp[0] == '\0') + continue; /* invalid line */ aliasPtr = tp; - while (tp[0] != '\0' && tp[0] != ' ' && tp[0] != '\t' && - tp[0] != '\r' && tp[0] != '\n') tp++; + while (tp[0] != '\0' && tp[0] != ' ' && tp[0] != '\t' && tp[0] != '\r' + && tp[0] != '\n') + tp++; tp[0] = '\0'; curAlias = malloc(sizeof(*curAlias)); @@ -524,9 +546,10 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, adir->alias_entries = curAlias; } - if (tf != NULL) fclose(tf); + if (tf != NULL) + fclose(tf); /* now read the fs keys, if possible */ - adir->keystr = (struct afsconf_keys *) 0; + adir->keystr = (struct afsconf_keys *)0; afsconf_IntGetKeys(adir); return 0; @@ -537,27 +560,31 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, *"[128.2.1.3] #hostname" for clones * into the appropriate pieces. */ -static int ParseHostLine(char *aline, register struct sockaddr_in *addr, - char *aname, char *aclone) +static int +ParseHostLine(char *aline, register struct sockaddr_in *addr, char *aname, + char *aclone) { int c1, c2, c3, c4; register afs_int32 code; register char *tp; if (*aline == '[') { - if (aclone) *aclone = 1; - code = sscanf(aline, "[%d.%d.%d.%d] #%s", &c1, &c2, &c3, &c4, aname); + if (aclone) + *aclone = 1; + code = sscanf(aline, "[%d.%d.%d.%d] #%s", &c1, &c2, &c3, &c4, aname); } else { - if (aclone) *aclone = 0; - code = sscanf(aline, "%d.%d.%d.%d #%s", &c1, &c2, &c3, &c4, aname); + if (aclone) + *aclone = 0; + code = sscanf(aline, "%d.%d.%d.%d #%s", &c1, &c2, &c3, &c4, aname); } - if (code != 5) return AFSCONF_SYNTAX; + if (code != 5) + return AFSCONF_SYNTAX; addr->sin_family = AF_INET; addr->sin_port = 0; #ifdef STRUCT_SOCKADDR_HAS_SA_LEN addr->sin_len = sizeof(struct sockaddr_in); #endif - tp = (char *) &addr->sin_addr; + tp = (char *)&addr->sin_addr; *tp++ = c1; *tp++ = c2; *tp++ = c3; @@ -569,12 +596,14 @@ static int ParseHostLine(char *aline, register struct sockaddr_in *addr, * ">cellname [linkedcellname] [#comments]" * into the appropriate pieces. */ -static int ParseCellLine(register char *aline, register char *aname, - register char *alname) +static int +ParseCellLine(register char *aline, register char *aname, + register char *alname) { register int code; code = sscanf(aline, ">%s %s", aname, alname); - if (code == 1) *alname = '\0'; + if (code == 1) + *alname = '\0'; if (code == 2) { if (*alname == '#') { *alname = '\0'; @@ -584,60 +613,60 @@ static int ParseCellLine(register char *aline, register char *aname, } /* call aproc(entry, arock, adir) for all cells. Proc must return 0, or we'll stop early and return the code it returns */ -int afsconf_CellApply(struct afsconf_dir *adir, int (*aproc)(struct afsconf_cell *cell, - char *arock, struct afsconf_dir *dir), char *arock) +int +afsconf_CellApply(struct afsconf_dir *adir, + int (*aproc) (struct afsconf_cell * cell, char *arock, + struct afsconf_dir * dir), char *arock) { register struct afsconf_entry *tde; register afs_int32 code; - LOCK_GLOBAL_MUTEX - for(tde=adir->entries; tde; tde=tde->next) { - code = (*aproc)(&tde->cellInfo, arock, adir); + LOCK_GLOBAL_MUTEX for (tde = adir->entries; tde; tde = tde->next) { + code = (*aproc) (&tde->cellInfo, arock, adir); if (code) { - UNLOCK_GLOBAL_MUTEX - return code; + UNLOCK_GLOBAL_MUTEX return code; } } - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } /* call aproc(entry, arock, adir) for all cell aliases. * Proc must return 0, or we'll stop early and return the code it returns */ -int afsconf_CellAliasApply(struct afsconf_dir *adir, int (*aproc)( - struct afsconf_cellalias *alias, char *arock, struct afsconf_dir *dir), char *arock) +int +afsconf_CellAliasApply(struct afsconf_dir *adir, + int (*aproc) (struct afsconf_cellalias * alias, + char *arock, struct afsconf_dir * dir), + char *arock) { register struct afsconf_aliasentry *tde; register afs_int32 code; - LOCK_GLOBAL_MUTEX - for(tde=adir->alias_entries; tde; tde=tde->next) { - code = (*aproc)(&tde->aliasInfo, arock, adir); + LOCK_GLOBAL_MUTEX for (tde = adir->alias_entries; tde; tde = tde->next) { + code = (*aproc) (&tde->aliasInfo, arock, adir); if (code) { - UNLOCK_GLOBAL_MUTEX - return code; + UNLOCK_GLOBAL_MUTEX return code; } } - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } afs_int32 afsconf_SawCell = 0; -int afsconf_GetExtendedCellInfo(struct afsconf_dir *adir, - char *acellName, char *aservice, struct afsconf_cell *acellInfo, - char clones[]) +int +afsconf_GetExtendedCellInfo(struct afsconf_dir *adir, char *acellName, + char *aservice, struct afsconf_cell *acellInfo, + char clones[]) { afs_int32 code; char *cell; code = afsconf_GetCellInfo(adir, acellName, aservice, acellInfo); - if (code) - return code; + if (code) + return code; - if (acellName) - cell = acellName; + if (acellName) + cell = acellName; else - cell = (char *) &acellInfo->name; + cell = (char *)&acellInfo->name; code = afsconf_OpenInternal(adir, cell, clones); return code; @@ -645,8 +674,9 @@ int afsconf_GetExtendedCellInfo(struct afsconf_dir *adir, #ifdef AFS_AFSDB_ENV #if !defined(AFS_NT40_ENV) -int afsconf_GetAfsdbInfo(char *acellName, char *aservice, - struct afsconf_cell *acellInfo) +int +afsconf_GetAfsdbInfo(char *acellName, char *aservice, + struct afsconf_cell *acellInfo) { afs_int32 code; int tservice, i; @@ -662,12 +692,10 @@ int afsconf_GetAfsdbInfo(char *acellName, char *aservice, * replaced with a more fine-grained lock just for the resolver * operations. */ - LOCK_GLOBAL_MUTEX - len = res_search(acellName, C_IN, T_AFSDB, answer, sizeof(answer)); - UNLOCK_GLOBAL_MUTEX - - if (len < 0) - return AFSCONF_NOTFOUND; + LOCK_GLOBAL_MUTEX len = + res_search(acellName, C_IN, T_AFSDB, answer, sizeof(answer)); + UNLOCK_GLOBAL_MUTEX if (len < 0) + return AFSCONF_NOTFOUND; p = answer + sizeof(HEADER); /* Skip header */ code = dn_expand(answer, answer + len, p, host, sizeof(host)); @@ -683,13 +711,13 @@ int afsconf_GetAfsdbInfo(char *acellName, char *aservice, if (code < 0) return AFSCONF_NOTFOUND; - p += code; /* Skip the name */ + p += code; /* Skip the name */ type = (p[0] << 8) | p[1]; - p += 4; /* Skip type and class */ + p += 4; /* Skip type and class */ ttl = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; - p += 4; /* Skip the TTL */ + p += 4; /* Skip the TTL */ size = (p[0] << 8) | p[1]; - p += 2; /* Skip the size */ + p += 2; /* Skip the size */ if (type == T_AFSDB) { struct hostent *he; @@ -705,12 +733,11 @@ int afsconf_GetAfsdbInfo(char *acellName, char *aservice, strcpy(realCellName, host); } - code = dn_expand(answer, answer+len, p+2, host, sizeof(host)); + code = dn_expand(answer, answer + len, p + 2, host, sizeof(host)); if (code < 0) return AFSCONF_NOTFOUND; - if ((afsdb_type == 1) && - (server_num < MAXHOSTSPERCELL) && + if ((afsdb_type == 1) && (server_num < MAXHOSTSPERCELL) && /* Do we want to get TTL data for the A record as well? */ (he = gethostbyname(host))) { afs_int32 ipaddr; @@ -720,18 +747,19 @@ int afsconf_GetAfsdbInfo(char *acellName, char *aservice, sizeof(acellInfo->hostName[server_num])); server_num++; - if (!minttl || ttl < minttl) minttl = ttl; + if (!minttl || ttl < minttl) + minttl = ttl; } } p += size; } - if (server_num == 0) /* No AFSDB records */ + if (server_num == 0) /* No AFSDB records */ return AFSCONF_NOTFOUND; /* Convert the real cell name to lowercase */ - for (p = (unsigned char *) realCellName; *p; p++) + for (p = (unsigned char *)realCellName; *p; p++) *p = tolower(*p); strncpy(acellInfo->name, realCellName, sizeof(acellInfo->name)); @@ -740,8 +768,8 @@ int afsconf_GetAfsdbInfo(char *acellName, char *aservice, if (aservice) { tservice = afsconf_FindService(aservice); if (tservice < 0) - return AFSCONF_NOTFOUND; /* service not found */ - for (i=0; inumServers; i++) { + return AFSCONF_NOTFOUND; /* service not found */ + for (i = 0; i < acellInfo->numServers; i++) { acellInfo->hostAddr[i].sin_port = tservice; } } @@ -750,60 +778,60 @@ int afsconf_GetAfsdbInfo(char *acellName, char *aservice, return 0; } -#else /* windows */ -int afsconf_GetAfsdbInfo(char *acellName, char *aservice, - struct afsconf_cell *acellInfo) +#else /* windows */ +int +afsconf_GetAfsdbInfo(char *acellName, char *aservice, + struct afsconf_cell *acellInfo) { register afs_int32 i; int tservice; struct afsconf_entry DNSce; - char *DNStmpStrp; /* a temp string pointer */ + char *DNStmpStrp; /* a temp string pointer */ struct hostent *thp; afs_int32 cellHosts[AFSMAXCELLHOSTS]; int numServers; int rc; int *ttl; - DNSce.cellInfo.numServers=0; + DNSce.cellInfo.numServers = 0; DNSce.next = NULL; rc = getAFSServer(acellName, cellHosts, &numServers, &ttl); /* ignore the ttl here since this code is only called by transitory programs - like klog, etc. */ + * like klog, etc. */ if (rc < 0) - return -1; + return -1; if (numServers == 0) - return -1; + return -1; - for (i = 0; i < numServers; i++) - { - memcpy(&acellInfo->hostAddr[i].sin_addr.s_addr, &cellHosts[i], sizeof(long)); - acellInfo->hostAddr[i].sin_family = AF_INET; + for (i = 0; i < numServers; i++) { + memcpy(&acellInfo->hostAddr[i].sin_addr.s_addr, &cellHosts[i], + sizeof(long)); + acellInfo->hostAddr[i].sin_family = AF_INET; - /* sin_port supplied by connection code */ + /* sin_port supplied by connection code */ } acellInfo->numServers = numServers; strcpy(acellInfo->name, acellName); if (aservice) { - LOCK_GLOBAL_MUTEX - tservice = afsconf_FindService(aservice); - UNLOCK_GLOBAL_MUTEX - if (tservice < 0) { - return AFSCONF_NOTFOUND; /* service not found */ - } - for(i=0; i< acellInfo->numServers; i++) { - acellInfo->hostAddr[i].sin_port = tservice; - } + LOCK_GLOBAL_MUTEX tservice = afsconf_FindService(aservice); + UNLOCK_GLOBAL_MUTEX if (tservice < 0) { + return AFSCONF_NOTFOUND; /* service not found */ + } + for (i = 0; i < acellInfo->numServers; i++) { + acellInfo->hostAddr[i].sin_port = tservice; + } } - acellInfo->linkedCell = NULL; /* no linked cell */ + acellInfo->linkedCell = NULL; /* no linked cell */ acellInfo->flags = 0; return 0; } #endif /* windows */ #endif /* AFS_AFSDB_ENV */ -int afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, - char *aservice, struct afsconf_cell *acellInfo) +int +afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, char *aservice, + struct afsconf_cell *acellInfo) { register struct afsconf_entry *tce; struct afsconf_aliasentry *tcae; @@ -815,28 +843,26 @@ int afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, int ambig; char tbuffer[64]; - LOCK_GLOBAL_MUTEX - if (adir) afsconf_Check(adir); + LOCK_GLOBAL_MUTEX if (adir) + afsconf_Check(adir); if (acellName) { tcell = acellName; - cnLen = strlen(tcell)+1; - lcstring (tcell, tcell, cnLen); - afsconf_SawCell = 1; /* will ignore the AFSCELL switch on future */ - /* call to afsconf_GetLocalCell: like klog */ + cnLen = strlen(tcell) + 1; + lcstring(tcell, tcell, cnLen); + afsconf_SawCell = 1; /* will ignore the AFSCELL switch on future */ + /* call to afsconf_GetLocalCell: like klog */ } else { i = afsconf_GetLocalCell(adir, tbuffer, sizeof(tbuffer)); if (i) { - UNLOCK_GLOBAL_MUTEX - return i; + UNLOCK_GLOBAL_MUTEX return i; } tcell = tbuffer; } cnLen = strlen(tcell); - bestce = (struct afsconf_entry *) 0; + bestce = (struct afsconf_entry *)0; ambig = 0; if (!adir) { - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } /* Look through the list of aliases */ @@ -847,16 +873,18 @@ int afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, } } - for(tce=adir->entries;tce;tce=tce->next) { + for (tce = adir->entries; tce; tce = tce->next) { if (strcasecmp(tce->cellInfo.name, tcell) == 0) { /* found our cell */ bestce = tce; ambig = 0; break; } - if (strlen(tce->cellInfo.name) < cnLen) continue; /* clearly wrong */ + if (strlen(tce->cellInfo.name) < cnLen) + continue; /* clearly wrong */ if (strncasecmp(tce->cellInfo.name, tcell, cnLen) == 0) { - if (bestce) ambig = 1; /* ambiguous unless we get exact match */ + if (bestce) + ambig = 1; /* ambiguous unless we get exact match */ bestce = tce; } } @@ -865,80 +893,80 @@ int afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, if (aservice) { tservice = afsconf_FindService(aservice); if (tservice < 0) { - UNLOCK_GLOBAL_MUTEX - return AFSCONF_NOTFOUND; /* service not found */ + UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; /* service not found */ } - for(i=0;inumServers;i++) { + for (i = 0; i < acellInfo->numServers; i++) { acellInfo->hostAddr[i].sin_port = tservice; } } acellInfo->timeout = 0; - UNLOCK_GLOBAL_MUTEX - return 0; - } - else { + UNLOCK_GLOBAL_MUTEX return 0; + } else { UNLOCK_GLOBAL_MUTEX #ifdef AFS_AFSDB_ENV - return afsconf_GetAfsdbInfo(tcell, aservice, acellInfo); + return afsconf_GetAfsdbInfo(tcell, aservice, acellInfo); #else - return AFSCONF_NOTFOUND; + return AFSCONF_NOTFOUND; #endif /* AFS_AFSDB_ENV */ } } -int afsconf_GetLocalCell(register struct afsconf_dir *adir, - char *aname, afs_int32 alen) +int +afsconf_GetLocalCell(register struct afsconf_dir *adir, char *aname, + afs_int32 alen) { - static int afsconf_showcell = 0; - char *afscell_path; - afs_int32 code = 0; - - LOCK_GLOBAL_MUTEX - /* - * If a cell switch was specified in a command, then it should override the - * AFSCELL variable. If a cell was specified, then the afsconf_SawCell flag - * is set and the cell name in the adir structure is used. - * Read the AFSCELL var each time: in case it changes (unsetenv AFSCELL). - */ - if ( !afsconf_SawCell && (afscell_path= getenv("AFSCELL")) ) { - if ( !afsconf_showcell ) { - fprintf(stderr, "Note: Operation is performed on cell %s\n", afscell_path); + static int afsconf_showcell = 0; + char *afscell_path; + afs_int32 code = 0; + + LOCK_GLOBAL_MUTEX + /* + * If a cell switch was specified in a command, then it should override the + * AFSCELL variable. If a cell was specified, then the afsconf_SawCell flag + * is set and the cell name in the adir structure is used. + * Read the AFSCELL var each time: in case it changes (unsetenv AFSCELL). + */ + if (!afsconf_SawCell && (afscell_path = getenv("AFSCELL"))) { + if (!afsconf_showcell) { + fprintf(stderr, "Note: Operation is performed on cell %s\n", + afscell_path); afsconf_showcell = 1; } strncpy(aname, afscell_path, alen); - } else { + } else { afsconf_Check(adir); if (adir->cellName) { strncpy(aname, adir->cellName, alen); - } - else code = AFSCONF_UNKNOWN; + } else + code = AFSCONF_UNKNOWN; } - UNLOCK_GLOBAL_MUTEX - return(code); + UNLOCK_GLOBAL_MUTEX return (code); } -int afsconf_Close(struct afsconf_dir *adir) +int +afsconf_Close(struct afsconf_dir *adir) { - LOCK_GLOBAL_MUTEX - afsconf_CloseInternal(adir); - if (adir->name) free(adir->name); + LOCK_GLOBAL_MUTEX afsconf_CloseInternal(adir); + if (adir->name) + free(adir->name); free(adir); - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } -static int afsconf_CloseInternal(register struct afsconf_dir *adir) +static int +afsconf_CloseInternal(register struct afsconf_dir *adir) { register struct afsconf_entry *td, *nd; struct afsconf_aliasentry *ta, *na; register char *tname; - tname = adir->name; /* remember name, since that's all we preserve */ + tname = adir->name; /* remember name, since that's all we preserve */ /* free everything we can find */ - if (adir->cellName) free(adir->cellName); - for(td=adir->entries;td;td=nd) { + if (adir->cellName) + free(adir->cellName); + for (td = adir->entries; td; td = nd) { nd = td->next; if (td->cellInfo.linkedCell) free(td->cellInfo.linkedCell); @@ -946,27 +974,31 @@ static int afsconf_CloseInternal(register struct afsconf_dir *adir) } for (ta = adir->alias_entries; ta; ta = na) { na = ta->next; - free (ta); + free(ta); } - if (adir->keystr) free(adir->keystr); + if (adir->keystr) + free(adir->keystr); /* reinit */ memset(adir, 0, sizeof(struct afsconf_dir)); - adir->name = tname; /* restore it */ + adir->name = tname; /* restore it */ return 0; } -static int afsconf_Reopen(register struct afsconf_dir *adir) +static int +afsconf_Reopen(register struct afsconf_dir *adir) { register afs_int32 code; code = afsconf_CloseInternal(adir); - if (code) return code; + if (code) + return code; code = afsconf_OpenInternal(adir, 0, 0); return code; } /* called during opening of config file */ -int afsconf_IntGetKeys(struct afsconf_dir *adir) +int +afsconf_IntGetKeys(struct afsconf_dir *adir) { char tbuffer[256]; register int fd; @@ -986,55 +1018,49 @@ int afsconf_IntGetKeys(struct afsconf_dir *adir) #endif /* AFS_NT40_ENV */ LOCK_GLOBAL_MUTEX - /* compute the key name and other setup */ - - strcompose(tbuffer, 256, adir->name, "/", AFSDIR_KEY_FILE, NULL); - tstr = (struct afsconf_keys *) malloc(sizeof (struct afsconf_keys)); + /* compute the key name and other setup */ + strcompose(tbuffer, 256, adir->name, "/", AFSDIR_KEY_FILE, NULL); + tstr = (struct afsconf_keys *)malloc(sizeof(struct afsconf_keys)); adir->keystr = tstr; /* read key file */ fd = open(tbuffer, O_RDONLY); if (fd < 0) { tstr->nkeys = 0; - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } code = read(fd, tstr, sizeof(struct afsconf_keys)); close(fd); if (code < sizeof(afs_int32)) { tstr->nkeys = 0; - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } /* convert key structure to host order */ tstr->nkeys = ntohl(tstr->nkeys); - for(fd=0;fdnkeys;fd++) + for (fd = 0; fd < tstr->nkeys; fd++) tstr->key[fd].kvno = ntohl(tstr->key[fd].kvno); - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } /* get keys structure */ -int afsconf_GetKeys(struct afsconf_dir *adir, struct afsconf_keys *astr) +int +afsconf_GetKeys(struct afsconf_dir *adir, struct afsconf_keys *astr) { register afs_int32 code; - LOCK_GLOBAL_MUTEX - code = afsconf_Check(adir); + LOCK_GLOBAL_MUTEX code = afsconf_Check(adir); if (code) { - UNLOCK_GLOBAL_MUTEX - return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; } memcpy(astr, adir->keystr, sizeof(struct afsconf_keys)); - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } /* get latest key */ -afs_int32 afsconf_GetLatestKey(struct afsconf_dir *adir, - afs_int32 *avno, char *akey) +afs_int32 +afsconf_GetLatestKey(struct afsconf_dir * adir, afs_int32 * avno, char *akey) { register int i; int maxa; @@ -1042,64 +1068,60 @@ afs_int32 afsconf_GetLatestKey(struct afsconf_dir *adir, register afs_int32 best; struct afsconf_key *bestk; register afs_int32 code; - - LOCK_GLOBAL_MUTEX - code = afsconf_Check(adir); + + LOCK_GLOBAL_MUTEX code = afsconf_Check(adir); if (code) { - UNLOCK_GLOBAL_MUTEX - return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; } maxa = adir->keystr->nkeys; - best = -1; /* highest kvno we've seen yet */ - bestk = (struct afsconf_key *) 0; /* ptr to structure providing best */ - for(tk = adir->keystr->key,i=0;ikvno == 999) continue; /* skip bcrypt keys */ + best = -1; /* highest kvno we've seen yet */ + bestk = (struct afsconf_key *)0; /* ptr to structure providing best */ + for (tk = adir->keystr->key, i = 0; i < maxa; i++, tk++) { + if (tk->kvno == 999) + continue; /* skip bcrypt keys */ if (tk->kvno > best) { best = tk->kvno; bestk = tk; } } - if (bestk) { /* found any */ - if (akey) memcpy(akey, bestk->key, 8); /* copy out latest key */ - if (avno) *avno = bestk->kvno; /* and kvno to caller */ - UNLOCK_GLOBAL_MUTEX - return 0; + if (bestk) { /* found any */ + if (akey) + memcpy(akey, bestk->key, 8); /* copy out latest key */ + if (avno) + *avno = bestk->kvno; /* and kvno to caller */ + UNLOCK_GLOBAL_MUTEX return 0; } - UNLOCK_GLOBAL_MUTEX - return AFSCONF_NOTFOUND; /* didn't find any keys */ + UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; /* didn't find any keys */ } /* get a particular key */ -int afsconf_GetKey(struct afsconf_dir *adir, afs_int32 avno, - char *akey) +int +afsconf_GetKey(struct afsconf_dir *adir, afs_int32 avno, char *akey) { register int i, maxa; register struct afsconf_key *tk; register afs_int32 code; - LOCK_GLOBAL_MUTEX - code = afsconf_Check(adir); + LOCK_GLOBAL_MUTEX code = afsconf_Check(adir); if (code) { - UNLOCK_GLOBAL_MUTEX - return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; } maxa = adir->keystr->nkeys; - for(tk = adir->keystr->key,i=0;ikeystr->key, i = 0; i < maxa; i++, tk++) { if (tk->kvno == avno) { memcpy(akey, tk->key, 8); - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } } - UNLOCK_GLOBAL_MUTEX - return AFSCONF_NOTFOUND; + UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; } /* save the key structure in the appropriate file */ -static int SaveKeys(struct afsconf_dir *adir) +static int +SaveKeys(struct afsconf_dir *adir) { struct afsconf_keys tkeys; register int fd; @@ -1109,46 +1131,46 @@ static int SaveKeys(struct afsconf_dir *adir) memcpy(&tkeys, adir->keystr, sizeof(struct afsconf_keys)); /* convert it to net byte order */ - for(i = 0; iname, "/", AFSDIR_KEY_FILE, NULL); fd = open(tbuffer, O_RDWR | O_CREAT | O_TRUNC, 0600); - if (fd < 0) return AFSCONF_FAILURE; + if (fd < 0) + return AFSCONF_FAILURE; i = write(fd, &tkeys, sizeof(tkeys)); if (i != sizeof(tkeys)) { close(fd); return AFSCONF_FAILURE; } - if (close(fd) < 0) return AFSCONF_FAILURE; + if (close(fd) < 0) + return AFSCONF_FAILURE; return 0; } -int afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, - char akey[8], afs_int32 overwrite) +int +afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, char akey[8], + afs_int32 overwrite) { register struct afsconf_keys *tk; register struct afsconf_key *tkey; register afs_int32 i; int foundSlot; - LOCK_GLOBAL_MUTEX - tk = adir->keystr; - + LOCK_GLOBAL_MUTEX tk = adir->keystr; + if (akvno != 999) { if (akvno < 0 || akvno > 255) { - UNLOCK_GLOBAL_MUTEX - return ERANGE; + UNLOCK_GLOBAL_MUTEX return ERANGE; } } foundSlot = 0; - for(i=0, tkey = tk->key; inkeys; i++, tkey++) { + for (i = 0, tkey = tk->key; i < tk->nkeys; i++, tkey++) { if (tkey->kvno == akvno) { if (!overwrite) { - UNLOCK_GLOBAL_MUTEX - return AFSCONF_KEYINUSE; + UNLOCK_GLOBAL_MUTEX return AFSCONF_KEYINUSE; } foundSlot = 1; break; @@ -1156,8 +1178,7 @@ int afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, } if (!foundSlot) { if (tk->nkeys >= AFSCONF_MAXKEYS) { - UNLOCK_GLOBAL_MUTEX - return AFSCONF_FULL; + UNLOCK_GLOBAL_MUTEX return AFSCONF_FULL; } tkey = &tk->key[tk->nkeys++]; } @@ -1165,42 +1186,39 @@ int afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, memcpy(tkey->key, akey, 8); i = SaveKeys(adir); afsconf_Touch(adir); - UNLOCK_GLOBAL_MUTEX - return i; + UNLOCK_GLOBAL_MUTEX return i; } /* this proc works by sliding the other guys down, rather than using a funny kvno value, so that callers can count on getting a good key in key[0]. */ -int afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno) +int +afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno) { register struct afsconf_keys *tk; register struct afsconf_key *tkey; register int i; int foundFlag = 0; - LOCK_GLOBAL_MUTEX - tk = adir->keystr; + LOCK_GLOBAL_MUTEX tk = adir->keystr; - for(i=0, tkey = tk->key; inkeys; i++, tkey++) { + for (i = 0, tkey = tk->key; i < tk->nkeys; i++, tkey++) { if (tkey->kvno == akvno) { foundFlag = 1; break; } } if (!foundFlag) { - UNLOCK_GLOBAL_MUTEX - return AFSCONF_NOTFOUND; + UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; } /* otherwise slide the others down. i and tkey point at the guy to delete */ - for(;inkeys-1; i++,tkey++) { - tkey->kvno = (tkey+1)->kvno; - memcpy(tkey->key, (tkey+1)->key, 8); + for (; i < tk->nkeys - 1; i++, tkey++) { + tkey->kvno = (tkey + 1)->kvno; + memcpy(tkey->key, (tkey + 1)->key, 8); } tk->nkeys--; i = SaveKeys(adir); afsconf_Touch(adir); - UNLOCK_GLOBAL_MUTEX - return i; + UNLOCK_GLOBAL_MUTEX return i; } diff --git a/src/auth/cellconfig.p.h b/src/auth/cellconfig.p.h index 8f4343a54..e2ae6ed2d 100644 --- a/src/auth/cellconfig.p.h +++ b/src/auth/cellconfig.p.h @@ -60,13 +60,13 @@ Creation date: * Complete server info for one cell. */ struct afsconf_cell { - char name[MAXCELLCHARS]; /*Cell name*/ - short numServers; /*Num active servers for the cell*/ - short flags; /* useful flags */ - struct sockaddr_in hostAddr[MAXHOSTSPERCELL]; /*IP addresses for cell's servers*/ - char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS]; /*Names for cell's servers*/ - char *linkedCell; /* Linked cell name, if any */ - int timeout; /* Data timeout, if non-zero */ + char name[MAXCELLCHARS]; /*Cell name */ + short numServers; /*Num active servers for the cell */ + short flags; /* useful flags */ + struct sockaddr_in hostAddr[MAXHOSTSPERCELL]; /*IP addresses for cell's servers */ + char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS]; /*Names for cell's servers */ + char *linkedCell; /* Linked cell name, if any */ + int timeout; /* Data timeout, if non-zero */ }; struct afsconf_cellalias { @@ -76,7 +76,7 @@ struct afsconf_cellalias { struct afsconf_entry { struct afsconf_entry *next; /* next guy in afsconf_dir */ - struct afsconf_cell cellInfo; /* info for this cell */ + struct afsconf_cell cellInfo; /* info for this cell */ }; struct afsconf_aliasentry { @@ -85,12 +85,12 @@ struct afsconf_aliasentry { }; struct afsconf_dir { - char *name; /* pointer to dir prefix */ - char *cellName; /* cell name, if any, we're in */ - struct afsconf_entry *entries; /* list of cell entries */ - struct afsconf_keys *keystr; /* structure containing keys */ - afs_int32 timeRead; /* time stamp of file last read */ - struct afsconf_aliasentry *alias_entries; /* cell aliases */ + char *name; /* pointer to dir prefix */ + char *cellName; /* cell name, if any, we're in */ + struct afsconf_entry *entries; /* list of cell entries */ + struct afsconf_keys *keystr; /* structure containing keys */ + afs_int32 timeRead; /* time stamp of file last read */ + struct afsconf_aliasentry *alias_entries; /* cell aliases */ }; struct afsconf_servPair { @@ -99,33 +99,43 @@ struct afsconf_servPair { }; extern struct afsconf_dir *afsconf_Open(register const char *adir); -extern int afsconf_CellApply(struct afsconf_dir *adir, int (*aproc)(struct afsconf_cell *cell, - char *arock, struct afsconf_dir *dir), char *arock); -extern int afsconf_CellAliasApply(struct afsconf_dir *adir, int (*aproc)( - struct afsconf_cellalias *alias, char *arock, struct afsconf_dir *dir), char *arock); -extern int afsconf_GetExtendedCellInfo(struct afsconf_dir *adir, - char *acellName, char *aservice, struct afsconf_cell *acellInfo, - char clones[]); -extern int afsconf_GetAfsdbInfo(char *acellName, char *aservice, - struct afsconf_cell *acellInfo); -extern int afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, - char *aservice, struct afsconf_cell *acellInfo); -extern int afsconf_GetLocalCell(register struct afsconf_dir *adir, - char *aname, afs_int32 alen); +extern int afsconf_CellApply(struct afsconf_dir *adir, + int (*aproc) (struct afsconf_cell * cell, + char *arock, + struct afsconf_dir * dir), + char *arock); +extern int afsconf_CellAliasApply(struct afsconf_dir *adir, + int (*aproc) (struct afsconf_cellalias * + alias, char *arock, + struct afsconf_dir * dir), + char *arock); +extern int afsconf_GetExtendedCellInfo(struct afsconf_dir *adir, + char *acellName, char *aservice, + struct afsconf_cell *acellInfo, + char clones[]); +extern int afsconf_GetAfsdbInfo(char *acellName, char *aservice, + struct afsconf_cell *acellInfo); +extern int afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, + char *aservice, + struct afsconf_cell *acellInfo); +extern int afsconf_GetLocalCell(register struct afsconf_dir *adir, + char *aname, afs_int32 alen); extern int afsconf_Close(struct afsconf_dir *adir); extern int afsconf_IntGetKeys(struct afsconf_dir *adir); -extern int afsconf_GetKeys(struct afsconf_dir *adir, struct afsconf_keys *astr); -extern afs_int32 afsconf_GetLatestKey(struct afsconf_dir *adir, - afs_int32 *avno, char *akey); -extern int afsconf_GetKey(struct afsconf_dir *adir, afs_int32 avno, - char *akey); -extern int afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, - char akey[8], afs_int32 overwrite); +extern int afsconf_GetKeys(struct afsconf_dir *adir, + struct afsconf_keys *astr); +extern afs_int32 afsconf_GetLatestKey(struct afsconf_dir *adir, + afs_int32 * avno, char *akey); +extern int afsconf_GetKey(struct afsconf_dir *adir, afs_int32 avno, + char *akey); +extern int afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, + char akey[8], afs_int32 overwrite); extern int afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno); struct rx_securityClass; -extern afs_int32 afsconf_ClientAuth(struct afsconf_dir *adir, - struct rx_securityClass **astr, afs_int32 *aindex); +extern afs_int32 afsconf_ClientAuth(struct afsconf_dir *adir, + struct rx_securityClass **astr, + afs_int32 * aindex); @@ -153,6 +163,6 @@ extern afs_int32 afsconf_ClientAuth(struct afsconf_dir *adir, #define AFSCONF_RSDBSERVICE "afsres" #define AFSCONF_RESPORT 7010 #define AFSCONF_REMIODBSERVICE "afsremio" -#define AFSCONF_REMIOPORT 7011 +#define AFSCONF_REMIOPORT 7011 #endif /* __CELLCONFIG_AFS_INCL_ */ diff --git a/src/auth/copyauth.c b/src/auth/copyauth.c index 2db707147..96a5e59c3 100644 --- a/src/auth/copyauth.c +++ b/src/auth/copyauth.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef HAVE_STRING_H #include @@ -35,8 +36,9 @@ RCSID("$Header$"); char whoami[256]; main(argc, argv) -int argc; -char **argv; { + int argc; + char **argv; +{ char localName[64]; register afs_int32 code; register char *cname; @@ -47,8 +49,10 @@ char **argv; { strcpy(whoami, argv[0]); if (argc <= 1) { - printf("%s: copies a file system ticket from the local cell to another cell\n",whoami); - printf("%s: usage is 'setauth \n",whoami); + printf + ("%s: copies a file system ticket from the local cell to another cell\n", + whoami); + printf("%s: usage is 'setauth \n", whoami); exit(1); } @@ -62,28 +66,32 @@ char **argv; { } code = afsconf_GetLocalCell(tdir, localName, sizeof(localName)); if (code) { - printf("%s: can't determine local cell name\n",whoami); + printf("%s: can't determine local cell name\n", whoami); exit(1); } /* done with configuration stuff now */ afsconf_Close(tdir); - - + + /* get ticket in local cell */ strcpy(tserver.cell, localName); strcpy(tserver.name, "afs"); tserver.instance[0] = 0; code = ktc_GetToken(&tserver, &token, sizeof(token), NULL); if (code) { - printf("%s: failed to get '%s' service ticket in cell '%s' (code %d)\n", whoami, tserver.name, tserver.cell, code); + printf + ("%s: failed to get '%s' service ticket in cell '%s' (code %d)\n", + whoami, tserver.name, tserver.cell, code); exit(1); } - + /* and now set the ticket in the new cell */ strcpy(tserver.cell, argv[1]); code = ktc_SetToken(&tserver, &token, NULL, 0); if (code) { - printf("%s: failed to set ticket (code %d), are you sure you're authenticated?\n", whoami, code); + printf + ("%s: failed to set ticket (code %d), are you sure you're authenticated?\n", + whoami, code); exit(1); } diff --git a/src/auth/ktc.c b/src/auth/ktc.c index 2c3848340..5308f64dd 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -16,7 +16,8 @@ #include #endif -RCSID("$Header$"); +RCSID + ("$Header$"); #if defined(UKERNEL) #include "afs/sysincludes.h" @@ -77,31 +78,31 @@ RCSID("$Header$"); #define AFS_KERBEROS_ENV #endif -#ifdef AFS_KERBEROS_ENV +#ifdef AFS_KERBEROS_ENV #include #include #include "cellconfig.h" static char lcell[MAXCELLCHARS]; - + #define TKT_ROOT "/tmp/tkt" - + #define KSUCCESS 0 #define KFAILURE 255 - + /* Definitions for ticket file utilities */ #define R_TKT_FIL 0 #define W_TKT_FIL 1 - + /* Error codes returned by ticket file utilities */ #define NO_TKT_FIL 76 /* No ticket file found */ #define TKT_FIL_ACC 77 /* Couldn't access tkt file */ #define TKT_FIL_LCK 78 /* Couldn't lock ticket file */ #define TKT_FIL_FMT 79 /* Bad ticket file format */ #define TKT_FIL_INI 80 /* afs_tf_init not called first */ - + /* Values returned by get_credentials */ #define RET_TKFIL 21 /* Can't read ticket file */ - + #ifndef BUFSIZ #define BUFSIZ 4096 #endif @@ -123,16 +124,16 @@ static struct flock fileUlock = { F_UNLCK, 0, 0, 0, 0 }; #ifndef EOF #define EOF (-1) #endif - + /* the following routines aren't static anymore on behalf of the kerberos IV * compatibility library built in subtree krb. */ -int afs_tf_init(), afs_tf_get_pname(), afs_tf_get_pinst(), afs_tf_get_cred(); -int afs_tf_save_cred(), afs_tf_close(), afs_tf_create(); +int afs_tf_init(), afs_tf_get_pname(), afs_tf_get_pinst(), afs_tf_get_cred(); +int afs_tf_save_cred(), afs_tf_close(), afs_tf_create(); int afs_tf_dest_tkt(); static void ktc_LocalCell(); char *ktc_tkt_string(); -#endif /* AFS_KERBEROS_ENV */ +#endif /* AFS_KERBEROS_ENV */ #ifdef AFS_DUX40_ENV #define PIOCTL afs_pioctl @@ -195,7 +196,7 @@ static int kernelKTC = 0; /* printf ("returned from KTC_NO_OP kernelKTC <= %d; code=%d, errno=%d\n", kernelKTC, code, errno); */\ } -#else /* AFS_DECOSF_ENV */ +#else /* AFS_DECOSF_ENV */ #define CHECK_KERNEL \ if (kernelKTC == 0) { \ @@ -209,7 +210,7 @@ static int kernelKTC = 0; else kernelKTC = 2; \ /* printf ("returned from KTC_NO_OP kernelKTC <= %d; code=%d, errno=%d\n", kernelKTC, code, errno); */\ } -#endif /* AFS_DECOSF_ENV */ +#endif /* AFS_DECOSF_ENV */ #define TRY_KERNEL(cmd,a1,a2,a3,a4) \ { CHECK_KERNEL; \ @@ -226,11 +227,11 @@ static int kernelKTC = 0; /* this is a structure used to communicate with the afs cache mgr, but is * otherwise irrelevant */ struct ClearToken { - afs_int32 AuthHandle; - char HandShakeKey[8]; - afs_int32 ViceId; - afs_int32 BeginTimestamp; - afs_int32 EndTimestamp; + afs_int32 AuthHandle; + char HandShakeKey[8]; + afs_int32 ViceId; + afs_int32 BeginTimestamp; + afs_int32 EndTimestamp; }; #endif /* !defined(UKERNEL) */ @@ -240,28 +241,34 @@ static struct { int valid; struct ktc_principal server; struct ktc_principal client; - struct ktc_token token; -} local_tokens[MAXLOCALTOKENS] = {{0}, {0}, {0}, {0}}; + struct ktc_token token; +} local_tokens[MAXLOCALTOKENS] = { { +0}, { +0}, { +0}, { +0}}; /* new interface routines to the ticket cache. Only handle afs service right * now. */ -static int NewSetToken (aserver, atoken, aclient, flags) - struct ktc_principal *aserver; - struct ktc_principal *aclient; - struct ktc_token *atoken; - afs_int32 flags; +static int +NewSetToken(aserver, atoken, aclient, flags) + struct ktc_principal *aserver; + struct ktc_principal *aclient; + struct ktc_token *atoken; + afs_int32 flags; { - TRY_KERNEL (KTC_SETTOKEN_OP, - aserver, aclient, atoken, sizeof(struct ktc_token)); + TRY_KERNEL(KTC_SETTOKEN_OP, aserver, aclient, atoken, + sizeof(struct ktc_token)); /* no kernel ticket cache */ return EINVAL; } -static int OldSetToken (aserver, atoken, aclient, flags) -struct ktc_principal *aserver, *aclient; -struct ktc_token *atoken; -afs_int32 flags; +static int +OldSetToken(aserver, atoken, aclient, flags) + struct ktc_principal *aserver, *aclient; + struct ktc_token *atoken; + afs_int32 flags; { struct ViceIoctl iob; char tbuffer[1024]; @@ -273,29 +280,36 @@ afs_int32 flags; if (strcmp(aserver->name, "afs") != 0) { int found = -1; int i; - for (i=0; iname) == 0) && - (strcmp (local_tokens[i].server.instance, aserver->instance) == 0) && - (strcmp (local_tokens[i].server.cell, aserver->cell) == 0)) { - found = i; /* replace existing entry */ + if ((strcmp(local_tokens[i].server.name, aserver->name) == 0) + && + (strcmp + (local_tokens[i].server.instance, + aserver->instance) == 0) + && (strcmp(local_tokens[i].server.cell, aserver->cell) == + 0)) { + found = i; /* replace existing entry */ break; - } - else /* valid, but no match */ ; - } else found = i; /* remember this empty slot */ - if (found == -1) return KTC_NOENT; + } else /* valid, but no match */ + ; + } else + found = i; /* remember this empty slot */ + if (found == -1) + return KTC_NOENT; memcpy(&local_tokens[found].token, atoken, sizeof(struct ktc_token)); local_tokens[found].server = *aserver; local_tokens[found].client = *aclient; local_tokens[found].valid = 1; return 0; } - tp = tbuffer; /* start copying here */ - if ((atoken->ticketLen < MINKTCTICKETLEN) || - (atoken->ticketLen > MAXKTCTICKETLEN)) return KTC_TOOBIG; - memcpy(tp, &atoken->ticketLen, sizeof(afs_int32)); /* copy in ticket length */ + tp = tbuffer; /* start copying here */ + if ((atoken->ticketLen < MINKTCTICKETLEN) + || (atoken->ticketLen > MAXKTCTICKETLEN)) + return KTC_TOOBIG; + memcpy(tp, &atoken->ticketLen, sizeof(afs_int32)); /* copy in ticket length */ tp += sizeof(afs_int32); - memcpy(tp, atoken->ticket, atoken->ticketLen); /* copy in ticket */ + memcpy(tp, atoken->ticket, atoken->ticketLen); /* copy in ticket */ tp += atoken->ticketLen; /* next, copy in the "clear token", describing who we are */ ct.AuthHandle = atoken->kvno; /* hide auth handle here */ @@ -303,25 +317,31 @@ afs_int32 flags; ct.BeginTimestamp = atoken->startTime; ct.EndTimestamp = atoken->endTime; - if (ct.BeginTimestamp == 0) ct.BeginTimestamp = 1; + if (ct.BeginTimestamp == 0) + ct.BeginTimestamp = 1; - if ((strlen(aclient->name) > strlen ("AFS ID ")) && - (aclient->instance[0] == 0)) { + if ((strlen(aclient->name) > strlen("AFS ID ")) + && (aclient->instance[0] == 0)) { int sign = 1; afs_int32 viceId = 0; - char *cp = aclient->name + strlen ("AFS ID "); - if (*cp == '-') { sign = -1; cp++; } + char *cp = aclient->name + strlen("AFS ID "); + if (*cp == '-') { + sign = -1; + cp++; + } while (*cp) { - if (isdigit(*cp)) viceId = viceId*10 + (int)(*cp - '0'); - else goto not_vice_id; + if (isdigit(*cp)) + viceId = viceId * 10 + (int)(*cp - '0'); + else + goto not_vice_id; cp++; } ct.ViceId = viceId * sign; /* OK to let any value here? */ if (((ct.EndTimestamp - ct.BeginTimestamp) & 1) == 0) ct.BeginTimestamp++; /* force lifetime to be odd */ } else { -not_vice_id: - ct.ViceId = getuid(); /* wrong, but works in primary cell */ + not_vice_id: + ct.ViceId = getuid(); /* wrong, but works in primary cell */ if (((ct.EndTimestamp - ct.BeginTimestamp) & 1) == 1) ct.BeginTimestamp++; /* force lifetime to be even */ } @@ -350,7 +370,7 @@ not_vice_id: * The following means that setpag will affect the parent process as * well as the current process. */ - if (flags & AFS_SETTOK_SETPAG) + if (flags & AFS_SETTOK_SETPAG) temp |= 0x8000; memcpy(tp, &temp, sizeof(afs_int32)); @@ -358,183 +378,193 @@ not_vice_id: /* finally copy in the cell name */ temp = strlen(aserver->cell); - if (temp >= MAXKTCREALMLEN) return KTC_TOOBIG; + if (temp >= MAXKTCREALMLEN) + return KTC_TOOBIG; strcpy(tp, aserver->cell); - tp += temp+1; + tp += temp + 1; /* now setup for the pioctl */ iob.in = tbuffer; - iob.in_size = tp-tbuffer; + iob.in_size = tp - tbuffer; iob.out = tbuffer; iob.out_size = sizeof(tbuffer); #if defined(NO_AFS_CLIENT) - { int fd; /* DEBUG */ - char *tkfile; - if ((tkfile=getenv("TKTFILE")) && - ((fd=open(tkfile, O_WRONLY|O_APPEND|O_TRUNC|O_CREAT, 0644)) >= 0)) { - printf("Writing ticket to: %s\n", tkfile); - code = (write(fd, iob.in, iob.in_size) != iob.in_size); - close(fd); - } - else - code = KTC_PIOCTLFAIL; + { + int fd; /* DEBUG */ + char *tkfile; + if ((tkfile = getenv("TKTFILE")) + && + ((fd = + open(tkfile, O_WRONLY | O_APPEND | O_TRUNC | O_CREAT, + 0644)) >= 0)) { + printf("Writing ticket to: %s\n", tkfile); + code = (write(fd, iob.in, iob.in_size) != iob.in_size); + close(fd); + } else + code = KTC_PIOCTLFAIL; } #else /* NO_AFS_CLIENT */ code = PIOCTL(0, VIOCSETTOK, &iob, 0); #endif /* NO_AFS_CLIENT */ - if (code) return KTC_PIOCTLFAIL; + if (code) + return KTC_PIOCTLFAIL; return 0; } -ktc_SetToken (aserver, atoken, aclient, flags) - struct ktc_principal *aserver; - struct ktc_principal *aclient; - struct ktc_token *atoken; - afs_int32 flags; +ktc_SetToken(aserver, atoken, aclient, flags) + struct ktc_principal *aserver; + struct ktc_principal *aclient; + struct ktc_token *atoken; + afs_int32 flags; { int ncode, ocode; LOCK_GLOBAL_MUTEX #ifdef AFS_KERBEROS_ENV - if (!lcell[0]) ktc_LocalCell(); - - if (/*!strcmp(aclient->cell, lcell) && this would only store local creds*/ - (strcmp(aserver->name, "AuthServer") || - strcmp(aserver->instance, "Admin"))){ - if (strcmp(aserver->name, "krbtgt") == 0) { - static char lrealm[MAXKTCREALMLEN]; - - if (!lrealm[0]) ucstring(lrealm, lcell, MAXKTCREALMLEN); - if (strcmp(aserver->instance, lrealm) == 0) { - afs_tf_create(aclient->name, aclient->instance); - } - } - - ncode = afs_tf_init(ktc_tkt_string(), W_TKT_FIL); - if (ncode == NO_TKT_FIL) { - (void) afs_tf_create(aclient->name, aclient->instance); - ncode = afs_tf_init(ktc_tkt_string(), W_TKT_FIL); - } - - if (!ncode) { - afs_tf_save_cred(aserver, atoken, aclient); - } - afs_tf_close(); + if (!lcell[0]) + ktc_LocalCell(); + + if ( /*!strcmp(aclient->cell, lcell) && this would only store local creds */ + (strcmp(aserver->name, "AuthServer") + || strcmp(aserver->instance, "Admin"))) { + if (strcmp(aserver->name, "krbtgt") == 0) { + static char lrealm[MAXKTCREALMLEN]; + + if (!lrealm[0]) + ucstring(lrealm, lcell, MAXKTCREALMLEN); + if (strcmp(aserver->instance, lrealm) == 0) { + afs_tf_create(aclient->name, aclient->instance); + } + } + + ncode = afs_tf_init(ktc_tkt_string(), W_TKT_FIL); + if (ncode == NO_TKT_FIL) { + (void)afs_tf_create(aclient->name, aclient->instance); + ncode = afs_tf_init(ktc_tkt_string(), W_TKT_FIL); + } + + if (!ncode) { + afs_tf_save_cred(aserver, atoken, aclient); + } + afs_tf_close(); #ifdef NO_AFS_CLIENT - UNLOCK_GLOBAL_MUTEX - return ncode; + UNLOCK_GLOBAL_MUTEX return ncode; #endif /* NO_AFS_CLIENT */ - } + } #endif #ifndef NO_AFS_CLIENT - ncode = NewSetToken (aserver, atoken, aclient, flags); - if (ncode || /* new style failed */ - (strcmp (aserver->name, "afs") == 0)) { /* for afs tokens do both */ - ocode = OldSetToken (aserver, atoken, aclient, flags); - } else ocode = 0; + ncode = NewSetToken(aserver, atoken, aclient, flags); + if (ncode || /* new style failed */ + (strcmp(aserver->name, "afs") == 0)) { /* for afs tokens do both */ + ocode = OldSetToken(aserver, atoken, aclient, flags); + } else + ocode = 0; if (ncode && ocode) { - UNLOCK_GLOBAL_MUTEX - if (ocode == -1) ocode = errno; - else if (ocode == KTC_PIOCTLFAIL) ocode = errno; - if (ocode == ESRCH) return KTC_NOCELL; - if (ocode == EINVAL) return KTC_NOPIOCTL; - if (ocode == EIO) return KTC_NOCM; + UNLOCK_GLOBAL_MUTEX if (ocode == -1) + ocode = errno; + else if (ocode == KTC_PIOCTLFAIL) + ocode = errno; + if (ocode == ESRCH) + return KTC_NOCELL; + if (ocode == EINVAL) + return KTC_NOPIOCTL; + if (ocode == EIO) + return KTC_NOCM; return KTC_PIOCTLFAIL; } #endif /* NO_AFS_CLIENT */ - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } /* get token, given server we need and token buffer. aclient will eventually * be set to our identity to the server. */ ktc_GetToken(aserver, atoken, atokenLen, aclient) -struct ktc_principal *aserver, *aclient; -int atokenLen; -struct ktc_token *atoken; { + struct ktc_principal *aserver, *aclient; + int atokenLen; + struct ktc_token *atoken; +{ struct ViceIoctl iob; char tbuffer[1024]; register afs_int32 code; int index; - char *stp, *cellp; /* secret token ptr */ + char *stp, *cellp; /* secret token ptr */ struct ClearToken ct; register char *tp; afs_int32 temp; - int maxLen; /* biggest ticket we can copy */ - int tktLen; /* server ticket length */ + int maxLen; /* biggest ticket we can copy */ + int tktLen; /* server ticket length */ char found = 0; - + LOCK_GLOBAL_MUTEX #ifndef NO_AFS_CLIENT - TRY_KERNEL (KTC_GETTOKEN_OP, aserver, aclient, atoken, atokenLen); + TRY_KERNEL(KTC_GETTOKEN_OP, aserver, aclient, atoken, atokenLen); #endif /* NO_AFS_CLIENT */ #ifdef AFS_KERBEROS_ENV - if (!lcell[0]) ktc_LocalCell(); + if (!lcell[0]) + ktc_LocalCell(); #endif #ifndef NO_AFS_CLIENT - if (strcmp(aserver->name, "afs") != 0) + if (strcmp(aserver->name, "afs") != 0) #endif /* NO_AFS_CLIENT */ - { + { int i; /* try the local tokens */ - for (i=0; iname) == 0) && - (strcmp (local_tokens[i].server.instance, aserver->instance) == 0) && - (strcmp (local_tokens[i].server.cell, aserver->cell) == 0)) { - memcpy (atoken, &local_tokens[i].token, min (atokenLen, sizeof(struct ktc_token))); + for (i = 0; i < MAXLOCALTOKENS; i++) + if (local_tokens[i].valid + && (strcmp(local_tokens[i].server.name, aserver->name) == 0) + && (strcmp(local_tokens[i].server.instance, aserver->instance) + == 0) + && (strcmp(local_tokens[i].server.cell, aserver->cell) == 0)) { + memcpy(atoken, &local_tokens[i].token, + min(atokenLen, sizeof(struct ktc_token))); if (aclient) *aclient = local_tokens[i].client; - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } #ifdef AFS_KERBEROS_ENV - if (!afs_tf_init(ktc_tkt_string(), R_TKT_FIL)) { - if (aclient) { - if (!afs_tf_get_pname(aclient->name) && - !afs_tf_get_pinst(aclient->instance)) - found = 1; - } else { - char tmpstring[MAXHOSTCHARS]; - afs_tf_get_pname(&tmpstring); - afs_tf_get_pinst(&tmpstring); - found = 1; - } - } - if (found) { - struct ktc_principal cprincipal; - struct ktc_token ctoken; - - while (!afs_tf_get_cred(&cprincipal, &ctoken)) { - if (strcmp(cprincipal.name, aserver->name) == 0 && - strcmp(cprincipal.instance, aserver->instance) == 0 && - strcmp(cprincipal.cell, aserver->cell) == 0) { - + if (!afs_tf_init(ktc_tkt_string(), R_TKT_FIL)) { + if (aclient) { + if (!afs_tf_get_pname(aclient->name) + && !afs_tf_get_pinst(aclient->instance)) + found = 1; + } else { + char tmpstring[MAXHOSTCHARS]; + afs_tf_get_pname(&tmpstring); + afs_tf_get_pinst(&tmpstring); + found = 1; + } + } + if (found) { + struct ktc_principal cprincipal; + struct ktc_token ctoken; + + while (!afs_tf_get_cred(&cprincipal, &ctoken)) { + if (strcmp(cprincipal.name, aserver->name) == 0 + && strcmp(cprincipal.instance, aserver->instance) == 0 + && strcmp(cprincipal.cell, aserver->cell) == 0) { + if (aclient) strcpy(aclient->cell, lcell); - memcpy(atoken, &ctoken, - min (atokenLen, sizeof(struct ktc_token))); - - afs_tf_close(); - UNLOCK_GLOBAL_MUTEX - return 0; - } - } - } - afs_tf_close(); + memcpy(atoken, &ctoken, + min(atokenLen, sizeof(struct ktc_token))); + + afs_tf_close(); + UNLOCK_GLOBAL_MUTEX return 0; + } + } + } + afs_tf_close(); #endif - UNLOCK_GLOBAL_MUTEX - return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX return KTC_NOENT; } - #ifndef NO_AFS_CLIENT - for (index=0; index<200; index++) { /* sanity check in case pioctl fails */ - iob.in = (char *) &index; + for (index = 0; index < 200; index++) { /* sanity check in case pioctl fails */ + iob.in = (char *)&index; iob.in_size = sizeof(afs_int32); iob.out = tbuffer; iob.out_size = sizeof(tbuffer); @@ -544,8 +574,7 @@ struct ktc_token *atoken; { if (code) { /* failed to retrieve specified token */ if (code < 0 && errno == EDOM) { - UNLOCK_GLOBAL_MUTEX - return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX return KTC_NOENT; } } else { /* token retrieved; parse buffer */ @@ -563,8 +592,7 @@ struct ktc_token *atoken; { /* get size of clear token and verify */ memcpy(&temp, tp, sizeof(afs_int32)); if (temp != sizeof(struct ClearToken)) { - UNLOCK_GLOBAL_MUTEX - return KTC_ERROR; + UNLOCK_GLOBAL_MUTEX return KTC_ERROR; } tp += sizeof(afs_int32); @@ -584,10 +612,10 @@ struct ktc_token *atoken; { #endif ) { /* got token for cell; check that it will fit */ - maxLen = atokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN; + maxLen = + atokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN; if (maxLen < tktLen) { - UNLOCK_GLOBAL_MUTEX - return KTC_TOOBIG; + UNLOCK_GLOBAL_MUTEX return KTC_TOOBIG; } /* set return values */ @@ -598,30 +626,30 @@ struct ktc_token *atoken; { ct.AuthHandle = 999; } atoken->kvno = ct.AuthHandle; - memcpy(&atoken->sessionKey, ct.HandShakeKey, sizeof(struct ktc_encryptionKey)); + memcpy(&atoken->sessionKey, ct.HandShakeKey, + sizeof(struct ktc_encryptionKey)); atoken->ticketLen = tktLen; if (aclient) { strcpy(aclient->cell, cellp); aclient->instance[0] = 0; - if ((atoken->kvno == 999) || /* old style bcrypt ticket */ - (ct.BeginTimestamp && /* new w/ prserver lookup */ + if ((atoken->kvno == 999) || /* old style bcrypt ticket */ + (ct.BeginTimestamp && /* new w/ prserver lookup */ (((ct.EndTimestamp - ct.BeginTimestamp) & 1) == 1))) { sprintf(aclient->name, "AFS ID %d", ct.ViceId); } else { sprintf(aclient->name, "Unix UID %d", ct.ViceId); } } - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } } } #endif /* NO_AFS_CLIENT */ - UNLOCK_GLOBAL_MUTEX - if ((code < 0) && (errno == EINVAL)) return KTC_NOPIOCTL; + UNLOCK_GLOBAL_MUTEX if ((code < 0) && (errno == EINVAL)) + return KTC_NOPIOCTL; return KTC_PIOCTLFAIL; /* probable cause */ } @@ -631,15 +659,14 @@ struct ktc_token *atoken; { */ #ifndef NO_AFS_CLIENT ktc_ForgetToken(aserver) -struct ktc_principal *aserver; { + struct ktc_principal *aserver; +{ int rc; - LOCK_GLOBAL_MUTEX - TRY_KERNEL (KTC_FORGETTOKEN_OP, aserver, 0,0,0); + LOCK_GLOBAL_MUTEX TRY_KERNEL(KTC_FORGETTOKEN_OP, aserver, 0, 0, 0); rc = ktc_ForgetAllTokens(); /* bogus, but better */ - UNLOCK_GLOBAL_MUTEX - return rc; + UNLOCK_GLOBAL_MUTEX return rc; } #endif /* NO_AFS_CLIENT */ @@ -648,8 +675,9 @@ struct ktc_principal *aserver; { * success. */ ktc_ListTokens(aprevIndex, aindex, aserver) -int aprevIndex, *aindex; -struct ktc_principal *aserver; { + int aprevIndex, *aindex; + struct ktc_principal *aserver; +{ struct ViceIoctl iob; char tbuffer[1024]; register afs_int32 code; @@ -660,87 +688,83 @@ struct ktc_principal *aserver; { LOCK_GLOBAL_MUTEX #ifndef NO_AFS_CLIENT - TRY_KERNEL (KTC_LISTTOKENS_OP, aserver, aprevIndex, aindex, 0); + TRY_KERNEL(KTC_LISTTOKENS_OP, aserver, aprevIndex, aindex, 0); #endif /* NO_AFS_CLIENT */ index = aprevIndex; #ifdef NO_AFS_CLIENT - if (index < 214) index = 214; + if (index < 214) + index = 214; #endif /* NO_AFS_CLIENT */ #ifdef AFS_KERBEROS_ENV - if (index >= 214) { - int i; - struct ktc_principal cprincipal; - struct ktc_token ctoken; - - if (afs_tf_init(ktc_tkt_string(), R_TKT_FIL) || - afs_tf_get_pname(tbuffer) || - afs_tf_get_pinst(tbuffer)) { - afs_tf_close(); - UNLOCK_GLOBAL_MUTEX - return KTC_NOENT; - } - - for (i=214; i= 214) { + int i; + struct ktc_principal cprincipal; + struct ktc_token ctoken; + + if (afs_tf_init(ktc_tkt_string(), R_TKT_FIL) + || afs_tf_get_pname(tbuffer) || afs_tf_get_pinst(tbuffer)) { + afs_tf_close(); + UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + } + + for (i = 214; i < index; i++) { + if (afs_tf_get_cred(&cprincipal, &ctoken)) { + afs_tf_close(); + UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + } + } + + again: + if (afs_tf_get_cred(&cprincipal, &ctoken)) { + afs_tf_close(); + UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + } + index++; + #ifndef NO_AFS_CLIENT - if (!strcmp(cprincipal.name, "afs") && cprincipal.instance[0]==0) { - goto again; - } + if (!strcmp(cprincipal.name, "afs") && cprincipal.instance[0] == 0) { + goto again; + } #endif /* NO_AFS_CLIENT */ - - for (i=0; i < MAXLOCALTOKENS; i++) { - if (!strcmp(cprincipal.name, local_tokens[i].server.name) && - !strcmp(cprincipal.instance, local_tokens[i].server.instance) && - !strcmp(cprincipal.cell, local_tokens[i].server.cell)) { - goto again; - } - } - - *aserver = cprincipal; - *aindex = index; - afs_tf_close(); - UNLOCK_GLOBAL_MUTEX - return 0; - } + + for (i = 0; i < MAXLOCALTOKENS; i++) { + if (!strcmp(cprincipal.name, local_tokens[i].server.name) + && !strcmp(cprincipal.instance, + local_tokens[i].server.instance) + && !strcmp(cprincipal.cell, local_tokens[i].server.cell)) { + goto again; + } + } + + *aserver = cprincipal; + *aindex = index; + afs_tf_close(); + UNLOCK_GLOBAL_MUTEX return 0; + } #endif #ifndef NO_AFS_CLIENT - if (index >= 123) { /* special hack for returning TCS */ - while (index-123 < MAXLOCALTOKENS) { - if (local_tokens[index-123].valid) { - *aserver = local_tokens[index-123].server; - *aindex = index+1; - UNLOCK_GLOBAL_MUTEX - return 0; + if (index >= 123) { /* special hack for returning TCS */ + while (index - 123 < MAXLOCALTOKENS) { + if (local_tokens[index - 123].valid) { + *aserver = local_tokens[index - 123].server; + *aindex = index + 1; + UNLOCK_GLOBAL_MUTEX return 0; } index++; } UNLOCK_GLOBAL_MUTEX #ifdef AFS_KERBEROS_ENV - return ktc_ListTokens(214, aindex, aserver); + return ktc_ListTokens(214, aindex, aserver); #else - return KTC_NOENT; + return KTC_NOENT; #endif } /* get tokens from the kernel */ - while (index<200) { /* sanity check in case pioctl fails */ - iob.in = (char *) &index; + while (index < 200) { /* sanity check in case pioctl fails */ + iob.in = (char *)&index; iob.in_size = sizeof(afs_int32); iob.out = tbuffer; iob.out_size = sizeof(tbuffer); @@ -748,22 +772,20 @@ struct ktc_principal *aserver; { if (code < 0 && errno == EDOM) { if (index < 123) { int rc; - rc = ktc_ListTokens (123, aindex, aserver); - UNLOCK_GLOBAL_MUTEX - return rc; - } - else { - UNLOCK_GLOBAL_MUTEX - return KTC_NOENT; + rc = ktc_ListTokens(123, aindex, aserver); + UNLOCK_GLOBAL_MUTEX return rc; + } else { + UNLOCK_GLOBAL_MUTEX return KTC_NOENT; } } - if (code == 0) break; /* got a ticket */ + if (code == 0) + break; /* got a ticket */ /* otherwise we should skip this ticket slot */ index++; } if (code < 0) { - UNLOCK_GLOBAL_MUTEX - if (errno == EINVAL) return KTC_NOPIOCTL; + UNLOCK_GLOBAL_MUTEX if (errno == EINVAL) + return KTC_NOPIOCTL; return KTC_PIOCTLFAIL; } @@ -771,45 +793,46 @@ struct ktc_principal *aserver; { tp = tbuffer; /* next iterator determined by earlier loop */ - *aindex = index+1; + *aindex = index + 1; - memcpy(&temp, tp, sizeof(afs_int32)); /* get size of secret token */ + memcpy(&temp, tp, sizeof(afs_int32)); /* get size of secret token */ tp += sizeof(afs_int32); - tp += temp; /* skip ticket for now */ - memcpy(&temp, tp, sizeof(afs_int32)); /* get size of clear token */ + tp += temp; /* skip ticket for now */ + memcpy(&temp, tp, sizeof(afs_int32)); /* get size of clear token */ if (temp != sizeof(struct ClearToken)) { - UNLOCK_GLOBAL_MUTEX - return KTC_ERROR; + UNLOCK_GLOBAL_MUTEX return KTC_ERROR; } - tp += sizeof(afs_int32); /* skip length */ - tp += temp; /* skip clear token itself */ - tp += sizeof(afs_int32); /* skip primary flag */ + tp += sizeof(afs_int32); /* skip length */ + tp += temp; /* skip clear token itself */ + tp += sizeof(afs_int32); /* skip primary flag */ /* tp now points to the cell name */ strcpy(aserver->cell, tp); aserver->instance[0] = 0; strcpy(aserver->name, "afs"); #endif /* NO_AFS_CLIENT */ - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } /* discard all tokens from this user's cache */ -static int NewForgetAll () +static int +NewForgetAll() { #ifndef NO_AFS_CLIENT - TRY_KERNEL (KTC_FORGETALLTOKENS_OP, 0,0,0,0); + TRY_KERNEL(KTC_FORGETALLTOKENS_OP, 0, 0, 0, 0); #endif /* NO_AFS_CLIENT */ return EINVAL; } -static int OldForgetAll () +static int +OldForgetAll() { struct ViceIoctl iob; register afs_int32 code; int i; - for (i=0; i. */ - + #if 0 #include #include @@ -878,12 +903,12 @@ ktc_OldPioctl () #include #include #endif - + #define TOO_BIG -1 #define TF_LCK_RETRY ((unsigned)2) /* seconds to sleep before - * retry if ticket file is - * locked */ - + * retry if ticket file is + * locked */ + /* * fd must be initialized to something that won't ever occur as a real * file descriptor. Since open(2) returns only non-negative numbers as @@ -897,13 +922,13 @@ ktc_OldPioctl () * c. In tf_close, be sure it gets reinitialized to a negative * number. */ -static fd = -1; -static curpos; /* Position in tfbfr */ -static lastpos; /* End of tfbfr */ -static char tfbfr[BUFSIZ]; /* Buffer for ticket data */ - +static fd = -1; +static curpos; /* Position in tfbfr */ +static lastpos; /* End of tfbfr */ +static char tfbfr[BUFSIZ]; /* Buffer for ticket data */ + static tf_gets(), tf_read(); - + /* * This file contains routines for manipulating the ticket cache file. * @@ -966,39 +991,39 @@ static tf_gets(), tf_read(); * TKT_FIL_ACC - file was in wrong mode, etc. * TKT_FIL_LCK - couldn't lock the file, even after a retry */ - + afs_tf_init(tf_name, rw) - char *tf_name; + char *tf_name; { - int wflag; - int me; - struct stat stat_buf; - - switch (rw) { - case R_TKT_FIL: - wflag = 0; - break; - case W_TKT_FIL: - wflag = 1; - break; - default: - return TKT_FIL_ACC; - } - if (lstat(tf_name, &stat_buf) < 0) - switch (errno) { - case ENOENT: - return NO_TKT_FIL; - default: - return TKT_FIL_ACC; - } - me = getuid(); - if ((stat_buf.st_uid != me && me != 0) || - ((stat_buf.st_mode & S_IFMT) != S_IFREG)) - return TKT_FIL_ACC; - - /* - * If "wflag" is set, open the ticket file in append-writeonly mode - * and lock the ticket file in exclusive mode. If unable to lock + int wflag; + int me; + struct stat stat_buf; + + switch (rw) { + case R_TKT_FIL: + wflag = 0; + break; + case W_TKT_FIL: + wflag = 1; + break; + default: + return TKT_FIL_ACC; + } + if (lstat(tf_name, &stat_buf) < 0) + switch (errno) { + case ENOENT: + return NO_TKT_FIL; + default: + return TKT_FIL_ACC; + } + me = getuid(); + if ((stat_buf.st_uid != me && me != 0) + || ((stat_buf.st_mode & S_IFMT) != S_IFREG)) + return TKT_FIL_ACC; + + /* + * If "wflag" is set, open the ticket file in append-writeonly mode + * and lock the ticket file in exclusive mode. If unable to lock * the file, sleep and try again. If we fail again, return with the * proper error message. */ @@ -1011,15 +1036,15 @@ afs_tf_init(tf_name, rw) return TKT_FIL_ACC; } #if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) - if (fcntl(fd, F_SETLK, &fileWlock) == -1) { + if (fcntl(fd, F_SETLK, &fileWlock) == -1) { sleep(TF_LCK_RETRY); - if (fcntl(fd, F_SETLK, &fileWlock) == -1) { + if (fcntl(fd, F_SETLK, &fileWlock) == -1) { #else if (flock(fd, LOCK_EX | LOCK_NB) < 0) { sleep(TF_LCK_RETRY); if (flock(fd, LOCK_EX | LOCK_NB) < 0) { #endif - (void) close(fd); + (void)close(fd); fd = -1; return TKT_FIL_LCK; } @@ -1036,15 +1061,15 @@ afs_tf_init(tf_name, rw) return TKT_FIL_ACC; } #if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) - if (fcntl(fd, F_SETLK, &fileRlock) == -1) { + if (fcntl(fd, F_SETLK, &fileRlock) == -1) { sleep(TF_LCK_RETRY); - if (fcntl(fd, F_SETLK, &fileRlock) == -1) { + if (fcntl(fd, F_SETLK, &fileRlock) == -1) { #else if (flock(fd, LOCK_SH | LOCK_NB) < 0) { sleep(TF_LCK_RETRY); if (flock(fd, LOCK_SH | LOCK_NB) < 0) { #endif - (void) close(fd); + (void)close(fd); fd = -1; return TKT_FIL_LCK; } @@ -1062,7 +1087,7 @@ afs_tf_init(tf_name, rw) */ afs_tf_get_pname(p) - char *p; + char *p; { if (fd < 0) { return TKT_FIL_INI; @@ -1083,7 +1108,7 @@ afs_tf_get_pname(p) */ afs_tf_get_pinst(inst) - char *inst; + char *inst; { if (fd < 0) { return TKT_FIL_INI; @@ -1105,11 +1130,11 @@ afs_tf_get_pinst(inst) */ afs_tf_get_cred(principal, token) - struct ktc_principal *principal; - struct ktc_token *token; + struct ktc_principal *principal; + struct ktc_token *token; { - int k_errno; - int kvno, lifetime; + int k_errno; + int kvno, lifetime; if (fd < 0) { return TKT_FIL_INI; @@ -1138,17 +1163,16 @@ afs_tf_get_cred(principal, token) return EOF; } lcstring(principal->cell, principal->cell, MAXKTCREALMLEN); - if ( - tf_read((char *) &(token->sessionKey), 8) < 1 || - tf_read((char *) &(lifetime), sizeof(lifetime)) < 1 || - tf_read((char *) &(kvno), sizeof(kvno)) < 1 || - tf_read((char *) &(token->ticketLen), sizeof(token->ticketLen)) + if (tf_read((char *)&(token->sessionKey), 8) < 1 + || tf_read((char *)&(lifetime), sizeof(lifetime)) < 1 + || tf_read((char *)&(kvno), sizeof(kvno)) < 1 + || tf_read((char *)&(token->ticketLen), sizeof(token->ticketLen)) < 1 || - /* don't try to read a silly amount into ticket->dat */ - token->ticketLen > MAXKTCTICKETLEN || - tf_read((char *) (token->ticket), token->ticketLen) < 1 || - tf_read((char *) &(token->startTime), sizeof(token->startTime)) < 1 - ) { + /* don't try to read a silly amount into ticket->dat */ + token->ticketLen > MAXKTCTICKETLEN + || tf_read((char *)(token->ticket), token->ticketLen) < 1 + || tf_read((char *)&(token->startTime), + sizeof(token->startTime)) < 1) { return TKT_FIL_FMT; } token->endTime = life_to_time(token->startTime, lifetime); @@ -1168,11 +1192,11 @@ afs_tf_close() { if (!(fd < 0)) { #if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) - (void) fcntl(fd, F_SETLK, &fileUlock); + (void)fcntl(fd, F_SETLK, &fileUlock); #else - (void) flock(fd, LOCK_UN); -#endif - (void) close(fd); + (void)flock(fd, LOCK_UN); +#endif + (void)close(fd); fd = -1; /* see declaration of fd above */ } memset(tfbfr, 0, sizeof(tfbfr)); @@ -1196,9 +1220,9 @@ afs_tf_close() * file is seriously ill. */ -static +static tf_gets(s, n) - register char *s; + register char *s; { register count; @@ -1214,7 +1238,7 @@ tf_gets(s, n) return 0; } *s = tfbfr[curpos++]; - if (*s++== '\0') + if (*s++ == '\0') return (n - count); } return TOO_BIG; @@ -1234,11 +1258,11 @@ tf_gets(s, n) static tf_read(s, n) - register char *s; - register n; + register char *s; + register n; { register count; - + for (count = n; count > 0; --count) { if (curpos >= sizeof(tfbfr)) { lastpos = read(fd, tfbfr, sizeof(tfbfr)); @@ -1251,8 +1275,8 @@ tf_read(s, n) } return n; } - -char *tkt_string(); + +char *tkt_string(); /* * afs_tf_save_cred() appends an incoming ticket to the end of the ticket @@ -1266,47 +1290,50 @@ char *tkt_string(); */ afs_tf_save_cred(aserver, atoken, aclient) - struct ktc_principal *aserver; - struct ktc_principal *aclient; - struct ktc_token *atoken; /* Token */ + struct ktc_principal *aserver; + struct ktc_principal *aclient; + struct ktc_token *atoken; /* Token */ { - char realm[MAXKTCREALMLEN+1]; + char realm[MAXKTCREALMLEN + 1]; char junk[MAXKTCNAMELEN]; struct ktc_principal principal; struct ktc_token token; - int status; - off_t start; - int lifetime, kvno; - int count; /* count for write */ + int status; + off_t start; + int lifetime, kvno; + int count; /* count for write */ if (fd < 0) { /* fd is ticket file as set by afs_tf_init */ - return TKT_FIL_INI; + return TKT_FIL_INI; } ucstring(realm, aserver->cell, MAXKTCREALMLEN); realm[MAXKTCREALMLEN] = '\0'; /* Look for a duplicate ticket */ - (void) lseek(fd, (off_t) 0L, 0); + (void)lseek(fd, (off_t) 0L, 0); curpos = sizeof(tfbfr); - if (afs_tf_get_pname(junk) || strcmp(junk, aclient->name) || - afs_tf_get_pinst(junk) || strcmp(junk, aclient->instance)) goto bad; + if (afs_tf_get_pname(junk) || strcmp(junk, aclient->name) + || afs_tf_get_pinst(junk) || strcmp(junk, aclient->instance)) + goto bad; do { start = lseek(fd, (off_t) 0L, 1) - lastpos + curpos; status = afs_tf_get_cred(&principal, &token); - } while (status == 0 && - (strcmp(aserver->name, principal.name) != 0 || - strcmp(aserver->instance, principal.instance) != 0 || - strcmp(aserver->cell, principal.cell) != 0)); + } while (status == 0 + && (strcmp(aserver->name, principal.name) != 0 + || strcmp(aserver->instance, principal.instance) != 0 + || strcmp(aserver->cell, principal.cell) != 0)); /* * Two tickets for the same user authenticating to the same service * should be the same length, but we check here just to make sure. */ - if (status == 0 && token.ticketLen != atoken->ticketLen) return KFAILURE; - if (status && status != EOF) return status; + if (status == 0 && token.ticketLen != atoken->ticketLen) + return KFAILURE; + if (status && status != EOF) + return status; /* Position over the credential we just matched (or the EOF) */ lseek(fd, start, 0); @@ -1326,32 +1353,31 @@ afs_tf_save_cred(aserver, atoken, aclient) if (write(fd, realm, count) != count) goto bad; /* Session key */ - if (write(fd, (char *) &atoken->sessionKey, 8) != 8) + if (write(fd, (char *)&atoken->sessionKey, 8) != 8) goto bad; /* Lifetime */ lifetime = time_to_life(atoken->startTime, atoken->endTime); - if (write(fd, (char *) &lifetime, sizeof(int)) != sizeof(int)) + if (write(fd, (char *)&lifetime, sizeof(int)) != sizeof(int)) goto bad; /* Key vno */ kvno = atoken->kvno; - if (write(fd, (char *) &kvno, sizeof(int)) != sizeof(int)) + if (write(fd, (char *)&kvno, sizeof(int)) != sizeof(int)) goto bad; /* Tkt length */ - if (write(fd, (char *) &(atoken->ticketLen), sizeof(int)) != - sizeof(int)) + if (write(fd, (char *)&(atoken->ticketLen), sizeof(int)) != sizeof(int)) goto bad; /* Ticket */ count = atoken->ticketLen; if (write(fd, atoken->ticket, count) != count) goto bad; /* Issue date */ - if (write(fd, (char *) &atoken->startTime, sizeof(afs_int32)) + if (write(fd, (char *)&atoken->startTime, sizeof(afs_int32)) != sizeof(afs_int32)) goto bad; /* Actually, we should check each write for success */ return (0); -bad: + bad: return (KFAILURE); } @@ -1381,24 +1407,23 @@ char *getenv(); static char krb_ticket_string[4096] = ""; -char *ktc_tkt_string() +char * +ktc_tkt_string() { char *env; - LOCK_GLOBAL_MUTEX - if (!*krb_ticket_string) { - if (env = getenv("KRBTKFILE")) { - (void) strncpy(krb_ticket_string, env, - sizeof(krb_ticket_string)-1); - krb_ticket_string[sizeof(krb_ticket_string)-1] = '\0'; + LOCK_GLOBAL_MUTEX if (!*krb_ticket_string) { + if (env = getenv("KRBTKFILE")) { + (void)strncpy(krb_ticket_string, env, + sizeof(krb_ticket_string) - 1); + krb_ticket_string[sizeof(krb_ticket_string) - 1] = '\0'; } else { /* 32 bits of signed integer will always fit in 11 characters - (including the sign), so no need to worry about overflow */ - (void) sprintf(krb_ticket_string, "%s%d",TKT_ROOT,getuid()); - } + * (including the sign), so no need to worry about overflow */ + (void)sprintf(krb_ticket_string, "%s%d", TKT_ROOT, getuid()); + } } - UNLOCK_GLOBAL_MUTEX - return krb_ticket_string; + UNLOCK_GLOBAL_MUTEX return krb_ticket_string; } /* @@ -1414,15 +1439,13 @@ char *ktc_tkt_string() void ktc_set_tkt_string(val) -char *val; + char *val; { - LOCK_GLOBAL_MUTEX - (void) strncpy(krb_ticket_string, val, sizeof(krb_ticket_string)-1); - krb_ticket_string[sizeof(krb_ticket_string)-1] = '\0'; - UNLOCK_GLOBAL_MUTEX - - return; + LOCK_GLOBAL_MUTEX(void) strncpy(krb_ticket_string, val, + sizeof(krb_ticket_string) - 1); + krb_ticket_string[sizeof(krb_ticket_string) - 1] = '\0'; + UNLOCK_GLOBAL_MUTEX return; } /* @@ -1432,9 +1455,9 @@ char *val; * success, or KFAILURE if something goes wrong. */ -afs_tf_create(pname,pinst) - char *pname; - char *pinst; +afs_tf_create(pname, pinst) + char *pname; + char *pinst; { int tktfile; int me, metoo; @@ -1445,63 +1468,63 @@ afs_tf_create(pname,pinst) char zerobuf[1024]; struct stat sbuf; - me = getuid (); + me = getuid(); metoo = geteuid(); - if (lstat(file,&sbuf) == 0) { - if ((sbuf.st_uid != me && me != 0) || ((sbuf.st_mode & S_IFMT) != S_IFREG) || - sbuf.st_mode & 077) { + if (lstat(file, &sbuf) == 0) { + if ((sbuf.st_uid != me && me != 0) + || ((sbuf.st_mode & S_IFMT) != S_IFREG) || sbuf.st_mode & 077) { return KFAILURE; } /* file already exists, and permissions appear ok, so nuke it */ if ((fd = open(file, O_RDWR, 0)) < 0) - goto out; /* can't zero it, but we can still try truncating it */ + goto out; /* can't zero it, but we can still try truncating it */ memset(zerobuf, 0, sizeof(zerobuf)); for (i = 0; i < sbuf.st_size; i += sizeof(zerobuf)) if (write(fd, zerobuf, sizeof(zerobuf)) != sizeof(zerobuf)) { - (void) fsync(fd); - (void) close(fd); + (void)fsync(fd); + (void)close(fd); goto out; } - - (void) fsync(fd); - (void) close(fd); + + (void)fsync(fd); + (void)close(fd); } - out: + out: /* arrange so the file is owned by the ruid - (swap real & effective uid if necessary). - This isn't a security problem, since the ticket file, if it already - exists, has the right uid (== ruid) and mode. */ + * (swap real & effective uid if necessary). + * This isn't a security problem, since the ticket file, if it already + * exists, has the right uid (== ruid) and mode. */ if (me != metoo) { if (setreuid(metoo, me) < 0) { - return(KFAILURE); + return (KFAILURE); } } tktfile = creat(file, 0600); if (me != metoo) { if (setreuid(me, metoo) < 0) { /* can't switch??? fail! */ - return(KFAILURE); + return (KFAILURE); } } if (tktfile < 0) { - return(KFAILURE); + return (KFAILURE); } - count = strlen(pname)+1; - if (write(tktfile,pname,count) != count) { - (void) close(tktfile); - return(KFAILURE); + count = strlen(pname) + 1; + if (write(tktfile, pname, count) != count) { + (void)close(tktfile); + return (KFAILURE); } - count = strlen(pinst)+1; - if (write(tktfile,pinst,count) != count) { - (void) close(tktfile); - return(KFAILURE); + count = strlen(pinst) + 1; + if (write(tktfile, pinst, count) != count) { + (void)close(tktfile); + return (KFAILURE); } - (void) close(tktfile); - return(KSUCCESS); + (void)close(tktfile); + return (KSUCCESS); } /* @@ -1514,12 +1537,12 @@ afs_tf_create(pname,pinst) afs_tf_dest_tkt() { char *file = ktc_tkt_string(); - int i,fd; + int i, fd; struct stat statb; char buf[BUFSIZ]; errno = 0; - if (lstat(file,&statb) < 0) + if (lstat(file, &statb) < 0) goto out; if (!(statb.st_mode & S_IFREG)) @@ -1532,32 +1555,36 @@ afs_tf_dest_tkt() for (i = 0; i < statb.st_size; i += BUFSIZ) if (write(fd, buf, BUFSIZ) != BUFSIZ) { - (void) fsync(fd); - (void) close(fd); + (void)fsync(fd); + (void)close(fd); goto out; } - (void) fsync(fd); - (void) close(fd); + (void)fsync(fd); + (void)close(fd); - (void) unlink(file); + (void)unlink(file); -out: - if (errno == ENOENT) return RET_TKFIL; - else if (errno != 0) return KFAILURE; + out: + if (errno == ENOENT) + return RET_TKFIL; + else if (errno != 0) + return KFAILURE; return 0; } -static afs_uint32 curpag() +static afs_uint32 +curpag() { gid_t groups[NGROUPS_MAX]; afs_uint32 g0, g1; afs_uint32 h, l, ret; - if (getgroups(sizeof groups/sizeof groups[0], groups) < 2) return 0; + if (getgroups(sizeof groups / sizeof groups[0], groups) < 2) + return 0; - g0 = groups[0] & 0xffff; - g1 = groups[1] & 0xffff; + g0 = groups[0] & 0xffff; + g1 = groups[1] & 0xffff; g0 -= 0x3f00; g1 -= 0x3f00; if (g0 < 0xc000 && g1 < 0xc000) { @@ -1573,7 +1600,7 @@ static afs_uint32 curpag() } return -1; } - + ktc_newpag() { @@ -1585,25 +1612,25 @@ ktc_newpag() int numenv; char **newenv, **senv, **denv; - LOCK_GLOBAL_MUTEX - if (stat("/ticket", &sbuf) == -1) { + LOCK_GLOBAL_MUTEX if (stat("/ticket", &sbuf) == -1) { prefix = "/tmp/tkt"; } pag = curpag() & 0xffffffff; if (pag == -1) { sprintf(fname, "%s%d", prefix, getuid()); - } - else { + } else { sprintf(fname, "%sp%ld", prefix, pag); } ktc_set_tkt_string(fname); - for (senv=environ, numenv=0; *senv; senv++) numenv++; - newenv = (char **)malloc((numenv+2) * sizeof(char *)); + for (senv = environ, numenv = 0; *senv; senv++) + numenv++; + newenv = (char **)malloc((numenv + 2) * sizeof(char *)); - for (senv=environ, denv=newenv; *senv; *senv++) { - if (strncmp(*senv, "KRBTKFILE=", 10) != 0) *denv++ = *senv; + for (senv = environ, denv = newenv; *senv; *senv++) { + if (strncmp(*senv, "KRBTKFILE=", 10) != 0) + *denv++ = *senv; } *denv = (char *)malloc(10 + strlen(fname) + 1); @@ -1611,22 +1638,22 @@ ktc_newpag() strcat(*denv, fname); *++denv = 0; environ = newenv; - UNLOCK_GLOBAL_MUTEX -} +UNLOCK_GLOBAL_MUTEX} /* * BLETCH! We have to invoke the entire afsconf package just to * find out what the local cell is. */ -static void ktc_LocalCell() +static void +ktc_LocalCell() { int code; struct afsconf_dir *conf; - if ((conf = afsconf_Open (AFSDIR_CLIENT_ETC_DIRPATH)) || - (conf = afsconf_Open (AFSDIR_SERVER_ETC_DIRPATH ))) { - code = afsconf_GetLocalCell (conf, lcell, sizeof(lcell)); - afsconf_Close (conf); + if ((conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH)) + || (conf = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH))) { + code = afsconf_GetLocalCell(conf, lcell, sizeof(lcell)); + afsconf_Close(conf); } if (!conf || code) { printf("** Can't determine local cell name!\n"); diff --git a/src/auth/ktc_nt.c b/src/auth/ktc_nt.c index cd6456143..12780aee2 100644 --- a/src/auth/ktc_nt.c +++ b/src/auth/ktc_nt.c @@ -12,7 +12,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -34,18 +35,16 @@ RCSID("$Header$"); /* Forward declarations for local token cache. */ static int SetLocalToken(struct ktc_principal *aserver, struct ktc_token *atoken, - struct ktc_principal *aclient, - afs_int32 flags); + struct ktc_principal *aclient, afs_int32 flags); static int GetLocalToken(struct ktc_principal *aserver, - struct ktc_token *atoken, - int atokenLen, + struct ktc_token *atoken, int atokenLen, struct ktc_principal *aclient); static int ForgetLocalTokens(); static int ForgetOneLocalToken(struct ktc_principal *aserver); static char AFSConfigKeyName[] = - "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"; + "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"; /* * Support for RPC's to send and receive session keys @@ -58,14 +57,16 @@ static char AFSConfigKeyName[] = char rpcErr[256]; -void __RPC_FAR * __RPC_USER midl_user_allocate (size_t cBytes) +void __RPC_FAR *__RPC_USER +midl_user_allocate(size_t cBytes) { - return ((void __RPC_FAR *) malloc(cBytes)); + return ((void __RPC_FAR *)malloc(cBytes)); } -void __RPC_USER midl_user_free(void __RPC_FAR * p) +void __RPC_USER +midl_user_free(void __RPC_FAR * p) { - free(p); + free(p); } /* @@ -73,607 +74,590 @@ void __RPC_USER midl_user_free(void __RPC_FAR * p) * the same as the client (i.e. standalone, non-gateway), NULL can be * used, so it is not necessary to call gethostbyname(). */ -void getservername(char **snp, unsigned int snSize) +void +getservername(char **snp, unsigned int snSize) { - HKEY parmKey; - long code; - - code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, - 0, KEY_QUERY_VALUE, &parmKey); - if (code != ERROR_SUCCESS) - goto nogateway; - code = RegQueryValueEx(parmKey, "Gateway", NULL, NULL, - *snp, &snSize); - RegCloseKey (parmKey); - if (code == ERROR_SUCCESS) - return; -nogateway: - /* No gateway name in registry; use ourself */ - *snp = NULL; + HKEY parmKey; + long code; + + code = + RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, 0, KEY_QUERY_VALUE, + &parmKey); + if (code != ERROR_SUCCESS) + goto nogateway; + code = RegQueryValueEx(parmKey, "Gateway", NULL, NULL, *snp, &snSize); + RegCloseKey(parmKey); + if (code == ERROR_SUCCESS) + return; + nogateway: + /* No gateway name in registry; use ourself */ + *snp = NULL; } -RPC_STATUS send_key(afs_uuid_t uuid, char sessionKey[8]) +RPC_STATUS +send_key(afs_uuid_t uuid, char sessionKey[8]) { - RPC_STATUS status; - char *stringBinding = NULL; - ULONG authnLevel, authnSvc; - char serverName[256]; - char *serverNamep = serverName; - char encrypt[32]; - BOOL encryptionOff = FALSE; - char protseq[32]; - - /* Encryption on by default */ - if (GetEnvironmentVariable("AFS_RPC_ENCRYPT", - encrypt, sizeof(encrypt))) - if (!strcmpi(encrypt, "OFF")) - encryptionOff = TRUE; - - /* Protocol sequence is named pipe by default */ - if (!GetEnvironmentVariable("AFS_RPC_PROTSEQ", - protseq, sizeof(protseq))) - strcpy(protseq, "ncacn_np"); - - /* Server name */ - getservername(&serverNamep, sizeof(serverName)); - - status = RpcStringBindingCompose("", /* obj uuid */ - protseq, - serverNamep, - "", /* endpoint */ - "", /* protocol options */ - &stringBinding); - if (status != RPC_S_OK) - goto cleanup; - - status = RpcBindingFromStringBinding(stringBinding, &hAfsHandle); - if (status != RPC_S_OK) - goto cleanup; - - /* - * On Windows 95/98, we must resolve the binding before calling - * SetAuthInfo. On Windows NT, we don't have to resolve yet, - * but it does no harm. - */ - status = RpcEpResolveBinding(hAfsHandle, afsrpc_v1_0_c_ifspec); - if (status != RPC_S_OK) - goto cleanup; - - if (encryptionOff) { - authnLevel = RPC_C_AUTHN_LEVEL_NONE; - authnSvc = RPC_C_AUTHN_WINNT; - } else { - authnLevel = RPC_C_AUTHN_LEVEL_PKT_PRIVACY; - authnSvc = RPC_C_AUTHN_WINNT; - } - - status = RpcBindingSetAuthInfo(hAfsHandle, NULL, authnLevel, authnSvc, - NULL, RPC_C_AUTHZ_NONE); - if (status != RPC_S_OK) - goto cleanup; + RPC_STATUS status; + char *stringBinding = NULL; + ULONG authnLevel, authnSvc; + char serverName[256]; + char *serverNamep = serverName; + char encrypt[32]; + BOOL encryptionOff = FALSE; + char protseq[32]; + + /* Encryption on by default */ + if (GetEnvironmentVariable("AFS_RPC_ENCRYPT", encrypt, sizeof(encrypt))) + if (!strcmpi(encrypt, "OFF")) + encryptionOff = TRUE; + + /* Protocol sequence is named pipe by default */ + if (!GetEnvironmentVariable("AFS_RPC_PROTSEQ", protseq, sizeof(protseq))) + strcpy(protseq, "ncacn_np"); + + /* Server name */ + getservername(&serverNamep, sizeof(serverName)); + + status = RpcStringBindingCompose("", /* obj uuid */ + protseq, serverNamep, "", /* endpoint */ + "", /* protocol options */ + &stringBinding); + if (status != RPC_S_OK) + goto cleanup; + + status = RpcBindingFromStringBinding(stringBinding, &hAfsHandle); + if (status != RPC_S_OK) + goto cleanup; + + /* + * On Windows 95/98, we must resolve the binding before calling + * SetAuthInfo. On Windows NT, we don't have to resolve yet, + * but it does no harm. + */ + status = RpcEpResolveBinding(hAfsHandle, afsrpc_v1_0_c_ifspec); + if (status != RPC_S_OK) + goto cleanup; + + if (encryptionOff) { + authnLevel = RPC_C_AUTHN_LEVEL_NONE; + authnSvc = RPC_C_AUTHN_WINNT; + } else { + authnLevel = RPC_C_AUTHN_LEVEL_PKT_PRIVACY; + authnSvc = RPC_C_AUTHN_WINNT; + } - RpcTryExcept { - status = AFSRPC_SetToken(uuid, sessionKey); - } - RpcExcept(1) { - status = RpcExceptionCode(); - } - RpcEndExcept + status = + RpcBindingSetAuthInfo(hAfsHandle, NULL, authnLevel, authnSvc, NULL, + RPC_C_AUTHZ_NONE); + if (status != RPC_S_OK) + goto cleanup; -cleanup: - if (stringBinding) - RpcStringFree(&stringBinding); + RpcTryExcept { + status = AFSRPC_SetToken(uuid, sessionKey); + } + RpcExcept(1) { + status = RpcExceptionCode(); + } + RpcEndExcept cleanup:if (stringBinding) + RpcStringFree(&stringBinding); - if (hAfsHandle != NULL) - RpcBindingFree(&hAfsHandle); + if (hAfsHandle != NULL) + RpcBindingFree(&hAfsHandle); - return status; + return status; } -RPC_STATUS receive_key(afs_uuid_t uuid, char sessionKey[8]) +RPC_STATUS +receive_key(afs_uuid_t uuid, char sessionKey[8]) { - RPC_STATUS status; - char *stringBinding = NULL; - ULONG authnLevel, authnSvc; - char serverName[256]; - char *serverNamep = serverName; - char encrypt[32]; - BOOL encryptionOff = FALSE; - char protseq[32]; - - /* Encryption on by default */ - if (GetEnvironmentVariable("AFS_RPC_ENCRYPT", - encrypt, sizeof(encrypt))) - if (!strcmpi(encrypt, "OFF")) - encryptionOff = TRUE; - - /* Protocol sequence is named pipe by default */ - if (!GetEnvironmentVariable("AFS_RPC_PROTSEQ", - protseq, sizeof(protseq))) - strcpy(protseq, "ncacn_np"); - - /* Server name */ - getservername(&serverNamep, sizeof(serverName)); - - status = RpcStringBindingCompose("", /* obj uuid */ - protseq, - serverNamep, - "", /* endpoint */ - "", /* protocol options */ - &stringBinding); - if (status != RPC_S_OK) - goto cleanup; - - status = RpcBindingFromStringBinding(stringBinding, &hAfsHandle); - if (status != RPC_S_OK) - goto cleanup; - - /* - * On Windows 95/98, we must resolve the binding before calling - * SetAuthInfo. On Windows NT, we don't have to resolve yet, - * but it does no harm. - */ - status = RpcEpResolveBinding(hAfsHandle, afsrpc_v1_0_c_ifspec); - if (status != RPC_S_OK) - goto cleanup; - - if (encryptionOff) { - authnLevel = RPC_C_AUTHN_LEVEL_NONE; - authnSvc = RPC_C_AUTHN_WINNT; - } else { - authnLevel = RPC_C_AUTHN_LEVEL_PKT_PRIVACY; - authnSvc = RPC_C_AUTHN_WINNT; - } + RPC_STATUS status; + char *stringBinding = NULL; + ULONG authnLevel, authnSvc; + char serverName[256]; + char *serverNamep = serverName; + char encrypt[32]; + BOOL encryptionOff = FALSE; + char protseq[32]; + + /* Encryption on by default */ + if (GetEnvironmentVariable("AFS_RPC_ENCRYPT", encrypt, sizeof(encrypt))) + if (!strcmpi(encrypt, "OFF")) + encryptionOff = TRUE; + + /* Protocol sequence is named pipe by default */ + if (!GetEnvironmentVariable("AFS_RPC_PROTSEQ", protseq, sizeof(protseq))) + strcpy(protseq, "ncacn_np"); + + /* Server name */ + getservername(&serverNamep, sizeof(serverName)); + + status = RpcStringBindingCompose("", /* obj uuid */ + protseq, serverNamep, "", /* endpoint */ + "", /* protocol options */ + &stringBinding); + if (status != RPC_S_OK) + goto cleanup; + + status = RpcBindingFromStringBinding(stringBinding, &hAfsHandle); + if (status != RPC_S_OK) + goto cleanup; + + /* + * On Windows 95/98, we must resolve the binding before calling + * SetAuthInfo. On Windows NT, we don't have to resolve yet, + * but it does no harm. + */ + status = RpcEpResolveBinding(hAfsHandle, afsrpc_v1_0_c_ifspec); + if (status != RPC_S_OK) + goto cleanup; + + if (encryptionOff) { + authnLevel = RPC_C_AUTHN_LEVEL_NONE; + authnSvc = RPC_C_AUTHN_WINNT; + } else { + authnLevel = RPC_C_AUTHN_LEVEL_PKT_PRIVACY; + authnSvc = RPC_C_AUTHN_WINNT; + } - status = RpcBindingSetAuthInfo(hAfsHandle, NULL, authnLevel, authnSvc, - NULL, RPC_C_AUTHZ_NONE); - if (status != RPC_S_OK) - goto cleanup; + status = + RpcBindingSetAuthInfo(hAfsHandle, NULL, authnLevel, authnSvc, NULL, + RPC_C_AUTHZ_NONE); + if (status != RPC_S_OK) + goto cleanup; - RpcTryExcept { - status = AFSRPC_GetToken(uuid, sessionKey); - } - RpcExcept(1) { - status = RpcExceptionCode(); - } - RpcEndExcept - -cleanup: - if (stringBinding) - RpcStringFree(&stringBinding); + RpcTryExcept { + status = AFSRPC_GetToken(uuid, sessionKey); + } + RpcExcept(1) { + status = RpcExceptionCode(); + } + RpcEndExcept cleanup:if (stringBinding) + RpcStringFree(&stringBinding); - if (hAfsHandle != NULL) - RpcBindingFree(&hAfsHandle); + if (hAfsHandle != NULL) + RpcBindingFree(&hAfsHandle); - return status; + return status; } -int ktc_SetToken( - struct ktc_principal *server, - struct ktc_token *token, - struct ktc_principal *client, - int flags) +int +ktc_SetToken(struct ktc_principal *server, struct ktc_token *token, + struct ktc_principal *client, int flags) { - struct ViceIoctl iob; - char tbuffer[1024]; - char *tp; - struct ClearToken ct; - int temp; - int code; - RPC_STATUS status; - afs_uuid_t uuid; - - if (token->ticketLen < MINKTCTICKETLEN - || token->ticketLen > MAXKTCTICKETLEN) - return KTC_INVAL; - - if (strcmp(server->name, "afs")) { - return SetLocalToken(server, token, client, flags); - } + struct ViceIoctl iob; + char tbuffer[1024]; + char *tp; + struct ClearToken ct; + int temp; + int code; + RPC_STATUS status; + afs_uuid_t uuid; + + if (token->ticketLen < MINKTCTICKETLEN + || token->ticketLen > MAXKTCTICKETLEN) + return KTC_INVAL; + + if (strcmp(server->name, "afs")) { + return SetLocalToken(server, token, client, flags); + } - tp = tbuffer; + tp = tbuffer; - /* ticket length */ - memcpy(tp, &token->ticketLen, sizeof(token->ticketLen)); - tp += sizeof(&token->ticketLen); + /* ticket length */ + memcpy(tp, &token->ticketLen, sizeof(token->ticketLen)); + tp += sizeof(&token->ticketLen); - /* ticket */ - memcpy(tp, token->ticket, token->ticketLen); - tp += token->ticketLen; + /* ticket */ + memcpy(tp, token->ticket, token->ticketLen); + tp += token->ticketLen; - /* clear token */ - ct.AuthHandle = token->kvno; - /* - * Instead of sending the session key in the clear, we zero it, - * and send it later, via RPC, encrypted. - */ + /* clear token */ + ct.AuthHandle = token->kvno; + /* + * Instead of sending the session key in the clear, we zero it, + * and send it later, via RPC, encrypted. + */ #ifndef AFS_WIN95_ENV - /* - memcpy(ct.HandShakeKey, &token->sessionKey, sizeof(token->sessionKey)); - */ - memset(ct.HandShakeKey, 0, sizeof(ct.HandShakeKey)); + /* + * memcpy(ct.HandShakeKey, &token->sessionKey, sizeof(token->sessionKey)); + */ + memset(ct.HandShakeKey, 0, sizeof(ct.HandShakeKey)); #else - memcpy(ct.HandShakeKey, &token->sessionKey, sizeof(token->sessionKey)); + memcpy(ct.HandShakeKey, &token->sessionKey, sizeof(token->sessionKey)); #endif - ct.BeginTimestamp = token->startTime; - ct.EndTimestamp = token->endTime; - if (ct.BeginTimestamp == 0) ct.BeginTimestamp = 1; - - /* We don't know from Vice ID's yet */ - ct.ViceId = 37; /* XXX */ - if (((ct.EndTimestamp - ct.BeginTimestamp) & 1) == 1) - ct.BeginTimestamp++; /* force lifetime to be even */ - - /* size of clear token */ - temp = sizeof(struct ClearToken); - memcpy(tp, &temp, sizeof(temp)); - tp += sizeof(temp); - - /* clear token itself */ - memcpy(tp, &ct, sizeof(ct)); - tp += sizeof(ct); - - /* flags; on NT there is no setpag flag, but there is an - * integrated logon flag */ - temp = ((flags & AFS_SETTOK_LOGON) ? PIOCTL_LOGON : 0); - memcpy(tp, &temp, sizeof(temp)); - tp += sizeof(temp); - - /* cell name */ - temp = strlen(server->cell); - if (temp >= MAXKTCREALMLEN) - return KTC_INVAL; - strcpy(tp, server->cell); - tp += temp+1; - - /* user name */ - temp = strlen(client->name); - if (temp >= MAXKTCNAMELEN) - return KTC_INVAL; - strcpy(tp, client->name); - tp += temp+1; + ct.BeginTimestamp = token->startTime; + ct.EndTimestamp = token->endTime; + if (ct.BeginTimestamp == 0) + ct.BeginTimestamp = 1; + + /* We don't know from Vice ID's yet */ + ct.ViceId = 37; /* XXX */ + if (((ct.EndTimestamp - ct.BeginTimestamp) & 1) == 1) + ct.BeginTimestamp++; /* force lifetime to be even */ + + /* size of clear token */ + temp = sizeof(struct ClearToken); + memcpy(tp, &temp, sizeof(temp)); + tp += sizeof(temp); + + /* clear token itself */ + memcpy(tp, &ct, sizeof(ct)); + tp += sizeof(ct); + + /* flags; on NT there is no setpag flag, but there is an + * integrated logon flag */ + temp = ((flags & AFS_SETTOK_LOGON) ? PIOCTL_LOGON : 0); + memcpy(tp, &temp, sizeof(temp)); + tp += sizeof(temp); + + /* cell name */ + temp = strlen(server->cell); + if (temp >= MAXKTCREALMLEN) + return KTC_INVAL; + strcpy(tp, server->cell); + tp += temp + 1; + + /* user name */ + temp = strlen(client->name); + if (temp >= MAXKTCNAMELEN) + return KTC_INVAL; + strcpy(tp, client->name); + tp += temp + 1; /* we need the SMB user name to associate the tokens with in the - integrated logon case. */ + * integrated logon case. */ if (flags & AFS_SETTOK_LOGON) { - if (client->smbname == NULL) - temp = 0; - else + if (client->smbname == NULL) + temp = 0; + else temp = strlen(client->smbname); - if (temp == 0 || temp >= MAXKTCNAMELEN) - return KTC_INVAL; - strcpy(tp, client->smbname); - tp += temp+1; + if (temp == 0 || temp >= MAXKTCNAMELEN) + return KTC_INVAL; + strcpy(tp, client->smbname); + tp += temp + 1; } - - /* uuid */ - status = UuidCreate((UUID *)&uuid); - memcpy(tp, &uuid, sizeof(uuid)); - tp += sizeof(uuid); + + /* uuid */ + status = UuidCreate((UUID *) & uuid); + memcpy(tp, &uuid, sizeof(uuid)); + tp += sizeof(uuid); #ifndef AFS_WIN95_ENV - /* RPC to send session key */ - status = send_key(uuid, token->sessionKey.data); - if (status != RPC_S_OK) { - if (status == 1) - strcpy(rpcErr, "RPC failure in AFS gateway"); - else - DceErrorInqText(status, rpcErr); - if (status == RPC_S_SERVER_UNAVAILABLE - || status == EPT_S_NOT_REGISTERED) - return KTC_NOCMRPC; - else - return KTC_RPC; - } + /* RPC to send session key */ + status = send_key(uuid, token->sessionKey.data); + if (status != RPC_S_OK) { + if (status == 1) + strcpy(rpcErr, "RPC failure in AFS gateway"); + else + DceErrorInqText(status, rpcErr); + if (status == RPC_S_SERVER_UNAVAILABLE + || status == EPT_S_NOT_REGISTERED) + return KTC_NOCMRPC; + else + return KTC_RPC; + } #endif /* AFS_WIN95_ENV */ - /* set up for pioctl */ - iob.in = tbuffer; - iob.in_size = tp - tbuffer; - iob.out = tbuffer; - iob.out_size = sizeof(tbuffer); - - code = pioctl(0, VIOCSETTOK, &iob, 0); - if (code) { - if (code == -1) { - if (errno == ESRCH) - return KTC_NOCELL; - else if (errno == ENODEV) - return KTC_NOCM; - else if (errno == EINVAL) - return KTC_INVAL; - else - return KTC_PIOCTLFAIL; - } - else - return KTC_PIOCTLFAIL; - } + /* set up for pioctl */ + iob.in = tbuffer; + iob.in_size = tp - tbuffer; + iob.out = tbuffer; + iob.out_size = sizeof(tbuffer); + + code = pioctl(0, VIOCSETTOK, &iob, 0); + if (code) { + if (code == -1) { + if (errno == ESRCH) + return KTC_NOCELL; + else if (errno == ENODEV) + return KTC_NOCM; + else if (errno == EINVAL) + return KTC_INVAL; + else + return KTC_PIOCTLFAIL; + } else + return KTC_PIOCTLFAIL; + } - return 0; + return 0; } -int ktc_GetToken( - struct ktc_principal *server, - struct ktc_token *token, - int tokenLen, - struct ktc_principal *client) +int +ktc_GetToken(struct ktc_principal *server, struct ktc_token *token, + int tokenLen, struct ktc_principal *client) { - struct ViceIoctl iob; - char tbuffer[1024]; - char *tp, *cp; - char *ticketP; - int ticketLen, temp; - struct ClearToken ct; - char *cellName; - int cellNameSize; - int maxLen; - int code; - RPC_STATUS status; - afs_uuid_t uuid; - - tp = tbuffer; - - /* check to see if the user is requesting tokens for a principal - * other than afs. If so, check the local token cache. - */ - if (strcmp(server->name, "afs")) { - return GetLocalToken(server, token, tokenLen, client); - } - - /* cell name */ - strcpy(tp, server->cell); - tp += strlen(server->cell) + 1; - - /* uuid */ - status = UuidCreate((UUID *)&uuid); - memcpy(tp, &uuid, sizeof(uuid)); - tp += sizeof(uuid); - - iob.in = tbuffer; - iob.in_size = tp - tbuffer; - iob.out = tbuffer; - iob.out_size = sizeof(tbuffer); - - code = pioctl(0, VIOCNEWGETTOK, &iob, 0); - if (code) { - if (code == -1) { - if (errno == ESRCH) - return KTC_NOCELL; - else if (errno == ENODEV) - return KTC_NOCM; - else if (errno == EINVAL) - return KTC_INVAL; - else if (errno == EDOM) - return KTC_NOENT; - else - return KTC_PIOCTLFAIL; - } - else - return KTC_PIOCTLFAIL; - } + struct ViceIoctl iob; + char tbuffer[1024]; + char *tp, *cp; + char *ticketP; + int ticketLen, temp; + struct ClearToken ct; + char *cellName; + int cellNameSize; + int maxLen; + int code; + RPC_STATUS status; + afs_uuid_t uuid; + + tp = tbuffer; + + /* check to see if the user is requesting tokens for a principal + * other than afs. If so, check the local token cache. + */ + if (strcmp(server->name, "afs")) { + return GetLocalToken(server, token, tokenLen, client); + } -#ifndef AFS_WIN95_ENV /* get rid of RPC for win95 build */ - /* RPC to receive session key */ - status = receive_key(uuid, token->sessionKey.data); - if (status != RPC_S_OK) { - if (status == 1) - strcpy(rpcErr, "RPC failure in AFS gateway"); - else - DceErrorInqText(status, rpcErr); - if (status == RPC_S_SERVER_UNAVAILABLE - || status == EPT_S_NOT_REGISTERED) - return KTC_NOCMRPC; - else - return KTC_RPC; - } + /* cell name */ + strcpy(tp, server->cell); + tp += strlen(server->cell) + 1; + + /* uuid */ + status = UuidCreate((UUID *) & uuid); + memcpy(tp, &uuid, sizeof(uuid)); + tp += sizeof(uuid); + + iob.in = tbuffer; + iob.in_size = tp - tbuffer; + iob.out = tbuffer; + iob.out_size = sizeof(tbuffer); + + code = pioctl(0, VIOCNEWGETTOK, &iob, 0); + if (code) { + if (code == -1) { + if (errno == ESRCH) + return KTC_NOCELL; + else if (errno == ENODEV) + return KTC_NOCM; + else if (errno == EINVAL) + return KTC_INVAL; + else if (errno == EDOM) + return KTC_NOENT; + else + return KTC_PIOCTLFAIL; + } else + return KTC_PIOCTLFAIL; + } +#ifndef AFS_WIN95_ENV /* get rid of RPC for win95 build */ + /* RPC to receive session key */ + status = receive_key(uuid, token->sessionKey.data); + if (status != RPC_S_OK) { + if (status == 1) + strcpy(rpcErr, "RPC failure in AFS gateway"); + else + DceErrorInqText(status, rpcErr); + if (status == RPC_S_SERVER_UNAVAILABLE + || status == EPT_S_NOT_REGISTERED) + return KTC_NOCMRPC; + else + return KTC_RPC; + } #endif /* AFS_WIN95_ENV */ - cp = tbuffer; + cp = tbuffer; - /* ticket length */ - memcpy(&ticketLen, cp, sizeof(ticketLen)); - cp += sizeof(ticketLen); + /* ticket length */ + memcpy(&ticketLen, cp, sizeof(ticketLen)); + cp += sizeof(ticketLen); - /* remember where ticket is and skip over it */ - ticketP = cp; - cp += ticketLen; + /* remember where ticket is and skip over it */ + ticketP = cp; + cp += ticketLen; - /* size of clear token */ - memcpy(&temp, cp, sizeof(temp)); - cp += sizeof(temp); - if (temp != sizeof(ct)) - return KTC_ERROR; + /* size of clear token */ + memcpy(&temp, cp, sizeof(temp)); + cp += sizeof(temp); + if (temp != sizeof(ct)) + return KTC_ERROR; - /* clear token */ - memcpy(&ct, cp, temp); - cp += temp; + /* clear token */ + memcpy(&ct, cp, temp); + cp += temp; - /* skip over primary flag */ - cp += sizeof(temp); + /* skip over primary flag */ + cp += sizeof(temp); - /* remember cell name and skip over it */ - cellName = cp; - cellNameSize = strlen(cp); - cp += cellNameSize + 1; + /* remember cell name and skip over it */ + cellName = cp; + cellNameSize = strlen(cp); + cp += cellNameSize + 1; - /* user name is here */ + /* user name is here */ - /* check that ticket will fit */ - maxLen = tokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN; - if (maxLen < ticketLen) - return KTC_TOOBIG; + /* check that ticket will fit */ + maxLen = tokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN; + if (maxLen < ticketLen) + return KTC_TOOBIG; - /* set return values */ - memcpy(token->ticket, ticketP, ticketLen); - token->startTime = ct.BeginTimestamp; - token->endTime = ct.EndTimestamp; - if (ct.AuthHandle == -1) ct.AuthHandle = 999; - token->kvno = ct.AuthHandle; + /* set return values */ + memcpy(token->ticket, ticketP, ticketLen); + token->startTime = ct.BeginTimestamp; + token->endTime = ct.EndTimestamp; + if (ct.AuthHandle == -1) + ct.AuthHandle = 999; + token->kvno = ct.AuthHandle; #ifndef AFS_WIN95_ENV - /* - * Session key has already been set via RPC - */ + /* + * Session key has already been set via RPC + */ #else - memcpy(&token->sessionKey, ct.HandShakeKey, sizeof(ct.HandShakeKey)); + memcpy(&token->sessionKey, ct.HandShakeKey, sizeof(ct.HandShakeKey)); #endif /* AFS_WIN95_ENV */ - token->ticketLen = ticketLen; - if (client) { - strcpy(client->name, cp); - client->instance[0] = '\0'; - strcpy(client->cell, cellName); - } + token->ticketLen = ticketLen; + if (client) { + strcpy(client->name, cp); + client->instance[0] = '\0'; + strcpy(client->cell, cellName); + } - return 0; + return 0; } -int ktc_ListTokens( - int cellNum, - int *cellNumP, - struct ktc_principal *server) +int +ktc_ListTokens(int cellNum, int *cellNumP, struct ktc_principal *server) { - struct ViceIoctl iob; - char tbuffer[1024]; - char *tp, *cp; - int newIter, ticketLen, temp; - int code; - - tp = tbuffer; - - /* iterator */ - memcpy(tp, &cellNum, sizeof(cellNum)); - tp += sizeof(cellNum); - - /* do pioctl */ - iob.in = tbuffer; - iob.in_size = tp - tbuffer; - iob.out = tbuffer; - iob.out_size = sizeof(tbuffer); - - code = pioctl(0, VIOCGETTOK, &iob, 0); - if (code) { - if (code == -1) { - if (errno == ESRCH) - return KTC_NOCELL; - else if (errno == ENODEV) - return KTC_NOCM; - else if (errno == EINVAL) - return KTC_INVAL; - else if (errno == EDOM) - return KTC_NOENT; - else - return KTC_PIOCTLFAIL; - } - else - return KTC_PIOCTLFAIL; - } + struct ViceIoctl iob; + char tbuffer[1024]; + char *tp, *cp; + int newIter, ticketLen, temp; + int code; + + tp = tbuffer; + + /* iterator */ + memcpy(tp, &cellNum, sizeof(cellNum)); + tp += sizeof(cellNum); + + /* do pioctl */ + iob.in = tbuffer; + iob.in_size = tp - tbuffer; + iob.out = tbuffer; + iob.out_size = sizeof(tbuffer); + + code = pioctl(0, VIOCGETTOK, &iob, 0); + if (code) { + if (code == -1) { + if (errno == ESRCH) + return KTC_NOCELL; + else if (errno == ENODEV) + return KTC_NOCM; + else if (errno == EINVAL) + return KTC_INVAL; + else if (errno == EDOM) + return KTC_NOENT; + else + return KTC_PIOCTLFAIL; + } else + return KTC_PIOCTLFAIL; + } - cp = tbuffer; + cp = tbuffer; - /* new iterator */ - memcpy(&newIter, cp, sizeof(newIter)); - cp += sizeof(newIter); + /* new iterator */ + memcpy(&newIter, cp, sizeof(newIter)); + cp += sizeof(newIter); - /* ticket length */ - memcpy(&ticketLen, cp, sizeof(ticketLen)); - cp += sizeof(ticketLen); + /* ticket length */ + memcpy(&ticketLen, cp, sizeof(ticketLen)); + cp += sizeof(ticketLen); - /* skip over ticket */ - cp += ticketLen; + /* skip over ticket */ + cp += ticketLen; - /* clear token size */ - memcpy(&temp, cp, sizeof(temp)); - cp += sizeof(temp); - if (temp != sizeof(struct ClearToken)) - return KTC_ERROR; + /* clear token size */ + memcpy(&temp, cp, sizeof(temp)); + cp += sizeof(temp); + if (temp != sizeof(struct ClearToken)) + return KTC_ERROR; - /* skip over clear token */ - cp += sizeof(struct ClearToken); + /* skip over clear token */ + cp += sizeof(struct ClearToken); - /* skip over primary flag */ - cp += sizeof(temp); + /* skip over primary flag */ + cp += sizeof(temp); - /* cell name is here */ + /* cell name is here */ - /* set return values */ - strcpy(server->cell, cp); - server->instance[0] = '\0'; - strcpy(server->name, "afs"); + /* set return values */ + strcpy(server->cell, cp); + server->instance[0] = '\0'; + strcpy(server->name, "afs"); - *cellNumP = newIter; - return 0; + *cellNumP = newIter; + return 0; } -int ktc_ForgetToken( - struct ktc_principal *server) +int +ktc_ForgetToken(struct ktc_principal *server) { - struct ViceIoctl iob; - char tbuffer[1024]; - char *tp; - int code; + struct ViceIoctl iob; + char tbuffer[1024]; + char *tp; + int code; - if (strcmp(server->name, "afs")) { - return ForgetOneLocalToken(server); - } + if (strcmp(server->name, "afs")) { + return ForgetOneLocalToken(server); + } - tp = tbuffer; - - /* cell name */ - strcpy(tp, server->cell); - tp += strlen(tp) + 1; - - /* do pioctl */ - iob.in = tbuffer; - iob.in_size = tp - tbuffer; - iob.out = tbuffer; - iob.out_size = sizeof(tbuffer); - - code = pioctl(0, VIOCDELTOK, &iob, 0); - if (code) { - if (code == -1) { - if (errno == ESRCH) - return KTC_NOCELL; - else if (errno == EDOM) - return KTC_NOENT; - else if (errno == ENODEV) - return KTC_NOCM; - else - return KTC_PIOCTLFAIL; - } - else - return KTC_PIOCTLFAIL; - } - return 0; + tp = tbuffer; + + /* cell name */ + strcpy(tp, server->cell); + tp += strlen(tp) + 1; + + /* do pioctl */ + iob.in = tbuffer; + iob.in_size = tp - tbuffer; + iob.out = tbuffer; + iob.out_size = sizeof(tbuffer); + + code = pioctl(0, VIOCDELTOK, &iob, 0); + if (code) { + if (code == -1) { + if (errno == ESRCH) + return KTC_NOCELL; + else if (errno == EDOM) + return KTC_NOENT; + else if (errno == ENODEV) + return KTC_NOCM; + else + return KTC_PIOCTLFAIL; + } else + return KTC_PIOCTLFAIL; + } + return 0; } -int ktc_ForgetAllTokens() +int +ktc_ForgetAllTokens() { - struct ViceIoctl iob; - char tbuffer[1024]; - int code; - - (void) ForgetLocalTokens(); - - /* do pioctl */ - iob.in = tbuffer; - iob.in_size = 0; - iob.out = tbuffer; - iob.out_size = sizeof(tbuffer); - - code = pioctl(0, VIOCDELALLTOK, &iob, 0); - if (code) { - if (code == -1) { - if (errno == ENODEV) - return KTC_NOCM; - else - return KTC_PIOCTLFAIL; - } - else - return KTC_PIOCTLFAIL; - } - return 0; + struct ViceIoctl iob; + char tbuffer[1024]; + int code; + + (void)ForgetLocalTokens(); + + /* do pioctl */ + iob.in = tbuffer; + iob.in_size = 0; + iob.out = tbuffer; + iob.out_size = sizeof(tbuffer); + + code = pioctl(0, VIOCDELALLTOK, &iob, 0); + if (code) { + if (code == -1) { + if (errno == ENODEV) + return KTC_NOCM; + else + return KTC_PIOCTLFAIL; + } else + return KTC_PIOCTLFAIL; + } + return 0; } -int ktc_OldPioctl () +int +ktc_OldPioctl() { return 1; } @@ -686,98 +670,92 @@ static struct { struct ktc_principal server; struct ktc_principal client; struct ktc_token token; -} local_tokens[MAXLOCALTOKENS] = {0}; +} local_tokens[MAXLOCALTOKENS] = { +0}; -static int SetLocalToken(struct ktc_principal *aserver, - struct ktc_token *atoken, - struct ktc_principal *aclient, - afs_int32 flags) +static int +SetLocalToken(struct ktc_principal *aserver, struct ktc_token *atoken, + struct ktc_principal *aclient, afs_int32 flags) { int found = -1; int i; - LOCK_GLOBAL_MUTEX - for (i = 0; i < MAXLOCALTOKENS; i++) + LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) if (local_tokens[i].valid) { - if ((strcmp(local_tokens[i].server.name, aserver->name) == 0) && - (strcmp(local_tokens[i].server.instance, - aserver->instance) == 0) && - (strcmp(local_tokens[i].server.cell, aserver->cell) == 0)) { + if ((strcmp(local_tokens[i].server.name, aserver->name) == 0) + && (strcmp(local_tokens[i].server.instance, aserver->instance) + == 0) + && (strcmp(local_tokens[i].server.cell, aserver->cell) == 0)) { found = i; /* replace existing entry */ break; } } else if (found == -1) - found = i; /* remember empty slot but keep looking for a match */ + found = i; /* remember empty slot but keep looking for a match */ if (found == -1) { - UNLOCK_GLOBAL_MUTEX - return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX return KTC_NOENT; } memcpy(&local_tokens[found].token, atoken, sizeof(struct ktc_token)); - memcpy(&local_tokens[found].server, aserver, sizeof(struct ktc_principal)); - memcpy(&local_tokens[found].client, aclient, sizeof(struct ktc_principal)); + memcpy(&local_tokens[found].server, aserver, + sizeof(struct ktc_principal)); + memcpy(&local_tokens[found].client, aclient, + sizeof(struct ktc_principal)); local_tokens[found].valid = 1; - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } -static int GetLocalToken(struct ktc_principal *aserver, - struct ktc_token *atoken, - int atokenLen, - struct ktc_principal *aclient) +static int +GetLocalToken(struct ktc_principal *aserver, struct ktc_token *atoken, + int atokenLen, struct ktc_principal *aclient) { int i; - LOCK_GLOBAL_MUTEX - for (i = 0; i < MAXLOCALTOKENS; i++) - if (local_tokens[i].valid && - (strcmp(local_tokens[i].server.name, aserver->name) == 0) && - (strcmp(local_tokens[i].server.instance,aserver->instance) == 0) && - (strcmp(local_tokens[i].server.cell, aserver->cell) == 0)) { + LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) + if (local_tokens[i].valid + && (strcmp(local_tokens[i].server.name, aserver->name) == 0) + && (strcmp(local_tokens[i].server.instance, aserver->instance) == + 0) + && (strcmp(local_tokens[i].server.cell, aserver->cell) == 0)) { memcpy(atoken, &local_tokens[i].token, min(atokenLen, sizeof(struct ktc_token))); memcpy(aclient, &local_tokens[i].client, sizeof(struct ktc_principal)); - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } - UNLOCK_GLOBAL_MUTEX - return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX return KTC_NOENT; } -static int ForgetLocalTokens() +static int +ForgetLocalTokens() { int i; - LOCK_GLOBAL_MUTEX - for (i = 0; i < MAXLOCALTOKENS; i++) { + LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) { local_tokens[i].valid = 0; memset(&local_tokens[i].token.sessionKey, 0, sizeof(struct ktc_encryptionKey)); } - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } -static int ForgetOneLocalToken(struct ktc_principal *aserver) +static int +ForgetOneLocalToken(struct ktc_principal *aserver) { int i; - LOCK_GLOBAL_MUTEX - for (i = 0; i < MAXLOCALTOKENS; i++) { - if (local_tokens[i].valid && - (strcmp(local_tokens[i].server.name, aserver->name) == 0) && - (strcmp(local_tokens[i].server.instance,aserver->instance) == 0) && - (strcmp(local_tokens[i].server.cell, aserver->cell) == 0)) { + LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) { + if (local_tokens[i].valid + && (strcmp(local_tokens[i].server.name, aserver->name) == 0) + && (strcmp(local_tokens[i].server.instance, aserver->instance) == + 0) + && (strcmp(local_tokens[i].server.cell, aserver->cell) == 0)) { local_tokens[i].valid = 0; memset(&local_tokens[i].token.sessionKey, 0, sizeof(struct ktc_encryptionKey)); - UNLOCK_GLOBAL_MUTEX - return 0; + UNLOCK_GLOBAL_MUTEX return 0; } } - UNLOCK_GLOBAL_MUTEX - return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX return KTC_NOENT; } diff --git a/src/auth/setkey.c b/src/auth/setkey.c index df8437e26..edefbd603 100644 --- a/src/auth/setkey.c +++ b/src/auth/setkey.c @@ -9,9 +9,10 @@ #include #include - -RCSID("$Header$"); - + +RCSID + ("$Header$"); + #include #include #include @@ -43,8 +44,9 @@ static int hex2char(char c); int main(argc, argv) -int argc; -char **argv; { + int argc; + char **argv; +{ struct afsconf_dir *tdir; register afs_int32 code; int i; @@ -62,32 +64,32 @@ char **argv; { tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); if (!tdir) { - printf("setkey: can't initialize conf dir '%s'\n", AFSDIR_SERVER_ETC_DIRPATH); + printf("setkey: can't initialize conf dir '%s'\n", + AFSDIR_SERVER_ETC_DIRPATH); exit(1); } - if (strcmp(argv[1], "add")==0) { + if (strcmp(argv[1], "add") == 0) { char tkey[8]; if (argc != 4) { printf("setkey add: usage is 'setkey add \n"); exit(1); } if (strlen(argv[3]) != 16) { - printf("key %s is not in right format\n", argv[3]); - printf(" should be an 8byte hex representation \n"); - printf(" Ex: setkey add 0 \"80b6a7cd7a9dadb6\"\n"); - exit(1); + printf("key %s is not in right format\n", argv[3]); + printf(" should be an 8byte hex representation \n"); + printf(" Ex: setkey add 0 \"80b6a7cd7a9dadb6\"\n"); + exit(1); } memset(tkey, 0, sizeof(tkey)); - for(i=7, cp = argv[3] + 15;i>=0; i--,cp-=2) - tkey[i] = char2hex(*cp) + char2hex(*(cp-1))*16; + for (i = 7, cp = argv[3] + 15; i >= 0; i--, cp -= 2) + tkey[i] = char2hex(*cp) + char2hex(*(cp - 1)) * 16; code = afsconf_AddKey(tdir, atoi(argv[2]), tkey, 1); if (code) { - printf("setkey: failed to set key, code %d.\n", (int) code); + printf("setkey: failed to set key, code %d.\n", (int)code); exit(1); } - } - else if (strcmp(argv[1], "delete")==0) { + } else if (strcmp(argv[1], "delete") == 0) { afs_int32 kvno; if (argc != 3) { printf("setkey delete: usage is 'setkey delete \n"); @@ -96,62 +98,66 @@ char **argv; { kvno = atoi(argv[2]); code = afsconf_DeleteKey(tdir, kvno); if (code) { - printf("setkey: failed to delete key %d, (code %d)\n", (int) kvno, (int) code); + printf("setkey: failed to delete key %d, (code %d)\n", (int)kvno, + (int)code); exit(1); } - } - else if (strcmp(argv[1], "list") == 0) { + } else if (strcmp(argv[1], "list") == 0) { struct afsconf_keys tkeys; register int i; char tbuffer[9]; - + code = afsconf_GetKeys(tdir, &tkeys); if (code) { - printf("setkey: failed to get keys, code %d\n", (int) code); + printf("setkey: failed to get keys, code %d\n", (int)code); exit(1); } - for(i=0;i= '0' && c <='9') - return ( c - 48); - if ( (c >= 'a') && (c <= 'f') ) - return (c-'a' + 10); - - if ( (c >= 'A') && (c <='F') ) - return (c-'A' + 10); - - return -1; + if (c >= '0' && c <= '9') + return (c - 48); + if ((c >= 'a') && (c <= 'f')) + return (c - 'a' + 10); + + if ((c >= 'A') && (c <= 'F')) + return (c - 'A' + 10); + + return -1; } -static int hex2char(char c) +static int +hex2char(char c) { - if (c <=9) - return (c+48); + if (c <= 9) + return (c + 48); - return (c - 10 + 'a'); + return (c - 10 + 'a'); } diff --git a/src/auth/test/ktctest.c b/src/auth/test/ktctest.c index 48590a65e..e745b8e54 100644 --- a/src/auth/test/ktctest.c +++ b/src/auth/test/ktctest.c @@ -17,7 +17,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -25,16 +26,14 @@ RCSID("$Header$"); extern int ktc_SetToken(struct ktc_principal *aserver, struct ktc_token *atoken, - struct ktc_principal *aclient, - int flags); + struct ktc_principal *aclient, int flags); extern int ktc_GetToken(struct ktc_principal *aserver, - struct ktc_token *atoken, - int atokenLen, + struct ktc_token *atoken, int atokenLen, struct ktc_principal *aclient); -extern int ktc_ListTokens(int aprevIndex, - int* aindex, struct ktc_principal *aserver); +extern int ktc_ListTokens(int aprevIndex, int *aindex, + struct ktc_principal *aserver); extern int ktc_ForgetAllTokens(void); @@ -45,7 +44,8 @@ static int SameToken(struct ktc_token *t1, struct ktc_token *t2); #define MAXCELLS 20 -int main(void) +int +main(void) { struct ktc_principal oldServer[MAXCELLS], newServer[MAXCELLS]; struct ktc_principal oldClient[MAXCELLS], newClient[MAXCELLS]; @@ -83,9 +83,9 @@ int main(void) } /* fetch token and client identity w.r.t. server */ - code = ktc_GetToken(&oldServer[i], - &oldToken[i], sizeof(struct ktc_token), - &oldClient[i]); + code = + ktc_GetToken(&oldServer[i], &oldToken[i], + sizeof(struct ktc_token), &oldClient[i]); if (code) { /* some unexpected error occured */ @@ -106,8 +106,8 @@ int main(void) for (i = 0; i < cellCount; i++) { printf("Token[%d]: server = %s@%s, client = %s@%s\n", i, - oldServer[i].name, oldServer[i].cell, - oldClient[i].name, oldClient[i].cell); + oldServer[i].name, oldServer[i].cell, oldClient[i].name, + oldClient[i].cell); } @@ -126,9 +126,9 @@ int main(void) struct ktc_principal dummyPrincipal; struct ktc_token dummyToken; - code = ktc_GetToken(&oldServer[i], - &dummyToken, sizeof(struct ktc_token), - &dummyPrincipal); + code = + ktc_GetToken(&oldServer[i], &dummyToken, sizeof(struct ktc_token), + &dummyPrincipal); if (code != KTC_NOENT) { printf("ktc_ForgetAllTokens did not eliminate all tokens.\n"); @@ -137,7 +137,7 @@ int main(void) cellIndex = 0; - code = ktc_ListTokens(cellIndex, &cellIndex, &dummyPrincipal); + code = ktc_ListTokens(cellIndex, &cellIndex, &dummyPrincipal); if (code != KTC_NOENT) { printf("ktc_ForgetAllTokens did not eliminate all tokens.\n"); @@ -182,9 +182,9 @@ int main(void) } /* fetch token and client identity w.r.t. server */ - code = ktc_GetToken(&newServer[i], - &newToken[i], sizeof(struct ktc_token), - &newClient[i]); + code = + ktc_GetToken(&newServer[i], &newToken[i], + sizeof(struct ktc_token), &newClient[i]); if (code) { /* some unexpected error occured */ @@ -208,9 +208,9 @@ int main(void) found = 0; for (k = 0; k < cellCount; k++) { - if (SamePrincipal(&oldServer[i], &newServer[k]) && - SamePrincipal(&oldClient[i], &newClient[k]) && - SameToken(&oldToken[i], &newToken[k])) { + if (SamePrincipal(&oldServer[i], &newServer[k]) + && SamePrincipal(&oldClient[i], &newClient[k]) + && SameToken(&oldToken[i], &newToken[k])) { /* found a matching token */ found = 1; break; @@ -233,9 +233,8 @@ int main(void) static int SamePrincipal(struct ktc_principal *p1, struct ktc_principal *p2) { - if (strcmp(p1->name, p2->name) || - strcmp(p1->instance, p2->instance) || - strcmp(p1->cell, p2->cell)) { + if (strcmp(p1->name, p2->name) || strcmp(p1->instance, p2->instance) + || strcmp(p1->cell, p2->cell)) { /* principals do not match */ return 0; } else { @@ -248,12 +247,10 @@ SamePrincipal(struct ktc_principal *p1, struct ktc_principal *p2) static int SameToken(struct ktc_token *t1, struct ktc_token *t2) { - if ((t1->startTime != t2->startTime) || - (t1->endTime != t2->endTime) || - memcmp(&t1->sessionKey, &t2->sessionKey, sizeof(t1->sessionKey)) || - (t1->kvno != t2->kvno) || - (t1->ticketLen != t2->ticketLen) || - memcmp(t1->ticket, t2->ticket, t1->ticketLen)) { + if ((t1->startTime != t2->startTime) || (t1->endTime != t2->endTime) + || memcmp(&t1->sessionKey, &t2->sessionKey, sizeof(t1->sessionKey)) + || (t1->kvno != t2->kvno) || (t1->ticketLen != t2->ticketLen) + || memcmp(t1->ticket, t2->ticket, t1->ticketLen)) { /* tokens do not match */ return 0; } else { diff --git a/src/auth/test/testcellconf.c b/src/auth/test/testcellconf.c index e84d07a24..4f8002615 100644 --- a/src/auth/test/testcellconf.c +++ b/src/auth/test/testcellconf.c @@ -25,7 +25,8 @@ Creation date: #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -40,24 +41,26 @@ RCSID("$Header$"); #include PrintOneCell(ainfo, arock, adir) -struct afsconf_cell *ainfo; -char *arock; -struct afsconf_dir *adir; { + struct afsconf_cell *ainfo; + char *arock; + struct afsconf_dir *adir; +{ register int i; long temp; printf("Cell %s:\n", ainfo->name); - for(i=0;inumServers;i++) { + for (i = 0; i < ainfo->numServers; i++) { memcpy(&temp, &ainfo->hostAddr[i].sin_addr, sizeof(long)); - printf(" host %s at %x.%x\n", ainfo->hostName[i], temp, ainfo->hostAddr[i].sin_port); + printf(" host %s at %x.%x\n", ainfo->hostName[i], temp, + ainfo->hostAddr[i].sin_port); } return 0; } /*Main for testcellconfig*/ main(argc, argv) -int argc; -char *argv[]; + int argc; + char *argv[]; { struct afsconf_dir *theDir; char tbuffer[1024]; @@ -67,7 +70,8 @@ char *argv[]; char *dirName; if (argc < 2) { - printf("usage: testcellconfig []*\n"); + printf + ("usage: testcellconfig []*\n"); exit(1); } @@ -77,7 +81,7 @@ char *argv[]; printf("could not open configuration files in '%s'\n", dirName); exit(1); } - + /* get the cell */ code = afsconf_GetLocalCell(theDir, tbuffer, sizeof(tbuffer)); if (code != 0) { @@ -85,7 +89,7 @@ char *argv[]; exit(1); } printf("Local cell is '%s'\n\n", tbuffer); - + if (argc == 2) { printf("About to print cell database contents:\n"); afsconf_CellApply(theDir, PrintOneCell, 0); @@ -93,26 +97,28 @@ char *argv[]; /* do this junk once */ printf("start of special test\n"); code = afsconf_GetCellInfo(theDir, NULL, "afsprot", &theCell); - if (code) printf("failed to find afsprot service (%d)\n", code); + if (code) + printf("failed to find afsprot service (%d)\n", code); else { printf("AFSPROT service:\n"); - PrintOneCell(&theCell, (char *) NULL, theDir); + PrintOneCell(&theCell, (char *)NULL, theDir); } code = afsconf_GetCellInfo(theDir, 0, "bozotheclown", &theCell); - if (code == 0) printf("unexpectedly found service 'bozotheclown'\n"); + if (code == 0) + printf("unexpectedly found service 'bozotheclown'\n"); code = afsconf_GetCellInfo(theDir, NULL, "telnet", &theCell); printf("Here's the telnet service:\n"); PrintOneCell(&theCell, NULL, theDir); printf("done with special test\n"); - } - else { + } else { /* now print out specified cell info */ - for(i = 2; i #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -25,7 +26,7 @@ RCSID("$Header$"); #include #endif #include -#include /* for realpath() */ +#include /* for realpath() */ #include #include #include @@ -48,64 +49,65 @@ RCSID("$Header$"); afs_int32 afsconf_SuperUser(); #if !defined(UKERNEL) -int afsconf_CheckAuth(adir, acall) -register struct rx_call *acall; -register struct afsconf_dir *adir; { - LOCK_GLOBAL_MUTEX - return ((afsconf_SuperUser(adir, acall, NULL) == 0)? 10029 : 0); - UNLOCK_GLOBAL_MUTEX -} +int +afsconf_CheckAuth(adir, acall) + register struct rx_call *acall; + register struct afsconf_dir *adir; +{ + LOCK_GLOBAL_MUTEX return ((afsconf_SuperUser(adir, acall, NULL) == 0) ? + 10029 : 0); +UNLOCK_GLOBAL_MUTEX} #endif /* !defined(UKERNEL) */ -static GetNoAuthFlag(adir) -struct afsconf_dir *adir; { +static +GetNoAuthFlag(adir) + struct afsconf_dir *adir; +{ if (access(AFSDIR_SERVER_NOAUTH_FILEPATH, 0) == 0) { - osi_audit ( NoAuthEvent, 0, AUD_END ); /* some random server is running noauth */ - return 1; /* if /usr/afs/local/NoAuth file exists, allow access */ - } + osi_audit(NoAuthEvent, 0, AUD_END); /* some random server is running noauth */ + return 1; /* if /usr/afs/local/NoAuth file exists, allow access */ + } return 0; } afsconf_GetNoAuthFlag(adir) -struct afsconf_dir *adir; { + struct afsconf_dir *adir; +{ int rc; - LOCK_GLOBAL_MUTEX - rc = GetNoAuthFlag(adir); - UNLOCK_GLOBAL_MUTEX - return rc; + LOCK_GLOBAL_MUTEX rc = GetNoAuthFlag(adir); + UNLOCK_GLOBAL_MUTEX return rc; } afsconf_SetNoAuthFlag(adir, aflag) -struct afsconf_dir *adir; -int aflag; { + struct afsconf_dir *adir; + int aflag; +{ register afs_int32 code; - - LOCK_GLOBAL_MUTEX - if (aflag == 0) { + LOCK_GLOBAL_MUTEX if (aflag == 0) { /* turn off noauth flag */ - code = ( unlink(AFSDIR_SERVER_NOAUTH_FILEPATH) ? errno : 0 ); - osi_audit ( NoAuthDisableEvent, code, AUD_END ); - } - else { + code = (unlink(AFSDIR_SERVER_NOAUTH_FILEPATH) ? errno : 0); + osi_audit(NoAuthDisableEvent, code, AUD_END); + } else { /* try to create file */ - code = open(AFSDIR_SERVER_NOAUTH_FILEPATH, O_CREAT | O_TRUNC | O_RDWR, 0666); - if (code >= 0) { - close(code); - osi_audit ( NoAuthEnableEvent, 0, AUD_END ); - } - else - osi_audit ( NoAuthEnableEvent, errno, AUD_END ); + code = + open(AFSDIR_SERVER_NOAUTH_FILEPATH, O_CREAT | O_TRUNC | O_RDWR, + 0666); + if (code >= 0) { + close(code); + osi_audit(NoAuthEnableEvent, 0, AUD_END); + } else + osi_audit(NoAuthEnableEvent, errno, AUD_END); } - UNLOCK_GLOBAL_MUTEX -} +UNLOCK_GLOBAL_MUTEX} /* deletes a user from the UserList file */ afsconf_DeleteUser(adir, auser) -struct afsconf_dir *adir; -register char *auser; { + struct afsconf_dir *adir; + register char *auser; +{ char tbuffer[1024]; char nbuffer[1024]; register FILE *tf; @@ -117,8 +119,8 @@ register char *auser; { struct stat tstat; register afs_int32 code; - LOCK_GLOBAL_MUTEX - strcompose(tbuffer, sizeof tbuffer, adir->name, "/", AFSDIR_ULIST_FILE, NULL); + LOCK_GLOBAL_MUTEX strcompose(tbuffer, sizeof tbuffer, adir->name, "/", + AFSDIR_ULIST_FILE, NULL); #ifndef AFS_NT40_ENV { /* @@ -135,64 +137,65 @@ register char *auser; { #endif /* AFS_NT40_ENV */ tf = fopen(tbuffer, "r"); if (!tf) { - UNLOCK_GLOBAL_MUTEX - return -1; + UNLOCK_GLOBAL_MUTEX return -1; } code = stat(tbuffer, &tstat); if (code < 0) { - UNLOCK_GLOBAL_MUTEX - return code; + UNLOCK_GLOBAL_MUTEX return code; } strcpy(nbuffer, tbuffer); strcat(nbuffer, ".NXX"); nf = fopen(nbuffer, "w+"); if (!nf) { fclose(tf); - UNLOCK_GLOBAL_MUTEX - return EIO; + UNLOCK_GLOBAL_MUTEX return EIO; } flag = 0; found = 0; while (1) { /* check for our user id */ tp = fgets(nbuffer, sizeof(nbuffer), tf); - if (tp == NULL) break; + if (tp == NULL) + break; code = sscanf(nbuffer, "%64s", tname); if (code == 1 && strcmp(tname, auser) == 0) { /* found the guy, don't copy to output file */ found = 1; - } - else { + } else { /* otherwise copy original line to output */ fprintf(nf, "%s", nbuffer); } } fclose(tf); - if (ferror(nf)) flag = 1; - if (fclose(nf) == EOF) flag = 1; + if (ferror(nf)) + flag = 1; + if (fclose(nf) == EOF) + flag = 1; strcpy(nbuffer, tbuffer); - strcat(nbuffer, ".NXX"); /* generate new file name again */ + strcat(nbuffer, ".NXX"); /* generate new file name again */ if (flag == 0) { /* try the rename */ flag = renamefile(nbuffer, tbuffer); if (flag == 0) flag = chmod(tbuffer, tstat.st_mode); - } - else unlink(nbuffer); + } else + unlink(nbuffer); /* finally, decide what to return to the caller */ - UNLOCK_GLOBAL_MUTEX - if (flag) return EIO; /* something mysterious went wrong */ - if (!found) return ENOENT; /* entry wasn't found, no changes made */ + UNLOCK_GLOBAL_MUTEX if (flag) + return EIO; /* something mysterious went wrong */ + if (!found) + return ENOENT; /* entry wasn't found, no changes made */ return 0; /* everything was fine */ } /* returns nth super user from the UserList file */ afsconf_GetNthUser(adir, an, abuffer, abufferLen) -struct afsconf_dir *adir; -afs_int32 an; -char *abuffer; -afs_int32 abufferLen; { + struct afsconf_dir *adir; + afs_int32 an; + char *abuffer; + afs_int32 abufferLen; +{ char tbuffer[256]; register FILE *tf; char tname[64]; @@ -200,34 +203,36 @@ afs_int32 abufferLen; { register int flag; register afs_int32 code; - LOCK_GLOBAL_MUTEX - strcompose(tbuffer, sizeof tbuffer, adir->name, "/", AFSDIR_ULIST_FILE, NULL); + LOCK_GLOBAL_MUTEX strcompose(tbuffer, sizeof tbuffer, adir->name, "/", + AFSDIR_ULIST_FILE, NULL); tf = fopen(tbuffer, "r"); if (!tf) { - UNLOCK_GLOBAL_MUTEX - return 1; + UNLOCK_GLOBAL_MUTEX return 1; } flag = 1; while (1) { /* check for our user id */ tp = fgets(tbuffer, sizeof(tbuffer), tf); - if (tp == NULL) break; + if (tp == NULL) + break; code = sscanf(tbuffer, "%64s", tname); if (code == 1 && an-- == 0) { flag = 0; break; } } - if (flag == 0) strcpy(abuffer, tname); + if (flag == 0) + strcpy(abuffer, tname); fclose(tf); - UNLOCK_GLOBAL_MUTEX - return flag; + UNLOCK_GLOBAL_MUTEX return flag; } /* returns true iff user is in the UserList file */ -static FindUser(adir, auser) -struct afsconf_dir *adir; -register char *auser; { +static +FindUser(adir, auser) + struct afsconf_dir *adir; + register char *auser; +{ char tbuffer[256]; register bufio_p bp; char tname[64]; @@ -235,14 +240,17 @@ register char *auser; { register afs_int32 code; int rc; - strcompose(tbuffer, sizeof tbuffer, adir->name, "/", AFSDIR_ULIST_FILE, NULL); + strcompose(tbuffer, sizeof tbuffer, adir->name, "/", AFSDIR_ULIST_FILE, + NULL); bp = BufioOpen(tbuffer, O_RDONLY, 0); - if (!bp) return 0; + if (!bp) + return 0; flag = 0; while (1) { /* check for our user id */ rc = BufioGets(bp, tbuffer, sizeof(tbuffer)); - if (rc < 0) break; + if (rc < 0) + break; code = sscanf(tbuffer, "%64s", tname); if (code == 1 && strcmp(tname, auser) == 0) { flag = 1; @@ -255,66 +263,69 @@ register char *auser; { /* add a user to the user list, checking for duplicates */ afsconf_AddUser(adir, aname) -struct afsconf_dir *adir; -char *aname; { + struct afsconf_dir *adir; + char *aname; +{ FILE *tf; register afs_int32 code; char tbuffer[256]; - LOCK_GLOBAL_MUTEX - if (FindUser(adir, aname)) { - UNLOCK_GLOBAL_MUTEX - return EEXIST; /* already in the list */ + LOCK_GLOBAL_MUTEX if (FindUser(adir, aname)) { + UNLOCK_GLOBAL_MUTEX return EEXIST; /* already in the list */ } - strcompose(tbuffer, sizeof tbuffer, adir->name, "/", AFSDIR_ULIST_FILE, NULL); + strcompose(tbuffer, sizeof tbuffer, adir->name, "/", AFSDIR_ULIST_FILE, + NULL); tf = fopen(tbuffer, "a+"); if (!tf) { - UNLOCK_GLOBAL_MUTEX - return EIO; + UNLOCK_GLOBAL_MUTEX return EIO; } fprintf(tf, "%s\n", aname); code = 0; - if (ferror(tf)) code = EIO; - if (fclose(tf)) code = EIO; - UNLOCK_GLOBAL_MUTEX - return code; + if (ferror(tf)) + code = EIO; + if (fclose(tf)) + code = EIO; + UNLOCK_GLOBAL_MUTEX return code; } /* special CompFindUser routine that builds up a princ and then calls finduser on it. If found, returns char * to user string, otherwise returns NULL. The resulting string should be immediately copied to other storage prior to release of mutex. */ -static char *CompFindUser(adir, name, sep, inst, realm) - struct afsconf_dir *adir; - char *name; - char *sep; - char *inst; - char *realm; +static char * +CompFindUser(adir, name, sep, inst, realm) + struct afsconf_dir *adir; + char *name; + char *sep; + char *inst; + char *realm; { - static char fullname[ MAXKTCNAMELEN + MAXKTCNAMELEN + - MAXKTCREALMLEN + 3 ]; + static char fullname[MAXKTCNAMELEN + MAXKTCNAMELEN + MAXKTCREALMLEN + 3]; /* always must have name */ - if ( !name || !name[0] ) { return NULL; } + if (!name || !name[0]) { + return NULL; + } strcpy(fullname, name); /* might have instance */ - if ( inst && inst[0] ) { - if ( !sep || !sep[0] ) { return NULL; } + if (inst && inst[0]) { + if (!sep || !sep[0]) { + return NULL; + } strcat(fullname, sep); strcat(fullname, inst); } /* might have realm */ - if ( realm && realm[0] ) - { + if (realm && realm[0]) { strcat(fullname, "@"); strcat(fullname, realm); } - if ( FindUser(adir, fullname) ) { + if (FindUser(adir, fullname)) { return fullname; } else { return NULL; @@ -326,77 +337,74 @@ static char *CompFindUser(adir, name, sep, inst, realm) users. Copy the "real name" of the authenticated user into namep if a pointer is passed. */ -afs_int32 afsconf_SuperUser(adir, acall, namep) -struct afsconf_dir *adir; -struct rx_call *acall; -char *namep; { +afs_int32 +afsconf_SuperUser(adir, acall, namep) + struct afsconf_dir *adir; + struct rx_call *acall; + char *namep; +{ register struct rx_connection *tconn; register afs_int32 code; int flag; - LOCK_GLOBAL_MUTEX - if (!adir) { - UNLOCK_GLOBAL_MUTEX - return 0; + LOCK_GLOBAL_MUTEX if (!adir) { + UNLOCK_GLOBAL_MUTEX return 0; } if (afsconf_GetNoAuthFlag(adir)) { - if (namep) strcpy(namep, ""); - UNLOCK_GLOBAL_MUTEX - return 1; + if (namep) + strcpy(namep, ""); + UNLOCK_GLOBAL_MUTEX return 1; } tconn = rx_ConnectionOf(acall); code = rx_SecurityClassOf(tconn); - if (code == 0) { - UNLOCK_GLOBAL_MUTEX - return 0; /* not authenticated at all, answer is no */ - } - else if (code == 1) { + if (code == 0) { + UNLOCK_GLOBAL_MUTEX return 0; /* not authenticated at all, answer is no */ + } else if (code == 1) { /* bcrypt tokens */ - UNLOCK_GLOBAL_MUTEX - return 0; /* not supported any longer */ - } - else if (code == 2) { + UNLOCK_GLOBAL_MUTEX return 0; /* not supported any longer */ + } else if (code == 2) { char tname[MAXKTCNAMELEN]; /* authentication from ticket */ char tinst[MAXKTCNAMELEN]; char tcell[MAXKTCREALMLEN]; char tcell_l[MAXKTCREALMLEN]; char *tmp; - + /* keep track of which one actually authorized request */ - char uname[MAXKTCNAMELEN+MAXKTCNAMELEN+MAXKTCREALMLEN+3]; + char uname[MAXKTCNAMELEN + MAXKTCNAMELEN + MAXKTCREALMLEN + 3]; afs_uint32 exp; static char lcell[MAXCELLCHARS] = ""; static char lrealm[AFS_REALM_SZ] = ""; - + /* get auth details from server connection */ - code = rxkad_GetServerInfo - (acall->conn, NULL, &exp, - tname, tinst, tcell, NULL); + code = + rxkad_GetServerInfo(acall->conn, NULL, &exp, tname, tinst, tcell, + NULL); if (code) { - UNLOCK_GLOBAL_MUTEX - return 0; /* bogus connection/other error */ + UNLOCK_GLOBAL_MUTEX return 0; /* bogus connection/other error */ } /* don't bother checking anything else if tix have expired */ #ifdef AFS_PTHREAD_ENV - if (exp < clock_Sec()) { + if (exp < clock_Sec()) { #else - if (exp < FT_ApproxTime()) { + if (exp < FT_ApproxTime()) { #endif - UNLOCK_GLOBAL_MUTEX - return 0; /* expired tix */ + UNLOCK_GLOBAL_MUTEX return 0; /* expired tix */ } /* generate lowercased version of cell name */ strcpy(tcell_l, tcell); tmp = tcell_l; - while ( *tmp ) { *tmp = tolower(*tmp); *tmp++; } + while (*tmp) { + *tmp = tolower(*tmp); + *tmp++; + } /* determine local cell name. It's static, so will only get - calculated the first time through */ + * calculated the first time through */ if (!lcell[0]) afsconf_GetLocalCell(adir, lcell, sizeof(lcell)); @@ -404,7 +412,7 @@ char *namep; { /* note - this assumes AFS_REALM_SZ <= MAXCELLCHARS */ /* just set it to lcell if it fails */ if (!lrealm[0]) { - if (afs_krb_get_lrealm(lrealm, 0) != 0) /* KSUCCESS */ + if (afs_krb_get_lrealm(lrealm, 0) != 0) /* KSUCCESS */ strncpy(lrealm, lcell, AFS_REALM_SZ); } @@ -414,38 +422,38 @@ char *namep; { flag = 0; /* localauth special case */ - if ( strlen(tinst) == 0 && strlen(tcell) == 0 && - !strcmp(tname, AUTH_SUPERUSER) ) { + if (strlen(tinst) == 0 && strlen(tcell) == 0 + && !strcmp(tname, AUTH_SUPERUSER)) { strcpy(uname, ""); flag = 1; - /* cell of connection matches local cell or krb4 realm */ - } else if ( !strcasecmp(tcell, lcell) || !strcasecmp(tcell,lrealm) ) { - if ( (tmp = CompFindUser(adir, tname, ".", tinst, NULL)) ) { + /* cell of connection matches local cell or krb4 realm */ + } else if (!strcasecmp(tcell, lcell) || !strcasecmp(tcell, lrealm)) { + if ((tmp = CompFindUser(adir, tname, ".", tinst, NULL))) { strcpy(uname, tmp); flag = 1; #ifdef notyet - } else if ( (tmp = CompFindUser(adir, tname, "/", tinst, NULL)) ) { + } else if ((tmp = CompFindUser(adir, tname, "/", tinst, NULL))) { strcpy(uname, tmp); flag = 1; #endif } - /* cell of conn doesn't match local cell or realm */ + /* cell of conn doesn't match local cell or realm */ } else { - if ( (tmp = CompFindUser(adir, tname, ".", tinst, tcell)) ) { + if ((tmp = CompFindUser(adir, tname, ".", tinst, tcell))) { strcpy(uname, tmp); flag = 1; #ifdef notyet - } else if ( (tmp = CompFindUser(adir, tname, "/", tinst, tcell)) ) { + } else if ((tmp = CompFindUser(adir, tname, "/", tinst, tcell))) { strcpy(uname, tmp); flag = 1; #endif - } else if ( (tmp = CompFindUser(adir, tname, ".", tinst, tcell_l)) ) { + } else if ((tmp = CompFindUser(adir, tname, ".", tinst, tcell_l))) { strcpy(uname, tmp); flag = 1; #ifdef notyet - } else if ( (tmp = CompFindUser(adir, tname, "/", tinst, tcell_l)) ) { + } else if ((tmp = CompFindUser(adir, tname, "/", tinst, tcell_l))) { strcpy(uname, tmp); flag = 1; #endif @@ -454,11 +462,8 @@ char *namep; { if (namep) strcpy(namep, uname); - UNLOCK_GLOBAL_MUTEX - return flag; - } - else { /* some other auth type */ - UNLOCK_GLOBAL_MUTEX - return 0; /* mysterious, just say no */ + UNLOCK_GLOBAL_MUTEX return flag; + } else { /* some other auth type */ + UNLOCK_GLOBAL_MUTEX return 0; /* mysterious, just say no */ } } diff --git a/src/auth/writeconfig.c b/src/auth/writeconfig.c index 66e3eebed..918504f25 100644 --- a/src/auth/writeconfig.c +++ b/src/auth/writeconfig.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -47,33 +48,37 @@ RCSID("$Header$"); by acellInfo parm. Useful only on the server (which describes only one cell). */ -static VerifyEntries(aci) -register struct afsconf_cell *aci; { +static +VerifyEntries(aci) + register struct afsconf_cell *aci; +{ register int i; register struct hostent *th; - - for(i=0;inumServers;i++) { + + for (i = 0; i < aci->numServers; i++) { if (aci->hostAddr[i].sin_addr.s_addr == 0) { /* no address spec'd */ if (*(aci->hostName[i]) != 0) { th = gethostbyname(aci->hostName[i]); if (!th) { - printf("Host %s not found in host database...\n", aci->hostName[i]); - return AFSCONF_FAILURE; + printf("Host %s not found in host database...\n", + aci->hostName[i]); + return AFSCONF_FAILURE; } - memcpy(&aci->hostAddr[i].sin_addr, th->h_addr, sizeof(afs_int32)); + memcpy(&aci->hostAddr[i].sin_addr, th->h_addr, + sizeof(afs_int32)); } /* otherwise we're deleting this entry */ - } - else { + } else { /* address spec'd, perhaps no name known */ - if (aci->hostName[i][0] != 0) continue; /* name known too */ + if (aci->hostName[i][0] != 0) + continue; /* name known too */ /* figure out name, if possible */ - th = gethostbyaddr((char *)(&aci->hostAddr[i].sin_addr), 4, AF_INET); + th = gethostbyaddr((char *)(&aci->hostAddr[i].sin_addr), 4, + AF_INET); if (!th) { strcpy(aci->hostName[i], "UNKNOWNHOST"); - } - else { + } else { strcpy(aci->hostName[i], th->h_name); } } @@ -84,89 +89,89 @@ register struct afsconf_cell *aci; { /* Changed the interface to accept the afsconf_dir datastructure. This is a handle to the internal cache that is maintained by the bosserver. */ - + afsconf_SetCellInfo(adir, apath, acellInfo) -struct afsconf_dir *adir; -char *apath; -struct afsconf_cell *acellInfo; + struct afsconf_dir *adir; + char *apath; + struct afsconf_cell *acellInfo; { afs_int32 code; code = afsconf_SetExtendedCellInfo(adir, apath, acellInfo, NULL); return code; } - + afsconf_SetExtendedCellInfo(adir, apath, acellInfo, clones) - struct afsconf_dir *adir; - char *apath; - struct afsconf_cell *acellInfo; - char clones[]; + struct afsconf_dir *adir; + char *apath; + struct afsconf_cell *acellInfo; + char clones[]; { register afs_int32 code; register int fd; char tbuffer[1024]; register FILE *tf; register afs_int32 i; - + LOCK_GLOBAL_MUTEX - /* write ThisCell file */ - strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, NULL); + /* write ThisCell file */ + strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, NULL); fd = open(tbuffer, O_RDWR | O_CREAT | O_TRUNC, 0666); if (fd < 0) { - UNLOCK_GLOBAL_MUTEX - return errno; + UNLOCK_GLOBAL_MUTEX return errno; } i = strlen(acellInfo->name); code = write(fd, acellInfo->name, i); if (code != i) { - UNLOCK_GLOBAL_MUTEX - return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; } if (close(fd) < 0) { - UNLOCK_GLOBAL_MUTEX - return errno; + UNLOCK_GLOBAL_MUTEX return errno; } - + /* make sure we have both name and address for each host, looking up other - if need be */ + * if need be */ code = VerifyEntries(acellInfo); if (code) { - UNLOCK_GLOBAL_MUTEX - return code; + UNLOCK_GLOBAL_MUTEX return code; } /* write CellServDB */ strcompose(tbuffer, 1024, apath, "/", AFSDIR_CELLSERVDB_FILE, NULL); tf = fopen(tbuffer, "w"); if (!tf) { - UNLOCK_GLOBAL_MUTEX - return AFSCONF_NOTFOUND; + UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; } - fprintf(tf, ">%s #Cell name\n", acellInfo->name); - for(i=0;i < acellInfo->numServers; i++) { + fprintf(tf, ">%s #Cell name\n", acellInfo->name); + for (i = 0; i < acellInfo->numServers; i++) { code = acellInfo->hostAddr[i].sin_addr.s_addr; /* net order */ - if (code == 0) continue; /* delete request */ + if (code == 0) + continue; /* delete request */ code = ntohl(code); /* convert to host order */ - if (clones && clones[i]) - fprintf(tf, "[%d.%d.%d.%d] #%s\n", (code>>24) & 0xff, (code>>16)&0xff, (code>>8)&0xff, code&0xff, acellInfo->hostName[i]); - else - fprintf(tf, "%d.%d.%d.%d #%s\n", (code>>24) & 0xff, (code>>16)&0xff, (code>>8)&0xff, code&0xff, acellInfo->hostName[i]); + if (clones && clones[i]) + fprintf(tf, "[%d.%d.%d.%d] #%s\n", (code >> 24) & 0xff, + (code >> 16) & 0xff, (code >> 8) & 0xff, code & 0xff, + acellInfo->hostName[i]); + else + fprintf(tf, "%d.%d.%d.%d #%s\n", (code >> 24) & 0xff, + (code >> 16) & 0xff, (code >> 8) & 0xff, code & 0xff, + acellInfo->hostName[i]); } if (ferror(tf)) { fclose(tf); - UNLOCK_GLOBAL_MUTEX - return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; } code = fclose(tf); /* Reset the timestamp in the cache, so that - the CellServDB is read into the cache next time. - Resolves the lost update problem due to an inconsistent cache - */ - if (adir) adir->timeRead = 0; + * the CellServDB is read into the cache next time. + * Resolves the lost update problem due to an inconsistent cache + */ + if (adir) + adir->timeRead = 0; - UNLOCK_GLOBAL_MUTEX - if (code == EOF) return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX if (code == EOF) + return AFSCONF_FAILURE; return 0; } diff --git a/src/bozo/bnode.c b/src/bozo/bnode.c index 39052a977..038db5d34 100644 --- a/src/bozo/bnode.c +++ b/src/bozo/bnode.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -36,7 +37,7 @@ RCSID("$Header$"); #endif #endif -#include /* signal(), kill(), wait(), etc. */ +#include /* signal(), kill(), wait(), etc. */ #include #include #include @@ -51,21 +52,22 @@ RCSID("$Header$"); #define BNODE_LWP_STACKSIZE (16 * 1024) int bnode_waiting = 0; -static PROCESS bproc_pid; /* pid of waker-upper */ -static struct bnode *allBnodes=0; /* list of all bnodes */ -static struct bnode_proc *allProcs=0; /* list of all processes for which we're waiting */ -static struct bnode_type *allTypes=0; /* list of registered type handlers */ +static PROCESS bproc_pid; /* pid of waker-upper */ +static struct bnode *allBnodes = 0; /* list of all bnodes */ +static struct bnode_proc *allProcs = 0; /* list of all processes for which we're waiting */ +static struct bnode_type *allTypes = 0; /* list of registered type handlers */ static struct bnode_stats { int weirdPids; } bnode_stats; #ifndef AFS_NT40_ENV -extern char **environ; /* env structure */ +extern char **environ; /* env structure */ #endif /* Remember the name of the process, if any, that failed last */ -static void RememberProcName(register struct bnode_proc *ap) +static void +RememberProcName(register struct bnode_proc *ap) { register struct bnode *tbnodep; @@ -75,7 +77,7 @@ static void RememberProcName(register struct bnode_proc *ap) tbnodep->lastErrorName = NULL; } if (ap->coreName) { - tbnodep->lastErrorName = (char *) malloc(strlen(ap->coreName)+1); + tbnodep->lastErrorName = (char *)malloc(strlen(ap->coreName) + 1); strcpy(tbnodep->lastErrorName, ap->coreName); } } @@ -83,8 +85,8 @@ static void RememberProcName(register struct bnode_proc *ap) /* utility for use by BOP_HASCORE functions to determine where a core file might * be stored. */ -int bnode_CoreName(register struct bnode *abnode, char *acoreName, - char *abuffer) +int +bnode_CoreName(register struct bnode *abnode, char *acoreName, char *abuffer) { strcpy(abuffer, AFSDIR_SERVER_CORELOG_FILEPATH); if (acoreName) { @@ -96,57 +98,63 @@ int bnode_CoreName(register struct bnode *abnode, char *acoreName, } /* save core file, if any */ -static void SaveCore(register struct bnode *abnode, register struct bnode_proc - *aproc) +static void +SaveCore(register struct bnode *abnode, register struct bnode_proc + *aproc) { char tbuffer[256]; struct stat tstat; register afs_int32 code; #ifdef BOZO_SAVE_CORES - struct timeval Start; + struct timeval Start; struct tm *TimeFields; char FileName[256]; #endif code = stat(AFSDIR_SERVER_CORELOG_FILEPATH, &tstat); - if (code) return; - + if (code) + return; + bnode_CoreName(abnode, aproc->coreName, tbuffer); #ifdef BOZO_SAVE_CORES TM_GetTimeOfDay(&Start, 0); TimeFields = localtime(&Start.tv_sec); - sprintf(FileName,"%s.%d%02d%02d%02d%02d%02d", tbuffer, - TimeFields->tm_year, TimeFields->tm_mon + 1, - TimeFields->tm_mday, TimeFields->tm_hour, TimeFields->tm_min, - TimeFields->tm_sec); - strcpy(tbuffer,FileName); + sprintf(FileName, "%s.%d%02d%02d%02d%02d%02d", tbuffer, + TimeFields->tm_year, TimeFields->tm_mon + 1, TimeFields->tm_mday, + TimeFields->tm_hour, TimeFields->tm_min, TimeFields->tm_sec); + strcpy(tbuffer, FileName); #endif code = renamefile(AFSDIR_SERVER_CORELOG_FILEPATH, tbuffer); } -int bnode_GetString(register struct bnode *abnode, register char *abuffer, -register afs_int32 alen) +int +bnode_GetString(register struct bnode *abnode, register char *abuffer, + register afs_int32 alen) { return BOP_GETSTRING(abnode, abuffer, alen); } -int bnode_GetParm(register struct bnode *abnode, register afs_int32 aindex, - register char *abuffer, afs_int32 alen) +int +bnode_GetParm(register struct bnode *abnode, register afs_int32 aindex, + register char *abuffer, afs_int32 alen) { return BOP_GETPARM(abnode, aindex, abuffer, alen); } -int bnode_GetStat(register struct bnode *abnode, register afs_int32 *astatus) +int +bnode_GetStat(register struct bnode *abnode, register afs_int32 * astatus) { return BOP_GETSTAT(abnode, astatus); } -int bnode_RestartP(register struct bnode *abnode) +int +bnode_RestartP(register struct bnode *abnode) { return BOP_RESTARTP(abnode); } -static int bnode_Check(register struct bnode *abnode) +static int +bnode_Check(register struct bnode *abnode) { if (abnode->flags & BNODE_WAIT) { abnode->flags &= ~BNODE_WAIT; @@ -156,19 +164,22 @@ static int bnode_Check(register struct bnode *abnode) } /* tell if an instance has a core file */ -int bnode_HasCore(register struct bnode *abnode) +int +bnode_HasCore(register struct bnode *abnode) { return BOP_HASCORE(abnode); } /* wait for all bnodes to stabilize */ -int bnode_WaitAll() { +int +bnode_WaitAll() +{ register struct bnode *tb; register afs_int32 code; afs_int32 stat; retry: - for(tb = allBnodes; tb; tb=tb->next) { + for (tb = allBnodes; tb; tb = tb->next) { bnode_Hold(tb); code = BOP_GETSTAT(tb, &stat); if (code) { @@ -187,7 +198,8 @@ int bnode_WaitAll() { } /* wait until bnode status is correct */ -int bnode_WaitStatus(register struct bnode *abnode, int astatus) +int +bnode_WaitStatus(register struct bnode *abnode, int astatus) { register afs_int32 code; afs_int32 stat; @@ -196,16 +208,17 @@ int bnode_WaitStatus(register struct bnode *abnode, int astatus) while (1) { /* get the status */ code = BOP_GETSTAT(abnode, &stat); - if (code) return code; + if (code) + return code; /* otherwise, check if we're done */ if (stat == astatus) { bnode_Release(abnode); - return 0; /* done */ + return 0; /* done */ } if (astatus != abnode->goal) { bnode_Release(abnode); - return -1; /* no longer our goal, don't keep waiting */ + return -1; /* no longer our goal, don't keep waiting */ } /* otherwise, block */ abnode->flags |= BNODE_WAIT; @@ -213,7 +226,8 @@ int bnode_WaitStatus(register struct bnode *abnode, int astatus) } } -int bnode_SetStat(register struct bnode *abnode, register int agoal) +int +bnode_SetStat(register struct bnode *abnode, register int agoal) { abnode->goal = agoal; bnode_Check(abnode); @@ -222,64 +236,75 @@ int bnode_SetStat(register struct bnode *abnode, register int agoal) return 0; } -int bnode_SetGoal(register struct bnode *abnode, register int agoal) +int +bnode_SetGoal(register struct bnode *abnode, register int agoal) { abnode->goal = agoal; bnode_Check(abnode); return 0; } -int bnode_SetFileGoal(register struct bnode *abnode, register int agoal) +int +bnode_SetFileGoal(register struct bnode *abnode, register int agoal) { - if (abnode->fileGoal == agoal) return 0; /* already done */ + if (abnode->fileGoal == agoal) + return 0; /* already done */ abnode->fileGoal = agoal; WriteBozoFile(0); return 0; } /* apply a function to all bnodes in the system */ -int bnode_ApplyInstance(int (*aproc)(), char *arock) +int +bnode_ApplyInstance(int (*aproc) (), char *arock) { register struct bnode *tb, *nb; register afs_int32 code; - for(tb = allBnodes; tb; tb=nb) { + for (tb = allBnodes; tb; tb = nb) { nb = tb->next; code = (*aproc) (tb, arock); - if (code) return code; + if (code) + return code; } return 0; } -struct bnode *bnode_FindInstance(register char *aname) +struct bnode * +bnode_FindInstance(register char *aname) { register struct bnode *tb; - - for(tb=allBnodes;tb;tb=tb->next) { - if (!strcmp(tb->name, aname)) return tb; + + for (tb = allBnodes; tb; tb = tb->next) { + if (!strcmp(tb->name, aname)) + return tb; } return NULL; } -static struct bnode_type *FindType(register char *aname) +static struct bnode_type * +FindType(register char *aname) { register struct bnode_type *tt; - - for(tt=allTypes;tt;tt=tt->next) { - if (!strcmp(tt->name, aname)) return tt; + + for (tt = allTypes; tt; tt = tt->next) { + if (!strcmp(tt->name, aname)) + return tt; } - return (struct bnode_type *) 0; + return (struct bnode_type *)0; } -int bnode_Register(char *atype, struct bnode_ops *aprocs, int anparms) +int +bnode_Register(char *atype, struct bnode_ops *aprocs, int anparms) { register struct bnode_type *tt; - for(tt=allTypes;tt;tt=tt->next) { - if (!strcmp(tt->name, atype)) break; + for (tt = allTypes; tt; tt = tt->next) { + if (!strcmp(tt->name, atype)) + break; } if (!tt) { - tt = (struct bnode_type *) malloc(sizeof(struct bnode_type)); + tt = (struct bnode_type *)malloc(sizeof(struct bnode_type)); memset(tt, 0, sizeof(struct bnode_type)); tt->next = allTypes; allTypes = tt; @@ -289,33 +314,38 @@ int bnode_Register(char *atype, struct bnode_ops *aprocs, int anparms) return 0; } -afs_int32 bnode_Create(char *atype, char *ainstance, struct bnode **abp, - char *ap1, char *ap2, char *ap3, char *ap4, - char *ap5, char *notifier, int fileGoal) +afs_int32 +bnode_Create(char *atype, char *ainstance, struct bnode ** abp, char *ap1, + char *ap2, char *ap3, char *ap4, char *ap5, char *notifier, + int fileGoal) { struct bnode_type *type; struct bnode *tb; char *notifierpath = NULL; struct stat tstat; - if (bnode_FindInstance(ainstance)) return BZEXISTS; + if (bnode_FindInstance(ainstance)) + return BZEXISTS; type = FindType(atype); - if (!type) return BZBADTYPE; + if (!type) + return BZBADTYPE; if (notifier && strcmp(notifier, NONOTIFIER)) { /* construct local path from canonical (wire-format) path */ if (ConstructLocalBinPath(notifier, ¬ifierpath)) { - bozo_Log("BNODE-Create: Notifier program path invalid '%s'\n", notifier); + bozo_Log("BNODE-Create: Notifier program path invalid '%s'\n", + notifier); return BZNOCREATE; } if (stat(notifierpath, &tstat)) { - bozo_Log("BNODE-Create: Notifier program '%s' not found\n", notifierpath); + bozo_Log("BNODE-Create: Notifier program '%s' not found\n", + notifierpath); free(notifierpath); return BZNOCREATE; } } - tb = (*type->ops->create)(ainstance, ap1, ap2, ap3, ap4, ap5); + tb = (*type->ops->create) (ainstance, ap1, ap2, ap3, ap4, ap5); if (!tb) { free(notifierpath); return BZNOCREATE; @@ -325,32 +355,36 @@ afs_int32 bnode_Create(char *atype, char *ainstance, struct bnode **abp, tb->type = type; /* The fs_create above calls bnode_InitBnode() which always sets the - ** fileGoal to BSTAT_NORMAL .... overwrite it with whatever is passed into - ** this function as a parameter... */ + ** fileGoal to BSTAT_NORMAL .... overwrite it with whatever is passed into + ** this function as a parameter... */ tb->fileGoal = fileGoal; - bnode_SetStat(tb, tb->goal); /* nudge it once */ + bnode_SetStat(tb, tb->goal); /* nudge it once */ WriteBozoFile(0); return 0; } -int bnode_DeleteName(char *ainstance) +int +bnode_DeleteName(char *ainstance) { register struct bnode *tb; tb = bnode_FindInstance(ainstance); - if (!tb) return BZNOENT; - + if (!tb) + return BZNOENT; + return bnode_Delete(tb); } -int bnode_Hold(register struct bnode *abnode) +int +bnode_Hold(register struct bnode *abnode) { abnode->refCount++; return 0; } -int bnode_Release(register struct bnode *abnode) +int +bnode_Release(register struct bnode *abnode) { abnode->refCount--; if (abnode->refCount == 0 && abnode->flags & BNODE_DELETE) { @@ -360,12 +394,13 @@ int bnode_Release(register struct bnode *abnode) return 0; } -int bnode_Delete(register struct bnode *abnode) +int +bnode_Delete(register struct bnode *abnode) { register afs_int32 code; register struct bnode **lb, *ub; afs_int32 temp; - + if (abnode->refCount != 0) { abnode->flags |= BNODE_DELETE; return 0; @@ -375,54 +410,58 @@ int bnode_Delete(register struct bnode *abnode) bnode_Hold(abnode); code = BOP_GETSTAT(abnode, &temp); bnode_Release(abnode); - if (code) return code; - if (temp != BSTAT_SHUTDOWN) return BZBUSY; + if (code) + return code; + if (temp != BSTAT_SHUTDOWN) + return BZBUSY; /* all clear to zap */ - for(lb = &allBnodes, ub = *lb; ub; lb= &ub->next, ub = *lb) { + for (lb = &allBnodes, ub = *lb; ub; lb = &ub->next, ub = *lb) { if (ub == abnode) { /* unthread it from the list */ *lb = ub->next; break; } } - free(abnode->name); /* do this first, since bnode fields may be bad after BOP_DELETE */ + free(abnode->name); /* do this first, since bnode fields may be bad after BOP_DELETE */ code = BOP_DELETE(abnode); /* don't play games like holding over this one */ WriteBozoFile(0); return code; } /* function to tell if there's a timeout coming up */ -int bnode_PendingTimeout(register struct bnode *abnode) +int +bnode_PendingTimeout(register struct bnode *abnode) { return (abnode->flags & BNODE_NEEDTIMEOUT); } /* function called to set / clear periodic bnode wakeup times */ -int bnode_SetTimeout(register struct bnode *abnode, afs_int32 atimeout) +int +bnode_SetTimeout(register struct bnode *abnode, afs_int32 atimeout) { if (atimeout != 0) { abnode->nextTimeout = FT_ApproxTime() + atimeout; abnode->flags |= BNODE_NEEDTIMEOUT; abnode->period = atimeout; IOMGR_Cancel(bproc_pid); - } - else { + } else { abnode->flags &= ~BNODE_NEEDTIMEOUT; } return 0; } /* used by new bnode creation code to format bnode header */ -int bnode_InitBnode (register struct bnode *abnode, - struct bnode_ops *abnodeops, char *aname) +int +bnode_InitBnode(register struct bnode *abnode, struct bnode_ops *abnodeops, + char *aname) { struct bnode **lb, *nb; /* format the bnode properly */ memset(abnode, 0, sizeof(struct bnode)); abnode->ops = abnodeops; - abnode->name = (char *) malloc(strlen(aname)+1); + abnode->name = (char *)malloc(strlen(aname) + 1); if (!abnode->name) return ENOMEM; strcpy(abnode->name, aname); @@ -431,18 +470,19 @@ int bnode_InitBnode (register struct bnode *abnode, abnode->goal = BSTAT_SHUTDOWN; /* put the bnode at the end of the list so we write bnode file in same order */ - for(lb = &allBnodes, nb = *lb; nb; lb = &nb->next, nb = *lb); + for (lb = &allBnodes, nb = *lb; nb; lb = &nb->next, nb = *lb); *lb = abnode; return 0; } -static int DeleteProc(register struct bnode_proc *abproc) +static int +DeleteProc(register struct bnode_proc *abproc) { register struct bnode_proc **pb, *tb; struct bnode_proc *nb; - for(pb = &allProcs,tb = *pb; tb; pb = &tb->next, tb=nb) { + for (pb = &allProcs, tb = *pb; tb; pb = &tb->next, tb = nb) { nb = tb->next; if (tb == abproc) { *pb = nb; @@ -454,22 +494,24 @@ static int DeleteProc(register struct bnode_proc *abproc) } /* bnode lwp executes this code repeatedly */ -static int bproc() { +static int +bproc() +{ register afs_int32 code; register struct bnode *tb; register afs_int32 temp; register struct bnode_proc *tp; struct bnode *nb; - int options; /* must not be register */ + int options; /* must not be register */ struct timeval tv; int setAny; int status; while (1) { /* first figure out how long to sleep for */ - temp = 0x7fffffff; /* afs_int32 time; maxint doesn't work in select */ + temp = 0x7fffffff; /* afs_int32 time; maxint doesn't work in select */ setAny = 0; - for(tb = allBnodes; tb; tb=tb->next) { + for (tb = allBnodes; tb; tb = tb->next) { if (tb->flags & BNODE_NEEDTIMEOUT) { if (tb->nextTimeout < temp) { setAny = 1; @@ -480,32 +522,34 @@ static int bproc() { /* now temp has the time at which we should wakeup next */ /* sleep */ - if (setAny) temp -= FT_ApproxTime(); /* how many seconds until next event */ - else temp = 999999; + if (setAny) + temp -= FT_ApproxTime(); /* how many seconds until next event */ + else + temp = 999999; if (temp > 0) { tv.tv_sec = temp; tv.tv_usec = 0; code = IOMGR_Select(0, 0, 0, 0, &tv); - } - else code = 0; /* fake timeout code */ + } else + code = 0; /* fake timeout code */ /* figure out why we woke up; child exit or timeouts */ - FT_GetTimeOfDay(&tv, 0); /* must do the real gettimeofday once and a while */ + FT_GetTimeOfDay(&tv, 0); /* must do the real gettimeofday once and a while */ temp = tv.tv_sec; /* check all bnodes to see which ones need timeout events */ - for(tb = allBnodes; tb; tb=nb) { + for (tb = allBnodes; tb; tb = nb) { if ((tb->flags & BNODE_NEEDTIMEOUT) && temp > tb->nextTimeout) { bnode_Hold(tb); BOP_TIMEOUT(tb); bnode_Check(tb); - if (tb->flags & BNODE_NEEDTIMEOUT) { /* check again, BOP_TIMEOUT could change */ + if (tb->flags & BNODE_NEEDTIMEOUT) { /* check again, BOP_TIMEOUT could change */ tb->nextTimeout = FT_ApproxTime() + tb->period; } nb = tb->next; - bnode_Release(tb); /* delete may occur here */ - } - else nb=tb->next; + bnode_Release(tb); /* delete may occur here */ + } else + nb = tb->next; } if (code < 0) { @@ -513,12 +557,14 @@ static int bproc() { while (1) { options = WNOHANG; bnode_waiting = options | 0x800000; - code = waitpid((pid_t)-1, &status, options); + code = waitpid((pid_t) - 1, &status, options); bnode_waiting = 0; - if (code == 0 || code == -1) break; /* all done */ + if (code == 0 || code == -1) + break; /* all done */ /* otherwise code has a process id, which we now search for */ - for(tp=allProcs; tp; tp=tp->next) - if (tp->pid == code) break; + for (tp = allProcs; tp; tp = tp->next) + if (tp->pid == code) + break; if (tp) { /* found the pid */ tb = tp->bnode; @@ -542,20 +588,20 @@ static int bproc() { tb->errorSignal = 0; } if (tp->coreName) - bozo_Log("%s:%s exited with code %d\n", - tb->name, tp->coreName, tp->lastExit); + bozo_Log("%s:%s exited with code %d\n", tb->name, + tp->coreName, tp->lastExit); else - bozo_Log("%s exited with code %d\n", - tb->name, tp->lastExit); - } - else { + bozo_Log("%s exited with code %d\n", tb->name, + tp->lastExit); + } else { /* Signal occurred, perhaps spurious due to shutdown request. * If due to a shutdown request, don't overwrite last error * information. */ tp->lastSignal = WTERMSIG(status); tp->lastExit = 0; - if (tp->lastSignal != SIGQUIT && tp->lastSignal != SIGTERM + if (tp->lastSignal != SIGQUIT + && tp->lastSignal != SIGTERM && tp->lastSignal != SIGKILL) { tb->errorSignal = tp->lastSignal; tb->lastErrorExit = FT_ApproxTime(); @@ -563,18 +609,21 @@ static int bproc() { } if (tp->coreName) bozo_Log("%s:%s exited on signal %d%s\n", - tb->name, tp->coreName, tp->lastSignal, - WCOREDUMP(status) ? " (core dumped)" : ""); + tb->name, tp->coreName, tp->lastSignal, + WCOREDUMP(status) ? " (core dumped)" : + ""); else - bozo_Log("%s exited on signal %d%s\n", - tb->name, tp->lastSignal, - WCOREDUMP(status) ? " (core dumped)" : ""); + bozo_Log("%s exited on signal %d%s\n", tb->name, + tp->lastSignal, + WCOREDUMP(status) ? " (core dumped)" : + ""); SaveCore(tb, tp); } tb->lastAnyExit = FT_ApproxTime(); if (tb->notifier) { - bozo_Log("BNODE: Notifier %s will be called\n", tb->notifier); + bozo_Log("BNODE: Notifier %s will be called\n", + tb->notifier); hdl_notifier(tp); } BOP_PROCEXIT(tb, tp); @@ -584,20 +633,21 @@ static int bproc() { /* 10 in 10 seconds */ tb->flags |= BNODE_ERRORSTOP; bnode_SetGoal(tb, BSTAT_SHUTDOWN); - bozo_Log("BNODE '%s' repeatedly failed to start, perhaps missing executable.\n", - tb->name); + bozo_Log + ("BNODE '%s' repeatedly failed to start, perhaps missing executable.\n", + tb->name); } bnode_Release(tb); /* bnode delete can happen here */ DeleteProc(tp); - } - else bnode_stats.weirdPids++; + } else + bnode_stats.weirdPids++; } } } } -static afs_int32 SendNotifierData(register int fd, - register struct bnode_proc *tp) +static afs_int32 +SendNotifierData(register int fd, register struct bnode_proc *tp) { register struct bnode *tb = tp->bnode; char buffer[1000], *bufp = buffer, *buf1; @@ -606,78 +656,80 @@ static afs_int32 SendNotifierData(register int fd, /* * First sent out the bnode_proc struct */ - (void) sprintf(bufp, "BEGIN bnode_proc\n"); + (void)sprintf(bufp, "BEGIN bnode_proc\n"); bufp += strlen(bufp); - (void) sprintf(bufp, "comLine: %s\n", tp->comLine); + (void)sprintf(bufp, "comLine: %s\n", tp->comLine); bufp += strlen(bufp); if (!(buf1 = tp->coreName)) buf1 = "(null)"; - (void) sprintf(bufp, "coreName: %s\n", buf1); + (void)sprintf(bufp, "coreName: %s\n", buf1); bufp += strlen(bufp); - (void) sprintf(bufp, "pid: %ld\n", tp->pid); + (void)sprintf(bufp, "pid: %ld\n", tp->pid); bufp += strlen(bufp); - (void) sprintf(bufp, "lastExit: %ld\n", tp->lastExit); + (void)sprintf(bufp, "lastExit: %ld\n", tp->lastExit); bufp += strlen(bufp); #ifdef notdef - (void) sprintf(bufp, "lastSignal: %ld\n", tp->lastSignal); + (void)sprintf(bufp, "lastSignal: %ld\n", tp->lastSignal); bufp += strlen(bufp); #endif - (void) sprintf(bufp, "flags: %ld\n", tp->flags); + (void)sprintf(bufp, "flags: %ld\n", tp->flags); bufp += strlen(bufp); - (void) sprintf(bufp, "END bnode_proc\n"); + (void)sprintf(bufp, "END bnode_proc\n"); bufp += strlen(bufp); - len =(int)(bufp-buffer); + len = (int)(bufp - buffer); if (write(fd, buffer, len) < 0) { return -1; } /* * Now sent out the bnode struct - */ + */ bufp = buffer; - (void) sprintf(bufp, "BEGIN bnode\n"); + (void)sprintf(bufp, "BEGIN bnode\n"); bufp += strlen(bufp); - (void) sprintf(bufp, "name: %s\n", tb->name); + (void)sprintf(bufp, "name: %s\n", tb->name); bufp += strlen(bufp); - (void) sprintf(bufp, "rsTime: %ld\n", tb->rsTime); + (void)sprintf(bufp, "rsTime: %ld\n", tb->rsTime); bufp += strlen(bufp); - (void) sprintf(bufp, "rsCount: %ld\n", tb->rsCount); + (void)sprintf(bufp, "rsCount: %ld\n", tb->rsCount); bufp += strlen(bufp); - (void) sprintf(bufp, "procStartTime: %ld\n", tb->procStartTime); + (void)sprintf(bufp, "procStartTime: %ld\n", tb->procStartTime); bufp += strlen(bufp); - (void) sprintf(bufp, "procStarts: %ld\n", tb->procStarts); + (void)sprintf(bufp, "procStarts: %ld\n", tb->procStarts); bufp += strlen(bufp); - (void) sprintf(bufp, "lastAnyExit: %ld\n", tb->lastAnyExit); + (void)sprintf(bufp, "lastAnyExit: %ld\n", tb->lastAnyExit); bufp += strlen(bufp); - (void) sprintf(bufp, "lastErrorExit: %ld\n", tb->lastErrorExit); + (void)sprintf(bufp, "lastErrorExit: %ld\n", tb->lastErrorExit); bufp += strlen(bufp); - (void) sprintf(bufp, "errorCode: %ld\n", tb->errorCode); + (void)sprintf(bufp, "errorCode: %ld\n", tb->errorCode); bufp += strlen(bufp); - (void) sprintf(bufp, "errorSignal: %ld\n", tb->errorSignal); + (void)sprintf(bufp, "errorSignal: %ld\n", tb->errorSignal); bufp += strlen(bufp); /* (void) sprintf(bufp, "lastErrorName: %s\n", tb->lastErrorName); bufp += strlen(bufp); */ - (void) sprintf(bufp, "goal: %d\n", tb->goal); + (void)sprintf(bufp, "goal: %d\n", tb->goal); bufp += strlen(bufp); - (void) sprintf(bufp, "END bnode\n"); + (void)sprintf(bufp, "END bnode\n"); bufp += strlen(bufp); - len = (int)bufp-(int)buffer; + len = (int)bufp - (int)buffer; if (write(fd, buffer, len) < 0) { return -1; } } -int hdl_notifier(struct bnode_proc *tp) +int +hdl_notifier(struct bnode_proc *tp) { -#ifndef AFS_NT40_ENV /* NT notifier callout not yet implemented */ +#ifndef AFS_NT40_ENV /* NT notifier callout not yet implemented */ int code, pid, status; struct stat tstat; if (stat(tp->bnode->notifier, &tstat)) { - bozo_Log("BNODE: Failed to find notifier '%s'; ignored\n", tp->bnode->notifier); - return(1); + bozo_Log("BNODE: Failed to find notifier '%s'; ignored\n", + tp->bnode->notifier); + return (1); } if ((pid = fork()) == 0) { FILE *fout; @@ -690,29 +742,32 @@ int hdl_notifier(struct bnode_proc *tp) #ifdef AFS_LINUX20_ENV ec = setpgrp(); #else - ec = setpgrp(0,0); + ec = setpgrp(0, 0); #endif #endif fout = popen(tb->notifier, "w"); if (fout == NULL) { - bozo_Log("BNODE: Failed to find notifier '%s'; ignored\n", tb->notifier); - perror(tb->notifier); + bozo_Log("BNODE: Failed to find notifier '%s'; ignored\n", + tb->notifier); + perror(tb->notifier); exit(1); } code = SendNotifierData(fileno(fout), tp); pclose(fout); exit(0); } else if (pid < 0) { - bozo_Log("Failed to fork creating process to handle notifier '%s'\n", tp->bnode->notifier); + bozo_Log("Failed to fork creating process to handle notifier '%s'\n", + tp->bnode->notifier); return -1; } #endif /* AFS_NT40_ENV */ - return(0); + return (0); } /* Called by IOMGR at low priority on IOMGR's stack shortly after a SIGCHLD * occurs. Wakes up bproc do redo things */ -int bnode_SoftInt(int asignal) +int +bnode_SoftInt(int asignal) { IOMGR_Cancel(bproc_pid); return 0; @@ -721,7 +776,8 @@ int bnode_SoftInt(int asignal) /* Called at signal interrupt level; queues function to be called * when IOMGR runs again. */ -void bnode_Int(int asignal) +void +bnode_Int(int asignal) { extern void bozo_ShutdownAndExit(); @@ -734,35 +790,42 @@ void bnode_Int(int asignal) /* intialize the whole system */ -int bnode_Init() { +int +bnode_Init() +{ PROCESS junk; register afs_int32 code; struct sigaction newaction; static initDone = 0; - if (initDone) return 0; + if (initDone) + return 0; initDone = 1; memset(&bnode_stats, 0, sizeof(bnode_stats)); - LWP_InitializeProcessSupport(1, &junk); /* just in case */ + LWP_InitializeProcessSupport(1, &junk); /* just in case */ IOMGR_Initialize(); code = LWP_CreateProcess(bproc, BNODE_LWP_STACKSIZE, - /* priority */ 1, (void *) /* parm */0, + /* priority */ 1, (void *) /* parm */ 0, "bnode-manager", &bproc_pid); - if (code) return code; + if (code) + return code; memset((char *)&newaction, 0, sizeof(newaction)); newaction.sa_handler = bnode_Int; code = sigaction(SIGCHLD, &newaction, NULL); - if (code) return errno; + if (code) + return errno; code = sigaction(SIGQUIT, &newaction, NULL); - if (code) return errno; + if (code) + return errno; return code; } - + /* free token list returned by parseLine */ -int bnode_FreeTokens(register struct bnode_token *alist) +int +bnode_FreeTokens(register struct bnode_token *alist) { register struct bnode_token *nlist; - for(; alist; alist = nlist) { + for (; alist; alist = nlist) { nlist = alist->next; free(alist->key); free(alist); @@ -770,13 +833,17 @@ int bnode_FreeTokens(register struct bnode_token *alist) return 0; } -static int space(int x) +static int +space(int x) { - if (x == 0 || x == ' ' || x == '\t' || x== '\n') return 1; - else return 0; + if (x == 0 || x == ' ' || x == '\t' || x == '\n') + return 1; + else + return 0; } -int bnode_ParseLine(char *aline, struct bnode_token **alist) +int +bnode_ParseLine(char *aline, struct bnode_token **alist) { char tbuffer[256]; register char *tptr; @@ -784,40 +851,43 @@ int bnode_ParseLine(char *aline, struct bnode_token **alist) struct bnode_token *first, *last; register struct bnode_token *ttok; register int tc; - - inToken = 0; /* not copying token chars at start */ - first = (struct bnode_token *) 0; - last = (struct bnode_token *) 0; + + inToken = 0; /* not copying token chars at start */ + first = (struct bnode_token *)0; + last = (struct bnode_token *)0; while (1) { tc = *aline++; - if (tc == 0 || space(tc)) { /* terminating null gets us in here, too */ + if (tc == 0 || space(tc)) { /* terminating null gets us in here, too */ if (inToken) { - inToken = 0; /* end of this token */ + inToken = 0; /* end of this token */ *tptr++ = 0; - ttok = (struct bnode_token *) malloc(sizeof(struct bnode_token)); - ttok->next = (struct bnode_token *) 0; - ttok->key = (char *) malloc(strlen(tbuffer)+1); + ttok = + (struct bnode_token *)malloc(sizeof(struct bnode_token)); + ttok->next = (struct bnode_token *)0; + ttok->key = (char *)malloc(strlen(tbuffer) + 1); strcpy(ttok->key, tbuffer); if (last) { last->next = ttok; last = ttok; - } - else last = ttok; - if (!first) first = ttok; + } else + last = ttok; + if (!first) + first = ttok; } - } - else { + } else { /* an alpha character */ if (!inToken) { tptr = tbuffer; inToken = 1; } - if (tptr - tbuffer >= sizeof(tbuffer)) return -1; /* token too long */ + if (tptr - tbuffer >= sizeof(tbuffer)) + return -1; /* token too long */ *tptr++ = tc; } if (tc == 0) { /* last token flushed 'cause space(0) --> true */ - if (last) last->next = (struct bnode_token *) 0; + if (last) + last->next = (struct bnode_token *)0; *alist = first; return 0; } @@ -825,8 +895,9 @@ int bnode_ParseLine(char *aline, struct bnode_token **alist) } #define MAXVARGS 128 -int bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName, - struct bnode_proc **aproc) +int +bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName, + struct bnode_proc **aproc) { struct bnode_token *tlist, *tt; afs_int32 code; @@ -835,9 +906,10 @@ int bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName, char *argv[MAXVARGS]; int i; - code = bnode_ParseLine(aexecString, &tlist); /* try parsing first */ - if (code) return code; - tp = (struct bnode_proc *) malloc(sizeof(struct bnode_proc)); + code = bnode_ParseLine(aexecString, &tlist); /* try parsing first */ + if (code) + return code; + tp = (struct bnode_proc *)malloc(sizeof(struct bnode_proc)); memset(tp, 0, sizeof(struct bnode_proc)); tp->next = allProcs; allProcs = tp; @@ -852,12 +924,12 @@ int bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName, for (tt = tlist, i = 0; i < (MAXVARGS - 1) && tt; tt = tt->next, i++) { argv[i] = tt->key; } - argv[i] = NULL; /* null-terminated */ + argv[i] = NULL; /* null-terminated */ cpid = spawnprocve(argv[0], argv, environ, -1); - osi_audit(BOSSpawnProcEvent, 0, AUD_STR, aexecString, AUD_END ); + osi_audit(BOSSpawnProcEvent, 0, AUD_STR, aexecString, AUD_END); - if (cpid == (pid_t)-1) { + if (cpid == (pid_t) - 1) { bozo_Log("Failed to spawn process for bnode '%s'\n", abnode->name); bnode_FreeTokens(tlist); free(tp); @@ -872,25 +944,29 @@ int bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName, return 0; } -int bnode_StopProc(register struct bnode_proc *aproc, int asignal) +int +bnode_StopProc(register struct bnode_proc *aproc, int asignal) { register int code; if (!(aproc->flags & BPROC_STARTED) || (aproc->flags & BPROC_EXITED)) return BZNOTACTIVE; - osi_audit( BOSStopProcEvent, 0, AUD_STR, (aproc ? aproc->comLine : NULL), AUD_END ); + osi_audit(BOSStopProcEvent, 0, AUD_STR, (aproc ? aproc->comLine : NULL), + AUD_END); code = kill(aproc->pid, asignal); bnode_Check(aproc->bnode); return code; } -int bnode_Deactivate(register struct bnode *abnode) +int +bnode_Deactivate(register struct bnode *abnode) { register struct bnode **pb, *tb; struct bnode *nb; - if (!(abnode->flags & BNODE_ACTIVE)) return BZNOTACTIVE; - for(pb = &allBnodes,tb = *pb; tb; tb=nb) { + if (!(abnode->flags & BNODE_ACTIVE)) + return BZNOTACTIVE; + for (pb = &allBnodes, tb = *pb; tb; tb = nb) { nb = tb->next; if (tb == abnode) { *pb = nb; @@ -900,4 +976,3 @@ int bnode_Deactivate(register struct bnode *abnode) } return BZNOENT; } - diff --git a/src/bozo/bnode.p.h b/src/bozo/bnode.p.h index 4340ac857..661938bbe 100644 --- a/src/bozo/bnode.p.h +++ b/src/bozo/bnode.p.h @@ -18,16 +18,16 @@ #define BOP_HASCORE(bnode) ((*(bnode)->ops->hascore)((bnode))) struct bnode_ops { - struct bnode *(*create)(/* variable args */); - int (*timeout) (/* bnode */); - int (*getstat) (/* bnode, status */); - int (*setstat) (/* bnode, status */); - int (*delete) (/* bnode */); - int (*procexit) (/* bnode, proc */); - int (*getstring) (/* bnode, buffer, bufLen */); - int (*getparm) (/* bnode, parmIndex, buffer, bufLen */); - int (*restartp) (/* bnode */); - int (*hascore) (/* bnode */); + struct bnode *(*create) ( /* variable args */ ); + int (*timeout) ( /* bnode */ ); + int (*getstat) ( /* bnode, status */ ); + int (*setstat) ( /* bnode, status */ ); + int (*delete) ( /* bnode */ ); + int (*procexit) ( /* bnode, proc */ ); + int (*getstring) ( /* bnode, buffer, bufLen */ ); + int (*getparm) ( /* bnode, parmIndex, buffer, bufLen */ ); + int (*restartp) ( /* bnode */ ); + int (*hascore) ( /* bnode */ ); }; struct bnode_type { @@ -42,78 +42,78 @@ struct bnode_token { }; struct bnode { - struct bnode *next; /* next pointer in top-level's list */ - char *name; /* instance name */ - afs_int32 nextTimeout; /* next time this guy should be woken */ - afs_int32 period; /* period between calls */ - afs_int32 rsTime; /* time we started counting restarts */ - afs_int32 rsCount; /* count of restarts since rsTime */ - struct bnode_type *type; /* type object */ - struct bnode_ops *ops; /* functions implementing bnode class */ - afs_int32 procStartTime; /* last time a process was started */ - afs_int32 procStarts; /* number of process starts */ - afs_int32 lastAnyExit; /* last time a process exited, for any reason */ - afs_int32 lastErrorExit; /* last time a process exited unexpectedly */ - afs_int32 errorCode; /* last exit return code */ - afs_int32 errorSignal; /* last proc terminating signal */ - char *lastErrorName; /* name of proc that failed last */ - char *notifier; /* notifier program to be executed on exits */ - short refCount; /* reference count */ - short flags; /* random flags */ - char goal; /* 1=running or 0=not running */ - char fileGoal; /* same, but to be stored in file */ + struct bnode *next; /* next pointer in top-level's list */ + char *name; /* instance name */ + afs_int32 nextTimeout; /* next time this guy should be woken */ + afs_int32 period; /* period between calls */ + afs_int32 rsTime; /* time we started counting restarts */ + afs_int32 rsCount; /* count of restarts since rsTime */ + struct bnode_type *type; /* type object */ + struct bnode_ops *ops; /* functions implementing bnode class */ + afs_int32 procStartTime; /* last time a process was started */ + afs_int32 procStarts; /* number of process starts */ + afs_int32 lastAnyExit; /* last time a process exited, for any reason */ + afs_int32 lastErrorExit; /* last time a process exited unexpectedly */ + afs_int32 errorCode; /* last exit return code */ + afs_int32 errorSignal; /* last proc terminating signal */ + char *lastErrorName; /* name of proc that failed last */ + char *notifier; /* notifier program to be executed on exits */ + short refCount; /* reference count */ + short flags; /* random flags */ + char goal; /* 1=running or 0=not running */ + char fileGoal; /* same, but to be stored in file */ }; struct bnode_proc { - struct bnode_proc *next; /* next guy in top-level's list */ - struct bnode *bnode; /* bnode creating this process */ - char *comLine; /* command line used to start this process */ - char *coreName; /* optional core file component name */ - afs_int32 pid; /* pid if created */ - afs_int32 lastExit; /* last termination code */ - afs_int32 lastSignal; /* last signal that killed this guy */ - afs_int32 flags; /* flags giving process state */ + struct bnode_proc *next; /* next guy in top-level's list */ + struct bnode *bnode; /* bnode creating this process */ + char *comLine; /* command line used to start this process */ + char *coreName; /* optional core file component name */ + afs_int32 pid; /* pid if created */ + afs_int32 lastExit; /* last termination code */ + afs_int32 lastSignal; /* last signal that killed this guy */ + afs_int32 flags; /* flags giving process state */ }; - + struct ezbnode { struct bnode b; afs_int32 zapTime; /* time we sent a sigterm */ char *command; struct bnode_proc *proc; - afs_int32 lastStart; /* time last started process */ + afs_int32 lastStart; /* time last started process */ char waitingForShutdown; /* have we started any shutdown procedure? */ - char running; /* is process running? */ - char killSent; /* have we tried sigkill signal? */ + char running; /* is process running? */ + char killSent; /* have we tried sigkill signal? */ }; /* this struct is used to construct a list of dirpaths, along with * their recommended permissions */ struct bozo_bosEntryStats { - const char *path; /* pathname to check */ - int dir; /* 1=>dir or 0=>file */ - int rootOwner; /* 1=>root must own */ - int reqPerm; /* required permissions */ - int proPerm; /* prohibited permissions */ + const char *path; /* pathname to check */ + int dir; /* 1=>dir or 0=>file */ + int rootOwner; /* 1=>root must own */ + int reqPerm; /* required permissions */ + int proPerm; /* prohibited permissions */ }; /* bnode flags */ -#define BNODE_NEEDTIMEOUT 1 /* timeouts are active */ -#define BNODE_ACTIVE 2 /* in generic lists */ -#define BNODE_WAIT 4 /* someone waiting for status change */ -#define BNODE_DELETE 8 /* delete this bnode asap */ -#define BNODE_ERRORSTOP 0x10 /* stopped due to errors */ +#define BNODE_NEEDTIMEOUT 1 /* timeouts are active */ +#define BNODE_ACTIVE 2 /* in generic lists */ +#define BNODE_WAIT 4 /* someone waiting for status change */ +#define BNODE_DELETE 8 /* delete this bnode asap */ +#define BNODE_ERRORSTOP 0x10 /* stopped due to errors */ /* flags for bnode_proc */ -#define BPROC_STARTED 1 /* ever started */ -#define BPROC_EXITED 2 /* exited */ +#define BPROC_STARTED 1 /* ever started */ +#define BPROC_EXITED 2 /* exited */ #define NONOTIFIER "__NONOTIFIER__" /* status values for bnodes, and goals */ -#define BSTAT_SHUTDOWN 0 /* shutdown normally */ -#define BSTAT_NORMAL 1 /* running normally */ -#define BSTAT_SHUTTINGDOWN 2 /* normal --> shutdown */ -#define BSTAT_STARTINGUP 3 /* shutdown --> normal */ +#define BSTAT_SHUTDOWN 0 /* shutdown normally */ +#define BSTAT_NORMAL 1 /* running normally */ +#define BSTAT_SHUTTINGDOWN 2 /* normal --> shutdown */ +#define BSTAT_STARTINGUP 3 /* shutdown --> normal */ /* exit values indicating that NT SCM integrator should restart bosserver */ #ifdef AFS_NT40_ENV @@ -124,14 +124,14 @@ struct bozo_bosEntryStats { #endif /* max time to wait for fileserver shutdown */ -#define FSSDTIME (30 * 60) /* seconds */ +#define FSSDTIME (30 * 60) /* seconds */ /* calls back up to the generic bnode layer */ -extern int bnode_SetTimeout(/* bnode, timeout */); -extern int bnode_Init(/* bnode, bnodeops */); -extern int bnode_Activate(/* bnode */); -extern int bnode_NewProc(/* bnode, execstring, corename, procaddr */); -extern int bnode_Init(/* no parms */); +extern int bnode_SetTimeout( /* bnode, timeout */ ); +extern int bnode_Init( /* bnode, bnodeops */ ); +extern int bnode_Activate( /* bnode */ ); +extern int bnode_NewProc( /* bnode, execstring, corename, procaddr */ ); +extern int bnode_Init( /* no parms */ ); extern afs_int32 bnode_Create(); extern struct bnode *bnode_FindInstance(); diff --git a/src/bozo/bos.c b/src/bozo/bos.c index 14c02ba7d..565bd3588 100644 --- a/src/bozo/bos.c +++ b/src/bozo/bos.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -28,7 +29,7 @@ RCSID("$Header$"); #include #endif /* AFS_NT40_ENV */ #include -#include /* signal(), kill(), wait(), etc. */ +#include /* signal(), kill(), wait(), etc. */ #include #include "bnode.h" #include @@ -84,26 +85,35 @@ static struct SalvageParms { /* dummy routine for the audit work. It should do nothing since audits */ /* occur at the server level and bos is not a server. */ -osi_audit() {return 0;} +osi_audit() +{ + return 0; +} /* keep those lines small */ -static char *em(acode) -afs_int32 acode; { +static char * +em(acode) + afs_int32 acode; +{ if (acode == -1) return "communications failure (-1)"; else if (acode == -3) return "communications timeout (-3)"; - else return (char *) error_message(acode); + else + return (char *)error_message(acode); } /* get partition id from a name */ -static afs_int32 GetPartitionID(aname) -char *aname; { +static afs_int32 +GetPartitionID(aname) + char *aname; +{ register char tc; char ascii[3]; tc = *aname; - if (tc == 0) return -1; /* unknown */ + if (tc == 0) + return -1; /* unknown */ /* numbers go straight through */ if (tc >= '0' && tc <= '9') { return atoi(aname); @@ -112,40 +122,41 @@ char *aname; { ascii[2] = 0; if (strlen(aname) <= 2) { strcpy(ascii, aname); - } - else if (!strncmp(aname, "/vicep", 6)) { - strncpy(ascii, aname+6, 2); - } - else if (!strncmp(aname, "vicep", 5)) { - strncpy(ascii, aname+5, 2); - } - else return -1; /* bad partition name */ + } else if (!strncmp(aname, "/vicep", 6)) { + strncpy(ascii, aname + 6, 2); + } else if (!strncmp(aname, "vicep", 5)) { + strncpy(ascii, aname + 5, 2); + } else + return -1; /* bad partition name */ /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab, * .../vicepzz, and are numbered from 0. Do the appropriate conversion */ if (ascii[1] == 0) { /* one char name, 0..25 */ - if (ascii[0] < 'a' || ascii[0] > 'z') return -1; /* wrongo */ + if (ascii[0] < 'a' || ascii[0] > 'z') + return -1; /* wrongo */ return ascii[0] - 'a'; - } - else { + } else { /* two char name, 26 .. */ - if (ascii[0] < 'a' || ascii[0] > 'z') return -1; /* wrongo */ - if (ascii[1] < 'a' || ascii[1] > 'z') return -1; /* just as bad */ + if (ascii[0] < 'a' || ascii[0] > 'z') + return -1; /* wrongo */ + if (ascii[1] < 'a' || ascii[1] > 'z') + return -1; /* just as bad */ return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26; } } /* make ctime easier to use */ -static char *DateOf(atime) -afs_int32 atime; { +static char * +DateOf(atime) + afs_int32 atime; +{ static char tbuffer[30]; register char *tp; - tp=ctime((time_t *)&atime); + tp = ctime((time_t *) & atime); if (tp) { strcpy(tbuffer, tp); - tbuffer[24] = 0; /* get rid of new line */ - } - else + tbuffer[24] = 0; /* get rid of new line */ + } else strcpy(tbuffer, "BAD TIME"); return tbuffer; } @@ -157,9 +168,11 @@ static int scIndex; /* use the syntax descr to get a connection, authenticated appropriately. * aencrypt is set if we want to encrypt the data on the wire. */ -static struct rx_connection *GetConn(as, aencrypt) -int aencrypt; -struct cmd_syndesc *as; { +static struct rx_connection * +GetConn(as, aencrypt) + int aencrypt; + struct cmd_syndesc *as; +{ struct hostent *th; char *hostname; register afs_int32 code; @@ -182,26 +195,27 @@ struct cmd_syndesc *as; { /* get tokens for making authenticated connections */ localauth = (as->parms[ADDPARMOFFSET + 2].items != 0); - confdir = (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH); - tdir = afsconf_Open (confdir); + confdir = + (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH); + tdir = afsconf_Open(confdir); if (tdir) { struct afsconf_cell info; char *tname; - if (as->parms[ADDPARMOFFSET].items) + if (as->parms[ADDPARMOFFSET].items) tname = as->parms[ADDPARMOFFSET].items->data; - else tname = NULL; + else + tname = NULL; /* next call expands cell name abbrevs for us and handles looking up - * local cell */ + * local cell */ code = afsconf_GetCellInfo(tdir, tname, NULL, &info); if (code) { - com_err ("bos", code, "(can't find cell '%s' in cell database)", - (tname? tname : "")); + com_err("bos", code, "(can't find cell '%s' in cell database)", + (tname ? tname : "")); exit(1); - } - else strcpy(sname.cell, info.name); - } - else { + } else + strcpy(sname.cell, info.name); + } else { printf("bos: can't open cell database (%s)\n", confdir); exit(1); } @@ -212,80 +226,97 @@ struct cmd_syndesc *as; { sc[2] = 0; scIndex = 0; - if (!as->parms[ADDPARMOFFSET + 1].items) { /* not -noauth */ - if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */ - code = afsconf_GetLatestKey (tdir, 0,0); - if (code) com_err ("bos", code, "(getting key from local KeyFile)"); + if (!as->parms[ADDPARMOFFSET + 1].items) { /* not -noauth */ + if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */ + code = afsconf_GetLatestKey(tdir, 0, 0); + if (code) + com_err("bos", code, "(getting key from local KeyFile)"); else { if (aencrypt) - code = afsconf_ClientAuthSecure (tdir, &sc[2], &scIndex); + code = afsconf_ClientAuthSecure(tdir, &sc[2], &scIndex); else - code = afsconf_ClientAuth (tdir, &sc[2], &scIndex); - if (code) com_err ("bos", code, "(calling ClientAuth)"); + code = afsconf_ClientAuth(tdir, &sc[2], &scIndex); + if (code) + com_err("bos", code, "(calling ClientAuth)"); else if (scIndex != 2) /* this shouldn't happen */ sc[scIndex] = sc[2]; } - } else { /* not -localauth, check for tickets */ + } else { /* not -localauth, check for tickets */ code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL); if (code == 0) { /* have tickets, will travel */ - if (ttoken.kvno >= 0 && ttoken.kvno <= 255) ; + if (ttoken.kvno >= 0 && ttoken.kvno <= 255); else { - fprintf (stderr, - "bos: funny kvno (%d) in ticket, proceeding\n", - ttoken.kvno); + fprintf(stderr, + "bos: funny kvno (%d) in ticket, proceeding\n", + ttoken.kvno); } /* kerberos tix */ - if (aencrypt) encryptLevel = rxkad_crypt; - else encryptLevel = rxkad_clear; + if (aencrypt) + encryptLevel = rxkad_crypt; + else + encryptLevel = rxkad_clear; sc[2] = (struct rx_securityClass *) - rxkad_NewClientSecurityObject - (encryptLevel, &ttoken.sessionKey, - ttoken.kvno, ttoken.ticketLen, ttoken.ticket); + rxkad_NewClientSecurityObject(encryptLevel, + &ttoken.sessionKey, + ttoken.kvno, + ttoken.ticketLen, + ttoken.ticket); scIndex = 2; - } else com_err ("bos", code, "(getting tickets)"); + } else + com_err("bos", code, "(getting tickets)"); } if ((scIndex == 0) || (sc[scIndex] == 0)) { - fprintf (stderr, "bos: running unauthenticated\n"); + fprintf(stderr, "bos: running unauthenticated\n"); scIndex = 0; } } - tconn = rx_NewConnection (addr, htons(AFSCONF_NANNYPORT), 1, - sc[scIndex], scIndex); + tconn = + rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc[scIndex], + scIndex); if (!tconn) { - fprintf (stderr, "bos: could not create rx connection\n"); + fprintf(stderr, "bos: could not create rx connection\n"); exit(1); } - rxs_Release (sc[scIndex]); + rxs_Release(sc[scIndex]); return tconn; } -static SetAuth(as) -struct cmd_syndesc *as; { +static +SetAuth(as) + struct cmd_syndesc *as; +{ register afs_int32 code; register struct rx_connection *tconn; afs_int32 flag; register char *tp; - + tconn = GetConn(as, 0); tp = as->parms[1].items->data; - if (strcmp(tp, "on")==0) flag = 0; /* auth req.: noauthflag is false */ - else if (strcmp(tp, "off") == 0) flag = 1; + if (strcmp(tp, "on") == 0) + flag = 0; /* auth req.: noauthflag is false */ + else if (strcmp(tp, "off") == 0) + flag = 1; else { - printf("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n", tp); + printf + ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n", + tp); return 1; } code = BOZO_SetNoAuthFlag(tconn, flag); - if (code) com_err ("bos", code, "(failed to set authentication flag)"); + if (code) + com_err("bos", code, "(failed to set authentication flag)"); return 0; } /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct * /usr/afs/bin/bar */ -static ComputeDestDir(aname, adir, aresult, alen) -char *aname, *adir, *aresult; -afs_int32 alen; { +static +ComputeDestDir(aname, adir, aresult, alen) + char *aname, *adir, *aresult; + afs_int32 alen; +{ register char *tp; strcpy(aresult, adir); @@ -294,8 +325,7 @@ afs_int32 alen; { /* no '/' in name */ strcat(aresult, "/"); strcat(aresult, aname); - } - else { + } else { /* tp points at the / character */ strcat(aresult, tp); } @@ -303,53 +333,69 @@ afs_int32 alen; { } /* copy data from fd afd to rx call acall */ -static CopyBytes(afd, acall) -int afd; -register struct rx_call *acall; { +static +CopyBytes(afd, acall) + int afd; + register struct rx_call *acall; +{ register afs_int32 code; register afs_int32 len; char tbuffer[256]; - while(1) { + while (1) { len = read(afd, tbuffer, sizeof(tbuffer)); - if (len < 0) return errno; - if (len == 0) return 0; /* all done */ + if (len < 0) + return errno; + if (len == 0) + return 0; /* all done */ code = rx_Write(acall, tbuffer, len); - if (code != len) return -1; + if (code != len) + return -1; } } -static Prune(as) -register struct cmd_syndesc *as; { +static +Prune(as) + register struct cmd_syndesc *as; +{ register afs_int32 code; register struct rx_connection *tconn; register afs_int32 flags; - + tconn = GetConn(as, 0); flags = 0; - if (as->parms[1].items) flags |= BOZO_PRUNEBAK; - if (as->parms[2].items) flags |= BOZO_PRUNEOLD; - if (as->parms[3].items) flags |= BOZO_PRUNECORE; - if (as->parms[4].items) flags |= 0xff; + if (as->parms[1].items) + flags |= BOZO_PRUNEBAK; + if (as->parms[2].items) + flags |= BOZO_PRUNEOLD; + if (as->parms[3].items) + flags |= BOZO_PRUNECORE; + if (as->parms[4].items) + flags |= 0xff; code = BOZO_Prune(tconn, flags); - if (code) com_err ("bos", code, "(failed to prune server files)"); + if (code) + com_err("bos", code, "(failed to prune server files)"); return code; } -static Exec(as) -register struct cmd_syndesc *as; { +static +Exec(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; tconn = GetConn(as, 0); code = BOZO_Exec(tconn, as->parms[1].items->data); - if (code) printf("bos: failed to execute command (%s)\n", - em(code)); + if (code) + printf("bos: failed to execute command (%s)\n", em(code)); return code; } -static GetDate(as) -register struct cmd_syndesc *as; { +static +GetDate(as) + register struct cmd_syndesc *as; +{ register afs_int32 code; char tbuffer[256]; char destDir[256]; @@ -364,10 +410,12 @@ register struct cmd_syndesc *as; { } /* compute dest dir or file; default MUST be canonical form of dir path */ - if (as->parms[2].items) strcpy(destDir, as->parms[2].items->data); - else strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH); + if (as->parms[2].items) + strcpy(destDir, as->parms[2].items->data); + else + strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { /* check date for each file */ ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer)); code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime); @@ -375,23 +423,30 @@ register struct cmd_syndesc *as; { printf("bos: failed to check date on %s (%s)\n", ti->data, em(code)); return 1; - } - else { + } else { printf("File %s ", tbuffer); - if (time == 0) printf("does not exist, "); - else printf("dated %s, ", DateOf(time)); - if (bakTime == 0) printf("no .BAK file, "); - else printf(".BAK file dated %s, ", DateOf(bakTime)); - if (oldTime == 0) printf("no .OLD file."); - else printf(".OLD file dated %s.", DateOf(oldTime)); + if (time == 0) + printf("does not exist, "); + else + printf("dated %s, ", DateOf(time)); + if (bakTime == 0) + printf("no .BAK file, "); + else + printf(".BAK file dated %s, ", DateOf(bakTime)); + if (oldTime == 0) + printf("no .OLD file."); + else + printf(".OLD file dated %s.", DateOf(oldTime)); printf("\n"); } } return 0; } -static UnInstall(as) -register struct cmd_syndesc *as; { +static +UnInstall(as) + register struct cmd_syndesc *as; +{ register afs_int32 code; char tbuffer[256]; char destDir[256]; @@ -405,26 +460,29 @@ register struct cmd_syndesc *as; { } /* compute dest dir or file; default MUST be canonical form of dir path */ - if (as->parms[2].items) strcpy(destDir, as->parms[2].items->data); - else strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH); + if (as->parms[2].items) + strcpy(destDir, as->parms[2].items->data); + else + strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { /* uninstall each file */ ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer)); code = BOZO_UnInstall(tconn, tbuffer); if (code) { - printf("bos: failed to uninstall %s (%s)\n", ti->data, - em(code)); + printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code)); return 1; - } - else printf("bos: uninstalled file %s\n", ti->data); + } else + printf("bos: uninstalled file %s\n", ti->data); } return 0; } -static afs_int32 GetServerGoal(aconn, aname) -char *aname; -struct rx_connection *aconn; { +static afs_int32 +GetServerGoal(aconn, aname) + char *aname; + struct rx_connection *aconn; +{ char buffer[500]; char *tp; register afs_int32 code; @@ -433,10 +491,10 @@ struct rx_connection *aconn; { tp = buffer; code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus); if (code) { - printf("bos: failed to get instance info for '%s' (%s)\n", - aname, em(code)); + printf("bos: failed to get instance info for '%s' (%s)\n", aname, + em(code)); /* if we can't get the answer, assume its running */ - return BSTAT_NORMAL; + return BSTAT_NORMAL; } if (istatus.goal == 0) return BSTAT_SHUTDOWN; @@ -444,8 +502,10 @@ struct rx_connection *aconn; { return BSTAT_NORMAL; } -static Install(as) -struct cmd_syndesc *as; { +static +Install(as) + struct cmd_syndesc *as; +{ struct rx_connection *tconn; register afs_int32 code; register struct cmd_item *ti; @@ -462,10 +522,12 @@ struct cmd_syndesc *as; { } /* compute dest dir or file; default MUST be canonical form of dir path */ - if (as->parms[2].items) strcpy(destDir, as->parms[2].items->data); - else strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH); + if (as->parms[2].items) + strcpy(destDir, as->parms[2].items->data); + else + strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { /* install each file */ fd = open(ti->data, O_RDONLY); if (fd < 0) { @@ -482,8 +544,9 @@ struct cmd_syndesc *as; { /* compute destination dir */ ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer)); tcall = rx_NewCall(tconn); - code = StartBOZO_Install(tcall, tbuffer, tstat.st_size, (afs_int32)tstat.st_mode, - tstat.st_mtime); + code = + StartBOZO_Install(tcall, tbuffer, tstat.st_size, + (afs_int32) tstat.st_mode, tstat.st_mtime); if (code == 0) { code = CopyBytes(fd, tcall); } @@ -491,29 +554,31 @@ struct cmd_syndesc *as; { if (code) { printf("bos: failed to install %s (%s)\n", ti->data, em(code)); return 1; - } - else printf("bos: installed file %s\n", ti->data); + } else + printf("bos: installed file %s\n", ti->data); } return 0; } -static Shutdown(as) -struct cmd_syndesc *as; { +static +Shutdown(as) + struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; register struct cmd_item *ti; - + tconn = GetConn(as, 0); if (as->parms[1].items == 0) { code = BOZO_ShutdownAll(tconn); - if (code) printf("bos: failed to shutdown servers (%s)\n", em(code)); - } - else { - for(ti = as->parms[1].items; ti; ti=ti->next) { + if (code) + printf("bos: failed to shutdown servers (%s)\n", em(code)); + } else { + for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN); if (code) - printf("bos: failed to shutdown instance %s (%s)\n", - ti->data, em(code)); + printf("bos: failed to shutdown instance %s (%s)\n", ti->data, + em(code)); } } if (as->parms[8].items) { @@ -525,9 +590,11 @@ struct cmd_syndesc *as; { return 0; } -static BlockScannerCmd(as, arock) -struct cmd_syndesc *as; -char *arock; { +static +BlockScannerCmd(as, arock) + struct cmd_syndesc *as; + char *arock; +{ register afs_int32 code; struct rx_connection *tconn; char BlockCommand[] = "/usr/afs/bin/scanner -block"; @@ -535,14 +602,17 @@ char *arock; { tconn = GetConn(as, 0); code = BOZO_Exec(tconn, BlockCommand); if (code) - printf("bos: failed to block scanner from making migration requests (%s)\n", - em(code)); + printf + ("bos: failed to block scanner from making migration requests (%s)\n", + em(code)); return 0; } -static UnBlockScannerCmd(as, arock) -struct cmd_syndesc *as; -char *arock; { +static +UnBlockScannerCmd(as, arock) + struct cmd_syndesc *as; + char *arock; +{ register afs_int32 code; struct rx_connection *tconn; char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock"; @@ -550,14 +620,17 @@ char *arock; { tconn = GetConn(as, 0); code = BOZO_Exec(tconn, UnBlockCommand); if (code) - printf("bos: failed to allow scanner daemon to make migration requests again (%s)\n", - em(code)); + printf + ("bos: failed to allow scanner daemon to make migration requests again (%s)\n", + em(code)); return 0; -} +} -static GetRestartCmd(as, arock) -struct cmd_syndesc *as; -char *arock; { +static +GetRestartCmd(as, arock) + struct cmd_syndesc *as; + char *arock; +{ register afs_int32 code; struct ktime generalTime, newBinaryTime; char messageBuffer[256]; @@ -569,12 +642,14 @@ char *arock; { code = BOZO_GetRestartTime(tconn, 1, &generalTime); if (code) { - printf("bos: failed to retrieve restart information (%s)\n", em(code)); + printf("bos: failed to retrieve restart information (%s)\n", + em(code)); return code; } code = BOZO_GetRestartTime(tconn, 2, &newBinaryTime); if (code) { - printf("bos: failed to retrieve restart information (%s)\n", em(code)); + printf("bos: failed to retrieve restart information (%s)\n", + em(code)); return code; } @@ -596,9 +671,11 @@ char *arock; { return 0; } -static SetRestartCmd(as, arock) -struct cmd_syndesc *as; -char *arock; { +static +SetRestartCmd(as, arock) + struct cmd_syndesc *as; + char *arock; +{ afs_int32 count; register afs_int32 code; struct ktime restartTime; @@ -607,13 +684,20 @@ char *arock; { count = 0; tconn = GetConn(as, 0); - if (as->parms[2].items) {count++; type = 1;} - if (as->parms[3].items) {count++; type = 2;} + if (as->parms[2].items) { + count++; + type = 1; + } + if (as->parms[3].items) { + count++; + type = 2; + } if (count > 1) { printf("bos: can't specify more than one restart time at a time\n"); return -1; } - if (count == 0) type = 1; /* by default set general restart time */ + if (count == 0) + type = 1; /* by default set general restart time */ if (code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime)) { printf("bos: failed to parse '%s' as periodic restart time(%s)\n", @@ -629,42 +713,46 @@ char *arock; { return 0; } -static Startup(as) -struct cmd_syndesc *as; { +static +Startup(as) + struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; register struct cmd_item *ti; - + tconn = GetConn(as, 0); if (as->parms[1].items == 0) { code = BOZO_StartupAll(tconn); if (code) printf("bos: failed to startup servers (%s)\n", em(code)); - } - else { - for(ti = as->parms[1].items; ti; ti=ti->next) { + } else { + for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL); if (code) - printf("bos: failed to start instance %s (%s)\n", - ti->data, em(code)); + printf("bos: failed to start instance %s (%s)\n", ti->data, + em(code)); } } return 0; } -static Restart(as) -struct cmd_syndesc *as; { +static +Restart(as) + struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; register struct cmd_item *ti; - + tconn = GetConn(as, 0); if (as->parms[2].items) { /* this is really a rebozo command */ if (as->parms[1].items) { /* specified specific things to restart, can't do this at the same - * time */ - printf("bos: can't specify both '-bos' and specific servers to restart.\n"); + * time */ + printf + ("bos: can't specify both '-bos' and specific servers to restart.\n"); return 1; } /* otherwise do a rebozo */ @@ -674,81 +762,91 @@ struct cmd_syndesc *as; { return code; } if (as->parms[1].items == 0) { - if (as->parms[3].items) { /* '-all' */ + if (as->parms[3].items) { /* '-all' */ code = BOZO_RestartAll(tconn); - if (code) printf("bos: failed to restart servers (%s)\n", em(code)); + if (code) + printf("bos: failed to restart servers (%s)\n", em(code)); } else printf("bos: To restart all processes please specify '-all'\n"); - } - else { + } else { if (as->parms[3].items) { printf("bos: Can't use '-all' along with individual instances\n"); } else { - for(ti = as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_Restart(tconn, ti->data); if (code) - printf("bos: failed to restart instance %s (%s)\n", ti->data, - em(code)); + printf("bos: failed to restart instance %s (%s)\n", + ti->data, em(code)); } } } return 0; } -static SetCellName(as) -struct cmd_syndesc *as; { +static +SetCellName(as) + struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; - + tconn = GetConn(as, 0); code = BOZO_SetCellName(tconn, as->parms[1].items->data); - if (code) printf("bos: failed to set cell (%s)\n", em(code)); + if (code) + printf("bos: failed to set cell (%s)\n", em(code)); return 0; } -static AddHost(as) -register struct cmd_syndesc *as; { +static +AddHost(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; register struct cmd_item *ti; char name[MAXHOSTCHARS]; - + tconn = GetConn(as, 0); - for(ti = as->parms[1].items; ti; ti=ti->next) { - if (as->parms[2].items) { - if (strlen(ti->data) > MAXHOSTCHARS - 3) { - fprintf(stderr, "bos: host name too long\n"); - return E2BIG; - } - name[0] = '['; - strcpy(&name[1],ti->data); - strcat((char *)&name, "]"); - code = BOZO_AddCellHost(tconn, name); - } else - code = BOZO_AddCellHost(tconn, ti->data); + for (ti = as->parms[1].items; ti; ti = ti->next) { + if (as->parms[2].items) { + if (strlen(ti->data) > MAXHOSTCHARS - 3) { + fprintf(stderr, "bos: host name too long\n"); + return E2BIG; + } + name[0] = '['; + strcpy(&name[1], ti->data); + strcat((char *)&name, "]"); + code = BOZO_AddCellHost(tconn, name); + } else + code = BOZO_AddCellHost(tconn, ti->data); if (code) printf("bos: failed to add host %s (%s)\n", ti->data, em(code)); } return 0; } -static RemoveHost(as) -register struct cmd_syndesc *as; { +static +RemoveHost(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; register struct cmd_item *ti; - + tconn = GetConn(as, 0); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_DeleteCellHost(tconn, ti->data); if (code) - printf("bos: failed to delete host %s (%s)\n", ti->data, em(code)); + printf("bos: failed to delete host %s (%s)\n", ti->data, + em(code)); } return 0; } -static ListHosts(as) -register struct cmd_syndesc *as; { +static +ListHosts(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; char tbuffer[256]; @@ -763,20 +861,23 @@ register struct cmd_syndesc *as; { exit(1); } printf("Cell name is %s\n", tbuffer); - for(i=0;;i++) { + for (i = 0;; i++) { code = BOZO_GetCellHost(tconn, i, &tp); - if (code == BZDOM) break; + if (code == BZDOM) + break; if (code != 0) { printf("bos: failed to get cell host %d (%s)\n", i, em(code)); exit(1); } - printf(" Host %d is %s\n", i+1, tbuffer); + printf(" Host %d is %s\n", i + 1, tbuffer); } return 0; } -static AddKey(as) -register struct cmd_syndesc *as; { +static +AddKey(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; struct ktc_encryptionKey tkey; @@ -784,34 +885,31 @@ register struct cmd_syndesc *as; { char *tcell; char cellBuffer[256]; char buf[BUFSIZ], ver[BUFSIZ]; - + tconn = GetConn(as, 1); memset(&tkey, 0, sizeof(struct ktc_encryptionKey)); - if(as->parms[1].items) - strcpy(buf,as->parms[1].items->data); - else - { - /* prompt for key */ - code=des_read_pw_string(buf,sizeof(buf),"input key: ",0); - if(code || strlen(buf)==0) - { - fprintf(stderr,"Bad key: \n"); - exit(1); - } - code=des_read_pw_string(ver,sizeof(ver),"Retype input key: ",0); - if(code || strlen(ver)==0) - { - fprintf(stderr,"Bad key: \n"); - exit(1); - } - if (strcmp (ver, buf) != 0) { - fprintf (stderr, "\nInput key mismatch\n"); - exit(1); - } - + if (as->parms[1].items) + strcpy(buf, as->parms[1].items->data); + else { + /* prompt for key */ + code = des_read_pw_string(buf, sizeof(buf), "input key: ", 0); + if (code || strlen(buf) == 0) { + fprintf(stderr, "Bad key: \n"); + exit(1); + } + code = des_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0); + if (code || strlen(ver) == 0) { + fprintf(stderr, "Bad key: \n"); + exit(1); + } + if (strcmp(ver, buf) != 0) { + fprintf(stderr, "\nInput key mismatch\n"); + exit(1); } + } + temp = atoi(as->parms[2].items->data); if (temp == 999) { /* bcrypt key */ @@ -819,24 +917,23 @@ register struct cmd_syndesc *as; { strcpy((char *)&tkey, as->parms[1].items->data); */ strcpy((char *)&tkey, buf); - } - else { /* kerberos key */ + } else { /* kerberos key */ if (as->parms[ADDPARMOFFSET].items) { strcpy(cellBuffer, as->parms[ADDPARMOFFSET].items->data); /* string to key needs upper-case cell names */ /* I don't believe this is true. The string to key function - * actually expands the cell name, then LOWER-CASES it. Perhaps it - * didn't use to??? */ + * actually expands the cell name, then LOWER-CASES it. Perhaps it + * didn't use to??? */ ucstring(cellBuffer, cellBuffer, strlen(cellBuffer)); tcell = cellBuffer; - } - else tcell = NULL; /* no cell specified, use current */ + } else + tcell = NULL; /* no cell specified, use current */ /* ka_StringToKey(as->parms[1].items->data, tcell, &tkey); */ - ka_StringToKey(buf,tcell,&tkey); + ka_StringToKey(buf, tcell, &tkey); } tconn = GetConn(as, 1); code = BOZO_AddKey(tconn, temp, &tkey); @@ -847,15 +944,17 @@ register struct cmd_syndesc *as; { return 0; } -static RemoveKey(as) -register struct cmd_syndesc *as; { +static +RemoveKey(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; afs_int32 temp; register struct cmd_item *ti; - + tconn = GetConn(as, 0); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { temp = atoi(ti->data); code = BOZO_DeleteKey(tconn, temp); if (code) { @@ -866,8 +965,9 @@ register struct cmd_syndesc *as; { return 0; } -static ListKeys(as) - IN register struct cmd_syndesc *as; +static +ListKeys(as) + IN register struct cmd_syndesc *as; { register struct rx_connection *tconn; register afs_int32 code; @@ -876,23 +976,24 @@ static ListKeys(as) struct bozo_keyInfo keyInfo; int everWorked; register afs_int32 i; - + tconn = GetConn(as, 1); everWorked = 0; - for(i=0;;i++) { + for (i = 0;; i++) { code = BOZO_ListKeys(tconn, i, &kvno, &tkey, &keyInfo); - if (code) break; + if (code) + break; everWorked = 1; /* first check if key is returned */ - if ((!ka_KeyIsZero (&tkey, sizeof(tkey))) && (as->parms[1].items)) { - printf ("key %d is '", kvno); - ka_PrintBytes (&tkey, sizeof(tkey)); - printf ("'\n"); + if ((!ka_KeyIsZero(&tkey, sizeof(tkey))) && (as->parms[1].items)) { + printf("key %d is '", kvno); + ka_PrintBytes(&tkey, sizeof(tkey)); + printf("'\n"); } else { - if (keyInfo.keyCheckSum == 0) /* shouldn't happen */ - printf ("key version is %d\n", kvno); + if (keyInfo.keyCheckSum == 0) /* shouldn't happen */ + printf("key version is %d\n", kvno); else - printf ("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum); + printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum); } } if (everWorked) { @@ -905,8 +1006,10 @@ static ListKeys(as) return 0; } -static AddSUser(as) -register struct cmd_syndesc *as; { +static +AddSUser(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; int failed; @@ -914,7 +1017,7 @@ register struct cmd_syndesc *as; { failed = 0; tconn = GetConn(as, 0); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_AddSUser(tconn, ti->data); if (code) { printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code)); @@ -924,8 +1027,10 @@ register struct cmd_syndesc *as; { return failed; } -static RemoveSUser(as) -register struct cmd_syndesc *as; { +static +RemoveSUser(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register struct cmd_item *ti; register afs_int32 code; @@ -933,7 +1038,7 @@ register struct cmd_syndesc *as; { failed = 0; tconn = GetConn(as, 0); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_DeleteSUser(tconn, ti->data); if (code) { printf("bos: failed to delete user '%s', ", ti->data); @@ -947,86 +1052,97 @@ register struct cmd_syndesc *as; { return failed; } -#define NPERLINE 10 /* dudes to print per line */ -static ListSUsers(as) -register struct cmd_syndesc *as; { +#define NPERLINE 10 /* dudes to print per line */ +static +ListSUsers(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register int i; register afs_int32 code; char tbuffer[256]; char *tp; int lastNL, printGreeting; - + tconn = GetConn(as, 0); lastNL = 0; printGreeting = 1; - for(i=0;;i++) { + for (i = 0;; i++) { tp = tbuffer; code = BOZO_ListSUsers(tconn, i, &tp); - if (code) break; + if (code) + break; if (printGreeting) { printGreeting = 0; /* delay until after first call succeeds */ printf("SUsers are: "); } printf("%s ", tbuffer); - if ((i % NPERLINE) == NPERLINE-1) { + if ((i % NPERLINE) == NPERLINE - 1) { printf("\n"); lastNL = 1; - } - else lastNL = 0; + } else + lastNL = 0; } if (code != 1) { /* a real error code, instead of scanned past end */ printf("bos: failed to retrieve super-user list (%s)\n", em(code)); return code; } - if (lastNL == 0) printf("\n"); + if (lastNL == 0) + printf("\n"); return 0; } -static StatServer(as) -register struct cmd_syndesc *as; { +static +StatServer(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; register int i; char ibuffer[BOZO_BSSIZE]; char *tp; int int32p; - + /* int32p==1 is obsolete, smaller, printout */ - int32p = (as->parms[2].items != 0? 2 : 0); + int32p = (as->parms[2].items != 0 ? 2 : 0); /* no parms does something pretty different */ - if (as->parms[1].items) return IStatServer(as, int32p); + if (as->parms[1].items) + return IStatServer(as, int32p); tconn = GetConn(as, 0); - for(i=0;;i++) { + for (i = 0;; i++) { /* for each instance */ tp = ibuffer; code = BOZO_EnumerateInstance(tconn, i, &tp); - if (code == BZDOM) break; + if (code == BZDOM) + break; if (code) { printf("bos: failed to contact host's bosserver (%s).\n", em(code)); break; } - DoStat(ibuffer, tconn, int32p, (i==0)); /* print status line */ + DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */ } return 0; } -static CreateServer(as) -register struct cmd_syndesc *as; { +static +CreateServer(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; char *parms[6]; register struct cmd_item *ti; register int i; - char *type, *name, *notifier=NONOTIFIER; + char *type, *name, *notifier = NONOTIFIER; tconn = GetConn(as, 0); - for(i=0;i<6;i++) parms[i] = ""; - for(i=0,ti=as->parms[3].items; (ti && i<6); ti=ti->next,i++) { + for (i = 0; i < 6; i++) + parms[i] = ""; + for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) { parms[i] = ti->data; } name = as->parms[1].items->data; @@ -1034,62 +1150,70 @@ register struct cmd_syndesc *as; { if (ti = as->parms[4].items) { notifier = ti->data; } - code = BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2], - parms[3], parms[4], notifier); + code = + BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2], + parms[3], parms[4], notifier); if (code) { - printf("bos: failed to create new server instance %s of type '%s' (%s)\n", - name, type, em(code)); + printf + ("bos: failed to create new server instance %s of type '%s' (%s)\n", + name, type, em(code)); } return code; } -static DeleteServer(as) -register struct cmd_syndesc *as; { +static +DeleteServer(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; register struct cmd_item *ti; code = 0; tconn = GetConn(as, 0); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_DeleteBnode(tconn, ti->data); if (code) { if (code == BZBUSY) printf("bos: can't delete running instance '%s'\n", ti->data); else - printf("bos: failed to delete instance '%s' (%s)\n", - ti->data, em(code)); + printf("bos: failed to delete instance '%s' (%s)\n", ti->data, + em(code)); } } return code; } -static StartServer(as) -register struct cmd_syndesc *as; { +static +StartServer(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; register struct cmd_item *ti; code = 0; tconn = GetConn(as, 0); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL); if (code) - printf("bos: failed to start instance '%s' (%s)\n", - ti->data, em(code)); + printf("bos: failed to start instance '%s' (%s)\n", ti->data, + em(code)); } return code; } -static StopServer(as) -register struct cmd_syndesc *as; { +static +StopServer(as) + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code; register struct cmd_item *ti; code = 0; tconn = GetConn(as, 0); - for(ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN); if (code) printf("bos: failed to change stop instance '%s' (%s)\n", @@ -1106,15 +1230,17 @@ register struct cmd_syndesc *as; { #define PARMBUFFERSSIZE 32 -static DoSalvage(aconn, aparm1, aparm2, aoutName, showlog,parallel,atmpDir,orphans) -struct rx_connection *aconn; -char *aoutName; -char *aparm1; -char *aparm2; -afs_int32 showlog; -char *parallel; -char *atmpDir; -char *orphans; +static +DoSalvage(aconn, aparm1, aparm2, aoutName, showlog, parallel, atmpDir, + orphans) + struct rx_connection *aconn; + char *aoutName; + char *aparm1; + char *aparm2; + afs_int32 showlog; + char *parallel; + char *atmpDir; + char *orphans; { register afs_int32 code; char *parms[6]; @@ -1125,13 +1251,13 @@ char *orphans; char *tp; FILE *outFile; int closeIt; - char partName[20]; /* canonical name for partition */ + char partName[20]; /* canonical name for partition */ char pbuffer[PARMBUFFERSSIZE]; afs_int32 partNumber; char *notifier = NONOTIFIER; /* if a partition was specified, canonicalize the name, since - the salvager has a stupid partition ID parser */ + * the salvager has a stupid partition ID parser */ if (aparm1) { partNumber = volutil_GetPartitionID(aparm1); if (partNumber < 0) { @@ -1144,8 +1270,8 @@ char *orphans; return EINVAL; } strcpy(partName, tp); - } - else partName[0] = 0; + } else + partName[0] = 0; /* open the file name */ if (aoutName) { @@ -1155,40 +1281,42 @@ char *orphans; aoutName); return ENOENT; } - closeIt = 1; /* close this file later */ - } - else { + closeIt = 1; /* close this file later */ + } else { outFile = stdout; - closeIt = 0; /* don't close this file later */ + closeIt = 0; /* don't close this file later */ } - for(code=2;code<6;code++) parms[code] = ""; - if (!aparm2) aparm2 = ""; + for (code = 2; code < 6; code++) + parms[code] = ""; + if (!aparm2) + aparm2 = ""; /* MUST pass canonical (wire-format) salvager path to bosserver */ strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE); if (*aparm2 != 0) { - if ( (strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) + 1) > BOZO_BSSIZE ) { - printf("bos: command line too big\n"); - return(E2BIG); + if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) + + 1) > BOZO_BSSIZE) { + printf("bos: command line too big\n"); + return (E2BIG); } strcat(tbuffer, " "); strcat(tbuffer, partName); strcat(tbuffer, " "); strcat(tbuffer, aparm2); } else { - if ( (strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE ) { - printf("bos: command line too big\n"); - return(E2BIG); + if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) { + printf("bos: command line too big\n"); + return (E2BIG); } - strcat (tbuffer, " -f "); - strcat (tbuffer, partName); + strcat(tbuffer, " -f "); + strcat(tbuffer, partName); } /* add the parallel option if given */ if (parallel != NULL) { - if ( (strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE ) { - printf("bos: command line too big\n"); - return(E2BIG); + if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) { + printf("bos: command line too big\n"); + return (E2BIG); } strcat(tbuffer, " -parallel "); strcat(tbuffer, parallel); @@ -1196,9 +1324,9 @@ char *orphans; /* add the tmpdir option if given */ if (atmpDir != NULL) { - if ( (strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE ) { - printf("bos: command line too big\n"); - return(E2BIG); + if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) { + printf("bos: command line too big\n"); + return (E2BIG); } strcat(tbuffer, " -tmpdir "); strcat(tbuffer, atmpDir); @@ -1206,59 +1334,60 @@ char *orphans; /* add the orphans option if given */ if (orphans != NULL) { - if ( (strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE ) { - printf("bos: command line too big\n"); - return(E2BIG); + if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) { + printf("bos: command line too big\n"); + return (E2BIG); } strcat(tbuffer, " -orphans "); strcat(tbuffer, orphans); } if (mrafsParm.Optdebug) - strcat(tbuffer," -debug"); + strcat(tbuffer, " -debug"); if (mrafsParm.Optnowrite) - strcat(tbuffer," -nowrite"); + strcat(tbuffer, " -nowrite"); if (mrafsParm.Optforce) - strcat(tbuffer," -force"); + strcat(tbuffer, " -force"); if (mrafsParm.Optoktozap) - strcat(tbuffer," -oktozap"); + strcat(tbuffer, " -oktozap"); if (mrafsParm.Optrootfiles) - strcat(tbuffer," -rootfiles"); + strcat(tbuffer, " -rootfiles"); if (mrafsParm.Optsalvagedirs) - strcat(tbuffer," -salvagedirs"); + strcat(tbuffer, " -salvagedirs"); if (mrafsParm.Optblockreads) - strcat(tbuffer," -blockreads"); + strcat(tbuffer, " -blockreads"); if (mrafsParm.OptListResidencies) - strcat(tbuffer," -ListResidencies"); + strcat(tbuffer, " -ListResidencies"); if (mrafsParm.OptSalvageRemote) - strcat(tbuffer," -SalvageRemote"); + strcat(tbuffer, " -SalvageRemote"); if (mrafsParm.OptSalvageArchival) - strcat(tbuffer," -SalvageArchival"); + strcat(tbuffer, " -SalvageArchival"); if (mrafsParm.OptIgnoreCheck) - strcat(tbuffer," -IgnoreCheck"); + strcat(tbuffer, " -IgnoreCheck"); if (mrafsParm.OptForceOnLine) - strcat(tbuffer," -ForceOnLine"); + strcat(tbuffer, " -ForceOnLine"); if (mrafsParm.OptUseRootDirACL) - strcat(tbuffer," -UseRootDirACL"); + strcat(tbuffer, " -UseRootDirACL"); if (mrafsParm.OptTraceBadLinkCounts) - strcat(tbuffer," -TraceBadLinkCounts"); + strcat(tbuffer, " -TraceBadLinkCounts"); if (mrafsParm.OptDontAskFS) - strcat(tbuffer," -DontAskFS"); + strcat(tbuffer, " -DontAskFS"); if (mrafsParm.OptLogLevel) { - sprintf(pbuffer, " -LogLevel %ld", mrafsParm.OptLogLevel); - strcat(tbuffer, pbuffer); + sprintf(pbuffer, " -LogLevel %ld", mrafsParm.OptLogLevel); + strcat(tbuffer, pbuffer); } if (mrafsParm.OptRxDebug) - strcat(tbuffer," -rxdebug"); + strcat(tbuffer, " -rxdebug"); if (mrafsParm.OptResidencies) { - sprintf(pbuffer, " -Residencies %lu", mrafsParm.OptResidencies); - strcat(tbuffer, pbuffer); - } + sprintf(pbuffer, " -Residencies %lu", mrafsParm.OptResidencies); + strcat(tbuffer, pbuffer); + } parms[0] = tbuffer; - parms[1] = "now"; /* when to do it */ - code = BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1], - parms[2], parms[3], parms[4], notifier); + parms[1] = "now"; /* when to do it */ + code = + BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1], + parms[2], parms[3], parms[4], notifier); if (code) { printf("bos: failed to start 'salvager' (%s)\n", em(code)); goto done; @@ -1268,7 +1397,8 @@ char *orphans; IOMGR_Sleep(5); tp = tbuffer; code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus); - if (code) break; + if (code) + break; printf("bos: waiting for salvage to complete.\n"); } if (code != BZNOENT) { @@ -1283,29 +1413,35 @@ char *orphans; fprintf(outFile, "SalvageLog:\n"); tcall = rx_NewCall(aconn); /* MUST pass canonical (wire-format) salvager log path to bosserver */ - code = StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH); + code = + StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH); if (code) { rx_EndCall(tcall, code); goto done; } /* copy data */ - while(1) { + while (1) { code = rx_Read(tcall, &buffer, 1); - if (code != 1) break; + if (code != 1) + break; putc(buffer, outFile); - if (buffer == 0) break; /* the end delimeter */ + if (buffer == 0) + break; /* the end delimeter */ } code = rx_EndCall(tcall, 0); /* fall through into cleanup code */ } done: - if (closeIt && outFile) fclose(outFile); + if (closeIt && outFile) + fclose(outFile); return code; } -static GetLogCmd(as) -register struct cmd_syndesc *as; { +static +GetLogCmd(as) + register struct cmd_syndesc *as; +{ struct rx_connection *tconn; register struct rx_call *tcall; register afs_int32 code; @@ -1322,13 +1458,14 @@ register struct cmd_syndesc *as; { } /* copy data */ error = 0; - while(1) { + while (1) { code = rx_Read(tcall, &buffer, 1); if (code != 1) { error = EIO; break; } - if (buffer == 0) break; /* the end delimeter */ + if (buffer == 0) + break; /* the end delimeter */ putchar(buffer); } code = rx_EndCall(tcall, error); @@ -1340,8 +1477,10 @@ register struct cmd_syndesc *as; { return code; } -static SalvageCmd(as) -struct cmd_syndesc *as; { +static +SalvageCmd(as) + struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register afs_int32 code, rc, i; char *outName; @@ -1355,7 +1494,7 @@ struct cmd_syndesc *as; { char *tp; memset(&mrafsParm, 0, sizeof(mrafsParm)); - + /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */ tconn = GetConn(as, 0); @@ -1363,7 +1502,7 @@ struct cmd_syndesc *as; { /* XXX this should really be done some other way, potentially by RPC */ tp = &tname; if (code = BOZO_GetInstanceParm(tconn, "fs", 3, &tp) == 0) - mrafs = 1; + mrafs = 1; /* we can do a volume, a partition or the whole thing, but not mixtures * thereof */ @@ -1406,69 +1545,73 @@ struct cmd_syndesc *as; { printf("Can't specify -orphans for MR-AFS fileserver\n"); return EINVAL; } - orphans = as->parms[8].items->data; + orphans = as->parms[8].items->data; } - + if (mrafs) { - if (as->parms[MRAFS_OFFSET].items) - mrafsParm.Optdebug = 1; - if (as->parms[MRAFS_OFFSET + 1].items) - mrafsParm.Optnowrite = 1; - if (as->parms[MRAFS_OFFSET + 2].items) - mrafsParm.Optforce = 1; - if (as->parms[MRAFS_OFFSET + 3].items) - mrafsParm.Optoktozap = 1; - if (as->parms[MRAFS_OFFSET + 4].items) - mrafsParm.Optrootfiles = 1; - if (as->parms[MRAFS_OFFSET + 5].items) - mrafsParm.Optsalvagedirs = 1; - if (as->parms[MRAFS_OFFSET + 6].items) - mrafsParm.Optblockreads = 1; - if (as->parms[MRAFS_OFFSET + 7].items) - mrafsParm.OptListResidencies = 1; - if (as->parms[MRAFS_OFFSET + 8].items) - mrafsParm.OptSalvageRemote = 1; - if (as->parms[MRAFS_OFFSET + 9].items) - mrafsParm.OptSalvageArchival = 1; - if (as->parms[MRAFS_OFFSET + 10].items) - mrafsParm.OptIgnoreCheck = 1; - if (as->parms[MRAFS_OFFSET + 11].items) - mrafsParm.OptForceOnLine = 1; - if (as->parms[MRAFS_OFFSET + 12].items) - mrafsParm.OptUseRootDirACL = 1; - if (as->parms[MRAFS_OFFSET + 13].items) - mrafsParm.OptTraceBadLinkCounts = 1; - if (as->parms[MRAFS_OFFSET + 14].items) - mrafsParm.OptDontAskFS = 1; - if (as->parms[MRAFS_OFFSET + 15].items) - mrafsParm.OptLogLevel = atoi(as->parms[MRAFS_OFFSET + 15].items->data); - if (as->parms[MRAFS_OFFSET + 16].items) - mrafsParm.OptRxDebug = 1; - if (as->parms[MRAFS_OFFSET + 17].items) { - if (as->parms[MRAFS_OFFSET + 8].items || - as->parms[MRAFS_OFFSET + 9].items) { - printf("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n"); - return EINVAL; - } - code = util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data, - &mrafsParm.OptResidencies); - if (code) { - printf("bos: '%s' is not a valid residency mask.\n", - as->parms[MRAFS_OFFSET + 13].items->data); - return code; - } - } + if (as->parms[MRAFS_OFFSET].items) + mrafsParm.Optdebug = 1; + if (as->parms[MRAFS_OFFSET + 1].items) + mrafsParm.Optnowrite = 1; + if (as->parms[MRAFS_OFFSET + 2].items) + mrafsParm.Optforce = 1; + if (as->parms[MRAFS_OFFSET + 3].items) + mrafsParm.Optoktozap = 1; + if (as->parms[MRAFS_OFFSET + 4].items) + mrafsParm.Optrootfiles = 1; + if (as->parms[MRAFS_OFFSET + 5].items) + mrafsParm.Optsalvagedirs = 1; + if (as->parms[MRAFS_OFFSET + 6].items) + mrafsParm.Optblockreads = 1; + if (as->parms[MRAFS_OFFSET + 7].items) + mrafsParm.OptListResidencies = 1; + if (as->parms[MRAFS_OFFSET + 8].items) + mrafsParm.OptSalvageRemote = 1; + if (as->parms[MRAFS_OFFSET + 9].items) + mrafsParm.OptSalvageArchival = 1; + if (as->parms[MRAFS_OFFSET + 10].items) + mrafsParm.OptIgnoreCheck = 1; + if (as->parms[MRAFS_OFFSET + 11].items) + mrafsParm.OptForceOnLine = 1; + if (as->parms[MRAFS_OFFSET + 12].items) + mrafsParm.OptUseRootDirACL = 1; + if (as->parms[MRAFS_OFFSET + 13].items) + mrafsParm.OptTraceBadLinkCounts = 1; + if (as->parms[MRAFS_OFFSET + 14].items) + mrafsParm.OptDontAskFS = 1; + if (as->parms[MRAFS_OFFSET + 15].items) + mrafsParm.OptLogLevel = + atoi(as->parms[MRAFS_OFFSET + 15].items->data); + if (as->parms[MRAFS_OFFSET + 16].items) + mrafsParm.OptRxDebug = 1; + if (as->parms[MRAFS_OFFSET + 17].items) { + if (as->parms[MRAFS_OFFSET + 8].items + || as->parms[MRAFS_OFFSET + 9].items) { + printf + ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n"); + return EINVAL; + } + code = + util_GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data, + &mrafsParm.OptResidencies); + if (code) { + printf("bos: '%s' is not a valid residency mask.\n", + as->parms[MRAFS_OFFSET + 13].items->data); + return code; + } + } } else { - int stop = 0; + int stop = 0; - for (i = 9; i < ADDPARMOFFSET; i++) { - if (as->parms[i].items) { - printf(" %s only possible for MR-AFS fileserver.\n", - as->parms[i].name); - stop = 1; - } - } - if (stop) exit(1); + for (i = 9; i < ADDPARMOFFSET; i++) { + if (as->parms[i].items) { + printf(" %s only possible for MR-AFS fileserver.\n", + as->parms[i].name); + stop = 1; + } + } + if (stop) + exit(1); } if (as->parms[4].items) { @@ -1483,11 +1626,13 @@ struct cmd_syndesc *as; { } code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */ if (code) - printf("bos: failed to wait for file server shutdown, continuing.\n"); + printf + ("bos: failed to wait for file server shutdown, continuing.\n"); } /* now do the salvage operation */ printf("Starting salvage.\n"); - rc = DoSalvage(tconn, NULL, NULL, outName, showlog,parallel,tmpDir,orphans); + rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir, + orphans); if (curGoal == BSTAT_NORMAL) { printf("bos: restarting fs.\n"); code = BOZO_SetTStatus(tconn, "fs", BSTAT_NORMAL); @@ -1496,11 +1641,12 @@ struct cmd_syndesc *as; { return code; } } - if (rc) return rc; - } - else if (!as->parms[2].items) { + if (rc) + return rc; + } else if (!as->parms[2].items) { if (!as->parms[1].items) { - printf("bos: must specify -all switch to salvage all partitions.\n"); + printf + ("bos: must specify -all switch to salvage all partitions.\n"); return -1; } if (volutil_GetPartitionID(as->parms[1].items->data) < 0) { @@ -1522,12 +1668,13 @@ struct cmd_syndesc *as; { } code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */ if (code) - printf("bos: failed to wait for file server shutdown, continuing.\n"); + printf + ("bos: failed to wait for file server shutdown, continuing.\n"); } /* now do the salvage operation */ printf("Starting salvage.\n"); - rc = DoSalvage(tconn, as->parms[1].items->data, NULL, - outName, showlog,parallel,tmpDir,orphans); + rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName, + showlog, parallel, tmpDir, orphans); if (curGoal == BSTAT_NORMAL) { printf("bos: restarting fs.\n"); code = BOZO_SetTStatus(tconn, "fs", BSTAT_NORMAL); @@ -1536,36 +1683,40 @@ struct cmd_syndesc *as; { return code; } } - if (rc) return rc; - } - else { + if (rc) + return rc; + } else { /* salvage individual volume (don't shutdown fs first), just use - * single-shot cron bnode. Must leave server running when using this - * option, since salvager will ask file server for the volume */ + * single-shot cron bnode. Must leave server running when using this + * option, since salvager will ask file server for the volume */ char *tmpname; afs_int32 err; const char *confdir; int localauth; - if (as->parms[ADDPARMOFFSET].items) + if (as->parms[ADDPARMOFFSET].items) tmpname = as->parms[ADDPARMOFFSET].items->data; - else tmpname = NULL; + else + tmpname = NULL; localauth = (as->parms[ADDPARMOFFSET + 2].items != 0); - confdir = (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH); - code = vsu_ClientInit(/* noauth */ 1, confdir, tmpname, - /* server auth */ 0, &cstruct, (int (*)()) 0); + confdir = + (localauth ? AFSDIR_SERVER_ETC_DIRPATH : + AFSDIR_CLIENT_ETC_DIRPATH); + code = vsu_ClientInit( /* noauth */ 1, confdir, tmpname, + /* server auth */ 0, &cstruct, (int (*)())0); if (code == 0) { newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); if (newID == 0) { - printf("bos: can't interpret %s as volume name or ID\n", as->parms[2].items->data); + printf("bos: can't interpret %s as volume name or ID\n", + as->parms[2].items->data); return -1; } sprintf(tname, "%u", newID); - } - else { - printf("bos: can't initialize volume system client (code %d), trying anyway.\n", - as->parms[2].items->data, code); + } else { + printf + ("bos: can't initialize volume system client (code %d), trying anyway.\n", + as->parms[2].items->data, code); strncpy(tname, as->parms[2].items->data, sizeof(tname)); } if (volutil_GetPartitionID(as->parms[1].items->data) < 0) { @@ -1578,33 +1729,36 @@ struct cmd_syndesc *as; { } printf("Starting salvage.\n"); rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName, - showlog,parallel,tmpDir,orphans); - if (rc) - return rc; + showlog, parallel, tmpDir, orphans); + if (rc) + return rc; } return 0; } -static IStatServer(as, int32p) -int int32p; -register struct cmd_syndesc *as; { +static +IStatServer(as, int32p) + int int32p; + register struct cmd_syndesc *as; +{ register struct rx_connection *tconn; register struct cmd_item *ti; int firstTime = 1; tconn = GetConn(as, 0); - for (ti=as->parms[1].items; ti; ti=ti->next) { + for (ti = as->parms[1].items; ti; ti = ti->next) { DoStat(ti->data, tconn, int32p, firstTime); firstTime = 0; } return 0; } -static DoStat (aname, aconn, aint32p, firstTime) - IN char *aname; - IN register struct rx_connection *aconn; - IN int aint32p; - IN int firstTime; /* true iff first instance in cmd */ +static +DoStat(aname, aconn, aint32p, firstTime) + IN char *aname; + IN register struct rx_connection *aconn; + IN int aint32p; + IN int firstTime; /* true iff first instance in cmd */ { afs_int32 temp; char buffer[500]; @@ -1617,20 +1771,24 @@ static DoStat (aname, aconn, aint32p, firstTime) tp = buffer; code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus); if (code) { - printf("bos: failed to get instance info for '%s' (%s)\n", - aname, em(code)); + printf("bos: failed to get instance info for '%s' (%s)\n", aname, + em(code)); return -1; } if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS)) - printf ("Bosserver reports inappropriate access on server directories\n"); + printf + ("Bosserver reports inappropriate access on server directories\n"); printf("Instance %s, ", aname); - if (aint32p) printf("(type is %s) ", buffer); + if (aint32p) + printf("(type is %s) ", buffer); if (istatus.fileGoal == istatus.goal) { - if (!istatus.goal) printf("disabled, "); - } - else { - if (istatus.fileGoal) printf("temporarily disabled, "); - else printf("temporarily enabled, "); + if (!istatus.goal) + printf("disabled, "); + } else { + if (istatus.fileGoal) + printf("temporarily disabled, "); + else + printf("temporarily enabled, "); } if (istatus.flags & BOZO_ERRORSTOP) @@ -1641,21 +1799,26 @@ static DoStat (aname, aconn, aint32p, firstTime) tp = buffer; code = BOZO_GetStatus(aconn, aname, &temp, &tp); if (code) - printf("bos: failed to get status for instance '%s' (%s)\n", - aname, em(code)); + printf("bos: failed to get status for instance '%s' (%s)\n", aname, + em(code)); else { printf("currently ", aname); - if (temp == BSTAT_NORMAL) printf("running normally.\n"); - else if (temp == BSTAT_SHUTDOWN) printf("shutdown.\n"); - else if (temp == BSTAT_STARTINGUP) printf("starting up.\n"); - else if (temp == BSTAT_SHUTTINGDOWN) printf("shutting down.\n"); + if (temp == BSTAT_NORMAL) + printf("running normally.\n"); + else if (temp == BSTAT_SHUTDOWN) + printf("shutdown.\n"); + else if (temp == BSTAT_STARTINGUP) + printf("starting up.\n"); + else if (temp == BSTAT_SHUTTINGDOWN) + printf("shutting down.\n"); if (buffer[0] != 0) { printf(" Auxiliary status is: %s.\n", buffer); } } /* are we done yet? */ - if (!aint32p) return 0; + if (!aint32p) + return 0; if (istatus.procStartTime) printf(" Process last started at %s (%d proc starts)\n", @@ -1685,18 +1848,18 @@ static DoStat (aname, aconn, aint32p, firstTime) printf("due to shutdown request\n"); else printf("due to signal %d\n", istatus.errorSignal); - } - else + } else printf("by exiting with code %d\n", istatus.errorCode); } - + if (aint32p > 1) { /* try to display all the parms */ - for(i=0;;i++) { + for (i = 0;; i++) { tp = buffer; code = BOZO_GetInstanceParm(aconn, aname, i, &tp); - if (code) break; - printf(" Command %d is '%s'\n", i+1, buffer); + if (code) + break; + printf(" Command %d is '%s'\n", i + 1, buffer); } tp = buffer; code = BOZO_GetInstanceParm(aconn, aname, 999, &tp); @@ -1710,48 +1873,56 @@ static DoStat (aname, aconn, aint32p, firstTime) } #ifdef BOS_RESTRICTED_MODE -static GetRestrict(as) -struct cmd_syndesc *as; { +static +GetRestrict(as) + struct cmd_syndesc *as; +{ register struct rx_connection *tconn; afs_int32 code, val; - + tconn = GetConn(as, 0); code = BOZO_GetRestrictedMode(tconn, &val); - if (code) printf("bos: failed to get restricted mode (%s)\n", em(code)); - else printf("Restricted mode is %s\n", val ? "on" : "off"); - + if (code) + printf("bos: failed to get restricted mode (%s)\n", em(code)); + else + printf("Restricted mode is %s\n", val ? "on" : "off"); + return 0; } -static SetRestrict(as) -struct cmd_syndesc *as; { +static +SetRestrict(as) + struct cmd_syndesc *as; +{ register struct rx_connection *tconn; afs_int32 code, val; - + tconn = GetConn(as, 0); util_GetInt32(as->parms[1].items->data, &val); code = BOZO_SetRestrictedMode(tconn, val); - if (code) printf("bos: failed to set restricted mode (%s)\n", em(code)); + if (code) + printf("bos: failed to set restricted mode (%s)\n", em(code)); return 0; } #endif -static void add_std_args (ts) - register struct cmd_syndesc *ts; +static void +add_std_args(ts) + register struct cmd_syndesc *ts; { cmd_Seek(ts, ADDPARMOFFSET); /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name"); /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, - "don't authenticate"); - /* + 2 */ cmd_AddParm (ts, "-localauth", CMD_FLAG, CMD_OPTIONAL, - "create tickets from KeyFile"); + "don't authenticate"); + /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL, + "create tickets from KeyFile"); } - + #include "AFS_component_version_number.c" main(argc, argv) - int argc; - char **argv; + int argc; + char **argv; { register afs_int32 code; register struct cmd_syndesc *ts; @@ -1765,7 +1936,7 @@ main(argc, argv) * generated which, in many cases, isn't too useful. */ struct sigaction nsa; - + sigemptyset(&nsa.sa_mask); nsa.sa_handler = SIG_DFL; nsa.sa_flags = SA_FULLDUMP; @@ -1797,7 +1968,7 @@ main(argc, argv) ts = cmd_CreateSyntax("start", StartServer, 0, "start running a server"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("stop", StopServer, 0, "halt a server instance"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); @@ -1805,15 +1976,15 @@ main(argc, argv) cmd_Seek(ts, 8); cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL, "wait for process to stop"); - add_std_args (ts); - + add_std_args(ts); + ts = cmd_CreateSyntax("status", StatServer, 0, "show server instance status"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "server process name"); cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("shutdown", Shutdown, 0, "shutdown all processes"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); @@ -1821,19 +1992,20 @@ main(argc, argv) cmd_Seek(ts, 8); cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL, "wait for process to stop"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("startup", Startup, 0, "start all processes"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("restart", Restart, 0, "restart processes"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances"); - cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL, "restart bosserver"); + cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL, + "restart bosserver"); cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes"); - add_std_args (ts); + add_std_args(ts); #ifndef OPBOS @@ -1843,105 +2015,107 @@ main(argc, argv) cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name"); cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type"); cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines"); - cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL, "Notifier program"); - add_std_args (ts); + cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL, + "Notifier program"); + add_std_args(ts); ts = cmd_CreateSyntax("delete", DeleteServer, 0, "delete a server instance"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name"); - add_std_args (ts); - + add_std_args(ts); + ts = cmd_CreateSyntax("adduser", AddSUser, 0, "add users to super-user list"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("removeuser", RemoveSUser, 0, "remove users from super-user list"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("listusers", ListSUsers, 0, "list super-users"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("addkey", AddKey, 0, - "add keys to key dbase (kvno 999 is bcrypt)"); + "add keys to key dbase (kvno 999 is bcrypt)"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key"); cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("removekey", RemoveKey, 0, "remove keys from key dbase"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("listkeys", ListKeys, 0, "list keys"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); - cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL, "show the actual key rather than the checksum"); - add_std_args (ts); + cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL, + "show the actual key rather than the checksum"); + add_std_args(ts); ts = cmd_CreateSyntax("listhosts", ListHosts, 0, "get cell host list"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); - add_std_args (ts); + add_std_args(ts); cmd_CreateAlias(ts, "getcell"); ts = cmd_CreateSyntax("setcellname", SetCellName, 0, "set cell name"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("addhost", AddHost, 0, "add host to cell dbase"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name"); cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("removehost", RemoveHost, 0, "remove host from cell dbase"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("setauth", SetAuth, 0, "set authentication required flag"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); - cmd_AddParm(ts, "-authrequired", CMD_SINGLE, - 0, "on or off: authentication required for admin requests"); - add_std_args (ts); - + cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0, + "on or off: authentication required for admin requests"); + add_std_args(ts); + ts = cmd_CreateSyntax("install", Install, 0, "install program"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install"); cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("uninstall", UnInstall, 0, "uninstall program"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall"); cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("getlog", GetLogCmd, 0, "examine log file"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("getdate", GetDate, 0, "get dates for programs"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check"); cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("exec", Exec, 0, "execute shell command on server"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("prune", Prune, 0, "prune server files"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); @@ -1949,78 +2123,101 @@ main(argc, argv) cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files"); cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files"); cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files"); - add_std_args (ts); + add_std_args(ts); - ts = cmd_CreateSyntax("setrestart", SetRestartCmd, 0, "set restart times"); + ts = cmd_CreateSyntax("setrestart", SetRestartCmd, 0, + "set restart times"); cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name"); - cmd_AddParm(ts, "-time", CMD_SINGLE, - CMD_REQUIRED, "time to restart server"); - cmd_AddParm(ts, "-general", CMD_FLAG, - CMD_OPTIONAL, "set general restart time"); - cmd_AddParm(ts, "-newbinary", CMD_FLAG, - CMD_OPTIONAL, "set new binary restart time"); - add_std_args (ts); - - ts = cmd_CreateSyntax("getrestart", GetRestartCmd, 0, "get restart times"); + cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED, + "time to restart server"); + cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL, + "set general restart time"); + cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL, + "set new binary restart time"); + add_std_args(ts); + + ts = cmd_CreateSyntax("getrestart", GetRestartCmd, 0, + "get restart times"); cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("salvage", SalvageCmd, 0, "salvage partition or volumes"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); - cmd_AddParm(ts, "-partition", CMD_SINGLE, - CMD_OPTIONAL, "salvage partition"); - cmd_AddParm(ts, "-volume", CMD_SINGLE, - CMD_OPTIONAL, "salvage volume number or volume name"); - cmd_AddParm(ts, "-file", CMD_SINGLE, - CMD_OPTIONAL, "salvage log output file"); + cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, + "salvage partition"); + cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, + "salvage volume number or volume name"); + cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, + "salvage log output file"); cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server"); - cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL, "display salvage log"); - cmd_AddParm(ts, "-parallel",CMD_SINGLE, CMD_OPTIONAL, - "# of max parallel partition salvaging"); - cmd_AddParm(ts, "-tmpdir",CMD_SINGLE, CMD_OPTIONAL, + cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL, + "display salvage log"); + cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL, + "# of max parallel partition salvaging"); + cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL, "directory to place tmp files"); - cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL, + cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL, "ignore | remove | attach"); - cmd_AddParm(ts, "-debug", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Run in Debugging mode"); - cmd_AddParm(ts, "-nowrite", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Run readonly/test mode"); - cmd_AddParm(ts, "-force", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Force full salvaging"); - cmd_AddParm(ts, "-oktozap", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag"); - cmd_AddParm(ts, "-rootfiles", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Show files owned by root - debugging flag"); - cmd_AddParm(ts, "-salvagedirs", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Force rebuild/salvage of all directories"); - cmd_AddParm(ts, "-blockreads", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Read smaller blocks to handle IO/bad blocks"); - cmd_AddParm(ts, "-ListResidencies", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Just list affected file residencies - debugging flag"); - cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Salvage storage systems that are not directly attached"); - cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Salvage HSM storage systems"); - cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell."); - cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly."); - cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Use the root directory ACL for lost+found directory if it is created."); - cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Print out lines about volume reference count changes."); - cmd_AddParm(ts, "-DontAskFS", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS."); - cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL, "(MR-AFS) log level"); - cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL, "(MR-AFS) Write out rx debug information."); - cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL, "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival"); - add_std_args (ts); + cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Run in Debugging mode"); + cmd_AddParm(ts, "-nowrite", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Run readonly/test mode"); + cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Force full salvaging"); + cmd_AddParm(ts, "-oktozap", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag"); + cmd_AddParm(ts, "-rootfiles", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Show files owned by root - debugging flag"); + cmd_AddParm(ts, "-salvagedirs", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Force rebuild/salvage of all directories"); + cmd_AddParm(ts, "-blockreads", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Read smaller blocks to handle IO/bad blocks"); + cmd_AddParm(ts, "-ListResidencies", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Just list affected file residencies - debugging flag"); + cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Salvage storage systems that are not directly attached"); + cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Salvage HSM storage systems"); + cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell."); + cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly."); + cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Use the root directory ACL for lost+found directory if it is created."); + cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Print out lines about volume reference count changes."); + cmd_AddParm(ts, "-DontAskFS", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS."); + cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL, + "(MR-AFS) log level"); + cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL, + "(MR-AFS) Write out rx debug information."); + cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL, + "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival"); + add_std_args(ts); ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, 0, - "block scanner daemon from making migration requests"); + "block scanner daemon from making migration requests"); cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name"); - add_std_args (ts); + add_std_args(ts); ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, 0, - "allow scanner daemon to make migration requests again"); + "allow scanner daemon to make migration requests again"); cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name"); - add_std_args (ts); + add_std_args(ts); #ifdef BOS_RESTRICTED_MODE - ts = cmd_CreateSyntax("getrestricted", GetRestrict, 0, "get restrict mode"); + ts = cmd_CreateSyntax("getrestricted", GetRestrict, 0, + "get restrict mode"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); - add_std_args (ts); + add_std_args(ts); - ts = cmd_CreateSyntax("setrestricted", SetRestrict, 0, "set restrict mode"); + ts = cmd_CreateSyntax("setrestricted", SetRestrict, 0, + "set restrict mode"); cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name"); cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set"); - add_std_args (ts); + add_std_args(ts); #endif #endif diff --git a/src/bozo/bos_util.c b/src/bozo/bos_util.c index 190cd12bb..b6e992fe9 100644 --- a/src/bozo/bos_util.c +++ b/src/bozo/bos_util.c @@ -22,7 +22,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -42,7 +43,7 @@ RCSID("$Header$"); #include #include -int +int main(int argc, char **argv) { struct afsconf_dir *tdir; @@ -62,10 +63,11 @@ main(int argc, char **argv) tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIR); if (!tdir) { - printf("bos_util: can't initialize conf dir '%s'\n", AFSDIR_SERVER_ETC_DIR); + printf("bos_util: can't initialize conf dir '%s'\n", + AFSDIR_SERVER_ETC_DIR); exit(1); } - if (strcmp(argv[1], "add")==0) { + if (strcmp(argv[1], "add") == 0) { struct ktc_encryptionKey tkey; int kvno; char buf[BUFSIZ], ver[BUFSIZ]; @@ -79,28 +81,27 @@ main(int argc, char **argv) memset(&tkey, 0, sizeof(struct ktc_encryptionKey)); /* prompt for key */ - code=des_read_pw_string(buf,sizeof(buf),"input key: ",0); - if(code || strlen(buf)==0) { + code = des_read_pw_string(buf, sizeof(buf), "input key: ", 0); + if (code || strlen(buf) == 0) { printf("Bad key: \n"); exit(1); } - code=des_read_pw_string(ver,sizeof(ver),"Retype input key: ",0); - if(code || strlen(ver)==0) { + code = des_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0); + if (code || strlen(ver) == 0) { printf("Bad key: \n"); exit(1); } - if (strcmp (ver, buf) != 0) { - printf ("\nInput key mismatch\n"); + if (strcmp(ver, buf) != 0) { + printf("\nInput key mismatch\n"); exit(1); } - ka_StringToKey(buf,tcell,&tkey); + ka_StringToKey(buf, tcell, &tkey); code = afsconf_AddKey(tdir, kvno, &tkey, 0); if (code) { printf("bos_util: failed to set key, code %d.\n", code); exit(1); } - } - else if (strcmp(argv[1], "adddes")==0) { + } else if (strcmp(argv[1], "adddes") == 0) { struct ktc_encryptionKey tkey; int kvno; register afs_int32 code; @@ -115,21 +116,21 @@ main(int argc, char **argv) memset(&tkey, 0, sizeof(struct ktc_encryptionKey)); /* prompt for key */ - code=des_read_pw_string(buf,sizeof(buf),"input key: ",0); - if(code || strlen(buf)==0) { + code = des_read_pw_string(buf, sizeof(buf), "input key: ", 0); + if (code || strlen(buf) == 0) { printf("Bad key: \n"); exit(1); } - code=des_read_pw_string(ver,sizeof(ver),"Retype input key: ",0); - if(code || strlen(ver)==0) { + code = des_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0); + if (code || strlen(ver) == 0) { printf("Bad key: \n"); exit(1); } - if (strcmp (ver, buf) != 0) { - printf ("\nInput key mismatch\n"); + if (strcmp(ver, buf) != 0) { + printf("\nInput key mismatch\n"); exit(1); } - des_string_to_key(buf,&tkey); + des_string_to_key(buf, &tkey); code = afsconf_AddKey(tdir, kvno, &tkey, 0); if (code) { printf("bos_util: failed to set key, code %d.\n", code); @@ -137,24 +138,25 @@ main(int argc, char **argv) } } #ifdef KERBEROS - else if (strcmp(argv[1], "srvtab2keyfile")==0) { + else if (strcmp(argv[1], "srvtab2keyfile") == 0) { char tkey[8], name[255], inst[255], realm[255]; int kvno; if (argc != 5) { - printf("bos_util add: usage is 'bos_util srvtab2keyfile \n"); + printf + ("bos_util add: usage is 'bos_util srvtab2keyfile \n"); exit(1); } kvno = atoi(argv[2]); bzero(tkey, sizeof(tkey)); code = kname_parse(name, inst, realm, argv[4]); if (code != 0) { - printf("Invalid kerberos name\n"); - exit(1); + printf("Invalid kerberos name\n"); + exit(1); } code = read_service_key(name, inst, realm, kvno, argv[3], tkey); if (code != 0) { - printf("Can't find key in %s\n", argv[3]); - exit(1); + printf("Can't find key in %s\n", argv[3]); + exit(1); } code = afsconf_AddKey(tdir, kvno, tkey, 0); if (code) { @@ -163,7 +165,7 @@ main(int argc, char **argv) } } #endif - else if (strcmp(argv[1], "delete")==0) { + else if (strcmp(argv[1], "delete") == 0) { long kvno; if (argc != 3) { printf("bos_util delete: usage is 'bos_util delete \n"); @@ -172,37 +174,38 @@ main(int argc, char **argv) kvno = atoi(argv[2]); code = afsconf_DeleteKey(tdir, kvno); if (code) { - printf("bos_util: failed to delete key %d, (code %d)\n", kvno, code); + printf("bos_util: failed to delete key %d, (code %d)\n", kvno, + code); exit(1); } - } - else if (strcmp(argv[1], "list") == 0) { + } else if (strcmp(argv[1], "list") == 0) { struct afsconf_keys tkeys; register int i; unsigned char tbuffer[9]; - + code = afsconf_GetKeys(tdir, &tkeys); if (code) { printf("bos_util: failed to get keys, code %d\n", code); exit(1); } - for(i=0;i #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -59,24 +60,25 @@ extern int DoLogging; extern int bozo_isrestricted; #endif -afs_int32 SBOZO_GetRestartTime(acall, atype, aktime) - struct rx_call *acall; - afs_int32 atype; - struct bozo_netKTime *aktime; +afs_int32 +SBOZO_GetRestartTime(acall, atype, aktime) + struct rx_call *acall; + afs_int32 atype; + struct bozo_netKTime *aktime; { register afs_int32 code; - code = 0; /* assume success */ + code = 0; /* assume success */ switch (atype) { - case 1: + case 1: memcpy(aktime, &bozo_nextRestartKT, sizeof(struct ktime)); break; - case 2: + case 2: memcpy(aktime, &bozo_nextDayKT, sizeof(struct ktime)); break; - default: + default: code = BZDOM; break; } @@ -84,32 +86,34 @@ afs_int32 SBOZO_GetRestartTime(acall, atype, aktime) return code; } -afs_int32 SBOZO_SetRestartTime(acall, atype, aktime) - struct rx_call *acall; - afs_int32 atype; - struct bozo_netKTime *aktime; +afs_int32 +SBOZO_SetRestartTime(acall, atype, aktime) + struct rx_call *acall; + afs_int32 atype; + struct bozo_netKTime *aktime; { register afs_int32 code; char caller[MAXKTCNAMELEN]; /* check for proper permissions */ if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing SetRestartTime\n", caller); + if (DoLogging) + bozo_Log("%s is executing SetRestartTime\n", caller); - code = 0; /* assume success */ + code = 0; /* assume success */ switch (atype) { - case 1: + case 1: memcpy(&bozo_nextRestartKT, aktime, sizeof(struct ktime)); break; - case 2: + case 2: memcpy(&bozo_nextDayKT, aktime, sizeof(struct ktime)); break; - default: + default: code = BZDOM; break; } @@ -120,43 +124,48 @@ afs_int32 SBOZO_SetRestartTime(acall, atype, aktime) bozo_newKTs = 1; } -fail: - osi_auditU (acall, BOS_SetRestartEvent, code, AUD_END); + fail: + osi_auditU(acall, BOS_SetRestartEvent, code, AUD_END); return code; } -afs_int32 SBOZO_Exec(acall, acmd) -struct rx_call *acall; -char *acmd; { +afs_int32 +SBOZO_Exec(acall, acmd) + struct rx_call *acall; + char *acmd; +{ char caller[MAXKTCNAMELEN]; int code; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } #ifdef BOS_RESTRICTED_MODE if (bozo_isrestricted) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } #endif - if (DoLogging) bozo_Log("%s is executing the shell command '%s'\n", caller, acmd); + if (DoLogging) + bozo_Log("%s is executing the shell command '%s'\n", caller, acmd); /* should copy output to acall, but don't yet cause its hard */ /* hard... NOT! Nnow _at least_ return the exit status */ code = system(acmd); - osi_auditU (acall, BOS_ExecEvent, code, AUD_STR, acmd, AUD_END); + osi_auditU(acall, BOS_ExecEvent, code, AUD_STR, acmd, AUD_END); -fail: + fail: return code; } -afs_int32 SBOZO_GetDates(acall, aname, atime, abakTime, aoldTime) -struct rx_call *acall; -char *aname; -afs_int32 *atime, *abakTime, *aoldTime; { +afs_int32 +SBOZO_GetDates(acall, aname, atime, abakTime, aoldTime) + struct rx_call *acall; + char *aname; + afs_int32 *atime, *abakTime, *aoldTime; +{ struct stat tstat; char *strp; char tbuffer[AFSDIR_PATH_MAX]; @@ -188,9 +197,11 @@ afs_int32 *atime, *abakTime, *aoldTime; { return 0; } -afs_int32 SBOZO_UnInstall(acall, aname) -struct rx_call *acall; -register char *aname; { +afs_int32 +SBOZO_UnInstall(acall, aname) + struct rx_call *acall; + register char *aname; +{ char *filepath; char fpOld[AFSDIR_PATH_MAX], fpBak[AFSDIR_PATH_MAX]; afs_int32 code; @@ -199,13 +210,13 @@ register char *aname; { if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { code = BZACCESS; - osi_auditU (acall, BOS_UnInstallEvent, code, AUD_STR, aname, AUD_END); + osi_auditU(acall, BOS_UnInstallEvent, code, AUD_STR, aname, AUD_END); return code; } #ifdef BOS_RESTRICTED_MODE if (bozo_isrestricted) { code = BZACCESS; - osi_auditU (acall, BOS_UnInstallEvent, code, AUD_STR, aname, AUD_END); + osi_auditU(acall, BOS_UnInstallEvent, code, AUD_STR, aname, AUD_END); return code; } #endif @@ -215,7 +226,8 @@ register char *aname; { return BZNOENT; } - if (DoLogging) bozo_Log("%s is executing UnInstall '%s'\n", caller, filepath); + if (DoLogging) + bozo_Log("%s is executing UnInstall '%s'\n", caller, filepath); strcpy(fpBak, filepath); strcat(fpBak, ".BAK"); @@ -226,7 +238,7 @@ register char *aname; { if (code) { /* can't find .BAK, try .OLD */ code = renamefile(fpOld, filepath); - if (code && errno == ENOENT) /* If doesn't exist don't fail */ + if (code && errno == ENOENT) /* If doesn't exist don't fail */ code = 0; } else { /* now rename .OLD to .BAK */ @@ -236,21 +248,22 @@ register char *aname; { if (code) code = errno; - osi_auditU (acall, BOS_UnInstallEvent, code, AUD_STR, filepath, AUD_END); + osi_auditU(acall, BOS_UnInstallEvent, code, AUD_STR, filepath, AUD_END); free(filepath); return code; } -#define BOZO_OLDTIME (7*24*3600) /* 7 days old */ -static void SaveOldFiles(char *aname) +#define BOZO_OLDTIME (7*24*3600) /* 7 days old */ +static void +SaveOldFiles(char *aname) { register afs_int32 code; char bbuffer[AFSDIR_PATH_MAX], obuffer[AFSDIR_PATH_MAX]; struct stat tstat; register afs_int32 now; afs_int32 oldTime, bakTime; - + strcpy(bbuffer, aname); strcat(bbuffer, ".BAK"); strcpy(obuffer, aname); @@ -258,31 +271,38 @@ static void SaveOldFiles(char *aname) now = FT_ApproxTime(); code = stat(aname, &tstat); - if (code < 0) return; /* can't stat file */ - - code = stat(obuffer, &tstat); /* discover old file's time */ - if (code) oldTime = 0; - else oldTime = tstat.st_mtime; + if (code < 0) + return; /* can't stat file */ - code = stat(bbuffer, &tstat); /* discover back file's time */ - if (code) bakTime = 0; - else bakTime = tstat.st_mtime; + code = stat(obuffer, &tstat); /* discover old file's time */ + if (code) + oldTime = 0; + else + oldTime = tstat.st_mtime; + + code = stat(bbuffer, &tstat); /* discover back file's time */ + if (code) + bakTime = 0; + else + bakTime = tstat.st_mtime; if (bakTime && (oldTime == 0 || bakTime < now - BOZO_OLDTIME)) { /* no .OLD file, or .BAK is at least a week old */ code = renamefile(bbuffer, obuffer); } - + /* finally rename to .BAK extension */ renamefile(aname, bbuffer); } -afs_int32 SBOZO_Install(acall, aname, asize, mode, amtime) -struct rx_call *acall; -char *aname; -afs_int32 asize; -afs_int32 amtime; -afs_int32 mode; { +afs_int32 +SBOZO_Install(acall, aname, asize, mode, amtime) + struct rx_call *acall; + char *aname; + afs_int32 asize; + afs_int32 amtime; + afs_int32 mode; +{ afs_int32 code; int fd; afs_int32 len; @@ -295,9 +315,11 @@ afs_int32 mode; { char filepath[AFSDIR_PATH_MAX], tbuffer[AFSDIR_PATH_MAX], *fpp; char caller[MAXKTCNAMELEN]; - if (!afsconf_SuperUser(bozo_confdir, acall, caller)) return BZACCESS; + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) + return BZACCESS; #ifdef BOS_RESTRICTED_MODE - if (bozo_isrestricted) return BZACCESS; + if (bozo_isrestricted) + return BZACCESS; #endif /* construct local path from canonical (wire-format) path */ @@ -307,39 +329,42 @@ afs_int32 mode; { strcpy(filepath, fpp); free(fpp); - if (DoLogging) bozo_Log("%s is executing Install '%s'\n", caller, filepath); + if (DoLogging) + bozo_Log("%s is executing Install '%s'\n", caller, filepath); /* open file */ fpp = filepath + strlen(filepath); - strcpy(fpp, ".NEW"); /* append ".NEW" to end of filepath */ + strcpy(fpp, ".NEW"); /* append ".NEW" to end of filepath */ fd = open(filepath, O_CREAT | O_RDWR | O_TRUNC, 0777); - if (fd < 0) return errno; + if (fd < 0) + return errno; total = 0; - while(1) { + while (1) { len = rx_Read(acall, tbuffer, sizeof(tbuffer)); if (len < 0) { close(fd); unlink(filepath); return 102; } - if (len == 0) break; /* no more input */ + if (len == 0) + break; /* no more input */ code = write(fd, tbuffer, len); if (code != len) { close(fd); unlink(filepath); return 100; } - total += len; /* track total written for safety check at end */ + total += len; /* track total written for safety check at end */ } close(fd); - if (asize != total) { + if (asize != total) { unlink(filepath); - return 101; /* wrong size */ + return 101; /* wrong size */ } /* save old files */ - *fpp = '\0'; /* remove ".NEW" from end of filepath */ - SaveOldFiles(filepath); /* don't care if it works, still install */ + *fpp = '\0'; /* remove ".NEW" from end of filepath */ + SaveOldFiles(filepath); /* don't care if it works, still install */ /* all done, rename to final name */ strcpy(tbuffer, filepath); @@ -360,104 +385,120 @@ afs_int32 mode; { chmod(filepath, mode); if (code < 0) { - osi_auditU (acall, BOS_InstallEvent, code, AUD_STR, filepath, AUD_END); - return errno; - } - else return 0; + osi_auditU(acall, BOS_InstallEvent, code, AUD_STR, filepath, AUD_END); + return errno; + } else + return 0; } -afs_int32 SBOZO_SetCellName(acall, aname) -struct rx_call *acall; -char *aname; { +afs_int32 +SBOZO_SetCellName(acall, aname) + struct rx_call *acall; + char *aname; +{ struct afsconf_cell tcell; register afs_int32 code; char caller[MAXKTCNAMELEN]; char clones[MAXHOSTSPERCELL]; - + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing SetCellName '%s'\n", caller, aname); + if (DoLogging) + bozo_Log("%s is executing SetCellName '%s'\n", caller, aname); - code = afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell, &clones); - if (code) - goto fail; + code = + afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell, + &clones); + if (code) + goto fail; /* Check that tcell has enough space for the new cellname. */ if (strlen(aname) > sizeof tcell.name - 1) { - bozo_Log("ERROR: SetCellName: cell name '%s' exceeds %ld bytes (cell name not changed)\n", - aname, (long)(sizeof tcell.name - 1)); + bozo_Log + ("ERROR: SetCellName: cell name '%s' exceeds %ld bytes (cell name not changed)\n", + aname, (long)(sizeof tcell.name - 1)); code = BZDOM; goto fail; } strcpy(tcell.name, aname); - code = afsconf_SetExtendedCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH, &tcell, &clones); + code = + afsconf_SetExtendedCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH, + &tcell, &clones); fail: - osi_auditU (acall, BOS_SetCellEvent, code, AUD_STR, aname, AUD_END); + osi_auditU(acall, BOS_SetCellEvent, code, AUD_STR, aname, AUD_END); return code; } -afs_int32 SBOZO_GetCellName(acall, aname) -struct rx_call *acall; -char **aname; { +afs_int32 +SBOZO_GetCellName(acall, aname) + struct rx_call *acall; + char **aname; +{ register afs_int32 code; char tname[MAXCELLCHARS]; - + code = afsconf_GetLocalCell(bozo_confdir, tname, sizeof(tname)); if (code) { - /* must set output parameters even if aborting */ - *aname = (char *) malloc(1); - **aname = 0; - } - else { - *aname = (char *) malloc(strlen(tname)+1); - strcpy(*aname, tname); + /* must set output parameters even if aborting */ + *aname = (char *)malloc(1); + **aname = 0; + } else { + *aname = (char *)malloc(strlen(tname) + 1); + strcpy(*aname, tname); } return code; } -afs_int32 SBOZO_GetCellHost(acall, awhich, aname) -struct rx_call *acall; -afs_uint32 awhich; -char **aname; { +afs_int32 +SBOZO_GetCellHost(acall, awhich, aname) + struct rx_call *acall; + afs_uint32 awhich; + char **aname; +{ register afs_int32 code; struct afsconf_cell tcell; register char *tp; char clones[MAXHOSTSPERCELL]; - code = afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell, &clones); - if (code) goto fail; + code = + afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell, + &clones); + if (code) + goto fail; if (awhich >= tcell.numServers) { code = BZDOM; goto fail; } - + tp = tcell.hostName[awhich]; - *aname = (char *) malloc(strlen(tp)+3); + *aname = (char *)malloc(strlen(tp) + 3); if (clones[awhich]) { strcpy(*aname, "["); strcat(*aname, tp); strcat(*aname, "]"); } else - strcpy(*aname, tp); + strcpy(*aname, tp); goto done; - -fail: - *aname = (char *) malloc(1); /* return fake string */ + + fail: + *aname = (char *)malloc(1); /* return fake string */ **aname = 0; -done: + done: return code; } -afs_int32 SBOZO_DeleteCellHost(acall, aname) -struct rx_call *acall; -char *aname; { +afs_int32 +SBOZO_DeleteCellHost(acall, aname) + struct rx_call *acall; + char *aname; +{ register afs_int32 code; struct afsconf_cell tcell; afs_int32 which; @@ -466,18 +507,20 @@ char *aname; { char clones[MAXHOSTSPERCELL]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) - bozo_Log("%s is executing DeleteCellHost '%s'\n", caller, aname); + if (DoLogging) + bozo_Log("%s is executing DeleteCellHost '%s'\n", caller, aname); - code = afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell, &clones); - if (code) - goto fail; + code = + afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell, + &clones); + if (code) + goto fail; which = -1; - for(i=0;i sizeof tcell.hostAddr/sizeof tcell.hostAddr[0]) { - bozo_Log("ERROR: AddCellHost: attempt to add more than %ld database servers (database server '%s' not added)\n", - (long)(sizeof tcell.hostAddr/sizeof tcell.hostAddr[0]), aname); + if (tcell.numServers > + sizeof tcell.hostAddr / sizeof tcell.hostAddr[0]) { + bozo_Log + ("ERROR: AddCellHost: attempt to add more than %ld database servers (database server '%s' not added)\n", + (long)(sizeof tcell.hostAddr / sizeof tcell.hostAddr[0]), + aname); code = BZDOM; goto fail; } /* Check that tcell has enough space for the new hostname. */ if (strlen(aname) > sizeof tcell.hostName[0] - 1) { - bozo_Log("ERROR: AddCellHost: host name '%s' exceeds %ld bytes (not added)\n", - aname, (long)(sizeof tcell.hostName[0] - 1)); + bozo_Log + ("ERROR: AddCellHost: host name '%s' exceeds %ld bytes (not added)\n", + aname, (long)(sizeof tcell.hostName[0] - 1)); code = BZDOM; goto fail; } @@ -564,19 +617,22 @@ char *aname; { memset(&tcell.hostAddr[which], 0, sizeof(struct sockaddr_in)); strcpy(tcell.hostName[which], n); clones[which] = isClone; - code = afsconf_SetExtendedCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH, &tcell, &clones); + code = + afsconf_SetExtendedCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH, + &tcell, &clones); fail: osi_auditU(acall, BOS_AddHostEvent, code, AUD_STR, aname, AUD_END); return code; } -afs_int32 SBOZO_ListKeys(acall, an, akvno, akey, akeyinfo) -struct rx_call *acall; -afs_int32 an; -afs_int32 *akvno; -struct bozo_keyInfo *akeyinfo; -struct bozo_key *akey; +afs_int32 +SBOZO_ListKeys(acall, an, akvno, akey, akeyinfo) + struct rx_call *acall; + afs_int32 an; + afs_int32 *akvno; + struct bozo_keyInfo *akeyinfo; + struct bozo_key *akey; { struct afsconf_keys tkeys; register afs_int32 code; @@ -586,18 +642,19 @@ struct bozo_key *akey; rxkad_level enc_level = rxkad_clear; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing ListKeys\n", caller); + if (DoLogging) + bozo_Log("%s is executing ListKeys\n", caller); code = afsconf_GetKeys(bozo_confdir, &tkeys); - if (code) - goto fail; + if (code) + goto fail; if (tkeys.nkeys <= an) { - code = BZDOM; - goto fail; + code = BZDOM; + goto fail; } *akvno = tkeys.key[an].kvno; memset(akeyinfo, 0, sizeof(struct bozo_keyInfo)); @@ -610,242 +667,274 @@ struct bozo_key *akey; if ((noauth) || (enc_level == rxkad_crypt)) { memcpy(akey, tkeys.key[an].key, 8); - } - else memset(akey, 0, 8); + } else + memset(akey, 0, 8); code = stat(AFSDIR_SERVER_KEY_FILEPATH, &tstat); if (code == 0) { akeyinfo->mod_sec = tstat.st_mtime; } - ka_KeyCheckSum (tkeys.key[an].key, &akeyinfo->keyCheckSum); + ka_KeyCheckSum(tkeys.key[an].key, &akeyinfo->keyCheckSum); /* only errors is bad key parity */ -fail: + fail: if (noauth) - osi_auditU(acall, BOS_UnAuthListKeysEvent, code, AUD_END); + osi_auditU(acall, BOS_UnAuthListKeysEvent, code, AUD_END); osi_auditU(acall, BOS_ListKeysEvent, code, AUD_END); return code; } -afs_int32 SBOZO_AddKey(acall, an, akey) -struct rx_call *acall; -afs_int32 an; -struct bozo_key *akey; { +afs_int32 +SBOZO_AddKey(acall, an, akey) + struct rx_call *acall; + afs_int32 an; + struct bozo_key *akey; +{ register afs_int32 code; char caller[MAXKTCNAMELEN]; rxkad_level enc_level = rxkad_clear; int noauth; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } noauth = afsconf_GetNoAuthFlag(bozo_confdir); rxkad_GetServerInfo(acall->conn, &enc_level, 0, 0, 0, 0, 0); if ((!noauth) && (enc_level != rxkad_crypt)) { - code = BZENCREQ; - goto fail; + code = BZENCREQ; + goto fail; } - if (DoLogging) bozo_Log("%s is executing AddKey\n", caller); + if (DoLogging) + bozo_Log("%s is executing AddKey\n", caller); code = afsconf_AddKey(bozo_confdir, an, akey, 0); - if (code == AFSCONF_KEYINUSE) + if (code == AFSCONF_KEYINUSE) code = BZKEYINUSE; /* Unique code for afs rpc calls */ -fail: + fail: osi_auditU(acall, BOS_AddKeyEvent, code, AUD_END); return code; } -afs_int32 SBOZO_SetNoAuthFlag(acall, aflag) -register struct rx_call *acall; -afs_int32 aflag; { - register afs_int32 code = 0; +afs_int32 +SBOZO_SetNoAuthFlag(acall, aflag) + register struct rx_call *acall; + afs_int32 aflag; +{ + register afs_int32 code = 0; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing Set No Authentication\n", caller); + if (DoLogging) + bozo_Log("%s is executing Set No Authentication\n", caller); afsconf_SetNoAuthFlag(bozo_confdir, aflag); -fail: + fail: osi_auditU(acall, BOS_SetNoAuthEvent, code, AUD_LONG, aflag, AUD_END); return code; } -afs_int32 SBOZO_DeleteKey(acall, an) -struct rx_call *acall; -afs_int32 an; { +afs_int32 +SBOZO_DeleteKey(acall, an) + struct rx_call *acall; + afs_int32 an; +{ register afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing DeleteKey\n", caller); + if (DoLogging) + bozo_Log("%s is executing DeleteKey\n", caller); code = afsconf_DeleteKey(bozo_confdir, an); -fail: + fail: osi_auditU(acall, BOS_DeleteKeyEvent, code, AUD_END); return code; } -afs_int32 SBOZO_ListSUsers(acall, an, aname) -struct rx_call *acall; -afs_int32 an; -register char **aname; { +afs_int32 +SBOZO_ListSUsers(acall, an, aname) + struct rx_call *acall; + afs_int32 an; + register char **aname; +{ register afs_int32 code; register char *tp; - tp = *aname = (char *) malloc(256); - *tp = 0; /* in case getnthuser doesn't null-terminate the string */ + tp = *aname = (char *)malloc(256); + *tp = 0; /* in case getnthuser doesn't null-terminate the string */ code = afsconf_GetNthUser(bozo_confdir, an, tp, 256); -fail: + fail: osi_auditU(acall, BOS_ListSUserEvent, code, AUD_END); return code; } -afs_int32 SBOZO_AddSUser(acall, aname) -struct rx_call *acall; -char *aname; { +afs_int32 +SBOZO_AddSUser(acall, aname) + struct rx_call *acall; + char *aname; +{ register afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) - bozo_Log("%s is executing Add SuperUser '%s'\n", caller, aname); + if (DoLogging) + bozo_Log("%s is executing Add SuperUser '%s'\n", caller, aname); code = afsconf_AddUser(bozo_confdir, aname); -fail: + fail: osi_auditU(acall, BOS_AddSUserEvent, code, AUD_END); return code; } -afs_int32 SBOZO_DeleteSUser(acall, aname) -struct rx_call *acall; -char *aname; { +afs_int32 +SBOZO_DeleteSUser(acall, aname) + struct rx_call *acall; + char *aname; +{ register afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) - bozo_Log("%s is executing Delete SuperUser '%s'\n", caller, aname); + if (DoLogging) + bozo_Log("%s is executing Delete SuperUser '%s'\n", caller, aname); code = afsconf_DeleteUser(bozo_confdir, aname); -fail: + fail: osi_auditU(acall, BOS_DeleteSUserEvent, code, AUD_END); return code; } -afs_int32 SBOZO_CreateBnode(acall, atype, ainstance, ap1, ap2, ap3, ap4, ap5, notifier) -struct rx_call *acall; -char *atype; -char *ainstance; -char *ap1, *ap2, *ap3, *ap4, *ap5; -char *notifier; { +afs_int32 +SBOZO_CreateBnode(acall, atype, ainstance, ap1, ap2, ap3, ap4, ap5, notifier) + struct rx_call *acall; + char *atype; + char *ainstance; + char *ap1, *ap2, *ap3, *ap4, *ap5; + char *notifier; +{ struct bnode *tb; afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } #ifdef BOS_RESTRICTED_MODE if (bozo_isrestricted) { - if (strcmp(atype, "cron") || strcmp(ainstance, "salvage-tmp") || - strcmp(ap2, "now") || - strncmp(ap1, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, - strlen(AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH))) { - code = BZACCESS; - goto fail; - } + if (strcmp(atype, "cron") || strcmp(ainstance, "salvage-tmp") + || strcmp(ap2, "now") + || strncmp(ap1, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, + strlen(AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH))) { + code = BZACCESS; + goto fail; + } } #endif - code = bnode_Create(atype, ainstance, &tb, ap1, ap2, ap3, ap4, ap5, notifier,BSTAT_NORMAL); + code = + bnode_Create(atype, ainstance, &tb, ap1, ap2, ap3, ap4, ap5, notifier, + BSTAT_NORMAL); if (!code) - bnode_SetStat(tb, BSTAT_NORMAL); + bnode_SetStat(tb, BSTAT_NORMAL); fail: osi_auditU(acall, BOS_CreateBnodeEvent, code, AUD_END); return code; } -afs_int32 SBOZO_WaitAll(acall) -register struct rx_call *acall; { +afs_int32 +SBOZO_WaitAll(acall) + register struct rx_call *acall; +{ register afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing Wait for All\n", caller); + if (DoLogging) + bozo_Log("%s is executing Wait for All\n", caller); code = bnode_WaitAll(); -fail: + fail: osi_auditU(acall, BOS_WaitAllEvent, code, AUD_END); return code; } -afs_int32 SBOZO_DeleteBnode(acall, ainstance) -struct rx_call *acall; -char *ainstance; { +afs_int32 +SBOZO_DeleteBnode(acall, ainstance) + struct rx_call *acall; + char *ainstance; +{ register afs_int32 code; char caller[MAXKTCNAMELEN]; if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } #ifdef BOS_RESTRICTED_MODE if (bozo_isrestricted) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } #endif - if (DoLogging) bozo_Log("%s is executing DeleteBnode '%s'\n", caller, ainstance); + if (DoLogging) + bozo_Log("%s is executing DeleteBnode '%s'\n", caller, ainstance); code = bnode_DeleteName(ainstance); -fail: - osi_auditU(acall, BOS_DeleteBnodeEvent, code, AUD_STR, ainstance, AUD_END); + fail: + osi_auditU(acall, BOS_DeleteBnodeEvent, code, AUD_STR, ainstance, + AUD_END); return code; } -static swproc(abnode, arock) -register struct bnode *abnode; -char *arock; { - if (abnode->goal == BSTAT_NORMAL) return 0; /* this one's not shutting down */ +static +swproc(abnode, arock) + register struct bnode *abnode; + char *arock; +{ + if (abnode->goal == BSTAT_NORMAL) + return 0; /* this one's not shutting down */ /* otherwise, we are shutting down */ bnode_Hold(abnode); bnode_WaitStatus(abnode, BSTAT_SHUTDOWN); bnode_Release(abnode); - return 0; /* don't stop apply function early, no matter what */ + return 0; /* don't stop apply function early, no matter what */ } -static stproc(abnode, arock) -struct bnode *abnode; -char *arock; { - if (abnode->fileGoal == BSTAT_SHUTDOWN) return 0; /* don't do these guys */ +static +stproc(abnode, arock) + struct bnode *abnode; + char *arock; +{ + if (abnode->fileGoal == BSTAT_SHUTDOWN) + return 0; /* don't do these guys */ bnode_Hold(abnode); bnode_SetStat(abnode, BSTAT_NORMAL); @@ -853,9 +942,11 @@ char *arock; { return 0; } -static sdproc(abnode, arock) -struct bnode *abnode; -char *arock; { +static +sdproc(abnode, arock) + struct bnode *abnode; + char *arock; +{ bnode_Hold(abnode); bnode_SetStat(abnode, BSTAT_SHUTDOWN); bnode_Release(abnode); @@ -863,202 +954,236 @@ char *arock; { } /* shutdown and leave down */ -afs_int32 SBOZO_ShutdownAll(acall) -struct rx_call *acall; { +afs_int32 +SBOZO_ShutdownAll(acall) + struct rx_call *acall; +{ /* iterate over all bnodes, setting the status to temporarily disabled */ register afs_int32 code; char caller[MAXKTCNAMELEN]; - + /* check for authorization */ if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing ShutdownAll\n", caller); + if (DoLogging) + bozo_Log("%s is executing ShutdownAll\n", caller); code = bnode_ApplyInstance(sdproc, NULL); fail: - osi_auditU (acall, BOS_ShutdownAllEvent, code, AUD_END); + osi_auditU(acall, BOS_ShutdownAllEvent, code, AUD_END); return code; } /* shutdown and restart */ -afs_int32 SBOZO_RestartAll(acall) -struct rx_call *acall; { +afs_int32 +SBOZO_RestartAll(acall) + struct rx_call *acall; +{ register afs_int32 code; char caller[MAXKTCNAMELEN]; - - if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing RestartAll\n", caller); + if (DoLogging) + bozo_Log("%s is executing RestartAll\n", caller); /* start shutdown of all processes */ code = bnode_ApplyInstance(sdproc, NULL); - if (code) goto fail; + if (code) + goto fail; /* wait for all done */ code = bnode_ApplyInstance(swproc, NULL); - if (code) goto fail; + if (code) + goto fail; /* start them up again */ code = bnode_ApplyInstance(stproc, NULL); fail: - osi_auditU (acall, BOS_RestartAllEvent, code, AUD_END); + osi_auditU(acall, BOS_RestartAllEvent, code, AUD_END); return code; } -afs_int32 SBOZO_ReBozo(acall) -register struct rx_call *acall; { +afs_int32 +SBOZO_ReBozo(acall) + register struct rx_call *acall; +{ register afs_int32 code; char caller[MAXKTCNAMELEN]; /* acall is null if called internally to restart bosserver */ - if (acall && !afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + if (acall && !afsconf_SuperUser(bozo_confdir, acall, caller)) { + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing ReBozo\n", caller); + if (DoLogging) + bozo_Log("%s is executing ReBozo\n", caller); /* start shutdown of all processes */ code = bnode_ApplyInstance(sdproc, NULL); - if (code) goto fail; + if (code) + goto fail; /* wait for all done */ code = bnode_ApplyInstance(swproc, NULL); - if (code) goto fail; + if (code) + goto fail; - if (acall) osi_auditU (acall, BOS_RebozoEvent, code, AUD_END); - else osi_audit (BOS_RebozoIntEvent, code, AUD_END); + if (acall) + osi_auditU(acall, BOS_RebozoEvent, code, AUD_END); + else + osi_audit(BOS_RebozoIntEvent, code, AUD_END); - if (acall) rx_EndCall(acall, 0); /* try to get it done */ + if (acall) + rx_EndCall(acall, 0); /* try to get it done */ rx_Finalize(); - bozo_ReBozo(); /* this reexecs us, and doesn't return, of course */ + bozo_ReBozo(); /* this reexecs us, and doesn't return, of course */ -fail: + fail: /* Differentiate between external and internal ReBozo; prevents AFS_Aud_NoCall event */ - if (acall) osi_auditU (acall, BOS_RebozoEvent, code, AUD_END); - else osi_audit (BOS_RebozoIntEvent, code, AUD_END); - return code; /* should only get here in unusual circumstances */ + if (acall) + osi_auditU(acall, BOS_RebozoEvent, code, AUD_END); + else + osi_audit(BOS_RebozoIntEvent, code, AUD_END); + return code; /* should only get here in unusual circumstances */ } /* make sure all are running */ -afs_int32 SBOZO_StartupAll(acall) -struct rx_call *acall; { +afs_int32 +SBOZO_StartupAll(acall) + struct rx_call *acall; +{ register afs_int32 code; char caller[MAXKTCNAMELEN]; - if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing StartupAll\n", caller); + if (DoLogging) + bozo_Log("%s is executing StartupAll\n", caller); code = bnode_ApplyInstance(stproc, NULL); -fail: - osi_auditU (acall, BOS_StartupAllEvent, code, AUD_END); + fail: + osi_auditU(acall, BOS_StartupAllEvent, code, AUD_END); return code; } -afs_int32 SBOZO_Restart(acall, ainstance) -struct rx_call *acall; -register char *ainstance; { +afs_int32 +SBOZO_Restart(acall, ainstance) + struct rx_call *acall; + register char *ainstance; +{ register struct bnode *tb; register afs_int32 code; char caller[MAXKTCNAMELEN]; - - if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing Restart '%s'\n", caller, ainstance); + if (DoLogging) + bozo_Log("%s is executing Restart '%s'\n", caller, ainstance); tb = bnode_FindInstance(ainstance); if (!tb) { - code = BZNOENT; - goto fail; + code = BZNOENT; + goto fail; } - + /* setup return code */ code = 0; bnode_Hold(tb); bnode_SetStat(tb, BSTAT_SHUTDOWN); - code = bnode_WaitStatus(tb, BSTAT_SHUTDOWN); /* this can fail */ + code = bnode_WaitStatus(tb, BSTAT_SHUTDOWN); /* this can fail */ bnode_SetStat(tb, BSTAT_NORMAL); bnode_Release(tb); -fail: - osi_auditU (acall, BOS_RestartEvent, code, AUD_STR, ainstance, AUD_END); + fail: + osi_auditU(acall, BOS_RestartEvent, code, AUD_STR, ainstance, AUD_END); return code; } /* set temp status */ -afs_int32 SBOZO_SetTStatus(acall, ainstance, astatus) -struct rx_call *acall; -char *ainstance; -afs_int32 astatus; { +afs_int32 +SBOZO_SetTStatus(acall, ainstance, astatus) + struct rx_call *acall; + char *ainstance; + afs_int32 astatus; +{ register struct bnode *tb; register afs_int32 code; char caller[MAXKTCNAMELEN]; - if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing SetTempStatus '%s'\n", caller, ainstance); + if (DoLogging) + bozo_Log("%s is executing SetTempStatus '%s'\n", caller, ainstance); tb = bnode_FindInstance(ainstance); if (!tb) { - code = BZNOENT; - goto fail; + code = BZNOENT; + goto fail; } bnode_Hold(tb); code = bnode_SetStat(tb, astatus); bnode_Release(tb); -fail: - osi_auditU (acall, BOS_SetTempStatusEvent, code, AUD_STR, ainstance, AUD_END); + fail: + osi_auditU(acall, BOS_SetTempStatusEvent, code, AUD_STR, ainstance, + AUD_END); return code; } -afs_int32 SBOZO_SetStatus(acall, ainstance, astatus) -struct rx_call *acall; -char *ainstance; -afs_int32 astatus; { +afs_int32 +SBOZO_SetStatus(acall, ainstance, astatus) + struct rx_call *acall; + char *ainstance; + afs_int32 astatus; +{ register struct bnode *tb; register afs_int32 code; char caller[MAXKTCNAMELEN]; - if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { + code = BZACCESS; + goto fail; } - if (DoLogging) bozo_Log("%s is executing SetStatus '%s' (status = %d)\n", caller, ainstance, astatus); + if (DoLogging) + bozo_Log("%s is executing SetStatus '%s' (status = %d)\n", caller, + ainstance, astatus); tb = bnode_FindInstance(ainstance); if (!tb) { - code = BZNOENT; - goto fail; + code = BZNOENT; + goto fail; } bnode_Hold(tb); bnode_SetFileGoal(tb, astatus); code = bnode_SetStat(tb, astatus); bnode_Release(tb); -fail: - osi_auditU (acall, BOS_SetStatusEvent, code, AUD_STR, ainstance, AUD_END); + fail: + osi_auditU(acall, BOS_SetStatusEvent, code, AUD_STR, ainstance, AUD_END); return code; } -afs_int32 SBOZO_GetStatus(acall, ainstance, astat, astatDescr) -struct rx_call *acall; -char *ainstance; -afs_int32 *astat; -char **astatDescr; { +afs_int32 +SBOZO_GetStatus(acall, ainstance, astat, astatDescr) + struct rx_call *acall; + char *ainstance; + afs_int32 *astat; + char **astatDescr; +{ register struct bnode *tb; register afs_int32 code; @@ -1067,22 +1192,23 @@ char **astatDescr; { code = BZNOENT; goto fail; } - + bnode_Hold(tb); code = bnode_GetStat(tb, astat); if (code) { bnode_Release(tb); goto fail; } - - *astatDescr = (char *) malloc(BOZO_BSSIZE); + + *astatDescr = (char *)malloc(BOZO_BSSIZE); code = bnode_GetString(tb, *astatDescr, BOZO_BSSIZE); bnode_Release(tb); - if (code) (*astatDescr)[0] = 0; /* null string means no further info */ + if (code) + (*astatDescr)[0] = 0; /* null string means no further info */ return 0; -fail: - *astatDescr = (char *) malloc(1); + fail: + *astatDescr = (char *)malloc(1); **astatDescr = 0; return code; } @@ -1092,23 +1218,26 @@ struct eidata { int counter; }; -static eifunc(abnode, arock) -struct bnode *abnode; -struct eidata *arock; { +static +eifunc(abnode, arock) + struct bnode *abnode; + struct eidata *arock; +{ if (arock->counter-- == 0) { /* done */ strcpy(arock->iname, abnode->name); return 1; - } - else { + } else { /* not there yet */ return 0; } } -static ZapFile(adir, aname) -register char *adir; -register char *aname; { +static +ZapFile(adir, aname) + register char *adir; + register char *aname; +{ char tbuffer[256]; strcpy(tbuffer, adir); strcat(tbuffer, "/"); @@ -1116,38 +1245,41 @@ register char *aname; { return unlink(tbuffer); } -afs_int32 SBOZO_Prune(acall, aflags) -struct rx_call *acall; -afs_int32 aflags; { +afs_int32 +SBOZO_Prune(acall, aflags) + struct rx_call *acall; + afs_int32 aflags; +{ register afs_int32 code; DIR *dirp; register struct dirent *tde; register int i; char caller[MAXKTCNAMELEN]; - if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { + code = BZACCESS; + goto fail; } #ifdef BOS_RESTRICTED_MODE if (bozo_isrestricted) { - code = BZACCESS; - goto fail; + code = BZACCESS; + goto fail; } #endif - if (DoLogging) bozo_Log("%s is executing Prune (flags=%d)\n", caller, aflags); + if (DoLogging) + bozo_Log("%s is executing Prune (flags=%d)\n", caller, aflags); /* first scan AFS binary directory */ dirp = opendir(AFSDIR_SERVER_BIN_DIRPATH); if (dirp) { - for(tde=readdir(dirp);tde;tde=readdir(dirp)) { + for (tde = readdir(dirp); tde; tde = readdir(dirp)) { i = strlen(tde->d_name); if (aflags & BOZO_PRUNEOLD) { - if(i >= 4 && strncmp(tde->d_name+i-4, ".OLD", 4)==0) + if (i >= 4 && strncmp(tde->d_name + i - 4, ".OLD", 4) == 0) ZapFile(AFSDIR_SERVER_BIN_DIRPATH, tde->d_name); } if (aflags & BOZO_PRUNEBAK) { - if(i >= 4 && strncmp(tde->d_name+i-4, ".BAK", 4)==0) + if (i >= 4 && strncmp(tde->d_name + i - 4, ".BAK", 4) == 0) ZapFile(AFSDIR_SERVER_BIN_DIRPATH, tde->d_name); } } @@ -1157,9 +1289,9 @@ afs_int32 aflags; { /* then scan AFS log directory */ dirp = opendir(AFSDIR_SERVER_LOGS_DIRPATH); if (dirp) { - for(tde=readdir(dirp);tde;tde=readdir(dirp)) { + for (tde = readdir(dirp); tde; tde = readdir(dirp)) { if (aflags & BOZO_PRUNECORE) { - if(strncmp(tde->d_name, AFSDIR_CORE_FILE, 4)==0) + if (strncmp(tde->d_name, AFSDIR_CORE_FILE, 4) == 0) ZapFile(AFSDIR_SERVER_LOGS_DIRPATH, tde->d_name); } } @@ -1168,35 +1300,40 @@ afs_int32 aflags; { code = 0; fail: - osi_auditU ( acall, BOS_PruneLogs, code, AUD_END); + osi_auditU(acall, BOS_PruneLogs, code, AUD_END); return code; } -afs_int32 SBOZO_EnumerateInstance(acall, anum, ainstance) -struct rx_call *acall; -afs_int32 anum; -char **ainstance; { +afs_int32 +SBOZO_EnumerateInstance(acall, anum, ainstance) + struct rx_call *acall; + afs_int32 anum; + char **ainstance; +{ struct eidata tdata; - *ainstance = (char *) malloc(BOZO_BSSIZE); + *ainstance = (char *)malloc(BOZO_BSSIZE); **ainstance = 0; tdata.counter = anum; tdata.iname = *ainstance; bnode_ApplyInstance(eifunc, &tdata); - if (tdata.counter >= 0) return BZDOM; /* anum > # of actual instances */ - else return 0; + if (tdata.counter >= 0) + return BZDOM; /* anum > # of actual instances */ + else + return 0; } struct bozo_bosEntryStats bozo_bosEntryStats[] = { - {NULL, 1,1, 0755, 02}, /* AFSDIR_SERVER_AFS_DIRPATH */ - {NULL, 1,1, 0755, 02}, /* AFSDIR_SERVER_ETC_DIRPATH */ - {NULL, 1,1, 0755, 02}, /* AFSDIR_SERVER_BIN_DIRPATH */ - {NULL, 1,1, 0755, 02}, /* AFSDIR_SERVER_LOGS_DIRPATH */ - {NULL, 1,0, 0700, 07}, /* AFSDIR_SERVER_BACKUP_DIRPATH */ - {NULL, 1,1, 0700, 07}, /* AFSDIR_SERVER_DB_DIRPATH */ - {NULL, 1,1, 0700, 07}, /* AFSDIR_SERVER_LOCAL_DIRPATH */ - {NULL, 0,1, 0600, 07}, /* AFSDIR_SERVER_KEY_FILEPATH */ - {NULL, 0,1, 0600, 03}};/* AFSDIR_SERVER_ULIST_FILEPATH */ + {NULL, 1, 1, 0755, 02}, /* AFSDIR_SERVER_AFS_DIRPATH */ + {NULL, 1, 1, 0755, 02}, /* AFSDIR_SERVER_ETC_DIRPATH */ + {NULL, 1, 1, 0755, 02}, /* AFSDIR_SERVER_BIN_DIRPATH */ + {NULL, 1, 1, 0755, 02}, /* AFSDIR_SERVER_LOGS_DIRPATH */ + {NULL, 1, 0, 0700, 07}, /* AFSDIR_SERVER_BACKUP_DIRPATH */ + {NULL, 1, 1, 0700, 07}, /* AFSDIR_SERVER_DB_DIRPATH */ + {NULL, 1, 1, 0700, 07}, /* AFSDIR_SERVER_LOCAL_DIRPATH */ + {NULL, 0, 1, 0600, 07}, /* AFSDIR_SERVER_KEY_FILEPATH */ + {NULL, 0, 1, 0600, 03} +}; /* AFSDIR_SERVER_ULIST_FILEPATH */ int bozo_nbosEntryStats = sizeof(bozo_bosEntryStats) / sizeof(bozo_bosEntryStats[0]); @@ -1207,42 +1344,46 @@ int bozo_nbosEntryStats = * the path names require procedural as opposed to static initialization. * The other fields in the struct are however, statically initialized. */ -int initBosEntryStats() +int +initBosEntryStats() { - bozo_bosEntryStats[0].path = AFSDIR_SERVER_AFS_DIRPATH; - bozo_bosEntryStats[1].path = AFSDIR_SERVER_ETC_DIRPATH; - bozo_bosEntryStats[2].path = AFSDIR_SERVER_BIN_DIRPATH; - bozo_bosEntryStats[3].path = AFSDIR_SERVER_LOGS_DIRPATH; - bozo_bosEntryStats[4].path = AFSDIR_SERVER_BACKUP_DIRPATH; - bozo_bosEntryStats[5].path = AFSDIR_SERVER_DB_DIRPATH; - bozo_bosEntryStats[6].path = AFSDIR_SERVER_LOCAL_DIRPATH; - bozo_bosEntryStats[7].path = AFSDIR_SERVER_KEY_FILEPATH; - bozo_bosEntryStats[8].path = AFSDIR_SERVER_ULIST_FILEPATH; - - return 0; + bozo_bosEntryStats[0].path = AFSDIR_SERVER_AFS_DIRPATH; + bozo_bosEntryStats[1].path = AFSDIR_SERVER_ETC_DIRPATH; + bozo_bosEntryStats[2].path = AFSDIR_SERVER_BIN_DIRPATH; + bozo_bosEntryStats[3].path = AFSDIR_SERVER_LOGS_DIRPATH; + bozo_bosEntryStats[4].path = AFSDIR_SERVER_BACKUP_DIRPATH; + bozo_bosEntryStats[5].path = AFSDIR_SERVER_DB_DIRPATH; + bozo_bosEntryStats[6].path = AFSDIR_SERVER_LOCAL_DIRPATH; + bozo_bosEntryStats[7].path = AFSDIR_SERVER_KEY_FILEPATH; + bozo_bosEntryStats[8].path = AFSDIR_SERVER_ULIST_FILEPATH; + + return 0; } + /* StatEachEntry - If it's not there, it is okay. If anything else goes wrong * complain. Otherwise check permissions: shouldn't allow write or (usually) * read. */ -static int StatEachEntry (stats) - IN struct bozo_bosEntryStats *stats; +static int +StatEachEntry(stats) + IN struct bozo_bosEntryStats *stats; { struct stat info; - if (stat (stats->path, &info)) { - if (errno == ENOENT) return 1; /* no such entry: just ignore it */ - return 0; /* something else went wrong */ + if (stat(stats->path, &info)) { + if (errno == ENOENT) + return 1; /* no such entry: just ignore it */ + return 0; /* something else went wrong */ } else { - int rights; + int rights; if (((info.st_mode & S_IFDIR) != 0) != stats->dir) - return 0; /* not expected type */ + return 0; /* not expected type */ if (stats->rootOwner && (info.st_uid != 0)) - return 0; /* not owned by root */ + return 0; /* not owned by root */ rights = (info.st_mode & 0000777); if ((rights & stats->reqPerm) != stats->reqPerm) - return 0; /* required permissions not present */ + return 0; /* required permissions not present */ if ((rights & stats->proPerm) != 0) - return 0; /* prohibited permissions present */ + return 0; /* prohibited permissions present */ } return 1; } @@ -1251,7 +1392,8 @@ static int StatEachEntry (stats) * returns 0 if some are not OK and 1 otherwise. For efficiency, it doesn't do * this check more often than every 5 seconds. */ -int DirAccessOK () +int +DirAccessOK() { #ifdef AFS_NT40_ENV /* underlying filesystem may not support directory protection */ @@ -1263,60 +1405,61 @@ int DirAccessOK () int result; int i; - if ((now-lastTime) < 5) return lastResult; + if ((now - lastTime) < 5) + return lastResult; lastTime = now; result = 1; - for (i=0; ipath, - e->dir ? "dir" : "file", - e->reqPerm, - e->proPerm, + e->path, e->dir ? "dir" : "file", e->reqPerm, e->proPerm, e->rootOwner ? ", owned by root" : ""); result = 0; break; } } - if (result != lastResult) { /* log changes */ - bozo_Log ("Server directory access is %sokay\n", - (result ? "" : "not ")); + if (result != lastResult) { /* log changes */ + bozo_Log("Server directory access is %sokay\n", + (result ? "" : "not ")); } lastResult = result; return lastResult; #endif /* AFS_NT40_ENV */ } -int GetRequiredDirPerm (path) - IN char *path; +int +GetRequiredDirPerm(path) + IN char *path; { int i; - for (i=0; itype) strcpy(*atype, tb->type->name); else - (*atype)[0] = 0; /* null string */ + (*atype)[0] = 0; /* null string */ memset(astatus, 0, sizeof(struct bozo_status)); /* good defaults */ astatus->goal = tb->goal; astatus->fileGoal = tb->fileGoal; @@ -1335,24 +1478,27 @@ afs_int32 SBOZO_GetInstanceInfo(acall, ainstance, atype, astatus) return 0; } -afs_int32 SBOZO_GetInstanceParm(acall, ainstance, anum, aparm) -struct rx_call *acall; -char *ainstance; -afs_int32 anum; -char **aparm; { +afs_int32 +SBOZO_GetInstanceParm(acall, ainstance, anum, aparm) + struct rx_call *acall; + char *ainstance; + afs_int32 anum; + char **aparm; +{ register struct bnode *tb; register char *tp; register afs_int32 code; - - tp = (char *) malloc(BOZO_BSSIZE); + + tp = (char *)malloc(BOZO_BSSIZE); *aparm = tp; - *tp = 0; /* null-terminate string in error case */ + *tp = 0; /* null-terminate string in error case */ tb = bnode_FindInstance(ainstance); - if (!tb) return BZNOENT; + if (!tb) + return BZNOENT; bnode_Hold(tb); if (anum == 999) { if (tb->notifier) { - memcpy(tp, tb->notifier, strlen(tb->notifier)+1); + memcpy(tp, tb->notifier, strlen(tb->notifier) + 1); code = 0; } else code = BZNOENT; /* XXXXX */ @@ -1364,9 +1510,11 @@ char **aparm; { return code; } -afs_int32 SBOZO_GetLog(acall, aname) -register struct rx_call *acall; -char *aname; { +afs_int32 +SBOZO_GetLog(acall, aname) + register struct rx_call *acall; + char *aname; +{ register afs_int32 code; FILE *tfile; int tc; @@ -1377,15 +1525,15 @@ char *aname; { /* Check access since 'aname' could specify a file outside of the * AFS log directory (which is bosserver's working directory). */ - if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - code = BZACCESS; - goto fail; + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { + code = BZACCESS; + goto fail; } #ifdef BOS_RESTRICTED_MODE - if (bozo_isrestricted && strchr(aname, '/') && - strcmp(aname, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH)) { - code = BZACCESS; - goto fail; + if (bozo_isrestricted && strchr(aname, '/') + && strcmp(aname, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH)) { + code = BZACCESS; + goto fail; } #endif @@ -1393,7 +1541,8 @@ char *aname; { if (ConstructLocalLogPath(aname, &logpath)) { return BZNOENT; } - if (DoLogging) bozo_Log("%s is executing GetLog '%s'\n", caller, logpath); + if (DoLogging) + bozo_Log("%s is executing GetLog '%s'\n", caller, logpath); tfile = fopen(logpath, "r"); free(logpath); @@ -1403,8 +1552,10 @@ char *aname; { while (1) { tc = getc(tfile); - if (tc == 0) continue; /* our termination condition on other end */ - if (tc == EOF) break; + if (tc == 0) + continue; /* our termination condition on other end */ + if (tc == EOF) + break; buffer = tc; if (rx_Write(acall, &buffer, 1) != 1) { fclose(tfile); @@ -1418,98 +1569,107 @@ char *aname; { /* write out the end delimeter */ buffer = 0; - if (rx_Write(acall, &buffer, 1) != 1) return BZNET; + if (rx_Write(acall, &buffer, 1) != 1) + return BZNET; code = 0; fail: - osi_auditU( acall, BOS_GetLogsEvent, code, AUD_END); + osi_auditU(acall, BOS_GetLogsEvent, code, AUD_END); return code; } -afs_int32 SBOZO_GetInstanceStrings(acall, abnodeName, as1, as2, as3, as4) -struct rx_call *acall; -char *abnodeName; -char **as1, **as2, **as3, **as4; { +afs_int32 +SBOZO_GetInstanceStrings(acall, abnodeName, as1, as2, as3, as4) + struct rx_call *acall; + char *abnodeName; + char **as1, **as2, **as3, **as4; +{ register struct bnode *tb; - *as2 = (char *) malloc(1); + *as2 = (char *)malloc(1); **as2 = 0; - *as3 = (char *) malloc(1); + *as3 = (char *)malloc(1); **as3 = 0; - *as4 = (char *) malloc(1); + *as4 = (char *)malloc(1); **as4 = 0; tb = bnode_FindInstance(abnodeName); - if (!tb) goto fail; + if (!tb) + goto fail; /* now, return the appropriate error string, if any */ if (tb->lastErrorName) { - *as1 = (char *) malloc(strlen(tb->lastErrorName)+1); + *as1 = (char *)malloc(strlen(tb->lastErrorName) + 1); strcpy(*as1, tb->lastErrorName); - } - else { - *as1 = (char *) malloc(1); + } else { + *as1 = (char *)malloc(1); **as1 = 0; } return 0; fail: - *as1 = (char *) malloc(1); + *as1 = (char *)malloc(1); **as1 = 0; return BZNOENT; } #ifdef BOS_RESTRICTED_MODE -afs_int32 SBOZO_GetRestrictedMode(acall, arestmode) -struct rx_call *acall; -afs_int32 *arestmode; +afs_int32 +SBOZO_GetRestrictedMode(acall, arestmode) + struct rx_call *acall; + afs_int32 *arestmode; { - *arestmode=bozo_isrestricted; - return 0; + *arestmode = bozo_isrestricted; + return 0; } -afs_int32 SBOZO_SetRestrictedMode(acall, arestmode) -struct rx_call *acall; -afs_int32 arestmode; +afs_int32 +SBOZO_SetRestrictedMode(acall, arestmode) + struct rx_call *acall; + afs_int32 arestmode; { - afs_int32 code; - char caller[MAXKTCNAMELEN]; - - if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { - return BZACCESS; - } - if (bozo_isrestricted) { - return BZACCESS; - } - if (arestmode !=0 && arestmode !=1) { - return BZDOM; - } - bozo_isrestricted=arestmode; - code = WriteBozoFile(0); - fail: - return code; + afs_int32 code; + char caller[MAXKTCNAMELEN]; + + if (!afsconf_SuperUser(bozo_confdir, acall, caller)) { + return BZACCESS; + } + if (bozo_isrestricted) { + return BZACCESS; + } + if (arestmode != 0 && arestmode != 1) { + return BZDOM; + } + bozo_isrestricted = arestmode; + code = WriteBozoFile(0); + fail: + return code; } #else -afs_int32 SBOZO_GetRestrictedMode(acall, arestmode) -struct rx_call *acall; -afs_int32 *arestmode; +afs_int32 +SBOZO_GetRestrictedMode(acall, arestmode) + struct rx_call *acall; + afs_int32 *arestmode; { - return RXGEN_OPCODE; + return RXGEN_OPCODE; } -afs_int32 SBOZO_SetRestrictedMode(acall, arestmode) -struct rx_call *acall; -afs_int32 arestmode; +afs_int32 +SBOZO_SetRestrictedMode(acall, arestmode) + struct rx_call *acall; + afs_int32 arestmode; { - return RXGEN_OPCODE; + return RXGEN_OPCODE; } #endif -void bozo_ShutdownAndExit(int asignal) +void +bozo_ShutdownAndExit(int asignal) { int code; - bozo_Log("Shutdown of BOS server and processes in response to signal %d\n", - asignal); + bozo_Log + ("Shutdown of BOS server and processes in response to signal %d\n", + asignal); /* start shutdown of all processes */ if ((code = bnode_ApplyInstance(sdproc, NULL)) == 0) { diff --git a/src/bozo/bosserver.c b/src/bozo/bosserver.c index b6ec651d5..b78484957 100644 --- a/src/bozo/bosserver.c +++ b/src/bozo/bosserver.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -41,7 +42,7 @@ RCSID("$Header$"); #include #include #include -#include /* signal(), kill(), wait(), etc. */ +#include /* signal(), kill(), wait(), etc. */ #if defined(AFS_SGI_ENV) #include #endif @@ -60,7 +61,7 @@ static char *bozo_pid; struct rx_securityClass *bozo_rxsc[3]; const char *bozo_fileName; FILE *bozo_logFile; -extern int rx_stackSize; /* for rx_SetStackSize macro */ +extern int rx_stackSize; /* for rx_SetStackSize macro */ int DoLogging = 0; int DoSyslog = 0; @@ -73,14 +74,15 @@ static afs_int32 nextDay; struct ktime bozo_nextRestartKT, bozo_nextDayKT; int bozo_newKTs; #ifdef BOS_RESTRICTED_MODE -int bozo_isrestricted=0; -int bozo_restdisable=0; +int bozo_isrestricted = 0; +int bozo_restdisable = 0; -void bozo_insecureme(int sig) +void +bozo_insecureme(int sig) { - signal(SIGFPE, bozo_insecureme); - bozo_isrestricted=0; - bozo_restdisable=1; + signal(SIGFPE, bozo_insecureme); + bozo_isrestricted = 0; + bozo_restdisable = 1; } #endif @@ -89,13 +91,15 @@ struct bztemp { }; /* check whether caller is authorized to manage RX statistics */ -int bozo_rxstat_userok(struct rx_call *call) +int +bozo_rxstat_userok(struct rx_call *call) { return afsconf_SuperUser(bozo_confdir, call, NULL); } /* restart bozo process */ -int bozo_ReBozo() +int +bozo_ReBozo() { #ifdef AFS_NT40_ENV /* exit with restart code; SCM integrator process will restart bosserver */ @@ -128,12 +132,11 @@ int bozo_ReBozo() argv[i] = "-log"; i++; } - #ifndef AFS_NT40_ENV /* if syslog logging is on, pass "-syslog" to new bosserver */ if (DoSyslog) { - char *arg=(char *)malloc(40); /* enough for -syslog=# */ - if ( DoSyslogFacility != LOG_DAEMON ) { + char *arg = (char *)malloc(40); /* enough for -syslog=# */ + if (DoSyslogFacility != LOG_DAEMON) { snprintf(arg, 40, "-syslog=%d", DoSyslogFacility); } else { strcpy(arg, "-syslog"); @@ -151,21 +154,23 @@ int bozo_ReBozo() close(i); } - execv(argv[0], argv); /* should not return */ + execv(argv[0], argv); /* should not return */ _exit(1); #endif /* AFS_NT40_ENV */ } /* make sure a dir exists */ -static int MakeDir(register char *adir) +static int +MakeDir(register char *adir) { struct stat tstat; register afs_int32 code; if (stat(adir, &tstat) < 0 || (tstat.st_mode & S_IFMT) != S_IFDIR) { int reqPerm; unlink(adir); - reqPerm = GetRequiredDirPerm (adir); - if (reqPerm == -1) reqPerm = 0777; + reqPerm = GetRequiredDirPerm(adir); + if (reqPerm == -1) + reqPerm = 0777; #ifdef AFS_NT40_ENV /* underlying filesystem may not support directory protection */ code = mkdir(adir); @@ -178,64 +183,77 @@ static int MakeDir(register char *adir) } /* create all the bozo dirs */ -static int CreateDirs() +static int +CreateDirs() { - if ((!strncmp(AFSDIR_USR_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH, - strlen(AFSDIR_USR_DIRPATH))) || - (!strncmp(AFSDIR_USR_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH, - strlen(AFSDIR_USR_DIRPATH)))) { + if ((!strncmp + (AFSDIR_USR_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH, + strlen(AFSDIR_USR_DIRPATH))) + || + (!strncmp + (AFSDIR_USR_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH, + strlen(AFSDIR_USR_DIRPATH)))) { MakeDir(AFSDIR_USR_DIRPATH); } - if (!strncmp(AFSDIR_SERVER_AFS_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH, - strlen(AFSDIR_SERVER_AFS_DIRPATH))) { + if (!strncmp + (AFSDIR_SERVER_AFS_DIRPATH, AFSDIR_SERVER_BIN_DIRPATH, + strlen(AFSDIR_SERVER_AFS_DIRPATH))) { MakeDir(AFSDIR_SERVER_AFS_DIRPATH); } MakeDir(AFSDIR_SERVER_BIN_DIRPATH); - MakeDir(AFSDIR_SERVER_ETC_DIRPATH); + MakeDir(AFSDIR_SERVER_ETC_DIRPATH); MakeDir(AFSDIR_SERVER_LOCAL_DIRPATH); - MakeDir(AFSDIR_SERVER_DB_DIRPATH); + MakeDir(AFSDIR_SERVER_DB_DIRPATH); MakeDir(AFSDIR_SERVER_LOGS_DIRPATH); #ifndef AFS_NT40_ENV - if (!strncmp(AFSDIR_CLIENT_VICE_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH, - strlen(AFSDIR_CLIENT_VICE_DIRPATH))) { + if (!strncmp + (AFSDIR_CLIENT_VICE_DIRPATH, AFSDIR_CLIENT_ETC_DIRPATH, + strlen(AFSDIR_CLIENT_VICE_DIRPATH))) { MakeDir(AFSDIR_CLIENT_VICE_DIRPATH); } MakeDir(AFSDIR_CLIENT_ETC_DIRPATH); - symlink(AFSDIR_SERVER_THISCELL_FILEPATH, AFSDIR_CLIENT_THISCELL_FILEPATH); - symlink(AFSDIR_SERVER_CELLSERVDB_FILEPATH, AFSDIR_CLIENT_CELLSERVDB_FILEPATH); + symlink(AFSDIR_SERVER_THISCELL_FILEPATH, AFSDIR_CLIENT_THISCELL_FILEPATH); + symlink(AFSDIR_SERVER_CELLSERVDB_FILEPATH, + AFSDIR_CLIENT_CELLSERVDB_FILEPATH); #endif /* AFS_NT40_ENV */ return 0; } /* strip the \\n from the end of the line, if it is present */ -static int StripLine(register char *abuffer) +static int +StripLine(register char *abuffer) { register char *tp; - - tp = abuffer + strlen(abuffer); /* starts off pointing at the null */ - if(tp == abuffer) return 0; /* null string, no last character to check */ - tp--; /* aim at last character */ - if (*tp == '\n') *tp = 0; + + tp = abuffer + strlen(abuffer); /* starts off pointing at the null */ + if (tp == abuffer) + return 0; /* null string, no last character to check */ + tp--; /* aim at last character */ + if (*tp == '\n') + *tp = 0; return 0; } /* write one bnode's worth of entry into the file */ -static bzwrite(register struct bnode *abnode, register struct bztemp *at) +static +bzwrite(register struct bnode *abnode, register struct bztemp *at) { register int i; char tbuffer[BOZO_BSSIZE]; register afs_int32 code; if (abnode->notifier) - fprintf(at->file, "bnode %s %s %d %s\n", - abnode->type->name, abnode->name, abnode->fileGoal, abnode->notifier); + fprintf(at->file, "bnode %s %s %d %s\n", abnode->type->name, + abnode->name, abnode->fileGoal, abnode->notifier); else - fprintf(at->file, "bnode %s %s %d\n", abnode->type->name, abnode->name, abnode->fileGoal); - for(i=0;;i++) { + fprintf(at->file, "bnode %s %s %d\n", abnode->type->name, + abnode->name, abnode->fileGoal); + for (i = 0;; i++) { code = bnode_GetParm(abnode, i, tbuffer, BOZO_BSSIZE); if (code) { - if (code != BZDOM) return code; + if (code != BZDOM) + return code; break; } fprintf(at->file, "parm %s\n", tbuffer); @@ -245,7 +263,8 @@ static bzwrite(register struct bnode *abnode, register struct bztemp *at) } #define MAXPARMS 20 -int ReadBozoFile(char *aname) +int +ReadBozoFile(char *aname) { register FILE *tfile; char tbuffer[BOZO_BSSIZE]; @@ -265,54 +284,60 @@ int ReadBozoFile(char *aname) /* if BozoInit exists and BosConfig doesn't, try a rename */ if (access(AFSDIR_SERVER_BOZINIT_FILEPATH, 0) == 0 && access(AFSDIR_SERVER_BOZCONF_FILEPATH, 0) != 0) { - code = renamefile(AFSDIR_SERVER_BOZINIT_FILEPATH, AFSDIR_SERVER_BOZCONF_FILEPATH); + code = + renamefile(AFSDIR_SERVER_BOZINIT_FILEPATH, + AFSDIR_SERVER_BOZCONF_FILEPATH); if (code < 0) perror("bosconfig rename"); } #ifdef BOS_NEW_CONFIG if (access(AFSDIR_SERVER_BOZCONFNEW_FILEPATH, 0) == 0) { - code = renamefile(AFSDIR_SERVER_BOZCONFNEW_FILEPATH, - AFSDIR_SERVER_BOZCONF_FILEPATH); - if (code < 0) - perror("bosconfig rename"); + code = + renamefile(AFSDIR_SERVER_BOZCONFNEW_FILEPATH, + AFSDIR_SERVER_BOZCONF_FILEPATH); + if (code < 0) + perror("bosconfig rename"); } -#endif +#endif } /* setup default times we want to do restarts */ bozo_nextRestartKT.mask = KTIME_HOUR | KTIME_MIN | KTIME_DAY; - bozo_nextRestartKT.hour = 4; /* 4 am */ + bozo_nextRestartKT.hour = 4; /* 4 am */ bozo_nextRestartKT.min = 0; - bozo_nextRestartKT.day = 0; /* Sunday */ + bozo_nextRestartKT.day = 0; /* Sunday */ bozo_nextDayKT.mask = KTIME_HOUR | KTIME_MIN; bozo_nextDayKT.hour = 5; bozo_nextDayKT.min = 0; - for(code=0;codefileGoal != BSTAT_NORMAL || abnode->goal != BSTAT_NORMAL) - return 0; /* don't restart stopped bnodes */ + return 0; /* don't restart stopped bnodes */ bnode_Hold(abnode); code = bnode_RestartP(abnode); if (code) { @@ -469,15 +506,16 @@ static int bdrestart(register struct bnode *abnode, char *arock) bnode_SetStat(abnode, BSTAT_NORMAL); } bnode_Release(abnode); - return 0; /* keep trying all bnodes */ + return 0; /* keep trying all bnodes */ } -#define BOZO_MINSKIP 3600 /* minimum to advance clock */ +#define BOZO_MINSKIP 3600 /* minimum to advance clock */ /* lwp to handle system restarts */ -static int BozoDaemon() +static int +BozoDaemon() { register afs_int32 now; - + /* now initialize the values */ bozo_newKTs = 1; while (1) { @@ -486,8 +524,8 @@ static int BozoDaemon() #ifdef BOS_RESTRICTED_MODE if (bozo_restdisable) { - bozo_Log("Restricted mode disabled by signal\n"); - bozo_restdisable=0; + bozo_Log("Restricted mode disabled by signal\n"); + bozo_restdisable = 0; } #endif if (bozo_newKTs) { /* need to recompute restart times */ @@ -500,11 +538,11 @@ static int BozoDaemon() if (now > nextRestart) { SBOZO_ReBozo(0); /* doesn't come back */ } - + /* see if we should restart a server */ if (now > nextDay) { nextDay = ktime_next(&bozo_nextDayKT, BOZO_MINSKIP); - + /* call the bnode restartp function, and restart all that require it */ bnode_ApplyInstance(bdrestart, 0); } @@ -512,7 +550,8 @@ static int BozoDaemon() } #ifdef AFS_AIX32_ENV -static int tweak_config() +static int +tweak_config() { FILE *f; char c[80]; @@ -523,20 +562,21 @@ static int tweak_config() f = popen("/usr/sbin/no -o sb_max", "r"); s = fscanf(f, "sb_max = %d", &sb_max); fclose(f); - if (s < 1) + if (s < 1) return; f = popen("/usr/sbin/no -o ipfragttl", "r"); s = fscanf(f, "ipfragttl = %d", &ipfragttl); fclose(f); - if (s < 1) + if (s < 1) ipfragttl = 20; - if (sb_max < 131072) + if (sb_max < 131072) sb_max = 131072; if (ipfragttl > 20) ipfragttl = 20; - - sprintf(c, "/usr/sbin/no -o sb_max=%d -o ipfragttl=%d", sb_max, ipfragttl); + + sprintf(c, "/usr/sbin/no -o sb_max=%d -o ipfragttl=%d", sb_max, + ipfragttl); f = popen(c, "r"); fclose(f); } @@ -571,7 +611,8 @@ static int tweak_config() */ #ifndef AFS_NT40_ENV -static void background(void) +static void +background(void) { /* * A process is a process group leader if its process ID @@ -587,18 +628,18 @@ static void background(void) */ if (getpid() == getpgrp()) { - pid_t pid; - pid = fork(); - switch(pid) { - case -1: - abort(); /* leave footprints */ - break; - case 0: /* child */ - break; - default: /* parent */ - exit(0); - break; - } + pid_t pid; + pid = fork(); + switch (pid) { + case -1: + abort(); /* leave footprints */ + break; + case 0: /* child */ + break; + default: /* parent */ + exit(0); + break; + } } /* @@ -607,12 +648,12 @@ static void background(void) */ { - pid_t sid = setsid(); + pid_t sid = setsid(); - if (sid == -1) { - static char err[] = "bosserver: WARNING: setsid() failed\n"; - write(STDERR_FILENO, err, sizeof err - 1); - } + if (sid == -1) { + static char err[] = "bosserver: WARNING: setsid() failed\n"; + write(STDERR_FILENO, err, sizeof err - 1); + } } /* @@ -630,18 +671,18 @@ static void background(void) */ if (getpid() == getpgrp()) { - pid_t pid; - pid = fork(); - switch(pid) { - case -1: - abort(); /* leave footprints */ - break; - case 0: /* child */ - break; - default: /* parent */ - exit(0); - break; - } + pid_t pid; + pid = fork(); + switch (pid) { + case -1: + abort(); /* leave footprints */ + break; + case 0: /* child */ + break; + default: /* parent */ + exit(0); + break; + } } /* @@ -649,15 +690,16 @@ static void background(void) */ { - int fd; + int fd; - fd = open("/dev/tty", O_RDONLY); + fd = open("/dev/tty", O_RDONLY); - if (fd >= 0) { - static char err[] = "bosserver: WARNING: /dev/tty still attached\n"; - close(fd); - write(STDERR_FILENO, err, sizeof err - 1); - } + if (fd >= 0) { + static char err[] = + "bosserver: WARNING: /dev/tty still attached\n"; + close(fd); + write(STDERR_FILENO, err, sizeof err - 1); + } } } #endif /* ! AFS_NT40_ENV */ @@ -666,7 +708,8 @@ static void background(void) #include "AFS_component_version_number.c" -int main (int argc, char **argv, char **envp) +int +main(int argc, char **argv, char **envp) { struct rx_service *tservice; register afs_int32 code; @@ -717,7 +760,8 @@ int main (int argc, char **argv, char **envp) #ifdef AFS_NT40_ENV ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0); #endif - fprintf(stderr, "%s: Unable to obtain AFS server directory.\n", argv[0]); + fprintf(stderr, "%s: Unable to obtain AFS server directory.\n", + argv[0]); exit(2); } @@ -737,37 +781,33 @@ int main (int argc, char **argv, char **envp) #endif /* parse cmd line */ - for(code=1;code=10) { + if (i >= 10) { bozo_Log("Bos giving up, can't initialize rx\n"); exit(code); } code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1, - (void *) /*parm*/0, "bozo-the-clown", &bozo_pid); + (void *) /*parm */ 0, "bozo-the-clown", + &bozo_pid); /* try to read the key from the config file */ tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); @@ -881,21 +921,28 @@ int main (int argc, char **argv, char **envp) exit(1); } memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr)); /* not computed */ - code = afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH, &tcell); + code = + afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH, + &tcell); if (code) { - bozo_Log("could not create cell database in '%s' (code %d), quitting\n", AFSDIR_SERVER_ETC_DIRPATH, code); + bozo_Log + ("could not create cell database in '%s' (code %d), quitting\n", + AFSDIR_SERVER_ETC_DIRPATH, code); exit(1); } tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); if (!tdir) { - bozo_Log("failed to open newly-created cell database, quitting\n"); + bozo_Log + ("failed to open newly-created cell database, quitting\n"); exit(1); } } /* read init file, starting up programs */ - if (code=ReadBozoFile(0)) { - bozo_Log("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n", code, AFSDIR_SERVER_BOZCONF_FILEPATH); + if (code = ReadBozoFile(0)) { + bozo_Log + ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n", + code, AFSDIR_SERVER_BOZCONF_FILEPATH); exit(code); } @@ -911,28 +958,32 @@ int main (int argc, char **argv, char **envp) afsconf_SetNoAuthFlag(tdir, noAuth); bozo_rxsc[0] = rxnull_NewServerSecurityObject(); - bozo_rxsc[1] = (struct rx_securityClass *) 0; - bozo_rxsc[2] = rxkad_NewServerSecurityObject( - 0, tdir, afsconf_GetKey, NULL); + bozo_rxsc[1] = (struct rx_securityClass *)0; + bozo_rxsc[2] = + rxkad_NewServerSecurityObject(0, tdir, afsconf_GetKey, NULL); /* Disable jumbograms */ rx_SetNoJumbo(); - tservice = rx_NewService(/* port */ 0, /* service id */ 1, - /*service name */ "bozo", /* security classes */ bozo_rxsc, - /* numb sec classes */ 3, BOZO_ExecuteRequest); + tservice = rx_NewService( /* port */ 0, /* service id */ 1, + /*service name */ "bozo", + /* security classes */ + bozo_rxsc, + /* numb sec classes */ 3, BOZO_ExecuteRequest); rx_SetMinProcs(tservice, 2); rx_SetMaxProcs(tservice, 4); - rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE); /* so gethostbyname works (in cell stuff) */ + rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE); /* so gethostbyname works (in cell stuff) */ - tservice = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", bozo_rxsc, - 3, RXSTATS_ExecuteRequest); + tservice = + rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", bozo_rxsc, 3, + RXSTATS_ExecuteRequest); rx_SetMinProcs(tservice, 2); rx_SetMaxProcs(tservice, 4); - rx_StartServer(1); /* donate this process */ + rx_StartServer(1); /* donate this process */ } -void bozo_Log(char *a, char *b, char *c, char *d, char *e, char *f) +void +bozo_Log(char *a, char *b, char *c, char *d, char *e, char *f) { char tdate[26]; time_t myTime; @@ -948,9 +999,10 @@ void bozo_Log(char *a, char *b, char *c, char *d, char *e, char *f) /* log normally closed, so can be removed */ - bozo_logFile=fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a"); - if(bozo_logFile == NULL) { - printf("bosserver: WARNING: problem with %s", AFSDIR_SERVER_BOZLOG_FILEPATH); + bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a"); + if (bozo_logFile == NULL) { + printf("bosserver: WARNING: problem with %s", + AFSDIR_SERVER_BOZLOG_FILEPATH); fflush(stdout); } @@ -962,7 +1014,7 @@ void bozo_Log(char *a, char *b, char *c, char *d, char *e, char *f) printf("%s ", tdate); printf(a, b, c, d, e, f); } - + /* close so rm BosLog works */ fclose(bozo_logFile); } diff --git a/src/bozo/cronbnodeops.c b/src/bozo/cronbnodeops.c index b9aab0b73..ecf0e6aea 100644 --- a/src/bozo/cronbnodeops.c +++ b/src/bozo/cronbnodeops.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -33,7 +34,7 @@ RCSID("$Header$"); #include #include -#include /* signal(), kill(), wait(), etc. */ +#include /* signal(), kill(), wait(), etc. */ #include "bnode.h" static int cron_timeout(), cron_getstat(), cron_setstat(), cron_delete(); @@ -42,7 +43,7 @@ static int cron_hascore(); struct bnode *cron_create(); extern char *ktime_DateOf(); -#define SDTIME 60 /* time in seconds given to a process to evaporate */ +#define SDTIME 60 /* time in seconds given to a process to evaporate */ struct bnode_ops cronbnode_ops = { cron_create, @@ -56,36 +57,41 @@ struct bnode_ops cronbnode_ops = { cron_restartp, cron_hascore, }; - + struct cronbnode { struct bnode b; afs_int32 zapTime; /* time we sent a sigterm */ char *command; char *whenString; /* string rep. of when to run */ struct bnode_proc *proc; - afs_int32 lastStart; /* time last started process */ + afs_int32 lastStart; /* time last started process */ afs_int32 nextRun; /* next time to run, if no proc running */ struct ktime whenToRun; /* high-level rep of when should we run this guy */ - afs_int32 when; /* computed at creation time and procexit time */ + afs_int32 when; /* computed at creation time and procexit time */ char everRun; /* true if ever ran */ char waitingForShutdown; /* have we started any shutdown procedure? */ - char running; /* is process running? */ - char killSent; /* have we tried sigkill signal? */ + char running; /* is process running? */ + char killSent; /* have we tried sigkill signal? */ }; -static int cron_hascore(register struct ezbnode *abnode) { +static int +cron_hascore(register struct ezbnode *abnode) +{ char tbuffer[256]; bnode_CoreName(abnode, NULL, tbuffer); - if (access(tbuffer, 0) == 0) return 1; - else return 0; + if (access(tbuffer, 0) == 0) + return 1; + else + return 0; } /* run at creation or after process exit. figures out if we're all done (if a one shot run) or when we should run again. Sleeps until we should run again. Note that the computation of when we should run again is made in procexit and/or create procs. This guy only schedules the sleep */ -int ScheduleCronBnode(register struct cronbnode *abnode) +int +ScheduleCronBnode(register struct cronbnode *abnode) { register afs_int32 code; register afs_int32 temp; @@ -93,7 +99,7 @@ int ScheduleCronBnode(register struct cronbnode *abnode) /* If this proc is shutdown, tell bproc() to no longer run this job */ if (abnode->b.goal == BSTAT_SHUTDOWN) { - bnode_SetTimeout(abnode, 0); + bnode_SetTimeout(abnode, 0); return 0; } @@ -120,24 +126,27 @@ int ScheduleCronBnode(register struct cronbnode *abnode) abnode->proc = tp; return 0; } - } - else { + } else { /* run periodically */ - if (abnode->running) return 0; + if (abnode->running) + return 0; /* otherwise find out when to run it, and do it then */ temp = abnode->when - FT_ApproxTime(); - if (temp < 1) temp = 1; /* temp is when to start dude */ + if (temp < 1) + temp = 1; /* temp is when to start dude */ bnode_SetTimeout(abnode, temp); } return 0; } -static int cron_restartp (register struct cronbnode *abnode) +static int +cron_restartp(register struct cronbnode *abnode) { return 0; } -static int cron_delete(struct cronbnode *abnode) +static int +cron_delete(struct cronbnode *abnode) { free(abnode->command); free(abnode->whenString); @@ -145,7 +154,8 @@ static int cron_delete(struct cronbnode *abnode) return 0; } -struct bnode *cron_create(char *ainstance, char *acommand, char *awhen) +struct bnode * +cron_create(char *ainstance, char *acommand, char *awhen) { struct cronbnode *te; afs_int32 code; @@ -158,7 +168,7 @@ struct bnode *cron_create(char *ainstance, char *acommand, char *awhen) return NULL; } - te = (struct cronbnode *) malloc(sizeof(struct cronbnode)); + te = (struct cronbnode *)malloc(sizeof(struct cronbnode)); memset(te, 0, sizeof(struct cronbnode)); code = ktime_ParsePeriodic(awhen, &te->whenToRun); if ((code < 0) || (bnode_InitBnode(te, &cronbnode_ops, ainstance) != 0)) { @@ -169,19 +179,21 @@ struct bnode *cron_create(char *ainstance, char *acommand, char *awhen) te->when = ktime_next(&te->whenToRun, 0); te->command = cmdpath; te->whenString = copystr(awhen); - return (struct bnode *) te; + return (struct bnode *)te; } /* called to SIGKILL a process if it doesn't terminate normally. In cron, also start up a process if it is time and not already running */ -static int cron_timeout(struct cronbnode *abnode) +static int +cron_timeout(struct cronbnode *abnode) { register afs_int32 temp; register afs_int32 code; struct bnode_proc *tp; if (!abnode->running) { - if (abnode->when == 0) return 0; /* spurious timeout activation */ + if (abnode->when == 0) + return 0; /* spurious timeout activation */ /* not running, perhaps we should start it */ if (FT_ApproxTime() >= abnode->when) { abnode->lastStart = FT_ApproxTime(); @@ -195,16 +207,16 @@ static int cron_timeout(struct cronbnode *abnode) abnode->everRun = 1; abnode->running = 1; abnode->proc = tp; - } - else { + } else { /* woke up too early, try again */ temp = abnode->when - FT_ApproxTime(); - if (temp < 1) temp = 1; + if (temp < 1) + temp = 1; bnode_SetTimeout(abnode, temp); } - } - else { - if (!abnode->waitingForShutdown) return 0; /* spurious */ + } else { + if (!abnode->waitingForShutdown) + return 0; /* spurious */ /* send kill and turn off timer */ bnode_StopProc(abnode->proc, SIGKILL); abnode->killSent = 1; @@ -213,66 +225,71 @@ static int cron_timeout(struct cronbnode *abnode) return 0; } -static int cron_getstat(struct cronbnode *abnode, afs_int32 *astatus) +static int +cron_getstat(struct cronbnode *abnode, afs_int32 * astatus) { register afs_int32 temp; - if (abnode->waitingForShutdown) temp = BSTAT_SHUTTINGDOWN; - else if (abnode->b.goal == 0) temp = BSTAT_SHUTDOWN; + if (abnode->waitingForShutdown) + temp = BSTAT_SHUTTINGDOWN; + else if (abnode->b.goal == 0) + temp = BSTAT_SHUTDOWN; else if (abnode->everRun && abnode->when == 0 && !abnode->running) { /* special hack: bnode deletion won't happen if bnode is active, so - we make bnodes that are ready to be deleted automatically appear - as BSTAT_SHUTDOWN so bnode_Delete is happy. */ + * we make bnodes that are ready to be deleted automatically appear + * as BSTAT_SHUTDOWN so bnode_Delete is happy. */ temp = BSTAT_SHUTDOWN; - } - else temp = BSTAT_NORMAL; + } else + temp = BSTAT_NORMAL; *astatus = temp; return 0; } -static int cron_setstat(register struct cronbnode *abnode, afs_int32 astatus) +static int +cron_setstat(register struct cronbnode *abnode, afs_int32 astatus) { - if (abnode->waitingForShutdown) return BZBUSY; + if (abnode->waitingForShutdown) + return BZBUSY; if (astatus == BSTAT_SHUTDOWN) { - if (abnode->running) { - /* start shutdown */ - bnode_StopProc(abnode->proc, SIGTERM); - abnode->waitingForShutdown = 1; - bnode_SetTimeout(abnode, SDTIME); - /* When shutdown is complete, bproc() calls BOP_PROCEXIT() - * [cron_procexit()] which will tell bproc() to no longer - * run this cron job. - */ - } else { - /* Tell bproc() to no longer run this cron job */ - bnode_SetTimeout(abnode, 0); - } - } - else if (astatus == BSTAT_NORMAL) { - /* start the cron job + if (abnode->running) { + /* start shutdown */ + bnode_StopProc(abnode->proc, SIGTERM); + abnode->waitingForShutdown = 1; + bnode_SetTimeout(abnode, SDTIME); + /* When shutdown is complete, bproc() calls BOP_PROCEXIT() + * [cron_procexit()] which will tell bproc() to no longer + * run this cron job. + */ + } else { + /* Tell bproc() to no longer run this cron job */ + bnode_SetTimeout(abnode, 0); + } + } else if (astatus == BSTAT_NORMAL) { + /* start the cron job * Figure out when to run next and schedule it */ - abnode->when = ktime_next(&abnode->whenToRun, 0); + abnode->when = ktime_next(&abnode->whenToRun, 0); ScheduleCronBnode(abnode); } return 0; } -static int cron_procexit(struct cronbnode *abnode, struct bnode_proc *aproc) +static int +cron_procexit(struct cronbnode *abnode, struct bnode_proc *aproc) { /* process has exited */ /* log interesting errors for folks */ if (aproc->lastSignal) - bozo_Log("cron job %s exited due to signal %d\n", - abnode->b.name, aproc->lastSignal); + bozo_Log("cron job %s exited due to signal %d\n", abnode->b.name, + aproc->lastSignal); else if (aproc->lastExit) - bozo_Log("cron job %s exited with non-zero code %d\n", - abnode->b.name, aproc->lastExit); + bozo_Log("cron job %s exited with non-zero code %d\n", abnode->b.name, + aproc->lastExit); abnode->waitingForShutdown = 0; abnode->running = 0; abnode->killSent = 0; - abnode->proc = (struct bnode_proc *) 0; + abnode->proc = (struct bnode_proc *)0; /* Figure out when to run next and schedule it */ abnode->when = ktime_next(&abnode->whenToRun, 0); @@ -280,21 +297,27 @@ static int cron_procexit(struct cronbnode *abnode, struct bnode_proc *aproc) return 0; } -static int cron_getstring(struct cronbnode *abnode, char *abuffer, - afs_int32 alen) +static int +cron_getstring(struct cronbnode *abnode, char *abuffer, afs_int32 alen) { - if (abnode->running) strcpy(abuffer, "running now"); - else if (abnode->when==0) strcpy(abuffer, "waiting to run once"); - else sprintf(abuffer, "run next at %s", ktime_DateOf(abnode->when)); + if (abnode->running) + strcpy(abuffer, "running now"); + else if (abnode->when == 0) + strcpy(abuffer, "waiting to run once"); + else + sprintf(abuffer, "run next at %s", ktime_DateOf(abnode->when)); return 0; } -static int cron_getparm(struct cronbnode *abnode, afs_int32 aindex, char *abuffer, afs_int32 alen) +static int +cron_getparm(struct cronbnode *abnode, afs_int32 aindex, char *abuffer, + afs_int32 alen) { - if (aindex == 0) strcpy(abuffer, abnode->command); + if (aindex == 0) + strcpy(abuffer, abnode->command); else if (aindex == 1) { strcpy(abuffer, abnode->whenString); - } - else return BZDOM; + } else + return BZDOM; return 0; } diff --git a/src/bozo/ezbnodeops.c b/src/bozo/ezbnodeops.c index 4921b25cb..7852d9cbd 100644 --- a/src/bozo/ezbnodeops.c +++ b/src/bozo/ezbnodeops.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -30,7 +31,7 @@ RCSID("$Header$"); #include #include -#include /* signal(), kill(), wait(), etc. */ +#include /* signal(), kill(), wait(), etc. */ #include "bnode.h" static int ez_timeout(), ez_getstat(), ez_setstat(), ez_delete(); @@ -38,7 +39,7 @@ static int ez_procexit(), ez_getstring(), ez_getparm(), ez_restartp(); static int ez_hascore(); struct bnode *ez_create(); -#define SDTIME 60 /* time in seconds given to a process to evaporate */ +#define SDTIME 60 /* time in seconds given to a process to evaporate */ struct bnode_ops ezbnode_ops = { ez_create, @@ -53,43 +54,53 @@ struct bnode_ops ezbnode_ops = { ez_hascore, }; -static int ez_hascore(register struct ezbnode *abnode) +static int +ez_hascore(register struct ezbnode *abnode) { char tbuffer[256]; bnode_CoreName(abnode, NULL, tbuffer); - if (access(tbuffer, 0) == 0) return 1; - else return 0; + if (access(tbuffer, 0) == 0) + return 1; + else + return 0; } -static int ez_restartp (register struct ezbnode *abnode) +static int +ez_restartp(register struct ezbnode *abnode) { struct bnode_token *tt; register afs_int32 code; struct stat tstat; - + code = bnode_ParseLine(abnode->command, &tt); - if (code) return 0; - if (!tt) return 0; + if (code) + return 0; + if (!tt) + return 0; code = stat(tt->key, &tstat); if (code) { bnode_FreeTokens(tt); return 0; } - if (tstat.st_ctime > abnode->lastStart) code = 1; - else code = 0; + if (tstat.st_ctime > abnode->lastStart) + code = 1; + else + code = 0; bnode_FreeTokens(tt); return code; } -static int ez_delete(struct ezbnode *abnode) +static int +ez_delete(struct ezbnode *abnode) { free(abnode->command); free(abnode); return 0; } -struct bnode *ez_create(char *ainstance, char *acommand) +struct bnode * +ez_create(char *ainstance, char *acommand) { struct ezbnode *te; char *cmdpath; @@ -99,20 +110,22 @@ struct bnode *ez_create(char *ainstance, char *acommand) return NULL; } - te = (struct ezbnode *) malloc(sizeof(struct ezbnode)); + te = (struct ezbnode *)malloc(sizeof(struct ezbnode)); memset(te, 0, sizeof(struct ezbnode)); if (bnode_InitBnode(te, &ezbnode_ops, ainstance) != 0) { free(te); return NULL; } te->command = cmdpath; - return (struct bnode *) te; + return (struct bnode *)te; } /* called to SIGKILL a process if it doesn't terminate normally */ -static int ez_timeout(struct ezbnode *abnode) +static int +ez_timeout(struct ezbnode *abnode) { - if (!abnode->waitingForShutdown) return 0; /* spurious */ + if (!abnode->waitingForShutdown) + return 0; /* spurious */ /* send kill and turn off timer */ bnode_StopProc(abnode->proc, SIGKILL); abnode->killSent = 1; @@ -120,32 +133,38 @@ static int ez_timeout(struct ezbnode *abnode) return 0; } -static int ez_getstat(struct ezbnode *abnode, afs_int32 *astatus) +static int +ez_getstat(struct ezbnode *abnode, afs_int32 * astatus) { register afs_int32 temp; - if (abnode->waitingForShutdown) temp = BSTAT_SHUTTINGDOWN; - else if (abnode->running) temp = BSTAT_NORMAL; - else temp = BSTAT_SHUTDOWN; + if (abnode->waitingForShutdown) + temp = BSTAT_SHUTTINGDOWN; + else if (abnode->running) + temp = BSTAT_NORMAL; + else + temp = BSTAT_SHUTDOWN; *astatus = temp; return 0; } -static int ez_setstat(register struct ezbnode *abnode, afs_int32 astatus) +static int +ez_setstat(register struct ezbnode *abnode, afs_int32 astatus) { struct bnode_proc *tp; register afs_int32 code; - if (abnode->waitingForShutdown) return BZBUSY; + if (abnode->waitingForShutdown) + return BZBUSY; if (astatus == BSTAT_NORMAL && !abnode->running) { /* start up */ abnode->lastStart = FT_ApproxTime(); code = bnode_NewProc(abnode, abnode->command, NULL, &tp); - if (code) return code; + if (code) + return code; abnode->running = 1; abnode->proc = tp; return 0; - } - else if (astatus == BSTAT_SHUTDOWN && abnode->running) { + } else if (astatus == BSTAT_SHUTDOWN && abnode->running) { /* start shutdown */ bnode_StopProc(abnode->proc, SIGTERM); abnode->waitingForShutdown = 1; @@ -155,7 +174,8 @@ static int ez_setstat(register struct ezbnode *abnode, afs_int32 astatus) return 0; } -static int ez_procexit(struct ezbnode *abnode, struct bnode_proc *aproc) +static int +ez_procexit(struct ezbnode *abnode, struct bnode_proc *aproc) { /* process has exited */ register afs_int32 code; @@ -163,22 +183,27 @@ static int ez_procexit(struct ezbnode *abnode, struct bnode_proc *aproc) abnode->waitingForShutdown = 0; abnode->running = 0; abnode->killSent = 0; - abnode->proc = (struct bnode_proc *) 0; + abnode->proc = (struct bnode_proc *)0; bnode_SetTimeout(abnode, 0); /* clear timer */ if (abnode->b.goal) code = ez_setstat(abnode, BSTAT_NORMAL); - else code = 0; + else + code = 0; return code; } -static int ez_getstring(struct ezbnode *abnode, char *abuffer, afs_int32 alen) +static int +ez_getstring(struct ezbnode *abnode, char *abuffer, afs_int32 alen) { - return -1; /* don't have much to add */ + return -1; /* don't have much to add */ } -static ez_getparm(struct ezbnode *abnode, afs_int32 aindex, char *abuffer, afs_int32 alen) +static +ez_getparm(struct ezbnode *abnode, afs_int32 aindex, char *abuffer, + afs_int32 alen) { - if (aindex > 0) return BZDOM; + if (aindex > 0) + return BZDOM; strcpy(abuffer, abnode->command); return 0; } diff --git a/src/bozo/fsbnodeops.c b/src/bozo/fsbnodeops.c index 74676ada4..dc5589706 100644 --- a/src/bozo/fsbnodeops.c +++ b/src/bozo/fsbnodeops.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -36,7 +37,7 @@ RCSID("$Header$"); #endif /* AFS_NT40_ENV */ #include -#include /* signal(), kill(), wait(), etc. */ +#include /* signal(), kill(), wait(), etc. */ #include #include "bnode.h" @@ -54,8 +55,8 @@ static int emergency = 0; /* if this file exists, then we have to salvage the file system */ #define SALFILE "SALVAGE." -#define POLLTIME 20 /* for handling below */ -#define SDTIME 60 /* time in seconds given to a process to evaporate */ +#define POLLTIME 20 /* for handling below */ +#define SDTIME 60 /* time in seconds given to a process to evaporate */ /* basic rules: Normal operation involves having the file server and the vol server both running. @@ -88,35 +89,35 @@ struct bnode_ops fsbnode_ops = { fs_restartp, fs_hascore, }; - + struct fsbnode { struct bnode b; - afs_int32 timeSDStarted; /* time shutdown operation started */ - char *filecmd; /* command to start primary file server */ - char *volcmd; /* command to start secondary vol server */ - char *salcmd; /* command to start salvager */ - char *scancmd; /* command to start scanner (MR-AFS) */ - struct bnode_proc *fileProc; /* process for file server */ - struct bnode_proc *volProc; /* process for vol server */ - struct bnode_proc *salProc; /* process for salvager */ - struct bnode_proc *scanProc; /* process for scanner (MR-AFS) */ - afs_int32 lastFileStart; /* last start for file */ - afs_int32 lastVolStart; /* last start for vol */ - afs_int32 lastScanStart; /* last start for scanner (MR-AFS) */ - char fileRunning; /* file process is running */ - char volRunning; /* volser is running */ - char salRunning; /* salvager is running */ - char scanRunning; /* scanner is running (MR_AFS) */ - char fileSDW; /* file shutdown wait */ - char volSDW; /* vol shutdown wait */ - char salSDW; /* waiting for the salvager to shutdown */ - char scanSDW; /* scanner shutdown wait (MR_AFS) */ - char fileKillSent; /* kill signal has been sent */ + afs_int32 timeSDStarted; /* time shutdown operation started */ + char *filecmd; /* command to start primary file server */ + char *volcmd; /* command to start secondary vol server */ + char *salcmd; /* command to start salvager */ + char *scancmd; /* command to start scanner (MR-AFS) */ + struct bnode_proc *fileProc; /* process for file server */ + struct bnode_proc *volProc; /* process for vol server */ + struct bnode_proc *salProc; /* process for salvager */ + struct bnode_proc *scanProc; /* process for scanner (MR-AFS) */ + afs_int32 lastFileStart; /* last start for file */ + afs_int32 lastVolStart; /* last start for vol */ + afs_int32 lastScanStart; /* last start for scanner (MR-AFS) */ + char fileRunning; /* file process is running */ + char volRunning; /* volser is running */ + char salRunning; /* salvager is running */ + char scanRunning; /* scanner is running (MR_AFS) */ + char fileSDW; /* file shutdown wait */ + char volSDW; /* vol shutdown wait */ + char salSDW; /* waiting for the salvager to shutdown */ + char scanSDW; /* scanner shutdown wait (MR_AFS) */ + char fileKillSent; /* kill signal has been sent */ char volKillSent; char salKillSent; - char scanKillSent; /* kill signal has been sent (MR_AFS) */ - char needsSalvage; /* salvage before running */ - char needsClock; /* do we need clock ticks */ + char scanKillSent; /* kill signal has been sent (MR_AFS) */ + char needsSalvage; /* salvage before running */ + char needsClock; /* do we need clock ticks */ }; /* Function to tell whether this bnode has a core file or not. You might @@ -125,76 +126,96 @@ struct fsbnode { * there may not be an active process for a bnode that dumped core at the * time the query is done. */ -static int fs_hascore(register struct ezbnode *abnode) +static int +fs_hascore(register struct ezbnode *abnode) { char tbuffer[256]; /* see if file server has a core file */ bnode_CoreName(abnode, "file", tbuffer); - if (access(tbuffer, 0) == 0) return 1; + if (access(tbuffer, 0) == 0) + return 1; /* see if volserver has a core file */ bnode_CoreName(abnode, "vol", tbuffer); - if (access(tbuffer, 0) == 0) return 1; + if (access(tbuffer, 0) == 0) + return 1; /* see if salvager left a core file */ bnode_CoreName(abnode, "salv", tbuffer); - if (access(tbuffer, 0) == 0) return 1; + if (access(tbuffer, 0) == 0) + return 1; /* see if scanner left a core file (MR-AFS) */ bnode_CoreName(abnode, "scan", tbuffer); - if (access(tbuffer, 0) == 0) return 1; + if (access(tbuffer, 0) == 0) + return 1; /* no one left a core file */ return 0; } -static int fs_restartp (register struct fsbnode *abnode) +static int +fs_restartp(register struct fsbnode *abnode) { struct bnode_token *tt; register afs_int32 code; struct stat tstat; - + code = bnode_ParseLine(abnode->filecmd, &tt); - if (code) return 0; - if (!tt) return 0; + if (code) + return 0; + if (!tt) + return 0; code = stat(tt->key, &tstat); if (code) { bnode_FreeTokens(tt); return 0; } - if (tstat.st_ctime > abnode->lastFileStart) code = 1; - else code = 0; + if (tstat.st_ctime > abnode->lastFileStart) + code = 1; + else + code = 0; bnode_FreeTokens(tt); - if (code) return code; + if (code) + return code; /* now do same for volcmd */ code = bnode_ParseLine(abnode->volcmd, &tt); - if (code) return 0; - if (!tt) return 0; + if (code) + return 0; + if (!tt) + return 0; code = stat(tt->key, &tstat); if (code) { bnode_FreeTokens(tt); return 0; } - if (tstat.st_ctime > abnode->lastVolStart) code = 1; - else code = 0; + if (tstat.st_ctime > abnode->lastVolStart) + code = 1; + else + code = 0; bnode_FreeTokens(tt); - if (code) return code; - - if (abnode->scancmd) { /* Only in MR-AFS */ - /* now do same for scancmd (MR-AFS) */ - code = bnode_ParseLine(abnode->scancmd, &tt); - if (code) return 0; - if (!tt) return 0; - code = stat(tt->key, &tstat); - if (code) { - bnode_FreeTokens(tt); - return 0; + if (code) + return code; + + if (abnode->scancmd) { /* Only in MR-AFS */ + /* now do same for scancmd (MR-AFS) */ + code = bnode_ParseLine(abnode->scancmd, &tt); + if (code) + return 0; + if (!tt) + return 0; + code = stat(tt->key, &tstat); + if (code) { + bnode_FreeTokens(tt); + return 0; } - if (tstat.st_ctime > abnode->lastScanStart) code = 1; - else code = 0; - bnode_FreeTokens(tt); + if (tstat.st_ctime > abnode->lastScanStart) + code = 1; + else + code = 0; + bnode_FreeTokens(tt); } return code; @@ -202,60 +223,66 @@ static int fs_restartp (register struct fsbnode *abnode) /* set needsSalvage flag, creating file SALVAGE. if we need to salvage the file system (so we can tell over panic reboots */ -static int SetSalFlag(register struct fsbnode *abnode, register int aflag) +static int +SetSalFlag(register struct fsbnode *abnode, register int aflag) { char tbuffer[AFSDIR_PATH_MAX]; int fd; abnode->needsSalvage = aflag; - strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/", SALFILE, - abnode->b.name, NULL); + strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/", + SALFILE, abnode->b.name, NULL); if (aflag) { fd = open(tbuffer, O_CREAT | O_TRUNC | O_RDWR, 0666); close(fd); - } - else { + } else { unlink(tbuffer); } return 0; } /* set the needsSalvage flag according to the existence of the salvage file */ -static int RestoreSalFlag(register struct fsbnode *abnode) { +static int +RestoreSalFlag(register struct fsbnode *abnode) +{ char tbuffer[AFSDIR_PATH_MAX]; - strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/", SALFILE, - abnode->b.name, NULL); + strcompose(tbuffer, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH, "/", + SALFILE, abnode->b.name, NULL); if (access(tbuffer, 0) == 0) { /* file exists, so need to salvage */ abnode->needsSalvage = 1; - } - else { + } else { abnode->needsSalvage = 0; } return 0; } -char *copystr(register char *a) +char * +copystr(register char *a) { register char *b; - b = (char *) malloc(strlen(a)+1); + b = (char *)malloc(strlen(a) + 1); strcpy(b, a); return b; } -static int fs_delete(struct fsbnode *abnode) { +static int +fs_delete(struct fsbnode *abnode) +{ free(abnode->filecmd); free(abnode->volcmd); free(abnode->salcmd); - if (abnode->scancmd) free(abnode->scancmd); + if (abnode->scancmd) + free(abnode->scancmd); free(abnode); return 0; } #ifdef AFS_NT40_ENV -static void AppendExecutableExtension(char *cmd) +static void +AppendExecutableExtension(char *cmd) { char cmdext[_MAX_EXT]; @@ -268,7 +295,9 @@ static void AppendExecutableExtension(char *cmd) #endif /* AFS_NT40_ENV */ -struct bnode *fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd, char *ascancmd) +struct bnode * +fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *asalcmd, + char *ascancmd) { struct stat tstat; register struct fsbnode *te; @@ -293,10 +322,10 @@ struct bnode *fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *as } if (ascancmd && strlen(ascancmd)) { - if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) { - bozo_Log("BNODE: command path invalid '%s'\n", ascancmd); - bailout = 1; - } + if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) { + bozo_Log("BNODE: command path invalid '%s'\n", ascancmd); + bailout = 1; + } } if (!bailout) { @@ -327,7 +356,7 @@ struct bnode *fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *as bailout = 1; } - if (ascancmd && strlen(ascancmd)) { + if (ascancmd && strlen(ascancmd)) { sscanf(scanCmdpath, "%s", cmdname); #ifdef AFS_NT40_ENV AppendExecutableExtension(cmdname); @@ -340,32 +369,38 @@ struct bnode *fs_create(char *ainstance, char *afilecmd, char *avolcmd, char *as } if (bailout) { - free(fileCmdpath); free(volCmdpath); free(salCmdpath); + free(fileCmdpath); + free(volCmdpath); + free(salCmdpath); return NULL; } - te = (struct fsbnode *) malloc(sizeof(struct fsbnode)); + te = (struct fsbnode *)malloc(sizeof(struct fsbnode)); memset(te, 0, sizeof(struct fsbnode)); te->filecmd = fileCmdpath; te->volcmd = volCmdpath; te->salcmd = salCmdpath; if (ascancmd && strlen(ascancmd)) - te->scancmd = scanCmdpath; - else - te->scancmd = NULL; + te->scancmd = scanCmdpath; + else + te->scancmd = NULL; if (bnode_InitBnode(te, &fsbnode_ops, ainstance) != 0) { free(te); - free(fileCmdpath); free(volCmdpath); free(salCmdpath); + free(fileCmdpath); + free(volCmdpath); + free(salCmdpath); return NULL; } bnode_SetTimeout(te, POLLTIME); /* ask for timeout activations every 10 seconds */ RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */ SetNeedsClock(te); /* compute needsClock field */ - return (struct bnode *) te; + return (struct bnode *)te; } /* called to SIGKILL a process if it doesn't terminate normally */ -static int fs_timeout(struct fsbnode *abnode) { +static int +fs_timeout(struct fsbnode *abnode) +{ register afs_int32 now; now = FT_ApproxTime(); @@ -374,59 +409,71 @@ static int fs_timeout(struct fsbnode *abnode) { if (!abnode->volKillSent && now - abnode->timeSDStarted > SDTIME) { bnode_StopProc(abnode->volProc, SIGKILL); abnode->volKillSent = 1; - bozo_Log("bos shutdown: volserver failed to shutdown within %d seconds\n", - SDTIME); + bozo_Log + ("bos shutdown: volserver failed to shutdown within %d seconds\n", + SDTIME); } } if (abnode->salSDW) { if (!abnode->salKillSent && now - abnode->timeSDStarted > SDTIME) { bnode_StopProc(abnode->salProc, SIGKILL); abnode->salKillSent = 1; - bozo_Log("bos shutdown: salvager failed to shutdown within %d seconds\n", - SDTIME); + bozo_Log + ("bos shutdown: salvager failed to shutdown within %d seconds\n", + SDTIME); } } if (abnode->fileSDW) { if (!abnode->fileKillSent && now - abnode->timeSDStarted > FSSDTIME) { bnode_StopProc(abnode->fileProc, SIGKILL); abnode->fileKillSent = 1; - bozo_Log("bos shutdown: fileserver failed to shutdown within %d seconds\n", - FSSDTIME); + bozo_Log + ("bos shutdown: fileserver failed to shutdown within %d seconds\n", + FSSDTIME); } } if (abnode->scanSDW) { - if (!abnode->scanKillSent && now - abnode->timeSDStarted > SDTIME) { - bnode_StopProc(abnode->scanProc, SIGKILL); - abnode->scanKillSent = 1; - bozo_Log("bos shutdown: scanner failed to shutdown within %d seconds\n", - SDTIME); - } + if (!abnode->scanKillSent && now - abnode->timeSDStarted > SDTIME) { + bnode_StopProc(abnode->scanProc, SIGKILL); + abnode->scanKillSent = 1; + bozo_Log + ("bos shutdown: scanner failed to shutdown within %d seconds\n", + SDTIME); + } } SetNeedsClock(abnode); return 0; } -static int fs_getstat(struct fsbnode *abnode, afs_int32 *astatus) +static int +fs_getstat(struct fsbnode *abnode, afs_int32 * astatus) { register afs_int32 temp; - if (abnode->volSDW || abnode->fileSDW || abnode->salSDW || abnode->scanSDW) + if (abnode->volSDW || abnode->fileSDW || abnode->salSDW + || abnode->scanSDW) temp = BSTAT_SHUTTINGDOWN; - else if (abnode->salRunning) temp = BSTAT_NORMAL; - else if (abnode->volRunning && abnode->fileRunning && (!abnode->scancmd || - abnode->scanRunning)) temp = BSTAT_NORMAL; - else if (!abnode->salRunning && !abnode->volRunning && !abnode->fileRunning - && !abnode->scanRunning) temp = BSTAT_SHUTDOWN; - else temp = BSTAT_STARTINGUP; + else if (abnode->salRunning) + temp = BSTAT_NORMAL; + else if (abnode->volRunning && abnode->fileRunning + && (!abnode->scancmd || abnode->scanRunning)) + temp = BSTAT_NORMAL; + else if (!abnode->salRunning && !abnode->volRunning + && !abnode->fileRunning && !abnode->scanRunning) + temp = BSTAT_SHUTDOWN; + else + temp = BSTAT_STARTINGUP; *astatus = temp; return 0; } -static int fs_setstat(register struct fsbnode *abnode, afs_int32 astatus) +static int +fs_setstat(register struct fsbnode *abnode, afs_int32 astatus) { return NudgeProcs(abnode); } -static int fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc) +static int +fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc) { /* process has exited */ @@ -435,35 +482,33 @@ static int fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc) abnode->volRunning = 0; abnode->volSDW = 0; abnode->volKillSent = 0; - } - else if (aproc == abnode->fileProc) { + } else if (aproc == abnode->fileProc) { /* if we were expecting a shutdown and we didn't send a kill signal * and exited (didn't have a signal termination), then we assume that * the file server exited after putting the appropriate volumes safely * offline, and don't salvage next time. */ - if (abnode->fileSDW && !abnode->fileKillSent && aproc->lastSignal == 0) - SetSalFlag(abnode, 0); /* shut down normally */ + if (abnode->fileSDW && !abnode->fileKillSent + && aproc->lastSignal == 0) + SetSalFlag(abnode, 0); /* shut down normally */ abnode->fileProc = 0; abnode->fileRunning = 0; abnode->fileSDW = 0; abnode->fileKillSent = 0; - } - else if (aproc == abnode->salProc) { + } else if (aproc == abnode->salProc) { /* if we didn't shutdown the salvager, then assume it exited ok, and thus - that we don't have to salvage again */ + * that we don't have to salvage again */ if (!abnode->salSDW) SetSalFlag(abnode, 0); /* salvage just completed */ abnode->salProc = 0; abnode->salRunning = 0; abnode->salSDW = 0; abnode->salKillSent = 0; - } - else if (aproc == abnode->scanProc) { - abnode->scanProc = 0; - abnode->scanRunning = 0; - abnode->scanSDW = 0; - abnode->scanKillSent = 0; + } else if (aproc == abnode->scanProc) { + abnode->scanProc = 0; + abnode->scanRunning = 0; + abnode->scanSDW = 0; + abnode->scanKillSent = 0; } /* now restart anyone who needs to restart */ @@ -471,31 +516,35 @@ static int fs_procexit(struct fsbnode *abnode, struct bnode_proc *aproc) } /* make sure we're periodically checking the state if we need to */ -static int SetNeedsClock(register struct fsbnode *ab) +static int +SetNeedsClock(register struct fsbnode *ab) { if (ab->b.goal == 1 && ab->fileRunning && ab->volRunning - && (!ab->scancmd || ab->scanRunning)) - ab->needsClock = 0; /* running normally */ - else if (ab->b.goal == 0 && !ab->fileRunning && !ab->volRunning + && (!ab->scancmd || ab->scanRunning)) + ab->needsClock = 0; /* running normally */ + else if (ab->b.goal == 0 && !ab->fileRunning && !ab->volRunning && !ab->salRunning && !ab->scanRunning) - ab->needsClock = 0; /* halted normally */ - else ab->needsClock = 1; /* other */ + ab->needsClock = 0; /* halted normally */ + else + ab->needsClock = 1; /* other */ if (ab->needsClock && !bnode_PendingTimeout(ab)) bnode_SetTimeout(ab, POLLTIME); - if (!ab->needsClock) bnode_SetTimeout(ab, 0); + if (!ab->needsClock) + bnode_SetTimeout(ab, 0); } -static int NudgeProcs(register struct fsbnode *abnode) +static int +NudgeProcs(register struct fsbnode *abnode) { - struct bnode_proc *tp; /* not register */ + struct bnode_proc *tp; /* not register */ register afs_int32 code; afs_int32 now; now = FT_ApproxTime(); if (abnode->b.goal == 1) { /* we're trying to run the system. If the file server is running, then we - are trying to start up the system. If it is not running, then needsSalvage - tells us if we need to run the salvager or not */ + * are trying to start up the system. If it is not running, then needsSalvage + * tells us if we need to run the salvager or not */ if (abnode->fileRunning) { if (abnode->salRunning) { bozo_Log("Salvager running along with file server!\n"); @@ -517,21 +566,23 @@ static int NudgeProcs(register struct fsbnode *abnode) if (abnode->scancmd) { if (!abnode->scanRunning) { abnode->lastScanStart = FT_ApproxTime(); - code = bnode_NewProc(abnode, abnode->scancmd, "scanner", &tp); + code = + bnode_NewProc(abnode, abnode->scancmd, "scanner", + &tp); if (code == 0) { abnode->scanProc = tp; abnode->scanRunning = 1; } } - } - } - else { /* file is not running */ + } + } else { /* file is not running */ /* see how to start */ if (!abnode->needsSalvage) { /* no crash apparent, just start up normally */ if (!abnode->fileRunning) { abnode->lastFileStart = FT_ApproxTime(); - code = bnode_NewProc(abnode, abnode->filecmd, "file", &tp); + code = + bnode_NewProc(abnode, abnode->filecmd, "file", &tp); if (code == 0) { abnode->fileProc = tp; abnode->fileRunning = 1; @@ -547,34 +598,38 @@ static int NudgeProcs(register struct fsbnode *abnode) } } if (abnode->scancmd && !abnode->scanRunning) { - abnode->lastScanStart = FT_ApproxTime(); - code = bnode_NewProc(abnode, abnode->scancmd, "scanner", - &tp); - if (code == 0) { - abnode->scanProc = tp; - abnode->scanRunning = 1; - } - } - } - else { /* needs to be salvaged */ + abnode->lastScanStart = FT_ApproxTime(); + code = + bnode_NewProc(abnode, abnode->scancmd, "scanner", + &tp); + if (code == 0) { + abnode->scanProc = tp; + abnode->scanRunning = 1; + } + } + } else { /* needs to be salvaged */ /* make sure file server and volser are gone */ if (abnode->volRunning) { bnode_StopProc(abnode->volProc, SIGTERM); - if (!abnode->volSDW) abnode->timeSDStarted = now; + if (!abnode->volSDW) + abnode->timeSDStarted = now; abnode->volSDW = 1; } if (abnode->fileRunning) { bnode_StopProc(abnode->fileProc, SIGQUIT); - if (!abnode->fileSDW) abnode->timeSDStarted = now; + if (!abnode->fileSDW) + abnode->timeSDStarted = now; abnode->fileSDW = 1; } - if (abnode->scanRunning) { - bnode_StopProc(abnode->scanProc, SIGTERM); - if (!abnode->scanSDW) abnode->timeSDStarted = now; - abnode->scanSDW = 1; - } - if (abnode->volRunning || abnode->fileRunning - || abnode->scanRunning) return 0; + if (abnode->scanRunning) { + bnode_StopProc(abnode->scanProc, SIGTERM); + if (!abnode->scanSDW) + abnode->timeSDStarted = now; + abnode->scanSDW = 1; + } + if (abnode->volRunning || abnode->fileRunning + || abnode->scanRunning) + return 0; /* otherwise, it is safe to start salvager */ if (!abnode->salRunning) { code = bnode_NewProc(abnode, abnode->salcmd, "salv", &tp); @@ -585,8 +640,7 @@ static int NudgeProcs(register struct fsbnode *abnode) } } } - } - else { /* goal is 0, we're shutting down */ + } else { /* goal is 0, we're shutting down */ /* trying to shutdown */ if (abnode->salRunning && !abnode->salSDW) { bnode_StopProc(abnode->salProc, SIGTERM); @@ -603,55 +657,61 @@ static int NudgeProcs(register struct fsbnode *abnode) abnode->volSDW = 1; abnode->timeSDStarted = now; } - if (abnode->scanRunning && !abnode->scanSDW) { - bnode_StopProc(abnode->scanProc, SIGTERM); - abnode->scanSDW = 1; - abnode->timeSDStarted = now; - } + if (abnode->scanRunning && !abnode->scanSDW) { + bnode_StopProc(abnode->scanProc, SIGTERM); + abnode->scanSDW = 1; + abnode->timeSDStarted = now; + } } SetNeedsClock(abnode); return 0; } -static int fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen) +static int +fs_getstring(struct fsbnode *abnode, char *abuffer, afs_int32 alen) { - if (alen < 40) return -1; + if (alen < 40) + return -1; if (abnode->b.goal == 1) { if (abnode->fileRunning) { - if (abnode->fileSDW) strcpy(abuffer, "file server shutting down"); + if (abnode->fileSDW) + strcpy(abuffer, "file server shutting down"); else if (abnode->scancmd) { - if (!abnode->volRunning && !abnode->scanRunning) - strcpy(abuffer, "file server up; volser and scanner down"); + if (!abnode->volRunning && !abnode->scanRunning) + strcpy(abuffer, + "file server up; volser and scanner down"); else if (abnode->volRunning && !abnode->scanRunning) - strcpy(abuffer, "file server up; volser up; scanner down"); + strcpy(abuffer, + "file server up; volser up; scanner down"); else if (!abnode->volRunning && abnode->scanRunning) - strcpy(abuffer, "file server up; volser down; scanner up"); + strcpy(abuffer, + "file server up; volser down; scanner up"); - else strcpy(abuffer, "file server running"); - } - else if (!abnode->volRunning) + else + strcpy(abuffer, "file server running"); + } else if (!abnode->volRunning) strcpy(abuffer, "file server up; volser down"); - else strcpy(abuffer, "file server running"); - } - else if (abnode->salRunning) { + else + strcpy(abuffer, "file server running"); + } else if (abnode->salRunning) { strcpy(abuffer, "salvaging file system"); - } - else strcpy(abuffer, "starting file server"); - } - else { + } else + strcpy(abuffer, "starting file server"); + } else { /* shutting down */ if (abnode->fileRunning || abnode->volRunning || abnode->scanRunning) { strcpy(abuffer, "file server shutting down"); - } - else if (abnode->salRunning) + } else if (abnode->salRunning) strcpy(abuffer, "salvager shutting down"); - else strcpy(abuffer, "file server shut down"); + else + strcpy(abuffer, "file server shut down"); } return 0; } -static int fs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer, - afs_int32 alen) +static int +fs_getparm(struct fsbnode *abnode, afs_int32 aindex, char *abuffer, + afs_int32 alen) { if (aindex == 0) strcpy(abuffer, abnode->filecmd); diff --git a/src/bozo/smail-notifier.c b/src/bozo/smail-notifier.c index bcb6f8680..b7670e020 100644 --- a/src/bozo/smail-notifier.c +++ b/src/bozo/smail-notifier.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -29,35 +30,37 @@ RCSID("$Header$"); /* * Replace it with a bboard (i.e. transarc.bosserver.auto-reports) */ -#define RECIPIENT "foo@cellname" +#define RECIPIENT "foo@cellname" #include "AFS_component_version_number.c" main(argc, argv) - int argc; - char **argv; + int argc; + char **argv; { struct stat tstat; FILE *fin = stdin; char buf[BUFSIZ], *bufp, *bufp1, *typep, *cmd, *bp; - register afs_int32 code, c, fd, id, pflags=-1, len, core=0, lastE=0; + register afs_int32 code, c, fd, id, pflags = -1, len, core = 0, lastE = 0; char comLine[60], coreName[40], name[40], lastErrorName[50]; - afs_int32 pid=-1, lastExit=-1, lastSignal=-1, rsTime=-1, rsCount=-1; - afs_int32 procStartTime=-1, procStarts=-1; - afs_int32 lastAnyExit=-1, lastErrorExit=-1, errorCode=-1, errorSignal=-1, goal=-1; + afs_int32 pid = -1, lastExit = -1, lastSignal = -1, rsTime = -1, rsCount = + -1; + afs_int32 procStartTime = -1, procStarts = -1; + afs_int32 lastAnyExit = -1, lastErrorExit = -1, errorCode = + -1, errorSignal = -1, goal = -1; char *timeStamp; - typep = (char *) malloc(50); - cmd = (char *) malloc(50); - bufp = bufp1 = (char *) malloc(1000); + typep = (char *)malloc(50); + cmd = (char *)malloc(50); + bufp = bufp1 = (char *)malloc(1000); while (fgets(buf, sizeof(buf), fin)) { - code = sscanf(buf, "%s %s\n", typep, cmd); + code = sscanf(buf, "%s %s\n", typep, cmd); if (code < 2) { continue; } - if (!strcmp(typep, "BEGIN") && !strcmp(cmd, "bnode_proc")) { + if (!strcmp(typep, "BEGIN") && !strcmp(cmd, "bnode_proc")) { while (fgets(buf, sizeof(buf), fin)) { - code = sscanf(buf, "%s %s\n", typep, cmd); + code = sscanf(buf, "%s %s\n", typep, cmd); if (code < 2) { printf("**bnode_proc**: typed=%s, cmd=%s\n", typep, cmd); break; @@ -79,13 +82,15 @@ main(argc, argv) else if (!strcmp(typep, "END")) { break; } else { - printf("Unexpected token %s in the bnode_proc (should be END)\n", typep); + printf + ("Unexpected token %s in the bnode_proc (should be END)\n", + typep); exit(1); } } - } else if (!strcmp(typep, "BEGIN") && !strcmp(cmd, "bnode")) { + } else if (!strcmp(typep, "BEGIN") && !strcmp(cmd, "bnode")) { while (fgets(buf, sizeof(buf), fin)) { - code = sscanf(buf, "%s %s\n", typep, cmd); + code = sscanf(buf, "%s %s\n", typep, cmd); if (code < 2) { printf("**bnode**: typed=%s, cmd=%s\n", typep, cmd); break; @@ -117,7 +122,9 @@ main(argc, argv) else if (!strcmp(typep, "END")) { break; } else { - printf("Unexpected token %s in the bnode (should be END)\n", typep); + printf + ("Unexpected token %s in the bnode (should be END)\n", + typep); exit(1); } } @@ -130,21 +137,24 @@ main(argc, argv) * Now make up the text for the post */ sprintf(buf, "/tmp/snote.%d", getpid()); - fd = open(buf, O_RDWR|O_CREAT|O_TRUNC, 0600); + fd = open(buf, O_RDWR | O_CREAT | O_TRUNC, 0600); if (fd == -1) { perror(buf); printf("Unable to create temp file, %s\n", buf); exit(1); } - (void) sprintf(bufp, "Subject: Bosserver's automatic notification\n\n"); - bufp += strlen(bufp); - (void) sprintf(bufp, "AUTOMATIC NOTIFICATION EVENT FOR AFS SERVER INSTANCE %s\n\n", name); - bufp += strlen(bufp); - (void) sprintf(bufp, "Server Process id was: %d\n", pid); - bufp += strlen(bufp); - (void) sprintf(bufp, "Server command line: %s\n", comLine); - bufp += strlen(bufp); - if (strcmp(coreName, "(null)")) core = 1; + (void)sprintf(bufp, "Subject: Bosserver's automatic notification\n\n"); + bufp += strlen(bufp); + (void)sprintf(bufp, + "AUTOMATIC NOTIFICATION EVENT FOR AFS SERVER INSTANCE %s\n\n", + name); + bufp += strlen(bufp); + (void)sprintf(bufp, "Server Process id was: %d\n", pid); + bufp += strlen(bufp); + (void)sprintf(bufp, "Server command line: %s\n", comLine); + bufp += strlen(bufp); + if (strcmp(coreName, "(null)")) + core = 1; bp = comLine; strcpy(bp, AFSDIR_SERVER_CORELOG_FILEPATH); if (core) { @@ -160,59 +170,69 @@ main(argc, argv) } else core = 0; strcat(bp, " "); - (void) sprintf(bufp, "There is %score dump left %sfor this server\n", - (core?(c?"a recent ":"an 'old' "):"no "), (core?bp:"")); - bufp += strlen(bufp); + (void)sprintf(bufp, "There is %score dump left %sfor this server\n", + (core ? (c ? "a recent " : "an 'old' ") : "no "), + (core ? bp : "")); + bufp += strlen(bufp); #ifdef notdef - (void) sprintf(bufp, "Last Exit code %d\n", lastExit); - bufp += strlen(bufp); - (void) sprintf(bufp, "Last Signal number %d\n", lastSignal); - bufp += strlen(bufp); + (void)sprintf(bufp, "Last Exit code %d\n", lastExit); + bufp += strlen(bufp); + (void)sprintf(bufp, "Last Signal number %d\n", lastSignal); + bufp += strlen(bufp); #endif if (pflags == 1) strcpy(bp, "PROCESS STARTED"); else if (pflags == 2) strcpy(bp, "PROCESS EXITED"); - else + else strcpy(bp, "UNKNOWN"); - (void) sprintf(bufp, "Process state %d (%s)\n", pflags, bp); - bufp += strlen(bufp); + (void)sprintf(bufp, "Process state %d (%s)\n", pflags, bp); + bufp += strlen(bufp); timeStamp = ctime(&rsTime); timeStamp[24] = 0; - (void) sprintf(bufp, "\nNumber of restarts since %s is %d\n", timeStamp, rsCount); - bufp += strlen(bufp); + (void)sprintf(bufp, "\nNumber of restarts since %s is %d\n", timeStamp, + rsCount); + bufp += strlen(bufp); if (procStartTime) { timeStamp = ctime(&procStartTime); timeStamp[24] = 0; - (void) sprintf(bufp, "Number of process restarts since the process started %s is %d\n", timeStamp, procStarts); + (void)sprintf(bufp, + "Number of process restarts since the process started %s is %d\n", + timeStamp, procStarts); } - bufp += strlen(bufp); + bufp += strlen(bufp); if (lastAnyExit) { timeStamp = ctime(&lastAnyExit); timeStamp[24] = 0; - (void) sprintf(bufp, "Last time process exited for any reason: %s\n", timeStamp); + (void)sprintf(bufp, "Last time process exited for any reason: %s\n", + timeStamp); } - bufp += strlen(bufp); + bufp += strlen(bufp); if (lastErrorExit) { timeStamp = ctime(&lastErrorExit); timeStamp[24] = 0; - (void) sprintf(bufp, "Last time process exited unexpectedly: %s\n", timeStamp); + (void)sprintf(bufp, "Last time process exited unexpectedly: %s\n", + timeStamp); } - bufp += strlen(bufp); - (void) sprintf(bufp, "Last exit return code %d\n", errorCode); - bufp += strlen(bufp); - (void) sprintf(bufp, "Last process terminating signal %d\n", errorSignal); - bufp += strlen(bufp); + bufp += strlen(bufp); + (void)sprintf(bufp, "Last exit return code %d\n", errorCode); + bufp += strlen(bufp); + (void)sprintf(bufp, "Last process terminating signal %d\n", errorSignal); + bufp += strlen(bufp); #ifdef notdef - if (strcmp(lastErrorName, "(null)")) lastE = 1; + if (strcmp(lastErrorName, "(null)")) + lastE = 1; if (lastE) { - (void) sprintf(bufp, "Short name of process that failed last in this bnode is: %s\n", lastErrorName); - bufp += strlen(bufp); + (void)sprintf(bufp, + "Short name of process that failed last in this bnode is: %s\n", + lastErrorName); + bufp += strlen(bufp); } #endif - (void) sprintf(bufp, "The server is now %srunning\n", (goal?"":"not ")); - bufp += strlen(bufp); - len =(int)(bufp-bufp1); + (void)sprintf(bufp, "The server is now %srunning\n", + (goal ? "" : "not ")); + bufp += strlen(bufp); + len = (int)(bufp - bufp1); if (write(fd, bufp1, len) < 0) { perror("Write"); exit(1); diff --git a/src/bozo/test/testproc.c b/src/bozo/test/testproc.c index ffe6f8dc5..b5eff7536 100644 --- a/src/bozo/test/testproc.c +++ b/src/bozo/test/testproc.c @@ -10,18 +10,21 @@ #include #include -static int ignore=0; +static int ignore = 0; static int sleepTime = 10; -sigproc() { +sigproc() +{ printf("testproc received signal\n"); - if (ignore) return 0; + if (ignore) + return 0; exit(0); } main(argc, argv) -int argc; -char **argv; { + int argc; + char **argv; +{ register int i; #ifdef AFS_AIX31_ENV @@ -32,7 +35,7 @@ char **argv; { * generated which, in many cases, isn't too useful. */ struct sigaction nsa; - + sigemptyset(&nsa.sa_mask); nsa.sa_handler = SIG_DFL; nsa.sa_flags = SA_FULLDUMP; @@ -40,15 +43,13 @@ char **argv; { #endif signal(SIGTERM, sigproc); signal(SIGQUIT, sigproc); - for(i=1;i sleep N seconds before exiting\n"); diff --git a/src/bu_utils/fms.c b/src/bu_utils/fms.c index 9c170101b..42b46044b 100644 --- a/src/bu_utils/fms.c +++ b/src/bu_utils/fms.c @@ -10,26 +10,26 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #undef IN #include #include -#include /* for mtio.h */ +#include /* for mtio.h */ #include #include #include /* structure for writing data to tape */ -typedef struct tapeDataBuffer -{ - struct tapeDataBuffer *tdb_next; - char *tdb_buffer; +typedef struct tapeDataBuffer { + struct tapeDataBuffer *tdb_next; + char *tdb_buffer; } tapeDataBufferT; typedef tapeDataBufferT *tapeDataBufferP; /* globals */ -char *tapeDevice = 0; /* device pathname */ +char *tapeDevice = 0; /* device pathname */ afs_int32 eotEnabled = 1; /* prototypes */ @@ -52,7 +52,7 @@ void tt_fileMarkSize(struct cmd_syndesc *as, char *arock); void quitFms(int); main(argc, argv) - int argc; + int argc; char **argv; { struct sigaction intaction, oldaction; @@ -63,14 +63,16 @@ main(argc, argv) sigaction(SIGINT, &intaction, &oldaction); - cptr = cmd_CreateSyntax(NULL, tt_fileMarkSize, 0, - "write a tape full of file marks"); + cptr = + cmd_CreateSyntax(NULL, tt_fileMarkSize, 0, + "write a tape full of file marks"); cmd_AddParm(cptr, "-tape", CMD_SINGLE, CMD_REQUIRED, "tape special file"); cmd_Dispatch(argc, argv); } -void tt_fileMarkSize(as, arock) +void +tt_fileMarkSize(as, arock) struct cmd_syndesc *as; char *arock; { @@ -86,7 +88,7 @@ fileMarkSize(tapeDevice) char *tapeDevice; { afs_uint32 nFileMarks, nBlocks, nbfTape; - double tpSize, fmSize; + double tpSize, fmSize; afs_uint32 bufferSize = 16384; usd_handle_t hTape; FILE *logFile; @@ -96,18 +98,16 @@ fileMarkSize(tapeDevice) afs_int32 rewindTape(); - code = usd_Open(tapeDevice, - (USD_OPEN_RDWR | USD_OPEN_WLOCK), 0777, &hTape); - if ( code ) - { + code = + usd_Open(tapeDevice, (USD_OPEN_RDWR | USD_OPEN_WLOCK), 0777, &hTape); + if (code) { printf("Can't open tape device %s\n", tapeDevice); fflush(stdout); exit(1); } logFile = fopen("fms.log", "w+"); - if ( logFile == NULL ) - { + if (logFile == NULL) { printf("Can't open log file\n"); fflush(stdout); exit(1); @@ -116,8 +116,7 @@ fileMarkSize(tapeDevice) fflush(logFile); code = rewindTape(hTape); - if ( code ) - { + if (code) { fprintf(logFile, "Can't rewind tape\n"); fflush(logFile); ERROR(code); @@ -125,18 +124,16 @@ fileMarkSize(tapeDevice) /* measure capacity of tape */ nbfTape = 0; - countr = 0; - while ( 1 ) - { + countr = 0; + while (1) { code = dataBlock(hTape, bufferSize); nbfTape++; count++; - countr++; - if ( code ) + countr++; + if (code) break; - if ( count >= 5 ) - { + if (count >= 5) { count = 0; printf("\rwrote block: %d", nbfTape); } @@ -149,17 +146,15 @@ fileMarkSize(tapeDevice) printf("Finished data capacity test - rewinding\n"); /* reset the tape device */ code = USD_CLOSE(hTape); - if (code) - { + if (code) { fprintf(logFile, "Can't close tape device at end of pass 1\n"); fflush(logFile); printf("Can't close tape device %s\n", tapeDevice); goto error_exit; } - code = usd_Open(tapeDevice, - (USD_OPEN_RDWR | USD_OPEN_WLOCK), 0777, &hTape); - if ( code ) - { + code = + usd_Open(tapeDevice, (USD_OPEN_RDWR | USD_OPEN_WLOCK), 0777, &hTape); + if (code) { fprintf(logFile, "Can't open tape device for pass 2\n"); fflush(logFile); printf("Can't open tape device %s\n", tapeDevice); @@ -167,8 +162,7 @@ fileMarkSize(tapeDevice) } code = rewindTape(hTape); - if ( code ) - { + if (code) { fprintf(logFile, "Can't rewind tape\n"); fflush(logFile); ERROR(code); @@ -176,45 +170,45 @@ fileMarkSize(tapeDevice) /* now measure file mark size */ nFileMarks = 0; - nBlocks = 0; - count = 0; - countr = 0; - while ( 1 ) - { + nBlocks = 0; + count = 0; + countr = 0; + while (1) { code = dataBlock(hTape, bufferSize); nBlocks++; - if ( code ) + if (code) break; code = fileMark(hTape); nFileMarks++; - if ( code ) + if (code) break; count++; - countr++; + countr++; - if ( count >= 2 ) - { + if (count >= 2) { count = 0; - printf("\rwrote %d blocks, %d filemarks", - nBlocks, nFileMarks); + printf("\rwrote %d blocks, %d filemarks", nBlocks, nFileMarks); } } printf("\nFinished filemark test\n"); - tpSize = (double)nbfTape*(double)bufferSize; - fmSize = (((double)nbfTape - (double)nBlocks)*(double)bufferSize)/(double)nFileMarks; + tpSize = (double)nbfTape *(double)bufferSize; + fmSize = + (((double)nbfTape - + (double)nBlocks) * (double)bufferSize) / (double)nFileMarks; printf("Tape capacity is %.0f bytes\n", tpSize); - printf("File marks are %.0f bytes\n", fmSize); + printf("File marks are %.0f bytes\n", fmSize); fprintf(logFile, "Tape capacity is %.0f bytes\n", tpSize); - fprintf(logFile, "File marks are %.0f bytes\n", fmSize); + fprintf(logFile, "File marks are %.0f bytes\n", fmSize); fflush(logFile); fclose(logFile); -error_exit: + error_exit: USD_CLOSE(hTape); - return(code); + return (code); } -void quitFms(int sig) +void +quitFms(int sig) { exit(0); } @@ -229,25 +223,26 @@ void quitFms(int sig) afs_int32 rewindTape(usd_handle_t hTape) { - usd_tapeop_t tapeop; - int rcode; + usd_tapeop_t tapeop; + int rcode; - tapeop.tp_op = USDTAPE_REW; - tapeop.tp_count = 1; - rcode = USD_IOCTL(hTape, USD_IOCTL_TAPEOPERATION, (void *)&tapeop); - return rcode; + tapeop.tp_op = USDTAPE_REW; + tapeop.tp_count = 1; + rcode = USD_IOCTL(hTape, USD_IOCTL_TAPEOPERATION, (void *)&tapeop); + return rcode; } /* write an EOF marker */ -int fileMark(usd_handle_t hTape) +int +fileMark(usd_handle_t hTape) { - usd_tapeop_t tapeop; - int rcode; + usd_tapeop_t tapeop; + int rcode; - tapeop.tp_op = USDTAPE_WEOF; - tapeop.tp_count = 1; - rcode = USD_IOCTL(hTape, USD_IOCTL_TAPEOPERATION, (void *)&tapeop); - return rcode; + tapeop.tp_op = USDTAPE_WEOF; + tapeop.tp_count = 1; + rcode = USD_IOCTL(hTape, USD_IOCTL_TAPEOPERATION, (void *)&tapeop); + return rcode; } /* dataBlock @@ -266,37 +261,28 @@ dataBlock(usd_handle_t hTape, afs_int32 reqSize) /* dbBuffersize is only valid when dB_buffer is non-zero */ - if ( (dB_buffer != 0) - && (dB_buffersize != reqSize ) - ) - { + if ((dB_buffer != 0) + && (dB_buffersize != reqSize) + ) { free(dB_buffer); dB_buffer = 0; } - if (dB_buffer == 0 ) - { - dB_buffer = (char *) malloc(reqSize); - if ( dB_buffer == 0 ) + if (dB_buffer == 0) { + dB_buffer = (char *)malloc(reqSize); + if (dB_buffer == 0) ERROR(-1); dB_buffersize = reqSize; memset(dB_buffer, 0, dB_buffersize); } - ptr = (int *) dB_buffer; + ptr = (int *)dB_buffer; *ptr = dB_count++; code = USD_WRITE(hTape, dB_buffer, dB_buffersize, &xferd); if (code || xferd != dB_buffersize) ERROR(-1); -error_exit: - return(code); + error_exit: + return (code); } - - - - - - - diff --git a/src/bubasics/bubasics.h b/src/bubasics/bubasics.h index 74ef32fff..8fbd5949f 100644 --- a/src/bubasics/bubasics.h +++ b/src/bubasics/bubasics.h @@ -25,17 +25,17 @@ * These are not version flags as the name suggests. */ -#define BUTM_VERSIONFLAG_0 0 /* every size measure is in bytes */ -#define BUTM_VERSIONFLAG_1 1 /* every size measure is in kbytes */ -#define BUTM_VERSIONFLAG_2 2 /* afs 3.1 features */ +#define BUTM_VERSIONFLAG_0 0 /* every size measure is in bytes */ +#define BUTM_VERSIONFLAG_1 1 /* every size measure is in kbytes */ +#define BUTM_VERSIONFLAG_2 2 /* afs 3.1 features */ /* current version of the interface */ #define BUTM_MAJORVERSION BUTM_VERSIONFLAG_2 /* versions for the bucoord <-> butc interface */ -#define BUTC_VERSION_1 1 /* initial version, afs 3.1 */ -#define BUTC_VERSION_2 2 /* 3.4 version - added voltype to tc_dumpDesc */ -#define BUTC_VERSION_3 3 /* 3.4 version - labeltape change */ +#define BUTC_VERSION_1 1 /* initial version, afs 3.1 */ +#define BUTC_VERSION_2 2 /* 3.4 version - added voltype to tc_dumpDesc */ +#define BUTC_VERSION_3 3 /* 3.4 version - labeltape change */ #define CUR_BUTC_VERSION BUTC_VERSION_3 /* TAPE_VERSION Version of the current tape format used by butc @@ -60,13 +60,13 @@ #define TAPE_VERSION_4 4 #define CUR_TAPE_VERSION TAPE_VERSION_4 -#define BC_SCHEDULE_MAGIC 0x74327285 /* magic # for schedules */ -#define BC_SCHEDULE_V3_1 1 /* afs 3.1 */ -#define BC_SCHEDULE_VERSION BC_SCHEDULE_V3_1 /* current version */ +#define BC_SCHEDULE_MAGIC 0x74327285 /* magic # for schedules */ +#define BC_SCHEDULE_V3_1 1 /* afs 3.1 */ +#define BC_SCHEDULE_VERSION BC_SCHEDULE_V3_1 /* current version */ -#define BC_DUMPDB_MAGIC 0x10381645 /* magic # for dump db */ -#define BC_DUMPDB_V3_1 1 /* afs 3.1 */ -#define BC_DUMPDB_VERSION BC_DUMPDB_V3_1 /* current version */ +#define BC_DUMPDB_MAGIC 0x10381645 /* magic # for dump db */ +#define BC_DUMPDB_V3_1 1 /* afs 3.1 */ +#define BC_DUMPDB_VERSION BC_DUMPDB_V3_1 /* current version */ /* define ports that move to system configuration later */ #define BC_MESSAGEPORT 7020 /* for communicating with backup coordinator */ @@ -75,11 +75,11 @@ #ifndef AFSCONF_BUDBPORT #define AFSCONF_BUDBPORT 7021 /* for communicating with backup database */ #endif -#define BUDB_SERVICE 22314 /* service id */ +#define BUDB_SERVICE 22314 /* service id */ -#define RX_SCINDEX_NULL 0 /* No security */ -#define RX_SCINDEX_VAB 1 /* vice tokens, with bcrypt */ -#define RX_SCINDEX_KAD 2 /* Kerberos/DES */ +#define RX_SCINDEX_NULL 0 /* No security */ +#define RX_SCINDEX_VAB 1 /* vice tokens, with bcrypt */ +#define RX_SCINDEX_KAD 2 /* Kerberos/DES */ /* maximums for various text strings * DON'T alter these values until all disk/tape structures can be handled @@ -87,30 +87,30 @@ */ /* dump states */ -#define DUMP_FAILED 1 /* outright failed */ -#define DUMP_PARTIAL 2 /* partial on tape */ -#define DUMP_SUCCESS 3 /* all ok */ -#define DUMP_RETRY 4 /* failed, but retry */ -#define DUMP_NORETRYEOT 5 /* failed, and don't retry */ -#define DUMP_NOTHING 6 /* Nothing was dumped */ -#define DUMP_NODUMP 7 /* don't dump, and don't retry */ - - -#define BU_MAXNAMELEN 32 /* max for misc. names: eg volumes */ -#define BU_MAXTAPELEN 32 /* for tape names */ -#define BU_MAXHOSTLEN 32 /* for server (machine) names */ -#define BU_MAXTOKENLEN 16 /* identifiers */ -#define BU_MAXUNAMELEN 256 /* length of a user name */ -#define BU_MAXCELLLEN 256 /* length of a cell name */ +#define DUMP_FAILED 1 /* outright failed */ +#define DUMP_PARTIAL 2 /* partial on tape */ +#define DUMP_SUCCESS 3 /* all ok */ +#define DUMP_RETRY 4 /* failed, but retry */ +#define DUMP_NORETRYEOT 5 /* failed, and don't retry */ +#define DUMP_NOTHING 6 /* Nothing was dumped */ +#define DUMP_NODUMP 7 /* don't dump, and don't retry */ + + +#define BU_MAXNAMELEN 32 /* max for misc. names: eg volumes */ +#define BU_MAXTAPELEN 32 /* for tape names */ +#define BU_MAXHOSTLEN 32 /* for server (machine) names */ +#define BU_MAXTOKENLEN 16 /* identifiers */ +#define BU_MAXUNAMELEN 256 /* length of a user name */ +#define BU_MAXCELLLEN 256 /* length of a cell name */ /* proposed maximum name lengths PA */ -#define BU_MAX_NAME 64 /* misc. names */ -#define BU_MAX_DUMP_PATH 256 /* length of schedule path name */ +#define BU_MAX_NAME 64 /* misc. names */ +#define BU_MAX_DUMP_PATH 256 /* length of schedule path name */ #define BC_MAXPORTOFFSET 58510 /* max number of port offsets in database */ #ifndef NEVERDATE -#define NEVERDATE 037777777777 /* a date that will never come */ +#define NEVERDATE 037777777777 /* a date that will never come */ #endif #ifndef NEVERSTRING #define NEVERSTRING "NEVER \n" @@ -121,7 +121,7 @@ #define Date afs_uint32 #endif -#define DUMP_TAPE_NAME "Ubik_db_dump" /* base database tape name */ +#define DUMP_TAPE_NAME "Ubik_db_dump" /* base database tape name */ /* for expiration date processing */ #define BC_NO_EXPDATE 0 /* no expiration date */ @@ -133,16 +133,15 @@ sprintf (name, (set)->format, (seq) + (set)->b) /* common structure definitions */ -struct dlqlink -{ - struct dlqlink *dlq_next; - struct dlqlink *dlq_prev; - afs_int32 dlq_type; - char * dlq_structPtr; /* enclosing structure */ +struct dlqlink { + struct dlqlink *dlq_next; + struct dlqlink *dlq_prev; + afs_int32 dlq_type; + char *dlq_structPtr; /* enclosing structure */ }; -typedef struct dlqlink dlqlinkT; -typedef dlqlinkT *dlqlinkP; +typedef struct dlqlink dlqlinkT; +typedef dlqlinkT *dlqlinkP; /* invariants */ @@ -179,49 +178,48 @@ extern dlqlinkP dlqUnlinkf(); * S - server side only * B - client or server */ - -#define STARTING 0x1 /* C; still setting up, no server task yet */ + +#define STARTING 0x1 /* C; still setting up, no server task yet */ #define ABORT_REQUEST 0x2 /* B; user requested abort */ -#define ABORT_SENT 0x4 /* C; abort sent to server (REQ cleared) */ +#define ABORT_SENT 0x4 /* C; abort sent to server (REQ cleared) */ #define ABORT_DONE 0x8 /* S; abort complete on server */ #define ABORT_LOCAL 0x10 /* C; abort local task if contact lost */ -#define TASK_DONE 0x20 /* B; task complete */ +#define TASK_DONE 0x20 /* B; task complete */ #define SILENT 0x400 /* C; don't be verbose about termination */ #define NOREMOVE 0x1000 /* C; don't remove from queue */ /* comm status */ -#define CONTACT_LOST 0x40 /* B; contact lost */ +#define CONTACT_LOST 0x40 /* B; contact lost */ /* errror handling */ -#define TASK_ERROR 0x80 /* S; had fatal error, will terminate */ +#define TASK_ERROR 0x80 /* S; had fatal error, will terminate */ /* general status - copied back to client for jobs status */ #define DRIVE_WAIT 0x100 /* S; waiting for drive to become free */ #define OPR_WAIT 0x200 /* S; waiting for operator action */ -#define CALL_WAIT 0x800 /* S; waiting for callout routine completion */ +#define CALL_WAIT 0x800 /* S; waiting for callout routine completion */ -struct statusS -{ - dlqlinkT link; +struct statusS { + dlqlinkT link; - afs_uint32 taskId; /* task identifier */ - afs_uint32 dbDumpId; /* dump id */ - afs_uint32 flags; /* as above */ - afs_uint32 nKBytes; /* bytes xferred */ - char volumeName[BU_MAXNAMELEN]; /* current volume (if any) */ - afs_int32 volsFailed; /* # operation failures */ - afs_int32 lastPolled; /* last successful poll */ + afs_uint32 taskId; /* task identifier */ + afs_uint32 dbDumpId; /* dump id */ + afs_uint32 flags; /* as above */ + afs_uint32 nKBytes; /* bytes xferred */ + char volumeName[BU_MAXNAMELEN]; /* current volume (if any) */ + afs_int32 volsFailed; /* # operation failures */ + afs_int32 lastPolled; /* last successful poll */ /* bucoord local */ - char taskName[64]; /* type of task */ - afs_int32 port; - afs_int32 jobNumber; - afs_int32 volsTotal; /* total # vols */ - afs_int32 scheduledDump; /* Time this dump was scheduled */ - char *cmdLine; /* Command to exectute for this dump */ + char taskName[64]; /* type of task */ + afs_int32 port; + afs_int32 jobNumber; + afs_int32 volsTotal; /* total # vols */ + afs_int32 scheduledDump; /* Time this dump was scheduled */ + char *cmdLine; /* Command to exectute for this dump */ }; -typedef struct statusS statusT; -typedef statusT *statusP; +typedef struct statusS statusT; +typedef statusT *statusP; #endif diff --git a/src/bubasics/butm.p.h b/src/bubasics/butm.p.h index 4106d9f37..cd4475375 100644 --- a/src/bubasics/butm.p.h +++ b/src/bubasics/butm.p.h @@ -11,8 +11,8 @@ #include struct blockMark { - int count; /* actual number of bytes valid in the block */ - afs_int32 magic; + int count; /* actual number of bytes valid in the block */ + afs_int32 magic; afs_int32 spare1; afs_int32 spare2; afs_int32 spare3; @@ -21,60 +21,60 @@ struct blockMark { /* The size of a tapeblock is 16KB: contains header info and data */ #define BUTM_BLOCKSIZE 16384 -#define BUTM_HDRSIZE ((5*sizeof(afs_int32)) + sizeof(int)) /* sizeof blockMark */ +#define BUTM_HDRSIZE ((5*sizeof(afs_int32)) + sizeof(int)) /* sizeof blockMark */ #define BUTM_BLKSIZE (BUTM_BLOCKSIZE - BUTM_HDRSIZE) struct butm_tapeInfo { - afs_int32 structVersion; + afs_int32 structVersion; struct { - afs_int32 (*mount)(); - afs_int32 (*dismount)(); - afs_int32 (*create)(); - afs_int32 (*readLabel)(); - afs_int32 (*seek)(); - afs_int32 (*seekEODump)(); - afs_int32 (*readFileBegin)(); - afs_int32 (*readFileData)(); - afs_int32 (*readFileEnd)(); - afs_int32 (*writeFileBegin)(); - afs_int32 (*writeFileData)(); - afs_int32 (*writeFileEnd)(); - afs_int32 (*writeEOT)(); - afs_int32 (*setSize)(); - afs_int32 (*getSize)(); + afs_int32(*mount) (); + afs_int32(*dismount) (); + afs_int32(*create) (); + afs_int32(*readLabel) (); + afs_int32(*seek) (); + afs_int32(*seekEODump) (); + afs_int32(*readFileBegin) (); + afs_int32(*readFileData) (); + afs_int32(*readFileEnd) (); + afs_int32(*writeFileBegin) (); + afs_int32(*writeFileData) (); + afs_int32(*writeFileEnd) (); + afs_int32(*writeEOT) (); + afs_int32(*setSize) (); + afs_int32(*getSize) (); } ops; - char name[BU_MAXTAPELEN]; - afs_int32 position; /* current position of tape */ - afs_uint32 posCount; /* position in bytes of the tape */ + char name[BU_MAXTAPELEN]; + afs_int32 position; /* current position of tape */ + afs_uint32 posCount; /* position in bytes of the tape */ /* the next three fields are used for modeling tape usage */ - afs_uint32 nBytes; /* number of bytes written */ - afs_uint32 kBytes; /* number of Kbytes written */ - afs_int32 nRecords; /* number of records written */ - afs_int32 nFiles; /* number of files written */ + afs_uint32 nBytes; /* number of bytes written */ + afs_uint32 kBytes; /* number of Kbytes written */ + afs_int32 nRecords; /* number of records written */ + afs_int32 nFiles; /* number of files written */ /* These fields provide the coefficients for the above variables */ - afs_int32 recordSize; /* bytes per record */ - afs_uint32 tapeSize; /* length of tape */ - afs_int32 coefBytes; /* length multiplier for bytes */ - afs_int32 coefRecords; /* ditto records */ - afs_int32 coefFiles; /* ditto files */ - int simultaneousTapes; /* number of tapes mounted simultaneously */ - int status; /* status of tape */ - int flags; /* e.g. read-only, sequential */ - char *tcRock; /* for random tape coordinator storage */ - char *tmRock; /* for random tape module storage */ - afs_int32 sizeflags; /* What the units of tape size are. */ - - afs_int32 debug; /* print debugging info */ - afs_int32 error; /* Error code from butm module */ - afs_int32 spare[8]; + afs_int32 recordSize; /* bytes per record */ + afs_uint32 tapeSize; /* length of tape */ + afs_int32 coefBytes; /* length multiplier for bytes */ + afs_int32 coefRecords; /* ditto records */ + afs_int32 coefFiles; /* ditto files */ + int simultaneousTapes; /* number of tapes mounted simultaneously */ + int status; /* status of tape */ + int flags; /* e.g. read-only, sequential */ + char *tcRock; /* for random tape coordinator storage */ + char *tmRock; /* for random tape module storage */ + afs_int32 sizeflags; /* What the units of tape size are. */ + + afs_int32 debug; /* print debugging info */ + afs_int32 error; /* Error code from butm module */ + afs_int32 spare[8]; }; -struct tapeConfig{ +struct tapeConfig { char device[256]; afs_uint32 capacity; - afs_int32 fileMarkSize; /* size of file marks, in bytes */ + afs_int32 fileMarkSize; /* size of file marks, in bytes */ afs_int32 portOffset; }; @@ -89,24 +89,24 @@ struct tapeConfig{ #define BUTM_STATUS_WRITEERROR (1<<2) /* tape error during write */ #define BUTM_STATUS_READERROR (1<<3) /* tape error during read */ #define BUTM_STATUS_SEEKERROR (1<<4) /* tape error during positioning */ -#define BUTM_STATUS_EOF (1<<5) /* tape at EOF */ -#define BUTM_STATUS_EOD (1<<6) /* end of tape reached */ +#define BUTM_STATUS_EOF (1<<5) /* tape at EOF */ +#define BUTM_STATUS_EOD (1<<6) /* end of tape reached */ #define BUTM_FLAGS_READONLY (1<<0) /* tape mounted read-only */ #define BUTM_FLAGS_SEQUENTIAL (1<<1) /* tape is sequential access: sort positions */ struct butm_tapeLabel { - afs_int32 structVersion; /* structure version number */ - Date creationTime; /* when tape was first labeled */ - Date expirationDate; /* when tape can be relabelled */ + afs_int32 structVersion; /* structure version number */ + Date creationTime; /* when tape was first labeled */ + Date expirationDate; /* when tape can be relabelled */ char AFSName[BU_MAXTAPELEN]; /* AFS assigned tape name */ struct ktc_principal creator; /* person creating tape */ - char cell[BU_MAXCELLLEN]; /* cell which owns tape. */ - afs_uint32 dumpid; /* which dump on this tape */ - afs_int32 useCount; /* # times written */ - afs_int32 spare[8]; + char cell[BU_MAXCELLLEN]; /* cell which owns tape. */ + afs_uint32 dumpid; /* which dump on this tape */ + afs_int32 useCount; /* # times written */ + afs_int32 spare[8]; char comment[96]; - char pName[BU_MAXTAPELEN]; /* permanent user assigned tape name */ + char pName[BU_MAXTAPELEN]; /* permanent user assigned tape name */ afs_uint32 size; char dumpPath[BU_MAX_DUMP_PATH]; /* dump schedule path name */ }; @@ -142,5 +142,3 @@ struct butm_tapeLabel { #define butm_WriteEOT(i) (*((i)->ops.writeEOT))(i) #define butm_SetSize(i,s) (*((i)->ops.setSize))(i,s) #define butm_GetSize(i,s) (*((i)->ops.getSize))(i,s) - - diff --git a/src/bubasics/tcdata.p.h b/src/bubasics/tcdata.p.h index 4cc8f61f4..c5fd013b8 100644 --- a/src/bubasics/tcdata.p.h +++ b/src/bubasics/tcdata.p.h @@ -20,57 +20,56 @@ * G - generated by butc */ -struct dumpNode -{ +struct dumpNode { /* administrative fields */ - afs_int32 taskID; /* the task id */ - struct dumpNode *next; /* ptr to the next node on the list */ - statusP statusNodePtr; /* status node pointer */ + afs_int32 taskID; /* the task id */ + struct dumpNode *next; /* ptr to the next node on the list */ + statusP statusNodePtr; /* status node pointer */ /* common to dumps and restores */ - afs_int32 arraySize; /* Size of dump/restore array */ + afs_int32 arraySize; /* Size of dump/restore array */ /* specific to dumps */ char dumpSetName[TC_MAXNAMELEN]; /* name of the dump "." */ - char *dumpName; /* full dump path */ - char *volumeSetName; /* volume set */ + char *dumpName; /* full dump path */ + char *volumeSetName; /* volume set */ struct tc_tapeSet tapeSetDesc; /* description of the tape set */ - struct tc_dumpDesc *dumps; /* list of vols to dump */ - afs_int32 parent; /* parent dump ID, from main call */ - afs_int32 level; /* this dump's level, from main call */ - int doAppend; /* Append this dump to a dump set */ + struct tc_dumpDesc *dumps; /* list of vols to dump */ + afs_int32 parent; /* parent dump ID, from main call */ + afs_int32 level; /* this dump's level, from main call */ + int doAppend; /* Append this dump to a dump set */ /* restore specific */ - struct tc_restoreDesc *restores; /* info needed to restore volumes*/ + struct tc_restoreDesc *restores; /* info needed to restore volumes */ }; -struct deviceSyncNode{ - struct Lock lock; /* this is used to synchronise access to tape drive */ +struct deviceSyncNode { + struct Lock lock; /* this is used to synchronise access to tape drive */ afs_int32 flags; }; /* flags used to monitor status of dumps/restores */ -#define INPROGRESS 0x01 /*dump is in progress */ -#define ABORT 0x02 /*abort this dump */ -#define ABORTED 0x04 /*aborted this dump */ -#define DONE 0x08 /*done with this dump */ -#define WAITING 0x10 /*someone is waiting on this dump */ -#define ERROR 0x20 /*error in operation */ -#define PARTIAL 0x40 /*partial failure in operation */ +#define INPROGRESS 0x01 /*dump is in progress */ +#define ABORT 0x02 /*abort this dump */ +#define ABORTED 0x04 /*aborted this dump */ +#define DONE 0x08 /*done with this dump */ +#define WAITING 0x10 /*someone is waiting on this dump */ +#define ERROR 0x20 /*error in operation */ +#define PARTIAL 0x40 /*partial failure in operation */ /* define the opcodes */ -#define DUMP 0x01 /*dumping */ -#define RESTORE 0x02 /*restoring */ +#define DUMP 0x01 /*dumping */ +#define RESTORE 0x02 /*restoring */ /*these definitions are temporary */ #define TCPORT 7010 #define TCSERVICE_ID 10 -#define TC_GCTIME 300 /* the interval after which the GC is invoked */ -#define TC_ABORTTIME 30 /*time alotted for process to respond to abort */ -#define TC_MAXVOLNAME 64 /*this should come from VNAMESIZE in volume header*/ +#define TC_GCTIME 300 /* the interval after which the GC is invoked */ +#define TC_ABORTTIME 30 /*time alotted for process to respond to abort */ +#define TC_MAXVOLNAME 64 /*this should come from VNAMESIZE in volume header */ /*define some magic numbers to be used with volume headers and trailors on tape */ -#define TC_VOLBEGINMAGIC 0xb0258191 /*32 bit magic numbers */ +#define TC_VOLBEGINMAGIC 0xb0258191 /*32 bit magic numbers */ #define TC_VOLENDMAGIC 0x9167345a #define TC_VOLCONTD 0xffffffff /* @@ -79,20 +78,20 @@ struct deviceSyncNode{ */ #define TC_TRAILERBEGIN "+=!@#$%><%$#@!=+" /*indicates that trailer follows */ #define TC_MAXTAPENAMELEN 100 /*dont know how to estimate these numbers */ -#define TC_DEVICEINUSE 0x1000 /* used to indicate use of device by somebody */ -#define TC_NULLTAPENAME "" /* default tape name */ -#define TC_QUOTEDNULLTAPENAME "\"\"" /* null tapename in quotes */ +#define TC_DEVICEINUSE 0x1000 /* used to indicate use of device by somebody */ +#define TC_NULLTAPENAME "" /* default tape name */ +#define TC_QUOTEDNULLTAPENAME "\"\"" /* null tapename in quotes */ /* for user prompt generation */ -#define READOPCODE 0 /* read tape - for restore */ -#define WRITEOPCODE 1 /* write tape - for dump */ -#define LABELOPCODE 2 /* label a tape */ -#define READLABELOPCODE 3 /* read tape label */ -#define SCANOPCODE 4 /* scan tape contents */ -#define APPENDOPCODE 5 /* append write tape - for dump */ -#define SAVEDBOPCODE 6 /* save a database tape */ -#define RESTOREDBOPCODE 7 /* restore a database tape */ -#define CLOSEOPCODE 8 /* close a tape drive - for callout */ +#define READOPCODE 0 /* read tape - for restore */ +#define WRITEOPCODE 1 /* write tape - for dump */ +#define LABELOPCODE 2 /* label a tape */ +#define READLABELOPCODE 3 /* read tape label */ +#define SCANOPCODE 4 /* scan tape contents */ +#define APPENDOPCODE 5 /* append write tape - for dump */ +#define SAVEDBOPCODE 6 /* save a database tape */ +#define RESTOREDBOPCODE 7 /* restore a database tape */ +#define CLOSEOPCODE 8 /* close a tape drive - for callout */ /* marker used on tape. A header is placed (as a separate block) before the * volume data, and is appended (contiguously with the data) to the volume @@ -104,51 +103,46 @@ struct volumeHeader { char volumeName[TC_MAXVOLNAME]; char pad[2]; afs_int32 volumeID; - afs_int32 server; /* which server */ - afs_int32 part; /* partition vol. was on */ - afs_int32 from; /* clone date of vol ?? */ + afs_int32 server; /* which server */ + afs_int32 part; /* partition vol. was on */ + afs_int32 from; /* clone date of vol ?? */ int frag; - afs_int32 magic; /* just for checking */ + afs_int32 magic; /* just for checking */ afs_int32 contd; char dumpSetName[TC_MAXNAMELEN]; - afs_int32 dumpID; /* ID of enclosing dump */ - afs_int32 level; /* dump level, 0=full */ - afs_int32 parentID; /* ID of parent dump */ + afs_int32 dumpID; /* ID of enclosing dump */ + afs_int32 level; /* dump level, 0=full */ + afs_int32 parentID; /* ID of parent dump */ afs_int32 endTime; - afs_int32 versionflags; /* previously spare[0] */ - afs_int32 cloneDate; /* when this vol. was cloned */ - afs_int32 spares[2]; /* spare used to be spare[4] */ + afs_int32 versionflags; /* previously spare[0] */ + afs_int32 cloneDate; /* when this vol. was cloned */ + afs_int32 spares[2]; /* spare used to be spare[4] */ }; /* Interface structure for STC_LabelTape */ -struct labelTapeIf -{ +struct labelTapeIf { struct tc_tapeLabel label; afs_uint32 taskId; }; -struct scanTapeIf -{ +struct scanTapeIf { afs_int32 addDbFlag; afs_uint32 taskId; }; /* Interface structure for STC_SaveDb */ -struct saveDbIf -{ - Date archiveTime; - afs_uint32 taskId; +struct saveDbIf { + Date archiveTime; + afs_uint32 taskId; statusP statusPtr; }; /* Iterface structure for STC_DeleteDump */ -struct deleteDumpIf -{ - afs_uint32 dumpID; - afs_uint32 taskId; +struct deleteDumpIf { + afs_uint32 dumpID; + afs_uint32 taskId; }; #endif - diff --git a/src/bucoord/bc.p.h b/src/bucoord/bc.p.h index 8cc12e5c4..b675fd35c 100644 --- a/src/bucoord/bc.p.h +++ b/src/bucoord/bc.p.h @@ -14,30 +14,30 @@ * Represents a host in the config database. */ struct bc_hostEntry { - struct bc_hostEntry *next; /*Ptr to next record*/ - char *name; /*Stringname for host*/ - struct sockaddr_in addr; /*Corresponding sockaddr*/ - afs_int32 portOffset; /*Port=standardPort+portOffset-allows multiple TC on a host*/ + struct bc_hostEntry *next; /*Ptr to next record */ + char *name; /*Stringname for host */ + struct sockaddr_in addr; /*Corresponding sockaddr */ + afs_int32 portOffset; /*Port=standardPort+portOffset-allows multiple TC on a host */ }; /* * Global backup program configuration information. */ struct bc_config { - char *path; /*Root directory for config info*/ - struct bc_hostEntry *dbaseHosts; /*Hosts providing the backup database service*/ - struct bc_hostEntry *tapeHosts; /*Hosts providing the tape drives*/ - struct bc_volumeSet *vset; /*List of all volume sets*/ - struct bc_dumpSchedule *dsched; /*Dump schedule list*/ - udbClientTextT configText[TB_NUM]; /* configuration text handles */ - char tmpTextFileNames[TB_NUM][AFSDIR_PATH_MAX]; /* names of temp files created to store config text recd from buserver */ + char *path; /*Root directory for config info */ + struct bc_hostEntry *dbaseHosts; /*Hosts providing the backup database service */ + struct bc_hostEntry *tapeHosts; /*Hosts providing the tape drives */ + struct bc_volumeSet *vset; /*List of all volume sets */ + struct bc_dumpSchedule *dsched; /*Dump schedule list */ + udbClientTextT configText[TB_NUM]; /* configuration text handles */ + char tmpTextFileNames[TB_NUM][AFSDIR_PATH_MAX]; /* names of temp files created to store config text recd from buserver */ }; /* * Central status information relating to per-opcode routine information. */ struct bc_opstatus { - int isCmdLineOpcode; /*Is this the opcode being done for the command line?*/ + int isCmdLineOpcode; /*Is this the opcode being done for the command line? */ }; /* @@ -45,40 +45,40 @@ struct bc_opstatus { * related volumes. Each volume set has a name and a list of volume * descriptions, one for each line in the volumeset configuration file. */ -#define VSFLAG_TEMPORARY 1 /* Volume set is temporary */ +#define VSFLAG_TEMPORARY 1 /* Volume set is temporary */ struct bc_volumeSet { - struct bc_volumeSet *next; /*Ptr to next volume set record*/ - char *name; /*Volume set name*/ - afs_int32 flags; /* flags */ - struct bc_volumeEntry *ventries; /*List of component volume entries*/ + struct bc_volumeSet *next; /*Ptr to next volume set record */ + char *name; /*Volume set name */ + afs_int32 flags; /* flags */ + struct bc_volumeEntry *ventries; /*List of component volume entries */ }; /* * Represents the name of a volume specifier in a volume set. */ struct bc_volumeEntry { - struct bc_volumeEntry *next; /*Ptr to next record in list*/ - char *serverName; /*Host name for volume spec*/ - struct sockaddr_in server; /*Host sockaddr for volume spec*/ - char *partname; /*Partition pattern name*/ - afs_int32 partition; /*Partition number for volume spec*/ - char *name; /*Volume pattern name*/ + struct bc_volumeEntry *next; /*Ptr to next record in list */ + char *serverName; /*Host name for volume spec */ + struct sockaddr_in server; /*Host sockaddr for volume spec */ + char *partname; /*Partition pattern name */ + afs_int32 partition; /*Partition number for volume spec */ + char *name; /*Volume pattern name */ }; /* * Represents an individual volume to be dumped, not a collection. */ struct bc_volumeDump { - struct bc_volumeDump *next; /*Ptr to next record*/ - afs_int32 vid; /*Volume id, or 0 if not known*/ - struct bc_volumeEntry *entry; /*Back pointer: information about server (obs?) */ - char *name; /*Individual volume name*/ - afs_int32 volType; /*Volume type*/ - afs_int32 date; /*From date (for full, incremental or whatever)*/ - afs_int32 cloneDate; /* time of this volume's snapshot */ - afs_int32 partition; /* partition containing this volume */ - struct sockaddr_in server; /* server to obtain data from */ + struct bc_volumeDump *next; /*Ptr to next record */ + afs_int32 vid; /*Volume id, or 0 if not known */ + struct bc_volumeEntry *entry; /*Back pointer: information about server (obs?) */ + char *name; /*Individual volume name */ + afs_int32 volType; /*Volume type */ + afs_int32 date; /*From date (for full, incremental or whatever) */ + afs_int32 cloneDate; /* time of this volume's snapshot */ + afs_int32 partition; /* partition containing this volume */ + struct sockaddr_in server; /* server to obtain data from */ }; /* @@ -86,46 +86,46 @@ struct bc_volumeDump { * safe5 daily incremental) */ struct bc_dumpSchedule { - struct bc_dumpSchedule *next; /*Ptr to next record*/ - char *name; /*Dump sched name*/ - char *vsname; /*Volume set name to dump*/ - afs_int32 period; /*Period in minutes*/ - afs_int32 periodType; /*Qualifier on above, for exceptions like 'monthly'*/ - char *parentName; /*Parent dump schedule name-unused PA*/ - struct bc_dumpSchedule *parent; /*These are built at run-time*/ + struct bc_dumpSchedule *next; /*Ptr to next record */ + char *name; /*Dump sched name */ + char *vsname; /*Volume set name to dump */ + afs_int32 period; /*Period in minutes */ + afs_int32 periodType; /*Qualifier on above, for exceptions like 'monthly' */ + char *parentName; /*Parent dump schedule name-unused PA */ + struct bc_dumpSchedule *parent; /*These are built at run-time */ struct bc_dumpSchedule *firstChild; struct bc_dumpSchedule *nextSibling; - afs_int32 level; /*Level of the dump (do we need this?)*/ - afs_int32 expDate; /* expiration date */ - afs_int32 expType; /* absolute or relative expiration */ + afs_int32 level; /*Level of the dump (do we need this?) */ + afs_int32 expDate; /* expiration date */ + afs_int32 expType; /* absolute or relative expiration */ }; /* * Private: represents a queued dump/restore item. */ struct bc_dumpTask { - int (*callProc)(); + int (*callProc) (); struct bc_config *config; struct bc_volumeDump *volumes; - char *dumpName; /*Dump name we're doing*/ - char *volSetName; /*Volume set we're dumping*/ + char *dumpName; /*Dump name we're doing */ + char *volSetName; /*Volume set we're dumping */ afs_int32 flags; - afs_int32 dumpID; /*Dump ID we're running*/ - int oldFlag; /* if a restore, whether we're doing it to the same vol#s */ + afs_int32 dumpID; /*Dump ID we're running */ + int oldFlag; /* if a restore, whether we're doing it to the same vol#s */ struct sockaddr_in destServer; /* destination server for restore command */ - afs_int32 destPartition; /* destination partition for restore command */ + afs_int32 destPartition; /* destination partition for restore command */ afs_int32 fromDate; /* date from which to do a restore command */ - afs_int32 parentDumpID; /* parent dump ID */ - afs_int32 dumpLevel; /* dump level being performed */ + afs_int32 parentDumpID; /* parent dump ID */ + afs_int32 dumpLevel; /* dump level being performed */ char *newExt; /* new volume extension if any, if oldFlag is false */ - afs_int32 bytesTransferred; /* How many bytes sent */ - afs_int32 volumeBeingDumped; /* the volume being processed */ - afs_int32 *portOffset; /* used to derive the ports of the TCs */ - afs_int32 portCount; /* number of points in the portOffset array */ + afs_int32 bytesTransferred; /* How many bytes sent */ + afs_int32 volumeBeingDumped; /* the volume being processed */ + afs_int32 *portOffset; /* used to derive the ports of the TCs */ + afs_int32 portCount; /* number of points in the portOffset array */ afs_int32 expDate; /* for dumps - expiration date */ afs_int32 expType; /* for dumps - abs. or relative expiration */ - int doAppend; /* for dumps - append this dump to the dump set */ - int dontExecute; /* dont execute the dump or restore */ + int doAppend; /* for dumps - append this dump to the dump set */ + int dontExecute; /* dont execute the dump or restore */ }; #define BC_DI_INUSE 1 /* entry not used */ @@ -136,6 +136,6 @@ struct bc_dumpTask { #define VSNAME "volumeset" #define BC_MAXSIMDUMPS 64 -#define BC_MAXPORTS 128 /* max number of port offsets for volrestore */ +#define BC_MAXPORTS 128 /* max number of port offsets for volrestore */ /* debugging support */ #define dprintf(x) diff --git a/src/bucoord/bc_status.c b/src/bucoord/bc_status.c index 5182b7a03..476b40e79 100644 --- a/src/bucoord/bc_status.c +++ b/src/bucoord/bc_status.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -42,11 +43,11 @@ RCSID("$Header$"); /* globals for backup coordinator status management */ -dlqlinkT statusHead; /* chain of status blocks */ -struct Lock statusQueueLock; /* access control for status chain */ -struct Lock cmdLineLock; /* lock on the cmdLine */ +dlqlinkT statusHead; /* chain of status blocks */ +struct Lock statusQueueLock; /* access control for status chain */ +struct Lock cmdLineLock; /* lock on the cmdLine */ -afs_int32 lastTaskCode; /* Error code from task that last finished */ +afs_int32 lastTaskCode; /* Error code from task that last finished */ /* nextItem * get next item for status interrogation, if any. @@ -55,24 +56,23 @@ static statusP nextItem(linkPtr) statusP linkPtr; { - dlqlinkP ptr; + dlqlinkP ptr; ptr = (dlqlinkP) linkPtr; /* if last known item has terminated, reset ptr */ - if ( ptr == 0 ) - { + if (ptr == 0) { ptr = &statusHead; - if ( dlqEmpty(ptr) ) - return(0); + if (dlqEmpty(ptr)) + return (0); } ptr = ptr->dlq_next; /* if we're back at the head again */ - if ( ptr == &statusHead ) - return(0); - return((statusP) ptr); + if (ptr == &statusHead) + return (0); + return ((statusP) ptr); } #ifdef notdef @@ -80,26 +80,24 @@ static statusP nextItem(linkPtr) statusP linkPtr; { - dlqlinkP ptr; + dlqlinkP ptr; ptr = (dlqlinkP) linkPtr; /* if last known item has terminated, reset ptr */ - if ( ptr == 0 ) - { + if (ptr == 0) { ptr = &statusHead; - if ( dlqEmpty(ptr) ) - return(0); + if (dlqEmpty(ptr)) + return (0); } ptr = ptr->dlq_next; /* if we're back at the head again */ - if ( ptr == &statusHead ) - { + if (ptr == &statusHead) { ptr = ptr->dlq_next; } - return((statusP) ptr); + return ((statusP) ptr); } #endif /* notdef */ @@ -108,8 +106,8 @@ char *cmdLine; cmdDispatch() { #define MAXV 100 - char **targv[MAXV]; /*Ptr to parsed argv stuff*/ - afs_int32 targc; /*Num parsed arguments*/ + char **targv[MAXV]; /*Ptr to parsed argv stuff */ + afs_int32 targc; /*Num parsed arguments */ afs_int32 code; char *internalCmdLine; @@ -118,11 +116,11 @@ cmdDispatch() code = cmd_ParseLine(internalCmdLine, targv, &targc, MAXV); if (code) { - printf("Couldn't parse line: '%s'", error_message(code)); - return(1); + printf("Couldn't parse line: '%s'", error_message(code)); + return (1); } free(internalCmdLine); - + /* * Because the "-at" option cannot be wildcarded, we cannot fall * into recusive loop here by setting dispatchCount to 1. @@ -133,7 +131,7 @@ cmdDispatch() statusWatcher() { - struct rx_connection *tconn = (struct rc_connection *)0; + struct rx_connection *tconn = (struct rc_connection *)0; statusP curPollPtr = 0; struct tciStatusS statusPtr; @@ -141,39 +139,38 @@ statusWatcher() /* task information */ afs_uint32 taskFlags; afs_uint32 localTaskFlags; - afs_uint32 temp; /* for flag manipulation */ + afs_uint32 temp; /* for flag manipulation */ afs_int32 jobNumber; afs_int32 taskId; afs_int32 port; afs_int32 atTime; PROCESS dispatchPid; - + afs_int32 code = 0; extern struct bc_config *bc_globalConfig; extern struct rx_connection *bc_GetConn(); lastTaskCode = 0; - while ( 1 ) - { /*w*/ - if (tconn) rx_DestroyConnection(tconn); + while (1) { /*w */ + if (tconn) + rx_DestroyConnection(tconn); tconn = (struct rc_connection *)0; lock_Status(); curPollPtr = nextItem(curPollPtr); - if ( curPollPtr == 0 ) - { + if (curPollPtr == 0) { #ifdef AFS_PTHREAD_ENV struct timespec delaytime; unlock_Status(); - delayTime.tv_sec = 5; + delayTime.tv_sec = 5; delayTime.tv_nsec = 0; pthread_delay_np(&delayTime); #else unlock_Status(); - IOMGR_Sleep(5); /* wait a while */ -#endif /*else AFS_PTHREAD_ENV*/ + IOMGR_Sleep(5); /* wait a while */ +#endif /*else AFS_PTHREAD_ENV */ continue; } @@ -189,21 +186,19 @@ statusWatcher() CLEAR_FLAG(ABORT_LOCAL); /* An abort request before the command even started */ - if ( atTime && (localTaskFlags & ABORT_REQUEST) ) - { + if (atTime && (localTaskFlags & ABORT_REQUEST)) { if (localTaskFlags & NOREMOVE) { - curPollPtr->flags |= (STARTING|ABORT_DONE); /* Will ignore on other passes */ - curPollPtr->scheduledDump = 0; + curPollPtr->flags |= (STARTING | ABORT_DONE); /* Will ignore on other passes */ + curPollPtr->scheduledDump = 0; } else { - deleteStatusNode(curPollPtr); + deleteStatusNode(curPollPtr); } curPollPtr = 0; continue; } /* A task not started yet - check its start time */ - if ( localTaskFlags & STARTING || atTime ) - { + if (localTaskFlags & STARTING || atTime) { /* * Start a timed dump if its time has come. When the job is * started, it will allocate its own status structure so this @@ -212,85 +207,75 @@ statusWatcher() * Avoid multiple processes trouncing the cmdLine by placing * lock around it. */ - if ( atTime && (atTime <= time(0)) ) - { - lock_cmdLine(); /* Will unlock in cmdDispatch */ + if (atTime && (atTime <= time(0))) { + lock_cmdLine(); /* Will unlock in cmdDispatch */ - cmdLine = curPollPtr->cmdLine; + cmdLine = curPollPtr->cmdLine; lock_Status(); curPollPtr->cmdLine = 0; unlock_Status(); - printf("Starting scheduled dump: job %d\n", jobNumber); - printf("schedD> %s\n", cmdLine); + printf("Starting scheduled dump: job %d\n", jobNumber); + printf("schedD> %s\n", cmdLine); - code = LWP_CreateProcess(cmdDispatch, 16384, - LWP_NORMAL_PRIORITY, (void *) 2, - "cmdDispatch", &dispatchPid); - if ( code ) - { - if (cmdLine) - free(cmdLine); + code = + LWP_CreateProcess(cmdDispatch, 16384, LWP_NORMAL_PRIORITY, + (void *)2, "cmdDispatch", &dispatchPid); + if (code) { + if (cmdLine) + free(cmdLine); unlock_cmdLine(); printf("Couldn't create cmdDispatch task\n"); } if (localTaskFlags & NOREMOVE) { - curPollPtr->flags |= STARTING; /* Will ignore on other passes */ - curPollPtr->flags |= (code?TASK_ERROR:TASK_DONE); - curPollPtr->scheduledDump = 0; + curPollPtr->flags |= STARTING; /* Will ignore on other passes */ + curPollPtr->flags |= (code ? TASK_ERROR : TASK_DONE); + curPollPtr->scheduledDump = 0; } else { - deleteStatusNode(curPollPtr); + deleteStatusNode(curPollPtr); } curPollPtr = 0; } continue; } - if ( localTaskFlags & ABORT_LOCAL ) - { + if (localTaskFlags & ABORT_LOCAL) { /* kill the local task */ - if ( (localTaskFlags & CONTACT_LOST) != 0 ) - { - printf("Job %d: in contact with butc at port %d\n", - jobNumber, port); + if ((localTaskFlags & CONTACT_LOST) != 0) { + printf("Job %d: in contact with butc at port %d\n", jobNumber, + port); printf("Job %d cont: Local kill ignored - use normal kill\n", jobNumber); } } - code = (afs_int32)bc_GetConn(bc_globalConfig, port, &tconn); - if (code) - { + code = (afs_int32) bc_GetConn(bc_globalConfig, port, &tconn); + if (code) { SET_FLAG(CONTACT_LOST); continue; } - if ( CheckTCVersion(tconn) ) - { + if (CheckTCVersion(tconn)) { SET_FLAG(CONTACT_LOST); continue; } /* Send abort to TC requst if we have to */ - if ( localTaskFlags & ABORT_REQUEST ) - { + if (localTaskFlags & ABORT_REQUEST) { code = TC_RequestAbort(tconn, taskId); - if ( code ) - { + if (code) { com_err("statusWatcher", code, "; Can't post abort request"); - com_err("statusWatcher", 0, "...Deleting job"); + com_err("statusWatcher", 0, "...Deleting job"); if (localTaskFlags & NOREMOVE) { - curPollPtr->flags |= (STARTING|TASK_ERROR); - curPollPtr->scheduledDump = 0; + curPollPtr->flags |= (STARTING | TASK_ERROR); + curPollPtr->scheduledDump = 0; } else { - deleteStatusNode(curPollPtr); + deleteStatusNode(curPollPtr); } curPollPtr = 0; continue; - } - else - { + } else { lock_Status(); curPollPtr->flags &= ~ABORT_REQUEST; curPollPtr->flags |= ABORT_SENT; @@ -300,21 +285,19 @@ statusWatcher() /* otherwise just get the status */ code = TC_GetStatus(tconn, taskId, &statusPtr); - if (code) - { - if (code == TC_NODENOTFOUND) - { - printf("Job %d: %s - no such task on port %d, deleting\n", - jobNumber, curPollPtr->taskName, port); + if (code) { + if (code == TC_NODENOTFOUND) { + printf("Job %d: %s - no such task on port %d, deleting\n", + jobNumber, curPollPtr->taskName, port); if (localTaskFlags & NOREMOVE) { - curPollPtr->flags |= (STARTING|TASK_ERROR); - curPollPtr->scheduledDump = 0; + curPollPtr->flags |= (STARTING | TASK_ERROR); + curPollPtr->scheduledDump = 0; } else { - deleteStatusNode(curPollPtr); /* delete this status node */ + deleteStatusNode(curPollPtr); /* delete this status node */ } curPollPtr = 0; - continue; + continue; } SET_FLAG(CONTACT_LOST); @@ -331,8 +314,10 @@ statusWatcher() lock_Status(); /* remember some status flags in local struct */ - temp = (DRIVE_WAIT | OPR_WAIT | CALL_WAIT | TASK_DONE | ABORT_DONE | TASK_ERROR); - curPollPtr->flags &= ~temp; /* clear */ + temp = + (DRIVE_WAIT | OPR_WAIT | CALL_WAIT | TASK_DONE | ABORT_DONE | + TASK_ERROR); + curPollPtr->flags &= ~temp; /* clear */ curPollPtr->flags |= (taskFlags & temp); /* update */ curPollPtr->dbDumpId = statusPtr.dbDumpId; @@ -343,50 +328,49 @@ statusWatcher() unlock_Status(); /* Are we done */ - if (taskFlags & TASK_DONE) - { /*done*/ - if (taskFlags & ABORT_DONE) - { - if (curPollPtr->dbDumpId) - printf("Job %d: %s: DumpID %u Aborted", - jobNumber, curPollPtr->taskName, curPollPtr->dbDumpId); + if (taskFlags & TASK_DONE) { /*done */ + if (taskFlags & ABORT_DONE) { + if (curPollPtr->dbDumpId) + printf("Job %d: %s: DumpID %u Aborted", jobNumber, + curPollPtr->taskName, curPollPtr->dbDumpId); else - printf("Job %d: %s Aborted", jobNumber, curPollPtr->taskName); + printf("Job %d: %s Aborted", jobNumber, + curPollPtr->taskName); + + if (taskFlags & TASK_ERROR) + printf(" with errors\n"); + else + printf("\n"); - if ( taskFlags & TASK_ERROR ) printf(" with errors\n"); - else printf("\n"); - lastTaskCode = 1; } - else if (taskFlags & TASK_ERROR) - { - if ( !(localTaskFlags & SILENT) ) { - if (curPollPtr->dbDumpId) - printf("Job %d: DumpID %u Failed with errors\n", - jobNumber, curPollPtr->dbDumpId); - else - printf("Job %d Failed with errors\n", jobNumber); + else if (taskFlags & TASK_ERROR) { + if (!(localTaskFlags & SILENT)) { + if (curPollPtr->dbDumpId) + printf("Job %d: DumpID %u Failed with errors\n", + jobNumber, curPollPtr->dbDumpId); + else + printf("Job %d Failed with errors\n", jobNumber); } lastTaskCode = 2; } - else - { - if ( !(localTaskFlags & SILENT) ) - { + else { + if (!(localTaskFlags & SILENT)) { if (curPollPtr->dbDumpId) - printf("Job %d: %s: DumpID %u finished", - jobNumber, curPollPtr->taskName, curPollPtr->dbDumpId); + printf("Job %d: %s: DumpID %u finished", jobNumber, + curPollPtr->taskName, curPollPtr->dbDumpId); else - printf("Job %d: %s finished", jobNumber, curPollPtr->taskName); - - if (curPollPtr->volsTotal) - { - printf(". %d volumes dumped", (curPollPtr->volsTotal- - curPollPtr->volsFailed)); - if ( curPollPtr->volsFailed) - printf(", %d failed", curPollPtr->volsFailed); + printf("Job %d: %s finished", jobNumber, + curPollPtr->taskName); + + if (curPollPtr->volsTotal) { + printf(". %d volumes dumped", + (curPollPtr->volsTotal - + curPollPtr->volsFailed)); + if (curPollPtr->volsFailed) + printf(", %d failed", curPollPtr->volsFailed); } printf("\n"); @@ -396,19 +380,19 @@ statusWatcher() /* make call to destroy task on server */ code = TC_EndStatus(tconn, taskId); - if ( code ) - printf("Job %d: %s, error in job termination cleanup\n", - jobNumber, curPollPtr->taskName); - + if (code) + printf("Job %d: %s, error in job termination cleanup\n", + jobNumber, curPollPtr->taskName); + if (localTaskFlags & NOREMOVE) { - curPollPtr->flags |= STARTING; - curPollPtr->scheduledDump = 0; + curPollPtr->flags |= STARTING; + curPollPtr->scheduledDump = 0; } else { - deleteStatusNode(curPollPtr); /* unlink and destroy local task */ + deleteStatusNode(curPollPtr); /* unlink and destroy local task */ } curPollPtr = 0; - } /*done*/ - } /*w*/ + } /*done */ + } /*w */ } /* bc_jobNumber @@ -424,16 +408,15 @@ bc_jobNumber() dlqlinkP ptr; ptr = statusHead.dlq_next; - while ( ptr != &statusHead ) - { + while (ptr != &statusHead) { /* compute max of all job numbers */ - if ( ((statusP) ptr)->jobNumber > retval ) + if (((statusP) ptr)->jobNumber > retval) retval = ((statusP) ptr)->jobNumber; ptr = ptr->dlq_next; } retval++; - return(retval); + return (retval); } /* waitForTask @@ -442,32 +425,32 @@ bc_jobNumber() * had been cleaned up, then just return 0. */ waitForTask(taskId) - afs_uint32 taskId; + afs_uint32 taskId; { statusP ptr; - afs_int32 done=0, rcode, t; + afs_int32 done = 0, rcode, t; extern statusP findStatus(); t = (TASK_DONE | ABORT_DONE | TASK_ERROR); while (!done) { - /* Sleep 2 seconds */ + /* Sleep 2 seconds */ #ifdef AFS_PTHREAD_ENV - struct timespec delaytime; - delayTime.tv_sec = 2; - delayTime.tv_nsec = 0; - pthread_delay_np(&delayTime); + struct timespec delaytime; + delayTime.tv_sec = 2; + delayTime.tv_nsec = 0; + pthread_delay_np(&delayTime); #else - IOMGR_Sleep(2); -#endif /*else AFS_PTHREAD_ENV*/ - - /* Check if we are done */ - lock_Status(); - ptr = findStatus(taskId); - if (!ptr || (ptr->flags & t)) { - rcode = (ptr ? ptr->flags : 0); - done=1; - } - unlock_Status(); + IOMGR_Sleep(2); +#endif /*else AFS_PTHREAD_ENV */ + + /* Check if we are done */ + lock_Status(); + ptr = findStatus(taskId); + if (!ptr || (ptr->flags & t)) { + rcode = (ptr ? ptr->flags : 0); + done = 1; + } + unlock_Status(); } return rcode; } diff --git a/src/bucoord/btest.c b/src/bucoord/btest.c index da98da543..a6d18170d 100644 --- a/src/bucoord/btest.c +++ b/src/bucoord/btest.c @@ -19,15 +19,18 @@ #include "AFS_component_version_number.c" main(argc, argv) -int argc; -char **argv; { + int argc; + char **argv; +{ struct rx_securityClass *rxsc; register struct rx_connection *tconn; register afs_int32 code; rx_Init(0); rxsc = rxnull_NewClientSecurityObject(); - tconn = rx_NewConnection(htonl(0x7f000001), htons(BC_MESSAGEPORT), 1, rxsc, 0); + tconn = + rx_NewConnection(htonl(0x7f000001), htons(BC_MESSAGEPORT), 1, rxsc, + 0); code = BC_Print(tconn, 1, 2, argv[1]); printf("Done, code %d\n", code); exit(0); diff --git a/src/bucoord/commands.c b/src/bucoord/commands.c index 2dce30775..aca15b848 100644 --- a/src/bucoord/commands.c +++ b/src/bucoord/commands.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -46,7 +47,8 @@ RCSID("$Header$"); extern struct bc_config *bc_globalConfig; extern char *ktime_GetDateUsage(); extern struct bc_dumpSchedule *bc_FindDumpSchedule(); -extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cfg, char *name); +extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cfg, + char *name); extern struct bc_dumpTask bc_dumpTasks[BC_MAXSIMDUMPS]; extern struct ubik_client *cstruct; extern int bc_Dumper(); /* function to do dumps */ @@ -70,294 +72,317 @@ extern afs_int32 lastTaskCode; #define HOSTADDR(sockaddr) (sockaddr)->sin_addr.s_addr #endif -int bc_EvalVolumeSet(aconfig, avs, avols, uclient) - struct bc_config *aconfig; - register struct bc_volumeSet *avs; - struct bc_volumeDump **avols; - struct ubik_client *uclient; -{ /*bc_EvalVolumeSet*/ - int code; - int a,b,c; - static afs_int32 use=2; - - if (use == 2) { /* Use EvalVolumeSet2() */ - code = EvalVolumeSet2(aconfig, avs, avols, uclient); - if (code == RXGEN_OPCODE) use = 1; - } - if (use == 1) { /* Use EvalVolumeSet1() */ - code = EvalVolumeSet1(aconfig, avs, avols, uclient); - } - return code; -} /*bc_EvalVolumeSet*/ +int +bc_EvalVolumeSet(aconfig, avs, avols, uclient) + struct bc_config *aconfig; + register struct bc_volumeSet *avs; + struct bc_volumeDump **avols; + struct ubik_client *uclient; +{ /*bc_EvalVolumeSet */ + int code; + int a, b, c; + static afs_int32 use = 2; + + if (use == 2) { /* Use EvalVolumeSet2() */ + code = EvalVolumeSet2(aconfig, avs, avols, uclient); + if (code == RXGEN_OPCODE) + use = 1; + } + if (use == 1) { /* Use EvalVolumeSet1() */ + code = EvalVolumeSet1(aconfig, avs, avols, uclient); + } + return code; +} /*bc_EvalVolumeSet */ struct partitionsort { - afs_int32 part; - struct bc_volumeDump *vdlist; - struct bc_volumeDump *lastvdlist; - struct bc_volumeDump *dupvdlist; - struct bc_volumeEntry *vole; - struct partitionsort *next; + afs_int32 part; + struct bc_volumeDump *vdlist; + struct bc_volumeDump *lastvdlist; + struct bc_volumeDump *dupvdlist; + struct bc_volumeEntry *vole; + struct partitionsort *next; }; struct serversort { - afs_uint32 ipaddr; - struct partitionsort *partitions; - struct serversort *next; + afs_uint32 ipaddr; + struct partitionsort *partitions; + struct serversort *next; }; -afs_int32 getSPEntries(server, partition, serverlist, ss, ps) - afs_uint32 server; - afs_int32 partition; - struct serversort **serverlist, **ss; - struct partitionsort **ps; +afs_int32 +getSPEntries(server, partition, serverlist, ss, ps) + afs_uint32 server; + afs_int32 partition; + struct serversort **serverlist, **ss; + struct partitionsort **ps; { - if (!(*ss) || ((*ss)->ipaddr != server)) { - *ps = 0; - for ((*ss)=*serverlist; (*ss); *ss=(*ss)->next) { - if ((*ss)->ipaddr == server) - break; - } - } - /* No server entry added. Add one */ - if (!(*ss)) { - *ss = (struct serversort *) malloc(sizeof(struct serversort)); - if (!(*ss)) { - com_err(whoami, BC_NOMEM, ""); - *ss = 0; - return(BC_NOMEM); - } - memset(*ss, 0, sizeof(struct serversort)); - (*ss)->ipaddr = server; - (*ss)->next = *serverlist; - *serverlist = *ss; - } - - - if (!(*ps) || ((*ps)->part != partition)) { - for (*ps=(*ss)->partitions; *ps; *ps=(*ps)->next) { - if ((*ps)->part == partition) - break; - } - } - /* No partition entry added. Add one */ - if (!(*ps)) { - *ps = (struct partitionsort *) malloc(sizeof(struct partitionsort)); - if (!(*ps)) { - com_err(whoami, BC_NOMEM, ""); - free (*ss); - *ps = 0; - *ss = 0; - return(BC_NOMEM); - } - memset(*ps, 0, sizeof(struct partitionsort)); - (*ps)->part = partition; - (*ps)->next = (*ss)->partitions; - (*ss)->partitions = *ps; - } - return 0; + if (!(*ss) || ((*ss)->ipaddr != server)) { + *ps = 0; + for ((*ss) = *serverlist; (*ss); *ss = (*ss)->next) { + if ((*ss)->ipaddr == server) + break; + } + } + /* No server entry added. Add one */ + if (!(*ss)) { + *ss = (struct serversort *)malloc(sizeof(struct serversort)); + if (!(*ss)) { + com_err(whoami, BC_NOMEM, ""); + *ss = 0; + return (BC_NOMEM); + } + memset(*ss, 0, sizeof(struct serversort)); + (*ss)->ipaddr = server; + (*ss)->next = *serverlist; + *serverlist = *ss; + } + + + if (!(*ps) || ((*ps)->part != partition)) { + for (*ps = (*ss)->partitions; *ps; *ps = (*ps)->next) { + if ((*ps)->part == partition) + break; + } + } + /* No partition entry added. Add one */ + if (!(*ps)) { + *ps = (struct partitionsort *)malloc(sizeof(struct partitionsort)); + if (!(*ps)) { + com_err(whoami, BC_NOMEM, ""); + free(*ss); + *ps = 0; + *ss = 0; + return (BC_NOMEM); + } + memset(*ps, 0, sizeof(struct partitionsort)); + (*ps)->part = partition; + (*ps)->next = (*ss)->partitions; + (*ss)->partitions = *ps; + } + return 0; } -afs_int32 randSPEntries(serverlist, avols) - struct serversort *serverlist; - struct bc_volumeDump **avols; +afs_int32 +randSPEntries(serverlist, avols) + struct serversort *serverlist; + struct bc_volumeDump **avols; { - struct serversort *ss, **pss, *tss; - struct partitionsort *ps, **pps; - afs_int32 r; - afs_int32 scount, pcount; - - *avols = 0; - - /* Seed random number generator */ - r = time(0) + getpid(); - srand(r); - - /* Count number of servers, remove one at a time */ - for (scount=0, ss=serverlist; ss; ss=ss->next, scount++); - for (; scount; scount--) { - /* Pick a random server in list and remove it */ - r = (rand()>>4) % scount; - for (pss=&serverlist, ss=serverlist; r; - pss=&ss->next, ss=ss->next, r--); - *pss = ss->next; - - /* Count number of partitions, remove one at a time */ - for (pcount=0, ps=ss->partitions; ps; ps=ps->next, pcount++); - for (; pcount; pcount--) { - /* Pick a random parition in list and remove it */ - r = (rand()>>4) % pcount; - for (pps=&ss->partitions, ps=ss->partitions; r; - pps=&ps->next, ps=ps->next, r--); - *pps = ps->next; - - ps->lastvdlist->next = *avols; - *avols = ps->vdlist; - free(ps); - } - free(ss); - } + struct serversort *ss, **pss, *tss; + struct partitionsort *ps, **pps; + afs_int32 r; + afs_int32 scount, pcount; + + *avols = 0; + + /* Seed random number generator */ + r = time(0) + getpid(); + srand(r); + + /* Count number of servers, remove one at a time */ + for (scount = 0, ss = serverlist; ss; ss = ss->next, scount++); + for (; scount; scount--) { + /* Pick a random server in list and remove it */ + r = (rand() >> 4) % scount; + for (pss = &serverlist, ss = serverlist; r; + pss = &ss->next, ss = ss->next, r--); + *pss = ss->next; + + /* Count number of partitions, remove one at a time */ + for (pcount = 0, ps = ss->partitions; ps; ps = ps->next, pcount++); + for (; pcount; pcount--) { + /* Pick a random parition in list and remove it */ + r = (rand() >> 4) % pcount; + for (pps = &ss->partitions, ps = ss->partitions; r; + pps = &ps->next, ps = ps->next, r--); + *pps = ps->next; + + ps->lastvdlist->next = *avols; + *avols = ps->vdlist; + free(ps); + } + free(ss); + } } -int EvalVolumeSet2(aconfig, avs, avols, uclient) - struct bc_config *aconfig; - struct bc_volumeSet *avs; - struct bc_volumeDump **avols; - struct ubik_client *uclient; -{ /*EvalVolumeSet2*/ - struct bc_volumeEntry *tve; - struct bc_volumeDump *tavols; - struct VldbListByAttributes attributes; - afs_int32 si, nsi; /* startIndex and nextStartIndex */ - afs_int32 nentries, e, ei, et, add, l; - nbulkentries bulkentries; - struct nvldbentry *entries=0; - struct bc_volumeDump *tvd; - afs_int32 code=0, tcode; - afs_int32 count=0; - struct serversort *servers=0, *lastserver=0, *ss=0, *nss; - struct partitionsort *ps=0, *nps; - - *avols = (struct bc_volumeDump *) 0; - bulkentries.nbulkentries_len = 0; - bulkentries.nbulkentries_val = 0; - - /* For each of the volume set entries - collect the volumes that match it */ - for (tve=avs->ventries; tve; tve=tve->next) { - /* Put together a call to the vlserver for this vlentry. The - * performance gain is from letting the vlserver expand the - * volumeset and not this routine. - */ - attributes.Mask = 0; - if (tve->server.sin_addr.s_addr) { /* The server */ - attributes.Mask |= VLLIST_SERVER; - attributes.server = tve->server.sin_addr.s_addr; - } - if (tve->partition != -1) { /* The partition */ - attributes.Mask |= VLLIST_PARTITION; - attributes.partition = tve->partition; - } - - /* Now make the call to the vlserver */ - for (si=0; si != -1; si=nsi) { - nentries = 0; - bulkentries.nbulkentries_len = 0; - bulkentries.nbulkentries_val = 0; - nsi = -1; - tcode = ubik_Call(VL_ListAttributesN2, uclient, 0, - &attributes, tve->name, si, - &nentries, &bulkentries, &nsi); - if (tcode) ERROR(tcode); - - /* The 3.4 vlserver has a VL_ListAttributesN2() RPC call, but - * it is not complete. The only way to tell if it is not complete - * is if et == 0 (which we check for below). Also, if the call didn't - * match any entries, then we don't know what version the vlserver - * is. In both cases, we return RXGEN_OPCODE and the calling routine - * will switch to the EvalVolumeSet1() call. +int +EvalVolumeSet2(aconfig, avs, avols, uclient) + struct bc_config *aconfig; + struct bc_volumeSet *avs; + struct bc_volumeDump **avols; + struct ubik_client *uclient; +{ /*EvalVolumeSet2 */ + struct bc_volumeEntry *tve; + struct bc_volumeDump *tavols; + struct VldbListByAttributes attributes; + afs_int32 si, nsi; /* startIndex and nextStartIndex */ + afs_int32 nentries, e, ei, et, add, l; + nbulkentries bulkentries; + struct nvldbentry *entries = 0; + struct bc_volumeDump *tvd; + afs_int32 code = 0, tcode; + afs_int32 count = 0; + struct serversort *servers = 0, *lastserver = 0, *ss = 0, *nss; + struct partitionsort *ps = 0, *nps; + + *avols = (struct bc_volumeDump *)0; + bulkentries.nbulkentries_len = 0; + bulkentries.nbulkentries_val = 0; + + /* For each of the volume set entries - collect the volumes that match it */ + for (tve = avs->ventries; tve; tve = tve->next) { + /* Put together a call to the vlserver for this vlentry. The + * performance gain is from letting the vlserver expand the + * volumeset and not this routine. */ - if (nentries == 0) ERROR(RXGEN_OPCODE); /* Use EvalVolumeSet1 */ - - /* Step through each entry and add it to the list of volumes */ - entries = bulkentries.nbulkentries_val; - for (e=0; e> 16) & 0xffff; - switch (et) { - case ITSRWVOL: {et = RWVOL; break;} - case ITSBACKVOL:{et = BACKVOL; break;} - case ITSROVOL: {et = ROVOL; break;} - default: ERROR(RXGEN_OPCODE); /* Use EvalVolumeSet1 */ - } - - /* Find server and partiton structure to hang the entry off of */ - tcode = getSPEntries(entries[e].serverNumber[ei], - entries[e].serverPartition[ei], - &servers, &ss, &ps); - if (tcode) { - com_err(whoami, tcode, ""); - ERROR(tcode); - } - - /* Detect if this entry should be added (not a duplicate). - * Use ps->dupvdlist and ps->vole to only search volumes from - * previous volume set entries. - */ - add = 1; - if (tve != avs->ventries) { - l = strlen(entries[e].name); - if (ps->vole != tve) { - ps->vole = tve; - ps->dupvdlist = ps->vdlist; - } - for (tavols=ps->dupvdlist; add && tavols; tavols=tavols->next) { - if (strncmp(tavols->name, entries[e].name, l) == 0) { - if ( (strcmp(&entries[e].name[l], ".backup") == 0) || - (strcmp(&entries[e].name[l], ".readonly") == 0) || - (strcmp(&entries[e].name[l], "") == 0) ) - add = 0; - } - } - } - - if (add) { - /* Allocate a volume dump structure and its name */ - tvd = (struct bc_volumeDump *) malloc(sizeof(struct bc_volumeDump)); - if (!tvd) { - com_err(whoami, BC_NOMEM, ""); - ERROR(BC_NOMEM); - } - memset(tvd, 0, sizeof(*tvd)); - - tvd->name = (char *) malloc(strlen(entries[e].name)+10); - if (!(tvd->name)) { - com_err(whoami, BC_NOMEM, ""); - free(tvd); - ERROR(BC_NOMEM); - } - - /* Fill it in and thread onto avols list */ - strcpy(tvd->name, entries[e].name); - if (et == BACKVOL) strcat(tvd->name, ".backup"); - else if (et == ROVOL) strcat(tvd->name, ".readonly"); - tvd->vid = entries[e].volumeId[et]; - tvd->entry = tve; - tvd->volType = et; - tvd->partition = entries[e].serverPartition[ei]; - tvd->server.sin_addr.s_addr = entries[e].serverNumber[ei]; - tvd->server.sin_port = 0; /* default FS port */ - tvd->server.sin_family = AF_INET; + attributes.Mask = 0; + if (tve->server.sin_addr.s_addr) { /* The server */ + attributes.Mask |= VLLIST_SERVER; + attributes.server = tve->server.sin_addr.s_addr; + } + if (tve->partition != -1) { /* The partition */ + attributes.Mask |= VLLIST_PARTITION; + attributes.partition = tve->partition; + } + + /* Now make the call to the vlserver */ + for (si = 0; si != -1; si = nsi) { + nentries = 0; + bulkentries.nbulkentries_len = 0; + bulkentries.nbulkentries_val = 0; + nsi = -1; + tcode = + ubik_Call(VL_ListAttributesN2, uclient, 0, &attributes, + tve->name, si, &nentries, &bulkentries, &nsi); + if (tcode) + ERROR(tcode); + + /* The 3.4 vlserver has a VL_ListAttributesN2() RPC call, but + * it is not complete. The only way to tell if it is not complete + * is if et == 0 (which we check for below). Also, if the call didn't + * match any entries, then we don't know what version the vlserver + * is. In both cases, we return RXGEN_OPCODE and the calling routine + * will switch to the EvalVolumeSet1() call. + */ + if (nentries == 0) + ERROR(RXGEN_OPCODE); /* Use EvalVolumeSet1 */ + + /* Step through each entry and add it to the list of volumes */ + entries = bulkentries.nbulkentries_val; + for (e = 0; e < nentries; e++) { + ei = entries[e].matchindex & 0xffff; + et = (entries[e].matchindex >> 16) & 0xffff; + switch (et) { + case ITSRWVOL:{ + et = RWVOL; + break; + } + case ITSBACKVOL:{ + et = BACKVOL; + break; + } + case ITSROVOL:{ + et = ROVOL; + break; + } + default: + ERROR(RXGEN_OPCODE); /* Use EvalVolumeSet1 */ + } + + /* Find server and partiton structure to hang the entry off of */ + tcode = + getSPEntries(entries[e].serverNumber[ei], + entries[e].serverPartition[ei], &servers, + &ss, &ps); + if (tcode) { + com_err(whoami, tcode, ""); + ERROR(tcode); + } + + /* Detect if this entry should be added (not a duplicate). + * Use ps->dupvdlist and ps->vole to only search volumes from + * previous volume set entries. + */ + add = 1; + if (tve != avs->ventries) { + l = strlen(entries[e].name); + if (ps->vole != tve) { + ps->vole = tve; + ps->dupvdlist = ps->vdlist; + } + for (tavols = ps->dupvdlist; add && tavols; + tavols = tavols->next) { + if (strncmp(tavols->name, entries[e].name, l) == 0) { + if ((strcmp(&entries[e].name[l], ".backup") == 0) + || (strcmp(&entries[e].name[l], ".readonly") + == 0) + || (strcmp(&entries[e].name[l], "") == 0)) + add = 0; + } + } + } + + if (add) { + /* Allocate a volume dump structure and its name */ + tvd = (struct bc_volumeDump *) + malloc(sizeof(struct bc_volumeDump)); + if (!tvd) { + com_err(whoami, BC_NOMEM, ""); + ERROR(BC_NOMEM); + } + memset(tvd, 0, sizeof(*tvd)); + + tvd->name = (char *)malloc(strlen(entries[e].name) + 10); + if (!(tvd->name)) { + com_err(whoami, BC_NOMEM, ""); + free(tvd); + ERROR(BC_NOMEM); + } + + /* Fill it in and thread onto avols list */ + strcpy(tvd->name, entries[e].name); + if (et == BACKVOL) + strcat(tvd->name, ".backup"); + else if (et == ROVOL) + strcat(tvd->name, ".readonly"); + tvd->vid = entries[e].volumeId[et]; + tvd->entry = tve; + tvd->volType = et; + tvd->partition = entries[e].serverPartition[ei]; + tvd->server.sin_addr.s_addr = entries[e].serverNumber[ei]; + tvd->server.sin_port = 0; /* default FS port */ + tvd->server.sin_family = AF_INET; #ifdef STRUCT_SOCKADDR_HAS_SA_LEN - tvd->server.sin_len = sizeof(struct sockaddr_in); -#endif - - /* String tvd off of partition struct */ - tvd->next = ps->vdlist; - ps->vdlist = tvd; - if (!tvd->next) - ps->lastvdlist = tvd; - - count++; - } - } - - /* Free memory allocated during VL call */ - if (bulkentries.nbulkentries_val) { - free((char *)bulkentries.nbulkentries_val); - bulkentries.nbulkentries_val = 0; - entries = 0; - } - } - } - - /* Randomly link the volumedump entries together */ - randSPEntries(servers, avols); - fprintf (stderr, "Total number of volumes : %u\n", count); - - error_exit: - if (bulkentries.nbulkentries_val) { - free((char *)bulkentries.nbulkentries_val); - } - return(code); -} /*EvalVolumeSet2*/ + tvd->server.sin_len = sizeof(struct sockaddr_in); +#endif + + /* String tvd off of partition struct */ + tvd->next = ps->vdlist; + ps->vdlist = tvd; + if (!tvd->next) + ps->lastvdlist = tvd; + + count++; + } + } + + /* Free memory allocated during VL call */ + if (bulkentries.nbulkentries_val) { + free((char *)bulkentries.nbulkentries_val); + bulkentries.nbulkentries_val = 0; + entries = 0; + } + } + } + + /* Randomly link the volumedump entries together */ + randSPEntries(servers, avols); + fprintf(stderr, "Total number of volumes : %u\n", count); + + error_exit: + if (bulkentries.nbulkentries_val) { + free((char *)bulkentries.nbulkentries_val); + } + return (code); +} /*EvalVolumeSet2 */ /*----------------------------------------------------------------------------- * EvalVolumeSetOld @@ -400,80 +425,80 @@ int EvalVolumeSet2(aconfig, avs, avols, uclient) * None. *----------------------------------------------------------------------------- */ -int EvalVolumeSet1(aconfig, avs, avols, uclient) - struct bc_config *aconfig; - struct bc_volumeSet *avs; - struct bc_volumeDump **avols; - struct ubik_client *uclient; -{ /*EvalVolumeSet1*/ - afs_int32 code; /*Result of various calls*/ +int +EvalVolumeSet1(aconfig, avs, avols, uclient) + struct bc_config *aconfig; + struct bc_volumeSet *avs; + struct bc_volumeDump **avols; + struct ubik_client *uclient; +{ /*EvalVolumeSet1 */ + afs_int32 code; /*Result of various calls */ char *errm; - struct bc_volumeDump *tvd; /*Ptr to new dump instance*/ - struct bc_volumeEntry *tve, *ctve; /*Ptr to new volume entry instance*/ - char patt[256]; /*Composite regex; also, target string*/ - int volType; /*Type of volume that worked */ - afs_int32 index; /*Current VLDB entry index*/ - afs_int32 count; /*Needed by VL_ListEntry()*/ - afs_int32 next_index; /*Next index to list*/ - struct vldbentry entry; /*VLDB entry*/ - int srvpartpair; /*Loop counter: server/partition pair*/ + struct bc_volumeDump *tvd; /*Ptr to new dump instance */ + struct bc_volumeEntry *tve, *ctve; /*Ptr to new volume entry instance */ + char patt[256]; /*Composite regex; also, target string */ + int volType; /*Type of volume that worked */ + afs_int32 index; /*Current VLDB entry index */ + afs_int32 count; /*Needed by VL_ListEntry() */ + afs_int32 next_index; /*Next index to list */ + struct vldbentry entry; /*VLDB entry */ + int srvpartpair; /*Loop counter: server/partition pair */ afs_int32 total = 0; int found, foundentry; - struct serversort *servers=0, *ss=0; - struct partitionsort *ps=0; + struct serversort *servers = 0, *ss = 0; + struct partitionsort *ps = 0; - *avols = (struct bc_volumeDump *) 0; - ctve = (struct bc_volumeEntry *) 0; /* no compiled entry */ + *avols = (struct bc_volumeDump *)0; + ctve = (struct bc_volumeEntry *)0; /* no compiled entry */ /* For each vldb entry. * Variable next_index is set to the index of the next VLDB entry * in the enumeration. */ - for (index=0; 1; index=next_index) - { /*w*/ + for (index = 0; 1; index = next_index) { /*w */ memset(&entry, 0, sizeof(entry)); - code = ubik_Call(VL_ListEntry, /*Routine to invoke*/ - uclient, /*Ubik client structure*/ - 0, /*Ubik flags*/ - index, /*Current index*/ - &count, /*Ptr to working variable*/ - &next_index, /*Ptr to next index value to list*/ - &entry); /*Ptr to entry to fill*/ - if (code) return code; - if (!next_index) break; /* If the next index is invalid, bail out now. */ + code = ubik_Call(VL_ListEntry, /*Routine to invoke */ + uclient, /*Ubik client structure */ + 0, /*Ubik flags */ + index, /*Current index */ + &count, /*Ptr to working variable */ + &next_index, /*Ptr to next index value to list */ + &entry); /*Ptr to entry to fill */ + if (code) + return code; + if (!next_index) + break; /* If the next index is invalid, bail out now. */ /* For each entry in the volume set */ - found = 0; /* No match in volume set yet */ - for (tve=avs->ventries; tve; tve=tve->next) - { /*ve*/ + found = 0; /* No match in volume set yet */ + for (tve = avs->ventries; tve; tve = tve->next) { /*ve */ /* for each server in the vldb entry */ - for (srvpartpair=0; srvpartpair < entry.nServers; srvpartpair++) - { /*s*/ - /* On the same server */ - if ( tve->server.sin_addr.s_addr && - !VLDB_IsSameAddrs(tve->server.sin_addr.s_addr, - entry.serverNumber[srvpartpair], - &code) ) { - if (code) return(code); + for (srvpartpair = 0; srvpartpair < entry.nServers; srvpartpair++) { /*s */ + /* On the same server */ + if (tve->server.sin_addr.s_addr + && !VLDB_IsSameAddrs(tve->server.sin_addr.s_addr, + entry.serverNumber[srvpartpair], + &code)) { + if (code) + return (code); continue; } - + /* On the same partition */ - if ( (tve->partition != -1) && - (tve->partition != entry.serverPartition[srvpartpair]) ) + if ((tve->partition != -1) + && (tve->partition != entry.serverPartition[srvpartpair])) continue; /* If the volume entry is not compiled, then compile it */ - if (ctve != tve) - { + if (ctve != tve) { sprintf(patt, "^%s$", tve->name); - errm = (char*)re_comp(patt); - if (errm) - { - com_err(whoami, 0, "Can't compile regular expression '%s': %s", + errm = (char *)re_comp(patt); + if (errm) { + com_err(whoami, 0, + "Can't compile regular expression '%s': %s", patt, errm); - return(-1); + return (-1); } ctve = tve; } @@ -481,14 +506,11 @@ int EvalVolumeSet1(aconfig, avs, avols, uclient) /* If the RW name matches the volume set entry, take * it and exit. First choice is to use the RW volume. */ - if (entry.serverFlags[srvpartpair] & ITSRWVOL) - { - if (entry.flags & RW_EXISTS) - { - sprintf(patt, "%s", entry.name); + if (entry.serverFlags[srvpartpair] & ITSRWVOL) { + if (entry.flags & RW_EXISTS) { + sprintf(patt, "%s", entry.name); code = re_exec(patt); - if (code == 1) - { + if (code == 1) { found = 1; foundentry = srvpartpair; volType = RWVOL; @@ -499,12 +521,10 @@ int EvalVolumeSet1(aconfig, avs, avols, uclient) /* If the BK name matches the volume set entry, take * it and exit. Second choice is to use the BK volume. */ - if (entry.flags & BACK_EXISTS) - { - sprintf(patt, "%s.backup", entry.name); + if (entry.flags & BACK_EXISTS) { + sprintf(patt, "%s.backup", entry.name); code = re_exec(patt); - if (code == 1) - { + if (code == 1) { found = 1; foundentry = srvpartpair; volType = BACKVOL; @@ -517,81 +537,79 @@ int EvalVolumeSet1(aconfig, avs, avols, uclient) * it, but continue searching. Further entries may be * RW or backup entries that will match. */ - else if ( !found && - (entry.serverFlags[srvpartpair] & ITSROVOL) && - (entry.flags & RO_EXISTS) ) - { + else if (!found && (entry.serverFlags[srvpartpair] & ITSROVOL) + && (entry.flags & RO_EXISTS)) { sprintf(patt, "%s.readonly", entry.name); code = re_exec(patt); - if (code == 1) - { - found = 1; + if (code == 1) { + found = 1; foundentry = srvpartpair; volType = ROVOL; } } - + if (code < 0) com_err(whoami, 0, "Internal error in regex package"); - } /*s*/ + } /*s */ /* If found a match, then create a new volume dump entry */ - if (found) - { /*f*/ - /* Find server and partition structure to hang the entry off of */ - code = getSPEntries(entry.serverNumber[foundentry], - entry.serverPartition[foundentry], - &servers, &ss, &ps); - if (code) { - com_err(whoami, code, ""); - return(code); - } + if (found) { /*f */ + /* Find server and partition structure to hang the entry off of */ + code = + getSPEntries(entry.serverNumber[foundentry], + entry.serverPartition[foundentry], &servers, + &ss, &ps); + if (code) { + com_err(whoami, code, ""); + return (code); + } total++; - tvd = (struct bc_volumeDump *) malloc(sizeof(struct bc_volumeDump)); - if (!tvd) - { - com_err(whoami, BC_NOMEM,""); - return(BC_NOMEM); + tvd = (struct bc_volumeDump *) + malloc(sizeof(struct bc_volumeDump)); + if (!tvd) { + com_err(whoami, BC_NOMEM, ""); + return (BC_NOMEM); } memset(tvd, 0, sizeof(*tvd)); - tvd->name = (char *) malloc(strlen(entry.name)+10); - if (!(tvd->name)) - { + tvd->name = (char *)malloc(strlen(entry.name) + 10); + if (!(tvd->name)) { com_err(whoami, BC_NOMEM, ""); free(tvd); - return(BC_NOMEM); + return (BC_NOMEM); } strcpy(tvd->name, entry.name); - if (volType == BACKVOL) strcat(tvd->name, ".backup"); - else if (volType == ROVOL) strcat(tvd->name, ".readonly"); - tvd->vid = entry.volumeId[volType]; - tvd->entry = tve; - tvd->volType = volType; - tvd->partition = entry.serverPartition[foundentry]; + if (volType == BACKVOL) + strcat(tvd->name, ".backup"); + else if (volType == ROVOL) + strcat(tvd->name, ".readonly"); + tvd->vid = entry.volumeId[volType]; + tvd->entry = tve; + tvd->volType = volType; + tvd->partition = entry.serverPartition[foundentry]; tvd->server.sin_addr.s_addr = entry.serverNumber[foundentry]; - tvd->server.sin_port = 0; /* default FS port */ - tvd->server.sin_family = AF_INET; - - /* String tvd off of partition struct */ - tvd->next = ps->vdlist; - ps->vdlist = tvd; - if (!tvd->next) - ps->lastvdlist = tvd; + tvd->server.sin_port = 0; /* default FS port */ + tvd->server.sin_family = AF_INET; + + /* String tvd off of partition struct */ + tvd->next = ps->vdlist; + ps->vdlist = tvd; + if (!tvd->next) + ps->lastvdlist = tvd; break; - } /*f*/ - } /*ve*/ - } /*w*/ + } /*f */ + } /*ve */ + } /*w */ /* Randomly link the volumedump entries together */ randSPEntries(servers, avols); - fprintf (stderr, "Total number of volumes : %u\n", total); - return(0); -} /*EvalVolumeSet1*/ + fprintf(stderr, "Total number of volumes : %u\n", total); + return (0); +} /*EvalVolumeSet1 */ /* compactDateString * print out a date in compact format, 16 chars, format is @@ -601,32 +619,36 @@ int EvalVolumeSet1(aconfig, avs, avols, uclient) * exit: * ptr to a string containing a representation of the date */ -char *compactDateString(date_long, string, size) - afs_int32 *date_long, size; - char *string; +char * +compactDateString(date_long, string, size) + afs_int32 *date_long, size; + char *string; { struct tm *ltime; - if (!string) return 0; + if (!string) + return 0; if (*date_long == NEVERDATE) { sprintf(string, "NEVER"); } else { ltime = localtime(date_long); /* prints date in U.S. format of mm/dd/yyyy */ - strftime (string, size, "%m/%d/%Y %H:%M", ltime); + strftime(string, size, "%m/%d/%Y %H:%M", ltime); } - return(string); + return (string); } -afs_int32 bc_SafeATOI(anum) - char *anum; +afs_int32 +bc_SafeATOI(anum) + char *anum; { - afs_int32 total=0; + afs_int32 total = 0; for (; *anum; anum++) { - if ((*anum < '0') || (*anum > '9')) return -1; - total = (10 * total) + (afs_int32)(*anum - '0'); + if ((*anum < '0') || (*anum > '9')) + return -1; + total = (10 * total) + (afs_int32) (*anum - '0'); } return total; } @@ -636,20 +658,21 @@ afs_int32 bc_SafeATOI(anum) * by a character representing the units (K,M,G,T). Default is 'K'. * Return the size in KBytes. */ -afs_int32 bc_FloatATOI(anum) - char *anum; +afs_int32 +bc_FloatATOI(anum) + char *anum; { float total = 0; afs_int32 rtotal; - afs_int32 fraction = 0; /* > 0 if past the decimal */ + afs_int32 fraction = 0; /* > 0 if past the decimal */ for (; *anum; anum++) { if ((*anum == 't') || (*anum == 'T')) { - total *= 1024*1024*1024; + total *= 1024 * 1024 * 1024; break; } if ((*anum == 'g') || (*anum == 'G')) { - total *= 1024*1024; + total *= 1024 * 1024; break; } if ((*anum == 'm') || (*anum == 'M')) { @@ -660,40 +683,42 @@ afs_int32 bc_FloatATOI(anum) break; } if (*anum == '.') { - fraction = 10; - continue; + fraction = 10; + continue; } - if ((*anum < '0') || (*anum > '9')) return -1; + if ((*anum < '0') || (*anum > '9')) + return -1; if (!fraction) { - total = (10. * total) + (float)(*anum - '0'); + total = (10. * total) + (float)(*anum - '0'); } else { - total += ((float)(*anum - '0')) / (float)fraction; - fraction *= 10; + total += ((float)(*anum - '0')) / (float)fraction; + fraction *= 10; } } - total += 0.5; /* Round up */ - if (total > 0x7fffffff) /* Don't go over 2G */ - total = 0x7fffffff; + total += 0.5; /* Round up */ + if (total > 0x7fffffff) /* Don't go over 2G */ + total = 0x7fffffff; rtotal = (afs_int32) total; return (rtotal); } /* make a copy of a string so that it can be freed later */ -char *bc_CopyString(astring) - char *astring; +char * +bc_CopyString(astring) + char *astring; { afs_int32 tlen; char *tp; - if (!astring) return(NULL); /* propagate null strings easily */ + if (!astring) + return (NULL); /* propagate null strings easily */ tlen = strlen(astring); - tp = (char *) malloc(tlen+1); /* don't forget the terminating null */ - if (!tp) - { - com_err(whoami,BC_NOMEM,""); - return(tp); + tp = (char *)malloc(tlen + 1); /* don't forget the terminating null */ + if (!tp) { + com_err(whoami, BC_NOMEM, ""); + return (tp); } strcpy(tp, astring); return tp; @@ -705,43 +730,41 @@ char *bc_CopyString(astring) * */ -char *concatParams(itemPtr) - struct cmd_item *itemPtr; +char * +concatParams(itemPtr) + struct cmd_item *itemPtr; { - struct cmd_item *tempPtr; - afs_int32 length = 0; - char *string; - - /* compute the length of string required */ - for (tempPtr = itemPtr; tempPtr; tempPtr = tempPtr->next) - { - length += strlen(tempPtr->data); - length++; /* space or null terminator */ - } - - if ( length == 0 ) /* no string (0 length) */ - { - com_err(whoami, 0, "Can't have zero length date and time string"); - return(NULL); - } - - string = (char *) malloc(length); /* allocate the string */ - if (!string) - { - com_err(whoami,BC_NOMEM,""); - return(NULL); - } - string[0] = 0; - - tempPtr = itemPtr; /* now assemble the string */ - while ( tempPtr ) - { - strcat(string, tempPtr->data); - tempPtr = tempPtr->next; - if ( tempPtr ) strcat(string, " "); - } - - return(string); /* return the string */ + struct cmd_item *tempPtr; + afs_int32 length = 0; + char *string; + + /* compute the length of string required */ + for (tempPtr = itemPtr; tempPtr; tempPtr = tempPtr->next) { + length += strlen(tempPtr->data); + length++; /* space or null terminator */ + } + + if (length == 0) { /* no string (0 length) */ + com_err(whoami, 0, "Can't have zero length date and time string"); + return (NULL); + } + + string = (char *)malloc(length); /* allocate the string */ + if (!string) { + com_err(whoami, BC_NOMEM, ""); + return (NULL); + } + string[0] = 0; + + tempPtr = itemPtr; /* now assemble the string */ + while (tempPtr) { + strcat(string, tempPtr->data); + tempPtr = tempPtr->next; + if (tempPtr) + strcat(string, " "); + } + + return (string); /* return the string */ } /* printIfStatus @@ -752,52 +775,53 @@ printIfStatus(statusPtr) struct tciStatusS *statusPtr; { printf("Task %d: %s: ", statusPtr->taskId, statusPtr->taskName); - if ( statusPtr->nKBytes ) + if (statusPtr->nKBytes) printf("%ld Kbytes transferred", statusPtr->nKBytes); - if ( strlen(statusPtr->volumeName) != 0 ) - { - if ( statusPtr->nKBytes ) printf(", "); + if (strlen(statusPtr->volumeName) != 0) { + if (statusPtr->nKBytes) + printf(", "); printf("volume %s", statusPtr->volumeName); } /* orphan */ - if ( statusPtr->flags & ABORT_REQUEST ) + if (statusPtr->flags & ABORT_REQUEST) printf(" [abort request rcvd]"); - - if ( statusPtr->flags & ABORT_DONE ) + + if (statusPtr->flags & ABORT_DONE) printf(" [abort complete]"); - - if ( statusPtr->flags & OPR_WAIT ) + + if (statusPtr->flags & OPR_WAIT) printf(" [operator wait]"); - - if ( statusPtr->flags & CALL_WAIT ) + + if (statusPtr->flags & CALL_WAIT) printf(" [callout in progress]"); - - if ( statusPtr->flags & DRIVE_WAIT ) + + if (statusPtr->flags & DRIVE_WAIT) printf(" [drive wait]"); - if ( statusPtr->flags & TASK_DONE ) + if (statusPtr->flags & TASK_DONE) printf(" [done]"); printf("\n"); } -afs_int32 getPortOffset(port) - char *port; +afs_int32 +getPortOffset(port) + char *port; { - afs_int32 portOffset; - - portOffset = bc_SafeATOI(port); - - if (portOffset < 0) { - com_err(whoami,0,"Can't decode port offset '%s'", port); - return(-1); - } - else if (portOffset > BC_MAXPORTOFFSET) { - com_err(whoami,0,"%u exceeds max port offset %u",portOffset,BC_MAXPORTOFFSET); - return(-1); - } - return(portOffset); + afs_int32 portOffset; + + portOffset = bc_SafeATOI(port); + + if (portOffset < 0) { + com_err(whoami, 0, "Can't decode port offset '%s'", port); + return (-1); + } else if (portOffset > BC_MAXPORTOFFSET) { + com_err(whoami, 0, "%u exceeds max port offset %u", portOffset, + BC_MAXPORTOFFSET); + return (-1); + } + return (portOffset); } /* bc_GetTapeStatusCmd @@ -806,7 +830,7 @@ afs_int32 getPortOffset(port) bc_GetTapeStatusCmd(as, arock) struct cmd_syndesc *as; - char *arock; + char *arock; { afs_int32 code; afs_int32 index, dumpID; @@ -820,33 +844,35 @@ bc_GetTapeStatusCmd(as, arock) code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } if (as->parms[0].items) { - portOffset = getPortOffset(as->parms[0].items->data); - if (portOffset < 0) return(BC_BADARG); + portOffset = getPortOffset(as->parms[0].items->data); + if (portOffset < 0) + return (BC_BADARG); } code = ConnectButc(bc_globalConfig, portOffset, &tconn); - if (code) return(code); - + if (code) + return (code); + flags = TSK_STAT_FIRST; taskId = 0; ntasks = 0; - while ( (flags & TSK_STAT_END) == 0 ) - { + while ((flags & TSK_STAT_END) == 0) { code = TC_ScanStatus(tconn, &taskId, &status, &flags); - if (code) - { - if (code == TC_NOTASKS) break; + if (code) { + if (code == TC_NOTASKS) + break; com_err(whoami, code, "; Can't get status from butc"); - return(-1); + return (-1); } - if ( (flags & TSK_STAT_NOTFOUND) ) break; /* Can't find the task id */ - flags &= ~TSK_STAT_FIRST; /* turn off flag */ + if ((flags & TSK_STAT_NOTFOUND)) + break; /* Can't find the task id */ + flags &= ~TSK_STAT_FIRST; /* turn off flag */ printIfStatus(&status); ntasks++; @@ -856,11 +882,11 @@ bc_GetTapeStatusCmd(as, arock) printf("Tape coordinator is idle\n"); if (flags & TSK_STAT_ADSM) - printf("TSM Tape coordinator\n"); + printf("TSM Tape coordinator\n"); else if (flags & TSK_STAT_XBSA) - printf("XBSA Tape coordinator\n"); + printf("XBSA Tape coordinator\n"); - return(0); + return (0); } extern struct Lock dispatchLock; @@ -874,27 +900,27 @@ bc_WaitForNoJobs() int i; int waitmsg = 1; int usefulJobRunning = 1; - + extern dlqlinkT statusHead; - statusP ptr; + statusP ptr; dlqlinkP dptr; com_err(whoami, 0, "waiting for job termination"); - while (usefulJobRunning) - { + while (usefulJobRunning) { usefulJobRunning = (dlqEmpty(&statusHead) ? 0 : 1); - if (dispatchLock.excl_locked) usefulJobRunning = 1; - for (i=0; (!usefulJobRunning && (idlq_next; - while ( ptr != &statusHead ) - { + while (ptr != &statusHead) { statusPtr = (statusP) ptr; ptr = ptr->dlq_next; - - if ( statusPtr->scheduledDump ) - { - dlqUnlink((dlqlinkP)statusPtr); - dlqLinkb(&atJobsHead, (dlqlinkP)statusPtr); - } - else - { + + if (statusPtr->scheduledDump) { + dlqUnlink((dlqlinkP) statusPtr); + dlqLinkb(&atJobsHead, (dlqlinkP) statusPtr); + } else { printf("Job %d:", statusPtr->jobNumber); printf(" %s", statusPtr->taskName); - - if ( statusPtr->dbDumpId ) - printf(": DumpID %u", statusPtr->dbDumpId); - if ( statusPtr->nKBytes ) - printf(", %ld Kbytes", statusPtr->nKBytes); - if ( strlen(statusPtr->volumeName) != 0 ) - printf(", volume %s", statusPtr->volumeName); - - if ( statusPtr->flags & CONTACT_LOST ) - printf(" [butc contact lost]"); - - if ( statusPtr->flags & ABORT_REQUEST ) - printf(" [abort request]"); - - if ( statusPtr->flags & ABORT_SENT ) - printf(" [abort sent]"); - - if ( statusPtr->flags & OPR_WAIT ) - printf(" [operator wait]"); - - if ( statusPtr->flags & CALL_WAIT ) - printf(" [callout in progress]"); - - if ( statusPtr->flags & DRIVE_WAIT ) - printf(" [drive wait]"); + + if (statusPtr->dbDumpId) + printf(": DumpID %u", statusPtr->dbDumpId); + if (statusPtr->nKBytes) + printf(", %ld Kbytes", statusPtr->nKBytes); + if (strlen(statusPtr->volumeName) != 0) + printf(", volume %s", statusPtr->volumeName); + + if (statusPtr->flags & CONTACT_LOST) + printf(" [butc contact lost]"); + + if (statusPtr->flags & ABORT_REQUEST) + printf(" [abort request]"); + + if (statusPtr->flags & ABORT_SENT) + printf(" [abort sent]"); + + if (statusPtr->flags & OPR_WAIT) + printf(" [operator wait]"); + + if (statusPtr->flags & CALL_WAIT) + printf(" [callout in progress]"); + + if (statusPtr->flags & DRIVE_WAIT) + printf(" [drive wait]"); printf("\n"); } } @@ -969,34 +991,32 @@ bc_JobsCmd(as, arock) /* * Now print the scheduled dumps. */ - if ( !dlqEmpty(&statusHead) && as ) - printf("\n"); /* blank line between running and scheduled dumps */ + if (!dlqEmpty(&statusHead) && as) + printf("\n"); /* blank line between running and scheduled dumps */ prevTime = 0; - while ( !dlqEmpty(&atJobsHead) ) - { - ptr = (&atJobsHead) -> dlq_next; + while (!dlqEmpty(&atJobsHead)) { + ptr = (&atJobsHead)->dlq_next; youngest = (statusP) ptr; - ptr = ptr->dlq_next; - while ( ptr != &atJobsHead ) /* Find the dump that starts the earliest */ - { + ptr = ptr->dlq_next; + while (ptr != &atJobsHead) { /* Find the dump that starts the earliest */ statusPtr = (statusP) ptr; - if ( statusPtr->scheduledDump < youngest->scheduledDump ) - youngest = statusPtr; + if (statusPtr->scheduledDump < youngest->scheduledDump) + youngest = statusPtr; ptr = ptr->dlq_next; } - + /* Print token expiration time */ - if ( (ttoken.endTime > prevTime) && (ttoken.endTime <= youngest->scheduledDump) && - as && (ttoken.endTime != NEVERDATE)) - { - if (ttoken.endTime > time(0)) { + if ((ttoken.endTime > prevTime) + && (ttoken.endTime <= youngest->scheduledDump) && as + && (ttoken.endTime != NEVERDATE)) { + if (ttoken.endTime > time(0)) { compactDateString(&ttoken.endTime, ds, 50); - printf(" %16s: TOKEN EXPIRATION\n", ds); - } else { - printf(" TOKEN HAS EXPIRED\n"); - } + printf(" %16s: TOKEN EXPIRATION\n", ds); + } else { + printf(" TOKEN HAS EXPIRED\n"); + } } prevTime = youngest->scheduledDump; @@ -1004,19 +1024,18 @@ bc_JobsCmd(as, arock) compactDateString(&youngest->scheduledDump, ds, 50); printf("Job %d:", youngest->jobNumber); printf(" %16s: %s", ds, youngest->cmdLine); - printf("\n"); - + printf("\n"); + /* return to original list */ - dlqUnlink((dlqlinkP)youngest); - dlqLinkb(&statusHead, (dlqlinkP)youngest); + dlqUnlink((dlqlinkP) youngest); + dlqLinkb(&statusHead, (dlqlinkP) youngest); } /* Print token expiration time if havn't already */ - if ( (ttoken.endTime == NEVERDATE) && as ) - printf(" : TOKEN NEVER EXPIRES\n"); - else if ( (ttoken.endTime > prevTime) && as ) - { - if (ttoken.endTime > time(0)) { + if ((ttoken.endTime == NEVERDATE) && as) + printf(" : TOKEN NEVER EXPIRES\n"); + else if ((ttoken.endTime > prevTime) && as) { + if (ttoken.endTime > time(0)) { compactDateString(&ttoken.endTime, ds, 50); printf(" %16s: TOKEN EXPIRATION\n", ds); } else { @@ -1030,7 +1049,7 @@ bc_JobsCmd(as, arock) bc_KillCmd(as, arock) struct cmd_syndesc *as; - char *arock; + char *arock; { afs_int32 i; afs_int32 slot; @@ -1047,41 +1066,33 @@ bc_KillCmd(as, arock) tp = as->parms[0].items->data; - if (strchr(tp, '.') == 0) - { + if (strchr(tp, '.') == 0) { slot = bc_SafeATOI(tp); - if (slot == -1) - { - com_err(whoami,0,"Bad syntax for number '%s'", tp); + if (slot == -1) { + com_err(whoami, 0, "Bad syntax for number '%s'", tp); return -1; } lock_Status(); ptr = (&statusHead)->dlq_next; - while ( ptr != &statusHead ) - { + while (ptr != &statusHead) { statusPtr = (statusP) ptr; - if ( statusPtr->jobNumber == slot ) - { + if (statusPtr->jobNumber == slot) { statusPtr->flags |= ABORT_REQUEST; unlock_Status(); - return(0); + return (0); } ptr = ptr->dlq_next; } unlock_Status(); fprintf(stderr, "Job %d not found\n", slot); - return(-1); - } - else - { + return (-1); + } else { /* vol.dump */ td = bc_dumpTasks; - for(i=0;iflags & BC_DI_INUSE) - { + for (i = 0; i < BC_MAXSIMDUMPS; i++, td++) { + if (td->flags & BC_DI_INUSE) { /* compute name */ strcpy(tbuffer, td->volSetName); strcat(tbuffer, "."); @@ -1090,32 +1101,30 @@ bc_KillCmd(as, arock) break; } } - if (i >= BC_MAXSIMDUMPS) - { - com_err(whoami,0,"Can't find job %s", tp); + if (i >= BC_MAXSIMDUMPS) { + com_err(whoami, 0, "Can't find job %s", tp); return -1; } lock_Status(); statusPtr = findStatus(td->dumpID); - if ( statusPtr == 0 ) - { + if (statusPtr == 0) { com_err(whoami, 0, "Can't locate status - internal error"); unlock_Status(); - return(-1); + return (-1); } statusPtr->flags |= ABORT_REQUEST; unlock_Status(); - return(0); + return (0); } return 0; } /* restore a volume or volumes */ bc_VolRestoreCmd(as, arock) - struct cmd_syndesc *as; - char *arock; + struct cmd_syndesc *as; + char *arock; { /* * parm 0 is the new server to restore to @@ -1130,12 +1139,12 @@ bc_VolRestoreCmd(as, arock) * a new volume ID for the restored volume. If a new extension is specified, * we add that extension to the volume name of the restored volume. */ - struct bc_volumeEntry tvolumeEntry; /* entry within the volume set */ + struct bc_volumeEntry tvolumeEntry; /* entry within the volume set */ struct bc_volumeDump *volsToRestore = (struct bc_volumeDump *)0; - struct bc_volumeDump *lastVol = (struct bc_volumeDump *)0; - struct bc_volumeDump *tvol; /* temp for same */ - struct sockaddr_in destServ; /* machine to which to restore volumes */ - afs_int32 destPartition; /* partition to which to restore volumes */ + struct bc_volumeDump *lastVol = (struct bc_volumeDump *)0; + struct bc_volumeDump *tvol; /* temp for same */ + struct sockaddr_in destServ; /* machine to which to restore volumes */ + afs_int32 destPartition; /* partition to which to restore volumes */ char *tp; struct cmd_item *ti; afs_int32 code; @@ -1144,114 +1153,110 @@ bc_VolRestoreCmd(as, arock) char *newExt, *timeString; afs_int32 i, portRemain; afs_int32 *ports = NULL; - afs_int32 portCount=0; - int dontExecute; + afs_int32 portCount = 0; + int dontExecute; code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } /* specified other destination host */ - if (as->parms[0].items) - { + if (as->parms[0].items) { tp = as->parms[0].items->data; - if (bc_ParseHost(tp, &destServ)) - { - com_err(whoami,0,"Failed to locate destination host '%s'", tp); + if (bc_ParseHost(tp, &destServ)) { + com_err(whoami, 0, "Failed to locate destination host '%s'", tp); return -1; } } /* specified other destination partition */ - if (as->parms[1].items) - { + if (as->parms[1].items) { tp = as->parms[1].items->data; - if (bc_GetPartitionID(tp, &destPartition)) - { - com_err(whoami,0,"Can't parse destination partition '%s'", tp); + if (bc_GetPartitionID(tp, &destPartition)) { + com_err(whoami, 0, "Can't parse destination partition '%s'", tp); return -1; } } - for (ti=as->parms[2].items; ti; ti=ti->next) - { + for (ti = as->parms[2].items; ti; ti = ti->next) { /* build list of volume items */ - tvol = (struct bc_volumeDump *) malloc(sizeof(struct bc_volumeDump)); - if (!tvol) - { - com_err(whoami,BC_NOMEM,""); + tvol = (struct bc_volumeDump *)malloc(sizeof(struct bc_volumeDump)); + if (!tvol) { + com_err(whoami, BC_NOMEM, ""); return BC_NOMEM; } memset(tvol, 0, sizeof(struct bc_volumeDump)); - tvol->name = (char *) malloc(VOLSER_MAXVOLNAME +1); - if (!tvol->name) - { - com_err(whoami,BC_NOMEM,""); + tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1); + if (!tvol->name) { + com_err(whoami, BC_NOMEM, ""); return BC_NOMEM; } - strncpy(tvol->name, ti->data,VOLSER_OLDMAXVOLNAME); + strncpy(tvol->name, ti->data, VOLSER_OLDMAXVOLNAME); tvol->entry = &tvolumeEntry; - if (lastVol) lastVol->next = tvol; /* thread onto end of list */ - else volsToRestore = tvol; + if (lastVol) + lastVol->next = tvol; /* thread onto end of list */ + else + volsToRestore = tvol; lastVol = tvol; } - if (as->parms[4].items) - { - timeString = concatParams(as->parms[4].items); - if (!timeString) return(-1); - + if (as->parms[4].items) { + timeString = concatParams(as->parms[4].items); + if (!timeString) + return (-1); + code = ktime_DateToLong(timeString, &fromDate); - free (timeString); - if (code) - { - com_err(whoami,0,"Can't parse restore date and time"); - com_err(whoami,0,"%s", ktime_GetDateUsage()); + free(timeString); + if (code) { + com_err(whoami, 0, "Can't parse restore date and time"); + com_err(whoami, 0, "%s", ktime_GetDateUsage()); return code; } - } - else - { - fromDate = 0x7fffffff; /* latest one */ + } else { + fromDate = 0x7fffffff; /* latest one */ } - newExt = (as->parms[3].items ? as->parms[3].items->data : NULL); + newExt = (as->parms[3].items ? as->parms[3].items->data : NULL); oldFlag = 0; /* Read all the port offsets into the ports array. The first element in the * array is for full restore and the rest are for incremental restores */ if (as->parms[5].items) { - for (ti=as->parms[5].items; ti; ti=ti->next) portCount++; - ports = (afs_int32 *)malloc(portCount*sizeof(afs_int32)); + for (ti = as->parms[5].items; ti; ti = ti->next) + portCount++; + ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32)); if (!ports) { - com_err(whoami,BC_NOMEM,""); + com_err(whoami, BC_NOMEM, ""); return BC_NOMEM; } - for (ti=as->parms[5].items, i=0; ti; ti=ti->next, i++) { - ports[i] = getPortOffset(ti->data); - if (ports[i] < 0) return(BC_BADARG); + for (ti = as->parms[5].items, i = 0; ti; ti = ti->next, i++) { + ports[i] = getPortOffset(ti->data); + if (ports[i] < 0) + return (BC_BADARG); } } - dontExecute = (as->parms[6].items ? 1 : 0); /* -n */ + dontExecute = (as->parms[6].items ? 1 : 0); /* -n */ /* * Perform the call to start the restore. */ - code = bc_StartDmpRst(bc_globalConfig, "volume", "restore", volsToRestore, &destServ, - destPartition, fromDate, newExt, oldFlag, - /*parentDump*/0, /*dumpLevel*/0, - bc_Restorer, ports, portCount, - /*dumpSched*/0, /*append*/0, dontExecute); - if (code) com_err(whoami,code,"; Failed to queue restore"); - - return(code); + code = + bc_StartDmpRst(bc_globalConfig, "volume", "restore", volsToRestore, + &destServ, destPartition, fromDate, newExt, oldFlag, + /*parentDump */ 0, /*dumpLevel */ 0, + bc_Restorer, ports, portCount, + /*dumpSched */ 0, /*append */ 0, dontExecute); + if (code) + com_err(whoami, code, "; Failed to queue restore"); + + return (code); } /* restore a whole partition or server */ @@ -1265,28 +1270,29 @@ bc_VolRestoreCmd(as, arock) */ bc_DiskRestoreCmd(as, arock) -struct cmd_syndesc *as; -char *arock; { - struct bc_volumeSet tvolumeSet; /* temporary volume set for EvalVolumeSet call */ - struct bc_volumeEntry tvolumeEntry; /* entry within the volume set */ + struct cmd_syndesc *as; + char *arock; +{ + struct bc_volumeSet tvolumeSet; /* temporary volume set for EvalVolumeSet call */ + struct bc_volumeEntry tvolumeEntry; /* entry within the volume set */ struct bc_volumeDump *volsToRestore = (struct bc_volumeDump *)0; - struct sockaddr_in destServ; /* machine to which to restore volumes */ - afs_int32 destPartition; /* partition to which to restore volumes */ + struct sockaddr_in destServ; /* machine to which to restore volumes */ + afs_int32 destPartition; /* partition to which to restore volumes */ char *tp; afs_int32 code; int oldFlag; afs_int32 fromDate; char *newExt; afs_int32 *ports = NULL; - afs_int32 portCount=0; - int dontExecute; + afs_int32 portCount = 0; + int dontExecute; struct bc_volumeDump *prev, *tvol, *nextvol; struct cmd_item *ti; afs_int32 i; /* parm 0 is the server to restore * parm 1 is the partition to restore - + * parm 8 and above as in VolRestoreCmd: * parm 8 is the new server to restore to * parm 9 is the new partition to restore to @@ -1294,13 +1300,13 @@ char *arock; { code = bc_UpdateVolumeSet(); if (code) { - com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + com_err(whoami, code, "; Can't retrieve volume sets"); + return (code); } code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } /* create a volume set corresponding to the volume pattern we've been given */ @@ -1311,92 +1317,91 @@ char *arock; { tvolumeEntry.serverName = as->parms[0].items->data; tvolumeEntry.partname = as->parms[1].items->data; - if (bc_GetPartitionID(tvolumeEntry.partname, &tvolumeEntry.partition)) - { - com_err(whoami,0,"Can't parse partition '%s'", tvolumeEntry.partname); + if (bc_GetPartitionID(tvolumeEntry.partname, &tvolumeEntry.partition)) { + com_err(whoami, 0, "Can't parse partition '%s'", + tvolumeEntry.partname); return -1; } - if (bc_ParseHost(tvolumeEntry.serverName, &tvolumeEntry.server)) - { - com_err(whoami,0,"Can't locate host '%s'", tvolumeEntry.serverName); + if (bc_ParseHost(tvolumeEntry.serverName, &tvolumeEntry.server)) { + com_err(whoami, 0, "Can't locate host '%s'", tvolumeEntry.serverName); return -1; } /* specified other destination host */ - if (as->parms[8].items) - { + if (as->parms[8].items) { tp = as->parms[8].items->data; - if (bc_ParseHost(tp, &destServ)) - { - com_err(whoami,0,"Can't locate destination host '%s'", tp); + if (bc_ParseHost(tp, &destServ)) { + com_err(whoami, 0, "Can't locate destination host '%s'", tp); return -1; } - } - else /* use destination host == original host */ + } else /* use destination host == original host */ memcpy(&destServ, &tvolumeEntry.server, sizeof(destServ)); /* specified other destination partition */ - if (as->parms[9].items) - { + if (as->parms[9].items) { tp = as->parms[9].items->data; - if (bc_GetPartitionID(tp, &destPartition)) - { - com_err(whoami,0,"Can't parse destination partition '%s'", tp); + if (bc_GetPartitionID(tp, &destPartition)) { + com_err(whoami, 0, "Can't parse destination partition '%s'", tp); return -1; } - } - else /* use original partition */ + } else /* use original partition */ destPartition = tvolumeEntry.partition; - tvolumeEntry.name = ".*"; /* match all volumes (this should be a parameter) */ + tvolumeEntry.name = ".*"; /* match all volumes (this should be a parameter) */ if (as->parms[2].items) { - for (ti=as->parms[2].items; ti; ti=ti->next) portCount++; - ports = (afs_int32 *)malloc(portCount*sizeof(afs_int32)); - if (!ports) { - com_err(whoami,BC_NOMEM,""); - return BC_NOMEM; - } + for (ti = as->parms[2].items; ti; ti = ti->next) + portCount++; + ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32)); + if (!ports) { + com_err(whoami, BC_NOMEM, ""); + return BC_NOMEM; + } - for (ti=as->parms[2].items, i=0; ti; ti=ti->next, i++) { - ports[i] = getPortOffset(ti->data); - if (ports[i] < 0) return(BC_BADARG); - } + for (ti = as->parms[2].items, i = 0; ti; ti = ti->next, i++) { + ports[i] = getPortOffset(ti->data); + if (ports[i] < 0) + return (BC_BADARG); + } } - newExt = (as->parms[10].items ? as->parms[10].items->data : NULL); - dontExecute = (as->parms[11].items ? 1 : 0); /* -n */ + newExt = (as->parms[10].items ? as->parms[10].items->data : NULL); + dontExecute = (as->parms[11].items ? 1 : 0); /* -n */ /* * Expand out the volume set into its component list of volumes, by calling VLDB server. */ - code = bc_EvalVolumeSet(bc_globalConfig, &tvolumeSet, &volsToRestore, cstruct); - if (code) - { - com_err(whoami,code,"; Failed to evaluate volume set"); - return(-1); + code = + bc_EvalVolumeSet(bc_globalConfig, &tvolumeSet, &volsToRestore, + cstruct); + if (code) { + com_err(whoami, code, "; Failed to evaluate volume set"); + return (-1); } /* Since we want only RW volumes, remove any * BK or RO volumes from the list. */ - for (prev=0, tvol=volsToRestore; tvol; tvol=nextvol) { - nextvol = tvol->next; - if (BackupName(tvol->name)) { - if (tvol->name) - fprintf (stderr, "Will not restore volume %s (its RW does not reside on the partition)\n", tvol->name); - - if (tvol == volsToRestore) { - volsToRestore = nextvol; - } else { - prev->next = nextvol; - } - if (tvol->name) free(tvol->name); - free(tvol); - } else { - prev = tvol; - } + for (prev = 0, tvol = volsToRestore; tvol; tvol = nextvol) { + nextvol = tvol->next; + if (BackupName(tvol->name)) { + if (tvol->name) + fprintf(stderr, + "Will not restore volume %s (its RW does not reside on the partition)\n", + tvol->name); + + if (tvol == volsToRestore) { + volsToRestore = nextvol; + } else { + prev->next = nextvol; + } + if (tvol->name) + free(tvol->name); + free(tvol); + } else { + prev = tvol; + } } fromDate = 0x7fffffff; /* last one before this date */ @@ -1405,160 +1410,162 @@ char *arock; { /* * Perform the call to start the dump. */ - code = bc_StartDmpRst(bc_globalConfig, "disk", "restore", volsToRestore, &destServ, - destPartition, fromDate, newExt, oldFlag, - /*parentDump*/0, /*dumpLevel*/0, - bc_Restorer, ports, portCount, - /*dumpSched*/0, /*append*/0, dontExecute); - if (code) com_err(whoami,code,"; Failed to queue restore"); - - return(code); + code = + bc_StartDmpRst(bc_globalConfig, "disk", "restore", volsToRestore, + &destServ, destPartition, fromDate, newExt, oldFlag, + /*parentDump */ 0, /*dumpLevel */ 0, + bc_Restorer, ports, portCount, + /*dumpSched */ 0, /*append */ 0, dontExecute); + if (code) + com_err(whoami, code, "; Failed to queue restore"); + + return (code); } /* bc_VolsetRestoreCmd * restore a volumeset or list of volumes. */ -bc_VolsetRestoreCmd (as, arock) - struct cmd_syndesc *as; - char *arock; +bc_VolsetRestoreCmd(as, arock) + struct cmd_syndesc *as; + char *arock; { int oldFlag; long fromDate; char *newExt; - int dontExecute; - afs_int32 *ports = NULL; - afs_int32 portCount=0; - afs_int32 code = 0; - afs_int32 portoffset = 0; - char *volsetName; - struct bc_volumeSet *volsetPtr; /* Ptr to list of generated volume info*/ + int dontExecute; + afs_int32 *ports = NULL; + afs_int32 portCount = 0; + afs_int32 code = 0; + afs_int32 portoffset = 0; + char *volsetName; + struct bc_volumeSet *volsetPtr; /* Ptr to list of generated volume info */ struct bc_volumeDump *volsToRestore = (struct bc_volumeDump *)0; - struct bc_volumeDump *lastVol = (struct bc_volumeDump *)0; - struct sockaddr_in destServer; /* machine to which to restore volume */ - afs_int32 destPartition; /* partition to which to restore volumes */ - struct cmd_item *ti; - afs_int32 i; - + struct bc_volumeDump *lastVol = (struct bc_volumeDump *)0; + struct sockaddr_in destServer; /* machine to which to restore volume */ + afs_int32 destPartition; /* partition to which to restore volumes */ + struct cmd_item *ti; + afs_int32 i; + code = bc_UpdateVolumeSet(); if (code) { - com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + com_err(whoami, code, "; Can't retrieve volume sets"); + return (code); } code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } - if (as->parms[0].items) - { - if (as->parms[1].items) - { + if (as->parms[0].items) { + if (as->parms[1].items) { com_err(whoami, 0, "Can't have both -name and -file options"); - return(-1); + return (-1); } volsetName = as->parms[0].items->data; - volsetPtr = bc_FindVolumeSet(bc_globalConfig, volsetName); - if (!volsetPtr) - { - com_err(whoami,0,"Can't find volume set '%s' in backup database", volsetName); - return(-1); + volsetPtr = bc_FindVolumeSet(bc_globalConfig, volsetName); + if (!volsetPtr) { + com_err(whoami, 0, + "Can't find volume set '%s' in backup database", + volsetName); + return (-1); } /* Expand out the volume set into its component list of volumes. */ - code = bc_EvalVolumeSet(bc_globalConfig, volsetPtr, &volsToRestore, cstruct); - if (code) - { - com_err(whoami,code,"; Failed to evaluate volume set"); - return(-1); + code = + bc_EvalVolumeSet(bc_globalConfig, volsetPtr, &volsToRestore, + cstruct); + if (code) { + com_err(whoami, code, "; Failed to evaluate volume set"); + return (-1); } - } - else if (as->parms[1].items) - { - FILE *fd; + } else if (as->parms[1].items) { + FILE *fd; char line[256]; char server[50], partition[50], volume[50], rest[256]; long count; struct bc_volumeDump *tvol; - fd = fopen(as->parms[1].items->data, "r"); - if (!fd) - { - com_err(whoami,errno,"; Cannot open file '%s'", as->parms[1].items->data); - return(-1); - } - - while ( fgets(line, 255, fd) ) - { - count = sscanf(line, "%s %s %s %s", server, partition, volume, rest); - - if (count <= 0) continue; - if (count < 3) - { - fprintf(stderr, + fd = fopen(as->parms[1].items->data, "r"); + if (!fd) { + com_err(whoami, errno, "; Cannot open file '%s'", + as->parms[1].items->data); + return (-1); + } + + while (fgets(line, 255, fd)) { + count = + sscanf(line, "%s %s %s %s", server, partition, volume, rest); + + if (count <= 0) + continue; + if (count < 3) { + fprintf(stderr, "Invalid volumeset file format: Wrong number of arguments: Ignoring\n"); fprintf(stderr, " %s", line); continue; } - if ( bc_ParseHost(server,&destServer) ) - { - com_err(whoami,0,"Failed to locate host '%s'", server); + if (bc_ParseHost(server, &destServer)) { + com_err(whoami, 0, "Failed to locate host '%s'", server); continue; } - if ( bc_GetPartitionID(partition,&destPartition) ) - { - com_err(whoami,0,"Failed to parse destination partition '%s'", partition); + if (bc_GetPartitionID(partition, &destPartition)) { + com_err(whoami, 0, + "Failed to parse destination partition '%s'", + partition); continue; } /* Allocate a volumeDump structure and link it in */ - tvol = (struct bc_volumeDump *) malloc(sizeof(struct bc_volumeDump)); + tvol = + (struct bc_volumeDump *)malloc(sizeof(struct bc_volumeDump)); memset(tvol, 0, sizeof(struct bc_volumeDump)); - tvol->name = (char *) malloc(VOLSER_MAXVOLNAME+1); - if (!tvol->name) - { - com_err(whoami,BC_NOMEM,""); + tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1); + if (!tvol->name) { + com_err(whoami, BC_NOMEM, ""); return BC_NOMEM; } strncpy(tvol->name, volume, VOLSER_OLDMAXVOLNAME); memcpy(&tvol->server, &destServer, sizeof(destServer)); tvol->partition = destPartition; - if (lastVol) lastVol->next = tvol; /* thread onto end of list */ - else volsToRestore = tvol; + if (lastVol) + lastVol->next = tvol; /* thread onto end of list */ + else + volsToRestore = tvol; lastVol = tvol; } fclose(fd); - } - else - { - com_err(whoami,0,"-name or -file option required"); - return(-1); + } else { + com_err(whoami, 0, "-name or -file option required"); + return (-1); } /* Get the port offset for the restore */ if (as->parms[2].items) { - for (ti=as->parms[2].items; ti; ti=ti->next) portCount++; - ports = (afs_int32 *)malloc(portCount*sizeof(afs_int32)); - if (!ports) { - com_err(whoami,BC_NOMEM,""); - return BC_NOMEM; - } + for (ti = as->parms[2].items; ti; ti = ti->next) + portCount++; + ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32)); + if (!ports) { + com_err(whoami, BC_NOMEM, ""); + return BC_NOMEM; + } - for (ti=as->parms[2].items, i=0; ti; ti=ti->next, i++) { - ports[i] = getPortOffset(ti->data); - if (ports[i] < 0) return(BC_BADARG); - } + for (ti = as->parms[2].items, i = 0; ti; ti = ti->next, i++) { + ports[i] = getPortOffset(ti->data); + if (ports[i] < 0) + return (BC_BADARG); + } } - newExt = (as->parms[3].items ? as->parms[3].items->data : NULL); + newExt = (as->parms[3].items ? as->parms[3].items->data : NULL); dontExecute = (as->parms[4].items ? 1 : 0); fromDate = 0x7fffffff; /* last one before this date */ @@ -1566,11 +1573,13 @@ bc_VolsetRestoreCmd (as, arock) /* Perform the call to start the restore */ code = bc_StartDmpRst(bc_globalConfig, "disk", "restore", volsToRestore, - /*destserver*/ 0, /*destpartition*/ 0, fromDate, newExt, oldFlag, - /*parentDump*/0, /*dumpLevel*/0, - bc_Restorer, ports, portCount, - /*dumpSched*/0, /*append*/0, dontExecute); - if (code) com_err(whoami,code,"; Failed to queue restore"); + /*destserver */ 0, /*destpartition */ 0, fromDate, + newExt, oldFlag, + /*parentDump */ 0, /*dumpLevel */ 0, + bc_Restorer, ports, portCount, + /*dumpSched */ 0, /*append */ 0, dontExecute); + if (code) + com_err(whoami, code, "; Failed to queue restore"); return code; } @@ -1597,35 +1606,36 @@ bc_VolsetRestoreCmd (as, arock) * As advertised. *--------------------------------------------------------------------------- */ -int dontExecute; - -int bc_DumpCmd(as, arock) - struct cmd_syndesc *as; - char *arock; -{ /*bc_DumpCmd*/ - static char rn[] = "bc_DumpCmd"; /*Routine name*/ - char *dumpPath, *vsName; /*Ptrs to various names*/ - struct bc_volumeSet *tvs; /*Ptr to list of generated volume info*/ - struct bc_dumpSchedule *tds, *baseds; /*Ptr to dump schedule node*/ - struct bc_volumeDump *tve, *volsToDump; /*Ptr to individual vols to be dumped*/ +int dontExecute; + +int +bc_DumpCmd(as, arock) + struct cmd_syndesc *as; + char *arock; +{ /*bc_DumpCmd */ + static char rn[] = "bc_DumpCmd"; /*Routine name */ + char *dumpPath, *vsName; /*Ptrs to various names */ + struct bc_volumeSet *tvs; /*Ptr to list of generated volume info */ + struct bc_dumpSchedule *tds, *baseds; /*Ptr to dump schedule node */ + struct bc_volumeDump *tve, *volsToDump; /*Ptr to individual vols to be dumped */ struct bc_volumeDump *ntve, *tves, *ptves, *rtves; - struct budb_dumpEntry dumpEntry, de, fde; /* dump entry */ + struct budb_dumpEntry dumpEntry, de, fde; /* dump entry */ afs_uint32 d; - afs_int32 parent; /* parent dump */ - afs_int32 level; /* this dump's level # */ - afs_int32 problemFindingDump; /* can't find parent(s) */ + afs_int32 parent; /* parent dump */ + afs_int32 level; /* this dump's level # */ + afs_int32 problemFindingDump; /* can't find parent(s) */ afs_int32 *portp = NULL; afs_int32 portCount = 0; - afs_int32 doAt, atTime; /* Time a timed-dump is to start at */ + afs_int32 doAt, atTime; /* Time a timed-dump is to start at */ afs_int32 length; char *timeString; - int doAppend; /* Append the dump to dump set */ - afs_int32 code; /* Return code */ - int loadfile; /* whether to load a file or not */ + int doAppend; /* Append the dump to dump set */ + afs_int32 code; /* Return code */ + int loadfile; /* whether to load a file or not */ - struct bc_dumpTask *dumpTaskPtr; /* for dump thread */ + struct bc_dumpTask *dumpTaskPtr; /* for dump thread */ afs_int32 dumpTaskSlot; char *junk; statusP statusPtr; @@ -1633,22 +1643,22 @@ int bc_DumpCmd(as, arock) extern struct bc_dumpTask bc_dumpTasks[]; extern afs_int32 bcdb_FindLastVolClone(); - extern afs_int32 volImageTime(); + extern afs_int32 volImageTime(); code = bc_UpdateDumpSchedule(); if (code) { - com_err(whoami, code, "; Can't retrieve dump schedule"); - return(code); + com_err(whoami, code, "; Can't retrieve dump schedule"); + return (code); } code = bc_UpdateVolumeSet(); if (code) { - com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + com_err(whoami, code, "; Can't retrieve volume sets"); + return (code); } code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } /* @@ -1656,22 +1666,18 @@ int bc_DumpCmd(as, arock) * The "-file" option cannot exist with the "-volume", "-dump", * "-portoffset", or "-append" option */ - if (as->parms[6].items) - { - loadfile = 1; - if ( as->parms[0].items || as->parms[1].items || - as->parms[2].items || as->parms[4].items ) - { - com_err(whoami,0,"Invalid option specified with -file option"); + if (as->parms[6].items) { + loadfile = 1; + if (as->parms[0].items || as->parms[1].items || as->parms[2].items + || as->parms[4].items) { + com_err(whoami, 0, "Invalid option specified with -file option"); return -1; } - } - else - { - loadfile = 0; - if ( !as->parms[0].items || !as->parms[1].items ) - { - com_err(whoami,0,"Must specify volume set name and dump level name"); + } else { + loadfile = 0; + if (!as->parms[0].items || !as->parms[1].items) { + com_err(whoami, 0, + "Must specify volume set name and dump level name"); return -1; } } @@ -1679,73 +1685,71 @@ int bc_DumpCmd(as, arock) /* * Get the time we are to perform this dump */ - if (as->parms[3].items) - { - doAt = 1; + if (as->parms[3].items) { + doAt = 1; timeString = concatParams(as->parms[3].items); - if (!timeString) return(-1); - + if (!timeString) + return (-1); + /* * Now parse this string for the time to start. */ code = ktime_DateToLong(timeString, &atTime); - free (timeString); - if ( code ) - { - com_err(whoami,0,"Can't parse dump start date and time"); - com_err(whoami,0,"%s", ktime_GetDateUsage()); - return(1); + free(timeString); + if (code) { + com_err(whoami, 0, "Can't parse dump start date and time"); + com_err(whoami, 0, "%s", ktime_GetDateUsage()); + return (1); } - } - else - doAt = 0; - - dontExecute = (as->parms[5].items ? 1 : 0); /* -n */ + } else + doAt = 0; + + dontExecute = (as->parms[5].items ? 1 : 0); /* -n */ /* * If this dump is not a load file, then check the parameters. */ - if (!loadfile) - { /*6*/ - vsName = as->parms[0].items->data; /* get volume set name */ - dumpPath = as->parms[1].items->data; /* get dump path */ + if (!loadfile) { /*6 */ + vsName = as->parms[0].items->data; /* get volume set name */ + dumpPath = as->parms[1].items->data; /* get dump path */ /* get the port number, if one was specified */ - if (as->parms[2].items) - { + if (as->parms[2].items) { portCount = 1; - portp = (afs_int32 *)malloc(sizeof(afs_int32)); - if (!portp) - { - com_err(whoami,BC_NOMEM,""); + portp = (afs_int32 *) malloc(sizeof(afs_int32)); + if (!portp) { + com_err(whoami, BC_NOMEM, ""); return BC_NOMEM; } *portp = getPortOffset(as->parms[2].items->data); - if (*portp < 0) return(BC_BADARG); + if (*portp < 0) + return (BC_BADARG); } - doAppend = (as->parms[4].items ? 1 : 0); /* -append */ + doAppend = (as->parms[4].items ? 1 : 0); /* -append */ /* * Get a hold of the given volume set and dump set. */ tvs = bc_FindVolumeSet(bc_globalConfig, vsName); - if (!tvs) - { - com_err(whoami,0, "Can't find volume set '%s' in backup database", vsName); - return(-1); + if (!tvs) { + com_err(whoami, 0, + "Can't find volume set '%s' in backup database", vsName); + return (-1); } baseds = bc_FindDumpSchedule(bc_globalConfig, dumpPath); - if (!baseds) - { - com_err(whoami,0, "Can't find dump schedule '%s' in backup database", dumpPath); - return(-1); + if (!baseds) { + com_err(whoami, 0, + "Can't find dump schedule '%s' in backup database", + dumpPath); + return (-1); } - } /*6*/ + } + /*6 */ /* * If given the "-at" option, then add this to the jobs list and return * with no error. @@ -1755,71 +1759,60 @@ int bc_DumpCmd(as, arock) * the -at option. If the -n option is there, it is scheduled with * the Timed dump as opposed to not scheduling the time dump at all. */ - if ( doAt ) - { - if ( atTime < time(0) ) - { - com_err(whoami,0,"Time of dump is earlier then current time - not added"); - } - else - { + if (doAt) { + if (atTime < time(0)) { + com_err(whoami, 0, + "Time of dump is earlier then current time - not added"); + } else { statusPtr = createStatusNode(); lock_Status(); statusPtr->scheduledDump = atTime; /* Determine length of the dump command */ length = 0; - length += 4; /* "dump" */ - if (loadfile) - { - length += 6; /* " -file" */ - length += 1 + strlen(as->parms[6].items->data); /* " " */ - } - else - { - /* length += 11; */ /* " -volumeset" */ - length += 1 + strlen(as->parms[0].items->data); /* " */ - - /* length += 6; */ /* " -dump" */ - length += 1 + strlen(as->parms[1].items->data); /* " */ - - if (as->parms[2].items) - { - /* length += 12; */ /* " -portoffset" */ - length += 1 + strlen(as->parms[2].items->data); /* " " */ + length += 4; /* "dump" */ + if (loadfile) { + length += 6; /* " -file" */ + length += 1 + strlen(as->parms[6].items->data); /* " " */ + } else { + /* length += 11; *//* " -volumeset" */ + length += 1 + strlen(as->parms[0].items->data); /* " */ + + /* length += 6; *//* " -dump" */ + length += 1 + strlen(as->parms[1].items->data); /* " */ + + if (as->parms[2].items) { + /* length += 12; *//* " -portoffset" */ + length += 1 + strlen(as->parms[2].items->data); /* " " */ } if (as->parms[4].items) - length += 8; /* " -append" */ + length += 8; /* " -append" */ } if (dontExecute) - length += 3; /* " -n" */ - length++; /* end-of-line */ + length += 3; /* " -n" */ + length++; /* end-of-line */ /* Allocate status block for this timed dump */ sprintf(statusPtr->taskName, "Scheduled Dump"); - statusPtr->jobNumber = bc_jobNumber(); - statusPtr->scheduledDump = atTime; - statusPtr->cmdLine = (char *) malloc(length); - if (!statusPtr->cmdLine) - { - com_err(whoami,BC_NOMEM,""); + statusPtr->jobNumber = bc_jobNumber(); + statusPtr->scheduledDump = atTime; + statusPtr->cmdLine = (char *)malloc(length); + if (!statusPtr->cmdLine) { + com_err(whoami, BC_NOMEM, ""); return BC_NOMEM; } - + /* Now reconstruct the dump command */ statusPtr->cmdLine[0] = 0; strcat(statusPtr->cmdLine, "dump"); - if (loadfile) - { - strcat(statusPtr->cmdLine, " -file"); + if (loadfile) { + strcat(statusPtr->cmdLine, " -file"); strcat(statusPtr->cmdLine, " "); strcat(statusPtr->cmdLine, as->parms[6].items->data); - } - else - { - /* strcat(statusPtr->cmdLine, " -volumeset"); */ + } else { + /* strcat(statusPtr->cmdLine, " -volumeset"); */ strcat(statusPtr->cmdLine, " "); strcat(statusPtr->cmdLine, as->parms[0].items->data); @@ -1827,8 +1820,7 @@ int bc_DumpCmd(as, arock) strcat(statusPtr->cmdLine, " "); strcat(statusPtr->cmdLine, as->parms[1].items->data); - if (as->parms[2].items) - { + if (as->parms[2].items) { /* strcat(statusPtr->cmdLine, " -portoffset"); */ strcat(statusPtr->cmdLine, " "); strcat(statusPtr->cmdLine, as->parms[2].items->data); @@ -1838,17 +1830,18 @@ int bc_DumpCmd(as, arock) strcat(statusPtr->cmdLine, " -append"); } if (dontExecute) - strcat(statusPtr->cmdLine, " -n"); + strcat(statusPtr->cmdLine, " -n"); printf("Add scheduled dump as job %d\n", statusPtr->jobNumber); - if ( (atTime > ttoken.endTime) && (ttoken.endTime != NEVERDATE) ) - com_err(whoami,0,"Warning: job %d starts after expiration of AFS token", + if ((atTime > ttoken.endTime) && (ttoken.endTime != NEVERDATE)) + com_err(whoami, 0, + "Warning: job %d starts after expiration of AFS token", statusPtr->jobNumber); - + unlock_Status(); } - return(0); + return (0); } /* @@ -1856,12 +1849,10 @@ int bc_DumpCmd(as, arock) * in the main routine prior the dispatch call. loadFile and dontExecute are * global variables so this can take place in main. */ - if (loadfile) - { - loadFile = (char *) malloc(strlen(as->parms[6].items->data)+1); - if (!loadFile) - { - com_err(whoami,BC_NOMEM,""); + if (loadfile) { + loadFile = (char *)malloc(strlen(as->parms[6].items->data) + 1); + if (!loadFile) { + com_err(whoami, BC_NOMEM, ""); return BC_NOMEM; } strcpy(loadFile, as->parms[6].items->data); @@ -1871,7 +1862,8 @@ int bc_DumpCmd(as, arock) /* * We are doing a real dump (no load file or timed dump). */ - printf("Starting dump of volume set '%s' (dump level '%s')\n", vsName, dumpPath); + printf("Starting dump of volume set '%s' (dump level '%s')\n", vsName, + dumpPath); /* For each dump-level above this one, see if the volumeset was dumped * at the level. We search all dump-levels since a higher dump-level @@ -1879,13 +1871,14 @@ int bc_DumpCmd(as, arock) */ parent = level = problemFindingDump = 0; for (tds = baseds->parent; tds; tds = tds->parent) { - /* Find the most recent dump of the volume-set at this dump-level. + /* Find the most recent dump of the volume-set at this dump-level. * Raise problem flag if didn't find a dump and a parent not yet found. */ - code = bcdb_FindLatestDump(vsName, tds->name, &dumpEntry); + code = bcdb_FindLatestDump(vsName, tds->name, &dumpEntry); if (code) { - if (!parent) problemFindingDump = 1; /* skipping a dump level */ - continue; + if (!parent) + problemFindingDump = 1; /* skipping a dump level */ + continue; } /* We found the most recent dump at this level. Now check @@ -1894,79 +1887,77 @@ int bc_DumpCmd(as, arock) * off of this dump. */ if (!parent || (dumpEntry.id > parent)) { - /* Follow the parent dumps to see if they are all there */ - for (d=dumpEntry.parent; d; d=de.parent) { - code = bcdb_FindDumpByID(d, &de); - if (code) break; + /* Follow the parent dumps to see if they are all there */ + for (d = dumpEntry.parent; d; d = de.parent) { + code = bcdb_FindDumpByID(d, &de); + if (code) + break; } /* If we found the entire level, remember it. Otherwise raise flag. * If we had already found a dump, raise the problem flag. */ if (!d && !code) { - if (parent) problemFindingDump = 1; - parent = dumpEntry.id; - level = dumpEntry.level+1; - memcpy(&fde, &dumpEntry, sizeof(dumpEntry)); - } - else { - /* Dump hierarchy not complete so can't base off the latest */ - problemFindingDump = 1; + if (parent) + problemFindingDump = 1; + parent = dumpEntry.id; + level = dumpEntry.level + 1; + memcpy(&fde, &dumpEntry, sizeof(dumpEntry)); + } else { + /* Dump hierarchy not complete so can't base off the latest */ + problemFindingDump = 1; } } } - + /* If the problemflag was raise, it means we are not doing the * dump at the level we requested it be done at. */ if (problemFindingDump) { - com_err(whoami,0, - "Warning: Doing level %d dump due to missing higher-level dumps", level); - if (parent) { - printf("Parent dump: dump %s (DumpID %u)\n", fde.name, parent); - } - } - else if (parent) { - printf("Found parent: dump %s (DumpID %u)\n", fde.name, parent); + com_err(whoami, 0, + "Warning: Doing level %d dump due to missing higher-level dumps", + level); + if (parent) { + printf("Parent dump: dump %s (DumpID %u)\n", fde.name, parent); + } + } else if (parent) { + printf("Found parent: dump %s (DumpID %u)\n", fde.name, parent); } /* Expand out the volume set into its component list of volumes. */ code = bc_EvalVolumeSet(bc_globalConfig, tvs, &volsToDump, cstruct); - if (code) - { - com_err(whoami,code,"; Failed to evaluate volume set"); - return(-1); + if (code) { + com_err(whoami, code, "; Failed to evaluate volume set"); + return (-1); } - if (!volsToDump) - { - printf("No volumes to dump\n"); - return(0); + if (!volsToDump) { + printf("No volumes to dump\n"); + return (0); } /* Determine what the clone time of the volume was when it was * last dumped (tve->date). This is the time from when an * incremental should be done (remains zero if a full dump). */ - if (parent) - { - for (tve=volsToDump; tve; tve=tve->next) - { + if (parent) { + for (tve = volsToDump; tve; tve = tve->next) { code = bcdb_FindClone(parent, tve->name, &tve->date); - if (code) tve->date = 0; + if (code) + tve->date = 0; /* Get the time the volume was last cloned and see if the volume has * changed since then. Only do this when the "-n" flag is specified * because butc will get the cloneDate at time of dump. */ - if (dontExecute) - { - code = volImageTime(tve->server.sin_addr.s_addr, tve->partition, - tve->vid, tve->volType, &tve->cloneDate); - if (code) tve->cloneDate = 0; - - if (tve->cloneDate && (tve->cloneDate == tve->date)) - { - com_err(whoami,0, + if (dontExecute) { + code = + volImageTime(tve->server.sin_addr.s_addr, tve->partition, + tve->vid, tve->volType, &tve->cloneDate); + if (code) + tve->cloneDate = 0; + + if (tve->cloneDate && (tve->cloneDate == tve->date)) { + com_err(whoami, 0, "Warning: Timestamp on volume %s unchanged from previous dump", tve->name); } @@ -1974,22 +1965,27 @@ int bc_DumpCmd(as, arock) } } - if (dontExecute) printf("Would have dumped the following volumes:\n"); - else printf("Preparing to dump the following volumes:\n"); - for (tve=volsToDump; tve; tve=tve->next) { - printf("\t%s (%u)\n", tve->name, tve->vid); - } - if (dontExecute) return(0); - - code = bc_StartDmpRst(bc_globalConfig, dumpPath, vsName, volsToDump, - /*destServer*/0, /*destPartition*/0, /*fromDate*/0, - /*newExt*/0, /*oldFlag*/0, - parent, level, bc_Dumper, portp, /*portCount*/1, baseds, - doAppend, dontExecute); - if (code) com_err(whoami,code,"; Failed to queue dump"); + if (dontExecute) + printf("Would have dumped the following volumes:\n"); + else + printf("Preparing to dump the following volumes:\n"); + for (tve = volsToDump; tve; tve = tve->next) { + printf("\t%s (%u)\n", tve->name, tve->vid); + } + if (dontExecute) + return (0); + + code = bc_StartDmpRst(bc_globalConfig, dumpPath, vsName, volsToDump, + /*destServer */ 0, /*destPartition */ 0, + /*fromDate */ 0, + /*newExt */ 0, /*oldFlag */ 0, + parent, level, bc_Dumper, portp, /*portCount */ 1, + baseds, doAppend, dontExecute); + if (code) + com_err(whoami, code, "; Failed to queue dump"); - return(code); -} /*bc_DumpCmd*/ + return (code); +} /*bc_DumpCmd */ /* bc_QuitCmd @@ -2000,25 +1996,26 @@ int bc_DumpCmd(as, arock) */ bc_QuitCmd(as, arock) - struct cmd_syndesc *as; - char *arock; + struct cmd_syndesc *as; + char *arock; { - int i; - struct bc_dumpTask *td; - extern dlqlinkT statusHead; - dlqlinkP ptr; - statusP statusPtr; + int i; + struct bc_dumpTask *td; + extern dlqlinkT statusHead; + dlqlinkP ptr; + statusP statusPtr; /* Check the status list for outstanding jobs */ lock_Status(); - for ( ptr=(&statusHead)->dlq_next; ptr!=&statusHead; ptr=ptr->dlq_next ) - { - statusPtr = (statusP) ptr; - if ( !(statusPtr->flags & ABORT_REQUEST) ) - { + for (ptr = (&statusHead)->dlq_next; ptr != &statusHead; + ptr = ptr->dlq_next) { + statusPtr = (statusP) ptr; + if (!(statusPtr->flags & ABORT_REQUEST)) { unlock_Status(); - com_err(whoami,0,"Job %d still running (and not aborted)", statusPtr->jobNumber); - com_err(whoami,0,"You must at least 'kill' all running jobs before quitting"); + com_err(whoami, 0, "Job %d still running (and not aborted)", + statusPtr->jobNumber); + com_err(whoami, 0, + "You must at least 'kill' all running jobs before quitting"); return -1; } } @@ -2027,20 +2024,20 @@ bc_QuitCmd(as, arock) /* A job still being initialized (but no status structure or job number since it * has not been handed to a butc process yet) */ - for(td=bc_dumpTasks, i=0; iflags & BC_DI_INUSE) - { - com_err(whoami,0,"A job is still running"); - com_err(whoami,0,"You must at least 'kill' all running jobs before quitting"); + for (td = bc_dumpTasks, i = 0; i < BC_MAXSIMDUMPS; i++, td++) { + if (td->flags & BC_DI_INUSE) { + com_err(whoami, 0, "A job is still running"); + com_err(whoami, 0, + "You must at least 'kill' all running jobs before quitting"); return -1; } } #ifdef AFS_NT40_ENV /* close the all temp text files before quitting */ - for(i=0; iconfigText[i], &bc_globalConfig->tmpTextFileNames[i][0]); + for (i = 0; i < TB_NUM; i++) + bc_closeTextFile(&bc_globalConfig->configText[i], + &bc_globalConfig->tmpTextFileNames[i][0]); #endif exit(lastTaskCode); } @@ -2054,57 +2051,56 @@ bc_LabelTapeCmd(as, arock) struct cmd_syndesc *as; char *arock; { - char *tapename=0, *pname=0; + char *tapename = 0, *pname = 0; afs_int32 size; afs_int32 code; afs_int32 port = 0; code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } - if(as->parms[0].items) { /* -name */ - tapename = as->parms[0].items->data; - if (strlen(tapename) >= TC_MAXTAPELEN) { - com_err(whoami,0,"AFS tape name '%s' is too long", tapename); + if (as->parms[0].items) { /* -name */ + tapename = as->parms[0].items->data; + if (strlen(tapename) >= TC_MAXTAPELEN) { + com_err(whoami, 0, "AFS tape name '%s' is too long", tapename); return -1; - } + } } - if(as->parms[3].items) { /* -pname */ - if (tapename) { + if (as->parms[3].items) { /* -pname */ + if (tapename) { com_err(whoami, 0, "Can only specify -name or -pname"); return -1; - } - pname = as->parms[3].items->data; - if (strlen(pname) >= TC_MAXTAPELEN) { - com_err(whoami,0,"Permanent tape name '%s' is too long", pname); + } + pname = as->parms[3].items->data; + if (strlen(pname) >= TC_MAXTAPELEN) { + com_err(whoami, 0, "Permanent tape name '%s' is too long", pname); return -1; - } + } } - if (as->parms[1].items) - { + if (as->parms[1].items) { size = bc_FloatATOI(as->parms[1].items->data); if (size == -1) { - com_err(whoami,0,"Bad syntax for tape size '%s'", + com_err(whoami, 0, "Bad syntax for tape size '%s'", as->parms[1].items->data); return -1; } - } - else + } else size = 0; - if (as->parms[2].items) - { - port = getPortOffset(as->parms[2].items->data); - if (port < 0) return(BC_BADARG); + if (as->parms[2].items) { + port = getPortOffset(as->parms[2].items->data); + if (port < 0) + return (BC_BADARG); } code = bc_LabelTape(tapename, pname, size, bc_globalConfig, port); - if (code) return code; + if (code) + return code; return 0; } @@ -2115,25 +2111,27 @@ bc_LabelTapeCmd(as, arock) */ bc_ReadLabelCmd(as, arock) -struct cmd_syndesc *as; -char *arock; + struct cmd_syndesc *as; + char *arock; { afs_int32 code; afs_int32 port = 0; - + code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } if (as->parms[0].items) { - port = getPortOffset(as->parms[0].items->data); - if (port < 0) return(BC_BADARG); + port = getPortOffset(as->parms[0].items->data); + if (port < 0) + return (BC_BADARG); } code = bc_ReadLabel(bc_globalConfig, port); - if (code) return code; + if (code) + return code; return 0; } @@ -2152,20 +2150,20 @@ bc_ScanDumpsCmd(as, arock) code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } /* check for flag */ - if ( as->parms[0].items != 0 ) /* add scan to database */ - { - dbAddFlag++; + if (as->parms[0].items != 0) { /* add scan to database */ + dbAddFlag++; } /* check for port */ if (as->parms[1].items) { - port = getPortOffset(as->parms[1].items->data); - if (port < 0) return(BC_BADARG); + port = getPortOffset(as->parms[1].items->data); + if (port < 0) + return (BC_BADARG); } code = bc_ScanDumps(bc_globalConfig, dbAddFlag, port); @@ -2187,66 +2185,63 @@ bc_ParseExpiration(paramPtr, expType, expDate) afs_int32 *expType; afs_int32 *expDate; { - struct cmd_item *itemPtr; - struct ktime_date kt; - char *dateString = 0; - afs_int32 code = 0; - - *expType = BC_NO_EXPDATE; - *expDate = 0; - - if ( !paramPtr->items ) ERROR(0); /* no expiration specified */ - - /* some form of expiration date specified. First validate the prefix */ - itemPtr = paramPtr->items; - - if ( strcmp(itemPtr->data, "at") == 0 ) - { - *expType = BC_ABS_EXPDATE; - - dateString = concatParams(itemPtr->next); - if (!dateString) ERROR(1); - - code = ktime_DateToLong(dateString, expDate); - if (code) ERROR(1); - } - else - if ( strcmp(itemPtr->data, "in") == 0 ) - { - *expType = BC_REL_EXPDATE; - - dateString = concatParams(itemPtr->next); - if (!dateString) ERROR(1); - - code = ParseRelDate(dateString, &kt); - if (code) ERROR(1); - *expDate = ktimeRelDate_ToLong(&kt); - } - else - { - dateString = concatParams(itemPtr); - if (!dateString) ERROR(1); - - if ( ktime_DateToLong(dateString,expDate) == 0 ) - { - *expType = BC_ABS_EXPDATE; - code = ktime_DateToLong(dateString, expDate); - if (code) ERROR(1); - } - else if ( ParseRelDate(dateString,&kt) == 0 ) - { - *expType = BC_REL_EXPDATE; - *expDate = ktimeRelDate_ToLong(&kt); - } - else - { - ERROR(1); - } - } - -error_exit: - if (dateString) free(dateString); - return(code); + struct cmd_item *itemPtr; + struct ktime_date kt; + char *dateString = 0; + afs_int32 code = 0; + + *expType = BC_NO_EXPDATE; + *expDate = 0; + + if (!paramPtr->items) + ERROR(0); /* no expiration specified */ + + /* some form of expiration date specified. First validate the prefix */ + itemPtr = paramPtr->items; + + if (strcmp(itemPtr->data, "at") == 0) { + *expType = BC_ABS_EXPDATE; + + dateString = concatParams(itemPtr->next); + if (!dateString) + ERROR(1); + + code = ktime_DateToLong(dateString, expDate); + if (code) + ERROR(1); + } else if (strcmp(itemPtr->data, "in") == 0) { + *expType = BC_REL_EXPDATE; + + dateString = concatParams(itemPtr->next); + if (!dateString) + ERROR(1); + + code = ParseRelDate(dateString, &kt); + if (code) + ERROR(1); + *expDate = ktimeRelDate_ToLong(&kt); + } else { + dateString = concatParams(itemPtr); + if (!dateString) + ERROR(1); + + if (ktime_DateToLong(dateString, expDate) == 0) { + *expType = BC_ABS_EXPDATE; + code = ktime_DateToLong(dateString, expDate); + if (code) + ERROR(1); + } else if (ParseRelDate(dateString, &kt) == 0) { + *expType = BC_REL_EXPDATE; + *expDate = ktimeRelDate_ToLong(&kt); + } else { + ERROR(1); + } + } + + error_exit: + if (dateString) + free(dateString); + return (code); } /* database lookup command and routines */ @@ -2264,11 +2259,11 @@ bc_dblookupCmd(as, arock) afs_int32 code; ciptr = as->parms[0].items; - if ( ciptr == 0 ) /* no argument specified */ - return(-1); + if (ciptr == 0) /* no argument specified */ + return (-1); code = DBLookupByVolume(ciptr->data); - return(code); + return (code); } @@ -2284,140 +2279,148 @@ bc_dbVerifyCmd(as, arock) afs_int32 host; struct hostent *hostPtr; - int detail; + int detail; afs_int32 code = 0; extern struct udbHandleS udbHandle; - - detail = (as->parms[0].items ? 1 : 0); /* print more details */ - code = ubik_Call(BUDB_DbVerify, udbHandle.uh_client, 0, - &status, &orphans, &host); + detail = (as->parms[0].items ? 1 : 0); /* print more details */ - if (code) - { + code = + ubik_Call(BUDB_DbVerify, udbHandle.uh_client, 0, &status, &orphans, + &host); + + if (code) { com_err(whoami, code, "; Unable to verify database"); - return(-1); + return (-1); } /* verification call succeeded */ - + if (status == 0) printf("Database OK\n"); else com_err(whoami, status, "; Database is NOT_OK"); - if (detail) - { + if (detail) { printf("Orphan blocks %d\n", orphans); if (!host) printf("Unable to lookup host id\n"); - else - { - hostPtr = gethostbyaddr((char *) &host, sizeof(host), AF_INET); - if (hostPtr == 0 ) - printf("Database checker was %d.%d.%d.%d\n", - ((host&0xFF000000)>>24), ((host&0xFF0000)>>16), - ((host&0xFF00)>>8), (host&0xFF)); + else { + hostPtr = gethostbyaddr((char *)&host, sizeof(host), AF_INET); + if (hostPtr == 0) + printf("Database checker was %d.%d.%d.%d\n", + ((host & 0xFF000000) >> 24), ((host & 0xFF0000) >> 16), + ((host & 0xFF00) >> 8), (host & 0xFF)); else - printf("Database checker was %s\n", hostPtr->h_name); + printf("Database checker was %s\n", hostPtr->h_name); } } - return((status ? -1 : 0)); + return ((status ? -1 : 0)); } /* deleteDump: * Delete a dump. If port is >= 0, it means try to delete from XBSA server */ deleteDump(dumpid, port, force) - afs_uint32 dumpid; /* The dumpid to delete */ - afs_int32 port; /* port==-1 means don't go to butc */ - afs_int32 force; + afs_uint32 dumpid; /* The dumpid to delete */ + afs_int32 port; /* port==-1 means don't go to butc */ + afs_int32 force; { - afs_int32 code=0, tcode; - struct budb_dumpEntry dumpEntry; - struct rx_connection *tconn=0; - afs_int32 i, taskflag, xbsadump; - statusP statusPtr=0; - budb_dumpsList dumps; - afs_uint32 taskId; - - /* If the port is set, we will try to send a delete request to the butc */ - if (port >= 0) { - tcode = bc_UpdateHosts(); - if (tcode) { - com_err(whoami, tcode, "; Can't retrieve tape hosts"); - ERROR(tcode); - } - - /* Find the dump in the backup database */ - tcode = bcdb_FindDumpByID(dumpid, &dumpEntry); - if (tcode) { - com_err(whoami, tcode, "; Unable to locate dumpID %u in database", dumpid); - ERROR(tcode); - } - xbsadump = (dumpEntry.flags & (BUDB_DUMP_ADSM|BUDB_DUMP_BUTA)); - - /* If dump is to an XBSA server, connect to butc and send it - * the dump to delete. Butc will contact the XBSA server. - * The dump will not be an appended dump because XBSA butc - * does not support the append option. - */ - if (xbsadump && dumpEntry.nVolumes) { - tcode = ConnectButc(bc_globalConfig, port, &tconn); - if (tcode) ERROR(tcode); - - tcode = TC_DeleteDump(tconn, dumpid, &taskId); - if (tcode) { - if (tcode == RXGEN_OPCODE) tcode = BC_VERSIONFAIL; - com_err(whoami, tcode, "; Unable to delete dumpID %u via butc", dumpid); + afs_int32 code = 0, tcode; + struct budb_dumpEntry dumpEntry; + struct rx_connection *tconn = 0; + afs_int32 i, taskflag, xbsadump; + statusP statusPtr = 0; + budb_dumpsList dumps; + afs_uint32 taskId; + + /* If the port is set, we will try to send a delete request to the butc */ + if (port >= 0) { + tcode = bc_UpdateHosts(); + if (tcode) { + com_err(whoami, tcode, "; Can't retrieve tape hosts"); + ERROR(tcode); + } + + /* Find the dump in the backup database */ + tcode = bcdb_FindDumpByID(dumpid, &dumpEntry); + if (tcode) { + com_err(whoami, tcode, "; Unable to locate dumpID %u in database", + dumpid); ERROR(tcode); - } - - statusPtr = createStatusNode(); - lock_Status(); - statusPtr->taskId = taskId; - statusPtr->port = port; - statusPtr->jobNumber = bc_jobNumber(); - statusPtr->flags |= (SILENT|NOREMOVE); /* No msg & keep statusPtr */ - statusPtr->flags &= ~STARTING; /* clearstatus to examine */ - sprintf(statusPtr->taskName, "DeleteDump"); - unlock_Status(); - - /* Wait for task to finish */ - taskflag = waitForTask(taskId); - if (taskflag & (TASK_ERROR|ABORT_DONE)) { - com_err(whoami, BUTX_DELETEOBJFAIL, "; Unable to delete dumpID %u via butc", dumpid); - ERROR(BUTX_DELETEOBJFAIL); /* the task failed */ - } - } - } + } + xbsadump = (dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA)); + + /* If dump is to an XBSA server, connect to butc and send it + * the dump to delete. Butc will contact the XBSA server. + * The dump will not be an appended dump because XBSA butc + * does not support the append option. + */ + if (xbsadump && dumpEntry.nVolumes) { + tcode = ConnectButc(bc_globalConfig, port, &tconn); + if (tcode) + ERROR(tcode); + + tcode = TC_DeleteDump(tconn, dumpid, &taskId); + if (tcode) { + if (tcode == RXGEN_OPCODE) + tcode = BC_VERSIONFAIL; + com_err(whoami, tcode, + "; Unable to delete dumpID %u via butc", dumpid); + ERROR(tcode); + } + + statusPtr = createStatusNode(); + lock_Status(); + statusPtr->taskId = taskId; + statusPtr->port = port; + statusPtr->jobNumber = bc_jobNumber(); + statusPtr->flags |= (SILENT | NOREMOVE); /* No msg & keep statusPtr */ + statusPtr->flags &= ~STARTING; /* clearstatus to examine */ + sprintf(statusPtr->taskName, "DeleteDump"); + unlock_Status(); + + /* Wait for task to finish */ + taskflag = waitForTask(taskId); + if (taskflag & (TASK_ERROR | ABORT_DONE)) { + com_err(whoami, BUTX_DELETEOBJFAIL, + "; Unable to delete dumpID %u via butc", dumpid); + ERROR(BUTX_DELETEOBJFAIL); /* the task failed */ + } + } + } error_exit: - if (statusPtr) deleteStatusNode(statusPtr); /* Clean up statusPtr - because NOREMOVE */ - if (tconn) rx_DestroyConnection(tconn); /* Destroy the connection */ - - /* Remove the dump from the backup database */ - if (!code || force) { - dumps.budb_dumpsList_len = 0; - dumps.budb_dumpsList_val = 0; - - tcode = bcdb_deleteDump(dumpid, 0, 0, &dumps); - if (tcode) { - com_err(whoami, tcode, "; Unable to delete dumpID %u from database", dumpid); - dumps.budb_dumpsList_len = 0; - if (!code) code = tcode; - } - - /* Display the dumps that were deleted - includes appended dumps */ - for (i=0; i0)?" Appended Dump":""); - if (dumps.budb_dumpsList_val) free(dumps.budb_dumpsList_val); - } - - return code; + if (statusPtr) + deleteStatusNode(statusPtr); /* Clean up statusPtr - because NOREMOVE */ + if (tconn) + rx_DestroyConnection(tconn); /* Destroy the connection */ + + /* Remove the dump from the backup database */ + if (!code || force) { + dumps.budb_dumpsList_len = 0; + dumps.budb_dumpsList_val = 0; + + tcode = bcdb_deleteDump(dumpid, 0, 0, &dumps); + if (tcode) { + com_err(whoami, tcode, + "; Unable to delete dumpID %u from database", dumpid); + dumps.budb_dumpsList_len = 0; + if (!code) + code = tcode; + } + + /* Display the dumps that were deleted - includes appended dumps */ + for (i = 0; i < dumps.budb_dumpsList_len; i++) + printf(" %u%s\n", dumps.budb_dumpsList_val[i], + (i > 0) ? " Appended Dump" : ""); + if (dumps.budb_dumpsList_val) + free(dumps.budb_dumpsList_val); + } + + return code; } /* bc_deleteDumpCmd @@ -2431,94 +2434,97 @@ bc_deleteDumpCmd(as, arock) char *arock; { afs_uint32 dumpid; - afs_int32 code = 0; + afs_int32 code = 0; afs_int32 rcode = 0; - afs_int32 groupId=0, havegroupid, sflags, noexecute; + afs_int32 groupId = 0, havegroupid, sflags, noexecute; struct cmd_item *ti; - afs_uint32 fromTime=0, toTime=0, havetime=0; - char *timeString; + afs_uint32 fromTime = 0, toTime = 0, havetime = 0; + char *timeString; budb_dumpsList dumps, flags; int i; - afs_int32 port=-1, dbonly=0, force; + afs_int32 port = -1, dbonly = 0, force; afs_uint32 taskid; /* Must specify at least one of -dumpid, -from, or -to */ - if ( !as->parms[0].items && !as->parms[1].items && !as->parms[2].items && - !as->parms[4].items) { + if (!as->parms[0].items && !as->parms[1].items && !as->parms[2].items + && !as->parms[4].items) { com_err(whoami, 0, "Must specify at least one field"); - return(-1); + return (-1); } /* Must have -to option with -from option */ - if ( as->parms[1].items && !as->parms[2].items ) { + if (as->parms[1].items && !as->parms[2].items) { com_err(whoami, 0, "Must specify '-to' field with '-from' field"); - return(-1); + return (-1); } /* Get the time to delete from */ - if ( as->parms[1].items ) { /* -from */ + if (as->parms[1].items) { /* -from */ timeString = concatParams(as->parms[1].items); - if (!timeString) return(-1); + if (!timeString) + return (-1); /* * Now parse this string for the time to start. */ code = ktime_DateToLong(timeString, &fromTime); - free (timeString); - if ( code ) - { - com_err(whoami,0,"Can't parse 'from' date and time"); - com_err(whoami,0,"%s", ktime_GetDateUsage()); - return(-1); + free(timeString); + if (code) { + com_err(whoami, 0, "Can't parse 'from' date and time"); + com_err(whoami, 0, "%s", ktime_GetDateUsage()); + return (-1); } havetime = 1; } - port = (as->parms[3].items ? getPortOffset(as->parms[3].items->data) : 0); /* -port */ - if (as->parms[5].items) /* -dbonly */ - port = -1; - - force = (as->parms[6].items ? 1 : 0); + port = (as->parms[3].items ? getPortOffset(as->parms[3].items->data) : 0); /* -port */ + if (as->parms[5].items) /* -dbonly */ + port = -1; + + force = (as->parms[6].items ? 1 : 0); - havegroupid = (as->parms[4].items ? 1 : 0); - if (havegroupid) groupId = atoi(as->parms[4].items->data); + havegroupid = (as->parms[4].items ? 1 : 0); + if (havegroupid) + groupId = atoi(as->parms[4].items->data); - noexecute = (as->parms[7].items ? 1 : 0); + noexecute = (as->parms[7].items ? 1 : 0); /* Get the time to delete to */ - if ( as->parms[2].items ) { /* -to */ + if (as->parms[2].items) { /* -to */ timeString = concatParams(as->parms[2].items); - if (!timeString) return(-1); + if (!timeString) + return (-1); /* * Now parse this string for the time to start. Simce * times are at minute granularity, add 59 seconds. */ code = ktime_DateToLong(timeString, &toTime); - free (timeString); - if ( code ) - { - com_err(whoami,0,"Can't parse 'to' date and time"); - com_err(whoami,0,"%s", ktime_GetDateUsage()); - return(-1); + free(timeString); + if (code) { + com_err(whoami, 0, "Can't parse 'to' date and time"); + com_err(whoami, 0, "%s", ktime_GetDateUsage()); + return (-1); } toTime += 59; havetime = 1; } - if ( fromTime > toTime ) { - com_err(whoami, 0, "'-from' date/time cannot be later than '-to' date/time"); - return(-1); + if (fromTime > toTime) { + com_err(whoami, 0, + "'-from' date/time cannot be later than '-to' date/time"); + return (-1); } /* Remove speicific dump ids - if any */ - printf("The following dumps %s deleted:\n", (noexecute?"would have been":"were")); - for ( ti=as->parms[0].items; ti != 0; ti=ti->next ) { /* -dumpid */ - dumpid = atoi(ti->data); + printf("The following dumps %s deleted:\n", + (noexecute ? "would have been" : "were")); + for (ti = as->parms[0].items; ti != 0; ti = ti->next) { /* -dumpid */ + dumpid = atoi(ti->data); if (!noexecute) { - code = deleteDump(dumpid, port, force); + code = deleteDump(dumpid, port, force); } else { - printf(" %u\n", dumpid); + printf(" %u\n", dumpid); } } @@ -2531,40 +2537,52 @@ bc_deleteDumpCmd(as, arock) flags.budb_dumpsList_len = 0; flags.budb_dumpsList_val = 0; sflags = 0; - if (havegroupid) sflags |= BUDB_OP_GROUPID; - if (havetime) sflags |= BUDB_OP_DATES; + if (havegroupid) + sflags |= BUDB_OP_GROUPID; + if (havetime) + sflags |= BUDB_OP_DATES; - code = bcdb_listDumps(sflags, groupId, fromTime, toTime, &dumps, &flags); - if ( code ) { - com_err(whoami, code, "; Error while deleting dumps from %u to %u", - fromTime, toTime); + code = + bcdb_listDumps(sflags, groupId, fromTime, toTime, &dumps, &flags); + if (code) { + com_err(whoami, code, + "; Error while deleting dumps from %u to %u", fromTime, + toTime); rcode = -1; } - for (i=0; iparms[0].items) { portOffset = getPortOffset(as->parms[0].items->data); - if (portOffset < 0) return(BC_BADARG); + if (portOffset < 0) + return (BC_BADARG); } /* Get the time to delete to */ - if ( as->parms[1].items ) - { + if (as->parms[1].items) { timeString = concatParams(as->parms[1].items); - if (!timeString) return(-1); + if (!timeString) + return (-1); /* * Now parse this string for the time. Since * times are at minute granularity, add 59 seconds. */ code = ktime_DateToLong(timeString, &toTime); - free (timeString); - if ( code ) - { - com_err(whoami,0,"Can't parse '-archive' date and time"); - com_err(whoami,0,"%s", ktime_GetDateUsage()); - return(-1); + free(timeString); + if (code) { + com_err(whoami, 0, "Can't parse '-archive' date and time"); + com_err(whoami, 0, "%s", ktime_GetDateUsage()); + return (-1); } toTime += 59; - } - else - toTime = 0; + } else + toTime = 0; code = ConnectButc(bc_globalConfig, portOffset, &tconn); - if (code) return(code); - - code = TC_SaveDb(tconn, toTime, &taskId); if (code) - { + return (code); + + code = TC_SaveDb(tconn, toTime, &taskId); + if (code) { com_err(whoami, code, "; Failed to save database"); goto exit; } @@ -2626,16 +2643,16 @@ bc_saveDbCmd(as, arock) /* create status monitor block */ statusPtr = createStatusNode(); lock_Status(); - statusPtr->taskId = taskId; - statusPtr->port = portOffset; + statusPtr->taskId = taskId; + statusPtr->port = portOffset; statusPtr->jobNumber = bc_jobNumber(); - statusPtr->flags &= ~STARTING; /* clearstatus to examine */ + statusPtr->flags &= ~STARTING; /* clearstatus to examine */ sprintf(statusPtr->taskName, "SaveDb"); unlock_Status(); -exit: + exit: rx_DestroyConnection(tconn); - return(code); + return (code); } bc_restoreDbCmd(as, arock) @@ -2650,21 +2667,22 @@ bc_restoreDbCmd(as, arock) code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } if (as->parms[0].items) { - portOffset = getPortOffset(as->parms[0].items->data); - if (portOffset < 0) return(BC_BADARG); + portOffset = getPortOffset(as->parms[0].items->data); + if (portOffset < 0) + return (BC_BADARG); } code = ConnectButc(bc_globalConfig, portOffset, &tconn); - if (code) return(code); - - code = TC_RestoreDb(tconn, &taskId); if (code) - { + return (code); + + code = TC_RestoreDb(tconn, &taskId); + if (code) { com_err(whoami, code, "; Failed to restore database"); goto exit; } @@ -2672,16 +2690,16 @@ bc_restoreDbCmd(as, arock) /* create status monitor block */ statusPtr = createStatusNode(); lock_Status(); - statusPtr->taskId = taskId; - statusPtr->port = portOffset; - statusPtr->jobNumber = bc_jobNumber(); - statusPtr->flags &= ~STARTING; /* clearstatus to examine */ + statusPtr->taskId = taskId; + statusPtr->port = portOffset; + statusPtr->jobNumber = bc_jobNumber(); + statusPtr->flags &= ~STARTING; /* clearstatus to examine */ sprintf(statusPtr->taskName, "RestoreDb"); unlock_Status(); -exit: + exit: rx_DestroyConnection(tconn); - return(code); + return (code); } /* ---------------------------------- @@ -2691,14 +2709,13 @@ exit: /* structures and defines for DBLookupByVolume */ -#define DBL_MAX_VOLUMES 20 /* max. for each dump */ +#define DBL_MAX_VOLUMES 20 /* max. for each dump */ /* dumpedVol - saves interesting information so that we can print it out * later */ -struct dumpedVol -{ +struct dumpedVol { struct dumpedVol *next; afs_int32 dumpID; afs_int32 initialDumpID; @@ -2706,7 +2723,7 @@ struct dumpedVol afs_int32 level; afs_int32 parent; afs_int32 createTime; - afs_int32 incTime; /* actually the clone time */ + afs_int32 incTime; /* actually the clone time */ }; /* ----------------------------------------- @@ -2727,123 +2744,124 @@ DBLookupByVolume(volumeName) struct budb_volumeEntry volumeEntry[DBL_MAX_VOLUMES]; afs_int32 numEntries; afs_int32 tapedumpid; - afs_int32 last,next; + afs_int32 last, next; struct dumpedVol *dvptr = 0; struct dumpedVol *tempPtr = 0; - afs_int32 code=0; + afs_int32 code = 0; int i, pass; char vname[BU_MAXNAMELEN]; char ds[50]; - + for (pass = 0; pass < 2; pass++) { - /*p*/ - /* On second pass, search for backup volume */ - if (pass == 1) { - if (!BackupName(volumeName)) { - strcpy(vname, volumeName); - strcat(vname, ".backup"); - volumeName = vname; - } - else { - continue; - } - } - - last = next = 0; - while ( next != -1 ) - { /*w*/ - code = bcdb_LookupVolume(volumeName, &volumeEntry[0], - last, &next, DBL_MAX_VOLUMES, &numEntries); - if (code) break; - - /* add the volumes to the list */ - for ( i = 0; i < numEntries; i++ ) - { /*f*/ - struct dumpedVol *insPtr, **prevPtr; - - tempPtr = (struct dumpedVol *) malloc(sizeof(struct dumpedVol)); - if (!tempPtr) ERROR(BC_NOMEM); - - memset(tempPtr, 0, sizeof(*tempPtr)); - tempPtr->incTime = volumeEntry[i].clone; - tempPtr->dumpID = volumeEntry[i].dump; - strncpy(tempPtr->tapeName, volumeEntry[i].tape, BU_MAXTAPELEN); - - /* check if we need to null terminate it - just for safety */ - if ( strlen(volumeEntry[i].tape) >= BU_MAXTAPELEN ) - tempPtr->tapeName[BU_MAXTAPELEN-1] = 0; - - code = bcdb_FindDumpByID(tempPtr->dumpID, &dumpEntry); - if (code) - { - free(tempPtr); - ERROR(code); - } - - tempPtr->initialDumpID = dumpEntry.initialDumpID; - tempPtr->parent = dumpEntry.parent; - tempPtr->level = dumpEntry.level; - tempPtr->createTime = dumpEntry.created; - - /* add volume to list in reverse chronological order */ - prevPtr = &dvptr; - insPtr = dvptr; - - while ( (insPtr != 0) - && (insPtr->createTime > tempPtr->createTime) - ) - { - prevPtr = &insPtr->next; - insPtr = insPtr->next; - } - - /* now at the right place - insert the block */ - tempPtr->next = *prevPtr; - *prevPtr = tempPtr; - } /*f*/ - - last = next; - } /*w*/ - } /*p*/ - + /*p */ + /* On second pass, search for backup volume */ + if (pass == 1) { + if (!BackupName(volumeName)) { + strcpy(vname, volumeName); + strcat(vname, ".backup"); + volumeName = vname; + } else { + continue; + } + } + + last = next = 0; + while (next != -1) { /*w */ + code = + bcdb_LookupVolume(volumeName, &volumeEntry[0], last, &next, + DBL_MAX_VOLUMES, &numEntries); + if (code) + break; + + /* add the volumes to the list */ + for (i = 0; i < numEntries; i++) { /*f */ + struct dumpedVol *insPtr, **prevPtr; + + tempPtr = + (struct dumpedVol *)malloc(sizeof(struct dumpedVol)); + if (!tempPtr) + ERROR(BC_NOMEM); + + memset(tempPtr, 0, sizeof(*tempPtr)); + tempPtr->incTime = volumeEntry[i].clone; + tempPtr->dumpID = volumeEntry[i].dump; + strncpy(tempPtr->tapeName, volumeEntry[i].tape, + BU_MAXTAPELEN); + + /* check if we need to null terminate it - just for safety */ + if (strlen(volumeEntry[i].tape) >= BU_MAXTAPELEN) + tempPtr->tapeName[BU_MAXTAPELEN - 1] = 0; + + code = bcdb_FindDumpByID(tempPtr->dumpID, &dumpEntry); + if (code) { + free(tempPtr); + ERROR(code); + } + + tempPtr->initialDumpID = dumpEntry.initialDumpID; + tempPtr->parent = dumpEntry.parent; + tempPtr->level = dumpEntry.level; + tempPtr->createTime = dumpEntry.created; + + /* add volume to list in reverse chronological order */ + prevPtr = &dvptr; + insPtr = dvptr; + + while ((insPtr != 0) + && (insPtr->createTime > tempPtr->createTime) + ) { + prevPtr = &insPtr->next; + insPtr = insPtr->next; + } + + /* now at the right place - insert the block */ + tempPtr->next = *prevPtr; + *prevPtr = tempPtr; + } /*f */ + + last = next; + } /*w */ + } /*p */ + if (dvptr) { - printf("DumpID lvl parentID creation date clone date tape name\n"); - for (tempPtr = dvptr; tempPtr; tempPtr = tempPtr->next) { - /* For the user, the tape name is its name and initial dump id */ - tapedumpid = (tempPtr->initialDumpID ? tempPtr->initialDumpID : tempPtr->dumpID); - - /* beware the static items in compactDateString */ - compactDateString(&tempPtr->createTime, ds, 50); - printf("%-9d %-2d %-9d %16s", - tempPtr->dumpID, tempPtr->level, tempPtr->parent, ds); - compactDateString(&tempPtr->incTime, ds, 50); - printf(" %16s %s (%u)\n", ds, tempPtr->tapeName, tapedumpid); - } - code = 0; - } - -error_exit: + printf + ("DumpID lvl parentID creation date clone date tape name\n"); + for (tempPtr = dvptr; tempPtr; tempPtr = tempPtr->next) { + /* For the user, the tape name is its name and initial dump id */ + tapedumpid = + (tempPtr->initialDumpID ? tempPtr->initialDumpID : tempPtr-> + dumpID); + + /* beware the static items in compactDateString */ + compactDateString(&tempPtr->createTime, ds, 50); + printf("%-9d %-2d %-9d %16s", tempPtr->dumpID, tempPtr->level, + tempPtr->parent, ds); + compactDateString(&tempPtr->incTime, ds, 50); + printf(" %16s %s (%u)\n", ds, tempPtr->tapeName, tapedumpid); + } + code = 0; + } + + error_exit: for (tempPtr = dvptr; tempPtr; tempPtr = dvptr) { dvptr = dvptr->next; free(tempPtr); } if (code) - com_err(whoami, code, ""); - return(code); + com_err(whoami, code, ""); + return (code); } /* structures for dumpInfo */ -struct volumeLink -{ +struct volumeLink { struct volumeLink *nextVolume; struct budb_volumeEntry volumeEntry; }; -struct tapeLink -{ +struct tapeLink { struct tapeLink *nextTape; struct budb_tapeEntry tapeEntry; struct volumeLink *firstVolume; @@ -2881,20 +2899,21 @@ dumpInfo(dumpid, detailFlag) lastTapeLinkPtr = 0; volumeLinkPtr = 0; lastVolumeLinkPtr = 0; - + /* first get information about the dump */ code = bcdb_FindDumpByID(dumpid, &dumpEntry); - if (code) ERROR(code); + if (code) + ERROR(code); /* For the user, the tape name is its name and initial dump id */ tapedumpid = (dumpEntry.initialDumpID ? dumpEntry.initialDumpID : dumpid); /* Is this a database dump id or not */ - if ( strcmp(dumpEntry.name,DUMP_TAPE_NAME) == 0 ) - dbDump = 1; + if (strcmp(dumpEntry.name, DUMP_TAPE_NAME) == 0) + dbDump = 1; else - dbDump = 0; + dbDump = 0; /* print out the information about the dump */ if (detailFlag) { @@ -2902,101 +2921,90 @@ dumpInfo(dumpid, detailFlag) printf("----\n"); printDumpEntry(&dumpEntry); } else { - if ( dbDump ) - printf("Dump: id %u, created: %s\n", - dumpEntry.id, ctime(&dumpEntry.created)); + if (dbDump) + printf("Dump: id %u, created: %s\n", dumpEntry.id, + ctime(&dumpEntry.created)); else printf("Dump: id %u, level %d, volumes %d, created: %s\n", dumpEntry.id, dumpEntry.level, dumpEntry.nVolumes, ctime(&dumpEntry.created)); } - if ( !detailFlag && (strlen(dumpEntry.tapes.tapeServer) > 0) && - (dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA)) ) { - printf("Backup Service: TSM: Server: %s\n", - dumpEntry.tapes.tapeServer); + if (!detailFlag && (strlen(dumpEntry.tapes.tapeServer) > 0) + && (dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA))) { + printf("Backup Service: TSM: Server: %s\n", + dumpEntry.tapes.tapeServer); } /* now get the list of tapes */ - for (tapeNumber=dumpEntry.tapes.b; tapeNumber<=dumpEntry.tapes.maxTapes; tapeNumber++) - { /*f*/ - tapeLinkPtr = (struct tapeLink *) malloc(sizeof(struct tapeLink)); - if (!tapeLinkPtr) - { - com_err(whoami,BC_NOMEM,""); + for (tapeNumber = dumpEntry.tapes.b; tapeNumber <= dumpEntry.tapes.maxTapes; tapeNumber++) { /*f */ + tapeLinkPtr = (struct tapeLink *)malloc(sizeof(struct tapeLink)); + if (!tapeLinkPtr) { + com_err(whoami, BC_NOMEM, ""); ERROR(BC_NOMEM); } memset(tapeLinkPtr, 0, sizeof(*tapeLinkPtr)); code = bcdb_FindTapeSeq(dumpid, tapeNumber, &tapeLinkPtr->tapeEntry); - if (code) - { + if (code) { code = 0; free(tapeLinkPtr); continue; } /* add this tape to previous chain */ - if (lastTapeLinkPtr) - { + if (lastTapeLinkPtr) { lastTapeLinkPtr->nextTape = tapeLinkPtr; lastTapeLinkPtr = tapeLinkPtr; } - if (head == 0) - { + if (head == 0) { head = tapeLinkPtr; lastTapeLinkPtr = head; } next = 0; - while (next != -1) - { /*wn*/ + while (next != -1) { /*wn */ vl.budb_volumeList_len = 0; vl.budb_volumeList_val = 0; last = next; /* now get all the volumes in this dump. */ - code = ubik_Call_SingleServer(BUDB_GetVolumes, udbHandle.uh_client, - UF_SINGLESERVER, - BUDB_MAJORVERSION, - BUDB_OP_DUMPID | BUDB_OP_TAPENAME, - tapeLinkPtr->tapeEntry.name, /* tape name */ - dumpid, /* dumpid (not initial dumpid) */ - 0, /* end */ - last, /* last */ - &next, /* nextindex */ - &dbTime, /* update time */ + code = ubik_Call_SingleServer(BUDB_GetVolumes, udbHandle.uh_client, UF_SINGLESERVER, BUDB_MAJORVERSION, BUDB_OP_DUMPID | BUDB_OP_TAPENAME, tapeLinkPtr->tapeEntry.name, /* tape name */ + dumpid, /* dumpid (not initial dumpid) */ + 0, /* end */ + last, /* last */ + &next, /* nextindex */ + &dbTime, /* update time */ &vl); - if (code) - { - if ( code == BUDB_ENDOFLIST ) /* 0 volumes on tape */ - { + if (code) { + if (code == BUDB_ENDOFLIST) { /* 0 volumes on tape */ code = 0; break; } ERROR(code); } - for (i=0; ifirstVolume; - volumeLinkPtr = (struct volumeLink *) malloc(sizeof(struct volumeLink)); - if (!volumeLinkPtr) - { - com_err(whoami,BC_NOMEM,""); + volumeLinkPtr = + (struct volumeLink *)malloc(sizeof(struct volumeLink)); + if (!volumeLinkPtr) { + com_err(whoami, BC_NOMEM, ""); ERROR(BC_NOMEM); } memset(volumeLinkPtr, 0, sizeof(*volumeLinkPtr)); - memcpy(&volumeLinkPtr->volumeEntry, &vl.budb_volumeList_val[i], sizeof(struct budb_volumeEntry)); + memcpy(&volumeLinkPtr->volumeEntry, + &vl.budb_volumeList_val[i], + sizeof(struct budb_volumeEntry)); /* now insert it onto the right place */ - while ( (*link != 0) && - (volumeLinkPtr->volumeEntry.position > (*link)->volumeEntry.position) ) - { + while ((*link != 0) + && (volumeLinkPtr->volumeEntry.position > + (*link)->volumeEntry.position)) { link = &((*link)->nextVolume); } @@ -3005,24 +3013,25 @@ dumpInfo(dumpid, detailFlag) *link = volumeLinkPtr; } - if (vl.budb_volumeList_val) free(vl.budb_volumeList_val); - } /*wn*/ - } /*f*/ + if (vl.budb_volumeList_val) + free(vl.budb_volumeList_val); + } /*wn */ + } /*f */ - for (tapeLinkPtr=head; tapeLinkPtr; tapeLinkPtr=tapeLinkPtr->nextTape) - { + for (tapeLinkPtr = head; tapeLinkPtr; tapeLinkPtr = tapeLinkPtr->nextTape) { if (detailFlag) { printf("\nTape\n"); printf("----\n"); printTapeEntry(&tapeLinkPtr->tapeEntry); } else { - printf("Tape: name %s (%u)\n", tapeLinkPtr->tapeEntry.name, tapedumpid); + printf("Tape: name %s (%u)\n", tapeLinkPtr->tapeEntry.name, + tapedumpid); printf("nVolumes %d, ", tapeLinkPtr->tapeEntry.nVolumes); compactDateString(&tapeLinkPtr->tapeEntry.written, ds, 50); printf("created %16s", ds); - if ( tapeLinkPtr->tapeEntry.expires != 0 ) { - compactDateString(&tapeLinkPtr->tapeEntry.expires, ds, 50); - printf(", expires %16s", ds); + if (tapeLinkPtr->tapeEntry.expires != 0) { + compactDateString(&tapeLinkPtr->tapeEntry.expires, ds, 50); + printf(", expires %16s", ds); } printf("\n\n"); } @@ -3030,70 +3039,65 @@ dumpInfo(dumpid, detailFlag) /* print out all the volumes */ /* print header for volume listing - db dumps have no volumes */ - if ( (detailFlag == 0) && !dbDump ) - printf("%4s %16s %9s %-s\n", "Pos", "Clone time", "Nbytes", "Volume"); - - for (volumeLinkPtr=tapeLinkPtr->firstVolume; volumeLinkPtr; - volumeLinkPtr=volumeLinkPtr->nextVolume) - { - if (detailFlag) - { + if ((detailFlag == 0) && !dbDump) + printf("%4s %16s %9s %-s\n", "Pos", "Clone time", "Nbytes", + "Volume"); + + for (volumeLinkPtr = tapeLinkPtr->firstVolume; volumeLinkPtr; + volumeLinkPtr = volumeLinkPtr->nextVolume) { + if (detailFlag) { printf("\nVolume\n"); printf("------\n"); printVolumeEntry(&volumeLinkPtr->volumeEntry); - } - else - { - compactDateString(&volumeLinkPtr->volumeEntry.clone, ds, 50), - printf("%4d %s %10u %16s\n", - volumeLinkPtr->volumeEntry.position, - ds, - volumeLinkPtr->volumeEntry.nBytes, - volumeLinkPtr->volumeEntry.name); + } else { + compactDateString(&volumeLinkPtr->volumeEntry.clone, ds, 50), + printf("%4d %s %10u %16s\n", + volumeLinkPtr->volumeEntry.position, ds, + volumeLinkPtr->volumeEntry.nBytes, + volumeLinkPtr->volumeEntry.name); } } } -error_exit: - if (code) com_err("dumpInfo", code, "; Can't get dump information"); + error_exit: + if (code) + com_err("dumpInfo", code, "; Can't get dump information"); /* free all allocated structures */ tapeLinkPtr = head; - while ( tapeLinkPtr ) - { + while (tapeLinkPtr) { volumeLinkPtr = tapeLinkPtr->firstVolume; - while ( volumeLinkPtr ) - { + while (volumeLinkPtr) { lastVolumeLinkPtr = volumeLinkPtr; volumeLinkPtr = volumeLinkPtr->nextVolume; free(lastVolumeLinkPtr); } - + lastTapeLinkPtr = tapeLinkPtr; tapeLinkPtr = tapeLinkPtr->nextTape; free(lastTapeLinkPtr); } - return(code); + return (code); } compareDump(ptr1, ptr2) struct budb_dumpEntry *ptr1, *ptr2; { - if ( ptr1->created < ptr2->created ) - return(-1); - else - if ( ptr1->created > ptr2->created ) - return(1); - return(0); + if (ptr1->created < ptr2->created) + return (-1); + else if (ptr1->created > ptr2->created) + return (1); + return (0); } -afs_int32 printRecentDumps(ndumps) +afs_int32 +printRecentDumps(ndumps) int ndumps; { - afs_int32 code = 0; - afs_int32 nextindex, index = 0; - afs_int32 dbTime; - afs_int32 tapedumpid; + afs_int32 code = 0; + afs_int32 nextindex, index = 0; + afs_int32 dbTime; + afs_int32 tapedumpid; budb_dumpList dl; struct budb_dumpEntry *dumpPtr; int i; @@ -3102,60 +3106,52 @@ afs_int32 printRecentDumps(ndumps) extern struct udbHandleS udbHandle; extern compareDump(); - do { /* while (nextindex != -1) */ - /* initialize the dump list */ - dl.budb_dumpList_len = 0; - dl.budb_dumpList_val = 0; - - /* outline algorithm */ - code = ubik_Call (BUDB_GetDumps, udbHandle.uh_client, 0, - BUDB_MAJORVERSION, - BUDB_OP_NPREVIOUS, - "", /* no name */ - 0, /* start */ - ndumps, /* end */ - index, /* index */ - &nextindex, - &dbTime, - &dl); - if (code) { - if (code == BUDB_ENDOFLIST) return 0; - com_err("dumpInfo", code, "; Can't get dump information"); - return(code); - } - - /* No need to sort, it's already sorted */ - - if (dl.budb_dumpList_len && (index == 0)) - printf("%10s %10s %2s %-16s %2s %5s dump name\n", - "dumpid", "parentid", "lv", "created", "nt", "nvols"); - - dumpPtr = dl.budb_dumpList_val; - for ( i = 1; i <= dl.budb_dumpList_len; i++ ) { - compactDateString(&dumpPtr->created, ds, 50), - printf("%10u %10u %-2d %16s %2d %5d %s", - dumpPtr->id, - dumpPtr->parent, - dumpPtr->level, - ds, - dumpPtr->tapes.maxTapes - dumpPtr->tapes.b + 1, - dumpPtr->nVolumes, - dumpPtr->name, - tapedumpid); - if (dumpPtr->initialDumpID) /* an appended dump */ - printf(" (%u)", dumpPtr->initialDumpID); - else if (dumpPtr->appendedDumpID) /* has appended dumps */ - printf(" (%u)", dumpPtr->id); - printf("\n"); - - dumpPtr++; - } - - if (dl.budb_dumpList_val) free(dl.budb_dumpList_val); - index = nextindex; - } while (nextindex != -1); - - return(code); + do { /* while (nextindex != -1) */ + /* initialize the dump list */ + dl.budb_dumpList_len = 0; + dl.budb_dumpList_val = 0; + + /* outline algorithm */ + code = ubik_Call(BUDB_GetDumps, udbHandle.uh_client, 0, BUDB_MAJORVERSION, BUDB_OP_NPREVIOUS, "", /* no name */ + 0, /* start */ + ndumps, /* end */ + index, /* index */ + &nextindex, &dbTime, &dl); + if (code) { + if (code == BUDB_ENDOFLIST) + return 0; + com_err("dumpInfo", code, "; Can't get dump information"); + return (code); + } + + /* No need to sort, it's already sorted */ + + if (dl.budb_dumpList_len && (index == 0)) + printf("%10s %10s %2s %-16s %2s %5s dump name\n", "dumpid", + "parentid", "lv", "created", "nt", "nvols"); + + dumpPtr = dl.budb_dumpList_val; + for (i = 1; i <= dl.budb_dumpList_len; i++) { + compactDateString(&dumpPtr->created, ds, 50), + printf("%10u %10u %-2d %16s %2d %5d %s", dumpPtr->id, + dumpPtr->parent, dumpPtr->level, ds, + dumpPtr->tapes.maxTapes - dumpPtr->tapes.b + 1, + dumpPtr->nVolumes, dumpPtr->name, tapedumpid); + if (dumpPtr->initialDumpID) /* an appended dump */ + printf(" (%u)", dumpPtr->initialDumpID); + else if (dumpPtr->appendedDumpID) /* has appended dumps */ + printf(" (%u)", dumpPtr->id); + printf("\n"); + + dumpPtr++; + } + + if (dl.budb_dumpList_val) + free(dl.budb_dumpList_val); + index = nextindex; + } while (nextindex != -1); + + return (code); } /* bc_dumpInfoCmd @@ -3175,32 +3171,26 @@ bc_dumpInfoCmd(as, arock) afs_int32 dumpInfo(); - if( as->parms[0].items ) - { - if(as->parms[1].items) - { - com_err(whoami, 0, "These options are exclusive - select only one"); - return(BC_BADARG); + if (as->parms[0].items) { + if (as->parms[1].items) { + com_err(whoami, 0, + "These options are exclusive - select only one"); + return (BC_BADARG); } ndumps = atoi(as->parms[0].items->data); - if (ndumps <= 0) - { + if (ndumps <= 0) { com_err(whoami, 0, "Must provide a positive number"); return -1; } code = printRecentDumps(ndumps); - } - else if (as->parms[1].items) - { - detailFlag = (as->parms[2].items ? 1 : 0); /* 1 = detailed listing */ - dumpid = atoi(as->parms[1].items->data); + } else if (as->parms[1].items) { + detailFlag = (as->parms[2].items ? 1 : 0); /* 1 = detailed listing */ + dumpid = atoi(as->parms[1].items->data); code = dumpInfo(dumpid, detailFlag); - } - else - { - code = printRecentDumps(10); + } else { + code = printRecentDumps(10); } - return(code); + return (code); } diff --git a/src/bucoord/config.c b/src/bucoord/config.c index 2a3a72cfe..f2addf9b6 100644 --- a/src/bucoord/config.c +++ b/src/bucoord/config.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #ifdef AFS_NT40_ENV @@ -27,15 +28,17 @@ RCSID("$Header$"); struct bc_config *bc_globalConfig; -static TrimLine(abuffer,aport) -afs_int32 *aport; -register char *abuffer; { +static +TrimLine(abuffer, aport) + afs_int32 *aport; + register char *abuffer; +{ register int tc; char garb[100]; *aport = 0; - sscanf(abuffer,"%s %u",garb,aport); - while(tc = *abuffer) { + sscanf(abuffer, "%s %u", garb, aport); + while (tc = *abuffer) { if (tc == ' ') { *abuffer = 0; return 0; @@ -45,39 +48,42 @@ register char *abuffer; { return 0; } -FILE *bc_open(aconfig, aname, aext, amode) -register struct bc_config *aconfig; -char *amode; -char *aext; -char *aname; { +FILE * +bc_open(aconfig, aname, aext, amode) + register struct bc_config *aconfig; + char *amode; + char *aext; + char *aname; +{ register FILE *tf; char tpath[256]; strcpy(tpath, aconfig->path); strcat(tpath, "/"); strcat(tpath, aname); - if (aext) strcat(tpath, aext); + if (aext) + strcat(tpath, aext); tf = fopen(tpath, amode); return tf; } -bc_InitConfig(apath) - char *apath; +bc_InitConfig(apath) + char *apath; { register struct bc_config *tb; register struct bc_hostEntry *the; /* initialize global config structure */ - tb = (struct bc_config *) malloc(sizeof(struct bc_config)); - if (!tb) return(BC_NOMEM); + tb = (struct bc_config *)malloc(sizeof(struct bc_config)); + if (!tb) + return (BC_NOMEM); bc_globalConfig = tb; memset(tb, 0, sizeof(struct bc_config)); - tb->path = (char *) malloc(strlen(apath)+1); - if (!tb->path) - { - free(tb); - return(BC_NOMEM); + tb->path = (char *)malloc(strlen(apath) + 1); + if (!tb->path) { + free(tb); + return (BC_NOMEM); } strcpy(tb->path, apath); @@ -87,32 +93,36 @@ bc_InitConfig(apath) return 0; } -static HostAdd(alist, aname,aport) -struct bc_hostEntry **alist; -afs_int32 aport; -char *aname; { +static +HostAdd(alist, aname, aport) + struct bc_hostEntry **alist; + afs_int32 aport; + char *aname; +{ register struct bc_hostEntry **tlast, *tentry; struct hostent *th; /* check that the host address is real */ th = gethostbyname(aname); - if (!th) return -1; + if (!th) + return -1; /* check if this guy is already in the list */ - for(tentry = *alist; tentry; tentry=tentry->next) - if (tentry->portOffset == aport) return EEXIST; + for (tentry = *alist; tentry; tentry = tentry->next) + if (tentry->portOffset == aport) + return EEXIST; /* add this guy to the end of the list */ tlast = alist; - for(tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast); + for (tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast); /* tlast now points to the next pointer (or head pointer) we should overwrite */ - tentry = (struct bc_hostEntry *) malloc(sizeof(struct bc_hostEntry)); + tentry = (struct bc_hostEntry *)malloc(sizeof(struct bc_hostEntry)); memset(tentry, 0, sizeof(*tentry)); - tentry->name = (char *) malloc(strlen(aname)+1); + tentry->name = (char *)malloc(strlen(aname) + 1); strcpy(tentry->name, aname); *tlast = tentry; - tentry->next = (struct bc_hostEntry *) 0; + tentry->next = (struct bc_hostEntry *)0; tentry->addr.sin_family = AF_INET; memcpy(&tentry->addr.sin_addr.s_addr, th->h_addr, sizeof(afs_int32)); tentry->addr.sin_port = 0; @@ -123,18 +133,21 @@ char *aname; { return 0; } -static HostDelete(alist, aname,aport) -struct bc_hostEntry **alist; -afs_int32 aport; -char *aname; { +static +HostDelete(alist, aname, aport) + struct bc_hostEntry **alist; + afs_int32 aport; + char *aname; +{ register struct bc_hostEntry **tlast, *tentry; /* find guy to zap */ tlast = alist; - for(tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast) + for (tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast) if (strcmp(tentry->name, aname) == 0 && (aport == tentry->portOffset)) break; - if (!tentry) return ENOENT; /* failed to find it */ + if (!tentry) + return ENOENT; /* failed to find it */ /* otherwise delete the entry from the list and free appropriate structures */ *tlast = tentry->next; @@ -143,21 +156,23 @@ char *aname; { return 0; } -bc_AddTapeHost(aconfig, aname,aport) -struct bc_config *aconfig; -afs_int32 aport; -char *aname; { +bc_AddTapeHost(aconfig, aname, aport) + struct bc_config *aconfig; + afs_int32 aport; + char *aname; +{ register afs_int32 code; - code = HostAdd(&aconfig->tapeHosts, aname,aport); + code = HostAdd(&aconfig->tapeHosts, aname, aport); return code; } bc_DeleteTapeHost(aconfig, aname, aport) -struct bc_config *aconfig; -afs_int32 aport; -char *aname; { + struct bc_config *aconfig; + afs_int32 aport; + char *aname; +{ register afs_int32 code; code = HostDelete(&aconfig->tapeHosts, aname, aport); diff --git a/src/bucoord/dlq.c b/src/bucoord/dlq.c index 30e77a69a..e7d647878 100644 --- a/src/bucoord/dlq.c +++ b/src/bucoord/dlq.c @@ -13,7 +13,8 @@ #include #endif -RCSID("$Header$"); +RCSID + ("$Header$"); #include @@ -33,30 +34,30 @@ RCSID("$Header$"); */ dlqEmpty(headptr) - dlqlinkP headptr; + dlqlinkP headptr; { DLQ_ASSERT_HEAD(headptr); - if ( headptr->dlq_next == headptr ) - return(1); - return(0); + if (headptr->dlq_next == headptr) + return (1); + return (0); } dlqInit(headptr) - dlqlinkP headptr; + dlqlinkP headptr; { headptr->dlq_next = headptr; headptr->dlq_prev = headptr; headptr->dlq_type = DLQ_HEAD; headptr->dlq_structPtr = NULL; - return(0); + return (0); } /* dlqLinkf * link item to front of chain */ dlqLinkf(headptr, entryptr) - dlqlinkP headptr; - dlqlinkP entryptr; + dlqlinkP headptr; + dlqlinkP entryptr; { DLQ_ASSERT_HEAD(headptr); /* link in as first item in chain */ @@ -64,16 +65,16 @@ dlqLinkf(headptr, entryptr) headptr->dlq_next->dlq_prev = entryptr; entryptr->dlq_prev = headptr; headptr->dlq_next = entryptr; - return(0); -} + return (0); +} /* dlqLinkb * link item to end of chain */ dlqLinkb(headptr, entryptr) - dlqlinkP headptr; - dlqlinkP entryptr; + dlqlinkP headptr; + dlqlinkP entryptr; { DLQ_ASSERT_HEAD(headptr); entryptr->dlq_next = headptr; @@ -81,7 +82,7 @@ dlqLinkb(headptr, entryptr) headptr->dlq_prev = entryptr; entryptr->dlq_prev->dlq_next = entryptr; - return(0); + return (0); } /* dlqMoveb @@ -89,16 +90,16 @@ dlqLinkb(headptr, entryptr) */ dlqMoveb(fromptr, toptr) - dlqlinkP fromptr; - dlqlinkP toptr; + dlqlinkP fromptr; + dlqlinkP toptr; { - dlqlinkP tailptr; + dlqlinkP tailptr; DLQ_ASSERT_HEAD(fromptr); DLQ_ASSERT_HEAD(toptr); - if ( dlqEmpty(fromptr) ) - return(0); + if (dlqEmpty(fromptr)) + return (0); tailptr = toptr->dlq_prev; @@ -120,22 +121,22 @@ dlqMoveb(fromptr, toptr) */ dlqlinkP -dlqUnlinkb(headptr) - dlqlinkP headptr; +dlqUnlinkb(headptr) + dlqlinkP headptr; { - dlqlinkP ptr; + dlqlinkP ptr; DLQ_ASSERT_HEAD(headptr); - if ( dlqEmpty(headptr) ) - return(0); + if (dlqEmpty(headptr)) + return (0); ptr = headptr->dlq_prev; ptr->dlq_prev->dlq_next = headptr; headptr->dlq_prev = ptr->dlq_prev; - + ptr->dlq_next = ptr; ptr->dlq_prev = ptr; - return(ptr); + return (ptr); } /* dlqUnlinkf @@ -144,13 +145,13 @@ dlqUnlinkb(headptr) dlqlinkP dlqUnlinkf(headptr) - dlqlinkP headptr; + dlqlinkP headptr; { - dlqlinkP ptr; + dlqlinkP ptr; DLQ_ASSERT_HEAD(headptr); - if ( dlqEmpty(headptr) ) - return(0); + if (dlqEmpty(headptr)) + return (0); ptr = headptr->dlq_next; @@ -159,7 +160,7 @@ dlqUnlinkf(headptr) ptr->dlq_next = ptr; ptr->dlq_prev = ptr; - return(ptr); + return (ptr); } /* dlqUnlink @@ -167,11 +168,10 @@ dlqUnlinkf(headptr) */ dlqUnlink(ptr) - dlqlinkP ptr; + dlqlinkP ptr; { /* must not be the queue head */ - if ( ptr->dlq_type == DLQ_HEAD ) - { + if (ptr->dlq_type == DLQ_HEAD) { printf("dlqUnlink: invalid unlink\n"); exit(1); } @@ -189,55 +189,50 @@ dlqUnlink(ptr) dlqlinkP dlqFront(headptr) - dlqlinkP headptr; + dlqlinkP headptr; { DLQ_ASSERT_HEAD(headptr); - if ( dlqEmpty(headptr) ) - return(0); + if (dlqEmpty(headptr)) + return (0); - return(headptr->dlq_next); + return (headptr->dlq_next); } int dlqCount(headptr) - dlqlinkP headptr; + dlqlinkP headptr; { - dlqlinkP ptr; + dlqlinkP ptr; int count = 0; DLQ_ASSERT_HEAD(headptr); ptr = headptr->dlq_next; - while ( ptr != headptr ) - { + while (ptr != headptr) { ptr = ptr->dlq_next; count++; } - return(count); + return (count); } dlqTraverseQueue(headptr, fn1, fn2) - dlqlinkP headptr; - int (*fn1)(); - int (*fn2)(); + dlqlinkP headptr; + int (*fn1) (); + int (*fn2) (); { - dlqlinkP ptr, oldPtr; + dlqlinkP ptr, oldPtr; DLQ_ASSERT_HEAD(headptr); ptr = headptr->dlq_next; - while ( ptr != headptr ) - { + while (ptr != headptr) { if (fn2 && ptr->dlq_structPtr) - (*fn2)(ptr->dlq_structPtr); + (*fn2) (ptr->dlq_structPtr); oldPtr = ptr; ptr = ptr->dlq_next; - if (fn1) (*fn1)(oldPtr); + if (fn1) + (*fn1) (oldPtr); } - return(0); + return (0); } - - - - diff --git a/src/bucoord/dsstub.c b/src/bucoord/dsstub.c index 7f81dec0d..f4243884d 100644 --- a/src/bucoord/dsstub.c +++ b/src/bucoord/dsstub.c @@ -14,7 +14,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -56,21 +57,24 @@ afs_int32 DeleteDump(); afs_int32 ScanDumpHdr(); /* return the tape file name corresponding to a particular tape */ -static char *TapeName(atapeName) -register char *atapeName; { +static char * +TapeName(atapeName) + register char *atapeName; +{ static char tbuffer[AFSDIR_PATH_MAX]; /* construct the backup dir path */ strcpy(tbuffer, AFSDIR_SERVER_BACKUP_DIRPATH); strcat(tbuffer, "/T"); - strcat(tbuffer+1, atapeName); + strcat(tbuffer + 1, atapeName); strcat(tbuffer, ".db"); return tbuffer; } /* return the dump file name corresponding to a particular dump ID */ -static char *DumpName(adumpID) -register afs_int32 adumpID; +static char * +DumpName(adumpID) + register afs_int32 adumpID; { static char tbuffer[AFSDIR_PATH_MAX]; char buf[AFSDIR_PATH_MAX]; @@ -82,9 +86,11 @@ register afs_int32 adumpID; return tbuffer; } -static FILE *OpenDump(adumpID, awrite) -char *awrite; -afs_int32 adumpID; { +static FILE * +OpenDump(adumpID, awrite) + char *awrite; + afs_int32 adumpID; +{ register char *tp; register FILE *tfile; @@ -98,9 +104,11 @@ afs_int32 adumpID; { * non-static for recoverDB */ -FILE *OpenTape(atapeName, awrite) -char *awrite; -char *atapeName; { +FILE * +OpenTape(atapeName, awrite) + char *awrite; + char *atapeName; +{ register char *tp; register FILE *tfile; tp = TapeName(atapeName); @@ -109,8 +117,10 @@ char *atapeName; { } /* scan for, and delete, all dumps whose parent dump ID is aparentID */ -static afs_int32 ScanForChildren(aparentID) -afs_int32 aparentID; { +static afs_int32 +ScanForChildren(aparentID) + afs_int32 aparentID; +{ DIR *tdir; register struct dirent *tde; afs_int32 dumpID, parent; @@ -119,16 +129,19 @@ afs_int32 aparentID; { afs_int32 j2, j3, j4; char dname[256]; char dumpName[1024]; - - tdir = opendir(AFSDIR_SERVER_BACKUP_DIRPATH); - if (!tdir) return -1; - for(tde=readdir(tdir); tde; tde=readdir(tdir)) { + tdir = opendir(AFSDIR_SERVER_BACKUP_DIRPATH); + if (!tdir) + return -1; + + for (tde = readdir(tdir); tde; tde = readdir(tdir)) { code = sscanf(tde->d_name, "D%ld.db", &dumpID); - if (code != 1) continue; + if (code != 1) + continue; tfile = OpenDump(dumpID, "r"); - if (!tfile) continue; /* shouldn't happen, but should continue anyway */ + if (!tfile) + continue; /* shouldn't happen, but should continue anyway */ code = ScanDumpHdr(tfile, dname, dumpName, &parent, &j2, &j3, &j4); fclose(tfile); @@ -140,26 +153,33 @@ afs_int32 aparentID; { /* if this guy's parent is the ID we're scanning for, delete it */ if (aparentID == parent) { code = DeleteDump(dumpID); - if (code) printf("backup:dsstub: failed to delete child dump %d\n", dumpID); + if (code) + printf("backup:dsstub: failed to delete child dump %d\n", + dumpID); } } closedir(tdir); return 0; } -static afs_int32 DeleteDump(adumpID) -afs_int32 adumpID; { +static afs_int32 +DeleteDump(adumpID) + afs_int32 adumpID; +{ register char *tp; register afs_int32 code; tp = DumpName(adumpID); code = unlink(tp); - if (code) return code; + if (code) + return code; code = ScanForChildren(adumpID); return code; } -static afs_int32 DeleteTape(atapeName) -char *atapeName; { +static afs_int32 +DeleteTape(atapeName) + char *atapeName; +{ register char *tp; register afs_int32 code; tp = TapeName(atapeName); @@ -178,18 +198,15 @@ tailCompPtr(pathNamePtr) { char *ptr; ptr = strrchr(pathNamePtr, '/'); - if ( ptr == 0 ) - { - /* this should never happen */ - printf("tailCompPtr: could not find / in name(%s)\n", - pathNamePtr); - return(pathNamePtr); - } - else - ptr++; /* skip the / */ - return(ptr); + if (ptr == 0) { + /* this should never happen */ + printf("tailCompPtr: could not find / in name(%s)\n", pathNamePtr); + return (pathNamePtr); + } else + ptr++; /* skip the / */ + return (ptr); } - + /* ScanDumpHdr * scan a dump header out of a dump file, leaving the file ptr set after * the header. @@ -220,33 +237,39 @@ ScanDumpHdr(afile, aname, dumpName, aparent, aincTime, acreateTime, alevel) register afs_int32 code; tp = fgets(tbuffer, sizeof(tbuffer), afile); - if (!tp) return -1; - code = sscanf(tbuffer, "%d %d %s %s %ld %ld %ld %ld", - &dbmagic, &dbversion, - aname, dumpName, aparent, aincTime, acreateTime, alevel); - if (code != 8) return -1; + if (!tp) + return -1; + code = + sscanf(tbuffer, "%d %d %s %s %ld %ld %ld %ld", &dbmagic, &dbversion, + aname, dumpName, aparent, aincTime, acreateTime, alevel); + if (code != 8) + return -1; /* now check the magic and version numbers */ - if ( (dbmagic != BC_DUMPDB_MAGIC) || (dbversion != BC_DUMPDB_VERSION) ) - return(-1); + if ((dbmagic != BC_DUMPDB_MAGIC) || (dbversion != BC_DUMPDB_VERSION)) + return (-1); return 0; } /* scan a tape header out of a tape file, leaving the file ptr positioned just past the header */ -static afs_int32 ScanTapeHdr(afile, adumpID, aseq, adamage) -register FILE *afile; -afs_int32 *adumpID; -afs_int32 *aseq; -afs_int32 *adamage; { +static afs_int32 +ScanTapeHdr(afile, adumpID, aseq, adamage) + register FILE *afile; + afs_int32 *adumpID; + afs_int32 *aseq; + afs_int32 *adamage; +{ char tbuffer[256]; char *tp; register afs_int32 code; tp = fgets(tbuffer, sizeof(tbuffer), afile); - if (!tp) return -1; + if (!tp) + return -1; code = sscanf(tbuffer, "%ld %ld %ld", adumpID, aseq, adamage); - if (code != 3) return -1; + if (code != 3) + return -1; return 0; } @@ -262,23 +285,28 @@ afs_int32 *adamage; { afs_int32 ScanTapeVolume(afile, avolName, avolID, atapeName, apos, aseq, alastp, cloneTime) -FILE *afile; -char *avolName; -afs_int32 *avolID; -char *atapeName; -afs_int32 *apos, *aseq, *alastp, *cloneTime; { + FILE *afile; + char *avolName; + afs_int32 *avolID; + char *atapeName; + afs_int32 *apos, *aseq, *alastp, *cloneTime; +{ char tbuffer[256]; register afs_int32 code; register char *tp; tp = fgets(tbuffer, sizeof(tbuffer), afile); - if (!tp) { /* something went wrong, or eof hit */ - if (ferror(afile)) return -1; /* error occurred */ - else return 1; /* eof */ + if (!tp) { /* something went wrong, or eof hit */ + if (ferror(afile)) + return -1; /* error occurred */ + else + return 1; /* eof */ } - code = sscanf(tbuffer, "%s %ld %s %ld %ld %ld %ld", avolName, avolID, - atapeName, apos, aseq, alastp, cloneTime); - if (code != 7) return -1; /* bad input line */ + code = + sscanf(tbuffer, "%s %ld %s %ld %ld %ld %ld", avolName, avolID, + atapeName, apos, aseq, alastp, cloneTime); + if (code != 7) + return -1; /* bad input line */ return 0; } @@ -298,29 +326,32 @@ ScanVolClone(tdump, volName, cloneTime) { char avolName[256], atapeName[256]; afs_int32 retval, avolID, apos, aseq, alastp; - - retval = ScanTapeVolume(tdump, &avolName[0], &avolID, &atapeName[0], - &apos, &aseq, &alastp, cloneTime); - while ( retval == 0 ) - { - if ( strcmp(avolName, volName) == 0 ) - return(0); - retval = ScanTapeVolume(tdump, &avolName[0], &avolID, &atapeName[0], - &apos, &aseq, &alastp, cloneTime); + + retval = + ScanTapeVolume(tdump, &avolName[0], &avolID, &atapeName[0], &apos, + &aseq, &alastp, cloneTime); + while (retval == 0) { + if (strcmp(avolName, volName) == 0) + return (0); + retval = + ScanTapeVolume(tdump, &avolName[0], &avolID, &atapeName[0], &apos, + &aseq, &alastp, cloneTime); } - return(-1); + return (-1); } /* seek a dump file (after a header scan has been done) to position apos */ -static SeekDump(afile, apos) -register FILE *afile; -afs_int32 apos; { +static +SeekDump(afile, apos) + register FILE *afile; + afs_int32 apos; +{ register afs_int32 i; register char *tp; char tbuffer[256]; /* now skip to appropriate position */ - for(i=0;i #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -42,12 +43,13 @@ extern FILE *bc_open(); extern void bc_HandleMisc(); extern char *whoami; -static char db_dsvs = 0; /*Assume debugging output turned off*/ -static char mn[] = "dsvs"; /*Module name*/ +static char db_dsvs = 0; /*Assume debugging output turned off */ +static char mn[] = "dsvs"; /*Module name */ -struct ubik_client *cstructp; /*Ptr to Ubik client structure*/ +struct ubik_client *cstructp; /*Ptr to Ubik client structure */ -extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cf, char *name); +extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cf, + char *name); /* Code to maintain dump schedule and volume set abstractions. @@ -58,9 +60,11 @@ extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cf, char *name); */ /* get partition id from a name */ -afs_int32 bc_GetPartitionID(aname, aval) - afs_int32 *aval; - char *aname; { +afs_int32 +bc_GetPartitionID(aname, aval) + afs_int32 *aval; + char *aname; +{ /*bc_GetPartitionID */ @@ -73,7 +77,8 @@ afs_int32 bc_GetPartitionID(aname, aval) return 0; } tc = *aname; - if (tc == 0) return -1; /* unknown */ + if (tc == 0) + return -1; /* unknown */ /* numbers go straight through */ if (tc >= '0' && tc <= '9') { *aval = bc_SafeATOI(aname); @@ -83,30 +88,30 @@ afs_int32 bc_GetPartitionID(aname, aval) ascii[2] = 0; if (strlen(aname) <= 2) { strcpy(ascii, aname); - } - else if (!strncmp(aname, "/vicep", 6)) { - strncpy(ascii, aname+6, 2); - } - else if (!strncmp(aname, "vicep", 5)) { - strncpy(ascii, aname+5, 2); - } - else return(BC_NOPARTITION); /* bad partition name */ + } else if (!strncmp(aname, "/vicep", 6)) { + strncpy(ascii, aname + 6, 2); + } else if (!strncmp(aname, "vicep", 5)) { + strncpy(ascii, aname + 5, 2); + } else + return (BC_NOPARTITION); /* bad partition name */ /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab, .../vicepzz, and are numbered - from 0. Do the appropriate conversion */ + * from 0. Do the appropriate conversion */ if (ascii[1] == 0) { /* one char name, 0..25 */ - if (ascii[0] < 'a' || ascii[0] > 'z') return -1; /* wrongo */ + if (ascii[0] < 'a' || ascii[0] > 'z') + return -1; /* wrongo */ *aval = ascii[0] - 'a'; return 0; - } - else { + } else { /* two char name, 26 .. */ - if (ascii[0] < 'a' || ascii[0] > 'z') return -1; /* wrongo */ - if (ascii[1] < 'a' || ascii[1] > 'z') return -1; /* just as bad */ + if (ascii[0] < 'a' || ascii[0] > 'z') + return -1; /* wrongo */ + if (ascii[1] < 'a' || ascii[1] > 'z') + return -1; /* just as bad */ *aval = (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26; return 0; } -} /*bc_GetPartitionID*/ +} /*bc_GetPartitionID */ /*---------------------------------------------------------------------------- * bc_ParseHost @@ -131,17 +136,18 @@ afs_int32 bc_GetPartitionID(aname, aval) *---------------------------------------------------------------------------- */ -int bc_ParseHost(aname, asockaddr) - char *aname; - struct sockaddr_in *asockaddr; +int +bc_ParseHost(aname, asockaddr) + char *aname; + struct sockaddr_in *asockaddr; -{ /*bc_ParseHost*/ +{ /*bc_ParseHost */ - register struct hostent *th; /*Host entry*/ - afs_int32 addr; /*Converted address*/ - afs_int32 b1, b2, b3, b4; /*Byte-sized address chunks*/ - register afs_int32 code; /*Return code from sscanf()*/ - afs_int32 tmp1,tmp2; + register struct hostent *th; /*Host entry */ + afs_int32 addr; /*Converted address */ + afs_int32 b1, b2, b3, b4; /*Byte-sized address chunks */ + register afs_int32 code; /*Return code from sscanf() */ + afs_int32 tmp1, tmp2; /* * Try to parse the given name as a dot-notation IP address first. @@ -152,15 +158,15 @@ int bc_ParseHost(aname, asockaddr) * Four chunks were read, so we assume success. Construct the socket. */ #ifdef STRUCT_SOCKADDR_HAS_SA_LEN - asockaddr->sin_len=sizeof(struct sockaddr_in); + asockaddr->sin_len = sizeof(struct sockaddr_in); #endif asockaddr->sin_family = AF_INET; - asockaddr->sin_port = 0; - addr = (b1<<24) | (b2<<16) | (b3<<8) | b4; + asockaddr->sin_port = 0; + addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; memcpy(&tmp1, &addr, sizeof(afs_int32)); tmp2 = htonl(tmp1); memcpy(&asockaddr->sin_addr.s_addr, &tmp2, sizeof(afs_int32)); - return(0); + return (0); } /* @@ -178,67 +184,73 @@ int bc_ParseHost(aname, asockaddr) /* * No such luck, return failure. */ - return(BC_NOHOST); + return (BC_NOHOST); /* * We found a mapping; construct the socket. */ #ifdef STRUCT_SOCKADDR_HAS_SA_LEN - asockaddr->sin_len=sizeof(struct sockaddr_in); + asockaddr->sin_len = sizeof(struct sockaddr_in); #endif asockaddr->sin_family = AF_INET; - asockaddr->sin_port = 0; + asockaddr->sin_port = 0; memcpy(&tmp1, th->h_addr, sizeof(afs_int32)); tmp2 = htonl(tmp1); - memcpy(&(asockaddr->sin_addr.s_addr), &tmp2, sizeof(asockaddr->sin_addr.s_addr)); - return(0); + memcpy(&(asockaddr->sin_addr.s_addr), &tmp2, + sizeof(asockaddr->sin_addr.s_addr)); + return (0); -} /*bc_ParseHost*/ +} /*bc_ParseHost */ /* create an empty volume set, new items are added via bc_AddVolumeItem */ bc_CreateVolumeSet(aconfig, avolName, aflags) - struct bc_config *aconfig; - char *avolName; - afs_int32 aflags; + struct bc_config *aconfig; + char *avolName; + afs_int32 aflags; { register struct bc_volumeSet **tlast, *tset, *nset; - if (bc_FindVolumeSet(aconfig, avolName)) return -1; /* already exists */ + if (bc_FindVolumeSet(aconfig, avolName)) + return -1; /* already exists */ /* move to end of the list */ - nset = (struct bc_volumeSet *) malloc(sizeof(struct bc_volumeSet)); + nset = (struct bc_volumeSet *)malloc(sizeof(struct bc_volumeSet)); memset(nset, 0, sizeof(*nset)); nset->flags = aflags; - nset->name = (char *) malloc(strlen(avolName)+1); + nset->name = (char *)malloc(strlen(avolName) + 1); strcpy(nset->name, avolName); if (aflags & VSFLAG_TEMPORARY) { - /* Add to beginning of list */ - nset->next = aconfig->vset; - aconfig->vset = nset; + /* Add to beginning of list */ + nset->next = aconfig->vset; + aconfig->vset = nset; } else { - /* Add to end of list */ - for(tlast = &aconfig->vset, tset = *tlast; tset; tlast = &tset->next, tset = *tlast); - *tlast = nset; + /* Add to end of list */ + for (tlast = &aconfig->vset, tset = *tlast; tset; + tlast = &tset->next, tset = *tlast); + *tlast = nset; } return 0; } -void FreeVolumeSet(avset) - struct bc_volumeSet *avset; +void +FreeVolumeSet(avset) + struct bc_volumeSet *avset; { - FreeVolumeEntryList(avset->ventries); - free(avset->name); - free(avset); + FreeVolumeEntryList(avset->ventries); + free(avset->name); + free(avset); } -static FreeVolumeEntryList(aentry) -register struct bc_volumeEntry *aentry; { +static +FreeVolumeEntryList(aentry) + register struct bc_volumeEntry *aentry; +{ register struct bc_volumeEntry *tnext; - while(aentry) { + while (aentry) { tnext = aentry->next; FreeVolumeEntry(aentry); aentry = tnext; @@ -246,8 +258,10 @@ register struct bc_volumeEntry *aentry; { return 0; } -static FreeVolumeEntry(aentry) -register struct bc_volumeEntry *aentry; { +static +FreeVolumeEntry(aentry) + register struct bc_volumeEntry *aentry; +{ free(aentry->name); free(aentry->serverName); free(aentry->partname); @@ -256,19 +270,19 @@ register struct bc_volumeEntry *aentry; { } bc_DeleteVolumeSet(aconfig, avolName, flags) - struct bc_config *aconfig; - char *avolName; - afs_int32 *flags; + struct bc_config *aconfig; + char *avolName; + afs_int32 *flags; { register struct bc_volumeSet **tlast, *tset; *flags = 0; tlast = &aconfig->vset; - for(tset = *tlast; tset; tlast = &tset->next, tset = *tlast) { + for (tset = *tlast; tset; tlast = &tset->next, tset = *tlast) { if (strcmp(avolName, tset->name) == 0) { - *flags = tset->flags; /* Remember flags */ - *tlast = tset->next; /* Remove from chain */ - FreeVolumeSet(tset); /* Free the volume set */ + *flags = tset->flags; /* Remember flags */ + *tlast = tset->next; /* Remove from chain */ + FreeVolumeSet(tset); /* Free the volume set */ return 0; } } @@ -278,19 +292,21 @@ bc_DeleteVolumeSet(aconfig, avolName, flags) } bc_DeleteVolumeItem(aconfig, avolName, anumber) - struct bc_config *aconfig; - char *avolName; - afs_int32 anumber; + struct bc_config *aconfig; + char *avolName; + afs_int32 anumber; { register afs_int32 i; register struct bc_volumeSet *tset; register struct bc_volumeEntry *tentry, **tlast; tset = bc_FindVolumeSet(aconfig, avolName); - if (!tset) return -1; + if (!tset) + return -1; tlast = &tset->ventries; - for(i=1, tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast, i++) { + for (i = 1, tentry = *tlast; tentry; + tlast = &tentry->next, tentry = *tlast, i++) { if (anumber == i) { /* found entry we want */ *tlast = tentry->next; @@ -298,59 +314,61 @@ bc_DeleteVolumeItem(aconfig, avolName, anumber) return 0; } } - return -2; /* not found */ + return -2; /* not found */ } bc_AddVolumeItem(aconfig, avolName, ahost, apart, avol) - struct bc_config *aconfig; - char *avolName; - char *ahost, *apart, *avol; + struct bc_config *aconfig; + char *avolName; + char *ahost, *apart, *avol; { struct bc_volumeSet *tset; register struct bc_volumeEntry **tlast, *tentry; register afs_int32 code; tset = bc_FindVolumeSet(aconfig, avolName); - if (!tset) return(BC_NOVOLSET); + if (!tset) + return (BC_NOVOLSET); /* otherwise append this item to the end of the real list */ tlast = &tset->ventries; /* move to end of the list */ - for(tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast); - tentry = (struct bc_volumeEntry *) malloc(sizeof(struct bc_volumeEntry)); + for (tentry = *tlast; tentry; tlast = &tentry->next, tentry = *tlast); + tentry = (struct bc_volumeEntry *)malloc(sizeof(struct bc_volumeEntry)); memset(tentry, 0, sizeof(*tentry)); - tentry->serverName = (char *) malloc(strlen(ahost)+1); + tentry->serverName = (char *)malloc(strlen(ahost) + 1); strcpy(tentry->serverName, ahost); - tentry->partname = (char *) malloc(strlen(apart)+1); + tentry->partname = (char *)malloc(strlen(apart) + 1); strcpy(tentry->partname, apart); - tentry->name = (char *) malloc(strlen(avol)+1); + tentry->name = (char *)malloc(strlen(avol) + 1); strcpy(tentry->name, avol); code = bc_ParseHost(tentry->serverName, &tentry->server); if (code) - return(code); + return (code); code = bc_GetPartitionID(tentry->partname, &tentry->partition); if (code) - return(code); + return (code); - *tlast = tentry; /* thread on the list */ + *tlast = tentry; /* thread on the list */ return 0; } -struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *aconfig, char *aname) -{ /*bc_FindVolumeSet*/ +struct bc_volumeSet * +bc_FindVolumeSet(struct bc_config *aconfig, char *aname) +{ /*bc_FindVolumeSet */ register struct bc_volumeSet *tvs; - for(tvs = aconfig->vset; tvs; tvs=tvs->next) { + for (tvs = aconfig->vset; tvs; tvs = tvs->next) { if (!strcmp(tvs->name, aname)) - return(tvs); + return (tvs); } - return(struct bc_volumeSet *)0; + return (struct bc_volumeSet *)0; -}/*bc_FindVolumeSet*/ +} /*bc_FindVolumeSet */ /* ------------------------------------ * dumpschedule management code @@ -366,26 +384,26 @@ struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *aconfig, char *aname) * expType - absolute or relative */ -bc_CreateDumpSchedule(aconfig,adumpName, expDate, expType) -struct bc_config *aconfig; -char *adumpName; -afs_int32 expDate; -afs_int32 expType; +bc_CreateDumpSchedule(aconfig, adumpName, expDate, expType) + struct bc_config *aconfig; + char *adumpName; + afs_int32 expDate; + afs_int32 expType; { register struct bc_dumpSchedule **tlast, *tdump; struct bc_dumpSchedule *parent, *node; afs_int32 code; - if(strcmp(adumpName, "none") == 0) - return -2; /* invalid name */ + if (strcmp(adumpName, "none") == 0) + return -2; /* invalid name */ - code = FindDump(aconfig, adumpName, &parent, &node); - if ( code == 0 ) - return -1; /* node already exists */ - else if ( code != -1 ) - return -2; /* name specification error */ + code = FindDump(aconfig, adumpName, &parent, &node); + if (code == 0) + return -1; /* node already exists */ + else if (code != -1) + return -2; /* name specification error */ - tdump = (struct bc_dumpSchedule *) malloc(sizeof(struct bc_dumpSchedule)); + tdump = (struct bc_dumpSchedule *)malloc(sizeof(struct bc_dumpSchedule)); memset(tdump, 0, sizeof(*tdump)); /* prepend this node to the dump schedule list */ @@ -393,7 +411,7 @@ afs_int32 expType; aconfig->dsched = tdump; /* save the name of this dump node */ - tdump->name = (char *) malloc(strlen(adumpName)+1); + tdump->name = (char *)malloc(strlen(adumpName) + 1); strcpy(tdump->name, adumpName); /* expiration information */ @@ -411,26 +429,27 @@ afs_int32 expType; */ bc_DeleteDumpScheduleAddr(aconfig, adumpAddr) -struct bc_config *aconfig; -struct bc_dumpSchedule *adumpAddr; { + struct bc_config *aconfig; + struct bc_dumpSchedule *adumpAddr; +{ register struct bc_dumpSchedule **tlast, *tdump; register struct bc_dumpSchedule *tnext; /* knock off all children first */ - for(tdump = adumpAddr->firstChild; tdump; tdump = tnext) { + for (tdump = adumpAddr->firstChild; tdump; tdump = tnext) { /* extract next ptr now, since will be freed by recursive call below */ tnext = tdump->nextSibling; bc_DeleteDumpScheduleAddr(aconfig, tdump); } /* finally, remove us from the list of good dudes */ - for(tlast = &aconfig->dsched, tdump = *tlast; tdump; - tlast = &tdump->next, tdump = *tlast) { + for (tlast = &aconfig->dsched, tdump = *tlast; tdump; + tlast = &tdump->next, tdump = *tlast) { if (tdump == adumpAddr) { /* found the one we're looking for */ *tlast = tdump->next; /* remove us from basic list */ free(tdump->name); - free(tdump); + free(tdump); return 0; } } @@ -446,15 +465,17 @@ struct bc_dumpSchedule *adumpAddr; { * 0 for failure, ptr to dumpschedule for success */ -struct bc_dumpSchedule *bc_FindDumpSchedule(aconfig, aname) -char *aname; -struct bc_config *aconfig; { +struct bc_dumpSchedule * +bc_FindDumpSchedule(aconfig, aname) + char *aname; + struct bc_config *aconfig; +{ register struct bc_dumpSchedule *tds; - for(tds=aconfig->dsched; tds; tds=tds->next) { + for (tds = aconfig->dsched; tds; tds = tds->next) { if (!strcmp(tds->name, aname)) return tds; } - return (struct bc_dumpSchedule *) 0; + return (struct bc_dumpSchedule *)0; } /* bc_DeleteDumpSchedule @@ -462,21 +483,22 @@ struct bc_config *aconfig; { */ bc_DeleteDumpSchedule(aconfig, adumpName) -struct bc_config *aconfig; -char *adumpName; { + struct bc_config *aconfig; + char *adumpName; +{ register struct bc_dumpSchedule *tdump; /* does a linear search of the dump schedules in order to find * the one to delete */ - for(tdump = aconfig->dsched; tdump; tdump=tdump->next) { - if (strcmp(tdump->name, adumpName)==0) { + for (tdump = aconfig->dsched; tdump; tdump = tdump->next) { + if (strcmp(tdump->name, adumpName) == 0) { /* found it, we can zap recursively */ bc_DeleteDumpScheduleAddr(aconfig, tdump); /* tree's been pruned, but we have to recompute the internal pointers - from first principles, since we didn't bother to maintain - the sibling and children pointers during the call to delete - the nodes */ + * from first principles, since we didn't bother to maintain + * the sibling and children pointers during the call to delete + * the nodes */ bc_ProcessDumpSchedule(aconfig); return 0; } @@ -493,7 +515,7 @@ char *adumpName; { */ bc_ProcessDumpSchedule(aconfig) -register struct bc_config *aconfig; + register struct bc_config *aconfig; { register struct bc_dumpSchedule *tds, *uds; struct bc_dumpSchedule *parentptr, *nodeptr; @@ -502,25 +524,21 @@ register struct bc_config *aconfig; /* first, clear all the links on all entries so that this function * may be called any number of times with no ill effects */ - for(tds = aconfig->dsched; tds; tds=tds->next) - { - tds->parent = (struct bc_dumpSchedule *) 0; - tds->nextSibling = (struct bc_dumpSchedule *) 0; - tds->firstChild = (struct bc_dumpSchedule *) 0; + for (tds = aconfig->dsched; tds; tds = tds->next) { + tds->parent = (struct bc_dumpSchedule *)0; + tds->nextSibling = (struct bc_dumpSchedule *)0; + tds->firstChild = (struct bc_dumpSchedule *)0; } - for(tds = aconfig->dsched; tds; tds=tds->next) - { + for (tds = aconfig->dsched; tds; tds = tds->next) { retval = FindDump(aconfig, tds->name, &parentptr, &nodeptr); - if ( retval != 0 ) - { + if (retval != 0) { printf("bc_processdumpschedule: finddump returns %d\n", retval); exit(1); } /* only need to do work if it is not a root node */ - if ( parentptr != 0 ) - { + if (parentptr != 0) { nodeptr->parent = parentptr; nodeptr->nextSibling = parentptr->firstChild; parentptr->firstChild = nodeptr; @@ -556,74 +574,69 @@ FindDump(aconfig, nodeString, parentptr, nodeptr) { struct bc_dumpSchedule *dsptr; char *separator; - int matchLength; + int matchLength; char *curptr; *parentptr = 0; *nodeptr = 0; /* ensure first char is correct separator */ - if ( (nodeString[0] != '/') - || (strlen(&nodeString[0]) <= 1) - ) - { - printf("FindDump: %s, error in dump name specification\n", nodeString); - return(-3); + if ((nodeString[0] != '/') + || (strlen(&nodeString[0]) <= 1) + ) { + printf("FindDump: %s, error in dump name specification\n", + nodeString); + return (-3); } matchLength = 0; - curptr = &nodeString[1]; /* past first / */ + curptr = &nodeString[1]; /* past first / */ separator = strchr(curptr, '/'); - if ( separator == 0 ) - matchLength = strlen(curptr) + 1; /* +1 for leading / */ + if (separator == 0) + matchLength = strlen(curptr) + 1; /* +1 for leading / */ else - matchLength = (separator-&nodeString[0]); - + matchLength = (separator - &nodeString[0]); + /* printf("matchLength = %d\n", matchLength); */ - while ( 1 ) - { + while (1) { /* now search all the nodes for this name */ - for ( dsptr = aconfig->dsched; dsptr != 0; dsptr = dsptr->next) - { + for (dsptr = aconfig->dsched; dsptr != 0; dsptr = dsptr->next) { /* printf("compare %s with %s for %d\n", - dsptr->name, nodeString, matchLength); */ - if ( strlen(dsptr->name) != matchLength ) - continue; + * dsptr->name, nodeString, matchLength); */ + if (strlen(dsptr->name) != matchLength) + continue; - if ( strncmp(dsptr->name, nodeString, matchLength) == 0) - { + if (strncmp(dsptr->name, nodeString, matchLength) == 0) { *nodeptr = dsptr; break; } } - if ( nodeString[matchLength] == 0 ) - { + if (nodeString[matchLength] == 0) { /* last node in the path */ - if ( *nodeptr ) - return(0); /* all ok */ + if (*nodeptr) + return (0); /* all ok */ else - /* node not found; parent exists for non root nodes */ - return(-1); + /* node not found; parent exists for non root nodes */ + return (-1); } - if ( *nodeptr == 0 ) - /* failed to find a node in the path */ - return(-2); - - curptr = separator+1; - if ( *curptr == 0 ) - { + if (*nodeptr == 0) + /* failed to find a node in the path */ + return (-2); + + curptr = separator + 1; + if (*curptr == 0) { printf("FindDump: trailing / in %s\n", nodeString); - return(-3); + return (-3); } - + separator = strchr(curptr, '/'); - if ( separator == 0 ) - matchLength = strlen(&nodeString[0]); + if (separator == 0) + matchLength = strlen(&nodeString[0]); else - matchLength = separator-&nodeString[0]; - + matchLength = separator - &nodeString[0]; + *parentptr = *nodeptr; *nodeptr = 0; } diff --git a/src/bucoord/dump.c b/src/bucoord/dump.c index 25d97c749..6c7deac42 100644 --- a/src/bucoord/dump.c +++ b/src/bucoord/dump.c @@ -14,7 +14,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -33,8 +34,8 @@ RCSID("$Header$"); #include #include #include -#include /* for checking TC_ABORTFAILED. PA */ -#include /* for checking TC_ABORTFAILED. PA */ +#include /* for checking TC_ABORTFAILED. PA */ +#include /* for checking TC_ABORTFAILED. PA */ #include #include "bc.h" @@ -49,7 +50,7 @@ extern char *whoami; extern char *tailCompPtr(); extern statusP createStatusNode(); extern afs_int32 bc_jobNumber(); - + extern afs_int32 lastTaskCode; #ifdef AFS_DEC_ENV @@ -78,44 +79,45 @@ bc_Dumper(aindex) struct tc_dumpInterface dumpInterface; struct tc_dumpInterface *tcdiPtr = &dumpInterface; - register struct bc_dumpTask *dumpTaskPtr; + register struct bc_dumpTask *dumpTaskPtr; register afs_int32 code = 0; dumpTaskPtr = &bc_dumpTasks[aindex]; if (!dumpTaskPtr->portOffset || (dumpTaskPtr->portCount == 0)) - port = 0; - else - port = dumpTaskPtr->portOffset[0]; + port = 0; + else + port = dumpTaskPtr->portOffset[0]; code = ConnectButc(dumpTaskPtr->config, port, &tconn); - if (code) return(code); - + if (code) + return (code); + /* count number of volumes to be dumped and * build array of volumes to be sent to backup system */ - for (count=0, tde=dumpTaskPtr->volumes; tde; tde=tde->next, count++); - volDesc = (struct tc_dumpDesc *) malloc(count*sizeof(struct tc_dumpDesc)); - if (!volDesc) - { - com_err(whoami,BC_NOMEM,""); + for (count = 0, tde = dumpTaskPtr->volumes; tde; + tde = tde->next, count++); + volDesc = + (struct tc_dumpDesc *)malloc(count * sizeof(struct tc_dumpDesc)); + if (!volDesc) { + com_err(whoami, BC_NOMEM, ""); ERROR(BC_NOMEM); } - for (count=0, tde=dumpTaskPtr->volumes; tde; tde=tde->next, count++) - { + for (count = 0, tde = dumpTaskPtr->volumes; tde; tde = tde->next, count++) { strcpy(volDesc[count].name, tde->name); - volDesc[count].vid = tde->vid; - volDesc[count].vtype = tde->volType; - volDesc[count].partition = tde->partition; - volDesc[count].hostAddr = HOSTADDR(&tde->server); /* the internet address */ - volDesc[count].date = tde->date; - volDesc[count].cloneDate = tde->cloneDate; /* Not yet known */ + volDesc[count].vid = tde->vid; + volDesc[count].vtype = tde->volType; + volDesc[count].partition = tde->partition; + volDesc[count].hostAddr = HOSTADDR(&tde->server); /* the internet address */ + volDesc[count].date = tde->date; + volDesc[count].cloneDate = tde->cloneDate; /* Not yet known */ } - volArray.tc_dumpArray_len = count; /* element count */ - volArray.tc_dumpArray_val = volDesc; /* and data */ + volArray.tc_dumpArray_len = count; /* element count */ + volArray.tc_dumpArray_val = volDesc; /* and data */ baseNamePtr = tailCompPtr(dumpTaskPtr->dumpName); @@ -134,7 +136,7 @@ bc_Dumper(aindex) tcdiPtr->tapeSet.a = 1; tcdiPtr->tapeSet.b = 1; tcdiPtr->tapeSet.maxTapes = 1000000000; - tcdiPtr->tapeSet.expDate = dumpTaskPtr->expDate; /* PA */ + tcdiPtr->tapeSet.expDate = dumpTaskPtr->expDate; /* PA */ tcdiPtr->tapeSet.expType = dumpTaskPtr->expType; /* construct dump set name */ @@ -149,33 +151,35 @@ bc_Dumper(aindex) /* start the dump on the tape coordinator */ printf("Starting dump\n"); code = TC_PerformDump(tconn, tcdiPtr, &volArray, &dumpTaskPtr->dumpID); - if (code) - { + if (code) { com_err(whoami, code, "; Failed to start dump"); ERROR(code); } - com_err(whoami,0,"Task %u: Dump (%s)", dumpTaskPtr->dumpID, tcdiPtr->dumpName); + com_err(whoami, 0, "Task %u: Dump (%s)", dumpTaskPtr->dumpID, + tcdiPtr->dumpName); /* create status monitor block */ statusPtr = createStatusNode(); lock_Status(); - statusPtr->taskId = dumpTaskPtr->dumpID; - statusPtr->port = port; + statusPtr->taskId = dumpTaskPtr->dumpID; + statusPtr->port = port; statusPtr->jobNumber = bc_jobNumber(); statusPtr->volsTotal = volArray.tc_dumpArray_len; - statusPtr->flags &= ~STARTING; - sprintf(statusPtr->taskName, "Dump (%s.%s)", dumpTaskPtr->volSetName, baseNamePtr); + statusPtr->flags &= ~STARTING; + sprintf(statusPtr->taskName, "Dump (%s.%s)", dumpTaskPtr->volSetName, + baseNamePtr); unlock_Status(); -error_exit: + error_exit: /* locally allocated resources */ - if (volDesc) free(volDesc); + if (volDesc) + free(volDesc); - if (tconn) + if (tconn) rx_DestroyConnection(tconn); - return(code); + return (code); } /* freeDumpTaskVolumeList @@ -185,18 +189,17 @@ error_exit: freeDumpTaskVolumeList(vdptr) struct bc_volumeDump *vdptr; { - struct bc_volumeDump *nextVdPtr; + struct bc_volumeDump *nextVdPtr; - while (vdptr != 0) - { - nextVdPtr = vdptr->next; + while (vdptr != 0) { + nextVdPtr = vdptr->next; - if ( vdptr->name ) - free(vdptr->name); - free(vdptr); + if (vdptr->name) + free(vdptr->name); + free(vdptr); - vdptr = nextVdPtr; - } + vdptr = nextVdPtr; + } } /* bc_DmpRstStart @@ -204,23 +207,28 @@ freeDumpTaskVolumeList(vdptr) * we allocated a dumpTask entry. Here we do the task and then free the entry. */ bc_DmpRstStart(aindex) - afs_int32 aindex; + afs_int32 aindex; { register struct bc_dumpTask *tdump; - register afs_int32 code; + register afs_int32 code; tdump = &bc_dumpTasks[aindex]; - code = (tdump->callProc)(aindex); - if (code) lastTaskCode = code; + code = (tdump->callProc) (aindex); + if (code) + lastTaskCode = code; /* Cleanup allocated data structures */ freeDumpTaskVolumeList(tdump->volumes); tdump->dumpID = 0; - if (tdump->dumpName) free(tdump->dumpName); - if (tdump->newExt) free(tdump->newExt); - if (tdump->volSetName) free(tdump->volSetName); - if (tdump->portOffset) free(tdump->portOffset); + if (tdump->dumpName) + free(tdump->dumpName); + if (tdump->newExt) + free(tdump->newExt); + if (tdump->volSetName) + free(tdump->volSetName); + if (tdump->portOffset) + free(tdump->portOffset); tdump->flags &= ~BC_DI_INUSE; return code; @@ -238,24 +246,24 @@ bc_DmpRstStart(aindex) * bc_Restorer for doing restores */ -bc_StartDmpRst(aconfig, adname, avname, avolsToDump, adestServer, adestPartition, - afromDate, anewExt, aoldFlag, aparent, alevel, aproc, ports, - portCount, dsptr, append, dontExecute) - struct bc_config *aconfig; - char *adname; - char *avname; - struct bc_volumeDump *avolsToDump; - struct sockaddr_in *adestServer; - afs_int32 adestPartition; - afs_int32 afromDate; - char *anewExt; - int aoldFlag; - afs_int32 aparent, alevel; - int (*aproc)(); - afs_int32 *ports; - afs_int32 portCount; - struct bc_dumpSchedule *dsptr; - int append, dontExecute; +bc_StartDmpRst(aconfig, adname, avname, avolsToDump, adestServer, + adestPartition, afromDate, anewExt, aoldFlag, aparent, alevel, + aproc, ports, portCount, dsptr, append, dontExecute) + struct bc_config *aconfig; + char *adname; + char *avname; + struct bc_volumeDump *avolsToDump; + struct sockaddr_in *adestServer; + afs_int32 adestPartition; + afs_int32 afromDate; + char *anewExt; + int aoldFlag; + afs_int32 aparent, alevel; + int (*aproc) (); + afs_int32 *ports; + afs_int32 portCount; + struct bc_dumpSchedule *dsptr; + int append, dontExecute; { register int i; register afs_int32 code; @@ -263,61 +271,65 @@ bc_StartDmpRst(aconfig, adname, avname, avolsToDump, adestServer, adestPartition int doit; struct bc_volumeDump *tvol, *temp; - for (i=0; i= BC_MAXSIMDUMPS) - { + if (i >= BC_MAXSIMDUMPS) { com_err(whoami, BC_NOTLOCKED, "All of the dump/restore slots are in use, try again later"); - return(BC_NOTLOCKED); + return (BC_NOTLOCKED); } - + memset(&bc_dumpTasks[i], 0, sizeof(struct bc_dumpTask)); - bc_dumpTasks[i].callProc = aproc; - bc_dumpTasks[i].config = aconfig; - bc_dumpTasks[i].volumes = avolsToDump; - bc_dumpTasks[i].flags = BC_DI_INUSE; - bc_dumpTasks[i].dumpName = bc_CopyString(adname); - bc_dumpTasks[i].volSetName = bc_CopyString(avname); - bc_dumpTasks[i].newExt = bc_CopyString(anewExt); - bc_dumpTasks[i].dumpLevel = alevel; - bc_dumpTasks[i].parentDumpID = aparent; - bc_dumpTasks[i].oldFlag = aoldFlag; - bc_dumpTasks[i].fromDate = afromDate; + bc_dumpTasks[i].callProc = aproc; + bc_dumpTasks[i].config = aconfig; + bc_dumpTasks[i].volumes = avolsToDump; + bc_dumpTasks[i].flags = BC_DI_INUSE; + bc_dumpTasks[i].dumpName = bc_CopyString(adname); + bc_dumpTasks[i].volSetName = bc_CopyString(avname); + bc_dumpTasks[i].newExt = bc_CopyString(anewExt); + bc_dumpTasks[i].dumpLevel = alevel; + bc_dumpTasks[i].parentDumpID = aparent; + bc_dumpTasks[i].oldFlag = aoldFlag; + bc_dumpTasks[i].fromDate = afromDate; bc_dumpTasks[i].destPartition = adestPartition; - bc_dumpTasks[i].portOffset = ports; - bc_dumpTasks[i].portCount = portCount; - bc_dumpTasks[i].doAppend = append; - bc_dumpTasks[i].dontExecute = dontExecute; + bc_dumpTasks[i].portOffset = ports; + bc_dumpTasks[i].portCount = portCount; + bc_dumpTasks[i].doAppend = append; + bc_dumpTasks[i].dontExecute = dontExecute; - if (dsptr) - { + if (dsptr) { /* This should be specified for dumps, but will be 0 for restores */ bc_dumpTasks[i].expDate = dsptr->expDate; bc_dumpTasks[i].expType = dsptr->expType; } if (adestServer) - memcpy(&bc_dumpTasks[i].destServer, adestServer, sizeof(struct sockaddr_in)); + memcpy(&bc_dumpTasks[i].destServer, adestServer, + sizeof(struct sockaddr_in)); else - memset(&bc_dumpTasks[i].destServer, 0, sizeof(struct sockaddr_in)); - - code = LWP_CreateProcess(bc_DmpRstStart, 20480, LWP_NORMAL_PRIORITY, - (void *) i, "helper", &junk); - if (code) - { + memset(&bc_dumpTasks[i].destServer, 0, sizeof(struct sockaddr_in)); + + code = + LWP_CreateProcess(bc_DmpRstStart, 20480, LWP_NORMAL_PRIORITY, + (void *)i, "helper", &junk); + if (code) { bc_HandleMisc(code); - com_err(whoami,code,"; Can't start thread"); + com_err(whoami, code, "; Can't start thread"); /* Cleanup allocated data structures */ freeDumpTaskVolumeList(bc_dumpTasks[i].volumes); bc_dumpTasks[i].dumpID = 0; - if (bc_dumpTasks[i].dumpName) free(bc_dumpTasks[i].dumpName); - if (bc_dumpTasks[i].newExt) free(bc_dumpTasks[i].newExt); - if (bc_dumpTasks[i].volSetName) free(bc_dumpTasks[i].volSetName); - if (bc_dumpTasks[i].portOffset) free(bc_dumpTasks[i].portOffset); + if (bc_dumpTasks[i].dumpName) + free(bc_dumpTasks[i].dumpName); + if (bc_dumpTasks[i].newExt) + free(bc_dumpTasks[i].newExt); + if (bc_dumpTasks[i].volSetName) + free(bc_dumpTasks[i].volSetName); + if (bc_dumpTasks[i].portOffset) + free(bc_dumpTasks[i].portOffset); bc_dumpTasks[i].flags &= ~BC_DI_INUSE; - return(code); + return (code); } return 0; @@ -340,17 +352,15 @@ bc_FindDumpSlot(dumpID, port) afs_int32 port; { int i; - - for ( i = 0; i < BC_MAXSIMDUMPS; i++ ) - { - if ( (bc_dumpTasks[i].flags & BC_DI_INUSE) && - (bc_dumpTasks[i].dumpID == dumpID) && - ((afs_int32)bc_dumpTasks[i].portOffset == port) ) - { - return(i); + + for (i = 0; i < BC_MAXSIMDUMPS; i++) { + if ((bc_dumpTasks[i].flags & BC_DI_INUSE) + && (bc_dumpTasks[i].dumpID == dumpID) + && ((afs_int32) bc_dumpTasks[i].portOffset == port)) { + return (i); } } - return(-1); + return (-1); } #endif @@ -359,11 +369,11 @@ bc_FindDumpSlot(dumpID, port) * label a tape */ -bc_LabelTape (afsname, pname, size, config, port) -char *afsname, *pname; -struct bc_config *config; -afs_int32 port; -afs_int32 size; +bc_LabelTape(afsname, pname, size, config, port) + char *afsname, *pname; + struct bc_config *config; + afs_int32 port; + afs_int32 size; { struct rx_connection *tconn; afs_int32 code = 0; @@ -372,20 +382,20 @@ afs_int32 size; afs_uint32 taskId; code = ConnectButc(config, port, &tconn); - if (code) return(code); - + if (code) + return (code); + memset(&label, 0, sizeof(label)); if (afsname) - strcpy(label.afsname, afsname); + strcpy(label.afsname, afsname); if (pname) - strcpy(label.pname, (strcmp(pname,"")?pname:"")); + strcpy(label.pname, (strcmp(pname, "") ? pname : "")); label.size = size; code = TC_LabelTape(tconn, &label, &taskId); - if (code) - { - com_err(whoami,code,"; Failed to start labeltape"); - return(code); + if (code) { + com_err(whoami, code, "; Failed to start labeltape"); + return (code); } /* create status monitor block */ @@ -394,13 +404,13 @@ afs_int32 size; statusPtr->taskId = taskId; statusPtr->port = port; statusPtr->jobNumber = bc_jobNumber(); - /* statusPtr->flags |= SILENT; */ /* don't report termination */ - statusPtr->flags &= ~STARTING; /* ok to examine */ + /* statusPtr->flags |= SILENT; *//* don't report termination */ + statusPtr->flags &= ~STARTING; /* ok to examine */ sprintf(statusPtr->taskName, "Labeltape (%s)", (pname ? pname : (afsname ? afsname : ""))); unlock_Status(); - + return 0; } @@ -409,53 +419,53 @@ afs_int32 size; * a tape */ -bc_ReadLabel(config,port) - struct bc_config *config; - afs_int32 port; +bc_ReadLabel(config, port) + struct bc_config *config; + afs_int32 port; { struct rx_connection *tconn; struct tc_tapeLabel label; afs_uint32 taskId; afs_int32 code = 0; - char *tname=0; + char *tname = 0; code = ConnectButc(config, port, &tconn); - if (code) return(code); - + if (code) + return (code); + memset(&label, 0, sizeof(label)); code = TC_ReadLabel(tconn, &label, &taskId); if (code) { - if (code == BUTM_NOLABEL) { - printf("Tape read was unlabelled\n"); - return 0; + if (code == BUTM_NOLABEL) { + printf("Tape read was unlabelled\n"); + return 0; } - com_err(whoami,code,"; Failed to start readlabel"); - return(code); + com_err(whoami, code, "; Failed to start readlabel"); + return (code); } - if (strcmp(label.pname,"")) - tname = label.pname; - else if (strcmp(label.afsname,"")) - tname = label.afsname; + if (strcmp(label.pname, "")) + tname = label.pname; + else if (strcmp(label.afsname, "")) + tname = label.afsname; if (!tname) { - printf("Tape read was labelled : size : %u\n",label.size); - } - else if (!label.tapeId) { - printf("Tape read was labelled : %s size : %lu Kbytes\n", tname, label.size); - } - else { - printf("Tape read was labelled : %s (%lu) size : %lu Kbytes\n", - tname, label.tapeId, label.size); + printf("Tape read was labelled : size : %u\n", label.size); + } else if (!label.tapeId) { + printf("Tape read was labelled : %s size : %lu Kbytes\n", tname, + label.size); + } else { + printf("Tape read was labelled : %s (%lu) size : %lu Kbytes\n", tname, + label.tapeId, label.size); } return 0; } bc_ScanDumps(config, dbAddFlag, port) - struct bc_config *config; - afs_int32 dbAddFlag; - afs_int32 port; + struct bc_config *config; + afs_int32 dbAddFlag; + afs_int32 port; { struct rx_connection *tconn; statusP statusPtr; @@ -463,26 +473,26 @@ bc_ScanDumps(config, dbAddFlag, port) afs_int32 code = 0; code = ConnectButc(config, port, &tconn); - if (code) return(code); - - code = TC_ScanDumps(tconn, dbAddFlag, &taskId); if (code) - { + return (code); + + code = TC_ScanDumps(tconn, dbAddFlag, &taskId); + if (code) { com_err(whoami, code, "; Failed to start scantape"); - return(code); + return (code); } /* create status monitor block */ statusPtr = createStatusNode(); lock_Status(); - statusPtr->taskId = taskId; - statusPtr->port = port; - statusPtr->jobNumber = bc_jobNumber(); - statusPtr->flags &= ~STARTING; /* ok to examine */ + statusPtr->taskId = taskId; + statusPtr->port = port; + statusPtr->jobNumber = bc_jobNumber(); + statusPtr->flags &= ~STARTING; /* ok to examine */ sprintf(statusPtr->taskName, "Scantape"); unlock_Status(); - - return(0); + + return (0); } /*************/ @@ -491,12 +501,12 @@ bc_ScanDumps(config, dbAddFlag, port) /* get a connection to the tape controller */ afs_int32 -bc_GetConn (aconfig, aport, tconn) - struct bc_config *aconfig; - afs_int32 aport; - struct rx_connection **tconn; +bc_GetConn(aconfig, aport, tconn) + struct bc_config *aconfig; + afs_int32 aport; + struct rx_connection **tconn; { - afs_int32 code = 0; + afs_int32 code = 0; afs_uint32 host; unsigned short port; static struct rx_securityClass *rxsc; @@ -507,24 +517,24 @@ bc_GetConn (aconfig, aport, tconn) /* use non-secure connections to butc */ if (!rxsc) rxsc = rxnull_NewClientSecurityObject(); - if (!rxsc || !aconfig) return(-1); + if (!rxsc || !aconfig) + return (-1); - for (te = aconfig->tapeHosts; te; te = te->next) - { - if ( te->portOffset == aport ) - { + for (te = aconfig->tapeHosts; te; te = te->next) { + if (te->portOffset == aport) { /* found the right port */ - host = te->addr.sin_addr.s_addr; - if (!host) return (BC_NOHOSTENTRY); /* gethostbyname in bc_ParseHosts failed */ + host = te->addr.sin_addr.s_addr; + if (!host) + return (BC_NOHOSTENTRY); /* gethostbyname in bc_ParseHosts failed */ port = htons(BC_TAPEPORT + aport); /* servers is 1; sec index is 0 */ *tconn = rx_NewConnection(host, port, 1, rxsc, 0); - return((*tconn ? 0 : -1)); + return ((*tconn ? 0 : -1)); } } - return(BC_NOHOSTENTRY); + return (BC_NOHOSTENTRY); } /* CheckTCVersion @@ -541,39 +551,42 @@ CheckTCVersion(tconn) afs_int32 code; code = TC_TCInfo(tconn, &tci); - if (code) return(code); - + if (code) + return (code); + if (tci.tcVersion != CUR_BUTC_VERSION) - return(BC_VERSIONFAIL); + return (BC_VERSIONFAIL); return 0; } + ConnectButc(config, port, tconn) - struct bc_config *config; - afs_int32 port; - struct rx_connection **tconn; + struct bc_config *config; + afs_int32 port; + struct rx_connection **tconn; { afs_int32 code; code = bc_GetConn(config, port, tconn); - if (code) - { - com_err(whoami,code,"; Can't connect to tape coordinator at port %d", port); - return(code); + if (code) { + com_err(whoami, code, + "; Can't connect to tape coordinator at port %d", port); + return (code); } code = CheckTCVersion(*tconn); - if (code) - { + if (code) { rx_DestroyConnection(*tconn); if (code == BC_VERSIONFAIL) - com_err(whoami, code, "; Backup and butc are not the same version"); + com_err(whoami, code, + "; Backup and butc are not the same version"); else - com_err(whoami, code, "; Can't access tape coordinator at port %d", port); + com_err(whoami, code, + "; Can't access tape coordinator at port %d", port); - return(code); + return (code); } - - return(0); + + return (0); } diff --git a/src/bucoord/dump_sched.c b/src/bucoord/dump_sched.c index 070c25ed4..6327a04e5 100644 --- a/src/bucoord/dump_sched.c +++ b/src/bucoord/dump_sched.c @@ -16,7 +16,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -49,7 +50,7 @@ extern char *whoami; * command level routines * ------------------------------------ */ - + /* bc_AddDumpCmd * add a dump schedule * params: @@ -57,11 +58,13 @@ extern char *whoami; * parm 1: expiration date (list) */ -afs_int32 bc_AddDumpCmd(as, arock) -struct cmd_syndesc *as; -char *arock; { - register char *dname; /* dump schedule name */ - char *dateString; /* expiration date */ +afs_int32 +bc_AddDumpCmd(as, arock) + struct cmd_syndesc *as; + char *arock; +{ + register char *dname; /* dump schedule name */ + char *dateString; /* expiration date */ register afs_int32 code; afs_int32 expType, expDate; register struct cmd_item *ti, *expItem; @@ -70,17 +73,13 @@ char *arock; { afs_int32 bc_ParseExpiration(); /* if an expiration date has been specified */ - if (as->parms[1].items) - { + if (as->parms[1].items) { code = bc_ParseExpiration(&as->parms[1], &expType, &expDate); - if (code) - { + if (code) { printf("Invalid expiration date syntax\n"); - return(1); + return (1); } - } - else - { + } else { /* no expiration date specified */ expDate = 0; expType = BC_NO_EXPDATE; @@ -90,60 +89,59 @@ char *arock; { ctPtr = &bc_globalConfig->configText[TB_DUMPSCHEDULE]; code = bc_LockText(ctPtr); - if (code) ERROR(code); + if (code) + ERROR(code); code = bc_UpdateDumpSchedule(); if (code) { - com_err(whoami, code, "; Can't retrieve dump schedule"); - return(code); + com_err(whoami, code, "; Can't retrieve dump schedule"); + return (code); } /* process each dump name using the expiration date computed above */ - for( ti=as->parms[0].items; ti != 0; ti = ti->next ) - { + for (ti = as->parms[0].items; ti != 0; ti = ti->next) { /* get next dump name to process */ dname = ti->data; - + /* validate the name dump name length */ - if ( strlen(dname) >= BU_MAX_DUMP_PATH ) - { - com_err(whoami, 0, "Dump names must be < %d characters", BU_MAX_DUMP_PATH); + if (strlen(dname) >= BU_MAX_DUMP_PATH) { + com_err(whoami, 0, "Dump names must be < %d characters", + BU_MAX_DUMP_PATH); com_err(whoami, 0, "Dump %s not added", dname); code = -1; continue; } - code = bc_CreateDumpSchedule(bc_globalConfig, dname, expDate, expType); - if (code) - { + code = + bc_CreateDumpSchedule(bc_globalConfig, dname, expDate, expType); + if (code) { if (code == -1) - com_err(whoami,0,"Dump already exists"); + com_err(whoami, 0, "Dump already exists"); + else if (code == -2) + com_err(whoami, 0, "Invalid path name '%s'", dname); + else if (code == -3) + com_err(whoami, 0, "Name specification error"); else - if (code == -2) - com_err(whoami,0,"Invalid path name '%s'", dname); - else - if ( code == -3 ) - com_err(whoami, 0, "Name specification error"); - else - com_err(whoami,code,"; Failed to create dump schedule"); + com_err(whoami, code, "; Failed to create dump schedule"); continue; } - + /* save the new schedule item */ code = bc_SaveDumpSchedule(); - if (code) - { + if (code) { com_err(whoami, code, "Cannot save dump schedule"); - com_err(whoami,0,"Changes are temporary - for this session only"); + com_err(whoami, 0, + "Changes are temporary - for this session only"); break; } - com_err(whoami,0,"Created new dump schedule %s", dname); + com_err(whoami, 0, "Created new dump schedule %s", dname); } -error_exit: - if (ctPtr->lockHandle) bc_UnlockText(ctPtr); - return(code); + error_exit: + if (ctPtr->lockHandle) + bc_UnlockText(ctPtr); + return (code); } @@ -151,52 +149,52 @@ error_exit: * delete a dump schedule */ -afs_int32 bc_DeleteDumpCmd(as, arock) -struct cmd_syndesc *as; -char *arock; { +afs_int32 +bc_DeleteDumpCmd(as, arock) + struct cmd_syndesc *as; + char *arock; +{ /* parm 0 is vol set name * parm 1 is dump schedule name */ - register char *dname; - register afs_int32 code; + register char *dname; + register afs_int32 code; udbClientTextP ctPtr; /* lock schedules and check validity */ ctPtr = &bc_globalConfig->configText[TB_DUMPSCHEDULE]; code = bc_LockText(ctPtr); - if ( code ) - ERROR(code); + if (code) + ERROR(code); code = bc_UpdateDumpSchedule(); if (code) { - com_err(whoami, code, "; Can't retrieve dump schedule"); - return(code); + com_err(whoami, code, "; Can't retrieve dump schedule"); + return (code); } dname = as->parms[0].items->data; code = bc_DeleteDumpSchedule(bc_globalConfig, dname); - if (code) - { + if (code) { if (code == -1) - com_err(whoami,0,"No such dump as %s", dname); + com_err(whoami, 0, "No such dump as %s", dname); else - com_err(whoami,code,"; Failed to delete dump schedule"); + com_err(whoami, code, "; Failed to delete dump schedule"); goto error_exit; } - + code = bc_SaveDumpSchedule(); if (code == 0) - printf("backup: deleted dump schedule %s\n", dname); - else - { + printf("backup: deleted dump schedule %s\n", dname); + else { com_err(whoami, code, "Cannot save dump schedule file"); - com_err(whoami,0,"Deletion is temporary - for this session only"); + com_err(whoami, 0, "Deletion is temporary - for this session only"); } -error_exit: - if ( ctPtr->lockHandle != 0 ) + error_exit: + if (ctPtr->lockHandle != 0) bc_UnlockText(ctPtr); return code; } @@ -209,9 +207,10 @@ error_exit: * ignored */ -afs_int32 bc_ListDumpScheduleCmd(as, arock) -struct cmd_syndesc *as; -char *arock; +afs_int32 +bc_ListDumpScheduleCmd(as, arock) + struct cmd_syndesc *as; + char *arock; { /* no parms */ afs_int32 code; @@ -220,18 +219,17 @@ char *arock; /* first check to see if schedules must be updated */ code = bc_UpdateDumpSchedule(); if (code) { - com_err(whoami, code, "; Can't retrieve dump schedule"); - return(code); + com_err(whoami, code, "; Can't retrieve dump schedule"); + return (code); } /* go through entire list, displaying trees for root-level dump * schedules */ - for(tdump = bc_globalConfig->dsched; tdump; tdump=tdump->next) - { - /* if this is a root-level dump, show it and its kids */ - if (!tdump->parent) - ListDumpSchedule(tdump, 0); + for (tdump = bc_globalConfig->dsched; tdump; tdump = tdump->next) { + /* if this is a root-level dump, show it and its kids */ + if (!tdump->parent) + ListDumpSchedule(tdump, 0); } return 0; } @@ -244,11 +242,12 @@ char *arock; * parm 1: expiration date (list) */ -afs_int32 bc_SetExpCmd(as, arock) +afs_int32 +bc_SetExpCmd(as, arock) struct cmd_syndesc *as; char *arock; { - register char *dname; /* dump schedule name */ + register char *dname; /* dump schedule name */ register struct cmd_item *ti; struct bc_dumpSchedule *node, *parent; afs_int32 expType, expDate; @@ -258,17 +257,13 @@ afs_int32 bc_SetExpCmd(as, arock) afs_int32 bc_ParseExpiration(); /* if an expiration date has been specified */ - if (as->parms[1].items) - { + if (as->parms[1].items) { code = bc_ParseExpiration(&as->parms[1], &expType, &expDate); - if (code) - { + if (code) { printf("Invalid expiration date syntax\n"); - return(1); + return (1); } - } - else - { + } else { /* no expiration date specified */ expDate = 0; expType = BC_NO_EXPDATE; @@ -278,32 +273,31 @@ afs_int32 bc_SetExpCmd(as, arock) ctPtr = &bc_globalConfig->configText[TB_DUMPSCHEDULE]; code = bc_LockText(ctPtr); - if (code) ERROR(code); + if (code) + ERROR(code); code = bc_UpdateDumpSchedule(); if (code) { - com_err(whoami, code, "; Can't retrieve dump schedule"); - return(code); + com_err(whoami, code, "; Can't retrieve dump schedule"); + return (code); } /* process each dump name using the expiration date computed above */ - for( ti = as->parms[0].items; ti != 0; ti = ti->next) - { + for (ti = as->parms[0].items; ti != 0; ti = ti->next) { /* get next dump name to process */ dname = ti->data; - + /* validate the name dump name length */ - if ( strlen(dname) >= BU_MAX_DUMP_PATH ) - { + if (strlen(dname) >= BU_MAX_DUMP_PATH) { code = -1; - com_err(whoami, 0, "Dump names must be < %d characters", BU_MAX_DUMP_PATH); + com_err(whoami, 0, "Dump names must be < %d characters", + BU_MAX_DUMP_PATH); com_err(whoami, 0, "Dump %s not added", dname); continue; } code = FindDump(bc_globalConfig, dname, &parent, &node); - if (code) - { + if (code) { com_err(whoami, 0, "Dump level %s not found", dname); continue; } @@ -311,17 +305,18 @@ afs_int32 bc_SetExpCmd(as, arock) node->expDate = expDate; node->expType = expType; } - + code = bc_SaveDumpSchedule(); - if ( code ) - { + if (code) { com_err(whoami, code, "Cannot save dump schedule"); - com_err(whoami,0,"Expiration changes effective for this session only"); + com_err(whoami, 0, + "Expiration changes effective for this session only"); } -error_exit: - if (ctPtr->lockHandle) bc_UnlockText(ctPtr); - return(code); + error_exit: + if (ctPtr->lockHandle) + bc_UnlockText(ctPtr); + return (code); } @@ -334,13 +329,13 @@ error_exit: bc_ParseDumpSchedule() { char tbuffer[1024]; - char dsname[256], period[64]; + char dsname[256], period[64]; char *tp; afs_int32 code; udbClientTextP ctPtr; register struct bc_dumpSchedule *tds; struct bc_dumpSchedule **ppds, *pds; - afs_int32 expDate, expType; + afs_int32 expDate, expType; register FILE *stream; @@ -348,56 +343,55 @@ bc_ParseDumpSchedule() ctPtr = &bc_globalConfig->configText[TB_DUMPSCHEDULE]; stream = ctPtr->textStream; - if ( ctPtr->textSize == 0 ) /* nothing defined yet */ - return(0); + if (ctPtr->textSize == 0) /* nothing defined yet */ + return (0); - if ( stream == NULL ) - return(BC_INTERNALERROR); + if (stream == NULL) + return (BC_INTERNALERROR); rewind(stream); /* check the magic number and version */ tp = fgets(tbuffer, sizeof(tbuffer), stream); - if ( tp == 0 ) + if (tp == 0) /* can't read first line - error */ - return(BC_INTERNALERROR); - else - { + return (BC_INTERNALERROR); + else { afs_int32 dsmagic, dsversion; - + /* read the first line, and then check magic # and version */ - + code = sscanf(tbuffer, "%d %d", &dsmagic, &dsversion); - if ( (code != 2) - || (dsmagic != BC_SCHEDULE_MAGIC) - || (dsversion != BC_SCHEDULE_VERSION) - ) - { + if ((code != 2) + || (dsmagic != BC_SCHEDULE_MAGIC) + || (dsversion != BC_SCHEDULE_VERSION) + ) { /* invalid or unexpected header - error */ com_err(whoami, 0, "Unable to understand dump schedule file"); - return(BC_INTERNALERROR); + return (BC_INTERNALERROR); } } - while(1) - { + while (1) { /* read all of the lines out */ tp = fgets(tbuffer, sizeof(tbuffer), stream); - if ( tp == 0 ) - break; /* hit eof? */ - code = sscanf(tbuffer, "%s %s %d %d", dsname, period, - &expDate, &expType); - if (code != 4) - { - com_err(whoami,0,"Syntax error in dump schedule file, line is: %s", + if (tp == 0) + break; /* hit eof? */ + code = + sscanf(tbuffer, "%s %s %d %d", dsname, period, &expDate, + &expType); + if (code != 4) { + com_err(whoami, 0, + "Syntax error in dump schedule file, line is: %s", tbuffer); return (BC_INTERNALERROR); } - tds = (struct bc_dumpSchedule *)malloc(sizeof(struct bc_dumpSchedule)); + tds = + (struct bc_dumpSchedule *)malloc(sizeof(struct bc_dumpSchedule)); memset(tds, 0, sizeof(*tds)); - tds->next = (struct bc_dumpSchedule *) 0; - tds->name = (char *) malloc(strlen(dsname)+1); + tds->next = (struct bc_dumpSchedule *)0; + tds->name = (char *)malloc(strlen(dsname) + 1); strcpy(tds->name, dsname); tds->expDate = expDate; @@ -406,14 +400,13 @@ bc_ParseDumpSchedule() /* find the end of the schedule list, and append the new item to it */ ppds = &bc_globalConfig->dsched; pds = *ppds; - while ( pds != 0 ) - { + while (pds != 0) { ppds = &pds->next; pds = *ppds; } *ppds = tds; } - return 0; + return 0; } @@ -428,45 +421,44 @@ bc_SaveDumpSchedule() /* setup the right ptr */ ctPtr = &bc_globalConfig->configText[TB_DUMPSCHEDULE]; - + /* must be locked */ - if ( ctPtr->lockHandle == 0 ) - return(BC_INTERNALERROR); + if (ctPtr->lockHandle == 0) + return (BC_INTERNALERROR); /* truncate the file */ code = ftruncate(fileno(ctPtr->textStream), 0); - if ( code ) - ERROR(errno); + if (code) + ERROR(errno); rewind(ctPtr->textStream); /* write the new information */ - fprintf(ctPtr->textStream, "%d %d\n", - BC_SCHEDULE_MAGIC, BC_SCHEDULE_VERSION); + fprintf(ctPtr->textStream, "%d %d\n", BC_SCHEDULE_MAGIC, + BC_SCHEDULE_VERSION); - for(tdump = bc_globalConfig->dsched; tdump; tdump = tdump->next) - { - fprintf(ctPtr->textStream, "%s %s %d %d\n",tdump->name, "any", - tdump->expDate, tdump->expType); + for (tdump = bc_globalConfig->dsched; tdump; tdump = tdump->next) { + fprintf(ctPtr->textStream, "%s %s %d %d\n", tdump->name, "any", + tdump->expDate, tdump->expType); } if (ferror(ctPtr->textStream)) - return(BC_INTERNALERROR); + return (BC_INTERNALERROR); - fflush(ctPtr->textStream); /* debug */ + fflush(ctPtr->textStream); /* debug */ /* send to server */ code = bcdb_SaveTextFile(ctPtr); - if ( code ) - ERROR(code); + if (code) + ERROR(code); /* increment local version number */ ctPtr->textVersion++; /* update locally stored file size */ ctPtr->textSize = filesize(ctPtr->textStream); -error_exit: - return(code); + error_exit: + return (code); } @@ -475,7 +467,8 @@ error_exit: * ------------------------------------ */ -afs_int32 bc_UpdateDumpSchedule() +afs_int32 +bc_UpdateDumpSchedule() { struct bc_dumpSchedule *dumpPtr, *nextDumpPtr; struct udbHandleS *uhptr = &udbHandle; @@ -487,29 +480,25 @@ afs_int32 bc_UpdateDumpSchedule() ctPtr = &bc_globalConfig->configText[TB_DUMPSCHEDULE]; code = bc_CheckTextVersion(ctPtr); - if ( code != BC_VERSIONMISMATCH ) - { - ERROR(code); /* Version matches or some other error */ + if (code != BC_VERSIONMISMATCH) { + ERROR(code); /* Version matches or some other error */ } /* Must update the dump schedules */ /* If we are not already locked, then lock it now */ - if ( !ctPtr->lockHandle ) - { - code = bc_LockText(ctPtr); - if ( code ) - ERROR(code); + if (!ctPtr->lockHandle) { + code = bc_LockText(ctPtr); + if (code) + ERROR(code); lock = 1; } - if (ctPtr->textVersion != -1) - { - printf("backup: obsolete dump schedule - updating\n"); - + if (ctPtr->textVersion != -1) { + printf("backup: obsolete dump schedule - updating\n"); + /* clear all old schedule information */ dumpPtr = bc_globalConfig->dsched; - while ( dumpPtr ) - { + while (dumpPtr) { nextDumpPtr = dumpPtr->next; free(dumpPtr); dumpPtr = nextDumpPtr; @@ -519,34 +508,38 @@ afs_int32 bc_UpdateDumpSchedule() /* open a temp file to store the config text received from buserver * * The open file stream is stored in ctPtr->textStream */ - code = bc_openTextFile(ctPtr, &bc_globalConfig->tmpTextFileNames[TB_DUMPSCHEDULE][0]); - if ( code ) - ERROR(code); + code = + bc_openTextFile(ctPtr, + &bc_globalConfig-> + tmpTextFileNames[TB_DUMPSCHEDULE][0]); + if (code) + ERROR(code); /* now get a fresh set of information from the database */ code = bcdb_GetTextFile(ctPtr); - if ( code ) - ERROR(code); + if (code) + ERROR(code); - /* fetch the version number */ - code = ubik_Call(BUDB_GetTextVersion, uhptr->uh_client, 0, - ctPtr->textType, &ctPtr->textVersion); - if ( code ) + /* fetch the version number */ + code = + ubik_Call(BUDB_GetTextVersion, uhptr->uh_client, 0, ctPtr->textType, + &ctPtr->textVersion); + if (code) ERROR(code); /* parse the file */ code = bc_ParseDumpSchedule(); - if ( code ) - ERROR(code); + if (code) + ERROR(code); /* rebuild the tree */ code = bc_ProcessDumpSchedule(bc_globalConfig); - if ( code ) - ERROR(code); + if (code) + ERROR(code); -error_exit: - if ( lock && ctPtr->lockHandle ) + error_exit: + if (lock && ctPtr->lockHandle) bc_UnlockText(ctPtr); - return(code); + return (code); } /* ListDumpSchedule @@ -557,9 +550,11 @@ error_exit: * alevel - 0 */ -static ListDumpSchedule(adump, alevel) -int alevel; -register struct bc_dumpSchedule *adump; { +static +ListDumpSchedule(adump, alevel) + int alevel; + register struct bc_dumpSchedule *adump; +{ register int i; register struct bc_dumpSchedule *child; @@ -572,7 +567,7 @@ register struct bc_dumpSchedule *adump; { } /* move to appropriate indentation level */ - for(i=0; iexpType ) - { - case BC_ABS_EXPDATE: + switch (adump->expType) { + case BC_ABS_EXPDATE: /* absolute expiration date. Never expires if date is 0 */ - if ( adump->expDate ) - { + if (adump->expDate) { printf("expires at %.24s", cTIME(&adump->expDate)); } break; - case BC_REL_EXPDATE: + case BC_REL_EXPDATE: { struct ktime_date kt; @@ -603,12 +596,12 @@ register struct bc_dumpSchedule *adump; { } break; - default: + default: break; } printf("\n"); - for(child = adump->firstChild; child; child = child->nextSibling) - ListDumpSchedule(child, alevel+1); + for (child = adump->firstChild; child; child = child->nextSibling) + ListDumpSchedule(child, alevel + 1); return 0; } diff --git a/src/bucoord/error_macros.h b/src/bucoord/error_macros.h index c01378959..af619a4fe 100644 --- a/src/bucoord/error_macros.h +++ b/src/bucoord/error_macros.h @@ -20,4 +20,3 @@ code = evalue; \ goto abort_exit; \ } - diff --git a/src/bucoord/expire.c b/src/bucoord/expire.c index 193770a5d..705f70387 100644 --- a/src/bucoord/expire.c +++ b/src/bucoord/expire.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -28,17 +29,15 @@ RCSID("$Header$"); #define MAX_DAY_VALUE 30 /* for parsing relative expiration dates */ -static struct parseseqS -{ +static struct parseseqS { afs_int32 ps_field; char ps_keychar; afs_int32 ps_maxValue; } parseseq[] = { KTIMEDATE_YEAR, 'y', MAX_YEAR_VALUE, /* no max. value */ - KTIMEDATE_MONTH, 'm', MAX_MONTH_VALUE, /* months max. 12 */ - KTIMEDATE_DAY, 'd', MAX_DAY_VALUE, /* days max. 31 */ - 0, 0, 0, -}; + KTIMEDATE_MONTH, 'm', MAX_MONTH_VALUE, /* months max. 12 */ + KTIMEDATE_DAY, 'd', MAX_DAY_VALUE, /* days max. 31 */ +0, 0, 0,}; /* Encodings to and from relative dates. The caller is responsible for * enforcing appropriate use of these routines @@ -49,9 +48,10 @@ ktimeRelDate_ToLong(kdptr) { afs_int32 retval; - retval = (((kdptr->year*(MAX_MONTH_VALUE+1)) + - kdptr->month)*(MAX_DAY_VALUE+1)) + kdptr->day; - return(retval); + retval = + (((kdptr->year * (MAX_MONTH_VALUE + 1)) + + kdptr->month) * (MAX_DAY_VALUE + 1)) + kdptr->day; + return (retval); } /* LongTo_ktimeRelDate @@ -64,26 +64,26 @@ LongTo_ktimeRelDate(longDate, kdptr) struct ktime_date *kdptr; { memset(kdptr, 0, sizeof(*kdptr)); - + kdptr->day = longDate % (MAX_DAY_VALUE + 1); - if ( kdptr->day != 0 ) - kdptr->mask |= KTIMEDATE_DAY; + if (kdptr->day != 0) + kdptr->mask |= KTIMEDATE_DAY; + + longDate = longDate / (MAX_DAY_VALUE + 1); - longDate = longDate/(MAX_DAY_VALUE + 1); - kdptr->month = longDate % (MAX_MONTH_VALUE + 1); - if ( kdptr->month != 0 ) - kdptr->mask |= KTIMEDATE_MONTH; + if (kdptr->month != 0) + kdptr->mask |= KTIMEDATE_MONTH; + + longDate = longDate / (MAX_MONTH_VALUE + 1); - longDate = longDate/(MAX_MONTH_VALUE + 1); - kdptr->year = longDate; - if ( kdptr->year != 0 ) - kdptr->mask |= KTIMEDATE_YEAR; + if (kdptr->year != 0) + kdptr->mask |= KTIMEDATE_YEAR; - return(0); + return (0); } - + #ifdef notdef /* First some date storage and retrieval routines. @@ -107,15 +107,10 @@ ktimeDate_ToCompactString(kdptr) { char buffer[1024]; - sprintf(buffer, "%-d:%-d:%-d:%-d:%-d:%-d", - kdptr->year, - kdptr->month, - kdptr->day, - kdptr->hour, - kdptr->min, - kdptr->sec); + sprintf(buffer, "%-d:%-d:%-d:%-d:%-d:%-d", kdptr->year, kdptr->month, + kdptr->day, kdptr->hour, kdptr->min, kdptr->sec); - return(&buffer[0]); + return (&buffer[0]); } /* CompactStringTo_ktimeDate @@ -131,38 +126,34 @@ CompactStringTo_ktimeDate(stptr, kdptr) { afs_int32 code; - code = sscanf(stptr, "%d:%d:%d:%d:%d:%d", - &kdptr->year, - &kdptr->month, - &kdptr->day, - &kdptr->hour, - &kdptr->min, - &kdptr->sec); + code = + sscanf(stptr, "%d:%d:%d:%d:%d:%d", &kdptr->year, &kdptr->month, + &kdptr->day, &kdptr->hour, &kdptr->min, &kdptr->sec); - if ( code != 6 ) - return(-1); + if (code != 6) + return (-1); kdptr->mask = 0; - if ( kdptr->year ) - kdptr->mask |= KTIMEDATE_YEAR; + if (kdptr->year) + kdptr->mask |= KTIMEDATE_YEAR; - if ( kdptr->month ) - kdptr->mask |= KTIMEDATE_MONTH; + if (kdptr->month) + kdptr->mask |= KTIMEDATE_MONTH; - if ( kdptr->day ) - kdptr->mask |= KTIMEDATE_DAY; + if (kdptr->day) + kdptr->mask |= KTIMEDATE_DAY; - if ( kdptr->hour ) - kdptr->mask |= KTIMEDATE_HOUR; + if (kdptr->hour) + kdptr->mask |= KTIMEDATE_HOUR; - if ( kdptr->min ) - kdptr->mask |= KTIMEDATE_MIN; + if (kdptr->min) + kdptr->mask |= KTIMEDATE_MIN; - if ( kdptr->sec ) - kdptr->mask |= KTIMEDATE_SEC; + if (kdptr->sec) + kdptr->mask |= KTIMEDATE_SEC; - return(0); + return (0); } /* ktimeDate_FromLong @@ -189,10 +180,11 @@ ktimeDate_FromLong(timeSecs, ktimePtr) ktimePtr->month = timePtr->mon; ktimePtr->year = timePtr->year; - ktimePtr->mask = KTIMEDATE_YEAR | KTIMEDATE_MONTH | KTIMEDATE_DAY | - KTIMEDATE_HOUR | KTIMEDATE_MIN | KTIMEDATE_SEC; + ktimePtr->mask = + KTIMEDATE_YEAR | KTIMEDATE_MONTH | KTIMEDATE_DAY | KTIMEDATE_HOUR | + KTIMEDATE_MIN | KTIMEDATE_SEC; - return(0); + return (0); } @@ -208,15 +200,15 @@ ktimeDate_FromLong(timeSecs, ktimePtr) */ afs_int32 -AddKtimeToNow( relDatePtr ) +AddKtimeToNow(relDatePtr) struct ktime_date *relDatePtr; { struct parseseqS typePtr; afs_int32 curTime; afs_int32 moreYears; static struct ktime_date absDate; - - curTime = time(0); /* get current time */ + + curTime = time(0); /* get current time */ ktimeDate_FromLong(curTime, &absDate); /* convert to ktime */ /* add in years */ @@ -224,24 +216,24 @@ AddKtimeToNow( relDatePtr ) /* add in months */ absDate.month += relDatePtr->month; - if ( absDate.month > 12 ) - { + if (absDate.month > 12) { moreYears = absDate.month / 12; absDate.month = absDate.month % 12; absDate.year += moreYears; } - + /* day computations depend upon month size, so do these in seconds */ curTime = ktime_InterpretDate(&absDate); - - curTime = curTime + relDatePtr->sec + relDatePtr->min*60 + - relDatePtr->hour*60*60 + relDatePtr->day*24*60*60; - return(curTime); -} + curTime = + curTime + relDatePtr->sec + relDatePtr->min * 60 + + relDatePtr->hour * 60 * 60 + relDatePtr->day * 24 * 60 * 60; + + return (curTime); +} #endif /* notdef */ -#define RD_DIGIT_LIMIT 4 /* max. no. digits permitted */ +#define RD_DIGIT_LIMIT 4 /* max. no. digits permitted */ /* ParseRelDate @@ -267,79 +259,74 @@ ParseRelDate(dateStr, relDatePtr) memset(relDatePtr, 0, sizeof(*relDatePtr)); type_index = 0; - while ( 1 ) - { /*w*/ + while (1) { /*w */ - while ( isspace(*dateStr) ) /* skip leading whitespace */ - dateStr++; + while (isspace(*dateStr)) /* skip leading whitespace */ + dateStr++; - if ( isdigit(*dateStr) == 0 ) - goto error; + if (isdigit(*dateStr) == 0) + goto error; digit_limit = RD_DIGIT_LIMIT; value = 0; - while ( isdigit(*dateStr) ) - { - value = value*10 + *dateStr - '0'; + while (isdigit(*dateStr)) { + value = value * 10 + *dateStr - '0'; dateStr++; - if ( digit_limit-- == 0 ) - goto error; + if (digit_limit-- == 0) + goto error; } psPtr = &parseseq[type_index]; /* determine the units. Search for a matching type character */ - while ( (psPtr->ps_keychar != *dateStr) - && (psPtr->ps_keychar != 0) - ) - { + while ((psPtr->ps_keychar != *dateStr) + && (psPtr->ps_keychar != 0) + ) { type_index++; psPtr = &parseseq[type_index]; } /* no matching type found */ - if ( psPtr->ps_keychar == 0 ) - goto error; + if (psPtr->ps_keychar == 0) + goto error; /* check the bounds on the maximum value. Can't be negative * and if a maximum value is specified, check against it */ - if ( (value < 0) - || ((psPtr->ps_maxValue > 0) && (value > psPtr->ps_maxValue)) - ) - goto error; + if ((value < 0) + || ((psPtr->ps_maxValue > 0) && (value > psPtr->ps_maxValue)) + ) + goto error; /* save computed value in the relevant type field */ - switch ( psPtr->ps_field ) - { - case KTIMEDATE_YEAR: + switch (psPtr->ps_field) { + case KTIMEDATE_YEAR: relDatePtr->year = value; relDatePtr->mask |= KTIMEDATE_YEAR; break; - case KTIMEDATE_MONTH: + case KTIMEDATE_MONTH: relDatePtr->month = value; relDatePtr->mask |= KTIMEDATE_MONTH; break; - case KTIMEDATE_DAY: + case KTIMEDATE_DAY: relDatePtr->mask |= KTIMEDATE_DAY; relDatePtr->day = value; break; - default: + default: goto error; } - dateStr++; /* next digit */ + dateStr++; /* next digit */ - if ( *dateStr == 0 ) - { + if (*dateStr == 0) { /* no more chars to process, return the result */ - return(0); + return (0); } - } /*w*/ + } /*w */ -error: - return(1); + error: + return (1); } /* RelDatetoString @@ -361,26 +348,23 @@ RelDatetoString(datePtr) dateString[0] = 0; sptr = &dateString[0]; - if ( datePtr->mask & KTIMEDATE_YEAR ) - { + if (datePtr->mask & KTIMEDATE_YEAR) { sprintf(tempstring, "%-dy", datePtr->year); strcat(sptr, tempstring); } - if ( datePtr->mask & KTIMEDATE_MONTH ) - { + if (datePtr->mask & KTIMEDATE_MONTH) { strcat(sptr, " "); sprintf(tempstring, "%-dm", datePtr->month); strcat(sptr, tempstring); } - if ( datePtr->mask & KTIMEDATE_DAY ) - { + if (datePtr->mask & KTIMEDATE_DAY) { strcat(sptr, " "); sprintf(tempstring, "%-dd", datePtr->day); strcat(sptr, tempstring); } - return(sptr); + return (sptr); } #define FAIL(n) \ @@ -404,92 +388,83 @@ bc_ParseExpiration(paramPtr, expType, expDate) afs_int32 *expType; afs_int32 *expDate; { - struct cmd_item *itemPtr, *tempPtr; - struct ktime_date kt; - char *dateString; - afs_int32 length = 0; - afs_int32 code = 0; - - if ( paramPtr->items == 0 ) - { - /* no expiration specified */ - *expType = BC_NO_EXPDATE; - *expDate = 0; - return(0); - } - - /* some form of expiration date specified. First validate the prefix */ - itemPtr = paramPtr->items; - - if ( strcmp(itemPtr->data, "at") == 0 ) - { - *expType = BC_ABS_EXPDATE; - } - else - if ( strcmp(itemPtr->data, "in") == 0 ) - { - *expType = BC_REL_EXPDATE; - } - else - FAIL(1); - - /* before parsing the date string - concatenate all the pieces */ - itemPtr = itemPtr->next; - tempPtr = itemPtr; - - /* compute the length of string required */ - while ( tempPtr != 0 ) - { - length += strlen(tempPtr->data); - tempPtr = tempPtr->next; - length++; /* space or null terminator */ - } - if ( length == 0 ) /* no actual date string */ - FAIL(1); - - dateString = (char *) malloc(length); - if ( dateString == 0 ) - FAIL(2); - - /* now assemble the date string */ - dateString[0] = 0; - while ( itemPtr != 0 ) - { - strcat(dateString, itemPtr->data); - itemPtr = itemPtr->next; - if ( itemPtr != 0 ) - strcat(dateString, " "); - } - - switch ( *expType ) - { - case BC_ABS_EXPDATE: - code = ktime_DateToLong(dateString, expDate); - if ( code ) - FAIL(1); - break; - - case BC_REL_EXPDATE: - code = ParseRelDate(dateString, &kt); - if ( code ) - FAIL(1); - *expDate = ktimeRelDate_ToLong(&kt); - break; - - default: - FAIL(1); - } - - /* code will be 0 */ -exit: - /* normal exit */ - if ( dateString ) + struct cmd_item *itemPtr, *tempPtr; + struct ktime_date kt; + char *dateString; + afs_int32 length = 0; + afs_int32 code = 0; + + if (paramPtr->items == 0) { + /* no expiration specified */ + *expType = BC_NO_EXPDATE; + *expDate = 0; + return (0); + } + + /* some form of expiration date specified. First validate the prefix */ + itemPtr = paramPtr->items; + + if (strcmp(itemPtr->data, "at") == 0) { + *expType = BC_ABS_EXPDATE; + } else if (strcmp(itemPtr->data, "in") == 0) { + *expType = BC_REL_EXPDATE; + } else + FAIL(1); + + /* before parsing the date string - concatenate all the pieces */ + itemPtr = itemPtr->next; + tempPtr = itemPtr; + + /* compute the length of string required */ + while (tempPtr != 0) { + length += strlen(tempPtr->data); + tempPtr = tempPtr->next; + length++; /* space or null terminator */ + } + if (length == 0) /* no actual date string */ + FAIL(1); + + dateString = (char *)malloc(length); + if (dateString == 0) + FAIL(2); + + /* now assemble the date string */ + dateString[0] = 0; + while (itemPtr != 0) { + strcat(dateString, itemPtr->data); + itemPtr = itemPtr->next; + if (itemPtr != 0) + strcat(dateString, " "); + } + + switch (*expType) { + case BC_ABS_EXPDATE: + code = ktime_DateToLong(dateString, expDate); + if (code) + FAIL(1); + break; + + case BC_REL_EXPDATE: + code = ParseRelDate(dateString, &kt); + if (code) + FAIL(1); + *expDate = ktimeRelDate_ToLong(&kt); + break; + + default: + FAIL(1); + } + + /* code will be 0 */ + exit: + /* normal exit */ + if (dateString) free(dateString); - return(code); - -error: - /* assign default values */ - *expType = BC_NO_EXPDATE; - *expDate = 0; - goto exit; + return (code); + + error: + /* assign default values */ + *expType = BC_NO_EXPDATE; + *expDate = 0; + goto exit; } diff --git a/src/bucoord/main.c b/src/bucoord/main.c index 7506bb356..adfffeaee 100644 --- a/src/bucoord/main.c +++ b/src/bucoord/main.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -39,15 +40,15 @@ RCSID("$Header$"); #include #include #include -#include /*VLDB_MAXSERVERS*/ +#include /*VLDB_MAXSERVERS */ #include #include #include -#include "bc.h" /*Backup Coordinator structs and defs*/ +#include "bc.h" /*Backup Coordinator structs and defs */ -int localauth, interact; +int localauth, interact; char tcell[64]; extern int BC_ExecuteRequest(); @@ -87,24 +88,28 @@ extern PrintError(); /* * Global configuration information for the Backup Coordinator. */ -struct bc_config *bc_globalConfig; /*Ptr to global BC configuration info*/ +struct bc_config *bc_globalConfig; /*Ptr to global BC configuration info */ -struct ubik_client *cstruct; /* Ptr to Ubik client structure*/ -struct ktc_token ttoken; /* The token */ +struct ubik_client *cstruct; /* Ptr to Ubik client structure */ +struct ktc_token ttoken; /* The token */ -static const char *DefaultConfDir; /*Default backup config directory*/ -static int bcInit = 0; /* backupInit called yet ? */ +static const char *DefaultConfDir; /*Default backup config directory */ +static int bcInit = 0; /* backupInit called yet ? */ char *whoami = "backup"; /* dummy routine for the audit work. It should do nothing since audits */ /* occur at the server level and bos is not a server. */ -osi_audit() {return 0;} +osi_audit() +{ + return 0; +} /* * Initialize all the error tables that may be used by com_err * in this module. */ -void InitErrTabs() +void +InitErrTabs() { initialize_ACFG_error_table(); initialize_KA_error_table(); @@ -124,53 +129,69 @@ void InitErrTabs() * got to account for the errors which are volume related but * not dealt with by standard errno and com_err stuff. */ -void bc_HandleMisc(code) -afs_int32 code; +void +bc_HandleMisc(code) + afs_int32 code; { - if(((code <= VMOVED) && (code >= VSALVAGE)) || (code < 0)){ - switch(code){ - case -1 : fprintf(STDERR,"Possible communication failure\n"); - break; - case VSALVAGE: fprintf(STDERR,"Volume needs salvage\n"); - break; - case VNOVNODE: fprintf(STDERR,"Bad vnode number quoted\n"); - break; - case VNOVOL: fprintf(STDERR,"Volume not attached, does not exist, or not on line\n"); - break; - case VVOLEXISTS:fprintf(STDERR,"Volume already exists\n"); - break; - case VNOSERVICE:fprintf(STDERR,"Volume is not in service\n"); - break; - case VOFFLINE: fprintf(STDERR,"Volume is off line\n"); - break; - case VONLINE: fprintf(STDERR,"Volume is already on line\n"); - break; - case VDISKFULL: fprintf(STDERR,"Partition is full\n"); - break; - case VOVERQUOTA:fprintf(STDERR,"Volume max quota exceeded\n"); - break; - case VBUSY: fprintf(STDERR,"Volume temporarily unavailable\n"); - break; - case VMOVED:fprintf(STDERR,"Volume has moved to another server\n"); - break; - default: - break; - } + if (((code <= VMOVED) && (code >= VSALVAGE)) || (code < 0)) { + switch (code) { + case -1: + fprintf(STDERR, "Possible communication failure\n"); + break; + case VSALVAGE: + fprintf(STDERR, "Volume needs salvage\n"); + break; + case VNOVNODE: + fprintf(STDERR, "Bad vnode number quoted\n"); + break; + case VNOVOL: + fprintf(STDERR, + "Volume not attached, does not exist, or not on line\n"); + break; + case VVOLEXISTS: + fprintf(STDERR, "Volume already exists\n"); + break; + case VNOSERVICE: + fprintf(STDERR, "Volume is not in service\n"); + break; + case VOFFLINE: + fprintf(STDERR, "Volume is off line\n"); + break; + case VONLINE: + fprintf(STDERR, "Volume is already on line\n"); + break; + case VDISKFULL: + fprintf(STDERR, "Partition is full\n"); + break; + case VOVERQUOTA: + fprintf(STDERR, "Volume max quota exceeded\n"); + break; + case VBUSY: + fprintf(STDERR, "Volume temporarily unavailable\n"); + break; + case VMOVED: + fprintf(STDERR, "Volume has moved to another server\n"); + break; + default: + break; + } } return; } /* Return true if line is all whitespace */ -static LineIsBlank(aline) - register char *aline; -{ +static +LineIsBlank(aline) + register char *aline; +{ register int tc; while (tc = *aline++) - if ( (tc != ' ') && (tc != '\t') && (tc != '\n') ) return(0); + if ((tc != ' ') && (tc != '\t') && (tc != '\n')) + return (0); - return(1); -} + return (1); +} /* bc_InitTextConfig @@ -186,20 +207,19 @@ bc_InitTextConfig() extern struct bc_config *bc_globalConfig; - mkdir(DefaultConfDir, 777); /* temporary */ + mkdir(DefaultConfDir, 777); /* temporary */ /* initialize the client text structures */ ctPtr = &bc_globalConfig->configText[0]; - for ( i = 0; i < TB_NUM; i++ ) - { + for (i = 0; i < TB_NUM; i++) { memset(ctPtr, 0, sizeof(*ctPtr)); ctPtr->textType = i; ctPtr->textVersion = -1; ctPtr++; } - - return(0); + + return (0); } /*---------------------------------------------------------------------------- @@ -220,12 +240,13 @@ bc_InitTextConfig() *---------------------------------------------------------------------------- */ -static int backupInit() +static int +backupInit() { register afs_int32 code; - static int initd = 0; /* ever called? */ + static int initd = 0; /* ever called? */ PROCESS watcherPid; - PROCESS pid; /* LWP process ID*/ + PROCESS pid; /* LWP process ID */ extern statusWatcher(); @@ -233,59 +254,58 @@ static int backupInit() initialize_CMD_error_table(); /* don't run more than once */ - if (initd) - { - com_err(whoami,0,"Backup already initialized."); + if (initd) { + com_err(whoami, 0, "Backup already initialized."); return 0; } initd = 1; code = bc_InitConfig(DefaultConfDir); - if (code) - { - com_err(whoami, code, "Can't initialize from config files in directory '%s'", + if (code) { + com_err(whoami, code, + "Can't initialize from config files in directory '%s'", DefaultConfDir); - return(code); + return (code); } /* * Set up Rx. */ code = LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid); - if (code) - { - com_err(whoami, code,"; Can't initialize LWP"); - return(code); + if (code) { + com_err(whoami, code, "; Can't initialize LWP"); + return (code); } - code = rx_Init(htons(0)); - if (code) - { + code = rx_Init(htons(0)); + if (code) { com_err(whoami, code, "; Can't initialize Rx"); - return(code); + return (code); } rx_SetRxDeadTime(60); /* VLDB initialization */ vldbClientInit(0, localauth, tcell, &cstruct, &ttoken); - if (code) return(code); + if (code) + return (code); /* Backup database initialization */ code = udbClientInit(0, localauth, tcell); - if (code) return(code); + if (code) + return (code); /* setup status monitoring thread */ initStatus(); - code = LWP_CreateProcess(statusWatcher, 20480, LWP_NORMAL_PRIORITY, - (void *) 2, "statusWatcher", &watcherPid); - if ( code ) - { + code = + LWP_CreateProcess(statusWatcher, 20480, LWP_NORMAL_PRIORITY, + (void *)2, "statusWatcher", &watcherPid); + if (code) { com_err(whoami, code, "; Can't create status monitor task"); - return(code); + return (code); } - return(0); + return (0); } /*---------------------------------------------------------------------------- @@ -309,31 +329,32 @@ static int backupInit() *---------------------------------------------------------------------------- */ -static int MyBeforeProc(as) - register struct cmd_syndesc *as; +static int +MyBeforeProc(as) + register struct cmd_syndesc *as; { char *rock; afs_int32 code; /* Handling the command line opcode */ - if (!bcInit) - { - localauth = ((as && as->parms[14].items) ? 1 : 0); - if (as && as->parms[15].items) strcpy(tcell, as->parms[15].items->data); - else tcell[0] = '\0'; - - code = backupInit(); - if (code) - { - com_err(whoami,code,"; Can't initialize backup"); + if (!bcInit) { + localauth = ((as && as->parms[14].items) ? 1 : 0); + if (as && as->parms[15].items) + strcpy(tcell, as->parms[15].items->data); + else + tcell[0] = '\0'; + + code = backupInit(); + if (code) { + com_err(whoami, code, "; Can't initialize backup"); exit(1); } - /* Get initial information from the database */ - code = bc_InitTextConfig(); - if (code) - { - com_err(whoami, code, "; Can't obtain configuration text from backup database"); + /* Get initial information from the database */ + code = bc_InitTextConfig(); + if (code) { + com_err(whoami, code, + "; Can't obtain configuration text from backup database"); exit(1); } } @@ -348,9 +369,9 @@ static int MyBeforeProc(as) #include "AFS_component_version_number.c" #define MAXRECURSION 20 -extern int dontExecute; /* declared in commands.c */ -extern char *loadFile; /* declared in commands.c */ -char lineBuffer[1024]; /* Line typed in by user or read from load file */ +extern int dontExecute; /* declared in commands.c */ +extern char *loadFile; /* declared in commands.c */ +char lineBuffer[1024]; /* Line typed in by user or read from load file */ /* * This will dispatch a command. It holds a recursive loop for the @@ -364,117 +385,115 @@ char lineBuffer[1024]; /* Line typed in by user or read from load * put a lock around it so only 1 process gets in at a time. */ -struct Lock dispatchLock; /* lock on the Dispatch call */ +struct Lock dispatchLock; /* lock on the Dispatch call */ #define lock_Dispatch() ObtainWriteLock(&dispatchLock) #define unlock_Dispatch() ReleaseWriteLock(&dispatchLock) -afs_int32 doDispatch(targc, targv, dispatchCount) - char **targv[MAXV]; - afs_int32 targc; - afs_int32 dispatchCount; /* to prevent infinite recursion */ +afs_int32 +doDispatch(targc, targv, dispatchCount) + char **targv[MAXV]; + afs_int32 targc; + afs_int32 dispatchCount; /* to prevent infinite recursion */ { - char **sargv[MAXV]; - afs_int32 sargc; - afs_int32 code, c; - FILE *fd; - int i; - int lineNumber; - int noExecute; /* local capy of global variable */ - char *internalLoadFile; - - lock_Dispatch(); - - loadFile = NULL; - code = cmd_Dispatch(targc, targv); - internalLoadFile = loadFile; - - unlock_Dispatch(); - - if (internalLoadFile) /* Load a file in */ - { - if (dispatchCount > MAXRECURSION) /* Beware recursive loops. */ - { - com_err(whoami,0,"Potential recursion: will not load file %s", internalLoadFile); - code = -1; - goto done; - } - - fd = fopen(internalLoadFile, "r"); /* Open the load file */ - if (!fd) - { - com_err(whoami,errno,"; Cannot open file %s", internalLoadFile); - code = -1; - goto done; - } - - noExecute = dontExecute; - if (noExecute) - printf("Would have executed the following commands:\n"); - - lineNumber = 0; - while ( fgets(lineBuffer, sizeof(lineBuffer)-1, fd) ) /* Get commands from file */ - { - lineNumber++; - - i = strlen(lineBuffer) - 1; - if (lineBuffer[i] == '\n') /* Drop return at end of line */ - lineBuffer[i] = '\0'; - - if (noExecute) - printf(" %s\n", lineBuffer); /* echo */ - else - printf("------> %s\n", lineBuffer); /* echo */ - - if ( !LineIsBlank(lineBuffer) && /* Skip if blank line */ - (lineBuffer[0] != '#') && /* or comment */ - (!noExecute) ) /* or no execute */ - { - c = cmd_ParseLine(lineBuffer, sargv, &sargc, MAXV); - if (c) - { - com_err(whoami, c, "; Can't parse line"); - } - else - { - doDispatch(sargc, sargv, dispatchCount+1); /* Recursive - ignore error */ - cmd_FreeArgv(sargv); /* Free up arguments */ - } - } - } - - fclose(fd); - } - -done: - if (internalLoadFile) free(internalLoadFile); - return(code); + char **sargv[MAXV]; + afs_int32 sargc; + afs_int32 code, c; + FILE *fd; + int i; + int lineNumber; + int noExecute; /* local capy of global variable */ + char *internalLoadFile; + + lock_Dispatch(); + + loadFile = NULL; + code = cmd_Dispatch(targc, targv); + internalLoadFile = loadFile; + + unlock_Dispatch(); + + if (internalLoadFile) { /* Load a file in */ + if (dispatchCount > MAXRECURSION) { /* Beware recursive loops. */ + com_err(whoami, 0, "Potential recursion: will not load file %s", + internalLoadFile); + code = -1; + goto done; + } + + fd = fopen(internalLoadFile, "r"); /* Open the load file */ + if (!fd) { + com_err(whoami, errno, "; Cannot open file %s", internalLoadFile); + code = -1; + goto done; + } + + noExecute = dontExecute; + if (noExecute) + printf("Would have executed the following commands:\n"); + + lineNumber = 0; + while (fgets(lineBuffer, sizeof(lineBuffer) - 1, fd)) { /* Get commands from file */ + lineNumber++; + + i = strlen(lineBuffer) - 1; + if (lineBuffer[i] == '\n') /* Drop return at end of line */ + lineBuffer[i] = '\0'; + + if (noExecute) + printf(" %s\n", lineBuffer); /* echo */ + else + printf("------> %s\n", lineBuffer); /* echo */ + + if (!LineIsBlank(lineBuffer) && /* Skip if blank line */ + (lineBuffer[0] != '#') && /* or comment */ + (!noExecute)) { /* or no execute */ + c = cmd_ParseLine(lineBuffer, sargv, &sargc, MAXV); + if (c) { + com_err(whoami, c, "; Can't parse line"); + } else { + doDispatch(sargc, sargv, dispatchCount + 1); /* Recursive - ignore error */ + cmd_FreeArgv(sargv); /* Free up arguments */ + } + } + } + + fclose(fd); + } + + done: + if (internalLoadFile) + free(internalLoadFile); + return (code); } -int bc_interactCmd(as, arock) - struct cmd_syndesc *as; - char *arock; +int +bc_interactCmd(as, arock) + struct cmd_syndesc *as; + char *arock; { interact = 1; } -static void add_std_args(ts) - register struct cmd_syndesc *ts; +static void +add_std_args(ts) + register struct cmd_syndesc *ts; { cmd_Seek(ts, 14); - cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL, "local authentication"); + cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL, + "local authentication"); cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name"); } main(argc, argv) - int argc; - char **argv; -{ /*main*/ - char **targv[MAXV]; /*Ptr to parsed argv stuff*/ - afs_int32 targc; /*Num parsed arguments*/ - afs_int32 code; /*Return code*/ - char *tp; /*Result of gets()*/ - register struct cmd_syndesc *ts; /*Ptr to parsed command line*/ + int argc; + char **argv; +{ /*main */ + char **targv[MAXV]; /*Ptr to parsed argv stuff */ + afs_int32 targc; /*Num parsed arguments */ + afs_int32 code; /*Return code */ + char *tp; /*Result of gets() */ + register struct cmd_syndesc *ts; /*Ptr to parsed command line */ int i; @@ -486,228 +505,308 @@ main(argc, argv) * generated which, in many cases, isn't too useful. */ struct sigaction nsa; - + sigemptyset(&nsa.sa_mask); nsa.sa_handler = SIG_DFL; nsa.sa_flags = SA_FULLDUMP; sigaction(SIGSEGV, &nsa, NULL); #endif Lock_Init(&dispatchLock); - InitErrTabs(); /* init all the error tables which may be used */ + InitErrTabs(); /* init all the error tables which may be used */ /* setup the default backup dir */ DefaultConfDir = AFSDIR_SERVER_BACKUP_DIRPATH; /* Get early warning if the command is interacive mode or not */ - interact = ( ((argc < 2) || (argv[1][0] == '-')) ? 1 : 0 ); + interact = (((argc < 2) || (argv[1][0] == '-')) ? 1 : 0); cmd_SetBeforeProc(MyBeforeProc, NULL); ts = cmd_CreateSyntax("dump", bc_DumpCmd, 0, "start dump"); - cmd_AddParm(ts, "-volumeset", CMD_SINGLE, CMD_OPTIONAL, "volume set name"); + cmd_AddParm(ts, "-volumeset", CMD_SINGLE, CMD_OPTIONAL, + "volume set name"); cmd_AddParm(ts, "-dump", CMD_SINGLE, CMD_OPTIONAL, "dump level name"); - cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); + cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, + "TC port offset"); cmd_AddParm(ts, "-at", CMD_LIST, CMD_OPTIONAL, "Date/time to start dump"); - cmd_AddParm(ts, "-append", CMD_FLAG, CMD_OPTIONAL, "append to existing dump set"); + cmd_AddParm(ts, "-append", CMD_FLAG, CMD_OPTIONAL, + "append to existing dump set"); cmd_AddParm(ts, "-n", CMD_FLAG, CMD_OPTIONAL, "don't really execute it"); cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "load file"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("volrestore", bc_VolRestoreCmd, 0, "restore volume"); - cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "destination machine"); - cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED, "destination partition"); - cmd_AddParm(ts, "-volume", CMD_LIST, CMD_REQUIRED, "volume(s) to restore"); - cmd_AddParm(ts, "-extension", CMD_SINGLE, CMD_OPTIONAL, "new volume name extension"); - cmd_AddParm(ts, "-date", CMD_LIST, CMD_OPTIONAL, "date from which to restore"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("volrestore", bc_VolRestoreCmd, 0, + "restore volume"); + cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, + "destination machine"); + cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED, + "destination partition"); + cmd_AddParm(ts, "-volume", CMD_LIST, CMD_REQUIRED, + "volume(s) to restore"); + cmd_AddParm(ts, "-extension", CMD_SINGLE, CMD_OPTIONAL, + "new volume name extension"); + cmd_AddParm(ts, "-date", CMD_LIST, CMD_OPTIONAL, + "date from which to restore"); cmd_AddParm(ts, "-portoffset", CMD_LIST, CMD_OPTIONAL, "TC port offsets"); cmd_AddParm(ts, "-n", CMD_FLAG, CMD_OPTIONAL, "don't really execute it"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("diskrestore", bc_DiskRestoreCmd, 0, "restore partition"); - cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine to restore"); - cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED, "partition to restore"); - cmd_AddParm(ts, "-portoffset", CMD_LIST, CMD_OPTIONAL, "TC port offset"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("diskrestore", bc_DiskRestoreCmd, 0, + "restore partition"); + cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, + "machine to restore"); + cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED, + "partition to restore"); + cmd_AddParm(ts, "-portoffset", CMD_LIST, CMD_OPTIONAL, "TC port offset"); cmd_Seek(ts, 8); - cmd_AddParm(ts, "-newserver", CMD_SINGLE, CMD_OPTIONAL, "destination machine"); - cmd_AddParm(ts, "-newpartition", CMD_SINGLE, CMD_OPTIONAL, "destination partition"); - cmd_AddParm(ts, "-extension", CMD_SINGLE, CMD_OPTIONAL, "new volume name extension"); + cmd_AddParm(ts, "-newserver", CMD_SINGLE, CMD_OPTIONAL, + "destination machine"); + cmd_AddParm(ts, "-newpartition", CMD_SINGLE, CMD_OPTIONAL, + "destination partition"); + cmd_AddParm(ts, "-extension", CMD_SINGLE, CMD_OPTIONAL, + "new volume name extension"); cmd_AddParm(ts, "-n", CMD_FLAG, CMD_OPTIONAL, "don't really execute it"); - if (!interact) add_std_args(ts); + if (!interact) + add_std_args(ts); ts = cmd_CreateSyntax("quit", bc_QuitCmd, 0, "leave the program"); - ts = cmd_CreateSyntax("volsetrestore", bc_VolsetRestoreCmd, 0, "restore a set of volumes"); + ts = cmd_CreateSyntax("volsetrestore", bc_VolsetRestoreCmd, 0, + "restore a set of volumes"); cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume set name"); cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "file name"); cmd_AddParm(ts, "-portoffset", CMD_LIST, CMD_OPTIONAL, "TC port offset"); - cmd_AddParm(ts, "-extension", CMD_SINGLE, CMD_OPTIONAL, "new volume name extension"); + cmd_AddParm(ts, "-extension", CMD_SINGLE, CMD_OPTIONAL, + "new volume name extension"); cmd_AddParm(ts, "-n", CMD_FLAG, CMD_OPTIONAL, "don't really execute it"); - if (!interact) add_std_args(ts); + if (!interact) + add_std_args(ts); ts = cmd_CreateSyntax("addhost", bc_AddHostCmd, 0, "add host to config"); - cmd_AddParm(ts, "-tapehost", CMD_SINGLE, CMD_REQUIRED, "tape machine name"); - cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("delhost", bc_DeleteHostCmd, 0, "delete host to config"); - cmd_AddParm(ts, "-tapehost", CMD_SINGLE, CMD_REQUIRED, "tape machine name"); - cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("listhosts", bc_ListHostsCmd, 0, "list config hosts"); - if (!interact) add_std_args(ts); + cmd_AddParm(ts, "-tapehost", CMD_SINGLE, CMD_REQUIRED, + "tape machine name"); + cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, + "TC port offset"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("delhost", bc_DeleteHostCmd, 0, + "delete host to config"); + cmd_AddParm(ts, "-tapehost", CMD_SINGLE, CMD_REQUIRED, + "tape machine name"); + cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, + "TC port offset"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("listhosts", bc_ListHostsCmd, 0, + "list config hosts"); + if (!interact) + add_std_args(ts); ts = cmd_CreateSyntax("jobs", bc_JobsCmd, 0, "list running jobs"); ts = cmd_CreateSyntax("kill", bc_KillCmd, 0, "kill running job"); - cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_REQUIRED, "job ID or dump set name"); + cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_REQUIRED, + "job ID or dump set name"); - ts = cmd_CreateSyntax("listvolsets", bc_ListVolSetCmd, 0, "list volume sets"); + ts = cmd_CreateSyntax("listvolsets", bc_ListVolSetCmd, 0, + "list volume sets"); cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume set name"); - if (!interact) add_std_args(ts); + if (!interact) + add_std_args(ts); - ts = cmd_CreateSyntax("listdumps", bc_ListDumpScheduleCmd, 0, "list dump schedules"); - if (!interact) add_std_args(ts); + ts = cmd_CreateSyntax("listdumps", bc_ListDumpScheduleCmd, 0, + "list dump schedules"); + if (!interact) + add_std_args(ts); - ts = cmd_CreateSyntax("addvolset", bc_AddVolSetCmd, 0, "create a new volume set"); + ts = cmd_CreateSyntax("addvolset", bc_AddVolSetCmd, 0, + "create a new volume set"); cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_REQUIRED, "volume set name"); - cmd_AddParm(ts, "-temporary", CMD_FLAG, CMD_OPTIONAL, "temporary volume set"); - if (!interact) add_std_args(ts); + cmd_AddParm(ts, "-temporary", CMD_FLAG, CMD_OPTIONAL, + "temporary volume set"); + if (!interact) + add_std_args(ts); - ts = cmd_CreateSyntax("status", bc_GetTapeStatusCmd, 0, + ts = cmd_CreateSyntax("status", bc_GetTapeStatusCmd, 0, "get tape coordinator status"); - cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); - if (!interact) add_std_args(ts); + cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, + "TC port offset"); + if (!interact) + add_std_args(ts); - ts = cmd_CreateSyntax("delvolset", bc_DeleteVolSetCmd, 0, "delete a volume set"); + ts = cmd_CreateSyntax("delvolset", bc_DeleteVolSetCmd, 0, + "delete a volume set"); cmd_AddParm(ts, "-name", CMD_LIST, CMD_REQUIRED, "volume set name"); - if (!interact) add_std_args(ts); + if (!interact) + add_std_args(ts); - ts = cmd_CreateSyntax("addvolentry", bc_AddVolEntryCmd, 0, "add a new volume entry"); + ts = cmd_CreateSyntax("addvolentry", bc_AddVolEntryCmd, 0, + "add a new volume entry"); cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_REQUIRED, "volume set name"); cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name"); cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED, "partition name"); - cmd_AddParm(ts, "-volumes", CMD_SINGLE, CMD_REQUIRED, "volume name (regular expression)"); - if (!interact) add_std_args(ts); + cmd_AddParm(ts, "-volumes", CMD_SINGLE, CMD_REQUIRED, + "volume name (regular expression)"); + if (!interact) + add_std_args(ts); - ts = cmd_CreateSyntax("delvolentry", bc_DeleteVolEntryCmd, 0, "delete a volume set sub-entry"); + ts = cmd_CreateSyntax("delvolentry", bc_DeleteVolEntryCmd, 0, + "delete a volume set sub-entry"); cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_REQUIRED, "volume set name"); cmd_AddParm(ts, "-entry", CMD_SINGLE, CMD_REQUIRED, "volume set index"); - if (!interact) add_std_args(ts); + if (!interact) + add_std_args(ts); ts = cmd_CreateSyntax("adddump", bc_AddDumpCmd, 0, "add dump schedule"); cmd_AddParm(ts, "-dump", CMD_LIST, CMD_REQUIRED, "dump level name"); cmd_AddParm(ts, "-expires", CMD_LIST, CMD_OPTIONAL, "expiration date"); - if (!interact) add_std_args(ts); + if (!interact) + add_std_args(ts); - ts = cmd_CreateSyntax("deldump", bc_DeleteDumpCmd, 0, "delete dump schedule"); + ts = cmd_CreateSyntax("deldump", bc_DeleteDumpCmd, 0, + "delete dump schedule"); cmd_AddParm(ts, "-dump", CMD_SINGLE, CMD_REQUIRED, "dump level name"); - if (!interact) add_std_args(ts); + if (!interact) + add_std_args(ts); ts = cmd_CreateSyntax("labeltape", bc_LabelTapeCmd, 0, "label a tape"); - cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "AFS tape name, defaults to NULL"); - cmd_AddParm(ts, "-size", CMD_SINGLE, CMD_OPTIONAL, + cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, + "AFS tape name, defaults to NULL"); + cmd_AddParm(ts, "-size", CMD_SINGLE, CMD_OPTIONAL, "tape size in Kbytes, defaults to size in tapeconfig"); - cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); - cmd_AddParm(ts, "-pname", CMD_SINGLE, CMD_OPTIONAL, "permanent tape name"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("readlabel", bc_ReadLabelCmd, 0, "read the label on tape"); - cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("scantape", bc_ScanDumpsCmd, 0, "dump information recovery from tape"); - cmd_AddParm(ts, "-dbadd", CMD_FLAG, CMD_OPTIONAL, "add information to the database"); - cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("volinfo", bc_dblookupCmd, 0, "query the backup database"); + cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, + "TC port offset"); + cmd_AddParm(ts, "-pname", CMD_SINGLE, CMD_OPTIONAL, + "permanent tape name"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("readlabel", bc_ReadLabelCmd, 0, + "read the label on tape"); + cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, + "TC port offset"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("scantape", bc_ScanDumpsCmd, 0, + "dump information recovery from tape"); + cmd_AddParm(ts, "-dbadd", CMD_FLAG, CMD_OPTIONAL, + "add information to the database"); + cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, + "TC port offset"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("volinfo", bc_dblookupCmd, 0, + "query the backup database"); cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume name"); - if (!interact) add_std_args(ts); + if (!interact) + add_std_args(ts); - ts = cmd_CreateSyntax("setexp", bc_SetExpCmd, 0, "set/clear dump expiration dates"); + ts = cmd_CreateSyntax("setexp", bc_SetExpCmd, 0, + "set/clear dump expiration dates"); cmd_AddParm(ts, "-dump", CMD_LIST, CMD_REQUIRED, "dump level name"); cmd_AddParm(ts, "-expires", CMD_LIST, CMD_OPTIONAL, "expiration date"); - if (!interact) add_std_args(ts); + if (!interact) + add_std_args(ts); ts = cmd_CreateSyntax("savedb", bc_saveDbCmd, 0, "save backup database"); - cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); - cmd_AddParm(ts, "-archive", CMD_LIST, CMD_OPTIONAL, "date time"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("restoredb", bc_restoreDbCmd, 0, "restore backup database"); - cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("dumpinfo", bc_dumpInfoCmd, 0, + cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, + "TC port offset"); + cmd_AddParm(ts, "-archive", CMD_LIST, CMD_OPTIONAL, "date time"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("restoredb", bc_restoreDbCmd, 0, + "restore backup database"); + cmd_AddParm(ts, "-portoffset", CMD_SINGLE, CMD_OPTIONAL, + "TC port offset"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("dumpinfo", bc_dumpInfoCmd, 0, "provide information about a dump in the database"); cmd_AddParm(ts, "-ndumps", CMD_SINGLE, CMD_OPTIONAL, "no. of dumps"); cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "dump id"); - cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "detailed description"); - if (!interact) add_std_args(ts); + cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, + "detailed description"); + if (!interact) + add_std_args(ts); - ts = cmd_CreateSyntax("dbverify", bc_dbVerifyCmd, 0, "check ubik database integrity"); + ts = cmd_CreateSyntax("dbverify", bc_dbVerifyCmd, 0, + "check ubik database integrity"); cmd_AddParm(ts, "-detail", CMD_FLAG, CMD_OPTIONAL, "additional details"); - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("deletedump", bc_deleteDumpCmd, 0, "delete dumps from the database"); - cmd_AddParm(ts, "-dumpid", CMD_LIST, CMD_OPTIONAL, "dump id"); - cmd_AddParm(ts, "-from", CMD_LIST, CMD_OPTIONAL, "date time"); - cmd_AddParm(ts, "-to", CMD_LIST, CMD_OPTIONAL, "date time"); - cmd_AddParm(ts, "-port", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("deletedump", bc_deleteDumpCmd, 0, + "delete dumps from the database"); + cmd_AddParm(ts, "-dumpid", CMD_LIST, CMD_OPTIONAL, "dump id"); + cmd_AddParm(ts, "-from", CMD_LIST, CMD_OPTIONAL, "date time"); + cmd_AddParm(ts, "-to", CMD_LIST, CMD_OPTIONAL, "date time"); + cmd_AddParm(ts, "-port", CMD_SINGLE, CMD_OPTIONAL, "TC port offset"); cmd_AddParm(ts, "-groupid", CMD_SINGLE, CMD_OPTIONAL, "group ID"); cmd_AddParm(ts, "-dbonly", CMD_FLAG, CMD_OPTIONAL, - "delete the dump from the backup database only"); - cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, - "always delete from backup database"); - cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL, "Just list the dumps"); - - if (!interact) add_std_args(ts); - - ts = cmd_CreateSyntax("interactive", bc_interactCmd, 0, "enter interactive mode"); + "delete the dump from the backup database only"); + cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, + "always delete from backup database"); + cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL, + "Just list the dumps"); + + if (!interact) + add_std_args(ts); + + ts = cmd_CreateSyntax("interactive", bc_interactCmd, 0, + "enter interactive mode"); add_std_args(ts); /* * Now execute the command. */ - targc = 0; targv[targc++] = argv[0]; - if (interact) targv[targc++] = "interactive"; - for (i=1; i "); fflush(stdout); - + while ((ret = LWP_GetLine(lineBuffer, sizeof(lineBuffer))) == 0) - printf("%s: Command line too long\n", whoami); /* line too long */ + printf("%s: Command line too long\n", whoami); /* line too long */ - if (ret == -1) return 0; /* Got EOF */ + if (ret == -1) + return 0; /* Got EOF */ - if ( !LineIsBlank(lineBuffer) ) - { + if (!LineIsBlank(lineBuffer)) { code = cmd_ParseLine(lineBuffer, targv, &targc, MAXV); if (code) - com_err(whoami,code,"; Can't parse line: '%s'", + com_err(whoami, code, "; Can't parse line: '%s'", error_message(code)); - else - { + else { doDispatch(targc, targv, 1); cmd_FreeArgv(targv); } } } -} /*main*/ +} /*main */ diff --git a/src/bucoord/regex.c b/src/bucoord/regex.c index c68401551..bb2176d8f 100644 --- a/src/bucoord/regex.c +++ b/src/bucoord/regex.c @@ -90,131 +90,130 @@ #define ESIZE 512 #define NBRA 9 -static char expbuf[ESIZE], *braslist[NBRA], *braelist[NBRA]; -static char circf; +static char expbuf[ESIZE], *braslist[NBRA], *braelist[NBRA]; +static char circf; /* * compile the regular expression argument into a dfa */ char * re_comp(sp) - register char *sp; + register char *sp; { - register int c; - register char *ep = expbuf; - int cclcnt, numbra = 0; - char *lastep = 0; - char bracket[NBRA]; - char *bracketp = &bracket[0]; - static char *retoolong = "Regular expression too long"; + register int c; + register char *ep = expbuf; + int cclcnt, numbra = 0; + char *lastep = 0; + char bracket[NBRA]; + char *bracketp = &bracket[0]; + static char *retoolong = "Regular expression too long"; #define comerr(msg) {expbuf[0] = 0; numbra = 0; return(msg); } - if (sp == 0 || *sp == '\0') { - if (*ep == 0) - return("No previous regular expression"); - return(0); + if (sp == 0 || *sp == '\0') { + if (*ep == 0) + return ("No previous regular expression"); + return (0); + } + if (*sp == '^') { + circf = 1; + sp++; + } else + circf = 0; + for (;;) { + if (ep >= &expbuf[ESIZE]) + comerr(retoolong); + if ((c = *sp++) == '\0') { + if (bracketp != bracket) + comerr("unmatched \\("); + *ep++ = CEOF; + *ep++ = 0; + return (0); } - if (*sp == '^') { - circf = 1; - sp++; - } - else - circf = 0; - for (;;) { - if (ep >= &expbuf[ESIZE]) - comerr(retoolong); - if ((c = *sp++) == '\0') { - if (bracketp != bracket) - comerr("unmatched \\("); - *ep++ = CEOF; - *ep++ = 0; - return(0); - } - if (c != '*') - lastep = ep; - switch (c) { - - case '.': - *ep++ = CDOT; - continue; - - case '*': - if (lastep == 0 || *lastep == CBRA || *lastep == CKET) - goto defchar; - *lastep |= CSTAR; - continue; - - case '$': - if (*sp != '\0') - goto defchar; - *ep++ = CDOL; - continue; - - case '[': - *ep++ = CCL; - *ep++ = 0; - cclcnt = 1; - if ((c = *sp++) == '^') { - c = *sp++; - ep[-2] = NCCL; - } - do { - if (c == '\0') - comerr("missing ]"); - if (c == '-' && ep [-1] != 0) { - if ((c = *sp++) == ']') { - *ep++ = '-'; - cclcnt++; - break; - } - while (ep[-1] < c) { - *ep = ep[-1] + 1; - ep++; - cclcnt++; - if (ep >= &expbuf[ESIZE]) - comerr(retoolong); - } - } - *ep++ = c; - cclcnt++; - if (ep >= &expbuf[ESIZE]) - comerr(retoolong); - } while ((c = *sp++) != ']'); - lastep[1] = cclcnt; - continue; - - case '\\': - if ((c = *sp++) == '(') { - if (numbra >= NBRA) - comerr("too many \\(\\) pairs"); - *bracketp++ = numbra; - *ep++ = CBRA; - *ep++ = numbra++; - continue; - } - if (c == ')') { - if (bracketp <= bracket) - comerr("unmatched \\)"); - *ep++ = CKET; - *ep++ = *--bracketp; - continue; - } - if (c >= '1' && c < ('1' + NBRA)) { - *ep++ = CBACK; - *ep++ = c - '1'; - continue; - } - *ep++ = CCHR; - *ep++ = c; - continue; - - defchar: - default: - *ep++ = CCHR; - *ep++ = c; + if (c != '*') + lastep = ep; + switch (c) { + + case '.': + *ep++ = CDOT; + continue; + + case '*': + if (lastep == 0 || *lastep == CBRA || *lastep == CKET) + goto defchar; + *lastep |= CSTAR; + continue; + + case '$': + if (*sp != '\0') + goto defchar; + *ep++ = CDOL; + continue; + + case '[': + *ep++ = CCL; + *ep++ = 0; + cclcnt = 1; + if ((c = *sp++) == '^') { + c = *sp++; + ep[-2] = NCCL; + } + do { + if (c == '\0') + comerr("missing ]"); + if (c == '-' && ep[-1] != 0) { + if ((c = *sp++) == ']') { + *ep++ = '-'; + cclcnt++; + break; + } + while (ep[-1] < c) { + *ep = ep[-1] + 1; + ep++; + cclcnt++; + if (ep >= &expbuf[ESIZE]) + comerr(retoolong); + } } + *ep++ = c; + cclcnt++; + if (ep >= &expbuf[ESIZE]) + comerr(retoolong); + } while ((c = *sp++) != ']'); + lastep[1] = cclcnt; + continue; + + case '\\': + if ((c = *sp++) == '(') { + if (numbra >= NBRA) + comerr("too many \\(\\) pairs"); + *bracketp++ = numbra; + *ep++ = CBRA; + *ep++ = numbra++; + continue; + } + if (c == ')') { + if (bracketp <= bracket) + comerr("unmatched \\)"); + *ep++ = CKET; + *ep++ = *--bracketp; + continue; + } + if (c >= '1' && c < ('1' + NBRA)) { + *ep++ = CBACK; + *ep++ = c - '1'; + continue; + } + *ep++ = CCHR; + *ep++ = c; + continue; + + defchar: + default: + *ep++ = CCHR; + *ep++ = c; } + } } /* @@ -222,178 +221,175 @@ re_comp(sp) */ int re_exec(p1) - register char *p1; + register char *p1; { - register char *p2 = expbuf; - register int c; - int rv; - - for (c = 0; c < NBRA; c++) { - braslist[c] = 0; - braelist[c] = 0; - } - if (circf) - return((advance(p1, p2))); - /* - * fast check for first character - */ - if (*p2 == CCHR) { - c = p2[1]; - do { - if (*p1 != c) - continue; - if (rv = advance(p1, p2)) - return(rv); - } while (*p1++); - return(0); - } - /* - * regular algorithm - */ - do - if (rv = advance(p1, p2)) - return(rv); - while (*p1++); - return(0); + register char *p2 = expbuf; + register int c; + int rv; + + for (c = 0; c < NBRA; c++) { + braslist[c] = 0; + braelist[c] = 0; + } + if (circf) + return ((advance(p1, p2))); + /* + * fast check for first character + */ + if (*p2 == CCHR) { + c = p2[1]; + do { + if (*p1 != c) + continue; + if (rv = advance(p1, p2)) + return (rv); + } while (*p1++); + return (0); + } + /* + * regular algorithm + */ + do + if (rv = advance(p1, p2)) + return (rv); + while (*p1++); + return (0); } /* * try to match the next thing in the dfa */ -static int +static int advance(lp, ep) - register char *lp, *ep; + register char *lp, *ep; { - register char *curlp; - int ct, i; - int rv; - - for (;;) - switch (*ep++) { - - case CCHR: - if (*ep++ == *lp++) - continue; - return(0); - - case CDOT: - if (*lp++) - continue; - return(0); - - case CDOL: - if (*lp == '\0') - continue; - return(0); - - case CEOF: - return(1); - - case CCL: - if (cclass(ep, *lp++, 1)) { - ep += *ep; - continue; - } - return(0); - - case NCCL: - if (cclass(ep, *lp++, 0)) { - ep += *ep; - continue; - } - return(0); - - case CBRA: - braslist[*ep++] = lp; - continue; - - case CKET: - braelist[*ep++] = lp; - continue; - - case CBACK: - if (braelist[i = *ep++] == 0) - return(-1); - if (backref(i, lp)) { - lp += braelist[i] - braslist[i]; - continue; - } - return(0); - - case CBACK|CSTAR: - if (braelist[i = *ep++] == 0) - return(-1); - curlp = lp; - ct = braelist[i] - braslist[i]; - while (backref(i, lp)) - lp += ct; - while (lp >= curlp) { - if (rv = advance(lp, ep)) - return(rv); - lp -= ct; - } - continue; - - case CDOT|CSTAR: - curlp = lp; - while (*lp++) - ; - goto star; - - case CCHR|CSTAR: - curlp = lp; - while (*lp++ == *ep) - ; - ep++; - goto star; - - case CCL|CSTAR: - case NCCL|CSTAR: - curlp = lp; - while (cclass(ep, *lp++, ep[-1] == (CCL|CSTAR))) - ; - ep += *ep; - goto star; - - star: - do { - lp--; - if (rv = advance(lp, ep)) - return(rv); - } while (lp > curlp); - return(0); - - default: - return(-1); - } + register char *curlp; + int ct, i; + int rv; + + for (;;) + switch (*ep++) { + + case CCHR: + if (*ep++ == *lp++) + continue; + return (0); + + case CDOT: + if (*lp++) + continue; + return (0); + + case CDOL: + if (*lp == '\0') + continue; + return (0); + + case CEOF: + return (1); + + case CCL: + if (cclass(ep, *lp++, 1)) { + ep += *ep; + continue; + } + return (0); + + case NCCL: + if (cclass(ep, *lp++, 0)) { + ep += *ep; + continue; + } + return (0); + + case CBRA: + braslist[*ep++] = lp; + continue; + + case CKET: + braelist[*ep++] = lp; + continue; + + case CBACK: + if (braelist[i = *ep++] == 0) + return (-1); + if (backref(i, lp)) { + lp += braelist[i] - braslist[i]; + continue; + } + return (0); + + case CBACK | CSTAR: + if (braelist[i = *ep++] == 0) + return (-1); + curlp = lp; + ct = braelist[i] - braslist[i]; + while (backref(i, lp)) + lp += ct; + while (lp >= curlp) { + if (rv = advance(lp, ep)) + return (rv); + lp -= ct; + } + continue; + + case CDOT | CSTAR: + curlp = lp; + while (*lp++); + goto star; + + case CCHR | CSTAR: + curlp = lp; + while (*lp++ == *ep); + ep++; + goto star; + + case CCL | CSTAR: + case NCCL | CSTAR: + curlp = lp; + while (cclass(ep, *lp++, ep[-1] == (CCL | CSTAR))); + ep += *ep; + goto star; + + star: + do { + lp--; + if (rv = advance(lp, ep)) + return (rv); + } while (lp > curlp); + return (0); + + default: + return (-1); + } } static backref(i, lp) - register int i; - register char *lp; + register int i; + register char *lp; { - register char *bp; + register char *bp; - bp = braslist[i]; - while (*bp++ == *lp++) - if (bp >= braelist[i]) - return(1); - return(0); + bp = braslist[i]; + while (*bp++ == *lp++) + if (bp >= braelist[i]) + return (1); + return (0); } static int cclass(set, c, af) - register char *set, c; - int af; + register char *set, c; + int af; { - register int n; - - if (c == 0) - return(0); - n = *set++; - while (--n) - if (*set++ == c) - return(af); - return(! af); + register int n; + + if (c == 0) + return (0); + n = *set++; + while (--n) + if (*set++ == c) + return (af); + return (!af); } diff --git a/src/bucoord/restore.c b/src/bucoord/restore.c index e60fd933f..9b261194e 100644 --- a/src/bucoord/restore.c +++ b/src/bucoord/restore.c @@ -14,7 +14,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -56,104 +57,103 @@ extern struct rx_connection *bc_GetConn(); /* local structure to keep track of volumes and the dumps from which * they should be restored */ -struct dumpinfo -{ - struct dumpinfo *next; - struct volinfo *volinfolist; - struct volinfo *lastinlist; - afs_int32 DumpId; - afs_int32 initialDumpId; - afs_int32 parentDumpId; - afs_int32 level; +struct dumpinfo { + struct dumpinfo *next; + struct volinfo *volinfolist; + struct volinfo *lastinlist; + afs_int32 DumpId; + afs_int32 initialDumpId; + afs_int32 parentDumpId; + afs_int32 level; }; -struct volinfo -{ - struct voli *next; - char *volname; - afs_int32 server; - afs_int32 partition; +struct volinfo { + struct voli *next; + char *volname; + afs_int32 server; + afs_int32 partition; }; /* local structure used to keep track of a tape, including a list of * volumes to restore from that tape (bc_tapeItem) */ -struct bc_tapeList -{ - struct bc_tapeList *next; /* next guy in list */ - char *tapeName; /* name of the tape */ - afs_int32 dumpID; /* dump located on this tape */ - afs_int32 initialDumpID; /* initial dump located on this tape */ - afs_int32 tapeNumber; /* which tape in the dump */ - struct bc_tapeItem *restoreList; /* volumes to restore from this tape */ +struct bc_tapeList { + struct bc_tapeList *next; /* next guy in list */ + char *tapeName; /* name of the tape */ + afs_int32 dumpID; /* dump located on this tape */ + afs_int32 initialDumpID; /* initial dump located on this tape */ + afs_int32 tapeNumber; /* which tape in the dump */ + struct bc_tapeItem *restoreList; /* volumes to restore from this tape */ }; /* each tape has a list of volumes to restore; hangs off of a struct bc_tapeList. Kept sorted so that we can read the tape once to do everything we need to do. */ -struct bc_tapeItem -{ +struct bc_tapeItem { struct bc_tapeItem *next; - char *volumeName; /* volume to restore */ - afs_int32 position; /* file slot on this tape */ - afs_int32 oid; /* id of the volume */ - afs_int32 dumplevel; /* level # of the containing dump (0 == top level) */ - afs_int32 vollevel; /* level # of the containing volume (0 == full dump) */ + char *volumeName; /* volume to restore */ + afs_int32 position; /* file slot on this tape */ + afs_int32 oid; /* id of the volume */ + afs_int32 dumplevel; /* level # of the containing dump (0 == top level) */ + afs_int32 vollevel; /* level # of the containing volume (0 == full dump) */ afs_uint32 server; afs_int32 partition; - int lastdump; /* The last incremental to restore */ + int lastdump; /* The last incremental to restore */ }; /* strip .backup from the end of a name */ -static StripBackup(aname) - register char *aname; +static +StripBackup(aname) + register char *aname; { int j; - + if (j = BackupName(aname)) { - aname[j] = 0; + aname[j] = 0; return 0; } return -1; } -int BackupName(aname) - char *aname; +int +BackupName(aname) + char *aname; { int j; j = strlen(aname); - if ((j > 7) && (strcmp(".backup", aname+j-7) == 0)) - return (j-7); - if ((j > 9) && (strcmp(".readonly", aname+j-9) == 0)) - return (j-9); + if ((j > 7) && (strcmp(".backup", aname + j - 7) == 0)) + return (j - 7); + if ((j > 9) && (strcmp(".readonly", aname + j - 9) == 0)) + return (j - 9); return 0; } extractTapeSeq(tapename) - char *tapename; + char *tapename; { char *sptr; sptr = strrchr(tapename, '.'); - if ( !sptr ) return(-1); + if (!sptr) + return (-1); sptr++; - return(atol(sptr)); + return (atol(sptr)); } viceName(value) - long value; + long value; { - char *alph; - int r; + char *alph; + int r; - alph = "abcdefjhijklmnopqrstuvwxyz"; + alph = "abcdefjhijklmnopqrstuvwxyz"; - if (value > 25) - viceName(value/26 - 1); + if (value > 25) + viceName(value / 26 - 1); - r = value % 26; - printf("%c", alph[r]); + r = value % 26; + printf("%c", alph[r]); } /* bc_DoRestore @@ -161,27 +161,27 @@ viceName(value) * aindex - index into bc_dumpTasks that describes this dump. */ bc_Restorer(aindex) - afs_int32 aindex; + afs_int32 aindex; { struct bc_dumpTask *dumpTaskPtr; - char vname[BU_MAXNAMELEN]; + char vname[BU_MAXNAMELEN]; struct budb_dumpEntry *dumpDescr, dumpDescr1, dumpDescr2; struct budb_volumeEntry *volumeEntries; struct bc_volumeDump *tvol; - afs_int32 code = 0, tcode; - afs_int32 tapedumpid, parent; + afs_int32 code = 0, tcode; + afs_int32 tapedumpid, parent; - afs_int32 nentries = 0; - afs_int32 last, next, ve, vecount; + afs_int32 nentries = 0; + afs_int32 last, next, ve, vecount; struct bc_tapeItem *ti, *pti, *nti; struct bc_tapeList *tapeList = (struct bc_tapeList *)0; struct bc_tapeList *tle, *ptle, *ntle; - afs_int32 tlid; - afs_int32 tapeid, tid; + afs_int32 tlid; + afs_int32 tapeid, tid; - struct tc_restoreArray rpcArray; /* the rpc structure we use */ - struct tc_restoreDesc *tcarray = (struct tc_restoreDesc *)0; + struct tc_restoreArray rpcArray; /* the rpc structure we use */ + struct tc_restoreDesc *tcarray = (struct tc_restoreDesc *)0; afs_int32 i, startentry, todump; afs_int32 port, nextport; @@ -192,58 +192,51 @@ bc_Restorer(aindex) struct dumpinfo *dumpinfolist = NULL; struct dumpinfo *pdi, *ndi, *di, dlevels[BC_MAXLEVELS]; - struct volinfo *pvi, *nvi, *vi; - afs_int32 lvl, lv; + struct volinfo *pvi, *nvi, *vi; + afs_int32 lvl, lv; - afs_int32 serverAll; /* The server to which all volumes are to be restore to */ - afs_int32 partitionAll; /* Likewise for partition */ - struct hostent *hostPtr; - long haddr; - u_long did; - int foundtape, c; + afs_int32 serverAll; /* The server to which all volumes are to be restore to */ + afs_int32 partitionAll; /* Likewise for partition */ + struct hostent *hostPtr; + long haddr; + u_long did; + int foundtape, c; extern statusP createStatusNode(); extern statusP findStatus(); - dumpTaskPtr = &bc_dumpTasks[aindex]; - serverAll = HOSTADDR(&dumpTaskPtr->destServer); + dumpTaskPtr = &bc_dumpTasks[aindex]; + serverAll = HOSTADDR(&dumpTaskPtr->destServer); partitionAll = dumpTaskPtr->destPartition; volumeEntries = (struct budb_volumeEntry *) - malloc(MAXTAPESATONCE * sizeof(struct budb_volumeEntry)); - if (!volumeEntries) - { - com_err(whoami,BC_NOMEM,""); + malloc(MAXTAPESATONCE * sizeof(struct budb_volumeEntry)); + if (!volumeEntries) { + com_err(whoami, BC_NOMEM, ""); ERROR(BC_NOMEM); } - + /* For each volume to restore, find which dump it's most recent full or * incremental is on and thread onto our dump list (from oldest to newest * dump). Also hang the volume off of the dump (no particular order). */ - for (tvol = dumpTaskPtr->volumes; tvol; tvol = tvol->next) - { /*tvol*/ - strcpy(vname, tvol->name); + for (tvol = dumpTaskPtr->volumes; tvol; tvol = tvol->next) { /*tvol */ + strcpy(vname, tvol->name); dumpDescr = &dumpDescr1; code = bcdb_FindDump(vname, dumpTaskPtr->fromDate, dumpDescr); - if ( !BackupName(vname) ) /* See if backup volume is there */ - { + if (!BackupName(vname)) { /* See if backup volume is there */ strcat(vname, ".backup"); dumpDescr = &dumpDescr2; tcode = code; code = bcdb_FindDump(vname, dumpTaskPtr->fromDate, dumpDescr); - if (code) /* Can't find backup, go with first results */ - { - strcpy(vname, tvol->name); + if (code) { /* Can't find backup, go with first results */ + strcpy(vname, tvol->name); dumpDescr = &dumpDescr1; code = tcode; - } - else if (!tcode) /* Both found an entry, go with latest result */ - { - if (dumpDescr1.created > dumpDescr2.created) - { + } else if (!tcode) { /* Both found an entry, go with latest result */ + if (dumpDescr1.created > dumpDescr2.created) { strcpy(vname, tvol->name); dumpDescr = &dumpDescr1; code = tcode; @@ -251,107 +244,99 @@ bc_Restorer(aindex) } } - if (code) /* If FindDump took an error */ - { - com_err(whoami, code, "; Can't find any dump for volume %s", tvol->name); + if (code) { /* If FindDump took an error */ + com_err(whoami, code, "; Can't find any dump for volume %s", + tvol->name); continue; } - + /* look to see if this dump has already been found */ - for (pdi=0, di=dumpinfolist; di; pdi=di, di=di->next) - { - if (di->DumpId < dumpDescr->id) { di = 0; break; } - else if (di->DumpId == dumpDescr->id) { break; } + for (pdi = 0, di = dumpinfolist; di; pdi = di, di = di->next) { + if (di->DumpId < dumpDescr->id) { + di = 0; + break; + } else if (di->DumpId == dumpDescr->id) { + break; + } } /* If didn't find it, create one and thread into list */ - if (!di) - { - di = (struct dumpinfo *) malloc(sizeof(struct dumpinfo)); - if (!di) - { - com_err(whoami,BC_NOMEM,""); + if (!di) { + di = (struct dumpinfo *)malloc(sizeof(struct dumpinfo)); + if (!di) { + com_err(whoami, BC_NOMEM, ""); ERROR(BC_NOMEM); } memset(di, 0, sizeof(struct dumpinfo)); - di->DumpId = dumpDescr->id; + di->DumpId = dumpDescr->id; di->initialDumpId = dumpDescr->initialDumpID; - di->parentDumpId = dumpDescr->parent; - di->level = dumpDescr->level; - - if (!pdi) - { - di->next = dumpinfolist; - dumpinfolist = di; - } - else - { - di->next = pdi->next; - pdi->next = di; + di->parentDumpId = dumpDescr->parent; + di->level = dumpDescr->level; + + if (!pdi) { + di->next = dumpinfolist; + dumpinfolist = di; + } else { + di->next = pdi->next; + pdi->next = di; } } - + /* Create one and thread into list */ - vi = (struct volinfo *) malloc(sizeof(struct volinfo)); - if (!vi) - { - com_err(whoami,BC_NOMEM,""); + vi = (struct volinfo *)malloc(sizeof(struct volinfo)); + if (!vi) { + com_err(whoami, BC_NOMEM, ""); ERROR(BC_NOMEM); } memset(vi, 0, sizeof(struct volinfo)); - - vi->volname = (char*)malloc(strlen(vname)+1); - if (!vi->volname) - { + + vi->volname = (char *)malloc(strlen(vname) + 1); + if (!vi->volname) { free(vi); - com_err(whoami,BC_NOMEM,""); + com_err(whoami, BC_NOMEM, ""); ERROR(BC_NOMEM); } strcpy(vi->volname, vname); - if (serverAll) - { - vi->server = serverAll; + if (serverAll) { + vi->server = serverAll; vi->partition = partitionAll; - } - else - { - vi->server = HOSTADDR(&tvol->server); + } else { + vi->server = HOSTADDR(&tvol->server); vi->partition = tvol->partition; } /* thread onto end of list */ - if (!di->lastinlist) di->volinfolist = vi; - else di->lastinlist->next = vi; + if (!di->lastinlist) + di->volinfolist = vi; + else + di->lastinlist->next = vi; di->lastinlist = vi; - } /*tvol*/ + } /*tvol */ /* For each of the above dumps we found (they could be increments), find * the dump's lineage (up to the full dump). */ - for (di=dumpinfolist; di; di=di->next) - { + for (di = dumpinfolist; di; di = di->next) { /* Find each of the parent dumps */ - memcpy(&dlevels[0], di, sizeof(struct dumpinfo)); - for (lvl=1, parent=dlevels[0].parentDumpId; parent; - parent=dlevels[lvl].parentDumpId, lvl++) - { + memcpy(&dlevels[0], di, sizeof(struct dumpinfo)); + for (lvl = 1, parent = dlevels[0].parentDumpId; parent; + parent = dlevels[lvl].parentDumpId, lvl++) { code = bcdb_FindDumpByID(parent, &dumpDescr1); - if (code) - { - for (vi=di->volinfolist; vi; vi=vi->next) - { - com_err(whoami, code, "; Can't find parent DumpID %u for volume %s", + if (code) { + for (vi = di->volinfolist; vi; vi = vi->next) { + com_err(whoami, code, + "; Can't find parent DumpID %u for volume %s", parent, vi->volname); } break; } - dlevels[lvl].DumpId = dumpDescr1.id; + dlevels[lvl].DumpId = dumpDescr1.id; dlevels[lvl].initialDumpId = dumpDescr1.initialDumpID; - dlevels[lvl].parentDumpId = dumpDescr1.parent; - dlevels[lvl].level = dumpDescr1.level; + dlevels[lvl].parentDumpId = dumpDescr1.parent; + dlevels[lvl].level = dumpDescr1.level; } /* For each of the volumes that has a dump in this lineage (vi), @@ -361,45 +346,44 @@ bc_Restorer(aindex) * Each volume fragment is sorted by tapeid, tape sequence, and tape * position. */ - for (vi=di->volinfolist; vi; vi=vi->next) - { - tle = tapeList; /* Use for searching the tapelist */ - ptle = 0; /* The previous tape list entry */ - tlid = 0; /* tapeid of first entry */ + for (vi = di->volinfolist; vi; vi = vi->next) { + tle = tapeList; /* Use for searching the tapelist */ + ptle = 0; /* The previous tape list entry */ + tlid = 0; /* tapeid of first entry */ /* Volume's dump-level. May not be same as dump's dump-level. This * value gets incremented everytime the volume is found on a dump. */ voldumplevel = 0; /* Do from level 0 dump to highest level dump */ - for (lv=(lvl-1); lv>=0; lv--) - { - foundvolume = 0; /* If found volume on this dump */ - tapeid = (dlevels[lv].initialDumpId ? dlevels[lv].initialDumpId : - dlevels[lv].DumpId); - - /* Cycle through the volume fragments for this volume on the tape */ - for (last=0,c=0; last>=0; last=next,c++) - { - code = bcdb_FindVolumes(dlevels[lv].DumpId, vi->volname, volumeEntries, - last, &next, MAXTAPESATONCE, &vecount); - if (code) - { - /* Volume wasn't found on the tape - so continue. + for (lv = (lvl - 1); lv >= 0; lv--) { + foundvolume = 0; /* If found volume on this dump */ + tapeid = + (dlevels[lv].initialDumpId ? dlevels[lv]. + initialDumpId : dlevels[lv].DumpId); + + /* Cycle through the volume fragments for this volume on the tape */ + for (last = 0, c = 0; last >= 0; last = next, c++) { + code = + bcdb_FindVolumes(dlevels[lv].DumpId, vi->volname, + volumeEntries, last, &next, + MAXTAPESATONCE, &vecount); + if (code) { + /* Volume wasn't found on the tape - so continue. * This can happen when volume doesn't exist during level 0 dump * but exists for incremental dump. */ - if (code == BUDB_ENDOFLIST) - { + if (code == BUDB_ENDOFLIST) { code = 0; break; } - com_err(whoami, code, "; Can't find volume %s in DumpID %u", + com_err(whoami, code, + "; Can't find volume %s in DumpID %u", vi->volname, dlevels[lv].DumpId); ERROR(code); } - + /* If we have made the Findvolumes call more than once for the same * volume, then begin the search at the top. This sort assumes that * we are collecting information from lowest level dump (full dump) @@ -408,9 +392,8 @@ bc_Restorer(aindex) * there is more than one call to FindVolumes, this is not true * anymore. */ - if (c) - { - tle = tapeList; + if (c) { + tle = tapeList; ptle = 0; tlid = 0; } @@ -419,16 +402,16 @@ bc_Restorer(aindex) * the list of tapes they are on. Sort by tapeid, then tape sequence. * Do from first fragment (where volume begins) to last fragment. */ - for (ve=(vecount-1); ve>=0; ve--) - { - foundvolume = 1; /* Found the volume on this dump */ + for (ve = (vecount - 1); ve >= 0; ve--) { + foundvolume = 1; /* Found the volume on this dump */ foundtape = 0; - tapeseq = volumeEntries[ve].tapeSeq; + tapeseq = volumeEntries[ve].tapeSeq; - /* Determine where in the list of tapes this should go */ - for (; tle; ptle=tle, tle=tle->next) - { - tid = (tle->initialDumpID ? tle->initialDumpID : tle->dumpID); + /* Determine where in the list of tapes this should go */ + for (; tle; ptle = tle, tle = tle->next) { + tid = + (tle->initialDumpID ? tle-> + initialDumpID : tle->dumpID); /* Sort by tapeids. BUT, we don't want add an entry in the middle * of a dumpset (might split a volume fragmented across tapes). @@ -437,179 +420,186 @@ bc_Restorer(aindex) * incremental was appended to a tape created prior its parent- * dump's tape, and needs to be restored after it. */ - if (tapeid < tid) - { - if (tlid != tid) - { tle = 0; break; } /* Allocate and insert a tape entry */ + if (tapeid < tid) { + if (tlid != tid) { + tle = 0; + break; + } /* Allocate and insert a tape entry */ } /* Found the tapeid (the dumpset). Check if its the correct * tape sequence */ - else if (tapeid == tid) - { - if (tapeseq < tle->tapeNumber) - { tle = 0; break; } /* Allocate and insert a tape entry */ - - if (tapeseq == tle->tapeNumber) - { break; } /* Don't allocate tape entry */ - - foundtape = 1; /* Found dumpset but not the tape */ + else if (tapeid == tid) { + if (tapeseq < tle->tapeNumber) { + tle = 0; + break; + } + /* Allocate and insert a tape entry */ + if (tapeseq == tle->tapeNumber) { + break; + } + /* Don't allocate tape entry */ + foundtape = 1; /* Found dumpset but not the tape */ } /* Prevously found the tapeid (the dumpset) but this tape * sequence not included (the tapeid has changed). So add * this tape entry to the end of its dumpset. */ - else if (foundtape) - { tle = 0; break; } /* Allocate and insert a tape entry */ - + else if (foundtape) { + tle = 0; + break; + } + /* Allocate and insert a tape entry */ } /* Allocate a new tapelist entry if one not found */ - if (!tle) - { - tle = (struct bc_tapeList *) malloc(sizeof(struct bc_tapeList)); - if (!tle) - { - com_err(whoami,BC_NOMEM,""); - return(BC_NOMEM); + if (!tle) { + tle = (struct bc_tapeList *) + malloc(sizeof(struct bc_tapeList)); + if (!tle) { + com_err(whoami, BC_NOMEM, ""); + return (BC_NOMEM); } memset(tle, 0, sizeof(struct bc_tapeList)); - tle->tapeName = (char*)malloc(strlen(volumeEntries[ve].tape)+1); - if (!tle->tapeName) - { - free(tle); - com_err(whoami,BC_NOMEM,""); - return(BC_NOMEM); + tle->tapeName = + (char *)malloc(strlen(volumeEntries[ve].tape) + + 1); + if (!tle->tapeName) { + free(tle); + com_err(whoami, BC_NOMEM, ""); + return (BC_NOMEM); } strcpy(tle->tapeName, volumeEntries[ve].tape); - tle->dumpID = dlevels[lv].DumpId; + tle->dumpID = dlevels[lv].DumpId; tle->initialDumpID = dlevels[lv].initialDumpId; - tle->tapeNumber = tapeseq; + tle->tapeNumber = tapeseq; /* Now thread the tape onto the list */ - if (!ptle) - { - tle->next = tapeList; + if (!ptle) { + tle->next = tapeList; tapeList = tle; - } - else - { - tle->next = ptle->next; + } else { + tle->next = ptle->next; ptle->next = tle; } } - tlid = (tle->initialDumpID ? tle->initialDumpID : tle->dumpID); + tlid = + (tle->initialDumpID ? tle->initialDumpID : tle-> + dumpID); /* Now place the volume fragment into the correct position on * this tapelist entry. Duplicate entries are ignored. */ - for (pti = 0, ti=tle->restoreList; ti; pti=ti, ti=ti->next) - { - if (volumeEntries[ve].position < ti->position) - { ti = 0; break; } /* Allocate an entry */ - - else if (volumeEntries[ve].position == ti->position) - { break; } /* Duplicate entry */ + for (pti = 0, ti = tle->restoreList; ti; + pti = ti, ti = ti->next) { + if (volumeEntries[ve].position < ti->position) { + ti = 0; + break; + } + /* Allocate an entry */ + else if (volumeEntries[ve].position == + ti->position) { + break; + } /* Duplicate entry */ } /* If didn't find one, allocate and thread onto list. * Remember the server and partition. */ - if (!ti) - { - ti = (struct bc_tapeItem *) malloc(sizeof(struct bc_tapeItem)); - if (!ti) - { - com_err(whoami,BC_NOMEM,""); - return(BC_NOMEM); + if (!ti) { + ti = (struct bc_tapeItem *) + malloc(sizeof(struct bc_tapeItem)); + if (!ti) { + com_err(whoami, BC_NOMEM, ""); + return (BC_NOMEM); } memset(ti, 0, sizeof(struct bc_tapeItem)); - ti->volumeName = (char*)malloc(strlen(volumeEntries[ve].name)+1); - if (!ti->volumeName) - { - free(ti); - com_err(whoami,BC_NOMEM,""); - return(BC_NOMEM); + ti->volumeName = + (char *)malloc(strlen(volumeEntries[ve].name) + + 1); + if (!ti->volumeName) { + free(ti); + com_err(whoami, BC_NOMEM, ""); + return (BC_NOMEM); } strcpy(ti->volumeName, volumeEntries[ve].name); - ti->server = vi->server; + ti->server = vi->server; ti->partition = vi->partition; - ti->oid = volumeEntries[ve].id; - ti->position = volumeEntries[ve].position; - ti->vollevel = voldumplevel; + ti->oid = volumeEntries[ve].id; + ti->position = volumeEntries[ve].position; + ti->vollevel = voldumplevel; ti->dumplevel = dlevels[lv].level; - ti->lastdump = ((lv == 0) ? 1 : 0); + ti->lastdump = ((lv == 0) ? 1 : 0); - if (!pti) - { - ti->next = tle->restoreList; - tle->restoreList = ti; - } - else - { - ti->next = pti->next; + if (!pti) { + ti->next = tle->restoreList; + tle->restoreList = ti; + } else { + ti->next = pti->next; pti->next = ti; } nentries++; - } /* !ti */ - } /* ve: for each returned volume fragment by bcdb_FindVolumes() */ - } /* last: Multiple calls to bcdb_FindVolumes() */ - - if (foundvolume) voldumplevel++; - } /* lv: For each dump level */ - } /* vi: For each volume to search for in the dump hierarchy */ - } /* di: For each dump */ - - if (!nentries) - { - com_err(whoami, 0, "No volumes to restore"); + } /* !ti */ + } /* ve: for each returned volume fragment by bcdb_FindVolumes() */ + } /* last: Multiple calls to bcdb_FindVolumes() */ + + if (foundvolume) + voldumplevel++; + } /* lv: For each dump level */ + } /* vi: For each volume to search for in the dump hierarchy */ + } /* di: For each dump */ + + if (!nentries) { + com_err(whoami, 0, "No volumes to restore"); ERROR(0); } - if (dumpTaskPtr->dontExecute) - { - for (tle=tapeList; tle; tle=tle->next) - { - for (ti=tle->restoreList; ti; ti=ti->next) - { - tapedumpid = (tle->initialDumpID ? tle->initialDumpID : tle->dumpID); + if (dumpTaskPtr->dontExecute) { + for (tle = tapeList; tle; tle = tle->next) { + for (ti = tle->restoreList; ti; ti = ti->next) { + tapedumpid = + (tle->initialDumpID ? tle->initialDumpID : tle->dumpID); strcpy(vname, ti->volumeName); StripBackup(vname); - if (dumpTaskPtr->newExt) strcat(vname, dumpTaskPtr->newExt); + if (dumpTaskPtr->newExt) + strcat(vname, dumpTaskPtr->newExt); /* print volume to restore and the tape and position its on */ - if (serverAll) - { - printf("Restore volume %s (ID %d) from tape %s (%u), position %d", - ti->volumeName, ti->oid, tle->tapeName, tapedumpid, ti->position); + if (serverAll) { + printf + ("Restore volume %s (ID %d) from tape %s (%u), position %d", + ti->volumeName, ti->oid, tle->tapeName, tapedumpid, + ti->position); if (strcmp(ti->volumeName, vname) != 0) - printf(" as %s", vname); + printf(" as %s", vname); printf(".\n"); } /* print in format recognized by volsetrestore */ - else - { + else { haddr = ti->server; - hostPtr = gethostbyaddr((char *) &haddr, sizeof(haddr), AF_INET); - if (hostPtr) printf("%s", hostPtr->h_name); - else printf("%u", ti->server); - + hostPtr = + gethostbyaddr((char *)&haddr, sizeof(haddr), AF_INET); + if (hostPtr) + printf("%s", hostPtr->h_name); + else + printf("%u", ti->server); + printf(" /vicep"); viceName(ti->partition); - printf(" %s # as %s; %s (%u); pos %d;", - ti->volumeName, vname, tle->tapeName, tapedumpid, ti->position); - + printf(" %s # as %s; %s (%u); pos %d;", ti->volumeName, + vname, tle->tapeName, tapedumpid, ti->position); + did = tle->dumpID; printf(" %s", ctime(&did)); } @@ -620,40 +610,40 @@ bc_Restorer(aindex) } /* Allocate a list of volumes to restore */ - tcarray = (struct tc_restoreDesc *) malloc(nentries*sizeof(struct tc_restoreDesc)); - if (!tcarray) - { - com_err(whoami,BC_NOMEM,""); + tcarray = + (struct tc_restoreDesc *)malloc(nentries * + sizeof(struct tc_restoreDesc)); + if (!tcarray) { + com_err(whoami, BC_NOMEM, ""); ERROR(BC_NOMEM); } - memset(tcarray, 0, nentries*sizeof(struct tc_restoreDesc)); + memset(tcarray, 0, nentries * sizeof(struct tc_restoreDesc)); /* Fill in the array with the list above */ i = 0; - for (tle=tapeList; tle; tle=tle->next) - { - for (ti=tle->restoreList; ti; ti=ti->next) - { - tcarray[i].origVid = ti->oid; /* means unknown */ - tcarray[i].vid = 0; - tcarray[i].flags = 0; + for (tle = tapeList; tle; tle = tle->next) { + for (ti = tle->restoreList; ti; ti = ti->next) { + tcarray[i].origVid = ti->oid; /* means unknown */ + tcarray[i].vid = 0; + tcarray[i].flags = 0; if (ti->vollevel == 0) - tcarray[i].flags |= RDFLAG_FIRSTDUMP; + tcarray[i].flags |= RDFLAG_FIRSTDUMP; if (ti->lastdump) - tcarray[i].flags |= RDFLAG_LASTDUMP; - tcarray[i].position = ti->position; - tcarray[i].dbDumpId = tle->dumpID; + tcarray[i].flags |= RDFLAG_LASTDUMP; + tcarray[i].position = ti->position; + tcarray[i].dbDumpId = tle->dumpID; tcarray[i].initialDumpId = tle->initialDumpID; - tcarray[i].hostAddr = ti->server; /* just the internet address */ - tcarray[i].partition = ti->partition; + tcarray[i].hostAddr = ti->server; /* just the internet address */ + tcarray[i].partition = ti->partition; strcpy(tcarray[i].tapeName, tle->tapeName); - strcpy(tcarray[i].oldName, ti->volumeName); - strcpy(tcarray[i].newName, ti->volumeName); + strcpy(tcarray[i].oldName, ti->volumeName); + strcpy(tcarray[i].newName, ti->volumeName); StripBackup(tcarray[i].newName); - if (dumpTaskPtr->newExt) strcat(tcarray[i].newName, dumpTaskPtr->newExt); + if (dumpTaskPtr->newExt) + strcat(tcarray[i].newName, dumpTaskPtr->newExt); - tcarray[i].dumpLevel = ti->dumplevel; + tcarray[i].dumpLevel = ti->dumplevel; i++; } } @@ -661,31 +651,31 @@ bc_Restorer(aindex) printf("Starting restore\n"); /* Loop until all of the tape entries are used */ - for (startentry=0; startentryportCount == 0) - { - port = 0; + if (dumpTaskPtr->portCount == 0) { + port = 0; todump = nentries - startentry; - } - else if (dumpTaskPtr->portCount == 1) - { - port = dumpTaskPtr->portOffset[0]; + } else if (dumpTaskPtr->portCount == 1) { + port = dumpTaskPtr->portOffset[0]; todump = nentries - startentry; - } - else - { + } else { level = tcarray[startentry].dumpLevel; - port = dumpTaskPtr->portOffset[(level <= dumpTaskPtr->portCount-1 ? - level : dumpTaskPtr->portCount-1)]; - - for (todump=1; ((startentry+todump) < nentries); todump++) - { - level = tcarray[startentry+todump].dumpLevel; - nextport = dumpTaskPtr->portOffset[(level <= dumpTaskPtr->portCount-1 ? - level : dumpTaskPtr->portCount-1)]; - if (port != nextport) break; /* break if we change ports */ + port = + dumpTaskPtr-> + portOffset[(level <= + dumpTaskPtr->portCount - + 1 ? level : dumpTaskPtr->portCount - 1)]; + + for (todump = 1; ((startentry + todump) < nentries); todump++) { + level = tcarray[startentry + todump].dumpLevel; + nextport = + dumpTaskPtr-> + portOffset[(level <= + dumpTaskPtr->portCount - + 1 ? level : dumpTaskPtr->portCount - 1)]; + if (port != nextport) + break; /* break if we change ports */ } } @@ -693,27 +683,30 @@ bc_Restorer(aindex) rpcArray.tc_restoreArray_val = &tcarray[startentry]; code = ConnectButc(dumpTaskPtr->config, port, &aconn); - if (code) return(code); - + if (code) + return (code); + if (tcarray[startentry].dumpLevel == 0) printf("\nFull restore being processed on port %d\n", port); else - printf("\nIncremental restore being processed on port %d\n", port); - - code = TC_PerformRestore(aconn, "DumpSetName", &rpcArray, &dumpTaskPtr->dumpID); - if (code) - { - com_err(whoami,code,"; Failed to start restore"); + printf("\nIncremental restore being processed on port %d\n", + port); + + code = + TC_PerformRestore(aconn, "DumpSetName", &rpcArray, + &dumpTaskPtr->dumpID); + if (code) { + com_err(whoami, code, "; Failed to start restore"); break; } /* setup status monitor node */ statusPtr = createStatusNode(); lock_Status(); - statusPtr->port = port; - statusPtr->taskId = dumpTaskPtr->dumpID; - statusPtr->jobNumber = bc_jobNumber(); - statusPtr->flags &= ~STARTING; /* clearStatus to examine */ + statusPtr->port = port; + statusPtr->taskId = dumpTaskPtr->dumpID; + statusPtr->jobNumber = bc_jobNumber(); + statusPtr->flags &= ~STARTING; /* clearStatus to examine */ if (tcarray[startentry].dumpLevel == 0) sprintf(statusPtr->taskName, "Full Restore"); else @@ -723,18 +716,16 @@ bc_Restorer(aindex) /* Wait until this restore pass is complete before starting the next * pass. Query the statusWatcher for the status */ - while (1) - { + while (1) { lock_Status(); newStatusPtr = findStatus(dumpTaskPtr->dumpID); - if (!newStatusPtr || (newStatusPtr->flags & - (ABORT_REQUEST|ABORT_SENT|ABORT_DONE|TASK_ERROR)) ) - { - unlock_Status(); + if (!newStatusPtr + || (newStatusPtr-> + flags & (ABORT_REQUEST | ABORT_SENT | ABORT_DONE | + TASK_ERROR))) { + unlock_Status(); ERROR(0); - } - else if (newStatusPtr->flags & (TASK_DONE)) - { + } else if (newStatusPtr->flags & (TASK_DONE)) { unlock_Status(); break; } @@ -743,45 +734,48 @@ bc_Restorer(aindex) IOMGR_Sleep(2); } - if (aconn) rx_DestroyConnection(aconn); + if (aconn) + rx_DestroyConnection(aconn); aconn = (struct rx_connection *)0; - } /* while */ + } /* while */ /* free up everything */ error_exit: - if (aconn) rx_DestroyConnection(aconn); + if (aconn) + rx_DestroyConnection(aconn); - if (tcarray) free(tcarray); + if (tcarray) + free(tcarray); /* Free the dumpinfo list and its volumes */ - for (di=dumpinfolist; di; di=ndi) - { - for (vi=di->volinfolist; vi; vi=nvi) - { - if (vi->volname) free(vi->volname); + for (di = dumpinfolist; di; di = ndi) { + for (vi = di->volinfolist; vi; vi = nvi) { + if (vi->volname) + free(vi->volname); nvi = vi->next; free(vi); } - ndi = di->next; + ndi = di->next; free(di); } /* Free the tape lists and items */ - for (tle = tapeList; tle; tle=ntle) - { - for(ti = tle->restoreList; ti; ti = nti) - { + for (tle = tapeList; tle; tle = ntle) { + for (ti = tle->restoreList; ti; ti = nti) { nti = ti->next; - if (ti->volumeName) free(ti->volumeName); + if (ti->volumeName) + free(ti->volumeName); free(ti); } ntle = tle->next; - if (tle->tapeName) free(tle->tapeName); + if (tle->tapeName) + free(tle->tapeName); free(tle); } /* free local-like things we alloacted to save stack space */ - if (volumeEntries) free(volumeEntries); + if (volumeEntries) + free(volumeEntries); return code; } diff --git a/src/bucoord/server.c b/src/bucoord/server.c index d71bad131..b7672ec89 100644 --- a/src/bucoord/server.c +++ b/src/bucoord/server.c @@ -11,7 +11,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -22,12 +23,13 @@ RCSID("$Header$"); /* services available on incoming message port */ BC_Print(acall, acode, aflags, amessage) -struct rx_call *acall; -afs_int32 acode, aflags; -char *amessage; { + struct rx_call *acall; + afs_int32 acode, aflags; + char *amessage; +{ struct rx_connection *tconn; struct rx_peer *tpeer; - + tconn = rx_ConnectionOf(acall); tpeer = rx_PeerOf(tconn); printf("From %08x: %s <%d>\n", tpeer->host, amessage, acode); diff --git a/src/bucoord/status.c b/src/bucoord/status.c index 314e57e61..61570ecc0 100644 --- a/src/bucoord/status.c +++ b/src/bucoord/status.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -30,9 +31,9 @@ RCSID("$Header$"); #include "error_macros.h" -extern dlqlinkT statusHead; /* chain of status blocks */ +extern dlqlinkT statusHead; /* chain of status blocks */ extern struct Lock statusQueueLock; /* access control for status chain */ -extern struct Lock cmdLineLock; /* lock on the cmdLine */ +extern struct Lock cmdLineLock; /* lock on the cmdLine */ /* task status management * @@ -74,21 +75,20 @@ clearStatus(taskId, flags) afs_uint32 taskId; afs_uint32 flags; { - statusP ptr; + statusP ptr; - extern statusP findStatus(); + extern statusP findStatus(); - ObtainWriteLock(&statusQueueLock); - ptr = findStatus(taskId); - if ( ptr == 0 ) - { - ReleaseWriteLock(&statusQueueLock); - return; - } + ObtainWriteLock(&statusQueueLock); + ptr = findStatus(taskId); + if (ptr == 0) { + ReleaseWriteLock(&statusQueueLock); + return; + } - ptr->flags &= ~flags; - ReleaseWriteLock(&statusQueueLock); - } + ptr->flags &= ~flags; + ReleaseWriteLock(&statusQueueLock); +} statusP createStatusNode() @@ -96,9 +96,8 @@ createStatusNode() statusP ptr; ptr = (statusP) malloc(sizeof(*ptr)); - if ( ptr == 0 ) - { - return(0); + if (ptr == 0) { + return (0); } memset(ptr, 0, sizeof(*ptr)); @@ -108,17 +107,17 @@ createStatusNode() ptr->flags = STARTING; ReleaseWriteLock(&statusQueueLock); - return(ptr); + return (ptr); } deleteStatusNode(ptr) statusP ptr; { ObtainWriteLock(&statusQueueLock); - dlqUnlink( (dlqlinkP) ptr); + dlqUnlink((dlqlinkP) ptr); if (ptr->cmdLine) - free(ptr->cmdLine); + free(ptr->cmdLine); free(ptr); ReleaseWriteLock(&statusQueueLock); } @@ -131,34 +130,30 @@ findStatus(taskId) dlqlinkP dlqPtr; dlqPtr = statusHead.dlq_next; - while ( dlqPtr != &statusHead ) - { - if ( ((statusP) dlqPtr)->taskId == taskId ) - { - ptr = (statusP) dlqPtr; - break; - } - dlqPtr = dlqPtr->dlq_next; + while (dlqPtr != &statusHead) { + if (((statusP) dlqPtr)->taskId == taskId) { + ptr = (statusP) dlqPtr; + break; + } + dlqPtr = dlqPtr->dlq_next; } - return(ptr); + return (ptr); } setStatus(taskId, flags) afs_uint32 taskId; afs_uint32 flags; { - statusP ptr; + statusP ptr; - ObtainWriteLock(&statusQueueLock); - ptr = findStatus(taskId); - if ( ptr == 0 ) - { - ReleaseWriteLock(&statusQueueLock); - return; - } + ObtainWriteLock(&statusQueueLock); + ptr = findStatus(taskId); + if (ptr == 0) { + ReleaseWriteLock(&statusQueueLock); + return; + } - ptr->flags |= flags; - ReleaseWriteLock(&statusQueueLock); + ptr->flags |= flags; + ReleaseWriteLock(&statusQueueLock); } - diff --git a/src/bucoord/tape_hosts.c b/src/bucoord/tape_hosts.c index af1396627..3a75a3da9 100644 --- a/src/bucoord/tape_hosts.c +++ b/src/bucoord/tape_hosts.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -49,7 +50,8 @@ extern char *whoami; * Add a host to the tape hosts */ -afs_int32 bc_AddHostCmd(as, arock) +afs_int32 +bc_AddHostCmd(as, arock) struct cmd_syndesc *as; char *arock; { @@ -60,38 +62,39 @@ afs_int32 bc_AddHostCmd(as, arock) ctPtr = &bc_globalConfig->configText[TB_TAPEHOSTS]; code = bc_LockText(ctPtr); - if ( code ) - ERROR(code); + if (code) + ERROR(code); code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } /* add tape hosts first */ ti = as->parms[0].items; if (ti) { if (as->parms[1].items) { - port = getPortOffset(as->parms[1].items->data); - if (port < 0) ERROR(BC_BADARG); + port = getPortOffset(as->parms[1].items->data); + if (port < 0) + ERROR(BC_BADARG); } - printf("Adding host %s offset %u to tape list...", ti->data,port); + printf("Adding host %s offset %u to tape list...", ti->data, port); fflush(stdout); code = bc_AddTapeHost(bc_globalConfig, ti->data, port); - if (code) - { - printf("failed\n"); fflush(stdout); - if (code == EEXIST) - com_err(whoami,0,"Port offset already in tape database"); + if (code) { + printf("failed\n"); + fflush(stdout); + if (code == EEXIST) + com_err(whoami, 0, "Port offset already in tape database"); ERROR(code); } code = bc_SaveHosts(); - if ( code ) - { + if (code) { com_err(whoami, code, "Cannot save tape hosts"); - com_err(whoami, 0,"Changes are temporary - for this session only"); + com_err(whoami, 0, + "Changes are temporary - for this session only"); ERROR(code); } } @@ -99,15 +102,16 @@ afs_int32 bc_AddHostCmd(as, arock) /* done */ printf("done\n"); -error_exit: - if ( ctPtr->lockHandle != 0 ) - bc_UnlockText(ctPtr); - return(code); + error_exit: + if (ctPtr->lockHandle != 0) + bc_UnlockText(ctPtr); + return (code); } - -afs_int32 bc_DeleteHostCmd(as, arock) + +afs_int32 +bc_DeleteHostCmd(as, arock) struct cmd_syndesc *as; - char *arock; + char *arock; { struct cmd_item *ti; afs_int32 port = 0; @@ -116,41 +120,41 @@ afs_int32 bc_DeleteHostCmd(as, arock) ctPtr = &bc_globalConfig->configText[TB_TAPEHOSTS]; code = bc_LockText(ctPtr); - if ( code ) - ERROR(code); + if (code) + ERROR(code); code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } /* delete tape hosts first */ ti = as->parms[0].items; if (ti) { - if (as->parms[1].items) { - port = bc_SafeATOI(as->parms[1].items->data); - if (port < 0) return(BC_BADARG); + if (as->parms[1].items) { + port = bc_SafeATOI(as->parms[1].items->data); + if (port < 0) + return (BC_BADARG); } - printf("Deleting host %s offset %u to tape list...", ti->data,port); + printf("Deleting host %s offset %u to tape list...", ti->data, port); fflush(stdout); - code = bc_DeleteTapeHost(bc_globalConfig, ti->data,port); - if (code) - { + code = bc_DeleteTapeHost(bc_globalConfig, ti->data, port); + if (code) { if (code == ENOENT) - printf("failed: no such host entry\n"); + printf("failed: no such host entry\n"); else - printf("failed with code %d\n", code); + printf("failed with code %d\n", code); ERROR(code); } code = bc_SaveHosts(); - if ( code ) - { + if (code) { com_err(whoami, code, "Cannot save tape hosts"); - com_err(whoami, 0,"Changes are temporary - for this session only"); - ERROR(code); + com_err(whoami, 0, + "Changes are temporary - for this session only"); + ERROR(code); } } @@ -158,10 +162,10 @@ afs_int32 bc_DeleteHostCmd(as, arock) printf("done\n"); fflush(stdout); -error_exit: - if ( ctPtr->lockHandle != 0 ) - bc_UnlockText(ctPtr); - return(code); + error_exit: + if (ctPtr->lockHandle != 0) + bc_UnlockText(ctPtr); + return (code); } @@ -171,24 +175,24 @@ error_exit: * ignored */ -afs_int32 bc_ListHostsCmd(as, arock) +afs_int32 +bc_ListHostsCmd(as, arock) struct cmd_syndesc *as; - char *arock; + char *arock; { afs_int32 code; register struct bc_hostEntry *tentry; code = bc_UpdateHosts(); if (code) { - com_err(whoami, code, "; Can't retrieve tape hosts"); - return(code); + com_err(whoami, code, "; Can't retrieve tape hosts"); + return (code); } printf("Tape hosts:\n"); - for ( tentry = bc_globalConfig->tapeHosts; tentry; tentry = tentry->next ) - { - printf(" Host %s, port offset %u\n", - tentry->name,tentry->portOffset); + for (tentry = bc_globalConfig->tapeHosts; tentry; tentry = tentry->next) { + printf(" Host %s, port offset %u\n", tentry->name, + tentry->portOffset); } fflush(stdout); return 0; @@ -206,16 +210,15 @@ bc_ClearHosts() register struct bc_hostEntry *tentry, *temp; tentry = bc_globalConfig->tapeHosts; - while ( tentry != 0 ) - { + while (tentry != 0) { temp = tentry->next; free(tentry->name); free(tentry); tentry = temp; } - bc_globalConfig->tapeHosts = (struct bc_hostEntry *) 0; - return(0); + bc_globalConfig->tapeHosts = (struct bc_hostEntry *)0; + return (0); } /* bc_ParseHosts @@ -226,7 +229,8 @@ bc_ClearHosts() * -1 otherwise. */ -int bc_ParseHosts() +int +bc_ParseHosts() { char tbuffer[256]; char hostName[256]; @@ -242,45 +246,41 @@ int bc_ParseHosts() ctPtr = &bc_globalConfig->configText[TB_TAPEHOSTS]; stream = ctPtr->textStream; - if ( ctPtr->textSize == 0 ) /* nothing defined yet */ - return(0); + if (ctPtr->textSize == 0) /* nothing defined yet */ + return (0); - if ( stream == NULL ) - return(BC_INTERNALERROR); + if (stream == NULL) + return (BC_INTERNALERROR); rewind(stream); /* now read the lines and build the structure list */ - tfirst = tlast = (struct bc_hostEntry *) 0; + tfirst = tlast = (struct bc_hostEntry *)0; - while(1) - { + while (1) { tp = fgets(tbuffer, sizeof(tbuffer), stream); if (!tp) - break; /* end of file */ + break; /* end of file */ sscanf(tbuffer, "%s %u", hostName, &port); th = gethostbyname(hostName); - if ( th == 0 ) - { - com_err(whoami,0,"can't get host info for %s from nameserver or /etc/hosts.", + if (th == 0) { + com_err(whoami, 0, + "can't get host info for %s from nameserver or /etc/hosts.", hostName); } - the = (struct bc_hostEntry *) malloc(sizeof(struct bc_hostEntry)); + the = (struct bc_hostEntry *)malloc(sizeof(struct bc_hostEntry)); if (the == (struct bc_hostEntry *)0) return (BC_NOMEM); memset(the, 0, sizeof(struct bc_hostEntry)); - if (tlast) - { + if (tlast) { tlast->next = the; tlast = the; - } - else - { + } else { tfirst = tlast = the; } - the->next = (struct bc_hostEntry *) 0; - the->name = (char *) malloc(strlen(hostName)+1); + the->next = (struct bc_hostEntry *)0; + the->name = (char *)malloc(strlen(hostName) + 1); strcpy(the->name, hostName); the->portOffset = port; if (th) { @@ -317,31 +317,30 @@ bc_SaveHosts() stream = ctPtr->textStream; /* must be locked */ - if ( ctPtr->lockHandle == 0 ) - return(BC_INTERNALERROR); + if (ctPtr->lockHandle == 0) + return (BC_INTERNALERROR); /* truncate the file */ code = ftruncate(fileno(stream), 0); - if ( code ) - ERROR(errno); + if (code) + ERROR(errno); rewind(stream); hePtr = bc_globalConfig->tapeHosts; - while ( hePtr != 0 ) - { + while (hePtr != 0) { fprintf(stream, "%s %u\n", hePtr->name, hePtr->portOffset); - hePtr = hePtr->next; + hePtr = hePtr->next; } - if (ferror(stream)) - return(BC_INTERNALERROR); + if (ferror(stream)) + return (BC_INTERNALERROR); /* send to server */ code = bcdb_SaveTextFile(ctPtr); - if ( code ) - ERROR(code); + if (code) + ERROR(code); /* do this on bcdb_SaveTextFile */ /* increment local version number */ @@ -350,64 +349,66 @@ bc_SaveHosts() /* update locally stored file size */ ctPtr->textSize = filesize(ctPtr->textStream); -error_exit: - return(code); + error_exit: + return (code); } -afs_int32 bc_UpdateHosts() +afs_int32 +bc_UpdateHosts() { struct udbHandleS *uhptr = &udbHandle; udbClientTextP ctPtr; afs_int32 code; - int lock=0; + int lock = 0; /* lock schedules and check validity */ ctPtr = &bc_globalConfig->configText[TB_TAPEHOSTS]; code = bc_CheckTextVersion(ctPtr); - if ( code != BC_VERSIONMISMATCH ) - { - ERROR(code); /* Version matches or some other error */ + if (code != BC_VERSIONMISMATCH) { + ERROR(code); /* Version matches or some other error */ } /* Must update the hosts */ /* If we are not already locked, then lock it now */ - if ( ctPtr->lockHandle == 0 ) { - code = bc_LockText(ctPtr); - if ( code ) - ERROR(code); + if (ctPtr->lockHandle == 0) { + code = bc_LockText(ctPtr); + if (code) + ERROR(code); lock = 1; } - if (ctPtr->textVersion != -1) - { - com_err(whoami,0,"obsolete tapehosts - updating"); - bc_ClearHosts(); + if (ctPtr->textVersion != -1) { + com_err(whoami, 0, "obsolete tapehosts - updating"); + bc_ClearHosts(); } /* open a temp file to store the config text received from buserver * * The open file stream is stored in ctPtr->textStream */ - code = bc_openTextFile(ctPtr, &bc_globalConfig->tmpTextFileNames[TB_TAPEHOSTS][0]); - if ( code ) - ERROR(code); + code = + bc_openTextFile(ctPtr, + &bc_globalConfig->tmpTextFileNames[TB_TAPEHOSTS][0]); + if (code) + ERROR(code); /* now get a fresh set of information from the database */ code = bcdb_GetTextFile(ctPtr); - if ( code ) - ERROR(code); + if (code) + ERROR(code); - /* fetch the version number */ - code = ubik_Call(BUDB_GetTextVersion, uhptr->uh_client, 0, - ctPtr->textType, &ctPtr->textVersion); - if ( code ) + /* fetch the version number */ + code = + ubik_Call(BUDB_GetTextVersion, uhptr->uh_client, 0, ctPtr->textType, + &ctPtr->textVersion); + if (code) ERROR(code); /* parse the file */ code = bc_ParseHosts(); - if ( code ) - ERROR(code); + if (code) + ERROR(code); -error_exit: - if ( lock && ctPtr->lockHandle ) + error_exit: + if (lock && ctPtr->lockHandle) bc_UnlockText(ctPtr); - return(code); + return (code); } diff --git a/src/bucoord/ttest.c b/src/bucoord/ttest.c index 1bcd8235e..e1177430f 100644 --- a/src/bucoord/ttest.c +++ b/src/bucoord/ttest.c @@ -24,25 +24,25 @@ extern TC_ExecuteRequest(); /* dump information */ -static afs_int32 transID = 1000; /* dump or restore transaction id */ -static afs_int32 bytesDumped=0; +static afs_int32 transID = 1000; /* dump or restore transaction id */ +static afs_int32 bytesDumped = 0; #include "AFS_component_version_number.c" main(argc, argv) -int argc; -char **argv; { + int argc; + char **argv; +{ register int i; register afs_int32 code; register struct rx_service *tservice; struct rx_securityClass *rxsc[1]; - - for(i=1;iformat); @@ -96,10 +100,10 @@ afs_int32 *adumpID; { tdentry.level = alevel; tdentry.incTime = 0; /* useless? */ tdentry.nVolumes = 1000000000; /* bogus, but not important */ - tdentry.tapes.a = 1; /* a*x+b is tape numbering scheme */ + tdentry.tapes.a = 1; /* a*x+b is tape numbering scheme */ tdentry.tapes.b = 0; tdentry.tapes.maxTapes = 1000000000; /* don't care */ - strcpy(tdentry.tapes.format, atapeSet->format); /* base name (e.g. sys) */ + strcpy(tdentry.tapes.format, atapeSet->format); /* base name (e.g. sys) */ strcat(tdentry.tapes.format, "."); strcat(tdentry.tapes.format, adumpName); /* e.g. .daily */ strcat(tdentry.tapes.format, ".%d"); /* so we get basename.0, basename.1, etc */ @@ -114,21 +118,23 @@ afs_int32 *adumpID; { memset(&ttentry, 0, sizeof(ttentry)); sprintf(ttentry.name, tdentry.tapes.format, 1); ttentry.written = time(0); - ttentry.dump = tdentry.id; /* dump we're in */ + ttentry.dump = tdentry.id; /* dump we're in */ ttentry.seq = 0; - ttentry.nVolumes = 0; /* perhaps we'll adjust during dump */ + ttentry.nVolumes = 0; /* perhaps we'll adjust during dump */ ttentry.flags = BUDB_TAPE_BEINGWRITTEN; /* starting I/O */ code = bcdb_UseTape(&ttentry, &new); if (code) { - printf("ttape: failed to start tape %s, code %d\n", ttentry.name, code); + printf("ttape: failed to start tape %s, code %d\n", ttentry.name, + code); return code; } tdescr = adumpArray->tc_dumpArray_val; - for(i=0;itc_dumpArray_len;i++, tdescr++) { + for (i = 0; i < adumpArray->tc_dumpArray_len; i++, tdescr++) { memcpy(&taddr, tdescr->hostID, sizeof(taddr)); - printf("dumping volid %s(%d) from host %08x since date %d\n", tdescr->name, - tdescr->vid, taddr.sin_addr.s_addr, tdescr->date); + printf("dumping volid %s(%d) from host %08x since date %d\n", + tdescr->name, tdescr->vid, taddr.sin_addr.s_addr, + tdescr->date); memset(&tventry, 0, sizeof(tventry)); strcpy(tventry.name, tdescr->name); tventry.clone = tdescr->date; @@ -141,7 +147,8 @@ afs_int32 *adumpID; { tventry.flags = (BUDB_VOL_LASTFRAG | BUDB_VOL_FIRSTFRAG); code = bcdb_AddVolume(&tventry); if (code) { - printf("failed to append volume entry for volume %d, code %d\n", tdescr->vid, code); + printf("failed to append volume entry for volume %d, code %d\n", + tdescr->vid, code); return code; } } @@ -163,21 +170,24 @@ afs_int32 *adumpID; { } STC_PerformRestore(acall, aname, arestore, adumpID) -struct rx_call *acall; -char *aname; -struct tc_restoreArray *arestore; -afs_int32 *adumpID; { + struct rx_call *acall; + char *aname; + struct tc_restoreArray *arestore; + afs_int32 *adumpID; +{ register int i; register struct tc_restoreDesc *tdescr; struct sockaddr_in taddr; printf("tape controller received request to start restore %s.\n", aname); tdescr = arestore->tc_restoreArray_val; - for(i=0;itc_restoreArray_len; i++, tdescr++) { + for (i = 0; i < arestore->tc_restoreArray_len; i++, tdescr++) { memcpy(&taddr, tdescr->hostID, sizeof(taddr)); - printf("restoring frag %d of volume %s from tape %s at position %d.\n New name is '%s', new vid is %d, new host is %08x, new partition is %d\n", - tdescr->frag, tdescr->oldName, tdescr->tapeName, tdescr->position, tdescr->newName, - tdescr->vid, taddr.sin_addr.s_addr, tdescr->partition); + printf + ("restoring frag %d of volume %s from tape %s at position %d.\n New name is '%s', new vid is %d, new host is %08x, new partition is %d\n", + tdescr->frag, tdescr->oldName, tdescr->tapeName, + tdescr->position, tdescr->newName, tdescr->vid, + taddr.sin_addr.s_addr, tdescr->partition); } *adumpID = ++transID; bytesDumped = 0; @@ -188,36 +198,43 @@ afs_int32 *adumpID; { the status of completed dumps for a reasonable period (2 - 12 hours) so that they can be examined later */ STC_CheckDump(acall, adumpID, astatus) -struct rx_call *acall; -afs_int32 adumpID; -struct tc_dumpStat *astatus; { - if (adumpID != transID) return 2; + struct rx_call *acall; + afs_int32 adumpID; + struct tc_dumpStat *astatus; +{ + if (adumpID != transID) + return 2; astatus->dumpID = adumpID; astatus->bytesDumped = (bytesDumped += 1470); - astatus->flags =0; - if (bytesDumped > 2000) astatus->flags = TC_STAT_DONE; + astatus->flags = 0; + if (bytesDumped > 2000) + astatus->flags = TC_STAT_DONE; return 0; } STC_AbortDump(acall, adumpID) -struct rx_call *acall; -afs_int32 adumpID; { + struct rx_call *acall; + afs_int32 adumpID; +{ return 0; } /* this call waits for a dump to complete; it ties up an LWP on the tape coordinator */ -STC_WaitForDump() { +STC_WaitForDump() +{ return 1; } STC_EndDump(acall, adumpID) -struct rx_call *acall; -afs_int32 adumpID; { + struct rx_call *acall; + afs_int32 adumpID; +{ return 0; } STC_GetTMInfo(acall) -struct rx_call *acall; { + struct rx_call *acall; +{ return 0; } diff --git a/src/bucoord/ubik_db_if.c b/src/bucoord/ubik_db_if.c index dad67e1ac..a572cd3a8 100644 --- a/src/bucoord/ubik_db_if.c +++ b/src/bucoord/ubik_db_if.c @@ -12,7 +12,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -22,7 +23,7 @@ RCSID("$Header$"); #elif defined(AFS_SUN5_ENV) #include #else -#include /* for hostnames etc */ +#include /* for hostnames etc */ #endif #include #include @@ -56,21 +57,21 @@ bcdb_AddVolume(veptr) { afs_int32 code; - code = ubik_Call( BUDB_AddVolume, udbHandle.uh_client, 0, veptr); - return(code); + code = ubik_Call(BUDB_AddVolume, udbHandle.uh_client, 0, veptr); + return (code); } bcdb_AddVolumes(veptr, count) - register struct budb_volumeEntry *veptr; - afs_int32 count; + register struct budb_volumeEntry *veptr; + afs_int32 count; { - struct budb_volumeList volumeList; - afs_int32 code; + struct budb_volumeList volumeList; + afs_int32 code; - volumeList.budb_volumeList_len = count; - volumeList.budb_volumeList_val = veptr; - code = ubik_Call(BUDB_AddVolumes, udbHandle.uh_client, 0, &volumeList); - return(code); + volumeList.budb_volumeList_len = count; + volumeList.budb_volumeList_val = veptr; + code = ubik_Call(BUDB_AddVolumes, udbHandle.uh_client, 0, &volumeList); + return (code); } @@ -80,35 +81,38 @@ bcdb_CreateDump(deptr) afs_int32 code; code = ubik_Call(BUDB_CreateDump, udbHandle.uh_client, 0, deptr); - return(code); + return (code); } bcdb_deleteDump(dumpID, fromTime, toTime, dumps) - afs_int32 dumpID; - afs_int32 fromTime; - afs_int32 toTime; - budb_dumpsList *dumps; + afs_int32 dumpID; + afs_int32 fromTime; + afs_int32 toTime; + budb_dumpsList *dumps; { afs_int32 code; budb_dumpsList dumpsList, *dumpsPtr; dumpsList.budb_dumpsList_len = 0; dumpsList.budb_dumpsList_val = 0; - dumpsPtr = ( dumps ? dumps : &dumpsList ); + dumpsPtr = (dumps ? dumps : &dumpsList); - code = ubik_Call(BUDB_DeleteDump, udbHandle.uh_client, 0, dumpID, fromTime, toTime, dumpsPtr); - if (dumpsList.budb_dumpsList_val) free(dumpsList.budb_dumpsList_val); - return(code); + code = + ubik_Call(BUDB_DeleteDump, udbHandle.uh_client, 0, dumpID, fromTime, + toTime, dumpsPtr); + if (dumpsList.budb_dumpsList_val) + free(dumpsList.budb_dumpsList_val); + return (code); } bcdb_listDumps(sflags, groupId, fromTime, toTime, dumps, flags) - afs_int32 groupId; - afs_int32 fromTime; - afs_int32 toTime; - budb_dumpsList *dumps; - budb_dumpsList *flags; + afs_int32 groupId; + afs_int32 fromTime; + afs_int32 toTime; + budb_dumpsList *dumps; + budb_dumpsList *flags; { - afs_int32 code, sflag=0; + afs_int32 code, sflag = 0; budb_dumpsList dumpsList, *dumpsPtr; budb_dumpsList flagsList, *flagsPtr; @@ -120,12 +124,15 @@ bcdb_listDumps(sflags, groupId, fromTime, toTime, dumps, flags) flagsList.budb_dumpsList_val = 0; flagsPtr = (flags ? flags : &flagsList); - code = ubik_Call(BUDB_ListDumps, udbHandle.uh_client, 0, - sflags, "", groupId, fromTime, toTime, dumpsPtr, flagsPtr); + code = + ubik_Call(BUDB_ListDumps, udbHandle.uh_client, 0, sflags, "", groupId, + fromTime, toTime, dumpsPtr, flagsPtr); - if (dumpsList.budb_dumpsList_val) free(dumpsList.budb_dumpsList_val); - if (flagsList.budb_dumpsList_val) free(flagsList.budb_dumpsList_val); - return(code); + if (dumpsList.budb_dumpsList_val) + free(dumpsList.budb_dumpsList_val); + if (flagsList.budb_dumpsList_val) + free(flagsList.budb_dumpsList_val); + return (code); } @@ -136,8 +143,10 @@ bcdb_DeleteVDP(dumpSetName, dumpPath, dumpID) { afs_int32 code; - code = ubik_Call( BUDB_DeleteVDP, udbHandle.uh_client, 0, dumpSetName, dumpPath, dumpID); - return(code); + code = + ubik_Call(BUDB_DeleteVDP, udbHandle.uh_client, 0, dumpSetName, + dumpPath, dumpID); + return (code); } /* bcdb_FindClone @@ -161,8 +170,10 @@ bcdb_FindClone(dumpID, volName, clonetime) afs_int32 *clonetime; { afs_int32 code; - code = ubik_Call( BUDB_FindClone, udbHandle.uh_client, 0, dumpID, volName, clonetime); - return(code); + code = + ubik_Call(BUDB_FindClone, udbHandle.uh_client, 0, dumpID, volName, + clonetime); + return (code); } /* bcdb_FindDump @@ -188,8 +199,10 @@ bcdb_FindDump(volumeName, beforeDate, deptr) struct budb_dumpEntry *deptr; { afs_int32 code; - code = ubik_Call( BUDB_FindDump, udbHandle.uh_client, 0, volumeName, beforeDate, deptr); - return(code); + code = + ubik_Call(BUDB_FindDump, udbHandle.uh_client, 0, volumeName, + beforeDate, deptr); + return (code); } /* bcdb_FindDumpByID @@ -203,8 +216,8 @@ bcdb_FindDumpByID(dumpID, deptr) register struct budb_dumpEntry *deptr; { register afs_int32 code; - afs_int32 nextindex; - afs_int32 dbTime; + afs_int32 nextindex; + afs_int32 dbTime; budb_dumpList dl; /* initialize the dump list */ @@ -212,39 +225,32 @@ bcdb_FindDumpByID(dumpID, deptr) dl.budb_dumpList_val = 0; /* outline algorithm */ - code = ubik_Call (BUDB_GetDumps, udbHandle.uh_client, 0, - BUDB_MAJORVERSION, - BUDB_OP_DUMPID, - "", /* no name */ - dumpID, /* start */ - 0, /* end */ - 0, /* index */ - &nextindex, - &dbTime, - &dl); - - if ( (code != 0) - || (dl.budb_dumpList_len != 1) /* single retn val expected */ - ) - { + code = ubik_Call(BUDB_GetDumps, udbHandle.uh_client, 0, BUDB_MAJORVERSION, BUDB_OP_DUMPID, "", /* no name */ + dumpID, /* start */ + 0, /* end */ + 0, /* index */ + &nextindex, &dbTime, &dl); + + if ((code != 0) + || (dl.budb_dumpList_len != 1) /* single retn val expected */ + ) { /* printf("bcdb_FindDumpByID: code %d, nvalues %d\n", code, dl.budb_dumpList_len); */ - if ( code == 0 ) - code = 1; /* multiple id's */ + if (code == 0) + code = 1; /* multiple id's */ goto error; } memcpy(deptr, dl.budb_dumpList_val, sizeof(*deptr)); -exit: - if ( dl.budb_dumpList_val ) - { + exit: + if (dl.budb_dumpList_val) { /* free any allocated structures */ free(dl.budb_dumpList_val); } - return(code); + return (code); -error: + error: memset(deptr, 0, sizeof(*deptr)); goto exit; } @@ -274,11 +280,11 @@ bcdb_FindLastVolClone(volSetName, dumpName, volName, clonetime) afs_int32 *clonetime; { /* server notes - search by dumpName - match on volumeset and dump path - search for the volume name + * search by dumpName + * match on volumeset and dump path + * search for the volume name */ - return(0); + return (0); } /* bcdb_FindLatestDump @@ -304,9 +310,10 @@ bcdb_FindLatestDump(volSetName, dumpPath, deptr) struct budb_dumpEntry *deptr; { afs_int32 code; - code = ubik_Call( BUDB_FindLatestDump, udbHandle.uh_client, 0, - volSetName, dumpPath, deptr); - return(code); + code = + ubik_Call(BUDB_FindLatestDump, udbHandle.uh_client, 0, volSetName, + dumpPath, deptr); + return (code); } @@ -331,22 +338,23 @@ bcdb_FindTape(dumpid, tapeName, teptr) tl.budb_tapeList_len = 0; tl.budb_tapeList_val = 0; - code = ubik_Call( BUDB_GetTapes, udbHandle.uh_client, 0, - BUDB_MAJORVERSION, - BUDB_OP_TAPENAME|BUDB_OP_DUMPID, - tapeName, dumpid, 0, 0, &next, &dbTime, &tl); + code = + ubik_Call(BUDB_GetTapes, udbHandle.uh_client, 0, BUDB_MAJORVERSION, + BUDB_OP_TAPENAME | BUDB_OP_DUMPID, tapeName, dumpid, 0, 0, + &next, &dbTime, &tl); - if (code) ERROR(code); + if (code) + ERROR(code); if (tl.budb_tapeList_len != 1) ERROR(BC_NOTUNIQUE); /* expecting a single descriptor */ memcpy(teptr, tl.budb_tapeList_val, sizeof(*teptr)); -error_exit: - if ( tl.budb_tapeList_val ) + error_exit: + if (tl.budb_tapeList_val) free(tl.budb_tapeList_val); - return(code); + return (code); } bcdb_FindTapeSeq(dumpid, tapeSeq, teptr) @@ -363,21 +371,22 @@ bcdb_FindTapeSeq(dumpid, tapeSeq, teptr) tl.budb_tapeList_len = 0; tl.budb_tapeList_val = 0; - code = ubik_Call( BUDB_GetTapes, udbHandle.uh_client, 0, - BUDB_MAJORVERSION, - BUDB_OP_TAPESEQ|BUDB_OP_DUMPID, - "", dumpid, tapeSeq, 0, &next, &dbTime, &tl); - if (code) ERROR(code); + code = + ubik_Call(BUDB_GetTapes, udbHandle.uh_client, 0, BUDB_MAJORVERSION, + BUDB_OP_TAPESEQ | BUDB_OP_DUMPID, "", dumpid, tapeSeq, 0, + &next, &dbTime, &tl); + if (code) + ERROR(code); if (tl.budb_tapeList_len != 1) ERROR(BC_NOTUNIQUE); /* expecting a single descriptor */ memcpy(teptr, tl.budb_tapeList_val, sizeof(*teptr)); -error_exit: - if ( tl.budb_tapeList_val ) + error_exit: + if (tl.budb_tapeList_val) free(tl.budb_tapeList_val); - return(code); + return (code); } /* bcdb_FindVolumes @@ -411,37 +420,33 @@ bcdb_FindVolumes(dumpID, volumeName, returnArray, last, next, maxa, nEntries) vl.budb_volumeList_val = returnArray; /* outline algorithm */ - code = ubik_Call (BUDB_GetVolumes, udbHandle.uh_client, 0, - BUDB_MAJORVERSION, - BUDB_OP_VOLUMENAME|BUDB_OP_DUMPID, - volumeName, /* name */ - dumpID, /* start */ - 0, /* end */ - last, /* index */ - next, /* nextindex */ - &dbTime, - &vl); - - *nEntries = vl.budb_volumeList_len; - return(code); + code = ubik_Call(BUDB_GetVolumes, udbHandle.uh_client, 0, BUDB_MAJORVERSION, BUDB_OP_VOLUMENAME | BUDB_OP_DUMPID, volumeName, /* name */ + dumpID, /* start */ + 0, /* end */ + last, /* index */ + next, /* nextindex */ + &dbTime, &vl); + + *nEntries = vl.budb_volumeList_len; + return (code); } bcdb_FinishDump(deptr) register struct budb_dumpEntry *deptr; { - afs_int32 code; - code = ubik_Call (BUDB_FinishDump, udbHandle.uh_client, 0, deptr); - return(code); + afs_int32 code; + code = ubik_Call(BUDB_FinishDump, udbHandle.uh_client, 0, deptr); + return (code); } bcdb_FinishTape(teptr) register struct budb_tapeEntry *teptr; { - afs_int32 code; - code = ubik_Call (BUDB_FinishTape, udbHandle.uh_client, 0, teptr); - return(code); - + afs_int32 code; + code = ubik_Call(BUDB_FinishTape, udbHandle.uh_client, 0, teptr); + return (code); + } /* bcdb_LookupVolumes @@ -464,23 +469,18 @@ bcdb_LookupVolume(volumeName, returnArray, last, next, maxa, nEntries) vl.budb_volumeList_val = returnArray; /* outline algorithm */ - code = ubik_Call (BUDB_GetVolumes, udbHandle.uh_client, 0, - BUDB_MAJORVERSION, - BUDB_OP_VOLUMENAME, - volumeName, /* name */ - 0, /* start */ - 0, /* end */ - last, /* index */ - next, /* nextindex */ - &dbTime, - &vl); - if ( code ) - { + code = ubik_Call(BUDB_GetVolumes, udbHandle.uh_client, 0, BUDB_MAJORVERSION, BUDB_OP_VOLUMENAME, volumeName, /* name */ + 0, /* start */ + 0, /* end */ + last, /* index */ + next, /* nextindex */ + &dbTime, &vl); + if (code) { *nEntries = 0; - return(code); + return (code); } *nEntries = vl.budb_volumeList_len; - return(0); + return (0); } @@ -488,9 +488,9 @@ bcdb_UseTape(teptr, newFlag) register struct budb_tapeEntry *teptr; afs_int32 *newFlag; { - afs_int32 code; - code = ubik_Call (BUDB_UseTape, udbHandle.uh_client, 0, teptr, newFlag); - return(code); + afs_int32 code; + code = ubik_Call(BUDB_UseTape, udbHandle.uh_client, 0, teptr, newFlag); + return (code); } @@ -500,7 +500,7 @@ bcdb_UseTape(teptr, newFlag) * The caller should pass in/out a fid for an unlinked, open file to prevent * tampering with the files contents; */ - + /* bcdb_GetTextFile * extract the specified textType and put it in a temporary, local * file. @@ -511,7 +511,7 @@ bcdb_UseTape(teptr, newFlag) bcdb_GetTextFile(register udbClientTextP ctPtr) { afs_int32 bufferSize; - afs_int32 offset, nextOffset, chunkSize; + afs_int32 offset, nextOffset, chunkSize; charListT charList; afs_int32 code = 0; @@ -520,64 +520,65 @@ bcdb_GetTextFile(register udbClientTextP ctPtr) memset((void *)&charList, 0, sizeof(charList)); /* check params and cleanup any previous state */ - if ( ctPtr->lockHandle == 0 ) - ERROR(BUDB_INTERNALERROR); + if (ctPtr->lockHandle == 0) + ERROR(BUDB_INTERNALERROR); - if ( ctPtr->textStream == NULL ) /* Should have an open stream */ - ERROR(BUDB_INTERNALERROR); + if (ctPtr->textStream == NULL) /* Should have an open stream */ + ERROR(BUDB_INTERNALERROR); /* allocate a buffer */ bufferSize = 1024; - charList.charListT_val = (char *) malloc(bufferSize); - if ( charList.charListT_val == 0 ) - ERROR(BUDB_INTERNALERROR); + charList.charListT_val = (char *)malloc(bufferSize); + if (charList.charListT_val == 0) + ERROR(BUDB_INTERNALERROR); charList.charListT_len = bufferSize; offset = 0; nextOffset = 0; ctPtr->textSize = 0; - while ( nextOffset != -1 ) - { + while (nextOffset != -1) { offset = nextOffset; charList.charListT_len = bufferSize; - code = ubik_Call(BUDB_GetText, udbHandle.uh_client, 0, - ctPtr->lockHandle, ctPtr->textType, bufferSize, - offset, &nextOffset, &charList); + code = + ubik_Call(BUDB_GetText, udbHandle.uh_client, 0, ctPtr->lockHandle, + ctPtr->textType, bufferSize, offset, &nextOffset, + &charList); - if ( code ) - ERROR(code); + if (code) + ERROR(code); - code = fwrite(charList.charListT_val, sizeof(char), - charList.charListT_len, ctPtr->textStream); - if ( ferror(ctPtr->textStream) ) - ERROR(BUDB_INTERNALERROR); + code = + fwrite(charList.charListT_val, sizeof(char), + charList.charListT_len, ctPtr->textStream); + if (ferror(ctPtr->textStream)) + ERROR(BUDB_INTERNALERROR); - ctPtr->textSize += charList.charListT_len; + ctPtr->textSize += charList.charListT_len; } /* get text version */ - code = ubik_Call(BUDB_GetTextVersion, udbHandle.uh_client, 0, - ctPtr->textType, &ctPtr->textVersion); - if ( code ) - ERROR(code); + code = + ubik_Call(BUDB_GetTextVersion, udbHandle.uh_client, 0, + ctPtr->textType, &ctPtr->textVersion); + if (code) + ERROR(code); -normal_exit: - fflush(ctPtr->textStream); /* debug */ + normal_exit: + fflush(ctPtr->textStream); /* debug */ /* exit, leaving the configuration text file open */ - if ( charList.charListT_val ) - free(charList.charListT_val); - return(code); - -error_exit: - if ( ctPtr->textStream != NULL ) - { - fclose(ctPtr->textStream); + if (charList.charListT_val) + free(charList.charListT_val); + return (code); + + error_exit: + if (ctPtr->textStream != NULL) { + fclose(ctPtr->textStream); ctPtr->textStream = NULL; } goto normal_exit; } - + /* bcdb_SaveTextFile * save the text file in ubik database @@ -597,14 +598,14 @@ bcdb_SaveTextFile(ctPtr) /* allocate a buffer */ bufferSize = 1024; - charList.charListT_val = (char *) malloc(bufferSize); - if ( charList.charListT_val == 0 ) - ERROR(BUDB_INTERNALERROR); + charList.charListT_val = (char *)malloc(bufferSize); + if (charList.charListT_val == 0) + ERROR(BUDB_INTERNALERROR); charList.charListT_len = bufferSize; - if ( ctPtr->textStream == NULL ) - ERROR(BUDB_INTERNALERROR); - rewind(ctPtr->textStream); + if (ctPtr->textStream == NULL) + ERROR(BUDB_INTERNALERROR); + rewind(ctPtr->textStream); fileSize = (afs_int32) filesize(ctPtr->textStream); @@ -613,64 +614,67 @@ bcdb_SaveTextFile(ctPtr) rewind(ctPtr->textStream); /* special case empty files */ - if ( fileSize == 0 ) - { - charList.charListT_len = 0; - code = ubik_Call(BUDB_SaveText, udbHandle.uh_client, 0, - ctPtr->lockHandle, ctPtr->textType, 0, - BUDB_TEXT_COMPLETE, &charList); + if (fileSize == 0) { + charList.charListT_len = 0; + code = + ubik_Call(BUDB_SaveText, udbHandle.uh_client, 0, + ctPtr->lockHandle, ctPtr->textType, 0, + BUDB_TEXT_COMPLETE, &charList); goto error_exit; } offset = 0; - while ( fileSize != 0 ) - { + while (fileSize != 0) { chunkSize = MIN(fileSize, bufferSize); - code = fread(charList.charListT_val, sizeof(char), chunkSize, - ctPtr->textStream); + code = + fread(charList.charListT_val, sizeof(char), chunkSize, + ctPtr->textStream); - if ( code != chunkSize ) - printf("code = %d\n", code ); - if ( ferror(ctPtr->textStream ) ) - ERROR(BUDB_INTERNALERROR); + if (code != chunkSize) + printf("code = %d\n", code); + if (ferror(ctPtr->textStream)) + ERROR(BUDB_INTERNALERROR); charList.charListT_len = chunkSize; - code = ubik_Call(BUDB_SaveText, udbHandle.uh_client, 0, - ctPtr->lockHandle, ctPtr->textType, offset, - (chunkSize == fileSize) ? BUDB_TEXT_COMPLETE: 0, - &charList); - if ( code ) - ERROR(code); + code = + ubik_Call(BUDB_SaveText, udbHandle.uh_client, 0, + ctPtr->lockHandle, ctPtr->textType, offset, + (chunkSize == fileSize) ? BUDB_TEXT_COMPLETE : 0, + &charList); + if (code) + ERROR(code); fileSize -= chunkSize; offset += chunkSize; } - -error_exit: + + error_exit: /* if ( ctPtr->textStream >= 0 ) - close(ctPtr->textStream); */ - if ( charList.charListT_val ) - free(charList.charListT_val); - return(code); + * close(ctPtr->textStream); */ + if (charList.charListT_val) + free(charList.charListT_val); + return (code); } bcdb_FindLastTape(dumpID, dumpEntry, tapeEntry, volEntry) - afs_int32 dumpID; - struct budb_dumpEntry *dumpEntry; - struct budb_tapeEntry *tapeEntry; - struct budb_volumeEntry *volEntry; + afs_int32 dumpID; + struct budb_dumpEntry *dumpEntry; + struct budb_tapeEntry *tapeEntry; + struct budb_volumeEntry *volEntry; { - return( ubik_Call(BUDB_FindLastTape,udbHandle.uh_client,0, - dumpID,dumpEntry,tapeEntry,volEntry) ); + return (ubik_Call + (BUDB_FindLastTape, udbHandle.uh_client, 0, dumpID, dumpEntry, + tapeEntry, volEntry)); } bcdb_MakeDumpAppended(appendedDumpID, initialDumpID, startTapeSeq) - afs_int32 appendedDumpID; - afs_int32 initialDumpID; - afs_int32 startTapeSeq; + afs_int32 appendedDumpID; + afs_int32 initialDumpID; + afs_int32 startTapeSeq; { - return( ubik_Call(BUDB_MakeDumpAppended,udbHandle.uh_client,0, - appendedDumpID,initialDumpID,startTapeSeq) ); + return (ubik_Call + (BUDB_MakeDumpAppended, udbHandle.uh_client, 0, appendedDumpID, + initialDumpID, startTapeSeq)); } @@ -687,10 +691,10 @@ filesize(stream) afs_int32 size; offset = ftell(stream); - fseek(stream, (afs_int32) 0, 2); /* end of file */ + fseek(stream, (afs_int32) 0, 2); /* end of file */ size = ftell(stream); fseek(stream, offset, 0); - return(size); + return (size); } @@ -715,21 +719,25 @@ bc_LockText(ctPtr) afs_int32 code; afs_int32 timeout, j = 0; - if (ctPtr->lockHandle != 0) return(1); /* already locked */ + if (ctPtr->lockHandle != 0) + return (1); /* already locked */ - timeout = ( (ctPtr->textSize == 0) ? 30 : ((ctPtr->textSize/50000) + 10) ); + timeout = + ((ctPtr->textSize == 0) ? 30 : ((ctPtr->textSize / 50000) + 10)); while (1) { - code = ubik_Call(BUDB_GetLock, udbHandle.uh_client, 0, - udbHandle.uh_instanceId, ctPtr->textType, timeout, - &ctPtr->lockHandle); - if ( (code != BUDB_LOCKED) && (code != BUDB_SELFLOCKED) ) { + code = + ubik_Call(BUDB_GetLock, udbHandle.uh_client, 0, + udbHandle.uh_instanceId, ctPtr->textType, timeout, + &ctPtr->lockHandle); + if ((code != BUDB_LOCKED) && (code != BUDB_SELFLOCKED)) { break; } /* Mention something every 30 seconds */ if (++j >= 30) { - com_err(whoami, code,"; Waiting for db configuration text unlock"); + com_err(whoami, code, + "; Waiting for db configuration text unlock"); j = 0; } #ifdef AFS_PTHREAD_ENV @@ -740,8 +748,9 @@ bc_LockText(ctPtr) } /* cleanup */ - if (code) ctPtr->lockHandle = 0; - return(code); + if (code) + ctPtr->lockHandle = 0; + return (code); } /* bc_UnlockText @@ -758,14 +767,15 @@ bc_UnlockText(ctPtr) { afs_int32 code = 0; - if ( ctPtr->lockHandle == 0 ) - return(0); + if (ctPtr->lockHandle == 0) + return (0); - code = ubik_Call(BUDB_FreeLock, udbHandle.uh_client, 0, ctPtr->lockHandle); + code = + ubik_Call(BUDB_FreeLock, udbHandle.uh_client, 0, ctPtr->lockHandle); ctPtr->lockHandle = 0; - + /* Don't try to analyse the error. Let the lock timeout */ - return(code); + return (code); } /* bc_CheckTextVersion @@ -780,18 +790,19 @@ bc_CheckTextVersion(ctPtr) afs_int32 code; afs_uint32 tversion; - if ( ctPtr->textVersion == -1 ) - return(BC_VERSIONMISMATCH); - - code = ubik_Call(BUDB_GetTextVersion, udbHandle.uh_client, 0, - ctPtr->textType, &tversion); - if ( code ) - return(code); - if ( tversion != ctPtr->textVersion ) - return(BC_VERSIONMISMATCH); - return(0); + if (ctPtr->textVersion == -1) + return (BC_VERSIONMISMATCH); + + code = + ubik_Call(BUDB_GetTextVersion, udbHandle.uh_client, 0, + ctPtr->textType, &tversion); + if (code) + return (code); + if (tversion != ctPtr->textVersion) + return (BC_VERSIONMISMATCH); + return (0); } - + /* ------------------------------------- * initialization routines * ------------------------------------- @@ -801,123 +812,115 @@ bc_CheckTextVersion(ctPtr) * Initialize a client for the vl ubik database. */ vldbClientInit(noAuthFlag, localauth, cellName, cstruct, ttoken) - int noAuthFlag; - int localauth; - char *cellName; + int noAuthFlag; + int localauth; + char *cellName; struct ubik_client **cstruct; - struct ktc_token *ttoken; + struct ktc_token *ttoken; { - afs_int32 code = 0; - struct afsconf_dir *acdir; + afs_int32 code = 0; + struct afsconf_dir *acdir; struct rc_securityClass *sc; - afs_int32 i, scIndex = 0; /* Index of Rx security object - noauth */ - struct afsconf_cell info; - struct ktc_principal sname; - struct rx_connection *serverconns[VLDB_MAXSERVERS]; + afs_int32 i, scIndex = 0; /* Index of Rx security object - noauth */ + struct afsconf_cell info; + struct ktc_principal sname; + struct rx_connection *serverconns[VLDB_MAXSERVERS]; /* Find out about the given cell */ - acdir = afsconf_Open((localauth ? AFSDIR_SERVER_ETC_DIRPATH : - AFSDIR_CLIENT_ETC_DIRPATH)); - if (!acdir) - { - com_err(whoami,0,"Can't open configuration directory '%s'", - (localauth ? AFSDIR_SERVER_ETC_DIRPATH : + acdir = + afsconf_Open((localauth ? AFSDIR_SERVER_ETC_DIRPATH : + AFSDIR_CLIENT_ETC_DIRPATH)); + if (!acdir) { + com_err(whoami, 0, "Can't open configuration directory '%s'", + (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH)); ERROR(BC_NOCELLCONFIG); } - if (!cellName[0]) - { - char cname[64]; + if (!cellName[0]) { + char cname[64]; - code = afsconf_GetLocalCell(acdir, cname, sizeof(cname)); - if (code) - { - com_err(whoami, code, "; Can't get the local cell name - check %s/%s", (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH), - AFSDIR_THISCELL_FILE); + code = afsconf_GetLocalCell(acdir, cname, sizeof(cname)); + if (code) { + com_err(whoami, code, + "; Can't get the local cell name - check %s/%s", + (localauth ? AFSDIR_SERVER_ETC_DIRPATH : + AFSDIR_CLIENT_ETC_DIRPATH), AFSDIR_THISCELL_FILE); ERROR(code); } strcpy(cellName, cname); } code = afsconf_GetCellInfo(acdir, cellName, AFSCONF_VLDBSERVICE, &info); - if (code) - { - com_err(whoami, code, "; Can't find cell %s's hosts in %s/%s", - cellName, (localauth ? AFSDIR_SERVER_ETC_DIRPATH : - AFSDIR_CLIENT_ETC_DIRPATH), - AFSDIR_CELLSERVDB_FILE); - ERROR(BC_NOCELLCONFIG); + if (code) { + com_err(whoami, code, "; Can't find cell %s's hosts in %s/%s", + cellName, + (localauth ? AFSDIR_SERVER_ETC_DIRPATH : + AFSDIR_CLIENT_ETC_DIRPATH), AFSDIR_CELLSERVDB_FILE); + ERROR(BC_NOCELLCONFIG); } /* * Grab tickets if we care about authentication. */ ttoken->endTime = 0; - if (localauth) - { - code = afsconf_GetLatestKey (acdir, 0, 0); - if (code) - { + if (localauth) { + code = afsconf_GetLatestKey(acdir, 0, 0); + if (code) { com_err(whoami, code, "; Can't get key from local key file"); ERROR(code); - } - else - { + } else { code = afsconf_ClientAuth(acdir, &sc, &scIndex); - if (code) - { + if (code) { com_err(whoami, code, "; Calling ClientAuth"); ERROR(code); } ttoken->endTime = NEVERDATE; } - } - else - { - if (!noAuthFlag) - { + } else { + if (!noAuthFlag) { strcpy(sname.cell, info.name); sname.instance[0] = 0; strcpy(sname.name, "afs"); - code = ktc_GetToken(&sname, ttoken, sizeof(struct ktc_token), NULL); - if (code) - { - com_err(whoami,code, 0,"; Can't get AFS tokens - running unauthenticated"); - } - else - { - if ( (ttoken->kvno < 0) || (ttoken->kvno > 255) ) - com_err(whoami, 0, "Funny kvno (%d) in ticket, proceeding", ttoken->kvno); - + code = + ktc_GetToken(&sname, ttoken, sizeof(struct ktc_token), NULL); + if (code) { + com_err(whoami, code, 0, + "; Can't get AFS tokens - running unauthenticated"); + } else { + if ((ttoken->kvno < 0) || (ttoken->kvno > 255)) + com_err(whoami, 0, + "Funny kvno (%d) in ticket, proceeding", + ttoken->kvno); + scIndex = 2; } } - - switch (scIndex) - { - case 0: - sc = rxnull_NewClientSecurityObject(); - break; - case 2: - sc = (struct rx_securityClass *) - rxkad_NewClientSecurityObject(rxkad_clear, &ttoken->sessionKey, - ttoken->kvno, ttoken->ticketLen, + + switch (scIndex) { + case 0: + sc = rxnull_NewClientSecurityObject(); + break; + case 2: + sc = (struct rx_securityClass *) + rxkad_NewClientSecurityObject(rxkad_clear, + &ttoken->sessionKey, + ttoken->kvno, ttoken->ticketLen, ttoken->ticket); - break; - default: - com_err(whoami, 0, "Unsupported authentication type %d", scIndex); - ERROR(-1); - break; + break; + default: + com_err(whoami, 0, "Unsupported authentication type %d", scIndex); + ERROR(-1); + break; } } - if (!sc) - { - com_err(whoami, 0, "Can't create a security object with security index %d", + if (!sc) { + com_err(whoami, 0, + "Can't create a security object with security index %d", scIndex); ERROR(-1); } @@ -925,31 +928,31 @@ vldbClientInit(noAuthFlag, localauth, cellName, cstruct, ttoken) /* tell UV module about default authentication */ UV_SetSecurity(sc, scIndex); - if (info.numServers > VLDB_MAXSERVERS) - { - com_err(whoami, 0, - "Warning: %d VLDB servers exist for cell '%s', can only remember the first %d", + if (info.numServers > VLDB_MAXSERVERS) { + com_err(whoami, 0, + "Warning: %d VLDB servers exist for cell '%s', can only remember the first %d", info.numServers, cellName, VLDB_MAXSERVERS); info.numServers = VLDB_MAXSERVERS; } - for (i=0; i 255)) - com_err(whoami, 0, "Unexpected kvno (%d) in ticket - proceeding", + if (code) { + com_err(whoami, code, + "; Can't get tokens - running unauthenticated"); + } else { + if ((token.kvno < 0) || (token.kvno > 255)) + com_err(whoami, 0, + "Unexpected kvno (%d) in ticket - proceeding", token.kvno); - udbHandle.uh_scIndex = RX_SCINDEX_KAD; /* Kerberos */ + udbHandle.uh_scIndex = RX_SCINDEX_KAD; /* Kerberos */ } } - switch (udbHandle.uh_scIndex) - { - case 0: - udbHandle.uh_secobj = rxnull_NewClientSecurityObject(); - break; - - case 2: - udbHandle.uh_secobj = (struct rx_securityClass *) + switch (udbHandle.uh_scIndex) { + case 0: + udbHandle.uh_secobj = rxnull_NewClientSecurityObject(); + break; + + case 2: + udbHandle.uh_secobj = (struct rx_securityClass *) rxkad_NewClientSecurityObject(rxkad_clear, &token.sessionKey, token.kvno, token.ticketLen, token.ticket); - break; + break; - default: - com_err(whoami, 0, "Unsupported authentication type %d", udbHandle.uh_scIndex ); - ERROR(-1); - break; + default: + com_err(whoami, 0, "Unsupported authentication type %d", + udbHandle.uh_scIndex); + ERROR(-1); + break; } } - if (!udbHandle.uh_secobj) - { - com_err(whoami, 0, "Can't create a security object with security index %d", + if (!udbHandle.uh_secobj) { + com_err(whoami, 0, + "Can't create a security object with security index %d", udbHandle.uh_secobj); ERROR(-1); } - if (info.numServers > MAXSERVERS) - { - com_err(whoami,0, - "Warning: %d BDB servers exist for cell '%s', can only remember the first %d", + if (info.numServers > MAXSERVERS) { + com_err(whoami, 0, + "Warning: %d BDB servers exist for cell '%s', can only remember the first %d", info.numServers, cellName, MAXSERVERS); info.numServers = MAXSERVERS; } /* establish connections to the servers. Check for failed connections? */ for (i = 0; i < info.numServers; i++) { - udbHandle.uh_serverConn[i] = rx_NewConnection(info.hostAddr[i].sin_addr.s_addr, - htons(AFSCONF_BUDBPORT), - BUDB_SERVICE, - udbHandle.uh_secobj, - udbHandle.uh_scIndex); + udbHandle.uh_serverConn[i] = + rx_NewConnection(info.hostAddr[i].sin_addr.s_addr, + htons(AFSCONF_BUDBPORT), BUDB_SERVICE, + udbHandle.uh_secobj, udbHandle.uh_scIndex); } udbHandle.uh_serverConn[i] = 0; code = ubik_ClientInit(udbHandle.uh_serverConn, &udbHandle.uh_client); if (code) { - com_err(whoami,code,"; Can't initialize ubik connection to backup database"); + com_err(whoami, code, + "; Can't initialize ubik connection to backup database"); ERROR(code); } /* Try to quickly find a good site by setting deadtime low */ for (i = 0; i < info.numServers; i++) rx_SetConnDeadTime(udbHandle.uh_client->conns[i], 1); - code = ubik_Call(BUDB_GetInstanceId, udbHandle.uh_client, 0, &udbHandle.uh_instanceId); + code = + ubik_Call(BUDB_GetInstanceId, udbHandle.uh_client, 0, + &udbHandle.uh_instanceId); /* Reset dead time back up to default */ for (i = 0; i < info.numServers; i++) - rx_SetConnDeadTime(udbHandle.uh_client->conns[i], 60); + rx_SetConnDeadTime(udbHandle.uh_client->conns[i], 60); /* If did not find a site on first quick pass, try again */ if (code == -1) - code = ubik_Call(BUDB_GetInstanceId, udbHandle.uh_client, 0, &udbHandle.uh_instanceId); + code = + ubik_Call(BUDB_GetInstanceId, udbHandle.uh_client, 0, + &udbHandle.uh_instanceId); if (code) { - com_err(whoami,code,"; Can't access backup database"); + com_err(whoami, code, "; Can't access backup database"); ERROR(code); } -error_exit: - if (acdir) afsconf_Close(acdir); - return(code); + error_exit: + if (acdir) + afsconf_Close(acdir); + return (code); } /* ------------------------------------- @@ -1140,12 +1139,11 @@ error_exit: * 4) if the vanilla ubik_Call is ever modified, the END_SINGLESERVER * flag can be discarded. The first call without SINGLESERVER set * can clean up the state. - */ + */ -struct ubikCallState -{ - afs_int32 ucs_flags; /* state flags */ - afs_int32 ucs_selectedServer; /* which server selected */ +struct ubikCallState { + afs_int32 ucs_flags; /* state flags */ + afs_int32 ucs_selectedServer; /* which server selected */ }; static struct ubikCallState uServer; @@ -1161,11 +1159,13 @@ static struct ubikCallState uServer; */ afs_int32 -ubik_Call_SingleServer(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16) - register struct ubik_client *aclient; - int (*aproc)(); - afs_int32 aflags; - char *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10, *p11, *p12, *p13, *p14, *p15, *p16; +ubik_Call_SingleServer(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, + p9, p10, p11, p12, p13, p14, p15, p16) + register struct ubik_client *aclient; + int (*aproc) (); + afs_int32 aflags; + char *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10, *p11, *p12, *p13, + *p14, *p15, *p16; { register afs_int32 code; afs_int32 someCode, newHost, thisHost; @@ -1176,30 +1176,25 @@ ubik_Call_SingleServer(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p struct rx_connection *tc; struct rx_peer *rxp; - if ( (aflags & (UF_SINGLESERVER | UF_END_SINGLESERVER)) != 0 ) - { - if ( ((aflags & UF_SINGLESERVER) != 0 ) - && ((uServer.ucs_flags & UF_SINGLESERVER ) != 0) - ) - { - + if ((aflags & (UF_SINGLESERVER | UF_END_SINGLESERVER)) != 0) { + if (((aflags & UF_SINGLESERVER) != 0) + && ((uServer.ucs_flags & UF_SINGLESERVER) != 0) + ) { + /* have a selected server */ tc = aclient->conns[uServer.ucs_selectedServer]; - - code = (*aproc)(tc, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, - p12, p13, p14, p15, p16); - if ( code ) - { + + code = + (*aproc) (tc, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, + p12, p13, p14, p15, p16); + if (code) { /* error. Clean up single server state */ memset(&uServer, 0, sizeof(uServer)); } - return(code); - } - else - if ( (aflags & UF_END_SINGLESERVER) != 0 ) - { + return (code); + } else if ((aflags & UF_END_SINGLESERVER) != 0) { memset(&uServer, 0, sizeof(uServer)); - return(0); + return (0); } } @@ -1207,26 +1202,26 @@ ubik_Call_SingleServer(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p chaseCount = 0; pass = 0; count = 0; - while(1) - { /*w*/ + while (1) { /*w */ /* tc is the next conn to try */ tc = aclient->conns[count]; - if ( tc == 0 ) - { - if (pass == 0) { + if (tc == 0) { + if (pass == 0) { pass = 1; /* in pass 1, we look at down hosts, too */ - count = 0; + count = 0; continue; - } - else break; /* nothing left to try */ + } else + break; /* nothing left to try */ } if (pass == 0 && (aclient->states[count] & CFLastFailed)) { count++; - continue; /* this guy's down, try someone else first */ + continue; /* this guy's down, try someone else first */ } - code = (*aproc)(tc, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16); + code = + (*aproc) (tc, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, + p13, p14, p15, p16); /* note that getting a UNOTSYNC error code back does *not* guarantee * that there is a sync site yet elected. However, if there is a @@ -1234,53 +1229,47 @@ ubik_Call_SingleServer(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p * requires a sync site, ubik will return UNOTSYNC, indicating the * operation won't work until you find a sync site */ - if (code == UNOTSYNC) - { /*ns*/ + if (code == UNOTSYNC) { /*ns */ /* means that this requires a sync site to work */ someCode = code; /* remember an error, if this fails */ /* now see if we can find the sync site host */ code = VOTE_GetSyncSite(tc, &newHost); if (code == 0 && newHost != 0) { - newHost = htonl(newHost); /* convert back to network order */ + newHost = htonl(newHost); /* convert back to network order */ /* position count at the appropriate slot in the client * structure and retry. If we can't find in slot, we'll just * continue through the whole list - */ - for(i=0;iconns[i]); if (!(thisHost = rx_HostOf(rxp))) { - count++; /* host not found, try the next dude */ + count++; /* host not found, try the next dude */ break; } - if (thisHost == newHost) - { + if (thisHost == newHost) { /* avoid asking in a loop */ - if (chaseCount++ > 2) - break; - count = i; /* we were told to use this one */ + if (chaseCount++ > 2) + break; + count = i; /* we were told to use this one */ break; } - } /*f*/ - } - else count++; /* not directed, keep looking for a sync site */ + } /*f */ + } else + count++; /* not directed, keep looking for a sync site */ continue; - } /*ns*/ - else if (code == UNOQUORUM) { /* this guy is still recovering */ + } /*ns */ + else if (code == UNOQUORUM) { /* this guy is still recovering */ someCode = code; count++; continue; - } - else if (code < 0) { /* network errors */ + } else if (code < 0) { /* network errors */ someCode = code; aclient->states[count] |= CFLastFailed; count++; continue; - } - else - { + } else { /* ok, operation worked */ aclient->states[count] &= ~CFLastFailed; /* either misc ubik code, or misc application code (incl success) @@ -1289,22 +1278,21 @@ ubik_Call_SingleServer(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p /* if the call succeeded, setup connection state for subsequent * calls */ - if ( (code == 0) - && (aflags & UF_SINGLESERVER != 0) - ) - { + if ((code == 0) + && (aflags & UF_SINGLESERVER != 0) + ) { /* need to save state */ uServer.ucs_flags = UF_SINGLESERVER; uServer.ucs_selectedServer = count; } - + return code; - } - } /*w*/ + } + } /*w */ return someCode; } - + /* ------------------------------------- * debug and test routines * ------------------------------------- @@ -1329,52 +1317,48 @@ udbLocalInit() /* get our host name */ gethostname(hostname, sizeof(hostname)); /* strcpy(hostname, "hops"); */ - + args[0] = ""; args[1] = "-servers"; args[2] = hostname; code = ubik_ParseClientList(3, args, serverList); - if ( code ) - { + if (code) { com_err(whoami, code, "; udbLocalInit: parsing ubik server list"); - return(-1); + return (-1); } udbHandle.uh_scIndex = RX_SCINDEX_NULL; - udbHandle.uh_secobj = (struct rx_securityClass *) - rxnull_NewClientSecurityObject(); - - for ( i = 0; serverList[i] != 0; i++ ) - { - udbHandle.uh_serverConn[i] = rx_NewConnection (serverList[i], - htons(AFSCONF_BUDBPORT), - BUDB_SERVICE, - udbHandle.uh_secobj, - udbHandle.uh_scIndex); - if ( udbHandle.uh_serverConn[i] == 0 ) - { + udbHandle.uh_secobj = (struct rx_securityClass *) + rxnull_NewClientSecurityObject(); + + for (i = 0; serverList[i] != 0; i++) { + udbHandle.uh_serverConn[i] = + rx_NewConnection(serverList[i], htons(AFSCONF_BUDBPORT), + BUDB_SERVICE, udbHandle.uh_secobj, + udbHandle.uh_scIndex); + if (udbHandle.uh_serverConn[i] == 0) { com_err(whoami, 0, "connection %d failed", i); continue; } } udbHandle.uh_serverConn[i] = 0; code = ubik_ClientInit(udbHandle.uh_serverConn, &udbHandle.uh_client); - if ( code ) - { + if (code) { com_err(whoami, code, "; in ubik_ClientInit"); - return(code); + return (code); } - code = ubik_Call(BUDB_GetInstanceId, udbHandle.uh_client, 0, &udbHandle.uh_instanceId); - if ( code ) - { + code = + ubik_Call(BUDB_GetInstanceId, udbHandle.uh_client, 0, + &udbHandle.uh_instanceId); + if (code) { com_err(whoami, code, "; Can't estblish instance Id"); - return(code); + return (code); } -abort: - return(0); + abort: + return (0); } /* bc_openTextFile - This function opens a temp file to read in the @@ -1391,42 +1375,42 @@ abort: * !0: error code * 0: Success. */ -int bc_openTextFile(udbClientTextP ctPtr, char *tmpFileName) +int +bc_openTextFile(udbClientTextP ctPtr, char *tmpFileName) { - int code = 0; + int code = 0; - if ( ctPtr->textStream != NULL ) - fclose(ctPtr->textStream); - - sprintf(tmpFileName, "%s/bu_XXXXXX", gettmpdir()); + if (ctPtr->textStream != NULL) + fclose(ctPtr->textStream); + + sprintf(tmpFileName, "%s/bu_XXXXXX", gettmpdir()); #ifdef AFS_LINUX20_ENV - mkstemp(tmpFileName); + mkstemp(tmpFileName); #else - mktemp(tmpFileName); + mktemp(tmpFileName); #endif - ctPtr->textStream = fopen(tmpFileName, "w+"); - if ( ctPtr->textStream == NULL ) - ERROR(BUDB_INTERNALERROR); - -#ifndef AFS_NT40_ENV /* This can't be done on NT */ - /* make the file invisible to others */ - code = unlink(tmpFileName); - if ( code ) - ERROR(errno); + ctPtr->textStream = fopen(tmpFileName, "w+"); + if (ctPtr->textStream == NULL) + ERROR(BUDB_INTERNALERROR); + +#ifndef AFS_NT40_ENV /* This can't be done on NT */ + /* make the file invisible to others */ + code = unlink(tmpFileName); + if (code) + ERROR(errno); #endif - - dprintf(("file is %s\n", tmpFileName)); -normal_exit: - return code; + dprintf(("file is %s\n", tmpFileName)); -error_exit: - if ( ctPtr->textStream != NULL ) - { - fclose(ctPtr->textStream); - ctPtr->textStream = NULL; + normal_exit: + return code; + + error_exit: + if (ctPtr->textStream != NULL) { + fclose(ctPtr->textStream); + ctPtr->textStream = NULL; } - goto normal_exit; + goto normal_exit; } @@ -1438,17 +1422,18 @@ error_exit: * 0 - Success * !0 - error code */ -int bc_closeTextFile(udbClientTextP ctPtr, char *tmpFileName) +int +bc_closeTextFile(udbClientTextP ctPtr, char *tmpFileName) { - int code = 0; + int code = 0; - if (ctPtr->textStream) - fclose(ctPtr->textStream); + if (ctPtr->textStream) + fclose(ctPtr->textStream); - if (*tmpFileName) { /* we have a valid name */ - code = unlink(tmpFileName); - if (code < 0) - code = errno; - } - return code; + if (*tmpFileName) { /* we have a valid name */ + code = unlink(tmpFileName); + if (code < 0) + code = errno; + } + return code; } diff --git a/src/bucoord/vol_sets.c b/src/bucoord/vol_sets.c index e15ce0bbe..10332fff5 100644 --- a/src/bucoord/vol_sets.c +++ b/src/bucoord/vol_sets.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -38,7 +39,8 @@ afs_int32 bc_UpdateVolumeSet(); extern struct bc_config *bc_globalConfig; extern struct udbHandleS udbHandle; extern char *whoami; -extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cf, char *name); +extern struct bc_volumeSet *bc_FindVolumeSet(struct bc_config *cf, + char *name); /* ------------------------------------ * command level routines @@ -65,54 +67,58 @@ bc_AddVolEntryCmd(as, arock) struct bc_volumeSet *tset; afs_int32 flags; - volSetName = as->parms[0].items->data; - serverName = as->parms[1].items->data; + volSetName = as->parms[0].items->data; + serverName = as->parms[1].items->data; partitionName = as->parms[2].items->data; - volRegExp = as->parms[3].items->data; + volRegExp = as->parms[3].items->data; code = bc_UpdateVolumeSet(); if (code) { com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + return (code); } ctPtr = &bc_globalConfig->configText[TB_VOLUMESET]; tset = bc_FindVolumeSet(bc_globalConfig, volSetName); if (!tset) { - com_err(whoami, code, "; Volume entry not added"); - ERROR(code); + com_err(whoami, code, "; Volume entry not added"); + ERROR(code); } if (!(tset->flags & VSFLAG_TEMPORARY)) { - code = bc_LockText(ctPtr); - if (code) ERROR(code); + code = bc_LockText(ctPtr); + if (code) + ERROR(code); } code = bc_UpdateVolumeSet(); if (code) { - com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + com_err(whoami, code, "; Can't retrieve volume sets"); + return (code); } - code = bc_AddVolumeItem(bc_globalConfig, volSetName, serverName, - partitionName, volRegExp); + code = + bc_AddVolumeItem(bc_globalConfig, volSetName, serverName, + partitionName, volRegExp); if (code) { com_err(whoami, code, "; Volume entry not added"); ERROR(code); } if (!(tset->flags & VSFLAG_TEMPORARY)) { - code = bc_SaveVolumeSet(); - if (code) { - com_err(whoami, code, "Cannot save volume set file"); - com_err(whoami,0,"Changes are temporary - for this session only"); - } + code = bc_SaveVolumeSet(); + if (code) { + com_err(whoami, code, "Cannot save volume set file"); + com_err(whoami, 0, + "Changes are temporary - for this session only"); + } } -error_exit: - if (ctPtr->lockHandle) bc_UnlockText(ctPtr); - return(code); + error_exit: + if (ctPtr->lockHandle) + bc_UnlockText(ctPtr); + return (code); } @@ -124,9 +130,10 @@ error_exit: * name of new volume set */ -afs_int32 bc_AddVolSetCmd(as, arock) +afs_int32 +bc_AddVolSetCmd(as, arock) struct cmd_syndesc *as; - char *arock; + char *arock; { /* parm 0 is vol set name */ register afs_int32 code; @@ -141,35 +148,39 @@ afs_int32 bc_AddVolSetCmd(as, arock) /* Don't lock if adding a temporary volumeset */ if (!(flags & VSFLAG_TEMPORARY)) { - code = bc_LockText(ctPtr); - if (code) ERROR(code); + code = bc_LockText(ctPtr); + if (code) + ERROR(code); } code = bc_UpdateVolumeSet(); if (code) { - com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + com_err(whoami, code, "; Can't retrieve volume sets"); + return (code); } /* validate size of volumeset name */ - code = bc_CreateVolumeSet(bc_globalConfig, (ti=as->parms[0].items)->data, flags); + code = + bc_CreateVolumeSet(bc_globalConfig, (ti = as->parms[0].items)->data, + flags); if (code) { if (code == -1) - com_err(whoami,0,"Volume set '%s' already exists", ti->data); - else com_err(whoami,0,"Unknown problem"); - } - else if (!(flags & VSFLAG_TEMPORARY)) { + com_err(whoami, 0, "Volume set '%s' already exists", ti->data); + else + com_err(whoami, 0, "Unknown problem"); + } else if (!(flags & VSFLAG_TEMPORARY)) { code = bc_SaveVolumeSet(); if (code) { com_err(whoami, code, "Cannot save new volume set file"); - com_err(whoami,0,"Changes are temporary - for this session only"); + com_err(whoami, 0, + "Changes are temporary - for this session only"); } } -error_exit: - if ( ctPtr->lockHandle != 0 ) - bc_UnlockText(ctPtr); - return(code); + error_exit: + if (ctPtr->lockHandle != 0) + bc_UnlockText(ctPtr); + return (code); } @@ -179,8 +190,9 @@ error_exit: * parm 0 is vol set name * parm 1 is entry # (integer, 1 based) */ - -afs_int32 bc_DeleteVolEntryCmd(as, arock) + +afs_int32 +bc_DeleteVolEntryCmd(as, arock) struct cmd_syndesc *as; char *arock; { @@ -194,8 +206,8 @@ afs_int32 bc_DeleteVolEntryCmd(as, arock) code = bc_UpdateVolumeSet(); if (code) { - com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + com_err(whoami, code, "; Can't retrieve volume sets"); + return (code); } /* lock schedules and check validity */ @@ -203,35 +215,39 @@ afs_int32 bc_DeleteVolEntryCmd(as, arock) tset = bc_FindVolumeSet(bc_globalConfig, vsname); if (!tset) { - com_err(whoami,0,"No such volume set as '%s'", vsname); - ERROR(code); + com_err(whoami, 0, "No such volume set as '%s'", vsname); + ERROR(code); } if (!(tset->flags & VSFLAG_TEMPORARY)) { - code = bc_LockText(ctPtr); - if (code) ERROR(code); + code = bc_LockText(ctPtr); + if (code) + ERROR(code); } code = bc_UpdateVolumeSet(); if (code) { - com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + com_err(whoami, code, "; Can't retrieve volume sets"); + return (code); } entry = bc_SafeATOI(as->parms[1].items->data); if (entry < 0) { - com_err(whoami,0,"Can't parse entry number '%s' as decimal integer", - as->parms[1].items->data); + com_err(whoami, 0, "Can't parse entry number '%s' as decimal integer", + as->parms[1].items->data); ERROR(BC_BADARG); } code = bc_DeleteVolumeItem(bc_globalConfig, vsname, entry); if (code) { - if (code == -1) { - com_err(whoami,0,"No such volume set as '%s'", vsname); + if (code == -1) { + com_err(whoami, 0, "No such volume set as '%s'", vsname); } else if (code == -2) { - com_err(whoami,0,"There aren't %d volume items for this volume set", entry); - com_err(whoami,0,"Use the 'listvolsets' command to examine the volume set"); + com_err(whoami, 0, + "There aren't %d volume items for this volume set", + entry); + com_err(whoami, 0, + "Use the 'listvolsets' command to examine the volume set"); } ERROR(code); } @@ -243,14 +259,15 @@ afs_int32 bc_DeleteVolEntryCmd(as, arock) entry, vsname); } else { com_err(whoami, code, "Cannot save volume set file"); - com_err(whoami,0,"Deletion is temporary - for this session only"); + com_err(whoami, 0, + "Deletion is temporary - for this session only"); } } -error_exit: - if ( ctPtr->lockHandle != 0 ) - bc_UnlockText(ctPtr); - return(code); + error_exit: + if (ctPtr->lockHandle != 0) + bc_UnlockText(ctPtr); + return (code); } @@ -263,69 +280,77 @@ error_exit: * name of volumeset to delete */ -afs_int32 bc_DeleteVolSetCmd(as, arock) +afs_int32 +bc_DeleteVolSetCmd(as, arock) struct cmd_syndesc *as; - char *arock; + char *arock; { /* parm 0 is vol set name */ register afs_int32 code; register struct cmd_item *ti; udbClientTextP ctPtr; afs_int32 c; - afs_int32 flags, tosave=0; + afs_int32 flags, tosave = 0; - /* lock schedules and check validity */ + /* lock schedules and check validity */ ctPtr = &bc_globalConfig->configText[TB_VOLUMESET]; code = bc_LockText(ctPtr); - if (code) ERROR(code); + if (code) + ERROR(code); code = bc_UpdateVolumeSet(); if (code) { - com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + com_err(whoami, code, "; Can't retrieve volume sets"); + return (code); } - for(ti=as->parms[0].items; ti; ti=ti->next) { + for (ti = as->parms[0].items; ti; ti = ti->next) { code = bc_DeleteVolumeSet(bc_globalConfig, ti->data, &flags); if (code) { - if (code == -1) - com_err(whoami,0,"Can't find volume set '%s'", ti->data); - else - com_err(whoami, code, "; Unknown problem deleting volume set '%s'", ti->data); + if (code == -1) + com_err(whoami, 0, "Can't find volume set '%s'", ti->data); + else + com_err(whoami, code, + "; Unknown problem deleting volume set '%s'", + ti->data); } else { - if (!(flags & VSFLAG_TEMPORARY)) tosave = 1; + if (!(flags & VSFLAG_TEMPORARY)) + tosave = 1; printf("backup: deleted volume set '%s'\n", ti->data); } } - + /* now write out the file */ if (tosave) { c = bc_SaveVolumeSet(); if (c) { - if (!code) code = c; + if (!code) + code = c; com_err(whoami, c, "Cannot save updated volume set file"); - com_err(whoami,0,"Deletion effective for this session only"); + com_err(whoami, 0, "Deletion effective for this session only"); } } -error_exit: - if (ctPtr->lockHandle) bc_UnlockText(ctPtr); - return(code); + error_exit: + if (ctPtr->lockHandle) + bc_UnlockText(ctPtr); + return (code); } /* bc_ListVolSetCmd - * list out all the information (?) about a volumeset or about all - * volumesets - * entry: - * optional parameter specifies a volumeset name - */ - -afs_int32 bc_ListVolSetCmd(as, arock) + * list out all the information (?) about a volumeset or about all + * volumesets + * entry: + * optional parameter specifies a volumeset name + */ + +afs_int32 +bc_ListVolSetCmd(as, arock) struct cmd_syndesc *as; - char *arock; + char *arock; { /* parm 0 is optional volume set to display */ register struct bc_volumeSet *tset; @@ -334,33 +359,26 @@ afs_int32 bc_ListVolSetCmd(as, arock) code = bc_UpdateVolumeSet(); if (code) { - com_err(whoami, code, "; Can't retrieve volume sets"); - return(code); + com_err(whoami, code, "; Can't retrieve volume sets"); + return (code); } /* figure out volume set to list */ - if (ti=as->parms[0].items) - { - /* for each volume set in the command item list */ - for(; ti; ti=ti->next) - { + if (ti = as->parms[0].items) { + /* for each volume set in the command item list */ + for (; ti; ti = ti->next) { tset = bc_FindVolumeSet(bc_globalConfig, ti->data); - if (tset) - { + if (tset) { ListVolSet(tset); printf("\n"); - } - else - { - com_err(whoami,0,"Can't find volume set '%s'", ti->data); + } else { + com_err(whoami, 0, "Can't find volume set '%s'", ti->data); code = 1; } } - } - else - { + } else { /* no command parameters specified, show entire list */ - for(tset = bc_globalConfig->vset; tset; tset=tset->next) { + for (tset = bc_globalConfig->vset; tset; tset = tset->next) { ListVolSet(tset); printf("\n"); } @@ -390,31 +408,32 @@ bc_ClearVolumeSets() for (vsPtr = bc_globalConfig->vset; vsPtr; vsPtr = vsNextPtr) { vsNextPtr = vsPtr->next; - if (vsPtr->flags & VSFLAG_TEMPORARY) { /* Skip temporary volumeSet */ - vsPrev = &(vsPtr->next); - continue; + if (vsPtr->flags & VSFLAG_TEMPORARY) { /* Skip temporary volumeSet */ + vsPrev = &(vsPtr->next); + continue; } - *vsPrev = vsPtr->next; /* Remove volumeSet from the chain */ + *vsPrev = vsPtr->next; /* Remove volumeSet from the chain */ FreeVolumeSet(vsPtr); } - return(0); + return (0); } -static ListVolSet(aset) - struct bc_volumeSet *aset; +static +ListVolSet(aset) + struct bc_volumeSet *aset; { struct bc_volumeEntry *tentry; int i; printf("Volume set %s", aset->name); if (aset->flags & VSFLAG_TEMPORARY) - printf(" (temporary)"); + printf(" (temporary)"); printf(":\n"); i = 1; - for(tentry=aset->ventries; tentry; tentry=tentry->next, i++) { - printf(" Entry %3d: server %s, partition %s, volumes: %s\n", - i, tentry->serverName, tentry->partname, tentry->name); + for (tentry = aset->ventries; tentry; tentry = tentry->next, i++) { + printf(" Entry %3d: server %s, partition %s, volumes: %s\n", i, + tentry->serverName, tentry->partname, tentry->name); } return 0; } @@ -431,18 +450,18 @@ static ListVolSet(aset) int bc_ParseVolumeSet() { - static char rn[] = "bc_ParseVolumeSet"; /*Routine name*/ - char tbuffer[1024]; /*Buffer for reading config file*/ - char vsname[256]; /*Volume set name*/ - char serverName[256]; /*Server name*/ - char partName[256]; /*Partition name*/ - register struct bc_volumeEntry *tve; /*Ptr to generated volume spec struct*/ - register struct bc_volumeSet *tvs; /*Ptr to volume set struct*/ + static char rn[] = "bc_ParseVolumeSet"; /*Routine name */ + char tbuffer[1024]; /*Buffer for reading config file */ + char vsname[256]; /*Volume set name */ + char serverName[256]; /*Server name */ + char partName[256]; /*Partition name */ + register struct bc_volumeEntry *tve; /*Ptr to generated volume spec struct */ + register struct bc_volumeSet *tvs; /*Ptr to volume set struct */ struct bc_volumeEntry **ppve, *pve; struct bc_volumeSet **ppvs, *pvs; - register afs_int32 code; /*Generalized return code*/ - char *tp; /*Result of fgets(), malloc()*/ - int readHeader; /*Is next thing to read a volume set hdr?*/ + register afs_int32 code; /*Generalized return code */ + char *tp; /*Result of fgets(), malloc() */ + int readHeader; /*Is next thing to read a volume set hdr? */ udbClientTextP ctPtr; register FILE *stream; @@ -458,61 +477,57 @@ bc_ParseVolumeSet() * Open up the volume set configuration file, fail if it can't be done. */ - if ( ctPtr->textSize == 0 ) /* empty is ok */ - return(0); + if (ctPtr->textSize == 0) /* empty is ok */ + return (0); /* stream checks and initialization */ - if ( stream == NULL ) - return(BC_INTERNALERROR); + if (stream == NULL) + return (BC_INTERNALERROR); rewind(stream); readHeader = 1; - while (1) - { + while (1) { /* Read in and process the next line of the volume set description * file. */ tp = fgets(tbuffer, sizeof(tbuffer), stream); if (!tp) break; - if (readHeader) - { /*r*/ + if (readHeader) { /*r */ /* * Scan a header entry. */ readHeader = 0; code = sscanf(tbuffer, "%s %s", serverName, vsname); - if ( (code != 2) - || (strcmp(serverName, "volumeset") != 0) - ) - { + if ((code != 2) + || (strcmp(serverName, "volumeset") != 0) + ) { com_err(whoami, 0, "Bad volume header line: '%s'", tbuffer); - return(-1); + return (-1); } /* Create and fill in the volume set descriptor structure from * the info just read placing it at the head of its queue in the * global configuration structure. */ - tvs = (struct bc_volumeSet *) malloc(sizeof(struct bc_volumeSet)); + tvs = (struct bc_volumeSet *)malloc(sizeof(struct bc_volumeSet)); memset(tvs, 0, sizeof(*tvs)); - tvs->name = (char *) malloc(strlen(vsname)+1); + tvs->name = (char *)malloc(strlen(vsname) + 1); strcpy(tvs->name, vsname); /* append to the end */ - for(ppvs = &bc_globalConfig->vset, pvs = *ppvs; pvs; ppvs = &pvs->next, pvs = *ppvs); + for (ppvs = &bc_globalConfig->vset, pvs = *ppvs; pvs; + ppvs = &pvs->next, pvs = *ppvs); *ppvs = tvs; - tvs->next = (struct bc_volumeSet *) 0; - } /*r*/ - else - { /*e*/ + tvs->next = (struct bc_volumeSet *)0; + } /*r */ + else { /*e */ /* Scan a volume name entry, which contains the server name, * partition pattern, and volume pattern. */ code = sscanf(tbuffer, "%s %s %s", serverName, partName, vsname); - if (code == 1 && strcmp(serverName, "end") == 0) - { + if (code == 1 && strcmp(serverName, "end") == 0) { /* This was really a line delimiting the current volume set. * Next time around, we should try to read a header. */ @@ -524,71 +539,72 @@ bc_ParseVolumeSet() * spec record, then get the rest of the information regarding * the host, and stuff everything into place. */ - tve = (struct bc_volumeEntry *) - malloc(sizeof(struct bc_volumeEntry)); - if (!tve) - { - com_err(whoami,0, "Can't malloc() a new volume spec record!"); - return(-1); + tve = (struct bc_volumeEntry *) + malloc(sizeof(struct bc_volumeEntry)); + if (!tve) { + com_err(whoami, 0, + "Can't malloc() a new volume spec record!"); + return (-1); } memset(tve, 0, sizeof(*tve)); if (bc_ParseHost(serverName, &(tve->server))) - com_err(whoami,0, "Can't get required info on host '%s'", serverName); + com_err(whoami, 0, "Can't get required info on host '%s'", + serverName); /* The above code has filled in the server sockaddr, now fill in * the rest of the fields. */ - tve->serverName = (char *) malloc(strlen(serverName)+1); - if (!tve->serverName) - { - com_err(whoami,0,"Can't malloc() a new volume spec server name field!"); - return(-1); + tve->serverName = (char *)malloc(strlen(serverName) + 1); + if (!tve->serverName) { + com_err(whoami, 0, + "Can't malloc() a new volume spec server name field!"); + return (-1); } strcpy(tve->serverName, serverName); - tve->partname = (char *) malloc(strlen(partName)+1); - if (!tve->partname) - { - com_err(whoami,0, "Can't malloc() a new volume spec partition pattern field!"); - return(-1); + tve->partname = (char *)malloc(strlen(partName) + 1); + if (!tve->partname) { + com_err(whoami, 0, + "Can't malloc() a new volume spec partition pattern field!"); + return (-1); } strcpy(tve->partname, partName); code = bc_GetPartitionID(partName, &tve->partition); - if (code) - { - com_err(whoami,0, "Can't parse partition '%s'", partName); + if (code) { + com_err(whoami, 0, "Can't parse partition '%s'", partName); return -1; } - tp = (char *) malloc(strlen(vsname)+1); - if (!tp) - { - com_err(whoami,0, "Can't malloc() a new volume spec volume pattern field!"); - return(-1); + tp = (char *)malloc(strlen(vsname) + 1); + if (!tp) { + com_err(whoami, 0, + "Can't malloc() a new volume spec volume pattern field!"); + return (-1); } strcpy(tp, vsname); - tve->name = tp; + tve->name = tp; /* Now, thread it onto the list of other volume spec entries for * the current volume set. */ - for(ppve = &tvs->ventries, pve = *ppve; pve; ppve = &pve->next, pve = *ppve); + for (ppve = &tvs->ventries, pve = *ppve; pve; + ppve = &pve->next, pve = *ppve); *ppve = tve; - tve->next = (struct bc_volumeEntry *) 0; + tve->next = (struct bc_volumeEntry *)0; } - } /*forever loop*/ + } /*forever loop */ /* If we hit an EOF in the middle of a volume set record, we bitch and * moan. */ if (!readHeader) - return(-1); + return (-1); /* * Well, we did it. Return successfully. */ - return(0); + return (0); -} /*bc_ParseVolumeSet*/ +} /*bc_ParseVolumeSet */ /* bc_SaveVolumeSet * save the current volume set information to disk @@ -611,35 +627,37 @@ bc_SaveVolumeSet() configPtr = bc_globalConfig; /* must be locked */ - if ( ctPtr->lockHandle == 0 ) - return(BC_INTERNALERROR); + if (ctPtr->lockHandle == 0) + return (BC_INTERNALERROR); /* truncate the file */ code = ftruncate(fileno(stream), 0); - if ( code ) - ERROR(errno); + if (code) + ERROR(errno); rewind(stream); /* now write the volumeset information */ - for(tset = bc_globalConfig->vset; tset != 0; tset=tset->next) { - if (tset->flags & VSFLAG_TEMPORARY) continue; /* skip temporary entries */ + for (tset = bc_globalConfig->vset; tset != 0; tset = tset->next) { + if (tset->flags & VSFLAG_TEMPORARY) + continue; /* skip temporary entries */ fprintf(stream, "volumeset %s\n", tset->name); - for(tentry=tset->ventries; tentry; tentry=tentry->next) { - fprintf(stream, "%s %s %s\n", tentry->serverName, tentry->partname, tentry->name); + for (tentry = tset->ventries; tentry; tentry = tentry->next) { + fprintf(stream, "%s %s %s\n", tentry->serverName, + tentry->partname, tentry->name); } fprintf(stream, "end\n"); } if (ferror(stream)) - return(BC_INTERNALERROR); + return (BC_INTERNALERROR); /* send to server */ code = bcdb_SaveTextFile(ctPtr); - if ( code ) - ERROR(code); + if (code) + ERROR(code); /* do this on bcdb_SaveTextFile */ /* increment local version number */ @@ -648,67 +666,68 @@ bc_SaveVolumeSet() /* update locally stored file size */ ctPtr->textSize = filesize(ctPtr->textStream); -error_exit: - return(code); + error_exit: + return (code); } -afs_int32 bc_UpdateVolumeSet() +afs_int32 +bc_UpdateVolumeSet() { struct bc_dumpSchedule *dumpPtr, *nextDumpPtr; struct udbHandleS *uhptr = &udbHandle; udbClientTextP ctPtr; afs_int32 code; - int lock=0; + int lock = 0; /* lock schedules and check validity */ ctPtr = &bc_globalConfig->configText[TB_VOLUMESET]; /* Don't need a lock to check the version */ code = bc_CheckTextVersion(ctPtr); - if ( code != BC_VERSIONMISMATCH ) - { - ERROR(code); /* version matches or some other error */ + if (code != BC_VERSIONMISMATCH) { + ERROR(code); /* version matches or some other error */ } /* Must update the volume sets */ /* If no lock alredy taken, then lock it */ - if ( ctPtr->lockHandle == 0 ) - { - code = bc_LockText(ctPtr); - if ( code ) - ERROR(code); + if (ctPtr->lockHandle == 0) { + code = bc_LockText(ctPtr); + if (code) + ERROR(code); lock = 1; } - if (ctPtr->textVersion != -1) - { - printf("backup: obsolete volumesets - updating\n"); - bc_ClearVolumeSets(); + if (ctPtr->textVersion != -1) { + printf("backup: obsolete volumesets - updating\n"); + bc_ClearVolumeSets(); } - + /* open a temp file to store the config text received from buserver * * The open file stream is stored in ctPtr->textStream */ - code = bc_openTextFile(ctPtr, &bc_globalConfig->tmpTextFileNames[TB_VOLUMESET][0]); - if ( code ) - ERROR(code); + code = + bc_openTextFile(ctPtr, + &bc_globalConfig->tmpTextFileNames[TB_VOLUMESET][0]); + if (code) + ERROR(code); /* now get a fresh set of information from the database */ code = bcdb_GetTextFile(ctPtr); - if ( code ) - ERROR(code); + if (code) + ERROR(code); - /* fetch the version number */ - code = ubik_Call(BUDB_GetTextVersion, uhptr->uh_client, 0, - ctPtr->textType, &ctPtr->textVersion); - if ( code ) + /* fetch the version number */ + code = + ubik_Call(BUDB_GetTextVersion, uhptr->uh_client, 0, ctPtr->textType, + &ctPtr->textVersion); + if (code) ERROR(code); /* parse the file */ code = bc_ParseVolumeSet(); - if ( code ) - ERROR(code); + if (code) + ERROR(code); -error_exit: - if ( lock && ctPtr->lockHandle ) + error_exit: + if (lock && ctPtr->lockHandle) bc_UnlockText(ctPtr); - return(code); + return (code); } diff --git a/src/bucoord/volstub.c b/src/bucoord/volstub.c index 9505e28a2..79ba6e0e7 100644 --- a/src/bucoord/volstub.c +++ b/src/bucoord/volstub.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -22,7 +23,7 @@ RCSID("$Header$"); #include #endif #include -#include /*Misc server-side Volume Location stuff*/ +#include /*Misc server-side Volume Location stuff */ #include #include "volser.h" #include "bc.h" @@ -35,16 +36,18 @@ extern char *whoami; /* Volserver routines */ /* ********************************************************************* */ -afs_int32 bc_GetEntryByID(uclient, volID, volType, vldbEntryPtr) - struct ubik_client *uclient; - afs_int32 volID; - afs_int32 volType; - struct vldbentry *vldbEntryPtr; +afs_int32 +bc_GetEntryByID(uclient, volID, volType, vldbEntryPtr) + struct ubik_client *uclient; + afs_int32 volID; + afs_int32 volType; + struct vldbentry *vldbEntryPtr; { afs_int32 code = 0; - code = ubik_Call(VL_GetEntryByID, uclient, 0, volID, volType, vldbEntryPtr); - return(code); + code = + ubik_Call(VL_GetEntryByID, uclient, 0, volID, volType, vldbEntryPtr); + return (code); } /* volImageTime @@ -58,51 +61,49 @@ afs_int32 bc_GetEntryByID(uclient, volID, volType, vldbEntryPtr) */ afs_int32 -volImageTime (serv, part, volid, voltype, clDatePtr) - afs_int32 serv; - afs_int32 part; - afs_int32 volid; - afs_int32 voltype; - afs_int32 *clDatePtr; +volImageTime(serv, part, volid, voltype, clDatePtr) + afs_int32 serv; + afs_int32 part; + afs_int32 volid; + afs_int32 voltype; + afs_int32 *clDatePtr; { afs_int32 code = 0; struct volintInfo *viptr; - if (voltype == RWVOL) - { - *clDatePtr = time(0); - return(0); + if (voltype == RWVOL) { + *clDatePtr = time(0); + return (0); } code = UV_ListOneVolume(htonl(serv), part, volid, &viptr); - if (code) - { - com_err(whoami, code, - "Warning: Can't get clone time of volume %u - using 0", volid); + if (code) { + com_err(whoami, code, + "Warning: Can't get clone time of volume %u - using 0", + volid); *clDatePtr = 0; - return(0); + return (0); } /* volume types from vol/voldefs.h */ - switch ( viptr->type ) - { - case RWVOL: + switch (viptr->type) { + case RWVOL: /* For a r/w volume there may not be any foolproof way of * preventing anomalies in the backups. Use the current time; */ *clDatePtr = time(0); break; - case ROVOL: - case BACKVOL: - *clDatePtr = viptr->creationDate; /* use the creation time */ + case ROVOL: + case BACKVOL: + *clDatePtr = viptr->creationDate; /* use the creation time */ break; - - default: - com_err(whoami, 0, - "Can't get clone time of volume %u - unknown volume type", volid); - return(-1); + + default: + com_err(whoami, 0, + "Can't get clone time of volume %u - unknown volume type", + volid); + return (-1); } - return(0); + return (0); } - diff --git a/src/budb/budb_client.p.h b/src/budb/budb_client.p.h index f2af7c0cb..7be2e3d84 100644 --- a/src/budb/budb_client.p.h +++ b/src/budb/budb_client.p.h @@ -11,7 +11,7 @@ #define __BUDB_CLIENT__ #include -#ifndef BUDB_MAJORVERSION /* get the installed RPC stuff */ +#ifndef BUDB_MAJORVERSION /* get the installed RPC stuff */ #include #include #include @@ -20,37 +20,35 @@ /* for ubik_Call_SingleServer */ -#define UF_SINGLESERVER 1 /* begin single server operation */ -#define UF_END_SINGLESERVER 2 /* terminate single server operation */ +#define UF_SINGLESERVER 1 /* begin single server operation */ +#define UF_END_SINGLESERVER 2 /* terminate single server operation */ /* handle for the ubik database connection */ -struct udbHandleS -{ - afs_int32 uh_scIndex; /* what type of sec. object */ - struct rx_securityClass *uh_secobj; /* security object */ - struct rx_connection *uh_serverConn[MAXSERVERS]; /* server connections*/ - struct ubik_client *uh_client; /* ubik client handle */ - afs_uint32 uh_instanceId; /* instance of client */ +struct udbHandleS { + afs_int32 uh_scIndex; /* what type of sec. object */ + struct rx_securityClass *uh_secobj; /* security object */ + struct rx_connection *uh_serverConn[MAXSERVERS]; /* server connections */ + struct ubik_client *uh_client; /* ubik client handle */ + afs_uint32 uh_instanceId; /* instance of client */ }; -typedef struct udbHandleS udbHandleT; -typedef udbHandleT *udbHandleP; +typedef struct udbHandleS udbHandleT; +typedef udbHandleT *udbHandleP; /* suggested text block management structure */ -struct udbClientTextS -{ - char *textName; /* for info. only */ - afs_int32 textType; /* used as key for access */ - afs_uint32 textVersion; /* version # for cache mgmt */ - afs_uint32 lockHandle; /* for atomicity */ - afs_int32 textSize; /* no. of bytes */ - FILE *textStream; /* file stream or NULL */ +struct udbClientTextS { + char *textName; /* for info. only */ + afs_int32 textType; /* used as key for access */ + afs_uint32 textVersion; /* version # for cache mgmt */ + afs_uint32 lockHandle; /* for atomicity */ + afs_int32 textSize; /* no. of bytes */ + FILE *textStream; /* file stream or NULL */ }; -typedef struct udbClientTextS udbClientTextT; -typedef udbClientTextT *udbClientTextP; +typedef struct udbClientTextS udbClientTextT; +typedef udbClientTextT *udbClientTextP; #endif diff --git a/src/budb/database.c b/src/budb/database.c index ebc38be66..af6cd3aaf 100644 --- a/src/budb/database.c +++ b/src/budb/database.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -36,25 +37,28 @@ RCSID("$Header$"); #endif -int pollCount; -struct memoryDB db; /* really allocate it here */ +int pollCount; +struct memoryDB db; /* really allocate it here */ -void db_panic (reason) - char *reason; +void +db_panic(reason) + char *reason; { LogError(0, "db_panic: %s\n", reason); BUDB_EXIT(-1); } -afs_int32 InitDB () -{ afs_int32 code; +afs_int32 +InitDB() +{ + afs_int32 code; pollCount = 0; memset(&db, 0, sizeof(db)); - Lock_Init (&db.lock); - if ((code = InitDBalloc ()) || (code = InitDBhash ())) - return code; + Lock_Init(&db.lock); + if ((code = InitDBalloc()) || (code = InitDBhash())) + return code; return 0; } @@ -70,37 +74,34 @@ afs_int32 InitDB () * len - size of the write */ -afs_int32 dbwrite (ut, pos, buff, len) - struct ubik_trans *ut; - afs_int32 pos; - char *buff; - afs_int32 len; +afs_int32 +dbwrite(ut, pos, buff, len) + struct ubik_trans *ut; + afs_int32 pos; + char *buff; + afs_int32 len; { afs_int32 code = 0; - if ( ( (pos < sizeof(db.h)) && (buff != (char *)&db.h + pos) ) || - (pos >= ntohl(db.h.eofPtr)) ) - { + if (((pos < sizeof(db.h)) && (buff != (char *)&db.h + pos)) + || (pos >= ntohl(db.h.eofPtr))) { Log("dbwrite: Illegal attempt to write at location 0 or past EOF\n"); ERROR(BUDB_IO); } code = ubik_Seek(ut, 0, pos); - if (code) - { + if (code) { LogError(code, "dbwrite: ubik_Seek to %d failed\n", pos); ERROR(code); } - code = ubik_Write(ut,buff,len); - if (code) - { + code = ubik_Write(ut, buff, len); + if (code) { LogError(code, "dbwrite: ubik_Write failed\n"); ERROR(code); } error_exit: - if (((++pollCount) % 4) == 0) /* Poll every 4 reads/writes */ - { + if (((++pollCount) % 4) == 0) { /* Poll every 4 reads/writes */ IOMGR_Poll(); pollCount = 0; } @@ -109,36 +110,34 @@ afs_int32 dbwrite (ut, pos, buff, len) /* same thing for read */ -afs_int32 dbread (ut, pos, buff, len) - struct ubik_trans *ut; - afs_int32 pos; - char *buff; - afs_int32 len; +afs_int32 +dbread(ut, pos, buff, len) + struct ubik_trans *ut; + afs_int32 pos; + char *buff; + afs_int32 len; { afs_int32 code = 0; - if (pos >= ntohl(db.h.eofPtr)) - { + if (pos >= ntohl(db.h.eofPtr)) { LogError(0, "dbread: Attempt to read @%d (past EOF)\n", pos); ERROR(BUDB_IO); } code = ubik_Seek(ut, 0, pos); - if (code) - { + if (code) { LogError(code, "dbread: ubik_Seek to %d failed\n", pos); ERROR(code); } code = ubik_Read(ut, buff, len); - if (code) - { - LogError(code, "dbread: ubik_Read pos %d, buff %d, len %d\n", pos, buff, len); + if (code) { + LogError(code, "dbread: ubik_Read pos %d, buff %d, len %d\n", pos, + buff, len); ERROR(code); } error_exit: - if (((++pollCount) % 4) == 0) /* Poll every 4 reads/writes */ - { + if (((++pollCount) % 4) == 0) { /* Poll every 4 reads/writes */ IOMGR_Poll(); pollCount = 0; } @@ -146,39 +145,37 @@ afs_int32 dbread (ut, pos, buff, len) } /* Same as dbread excepts it does checking */ -afs_int32 cdbread (ut, type, pos, buff, len) - struct ubik_trans *ut; - int type; - afs_int32 pos; - char *buff; - afs_int32 len; +afs_int32 +cdbread(ut, type, pos, buff, len) + struct ubik_trans *ut; + int type; + afs_int32 pos; + char *buff; + afs_int32 len; { afs_int32 code = 0; code = checkDiskAddress(pos, type, 0, 0); - if (code) - { - LogError(code, "cdbread: Bad Address for block %d (addr 0x%x)\n", + if (code) { + LogError(code, "cdbread: Bad Address for block %d (addr 0x%x)\n", type, pos); ERROR(code); } code = ubik_Seek(ut, 0, pos); - if (code) - { + if (code) { LogError(code, "cdbread: ubik_Seek to 0x%x failed\n", pos); ERROR(code); } code = ubik_Read(ut, buff, len); - if (code) - { - LogError(code, "cdbread: ubik_Read pos 0x%x, buff %d, len %d\n", pos, buff, len); + if (code) { + LogError(code, "cdbread: ubik_Read pos 0x%x, buff %d, len %d\n", pos, + buff, len); ERROR(code); } error_exit: - if (((++pollCount) % 4) == 0) /* Poll every 4 reads/writes */ - { + if (((++pollCount) % 4) == 0) { /* Poll every 4 reads/writes */ IOMGR_Poll(); pollCount = 0; } @@ -189,46 +186,45 @@ afs_int32 cdbread (ut, type, pos, buff, len) manner, to avoid bogusly reinitializing the db. */ afs_int32 -CheckInit (ut, db_init) +CheckInit(ut, db_init) struct ubik_trans *ut; - int (*db_init)(); /* procedure to call if rebuilding DB */ -{ + int (*db_init) (); /* procedure to call if rebuilding DB */ +{ register afs_int32 code; /* Don't read header if not necessary */ - if (!ubik_CacheUpdate (ut)) return 0; + if (!ubik_CacheUpdate(ut)) + return 0; - ObtainWriteLock (&db.lock); + ObtainWriteLock(&db.lock); db.h.eofPtr = htonl(sizeof(db.h)); /* for sanity check in dbread */ - code = dbread(ut, 0, (char *) &db.h, sizeof(db.h)); - if (code) ERROR(code); + code = dbread(ut, 0, (char *)&db.h, sizeof(db.h)); + if (code) + ERROR(code); - if ((ntohl(db.h.version) != BUDB_VERSION) || (ntohl(db.h.checkVersion) != BUDB_VERSION)) - { + if ((ntohl(db.h.version) != BUDB_VERSION) + || (ntohl(db.h.checkVersion) != BUDB_VERSION)) { - if ((ntohl(db.h.version) == 0) || (ntohl(db.h.checkVersion) == 0)) + if ((ntohl(db.h.version) == 0) || (ntohl(db.h.checkVersion) == 0)) ERROR(BUDB_EMPTY); - LogError(0, "DB version should be %d; Initial = %d; Terminal = %d\n", - BUDB_VERSION, ntohl(db.h.version), ntohl(db.h.checkVersion)); + LogError(0, "DB version should be %d; Initial = %d; Terminal = %d\n", + BUDB_VERSION, ntohl(db.h.version), ntohl(db.h.checkVersion)); ERROR(BUDB_IO); } db.readTime = time(0); - ht_Reset (&db.volName); - ht_Reset (&db.tapeName); - ht_Reset (&db.dumpName); - ht_Reset (&db.dumpIden); + ht_Reset(&db.volName); + ht_Reset(&db.tapeName); + ht_Reset(&db.dumpName); + ht_Reset(&db.dumpIden); error_exit: - ReleaseWriteLock (&db.lock); - if (code) - { - if ((code == UEOF) || (code == BUDB_EMPTY)) - { - if (db_init) - { + ReleaseWriteLock(&db.lock); + if (code) { + if ((code == UEOF) || (code == BUDB_EMPTY)) { + if (db_init) { LogDebug(0, "No data base - Building new one\n"); /* try to write a good header */ @@ -239,20 +235,18 @@ CheckInit (ut, db_init) db.h.eofPtr = htonl(sizeof(db.h)); /* text ptrs cleared by bzero */ - ht_DBInit (); - - code = dbwrite(ut, 0, (char *) &db.h, sizeof(db.h)); - if (code) code = BUDB_IO; /* return the error code */ - else code = db_init(ut); /* initialize the db */ + ht_DBInit(); + + code = dbwrite(ut, 0, (char *)&db.h, sizeof(db.h)); + if (code) + code = BUDB_IO; /* return the error code */ + else + code = db_init(ut); /* initialize the db */ + } else { + LogDebug(0, "No data base\n"); + code = BUDB_EMPTY; } - else - { - LogDebug(0, "No data base\n"); - code = BUDB_EMPTY; - } - } - else - { + } else { LogDebug(0, "I/O Error\n"); code = BUDB_IO; } diff --git a/src/budb/database.h b/src/budb/database.h index 337159cef..6598e6c01 100644 --- a/src/budb/database.h +++ b/src/budb/database.h @@ -15,39 +15,37 @@ typedef afs_uint32 dbadr; struct hashTable { - afs_int32 functionType; /* type of hash function */ - afs_int32 threadOffset; /* Byte offset of hash thread */ - afs_int32 entries; /* number of entries in hash table */ - afs_int32 length; /* number of hash table slots */ - dbadr table; /* pointer to actual table */ - afs_int32 progress; /* number empty buckets in oldTable */ - afs_int32 oldLength; /* slots in old table */ - dbadr oldTable; /* old table */ + afs_int32 functionType; /* type of hash function */ + afs_int32 threadOffset; /* Byte offset of hash thread */ + afs_int32 entries; /* number of entries in hash table */ + afs_int32 length; /* number of hash table slots */ + dbadr table; /* pointer to actual table */ + afs_int32 progress; /* number empty buckets in oldTable */ + afs_int32 oldLength; /* slots in old table */ + dbadr oldTable; /* old table */ }; /* text blocks and related structures */ -struct textBlock -{ - afs_uint32 version; /* for access consistency checks */ - afs_int32 size; /* size in bytes */ - dbadr textAddr; /* list of blocks */ - afs_int32 newsize; /* replacement size */ - dbadr newTextAddr; /* list of new blocks */ +struct textBlock { + afs_uint32 version; /* for access consistency checks */ + afs_int32 size; /* size in bytes */ + dbadr textAddr; /* list of blocks */ + afs_int32 newsize; /* replacement size */ + dbadr newTextAddr; /* list of new blocks */ }; -struct db_lockS -{ - afs_int32 type; /* user defined - for consistency checks */ - afs_int32 lockState; /* locked/free */ - afs_int32 lockTime; /* when locked */ - afs_int32 expires; /* when timeout expires */ - afs_int32 instanceId; /* user instance id */ - int lockHost; /* locking host, if possible */ +struct db_lockS { + afs_int32 type; /* user defined - for consistency checks */ + afs_int32 lockState; /* locked/free */ + afs_int32 lockTime; /* when locked */ + afs_int32 expires; /* when timeout expires */ + afs_int32 instanceId; /* user instance id */ + int lockHost; /* locking host, if possible */ }; -typedef struct db_lockS db_lockT; -typedef db_lockT *db_lockP; +typedef struct db_lockS db_lockT; +typedef db_lockT *db_lockP; /* hash table function types */ #define HT_dumpIden_FUNCTION 1 @@ -75,23 +73,23 @@ typedef db_lockT *db_lockP; #define BUDB_VERSION 1 struct dbHeader { - afs_int32 version; /* database version number */ - dumpId lastDumpId; /* last dump id value */ - afs_uint32 lastTapeId; /* last tape id allocated */ - afs_uint32 lastInstanceId; /* last instance Id handed out */ + afs_int32 version; /* database version number */ + dumpId lastDumpId; /* last dump id value */ + afs_uint32 lastTapeId; /* last tape id allocated */ + afs_uint32 lastInstanceId; /* last instance Id handed out */ dbadr freePtrs[NBLOCKTYPES]; /* pointers to free blocks */ - dbadr eofPtr; /* first free byte in db */ - afs_int32 nHTBuckets; /* size of hashtable blocks */ - Date lastUpdate; /* time of last change to database */ - afs_int32 ptrs[10]; /* spare pointers */ - struct hashTable volName; /* hash tables */ + dbadr eofPtr; /* first free byte in db */ + afs_int32 nHTBuckets; /* size of hashtable blocks */ + Date lastUpdate; /* time of last change to database */ + afs_int32 ptrs[10]; /* spare pointers */ + struct hashTable volName; /* hash tables */ struct hashTable tapeName; struct hashTable dumpName; struct hashTable dumpIden; - db_lockT textLocks[TB_MAX]; /* locks for text blocks */ + db_lockT textLocks[TB_MAX]; /* locks for text blocks */ struct textBlock textBlock[TB_MAX]; /* raw text information */ - afs_int32 words[10]; /* spare words */ - afs_int32 checkVersion; /* version# for consistency checking */ + afs_int32 words[10]; /* spare words */ + afs_int32 checkVersion; /* version# for consistency checking */ }; /* The database is composed of several types of structures of different sizes. @@ -106,17 +104,17 @@ struct dbHeader { sizeof(struct dbHeader)) struct blockHeader { - char type; /* type: implies structure size */ - char flags; /* miscellaneous bits */ - short nFree; /* number of free structures */ - dbadr next; /* next free block same type */ + char type; /* type: implies structure size */ + char flags; /* miscellaneous bits */ + short nFree; /* number of free structures */ + dbadr next; /* next free block same type */ }; #define BLOCK_DATA_SIZE (BLOCKSIZE-sizeof(struct blockHeader)) struct block { struct blockHeader h; - char a[BLOCKSIZE-sizeof(struct blockHeader)]; + char a[BLOCKSIZE - sizeof(struct blockHeader)]; }; #define NhtBucketS ((BLOCKSIZE-sizeof(struct blockHeader))/sizeof(dbadr)) @@ -130,25 +128,25 @@ struct htBlock { #define VOLFRAGMENTFLAGS 0xffff struct volFragment { - dbadr vol; /* full volume info */ - dbadr sameNameChain; /* next with same vol info */ - dbadr tape; /* tape containing this fragment */ - dbadr sameTapeChain; /* next fragment on tape */ - - afs_int32 position; /* on tape */ - Date clone; /* clone date of volume */ - Date incTime; /* time for incremental; 0 => full */ - afs_int32 startByte; /* first byte of volume in this frag */ - afs_uint32 nBytes; /* bytes in fragment */ - short flags; /* miscellaneous bits */ - short sequence; /* seq of frag in dumped volume */ + dbadr vol; /* full volume info */ + dbadr sameNameChain; /* next with same vol info */ + dbadr tape; /* tape containing this fragment */ + dbadr sameTapeChain; /* next fragment on tape */ + + afs_int32 position; /* on tape */ + Date clone; /* clone date of volume */ + Date incTime; /* time for incremental; 0 => full */ + afs_int32 startByte; /* first byte of volume in this frag */ + afs_uint32 nBytes; /* bytes in fragment */ + short flags; /* miscellaneous bits */ + short sequence; /* seq of frag in dumped volume */ }; #define NvolFragmentS 45 struct vfBlock { struct blockHeader h; struct { struct volFragment s; - char pad[4]; + char pad[4]; } a[NvolFragmentS]; }; @@ -159,24 +157,24 @@ struct vfBlock { #define VOLINFOFLAGS 0xffff0000 struct volInfo { - char name[BU_MAXNAMELEN]; /* name of volume: the hash key */ - afs_int32 flags; /* miscellaneous bits */ - afs_int32 id; /* read-write volume's id */ - char server[BU_MAXHOSTLEN]; /* file server */ - afs_int32 partition; /* disk partition on server */ - afs_int32 nFrags; /* number of fragments on list */ - - dbadr nameHashChain; /* for volume name hash table */ - dbadr sameNameHead; /* volInfo of first struct this name */ - dbadr sameNameChain; /* next volume with this name */ - dbadr firstFragment; /* all volFragment with this volInfo */ + char name[BU_MAXNAMELEN]; /* name of volume: the hash key */ + afs_int32 flags; /* miscellaneous bits */ + afs_int32 id; /* read-write volume's id */ + char server[BU_MAXHOSTLEN]; /* file server */ + afs_int32 partition; /* disk partition on server */ + afs_int32 nFrags; /* number of fragments on list */ + + dbadr nameHashChain; /* for volume name hash table */ + dbadr sameNameHead; /* volInfo of first struct this name */ + dbadr sameNameChain; /* next volume with this name */ + dbadr firstFragment; /* all volFragment with this volInfo */ }; #define NvolInfoS 20 struct viBlock { struct blockHeader h; struct { struct volInfo s; - char pad[4]; + char pad[4]; } a[NvolInfoS]; }; @@ -185,26 +183,25 @@ struct viBlock { * backup system. Some of the data may persist event though the tape's * contents are repeatedly overwritten. */ -struct tape -{ - char name[BU_MAXTAPELEN]; /* name of physical tape */ - afs_int32 flags; /* miscellaneous bits */ - Date written; /* tape writing started */ - Date expires; /* expiration date */ - afs_uint32 nMBytes; /* length of tape in Mbytes */ - afs_uint32 nBytes; /* remainder of Mbytes */ - afs_int32 nFiles; /* ditto for EOFs */ - afs_int32 nVolumes; /* ditto for volume fragments */ - afs_int32 seq; /* sequence in tapeSet */ - - afs_uint32 labelpos; /* Position of the tape label */ - afs_int32 useCount; /* # of times used */ - afs_int32 useKBytes; /* How much of tape is used (in KBytes) */ - - dbadr nameHashChain; /* for tape name hash table */ - dbadr dump; /* dump (tapeSet) this is part of */ - dbadr nextTape; /* next tape in dump (tapeSet) */ - dbadr firstVol; /* first volume fragment on tape */ +struct tape { + char name[BU_MAXTAPELEN]; /* name of physical tape */ + afs_int32 flags; /* miscellaneous bits */ + Date written; /* tape writing started */ + Date expires; /* expiration date */ + afs_uint32 nMBytes; /* length of tape in Mbytes */ + afs_uint32 nBytes; /* remainder of Mbytes */ + afs_int32 nFiles; /* ditto for EOFs */ + afs_int32 nVolumes; /* ditto for volume fragments */ + afs_int32 seq; /* sequence in tapeSet */ + + afs_uint32 labelpos; /* Position of the tape label */ + afs_int32 useCount; /* # of times used */ + afs_int32 useKBytes; /* How much of tape is used (in KBytes) */ + + dbadr nameHashChain; /* for tape name hash table */ + dbadr dump; /* dump (tapeSet) this is part of */ + dbadr nextTape; /* next tape in dump (tapeSet) */ + dbadr firstVol; /* first volume fragment on tape */ }; #define NtapeS 20 @@ -212,7 +209,7 @@ struct tBlock { struct blockHeader h; struct { struct tape s; - char pad[8]; + char pad[8]; } a[NtapeS]; }; @@ -220,38 +217,37 @@ struct tBlock { * on at least one tape. */ -struct dump -{ +struct dump { /* similar to budb_dumpEntry */ - afs_int32 id; /* unique identifier for dump */ - dumpId parent; /* parent dump */ - afs_int32 level; /* dump level */ - afs_int32 flags; /* miscellaneous bits */ - char volumeSet[BU_MAXNAMELEN]; /* name of volume that was dumped */ - char dumpPath[BU_MAX_DUMP_PATH]; /* "path" name of dump level */ - char dumpName[BU_MAXNAMELEN]; /* dump name */ - Date created; /* time dump initiated */ + afs_int32 id; /* unique identifier for dump */ + dumpId parent; /* parent dump */ + afs_int32 level; /* dump level */ + afs_int32 flags; /* miscellaneous bits */ + char volumeSet[BU_MAXNAMELEN]; /* name of volume that was dumped */ + char dumpPath[BU_MAX_DUMP_PATH]; /* "path" name of dump level */ + char dumpName[BU_MAXNAMELEN]; /* dump name */ + Date created; /* time dump initiated */ /* Date incTime; target time for incremental dumps */ - afs_int32 nVolumes; /* number of volumes in dump */ - struct budb_tapeSet tapes; /* tapes for this dump */ + afs_int32 nVolumes; /* number of volumes in dump */ + struct budb_tapeSet tapes; /* tapes for this dump */ struct ktc_principal dumper; /* user doing dump */ - afs_uint32 initialDumpID; /* The dumpid of the initisl dump (for appended dumps) */ - dbadr appendedDumpChain; /* Ptr to dump appended to this dump */ + afs_uint32 initialDumpID; /* The dumpid of the initisl dump (for appended dumps) */ + dbadr appendedDumpChain; /* Ptr to dump appended to this dump */ - dbadr idHashChain; /* for dump id hash table */ - dbadr nameHashChain; /* for dump name hash table */ - dbadr firstTape; /* first tape in dump (tapeSet) */ + dbadr idHashChain; /* for dump id hash table */ + dbadr nameHashChain; /* for dump name hash table */ + dbadr firstTape; /* first tape in dump (tapeSet) */ }; -typedef struct dump dbDumpT; -typedef dbDumpT *dbDumpP; +typedef struct dump dbDumpT; +typedef dbDumpT *dbDumpP; #define NdumpS 3 struct dBlock { struct blockHeader h; struct { struct dump s; - char pad[44]; + char pad[44]; } a[NdumpS]; }; @@ -261,28 +257,28 @@ struct dBlock { table together. In memory this information is inferred */ struct memoryHTBlock { - int valid; /* block needs to be read in */ - dbadr a; /* where stored in db */ + int valid; /* block needs to be read in */ + dbadr a; /* where stored in db */ struct htBlock b; }; struct memoryHashTable { - struct hashTable *ht; /* ptr to appropriate db.h hashtable */ + struct hashTable *ht; /* ptr to appropriate db.h hashtable */ /* these are host byte order version of the corresponding HT fields */ - int threadOffset; /* Byte offset of hash thread */ - int length; /* number of hash table slots */ - int oldLength; /* slots in old table */ - int progress; /* number empty buckets in oldTable */ + int threadOffset; /* Byte offset of hash thread */ + int length; /* number of hash table slots */ + int oldLength; /* slots in old table */ + int progress; /* number empty buckets in oldTable */ /* these are the memory copies of the hash table buckets */ - int size; /* allocated size of array */ + int size; /* allocated size of array */ struct memoryHTBlock *(*blocks); /* ptr to array of ht block pointers */ - int oldSize; /* ditto for old HT */ + int oldSize; /* ditto for old HT */ struct memoryHTBlock *(*oldBlocks); }; -struct memoryDB { /* in core copies of database structures */ +struct memoryDB { /* in core copies of database structures */ struct Lock lock; - Date readTime; + Date readTime; struct dbHeader h; struct memoryHashTable volName; struct memoryHashTable tapeName; @@ -315,7 +311,6 @@ extern struct memoryDB db; #define MAX(x,y) ((x) > (y) ? (x) : (y)) #endif /* notdef */ -struct memoryHashTable *ht_GetType (); -extern afs_uint32 ht_HashEntry (); -extern dbadr ht_LookupBucket (); - +struct memoryHashTable *ht_GetType(); +extern afs_uint32 ht_HashEntry(); +extern dbadr ht_LookupBucket(); diff --git a/src/budb/db_alloc.c b/src/budb/db_alloc.c index 09484d357..cbdb79698 100644 --- a/src/budb/db_alloc.c +++ b/src/budb/db_alloc.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -38,7 +39,8 @@ RCSID("$Header$"); static int nEntries[NBLOCKTYPES]; static int sizeEntries[NBLOCKTYPES]; -afs_int32 InitDBalloc () +afs_int32 +InitDBalloc() { nEntries[0] = 0; sizeEntries[0] = 0; @@ -48,10 +50,10 @@ afs_int32 InitDBalloc () nEntries[tape_BLOCK] = NtapeS; nEntries[dump_BLOCK] = NdumpS; - sizeEntries[volFragment_BLOCK] = sizeof(((struct vfBlock *)NULL)->a[0]); - sizeEntries[volInfo_BLOCK] = sizeof(((struct viBlock *)NULL)->a[0]); - sizeEntries[tape_BLOCK] = sizeof(((struct tBlock *)NULL)->a[0]); - sizeEntries[dump_BLOCK] = sizeof(((struct dBlock *)NULL)->a[0]); + sizeEntries[volFragment_BLOCK] = sizeof(((struct vfBlock *) NULL)->a[0]); + sizeEntries[volInfo_BLOCK] = sizeof(((struct viBlock *) NULL)->a[0]); + sizeEntries[tape_BLOCK] = sizeof(((struct tBlock *) NULL)->a[0]); + sizeEntries[dump_BLOCK] = sizeof(((struct dBlock *) NULL)->a[0]); return 0; } @@ -65,29 +67,26 @@ afs_int32 InitDBalloc () */ afs_int32 -AllocBlock (ut, block, aP) +AllocBlock(ut, block, aP) struct ubik_trans *ut; - struct block *block; /* copy of data */ - dbadr *aP; /* db addr of block */ -{ + struct block *block; /* copy of data */ + dbadr *aP; /* db addr of block */ +{ dbadr a; - - if (db.h.freePtrs[0] == 0) - { + + if (db.h.freePtrs[0] == 0) { /* if there are no free blocks, extend the database */ LogDebug(2, "AllocBlock: extending db\n"); a = ntohl(db.h.eofPtr); - if (set_header_word (ut, eofPtr, htonl(a+BLOCKSIZE))) - return BUDB_IO; - } - else - { + if (set_header_word(ut, eofPtr, htonl(a + BLOCKSIZE))) + return BUDB_IO; + } else { a = ntohl(db.h.freePtrs[0]); - if ( dbread (ut, a, (char *)block, sizeof(block->h)) /* read hdr */ - || set_header_word (ut, freePtrs[0], block->h.next) /* set next */ - ) - return BUDB_IO; + if (dbread(ut, a, (char *)block, sizeof(block->h)) /* read hdr */ + ||set_header_word(ut, freePtrs[0], block->h.next) /* set next */ + ) + return BUDB_IO; } /* clear and return the block */ @@ -103,17 +102,19 @@ AllocBlock (ut, block, aP) * a - disk address of the block */ -afs_int32 -FreeBlock (ut, bh, a) - struct ubik_trans *ut; - struct blockHeader *bh; /* copy of data */ - dbadr a; /* db address of block */ +afs_int32 +FreeBlock(ut, bh, a) + struct ubik_trans *ut; + struct blockHeader *bh; /* copy of data */ + dbadr a; /* db address of block */ { - if (a != BlockBase(a)) db_panic ("Block addr no good"); + if (a != BlockBase(a)) + db_panic("Block addr no good"); memset(bh, 0, sizeof(*bh)); bh->next = db.h.freePtrs[0]; - if (set_header_word (ut, freePtrs[0], htonl(a)) || - dbwrite (ut, a, (char *)bh, sizeof(*bh))) return BUDB_IO; + if (set_header_word(ut, freePtrs[0], htonl(a)) + || dbwrite(ut, a, (char *)bh, sizeof(*bh))) + return BUDB_IO; return 0; } @@ -129,142 +130,138 @@ FreeBlock (ut, bh, a) afs_int32 AllocStructure(ut, type, related, saP, s) struct ubik_trans *ut; - char type; + char type; dbadr related; dbadr *saP; char *s; { - dbadr a; /* block addr */ - struct block b; /* copy of data */ - int i; /* block structure array index */ - afs_int32 *bs; /* ptr to first word of structure */ - int nFree; - - if ( (type == 0) - || (type > MAX_STRUCTURE_BLOCK_TYPE) - ) - { - db_panic ("bad structure type"); + dbadr a; /* block addr */ + struct block b; /* copy of data */ + int i; /* block structure array index */ + afs_int32 *bs; /* ptr to first word of structure */ + int nFree; + + if ((type == 0) + || (type > MAX_STRUCTURE_BLOCK_TYPE) + ) { + db_panic("bad structure type"); } - bs = (afs_int32 *)b.a; /* ptr to first structure of block */ + bs = (afs_int32 *) b.a; /* ptr to first structure of block */ - if (db.h.freePtrs[type] == 0) - { + if (db.h.freePtrs[type] == 0) { /* no free items of specified type */ - if ( AllocBlock(ut, &b, &a) - || set_header_word (ut, freePtrs[type], htonl(a)) - ) - { + if (AllocBlock(ut, &b, &a) + || set_header_word(ut, freePtrs[type], htonl(a)) + ) { return BUDB_IO; } b.h.next = 0; b.h.type = type; b.h.flags = 0; - b.h.nFree = ntohs(nEntries[type]-1); - *bs = 1; /* not free anymore */ + b.h.nFree = ntohs(nEntries[type] - 1); + *bs = 1; /* not free anymore */ - if ( dbwrite (ut, a, (char *)&b, sizeof(b)) ) + if (dbwrite(ut, a, (char *)&b, sizeof(b))) return BUDB_IO; LogDebug(2, "AllocStructure: allocated new block\n"); - } - else - { + } else { int count = 10; /* Only do 10 (or so) at a time, to avoid transactions which modify - * many buffer. + * many buffer. */ - while (1) - { + while (1) { a = ntohl(db.h.freePtrs[type]); - if ( dbread (ut, a, (char *)&b, sizeof(b)) ) + if (dbread(ut, a, (char *)&b, sizeof(b))) return BUDB_IO; nFree = ntohs(b.h.nFree); if (nFree == 0) - db_panic ("nFree is zero"); - + db_panic("nFree is zero"); + /* Completely empty blocks go to generic free list if there are * more blocks on this free list */ - if (b.h.next && (nFree == nEntries[type]) && (count-- > 0)) - { - if ( set_header_word (ut, freePtrs[type], b.h.next) - || FreeBlock (ut, &b.h, a) - ) - { + if (b.h.next && (nFree == nEntries[type]) && (count-- > 0)) { + if (set_header_word(ut, freePtrs[type], b.h.next) + || FreeBlock(ut, &b.h, a) + ) { return BUDB_IO; } LogDebug(2, "AllocStrucure: add to free block list\n"); - } - else - { + } else { /* we found a free structure */ - if (nFree == 1) - { + if (nFree == 1) { /* if last free one: unthread block */ - if (set_header_word (ut, freePtrs[type], b.h.next)) + if (set_header_word(ut, freePtrs[type], b.h.next)) return BUDB_IO; } break; } } - + /* find the free structure - arbitrarily uses first word as * allocated/free status. PA. */ i = 0; - while ( *bs ) - { + while (*bs) { i++; - bs = (afs_int32 *) ((char *) bs + sizeEntries[type]); + bs = (afs_int32 *) ((char *)bs + sizeEntries[type]); } - + if (i >= nEntries[type]) - db_panic ("free count inconsistent with block"); + db_panic("free count inconsistent with block"); b.h.nFree = htons(nFree - 1); - if (dbwrite (ut, a, (char *)&b, sizeof(b.h))) return BUDB_IO; + if (dbwrite(ut, a, (char *)&b, sizeof(b.h))) + return BUDB_IO; } - *(afs_int32 *)s = 1; /* make sure structure is not free */ + *(afs_int32 *) s = 1; /* make sure structure is not free */ *saP = a + ((char *)bs - (char *)&b); - - LogDebug(3, "allocated at %d, block at %d, offset %d\n", - *saP, a, ((char *)bs - (char *)&b) ); + + LogDebug(3, "allocated at %d, block at %d, offset %d\n", *saP, a, + ((char *)bs - (char *)&b)); /* caller must write back at least first word of structure */ return 0; } -afs_int32 FreeStructure (ut, type, sa) - struct ubik_trans *ut; - char type; /* type of structure to allocate */ - dbadr sa; /* db addr of structure */ -{ struct blockHeader bh; /* header of containing block */ - dbadr a; /* db address of block */ - int nFree; /* new free structures count */ +afs_int32 +FreeStructure(ut, type, sa) + struct ubik_trans *ut; + char type; /* type of structure to allocate */ + dbadr sa; /* db addr of structure */ +{ + struct blockHeader bh; /* header of containing block */ + dbadr a; /* db address of block */ + int nFree; /* new free structures count */ afs_int32 freeWord; if ((type == 0) || (type > MAX_STRUCTURE_BLOCK_TYPE)) - db_panic ("bad structure type"); + db_panic("bad structure type"); a = BlockBase(sa); - if (dbread(ut, a, (char *)&bh, sizeof(bh))) return BUDB_IO; - if (type != bh.type) db_panic ("block and structure of different types"); + if (dbread(ut, a, (char *)&bh, sizeof(bh))) + return BUDB_IO; + if (type != bh.type) + db_panic("block and structure of different types"); - bh.nFree = htons (nFree = ntohs(bh.nFree) + 1); - if (nFree > nEntries[type]) db_panic ("free count too large"); - if (nFree == 1) { /* add to free list for type */ + bh.nFree = htons(nFree = ntohs(bh.nFree) + 1); + if (nFree > nEntries[type]) + db_panic("free count too large"); + if (nFree == 1) { /* add to free list for type */ bh.next = db.h.freePtrs[type]; - if (set_header_word (ut, freePtrs[type], htonl(a))) return BUDB_IO; + if (set_header_word(ut, freePtrs[type], htonl(a))) + return BUDB_IO; } /* mark the structure as free, and write out block header */ - if (set_word_offset (ut, sa, &freeWord, 0, 0) || - dbwrite (ut, a, (char *)&bh, sizeof(bh))) return BUDB_IO; + if (set_word_offset(ut, sa, &freeWord, 0, 0) + || dbwrite(ut, a, (char *)&bh, sizeof(bh))) + return BUDB_IO; return 0; } diff --git a/src/budb/db_dump.c b/src/budb/db_dump.c index 1f19b76a7..587fde42c 100644 --- a/src/budb/db_dump.c +++ b/src/budb/db_dump.c @@ -15,7 +15,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -55,8 +56,8 @@ RCSID("$Header$"); /* interlocking for database dump */ -dumpSyncT dumpSync; -dumpSyncP dumpSyncPtr = &dumpSync; +dumpSyncT dumpSync; +dumpSyncP dumpSyncPtr = &dumpSync; /* canWrite @@ -76,21 +77,19 @@ canWrite(fid) ObtainWriteLock(&dumpSyncPtr->ds_lock); /* let the pipe drain */ - while ( dumpSyncPtr->ds_bytes > 0 ) - { - if ( dumpSyncPtr->ds_readerStatus == DS_WAITING ) - { - dumpSyncPtr->ds_readerStatus = 0; - code = LWP_SignalProcess(&dumpSyncPtr->ds_readerStatus); - if ( code ) + while (dumpSyncPtr->ds_bytes > 0) { + if (dumpSyncPtr->ds_readerStatus == DS_WAITING) { + dumpSyncPtr->ds_readerStatus = 0; + code = LWP_SignalProcess(&dumpSyncPtr->ds_readerStatus); + if (code) LogError(code, "canWrite: Signal delivery failed\n"); - } - dumpSyncPtr->ds_writerStatus = DS_WAITING; - ReleaseWriteLock(&dumpSyncPtr->ds_lock); - LWP_WaitProcess(&dumpSyncPtr->ds_writerStatus); - ObtainWriteLock(&dumpSyncPtr->ds_lock); + } + dumpSyncPtr->ds_writerStatus = DS_WAITING; + ReleaseWriteLock(&dumpSyncPtr->ds_lock); + LWP_WaitProcess(&dumpSyncPtr->ds_writerStatus); + ObtainWriteLock(&dumpSyncPtr->ds_lock); } - return(1); + return (1); } @@ -108,11 +107,10 @@ haveWritten(nbytes) extern dumpSyncP dumpSyncPtr; dumpSyncPtr->ds_bytes += nbytes; - if ( dumpSyncPtr->ds_readerStatus == DS_WAITING ) - { - dumpSyncPtr->ds_readerStatus = 0; - code = LWP_SignalProcess(&dumpSyncPtr->ds_readerStatus); - if ( code ) + if (dumpSyncPtr->ds_readerStatus == DS_WAITING) { + dumpSyncPtr->ds_readerStatus = 0; + code = LWP_SignalProcess(&dumpSyncPtr->ds_readerStatus); + if (code) LogError(code, "haveWritten: Signal delivery failed\n"); } ReleaseWriteLock(&dumpSyncPtr->ds_lock); @@ -124,33 +122,34 @@ haveWritten(nbytes) */ doneWriting(error) - afs_int32 error; + afs_int32 error; { afs_int32 code = 0; /* wait for the reader */ ObtainWriteLock(&dumpSyncPtr->ds_lock); - while ( dumpSyncPtr->ds_readerStatus != DS_WAITING ) - { + while (dumpSyncPtr->ds_readerStatus != DS_WAITING) { LogDebug(4, "doneWriting: waiting for Reader\n"); - dumpSyncPtr->ds_writerStatus = DS_WAITING; + dumpSyncPtr->ds_writerStatus = DS_WAITING; ReleaseWriteLock(&dumpSyncPtr->ds_lock); - LWP_WaitProcess(&dumpSyncPtr->ds_writerStatus); - ObtainWriteLock(&dumpSyncPtr->ds_lock); + LWP_WaitProcess(&dumpSyncPtr->ds_writerStatus); + ObtainWriteLock(&dumpSyncPtr->ds_lock); } LogDebug(4, "doneWriting: setting done\n"); /* signal that we are done */ - if (error) dumpSyncPtr->ds_writerStatus = DS_DONE_ERROR; - else dumpSyncPtr->ds_writerStatus = DS_DONE; + if (error) + dumpSyncPtr->ds_writerStatus = DS_DONE_ERROR; + else + dumpSyncPtr->ds_writerStatus = DS_DONE; dumpSyncPtr->ds_readerStatus = 0; code = LWP_NoYieldSignal(&dumpSyncPtr->ds_readerStatus); - if ( code ) + if (code) LogError(code, "doneWriting: Signal delivery failed\n"); ReleaseWriteLock(&dumpSyncPtr->ds_lock); } - + /* notes: * ut - setup and pass down */ @@ -169,44 +168,43 @@ writeStructHeader(fid, type) hostDumpHeader.type = type; hostDumpHeader.structversion = 1; - - switch ( type ) - { - case SD_DBHEADER: + + switch (type) { + case SD_DBHEADER: hostDumpHeader.size = sizeof(struct DbHeader); break; - case SD_DUMP: + case SD_DUMP: hostDumpHeader.size = sizeof(struct budb_dumpEntry); break; - case SD_TAPE: + case SD_TAPE: hostDumpHeader.size = sizeof(struct budb_tapeEntry); break; - case SD_VOLUME: + case SD_VOLUME: hostDumpHeader.size = sizeof(struct budb_volumeEntry); break; - case SD_END: + case SD_END: hostDumpHeader.size = 0; break; - default: + default: LogError(0, "writeStructHeader: invalid type %d\n", type); BUDB_EXIT(1); } structDumpHeader_hton(&hostDumpHeader, &netDumpHeader); - if ( canWrite(fid) <= 0 ) - return(BUDB_DUMPFAILED); - if ( write(fid, &netDumpHeader, sizeof(netDumpHeader)) != - sizeof(netDumpHeader) ) - return(BUDB_DUMPFAILED); + if (canWrite(fid) <= 0) + return (BUDB_DUMPFAILED); + if (write(fid, &netDumpHeader, sizeof(netDumpHeader)) != + sizeof(netDumpHeader)) + return (BUDB_DUMPFAILED); haveWritten(sizeof(netDumpHeader)); - - return(0); + + return (0); } /* writeTextHeader @@ -219,24 +217,23 @@ writeTextHeader(fid, type) afs_int32 type; { struct structDumpHeader hostDumpHeader, netDumpHeader; - + hostDumpHeader.structversion = 1; - switch ( type ) - { - case TB_DUMPSCHEDULE: + switch (type) { + case TB_DUMPSCHEDULE: hostDumpHeader.type = SD_TEXT_DUMPSCHEDULE; break; - case TB_VOLUMESET: + case TB_VOLUMESET: hostDumpHeader.type = SD_TEXT_VOLUMESET; break; - case TB_TAPEHOSTS: + case TB_TAPEHOSTS: hostDumpHeader.type = SD_TEXT_TAPEHOSTS; break; - default: + default: LogError(0, "writeTextHeader: invalid type %d\n", type); BUDB_EXIT(1); } @@ -245,14 +242,15 @@ writeTextHeader(fid, type) structDumpHeader_hton(&hostDumpHeader, &netDumpHeader); if (canWrite(fid) <= 0) - return(BUDB_DUMPFAILED); + return (BUDB_DUMPFAILED); - if (write(fid, &netDumpHeader, sizeof(netDumpHeader)) != sizeof(netDumpHeader)) - return(BUDB_DUMPFAILED); + if (write(fid, &netDumpHeader, sizeof(netDumpHeader)) != + sizeof(netDumpHeader)) + return (BUDB_DUMPFAILED); haveWritten(sizeof(netDumpHeader)); - - return(0); + + return (0); } afs_int32 @@ -266,7 +264,7 @@ writeDbHeader(fid) extern struct memoryDB db; /* check the memory database header for integrity */ - if ( db.h.version != db.h.checkVersion ) + if (db.h.version != db.h.checkVersion) ERROR(BUDB_DATABASEINCONSISTENT); curtime = time(0); @@ -284,29 +282,29 @@ writeDbHeader(fid) ERROR(tcode); if (canWrite(fid) <= 0) - ERROR(BUDB_DUMPFAILED); + ERROR(BUDB_DUMPFAILED); if (write(fid, &header, sizeof(header)) != sizeof(header)) - ERROR(BUDB_DUMPFAILED); + ERROR(BUDB_DUMPFAILED); haveWritten(sizeof(header)); -error_exit: - return(code); + error_exit: + return (code); } /* writeDump * write out a dump entry structure */ -afs_int32 +afs_int32 writeDump(fid, dumpPtr) int fid; dbDumpP dumpPtr; { struct budb_dumpEntry dumpEntry; afs_int32 code = 0, tcode; - + tcode = dumpToBudbDump(dumpPtr, &dumpEntry); if (tcode) ERROR(tcode); @@ -316,12 +314,12 @@ writeDump(fid, dumpPtr) if (canWrite(fid) <= 0) ERROR(BUDB_DUMPFAILED); - if ( write(fid, &dumpEntry, sizeof(dumpEntry)) != sizeof(dumpEntry) ) + if (write(fid, &dumpEntry, sizeof(dumpEntry)) != sizeof(dumpEntry)) ERROR(BUDB_DUMPFAILED); haveWritten(sizeof(dumpEntry)); -error_exit: - return(code); + error_exit: + return (code); } afs_int32 @@ -332,7 +330,7 @@ writeTape(fid, tapePtr, dumpid) { struct budb_tapeEntry tapeEntry; afs_int32 code = 0, tcode; - + tcode = writeStructHeader(fid, SD_TAPE); if (tcode) ERROR(tcode); @@ -349,8 +347,8 @@ writeTape(fid, tapePtr, dumpid) haveWritten(sizeof(tapeEntry)); -error_exit: - return(code); + error_exit: + return (code); } /* combines volFragment and volInfo */ @@ -360,13 +358,13 @@ writeVolume(ut, fid, volFragmentPtr, volInfoPtr, dumpid, tapeName) struct ubik_trans *ut; int fid; struct volFragment *volFragmentPtr; - struct volInfo *volInfoPtr; + struct volInfo *volInfoPtr; afs_int32 dumpid; char *tapeName; { struct budb_volumeEntry budbVolume; afs_int32 code = 0; - + volsToBudbVol(volFragmentPtr, volInfoPtr, &budbVolume); budbVolume.dump = htonl(dumpid); @@ -382,8 +380,8 @@ writeVolume(ut, fid, volFragmentPtr, volInfoPtr, dumpid, tapeName) haveWritten(sizeof(budbVolume)); -error_exit: - return(code); + error_exit: + return (code); } /* ------------------- @@ -402,16 +400,16 @@ afs_int32 checkLock(textType) afs_int32 textType; { - db_lockP lockPtr; + db_lockP lockPtr; - if ( (textType < 0) || (textType > TB_NUM-1) ) - return(BUDB_BADARGUMENT); + if ((textType < 0) || (textType > TB_NUM - 1)) + return (BUDB_BADARGUMENT); lockPtr = &db.h.textLocks[textType]; - if ( lockPtr->lockState != 0 ) - return(BUDB_LOCKED); - return(0); + if (lockPtr->lockState != 0) + return (BUDB_LOCKED); + return (0); } /* checkText @@ -423,7 +421,7 @@ checkText(ut, textType) afs_int32 textType; { struct textBlock *tbPtr; - afs_int32 nBytes = 0; /* accumulated actual size */ + afs_int32 nBytes = 0; /* accumulated actual size */ afs_int32 size; struct block block; dbadr blockAddr; @@ -434,15 +432,15 @@ checkText(ut, textType) blockAddr = ntohl(tbPtr->textAddr); size = ntohl(tbPtr->size); - while ( blockAddr != 0 ) - { + while (blockAddr != 0) { /* read the block */ - code = cdbread(ut, text_BLOCK, blockAddr, (char *) &block, sizeof(block)); - if ( code ) + code = + cdbread(ut, text_BLOCK, blockAddr, (char *)&block, sizeof(block)); + if (code) ERROR(code); - + /* check its type */ - if ( block.h.type != text_BLOCK ) + if (block.h.type != text_BLOCK) ERROR(BUDB_DATABASEINCONSISTENT); /* add up the size */ @@ -452,11 +450,11 @@ checkText(ut, textType) } /* ensure that we have at least the expected amount of text */ - if ( nBytes < size ) + if (nBytes < size) ERROR(BUDB_DATABASEINCONSISTENT); - -error_exit: - return(code); + + error_exit: + return (code); } /* writeText @@ -464,7 +462,7 @@ error_exit: * textType - type of text block, e.g. TB_DUMPSCHEDULE */ -afs_int32 +afs_int32 writeText(ut, fid, textType) struct ubik_trans *ut; int fid; @@ -475,13 +473,13 @@ writeText(ut, fid, textType) dbadr dbAddr; struct block block; afs_int32 code = 0; - + /* check lock is free */ code = checkLock(textType); if (code) ERROR(code); - /* ensure that this block has the correct type */ + /* ensure that this block has the correct type */ code = checkText(ut, textType); if (code) { LogError(0, "writeText: text type %d damaged\n", textType); @@ -493,12 +491,12 @@ writeText(ut, fid, textType) dbAddr = ntohl(tbPtr->textAddr); if (!dbAddr) - goto error_exit; /* Don't save anything if no blocks */ + goto error_exit; /* Don't save anything if no blocks */ writeTextHeader(fid, textType); while (dbAddr) { - code = cdbread(ut, text_BLOCK, dbAddr, (char *) &block, sizeof(block)); + code = cdbread(ut, text_BLOCK, dbAddr, (char *)&block, sizeof(block)); if (code) ERROR(code); @@ -509,7 +507,7 @@ writeText(ut, fid, textType) if (canWrite(fid) <= 0) ERROR(BUDB_DUMPFAILED); - if (write(fid, &block.a[0], writeSize) != writeSize) + if (write(fid, &block.a[0], writeSize) != writeSize) ERROR(BUDB_IO); haveWritten(writeSize); @@ -518,8 +516,8 @@ writeText(ut, fid, textType) dbAddr = ntohl(block.h.next); } -error_exit: - return(code); + error_exit: + return (code); } #define MAXAPPENDS 200 @@ -535,7 +533,7 @@ writeDatabase(ut, fid) struct tape diskTape; dbadr volFragAddr; struct volFragment diskVolFragment; - struct volInfo diskVolInfo; + struct volInfo diskVolInfo; int length, hash; int old = 0; int entrySize; @@ -549,208 +547,232 @@ writeDatabase(ut, fid) /* write out a header identifying this database etc */ tcode = writeDbHeader(fid); if (tcode) { - LogError(tcode, "writeDatabase: Can't write Header\n"); + LogError(tcode, "writeDatabase: Can't write Header\n"); ERROR(tcode); } /* write out the tree of dump structures */ - mht = ht_GetType (HT_dumpIden_FUNCTION, &entrySize); + mht = ht_GetType(HT_dumpIden_FUNCTION, &entrySize); if (!mht) { - LogError(tcode, "writeDatabase: Can't get dump type\n"); + LogError(tcode, "writeDatabase: Can't get dump type\n"); ERROR(BUDB_BADARGUMENT); } for (old = 0; old <= 1; old++) { - /*oldnew*/ + /*oldnew */ /* only two states, old or not old */ - length = (old ? mht->oldLength : mht->length); + length = (old ? mht->oldLength : mht->length); if (!length) continue; - - for (hash=0; hash= MAXAPPENDS) numaddrs = MAXAPPENDS-1; /* don't overflow */ + if (numaddrs >= MAXAPPENDS) + numaddrs = MAXAPPENDS - 1; /* don't overflow */ appDumpAddrs[numaddrs] = dbAppAddr; numaddrs++; /* If we dump a 1000 appended dumps, assume a loop */ if (appcount >= 5 * MAXAPPENDS) { - Log("writeDatabase: Potential circular loop of appended dumps\n"); - Log("Skipping rest of appended dumps of dumpID %u. Dumped %d\n", - ntohl(diskDump.id), appcount); - break; + Log("writeDatabase: Potential circular loop of appended dumps\n"); + Log("Skipping rest of appended dumps of dumpID %u. Dumped %d\n", ntohl(diskDump.id), appcount); + break; } appcount++; /* Read the dump entry */ if (dbAddr == dbAppAddr) { - /* First time through, don't need to read the dump entry again */ - memcpy(&apDiskDump, &diskDump, sizeof(diskDump)); - } - else { - if (badEntry(dbAppAddr)) { - LogError(0, "writeDatabase: Damaged appended dump entry at addr 0x%x\n", dbAddr); - Log (" Skipping this and remainder of appended dumps of initial DumpID %u\n", - ntohl(diskDump.id)); - break; - } - - tcode = cdbread(ut, dump_BLOCK, dbAppAddr, &apDiskDump, sizeof(apDiskDump)); - if (tcode) { - LogError(tcode, "writeDatabase: Can't read appended dump entry (addr 0x%x)\n", - dbAppAddr); - Log (" Skipping this and remainder of appended dumps of initial DumpID %u\n", - ntohl(diskDump.id)); - break; - } - - /* Verify that this appended dump points to the initial dump */ - if (ntohl(apDiskDump.initialDumpID) != ntohl(diskDump.id)) { - LogError(0, "writeDatabase: Appended dumpID %u does not reference initial dumpID %u\n", - ntohl(apDiskDump.id), ntohl(diskDump.id)); - Log (" Skipping this appended dump\n"); - continue; - } + /* First time through, don't need to read the dump entry again */ + memcpy(&apDiskDump, &diskDump, sizeof(diskDump)); + } else { + if (badEntry(dbAppAddr)) { + LogError(0, + "writeDatabase: Damaged appended dump entry at addr 0x%x\n", + dbAddr); + Log(" Skipping this and remainder of appended dumps of initial DumpID %u\n", ntohl(diskDump.id)); + break; + } + + tcode = + cdbread(ut, dump_BLOCK, dbAppAddr, &apDiskDump, + sizeof(apDiskDump)); + if (tcode) { + LogError(tcode, + "writeDatabase: Can't read appended dump entry (addr 0x%x)\n", + dbAppAddr); + Log(" Skipping this and remainder of appended dumps of initial DumpID %u\n", ntohl(diskDump.id)); + break; + } + + /* Verify that this appended dump points to the initial dump */ + if (ntohl(apDiskDump.initialDumpID) != + ntohl(diskDump.id)) { + LogError(0, + "writeDatabase: Appended dumpID %u does not reference initial dumpID %u\n", + ntohl(apDiskDump.id), + ntohl(diskDump.id)); + Log(" Skipping this appended dump\n"); + continue; + } } /* Save the dump entry */ tcode = writeDump(fid, &apDiskDump); if (tcode) { - LogError(tcode, "writeDatabase: Can't write dump entry\n"); - ERROR(tcode); + LogError(tcode, + "writeDatabase: Can't write dump entry\n"); + ERROR(tcode); } - + /* For each tape on this dump */ - for (tapeAddr = ntohl(apDiskDump.firstTape); - tapeAddr; - tapeAddr = ntohl(diskTape.nextTape)) - { /*tapes*/ - /* read the tape entry */ - tcode = cdbread(ut, tape_BLOCK, tapeAddr, &diskTape, sizeof(diskTape)); + for (tapeAddr = ntohl(apDiskDump.firstTape); tapeAddr; tapeAddr = ntohl(diskTape.nextTape)) { /*tapes */ + /* read the tape entry */ + tcode = + cdbread(ut, tape_BLOCK, tapeAddr, &diskTape, + sizeof(diskTape)); if (tcode) { - LogError(tcode, "writeDatabase: Can't read tape entry (addr 0x%x) of dumpID %u\n", - tapeAddr, ntohl(apDiskDump.id)); - Log(" Skipping this and remaining tapes in the dump (and all their volumes)\n"); - break; + LogError(tcode, + "writeDatabase: Can't read tape entry (addr 0x%x) of dumpID %u\n", + tapeAddr, ntohl(apDiskDump.id)); + Log(" Skipping this and remaining tapes in the dump (and all their volumes)\n"); + break; } /* Save the tape entry */ - tcode = writeTape(fid, &diskTape, ntohl(apDiskDump.id)); + tcode = + writeTape(fid, &diskTape, ntohl(apDiskDump.id)); if (tcode) { - LogError(tcode, "writeDatabase: Can't write tape entry\n"); - ERROR(tcode); + LogError(tcode, + "writeDatabase: Can't write tape entry\n"); + ERROR(tcode); } - + /* For each volume on this tape. */ - for (volFragAddr = ntohl(diskTape.firstVol); - volFragAddr; - volFragAddr = ntohl(diskVolFragment.sameTapeChain)) - { /*volumes*/ + for (volFragAddr = ntohl(diskTape.firstVol); volFragAddr; volFragAddr = ntohl(diskVolFragment.sameTapeChain)) { /*volumes */ /* Read the volume Fragment entry */ - tcode = cdbread(ut, volFragment_BLOCK, volFragAddr, - &diskVolFragment, sizeof(diskVolFragment)); + tcode = + cdbread(ut, volFragment_BLOCK, volFragAddr, + &diskVolFragment, + sizeof(diskVolFragment)); if (tcode) { - LogError(tcode, "writeDatabase: Can't read volfrag entry (addr 0x%x) of dumpID %u\n", - volFragAddr, ntohl(apDiskDump.id)); - Log(" Skipping this and remaining volumes on tape '%s'\n", diskTape.name); - break; + LogError(tcode, + "writeDatabase: Can't read volfrag entry (addr 0x%x) of dumpID %u\n", + volFragAddr, ntohl(apDiskDump.id)); + Log(" Skipping this and remaining volumes on tape '%s'\n", diskTape.name); + break; } /* Read the volume Info entry */ - tcode = cdbread(ut, volInfo_BLOCK, ntohl(diskVolFragment.vol), - &diskVolInfo, sizeof(diskVolInfo)); + tcode = + cdbread(ut, volInfo_BLOCK, + ntohl(diskVolFragment.vol), + &diskVolInfo, sizeof(diskVolInfo)); if (tcode) { - LogError(tcode, "writeDatabase: Can't read volinfo entry (addr 0x%x) of dumpID %u\n", - ntohl(diskVolFragment.vol), ntohl(apDiskDump.id)); - Log(" Skipping volume on tape '%s'\n", diskTape.name); - continue; + LogError(tcode, + "writeDatabase: Can't read volinfo entry (addr 0x%x) of dumpID %u\n", + ntohl(diskVolFragment.vol), + ntohl(apDiskDump.id)); + Log(" Skipping volume on tape '%s'\n", + diskTape.name); + continue; } /* Save the volume entry */ - tcode = writeVolume(ut, fid, &diskVolFragment, &diskVolInfo, - ntohl(apDiskDump.id), diskTape.name); + tcode = + writeVolume(ut, fid, &diskVolFragment, + &diskVolInfo, + ntohl(apDiskDump.id), + diskTape.name); if (tcode) { - LogError(tcode, "writeDatabase: Can't write volume entry\n"); - ERROR(tcode); + LogError(tcode, + "writeDatabase: Can't write volume entry\n"); + ERROR(tcode); } - } /*volumes*/ - } /*tapes*/ - } /*appendedDumps*/ - } /*initialDumps*/ - } /*hashBuckets*/ - } /*oldnew*/ + } /*volumes */ + } /*tapes */ + } /*appendedDumps */ + } /*initialDumps */ + } /*hashBuckets */ + } /*oldnew */ /* write out the textual configuration information */ tcode = writeText(ut, fid, TB_DUMPSCHEDULE); if (tcode) { - LogError(tcode, "writeDatabase: Can't write dump schedule\n"); + LogError(tcode, "writeDatabase: Can't write dump schedule\n"); ERROR(tcode); } tcode = writeText(ut, fid, TB_VOLUMESET); if (tcode) { - LogError(tcode, "writeDatabase: Can't write volume set\n"); + LogError(tcode, "writeDatabase: Can't write volume set\n"); ERROR(tcode); } tcode = writeText(ut, fid, TB_TAPEHOSTS); if (tcode) { - LogError(tcode, "writeDatabase: Can't write tape hosts\n"); + LogError(tcode, "writeDatabase: Can't write tape hosts\n"); ERROR(tcode); } tcode = writeStructHeader(fid, SD_END); if (tcode) { - LogError(tcode, "writeDatabase: Can't write end savedb\n"); + LogError(tcode, "writeDatabase: Can't write end savedb\n"); ERROR(tcode); } - -error_exit: + + error_exit: doneWriting(code); - return(code); + return (code); } @@ -767,12 +789,12 @@ canWrite(fid) tp.tv_sec = 0; tp.tv_usec = 0; - out = ( 1 << fid ); + out = (1 << fid); in = 0; except = 0; code = IOMGR_Select(32, &in, &out, &except, &tp); - return(code); + return (code); } #endif /* notdef */ diff --git a/src/budb/db_hash.c b/src/budb/db_hash.c index fa4246c2c..3dc0dbbd6 100644 --- a/src/budb/db_hash.c +++ b/src/budb/db_hash.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -34,29 +35,34 @@ RCSID("$Header$"); #include "error_macros.h" -int sizeFunctions[HT_MAX_FUNCTION+1]; -int nHTBuckets = NhtBucketS; /* testing: we need small HT blocks */ +int sizeFunctions[HT_MAX_FUNCTION + 1]; +int nHTBuckets = NhtBucketS; /* testing: we need small HT blocks */ /* ht_TableSize - return the size of table necessary to represent a hashtable * of given length in memory. It basically rounds the length up by the number * of buckets per block. */ -int ht_TableSize (length) - int length; -{ int n; - if (length == 0) return 0; - n = (length + nHTBuckets-1) / nHTBuckets; - return n*sizeof(struct memoryHTBlock *); +int +ht_TableSize(length) + int length; +{ + int n; + if (length == 0) + return 0; + n = (length + nHTBuckets - 1) / nHTBuckets; + return n * sizeof(struct memoryHTBlock *); } /* ht_ResetT - resets the in-memory representation of a hashtable block array. * It also resets the global variable nHTBuckets. */ -static void ht_ResetT (blocksP, sizeP, length) - struct memoryHTBlock ***blocksP; - int *sizeP; - int length; -{ struct memoryHTBlock **b = *blocksP; +static void +ht_ResetT(blocksP, sizeP, length) + struct memoryHTBlock ***blocksP; + int *sizeP; + int length; +{ + struct memoryHTBlock **b = *blocksP; int newsize; int n; int i; @@ -64,18 +70,20 @@ static void ht_ResetT (blocksP, sizeP, length) nHTBuckets = ntohl(db.h.nHTBuckets); if (b) { n = *sizeP / sizeof(b[0]); - newsize = ht_TableSize (length); + newsize = ht_TableSize(length); if (*sizeP != newsize) { /* free all blocks in the old array */ - for (i=0; ivalid = 0; + for (i = 0; i < n; i++) + if (b[i]) + b[i]->valid = 0; } } } @@ -84,25 +92,28 @@ static void ht_ResetT (blocksP, sizeP, length) * reinitialize a memory hash table. * Calls ht_ResetT to invalidate the two block arrays. */ - -void ht_Reset (mht) - struct memoryHashTable *mht; -{ struct hashTable *ht; + +void +ht_Reset(mht) + struct memoryHashTable *mht; +{ + struct hashTable *ht; if (!(mht && (ht = mht->ht))) - db_panic ("some ht called with bad mht"); + db_panic("some ht called with bad mht"); mht->threadOffset = ntohl(ht->threadOffset); mht->length = ntohl(ht->length); mht->oldLength = ntohl(ht->oldLength); mht->progress = ntohl(ht->progress); - ht_ResetT (&mht->blocks, &mht->size, mht->length); - ht_ResetT (&mht->oldBlocks, &mht->oldSize, mht->oldLength); + ht_ResetT(&mht->blocks, &mht->size, mht->length); + ht_ResetT(&mht->oldBlocks, &mht->oldSize, mht->oldLength); } /* InitDBhash - When server starts, do hash table initialization. test - initialization parameters: bit 4 is small ht. */ -afs_int32 InitDBhash () +afs_int32 +InitDBhash() { sizeFunctions[0] = 0; @@ -120,192 +131,216 @@ afs_int32 InitDBhash () /* ht_DBInit - When rebuilding database, this sets up the hash tables. */ -void ht_DBInit () +void +ht_DBInit() { db.h.nHTBuckets = htonl(nHTBuckets); - { struct volInfo *s = 0; - db.h.volName.threadOffset = htonl((char *)&s->nameHashChain - (char *)s); + { + struct volInfo *s = 0; + db.h.volName.threadOffset = + htonl((char *)&s->nameHashChain - (char *)s); db.h.volName.functionType = htonl(HT_volName_FUNCTION); } - { struct tape *s = 0; - db.h.tapeName.threadOffset = htonl((char *)&s->nameHashChain - (char *)s); + { + struct tape *s = 0; + db.h.tapeName.threadOffset = + htonl((char *)&s->nameHashChain - (char *)s); db.h.tapeName.functionType = htonl(HT_tapeName_FUNCTION); } - { struct dump *s = 0; - db.h.dumpName.threadOffset = htonl((char *)&s->nameHashChain - (char *)s); + { + struct dump *s = 0; + db.h.dumpName.threadOffset = + htonl((char *)&s->nameHashChain - (char *)s); db.h.dumpName.functionType = htonl(HT_dumpName_FUNCTION); - db.h.dumpIden.threadOffset = htonl((char *)&s->idHashChain - (char *)s); + db.h.dumpIden.threadOffset = + htonl((char *)&s->idHashChain - (char *)s); db.h.dumpIden.functionType = htonl(HT_dumpIden_FUNCTION); } - ht_Reset (&db.volName); - ht_Reset (&db.tapeName); - ht_Reset (&db.dumpName); - ht_Reset (&db.dumpIden); + ht_Reset(&db.volName); + ht_Reset(&db.tapeName); + ht_Reset(&db.dumpName); + ht_Reset(&db.dumpIden); } -afs_int32 ht_AllocTable (ut, mht) - struct ubik_trans *ut; - struct memoryHashTable *mht; -{ struct hashTable *ht; - afs_int32 code; - int len; - int nb, mnb; /* number of blocks for hashTable */ - int i; +afs_int32 +ht_AllocTable(ut, mht) + struct ubik_trans *ut; + struct memoryHashTable *mht; +{ + struct hashTable *ht; + afs_int32 code; + int len; + int nb, mnb; /* number of blocks for hashTable */ + int i; struct memoryHTBlock **b; - if (!(mht && (ht = mht->ht))) db_panic ("some ht called with bad mht"); - if (ht->length || mht->blocks) db_panic ("previous table still allocated"); + if (!(mht && (ht = mht->ht))) + db_panic("some ht called with bad mht"); + if (ht->length || mht->blocks) + db_panic("previous table still allocated"); len = ntohl(ht->entries) * 2; /* allow room to grow */ - nb = (len + nHTBuckets-1) / nHTBuckets; + nb = (len + nHTBuckets - 1) / nHTBuckets; mnb = ht_minHBlocks(mht); - if (nb < mnb) nb = mnb; /* use minimum */ - len = nb * nHTBuckets; /* new hash table length */ + if (nb < mnb) + nb = mnb; /* use minimum */ + len = nb * nHTBuckets; /* new hash table length */ - mht->size = nb*sizeof(struct memoryHTBlock *); - b = mht->blocks = (struct memoryHTBlock **)malloc (mht->size); + mht->size = nb * sizeof(struct memoryHTBlock *); + b = mht->blocks = (struct memoryHTBlock **)malloc(mht->size); memset(b, 0, mht->size); - for (i=0; ib, &b[i]->a); - if (code) return code; + for (i = 0; i < nb; i++) { + b[i] = (struct memoryHTBlock *)malloc(sizeof(struct memoryHTBlock)); + code = AllocBlock(ut, (struct block *)&b[i]->b, &b[i]->a); + if (code) + return code; b[i]->valid = 0; b[i]->b.h.type = hashTable_BLOCK; /* thread the blocks */ - if (i) b[i-1]->b.h.next = htonl(b[i]->a); + if (i) + b[i - 1]->b.h.next = htonl(b[i]->a); } - for (i=0; ia, (char *)&b[i]->b, - sizeof(struct htBlock) + (nHTBuckets-NhtBucketS)*sizeof(dbadr)); + for (i = 0; i < nb; i++) { + code = + dbwrite(ut, b[i]->a, (char *)&b[i]->b, + sizeof(struct htBlock) + (nHTBuckets - + NhtBucketS) * sizeof(dbadr)); if (code) return code; } - if (code = set_word_addr (ut, 0, &db.h, &ht->table, htonl(b[0]->a))) + if (code = set_word_addr(ut, 0, &db.h, &ht->table, htonl(b[0]->a))) return code; - if (code = set_word_addr (ut, 0, &db.h, &ht->length, htonl(len))) + if (code = set_word_addr(ut, 0, &db.h, &ht->length, htonl(len))) return code; mht->length = len; return 0; } -afs_int32 ht_FreeTable (ut, mht) - struct ubik_trans *ut; - struct memoryHashTable *mht; -{ struct hashTable *ht; - afs_int32 code; +afs_int32 +ht_FreeTable(ut, mht) + struct ubik_trans *ut; + struct memoryHashTable *mht; +{ + struct hashTable *ht; + afs_int32 code; struct blockHeader bh; - dbadr a,na; + dbadr a, na; - if (!(mht && (ht = mht->ht))) db_panic ("some ht called with bad mht"); - if (ht->oldLength == 0) db_panic ("no table to free"); + if (!(mht && (ht = mht->ht))) + db_panic("some ht called with bad mht"); + if (ht->oldLength == 0) + db_panic("no table to free"); - ht_ResetT (&mht->oldBlocks, &mht->oldSize, 0); + ht_ResetT(&mht->oldBlocks, &mht->oldSize, 0); - for (a=ntohl(ht->oldTable); a; a=na) { - if (dbread (ut, a, (char *)&bh, sizeof(bh))) - { + for (a = ntohl(ht->oldTable); a; a = na) { + if (dbread(ut, a, (char *)&bh, sizeof(bh))) { Log("ht_FreeTable: dbread failed\n"); return BUDB_IO; } na = ntohl(bh.next); - if (code = FreeBlock (ut, &bh, a)) return code; + if (code = FreeBlock(ut, &bh, a)) + return code; } - if (set_word_addr (ut, 0, &db.h, &ht->oldTable, 0) || - set_word_addr (ut, 0, &db.h, &ht->oldLength, 0) || - set_word_addr (ut, 0, &db.h, &ht->progress, 0)) + if (set_word_addr(ut, 0, &db.h, &ht->oldTable, 0) + || set_word_addr(ut, 0, &db.h, &ht->oldLength, 0) + || set_word_addr(ut, 0, &db.h, &ht->progress, 0)) return BUDB_IO; mht->oldLength = mht->progress = 0; return 0; } -afs_int32 -ht_GetTableBlock (ut, mht, hash, old, blockP, boP) - struct ubik_trans *ut; - struct memoryHashTable *mht; - afs_uint32 hash; - int old; - struct memoryHTBlock **blockP; - int *boP; -{ +afs_int32 +ht_GetTableBlock(ut, mht, hash, old, blockP, boP) + struct ubik_trans *ut; + struct memoryHashTable *mht; + afs_uint32 hash; + int old; + struct memoryHTBlock **blockP; + int *boP; +{ struct hashTable *ht; struct memoryHTBlock **b; - int hi,bi; + int hi, bi; struct memoryHTBlock ***blocksP; - int *sizeP; - int n; - int i; - int length; + int *sizeP; + int n; + int i; + int length; dbadr ta; - if ( (mht == 0) - || ((ht = mht->ht) == 0) - ) - { - db_panic ("some ht called with bad mht"); + if ((mht == 0) + || ((ht = mht->ht) == 0) + ) { + db_panic("some ht called with bad mht"); } *blockP = 0; if (old) { - if ((length = mht->oldLength) == 0) return 0; /* no entries */ + if ((length = mht->oldLength) == 0) + return 0; /* no entries */ hi = hash % length; - if (hi < mht->progress) return 0; /* no such entry */ + if (hi < mht->progress) + return 0; /* no such entry */ blocksP = &mht->oldBlocks; sizeP = &mht->oldSize; } else { - if ((length = mht->length) == 0) return 0; /* no entries */ + if ((length = mht->length) == 0) + return 0; /* no entries */ hi = hash % length; blocksP = &mht->blocks; sizeP = &mht->size; } - bi = hi / nHTBuckets; /* block index */ - *boP = hi - bi*nHTBuckets; /* block offset ptr */ + bi = hi / nHTBuckets; /* block index */ + *boP = hi - bi * nHTBuckets; /* block offset ptr */ if (*blocksP == 0) { - *sizeP = ht_TableSize (length); - *blocksP = (struct memoryHTBlock **)malloc (*sizeP); + *sizeP = ht_TableSize(length); + *blocksP = (struct memoryHTBlock **)malloc(*sizeP); memset(*blocksP, 0, *sizeP); } - n = *sizeP / sizeof (struct memoryHTBlock *); - if (bi >= n) db_panic ("table size inconsistent"); + n = *sizeP / sizeof(struct memoryHTBlock *); + if (bi >= n) + db_panic("table size inconsistent"); b = *blocksP; /* find an allocated block or the beginning of the block array */ - for (i=bi; (i>0) && (b[i] == 0); i--); + for (i = bi; (i > 0) && (b[i] == 0); i--); while (1) { if (b[i] == 0) { - if (i == 0) { /* the first block is found from the hashTable */ + if (i == 0) { /* the first block is found from the hashTable */ ta = ntohl(old ? ht->oldTable : ht->table); - if (ta == 0) db_panic ("non-zero length, but no table"); + if (ta == 0) + db_panic("non-zero length, but no table"); } /* else ta is set from last time around loop */ - b[i] = (struct memoryHTBlock *)malloc (sizeof (struct memoryHTBlock)); + b[i] = + (struct memoryHTBlock *)malloc(sizeof(struct memoryHTBlock)); b[i]->a = ta; b[i]->valid = 0; } if (!b[i]->valid) { - if (dbread (ut, b[i]->a, (char *)&b[i]->b, sizeof(struct htBlock))) + if (dbread(ut, b[i]->a, (char *)&b[i]->b, sizeof(struct htBlock))) return BUDB_IO; b[i]->valid = 1; } - if (i == bi) - { + if (i == bi) { *blockP = b[bi]; /* printf("ht_GetTableBlock: hash %d block %d offset %d\n", - hash, *blockP, *boP); */ + * hash, *blockP, *boP); */ return 0; - } + } ta = ntohl(b[i++]->b.h.next); /* get next ptr from current block */ } @@ -317,17 +352,17 @@ ht_GetTableBlock (ut, mht, hash, old, blockP, boP) * into the current table. */ -static afs_int32 -ht_MaybeAdjust (ut, mht) +static afs_int32 +ht_MaybeAdjust(ut, mht) struct ubik_trans *ut; struct memoryHashTable *mht; -{ +{ struct hashTable *ht = mht->ht; int numberEntries = ntohl(ht->entries); /* old hash table must be empty */ - if ( mht->oldLength != 0) - return(0); + if (mht->oldLength != 0) + return (0); /* * It costs a lot to grow and shrink the hash table. Therefore, we will not @@ -346,54 +381,64 @@ ht_MaybeAdjust (ut, mht) * in which case we do want to grow it). We don't grow anything larger * than 20,450 entries because it's expensive to re-hash everything. */ - if ((numberEntries > mht->length*2) && (numberEntries < 20450)) - { /* push current hash table to old hash table */ + if ((numberEntries > mht->length * 2) && (numberEntries < 20450)) { /* push current hash table to old hash table */ ht->oldLength = ht->length; - ht->oldTable = ht->table; - ht->progress = 0; - ht->length = 0; - ht->table = 0; - if (dbwrite (ut, ((char *)ht - (char *)&db.h), (char *)ht, sizeof (*ht))) + ht->oldTable = ht->table; + ht->progress = 0; + ht->length = 0; + ht->table = 0; + if (dbwrite + (ut, ((char *)ht - (char *)&db.h), (char *)ht, sizeof(*ht))) return BUDB_IO; - ht_Reset (mht); + ht_Reset(mht); LogDebug(2, "ht_MaybeAdjust: push ht to old\n"); } return 0; } -dbadr ht_LookupBucket (ut, mht, hash, old) - struct ubik_trans *ut; - struct memoryHashTable *mht; - afs_uint32 hash; - int old; -{ struct memoryHTBlock *block; - int bo; - afs_int32 code; - - if ((old ? mht->oldLength : mht->length) == 0) return 0; - code = ht_GetTableBlock (ut, mht, hash, old, &block, &bo); - if (code || (block == 0)) return 0; +dbadr +ht_LookupBucket(ut, mht, hash, old) + struct ubik_trans *ut; + struct memoryHashTable *mht; + afs_uint32 hash; + int old; +{ + struct memoryHTBlock *block; + int bo; + afs_int32 code; + + if ((old ? mht->oldLength : mht->length) == 0) + return 0; + code = ht_GetTableBlock(ut, mht, hash, old, &block, &bo); + if (code || (block == 0)) + return 0; return ntohl(block->b.bucket[bo]); } /* This function is not too bad, for small hash tables, but suffers, I think, * from insufficient mixing of the hash information. */ -afs_uint32 Old2StringHashFunction (str) - unsigned char *str; -{ afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ - while (*str) hash = (hash<<1) + (hash>>31) + *str++; +afs_uint32 +Old2StringHashFunction(str) + unsigned char *str; +{ + afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ + while (*str) + hash = (hash << 1) + (hash >> 31) + *str++; return hash; } /* This was actually a coding error, and produces dreadful results. The * problem is that the hash needs to be mixed up not the incoming character. */ -afs_uint32 Old3StringHashFunction (str) - unsigned char *str; -{ afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ - while (*str) hash += (*str++) * 0x072a51a4; +afs_uint32 +Old3StringHashFunction(str) + unsigned char *str; +{ + afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ + while (*str) + hash += (*str++) * 0x072a51a4; return hash; } @@ -401,20 +446,26 @@ afs_uint32 Old3StringHashFunction (str) * the hash multiplier are zero which tends to shift information too far left. * It behaves especially badly for hash tables whose size is a power of two. */ -afs_uint32 Old4StringHashFunction (str) - unsigned char *str; -{ afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ - while (*str) hash = (*str++) + hash * 0x072a51a4; +afs_uint32 +Old4StringHashFunction(str) + unsigned char *str; +{ + afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ + while (*str) + hash = (*str++) + hash * 0x072a51a4; return hash; } /* While this is good for a hash table with 500 buckets it is nearly as bad as * #3 with a hash table as big as 8200. */ -afs_uint32 Old5StringHashFunction (str) - unsigned char *str; -{ afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ - while (*str) hash += (*str++); +afs_uint32 +Old5StringHashFunction(str) + unsigned char *str; +{ + afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ + while (*str) + hash += (*str++); return hash; } @@ -423,10 +474,13 @@ afs_uint32 Old5StringHashFunction (str) * and the difference seems to be smaller with larger hash tables. It behaves * better than the random hash function. */ -afs_uint32 Old6StringHashFunction (str) - unsigned char *str; -{ afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ - while (*str) hash = hash*0x81 + (*str++); +afs_uint32 +Old6StringHashFunction(str) + unsigned char *str; +{ + afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ + while (*str) + hash = hash * 0x81 + (*str++); return hash; } @@ -435,10 +489,13 @@ afs_uint32 Old6StringHashFunction (str) * having the bits spanning the same range farther apart also doesn't do as * well. All these differences are fairly small, however. */ -afs_uint32 Old7StringHashFunction (str) - unsigned char *str; -{ afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ - while (*str) hash = hash*0x42108421 + (*str++); +afs_uint32 +Old7StringHashFunction(str) + unsigned char *str; +{ + afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ + while (*str) + hash = hash * 0x42108421 + (*str++); return hash; } @@ -446,12 +503,15 @@ afs_uint32 Old7StringHashFunction (str) * from higher-order bits in the word. It also uses shifts instead of * multiplies, which may be faster on some architectures. */ -afs_uint32 Old8StringHashFunction (str) - unsigned char *str; -{ afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ +afs_uint32 +Old8StringHashFunction(str) + unsigned char *str; +{ + afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ while (*str) - hash = hash + (hash<<7) + (hash<<14) + (hash<<21) + (hash<<28) + - (hash>>17) + *str++; + hash = + hash + (hash << 7) + (hash << 14) + (hash << 21) + (hash << 28) + + (hash >> 17) + *str++; return hash; } @@ -460,86 +520,93 @@ afs_uint32 Old8StringHashFunction (str) * constraints. It shouldn't have too many or too few one bits and should be * odd. It behaves beeter than the random hash function. */ -afs_uint32 StringHashFunction (str) - unsigned char *str; -{ afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ +afs_uint32 +StringHashFunction(str) + unsigned char *str; +{ + afs_uint32 hash = 1000003; /* big prime to make "" hash nicely */ /* The multiplicative constant should be odd and have a goodly number of * one bits. */ - while (*str) hash = (*str++) + hash * 0x10204081; + while (*str) + hash = (*str++) + hash * 0x10204081; return hash; } -afs_uint32 IdHashFunction (id) - afs_uint32 id; -{ afs_uint32 l,r; +afs_uint32 +IdHashFunction(id) + afs_uint32 id; +{ + afs_uint32 l, r; id *= 81847; l = id | 0xaaaaaaaa; r = id | 0x55555555; - return (l*r); + return (l * r); } /* The minimum hash table blocks to allocate. Each block contains 510 * buckets. They hash table grows when the number of entries reaches * twice the number of buckets. */ -int ht_minHBlocks(mht) - struct memoryHashTable *mht; +int +ht_minHBlocks(mht) + struct memoryHashTable *mht; { int retval; - switch ( ntohl(mht->ht->functionType) ) - { - case HT_dumpIden_FUNCTION: - case HT_dumpName_FUNCTION: /* hash table able to handle (befor it grows) ... */ - retval = 2; /* 1,020 dump entries */ + switch (ntohl(mht->ht->functionType)) { + case HT_dumpIden_FUNCTION: + case HT_dumpName_FUNCTION: /* hash table able to handle (befor it grows) ... */ + retval = 2; /* 1,020 dump entries */ break; - case HT_tapeName_FUNCTION: - retval = 4; /* 2,040 tape entries */ + case HT_tapeName_FUNCTION: + retval = 4; /* 2,040 tape entries */ break; - case HT_volName_FUNCTION: - retval = 60; /* 61,200 volInfo entries (with different names) */ + case HT_volName_FUNCTION: + retval = 60; /* 61,200 volInfo entries (with different names) */ break; - default: db_panic ("Illegal hash function type"); + default: + db_panic("Illegal hash function type"); } return (retval); } -afs_uint32 ht_HashEntry (mht, e) - struct memoryHashTable *mht; - char *e; /* entry's address (in b) */ -{ - int type = ntohl(mht->ht->functionType); +afs_uint32 +ht_HashEntry(mht, e) + struct memoryHashTable *mht; + char *e; /* entry's address (in b) */ +{ + int type = ntohl(mht->ht->functionType); afs_uint32 retval; - - switch (type) - { - case HT_dumpIden_FUNCTION: + + switch (type) { + case HT_dumpIden_FUNCTION: retval = IdHashFunction(ntohl(((struct dump *)e)->id)); LogDebug(5, "HashEntry: dumpid returns %d\n", retval); break; - case HT_dumpName_FUNCTION: + case HT_dumpName_FUNCTION: retval = StringHashFunction(((struct dump *)e)->dumpName); LogDebug(5, "HashEntry: dumpname returns %d\n", retval); break; - case HT_tapeName_FUNCTION: + case HT_tapeName_FUNCTION: retval = StringHashFunction(((struct tape *)e)->name); LogDebug(5, "HashEntry: tapename returns %d\n", retval); break; - case HT_volName_FUNCTION: - retval = StringHashFunction (((struct volInfo *)e)->name); + case HT_volName_FUNCTION: + retval = StringHashFunction(((struct volInfo *)e)->name); LogDebug(5, "HashEntry: volname returns %d\n", retval); break; - default: db_panic ("illegal hash function"); + default: + db_panic("illegal hash function"); } - return(retval); + return (retval); } @@ -550,56 +617,59 @@ afs_uint32 ht_HashEntry (mht, e) struct memoryHashTable * ht_GetType(type, e_sizeP) - int type; - int *e_sizeP; -{ + int type; + int *e_sizeP; +{ struct memoryHashTable *mht; - if ((type <= 0) || (type > HT_MAX_FUNCTION)) + if ((type <= 0) || (type > HT_MAX_FUNCTION)) return 0; - if (e_sizeP) *e_sizeP = sizeFunctions[type]; - switch (type) - { - case HT_dumpIden_FUNCTION: + if (e_sizeP) + *e_sizeP = sizeFunctions[type]; + switch (type) { + case HT_dumpIden_FUNCTION: mht = &db.dumpIden; break; - case HT_dumpName_FUNCTION: + case HT_dumpName_FUNCTION: mht = &db.dumpName; break; - case HT_tapeName_FUNCTION: + case HT_tapeName_FUNCTION: mht = &db.tapeName; break; - case HT_volName_FUNCTION: + case HT_volName_FUNCTION: mht = &db.volName; break; - default: return 0; + default: + return 0; } if (ntohl(mht->ht->functionType) != type) - db_panic ("ht types don't match"); + db_panic("ht types don't match"); return mht; } -static int ht_KeyMatch (type, key, e) - int type; - char *key; - char *e; +static int +ht_KeyMatch(type, key, e) + int type; + char *key; + char *e; { switch (type) { - case HT_dumpIden_FUNCTION: - return *(dumpId *)key == ntohl(((struct dump *)e)->id); - case HT_dumpName_FUNCTION: - return strcmp (key, ((struct dump *)e)->dumpName) == 0; - case HT_tapeName_FUNCTION: - return strcmp (key, ((struct tape *)e)->name) == 0; - case HT_volName_FUNCTION: - return strcmp (key, ((struct volInfo *)e)->name) == 0; - - default: db_panic ("illegal hash function"); + case HT_dumpIden_FUNCTION: + return *(dumpId *) key == ntohl(((struct dump *)e)->id); + case HT_dumpName_FUNCTION: + return strcmp(key, ((struct dump *)e)->dumpName) == 0; + case HT_tapeName_FUNCTION: + return strcmp(key, ((struct tape *)e)->name) == 0; + case HT_volName_FUNCTION: + return strcmp(key, ((struct volInfo *)e)->name) == 0; + + default: + db_panic("illegal hash function"); } } @@ -614,45 +684,47 @@ static int ht_KeyMatch (type, key, e) */ afs_int32 -ht_LookupEntry (ut, mht, key, eaP, e) - struct ubik_trans *ut; - struct memoryHashTable *mht; - char *key; /* pointer to lookup key to match */ - dbadr *eaP; /* db addr of entry found or zero */ - char *e; /* contents of located entry */ -{ struct hashTable *ht; - int type; - int e_size; - int old; +ht_LookupEntry(ut, mht, key, eaP, e) + struct ubik_trans *ut; + struct memoryHashTable *mht; + char *key; /* pointer to lookup key to match */ + dbadr *eaP; /* db addr of entry found or zero */ + char *e; /* contents of located entry */ +{ + struct hashTable *ht; + int type; + int e_size; + int old; afs_uint32 hash; dbadr a; - if (!key || !eaP || !e) db_panic ("null ptrs passed to LookupEntry"); - if (!(mht && (ht = mht->ht))) db_panic ("some ht called with bad mht"); + if (!key || !eaP || !e) + db_panic("null ptrs passed to LookupEntry"); + if (!(mht && (ht = mht->ht))) + db_panic("some ht called with bad mht"); - *eaP = 0; /* initialize not-found indicator */ + *eaP = 0; /* initialize not-found indicator */ type = ntohl(ht->functionType); e_size = sizeFunctions[type]; if (type == HT_dumpIden_FUNCTION) - hash = IdHashFunction (*(dumpId *)key); + hash = IdHashFunction(*(dumpId *) key); else - hash = StringHashFunction (key); + hash = StringHashFunction(key); - for (old=0; ; old++) - { - a = ht_LookupBucket (ut, mht, hash, old); + for (old = 0;; old++) { + a = ht_LookupBucket(ut, mht, hash, old); while (a) { - if (dbread (ut, a, e, e_size)) - return BUDB_IO; - if (ht_KeyMatch (type, key, e)) - { + if (dbread(ut, a, e, e_size)) + return BUDB_IO; + if (ht_KeyMatch(type, key, e)) { *eaP = a; return 0; } - a = ntohl(*(dbadr *)(e + mht->threadOffset)); + a = ntohl(*(dbadr *) (e + mht->threadOffset)); } - if (old) return 0; + if (old) + return 0; } } @@ -663,7 +735,8 @@ ht_LookupEntry (ut, mht, key, eaP, e) * opQuota - adjusted to reflect # of moves */ -static afs_int32 ht_HashInList (ut, mht, opQuota, block, blockOffset) +static afs_int32 +ht_HashInList(ut, mht, opQuota, block, blockOffset) struct ubik_trans *ut; struct memoryHashTable *mht; int *opQuota; @@ -671,16 +744,14 @@ static afs_int32 ht_HashInList (ut, mht, opQuota, block, blockOffset) int blockOffset; { struct hashTable *ht = mht->ht; - afs_int32 code; + afs_int32 code; dbadr ea, next_ea; dbadr listA; - char e[sizeof(struct block)]; /* unnecessarily conservative */ - int e_size = sizeFunctions[ntohl(ht->functionType)]; + char e[sizeof(struct block)]; /* unnecessarily conservative */ + int e_size = sizeFunctions[ntohl(ht->functionType)]; - if (mht->length == 0) - { - if (code = ht_AllocTable (ut, mht)) - { + if (mht->length == 0) { + if (code = ht_AllocTable(ut, mht)) { Log("ht_HashInList: ht_AllocTable failed\n"); return code; } @@ -688,52 +759,49 @@ static afs_int32 ht_HashInList (ut, mht, opQuota, block, blockOffset) listA = ntohl(block->b.bucket[blockOffset]); - if (listA == 0) - { + if (listA == 0) { Log("ht_HashInList: expecting non-zero bucket\n"); return 0; } - for (ea=listA; ea; ea=next_ea) - { /*f*/ + for (ea = listA; ea; ea = next_ea) { /*f */ - LogDebug(3, "ht_HashInList: move entry at %d, type %d\n", - ea, ntohl(mht->ht->functionType)); + LogDebug(3, "ht_HashInList: move entry at %d, type %d\n", ea, + ntohl(mht->ht->functionType)); - if (dbread (ut, ea, e, e_size)) + if (dbread(ut, ea, e, e_size)) return BUDB_IO; - /* LogNetDump((struct dump *) e); */ + /* LogNetDump((struct dump *) e); */ /* get the address of the next item on the list */ - next_ea = ntohl(*(dbadr *)(e + mht->threadOffset)); + next_ea = ntohl(*(dbadr *) (e + mht->threadOffset)); /* write the link into the bucket */ - code = set_word_addr (ut, block->a, &block->b, &block->b.bucket[blockOffset], - htonl(next_ea)); - if (code) - { + code = + set_word_addr(ut, block->a, &block->b, + &block->b.bucket[blockOffset], htonl(next_ea)); + if (code) { Log("ht_HashInList: bucket update failed\n"); - return(code); + return (code); } - { struct memoryHTBlock *block; - int bo; + { + struct memoryHTBlock *block; + int bo; afs_uint32 hash; /* get the hash value */ - hash = ht_HashEntry (mht, e) % mht->length; + hash = ht_HashEntry(mht, e) % mht->length; LogDebug(4, "ht_HashInList: moved to %d\n", hash); /* get the new hash table block */ - code = ht_GetTableBlock (ut, mht, hash, 0/*old*/, &block, &bo); - if (code) - { + code = ht_GetTableBlock(ut, mht, hash, 0 /*old */ , &block, &bo); + if (code) { Log("ht_HashInList: ht_GetTableBlock failed\n"); return code; } - if (block == 0) - { + if (block == 0) { Log("ht_HashInList: ht_GetTableBlock returned 0\n"); return BUDB_INTERNALERROR; } @@ -742,14 +810,16 @@ static afs_int32 ht_HashInList (ut, mht, opQuota, block, blockOffset) * first threadOffset of entry = bucket * then bucket = addr of entry */ - if (set_word_offset (ut, ea, e, mht->threadOffset, block->b.bucket[bo]) || - set_word_addr (ut, block->a, &block->b, &block->b.bucket[bo], htonl(ea))) + if (set_word_offset + (ut, ea, e, mht->threadOffset, block->b.bucket[bo]) + || set_word_addr(ut, block->a, &block->b, + &block->b.bucket[bo], htonl(ea))) return BUDB_IO; } - if ( --(*opQuota) == 0 ) + if (--(*opQuota) == 0) break; - } /*f*/ + } /*f */ return 0; } @@ -759,16 +829,16 @@ static afs_int32 ht_HashInList (ut, mht, opQuota, block, blockOffset) * to the new. */ -static afs_int32 +static afs_int32 ht_MoveEntries(ut, mht) struct ubik_trans *ut; struct memoryHashTable *mht; -{ +{ struct memoryHTBlock *block; afs_uint32 hash; int count; - int bo; - afs_int32 code; + int bo; + afs_int32 code; if (mht->oldLength == 0) return 0; @@ -780,43 +850,39 @@ ht_MoveEntries(ut, mht) hash = mht->progress; /* get hash table block ? */ - code = ht_GetTableBlock (ut, mht, hash, 1 /*old*/, &block, &bo); - if (code) + code = ht_GetTableBlock(ut, mht, hash, 1 /*old */ , &block, &bo); + if (code) return code; - if (block == 0) + if (block == 0) return BUDB_INTERNALERROR; - count = 10; /* max. # entries to move */ + count = 10; /* max. # entries to move */ do { - if (block->b.bucket[bo]) - { + if (block->b.bucket[bo]) { code = ht_HashInList(ut, mht, &count, block, bo); - if ( code ) - { + if (code) { Log("ht_MoveEntries: ht_HashInList failed\n"); - return(BUDB_IO); + return (BUDB_IO); } } - if (block->b.bucket[bo] == 0) - { + if (block->b.bucket[bo] == 0) { /* this bucket is now empty */ mht->progress++; } /* don't exceed the quota of items to be moved */ - if ( count == 0 ) + if (count == 0) break; } while (++bo < nHTBuckets); if (mht->progress >= mht->oldLength) - return( ht_FreeTable (ut, mht) ); + return (ht_FreeTable(ut, mht)); - if (set_word_addr (ut, 0, &db.h, &mht->ht->progress, htonl(mht->progress))) - { + if (set_word_addr(ut, 0, &db.h, &mht->ht->progress, htonl(mht->progress))) { Log("ht_MoveEntries: progress set failed\n"); return BUDB_IO; } @@ -825,15 +891,15 @@ ht_MoveEntries(ut, mht) #ifdef notdef -static afs_int32 +static afs_int32 ht_MoveEntries(ut, mht) struct ubik_trans *ut; struct memoryHashTable *mht; -{ +{ afs_uint32 hash; - int bo; + int bo; struct memoryHTBlock *block; - afs_int32 code; + afs_int32 code; if (mht->oldLength == 0) return 0; @@ -845,26 +911,25 @@ ht_MoveEntries(ut, mht) hash = mht->progress; /* get hash table block ? */ - code = ht_GetTableBlock (ut, mht, hash, 1 /*old*/, &block, &bo); - if (code) + code = ht_GetTableBlock(ut, mht, hash, 1 /*old */ , &block, &bo); + if (code) return code; - if (block == 0) + if (block == 0) return BUDB_INTERNALERROR; do { mht->progress++; - if (block->b.bucket[bo]) - { + if (block->b.bucket[bo]) { code = ht_HashInList(ut, mht, ntohl(block->b.bucket[bo])); - if ( code ) - { + if (code) { Log("ht_MoveEntries: ht_HashInList failed\n"); - return(BUDB_IO); + return (BUDB_IO); } - code = set_word_addr(ut, block->a, &block->b, &block->b.bucket[bo], 0); - if ( code ) - { + code = + set_word_addr(ut, block->a, &block->b, &block->b.bucket[bo], + 0); + if (code) { Log("ht_MoveEntries: clear old entry failed\n"); return BUDB_IO; } @@ -873,10 +938,9 @@ ht_MoveEntries(ut, mht) } while (++bo < nHTBuckets); if (mht->progress >= mht->oldLength) - return( ht_FreeTable (ut, mht) ); + return (ht_FreeTable(ut, mht)); - if (set_word_addr (ut, 0, &db.h, &mht->ht->progress, htonl(mht->progress))) - { + if (set_word_addr(ut, 0, &db.h, &mht->ht->progress, htonl(mht->progress))) { Log("ht_MoveEntries: progress set failed\n"); return BUDB_IO; } @@ -884,45 +948,55 @@ ht_MoveEntries(ut, mht) } #endif /* notdef */ -afs_int32 +afs_int32 ht_HashIn(ut, mht, ea, e) struct ubik_trans *ut; struct memoryHashTable *mht; - dbadr ea; /* block db address */ - char *e; /* entry's address (in b) */ -{ + dbadr ea; /* block db address */ + char *e; /* entry's address (in b) */ +{ struct hashTable *ht; afs_uint32 hash; struct memoryHTBlock *block; - int bo; - afs_int32 code; + int bo; + afs_int32 code; - if (!(mht && (ht = mht->ht))) - db_panic("some ht called with bad mht"); + if (!(mht && (ht = mht->ht))) + db_panic("some ht called with bad mht"); - if (code = ht_MaybeAdjust (ut, mht)) + if (code = ht_MaybeAdjust(ut, mht)) return code; - if (mht->length == 0) - if (code = ht_AllocTable (ut, mht)) + if (mht->length == 0) + if (code = ht_AllocTable(ut, mht)) return code; - hash = ht_HashEntry (mht, e); - code = ht_GetTableBlock (ut, mht, hash, 0/*old*/, &block, &bo); - if (code) return code; - if (!block) return BUDB_INTERNALERROR; + hash = ht_HashEntry(mht, e); + code = ht_GetTableBlock(ut, mht, hash, 0 /*old */ , &block, &bo); + if (code) + return code; + if (!block) + return BUDB_INTERNALERROR; code = set_word_offset(ut, ea, e, mht->threadOffset, block->b.bucket[bo]); - if (code) return BUDB_IO; - LogDebug(5, "Hashin: set %d to %d\n", mht->threadOffset, block->b.bucket[bo]); + if (code) + return BUDB_IO; + LogDebug(5, "Hashin: set %d to %d\n", mht->threadOffset, + block->b.bucket[bo]); - code = set_word_addr (ut, block->a, &block->b, &block->b.bucket[bo], htonl(ea)); - if (code) return BUDB_IO; + code = + set_word_addr(ut, block->a, &block->b, &block->b.bucket[bo], + htonl(ea)); + if (code) + return BUDB_IO; LogDebug(5, "Hashin: set %d to %d\n", &block->b.bucket[bo], htonl(ea)); - code = set_word_addr (ut, 0, &db.h, &ht->entries, htonl(ntohl(ht->entries)+1)); - if (code) return BUDB_IO; - - return ht_MoveEntries (ut, mht); + code = + set_word_addr(ut, 0, &db.h, &ht->entries, + htonl(ntohl(ht->entries) + 1)); + if (code) + return BUDB_IO; + + return ht_MoveEntries(ut, mht); } /* RemoveFromList - generic procedure to delete an entry from a list given its @@ -932,150 +1006,161 @@ ht_HashIn(ut, mht, ea, e) * modified. The entry pointer is only used to calculate the thread offset, * but is not otherwise used. */ -afs_int32 RemoveFromList (ut, ea, e, head, ta, t, thread) - struct ubik_trans *ut; - dbadr ea; /* db addr of head structure */ - char *e; /* head structure */ - dbadr *head; /* address of head pointer */ - dbadr ta; /* db addr of strucure to be removed */ - char *t; /* structure being removed */ - dbadr *thread; /* pointer to thread pointer */ -{ afs_int32 code; - int threadOffset = ((char *)thread - t); - dbadr next_a; /* db addr of next element in list */ - dbadr loop_a; /* db addr of current list element */ - - if (*head == 0) return -1; /* empty list: not found */ - next_a = ntohl(*head); /* start at head of list */ - if (next_a == ta) { /* remove from head of list */ - code = set_word_addr (ut, ea, e, head, *thread); +afs_int32 +RemoveFromList(ut, ea, e, head, ta, t, thread) + struct ubik_trans *ut; + dbadr ea; /* db addr of head structure */ + char *e; /* head structure */ + dbadr *head; /* address of head pointer */ + dbadr ta; /* db addr of strucure to be removed */ + char *t; /* structure being removed */ + dbadr *thread; /* pointer to thread pointer */ +{ + afs_int32 code; + int threadOffset = ((char *)thread - t); + dbadr next_a; /* db addr of next element in list */ + dbadr loop_a; /* db addr of current list element */ + + if (*head == 0) + return -1; /* empty list: not found */ + next_a = ntohl(*head); /* start at head of list */ + if (next_a == ta) { /* remove from head of list */ + code = set_word_addr(ut, ea, e, head, *thread); return code; } do { loop_a = next_a; - code = dbread (ut, loop_a+threadOffset, (char *)&next_a, sizeof(dbadr)); - if (code) return code; - if (next_a == 0) return -1; /* end of list: not found */ + code = + dbread(ut, loop_a + threadOffset, (char *)&next_a, sizeof(dbadr)); + if (code) + return code; + if (next_a == 0) + return -1; /* end of list: not found */ } while (ta != (next_a = ntohl(next_a))); - code = dbwrite (ut, loop_a+threadOffset, (char *)thread, sizeof(dbadr)); + code = dbwrite(ut, loop_a + threadOffset, (char *)thread, sizeof(dbadr)); return code; } -afs_int32 ht_HashOutT (ut, mht, hash, ea, e, old) - struct ubik_trans *ut; - struct memoryHashTable *mht; - afs_uint32 hash; - dbadr ea; - char *e; - int old; +afs_int32 +ht_HashOutT(ut, mht, hash, ea, e, old) + struct ubik_trans *ut; + struct memoryHashTable *mht; + afs_uint32 hash; + dbadr ea; + char *e; + int old; { struct memoryHTBlock *block; - int bo; - afs_int32 code; + int bo; + afs_int32 code; if ((old ? mht->oldLength : mht->length) == 0) return -1; - code = ht_GetTableBlock (ut, mht, hash, old, &block, &bo); + code = ht_GetTableBlock(ut, mht, hash, old, &block, &bo); if (code) return code; if ((block == 0) || (block->b.bucket[bo] == 0)) return -1; - code = RemoveFromList(ut, block->a, (char *)&block->b, - &block->b.bucket[bo], ea, e, - (dbadr *)(e+mht->threadOffset)); + code = + RemoveFromList(ut, block->a, (char *)&block->b, &block->b.bucket[bo], + ea, e, (dbadr *) (e + mht->threadOffset)); if (code) return code; #if 0 net_ea = htonl(ea); - unthread_ea = *(afs_int32 *)((char *)e + mht->threadOffset); + unthread_ea = *(afs_int32 *) ((char *)e + mht->threadOffset); if (block->b.bucket[bo] == net_ea) { - if (set_word_addr (ut, block->a, &block->b, &block->b.bucket[bo], unthread_ea)) + if (set_word_addr + (ut, block->a, &block->b, &block->b.bucket[bo], unthread_ea)) return BUDB_IO; goto done; } loop_a = ntohl(block->b.bucket[bo]); while (1) { - if (dbread (ut, loop_a + mht->threadOffset, - (char *)&next_loop_a, sizeof(dbadr))) + if (dbread + (ut, loop_a + mht->threadOffset, (char *)&next_loop_a, + sizeof(dbadr))) return BUDB_IO; - if (next_loop_a == 0) return -1; /* not found */ + if (next_loop_a == 0) + return -1; /* not found */ if (net_ea == next_loop_a) { - if (dbwrite (ut, loop_a + mht->threadOffset, (char *)&unthread_ea, sizeof(dbadr))) - return BUDB_IO; + if (dbwrite + (ut, loop_a + mht->threadOffset, (char *)&unthread_ea, + sizeof(dbadr))) + return BUDB_IO; goto done; } - loop_a = ntohl (next_loop_a); - } + loop_a = ntohl(next_loop_a); + } done: #endif - if (set_word_addr (ut, 0, &db.h, &mht->ht->entries, htonl(ntohl(mht->ht->entries) - 1))) - return BUDB_IO; + if (set_word_addr + (ut, 0, &db.h, &mht->ht->entries, htonl(ntohl(mht->ht->entries) - 1))) + return BUDB_IO; return 0; } afs_int32 -ht_HashOut (ut, mht, ea, e) +ht_HashOut(ut, mht, ea, e) struct ubik_trans *ut; struct memoryHashTable *mht; dbadr ea; char *e; { afs_uint32 hash; - afs_int32 code; - - if (!mht) - db_panic ("some ht called with bad mht"); - hash = ht_HashEntry (mht, e); - if (mht->oldLength) - { - code = ht_HashOutT (ut, mht, hash, ea, e, 1/*old*/); - if (code == 0) + afs_int32 code; + + if (!mht) + db_panic("some ht called with bad mht"); + hash = ht_HashEntry(mht, e); + if (mht->oldLength) { + code = ht_HashOutT(ut, mht, hash, ea, e, 1 /*old */ ); + if (code == 0) return 0; - else - if (code != -1) + else if (code != -1) ERROR(code); } - if (mht->length == 0) /* not found */ + if (mht->length == 0) /* not found */ ERROR(BUDB_INTERNALERROR); - code = ht_HashOutT (ut, mht, hash, ea, e, 0/*old*/); + code = ht_HashOutT(ut, mht, hash, ea, e, 0 /*old */ ); if (code == -1) ERROR(BUDB_NOENT); if (code) ERROR(code); - code = ht_MoveEntries (ut, mht); - if ( code ) + code = ht_MoveEntries(ut, mht); + if (code) ERROR(code); - code = ht_MaybeAdjust (ut, mht); - if ( code ) + code = ht_MaybeAdjust(ut, mht); + if (code) ERROR(code); -error_exit: - return(code); + error_exit: + return (code); } /* generic hash table traversal routines */ afs_int32 -scanHashTableBlock(ut, mhtPtr, htBlockPtr, old, length, index, - selectFn, operationFn, rockPtr) +scanHashTableBlock(ut, mhtPtr, htBlockPtr, old, length, index, selectFn, + operationFn, rockPtr) struct ubik_trans *ut; struct memoryHashTable *mhtPtr; struct htBlock *htBlockPtr; int old; - afs_int32 length; /* size of whole hash table */ - int index; /* base index of this block */ - int (*selectFn)(); - int (*operationFn)(); + afs_int32 length; /* size of whole hash table */ + int index; /* base index of this block */ + int (*selectFn) (); + int (*operationFn) (); char *rockPtr; { - int type; /* hash table type */ - int entrySize; /* hashed entry size */ + int type; /* hash table type */ + int entrySize; /* hashed entry size */ + + afs_uint32 *mapEntryPtr = 0; /* for status checks */ - afs_uint32 *mapEntryPtr = 0; /* for status checks */ - char entry[sizeof(struct block)]; dbadr entryAddr, nextEntryAddr; @@ -1089,109 +1174,100 @@ scanHashTableBlock(ut, mhtPtr, htBlockPtr, old, length, index, * before the end of the overall hash table */ - for ( i = 0; (i < nHTBuckets) && (index < length); i++, index++ ) - { /*f*/ + for (i = 0; (i < nHTBuckets) && (index < length); i++, index++) { /*f */ entryAddr = 0; - nextEntryAddr = ntohl( htBlockPtr->bucket[i] ); + nextEntryAddr = ntohl(htBlockPtr->bucket[i]); /* if this is the old hash table, all entries below the progress mark * should have been moved to the new hash table */ if (old && (index < mhtPtr->progress) && nextEntryAddr) - return BUDB_INTERNALERROR; + return BUDB_INTERNALERROR; /* now walk down the chain of each bucket */ - while ( nextEntryAddr ) - { /*w*/ + while (nextEntryAddr) { /*w */ entryAddr = nextEntryAddr; - if ( dbread(ut, entryAddr, &entry[0], entrySize) ) - return(BUDB_INTERNALERROR); + if (dbread(ut, entryAddr, &entry[0], entrySize)) + return (BUDB_INTERNALERROR); - if ( (*selectFn)(entryAddr, &entry[0], rockPtr) ) - { - (*operationFn)(entryAddr, &entry[0], rockPtr); + if ((*selectFn) (entryAddr, &entry[0], rockPtr)) { + (*operationFn) (entryAddr, &entry[0], rockPtr); } - nextEntryAddr = ntohl( *((dbadr *)(entry + mhtPtr->threadOffset))); - } /*w*/ + nextEntryAddr = + ntohl(*((dbadr *) (entry + mhtPtr->threadOffset))); + } /*w */ - } /*f*/ + } /*f */ - return(0); + return (0); } afs_int32 scanHashTable(ut, mhtPtr, selectFn, operationFn, rockPtr) - struct ubik_trans *ut; - struct memoryHashTable *mhtPtr; - int (*selectFn)(); - int (*operationFn)(); - char *rockPtr; + struct ubik_trans *ut; + struct memoryHashTable *mhtPtr; + int (*selectFn) (); + int (*operationFn) (); + char *rockPtr; { struct htBlock hashTableBlock; - dbadr tableAddr; /* disk addr of hash block */ - int tableLength; /* # entries */ - int blockLength; /* # blocks */ + dbadr tableAddr; /* disk addr of hash block */ + int tableLength; /* # entries */ + int blockLength; /* # blocks */ int hashIndex; int blockIndex, entryIndex; int old; int i; afs_int32 code = 0; - extern int nHTBuckets; /* # buckets in a hash table */ - - for ( old = 0; old <= 1; old++ ) - { /*fo*/ - if (old) - { - /* check the old hash table */ - tableLength = mhtPtr->oldLength; - if ( tableLength == 0 ) - continue; /* nothing to do */ - - tableAddr = ntohl(mhtPtr->ht->oldTable); - } - else - { - /* check current hash table */ - tableLength = mhtPtr->length; - if ( tableLength == 0 ) - continue; /* nothing to do */ - - tableAddr = ntohl(mhtPtr->ht->table); - } - - blockLength = (tableLength-1)/nHTBuckets; - hashIndex = 0; - - /* follow the hash chain */ - for ( i = 0; i <= blockLength; i++ ) - { /*fi*/ - /* chain too short */ - if ( tableAddr == 0 ) - ERROR(BUDB_DATABASEINCONSISTENT); - - code = dbread(ut, tableAddr, &hashTableBlock, - sizeof(hashTableBlock)); - if ( code ) - goto error_exit; - - code = scanHashTableBlock(ut, mhtPtr, &hashTableBlock, old, - tableLength, hashIndex, - selectFn, operationFn, - rockPtr); - if ( code ) - goto error_exit; - - hashIndex += nHTBuckets; - tableAddr = ntohl(hashTableBlock.h.next); - } /*fi*/ - } /*fo*/ - -error_exit: - return(code); -} + extern int nHTBuckets; /* # buckets in a hash table */ + + for (old = 0; old <= 1; old++) { /*fo */ + if (old) { + /* check the old hash table */ + tableLength = mhtPtr->oldLength; + if (tableLength == 0) + continue; /* nothing to do */ + + tableAddr = ntohl(mhtPtr->ht->oldTable); + } else { + /* check current hash table */ + tableLength = mhtPtr->length; + if (tableLength == 0) + continue; /* nothing to do */ + + tableAddr = ntohl(mhtPtr->ht->table); + } + blockLength = (tableLength - 1) / nHTBuckets; + hashIndex = 0; + /* follow the hash chain */ + for (i = 0; i <= blockLength; i++) { /*fi */ + /* chain too short */ + if (tableAddr == 0) + ERROR(BUDB_DATABASEINCONSISTENT); + + code = + dbread(ut, tableAddr, &hashTableBlock, + sizeof(hashTableBlock)); + if (code) + goto error_exit; + code = + scanHashTableBlock(ut, mhtPtr, &hashTableBlock, old, + tableLength, hashIndex, selectFn, + operationFn, rockPtr); + if (code) + goto error_exit; + + hashIndex += nHTBuckets; + tableAddr = ntohl(hashTableBlock.h.next); + } /*fi */ + } /*fo */ + + error_exit: + return (code); +} diff --git a/src/budb/db_lock.c b/src/budb/db_lock.c index 9dbdc45b4..d4a6d1ae9 100644 --- a/src/budb/db_lock.c +++ b/src/budb/db_lock.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #ifdef AFS_NT40_ENV @@ -32,111 +33,115 @@ RCSID("$Header$"); afs_int32 FreeAllLocks(), FreeLock(), GetInstanceId(), GetLock(); -afs_int32 SBUDB_FreeAllLocks (call, instanceId) +afs_int32 +SBUDB_FreeAllLocks(call, instanceId) struct rx_call *call; afs_uint32 instanceId; { - afs_int32 code; + afs_int32 code; - code = FreeAllLocks (call, instanceId); - osi_auditU (call, BUDB_FrALckEvent, code, AUD_END); - return code; + code = FreeAllLocks(call, instanceId); + osi_auditU(call, BUDB_FrALckEvent, code, AUD_END); + return code; } -afs_int32 FreeAllLocks (call, instanceId) +afs_int32 +FreeAllLocks(call, instanceId) struct rx_call *call; afs_uint32 instanceId; { - db_lockP startPtr, endPtr; + db_lockP startPtr, endPtr; struct ubik_trans *ut; afs_int32 code; - if ( callPermitted(call) == 0 ) - return(BUDB_NOTPERMITTED); + if (callPermitted(call) == 0) + return (BUDB_NOTPERMITTED); code = InitRPC(&ut, LOCKWRITE, 1); - if ( code ) - return(code); + if (code) + return (code); startPtr = &db.h.textLocks[0]; - endPtr = &db.h.textLocks[TB_NUM-1]; - while ( startPtr <= endPtr ) - { - if ( (ntohl(startPtr->lockState) == 1) - && (ntohl(startPtr->instanceId) == instanceId) - ) - { + endPtr = &db.h.textLocks[TB_NUM - 1]; + while (startPtr <= endPtr) { + if ((ntohl(startPtr->lockState) == 1) + && (ntohl(startPtr->instanceId) == instanceId) + ) { /* release the lock */ - startPtr->lockState = 0; /* unlock it */ + startPtr->lockState = 0; /* unlock it */ startPtr->lockTime = 0; startPtr->expires = 0; startPtr->instanceId = 0; - dbwrite(ut, DBH_POS(startPtr), (char *) startPtr, + dbwrite(ut, DBH_POS(startPtr), (char *)startPtr, sizeof(db_lockT)); } - startPtr++; + startPtr++; } code = ubik_EndTrans(ut); - return(code); + return (code); } -afs_int32 SBUDB_FreeLock (call, lockHandle) +afs_int32 +SBUDB_FreeLock(call, lockHandle) struct rx_call *call; afs_uint32 lockHandle; { - afs_int32 code; + afs_int32 code; - code = FreeLock (call, lockHandle); - osi_auditU (call, BUDB_FreLckEvent, code, AUD_END); - return code; + code = FreeLock(call, lockHandle); + osi_auditU(call, BUDB_FreLckEvent, code, AUD_END); + return code; } -afs_int32 FreeLock (call, lockHandle) +afs_int32 +FreeLock(call, lockHandle) struct rx_call *call; afs_uint32 lockHandle; { - db_lockP lockPtr = 0; + db_lockP lockPtr = 0; struct ubik_trans *ut; afs_int32 code; - if ( callPermitted(call) == 0 ) - return(BUDB_NOTPERMITTED); + if (callPermitted(call) == 0) + return (BUDB_NOTPERMITTED); code = InitRPC(&ut, LOCKWRITE, 1); - if ( code ) - return(code); + if (code) + return (code); - if ( checkLockHandle(ut, lockHandle) == 0 ) - ABORT(BUDB_BADARGUMENT); + if (checkLockHandle(ut, lockHandle) == 0) + ABORT(BUDB_BADARGUMENT); - lockPtr = &db.h.textLocks[lockHandle-1]; + lockPtr = &db.h.textLocks[lockHandle - 1]; - lockPtr->lockState = 0; /* unlock it */ + lockPtr->lockState = 0; /* unlock it */ lockPtr->lockTime = 0; lockPtr->expires = 0; lockPtr->instanceId = 0; - dbwrite(ut, DBH_POS(lockPtr), (char *) lockPtr, sizeof(db_lockT)); + dbwrite(ut, DBH_POS(lockPtr), (char *)lockPtr, sizeof(db_lockT)); code = ubik_EndTrans(ut); - return(code); - -abort_exit: - ubik_AbortTrans (ut); - return(code); + return (code); + + abort_exit: + ubik_AbortTrans(ut); + return (code); } -afs_int32 SBUDB_GetInstanceId(call, instanceId) +afs_int32 +SBUDB_GetInstanceId(call, instanceId) struct rx_call *call; afs_uint32 *instanceId; { - afs_int32 code; + afs_int32 code; - code = GetInstanceId (call, instanceId); - osi_auditU (call, BUDB_GetIIdEvent, code, AUD_END); - return code; + code = GetInstanceId(call, instanceId); + osi_auditU(call, BUDB_GetIIdEvent, code, AUD_END); + return code; } -afs_int32 GetInstanceId (call, instanceId) +afs_int32 +GetInstanceId(call, instanceId) struct rx_call *call; afs_uint32 *instanceId; { @@ -152,33 +157,35 @@ afs_int32 GetInstanceId (call, instanceId) */ code = InitRPC(&ut, LOCKWRITE, 1); - if ( code ) - return(code); + if (code) + return (code); instanceValue = ntohl(db.h.lastInstanceId) + 1; set_header_word(ut, lastInstanceId, htonl(instanceValue)); code = ubik_EndTrans(ut); - return(code); + return (code); } -afs_int32 SBUDB_GetLock (call, instanceId, lockName, expiration, lockHandle) +afs_int32 +SBUDB_GetLock(call, instanceId, lockName, expiration, lockHandle) struct rx_call *call; afs_uint32 instanceId; afs_int32 lockName; afs_int32 expiration; afs_uint32 *lockHandle; { - afs_int32 code; + afs_int32 code; - code = GetLock (call, instanceId, lockName, expiration, lockHandle); - osi_auditU (call, BUDB_GetLckEvent, code, AUD_END); - return code; + code = GetLock(call, instanceId, lockName, expiration, lockHandle); + osi_auditU(call, BUDB_GetLckEvent, code, AUD_END); + return code; } -afs_int32 GetLock (call, instanceId, lockName, expiration, lockHandle) +afs_int32 +GetLock(call, instanceId, lockName, expiration, lockHandle) struct rx_call *call; afs_uint32 instanceId; afs_int32 lockName; @@ -186,51 +193,51 @@ afs_int32 GetLock (call, instanceId, lockName, expiration, lockHandle) afs_uint32 *lockHandle; { struct timeval tv; - db_lockP lockPtr; + db_lockP lockPtr; struct ubik_trans *ut; afs_int32 code; - if ( callPermitted(call) == 0 ) - return(BUDB_NOTPERMITTED); + if (callPermitted(call) == 0) + return (BUDB_NOTPERMITTED); - if ( (lockName < 0) || (lockName >= TB_NUM) ) - return(BUDB_BADARGUMENT); + if ((lockName < 0) || (lockName >= TB_NUM)) + return (BUDB_BADARGUMENT); /* get the current time */ gettimeofday(&tv, 0); code = InitRPC(&ut, LOCKWRITE, 1); - if ( code ) - return(code); + if (code) + return (code); lockPtr = &db.h.textLocks[lockName]; - if ( (ntohl(lockPtr->lockState) != 0) /* lock set */ - && (ntohl(lockPtr->expires) > tv.tv_sec) /* not expired */ - ) - { - if ( ntohl(lockPtr->instanceId) == instanceId ) - code = BUDB_SELFLOCKED; + if ((ntohl(lockPtr->lockState) != 0) /* lock set */ + &&(ntohl(lockPtr->expires) > tv.tv_sec) /* not expired */ + ) { + if (ntohl(lockPtr->instanceId) == instanceId) + code = BUDB_SELFLOCKED; else - code = BUDB_LOCKED; + code = BUDB_LOCKED; goto abort_exit; } - - lockPtr->lockState = htonl(1); /* lock it */ - lockPtr->lockTime = htonl(tv.tv_sec); /* when locked */ + + lockPtr->lockState = htonl(1); /* lock it */ + lockPtr->lockTime = htonl(tv.tv_sec); /* when locked */ lockPtr->expires = htonl(tv.tv_sec + expiration); lockPtr->instanceId = htonl(instanceId); - code = dbwrite(ut, DBH_POS(lockPtr), (char *) lockPtr, sizeof(db_lockT)); - if (code) ABORT(code); + code = dbwrite(ut, DBH_POS(lockPtr), (char *)lockPtr, sizeof(db_lockT)); + if (code) + ABORT(code); - *lockHandle = (afs_uint32)(lockName + 1); + *lockHandle = (afs_uint32) (lockName + 1); code = ubik_EndTrans(ut); - return(code); + return (code); -abort_exit: - ubik_AbortTrans (ut); - return(code); + abort_exit: + ubik_AbortTrans(ut); + return (code); } @@ -246,4 +253,3 @@ checkLockHandle(ut, lockHandle) { return (((lockHandle > 0) && (lockHandle <= TB_NUM)) ? 1 : 0); } - diff --git a/src/budb/db_lock.h b/src/budb/db_lock.h index d49a31471..ef78afca5 100644 --- a/src/budb/db_lock.h +++ b/src/budb/db_lock.h @@ -7,15 +7,14 @@ * directory or online at http://www.openafs.org/dl/license10.html */ -struct db_lockS -{ - afs_int32 type; /* user defined - for consistency checks */ - afs_int32 lockState; /* locked/free */ - afs_int32 lockTime; /* when locked */ - afs_int32 expires; /* when timeout expires */ - afs_int32 instanceId; /* user instance id */ - int lockHost; /* locking host, if possible */ +struct db_lockS { + afs_int32 type; /* user defined - for consistency checks */ + afs_int32 lockState; /* locked/free */ + afs_int32 lockTime; /* when locked */ + afs_int32 expires; /* when timeout expires */ + afs_int32 instanceId; /* user instance id */ + int lockHost; /* locking host, if possible */ }; -typedef struct db_lockS db_lockT; -typedef db_lockT db_lockP; +typedef struct db_lockS db_lockT; +typedef db_lockT db_lockP; diff --git a/src/budb/db_text.c b/src/budb/db_text.c index 06307d0df..66378561b 100644 --- a/src/budb/db_text.c +++ b/src/budb/db_text.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -51,8 +52,9 @@ RCSID("$Header$"); afs_int32 GetText(), GetTextVersion(), SaveText(); -afs_int32 SBUDB_GetText (call, lockHandle, textType, maxLength, offset, - nextOffset, charListPtr) +afs_int32 +SBUDB_GetText(call, lockHandle, textType, maxLength, offset, nextOffset, + charListPtr) struct rx_call *call; afs_uint32 lockHandle; afs_int32 textType; @@ -61,16 +63,18 @@ afs_int32 SBUDB_GetText (call, lockHandle, textType, maxLength, offset, afs_int32 *nextOffset; charListT *charListPtr; { - afs_int32 code; + afs_int32 code; - code = GetText (call, lockHandle, textType, maxLength, offset, - nextOffset, charListPtr); - osi_auditU (call, BUDB_GetTxtEvent, code, AUD_LONG, textType, AUD_END); - return code; + code = + GetText(call, lockHandle, textType, maxLength, offset, nextOffset, + charListPtr); + osi_auditU(call, BUDB_GetTxtEvent, code, AUD_LONG, textType, AUD_END); + return code; } -afs_int32 GetText (call, lockHandle, textType, maxLength, offset, - nextOffset, charListPtr) +afs_int32 +GetText(call, lockHandle, textType, maxLength, offset, nextOffset, + charListPtr) struct rx_call *call; afs_uint32 lockHandle; afs_int32 textType; @@ -91,21 +95,19 @@ afs_int32 GetText (call, lockHandle, textType, maxLength, offset, afs_int32 code; LogDebug(5, "GetText: type %d, offset %d, nextOffset %d, maxLength %d\n", - textType, offset, nextOffset, maxLength); + textType, offset, nextOffset, maxLength); - if ( callPermitted(call) == 0 ) - { - code = BUDB_NOTPERMITTED; + if (callPermitted(call) == 0) { + code = BUDB_NOTPERMITTED; goto no_xfer_abort; } /* check parameters */ - if ( (offset < 0) - || (textType < 0) - || (textType >= TB_NUM) - ) - { - code = BUDB_BADARGUMENT; + if ((offset < 0) + || (textType < 0) + || (textType >= TB_NUM) + ) { + code = BUDB_BADARGUMENT; goto no_xfer_abort; } @@ -115,19 +117,17 @@ afs_int32 GetText (call, lockHandle, textType, maxLength, offset, goto no_xfer_abort; /* fetch the lock state */ - if ( checkLockHandle(ut, lockHandle) == 0) - { + if (checkLockHandle(ut, lockHandle) == 0) { code = BUDB_NOTLOCKED; goto no_xfer_abort; } tbPtr = &db.h.textBlock[textType]; - if ( (ntohl(tbPtr->size) > 0) - && (offset >= ntohl(tbPtr->size)) - ) - { - code = BUDB_BADARGUMENT; + if ((ntohl(tbPtr->size) > 0) + && (offset >= ntohl(tbPtr->size)) + ) { + code = BUDB_BADARGUMENT; goto no_xfer_abort; } @@ -139,14 +139,13 @@ afs_int32 GetText (call, lockHandle, textType, maxLength, offset, /* allocate the transfer storage */ if (transferSize <= 0) { - charListPtr->charListT_len = 0L; - charListPtr->charListT_val = NULL; - } - else { - charListPtr->charListT_len = transferSize; - charListPtr->charListT_val = (char *) malloc(transferSize); - if ( charListPtr->charListT_val == 0 ) - ABORT(BUDB_NOMEM); + charListPtr->charListT_len = 0L; + charListPtr->charListT_val = NULL; + } else { + charListPtr->charListT_len = transferSize; + charListPtr->charListT_val = (char *)malloc(transferSize); + if (charListPtr->charListT_val == 0) + ABORT(BUDB_NOMEM); } textPtr = charListPtr->charListT_val; @@ -155,22 +154,20 @@ afs_int32 GetText (call, lockHandle, textType, maxLength, offset, /* setup the datablock. read and discard all blocks up to the one the * offset specifies */ - nblocks = offset/BLOCK_DATA_SIZE; + nblocks = offset / BLOCK_DATA_SIZE; lastBlockAddr = ntohl(tbPtr->textAddr); - - while ( nblocks-- ) - { - code = dbread(ut, lastBlockAddr, (char *) &block, sizeof(block)); - if ( code ) - ABORT(BUDB_IO); + + while (nblocks--) { + code = dbread(ut, lastBlockAddr, (char *)&block, sizeof(block)); + if (code) + ABORT(BUDB_IO); lastBlockAddr = ntohl(block.h.next); } - - while ( transferSize > 0 ) - { - code = dbread(ut, lastBlockAddr, (char *) &block, sizeof(block)); - if ( code ) - ABORT(BUDB_IO); + + while (transferSize > 0) { + code = dbread(ut, lastBlockAddr, (char *)&block, sizeof(block)); + if (code) + ABORT(BUDB_IO); LogDebug(5, "fetched block %d\n", lastBlockAddr); @@ -187,33 +184,31 @@ afs_int32 GetText (call, lockHandle, textType, maxLength, offset, offset += chunkSize; textPtr += chunkSize; - if ( transferSize ) - { + if (transferSize) { /* setup lastBlockAddr */ lastBlockAddr = ntohl(block.h.next); } } - if ( *nextOffset == ntohl(tbPtr->size) ) - { + if (*nextOffset == ntohl(tbPtr->size)) { /* all done */ *nextOffset = -1; } -error_exit: + error_exit: code = ubik_EndTrans(ut); /* printf("in error exit, code=%ld\n", code); */ - return(code); + return (code); -no_xfer_abort: + no_xfer_abort: charListPtr->charListT_len = 0; - charListPtr->charListT_val = (char *) malloc(0); + charListPtr->charListT_val = (char *)malloc(0); -abort_exit: - if ( ut ) + abort_exit: + if (ut) ubik_AbortTrans(ut); /* printf("in abort exit, code=%ld\n", code); */ - return(code); + return (code); } freeOldBlockChain(ut, diskAddr) @@ -224,39 +219,41 @@ freeOldBlockChain(ut, diskAddr) dbadr nextDiskAddr; afs_int32 code; - while ( diskAddr != 0 ) - { + while (diskAddr != 0) { /* read in the header */ - code = dbread(ut, diskAddr, (char *) &blockHeader,sizeof(blockHeader)); - if ( code ) - ABORT(code); + code = + dbread(ut, diskAddr, (char *)&blockHeader, sizeof(blockHeader)); + if (code) + ABORT(code); nextDiskAddr = ntohl(blockHeader.next); code = FreeBlock(ut, &blockHeader, diskAddr); - if ( code ) - ABORT(code); + if (code) + ABORT(code); diskAddr = nextDiskAddr; } -abort_exit: - return(code); + abort_exit: + return (code); } /* BUDB_GetTextVersion * get the version number for the specified text block */ -afs_int32 SBUDB_GetTextVersion (call, textType, tversion) +afs_int32 +SBUDB_GetTextVersion(call, textType, tversion) struct rx_call *call; afs_int32 textType; afs_uint32 *tversion; { - afs_int32 code; + afs_int32 code; - code = GetTextVersion (call, textType, tversion); - osi_auditU (call, BUDB_GetTxVEvent, code, AUD_LONG, textType, AUD_END); - return code; + code = GetTextVersion(call, textType, tversion); + osi_auditU(call, BUDB_GetTxVEvent, code, AUD_LONG, textType, AUD_END); + return code; } -afs_int32 GetTextVersion (call, textType, tversion) +afs_int32 +GetTextVersion(call, textType, tversion) struct rx_call *call; afs_int32 textType; afs_uint32 *tversion; @@ -264,19 +261,19 @@ afs_int32 GetTextVersion (call, textType, tversion) afs_int32 code; struct ubik_trans *ut; - if ( callPermitted(call) == 0 ) - return(BUDB_NOTPERMITTED); + if (callPermitted(call) == 0) + return (BUDB_NOTPERMITTED); - if ( (textType < 0) || (textType >= TB_NUM) ) - return(BUDB_BADARGUMENT); + if ((textType < 0) || (textType >= TB_NUM)) + return (BUDB_BADARGUMENT); code = InitRPC(&ut, LOCKREAD, 1); if (code) - return(code); + return (code); *tversion = ntohl(db.h.textBlock[textType].version); code = ubik_EndTrans(ut); - return(code); + return (code); } /* text blocks @@ -289,7 +286,8 @@ afs_int32 GetTextVersion (call, textType, tversion) * charListPtr storage automatically malloced and freed */ -afs_int32 SBUDB_SaveText (call, lockHandle, textType, offset, flags, charListPtr) +afs_int32 +SBUDB_SaveText(call, lockHandle, textType, offset, flags, charListPtr) struct rx_call *call; afs_uint32 lockHandle; afs_int32 textType; @@ -297,14 +295,15 @@ afs_int32 SBUDB_SaveText (call, lockHandle, textType, offset, flags, charListPtr afs_int32 flags; charListT *charListPtr; { - afs_int32 code; + afs_int32 code; - code = SaveText (call, lockHandle, textType, offset, flags, charListPtr); - osi_auditU (call, BUDB_SavTxtEvent, code, AUD_LONG, textType, AUD_END); - return code; + code = SaveText(call, lockHandle, textType, offset, flags, charListPtr); + osi_auditU(call, BUDB_SavTxtEvent, code, AUD_LONG, textType, AUD_END); + return code; } -afs_int32 SaveText (call, lockHandle, textType, offset, flags, charListPtr) +afs_int32 +SaveText(call, lockHandle, textType, offset, flags, charListPtr) struct rx_call *call; afs_uint32 lockHandle; afs_int32 textType; @@ -321,40 +320,41 @@ afs_int32 SaveText (call, lockHandle, textType, offset, flags, charListPtr) char *textptr = charListPtr->charListT_val; afs_int32 code; - LogDebug(5, "SaveText: type %d, offset %d, length %d\n", - textType, offset, textLength); + LogDebug(5, "SaveText: type %d, offset %d, length %d\n", textType, offset, + textLength); - if ( callPermitted(call) == 0 ) - return(BUDB_NOTPERMITTED); + if (callPermitted(call) == 0) + return (BUDB_NOTPERMITTED); - if ( (textLength > BLOCK_DATA_SIZE) || (offset < 0) ) - return(BUDB_BADARGUMENT); + if ((textLength > BLOCK_DATA_SIZE) || (offset < 0)) + return (BUDB_BADARGUMENT); code = InitRPC(&ut, LOCKWRITE, 1); - if (code) return(code); + if (code) + return (code); /* fetch the lock state */ - if ( checkLockHandle(ut, lockHandle) == 0) - ABORT(BUDB_NOTLOCKED); + if (checkLockHandle(ut, lockHandle) == 0) + ABORT(BUDB_NOTLOCKED); - if ( (textType < 0) || (textType >= TB_NUM) ) - ABORT(BUDB_BADARGUMENT); + if ((textType < 0) || (textType >= TB_NUM)) + ABORT(BUDB_BADARGUMENT); tbPtr = &db.h.textBlock[textType]; - LogDebug(5, "SaveText: lockHandle %d textType %d offset %d flags %d txtlength %d\n", - lockHandle, textType, offset, flags, textLength); + LogDebug(5, + "SaveText: lockHandle %d textType %d offset %d flags %d txtlength %d\n", + lockHandle, textType, offset, flags, textLength); - if (offset == 0) - { + if (offset == 0) { /* release any blocks from previous transactions */ diskBlockAddr = ntohl(tbPtr->newTextAddr); freeOldBlockChain(ut, diskBlockAddr); - if (textLength) - { + if (textLength) { code = AllocBlock(ut, &diskBlock, &diskBlockAddr); - if (code) ABORT(code); + if (code) + ABORT(code); LogDebug(5, "allocated block %d\n", diskBlockAddr); @@ -364,72 +364,75 @@ afs_int32 SaveText (call, lockHandle, textType, offset, flags, charListPtr) /* save it in the database header */ tbPtr->newsize = 0; tbPtr->newTextAddr = htonl(diskBlockAddr); - dbwrite(ut, (char *)tbPtr - (char *)&db.h, (char *)tbPtr, sizeof(struct textBlock)); - } - else - { + dbwrite(ut, (char *)tbPtr - (char *)&db.h, (char *)tbPtr, + sizeof(struct textBlock)); + } else { tbPtr->newsize = 0; tbPtr->newTextAddr = 0; } - } - else - { + } else { /* non-zero offset */ int nblocks; - if (offset != ntohl(tbPtr->newsize)) + if (offset != ntohl(tbPtr->newsize)) ABORT(BUDB_BADARGUMENT); /* locate the block to which offset refers */ - nblocks = offset/BLOCK_DATA_SIZE; + nblocks = offset / BLOCK_DATA_SIZE; diskBlockAddr = ntohl(tbPtr->newTextAddr); - if (diskBlockAddr == 0) + if (diskBlockAddr == 0) ABORT(BUDB_BADARGUMENT); - code = dbread(ut, diskBlockAddr, (char *)&diskBlock, sizeof(diskBlock)); - if (code) ABORT(code); + code = + dbread(ut, diskBlockAddr, (char *)&diskBlock, sizeof(diskBlock)); + if (code) + ABORT(code); - while ( nblocks-- ) - { + while (nblocks--) { diskBlockAddr = ntohl(diskBlock.h.next); - code = dbread(ut, diskBlockAddr, (char *) &diskBlock, sizeof(diskBlock)); - if (code) ABORT(code); + code = + dbread(ut, diskBlockAddr, (char *)&diskBlock, + sizeof(diskBlock)); + if (code) + ABORT(code); } } /* diskBlock and diskBlockAddr now point to the last block in the chain */ - while (textLength) - { + while (textLength) { /* compute the transfer size */ remainingInBlock = (BLOCK_DATA_SIZE - (offset % BLOCK_DATA_SIZE)); - chunkSize = MIN(remainingInBlock, textLength); + chunkSize = MIN(remainingInBlock, textLength); /* copy in the data */ memcpy(&diskBlock.a[offset % BLOCK_DATA_SIZE], textptr, chunkSize); - /* LogDebug(5, "text is %s\n", textptr); */ + /* LogDebug(5, "text is %s\n", textptr); */ textLength -= chunkSize; - textptr += chunkSize; - offset += chunkSize; + textptr += chunkSize; + offset += chunkSize; tbPtr->newsize = htonl(ntohl(tbPtr->newsize) + chunkSize); - if ( textLength > 0 ) - { + if (textLength > 0) { afs_int32 prevBlockAddr; afs_int32 linkOffset; afs_int32 linkValue; /* have to add another block to the chain */ - code = dbwrite(ut, diskBlockAddr, (char *)&diskBlock, sizeof(diskBlock)); - if (code) ABORT(code); + code = + dbwrite(ut, diskBlockAddr, (char *)&diskBlock, + sizeof(diskBlock)); + if (code) + ABORT(code); prevBlockAddr = (afs_int32) diskBlockAddr; code = AllocBlock(ut, &diskBlock, &diskBlockAddr); - if (code) ABORT(code); + if (code) + ABORT(code); LogDebug(5, "allocated block %d\n", diskBlockAddr); @@ -437,22 +440,26 @@ afs_int32 SaveText (call, lockHandle, textType, offset, flags, charListPtr) diskBlock.h.type = text_BLOCK; /* now have to update the previous block's link */ - linkOffset = (afs_int32) &diskBlock.h.next - (afs_int32) &diskBlock; + linkOffset = + (afs_int32) & diskBlock.h.next - (afs_int32) & diskBlock; linkValue = htonl(diskBlockAddr); - code = dbwrite(ut, (afs_int32)prevBlockAddr + linkOffset, (char *)&linkValue, sizeof(afs_int32)); - if (code) ABORT(code); - } - else - { + code = + dbwrite(ut, (afs_int32) prevBlockAddr + linkOffset, + (char *)&linkValue, sizeof(afs_int32)); + if (code) + ABORT(code); + } else { /* just write the old block */ - code = dbwrite(ut, diskBlockAddr, (char *) &diskBlock, sizeof(diskBlock)); - if (code) ABORT(code); + code = + dbwrite(ut, diskBlockAddr, (char *)&diskBlock, + sizeof(diskBlock)); + if (code) + ABORT(code); } } - if ( flags & BUDB_TEXT_COMPLETE ) /* done */ - { + if (flags & BUDB_TEXT_COMPLETE) { /* done */ /* this was the last chunk of text */ diskBlockAddr = ntohl(tbPtr->textAddr); freeOldBlockChain(ut, diskBlockAddr); @@ -467,16 +474,19 @@ afs_int32 SaveText (call, lockHandle, textType, offset, flags, charListPtr) } /* update size and other text header info */ - code = dbwrite(ut, (char *)tbPtr - (char *)&db.h, (char *)tbPtr, sizeof(struct textBlock)); - if (code) ABORT(code); + code = + dbwrite(ut, (char *)tbPtr - (char *)&db.h, (char *)tbPtr, + sizeof(struct textBlock)); + if (code) + ABORT(code); -error_exit: + error_exit: code = ubik_EndTrans(ut); - return(code); + return (code); -abort_exit: + abort_exit: ubik_AbortTrans(ut); - return(code); + return (code); } /* debug support */ @@ -493,14 +503,13 @@ saveTextToFile(ut, tbPtr) int fid; sprintf(filename, "%s/%s", gettmpdir(), "dbg_XXXXXX"); - + fid = mkstemp(filename); size = ntohl(tbPtr->size); blockAddr = ntohl(tbPtr->textAddr); - while ( size ) - { + while (size) { chunkSize = MIN(BLOCK_DATA_SIZE, size); - dbread(ut, blockAddr, (char *) &block, sizeof(block)); + dbread(ut, blockAddr, (char *)&block, sizeof(block)); write(fid, &block.a[0], chunkSize); blockAddr = ntohl(block.h.next); size -= chunkSize; @@ -530,14 +539,12 @@ mkstemp(st) int retval = -1; #ifdef AFS_LINUX20_ENV - retval = open(mkstemp(st), O_RDWR|O_CREAT|O_EXCL, 0600); + retval = open(mkstemp(st), O_RDWR | O_CREAT | O_EXCL, 0600); #else - retval = open(mktemp(st), O_RDWR|O_CREAT|O_EXCL, 0600); + retval = open(mktemp(st), O_RDWR | O_CREAT | O_EXCL, 0600); #endif -error_exit: - return(retval); + error_exit: + return (retval); } -#endif - - +#endif diff --git a/src/budb/dbs_dump.c b/src/budb/dbs_dump.c index bcb49e8d2..f345383db 100644 --- a/src/budb/dbs_dump.c +++ b/src/budb/dbs_dump.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -56,7 +57,7 @@ badEntry(dbAddr) afs_uint32 dbAddr; { /* return entry ok */ - return(0); + return (0); } /* setupDbDump @@ -69,46 +70,48 @@ setupDbDump(writeFid) afs_int32 code = 0; code = InitRPC(&dumpSyncPtr->ut, LOCKREAD, 1); - if ( code ) + if (code) goto error_exit; code = writeDatabase(dumpSyncPtr->ut, writeFid); - if ( code ) + if (code) LogError(code, "writeDatabase failed\n"); code = close(writeFid); - if ( code ) + if (code) LogError(code, "pipe writer close failed\n"); LogDebug(5, "writeDatabase complete\n"); -error_exit: - if ( dumpSyncPtr->ut ) + error_exit: + if (dumpSyncPtr->ut) ubik_EndTrans(dumpSyncPtr->ut); - return(code); + return (code); } afs_int32 DumpDB(), RestoreDbHeader(); -afs_int32 SBUDB_DumpDB (call, firstcall, maxLength, charListPtr, done) +afs_int32 +SBUDB_DumpDB(call, firstcall, maxLength, charListPtr, done) struct rx_call *call; - int firstcall; + int firstcall; afs_int32 maxLength; - charListT *charListPtr; + charListT *charListPtr; afs_int32 *done; { - afs_int32 code; + afs_int32 code; - code = DumpDB (call, firstcall, maxLength, charListPtr, done); - osi_auditU (call, BUDB_DmpDBEvent, code, AUD_END); - return code; + code = DumpDB(call, firstcall, maxLength, charListPtr, done); + osi_auditU(call, BUDB_DmpDBEvent, code, AUD_END); + return code; } -afs_int32 DumpDB (call, firstcall, maxLength, charListPtr, done) +afs_int32 +DumpDB(call, firstcall, maxLength, charListPtr, done) struct rx_call *call; - int firstcall; /* 1 - init. 0 - no init */ + int firstcall; /* 1 - init. 0 - no init */ afs_int32 maxLength; - charListT *charListPtr; + charListT *charListPtr; afs_int32 *done; { PROCESS dumperPid, watcherPid; @@ -116,7 +119,7 @@ afs_int32 DumpDB (call, firstcall, maxLength, charListPtr, done) afs_int32 code = 0; extern dumpWatcher(); - if ( callPermitted(call) == 0 ) + if (callPermitted(call) == 0) ERROR(BUDB_NOTPERMITTED); ObtainWriteLock(&dumpSyncPtr->ds_lock); @@ -124,21 +127,20 @@ afs_int32 DumpDB (call, firstcall, maxLength, charListPtr, done) /* If asking for zero bytes, then this is a call to reset the timeToLive * timer. Reset it if there is a dump in progress. */ - if (maxLength == 0) - { + if (maxLength == 0) { charListPtr->charListT_val = NULL; charListPtr->charListT_len = 0; - *done = ((dumpSyncPtr->statusFlags == 0) ? 1 : 0); + *done = ((dumpSyncPtr->statusFlags == 0) ? 1 : 0); /* reset the clock on dump timeout */ dumpSyncPtr->timeToLive = time(0) + DUMP_TTL_INC; goto error_exit; } - if (dumpSyncPtr->statusFlags == 0) - { - if (!firstcall) ERROR(BUDB_DUMPFAILED); + if (dumpSyncPtr->statusFlags == 0) { + if (!firstcall) + ERROR(BUDB_DUMPFAILED); LogDebug(5, "Setup dump\n"); @@ -150,41 +152,41 @@ afs_int32 DumpDB (call, firstcall, maxLength, charListPtr, done) dumpSyncPtr->statusFlags = 1; code = pipe(dumpSyncPtr->pipeFid); - if (code) ERROR(errno); - - code = LWP_CreateProcess(setupDbDump, 16384, 1, - (void *) dumpSyncPtr->pipeFid[1], - "Database Dumper", &dumperPid); - if (code) goto error_exit; - - dumpSyncPtr->dumperPid = dumperPid; + if (code) + ERROR(errno); + + code = + LWP_CreateProcess(setupDbDump, 16384, 1, + (void *)dumpSyncPtr->pipeFid[1], + "Database Dumper", &dumperPid); + if (code) + goto error_exit; + + dumpSyncPtr->dumperPid = dumperPid; dumpSyncPtr->timeToLive = time(0) + DUMP_TTL_INC; /* now create the watcher thread */ - code = LWP_CreateProcess(dumpWatcher, 16384, 1, 0, - "Database Dump Watchdog", &watcherPid); - } - else if (firstcall) - ERROR(BUDB_LOCKED); + code = + LWP_CreateProcess(dumpWatcher, 16384, 1, 0, + "Database Dump Watchdog", &watcherPid); + } else if (firstcall) + ERROR(BUDB_LOCKED); /* now read the database and feed it to the rpc connection */ /* wait for data */ - while ( dumpSyncPtr->ds_bytes == 0 ) - { + while (dumpSyncPtr->ds_bytes == 0) { /* if no more data */ - if ( (dumpSyncPtr->ds_writerStatus == DS_DONE ) || - (dumpSyncPtr->ds_writerStatus == DS_DONE_ERROR) ) - { + if ((dumpSyncPtr->ds_writerStatus == DS_DONE) + || (dumpSyncPtr->ds_writerStatus == DS_DONE_ERROR)) { break; } - if ( dumpSyncPtr->ds_writerStatus == DS_WAITING ) - { + if (dumpSyncPtr->ds_writerStatus == DS_WAITING) { LogDebug(6, "wakup writer\n"); dumpSyncPtr->ds_writerStatus = 0; code = LWP_SignalProcess(&dumpSyncPtr->ds_writerStatus); - if ( code ) + if (code) LogError(code, "BUDB_DumpDB: signal delivery failed\n"); } LogDebug(6, "wait for writer\n"); @@ -193,53 +195,54 @@ afs_int32 DumpDB (call, firstcall, maxLength, charListPtr, done) LWP_WaitProcess(&dumpSyncPtr->ds_readerStatus); ObtainWriteLock(&dumpSyncPtr->ds_lock); } - - charListPtr->charListT_val = (char *) malloc(maxLength); - readSize = read(dumpSyncPtr->pipeFid[0], charListPtr->charListT_val, maxLength); + + charListPtr->charListT_val = (char *)malloc(maxLength); + readSize = + read(dumpSyncPtr->pipeFid[0], charListPtr->charListT_val, maxLength); /* reset the clock on dump timeout */ dumpSyncPtr->timeToLive = time(0) + DUMP_TTL_INC; - + LogDebug(4, "read of len %d returned %d\n", maxLength, readSize); charListPtr->charListT_len = readSize; - if ( readSize == 0 ) /* last chunk */ - { + if (readSize == 0) { /* last chunk */ *done = 1; close(dumpSyncPtr->pipeFid[0]); dumpSyncPtr->statusFlags = 0; - } - else + } else *done = 0; dumpSyncPtr->ds_bytes -= readSize; - if ( dumpSyncPtr->ds_writerStatus == DS_WAITING ) - { + if (dumpSyncPtr->ds_writerStatus == DS_WAITING) { dumpSyncPtr->ds_writerStatus = 0; code = LWP_SignalProcess(&dumpSyncPtr->ds_writerStatus); - if ( code ) - LogError(code, "BUDB_DumpDB: signal delivery failed\n"); + if (code) + LogError(code, "BUDB_DumpDB: signal delivery failed\n"); } -error_exit: - if ( !code && (dumpSyncPtr->ds_writerStatus == DS_DONE_ERROR) ) code = -1; + error_exit: + if (!code && (dumpSyncPtr->ds_writerStatus == DS_DONE_ERROR)) + code = -1; ReleaseWriteLock(&dumpSyncPtr->ds_lock); - return(code); + return (code); } -afs_int32 SBUDB_RestoreDbHeader (call, header) +afs_int32 +SBUDB_RestoreDbHeader(call, header) struct rx_call *call; struct DbHeader *header; { - afs_int32 code; + afs_int32 code; - code = RestoreDbHeader (call, header); - osi_auditU (call, BUDB_RstDBHEvent, code, AUD_END); - return code; + code = RestoreDbHeader(call, header); + osi_auditU(call, BUDB_RstDBHEvent, code, AUD_END); + return code; } -afs_int32 RestoreDbHeader (call, header) +afs_int32 +RestoreDbHeader(call, header) struct rx_call *call; struct DbHeader *header; { @@ -248,34 +251,34 @@ afs_int32 RestoreDbHeader (call, header) extern struct memoryDB db; - if ( callPermitted(call) == 0 ) + if (callPermitted(call) == 0) ERROR(BUDB_NOTPERMITTED); code = InitRPC(&ut, LOCKWRITE, 1); - if ( code ) + if (code) goto error_exit; - if ( header->dbversion != ntohl(db.h.version) ) + if (header->dbversion != ntohl(db.h.version)) ERROR(BUDB_VERSIONMISMATCH); /* merge rather than replace the header information */ - if ( db.h.lastDumpId < htonl(header->lastDumpId)) + if (db.h.lastDumpId < htonl(header->lastDumpId)) db.h.lastDumpId = htonl(header->lastDumpId); - if ( db.h.lastTapeId < htonl(header->lastTapeId)) + if (db.h.lastTapeId < htonl(header->lastTapeId)) db.h.lastTapeId = htonl(header->lastTapeId); - if ( db.h.lastInstanceId < htonl(header->lastInstanceId)) + if (db.h.lastInstanceId < htonl(header->lastInstanceId)) db.h.lastInstanceId = htonl(header->lastInstanceId); - code = dbwrite(ut, 0, (char *) &db.h, sizeof(db.h)); - if ( code ) + code = dbwrite(ut, 0, (char *)&db.h, sizeof(db.h)); + if (code) code = BUDB_IO; -error_exit: - if ( ut ) + error_exit: + if (ut) ubik_EndTrans(ut); - return(code); + return (code); } /* dumpWatcher @@ -290,47 +293,46 @@ dumpWatcher() { afs_int32 code; - while ( 1 ) - { /*w*/ + while (1) { /*w */ /* printf("dumpWatcher\n"); */ ObtainWriteLock(&dumpSyncPtr->ds_lock); - if ( dumpSyncPtr->statusFlags == 0 ) - { + if (dumpSyncPtr->statusFlags == 0) { /* dump has finished */ goto exit; } /* check time to live */ - if ( time(0) > dumpSyncPtr->timeToLive ) - { /*i*/ + if (time(0) > dumpSyncPtr->timeToLive) { /*i */ /* dump has exceeded the allocated time - terminate it */ - LogError(0, "Database dump timeout exceeded: %s", ctime(&dumpSyncPtr->timeToLive)); + LogError(0, "Database dump timeout exceeded: %s", + ctime(&dumpSyncPtr->timeToLive)); LogError(0, "Terminating database dump\n"); - + close(dumpSyncPtr->pipeFid[0]); close(dumpSyncPtr->pipeFid[1]); code = LWP_DestroyProcess(dumpSyncPtr->dumperPid); - if (code) LogError(code, "dumpWatcher: failed to kill dump thread\n"); + if (code) + LogError(code, "dumpWatcher: failed to kill dump thread\n"); - if ( dumpSyncPtr->ut ) - { + if (dumpSyncPtr->ut) { code = ubik_AbortTrans(dumpSyncPtr->ut); - if (code) LogError(code, "Aborting dump transaction\n"); + if (code) + LogError(code, "Aborting dump transaction\n"); } memset(dumpSyncPtr, 0, sizeof(*dumpSyncPtr)); goto exit; - } /*i*/ - - ReleaseWriteLock(&dumpSyncPtr->ds_lock); + } + /*i */ + ReleaseWriteLock(&dumpSyncPtr->ds_lock); IOMGR_Sleep(5); - } /*w*/ + } /*w */ -exit: + exit: ReleaseWriteLock(&dumpSyncPtr->ds_lock); /* printf("dumpWatcher exit\n"); */ - return(0); + return (0); } diff --git a/src/budb/globals.h b/src/budb/globals.h index 39e7a6e13..fbca64b3e 100644 --- a/src/budb/globals.h +++ b/src/budb/globals.h @@ -12,7 +12,7 @@ * ------------------ */ -#define DEFAULT_DBPREFIX "bdb" /* db name prefix */ +#define DEFAULT_DBPREFIX "bdb" /* db name prefix */ /* debug and test flags */ @@ -21,64 +21,56 @@ #define DF_SMALLHT 0x4 /* use small hash tables */ #define DF_TRUNCATEDB 0x8 /* truncate database on startup */ -extern int debugging; /* for controlling debug output */ +extern int debugging; /* for controlling debug output */ -struct buServerConfS -{ +struct buServerConfS { /* global configuration */ - char *databaseDirectory; /* where database is placed */ - char *databaseName; /* database file name */ - char *databaseExtension; /* extension (depends on ubik) */ + char *databaseDirectory; /* where database is placed */ + char *databaseName; /* database file name */ + char *databaseExtension; /* extension (depends on ubik) */ /* error logging */ - FILE *log; /* log file for status/errors */ - + FILE *log; /* log file for status/errors */ + /* ubik and comm. related */ afs_int32 myHost; afs_int32 serverList[MAXSERVERS]; /* list of ubik servers */ - char *cellConfigdir; /* afs cell config. directory */ - struct ubik_dbase *database; /* handle for the database */ + char *cellConfigdir; /* afs cell config. directory */ + struct ubik_dbase *database; /* handle for the database */ /* debug and test */ - afs_uint32 debugFlags; + afs_uint32 debugFlags; }; -typedef struct buServerConfS buServerConfT; -typedef buServerConfT *buServerConfP; +typedef struct buServerConfS buServerConfT; +typedef buServerConfT *buServerConfP; -extern buServerConfP globalConfPtr; +extern buServerConfP globalConfPtr; /* for synchronizing the threads dumping the database */ -#define DS_WAITING 1 /* reader/writer sleeping */ -#define DS_DONE 2 /* finished */ -#define DS_DONE_ERROR 4 /* finished with errors */ +#define DS_WAITING 1 /* reader/writer sleeping */ +#define DS_DONE 2 /* finished */ +#define DS_DONE_ERROR 4 /* finished with errors */ -#define DUMP_TTL_INC 300 /* secs. before dump times out */ +#define DUMP_TTL_INC 300 /* secs. before dump times out */ #include -struct dumpSyncS -{ - struct Lock ds_lock; /* for this struct. */ - afs_int32 statusFlags; /* 0, or 1 for dump in progress */ - int pipeFid[2]; /* pipe between threads */ - char ds_writerStatus; - char ds_readerStatus; - - PROCESS dumperPid; /* pid of dumper lwp */ - struct ubik_trans *ut; /* dump db transaction */ - afs_int32 ds_bytes; /* no. of bytes buffered */ - time_t timeToLive; /* time. After this, kill the dump */ +struct dumpSyncS { + struct Lock ds_lock; /* for this struct. */ + afs_int32 statusFlags; /* 0, or 1 for dump in progress */ + int pipeFid[2]; /* pipe between threads */ + char ds_writerStatus; + char ds_readerStatus; + + PROCESS dumperPid; /* pid of dumper lwp */ + struct ubik_trans *ut; /* dump db transaction */ + afs_int32 ds_bytes; /* no. of bytes buffered */ + time_t timeToLive; /* time. After this, kill the dump */ }; -typedef struct dumpSyncS dumpSyncT; -typedef dumpSyncT *dumpSyncP; - -extern dumpSyncP dumpSyncPtr; /* defined in dbs_dump.c */ - - - - - +typedef struct dumpSyncS dumpSyncT; +typedef dumpSyncT *dumpSyncP; +extern dumpSyncP dumpSyncPtr; /* defined in dbs_dump.c */ diff --git a/src/budb/ol_verify.c b/src/budb/ol_verify.c index f773abf8e..dac5d5964 100644 --- a/src/budb/ol_verify.c +++ b/src/budb/ol_verify.c @@ -12,7 +12,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #ifdef AFS_NT40_ENV @@ -84,117 +85,104 @@ RCSID("$Header$"); * array describes the status of a data structure/entry in that block */ -struct blockMap -{ - struct blockHeader header; /* copy of the block header */ - char free; /* on free list */ - int nEntries; /* size of the entries arrays */ - afs_uint32 entries[1]; /* describes each entry */ +struct blockMap { + struct blockHeader header; /* copy of the block header */ + char free; /* on free list */ + int nEntries; /* size of the entries arrays */ + afs_uint32 entries[1]; /* describes each entry */ }; /* status for verify call */ -struct dbStatus -{ +struct dbStatus { char hostname[64]; /* host on which checked */ afs_int32 status; /* ok, not ok */ }; int nBlocks; /* total number of blocks in db */ -struct misc_hash_stats { /* stats for hashing */ - int max; /* longest chain length */ - double avg; /* avg length */ - double std_dev; /* standard deviation of length */ +struct misc_hash_stats { /* stats for hashing */ + int max; /* longest chain length */ + double avg; /* avg length */ + double std_dev; /* standard deviation of length */ }; struct misc_data { - int errors; /* errors encountered */ - int maxErrors; /* abort after this many errors */ - int nBlocks; /* number of database blocks */ - int nDump, nTape, nVolInfo, nVolFrag; /* counts of each type */ - int nVolName; /* volInfos w/ head==0 */ - int maxVolsPerVolInfo; /* maximum list lengths */ - int maxVolsPerTape; - int maxVolsPerDump; - int maxVolInfosPerName; - int maxTapesPerDump; - int maxAppendsPerDump; - int freeLength[NBLOCKTYPES]; /* length of free lists */ - int fullyFree[NBLOCKTYPES]; /* free blocks full of free entries */ - int veryLongChain; /* length of chain to report */ - int checkFragCount; /* report fragment count errors */ + int errors; /* errors encountered */ + int maxErrors; /* abort after this many errors */ + int nBlocks; /* number of database blocks */ + int nDump, nTape, nVolInfo, nVolFrag; /* counts of each type */ + int nVolName; /* volInfos w/ head==0 */ + int maxVolsPerVolInfo; /* maximum list lengths */ + int maxVolsPerTape; + int maxVolsPerDump; + int maxVolInfosPerName; + int maxTapesPerDump; + int maxAppendsPerDump; + int freeLength[NBLOCKTYPES]; /* length of free lists */ + int fullyFree[NBLOCKTYPES]; /* free blocks full of free entries */ + int veryLongChain; /* length of chain to report */ + int checkFragCount; /* report fragment count errors */ struct misc_hash_stats dumpName, dumpIden, tapeName, volName; - FILE *recreate; /* stream for recreate instructions */ + FILE *recreate; /* stream for recreate instructions */ } miscData; struct misc_data *misc; -struct blockMap **blockMap = 0; /* initial block map */ +struct blockMap **blockMap = 0; /* initial block map */ /* describes number of entries for each type of block */ -int blockEntries[NBLOCKTYPES] = -{ - 0 /* free_BLOCK */, +int blockEntries[NBLOCKTYPES] = { + 0 /* free_BLOCK */ , NvolFragmentS, NvolInfoS, NtapeS, NdumpS, - 1, /* hashTable_BLOCK */ - 1 /* text block */ + 1, /* hashTable_BLOCK */ + 1 /* text block */ }; -int blockEntrySize[NBLOCKTYPES] = -{ - 0 /* free */, - sizeof(((struct vfBlock *)NULL)->a[0]), - sizeof(((struct viBlock *)NULL)->a[0]), - sizeof(((struct tBlock *)NULL)->a[0]), - sizeof(((struct dBlock *)NULL)->a[0]), - 0}; - -char *typeName[NBLOCKTYPES] = -{ +int blockEntrySize[NBLOCKTYPES] = { + 0 /* free */ , + sizeof(((struct vfBlock *) NULL)->a[0]), + sizeof(((struct viBlock *) NULL)->a[0]), + sizeof(((struct tBlock *) NULL)->a[0]), + sizeof(((struct dBlock *) NULL)->a[0]), + 0 +}; + +char *typeName[NBLOCKTYPES] = { "free", "volFragment", "volInfo", - "tape", + "tape", "dump", "hashTable" }; -int hashBlockType[HT_MAX_FUNCTION+1] = - { +int hashBlockType[HT_MAX_FUNCTION + 1] = { 0, dump_BLOCK, - dump_BLOCK, - tape_BLOCK, + dump_BLOCK, + tape_BLOCK, volInfo_BLOCK }; /* Compatibility table for the bits in the blockMap. */ -struct mapCompatability -{ - short trigger; /* these bits trigger this element */ -} mapC[] = -{ - MAP_FREE, - MAP_HTBLOCK, - MAP_DUMPHASH | MAP_IDHASH, - MAP_TAPEHASH | MAP_TAPEONDUMP, - MAP_VOLINFOONNAME, - MAP_VOLINFONAMEHEAD | MAP_VOLHASH, - MAP_VOLFRAGONTAPE | MAP_VOLFRAGONVOL, - MAP_TEXTBLOCK -}; +struct mapCompatability { + short trigger; /* these bits trigger this element */ +} mapC[] = { +MAP_FREE, MAP_HTBLOCK, MAP_DUMPHASH | MAP_IDHASH, + MAP_TAPEHASH | MAP_TAPEONDUMP, MAP_VOLINFOONNAME, + MAP_VOLINFONAMEHEAD | MAP_VOLHASH, + MAP_VOLFRAGONTAPE | MAP_VOLFRAGONVOL, MAP_TEXTBLOCK}; /* no. of entries in the mapC array */ -int NMAPCs = (sizeof(mapC)/sizeof(mapC[0])); +int NMAPCs = (sizeof(mapC) / sizeof(mapC[0])); /* for identifying stored textual information */ -char *textName[TB_NUM] = -{ +char *textName[TB_NUM] = { "Dump Schedule\n", "Volume Sets\n", "Tape Hosts\n" @@ -220,10 +208,10 @@ extern int nHTBuckets; afs_int32 BumpErrors() { - if ( ++miscData.errors >= miscData.maxErrors ) - return(1); + if (++miscData.errors >= miscData.maxErrors) + return (1); else - return(0); + return (0); } /* convertDiskAddress @@ -244,30 +232,33 @@ checkDiskAddress(address, type, blockIndexPtr, entryIndexPtr) int *entryIndexPtr; { int index, offset; - - if (blockIndexPtr) *blockIndexPtr = -1; - if (entryIndexPtr) *entryIndexPtr = -1; - + + if (blockIndexPtr) + *blockIndexPtr = -1; + if (entryIndexPtr) + *entryIndexPtr = -1; + /* This is safest way to handle totally bogus addresses (eg 0x80001234). */ - if ( (address < sizeof(db.h)) || (address >= ntohl(db.h.eofPtr)) ) + if ((address < sizeof(db.h)) || (address >= ntohl(db.h.eofPtr))) return BUDB_ADDR; address -= sizeof(db.h); index = address / BLOCKSIZE; offset = address - (index * BLOCKSIZE); - if (offset % sizeof(afs_int32)) /* alignment check */ + if (offset % sizeof(afs_int32)) /* alignment check */ return BUDB_ADDR; - if (offset && (type > 0) && (type <= MAX_STRUCTURE_BLOCK_TYPE)) - { - offset -= sizeof(struct blockHeader); - if ((offset < 0) || (offset % blockEntrySize[type])) + if (offset && (type > 0) && (type <= MAX_STRUCTURE_BLOCK_TYPE)) { + offset -= sizeof(struct blockHeader); + if ((offset < 0) || (offset % blockEntrySize[type])) return BUDB_ADDR; - offset /= blockEntrySize[type]; - if (offset >= blockEntries[type]) + offset /= blockEntrySize[type]; + if (offset >= blockEntries[type]) return BUDB_ADDR; } - if (blockIndexPtr) *blockIndexPtr = index; - if (entryIndexPtr) *entryIndexPtr = offset; + if (blockIndexPtr) + *blockIndexPtr = index; + if (entryIndexPtr) + *entryIndexPtr = offset; return 0; } @@ -280,7 +271,7 @@ checkDiskAddress(address, type, blockIndexPtr, entryIndexPtr) * 0 - ok * BUDB_ADDR - address alignment checks failed */ - + afs_int32 ConvertDiskAddress(address, blockIndexPtr, entryIndexPtr) afs_uint32 address; @@ -289,7 +280,7 @@ ConvertDiskAddress(address, blockIndexPtr, entryIndexPtr) { int index, type; afs_int32 code; - + index = (address - sizeof(db.h)) / BLOCKSIZE; type = blockMap[index]->header.type; @@ -303,25 +294,24 @@ TypeName(index) { static char error[16]; - if ( (index < 0) || (index >= NBLOCKTYPES)) - { - sprintf(error, "UNKNOWN_TYPE", index); - return(error); + if ((index < 0) || (index >= NBLOCKTYPES)) { + sprintf(error, "UNKNOWN_TYPE", index); + return (error); } - return(typeName[index]); + return (typeName[index]); } getDumpID(ut, tapePtr, dumpID) - struct tape *tapePtr; - afs_int32 *dumpID; + struct tape *tapePtr; + afs_int32 *dumpID; { - struct dump d; - afs_int32 code; - - *dumpID = 0; - code = dbread(ut, ntohl(tapePtr->dump), &d, sizeof(d)); - if (!code) - *dumpID = ntohl(d.id); + struct dump d; + afs_int32 code; + + *dumpID = 0; + code = dbread(ut, ntohl(tapePtr->dump), &d, sizeof(d)); + if (!code) + *dumpID = ntohl(d.id); } /* ------------------------------------ @@ -334,63 +324,62 @@ getDumpID(ut, tapePtr, dumpID) * to the dump. */ afs_int32 -verifyDumpEntry( ut, dumpAddr, ai, ao, dumpPtr) +verifyDumpEntry(ut, dumpAddr, ai, ao, dumpPtr) struct ubik_trans *ut; afs_int32 dumpAddr; int ai, ao; struct dump *dumpPtr; { struct tape tape; - afs_int32 tapeAddr, tapeCount=0, volCount=0, appDumpCount=0; + afs_int32 tapeAddr, tapeCount = 0, volCount = 0, appDumpCount = 0; afs_int32 appDumpAddr, appDumpIndex, appDumpOffset; struct dump appDump; - int tapeIndex, tapeOffset, ccheck=1; + int tapeIndex, tapeOffset, ccheck = 1; afs_int32 code = 0, tcode; int dumpIndex, dumpOffset; tcode = ConvertDiskAddress(dumpAddr, &dumpIndex, &dumpOffset); - if (tcode) - { - Log("verifyDumpEntry: Invalid dump entry addr 0x%x\n", dumpAddr); - if (BumpErrors()) ERROR(DBBAD); + if (tcode) { + Log("verifyDumpEntry: Invalid dump entry addr 0x%x\n", dumpAddr); + if (BumpErrors()) + ERROR(DBBAD); ERROR(0); } /* Step though list of tapes hanging off of this dump */ - for (tapeAddr=ntohl(dumpPtr->firstTape); tapeAddr; tapeAddr=ntohl(tape.nextTape)) - { + for (tapeAddr = ntohl(dumpPtr->firstTape); tapeAddr; + tapeAddr = ntohl(tape.nextTape)) { tcode = ConvertDiskAddress(tapeAddr, &tapeIndex, &tapeOffset); - if (tcode) - { - Log("verifyDumpEntry: Invalid tape entry addr 0x%x (on DumpID %u)\n", - tapeAddr, ntohl(dumpPtr->id)); + if (tcode) { + Log("verifyDumpEntry: Invalid tape entry addr 0x%x (on DumpID %u)\n", tapeAddr, ntohl(dumpPtr->id)); Log(" Skipping remainder of tapes in dump\n"); - if (BumpErrors()) ERROR(DBBAD); + if (BumpErrors()) + ERROR(DBBAD); ccheck = 0; break; } tcode = dbread(ut, tapeAddr, &tape, sizeof(tape)); - if (tcode) ERROR(BUDB_IO); + if (tcode) + ERROR(BUDB_IO); - if ( ntohl(tape.dump) != dumpAddr ) - { + if (ntohl(tape.dump) != dumpAddr) { afs_int32 did; - + getDumpID(ut, &tape, &did); Log("verifyDumpEntry: Tape '%s' (addr 0x%x) doesn't point to\n", tape.name, tapeAddr); - Log(" dumpID %u (addr 0x%x). Points to DumpID %u (addr 0x%x)\n", - ntohl(dumpPtr->id), dumpAddr, did, ntohl(tape.dump)); - if (BumpErrors()) return(DBBAD); + Log(" dumpID %u (addr 0x%x). Points to DumpID %u (addr 0x%x)\n", ntohl(dumpPtr->id), dumpAddr, did, ntohl(tape.dump)); + if (BumpErrors()) + return (DBBAD); } /* Check if this tape entry has been examine already */ - if ( blockMap[tapeIndex]->entries[tapeOffset] & MAP_TAPEONDUMP ) - { + if (blockMap[tapeIndex]->entries[tapeOffset] & MAP_TAPEONDUMP) { Log("verifyDumpEntry: Tape '%s' (addr 0x%x) on multiple dumps\n", tape.name, tapeAddr); - if (BumpErrors()) return(DBBAD); + if (BumpErrors()) + return (DBBAD); } blockMap[tapeIndex]->entries[tapeOffset] |= MAP_TAPEONDUMP; @@ -398,62 +387,69 @@ verifyDumpEntry( ut, dumpAddr, ai, ao, dumpPtr) volCount += ntohl(tape.nVolumes); } - if (ccheck && (ntohl(dumpPtr->nVolumes) != volCount)) - { - Log("verifyDumpEntry: DumpID %u (addr 0x%x) volume count of %d is wrong (should be %d)\n", - ntohl(dumpPtr->id), dumpAddr, ntohl(dumpPtr->nVolumes), volCount); - if (BumpErrors()) return(DBBAD); + if (ccheck && (ntohl(dumpPtr->nVolumes) != volCount)) { + Log("verifyDumpEntry: DumpID %u (addr 0x%x) volume count of %d is wrong (should be %d)\n", ntohl(dumpPtr->id), dumpAddr, ntohl(dumpPtr->nVolumes), volCount); + if (BumpErrors()) + return (DBBAD); } - - if (volCount > misc->maxVolsPerDump) misc->maxVolsPerDump = volCount; - if (tapeCount > misc->maxTapesPerDump) misc->maxTapesPerDump = tapeCount; + + if (volCount > misc->maxVolsPerDump) + misc->maxVolsPerDump = volCount; + if (tapeCount > misc->maxTapesPerDump) + misc->maxTapesPerDump = tapeCount; /* If this is an initial dump, then step though list of appended dumps * hanging off of this dump. */ if (ntohl(dumpPtr->initialDumpID) == 0) { - for (appDumpAddr=ntohl(dumpPtr->appendedDumpChain); appDumpAddr; - appDumpAddr=ntohl(appDump.appendedDumpChain)) { - - tcode = ConvertDiskAddress(appDumpAddr, &appDumpIndex, &appDumpOffset); - if (tcode) { - Log("verifyDumpEntry: Invalid appended dump entry addr 0x%x\n", appDumpAddr); - Log("Skipping remainder of appended dumps\n"); - if (BumpErrors()) ERROR(DBBAD); - break; - } - - /* Read the appended dump in */ - tcode = dbread(ut, appDumpAddr, &appDump, sizeof(appDump)); - if (tcode) ERROR(BUDB_IO); - - /* Verify that it points to the parent dump */ - if (ntohl(appDump.initialDumpID) != ntohl(dumpPtr->id)) { - Log("verifyDumpEntry: DumpID %u (addr 0x%x) initial DumpID incorrect (is %u, should be %u)\n", - ntohl(appDump.id), appDumpAddr, - ntohl(appDump.initialDumpID), ntohl(dumpPtr->id)); - if (BumpErrors()) return(DBBAD); - } - - /* Check if this appended dump entry has been examined already */ - if ( blockMap[appDumpIndex]->entries[appDumpOffset] & MAP_APPENDEDDUMP ) { - Log("verifyDumpEntry: DumpID %u (addr %u) is on multiple appended dump chains\n", - ntohl(appDump.id), appDumpAddr); - Log("Skipping remainder of appended dumps\n"); - if (BumpErrors()) return(DBBAD); - break; - } - blockMap[appDumpIndex]->entries[appDumpOffset] |= MAP_APPENDEDDUMP; - - appDumpCount++; - } + for (appDumpAddr = ntohl(dumpPtr->appendedDumpChain); appDumpAddr; + appDumpAddr = ntohl(appDump.appendedDumpChain)) { + + tcode = + ConvertDiskAddress(appDumpAddr, &appDumpIndex, + &appDumpOffset); + if (tcode) { + Log("verifyDumpEntry: Invalid appended dump entry addr 0x%x\n", appDumpAddr); + Log("Skipping remainder of appended dumps\n"); + if (BumpErrors()) + ERROR(DBBAD); + break; + } + + /* Read the appended dump in */ + tcode = dbread(ut, appDumpAddr, &appDump, sizeof(appDump)); + if (tcode) + ERROR(BUDB_IO); + + /* Verify that it points to the parent dump */ + if (ntohl(appDump.initialDumpID) != ntohl(dumpPtr->id)) { + Log("verifyDumpEntry: DumpID %u (addr 0x%x) initial DumpID incorrect (is %u, should be %u)\n", ntohl(appDump.id), appDumpAddr, ntohl(appDump.initialDumpID), ntohl(dumpPtr->id)); + if (BumpErrors()) + return (DBBAD); + } + + /* Check if this appended dump entry has been examined already */ + if (blockMap[appDumpIndex]-> + entries[appDumpOffset] & MAP_APPENDEDDUMP) { + Log("verifyDumpEntry: DumpID %u (addr %u) is on multiple appended dump chains\n", ntohl(appDump.id), appDumpAddr); + Log("Skipping remainder of appended dumps\n"); + if (BumpErrors()) + return (DBBAD); + break; + } + blockMap[appDumpIndex]->entries[appDumpOffset] |= + MAP_APPENDEDDUMP; + + appDumpCount++; + } } - if (appDumpCount > misc->maxAppendsPerDump) misc->maxAppendsPerDump = appDumpCount; + if (appDumpCount > misc->maxAppendsPerDump) + misc->maxAppendsPerDump = appDumpCount; misc->nDump++; -error_exit: - return(code); + error_exit: + return (code); } /* @@ -462,57 +458,55 @@ error_exit: * they belong to the tape. */ afs_int32 -verifyTapeEntry (ut, tapeAddr, ai, ao, tapePtr) - struct ubik_trans *ut; - afs_int32 tapeAddr; - int ai, ao; - struct tape *tapePtr; +verifyTapeEntry(ut, tapeAddr, ai, ao, tapePtr) + struct ubik_trans *ut; + afs_int32 tapeAddr; + int ai, ao; + struct tape *tapePtr; { - int volCount = 0, ccheck=1; + int volCount = 0, ccheck = 1; afs_int32 volFragAddr; int blockIndex, entryIndex; struct volFragment volFragment; afs_int32 code = 0, tcode; - for (volFragAddr=ntohl(tapePtr->firstVol); - volFragAddr; - volFragAddr=ntohl(volFragment.sameTapeChain)) - { + for (volFragAddr = ntohl(tapePtr->firstVol); volFragAddr; + volFragAddr = ntohl(volFragment.sameTapeChain)) { tcode = ConvertDiskAddress(volFragAddr, &blockIndex, &entryIndex); - if (tcode) - { + if (tcode) { afs_int32 did; - + getDumpID(ut, tapePtr, &did); - Log("verifyTapeEntry: Invalid volFrag addr 0x%x (on tape '%s' DumpID %u)\n", - volFragAddr, tapePtr->name, did); + Log("verifyTapeEntry: Invalid volFrag addr 0x%x (on tape '%s' DumpID %u)\n", volFragAddr, tapePtr->name, did); Log(" Skipping remainder of volumes on tape\n"); - if (BumpErrors()) ERROR(DBBAD); + if (BumpErrors()) + ERROR(DBBAD); ccheck = 0; break; } - tcode = dbread (ut, volFragAddr, &volFragment, sizeof(volFragment)); - if (tcode) ERROR(tcode); + tcode = dbread(ut, volFragAddr, &volFragment, sizeof(volFragment)); + if (tcode) + ERROR(tcode); - if ( ntohl(volFragment.tape) != tapeAddr ) - { + if (ntohl(volFragment.tape) != tapeAddr) { afs_int32 did; - + getDumpID(ut, tapePtr, &did); Log("verifyTapeEntry: VolFrag (addr 0x%x) doesn't point to \n", volFragAddr); - Log (" tape '%s' DumpID %u (addr 0x%x). Points to addr 0x%x\n", - tapePtr->name, did, tapeAddr, ntohl(volFragment.tape)); - if (BumpErrors()) ERROR(DBBAD); + Log(" tape '%s' DumpID %u (addr 0x%x). Points to addr 0x%x\n", + tapePtr->name, did, tapeAddr, ntohl(volFragment.tape)); + if (BumpErrors()) + ERROR(DBBAD); } /* Has this volume fragment already been examined */ - if ( blockMap[blockIndex]->entries[entryIndex] & MAP_VOLFRAGONTAPE ) - { + if (blockMap[blockIndex]->entries[entryIndex] & MAP_VOLFRAGONTAPE) { Log("verifyTapeEntry: VolFrag (addr %d) on multiple tapes\n", volFragAddr); - if (BumpErrors()) ERROR(DBBAD); + if (BumpErrors()) + ERROR(DBBAD); } blockMap[blockIndex]->entries[entryIndex] |= MAP_VOLFRAGONTAPE; @@ -520,21 +514,21 @@ verifyTapeEntry (ut, tapeAddr, ai, ao, tapePtr) } /* now check computed vs. recorded volume counts */ - if (ccheck && (ntohl(tapePtr->nVolumes) != volCount)) - { - afs_int32 did; - + if (ccheck && (ntohl(tapePtr->nVolumes) != volCount)) { + afs_int32 did; + getDumpID(ut, tapePtr, &did); - Log("verifyTapeEntry: Tape '%s' DumpID %u (addr 0x%x) volFrag count of %d is wrong (should be %d)\n", - tapePtr->name, did, tapeAddr, ntohl(tapePtr->nVolumes), volCount); - if (BumpErrors()) ERROR(DBBAD); + Log("verifyTapeEntry: Tape '%s' DumpID %u (addr 0x%x) volFrag count of %d is wrong (should be %d)\n", tapePtr->name, did, tapeAddr, ntohl(tapePtr->nVolumes), volCount); + if (BumpErrors()) + ERROR(DBBAD); } - if (volCount > misc->maxVolsPerTape) misc->maxVolsPerTape = volCount; + if (volCount > misc->maxVolsPerTape) + misc->maxVolsPerTape = volCount; misc->nTape++; -error_exit: - return(code); + error_exit: + return (code); } /* @@ -543,7 +537,7 @@ error_exit: * So no check is done agaist it. */ afs_int32 -verifyVolFragEntry (ut, va, ai, ao, v) +verifyVolFragEntry(ut, va, ai, ao, v) struct ubik_trans *ut; afs_int32 va; int ai, ao; @@ -560,13 +554,13 @@ verifyVolFragEntry (ut, va, ai, ao, v) * also verify all entries are also on the chain. */ afs_int32 -verifyVolInfoEntry (ut, volInfoAddr, ai, ao, volInfo) +verifyVolInfoEntry(ut, volInfoAddr, ai, ao, volInfo) struct ubik_trans *ut; afs_int32 volInfoAddr; int ai, ao; struct volInfo *volInfo; { - int volCount = 0, ccheck=1; + int volCount = 0, ccheck = 1; int nFrags; afs_int32 volFragAddr; int blockIndex, entryIndex, bindex, eindex; @@ -574,38 +568,36 @@ verifyVolInfoEntry (ut, volInfoAddr, ai, ao, volInfo) afs_int32 code = 0, tcode; /* check each fragment attached to this volinfo structure */ - for (volFragAddr=ntohl(volInfo->firstFragment); volFragAddr; - volFragAddr=ntohl(volFragment.sameNameChain)) - { - tcode = ConvertDiskAddress (volFragAddr, &blockIndex, &entryIndex); - if (tcode) - { - Log("verifyVolInfoEntry: Invalid volFrag entry addr 0x%x (on volume '%s')\n", - volFragAddr, volInfo->name); + for (volFragAddr = ntohl(volInfo->firstFragment); volFragAddr; + volFragAddr = ntohl(volFragment.sameNameChain)) { + tcode = ConvertDiskAddress(volFragAddr, &blockIndex, &entryIndex); + if (tcode) { + Log("verifyVolInfoEntry: Invalid volFrag entry addr 0x%x (on volume '%s')\n", volFragAddr, volInfo->name); Log(" Skipping remainder of volumes on tape\n"); - if (BumpErrors()) ERROR(DBBAD); + if (BumpErrors()) + ERROR(DBBAD); ccheck = 0; break; } tcode = dbread(ut, volFragAddr, &volFragment, sizeof(volFragment)); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); - if ( ntohl(volFragment.vol) != volInfoAddr ) - { + if (ntohl(volFragment.vol) != volInfoAddr) { Log("verifyVolInfoEntry: volFrag (addr 0x%x) doesn't point to \n", volFragAddr); Log(" volInfo '%s' (addr 0x%x). Points to addr 0x%x\n", volInfo->name, volInfoAddr, ntohl(volFragment.vol)); - if (BumpErrors()) ERROR(DBBAD); + if (BumpErrors()) + ERROR(DBBAD); } /* volume fragment already on a volinfo chain? */ - if ( blockMap[blockIndex]->entries[entryIndex] & MAP_VOLFRAGONVOL ) - { - Log("verifyVolInfoEntry: VolFrag (addr %d) on multiple volInfo chains\n", - volFragAddr); - if (BumpErrors()) ERROR(DBBAD); + if (blockMap[blockIndex]->entries[entryIndex] & MAP_VOLFRAGONVOL) { + Log("verifyVolInfoEntry: VolFrag (addr %d) on multiple volInfo chains\n", volFragAddr); + if (BumpErrors()) + ERROR(DBBAD); } blockMap[blockIndex]->entries[entryIndex] |= MAP_VOLFRAGONVOL; @@ -613,77 +605,74 @@ verifyVolInfoEntry (ut, volInfoAddr, ai, ao, volInfo) } /* check computed vs. recorded number of fragments */ - if (ccheck && misc->checkFragCount && (ntohl(volInfo->nFrags) != volCount)) - { - Log("verifyVolInfoEntry: VolInfo '%s' (addr 0x%x) volFrag count of %d is wrong (should be %d)\n", - volInfo->name, volInfoAddr, ntohl(volInfo->nFrags), volCount); - if (BumpErrors()) ERROR(DBBAD); + if (ccheck && misc->checkFragCount + && (ntohl(volInfo->nFrags) != volCount)) { + Log("verifyVolInfoEntry: VolInfo '%s' (addr 0x%x) volFrag count of %d is wrong (should be %d)\n", volInfo->name, volInfoAddr, ntohl(volInfo->nFrags), volCount); + if (BumpErrors()) + ERROR(DBBAD); } - if (volCount > misc->maxVolsPerVolInfo) misc->maxVolsPerVolInfo = volCount; + if (volCount > misc->maxVolsPerVolInfo) + misc->maxVolsPerVolInfo = volCount; /* Check that all volInfo structures with same name point to the same * head. If sameNameHead == 0, this is the head structure so we check, * otherwise ignore */ - if (volInfo->sameNameHead == 0) - { /*i*/ - int viCount = 1; /* count this one */ + if (volInfo->sameNameHead == 0) { /*i */ + int viCount = 1; /* count this one */ struct volInfo tvi; afs_int32 tviAddr; - for (tviAddr=ntohl(volInfo->sameNameChain); tviAddr; tviAddr = ntohl(tvi.sameNameChain)) - { + for (tviAddr = ntohl(volInfo->sameNameChain); tviAddr; + tviAddr = ntohl(tvi.sameNameChain)) { viCount++; - tcode = ConvertDiskAddress (tviAddr, &blockIndex, &entryIndex); - if (tcode) - { - Log("verifyVolInfoEntry: Invalid volInfo entry %s addr 0x%x\n", - volInfo->name, tviAddr); + tcode = ConvertDiskAddress(tviAddr, &blockIndex, &entryIndex); + if (tcode) { + Log("verifyVolInfoEntry: Invalid volInfo entry %s addr 0x%x\n", volInfo->name, tviAddr); Log(" Skipping remainder of volumes on same name chain\n"); - if (BumpErrors()) ERROR(DBBAD); + if (BumpErrors()) + ERROR(DBBAD); code = 0; break; } tcode = dbread(ut, tviAddr, &tvi, sizeof(tvi)); - if (tcode) ERROR(tcode); - - if ( ntohl(tvi.sameNameHead) != volInfoAddr) - { - Log("verifyVolInfoEntry: VolInfo '%s' (addr 0x%x) doesn't point to \n", - volInfo->name, tviAddr); - Log(" head of sameName volInfo (addr 0x%x). Points to addr 0x%x\n", - volInfoAddr, ntohl(tvi.sameNameHead)); - if (BumpErrors()) ERROR(DBBAD); + if (tcode) + ERROR(tcode); + + if (ntohl(tvi.sameNameHead) != volInfoAddr) { + Log("verifyVolInfoEntry: VolInfo '%s' (addr 0x%x) doesn't point to \n", volInfo->name, tviAddr); + Log(" head of sameName volInfo (addr 0x%x). Points to addr 0x%x\n", volInfoAddr, ntohl(tvi.sameNameHead)); + if (BumpErrors()) + ERROR(DBBAD); } - if (blockMap[blockIndex]->entries[entryIndex] & MAP_VOLINFOONNAME) - { - Log("verifyVolInfoEntry: VolInfo (addr 0x%x) on multiple same name chains\n", - tviAddr); - if (BumpErrors()) ERROR(DBBAD); + if (blockMap[blockIndex]->entries[entryIndex] & MAP_VOLINFOONNAME) { + Log("verifyVolInfoEntry: VolInfo (addr 0x%x) on multiple same name chains\n", tviAddr); + if (BumpErrors()) + ERROR(DBBAD); } blockMap[blockIndex]->entries[entryIndex] |= MAP_VOLINFOONNAME; } /* select the passed in structure flags */ - if ( blockMap[ai]->entries[ao] & MAP_VOLINFONAMEHEAD) - { - Log("verifyVolInfoEntry: VolInfo '%s' (addr 0x%x) is name head multiple times\n", - volInfo->name, volInfoAddr); - if (BumpErrors()) ERROR(DBBAD); + if (blockMap[ai]->entries[ao] & MAP_VOLINFONAMEHEAD) { + Log("verifyVolInfoEntry: VolInfo '%s' (addr 0x%x) is name head multiple times\n", volInfo->name, volInfoAddr); + if (BumpErrors()) + ERROR(DBBAD); } blockMap[ai]->entries[ao] |= MAP_VOLINFONAMEHEAD; - if (viCount > misc->maxVolInfosPerName) misc->maxVolInfosPerName = viCount; + if (viCount > misc->maxVolInfosPerName) + misc->maxVolInfosPerName = viCount; misc->nVolName++; - } /*i*/ - + } + /*i */ misc->nVolInfo++; -error_exit: - return(code); + error_exit: + return (code); } @@ -709,27 +698,30 @@ verifyBlocks(ut) afs_int32 code = 0, tcode; /* Remember every header of every block in the database */ - for (i=0; i= NBLOCKTYPES) ) - { - Log("Block (index %d addr %d) has invalid type of %d\n", i, blockAddr, blocktype); + blocktype = block.h.type; /* char */ + if ((blocktype < 0) || (blocktype >= NBLOCKTYPES)) { + Log("Block (index %d addr %d) has invalid type of %d\n", i, + blockAddr, blocktype); ERROR(BUDB_BLOCKTYPE); } /* allocate the block map memory */ - bmsize = sizeof(*ablockMap) + (blockEntries[blocktype]-1) * sizeof(ablockMap->entries[0]); - ablockMap = (struct blockMap *) malloc(bmsize); - if (!ablockMap) ERROR(BUDB_NOMEM); + bmsize = + sizeof(*ablockMap) + (blockEntries[blocktype] - + 1) * sizeof(ablockMap->entries[0]); + ablockMap = (struct blockMap *)malloc(bmsize); + if (!ablockMap) + ERROR(BUDB_NOMEM); memset(ablockMap, 0, bmsize); ablockMap->nEntries = blockEntries[blocktype]; @@ -739,8 +731,8 @@ verifyBlocks(ut) blockMap[i] = ablockMap; } -error_exit: - return(code); + error_exit: + return (code); } int minvols, maxvols, ttlvols; @@ -756,17 +748,17 @@ verifyHashTableBlock(ut, mhtPtr, htBlockPtr, old, length, index, mapBit) struct memoryHashTable *mhtPtr; struct htBlock *htBlockPtr; int old; - afs_int32 length; /* size of whole hash table */ - int index; /* base index of this block */ + afs_int32 length; /* size of whole hash table */ + int index; /* base index of this block */ int mapBit; { - int type; /* hash table type */ - int entrySize; /* hashed entry size */ - int blockType; /* block type for this hash table */ + int type; /* hash table type */ + int entrySize; /* hashed entry size */ + int blockType; /* block type for this hash table */ int blockIndex, entryIndex; char entry[sizeof(struct block)]; dbadr entryAddr; - int hash; /* calculated hash value for entry */ + int hash; /* calculated hash value for entry */ int i, count; afs_int32 code = 0, tcode; @@ -778,73 +770,73 @@ verifyHashTableBlock(ut, mhtPtr, htBlockPtr, old, length, index, mapBit) * before the end of the overall hash table */ - for ( i = 0; (i < nHTBuckets) && (index < length); i++, index++ ) - { /*f*/ + for (i = 0; (i < nHTBuckets) && (index < length); i++, index++) { /*f */ entryAddr = ntohl(htBlockPtr->bucket[i]); /* if this is the old hash table, all entries below the progress mark * should have been moved to the new hash table */ - if (old && (index < mhtPtr->progress) && entryAddr) - { + if (old && (index < mhtPtr->progress) && entryAddr) { Log("Old hash table not empty (entry %d) below progress (%d)\n", - i, mhtPtr->progress); - if (BumpErrors()) ERROR(DBBAD); - } + i, mhtPtr->progress); + if (BumpErrors()) + ERROR(DBBAD); + } /* now walk down the chain of each bucket */ - for (count=0; entryAddr; count++) - { /*w*/ + for (count = 0; entryAddr; count++) { /*w */ tcode = ConvertDiskAddress(entryAddr, &blockIndex, &entryIndex); - if (tcode) - { + if (tcode) { Log("verifyHashTableBlock: Invalid hash table chain addr 0x%x\n", entryAddr); Log(" Skipping remainder of bucket %d\n", index); - if (BumpErrors()) ERROR(DBBAD); + if (BumpErrors()) + ERROR(DBBAD); code = 0; break; } - if (blockMap[blockIndex]->header.type != blockType) - { - Log("Hash table chain (block index %d) incorrect\n", blockIndex); - Log(" Table type %d traverses block type %d\n", - blockType, blockMap[blockIndex]->header.type); + if (blockMap[blockIndex]->header.type != blockType) { + Log("Hash table chain (block index %d) incorrect\n", + blockIndex); + Log(" Table type %d traverses block type %d\n", blockType, + blockMap[blockIndex]->header.type); Log(" Skipping remainder of bucket %d\n", index); - if (BumpErrors()) ERROR(DBBAD); + if (BumpErrors()) + ERROR(DBBAD); break; } - if ( dbread(ut, entryAddr, &entry[0], entrySize) ) + if (dbread(ut, entryAddr, &entry[0], entrySize)) ERROR(DBBAD); hash = ht_HashEntry(mhtPtr, &entry[0]) % length; - if (hash != index) /* if it hashed to some other place */ - { - Log("Entry (addr 0x%x) bucket %d, should be hashed into bucket %d\n", - entryAddr, index, hash); - if (BumpErrors()) ERROR(DBBAD); + if (hash != index) { /* if it hashed to some other place */ + Log("Entry (addr 0x%x) bucket %d, should be hashed into bucket %d\n", entryAddr, index, hash); + if (BumpErrors()) + ERROR(DBBAD); } /* check if entry has been examined */ - if (blockMap[blockIndex]->entries[entryIndex] & mapBit) - { + if (blockMap[blockIndex]->entries[entryIndex] & mapBit) { Log("Entry (addr 0x%x) multiply referenced\n", entryAddr); - if (BumpErrors()) ERROR(DBBAD); + if (BumpErrors()) + ERROR(DBBAD); } blockMap[blockIndex]->entries[entryIndex] |= mapBit; - entryAddr = ntohl( *((dbadr *)(entry + mhtPtr->threadOffset))); - } /*w*/ - + entryAddr = ntohl(*((dbadr *) (entry + mhtPtr->threadOffset))); + } /*w */ + /* Log("Bucket %4d contains %d entries\n", index+1, count); */ ttlvols += count; - if (count < minvols) minvols = count; - if (count > maxvols) maxvols = count; - } /*f*/ + if (count < minvols) + minvols = count; + if (count > maxvols) + maxvols = count; + } /*f */ -error_exit: - return(code); + error_exit: + return (code); } /* verifyHashTable @@ -862,88 +854,91 @@ verifyHashTable(ut, mhtPtr, mapBit) struct hashTable *htPtr = mhtPtr->ht; struct htBlock hashTableBlock; - int tableLength; /* # entries */ - int hashblocks; /* # blocks */ - dbadr tableAddr; /* disk addr of hash block */ + int tableLength; /* # entries */ + int hashblocks; /* # blocks */ + dbadr tableAddr; /* disk addr of hash block */ int blockIndex, entryIndex; int old; int i; afs_int32 code = 0, tcode; - extern int nHTBuckets; /* # buckets in a hash table */ + extern int nHTBuckets; /* # buckets in a hash table */ LogDebug(4, "Htable: length %d oldlength %d progress %d\n", - mhtPtr->length, mhtPtr->oldLength, mhtPtr->progress); + mhtPtr->length, mhtPtr->oldLength, mhtPtr->progress); /* check both old and current tables */ - for ( old = 0; old <= 1; old++ ) - { /*fo*/ - tableLength = (old ? mhtPtr->oldLength : mhtPtr->length); - if (tableLength == 0) continue; - tableAddr = (old ? ntohl(htPtr->oldTable) : ntohl(htPtr->table)); - minvols = 999999; + for (old = 0; old <= 1; old++) { /*fo */ + tableLength = (old ? mhtPtr->oldLength : mhtPtr->length); + if (tableLength == 0) + continue; + tableAddr = (old ? ntohl(htPtr->oldTable) : ntohl(htPtr->table)); + minvols = 999999; maxvols = ttlvols = 0; /* follow the chain of hashtable blocks - avoid infinite loops */ - hashblocks = ((tableLength-1)/nHTBuckets)+1; /* numb of 2K hashtable blocks */ - for (i=0; (tableAddr && (iheader.type != hashTable_BLOCK ) - { - Log("Hashtable block (index %d addr 0x%x) hashtype %d - type %d, expected type %d\n", - i+1, tableAddr, ntohl(htPtr->functionType), - blockMap[blockIndex]->header.type, hashTable_BLOCK); + if (blockMap[blockIndex]->header.type != hashTable_BLOCK) { + Log("Hashtable block (index %d addr 0x%x) hashtype %d - type %d, expected type %d\n", i + 1, tableAddr, ntohl(htPtr->functionType), blockMap[blockIndex]->header.type, hashTable_BLOCK); Log(" Skipping remainder of hash table chain\n"); - if (BumpErrors()) ERROR(BUDB_BLOCKTYPE); + if (BumpErrors()) + ERROR(BUDB_BLOCKTYPE); break; } /* check if we've examined this block before */ /* mark this (hash table) block as examined */ - if (blockMap[blockIndex]->entries[entryIndex] & MAP_HTBLOCK) - { - Log("Hash table block (index %d addr 0x%x) multiple ref\n", i+1, tableAddr); - if (BumpErrors()) ERROR(BUDB_DATABASEINCONSISTENT); - } - blockMap[blockIndex]->entries[entryIndex] |= MAP_HTBLOCK; + if (blockMap[blockIndex]->entries[entryIndex] & MAP_HTBLOCK) { + Log("Hash table block (index %d addr 0x%x) multiple ref\n", + i + 1, tableAddr); + if (BumpErrors()) + ERROR(BUDB_DATABASEINCONSISTENT); + } + blockMap[blockIndex]->entries[entryIndex] |= MAP_HTBLOCK; /* Read the actual hash table block */ - tcode = dbread(ut, tableAddr, &hashTableBlock, sizeof(hashTableBlock)); - if (tcode) ERROR(tcode); + tcode = + dbread(ut, tableAddr, &hashTableBlock, + sizeof(hashTableBlock)); + if (tcode) + ERROR(tcode); /* Verify its entries */ - tcode = verifyHashTableBlock(ut, mhtPtr, &hashTableBlock, old, - tableLength, (i*nHTBuckets), mapBit); - if (tcode) ERROR(tcode); + tcode = + verifyHashTableBlock(ut, mhtPtr, &hashTableBlock, old, + tableLength, (i * nHTBuckets), mapBit); + if (tcode) + ERROR(tcode); tableAddr = ntohl(hashTableBlock.h.next); } /* Verify numb hash blocks is as it says */ - if (i != hashblocks) - { - Log("Incorrect number of hash chain blocks: %d (expected %d), hashtype %d\n", - i, hashblocks, ntohl(htPtr->functionType)); - if (BumpErrors()) ERROR(BUDB_DATABASEINCONSISTENT); + if (i != hashblocks) { + Log("Incorrect number of hash chain blocks: %d (expected %d), hashtype %d\n", i, hashblocks, ntohl(htPtr->functionType)); + if (BumpErrors()) + ERROR(BUDB_DATABASEINCONSISTENT); } - if (ttlvols) - Log("%d entries; %u buckets; min = %d; max = %d\n", - ttlvols, tableLength, minvols, maxvols); - } /*fo*/ + if (ttlvols) + Log("%d entries; %u buckets; min = %d; max = %d\n", ttlvols, + tableLength, minvols, maxvols); + } /*fo */ -error_exit: - return(code); + error_exit: + return (code); } /* verifyEntryChains @@ -963,62 +958,57 @@ verifyEntryChains(ut) int type; int nFree; - static afs_int32 (*checkEntry[NBLOCKTYPES])() - = { 0, /* free block */ - verifyVolFragEntry, - verifyVolInfoEntry, - verifyTapeEntry, - verifyDumpEntry, - 0 /* text block */ - }; - - for (blockIndex=0; blockIndexheader.type; - if ((type <= 0) || (type > MAX_STRUCTURE_BLOCK_TYPE)) + type = blockMap[blockIndex]->header.type; + if ((type <= 0) || (type > MAX_STRUCTURE_BLOCK_TYPE)) continue; - entrySize = blockEntrySize[type]; - nFree = 0; + entrySize = blockEntrySize[type]; + nFree = 0; - for (entryIndex=0; entryIndexnEntries; entryIndex++) - { /*f*/ - offset = sizeof(db.h) + (blockIndex * BLOCKSIZE) + - sizeof(struct blockHeader) + (entryIndex * entrySize); - if ( dbread(ut, offset, &entry[0], entrySize) ) + for (entryIndex = 0; entryIndex < blockMap[blockIndex]->nEntries; entryIndex++) { /*f */ + offset = + sizeof(db.h) + (blockIndex * BLOCKSIZE) + + sizeof(struct blockHeader) + (entryIndex * entrySize); + if (dbread(ut, offset, &entry[0], entrySize)) return BUDB_IO; /* check if entry is free by looking at the first "afs_int32" of the structure */ - if ( *((afs_int32 *)&entry[0]) == 0 ) /* zero is free */ - { - /* Is it on any hash chain? */ - if ( blockMap[blockIndex]->entries[entryIndex] & MAP_HASHES ) - { - Log("Entry: blockindex %d, entryindex %d - marked free but hashed 0x%x\n", - blockIndex, entryIndex, blockMap[blockIndex]->entries[entryIndex]); - if (BumpErrors()) return DBBAD; + if (*((afs_int32 *) & entry[0]) == 0) { /* zero is free */ + /* Is it on any hash chain? */ + if (blockMap[blockIndex]->entries[entryIndex] & MAP_HASHES) { + Log("Entry: blockindex %d, entryindex %d - marked free but hashed 0x%x\n", blockIndex, entryIndex, blockMap[blockIndex]->entries[entryIndex]); + if (BumpErrors()) + return DBBAD; } blockMap[blockIndex]->entries[entryIndex] |= MAP_FREE; nFree++; - } - else - { + } else { /* check the entry itself for consistency */ - code = (*(checkEntry[type]))(ut, offset, blockIndex, entryIndex, &entry[0]); - if (code) return code; + code = + (*(checkEntry[type])) (ut, offset, blockIndex, entryIndex, + &entry[0]); + if (code) + return code; } - } /*f*/ + } /*f */ /* check computed free with recorded free entries */ - if ( nFree != ntohs(blockMap[blockIndex]->header.nFree) ) - { + if (nFree != ntohs(blockMap[blockIndex]->header.nFree)) { Log("Block (index %d) free count %d has %d free structs\n", blockIndex, ntohs(blockMap[blockIndex]->header.nFree), nFree); - if (BumpErrors()) return DBBAD; - } - } /*f*/ + if (BumpErrors()) + return DBBAD; + } + } /*f */ return 0; } @@ -1034,55 +1024,49 @@ verifyFreeLists() afs_int32 code; /* for each free list */ - for (i=0; ifullyFree[i] = misc->freeLength[i] = 0; - for (addr=ntohl(db.h.freePtrs[i]); addr; addr=ntohl(blockMap[blockIndex]->header.next)) - { + for (addr = ntohl(db.h.freePtrs[i]); addr; + addr = ntohl(blockMap[blockIndex]->header.next)) { misc->freeLength[i]++; - code = ConvertDiskAddress (addr, &blockIndex, &entryIndex); - if (code || (entryIndex != 0)) - { - Log("verifyFreeLists: Invalid free chain addr 0x%x in %s free chain\n", - addr, TypeName(i)); + code = ConvertDiskAddress(addr, &blockIndex, &entryIndex); + if (code || (entryIndex != 0)) { + Log("verifyFreeLists: Invalid free chain addr 0x%x in %s free chain\n", addr, TypeName(i)); Log(" Skipping remainder of free chain\n"); - if (BumpErrors()) return(DBBAD); + if (BumpErrors()) + return (DBBAD); code = 0; break; } /* check block type */ - if (blockMap[blockIndex]->header.type != i) - { + if (blockMap[blockIndex]->header.type != i) { Log("verifyFreeLists: Found %s type in %s free chain\n", - TypeName(blockMap[blockIndex]->header.type), TypeName(i), addr); - if (BumpErrors()) return(DBBAD); + TypeName(blockMap[blockIndex]->header.type), TypeName(i), + addr); + if (BumpErrors()) + return (DBBAD); } /* If entire block isn't free, check if count of free entries is ok */ nFree = ntohs(blockMap[blockIndex]->header.nFree); - if (i != free_BLOCK) - { - if ((nFree <= 0) || (nFree > blockEntries[i])) - { - Log ("verifyFreeLists: Illegal free count %d on %s free chain\n", - nFree, TypeName(i)); - if (BumpErrors()) return(DBBAD); - } - else if (nFree == blockEntries[i]) - { + if (i != free_BLOCK) { + if ((nFree <= 0) || (nFree > blockEntries[i])) { + Log("verifyFreeLists: Illegal free count %d on %s free chain\n", nFree, TypeName(i)); + if (BumpErrors()) + return (DBBAD); + } else if (nFree == blockEntries[i]) { misc->fullyFree[i]++; } } /* Check if already examined the block */ - if (blockMap[blockIndex]->free) - { - Log("verifyFreeLists: %s free chain block at addr 0x%x multiply threaded\n", - TypeName(i), addr); - if (BumpErrors()) return DBBAD; + if (blockMap[blockIndex]->free) { + Log("verifyFreeLists: %s free chain block at addr 0x%x multiply threaded\n", TypeName(i), addr); + if (BumpErrors()) + return DBBAD; } blockMap[blockIndex]->free++; } @@ -1101,84 +1085,94 @@ verifyMapBits() int blockIndex, entryIndex, i, entrySize, type, bits; afs_int32 offset; - for (blockIndex=0; blockIndexnEntries == 0) && !blockMap[blockIndex]->free) - { + if ((blockMap[blockIndex]->nEntries == 0) + && !blockMap[blockIndex]->free) { Log("verifyMapBits: Orphan free block (index %d)\n", blockIndex); - if (BumpErrors()) return DBBAD; + if (BumpErrors()) + return DBBAD; } /* check each entry */ - for (entryIndex=0; entryIndexnEntries; entryIndex++) - { /*f*/ - if ((entryIndex%1024) == 0) IOMGR_Poll(); + for (entryIndex = 0; entryIndex < blockMap[blockIndex]->nEntries; entryIndex++) { /*f */ + if ((entryIndex % 1024) == 0) + IOMGR_Poll(); bits = blockMap[blockIndex]->entries[entryIndex]; - for (i=0; i= NMAPCs) - { - char logstr[256]; + if (i >= NMAPCs) { + char logstr[256]; - type = blockMap[blockIndex]->header.type; - entrySize = blockEntrySize[type]; - offset = sizeof(db.h) + (blockIndex * BLOCKSIZE) + - sizeof(struct blockHeader) + (entryIndex * entrySize); + type = blockMap[blockIndex]->header.type; + entrySize = blockEntrySize[type]; + offset = + sizeof(db.h) + (blockIndex * BLOCKSIZE) + + sizeof(struct blockHeader) + (entryIndex * entrySize); sprintf(logstr, "%s entry Block %d, Entry %d, (addr 0x%x)", TypeName(type), blockIndex, entryIndex, offset); - if (!bits) strcat(logstr, ": An orphaned entry"); - if (bits & MAP_FREE) strcat(logstr, ": A valid free block"); - if (bits & MAP_HTBLOCK) strcat(logstr, ": A valid hash-table block"); - if (bits & MAP_TEXTBLOCK) strcat(logstr, ": A valid text block"); - if (bits & (MAP_DUMPHASH | MAP_IDHASH)) - { - if (!(bits & MAP_DUMPHASH)) - strcat(logstr, ": A dump not on dump-name hash-chain"); + if (!bits) + strcat(logstr, ": An orphaned entry"); + if (bits & MAP_FREE) + strcat(logstr, ": A valid free block"); + if (bits & MAP_HTBLOCK) + strcat(logstr, ": A valid hash-table block"); + if (bits & MAP_TEXTBLOCK) + strcat(logstr, ": A valid text block"); + if (bits & (MAP_DUMPHASH | MAP_IDHASH)) { + if (!(bits & MAP_DUMPHASH)) + strcat(logstr, + ": A dump not on dump-name hash-chain"); else if (!(bits & MAP_IDHASH)) - strcat(logstr, ": A dump not on dump-id hash-chain"); + strcat(logstr, ": A dump not on dump-id hash-chain"); else - strcat(logstr, ": A valid dump entry"); + strcat(logstr, ": A valid dump entry"); } - if (bits & (MAP_TAPEHASH | MAP_TAPEONDUMP)) - { + if (bits & (MAP_TAPEHASH | MAP_TAPEONDUMP)) { if (!(bits & MAP_TAPEHASH)) - strcat(logstr, ": A tape not on tape-name hash-chain"); + strcat(logstr, + ": A tape not on tape-name hash-chain"); else if (!(bits & MAP_TAPEONDUMP)) - strcat(logstr, ": A tape not associated with a dump"); + strcat(logstr, ": A tape not associated with a dump"); else - strcat(logstr, ": A valid tape entry"); + strcat(logstr, ": A valid tape entry"); } - if (bits & MAP_VOLINFOONNAME) - strcat(logstr, ": A valid volInfo on a volume-name chain"); - if (bits & (MAP_VOLINFONAMEHEAD | MAP_VOLHASH)) - { + if (bits & MAP_VOLINFOONNAME) + strcat(logstr, + ": A valid volInfo on a volume-name chain"); + if (bits & (MAP_VOLINFONAMEHEAD | MAP_VOLHASH)) { if (!(bits & MAP_VOLINFONAMEHEAD)) - strcat(logstr, ": A volInfo not the head of a volume-name hash-chain"); + strcat(logstr, + ": A volInfo not the head of a volume-name hash-chain"); else if (!(bits & MAP_VOLHASH)) - strcat(logstr, ": A volInfo not on volume-name hash-chain"); + strcat(logstr, + ": A volInfo not on volume-name hash-chain"); else - strcat(logstr, ": A valid volInfo in volume-name hash-chain"); + strcat(logstr, + ": A valid volInfo in volume-name hash-chain"); } - if (bits & (MAP_VOLFRAGONTAPE | MAP_VOLFRAGONVOL)) - { + if (bits & (MAP_VOLFRAGONTAPE | MAP_VOLFRAGONVOL)) { if (!(bits & MAP_VOLFRAGONTAPE)) - strcat(logstr, ": A volFrag not associated with a tape"); + strcat(logstr, + ": A volFrag not associated with a tape"); else if (!(bits & MAP_VOLFRAGONVOL)) - strcat(logstr, ": A volFrag not associated with a volume"); - else - strcat(logstr, ": A valid volFrag entry"); + strcat(logstr, + ": A volFrag not associated with a volume"); + else + strcat(logstr, ": A valid volFrag entry"); } Log("%s\n", logstr); - if (BumpErrors()) return DBBAD; + if (BumpErrors()) + return DBBAD; } - } /*f*/ + } /*f */ } return 0; @@ -1193,13 +1187,13 @@ verifyText(ut) extern afs_int32 verifyTextChain(); /* check each of the text types in use */ - for (i=0; itextAddr); - for (blockAddr = (new ? ntohl(tbPtr->newTextAddr) : ntohl(tbPtr->textAddr)); - blockAddr; blockAddr = ntohl(block.h.next)) - { + for (blockAddr = + (new ? ntohl(tbPtr->newTextAddr) : ntohl(tbPtr->textAddr)); + blockAddr; blockAddr = ntohl(block.h.next)) { tcode = ConvertDiskAddress(blockAddr, &blockIndex, &entryIndex); - if (tcode) - { - Log("verifyTextChain: Invalid %s text block addr 0x%x\n", - (new?"new":""), blockAddr); + if (tcode) { + Log("verifyTextChain: Invalid %s text block addr 0x%x\n", + (new ? "new" : ""), blockAddr); Log(" Skipping remainder of text chain\n"); - if (BumpErrors()) ERROR(tcode); + if (BumpErrors()) + ERROR(tcode); break; } tcode = dbread(ut, blockAddr, &block, sizeof(block)); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); - if ( blockMap[blockIndex]->entries[entryIndex] & MAP_TEXTBLOCK ) - { - Log("verifyTextChain: Text block (addr 0x%x) multiply chained\n", blockAddr); - if (BumpErrors()) ERROR(DBBAD); + if (blockMap[blockIndex]->entries[entryIndex] & MAP_TEXTBLOCK) { + Log("verifyTextChain: Text block (addr 0x%x) multiply chained\n", blockAddr); + if (BumpErrors()) + ERROR(DBBAD); } blockMap[blockIndex]->entries[entryIndex] |= MAP_TEXTBLOCK; size += BLOCK_DATA_SIZE; } - if ( ntohl(new?tbPtr->newsize:tbPtr->size) > size ) - { - Log("verifyTextChain: Text block %s size %d > computed capacity %d\n", - (new?"new":""), ntohl(new?tbPtr->newsize:tbPtr->size), size); - if (BumpErrors()) ERROR(DBBAD); + if (ntohl(new ? tbPtr->newsize : tbPtr->size) > size) { + Log("verifyTextChain: Text block %s size %d > computed capacity %d\n", (new ? "new" : ""), ntohl(new ? tbPtr->newsize : tbPtr->size), size); + if (BumpErrors()) + ERROR(DBBAD); } } -error_exit: - return(code); + error_exit: + return (code); } /* ----------------------------------------- @@ -1272,13 +1265,13 @@ error_exit: afs_int32 verifyDatabase(ut, recreateFile) struct ubik_trans *ut; - FILE *recreateFile; /* not used */ + FILE *recreateFile; /* not used */ { afs_int32 eof; - int j, bmsize; + int j, bmsize; afs_int32 code = 0, tcode; - extern int nBlocks; /* no. blocks in database */ + extern int nBlocks; /* no. blocks in database */ extern struct ubik_dbase *BU_dbase; /* clear verification statistics */ @@ -1288,21 +1281,20 @@ verifyDatabase(ut, recreateFile) #ifdef PDEBUG miscData.maxErrors = 1000000; #else - miscData.maxErrors = 50; /* Catch the first 50 errors */ + miscData.maxErrors = 50; /* Catch the first 50 errors */ #endif miscData.veryLongChain = 0; - miscData.checkFragCount = 1; /* check frags */ + miscData.checkFragCount = 1; /* check frags */ /* check eofPtr */ eof = ntohl(db.h.eofPtr); - eof -= sizeof(db.h); /* subtract header */ + eof -= sizeof(db.h); /* subtract header */ nBlocks = eof / BLOCKSIZE; Log("Verify of backup database started\n"); Log("Database is %u. %d blocks of %d Bytes\n", eof, nBlocks, BLOCKSIZE); - if ((eof < 0) || (nBlocks*BLOCKSIZE != eof)) - { + if ((eof < 0) || (nBlocks * BLOCKSIZE != eof)) { Log("Database eofPtr (%d) bad, blocksize %d\n", eof, BLOCKSIZE); ERROR(DBBAD); } @@ -1310,66 +1302,75 @@ verifyDatabase(ut, recreateFile) /* set size of database */ miscData.nBlocks = nBlocks; - if (nBlocks == 0) ERROR(0); /* Nothing to check? */ + if (nBlocks == 0) + ERROR(0); /* Nothing to check? */ /* construct block map - first level is the array of pointers */ - bmsize = nBlocks*sizeof(struct blockMap *); - blockMap = (struct blockMap **) malloc(bmsize); - if (!blockMap) ERROR(BUDB_NOMEM); + bmsize = nBlocks * sizeof(struct blockMap *); + blockMap = (struct blockMap **)malloc(bmsize); + if (!blockMap) + ERROR(BUDB_NOMEM); memset(blockMap, 0, bmsize); - /* verify blocks and construct the block map */ + /* verify blocks and construct the block map */ Log("Read header of every block\n"); tcode = verifyBlocks(ut); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); /* check the various hash tables */ Log("Verify volume name hash table\n"); tcode = verifyHashTable(ut, &db.volName, MAP_VOLHASH); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); Log("Verify tape name hash table\n"); tcode = verifyHashTable(ut, &db.tapeName, MAP_TAPEHASH); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); Log("Verify dump name hash table\n"); tcode = verifyHashTable(ut, &db.dumpName, MAP_DUMPHASH); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); Log("Verify dump id hash table\n"); tcode = verifyHashTable(ut, &db.dumpIden, MAP_IDHASH); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); /* check the entry chains */ Log("Verify all blocks and entries\n"); tcode = verifyEntryChains(ut); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); /* check text blocks - Log message in verifyText */ tcode = verifyText(ut); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); /* check free list */ Log("Verify Free Lists\n"); tcode = verifyFreeLists(); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); /* check entry map bit compatibility */ Log("Verify Map bits\n"); tcode = verifyMapBits(); - if (tcode) ERROR(tcode); + if (tcode) + ERROR(tcode); -error_exit: + error_exit: /* free the block map */ - if ( blockMap != 0 ) - { + if (blockMap != 0) { int i; /* free all the individual maps */ - for ( i = 0; i < nBlocks; i++ ) - { - if ( blockMap[i] ) + for (i = 0; i < nBlocks; i++) { + if (blockMap[i]) free(blockMap[i]); } @@ -1379,33 +1380,38 @@ error_exit: } if (!tcode) { - Log("# 2K database blocks = %d\n", miscData.nBlocks); - Log("# Dump entries found = %d. 3 dumps per block\n", miscData.nDump); - Log(" max tapes on a dump = %d\n", miscData.maxTapesPerDump); - Log(" max volumes on a dump = %d\n", miscData.maxVolsPerDump); - Log(" max appends on a dump = %d\n", miscData.maxAppendsPerDump); - Log(" # Blocks with space = %d\n", miscData.freeLength[4]); - Log(" # of those fully free = %d\n", miscData.fullyFree[4]); - Log("# Tape entries found = %d. 20 tapes per block\n", miscData.nTape); - Log(" max volumes on a tape = %d\n", miscData.maxVolsPerTape); - Log(" # Blocks with space = %d\n", miscData.freeLength[3]); - Log(" # of those fully free = %d\n", miscData.fullyFree[3]); - Log("# VolInfo entries found = %d. 20 volInfos per block\n", miscData.nVolInfo); - Log(" # head of sameNameCh = %d\n", miscData.nVolName); - Log(" max on a sameNameCh = %d\n", miscData.maxVolInfosPerName); - Log(" max VolFrags on chain = %d\n", miscData.maxVolsPerVolInfo); - Log(" # Blocks with space = %d\n", miscData.freeLength[2]); - Log(" # of those fully free = %d\n", miscData.fullyFree[2]); - Log("# VolFrag entries found = %d. 45 VolFrags per block\n", miscData.nVolFrag); - Log(" # Blocks with space = %d\n", miscData.freeLength[1]); - Log(" # of those fully free = %d\n", miscData.fullyFree[1]); - Log("# free blocks = %d\n", miscData.freeLength[0]); + Log("# 2K database blocks = %d\n", miscData.nBlocks); + Log("# Dump entries found = %d. 3 dumps per block\n", + miscData.nDump); + Log(" max tapes on a dump = %d\n", miscData.maxTapesPerDump); + Log(" max volumes on a dump = %d\n", miscData.maxVolsPerDump); + Log(" max appends on a dump = %d\n", miscData.maxAppendsPerDump); + Log(" # Blocks with space = %d\n", miscData.freeLength[4]); + Log(" # of those fully free = %d\n", miscData.fullyFree[4]); + Log("# Tape entries found = %d. 20 tapes per block\n", + miscData.nTape); + Log(" max volumes on a tape = %d\n", miscData.maxVolsPerTape); + Log(" # Blocks with space = %d\n", miscData.freeLength[3]); + Log(" # of those fully free = %d\n", miscData.fullyFree[3]); + Log("# VolInfo entries found = %d. 20 volInfos per block\n", + miscData.nVolInfo); + Log(" # head of sameNameCh = %d\n", miscData.nVolName); + Log(" max on a sameNameCh = %d\n", miscData.maxVolInfosPerName); + Log(" max VolFrags on chain = %d\n", miscData.maxVolsPerVolInfo); + Log(" # Blocks with space = %d\n", miscData.freeLength[2]); + Log(" # of those fully free = %d\n", miscData.fullyFree[2]); + Log("# VolFrag entries found = %d. 45 VolFrags per block\n", + miscData.nVolFrag); + Log(" # Blocks with space = %d\n", miscData.freeLength[1]); + Log(" # of those fully free = %d\n", miscData.fullyFree[1]); + Log("# free blocks = %d\n", miscData.freeLength[0]); } Log("Verify of database completed. %d errors found\n", miscData.errors); - if (miscData.errors && !code) code = DBBAD; - return(code); + if (miscData.errors && !code) + code = DBBAD; + return (code); } @@ -1422,20 +1428,22 @@ error_exit: * host - address of host that did verification */ afs_int32 DbVerify(); -afs_int32 SBUDB_DbVerify(call, status, orphans, host) +afs_int32 +SBUDB_DbVerify(call, status, orphans, host) struct rx_call *call; afs_int32 *status; afs_int32 *orphans; afs_int32 *host; { - afs_int32 code; + afs_int32 code; - code = DbVerify(call, status, orphans, host); - osi_auditU(call, BUDB_DBVfyEvent, code, AUD_END); - return code; + code = DbVerify(call, status, orphans, host); + osi_auditU(call, BUDB_DBVfyEvent, code, AUD_END); + return code; } -afs_int32 DbVerify(call, status, orphans, host) +afs_int32 +DbVerify(call, status, orphans, host) struct rx_call *call; afs_int32 *status; afs_int32 *orphans; @@ -1446,34 +1454,38 @@ afs_int32 DbVerify(call, status, orphans, host) char hostname[64]; struct hostent *th; - if ( callPermitted(call) == 0 ) + if (callPermitted(call) == 0) ERROR(BUDB_NOTPERMITTED); - tcode = InitRPC (&ut, LOCKREAD, 1); - if (tcode) ERROR(tcode); + tcode = InitRPC(&ut, LOCKREAD, 1); + if (tcode) + ERROR(tcode); - tcode = verifyDatabase(ut, 0); /* check the database */ - if (tcode) ERROR(tcode); + tcode = verifyDatabase(ut, 0); /* check the database */ + if (tcode) + ERROR(tcode); -error_exit: + error_exit: if (ut) { - if (code) ubik_AbortTrans(ut); - else code = ubik_EndTrans(ut); + if (code) + ubik_AbortTrans(ut); + else + code = ubik_EndTrans(ut); } - *status = code; + *status = code; *orphans = 0; gethostname(hostname, sizeof(hostname)); th = gethostbyname(hostname); - if (!th) *host = 0; - else - { + if (!th) + *host = 0; + else { memcpy(host, th->h_addr, sizeof(afs_int32)); *host = ntohl(*host); } - return(0); + return (0); } /* ---------------------- @@ -1492,22 +1504,18 @@ check_header(callerst) afs_int32 eof; eof = ntohl(db.h.eofPtr); - if ( (eof == 0) || (eof < 0) ) - { - Log("Eof check failed, caller %s, eof 0x%x\n", - callerst, eof); + if ((eof == 0) || (eof < 0)) { + Log("Eof check failed, caller %s, eof 0x%x\n", callerst, eof); } eof -= sizeof(db.h); - if ( eof < 0 ) - { - Log("Adjusted Eof check failed, caller %s, eof 0x%x\n", - callerst, eof); + if (eof < 0) { + Log("Adjusted Eof check failed, caller %s, eof 0x%x\n", callerst, + eof); } iteration_count++; - if ( iteration_count >= 10 ) - { + if (iteration_count >= 10) { Log("Eof ptr is 0x%x\n", eof); iteration_count = 0; } diff --git a/src/budb/procs.c b/src/budb/procs.c index 4691ee12f..c538dc56b 100644 --- a/src/budb/procs.c +++ b/src/budb/procs.c @@ -16,7 +16,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -65,34 +66,35 @@ RCSID("$Header$"); extern struct ubik_dbase *BU_dbase; extern struct afsconf_dir *BU_conf; /* for getting cell info */ extern afs_int32 myHost; -extern struct memoryDB db; /* incore copies of db structures */ +extern struct memoryDB db; /* incore copies of db structures */ -afs_int32 AddVolume(), AddVolumes(), CreateDump(), DoDeleteDump(), DoDeleteTape(), ListDumps(); +afs_int32 AddVolume(), AddVolumes(), CreateDump(), DoDeleteDump(), +DoDeleteTape(), ListDumps(); afs_int32 DeleteVDP(), FindClone(), FindDump(), FindLatestDump(); -afs_int32 FinishDump(), FinishTape(), GetDumps(), getExpiration(), T_DumpDatabase(); +afs_int32 FinishDump(), FinishTape(), GetDumps(), getExpiration(), +T_DumpDatabase(); afs_int32 makeAppended(), MakeDumpAppended(), FindLastTape(), GetTapes(); afs_int32 GetVolumes(), UseTape(), T_DumpHashTable(), T_GetVersion(); /* Text block management */ -struct memTextBlock -{ +struct memTextBlock { struct memTextBlock *mtb_next; /* next in chain */ - afs_int32 mtb_nbytes; /* # of bytes in this block */ - struct blockHeader mtb_blkHeader; /* in memory header */ - dbadr mtb_addr; /* disk address of block */ + afs_int32 mtb_nbytes; /* # of bytes in this block */ + struct blockHeader mtb_blkHeader; /* in memory header */ + dbadr mtb_addr; /* disk address of block */ }; -typedef struct memTextBlock memTextBlockT; -typedef memTextBlockT *memTextBlockP; +typedef struct memTextBlock memTextBlockT; +typedef memTextBlockT *memTextBlockP; /* These variable are for returning debugging info about the state of the server. If they get trashed during multi-threaded operation it doesn't matter. */ /* This is global so COUNT_REQ in krb_udp.c can refer to it. */ -char *lastOperation; /* name of last operation */ -static Date lastTrans; /* time of last transaction */ +char *lastOperation; /* name of last operation */ +static Date lastTrans; /* time of last transaction */ /* procsInited is sort of a lock: during a transaction only one process runs while procsInited is false. */ @@ -101,24 +103,25 @@ static int procsInited = 0; /* This variable is protected by the procsInited flag. */ -static int (*rebuildDatabase)(); +static int (*rebuildDatabase) (); /* AwaitInitialization * Wait unitl budb has initialized (InitProcs). If it hasn't * within 5 seconds, then return no quorum. - */ + */ afs_int32 -AwaitInitialization() -{ - afs_int32 start = 0; +AwaitInitialization() +{ + afs_int32 start = 0; - while (!procsInited) - { - if (!start) start = time(0); - else if (time(0)-start > 5) return UNOQUORUM; - IOMGR_Sleep (1); - } - return 0; + while (!procsInited) { + if (!start) + start = time(0); + else if (time(0) - start > 5) + return UNOQUORUM; + IOMGR_Sleep(1); + } + return 0; } /* tailCompPtr @@ -132,16 +135,14 @@ tailCompPtr(pathNamePtr) { char *ptr; ptr = strrchr(pathNamePtr, '/'); - if ( ptr == 0 ) - { - /* this should never happen */ - LogError(0, "tailCompPtr: could not find / in name(%s)\n", - pathNamePtr); - return(pathNamePtr); - } - else - ptr++; /* skip the / */ - return(ptr); + if (ptr == 0) { + /* this should never happen */ + LogError(0, "tailCompPtr: could not find / in name(%s)\n", + pathNamePtr); + return (pathNamePtr); + } else + ptr++; /* skip the / */ + return (ptr); } /* callPermitted @@ -152,20 +153,22 @@ tailCompPtr(pathNamePtr) */ callPermitted(call) - struct rx_call *call; + struct rx_call *call; { int permitted = 0; struct afsconf_dir *acdir; acdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); - if (!acdir) return 0; + if (!acdir) + return 0; - if ( afsconf_SuperUser(acdir, call, NULL) ) - permitted = 1; + if (afsconf_SuperUser(acdir, call, NULL)) + permitted = 1; exit: - if (acdir) afsconf_Close(acdir); - return(permitted); + if (acdir) + afsconf_Close(acdir); + return (permitted); } /* InitRPC @@ -180,67 +183,63 @@ callPermitted(call) * single threading by use of the lock. */ -afs_int32 -InitRPC (ut, lock, this_op) - struct ubik_trans **ut; - int lock; /* indicate read/write transaction */ - int this_op; /* opcode of RCP, for COUNT_ABO */ -{ - int code; - float wait = 0.91; /* start waiting for 1 second */ +afs_int32 +InitRPC(ut, lock, this_op) + struct ubik_trans **ut; + int lock; /* indicate read/write transaction */ + int this_op; /* opcode of RCP, for COUNT_ABO */ +{ + int code; + float wait = 0.91; /* start waiting for 1 second */ -start: + start: /* wait for server initialization to finish if this is not InitProcs calling */ - if (this_op) - if (code = AwaitInitialization()) + if (this_op) + if (code = AwaitInitialization()) return code; - for (code = UNOQUORUM; code == UNOQUORUM; ) - { - code = ubik_BeginTrans(BU_dbase, - ((lock == LOCKREAD) ? UBIK_READTRANS : UBIK_WRITETRANS), - ut); - if (code == UNOQUORUM) - { /* no quorum elected */ - if (wait < 1) Log("Waiting for quorum election\n"); - if (wait < 15.0) wait *= 1.1; - IOMGR_Sleep ((int)wait); + for (code = UNOQUORUM; code == UNOQUORUM;) { + code = + ubik_BeginTrans(BU_dbase, + ((lock == + LOCKREAD) ? UBIK_READTRANS : UBIK_WRITETRANS), + ut); + if (code == UNOQUORUM) { /* no quorum elected */ + if (wait < 1) + Log("Waiting for quorum election\n"); + if (wait < 15.0) + wait *= 1.1; + IOMGR_Sleep((int)wait); } } - if (code) return code; - if (wait > 1) Log("Have established quorum\n"); + if (code) + return code; + if (wait > 1) + Log("Have established quorum\n"); /* set lock at posiion 1, for 1 byte of type lock */ - if (code = ubik_SetLock (*ut, 1, 1, lock)) - { - ubik_AbortTrans (*ut); + if (code = ubik_SetLock(*ut, 1, 1, lock)) { + ubik_AbortTrans(*ut); return code; } /* check that dbase is initialized and setup cheader */ - if (lock == LOCKREAD) - { + if (lock == LOCKREAD) { /* init but don't fix because this is read only */ - if ( code = CheckInit(*ut, 0) ) - { + if (code = CheckInit(*ut, 0)) { ubik_AbortTrans(*ut); - if ( code = InitRPC(ut, LOCKWRITE, 0) ) /* Now fix the database */ - { - LogError(code, "InitRPC: InitRPC failed\n"); + if (code = InitRPC(ut, LOCKWRITE, 0)) { /* Now fix the database */ + LogError(code, "InitRPC: InitRPC failed\n"); return code; } - if ( code = ubik_EndTrans(*ut) ) - { - LogError(code, "InitRPC: ubik_EndTrans failed\n"); + if (code = ubik_EndTrans(*ut)) { + LogError(code, "InitRPC: ubik_EndTrans failed\n"); return code; } - goto start; /* now redo the read transaction */ + goto start; /* now redo the read transaction */ } - } - else - { - if (code = CheckInit(*ut, rebuildDatabase)) - { + } else { + if (code = CheckInit(*ut, rebuildDatabase)) { ubik_AbortTrans(*ut); return code; } @@ -250,118 +249,123 @@ start: } /* This is called to initialize a newly created database */ -static int initialize_database (ut) - struct ubik_trans *ut; +static int +initialize_database(ut) + struct ubik_trans *ut; { return 0; } static int noAuthenticationRequired; /* global state */ -static int recheckNoAuth; /* global state */ +static int recheckNoAuth; /* global state */ afs_int32 InitProcs() { - struct ubik_trans *ut; + struct ubik_trans *ut; afs_int32 code = 0; procsInited = 0; - if ( (globalConfPtr->myHost == 0) || (BU_conf == 0) ) + if ((globalConfPtr->myHost == 0) || (BU_conf == 0)) ERROR(BUDB_INTERNALERROR); recheckNoAuth = 1; - if ( globalConfPtr->debugFlags & DF_NOAUTH ) + if (globalConfPtr->debugFlags & DF_NOAUTH) noAuthenticationRequired = 1; - if ( globalConfPtr->debugFlags & DF_RECHECKNOAUTH ) + if (globalConfPtr->debugFlags & DF_RECHECKNOAUTH) recheckNoAuth = 0; if (recheckNoAuth) noAuthenticationRequired = afsconf_GetNoAuthFlag(BU_conf); - if (noAuthenticationRequired) + if (noAuthenticationRequired) LogError(0, "Running server with security disabled\n"); InitDB(); rebuildDatabase = initialize_database; - if (code = InitRPC (&ut, LOCKREAD, 0)) - { + if (code = InitRPC(&ut, LOCKREAD, 0)) { LogError(code, "InitProcs: InitRPC failed\n"); return code; } code = ubik_EndTrans(ut); - if (code) - { + if (code) { LogError(code, "InitProcs: ubik_EndTrans failed\n"); return code; } - rebuildDatabase = 0; /* only do this during init */ + rebuildDatabase = 0; /* only do this during init */ procsInited = 1; error_exit: - return(code); + return (code); } struct returnList { - int nElements; /* number in list */ - int allocSize; /* number of elements allocated */ - dbadr *elements; /* array of addresses */ + int nElements; /* number in list */ + int allocSize; /* number of elements allocated */ + dbadr *elements; /* array of addresses */ }; -static void InitReturnList (list) - struct returnList *list; +static void +InitReturnList(list) + struct returnList *list; { - list->nElements = 0; - list->allocSize = 0; - list->elements = (dbadr *)0; + list->nElements = 0; + list->allocSize = 0; + list->elements = (dbadr *) 0; } -static void FreeReturnList (list) - struct returnList *list; +static void +FreeReturnList(list) + struct returnList *list; { - if (list->elements) free(list->elements); - list->elements = (dbadr *)0; - list->nElements = 0; + if (list->elements) + free(list->elements); + list->elements = (dbadr *) 0; + list->nElements = 0; } /* As entries are collected, they are added to a return list. Once all * entries have been collected, it is then placed in the return buffer * with SendReturnList(). The first *to_skipP are not recorded. */ -static afs_int32 AddToReturnList (list, a, to_skipP) - struct returnList *list; - dbadr a; - afs_int32 *to_skipP; +static afs_int32 +AddToReturnList(list, a, to_skipP) + struct returnList *list; + dbadr a; + afs_int32 *to_skipP; { - char *tmp; - afs_int32 size; + char *tmp; + afs_int32 size; - if (a == 0) return 0; + if (a == 0) + return 0; if (*to_skipP > 0) { - (*to_skipP)--; - return 0; + (*to_skipP)--; + return 0; } /* Up to 5 plus a maximum so SendReturnList() knows if we * need to come back for more. */ - if (list->nElements >= BUDB_MAX_RETURN_LIST+5) - return BUDB_LIST2BIG; + if (list->nElements >= BUDB_MAX_RETURN_LIST + 5) + return BUDB_LIST2BIG; if (list->nElements >= list->allocSize) { if (list->elements == 0) { size = 10; - tmp = (char *) malloc (sizeof(dbadr) * size); + tmp = (char *)malloc(sizeof(dbadr) * size); } else { size = list->allocSize + 10; - tmp = (char *) realloc (list->elements, sizeof(dbadr) * size); + tmp = (char *)realloc(list->elements, sizeof(dbadr) * size); } - if (!tmp) return BUDB_NOMEM; + if (!tmp) + return BUDB_NOMEM; list->elements = (dbadr *) tmp; list->allocSize = size; } @@ -371,54 +375,61 @@ static afs_int32 AddToReturnList (list, a, to_skipP) return 0; } -afs_int32 FillVolEntry(ut, va, vol) - struct ubik_trans *ut; - dbadr va; - struct budb_volumeEntry *vol; +afs_int32 +FillVolEntry(ut, va, vol) + struct ubik_trans *ut; + dbadr va; + struct budb_volumeEntry *vol; { - struct dump d; - struct tape t; - struct volInfo vi; + struct dump d; + struct tape t; + struct volInfo vi; struct volFragment vf; - if (dbread (ut, va, &vf, sizeof(vf))) return BUDB_IO; /* The volFrag */ - if (dbread (ut, ntohl(vf.vol), &vi, sizeof(vi))) return BUDB_IO; /* The volInfo */ - if (dbread (ut, ntohl(vf.tape), &t, sizeof(t))) return BUDB_IO; /* The tape */ - if (dbread (ut, ntohl(t.dump), &d, sizeof(d))) return BUDB_IO; /* The dump */ - - strcpy (vol->name, vi.name); - strcpy (vol->server, vi.server); - strcpy (vol->tape, t.name); - vol->tapeSeq = ntohl(t.seq); - vol->dump = ntohl(d.id); - vol->position = ntohl(vf.position); - vol->clone = ntohl(vf.clone); - vol->incTime = ntohl(vf.incTime); - vol->nBytes = ntohl(vf.nBytes); + if (dbread(ut, va, &vf, sizeof(vf))) + return BUDB_IO; /* The volFrag */ + if (dbread(ut, ntohl(vf.vol), &vi, sizeof(vi))) + return BUDB_IO; /* The volInfo */ + if (dbread(ut, ntohl(vf.tape), &t, sizeof(t))) + return BUDB_IO; /* The tape */ + if (dbread(ut, ntohl(t.dump), &d, sizeof(d))) + return BUDB_IO; /* The dump */ + + strcpy(vol->name, vi.name); + strcpy(vol->server, vi.server); + strcpy(vol->tape, t.name); + vol->tapeSeq = ntohl(t.seq); + vol->dump = ntohl(d.id); + vol->position = ntohl(vf.position); + vol->clone = ntohl(vf.clone); + vol->incTime = ntohl(vf.incTime); + vol->nBytes = ntohl(vf.nBytes); vol->startByte = ntohl(vf.startByte); - vol->flags = (ntohs(vf.flags) & VOLFRAGMENTFLAGS); /* low 16 bits here */ - vol->flags |= (ntohl(vi.flags) & VOLINFOFLAGS); /* high 16 bits here */ - vol->seq = ntohs(vf.sequence); - vol->id = ntohl(vi.id); + vol->flags = (ntohs(vf.flags) & VOLFRAGMENTFLAGS); /* low 16 bits here */ + vol->flags |= (ntohl(vi.flags) & VOLINFOFLAGS); /* high 16 bits here */ + vol->seq = ntohs(vf.sequence); + vol->id = ntohl(vi.id); vol->partition = ntohl(vi.partition); return 0; } -afs_int32 FillDumpEntry (ut, da, dump) - struct ubik_trans *ut; - dbadr da; - struct budb_dumpEntry *dump; +afs_int32 +FillDumpEntry(ut, da, dump) + struct ubik_trans *ut; + dbadr da; + struct budb_dumpEntry *dump; { struct dump d, ad; - if (dbread (ut, da, &d, sizeof(d))) return BUDB_IO; + if (dbread(ut, da, &d, sizeof(d))) + return BUDB_IO; dump->id = ntohl(d.id); dump->flags = ntohl(d.flags); dump->created = ntohl(d.created); - strncpy (dump->name, d.dumpName, sizeof(dump->name)); - strncpy (dump->dumpPath, d.dumpPath, sizeof(dump->dumpPath)); - strncpy (dump->volumeSetName, d.volumeSet, sizeof(dump->volumeSetName)); + strncpy(dump->name, d.dumpName, sizeof(dump->name)); + strncpy(dump->dumpPath, d.dumpPath, sizeof(dump->dumpPath)); + strncpy(dump->volumeSetName, d.volumeSet, sizeof(dump->volumeSetName)); dump->parent = ntohl(d.parent); dump->level = ntohl(d.level); @@ -427,45 +438,45 @@ afs_int32 FillDumpEntry (ut, da, dump) tapeSet_ntoh(&d.tapes, &dump->tapes); if (strlen(d.dumper.name) < sizeof(dump->dumper.name)) - strcpy (dump->dumper.name, d.dumper.name); + strcpy(dump->dumper.name, d.dumper.name); if (strlen(d.dumper.instance) < sizeof(dump->dumper.instance)) - strcpy (dump->dumper.instance, d.dumper.instance); + strcpy(dump->dumper.instance, d.dumper.instance); if (strlen(d.dumper.cell) < sizeof(dump->dumper.cell)) - strcpy (dump->dumper.cell, d.dumper.cell); + strcpy(dump->dumper.cell, d.dumper.cell); /* Get the initial dumpid and the appended dump id */ dump->initialDumpID = ntohl(d.initialDumpID); - if (d.appendedDumpChain) - { - if (dbread (ut, ntohl(d.appendedDumpChain), &ad, sizeof(ad))) return BUDB_IO; + if (d.appendedDumpChain) { + if (dbread(ut, ntohl(d.appendedDumpChain), &ad, sizeof(ad))) + return BUDB_IO; dump->appendedDumpID = ntohl(ad.id); - } - else - dump->appendedDumpID = 0; + } else + dump->appendedDumpID = 0; /* printf("dump name %s, parent %d, level %d\n", - d.dumpName, ntohl(d.parent), ntohl(d.level)); */ + * d.dumpName, ntohl(d.parent), ntohl(d.level)); */ return 0; } -afs_int32 FillTapeEntry (ut, ta, tape) - struct ubik_trans *ut; - dbadr ta; - struct budb_tapeEntry *tape; +afs_int32 +FillTapeEntry(ut, ta, tape) + struct ubik_trans *ut; + dbadr ta; + struct budb_tapeEntry *tape; { struct tape t; struct dump d; afs_int32 code; - if ( dbread (ut, ta, &t, sizeof(t)) ) + if (dbread(ut, ta, &t, sizeof(t))) return BUDB_IO; /* Get the tape's expiration date */ - if ( code = getExpiration(ut,&t) ) - return(code); + if (code = getExpiration(ut, &t)) + return (code); - strcpy (tape->name, t.name); + strcpy(tape->name, t.name); tape->flags = ntohl(t.flags); tape->written = ntohl(t.written); tape->expires = ntohl(t.expires); @@ -478,7 +489,8 @@ afs_int32 FillTapeEntry (ut, ta, tape) tape->useCount = ntohl(t.useCount); tape->useKBytes = ntohl(t.useKBytes); - if (dbread (ut, ntohl(t.dump), &d, sizeof(d))) return BUDB_IO; + if (dbread(ut, ntohl(t.dump), &d, sizeof(d))) + return BUDB_IO; tape->dump = ntohl(d.id); return 0; } @@ -492,19 +504,19 @@ afs_int32 FillTapeEntry (ut, ta, tape) * if there are more and how many to skip on the next request. */ static afs_int32 -SendReturnList (ut, list, FillProc, e_size, index, nextIndexP, dbTimeP, eList) - struct ubik_trans *ut; - struct returnList *list; /* list of elements to return */ - afs_int32 (*FillProc)(); /* proc to fill entry */ - int e_size; /* size of each element */ - afs_int32 index; /* index from previous call */ - afs_int32 *nextIndexP; /* if more elements are available */ - afs_int32 *dbTimeP; /* time of last db update */ - budb_dumpList *eList; /* rxgen list structure (e.g.) */ +SendReturnList(ut, list, FillProc, e_size, index, nextIndexP, dbTimeP, eList) + struct ubik_trans *ut; + struct returnList *list; /* list of elements to return */ +afs_int32(*FillProc) (); /* proc to fill entry */ + int e_size; /* size of each element */ + afs_int32 index; /* index from previous call */ + afs_int32 *nextIndexP; /* if more elements are available */ + afs_int32 *dbTimeP; /* time of last db update */ + budb_dumpList *eList; /* rxgen list structure (e.g.) */ { afs_int32 code; - int to_return; - int i; + int to_return; + int i; char *e; *nextIndexP = -1; @@ -515,53 +527,66 @@ SendReturnList (ut, list, FillProc, e_size, index, nextIndexP, dbTimeP, eList) */ to_return = list->nElements; if (to_return > BUDB_MAX_RETURN_LIST) - to_return = BUDB_MAX_RETURN_LIST; + to_return = BUDB_MAX_RETURN_LIST; if (eList->budb_dumpList_len && (to_return > eList->budb_dumpList_len)) - to_return = eList->budb_dumpList_len; + to_return = eList->budb_dumpList_len; /* Allocate space for the return values if needed and zero it */ if (eList->budb_dumpList_val == 0) { - eList->budb_dumpList_val = (struct budb_dumpEntry *)malloc (e_size * to_return); - if (!eList->budb_dumpList_val) return(BUDB_NOMEM); + eList->budb_dumpList_val = + (struct budb_dumpEntry *)malloc(e_size * to_return); + if (!eList->budb_dumpList_val) + return (BUDB_NOMEM); } memset(eList->budb_dumpList_val, 0, e_size * to_return); eList->budb_dumpList_len = to_return; e = (char *)(eList->budb_dumpList_val); - for (i=0; ielements[i], e); - if (code) return code; + if (code) + return code; } if (list->nElements > i) - *nextIndexP = index + i; + *nextIndexP = index + i; return 0; } /* Come here to delete a volInfo structure. */ -static afs_int32 DeleteVolInfo (ut, via, vi) - struct ubik_trans *ut; - dbadr via; - struct volInfo *vi; -{ afs_int32 code; +static afs_int32 +DeleteVolInfo(ut, via, vi) + struct ubik_trans *ut; + dbadr via; + struct volInfo *vi; +{ + afs_int32 code; dbadr hvia; struct volInfo hvi; - if (vi->firstFragment) return 0; /* still some frags, don't free yet */ - if (vi->sameNameHead == 0) { /* this is the head */ - if (vi->sameNameChain) return 0; /* empty head, some non-heads left */ + if (vi->firstFragment) + return 0; /* still some frags, don't free yet */ + if (vi->sameNameHead == 0) { /* this is the head */ + if (vi->sameNameChain) + return 0; /* empty head, some non-heads left */ - code = ht_HashOut (ut, &db.volName, via, vi); - if (code) return code; - code = FreeStructure (ut, volInfo_BLOCK, via); + code = ht_HashOut(ut, &db.volName, via, vi); + if (code) + return code; + code = FreeStructure(ut, volInfo_BLOCK, via); return code; } hvia = ntohl(vi->sameNameHead); - if (dbread (ut, hvia, &hvi, sizeof(hvi))) return BUDB_IO; - code = RemoveFromList (ut, hvia, &hvi, &hvi.sameNameChain, via, vi, &vi->sameNameChain); - if (code == -1) return BUDB_DATABASEINCONSISTENT; - if (code == 0) code = FreeStructure (ut, volInfo_BLOCK, via); + if (dbread(ut, hvia, &hvi, sizeof(hvi))) + return BUDB_IO; + code = + RemoveFromList(ut, hvia, &hvi, &hvi.sameNameChain, via, vi, + &vi->sameNameChain); + if (code == -1) + return BUDB_DATABASEINCONSISTENT; + if (code == 0) + code = FreeStructure(ut, volInfo_BLOCK, via); return code; } @@ -569,26 +594,37 @@ static afs_int32 DeleteVolInfo (ut, via, vi) already freed. This routine frees the structure and the caller must not write it out. */ -static afs_int32 DeleteVolFragment (ut, va, v) - struct ubik_trans *ut; - dbadr va; - struct volFragment *v; -{ afs_int32 code; +static afs_int32 +DeleteVolFragment(ut, va, v) + struct ubik_trans *ut; + dbadr va; + struct volFragment *v; +{ + afs_int32 code; struct volInfo vi; dbadr via; via = ntohl(v->vol); - if (dbread (ut, via, &vi, sizeof(vi))) return BUDB_IO; - code = RemoveFromList (ut, via, &vi, &vi.firstFragment, va, v, &v->sameNameChain); - if (code == -1) return BUDB_DATABASEINCONSISTENT; - if (code) return code; + if (dbread(ut, via, &vi, sizeof(vi))) + return BUDB_IO; + code = + RemoveFromList(ut, via, &vi, &vi.firstFragment, va, v, + &v->sameNameChain); + if (code == -1) + return BUDB_DATABASEINCONSISTENT; + if (code) + return code; if (vi.firstFragment == 0) - if (code = DeleteVolInfo (ut, via, &vi)) return code; - if (code = FreeStructure (ut, volFragment_BLOCK, va)) return code; + if (code = DeleteVolInfo(ut, via, &vi)) + return code; + if (code = FreeStructure(ut, volFragment_BLOCK, va)) + return code; /* decrement frag counter */ - code = set_word_addr (ut, via, &vi, &vi.nFrags, htonl(ntohl(vi.nFrags)-1)); - if (code) return code; + code = + set_word_addr(ut, via, &vi, &vi.nFrags, htonl(ntohl(vi.nFrags) - 1)); + if (code) + return code; return 0; } @@ -596,49 +632,61 @@ static afs_int32 DeleteVolFragment (ut, va, v) * The caller will remove it from the hash table if necessary. The caller is * also responsible for writing the tape out if necessary. */ -static afs_int32 DeleteTape (ut, ta, t) - struct ubik_trans *ut; - dbadr ta; - struct tape *t; -{ afs_int32 code; +static afs_int32 +DeleteTape(ut, ta, t) + struct ubik_trans *ut; + dbadr ta; + struct tape *t; +{ + afs_int32 code; struct dump d; dbadr da; da = ntohl(t->dump); - if (da == 0) return BUDB_DATABASEINCONSISTENT; - if (dbread (ut, da, &d, sizeof(d))) return BUDB_IO; - if (d.firstTape == 0) return BUDB_DATABASEINCONSISTENT; + if (da == 0) + return BUDB_DATABASEINCONSISTENT; + if (dbread(ut, da, &d, sizeof(d))) + return BUDB_IO; + if (d.firstTape == 0) + return BUDB_DATABASEINCONSISTENT; - code = RemoveFromList (ut, da, &d, &d.firstTape, ta, t, &t->nextTape); - if (code == -1) return BUDB_DATABASEINCONSISTENT; - if (code) return code; + code = RemoveFromList(ut, da, &d, &d.firstTape, ta, t, &t->nextTape); + if (code == -1) + return BUDB_DATABASEINCONSISTENT; + if (code) + return code; /* Since the tape should have been truncated there should never be any * volumes in the tape. */ - if (t->firstVol || t->nVolumes) return BUDB_DATABASEINCONSISTENT; + if (t->firstVol || t->nVolumes) + return BUDB_DATABASEINCONSISTENT; return 0; } static afs_int32 -DeleteDump (ut, da, d) +DeleteDump(ut, da, d) struct ubik_trans *ut; dbadr da; struct dump *d; -{ - afs_int32 code = 0; +{ + afs_int32 code = 0; - code = ht_HashOut (ut, &db.dumpIden, da, d); - if (code) ERROR(code); + code = ht_HashOut(ut, &db.dumpIden, da, d); + if (code) + ERROR(code); - code = ht_HashOut (ut, &db.dumpName, da, d); - if (code) ERROR(code); + code = ht_HashOut(ut, &db.dumpName, da, d); + if (code) + ERROR(code); /* Since the tape should have been truncated this should never happen. */ - if (d->firstTape || d->nVolumes) ERROR(BUDB_DATABASEINCONSISTENT); + if (d->firstTape || d->nVolumes) + ERROR(BUDB_DATABASEINCONSISTENT); - code = FreeStructure (ut, dump_BLOCK, da); - if (code) ERROR(code); + code = FreeStructure(ut, dump_BLOCK, da); + if (code) + ERROR(code); error_exit: return code; @@ -656,16 +704,16 @@ DeleteDump (ut, da, d) * Always AND the flags with VOLINFOFLAGS for backwards compatability (3.3). */ -static int VolInfoMatch (vol, vi) - struct budb_volumeEntry *vol; - struct volInfo *vi; +static int +VolInfoMatch(vol, vi) + struct budb_volumeEntry *vol; + struct volInfo *vi; { - return ( (strcmp (vol->name, vi->name) == 0) && /* same volume name */ - (vol->id == ntohl(vi->id)) && /* same volume id */ - ((vol->flags & VOLINFOFLAGS) == - (ntohl(vi->flags) & VOLINFOFLAGS)) && /* same flags */ - (vol->partition == ntohl(vi->partition)) && /* same partition (N/A)*/ - (strcmp (vol->server, vi->server) == 0) ); /* same server (N/A) */ + return ((strcmp(vol->name, vi->name) == 0) && /* same volume name */ + (vol->id == ntohl(vi->id)) && /* same volume id */ + ((vol->flags & VOLINFOFLAGS) == (ntohl(vi->flags) & VOLINFOFLAGS)) && /* same flags */ + (vol->partition == ntohl(vi->partition)) && /* same partition (N/A) */ + (strcmp(vol->server, vi->server) == 0)); /* same server (N/A) */ } /* @@ -676,76 +724,82 @@ static int VolInfoMatch (vol, vi) * The caller must write the entry out. */ -static afs_int32 GetVolInfo (ut, volP, viaP, viP) - struct ubik_trans *ut; - struct budb_volumeEntry *volP; - dbadr *viaP; - struct volInfo *viP; +static afs_int32 +GetVolInfo(ut, volP, viaP, viP) + struct ubik_trans *ut; + struct budb_volumeEntry *volP; + dbadr *viaP; + struct volInfo *viP; { - dbadr hvia, via; + dbadr hvia, via; struct volInfo hvi; - afs_int32 eval, code = 0; - - eval = ht_LookupEntry (ut, &db.volName, volP->name, &via, viP); - if (eval) ERROR(eval); - - if (!via) - { - /* allocate a new volinfo structure */ - eval = AllocStructure (ut, volInfo_BLOCK, 0, &via, viP); - if (eval) ERROR(eval); + afs_int32 eval, code = 0; - strcpy (viP->name, volP->name); - strcpy (viP->server, volP->server); - viP->sameNameHead = 0; /* The head of same name chain */ - viP->sameNameChain = 0; /* Same name chain is empty */ + eval = ht_LookupEntry(ut, &db.volName, volP->name, &via, viP); + if (eval) + ERROR(eval); + + if (!via) { + /* allocate a new volinfo structure */ + eval = AllocStructure(ut, volInfo_BLOCK, 0, &via, viP); + if (eval) + ERROR(eval); + + strcpy(viP->name, volP->name); + strcpy(viP->server, volP->server); + viP->sameNameHead = 0; /* The head of same name chain */ + viP->sameNameChain = 0; /* Same name chain is empty */ viP->firstFragment = 0; - viP->nFrags = 0; - viP->id = htonl(volP->id); - viP->partition = htonl(volP->partition); - viP->flags = htonl(volP->flags & VOLINFOFLAGS); + viP->nFrags = 0; + viP->id = htonl(volP->id); + viP->partition = htonl(volP->partition); + viP->flags = htonl(volP->flags & VOLINFOFLAGS); /* Chain onto volname hash table */ - eval = ht_HashIn (ut, &db.volName, via, viP); - if (eval) ERROR(eval); + eval = ht_HashIn(ut, &db.volName, via, viP); + if (eval) + ERROR(eval); - LogDebug(4, "volume Info for %s placed at %d\n", db.volName, via); + LogDebug(4, "volume Info for %s placed at %d\n", db.volName, via); } - else if ( !VolInfoMatch(volP,viP) ) /* Not the head volinfo struct */ - { - hvia = via; /* remember the head volinfo struct */ + else if (!VolInfoMatch(volP, viP)) { /* Not the head volinfo struct */ + hvia = via; /* remember the head volinfo struct */ memcpy(&hvi, viP, sizeof(hvi)); - /* Search the same name chain for the correct volinfo structure */ - for (via=ntohl(viP->sameNameChain); via; via=ntohl(viP->sameNameChain)) - { - eval = dbread (ut, via, viP, sizeof(*viP)); - if (eval) ERROR(eval); + /* Search the same name chain for the correct volinfo structure */ + for (via = ntohl(viP->sameNameChain); via; + via = ntohl(viP->sameNameChain)) { + eval = dbread(ut, via, viP, sizeof(*viP)); + if (eval) + ERROR(eval); - if ( VolInfoMatch(volP,viP) ) break; /* found the one */ + if (VolInfoMatch(volP, viP)) + break; /* found the one */ } - + /* if the correct volinfo struct isn't found, create one */ - if (!via) - { - eval = AllocStructure (ut, volInfo_BLOCK, 0, &via, viP); - if (eval) ERROR(eval); - - strcpy (viP->name, volP->name); - strcpy (viP->server, volP->server); - viP->nameHashChain = 0; /* not in hash table */ - viP->sameNameHead = htonl(hvia); /* chain to head of sameNameChain */ + if (!via) { + eval = AllocStructure(ut, volInfo_BLOCK, 0, &via, viP); + if (eval) + ERROR(eval); + + strcpy(viP->name, volP->name); + strcpy(viP->server, volP->server); + viP->nameHashChain = 0; /* not in hash table */ + viP->sameNameHead = htonl(hvia); /* chain to head of sameNameChain */ viP->sameNameChain = hvi.sameNameChain; viP->firstFragment = 0; - viP->nFrags = 0; - viP->id = htonl(volP->id); - viP->partition = htonl(volP->partition); - viP->flags = htonl(volP->flags & VOLINFOFLAGS); + viP->nFrags = 0; + viP->id = htonl(volP->id); + viP->partition = htonl(volP->partition); + viP->flags = htonl(volP->flags & VOLINFOFLAGS); /* write the head entry's sameNameChain link */ - eval = set_word_addr (ut, hvia, &hvi, &hvi.sameNameChain, htonl(via)); - if (eval) ERROR(eval); + eval = + set_word_addr(ut, hvia, &hvi, &hvi.sameNameChain, htonl(via)); + if (eval) + ERROR(eval); } } @@ -771,24 +825,27 @@ deleteSomeVolumesFromTape(ut, tapeAddr, tapePtr, maxVolumesToDelete) struct tape *tapePtr; int maxVolumesToDelete; { - dbadr volFragAddr, nextVolFragAddr, dumpAddr; + dbadr volFragAddr, nextVolFragAddr, dumpAddr; struct volFragment volFrag; - struct dump dump; - int volumesDeleted = 0; - afs_int32 eval, code = 0; + struct dump dump; + int volumesDeleted = 0; + afs_int32 eval, code = 0; - if (!tapePtr) ERROR(0); + if (!tapePtr) + ERROR(0); - for (volFragAddr=ntohl(tapePtr->firstVol); (volFragAddr && (maxVolumesToDelete > 0)); - volFragAddr=nextVolFragAddr) - { + for (volFragAddr = ntohl(tapePtr->firstVol); + (volFragAddr && (maxVolumesToDelete > 0)); + volFragAddr = nextVolFragAddr) { eval = dbread(ut, volFragAddr, &volFrag, sizeof(volFrag)); - if (eval) ERROR(eval); + if (eval) + ERROR(eval); - nextVolFragAddr = ntohl(volFrag.sameTapeChain); + nextVolFragAddr = ntohl(volFrag.sameTapeChain); - eval = DeleteVolFragment(ut, volFragAddr, &volFrag); - if (eval) ERROR(eval); + eval = DeleteVolFragment(ut, volFragAddr, &volFrag); + if (eval) + ERROR(eval); maxVolumesToDelete--; volumesDeleted++; @@ -796,24 +853,27 @@ deleteSomeVolumesFromTape(ut, tapeAddr, tapePtr, maxVolumesToDelete) /* reset the volume fragment pointer in the tape */ tapePtr->firstVol = htonl(volFragAddr); - + /* diminish the tape's volume count */ tapePtr->nVolumes = htonl(ntohl(tapePtr->nVolumes) - volumesDeleted); eval = dbwrite(ut, tapeAddr, tapePtr, sizeof(*tapePtr)); - if (eval) ERROR(eval); + if (eval) + ERROR(eval); /* diminish the dump's volume count */ dumpAddr = ntohl(tapePtr->dump); eval = dbread(ut, dumpAddr, &dump, sizeof(dump)); - if (eval) ERROR(eval); + if (eval) + ERROR(eval); - dump.nVolumes = htonl(ntohl(dump.nVolumes) - volumesDeleted); + dump.nVolumes = htonl(ntohl(dump.nVolumes) - volumesDeleted); eval = dbwrite(ut, dumpAddr, &dump, sizeof(dump)); - if (eval) ERROR(eval); + if (eval) + ERROR(eval); error_exit: - return(code); + return (code); } /* deleteDump @@ -830,113 +890,123 @@ deleteSomeVolumesFromTape(ut, tapeAddr, tapePtr, maxVolumesToDelete) afs_int32 deleteDump(call, id, dumps) - struct rx_call *call; - dumpId id; - budb_dumpsList *dumps; + struct rx_call *call; + dumpId id; + budb_dumpsList *dumps; { struct ubik_trans *ut; - dbadr dumpAddr, tapeAddr, appendedDump; - struct dump dump; - struct tape tape; - dumpId dumpid; - int firstdump; - afs_int32 eval, code = 0; - int partialDel; + dbadr dumpAddr, tapeAddr, appendedDump; + struct dump dump; + struct tape tape; + dumpId dumpid; + int firstdump; + afs_int32 eval, code = 0; + int partialDel; /* iterate until the dump is truly deleted */ dumpid = id; - while (dumpid) - { - partialDel = 0; - while (1) - { + while (dumpid) { + partialDel = 0; + while (1) { eval = InitRPC(&ut, LOCKWRITE, 1); - if (eval) ERROR(eval); /* can't start transaction */ + if (eval) + ERROR(eval); /* can't start transaction */ - eval = ht_LookupEntry (ut, &db.dumpIden, &dumpid, &dumpAddr, &dump); - if (eval) ABORT(eval); - if (!dumpAddr) ABORT(BUDB_NOENT); /* can't find dump */ + eval = + ht_LookupEntry(ut, &db.dumpIden, &dumpid, &dumpAddr, &dump); + if (eval) + ABORT(eval); + if (!dumpAddr) + ABORT(BUDB_NOENT); /* can't find dump */ - if ( (dumpid == id) && (dump.initialDumpID) ) /* can't be an appended dump */ - ABORT(BUDB_NOTINITIALDUMP); + if ((dumpid == id) && (dump.initialDumpID)) /* can't be an appended dump */ + ABORT(BUDB_NOTINITIALDUMP); tapeAddr = ntohl(dump.firstTape); - if (tapeAddr == 0) break; - + if (tapeAddr == 0) + break; + /* there is a tape to delete */ eval = dbread(ut, tapeAddr, &tape, sizeof(tape)); - if (eval) ABORT(eval); - - if ( ntohl(tape.nVolumes) ) - { - /* tape is not empty */ - eval = deleteSomeVolumesFromTape(ut, tapeAddr, &tape, 10); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); + + if (ntohl(tape.nVolumes)) { + /* tape is not empty */ + eval = deleteSomeVolumesFromTape(ut, tapeAddr, &tape, 10); + if (eval) + ABORT(eval); } - - if ( ntohl(tape.nVolumes) == 0 ) - { - /* tape is now empty, delete it */ - eval = DeleteTape(ut, tapeAddr, &tape); - if (eval) ABORT(eval); + + if (ntohl(tape.nVolumes) == 0) { + /* tape is now empty, delete it */ + eval = DeleteTape(ut, tapeAddr, &tape); + if (eval) + ABORT(eval); eval = ht_HashOut(ut, &db.tapeName, tapeAddr, &tape); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); eval = FreeStructure(ut, tape_BLOCK, tapeAddr); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); } eval = ubik_EndTrans(ut); - if (eval) ERROR(eval); + if (eval) + ERROR(eval); partialDel = 1; - } /* next deletion portion */ + } /* next deletion portion */ /* Record the dump just deleted */ - if (dumps && (dumps->budb_dumpsList_len < BUDB_MAX_RETURN_LIST)) - { - if (dumps->budb_dumpsList_len == 0) - dumps->budb_dumpsList_val = (afs_int32 *) malloc(sizeof(afs_int32)); - else - dumps->budb_dumpsList_val = - (afs_int32 *) realloc(dumps->budb_dumpsList_val, - (dumps->budb_dumpsList_len+1)*sizeof(afs_int32)); - - if ( !dumps->budb_dumpsList_val ) ABORT(BUDB_NOMEM); - - dumps->budb_dumpsList_val[dumps->budb_dumpsList_len] = dumpid; - dumps->budb_dumpsList_len++; + if (dumps && (dumps->budb_dumpsList_len < BUDB_MAX_RETURN_LIST)) { + if (dumps->budb_dumpsList_len == 0) + dumps->budb_dumpsList_val = + (afs_int32 *) malloc(sizeof(afs_int32)); + else + dumps->budb_dumpsList_val = + (afs_int32 *) realloc(dumps->budb_dumpsList_val, + (dumps->budb_dumpsList_len + + 1) * sizeof(afs_int32)); + + if (!dumps->budb_dumpsList_val) + ABORT(BUDB_NOMEM); + + dumps->budb_dumpsList_val[dumps->budb_dumpsList_len] = dumpid; + dumps->budb_dumpsList_len++; } appendedDump = ntohl(dump.appendedDumpChain); /* finally done. No more tapes left in the dump. Delete the dump itself */ eval = DeleteDump(ut, dumpAddr, &dump); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); /* Now delete the appended dump too */ - if ( appendedDump ) - { + if (appendedDump) { eval = dbread(ut, appendedDump, &dump, sizeof(dump)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); dumpid = ntohl(dump.id); - } - else + } else dumpid = 0; - + eval = ubik_EndTrans(ut); - if (eval) ERROR(eval); + if (eval) + ERROR(eval); - Log("Delete dump %s (DumpID %u), path %s\n", - dump.dumpName, ntohl(dump.id), dump.dumpPath); + Log("Delete dump %s (DumpID %u), path %s\n", dump.dumpName, + ntohl(dump.id), dump.dumpPath); } error_exit: if (code && partialDel) { - Log("Delete dump %s (DumpID %u), path %s - INCOMPLETE (code = %u)\n", - dump.dumpName, ntohl(dump.id), dump.dumpPath, code); + Log("Delete dump %s (DumpID %u), path %s - INCOMPLETE (code = %u)\n", + dump.dumpName, ntohl(dump.id), dump.dumpPath, code); } - return(code); + return (code); abort_exit: ubik_AbortTrans(ut); @@ -950,17 +1020,15 @@ deleteDump(call, id, dumps) /* most recent dump selection */ -struct chosenDump -{ +struct chosenDump { struct chosenDump *next; dbadr addr; - afs_uint32 date; + afs_uint32 date; }; -struct wantDumpRock -{ - int maxDumps; /* max wanted */ - int ndumps; /* actual in chain */ +struct wantDumpRock { + int maxDumps; /* max wanted */ + int ndumps; /* actual in chain */ struct chosenDump *chain; }; @@ -975,21 +1043,21 @@ wantDump(dumpAddrParam, dumpParam, dumpListPtrParam) struct wantDumpRock *rockPtr; dumpAddr = (dbadr) dumpAddrParam; - dumpPtr = (struct dump *) dumpParam; - rockPtr = (struct wantDumpRock *) dumpListPtrParam; + dumpPtr = (struct dump *)dumpParam; + rockPtr = (struct wantDumpRock *)dumpListPtrParam; /* if we don't have our full complement, just add another */ - if ( rockPtr->ndumps < rockPtr->maxDumps ) - return(1); + if (rockPtr->ndumps < rockPtr->maxDumps) + return (1); /* got the number we need, select based on date */ - if ( (afs_uint32) ntohl(dumpPtr->created) > rockPtr->chain->date ) - return(1); + if ((afs_uint32) ntohl(dumpPtr->created) > rockPtr->chain->date) + return (1); - return(0); + return (0); } -rememberDump(dumpAddrParam, dumpParam, dumpListPtrParam) +rememberDump(dumpAddrParam, dumpParam, dumpListPtrParam) char *dumpAddrParam; char *dumpParam; char *dumpListPtrParam; @@ -1000,35 +1068,35 @@ rememberDump(dumpAddrParam, dumpParam, dumpListPtrParam) struct chosenDump *ptr, *deletedPtr, **nextPtr; dumpAddr = (dbadr) dumpAddrParam; - dumpPtr = (struct dump *) dumpParam; - rockPtr = (struct wantDumpRock *) dumpListPtrParam; + dumpPtr = (struct dump *)dumpParam; + rockPtr = (struct wantDumpRock *)dumpListPtrParam; - ptr = (struct chosenDump *) malloc(sizeof(*ptr)); + ptr = (struct chosenDump *)malloc(sizeof(*ptr)); if (!ptr) - return(0); + return (0); memset(ptr, 0, sizeof(*ptr)); ptr->addr = dumpAddr; - ptr->date = (afs_uint32) ntohl(dumpPtr->created); + ptr->date = (afs_uint32) ntohl(dumpPtr->created); /* Don't overflow the max */ while (rockPtr->ndumps >= rockPtr->maxDumps) { - /* have to drop one */ - deletedPtr = rockPtr->chain; - rockPtr->chain = deletedPtr->next; - free(deletedPtr); - rockPtr->ndumps--; + /* have to drop one */ + deletedPtr = rockPtr->chain; + rockPtr->chain = deletedPtr->next; + free(deletedPtr); + rockPtr->ndumps--; } /* now insert in the right place */ for (nextPtr = &rockPtr->chain; *nextPtr; nextPtr = &((*nextPtr)->next)) { - if (ptr->date < (*nextPtr)->date) - break; + if (ptr->date < (*nextPtr)->date) + break; } ptr->next = *nextPtr; - *nextPtr = ptr; + *nextPtr = ptr; rockPtr->ndumps++; - return(0); + return (0); } @@ -1037,109 +1105,123 @@ rememberDump(dumpAddrParam, dumpParam, dumpListPtrParam) * --------------------------------------------- */ -afs_int32 SBUDB_AddVolume (call, vol) - struct rx_call *call; - struct budb_volumeEntry *vol; +afs_int32 +SBUDB_AddVolume(call, vol) + struct rx_call *call; + struct budb_volumeEntry *vol; { - afs_int32 code; + afs_int32 code; - code = AddVolume (call, vol); - osi_auditU (call, BUDB_AddVolEvent, code, AUD_LONG, (vol ? vol->id : 0), AUD_END); - return code; + code = AddVolume(call, vol); + osi_auditU(call, BUDB_AddVolEvent, code, AUD_LONG, (vol ? vol->id : 0), + AUD_END); + return code; } -afs_int32 AddVolume (call, vol) - struct rx_call *call; - struct budb_volumeEntry *vol; -{ - struct ubik_trans *ut; - dbadr da, ta, via, va; - struct dump d; - struct tape t; - struct volInfo vi; +afs_int32 +AddVolume(call, vol) + struct rx_call *call; + struct budb_volumeEntry *vol; +{ + struct ubik_trans *ut; + dbadr da, ta, via, va; + struct dump d; + struct tape t; + struct volInfo vi; struct volFragment v; - afs_uint32 bytes; - afs_int32 eval, code = 0; + afs_uint32 bytes; + afs_int32 eval, code = 0; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - if ( ( strlen(vol->name) >= sizeof(vi.name) ) || - ( strlen(vol->server) >= sizeof(vi.server) ) || - ( strlen(vol->tape) >= sizeof(t.name) ) ) - return BUDB_BADARGUMENT; + if ((strlen(vol->name) >= sizeof(vi.name)) + || (strlen(vol->server) >= sizeof(vi.server)) + || (strlen(vol->tape) >= sizeof(t.name))) + return BUDB_BADARGUMENT; - eval = InitRPC (&ut, LOCKWRITE, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKWRITE, 1); + if (eval) + return eval; /* Find the dump in dumpid hash table */ - eval = ht_LookupEntry (ut, &db.dumpIden, &vol->dump, &da, &d); - if (eval) ABORT(eval); - if (!da) ABORT(BUDB_NODUMPID); + eval = ht_LookupEntry(ut, &db.dumpIden, &vol->dump, &da, &d); + if (eval) + ABORT(eval); + if (!da) + ABORT(BUDB_NODUMPID); /* search for the right tape in the dump */ - for (ta=ntohl(d.firstTape); ta; ta=ntohl(t.nextTape)) - { - /* read the tape entry */ + for (ta = ntohl(d.firstTape); ta; ta = ntohl(t.nextTape)) { + /* read the tape entry */ eval = dbread(ut, ta, &t, sizeof(t)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); /* Check if the right tape name */ - if ( strcmp(t.name, vol->tape) == 0 ) + if (strcmp(t.name, vol->tape) == 0) break; } - if (!ta) ABORT(BUDB_NOTAPENAME); + if (!ta) + ABORT(BUDB_NOTAPENAME); - if ( (t.dump != htonl(da)) || /* tape must belong to dump */ - ((ntohl(t.flags) & BUDB_TAPE_BEINGWRITTEN) == 0) || /* tape must be being written */ - ((ntohl(d.flags) & BUDB_DUMP_INPROGRESS) == 0) ) /* dump must be in progress */ - ABORT(BUDB_BADPROTOCOL); + if ((t.dump != htonl(da)) || /* tape must belong to dump */ + ((ntohl(t.flags) & BUDB_TAPE_BEINGWRITTEN) == 0) || /* tape must be being written */ + ((ntohl(d.flags) & BUDB_DUMP_INPROGRESS) == 0)) /* dump must be in progress */ + ABORT(BUDB_BADPROTOCOL); /* find or create a volume info structure */ eval = GetVolInfo(ut, vol, &via, &vi); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); /* Create a volume fragment */ - eval = AllocStructure (ut, volFragment_BLOCK, 0, &va, &v); - if (eval) ABORT(eval); + eval = AllocStructure(ut, volFragment_BLOCK, 0, &va, &v); + if (eval) + ABORT(eval); - v.vol = htonl(via); /* vol frag points to vol info */ - v.sameNameChain = vi.firstFragment; /* vol frag is chained to vol info */ + v.vol = htonl(via); /* vol frag points to vol info */ + v.sameNameChain = vi.firstFragment; /* vol frag is chained to vol info */ vi.firstFragment = htonl(va); - vi.nFrags = htonl(ntohl(vi.nFrags)+1); + vi.nFrags = htonl(ntohl(vi.nFrags) + 1); - eval = dbwrite(ut, via, &vi, sizeof(vi)); /* write the vol info struct */ - if (eval) ABORT(eval); + eval = dbwrite(ut, via, &vi, sizeof(vi)); /* write the vol info struct */ + if (eval) + ABORT(eval); - v.tape = htonl(ta); /* vol frag points to tape */ - v.sameTapeChain = t.firstVol; /* vol frag is chained to tape info */ - t.firstVol = htonl(va); - t.nVolumes = htonl(ntohl(t.nVolumes) + 1); - bytes = ntohl(t.nBytes) + vol->nBytes; /* update bytes on tape */ - t.nMBytes = htonl(ntohl(t.nMBytes) + bytes/(1024*1024)); - t.nBytes = htonl(bytes % (1024*1024)); + v.tape = htonl(ta); /* vol frag points to tape */ + v.sameTapeChain = t.firstVol; /* vol frag is chained to tape info */ + t.firstVol = htonl(va); + t.nVolumes = htonl(ntohl(t.nVolumes) + 1); + bytes = ntohl(t.nBytes) + vol->nBytes; /* update bytes on tape */ + t.nMBytes = htonl(ntohl(t.nMBytes) + bytes / (1024 * 1024)); + t.nBytes = htonl(bytes % (1024 * 1024)); - eval = dbwrite(ut, ta, &t, sizeof(t)); /* write the tape structure */ - if (eval) ABORT(eval); + eval = dbwrite(ut, ta, &t, sizeof(t)); /* write the tape structure */ + if (eval) + ABORT(eval); - d.nVolumes = htonl(ntohl(d.nVolumes) + 1); /* one more volume on dump */ + d.nVolumes = htonl(ntohl(d.nVolumes) + 1); /* one more volume on dump */ - eval = dbwrite(ut, da, &d, sizeof(d)); /* write out the dump structure */ - if (eval) ABORT(eval); + eval = dbwrite(ut, da, &d, sizeof(d)); /* write out the dump structure */ + if (eval) + ABORT(eval); - v.position = htonl(vol->position); /* vol frag info */ - v.clone = htonl(vol->clone); - v.incTime = htonl(vol->incTime); + v.position = htonl(vol->position); /* vol frag info */ + v.clone = htonl(vol->clone); + v.incTime = htonl(vol->incTime); v.startByte = htonl(vol->startByte); - v.nBytes = htonl(vol->nBytes); - v.flags = htons(vol->flags & VOLFRAGMENTFLAGS); - v.sequence = htons(vol->seq); + v.nBytes = htonl(vol->nBytes); + v.flags = htons(vol->flags & VOLFRAGMENTFLAGS); + v.sequence = htons(vol->seq); - eval = dbwrite(ut, va, &v, sizeof(v)); /* write out the vol frag struct */ - if (eval) ABORT(eval); + eval = dbwrite(ut, va, &v, sizeof(v)); /* write out the vol frag struct */ + if (eval) + ABORT(eval); eval = set_header_word(ut, lastUpdate, htonl(time(0))); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); LogDebug(4, "added volume %s at %d\n", vol->name, va); @@ -1152,129 +1234,141 @@ afs_int32 AddVolume (call, vol) } -afs_int32 SBUDB_AddVolumes (call, vols) - struct rx_call *call; - struct budb_volumeList *vols; +afs_int32 +SBUDB_AddVolumes(call, vols) + struct rx_call *call; + struct budb_volumeList *vols; { - afs_int32 code; + afs_int32 code; - code = AddVolumes (call, vols); - osi_auditU (call, BUDB_AddVolEvent, code, AUD_LONG, 0, AUD_END); - return code; + code = AddVolumes(call, vols); + osi_auditU(call, BUDB_AddVolEvent, code, AUD_LONG, 0, AUD_END); + return code; } -afs_int32 AddVolumes (call, vols) - struct rx_call *call; - struct budb_volumeList *vols; -{ +afs_int32 +AddVolumes(call, vols) + struct rx_call *call; + struct budb_volumeList *vols; +{ struct budb_volumeEntry *vol, *vol1; - struct ubik_trans *ut; - dbadr da, ta, via, va; - struct dump d; - struct tape t; - struct volInfo vi; + struct ubik_trans *ut; + dbadr da, ta, via, va; + struct dump d; + struct tape t; + struct volInfo vi; struct volFragment v; - afs_uint32 bytes; - afs_int32 eval, e, code = 0; + afs_uint32 bytes; + afs_int32 eval, e, code = 0; - if ( !callPermitted(call) ) - return BUDB_NOTPERMITTED; + if (!callPermitted(call)) + return BUDB_NOTPERMITTED; + + if (!vols || (vols->budb_volumeList_len <= 0) + || !vols->budb_volumeList_val) + return BUDB_BADARGUMENT; - if (!vols || (vols->budb_volumeList_len <= 0) || !vols->budb_volumeList_val) - return BUDB_BADARGUMENT; - /* The first volume in the list of volumes to add */ vol1 = (struct budb_volumeEntry *)vols->budb_volumeList_val; - eval = InitRPC (&ut, LOCKWRITE, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKWRITE, 1); + if (eval) + return eval; /* Find the dump in dumpid hash table */ - eval = ht_LookupEntry (ut, &db.dumpIden, &vol1->dump, &da, &d); - if (eval) ABORT(eval); - if (!da) ABORT(BUDB_NODUMPID); + eval = ht_LookupEntry(ut, &db.dumpIden, &vol1->dump, &da, &d); + if (eval) + ABORT(eval); + if (!da) + ABORT(BUDB_NODUMPID); /* search for the right tape in the dump */ - for (ta=ntohl(d.firstTape); ta; ta=ntohl(t.nextTape)) { - /* read the tape entry */ - eval = dbread(ut, ta, &t, sizeof(t)); - if (eval) ABORT(eval); - - /* Check if the right tape name */ - if ( strcmp(t.name, vol1->tape) == 0 ) - break; + for (ta = ntohl(d.firstTape); ta; ta = ntohl(t.nextTape)) { + /* read the tape entry */ + eval = dbread(ut, ta, &t, sizeof(t)); + if (eval) + ABORT(eval); + + /* Check if the right tape name */ + if (strcmp(t.name, vol1->tape) == 0) + break; } - if (!ta) ABORT(BUDB_NOTAPENAME); - - if ( (t.dump != htonl(da)) || /* tape must belong to dump */ - ((ntohl(t.flags) & BUDB_TAPE_BEINGWRITTEN) == 0) || /* tape must be being written */ - ((ntohl(d.flags) & BUDB_DUMP_INPROGRESS) == 0) ) /* dump must be in progress */ - ABORT(BUDB_BADPROTOCOL); - - for (vol=vol1, e=0; e < vols->budb_volumeList_len; vol++, e++) { - /*v*/ - if ( ( strlen(vol->name) >= sizeof(vi.name) ) || - ( strcmp(vol->name, "") == 0 ) || /* no null volnames */ - ( strlen(vol->server) >= sizeof(vi.server) ) || - ( strlen(vol->tape) >= sizeof(t.name) ) || - ( strcmp(vol->tape, vol1->tape) != 0 ) ) { - Log("Volume '%s' %u, tape '%s', dumpID %u is an invalid entry - not added\n", - vol->name, vol->id, vol->tape, vol->dump); - continue; - } - - /* find or create a volume info structure */ - eval = GetVolInfo(ut, vol, &via, &vi); - if (eval) ABORT(eval); - if (*(afs_int32 *)(&vi) == 0) { - Log("Volume '%s', tape '%s', dumpID %u is an invalid entry - aborted\n", - vol->name, vol->tape, vol->dump); - ABORT(BUDB_BADARGUMENT); - } - - /* Create a volume fragment */ - eval = AllocStructure (ut, volFragment_BLOCK, 0, &va, &v); - if (eval) ABORT(eval); - - v.vol = htonl(via); /* vol frag points to vol info */ - v.sameNameChain = vi.firstFragment; /* vol frag is chained to vol info */ - vi.firstFragment = htonl(va); - vi.nFrags = htonl(ntohl(vi.nFrags)+1); - eval = dbwrite(ut, via, &vi, sizeof(vi)); /* write the vol info struct */ - if (eval) ABORT(eval); - - v.tape = htonl(ta); /* vol frag points to tape */ - v.sameTapeChain = t.firstVol; /* vol frag is chained to tape info */ - t.firstVol = htonl(va); - t.nVolumes = htonl(ntohl(t.nVolumes) + 1); - bytes = ntohl(t.nBytes) + vol->nBytes; /* update bytes on tape */ - t.nMBytes = htonl(ntohl(t.nMBytes) + bytes/(1024*1024)); - t.nBytes = htonl(bytes % (1024*1024)); - - d.nVolumes = htonl(ntohl(d.nVolumes) + 1); /* one more volume on dump */ - - v.position = htonl(vol->position); /* vol frag info */ - v.clone = htonl(vol->clone); - v.incTime = htonl(vol->incTime); - v.startByte = htonl(vol->startByte); - v.nBytes = htonl(vol->nBytes); - v.flags = htons(vol->flags & VOLFRAGMENTFLAGS); - v.sequence = htons(vol->seq); - - eval = dbwrite(ut, va, &v, sizeof(v)); /* write out the vol frag struct */ - if (eval) ABORT(eval); - - LogDebug(4, "added volume %s at %d\n", vol->name, va); - } /*v*/ - - eval = dbwrite(ut, ta, &t, sizeof(t)); /* write the tape structure */ - if (eval) ABORT(eval); - - eval = dbwrite(ut, da, &d, sizeof(d)); /* write out the dump structure */ - if (eval) ABORT(eval); + if (!ta) + ABORT(BUDB_NOTAPENAME); + + if ((t.dump != htonl(da)) || /* tape must belong to dump */ + ((ntohl(t.flags) & BUDB_TAPE_BEINGWRITTEN) == 0) || /* tape must be being written */ + ((ntohl(d.flags) & BUDB_DUMP_INPROGRESS) == 0)) /* dump must be in progress */ + ABORT(BUDB_BADPROTOCOL); + + for (vol = vol1, e = 0; e < vols->budb_volumeList_len; vol++, e++) { + /*v */ + if ((strlen(vol->name) >= sizeof(vi.name)) || (strcmp(vol->name, "") == 0) || /* no null volnames */ + (strlen(vol->server) >= sizeof(vi.server)) + || (strlen(vol->tape) >= sizeof(t.name)) + || (strcmp(vol->tape, vol1->tape) != 0)) { + Log("Volume '%s' %u, tape '%s', dumpID %u is an invalid entry - not added\n", vol->name, vol->id, vol->tape, vol->dump); + continue; + } + + /* find or create a volume info structure */ + eval = GetVolInfo(ut, vol, &via, &vi); + if (eval) + ABORT(eval); + if (*(afs_int32 *) (&vi) == 0) { + Log("Volume '%s', tape '%s', dumpID %u is an invalid entry - aborted\n", vol->name, vol->tape, vol->dump); + ABORT(BUDB_BADARGUMENT); + } + + /* Create a volume fragment */ + eval = AllocStructure(ut, volFragment_BLOCK, 0, &va, &v); + if (eval) + ABORT(eval); + + v.vol = htonl(via); /* vol frag points to vol info */ + v.sameNameChain = vi.firstFragment; /* vol frag is chained to vol info */ + vi.firstFragment = htonl(va); + vi.nFrags = htonl(ntohl(vi.nFrags) + 1); + eval = dbwrite(ut, via, &vi, sizeof(vi)); /* write the vol info struct */ + if (eval) + ABORT(eval); + + v.tape = htonl(ta); /* vol frag points to tape */ + v.sameTapeChain = t.firstVol; /* vol frag is chained to tape info */ + t.firstVol = htonl(va); + t.nVolumes = htonl(ntohl(t.nVolumes) + 1); + bytes = ntohl(t.nBytes) + vol->nBytes; /* update bytes on tape */ + t.nMBytes = htonl(ntohl(t.nMBytes) + bytes / (1024 * 1024)); + t.nBytes = htonl(bytes % (1024 * 1024)); + + d.nVolumes = htonl(ntohl(d.nVolumes) + 1); /* one more volume on dump */ + + v.position = htonl(vol->position); /* vol frag info */ + v.clone = htonl(vol->clone); + v.incTime = htonl(vol->incTime); + v.startByte = htonl(vol->startByte); + v.nBytes = htonl(vol->nBytes); + v.flags = htons(vol->flags & VOLFRAGMENTFLAGS); + v.sequence = htons(vol->seq); + + eval = dbwrite(ut, va, &v, sizeof(v)); /* write out the vol frag struct */ + if (eval) + ABORT(eval); + + LogDebug(4, "added volume %s at %d\n", vol->name, va); + } /*v */ + + eval = dbwrite(ut, ta, &t, sizeof(t)); /* write the tape structure */ + if (eval) + ABORT(eval); + + eval = dbwrite(ut, da, &d, sizeof(d)); /* write out the dump structure */ + if (eval) + ABORT(eval); eval = set_header_word(ut, lastUpdate, htonl(time(0))); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); code = ubik_EndTrans(ut); return code; @@ -1292,122 +1386,131 @@ afs_int32 AddVolumes (call, vols) * 1) record the volume set */ -afs_int32 SBUDB_CreateDump(call, dump) +afs_int32 +SBUDB_CreateDump(call, dump) struct rx_call *call; struct budb_dumpEntry *dump; { - afs_int32 code; + afs_int32 code; - code = CreateDump(call, dump); - osi_auditU (call, BUDB_CrDmpEvent, code, AUD_DATE, (dump ? dump->id : 0), AUD_END); - if (dump && !code) { - Log("Create dump %s (DumpID %u), path %s\n", - dump->name, dump->id, dump->dumpPath); - } - return code; + code = CreateDump(call, dump); + osi_auditU(call, BUDB_CrDmpEvent, code, AUD_DATE, (dump ? dump->id : 0), + AUD_END); + if (dump && !code) { + Log("Create dump %s (DumpID %u), path %s\n", dump->name, dump->id, + dump->dumpPath); + } + return code; } -afs_int32 CreateDump(call, dump) +afs_int32 +CreateDump(call, dump) struct rx_call *call; struct budb_dumpEntry *dump; -{ +{ struct ubik_trans *ut; - dbadr findDumpAddr, da; - struct dump findDump, d; - afs_int32 eval, code = 0; + dbadr findDumpAddr, da; + struct dump findDump, d; + afs_int32 eval, code = 0; - rxkad_level level; - afs_int32 kvno; - Date expiration; /* checked by Security Module */ + rxkad_level level; + afs_int32 kvno; + Date expiration; /* checked by Security Module */ struct ktc_principal principal; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; if (strlen(dump->name) >= sizeof(d.dumpName)) - return BUDB_BADARGUMENT; + return BUDB_BADARGUMENT; - eval = InitRPC (&ut, LOCKWRITE, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKWRITE, 1); + if (eval) + return eval; - eval = rxkad_GetServerInfo( rx_ConnectionOf(call), - &level, &expiration, - principal.name, - principal.instance, - principal.cell, - &kvno ); + eval = + rxkad_GetServerInfo(rx_ConnectionOf(call), &level, &expiration, + principal.name, principal.instance, + principal.cell, &kvno); - if (eval) - { - if (eval != RXKADNOAUTH) ABORT(eval); + if (eval) { + if (eval != RXKADNOAUTH) + ABORT(eval); - strcpy(principal.name, ""); + strcpy(principal.name, ""); strcpy(principal.instance, ""); - strcpy(principal.cell, ""); + strcpy(principal.cell, ""); expiration = 0; - } - else - { + } else { /* authenticated. Take user supplied principal information */ - if ( strcmp(dump->dumper.name, "") != 0 ) - strncpy(principal.name, dump->dumper.name, sizeof(principal.name)); + if (strcmp(dump->dumper.name, "") != 0) + strncpy(principal.name, dump->dumper.name, + sizeof(principal.name)); - if ( strcmp(dump->dumper.instance, "") != 0 ) - strncpy(principal.instance, dump->dumper.instance, sizeof(principal.instance)); + if (strcmp(dump->dumper.instance, "") != 0) + strncpy(principal.instance, dump->dumper.instance, + sizeof(principal.instance)); - if ( strcmp(dump->dumper.cell, "") != 0 ) - strncpy(principal.cell, dump->dumper.cell, sizeof(principal.cell)); + if (strcmp(dump->dumper.cell, "") != 0) + strncpy(principal.cell, dump->dumper.cell, + sizeof(principal.cell)); } /* dump id's are time stamps */ - if (!dump->id) - { - while (1) /* allocate a unique dump id */ - { /*w*/ + if (!dump->id) { + while (1) { /* allocate a unique dump id *//*w */ dump->id = time(0); /* ensure it is unique - seach for dumpid in hash table */ - eval = ht_LookupEntry(ut, &db.dumpIden, &dump->id, &findDumpAddr, &findDump); - if (eval) ABORT(eval); + eval = + ht_LookupEntry(ut, &db.dumpIden, &dump->id, &findDumpAddr, + &findDump); + if (eval) + ABORT(eval); - if (!findDumpAddr) /* dumpid not in use */ - { + if (!findDumpAddr) { /* dumpid not in use */ /* update the last dump id allocated */ eval = set_header_word(ut, lastDumpId, htonl(dump->id)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); break; } /* dump id is in use - wait a while */ IOMGR_Sleep(1); - } /*w*/ - } - else - { + } /*w */ + } else { /* dump id supplied (e.g. for database restore) */ - eval = ht_LookupEntry(ut, &db.dumpIden, &dump->id, &findDumpAddr, &findDump); - if (eval) ABORT(eval); - + eval = + ht_LookupEntry(ut, &db.dumpIden, &dump->id, &findDumpAddr, + &findDump); + if (eval) + ABORT(eval); + /* Dump id must not already exist */ - if (findDumpAddr) ABORT(BUDB_DUMPIDEXISTS); + if (findDumpAddr) + ABORT(BUDB_DUMPIDEXISTS); } - + /* Allocate a dump structure */ memset(&d, 0, sizeof(d)); - eval = AllocStructure (ut, dump_BLOCK, 0, &da, &d); - if (eval) ABORT(eval); + eval = AllocStructure(ut, dump_BLOCK, 0, &da, &d); + if (eval) + ABORT(eval); - strcpy(d.dumpName, dump->name); /* volset.dumpname */ - strcpy(d.dumpPath, dump->dumpPath); /* dump node path */ + strcpy(d.dumpName, dump->name); /* volset.dumpname */ + strcpy(d.dumpPath, dump->dumpPath); /* dump node path */ strcpy(d.volumeSet, dump->volumeSetName); /* volume set */ - d.id = htonl(dump->id); - d.parent = htonl(dump->parent); /* parent id */ - d.level = htonl(dump->level); + d.id = htonl(dump->id); + d.parent = htonl(dump->parent); /* parent id */ + d.level = htonl(dump->level); - LogDebug(4, "dump name %s, parent %d level %d\n", dump->name, dump->parent, dump->level); + LogDebug(4, "dump name %s, parent %d level %d\n", dump->name, + dump->parent, dump->level); /* if creation time specified, use that. Else use the dumpid time */ - if (dump->created == 0) dump->created = dump->id; + if (dump->created == 0) + dump->created = dump->id; d.created = htonl(dump->created); principal_hton(&principal, &d.dumper); @@ -1415,21 +1518,26 @@ afs_int32 CreateDump(call, dump) d.flags = htonl(dump->flags | BUDB_DUMP_INPROGRESS); - eval = ht_HashIn (ut, &db.dumpName, da, &d); /* Into dump name hash table */ - if (eval) ABORT(eval); + eval = ht_HashIn(ut, &db.dumpName, da, &d); /* Into dump name hash table */ + if (eval) + ABORT(eval); - eval = ht_HashIn (ut, &db.dumpIden, da, &d); /* Into dumpid hash table */ - if (eval) ABORT(eval); + eval = ht_HashIn(ut, &db.dumpIden, da, &d); /* Into dumpid hash table */ + if (eval) + ABORT(eval); - eval = dbwrite (ut, da, (char *)&d, sizeof(d)); /* Write the dump structure */ - if (eval) ABORT(eval); + eval = dbwrite(ut, da, (char *)&d, sizeof(d)); /* Write the dump structure */ + if (eval) + ABORT(eval); - eval = set_header_word (ut, lastUpdate, htonl(time(0))); - if (eval) ABORT(eval); + eval = set_header_word(ut, lastUpdate, htonl(time(0))); + if (eval) + ABORT(eval); /* If to append this dump, then append it - will write the appended dump */ eval = makeAppended(ut, dump->id, dump->initialDumpID, dump->tapes.b); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); code = ubik_EndTrans(ut); LogDebug(5, "made dump %s, path %s\n", d.dumpName, d.dumpPath); @@ -1440,194 +1548,237 @@ afs_int32 CreateDump(call, dump) return code; } -afs_int32 SBUDB_DeleteDump (call, id, fromTime, toTime, dumps) +afs_int32 +SBUDB_DeleteDump(call, id, fromTime, toTime, dumps) struct rx_call *call; dumpId id; - Date fromTime; - Date toTime; + Date fromTime; + Date toTime; budb_dumpsList *dumps; { - afs_int32 code; + afs_int32 code; - code = DoDeleteDump (call, id, fromTime, toTime, dumps); - osi_auditU (call, BUDB_DelDmpEvent, code, AUD_DATE, id, AUD_END); - return code; + code = DoDeleteDump(call, id, fromTime, toTime, dumps); + osi_auditU(call, BUDB_DelDmpEvent, code, AUD_DATE, id, AUD_END); + return code; } #define MAXOFFS 30 -afs_int32 DoDeleteDump (call, id, fromTime, toTime, dumps) - struct rx_call *call; - dumpId id; - Date fromTime; - Date toTime; - budb_dumpsList *dumps; +afs_int32 +DoDeleteDump(call, id, fromTime, toTime, dumps) + struct rx_call *call; + dumpId id; + Date fromTime; + Date toTime; + budb_dumpsList *dumps; { - afs_int32 code = 0; + afs_int32 code = 0; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - if (id) code = deleteDump(call, id, dumps); - return(code); + if (id) + code = deleteDump(call, id, dumps); + return (code); } -afs_int32 SBUDB_ListDumps (call, sflags, name, groupid, fromTime, toTime, dumps, flags) - struct rx_call *call; - afs_int32 sflags, groupid; - char *name; - Date fromTime, toTime; - budb_dumpsList *dumps, *flags; +afs_int32 +SBUDB_ListDumps(call, sflags, name, groupid, fromTime, toTime, dumps, flags) + struct rx_call *call; + afs_int32 sflags, groupid; + char *name; + Date fromTime, toTime; + budb_dumpsList *dumps, *flags; { - afs_int32 code; + afs_int32 code; - code = ListDumps(call, sflags, groupid, fromTime, toTime, dumps, flags); - osi_auditU (call, BUDB_LstDmpEvent, code, AUD_LONG, flags, AUD_END); - return code; + code = ListDumps(call, sflags, groupid, fromTime, toTime, dumps, flags); + osi_auditU(call, BUDB_LstDmpEvent, code, AUD_LONG, flags, AUD_END); + return code; } -afs_int32 ListDumps (call, sflags, groupid, fromTime, toTime, dumps, flags) - struct rx_call *call; - afs_int32 sflags, groupid; - Date fromTime, toTime; - budb_dumpsList *dumps, *flags; +afs_int32 +ListDumps(call, sflags, groupid, fromTime, toTime, dumps, flags) + struct rx_call *call; + afs_int32 sflags, groupid; + Date fromTime, toTime; + budb_dumpsList *dumps, *flags; { - struct ubik_trans *ut; + struct ubik_trans *ut; struct memoryHashTable *mht; - struct dump diskDump, appDiskDump; - dbadr dbAddr, dbAppAddr; + struct dump diskDump, appDiskDump; + dbadr dbAddr, dbAppAddr; - afs_int32 eval, code = 0; - int old, hash, length, entrySize, j, k, count=0; - afs_uint32 toList, toFlag; + afs_int32 eval, code = 0; + int old, hash, length, entrySize, j, k, count = 0; + afs_uint32 toList, toFlag; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - eval= InitRPC (&ut, LOCKREAD, 1); - if (eval) return(eval); + eval = InitRPC(&ut, LOCKREAD, 1); + if (eval) + return (eval); /* Search the database */ mht = ht_GetType(HT_dumpIden_FUNCTION, &entrySize); - if (!mht) return(BUDB_BADARGUMENT); - - for (old=0; old<=1; old++) { /*o*/ /* old and new hash tables */ - length = (old ? mht->oldLength : mht->length); - if (length == 0) continue; - - for (hash=0; hash toTime)) - break; /*nope*/ + if (!mht) + return (BUDB_BADARGUMENT); + + for (old = 0; old <= 1; old++) { /*o *//* old and new hash tables */ + length = (old ? mht->oldLength : mht->length); + if (length == 0) + continue; + + for (hash = 0; hash < length; hash++) { /*h *//* for each hash bucket */ + for (dbAddr = ht_LookupBucket(ut, mht, hash, old); dbAddr; dbAddr = ntohl(diskDump.idHashChain)) { /*d */ + + /* read the entry */ + eval = dbread(ut, dbAddr, &diskDump, sizeof(diskDump)); + if (eval) + ABORT(eval); + + /* Skip appended dumps */ + if (ntohl(diskDump.initialDumpID) != 0) { + continue; } - if (dbAppAddr) continue; /*nope*/ - } - - /* Add it and each of its appended dump to our list to return */ - for (dbAppAddr=dbAddr; dbAppAddr; dbAppAddr=ntohl(appDiskDump.appendedDumpChain)) { - eval = dbread (ut, dbAppAddr, &appDiskDump, sizeof(appDiskDump)); - if (eval) ABORT(eval); - - /* Make sure we have space to list it */ - if (dumps->budb_dumpsList_len >= count) { - count += 10; - if (count == 10) { - dumps->budb_dumpsList_val = (afs_int32 *)malloc(count * sizeof(afs_int32)); - flags->budb_dumpsList_val = (afs_int32 *)malloc(count * sizeof(afs_int32)); - } else { - dumps->budb_dumpsList_val = - (afs_int32 *)realloc(dumps->budb_dumpsList_val, count*sizeof(afs_int32)); - flags->budb_dumpsList_val = - (afs_int32 *)realloc(flags->budb_dumpsList_val, count*sizeof(afs_int32)); - } - if (!dumps->budb_dumpsList_val || !dumps->budb_dumpsList_val) - ABORT(BUDB_NOMEM); + + /* Skip dumps with different goup id */ + if ((sflags & BUDB_OP_GROUPID) + && (ntohl(diskDump.tapes.id) != groupid)) { + continue; /*nope */ } - /* Add it to our list */ - dumps->budb_dumpsList_val[dumps->budb_dumpsList_len] = ntohl(appDiskDump.id); - flags->budb_dumpsList_val[flags->budb_dumpsList_len] = 0; - if ( ntohl(appDiskDump.initialDumpID) != 0 ) { - flags->budb_dumpsList_val[flags->budb_dumpsList_len] |= BUDB_OP_APPDUMP; + /* Look at this dump to see if it meets the criteria for listing */ + if (sflags & BUDB_OP_DATES) { + /* This and each appended dump should be in time */ + for (dbAppAddr = dbAddr; dbAppAddr; + dbAppAddr = ntohl(appDiskDump.appendedDumpChain)) { + eval = + dbread(ut, dbAppAddr, &appDiskDump, + sizeof(appDiskDump)); + if (eval) + ABORT(eval); + + if ((ntohl(appDiskDump.id) < fromTime) + || (ntohl(appDiskDump.id) > toTime)) + break; /*nope */ + } + if (dbAppAddr) + continue; /*nope */ } - if (strcmp(appDiskDump.dumpName,DUMP_TAPE_NAME) == 0) { - flags->budb_dumpsList_val[flags->budb_dumpsList_len] |= BUDB_OP_DBDUMP; + + /* Add it and each of its appended dump to our list to return */ + for (dbAppAddr = dbAddr; dbAppAddr; + dbAppAddr = ntohl(appDiskDump.appendedDumpChain)) { + eval = + dbread(ut, dbAppAddr, &appDiskDump, + sizeof(appDiskDump)); + if (eval) + ABORT(eval); + + /* Make sure we have space to list it */ + if (dumps->budb_dumpsList_len >= count) { + count += 10; + if (count == 10) { + dumps->budb_dumpsList_val = + (afs_int32 *) malloc(count * + sizeof(afs_int32)); + flags->budb_dumpsList_val = + (afs_int32 *) malloc(count * + sizeof(afs_int32)); + } else { + dumps->budb_dumpsList_val = + (afs_int32 *) realloc(dumps-> + budb_dumpsList_val, + count * + sizeof(afs_int32)); + flags->budb_dumpsList_val = + (afs_int32 *) realloc(flags-> + budb_dumpsList_val, + count * + sizeof(afs_int32)); + } + if (!dumps->budb_dumpsList_val + || !dumps->budb_dumpsList_val) + ABORT(BUDB_NOMEM); + } + + /* Add it to our list */ + dumps->budb_dumpsList_val[dumps->budb_dumpsList_len] = + ntohl(appDiskDump.id); + flags->budb_dumpsList_val[flags->budb_dumpsList_len] = 0; + if (ntohl(appDiskDump.initialDumpID) != 0) { + flags->budb_dumpsList_val[flags-> + budb_dumpsList_len] |= + BUDB_OP_APPDUMP; + } + if (strcmp(appDiskDump.dumpName, DUMP_TAPE_NAME) == 0) { + flags->budb_dumpsList_val[flags-> + budb_dumpsList_len] |= + BUDB_OP_DBDUMP; + } + dumps->budb_dumpsList_len++; + flags->budb_dumpsList_len++; } - dumps->budb_dumpsList_len++; - flags->budb_dumpsList_len++; - } - } /*d*/ - } /*h*/ - } /*o*/ - + } /*d */ + } /*h */ + } /*o */ + code = ubik_EndTrans(ut); - return(code); + return (code); abort_exit: ubik_AbortTrans(ut); - return(code); + return (code); } -afs_int32 SBUDB_DeleteTape (call, tape) - struct rx_call *call; - struct budb_tapeEntry *tape; /* tape info */ +afs_int32 +SBUDB_DeleteTape(call, tape) + struct rx_call *call; + struct budb_tapeEntry *tape; /* tape info */ { - afs_int32 code; + afs_int32 code; - code = DoDeleteTape (call, tape); - osi_auditU (call, BUDB_DelTpeEvent, code, AUD_DATE, (tape ? tape->dump : 0), AUD_END); - return code; + code = DoDeleteTape(call, tape); + osi_auditU(call, BUDB_DelTpeEvent, code, AUD_DATE, + (tape ? tape->dump : 0), AUD_END); + return code; } -afs_int32 DoDeleteTape (call, tape) - struct rx_call *call; - struct budb_tapeEntry *tape; /* tape info */ +afs_int32 +DoDeleteTape(call, tape) + struct rx_call *call; + struct budb_tapeEntry *tape; /* tape info */ { struct ubik_trans *ut; - struct tape t; - dbadr a; - afs_int32 eval, code; + struct tape t; + dbadr a; + afs_int32 eval, code; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - eval = InitRPC (&ut, LOCKWRITE, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKWRITE, 1); + if (eval) + return eval; - eval = ht_LookupEntry (ut, &db.tapeName, tape->name, &a, &t); - if (eval) ABORT(eval); + eval = ht_LookupEntry(ut, &db.tapeName, tape->name, &a, &t); + if (eval) + ABORT(eval); - eval = DeleteTape (ut, a, &t); - if (eval) ABORT(eval); + eval = DeleteTape(ut, a, &t); + if (eval) + ABORT(eval); - eval = FreeStructure (ut, tape_BLOCK, a); - if (eval) ABORT(eval); + eval = FreeStructure(ut, tape_BLOCK, a); + if (eval) + ABORT(eval); - eval = set_header_word (ut, lastUpdate, htonl(time(0))); - if (eval) ABORT(eval); + eval = set_header_word(ut, lastUpdate, htonl(time(0))); + if (eval) + ABORT(eval); code = ubik_EndTrans(ut); return code; @@ -1651,20 +1802,22 @@ afs_int32 DoDeleteTape (call, tape) * n - some error. May or may not have deleted information. */ -afs_int32 SBUDB_DeleteVDP (call, dsname, dumpPath, curDumpId) +afs_int32 +SBUDB_DeleteVDP(call, dsname, dumpPath, curDumpId) struct rx_call *call; char *dsname; char *dumpPath; afs_int32 curDumpId; { - afs_int32 code; + afs_int32 code; - code = DeleteVDP (call, dsname, dumpPath, curDumpId); - osi_auditU (call, BUDB_DelVDPEvent, code, AUD_STR, dsname, AUD_END); - return code; + code = DeleteVDP(call, dsname, dumpPath, curDumpId); + osi_auditU(call, BUDB_DelVDPEvent, code, AUD_STR, dsname, AUD_END); + return code; } -afs_int32 DeleteVDP (call, dsname, dumpPath, curDumpId) +afs_int32 +DeleteVDP(call, dsname, dumpPath, curDumpId) struct rx_call *call; char *dsname; char *dumpPath; @@ -1672,32 +1825,33 @@ afs_int32 DeleteVDP (call, dsname, dumpPath, curDumpId) { struct dump dump; dbadr dumpAddr; - + struct ubik_trans *ut; - afs_int32 eval, code = 0; + afs_int32 eval, code = 0; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - while (1) - { - eval = InitRPC (&ut, LOCKREAD, 1); - if (eval) return(eval); + while (1) { + eval = InitRPC(&ut, LOCKREAD, 1); + if (eval) + return (eval); eval = ht_LookupEntry(ut, &db.dumpName, dsname, &dumpAddr, &dump); - if (eval) ABORT(eval); - - while ( dumpAddr != 0 ) - { /*wd*/ - if ( (strcmp(dump.dumpName, dsname) == 0) && - (strcmp(dump.dumpPath, dumpPath) == 0) && - (ntohl(dump.id) != curDumpId) ) - { + if (eval) + ABORT(eval); + + while (dumpAddr != 0) { /*wd */ + if ((strcmp(dump.dumpName, dsname) == 0) + && (strcmp(dump.dumpPath, dumpPath) == 0) + && (ntohl(dump.id) != curDumpId)) { eval = ubik_EndTrans(ut); - if (eval) return(eval); + if (eval) + return (eval); eval = deleteDump(call, ntohl(dump.id), 0); - if (eval) return(eval); + if (eval) + return (eval); /* start the traversal over since the various chains may * have changed @@ -1706,24 +1860,23 @@ afs_int32 DeleteVDP (call, dsname, dumpPath, curDumpId) } dumpAddr = ntohl(dump.nameHashChain); - if (dumpAddr) - { + if (dumpAddr) { eval = dbread(ut, dumpAddr, &dump, sizeof(dump)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); } - } /*wd*/ + } /*wd */ /* check if all the dumps have been examined - can terminate */ - if (!dumpAddr) - { + if (!dumpAddr) { eval = ubik_EndTrans(ut); - return(eval); + return (eval); } } abort_exit: ubik_AbortTrans(ut); - return(code); + return (code); } /* BUDB_FindClone @@ -1737,92 +1890,97 @@ afs_int32 DeleteVDP (call, dsname, dumpPath, curDumpId) * volume is not found in the dump, then look for it in its parent dump. */ -afs_int32 SBUDB_FindClone(call, dumpID, volName, clonetime) +afs_int32 +SBUDB_FindClone(call, dumpID, volName, clonetime) struct rx_call *call; afs_int32 dumpID; char *volName; afs_int32 *clonetime; { - afs_int32 code; + afs_int32 code; - code = FindClone (call, dumpID, volName, clonetime); - osi_auditU (call, BUDB_FndClnEvent, code, AUD_STR, volName, AUD_END); - return code; + code = FindClone(call, dumpID, volName, clonetime); + osi_auditU(call, BUDB_FndClnEvent, code, AUD_STR, volName, AUD_END); + return code; } -afs_int32 FindClone (call, dumpID, volName, clonetime) +afs_int32 +FindClone(call, dumpID, volName, clonetime) struct rx_call *call; afs_int32 dumpID; char *volName; afs_int32 *clonetime; { - struct ubik_trans *ut; - dbadr da, ta, hvia, via, vfa; - struct dump d; - struct tape t; + struct ubik_trans *ut; + dbadr da, ta, hvia, via, vfa; + struct dump d; + struct tape t; struct volFragment vf; - struct volInfo vi; - int rvi; /* read the volInfo struct */ - afs_int32 eval, code = 0; + struct volInfo vi; + int rvi; /* read the volInfo struct */ + afs_int32 eval, code = 0; - if ( !callPermitted(call) ) - return BUDB_NOTPERMITTED; + if (!callPermitted(call)) + return BUDB_NOTPERMITTED; - eval = InitRPC (&ut, LOCKREAD, 1); - if (eval) return(eval); + eval = InitRPC(&ut, LOCKREAD, 1); + if (eval) + return (eval); *clonetime = 0; /* Search for the volume by name */ - eval = ht_LookupEntry (ut, &db.volName, volName, &hvia, &vi); - if (eval) ABORT(eval); - if (!hvia) ABORT(BUDB_NOVOLUMENAME); + eval = ht_LookupEntry(ut, &db.volName, volName, &hvia, &vi); + if (eval) + ABORT(eval); + if (!hvia) + ABORT(BUDB_NOVOLUMENAME); rvi = 0; /* Follw the dump levels up */ - for (; dumpID; dumpID = ntohl(d.parent)) - { /*d*/ + for (; dumpID; dumpID = ntohl(d.parent)) { /*d */ /* Get the dump entry */ - eval = ht_LookupEntry (ut, &db.dumpIden, &dumpID, &da, &d); - if (eval) ABORT(eval); - if (!da) ABORT(BUDB_NODUMPID); - + eval = ht_LookupEntry(ut, &db.dumpIden, &dumpID, &da, &d); + if (eval) + ABORT(eval); + if (!da) + ABORT(BUDB_NODUMPID); + /* seach all the volInfo entries on the sameNameChain */ - for (via=hvia; via; via=ntohl(vi.sameNameChain)) - { /*via*/ - if (rvi) /* Read the volInfo entry - except first time */ - { - eval = dbread(ut, via, &vi, sizeof(vi)); - if (eval) ABORT(eval); + for (via = hvia; via; via = ntohl(vi.sameNameChain)) { /*via */ + if (rvi) { /* Read the volInfo entry - except first time */ + eval = dbread(ut, via, &vi, sizeof(vi)); + if (eval) + ABORT(eval); } rvi = 1; /* search all the volFrag entries on the volFrag */ - for (vfa=ntohl(vi.firstFragment); vfa; vfa=ntohl(vf.sameNameChain)) - { /*vfa*/ - eval = dbread(ut, vfa, &vf, sizeof(vf)); /* Read the volFrag entry */ - if (eval) ABORT(eval); + for (vfa = ntohl(vi.firstFragment); vfa; vfa = ntohl(vf.sameNameChain)) { /*vfa */ + eval = dbread(ut, vfa, &vf, sizeof(vf)); /* Read the volFrag entry */ + if (eval) + ABORT(eval); - eval = dbread(ut, ntohl(vf.tape), &t, sizeof(t)); /* Read the tape */ - if (eval) ABORT(eval); + eval = dbread(ut, ntohl(vf.tape), &t, sizeof(t)); /* Read the tape */ + if (eval) + ABORT(eval); /* Now check to see if this fragment belongs to the dump we have */ - if (ntohl(t.dump) == da) - { - *clonetime = ntohl(vf.clone); /* return the clone */ + if (ntohl(t.dump) == da) { + *clonetime = ntohl(vf.clone); /* return the clone */ ERROR(0); } - } /*vfa*/ - } /*via*/ - } /*d*/ + } /*vfa */ + } /*via */ + } /*d */ error_exit: code = ubik_EndTrans(ut); - return(code); + return (code); abort_exit: ubik_EndTrans(ut); - return(code); + return (code); } #ifdef notdef @@ -1832,78 +1990,84 @@ afs_int32 FindClone (call, dumpID, volName, clonetime) * * Re-write to do lookups by volume name. */ -afs_int32 FindClone (call, dumpID, volName, clonetime) +afs_int32 +FindClone(call, dumpID, volName, clonetime) struct rx_call *call; afs_int32 dumpID; char *volName; afs_int32 *clonetime; { - struct ubik_trans *ut; - dbadr diskAddr, tapeAddr, volFragmentAddr; - struct dump dump; - struct tape tape; + struct ubik_trans *ut; + dbadr diskAddr, tapeAddr, volFragmentAddr; + struct dump dump; + struct tape tape; struct volFragment volFragment; - struct volInfo volInfo; - afs_int32 eval, code = 0; + struct volInfo volInfo; + afs_int32 eval, code = 0; - if ( !callPermitted(call) ) - return BUDB_NOTPERMITTED; + if (!callPermitted(call)) + return BUDB_NOTPERMITTED; - eval = InitRPC (&ut, LOCKREAD, 1); - if (eval) return(eval); + eval = InitRPC(&ut, LOCKREAD, 1); + if (eval) + return (eval); *clonetime = 0; - for (; dumpID; dumpID = ntohl(dump.parent)) - { /*d*/ + for (; dumpID; dumpID = ntohl(dump.parent)) { /*d */ /* Get the dump entry */ - eval = ht_LookupEntry (ut, &db.dumpIden, &dumpID, &diskAddr, &dump); - if (eval) ABORT(eval); - if (!diskAddr) ABORT(BUDB_NODUMPID); - + eval = ht_LookupEntry(ut, &db.dumpIden, &dumpID, &diskAddr, &dump); + if (eval) + ABORT(eval); + if (!diskAddr) + ABORT(BUDB_NODUMPID); + /* just to be sure */ - if (ntohl(dump.id) != dumpID) - { - LogDebug(4, "BUDB_FindClone: requested %d, found %d\n", dumpID, ntohl(dump.id)); + if (ntohl(dump.id) != dumpID) { + LogDebug(4, "BUDB_FindClone: requested %d, found %d\n", dumpID, + ntohl(dump.id)); ABORT(BUDB_INTERNALERROR); } - + /* search all the tapes in this dump */ - for (tapeAddr=ntohl(dump.firstTape); tapeAddr; tapeAddr=ntohl(tape.nextTape)) - { /*t*/ + for (tapeAddr = ntohl(dump.firstTape); tapeAddr; tapeAddr = ntohl(tape.nextTape)) { /*t */ /* Get the tape entry */ eval = dbread(ut, tapeAddr, &tape, sizeof(tape)); - if (eval) ABORT(eval); - + if (eval) + ABORT(eval); + /* search all the volume fragments on this tape */ - for (volFragmentAddr=ntohl(tape.firstVol); volFragmentAddr; - volFragmentAddr=ntohl(volFragment.sameTapeChain)) - { /*vf*/ + for (volFragmentAddr = ntohl(tape.firstVol); volFragmentAddr; volFragmentAddr = ntohl(volFragment.sameTapeChain)) { /*vf */ /* Get the volume fragment entry */ - eval = dbread(ut, volFragmentAddr, &volFragment, sizeof(volFragment)); - if (eval) ABORT(eval); + eval = + dbread(ut, volFragmentAddr, &volFragment, + sizeof(volFragment)); + if (eval) + ABORT(eval); /* Get the volume info entry */ - eval = dbread(ut, ntohl(volFragment.vol), &volInfo, sizeof(volInfo)); - if (eval) ABORT(eval); + eval = + dbread(ut, ntohl(volFragment.vol), &volInfo, + sizeof(volInfo)); + if (eval) + ABORT(eval); /* check if this volume is the one we want */ - if ( strcmp(volInfo.name,volName) == 0 ) - { + if (strcmp(volInfo.name, volName) == 0) { *clonetime = ntohl(volFragment.clone); ERROR(0); } - } /*vf*/ - } /*t*/ - } /*d*/ + } /*vf */ + } /*t */ + } /*d */ error_exit: code = ubik_EndTrans(ut); - return(code); + return (code); abort_exit: ubik_EndTrans(ut); - return(code); + return (code); } #endif @@ -1917,93 +2081,104 @@ afs_int32 FindClone (call, dumpID, volName, clonetime) * deptr - descriptor of most recent dump */ -afs_int32 SBUDB_FindDump (call, volumeName, beforeDate, deptr) +afs_int32 +SBUDB_FindDump(call, volumeName, beforeDate, deptr) struct rx_call *call; char *volumeName; afs_int32 beforeDate; struct budb_dumpEntry *deptr; { - afs_int32 code; + afs_int32 code; - code = FindDump (call, volumeName, beforeDate, deptr); - osi_auditU (call, BUDB_FndDmpEvent, code, AUD_STR, volumeName, AUD_END); - return code; + code = FindDump(call, volumeName, beforeDate, deptr); + osi_auditU(call, BUDB_FndDmpEvent, code, AUD_STR, volumeName, AUD_END); + return code; } -afs_int32 FindDump (call, volumeName, beforeDate, deptr) +afs_int32 +FindDump(call, volumeName, beforeDate, deptr) struct rx_call *call; char *volumeName; afs_int32 beforeDate; struct budb_dumpEntry *deptr; { - struct ubik_trans *ut; - dbadr volInfoAddr, volFragmentAddr; - struct tape tape; - struct volInfo volInfo; + struct ubik_trans *ut; + dbadr volInfoAddr, volFragmentAddr; + struct tape tape; + struct volInfo volInfo; struct volFragment volFragment; dbadr selectedDumpAddr = 0; - afs_int32 selectedDate = 0; + afs_int32 selectedDate = 0; afs_int32 volCloned; - int rvoli; + int rvoli; afs_int32 eval, code = 0; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - eval = InitRPC (&ut, LOCKREAD, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKREAD, 1); + if (eval) + return eval; /* Find volinfo struct for volume name in hash table */ - eval = ht_LookupEntry (ut, &db.volName, volumeName, &volInfoAddr, &volInfo); - if (eval) ABORT(eval); - if (!volInfoAddr) ABORT(BUDB_NOVOLUMENAME); + eval = + ht_LookupEntry(ut, &db.volName, volumeName, &volInfoAddr, &volInfo); + if (eval) + ABORT(eval); + if (!volInfoAddr) + ABORT(BUDB_NOVOLUMENAME); /* Step through all the volinfo structures on the same name chain. * No need to read the first - we read it above. */ - for (rvoli=0; volInfoAddr; rvoli=1, volInfoAddr=ntohl(volInfo.sameNameChain)) - { - if (rvoli) /* read the volinfo structure */ - { + for (rvoli = 0; volInfoAddr; + rvoli = 1, volInfoAddr = ntohl(volInfo.sameNameChain)) { + if (rvoli) { /* read the volinfo structure */ eval = dbread(ut, volInfoAddr, &volInfo, sizeof(volInfo)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); } - + /* step through the volfrag structures */ - for (volFragmentAddr=ntohl(volInfo.firstFragment); volFragmentAddr; - volFragmentAddr=ntohl(volFragment.sameNameChain)) - { + for (volFragmentAddr = ntohl(volInfo.firstFragment); volFragmentAddr; + volFragmentAddr = ntohl(volFragment.sameNameChain)) { /* read the volfrag struct */ - eval = dbread(ut, volFragmentAddr, &volFragment, sizeof(volFragment)); - if (eval) ABORT(eval); + eval = + dbread(ut, volFragmentAddr, &volFragment, + sizeof(volFragment)); + if (eval) + ABORT(eval); volCloned = ntohl(volFragment.clone); /* now we can examine the date for most recent dump */ - if ( (volCloned > selectedDate) && (volCloned < beforeDate) ) - { + if ((volCloned > selectedDate) && (volCloned < beforeDate)) { /* from the volfrag struct, read the tape struct */ - eval = dbread(ut, ntohl(volFragment.tape), &tape, sizeof(tape)); - if (eval) ABORT(eval); + eval = + dbread(ut, ntohl(volFragment.tape), &tape, sizeof(tape)); + if (eval) + ABORT(eval); - selectedDate = volCloned; + selectedDate = volCloned; selectedDumpAddr = ntohl(tape.dump); } } } - if (!selectedDumpAddr) ABORT(BUDB_NOENT); + if (!selectedDumpAddr) + ABORT(BUDB_NOENT); eval = FillDumpEntry(ut, selectedDumpAddr, deptr); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); code = ubik_EndTrans(ut); - return(code); + return (code); abort_exit: ubik_EndTrans(ut); - return(code); + return (code); } /* BUDB_FindLatestDump @@ -2013,183 +2188,196 @@ afs_int32 FindDump (call, volumeName, beforeDate, deptr) * dname - dumpname */ -afs_int32 SBUDB_FindLatestDump (call, vsname, dumpPath, dumpentry) +afs_int32 +SBUDB_FindLatestDump(call, vsname, dumpPath, dumpentry) struct rx_call *call; - char *vsname, *dumpPath; - struct budb_dumpEntry *dumpentry; + char *vsname, *dumpPath; + struct budb_dumpEntry *dumpentry; { - afs_int32 code; + afs_int32 code; - code = FindLatestDump (call, vsname, dumpPath, dumpentry); - osi_auditU (call, BUDB_FndLaDEvent, code, AUD_STR, vsname, AUD_END); - return code; + code = FindLatestDump(call, vsname, dumpPath, dumpentry); + osi_auditU(call, BUDB_FndLaDEvent, code, AUD_STR, vsname, AUD_END); + return code; } -afs_int32 FindLatestDump (call, vsname, dumpPath, dumpentry) +afs_int32 +FindLatestDump(call, vsname, dumpPath, dumpentry) struct rx_call *call; - char *vsname, *dumpPath; - struct budb_dumpEntry *dumpentry; + char *vsname, *dumpPath; + struct budb_dumpEntry *dumpentry; { struct ubik_trans *ut; - dbadr curdbaddr, retdbaddr, firstdbaddr; - struct dump d; - Date latest; - char dumpName[BU_MAXNAMELEN+2]; - afs_int32 eval, code = 0; + dbadr curdbaddr, retdbaddr, firstdbaddr; + struct dump d; + Date latest; + char dumpName[BU_MAXNAMELEN + 2]; + afs_int32 eval, code = 0; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; eval = InitRPC(&ut, LOCKREAD, 1); - if (eval) return(eval); + if (eval) + return (eval); - if ( (strcmp(vsname,"") == 0) && (strcmp(dumpPath,"") == 0) ) - { - /* Construct a database dump name */ + if ((strcmp(vsname, "") == 0) && (strcmp(dumpPath, "") == 0)) { + /* Construct a database dump name */ strcpy(dumpName, DUMP_TAPE_NAME); - } - else if (strchr(dumpPath,'/') == 0) { - int level, old, length, hash; - struct dump hostDump, diskDump; + } else if (strchr(dumpPath, '/') == 0) { + int level, old, length, hash; + struct dump hostDump, diskDump; struct memoryHashTable *mht; - int entrySize; - dbadr dbAddr; - afs_uint32 bestDumpId=0; + int entrySize; + dbadr dbAddr; + afs_uint32 bestDumpId = 0; - level = atoi(dumpPath); + level = atoi(dumpPath); if (level < 0) { - ABORT(BUDB_BADARGUMENT); + ABORT(BUDB_BADARGUMENT); } - + /* Brute force search of all the dumps in the database - yuck! */ retdbaddr = 0; mht = ht_GetType(HT_dumpIden_FUNCTION, &entrySize); - if (!mht) ABORT(BUDB_BADARGUMENT); + if (!mht) + ABORT(BUDB_BADARGUMENT); - for (old=0; old <= 1; old++) { /*fo*/ + for (old = 0; old <= 1; old++) { /*fo */ length = (old ? mht->oldLength : mht->length); - if (!length) continue; - - for (hash=0; hash bestDumpId) ) { /* more recent */ + if ((strcmp(hostDump.volumeSet, vsname) == 0) && /* the volumeset */ + (hostDump.level == level) && /* same level */ + (hostDump.id > bestDumpId)) { /* more recent */ bestDumpId = hostDump.id; - retdbaddr = dbAddr; + retdbaddr = dbAddr; } - } /*w*/ - } /*f*/ - } /*fo*/ + } /*w */ + } /*f */ + } /*fo */ if (!retdbaddr) - ABORT(BUDB_NODUMPNAME); + ABORT(BUDB_NODUMPNAME); goto finished; - } - else - { - /* construct the name of the dump */ - if ( (strlen(vsname) + strlen(tailCompPtr(dumpPath))) > BU_MAXNAMELEN ) + } else { + /* construct the name of the dump */ + if ((strlen(vsname) + strlen(tailCompPtr(dumpPath))) > BU_MAXNAMELEN) ABORT(BUDB_NODUMPNAME); strcpy(dumpName, vsname); strcat(dumpName, "."); strcat(dumpName, tailCompPtr(dumpPath)); } - + LogDebug(5, "lookup on :%s:\n", dumpName); - + /* Lookup on dumpname in hash table */ eval = ht_LookupEntry(ut, &db.dumpName, dumpName, &firstdbaddr, &d); - if (eval) ABORT(eval); - - latest = 0; + if (eval) + ABORT(eval); + + latest = 0; retdbaddr = 0; /* folow remaining dumps in hash chain, looking for most latest dump */ - for (curdbaddr=firstdbaddr; curdbaddr; curdbaddr=ntohl(d.nameHashChain)) - { - if (curdbaddr != firstdbaddr) { - eval = dbread(ut, curdbaddr, &d, sizeof(d)); - if (eval) ABORT(eval); + for (curdbaddr = firstdbaddr; curdbaddr; + curdbaddr = ntohl(d.nameHashChain)) { + if (curdbaddr != firstdbaddr) { + eval = dbread(ut, curdbaddr, &d, sizeof(d)); + if (eval) + ABORT(eval); } - if ( (strcmp(d.dumpPath, dumpPath) == 0) && /* Same dumppath */ - (strcmp(d.dumpName, dumpName) == 0) && /* Same dumpname */ - (ntohl(d.created) > latest) ) /* most recent */ - { - latest = ntohl(d.created); + if ((strcmp(d.dumpPath, dumpPath) == 0) && /* Same dumppath */ + (strcmp(d.dumpName, dumpName) == 0) && /* Same dumpname */ + (ntohl(d.created) > latest)) { /* most recent */ + latest = ntohl(d.created); retdbaddr = curdbaddr; } } - if (!retdbaddr) ABORT(BUDB_NODUMPNAME); + if (!retdbaddr) + ABORT(BUDB_NODUMPNAME); finished: /* return the dump found */ FillDumpEntry(ut, retdbaddr, dumpentry); code = ubik_EndTrans(ut); - return(code); + return (code); abort_exit: ubik_AbortTrans(ut); - return(code); + return (code); } -afs_int32 SBUDB_FinishDump (call, dump) - struct rx_call *call; - struct budb_dumpEntry *dump; +afs_int32 +SBUDB_FinishDump(call, dump) + struct rx_call *call; + struct budb_dumpEntry *dump; { - afs_int32 code; + afs_int32 code; - code = FinishDump (call, dump); - osi_auditU (call, BUDB_FinDmpEvent, code, AUD_DATE, (dump ? dump->id : 0), AUD_END); - return code; + code = FinishDump(call, dump); + osi_auditU(call, BUDB_FinDmpEvent, code, AUD_DATE, (dump ? dump->id : 0), + AUD_END); + return code; } -afs_int32 FinishDump (call, dump) - struct rx_call *call; - struct budb_dumpEntry *dump; +afs_int32 +FinishDump(call, dump) + struct rx_call *call; + struct budb_dumpEntry *dump; { struct ubik_trans *ut; - dbadr a; - struct dump d; - afs_int32 eval, code = 0; + dbadr a; + struct dump d; + afs_int32 eval, code = 0; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; eval = InitRPC(&ut, LOCKWRITE, 1); - if (eval) return eval; + if (eval) + return eval; - eval = ht_LookupEntry (ut, &db.dumpIden, &dump->id, &a, &d); - if (eval) ABORT(eval); - if (!a) ABORT(BUDB_NODUMPID); + eval = ht_LookupEntry(ut, &db.dumpIden, &dump->id, &a, &d); + if (eval) + ABORT(eval); + if (!a) + ABORT(BUDB_NODUMPID); if ((ntohl(d.flags) & BUDB_DUMP_INPROGRESS) == 0) - ABORT(BUDB_DUMPNOTINUSE); + ABORT(BUDB_DUMPNOTINUSE); d.flags = htonl(dump->flags & ~BUDB_DUMP_INPROGRESS); /* if creation time specified set it */ - if (dump->created) d.created = htonl(dump->created); + if (dump->created) + d.created = htonl(dump->created); dump->created = ntohl(d.created); /* Write the dump entry out */ eval = dbwrite(ut, a, &d, sizeof(d)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); eval = set_header_word(ut, lastUpdate, htonl(time(0))); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); code = ubik_EndTrans(ut); return code; @@ -2199,68 +2387,79 @@ afs_int32 FinishDump (call, dump) return code; } -afs_int32 SBUDB_FinishTape (call, tape) - struct rx_call *call; - struct budb_tapeEntry *tape; +afs_int32 +SBUDB_FinishTape(call, tape) + struct rx_call *call; + struct budb_tapeEntry *tape; { - afs_int32 code; + afs_int32 code; - code = FinishTape (call, tape); - osi_auditU (call, BUDB_FinTpeEvent, code, AUD_DATE, (tape ? tape->dump : 0), AUD_END); - return code; + code = FinishTape(call, tape); + osi_auditU(call, BUDB_FinTpeEvent, code, AUD_DATE, + (tape ? tape->dump : 0), AUD_END); + return code; } -afs_int32 FinishTape (call, tape) - struct rx_call *call; - struct budb_tapeEntry *tape; +afs_int32 +FinishTape(call, tape) + struct rx_call *call; + struct budb_tapeEntry *tape; { struct ubik_trans *ut; - dbadr a; - struct tape t; - struct dump d; - afs_int32 eval, code = 0; + dbadr a; + struct tape t; + struct dump d; + afs_int32 eval, code = 0; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - eval = InitRPC (&ut, LOCKWRITE, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKWRITE, 1); + if (eval) + return eval; /* find the tape struct in the tapename hash chain */ - eval = ht_LookupEntry (ut, &db.tapeName, tape->name, &a, &t); - if (eval) ABORT(eval); - if (!a) ABORT(BUDB_NOTAPENAME); + eval = ht_LookupEntry(ut, &db.tapeName, tape->name, &a, &t); + if (eval) + ABORT(eval); + if (!a) + ABORT(BUDB_NOTAPENAME); /* Read the dump structure */ - eval = dbread(ut, ntohl(t.dump), &d, sizeof(d)); - if (eval) ABORT(eval); + eval = dbread(ut, ntohl(t.dump), &d, sizeof(d)); + if (eval) + ABORT(eval); /* search for the right tape on the rest of the chain */ - while (ntohl(d.id) != tape->dump) - { + while (ntohl(d.id) != tape->dump) { a = ntohl(t.nameHashChain); - if (!a) ABORT(BUDB_NOTAPENAME); + if (!a) + ABORT(BUDB_NOTAPENAME); eval = dbread(ut, a, &t, sizeof(t)); - if (eval) ABORT(eval); - + if (eval) + ABORT(eval); + eval = dbread(ut, ntohl(t.dump), &d, sizeof(d)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); } - if ( (ntohl(t.flags) & BUDB_TAPE_BEINGWRITTEN) == 0 ) - ABORT(BUDB_TAPENOTINUSE); + if ((ntohl(t.flags) & BUDB_TAPE_BEINGWRITTEN) == 0) + ABORT(BUDB_TAPENOTINUSE); /* t.nBytes = htonl(tape->nBytes); */ - t.nFiles = htonl(tape->nFiles); + t.nFiles = htonl(tape->nFiles); t.useKBytes = htonl(tape->useKBytes); - t.flags = htonl(tape->flags & ~BUDB_TAPE_BEINGWRITTEN); + t.flags = htonl(tape->flags & ~BUDB_TAPE_BEINGWRITTEN); eval = dbwrite(ut, a, &t, sizeof(t)); - if (eval) ABORT(BUDB_IO); + if (eval) + ABORT(BUDB_IO); - eval = set_header_word (ut, lastUpdate, htonl(time(0))); - if (eval) ABORT(eval); + eval = set_header_word(ut, lastUpdate, htonl(time(0))); + if (eval) + ABORT(eval); code = ubik_EndTrans(ut); return code; @@ -2269,7 +2468,7 @@ afs_int32 FinishTape (call, tape) ubik_AbortTrans(ut); return code; } - + /* BUDB_GetDumps * return a set of dumps that match the specified criteria * entry: @@ -2295,102 +2494,110 @@ afs_int32 FinishTape (call, tape) * BUDB_OP_DUMPID */ -afs_int32 SBUDB_GetDumps (call, majorVersion, flags, name, start, end, - index, nextIndexP, dbTimeP, dumps) - struct rx_call *call; - afs_int32 majorVersion; /* version of interface structures */ - afs_int32 flags; /* search & select controls */ - char *name; /* s&s parameters */ - afs_int32 start; - afs_int32 end; - afs_int32 index; /* start index of returned entries */ - afs_int32 *nextIndexP; /* output index for next call */ - afs_int32 *dbTimeP; - budb_dumpList *dumps; /* pointer to buffer */ -{ - afs_int32 code; - - code = GetDumps (call, majorVersion, flags, name, start, end, - index, nextIndexP, dbTimeP, dumps); - osi_auditU (call, BUDB_GetDmpEvent, code, AUD_END); - return code; -} - -afs_int32 GetDumps (call, majorVersion, flags, name, start, end, - index, nextIndexP, dbTimeP, dumps) - struct rx_call *call; - afs_int32 majorVersion; /* version of interface structures */ - afs_int32 flags; /* search & select controls */ - char *name; /* s&s parameters */ - afs_int32 start; - afs_int32 end; - afs_int32 index; /* start index of returned entries */ - afs_int32 *nextIndexP; /* output index for next call */ - afs_int32 *dbTimeP; - budb_dumpList *dumps; /* pointer to buffer */ -{ +afs_int32 +SBUDB_GetDumps(call, majorVersion, flags, name, start, end, index, nextIndexP, + dbTimeP, dumps) + struct rx_call *call; + afs_int32 majorVersion; /* version of interface structures */ + afs_int32 flags; /* search & select controls */ + char *name; /* s&s parameters */ + afs_int32 start; + afs_int32 end; + afs_int32 index; /* start index of returned entries */ + afs_int32 *nextIndexP; /* output index for next call */ + afs_int32 *dbTimeP; + budb_dumpList *dumps; /* pointer to buffer */ +{ + afs_int32 code; + + code = + GetDumps(call, majorVersion, flags, name, start, end, index, + nextIndexP, dbTimeP, dumps); + osi_auditU(call, BUDB_GetDmpEvent, code, AUD_END); + return code; +} + +afs_int32 +GetDumps(call, majorVersion, flags, name, start, end, index, nextIndexP, + dbTimeP, dumps) + struct rx_call *call; + afs_int32 majorVersion; /* version of interface structures */ + afs_int32 flags; /* search & select controls */ + char *name; /* s&s parameters */ + afs_int32 start; + afs_int32 end; + afs_int32 index; /* start index of returned entries */ + afs_int32 *nextIndexP; /* output index for next call */ + afs_int32 *dbTimeP; + budb_dumpList *dumps; /* pointer to buffer */ +{ struct ubik_trans *ut; - dbadr da; - struct dump d; - afs_int32 nameFlags, startFlags, endFlags, timeFlags; - afs_int32 eval, code = 0; - afs_int32 toskip; + dbadr da; + struct dump d; + afs_int32 nameFlags, startFlags, endFlags, timeFlags; + afs_int32 eval, code = 0; + afs_int32 toskip; struct returnList list; /* Don't check permissions when we look up a specific dump id */ - if ( ((flags & BUDB_OP_STARTS) != BUDB_OP_DUMPID) && !callPermitted(call) ) + if (((flags & BUDB_OP_STARTS) != BUDB_OP_DUMPID) && !callPermitted(call)) return BUDB_NOTPERMITTED; - if (majorVersion != BUDB_MAJORVERSION) return BUDB_OLDINTERFACE; - if (index < 0) return BUDB_ENDOFLIST; + if (majorVersion != BUDB_MAJORVERSION) + return BUDB_OLDINTERFACE; + if (index < 0) + return BUDB_ENDOFLIST; - eval = InitRPC (&ut, LOCKREAD, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKREAD, 1); + if (eval) + return eval; - nameFlags = flags & BUDB_OP_NAMES; + nameFlags = flags & BUDB_OP_NAMES; startFlags = flags & BUDB_OP_STARTS; - endFlags = flags & BUDB_OP_ENDS; - timeFlags = flags & BUDB_OP_TIMES; + endFlags = flags & BUDB_OP_ENDS; + timeFlags = flags & BUDB_OP_TIMES; - InitReturnList (&list); + InitReturnList(&list); toskip = index; - if (nameFlags == BUDB_OP_DUMPNAME) - { + if (nameFlags == BUDB_OP_DUMPNAME) { /* not yet implemented */ - if (startFlags || endFlags || timeFlags) ABORT(BUDB_BADFLAGS); - - eval = ht_LookupEntry (ut, &db.dumpName, name, &da, &d); - if (eval) ABORT(eval); - if (!da) ABORT(BUDB_NODUMPNAME); - - while (1) - { - if (strcmp (d.dumpName, name) == 0) - { - eval = AddToReturnList (&list, da, &toskip); - if (eval == BUDB_LIST2BIG) break; - if (eval) ABORT(eval); + if (startFlags || endFlags || timeFlags) + ABORT(BUDB_BADFLAGS); + + eval = ht_LookupEntry(ut, &db.dumpName, name, &da, &d); + if (eval) + ABORT(eval); + if (!da) + ABORT(BUDB_NODUMPNAME); + + while (1) { + if (strcmp(d.dumpName, name) == 0) { + eval = AddToReturnList(&list, da, &toskip); + if (eval == BUDB_LIST2BIG) + break; + if (eval) + ABORT(eval); } da = ntohl(d.nameHashChain); /* get next dump w/ name */ - if (!da) break; + if (!da) + break; - eval = dbread (ut, da, &d, sizeof(d)); - if (eval) ABORT(eval); + eval = dbread(ut, da, &d, sizeof(d)); + if (eval) + ABORT(eval); } - } - else - if ( nameFlags == BUDB_OP_VOLUMENAME ) - { + } else if (nameFlags == BUDB_OP_VOLUMENAME) { #ifdef PA struct volInfo vi; - + LogError(0, "NYI, BUDB_OP_VOLUMENAME\n"); ABORT(BUDB_BADFLAGS); - if (startFlags != BUDB_OP_STARTTIME) ABORT(BUDB_BADFLAGS); + if (startFlags != BUDB_OP_STARTTIME) + ABORT(BUDB_BADFLAGS); /* lookup a dump by volumename and time stamp. Find the most recent * dump of the specified volumename, that occured before the supplied @@ -2399,31 +2606,32 @@ afs_int32 GetDumps (call, majorVersion, flags, name, start, end, /* get us a volInfo for name */ eval = ht_LookupEntry(ut, &db.volName, name, &da, &vi); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); - while (1) - { + while (1) { /* now iterate over all the entries of this name */ - for ( va = vi.firstFragment; va != 0; va = v.sameNameChain ) - { + for (va = vi.firstFragment; va != 0; va = v.sameNameChain) { va = ntohl(va); eval = dbread(ut, va, &v, sizeof(v)); - if (eval) ABORT(eval); - - if date on fragment > date - ignore it - too recent; - - if ( date on fragment < date && date on fragment > bestfound ) - bestfound = date on fragment; - - } /* for va */ + if (eval) + ABORT(eval); + + if date + on fragment > date ignore it - too recent; + + if (date on fragment < date && date on fragment > bestfound) + bestfound = date on fragment; + + } /* for va */ da = vi.sameNameChain; - if ( da == 0 ) - break; + if (da == 0) + break; da = ntohl(da); eval = dbread(ut, da, &vi, sizeof(vi)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); } /* @@ -2435,22 +2643,23 @@ afs_int32 GetDumps (call, majorVersion, flags, name, start, end, */ #endif /* PA */ - - } - else if (startFlags == BUDB_OP_DUMPID) - { - if (endFlags || timeFlags) ABORT(BUDB_BADFLAGS); - if (nameFlags) ABORT(BUDB_BADFLAGS); /* NYI */ - - eval = ht_LookupEntry (ut, &db.dumpIden, &start, &da, &d); - if (eval) ABORT(eval); - if (!da) ABORT(BUDB_NODUMPID); - - eval = AddToReturnList (&list, da, &toskip); - if (eval) ABORT(eval); - } - else if (endFlags == BUDB_OP_NPREVIOUS) - { + + } else if (startFlags == BUDB_OP_DUMPID) { + if (endFlags || timeFlags) + ABORT(BUDB_BADFLAGS); + if (nameFlags) + ABORT(BUDB_BADFLAGS); /* NYI */ + + eval = ht_LookupEntry(ut, &db.dumpIden, &start, &da, &d); + if (eval) + ABORT(eval); + if (!da) + ABORT(BUDB_NODUMPID); + + eval = AddToReturnList(&list, da, &toskip); + if (eval) + ABORT(eval); + } else if (endFlags == BUDB_OP_NPREVIOUS) { struct wantDumpRock rock; struct chosenDump *ptr, *nextPtr; @@ -2459,28 +2668,30 @@ afs_int32 GetDumps (call, majorVersion, flags, name, start, end, /* no other flags should be set */ /* end specifies how many dumps */ - if (!end) ABORT(BUDB_BADFLAGS); + if (!end) + ABORT(BUDB_BADFLAGS); memset(&rock, 0, sizeof(rock)); rock.maxDumps = end; - scanHashTable(ut, &db.dumpName, wantDump, rememberDump, (char *) &rock); + scanHashTable(ut, &db.dumpName, wantDump, rememberDump, + (char *)&rock); - for (ptr=rock.chain; ptr; ptr=nextPtr) - { + for (ptr = rock.chain; ptr; ptr = nextPtr) { nextPtr = ptr->next; - AddToReturnList (&list, ptr->addr, &toskip); /* ignore error for free */ + AddToReturnList(&list, ptr->addr, &toskip); /* ignore error for free */ free(ptr); } - } - else - { - ABORT(BUDB_BADFLAGS); + } else { + ABORT(BUDB_BADFLAGS); } - eval = SendReturnList (ut, &list, FillDumpEntry, sizeof(struct budb_dumpEntry), - index, nextIndexP, dbTimeP, (returnList_t)dumps); - if (eval) ABORT(eval); + eval = + SendReturnList(ut, &list, FillDumpEntry, + sizeof(struct budb_dumpEntry), index, nextIndexP, + dbTimeP, (returnList_t) dumps); + if (eval) + ABORT(eval); error_exit: FreeReturnList(&list); @@ -2498,91 +2709,97 @@ afs_int32 GetDumps (call, majorVersion, flags, name, start, end, * we should use the most recent expiration date. Put the most recent * expiration tape into the given tape structure. */ -afs_int32 getExpiration (ut, tapePtr) +afs_int32 +getExpiration(ut, tapePtr) struct ubik_trans *ut; - struct tape *tapePtr; + struct tape *tapePtr; { - dbadr ad; + dbadr ad; struct dump d; struct tape t; - afs_int32 initDump; - afs_int32 eval, code = 0; + afs_int32 initDump; + afs_int32 eval, code = 0; - if (!tapePtr) ERROR(0); + if (!tapePtr) + ERROR(0); /* Get the dump for this tape */ ad = ntohl(tapePtr->dump); - eval = dbread(ut,ad,&d,sizeof(d)); - if (eval) ERROR(eval); - + eval = dbread(ut, ad, &d, sizeof(d)); + if (eval) + ERROR(eval); + /* If not an initial dump, get the initial dump */ - if (d.initialDumpID) - { - initDump = ntohl(d.initialDumpID); - eval = ht_LookupEntry (ut, &db.dumpIden, &initDump, &ad, &d); - if (eval) ERROR(eval); + if (d.initialDumpID) { + initDump = ntohl(d.initialDumpID); + eval = ht_LookupEntry(ut, &db.dumpIden, &initDump, &ad, &d); + if (eval) + ERROR(eval); } /* Cycle through the dumps and appended dumps */ - while (ad) - { - /* Get the first tape in this dump. No need to check the rest of the tapes */ - /* for this dump since they will all have the same expiration date */ - eval = dbread (ut, ntohl(d.firstTape), &t, sizeof(t)); - if (eval) ERROR(eval); - + while (ad) { + /* Get the first tape in this dump. No need to check the rest of the tapes */ + /* for this dump since they will all have the same expiration date */ + eval = dbread(ut, ntohl(d.firstTape), &t, sizeof(t)); + if (eval) + ERROR(eval); + /* Take the greater of the expiration dates */ - if ( ntohl(tapePtr->expires) < ntohl(t.expires) ) + if (ntohl(tapePtr->expires) < ntohl(t.expires)) tapePtr->expires = t.expires; /* Step to and read the next appended dump */ - if ( ad = ntohl(d.appendedDumpChain) ) - { - eval = dbread(ut,ad,&d,sizeof(d)); - if (eval) ERROR(eval); + if (ad = ntohl(d.appendedDumpChain)) { + eval = dbread(ut, ad, &d, sizeof(d)); + if (eval) + ERROR(eval); } } error_exit: - return(code); + return (code); } /* Mark the following dump as appended to another, intial dump */ -afs_int32 makeAppended (ut, appendedDumpID, initialDumpID, startTapeSeq) +afs_int32 +makeAppended(ut, appendedDumpID, initialDumpID, startTapeSeq) struct ubik_trans *ut; - afs_int32 appendedDumpID; - afs_int32 initialDumpID; - afs_int32 startTapeSeq; + afs_int32 appendedDumpID; + afs_int32 initialDumpID; + afs_int32 startTapeSeq; { - dbadr ada, da, lastDumpAddr; - struct dump ad, d; - afs_int32 eval, code = 0; + dbadr ada, da, lastDumpAddr; + struct dump ad, d; + afs_int32 eval, code = 0; if (!initialDumpID) - ERROR(0); + ERROR(0); if (appendedDumpID == initialDumpID) - ERROR(BUDB_INTERNALERROR); + ERROR(BUDB_INTERNALERROR); /* If there is an initial dump, append this dump to it */ /* Find the appended dump via its id */ - eval = ht_LookupEntry(ut,&db.dumpIden,&appendedDumpID,&ada,&ad); - if (eval) ERROR(eval); + eval = ht_LookupEntry(ut, &db.dumpIden, &appendedDumpID, &ada, &ad); + if (eval) + ERROR(eval); /* If the dump is already marked as appended, * then we have an internal error. */ if (ad.initialDumpID) { - if (ntohl(ad.initialDumpID) != initialDumpID) - ERROR(BUDB_INTERNALERROR); + if (ntohl(ad.initialDumpID) != initialDumpID) + ERROR(BUDB_INTERNALERROR); } /* Update the appended dump to point to the initial dump */ ad.initialDumpID = htonl(initialDumpID); - ad.tapes.b = htonl(startTapeSeq); + ad.tapes.b = htonl(startTapeSeq); /* find the initial dump via its id */ - eval = ht_LookupEntry(ut,&db.dumpIden,&initialDumpID,&da,&d); - if (eval) ERROR(eval); + eval = ht_LookupEntry(ut, &db.dumpIden, &initialDumpID, &da, &d); + if (eval) + ERROR(eval); /* Update the appended dump's tape format with that of the initial */ strcpy(ad.tapes.format, d.tapes.format); @@ -2591,340 +2808,371 @@ afs_int32 makeAppended (ut, appendedDumpID, initialDumpID, startTapeSeq) * we reach the last appended dump. */ lastDumpAddr = da; - while (d.appendedDumpChain) { - lastDumpAddr = ntohl(d.appendedDumpChain); - if (lastDumpAddr == ada) ERROR(0); /* Already appended */ - eval = dbread(ut, lastDumpAddr, &d, sizeof(d)); - if (eval) ERROR(eval); + while (d.appendedDumpChain) { + lastDumpAddr = ntohl(d.appendedDumpChain); + if (lastDumpAddr == ada) + ERROR(0); /* Already appended */ + eval = dbread(ut, lastDumpAddr, &d, sizeof(d)); + if (eval) + ERROR(eval); } - + /* Update the last dump to point to our new appended dump. * The appended dump is the last one in the dump chain. */ - d.appendedDumpChain = htonl(ada); + d.appendedDumpChain = htonl(ada); ad.appendedDumpChain = 0; /* Write the appended dump and the initial dump */ - eval = dbwrite(ut,ada,(char *)&ad,sizeof(ad)); - if (eval) ERROR(eval); + eval = dbwrite(ut, ada, (char *)&ad, sizeof(ad)); + if (eval) + ERROR(eval); - eval = dbwrite (ut, lastDumpAddr, (char *)&d, sizeof(d)); - if (eval) ERROR(eval); + eval = dbwrite(ut, lastDumpAddr, (char *)&d, sizeof(d)); + if (eval) + ERROR(eval); - eval = set_header_word (ut, lastUpdate, htonl(time(0))); - if (eval) ERROR(eval); + eval = set_header_word(ut, lastUpdate, htonl(time(0))); + if (eval) + ERROR(eval); error_exit: - return(code); + return (code); } -afs_int32 SBUDB_MakeDumpAppended (call, appendedDumpID, initialDumpID, startTapeSeq) +afs_int32 +SBUDB_MakeDumpAppended(call, appendedDumpID, initialDumpID, startTapeSeq) struct rx_call *call; - afs_int32 appendedDumpID; - afs_int32 initialDumpID; - afs_int32 startTapeSeq; + afs_int32 appendedDumpID; + afs_int32 initialDumpID; + afs_int32 startTapeSeq; { - afs_int32 code; + afs_int32 code; - code = MakeDumpAppended (call, appendedDumpID, initialDumpID, startTapeSeq); - osi_auditU (call, BUDB_AppDmpEvent, code, AUD_LONG, appendedDumpID, AUD_END); - return code; + code = + MakeDumpAppended(call, appendedDumpID, initialDumpID, startTapeSeq); + osi_auditU(call, BUDB_AppDmpEvent, code, AUD_LONG, appendedDumpID, + AUD_END); + return code; } -afs_int32 MakeDumpAppended (call, appendedDumpID, initialDumpID, startTapeSeq) +afs_int32 +MakeDumpAppended(call, appendedDumpID, initialDumpID, startTapeSeq) struct rx_call *call; - afs_int32 appendedDumpID; - afs_int32 initialDumpID; - afs_int32 startTapeSeq; + afs_int32 appendedDumpID; + afs_int32 initialDumpID; + afs_int32 startTapeSeq; { - struct ubik_trans *ut; - afs_int32 eval, code = 0; + struct ubik_trans *ut; + afs_int32 eval, code = 0; - if ( !callPermitted(call) ) - return BUDB_NOTPERMITTED; + if (!callPermitted(call)) + return BUDB_NOTPERMITTED; - eval = InitRPC (&ut, LOCKWRITE, 1); - if (eval) return(eval); + eval = InitRPC(&ut, LOCKWRITE, 1); + if (eval) + return (eval); - eval = makeAppended(ut,appendedDumpID,initialDumpID,startTapeSeq); - if (eval) ABORT(eval); + eval = makeAppended(ut, appendedDumpID, initialDumpID, startTapeSeq); + if (eval) + ABORT(eval); - code = ubik_EndTrans(ut); - return (code); + code = ubik_EndTrans(ut); + return (code); - abort_exit: - ubik_AbortTrans(ut); - return(code); + abort_exit: + ubik_AbortTrans(ut); + return (code); } /* Find the last tape of a dump-set. This includes any appended dumps */ -afs_int32 SBUDB_FindLastTape (call, dumpID, dumpEntry, tapeEntry, volEntry) - struct rx_call *call; - afs_int32 dumpID; - struct budb_dumpEntry *dumpEntry; - struct budb_tapeEntry *tapeEntry; +afs_int32 +SBUDB_FindLastTape(call, dumpID, dumpEntry, tapeEntry, volEntry) + struct rx_call *call; + afs_int32 dumpID; + struct budb_dumpEntry *dumpEntry; + struct budb_tapeEntry *tapeEntry; struct budb_volumeEntry *volEntry; { - afs_int32 code; + afs_int32 code; - code = FindLastTape (call, dumpID, dumpEntry, tapeEntry, volEntry); - osi_auditU (call, BUDB_FndLTpeEvent, code, AUD_LONG, dumpID, AUD_END); - return code; + code = FindLastTape(call, dumpID, dumpEntry, tapeEntry, volEntry); + osi_auditU(call, BUDB_FndLTpeEvent, code, AUD_LONG, dumpID, AUD_END); + return code; } -afs_int32 FindLastTape (call, dumpID, dumpEntry, tapeEntry, volEntry) - struct rx_call *call; - afs_int32 dumpID; - struct budb_dumpEntry *dumpEntry; - struct budb_tapeEntry *tapeEntry; +afs_int32 +FindLastTape(call, dumpID, dumpEntry, tapeEntry, volEntry) + struct rx_call *call; + afs_int32 dumpID; + struct budb_dumpEntry *dumpEntry; + struct budb_tapeEntry *tapeEntry; struct budb_volumeEntry *volEntry; { - struct ubik_trans *ut; - struct dump d; - dbadr lastDump; - struct tape t; - dbadr lastTape, thisTape; - afs_int32 lastTapeSeq; - struct volFragment vf; - dbadr lastVol, thisVol; - afs_int32 lastVolPos; - afs_int32 eval, code = 0; - - if ( !callPermitted(call) ) - return BUDB_NOTPERMITTED; - - if (!dumpID) return(BUDB_BADARGUMENT); - - eval = InitRPC (&ut, LOCKREAD, 1); - if (eval) return(eval); - - /* find and read its initial dump via its id */ - eval = ht_LookupEntry (ut, &db.dumpIden, &dumpID, &lastDump, &d); - if (eval) ABORT(eval); - if (!lastDump) ABORT(BUDB_NODUMPID); - - /* Follow the append dumps link chain until we reach the last dump */ - while (d.appendedDumpChain) - { - lastDump = ntohl(d.appendedDumpChain); - eval = dbread(ut,lastDump,&d,sizeof(d)); - if (eval) ABORT(eval); - } - - /* We now have the last dump of the last appended dump */ - /* Copy this into our return structure */ - eval = FillDumpEntry(ut,lastDump,dumpEntry); - if (eval) ABORT(eval); - - /* Fail if the last dump has no tapes */ - if (!d.firstTape) ABORT(BUDB_NOTAPENAME); - - /* Follow the tapes in this dump until we reach the last tape */ - eval = dbread (ut, ntohl(d.firstTape), &t, sizeof(t)); - if (eval) ABORT(eval); - - lastTape = ntohl(d.firstTape); - lastTapeSeq = ntohl(t.seq); - lastVol = ntohl(t.firstVol); - - while (t.nextTape) - { - thisTape = ntohl(t.nextTape); - eval = dbread(ut,thisTape,&t,sizeof(t)); - if (eval) ABORT(eval); - - if (ntohl(t.seq) > lastTapeSeq) - { - lastTape = thisTape; - lastTapeSeq = ntohl(t.seq); - lastVol = ntohl(t.firstVol); - } - } - - /* We now have the last tape of the last appended dump */ - /* Copy this into our return structure */ - eval = FillTapeEntry(ut,lastTape,tapeEntry); - if (eval) ABORT(eval); - - /* Zero volume entry if the last tape has no volumes */ - if (!lastVol) { - memset(volEntry, 0, sizeof(*volEntry)); - } else { - /* Follow the volumes until we reach the last volume */ - eval = dbread (ut,lastVol,&vf,sizeof(vf)); - if (eval) ABORT(eval); + struct ubik_trans *ut; + struct dump d; + dbadr lastDump; + struct tape t; + dbadr lastTape, thisTape; + afs_int32 lastTapeSeq; + struct volFragment vf; + dbadr lastVol, thisVol; + afs_int32 lastVolPos; + afs_int32 eval, code = 0; + + if (!callPermitted(call)) + return BUDB_NOTPERMITTED; + + if (!dumpID) + return (BUDB_BADARGUMENT); + + eval = InitRPC(&ut, LOCKREAD, 1); + if (eval) + return (eval); + + /* find and read its initial dump via its id */ + eval = ht_LookupEntry(ut, &db.dumpIden, &dumpID, &lastDump, &d); + if (eval) + ABORT(eval); + if (!lastDump) + ABORT(BUDB_NODUMPID); + + /* Follow the append dumps link chain until we reach the last dump */ + while (d.appendedDumpChain) { + lastDump = ntohl(d.appendedDumpChain); + eval = dbread(ut, lastDump, &d, sizeof(d)); + if (eval) + ABORT(eval); + } + + /* We now have the last dump of the last appended dump */ + /* Copy this into our return structure */ + eval = FillDumpEntry(ut, lastDump, dumpEntry); + if (eval) + ABORT(eval); + + /* Fail if the last dump has no tapes */ + if (!d.firstTape) + ABORT(BUDB_NOTAPENAME); + + /* Follow the tapes in this dump until we reach the last tape */ + eval = dbread(ut, ntohl(d.firstTape), &t, sizeof(t)); + if (eval) + ABORT(eval); + + lastTape = ntohl(d.firstTape); + lastTapeSeq = ntohl(t.seq); + lastVol = ntohl(t.firstVol); + + while (t.nextTape) { + thisTape = ntohl(t.nextTape); + eval = dbread(ut, thisTape, &t, sizeof(t)); + if (eval) + ABORT(eval); + + if (ntohl(t.seq) > lastTapeSeq) { + lastTape = thisTape; + lastTapeSeq = ntohl(t.seq); + lastVol = ntohl(t.firstVol); + } + } + + /* We now have the last tape of the last appended dump */ + /* Copy this into our return structure */ + eval = FillTapeEntry(ut, lastTape, tapeEntry); + if (eval) + ABORT(eval); + + /* Zero volume entry if the last tape has no volumes */ + if (!lastVol) { + memset(volEntry, 0, sizeof(*volEntry)); + } else { + /* Follow the volumes until we reach the last volume */ + eval = dbread(ut, lastVol, &vf, sizeof(vf)); + if (eval) + ABORT(eval); lastVolPos = vf.position; while (vf.sameTapeChain) { - thisVol = ntohl(vf.sameTapeChain); - eval = dbread(ut,thisVol,&vf,sizeof(vf)); - if (eval) ABORT(eval); - - if (vf.position > lastVolPos) { - lastVol = thisVol; - lastVolPos = vf.position; - } + thisVol = ntohl(vf.sameTapeChain); + eval = dbread(ut, thisVol, &vf, sizeof(vf)); + if (eval) + ABORT(eval); + + if (vf.position > lastVolPos) { + lastVol = thisVol; + lastVolPos = vf.position; + } } /* We now have the last volume of this tape */ /* Copy this into our return structure */ - eval = FillVolEntry(ut,lastVol,volEntry); - if (eval) ABORT(eval); - } + eval = FillVolEntry(ut, lastVol, volEntry); + if (eval) + ABORT(eval); + } - eval = ubik_EndTrans(ut); - if (!code) code = eval; - return (code); + eval = ubik_EndTrans(ut); + if (!code) + code = eval; + return (code); - abort_exit: - ubik_AbortTrans(ut); - return(code); + abort_exit: + ubik_AbortTrans(ut); + return (code); } -afs_int32 SBUDB_GetTapes (call, majorVersion, flags, name, start, end, index, nextIndexP, +afs_int32 +SBUDB_GetTapes(call, majorVersion, flags, name, start, end, index, nextIndexP, dbTimeP, tapes) struct rx_call *call; - afs_int32 majorVersion; /* version of interface structures */ - afs_int32 flags; /* search & select controls */ - char *name; /* s&s parameters */ - afs_int32 start; - afs_int32 end; /* reserved: MBZ */ - afs_int32 index; /* start index of returned entries */ - afs_int32 *nextIndexP; /* output index for next call */ + afs_int32 majorVersion; /* version of interface structures */ + afs_int32 flags; /* search & select controls */ + char *name; /* s&s parameters */ + afs_int32 start; + afs_int32 end; /* reserved: MBZ */ + afs_int32 index; /* start index of returned entries */ + afs_int32 *nextIndexP; /* output index for next call */ afs_int32 *dbTimeP; - budb_tapeList *tapes; /* pointer to buffer */ + budb_tapeList *tapes; /* pointer to buffer */ { - afs_int32 code; + afs_int32 code; - code = GetTapes (call, majorVersion, flags, name, start, end, - index, nextIndexP, dbTimeP, tapes); - osi_auditU (call, BUDB_GetTpeEvent, code, AUD_END); - return code; + code = + GetTapes(call, majorVersion, flags, name, start, end, index, + nextIndexP, dbTimeP, tapes); + osi_auditU(call, BUDB_GetTpeEvent, code, AUD_END); + return code; } -afs_int32 GetTapes (call, majorVersion, flags, name, start, end, - index, nextIndexP, dbTimeP, tapes) +afs_int32 +GetTapes(call, majorVersion, flags, name, start, end, index, nextIndexP, + dbTimeP, tapes) struct rx_call *call; - afs_int32 majorVersion; /* version of interface structures */ - afs_int32 flags; /* search & select controls */ - char *name; /* s&s parameters */ - afs_int32 start; - afs_int32 end; /* reserved: MBZ */ - afs_int32 index; /* start index of returned entries */ - afs_int32 *nextIndexP; /* output index for next call */ + afs_int32 majorVersion; /* version of interface structures */ + afs_int32 flags; /* search & select controls */ + char *name; /* s&s parameters */ + afs_int32 start; + afs_int32 end; /* reserved: MBZ */ + afs_int32 index; /* start index of returned entries */ + afs_int32 *nextIndexP; /* output index for next call */ afs_int32 *dbTimeP; - budb_tapeList *tapes; /* pointer to buffer */ + budb_tapeList *tapes; /* pointer to buffer */ { struct ubik_trans *ut; - dbadr da, ta; - struct dump d; - struct tape t; - afs_int32 nameFlags, startFlags, endFlags, timeFlags; + dbadr da, ta; + struct dump d; + struct tape t; + afs_int32 nameFlags, startFlags, endFlags, timeFlags; struct returnList list; - afs_int32 eval, code = 0; - afs_int32 toskip; + afs_int32 eval, code = 0; + afs_int32 toskip; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; if (majorVersion != BUDB_MAJORVERSION) - return BUDB_OLDINTERFACE; + return BUDB_OLDINTERFACE; - if (index < 0) return BUDB_ENDOFLIST; + if (index < 0) + return BUDB_ENDOFLIST; - eval = InitRPC (&ut, LOCKREAD, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKREAD, 1); + if (eval) + return eval; - nameFlags = flags & BUDB_OP_NAMES; + nameFlags = flags & BUDB_OP_NAMES; startFlags = flags & BUDB_OP_STARTS; - endFlags = flags & BUDB_OP_ENDS; - timeFlags = flags & BUDB_OP_TIMES; + endFlags = flags & BUDB_OP_ENDS; + timeFlags = flags & BUDB_OP_TIMES; - InitReturnList (&list); + InitReturnList(&list); toskip = index; - if (nameFlags == BUDB_OP_TAPENAME) - { /*it*/ - eval = ht_LookupEntry (ut, &db.tapeName, name, &ta, &t); - if (eval) ABORT(eval); - if (!ta) ABORT(BUDB_NOTAPENAME); - + if (nameFlags == BUDB_OP_TAPENAME) { /*it */ + eval = ht_LookupEntry(ut, &db.tapeName, name, &ta, &t); + if (eval) + ABORT(eval); + if (!ta) + ABORT(BUDB_NOTAPENAME); + /* NYI */ - if ( (startFlags & ~BUDB_OP_DUMPID) || endFlags || timeFlags ) ABORT(BUDB_BADFLAGS); + if ((startFlags & ~BUDB_OP_DUMPID) || endFlags || timeFlags) + ABORT(BUDB_BADFLAGS); /* follow the hash chain to the end */ - while (ta) - { /*w*/ - if (startFlags & BUDB_OP_DUMPID) - { + while (ta) { /*w */ + if (startFlags & BUDB_OP_DUMPID) { /* read in the dump */ eval = dbread(ut, ntohl(t.dump), &d, sizeof(d)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); /* check if both name and dump id match */ - if ( (strcmp(name, t.name) == 0) && (ntohl(d.id) == start) ) - { - eval = AddToReturnList (&list, ta, &toskip); - if (eval && (eval != BUDB_LIST2BIG)) ABORT(eval); + if ((strcmp(name, t.name) == 0) && (ntohl(d.id) == start)) { + eval = AddToReturnList(&list, ta, &toskip); + if (eval && (eval != BUDB_LIST2BIG)) + ABORT(eval); break; } - } - else - { - /* Add to return list and continue search */ - if ( strcmp(name, t.name) == 0 ) - { - eval = AddToReturnList (&list, ta, &toskip); - if (eval == BUDB_LIST2BIG) break; - if (eval) ABORT(eval); + } else { + /* Add to return list and continue search */ + if (strcmp(name, t.name) == 0) { + eval = AddToReturnList(&list, ta, &toskip); + if (eval == BUDB_LIST2BIG) + break; + if (eval) + ABORT(eval); } } ta = ntohl(t.nameHashChain); - if (ta) dbread(ut, ta, &t, sizeof(t)); - } /*w*/ - } /*it*/ - else if (nameFlags == BUDB_OP_TAPESEQ) - { - eval = ht_LookupEntry(ut,&db.dumpIden, &start, &da, &d); - if (eval) ABORT(eval); - if (!da) ABORT(BUDB_NODUMPNAME); - + if (ta) + dbread(ut, ta, &t, sizeof(t)); + } /*w */ + } /*it */ + else if (nameFlags == BUDB_OP_TAPESEQ) { + eval = ht_LookupEntry(ut, &db.dumpIden, &start, &da, &d); + if (eval) + ABORT(eval); + if (!da) + ABORT(BUDB_NODUMPNAME); + /* search for the right tape */ ta = ntohl(d.firstTape); - for (ta = ntohl(d.firstTape); ta; ta = ntohl(t.nextTape)) - { + for (ta = ntohl(d.firstTape); ta; ta = ntohl(t.nextTape)) { eval = dbread(ut, ta, &t, sizeof(t)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); - if (ntohl(t.seq) == end) - { - eval = AddToReturnList (&list, ta, &toskip); - if (eval && (eval != BUDB_LIST2BIG)) ABORT(eval); + if (ntohl(t.seq) == end) { + eval = AddToReturnList(&list, ta, &toskip); + if (eval && (eval != BUDB_LIST2BIG)) + ABORT(eval); break; } } - } - else - { - ABORT (BUDB_BADFLAGS); + } else { + ABORT(BUDB_BADFLAGS); } - eval = SendReturnList (ut, &list, FillTapeEntry, - sizeof(struct budb_tapeEntry), - index, nextIndexP, dbTimeP, (returnList_t)tapes); - if (eval) ABORT(eval); + eval = + SendReturnList(ut, &list, FillTapeEntry, + sizeof(struct budb_tapeEntry), index, nextIndexP, + dbTimeP, (returnList_t) tapes); + if (eval) + ABORT(eval); FreeReturnList(&list); code = ubik_EndTrans(ut); - return code; - + return code; + abort_exit: FreeReturnList(&list); ubik_AbortTrans(ut); - return(code); + return (code); } /* BUDB_GetVolumes @@ -2937,125 +3185,137 @@ afs_int32 GetTapes (call, majorVersion, flags, name, start, end, * name on the selected dumpid. */ -afs_int32 SBUDB_GetVolumes (call, majorVersion, flags, name, start, end, - index, nextIndexP, dbTimeP, volumes) - struct rx_call *call; - afs_int32 majorVersion; /* version of interface structures */ - afs_int32 flags; /* search & select controls */ - char *name; /* - parameters for search */ - afs_int32 start; /* - usage depends which BUDP_OP_* */ - afs_int32 end; /* - bits are set */ - afs_int32 index; /* start index of returned entries */ - afs_int32 *nextIndexP; /* output index for next call */ - afs_int32 *dbTimeP; - budb_volumeList *volumes; /* pointer to buffer */ -{ - afs_int32 code; - - code = GetVolumes (call, majorVersion, flags, name, start, end, - index, nextIndexP, dbTimeP, volumes); - osi_auditU (call, BUDB_GetVolEvent, code, AUD_END); - return code; -} - -afs_int32 GetVolumes (call, majorVersion, flags, name, start, end, - index, nextIndexP, dbTimeP, volumes) - struct rx_call *call; - afs_int32 majorVersion; /* version of interface structures */ - afs_int32 flags; /* search & select controls */ - char *name; /* - parameters for search */ - afs_int32 start; /* - usage depends which BUDP_OP_* */ - afs_int32 end; /* - bits are set */ - afs_int32 index; /* start index of returned entries */ - afs_int32 *nextIndexP; /* output index for next call */ - afs_int32 *dbTimeP; - budb_volumeList *volumes; /* pointer to buffer */ +afs_int32 +SBUDB_GetVolumes(call, majorVersion, flags, name, start, end, index, + nextIndexP, dbTimeP, volumes) + struct rx_call *call; + afs_int32 majorVersion; /* version of interface structures */ + afs_int32 flags; /* search & select controls */ + char *name; /* - parameters for search */ + afs_int32 start; /* - usage depends which BUDP_OP_* */ + afs_int32 end; /* - bits are set */ + afs_int32 index; /* start index of returned entries */ + afs_int32 *nextIndexP; /* output index for next call */ + afs_int32 *dbTimeP; + budb_volumeList *volumes; /* pointer to buffer */ +{ + afs_int32 code; + + code = + GetVolumes(call, majorVersion, flags, name, start, end, index, + nextIndexP, dbTimeP, volumes); + osi_auditU(call, BUDB_GetVolEvent, code, AUD_END); + return code; +} + +afs_int32 +GetVolumes(call, majorVersion, flags, name, start, end, index, nextIndexP, + dbTimeP, volumes) + struct rx_call *call; + afs_int32 majorVersion; /* version of interface structures */ + afs_int32 flags; /* search & select controls */ + char *name; /* - parameters for search */ + afs_int32 start; /* - usage depends which BUDP_OP_* */ + afs_int32 end; /* - bits are set */ + afs_int32 index; /* start index of returned entries */ + afs_int32 *nextIndexP; /* output index for next call */ + afs_int32 *dbTimeP; + budb_volumeList *volumes; /* pointer to buffer */ { struct ubik_trans *ut; - dbadr via; - struct volInfo vi; - afs_int32 nameFlags, startFlags, endFlags, timeFlags; - afs_int32 eval, code = 0; + dbadr via; + struct volInfo vi; + afs_int32 nameFlags, startFlags, endFlags, timeFlags; + afs_int32 eval, code = 0; struct returnList vollist; - afs_int32 toskip; + afs_int32 toskip; /* Don't check permissions when we look up a specific volume name */ - if ( ((flags & BUDB_OP_NAMES) != BUDB_OP_VOLUMENAME) && !callPermitted(call) ) + if (((flags & BUDB_OP_NAMES) != BUDB_OP_VOLUMENAME) + && !callPermitted(call)) return BUDB_NOTPERMITTED; - if (majorVersion != BUDB_MAJORVERSION) return BUDB_OLDINTERFACE; - if (index < 0) return BUDB_ENDOFLIST; + if (majorVersion != BUDB_MAJORVERSION) + return BUDB_OLDINTERFACE; + if (index < 0) + return BUDB_ENDOFLIST; - eval = InitRPC (&ut, LOCKREAD, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKREAD, 1); + if (eval) + return eval; - nameFlags = flags & BUDB_OP_NAMES; + nameFlags = flags & BUDB_OP_NAMES; startFlags = flags & BUDB_OP_STARTS; - endFlags = flags & BUDB_OP_ENDS; - timeFlags = flags & BUDB_OP_TIMES; + endFlags = flags & BUDB_OP_ENDS; + timeFlags = flags & BUDB_OP_TIMES; - InitReturnList (&vollist); + InitReturnList(&vollist); toskip = index; /* lookup a the volume (specified by name) in the dump (specified by id) */ - if (nameFlags == BUDB_OP_VOLUMENAME) - { + if (nameFlags == BUDB_OP_VOLUMENAME) { /* dumpid permissible, all others off */ - if ( ((startFlags & ~BUDB_OP_DUMPID) != 0) || endFlags || timeFlags ) + if (((startFlags & ~BUDB_OP_DUMPID) != 0) || endFlags || timeFlags) ABORT(BUDB_BADFLAGS); /* returns ptr to volinfo of requested name */ - eval = ht_LookupEntry (ut, &db.volName, name, &via, &vi); - if (eval) ABORT(eval); - if (!via) ABORT(BUDB_NOVOLUMENAME); + eval = ht_LookupEntry(ut, &db.volName, name, &via, &vi); + if (eval) + ABORT(eval); + if (!via) + ABORT(BUDB_NOVOLUMENAME); /* Iterate over all volume fragments with this name */ - while (1) - { + while (1) { struct volFragment v; afs_int32 va; /* traverse all the volume fragments for this volume info structure */ - for (va=vi.firstFragment; va; va=v.sameNameChain) - { + for (va = vi.firstFragment; va; va = v.sameNameChain) { va = ntohl(va); - eval = dbread (ut, va, &v, sizeof(v)); - if (eval) ABORT(eval); + eval = dbread(ut, va, &v, sizeof(v)); + if (eval) + ABORT(eval); - if ( startFlags & BUDB_OP_DUMPID ) - { + if (startFlags & BUDB_OP_DUMPID) { struct tape atape; struct dump adump; /* get the dump id for this fragment */ eval = dbread(ut, ntohl(v.tape), &atape, sizeof(atape)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); - eval = dbread(ut, ntohl(atape.dump), &adump, sizeof(adump)); - if (eval) ABORT(BUDB_IO); + eval = + dbread(ut, ntohl(atape.dump), &adump, sizeof(adump)); + if (eval) + ABORT(BUDB_IO); /* dump id does not match */ - if ( ntohl(adump.id) != start ) + if (ntohl(adump.id) != start) continue; } - eval = AddToReturnList (&vollist, va, &toskip); - if (eval == BUDB_LIST2BIG) break; - if (eval) ABORT(eval); + eval = AddToReturnList(&vollist, va, &toskip); + if (eval == BUDB_LIST2BIG) + break; + if (eval) + ABORT(eval); } - if (eval == BUDB_LIST2BIG) break; + if (eval == BUDB_LIST2BIG) + break; via = vi.sameNameChain; - if (via == 0) break; + if (via == 0) + break; via = ntohl(via); - eval = dbread (ut, via, &vi, sizeof(vi)); - if (eval) ABORT(eval); + eval = dbread(ut, via, &vi, sizeof(vi)); + if (eval) + ABORT(eval); } - } - else if ( ((nameFlags == 0) || (nameFlags == BUDB_OP_TAPENAME)) && - (startFlags == BUDB_OP_DUMPID) ) - { + } else if (((nameFlags == 0) || (nameFlags == BUDB_OP_TAPENAME)) + && (startFlags == BUDB_OP_DUMPID)) { struct dump dump; dbadr dumpAddr; struct tape tape; @@ -3066,44 +3326,50 @@ afs_int32 GetVolumes (call, majorVersion, flags, name, start, end, /* lookup all volumes for a specified dump id */ /* no other flags should be set */ - if (endFlags || timeFlags) ABORT(BUDB_BADFLAGS); + if (endFlags || timeFlags) + ABORT(BUDB_BADFLAGS); /* find the dump */ eval = ht_LookupEntry(ut, &db.dumpIden, &start, &dumpAddr, &dump); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); /* traverse all the tapes */ - for (tapeAddr=ntohl(dump.firstTape); tapeAddr; tapeAddr=ntohl(tape.nextTape)) - { /*w*/ + for (tapeAddr = ntohl(dump.firstTape); tapeAddr; tapeAddr = ntohl(tape.nextTape)) { /*w */ eval = dbread(ut, tapeAddr, &tape, sizeof(tape)); - if (eval) ABORT(eval); - - if ( ( nameFlags != BUDB_OP_TAPENAME ) || - ((nameFlags == BUDB_OP_TAPENAME) && (strcmp(tape.name,name) == 0)) ) - { - /* now return all the volumes */ - for (volFragAddr=ntohl(tape.firstVol); volFragAddr; - volFragAddr=ntohl(volFrag.sameTapeChain)) - { + if (eval) + ABORT(eval); + + if ((nameFlags != BUDB_OP_TAPENAME) + || ((nameFlags == BUDB_OP_TAPENAME) + && (strcmp(tape.name, name) == 0))) { + /* now return all the volumes */ + for (volFragAddr = ntohl(tape.firstVol); volFragAddr; + volFragAddr = ntohl(volFrag.sameTapeChain)) { eval = dbread(ut, volFragAddr, &volFrag, sizeof(volFrag)); - if (eval) ABORT(eval); + if (eval) + ABORT(eval); eval = AddToReturnList(&vollist, volFragAddr, &toskip); - if (eval == BUDB_LIST2BIG) break; - if (eval) ABORT(eval); + if (eval == BUDB_LIST2BIG) + break; + if (eval) + ABORT(eval); } } - if (eval == BUDB_LIST2BIG) break; - } /*w*/ - } - else - { - ABORT(BUDB_BADFLAGS); + if (eval == BUDB_LIST2BIG) + break; + } /*w */ + } else { + ABORT(BUDB_BADFLAGS); } - eval = SendReturnList(ut, &vollist, FillVolEntry, sizeof(struct budb_volumeEntry), - index, nextIndexP, dbTimeP, (returnList_t)volumes); - if (eval) ABORT(eval); + eval = + SendReturnList(ut, &vollist, FillVolEntry, + sizeof(struct budb_volumeEntry), index, nextIndexP, + dbTimeP, (returnList_t) volumes); + if (eval) + ABORT(eval); error_exit: FreeReturnList(&vollist); @@ -3116,81 +3382,94 @@ afs_int32 GetVolumes (call, majorVersion, flags, name, start, end, return code; } -afs_int32 SBUDB_UseTape (call, tape, new) - struct rx_call *call; - struct budb_tapeEntry *tape; /* tape info */ - afs_int32 *new; /* set if tape is new */ +afs_int32 +SBUDB_UseTape(call, tape, new) + struct rx_call *call; + struct budb_tapeEntry *tape; /* tape info */ + afs_int32 *new; /* set if tape is new */ { - afs_int32 code; + afs_int32 code; - code = UseTape (call, tape, new); - osi_auditU (call, BUDB_UseTpeEvent, code, AUD_DATE, (tape ? tape->dump : 0), AUD_END); - return code; + code = UseTape(call, tape, new); + osi_auditU(call, BUDB_UseTpeEvent, code, AUD_DATE, + (tape ? tape->dump : 0), AUD_END); + return code; } -afs_int32 UseTape (call, tape, new) - struct rx_call *call; - struct budb_tapeEntry *tape; /* tape info */ - int *new; /* set if tape is new */ +afs_int32 +UseTape(call, tape, new) + struct rx_call *call; + struct budb_tapeEntry *tape; /* tape info */ + int *new; /* set if tape is new */ { struct ubik_trans *ut; - dbadr da, a; - struct dump d; - struct tape t; - afs_int32 eval, code; + dbadr da, a; + struct dump d; + struct tape t; + afs_int32 eval, code; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - if (strlen (tape->name) >= sizeof(t.name)) return BUDB_BADARGUMENT; + if (strlen(tape->name) >= sizeof(t.name)) + return BUDB_BADARGUMENT; - eval = InitRPC (&ut, LOCKWRITE, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKWRITE, 1); + if (eval) + return eval; *new = 0; memset(&t, 0, sizeof(t)); - eval = AllocStructure (ut, tape_BLOCK, 0, &a, &t); - if (eval) ABORT(eval); + eval = AllocStructure(ut, tape_BLOCK, 0, &a, &t); + if (eval) + ABORT(eval); - strcpy (t.name, tape->name); + strcpy(t.name, tape->name); - eval = ht_HashIn (ut, &db.tapeName, a, &t); - if (eval) ABORT(eval); + eval = ht_HashIn(ut, &db.tapeName, a, &t); + if (eval) + ABORT(eval); *new = 1; /* Since deleting a tape may change the dump (if its the same one), read in - the dump after the call to DeleteTape. */ - - eval = ht_LookupEntry (ut, &db.dumpIden, &tape->dump, &da, &d); - if (eval) ABORT(eval); - if (!da) ABORT(BUDB_NODUMPID); - - if (!tape->written) tape->written = time(0); /* fill in tape struct */ - t.written = htonl(tape->written); - t.expires = htonl(tape->expires); - t.dump = htonl(da); - t.seq = htonl(tape->seq); - t.useCount = htonl(tape->useCount); - t.labelpos = htonl(tape->labelpos); + * the dump after the call to DeleteTape. */ + + eval = ht_LookupEntry(ut, &db.dumpIden, &tape->dump, &da, &d); + if (eval) + ABORT(eval); + if (!da) + ABORT(BUDB_NODUMPID); + + if (!tape->written) + tape->written = time(0); /* fill in tape struct */ + t.written = htonl(tape->written); + t.expires = htonl(tape->expires); + t.dump = htonl(da); + t.seq = htonl(tape->seq); + t.useCount = htonl(tape->useCount); + t.labelpos = htonl(tape->labelpos); t.useKBytes = 0; - t.flags = htonl(tape->flags | BUDB_TAPE_BEINGWRITTEN); + t.flags = htonl(tape->flags | BUDB_TAPE_BEINGWRITTEN); - t.nextTape = d.firstTape; /* Chain the tape to the dump */ + t.nextTape = d.firstTape; /* Chain the tape to the dump */ d.firstTape = htonl(a); - if (tape->seq >= ntohl(d.tapes.maxTapes)) /* inc # tapes in the dump */ + if (tape->seq >= ntohl(d.tapes.maxTapes)) /* inc # tapes in the dump */ d.tapes.maxTapes = htonl(tape->seq); - eval = dbwrite (ut, a, &t, sizeof(t)); /* write tape struct */ - if (eval) ABORT(eval); + eval = dbwrite(ut, a, &t, sizeof(t)); /* write tape struct */ + if (eval) + ABORT(eval); - eval = dbwrite (ut, da, &d, sizeof(d)); /* write the dump struct */ - if (eval) ABORT(eval); + eval = dbwrite(ut, da, &d, sizeof(d)); /* write the dump struct */ + if (eval) + ABORT(eval); - eval = set_header_word (ut, lastUpdate, htonl(time(0))); - if (eval) ABORT(eval); + eval = set_header_word(ut, lastUpdate, htonl(time(0))); + if (eval) + ABORT(eval); LogDebug(5, "added tape %s\n", tape->name); @@ -3209,256 +3488,290 @@ afs_int32 UseTape (call, tape, new) * --------------------------------------------- */ -afs_int32 SBUDB_T_DumpHashTable (call, type, filename) - struct rx_call *call; - afs_int32 type; - char *filename; +afs_int32 +SBUDB_T_DumpHashTable(call, type, filename) + struct rx_call *call; + afs_int32 type; + char *filename; { - afs_int32 code; + afs_int32 code; - code = T_DumpHashTable (call, type, filename); - osi_auditU (call, BUDB_TDmpHaEvent, code, AUD_STR, filename, AUD_END); - return code; + code = T_DumpHashTable(call, type, filename); + osi_auditU(call, BUDB_TDmpHaEvent, code, AUD_STR, filename, AUD_END); + return code; } -afs_int32 T_DumpHashTable (call, type, filename) - struct rx_call *call; - int type; - char *filename; +afs_int32 +T_DumpHashTable(call, type, filename) + struct rx_call *call; + int type; + char *filename; { - struct ubik_trans *ut; + struct ubik_trans *ut; struct memoryHashTable *mht; - int ent; - afs_int32 eval, code = 0; - char path[64]; - FILE *DUMP; - - int length; - afs_uint32 hash; - dbadr a, first_a; - char e[sizeof(struct block)]; /* unnecessarily conservative */ - int e_size; - int old; - - if ( !callPermitted(call) ) + int ent; + afs_int32 eval, code = 0; + char path[64]; + FILE *DUMP; + + int length; + afs_uint32 hash; + dbadr a, first_a; + char e[sizeof(struct block)]; /* unnecessarily conservative */ + int e_size; + int old; + + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - if (strlen (filename) >= sizeof(path)-5) return BUDB_BADARGUMENT; + if (strlen(filename) >= sizeof(path) - 5) + return BUDB_BADARGUMENT; - eval = InitRPC (&ut, LOCKWRITE, 1); - if (eval) return eval; + eval = InitRPC(&ut, LOCKWRITE, 1); + if (eval) + return eval; - if ((mht = ht_GetType (type, &e_size)) == 0) return BUDB_BADARGUMENT; + if ((mht = ht_GetType(type, &e_size)) == 0) + return BUDB_BADARGUMENT; sprintf(path, "%s/%s", gettmpdir(), filename); - DUMP = fopen (path, "w"); - if (!DUMP) ABORT(BUDB_BADARGUMENT); + DUMP = fopen(path, "w"); + if (!DUMP) + ABORT(BUDB_BADARGUMENT); ent = 0; - for (old=0; ; old++) - { + for (old = 0;; old++) { length = (old ? mht->oldLength : mht->length); - if (length) fprintf (DUMP, "Dumping %sHash Table:\n", (old?"Old ":"")); + if (length) + fprintf(DUMP, "Dumping %sHash Table:\n", (old ? "Old " : "")); - for (hash=0; hashid)); + case HT_dumpIden_FUNCTION: + fprintf(DUMP, "%d\n", ntohl(((struct dump *)e)->id)); break; - case HT_dumpName_FUNCTION: - fprintf (DUMP, "%s\n", ((struct dump *)e)->dumpName); + case HT_dumpName_FUNCTION: + fprintf(DUMP, "%s\n", ((struct dump *)e)->dumpName); break; - case HT_tapeName_FUNCTION: - fprintf (DUMP, "%s\n", ((struct tape *)e)->name); + case HT_tapeName_FUNCTION: + fprintf(DUMP, "%s\n", ((struct tape *)e)->name); break; - case HT_volName_FUNCTION: - fprintf (DUMP, "%s\n", ((struct volInfo *)e)->name); + case HT_volName_FUNCTION: + fprintf(DUMP, "%s\n", ((struct volInfo *)e)->name); break; } - if ((ht_HashEntry(mht,e) % length) != hash) ABORT(BUDB_DATABASEINCONSISTENT); - a = ntohl(*(dbadr *)(e + mht->threadOffset)); + if ((ht_HashEntry(mht, e) % length) != hash) + ABORT(BUDB_DATABASEINCONSISTENT); + a = ntohl(*(dbadr *) (e + mht->threadOffset)); } } - if (old) break; + if (old) + break; } - fprintf (DUMP, "%d entries found\n", ent); - if (ntohl(mht->ht->entries) != ent) ABORT(BUDB_DATABASEINCONSISTENT); + fprintf(DUMP, "%d entries found\n", ent); + if (ntohl(mht->ht->entries) != ent) + ABORT(BUDB_DATABASEINCONSISTENT); code = ubik_EndTrans(ut); - if (DUMP) fclose (DUMP); + if (DUMP) + fclose(DUMP); return code; - + abort_exit: ubik_AbortTrans(ut); - if (DUMP) fclose (DUMP); + if (DUMP) + fclose(DUMP); return code; } -afs_int32 SBUDB_T_GetVersion (call, majorVersion) - struct rx_call *call; - afs_int32 *majorVersion; +afs_int32 +SBUDB_T_GetVersion(call, majorVersion) + struct rx_call *call; + afs_int32 *majorVersion; { - afs_int32 code; + afs_int32 code; - code = T_GetVersion (call, majorVersion); - osi_auditU (call, BUDB_TGetVrEvent, code, AUD_END); - return code; + code = T_GetVersion(call, majorVersion); + osi_auditU(call, BUDB_TGetVrEvent, code, AUD_END); + return code; } -afs_int32 T_GetVersion (call, majorVersion) - struct rx_call *call; - int *majorVersion; +afs_int32 +T_GetVersion(call, majorVersion) + struct rx_call *call; + int *majorVersion; { struct ubik_trans *ut; afs_int32 code; - - code = InitRPC (&ut, LOCKREAD, 0); - if (code) return(code); - + + code = InitRPC(&ut, LOCKREAD, 0); + if (code) + return (code); + *majorVersion = BUDB_MAJORVERSION; - + code = ubik_EndTrans(ut); - return(code); + return (code); } /* BUDB_T_DumpDatabase * dump as much of the database as possible int /tmp/ */ -afs_int32 SBUDB_T_DumpDatabase (call, filename) +afs_int32 +SBUDB_T_DumpDatabase(call, filename) struct rx_call *call; char *filename; { - afs_int32 code; + afs_int32 code; - code = T_DumpDatabase (call, filename); - osi_auditU (call, BUDB_TDmpDBEvent, code, AUD_STR, filename, AUD_END); - return code; + code = T_DumpDatabase(call, filename); + osi_auditU(call, BUDB_TDmpDBEvent, code, AUD_STR, filename, AUD_END); + return code; } -afs_int32 T_DumpDatabase (call, filename) +afs_int32 +T_DumpDatabase(call, filename) struct rx_call *call; char *filename; -{ +{ FILE *dumpfid; - int entrySize; + int entrySize; struct ubik_trans *ut; char *path = 0; dbadr dbAddr; int type, old, length, hash; int block, index; struct memoryHashTable *mht; - afs_int32 eval, code = 0; + afs_int32 eval, code = 0; - if ( !callPermitted(call) ) + if (!callPermitted(call)) return BUDB_NOTPERMITTED; - path = (char *) malloc(strlen(gettmpdir())+1+strlen(filename)+1); - if (!path) return(BUDB_INTERNALERROR); + path = (char *)malloc(strlen(gettmpdir()) + 1 + strlen(filename) + 1); + if (!path) + return (BUDB_INTERNALERROR); sprintf(path, "%s/%s", gettmpdir(), filename); dumpfid = fopen(path, "w"); - if (!dumpfid) return(BUDB_BADARGUMENT); - - eval = InitRPC (&ut, LOCKWRITE, 1); - if (eval) return(eval); - - /* dump all items in the database */ - for ( type=1; type<=HT_MAX_FUNCTION; type++ ) - { /*ft*/ - mht = ht_GetType (type, &entrySize); - if (!mht) ERROR(BUDB_BADARGUMENT); - - for ( old =0; old <= 1; old++ ) - { /*fo*/ - length = ( old ? mht->oldLength : mht->length); - if (!length) continue; - - fprintf (dumpfid, "Dumping %s Hash Table:\n", (old ? "Old ":"")); - - for ( hash = 0; hash < length; hash++ ) - { /*f*/ - dbAddr = ht_LookupBucket (ut, mht, hash, old); - - while ( dbAddr ) - { /*w*/ - switch (type) - { /*s*/ - case HT_dumpIden_FUNCTION: + if (!dumpfid) + return (BUDB_BADARGUMENT); + + eval = InitRPC(&ut, LOCKWRITE, 1); + if (eval) + return (eval); + + /* dump all items in the database */ + for (type = 1; type <= HT_MAX_FUNCTION; type++) { /*ft */ + mht = ht_GetType(type, &entrySize); + if (!mht) + ERROR(BUDB_BADARGUMENT); + + for (old = 0; old <= 1; old++) { /*fo */ + length = (old ? mht->oldLength : mht->length); + if (!length) + continue; + + fprintf(dumpfid, "Dumping %s Hash Table:\n", (old ? "Old " : "")); + + for (hash = 0; hash < length; hash++) { /*f */ + dbAddr = ht_LookupBucket(ut, mht, hash, old); + + while (dbAddr) { /*w */ + switch (type) { /*s */ + case HT_dumpIden_FUNCTION: { struct dump hostDump, diskDump; - eval = cdbread (ut, dump_BLOCK, dbAddr, &diskDump, sizeof(diskDump)); - if (eval) ERROR(eval); + eval = + cdbread(ut, dump_BLOCK, dbAddr, &diskDump, + sizeof(diskDump)); + if (eval) + ERROR(eval); - fprintf(dumpfid, "\ndumpId hash %d, entry at %u: block %d, index %d\n", + fprintf(dumpfid, + "\ndumpId hash %d, entry at %u: block %d, index %d\n", hash, dbAddr, block, index); - fprintf(dumpfid, "----------------------------\n"); + fprintf(dumpfid, + "----------------------------\n"); dump_ntoh(&diskDump, &hostDump); printDump(dumpfid, &hostDump); dbAddr = hostDump.idHashChain; } break; - - case HT_dumpName_FUNCTION: + + case HT_dumpName_FUNCTION: { struct dump hostDump, diskDump; - eval = cdbread (ut, dump_BLOCK, dbAddr, &diskDump, sizeof(diskDump)); - if (eval) ERROR(eval); + eval = + cdbread(ut, dump_BLOCK, dbAddr, &diskDump, + sizeof(diskDump)); + if (eval) + ERROR(eval); fprintf(dumpfid, "\ndumpname hash %d, entry at %u: block %d, index %d\n", hash, dbAddr, block, index); - fprintf(dumpfid, "----------------------------\n"); + fprintf(dumpfid, + "----------------------------\n"); dump_ntoh(&diskDump, &hostDump); printDump(dumpfid, &hostDump); dbAddr = hostDump.nameHashChain; } break; - case HT_tapeName_FUNCTION: + case HT_tapeName_FUNCTION: { struct tape hostTape, diskTape; - eval = cdbread (ut, tape_BLOCK, dbAddr, &diskTape, sizeof(diskTape)); - if (eval) ERROR(eval); + eval = + cdbread(ut, tape_BLOCK, dbAddr, &diskTape, + sizeof(diskTape)); + if (eval) + ERROR(eval); - fprintf(dumpfid, + fprintf(dumpfid, "\ntapename hash %d, entry at %u: block %d, index %d\n", hash, dbAddr, block, index); - fprintf(dumpfid, "----------------------------\n"); + fprintf(dumpfid, + "----------------------------\n"); tape_ntoh(&diskTape, &hostTape); printTape(dumpfid, &hostTape); dbAddr = hostTape.nameHashChain; } break; - case HT_volName_FUNCTION: + case HT_volName_FUNCTION: { struct volInfo hostVolInfo, diskVolInfo; - eval = cdbread (ut, volInfo_BLOCK, dbAddr, &diskVolInfo, sizeof(diskVolInfo)); - if (eval) ERROR(eval); + eval = + cdbread(ut, volInfo_BLOCK, dbAddr, + &diskVolInfo, sizeof(diskVolInfo)); + if (eval) + ERROR(eval); - fprintf(dumpfid, + fprintf(dumpfid, "\nvolname hash %d, entry at %u: block %d, index %d\n", hash, dbAddr, block, index); - fprintf(dumpfid, "----------------------------\n"); + fprintf(dumpfid, + "----------------------------\n"); volInfo_ntoh(&diskVolInfo, &hostVolInfo); printVolInfo(dumpfid, &hostVolInfo); dbAddr = hostVolInfo.nameHashChain; @@ -3467,41 +3780,44 @@ afs_int32 T_DumpDatabase (call, filename) hostVolInfo.firstFragment); } break; - - default: + + default: fprintf(dumpfid, "unknown type %d\n", type); break; - - } /*s*/ - } /*w*/ - } /*f*/ - } /*fo*/ - } /*ft*/ + + } /*s */ + } /*w */ + } /*f */ + } /*fo */ + } /*ft */ error_exit: - code = ubik_EndTrans(ut); /* is this safe if no ut started ?*/ - if (dumpfid) fclose(dumpfid); - if (path) free(path); - return(code); + code = ubik_EndTrans(ut); /* is this safe if no ut started ? */ + if (dumpfid) + fclose(dumpfid); + if (path) + free(path); + return (code); } volFragsDump(ut, dumpfid, dbAddr) - struct ubik_trans *ut; - FILE *dumpfid; - dbadr dbAddr; + struct ubik_trans *ut; + FILE *dumpfid; + dbadr dbAddr; { struct volFragment hostVolFragment, diskVolFragment; afs_int32 code; int block, index; - - while (dbAddr) - { - code = cdbread (ut, volFragment_BLOCK, dbAddr, &diskVolFragment, sizeof(diskVolFragment)); - if (code) { /* don't be fussy about errors */ + + while (dbAddr) { + code = + cdbread(ut, volFragment_BLOCK, dbAddr, &diskVolFragment, + sizeof(diskVolFragment)); + if (code) { /* don't be fussy about errors */ fprintf(dumpfid, "volFragsDump: Error reading database\n"); - return(0); + return (0); } - + fprintf(dumpfid, "\nvolfragment entry at %u: block %d, index %d\n", dbAddr, block, index); fprintf(dumpfid, "----------------------------\n"); @@ -3509,7 +3825,7 @@ volFragsDump(ut, dumpfid, dbAddr) printVolFragment(dumpfid, &hostVolFragment); dbAddr = hostVolFragment.sameNameChain; } - return(0); + return (0); } #ifdef notdef @@ -3570,7 +3886,7 @@ tapeDiskToHost(diskTapePtr, hostTapePtr) dumpDiskToHost(diskDumpPtr, hostDumpPtr) struct dump *diskDumpPtr, *hostDumpPtr; { - hostDumpPtr->id = ntohl(diskDumpPtr->id); + hostDumpPtr->id = ntohl(diskDumpPtr->id); hostDumpPtr->idHashChain = ntohl(diskDumpPtr->idHashChain); strcpy(hostDumpPtr->dumpName, diskDumpPtr->dumpName); strcpy(hostDumpPtr->dumpPath, diskDumpPtr->dumpPath); @@ -3591,7 +3907,7 @@ dumpDiskToHost(diskDumpPtr, hostDumpPtr) #endif /* notdef */ -checkHash(ut,hashType) +checkHash(ut, hashType) struct ubik_trans *ut; int hashType; { @@ -3602,61 +3918,60 @@ checkHash(ut,hashType) afs_int32 code; mhtPtr = ht_GetType(hashType, &entrySize); - if ( mhtPtr == 0 ) + if (mhtPtr == 0) ERROR(-1); - for ( old = 0; old < 1; old++) - { + for (old = 0; old < 1; old++) { LogDebug(5, "\nold = %d\n", old); printMemoryHashTable(stdout, mhtPtr); LogDebug(5, "\n"); - hashTableLength = ( old ? mhtPtr->oldLength : mhtPtr->length); + hashTableLength = (old ? mhtPtr->oldLength : mhtPtr->length); - for ( bucket = 0; bucket < hashTableLength; bucket++ ) - { + for (bucket = 0; bucket < hashTableLength; bucket++) { dbadr entryAddr; - entryAddr = ht_LookupBucket (ut, mhtPtr, bucket, old); - while (entryAddr != 0) - { - LogDebug(6, "bucket %d has disk addr %d\n", bucket, entryAddr); - switch (hashType) - { - case HT_dumpIden_FUNCTION: - { - struct dump diskDump, hostDump; - - code = dbread(ut, entryAddr, &diskDump, entrySize); - if (code) ERROR(-1); - - dump_ntoh(&diskDump, &hostDump); - printDump(stdout, &hostDump); - entryAddr = hostDump.idHashChain; - } - break; - - case HT_dumpName_FUNCTION: + entryAddr = ht_LookupBucket(ut, mhtPtr, bucket, old); + while (entryAddr != 0) { + LogDebug(6, "bucket %d has disk addr %d\n", bucket, + entryAddr); + switch (hashType) { + case HT_dumpIden_FUNCTION: + { + struct dump diskDump, hostDump; + + code = dbread(ut, entryAddr, &diskDump, entrySize); + if (code) + ERROR(-1); + + dump_ntoh(&diskDump, &hostDump); + printDump(stdout, &hostDump); + entryAddr = hostDump.idHashChain; + } break; - case HT_tapeName_FUNCTION: + case HT_dumpName_FUNCTION: break; - case HT_volName_FUNCTION: - { - struct volInfo diskVolInfo, hostVolInfo; + case HT_tapeName_FUNCTION: + break; - code = dbread(ut, entryAddr, &diskVolInfo, entrySize); - if (code) ERROR(-1); + case HT_volName_FUNCTION: + { + struct volInfo diskVolInfo, hostVolInfo; - volInfo_ntoh(&diskVolInfo, &hostVolInfo); - printVolInfo(stdout, &hostVolInfo); - entryAddr = hostVolInfo.nameHashChain; - break; - } - } + code = dbread(ut, entryAddr, &diskVolInfo, entrySize); + if (code) + ERROR(-1); + + volInfo_ntoh(&diskVolInfo, &hostVolInfo); + printVolInfo(stdout, &hostVolInfo); + entryAddr = hostVolInfo.nameHashChain; + break; + } + } } } } error_exit: - return(code); + return (code); } diff --git a/src/budb/server.c b/src/budb/server.c index 44db9ee78..b61d3df7b 100644 --- a/src/budb/server.c +++ b/src/budb/server.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifdef AFS_NT40_ENV #include @@ -61,56 +62,56 @@ RCSID("$Header$"); extern afs_int32 ubik_lastYesTime; extern afs_int32 ubik_nBuffers; -struct ubik_dbase *BU_dbase; -struct afsconf_dir *BU_conf; /* for getting cell info */ +struct ubik_dbase *BU_dbase; +struct afsconf_dir *BU_conf; /* for getting cell info */ char lcell[MAXKTCREALMLEN]; afs_int32 myHost = 0; -int helpOption; +int helpOption; /* server's global configuration information. This is exported to other * files/routines */ -buServerConfT globalConf; -buServerConfP globalConfPtr = &globalConf; +buServerConfT globalConf; +buServerConfP globalConfPtr = &globalConf; char dbDir[AFSDIR_PATH_MAX], cellConfDir[AFSDIR_PATH_MAX]; /* debugging control */ int debugging = 0; /* check whether caller is authorized to manage RX statistics */ -int BU_rxstat_userok(call) - struct rx_call *call; +int +BU_rxstat_userok(call) + struct rx_call *call; { return afsconf_SuperUser(BU_conf, call, NULL); } int -convert_cell_to_ubik (cellinfo, myHost, serverList) +convert_cell_to_ubik(cellinfo, myHost, serverList) struct afsconf_cell *cellinfo; - afs_int32 *myHost; - afs_int32 *serverList; -{ - int i; + afs_int32 *myHost; + afs_int32 *serverList; +{ + int i; char hostname[64]; struct hostent *th; /* get this host */ - gethostname(hostname,sizeof(hostname)); + gethostname(hostname, sizeof(hostname)); th = gethostbyname(hostname); - if (!th) - { + if (!th) { printf("prserver: couldn't get address of this host.\n"); BUDB_EXIT(1); } memcpy(myHost, th->h_addr, sizeof(afs_int32)); - for (i=0; inumServers; i++) + for (i = 0; i < cellinfo->numServers; i++) /* omit my host from serverList */ - if (cellinfo->hostAddr[i].sin_addr.s_addr != *myHost) + if (cellinfo->hostAddr[i].sin_addr.s_addr != *myHost) *serverList++ = cellinfo->hostAddr[i].sin_addr.s_addr; - *serverList = 0; /* terminate list */ + *serverList = 0; /* terminate list */ return 0; } @@ -119,11 +120,12 @@ convert_cell_to_ubik (cellinfo, myHost, serverList) * if the -help option was not within the command line. * If it were, this routine would never have been called. */ -static int MyBeforeProc(as) - register struct cmd_syndesc *as; +static int +MyBeforeProc(as) + register struct cmd_syndesc *as; { - helpOption = 0; - return 0; + helpOption = 0; + return 0; } /* initializeCommands @@ -138,29 +140,28 @@ initializeArgHandler() cmd_SetBeforeProc(MyBeforeProc, NULL); - cptr = cmd_CreateSyntax(NULL, argHandler, NULL, - "Backup database server"); + cptr = cmd_CreateSyntax(NULL, argHandler, NULL, "Backup database server"); cmd_AddParm(cptr, "-database", CMD_SINGLE, CMD_OPTIONAL, - "database directory"); + "database directory"); cmd_AddParm(cptr, "-cellservdb", CMD_SINGLE, CMD_OPTIONAL, - "cell configuration directory"); + "cell configuration directory"); cmd_AddParm(cptr, "-resetdb", CMD_FLAG, CMD_OPTIONAL, - "truncate the database"); + "truncate the database"); cmd_AddParm(cptr, "-noauth", CMD_FLAG, CMD_OPTIONAL, - "run without authentication"); + "run without authentication"); cmd_AddParm(cptr, "-smallht", CMD_FLAG, CMD_OPTIONAL, - "use small hash tables"); + "use small hash tables"); cmd_AddParm(cptr, "-servers", CMD_LIST, CMD_OPTIONAL, - "list of ubik database servers"); + "list of ubik database servers"); cmd_AddParm(cptr, "-ubikbuffers", CMD_SINGLE, CMD_OPTIONAL, - "the number of ubik buffers"); + "the number of ubik buffers"); } @@ -173,21 +174,19 @@ argHandler(as, arock) /* globalConfPtr provides the handle for the configuration information */ /* database directory */ - if ( as->parms[0].items != 0 ) - { - globalConfPtr->databaseDirectory = - (char *) malloc(strlen(as->parms[0].items->data)+1); - if ( globalConfPtr->databaseDirectory == 0 ) + if (as->parms[0].items != 0) { + globalConfPtr->databaseDirectory = + (char *)malloc(strlen(as->parms[0].items->data) + 1); + if (globalConfPtr->databaseDirectory == 0) BUDB_EXIT(-1); strcpy(globalConfPtr->databaseDirectory, as->parms[0].items->data); } /* -cellservdb, cell configuration directory */ - if ( as->parms[1].items != 0 ) - { - globalConfPtr->cellConfigdir = - (char *) malloc(strlen(as->parms[1].items->data)+1); - if ( globalConfPtr->cellConfigdir == 0 ) + if (as->parms[1].items != 0) { + globalConfPtr->cellConfigdir = + (char *)malloc(strlen(as->parms[1].items->data) + 1); + if (globalConfPtr->cellConfigdir == 0) BUDB_EXIT(-1); strcpy(globalConfPtr->cellConfigdir, as->parms[1].items->data); @@ -196,25 +195,26 @@ argHandler(as, arock) } /* truncate the database */ - if ( as->parms[2].items != 0 ) + if (as->parms[2].items != 0) truncateDatabase(); /* run without authentication */ - if ( as->parms[3].items != 0 ) + if (as->parms[3].items != 0) globalConfPtr->debugFlags |= DF_NOAUTH; /* use small hash tables */ - if ( as->parms[4].items != 0 ) + if (as->parms[4].items != 0) globalConfPtr->debugFlags |= DF_SMALLHT; /* user provided list of ubik database servers */ - if ( as->parms[5].items != 0 ) + if (as->parms[5].items != 0) parseServerList(as->parms[5].items); /* user provided the number of ubik buffers */ - if ( as->parms[6].items != 0 ) + if (as->parms[6].items != 0) ubik_nBuffers = atoi(as->parms[6].items->data); - else ubik_nBuffers = 0; + else + ubik_nBuffers = 0; return 0; } @@ -233,17 +233,16 @@ parseServerList(itemPtr) save = itemPtr; /* compute number of servers in the list */ - while ( itemPtr ) - { + while (itemPtr) { nservers++; itemPtr = itemPtr->next; } LogDebug(3, "%d servers\n", nservers); - + /* now can allocate the space for the server arguments */ - serverArgs = (char **) malloc( (nservers+2) * sizeof(char *) ); - if ( serverArgs == 0 ) + serverArgs = (char **)malloc((nservers + 2) * sizeof(char *)); + if (serverArgs == 0) ERROR(-1); ptr = serverArgs; @@ -252,23 +251,22 @@ parseServerList(itemPtr) /* now go through and construct the list of servers */ itemPtr = save; - while ( itemPtr ) - { + while (itemPtr) { *ptr++ = itemPtr->data; itemPtr = itemPtr->next; } - code = ubik_ParseServerList(nservers+2, serverArgs, - &globalConfPtr->myHost, - globalConfPtr->serverList); - if ( code ) + code = + ubik_ParseServerList(nservers + 2, serverArgs, &globalConfPtr->myHost, + globalConfPtr->serverList); + if (code) ERROR(code); - + /* free space for the server args */ - free( (char *) serverArgs); - -error_exit: - return(code); + free((char *)serverArgs); + + error_exit: + return (code); } /* truncateDatabase @@ -281,10 +279,11 @@ truncateDatabase() afs_int32 code = 0; int fd; - path = (char *) malloc(strlen(globalConfPtr->databaseDirectory) + - strlen(globalConfPtr->databaseName) + - strlen(globalConfPtr->databaseExtension) + 1); - if ( path == 0 ) + path = + (char *)malloc(strlen(globalConfPtr->databaseDirectory) + + strlen(globalConfPtr->databaseName) + + strlen(globalConfPtr->databaseExtension) + 1); + if (path == 0) ERROR(-1); /* construct the database name */ @@ -296,14 +295,14 @@ truncateDatabase() if (!fd) { code = errno; } else { - if (ftruncate(fd, 0) != 0 ) { + if (ftruncate(fd, 0) != 0) { code = errno; } else close(fd); } -error_exit: - return(code); + error_exit: + return (code); } @@ -312,30 +311,30 @@ error_exit: #include "AFS_component_version_number.c" main(argc, argv) - int argc; + int argc; char *argv[]; { char *whoami = argv[0]; char *dbNamePtr = 0; - struct afsconf_cell cellinfo; - time_t currentTime; - afs_int32 code = 0; + struct afsconf_cell cellinfo; + time_t currentTime; + afs_int32 code = 0; struct rx_service *tservice; struct rx_securityClass *sca[3]; - + extern int afsconf_ServerAuth(); extern int afsconf_CheckAuth(); extern int rx_stackSize; extern int BUDB_ExecuteRequest(); - + #ifdef AFS_NT40_ENV /* initialize winsock */ - if (afs_winsockInit()<0) { - ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0],0); - fprintf(stderr, "%s: Couldn't initialize winsock.\n", whoami); - exit(1); + if (afs_winsockInit() < 0) { + ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0); + fprintf(stderr, "%s: Couldn't initialize winsock.\n", whoami); + exit(1); } #endif @@ -347,7 +346,7 @@ main(argc, argv) * generated which, in many cases, isn't too useful. */ struct sigaction nsa; - + sigemptyset(&nsa.sa_mask); nsa.sa_handler = SIG_DFL; nsa.sa_flags = SA_FULLDUMP; @@ -364,7 +363,7 @@ main(argc, argv) #ifdef AFS_NT40_ENV ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0); #endif - com_err(whoami,errno,"; Unable to obtain AFS server directory."); + com_err(whoami, errno, "; Unable to obtain AFS server directory."); exit(2); } @@ -387,63 +386,59 @@ main(argc, argv) BUDB_EXIT(-1); } */ - - srandom (1); + + srandom(1); /* process the user supplied args */ helpOption = 1; code = cmd_Dispatch(argc, argv); - if ( code ) + if (code) ERROR(code); /* exit if there was a help option */ if (helpOption) - BUDB_EXIT(0); + BUDB_EXIT(0); /* open the log file */ globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a"); - if ( globalConfPtr->log == NULL ) - { - printf("Can't open log file %s - aborting\n", + if (globalConfPtr->log == NULL) { + printf("Can't open log file %s - aborting\n", AFSDIR_SERVER_BUDBLOG_FILEPATH); BUDB_EXIT(-1); } - /* keep log closed so can remove it */ + /* keep log closed so can remove it */ - fclose(globalConfPtr->log); + fclose(globalConfPtr->log); /* open the cell's configuration directory */ LogDebug(4, "opening %s\n", globalConfPtr->cellConfigdir); BU_conf = afsconf_Open(globalConfPtr->cellConfigdir); - if ( BU_conf == 0 ) - { + if (BU_conf == 0) { LogError(code, "Failed getting cell info\n"); com_err(whoami, code, "Failed getting cell info"); ERROR(BUDB_NOCELLS); } code = afsconf_GetLocalCell(BU_conf, lcell, sizeof(lcell)); - if ( code ) - { + if (code) { LogError(0, "** Can't determine local cell name!\n"); ERROR(code); } - if ( globalConfPtr->myHost == 0 ) - { + if (globalConfPtr->myHost == 0) { /* if user hasn't supplied a list of servers, extract server * list from the cell's database */ LogDebug(1, "Using server list from %s cell database.\n", lcell); - code = afsconf_GetCellInfo (BU_conf, lcell, 0, &cellinfo); - code = convert_cell_to_ubik (&cellinfo, - &globalConfPtr->myHost, - globalConfPtr->serverList); - if ( code ) + code = afsconf_GetCellInfo(BU_conf, lcell, 0, &cellinfo); + code = + convert_cell_to_ubik(&cellinfo, &globalConfPtr->myHost, + globalConfPtr->serverList); + if (code) ERROR(code); } @@ -458,28 +453,25 @@ main(argc, argv) ubik_CheckRXSecurityRock = (char *)BU_conf; if (ubik_nBuffers == 0) - ubik_nBuffers = 400; + ubik_nBuffers = 400; LogError(0, "Will allocate %d ubik buffers\n", ubik_nBuffers); - dbNamePtr = (char *) malloc(strlen(globalConfPtr->databaseDirectory) + - strlen(globalConfPtr->databaseName) + 1); - if ( dbNamePtr == 0 ) - ERROR(-1); + dbNamePtr = + (char *)malloc(strlen(globalConfPtr->databaseDirectory) + + strlen(globalConfPtr->databaseName) + 1); + if (dbNamePtr == 0) + ERROR(-1); /* construct the database name */ strcpy(dbNamePtr, globalConfPtr->databaseDirectory); strcat(dbNamePtr, globalConfPtr->databaseName); /* name prefix */ - rx_SetRxDeadTime(60); /* 60 seconds inactive before timeout */ + rx_SetRxDeadTime(60); /* 60 seconds inactive before timeout */ - code = ubik_ServerInit(globalConfPtr->myHost, - htons(AFSCONF_BUDBPORT), - globalConfPtr->serverList, - dbNamePtr, /* name prefix */ + code = ubik_ServerInit(globalConfPtr->myHost, htons(AFSCONF_BUDBPORT), globalConfPtr->serverList, dbNamePtr, /* name prefix */ &BU_dbase); - if (code) - { + if (code) { LogError(code, "Ubik init failed\n"); com_err(whoami, code, "Ubik init failed"); ERROR(code); @@ -487,18 +479,17 @@ main(argc, argv) sca[RX_SCINDEX_NULL] = rxnull_NewServerSecurityObject(); sca[RX_SCINDEX_VAB] = 0; - sca[RX_SCINDEX_KAD] = rxkad_NewServerSecurityObject(rxkad_clear, - BU_conf, - afsconf_GetKey, - NULL); + sca[RX_SCINDEX_KAD] = + rxkad_NewServerSecurityObject(rxkad_clear, BU_conf, afsconf_GetKey, + NULL); /* Disable jumbograms */ rx_SetNoJumbo(); - tservice = rx_NewService(0, BUDB_SERVICE, "BackupDatabase", - sca, 3, BUDB_ExecuteRequest); - if (tservice == (struct rx_service *)0) - { + tservice = + rx_NewService(0, BUDB_SERVICE, "BackupDatabase", sca, 3, + BUDB_ExecuteRequest); + if (tservice == (struct rx_service *)0) { LogError(0, "Could not create backup database rx service\n"); printf("Could not create backup database rx service\n"); BUDB_EXIT(3); @@ -516,78 +507,75 @@ main(argc, argv) memset(dumpSyncPtr, 0, sizeof(*dumpSyncPtr)); Lock_Init(&dumpSyncPtr->ds_lock); - rx_StartServer(0); /* start handling requests */ + rx_StartServer(0); /* start handling requests */ code = InitProcs(); - if ( code ) + if (code) ERROR(code); currentTime = time(0); LogError(0, "Ready to process requests at %s\n", ctime(¤tTime)); - rx_ServerProc(); /* donate this LWP */ + rx_ServerProc(); /* donate this LWP */ -error_exit: + error_exit: osi_audit(BUDB_FinishEvent, code, AUD_END); - return(code); + return (code); } consistencyCheckDb() { /* do consistency checks on structure sizes */ - if ( (sizeof(struct htBlock) > BLOCKSIZE) - || (sizeof(struct vfBlock) > BLOCKSIZE) - || (sizeof(struct viBlock) > BLOCKSIZE) - || (sizeof(struct dBlock) > BLOCKSIZE) - || (sizeof(struct tBlock) > BLOCKSIZE) - ) - { - fprintf (stderr, "Block layout error!\n"); - BUDB_EXIT (99); + if ((sizeof(struct htBlock) > BLOCKSIZE) + || (sizeof(struct vfBlock) > BLOCKSIZE) + || (sizeof(struct viBlock) > BLOCKSIZE) + || (sizeof(struct dBlock) > BLOCKSIZE) + || (sizeof(struct tBlock) > BLOCKSIZE) + ) { + fprintf(stderr, "Block layout error!\n"); + BUDB_EXIT(99); } } -/*VARARGS*/ -LogDebug(level, a,b,c,d,e,f,g,h,i) - int level; - char *a, *b, *c, *d, *e, *f, *g, *h, *i; + /*VARARGS*/ +LogDebug(level, a, b, c, d, e, f, g, h, i) + int level; + char *a, *b, *c, *d, *e, *f, *g, *h, *i; { - if ( debugging >= level) - { + if (debugging >= level) { /* log normally closed so can remove it */ - globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a"); - if ( globalConfPtr->log != NULL ) - { - fprintf(globalConfPtr->log, a, b, c, d, e, f, g, h, i); - fflush(globalConfPtr->log); - fclose(globalConfPtr->log); + globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a"); + if (globalConfPtr->log != NULL) { + fprintf(globalConfPtr->log, a, b, c, d, e, f, g, h, i); + fflush(globalConfPtr->log); + fclose(globalConfPtr->log); } } } -static char *TimeStamp(time_t t) +static char * +TimeStamp(time_t t) { - struct tm *lt; - static char timestamp[20]; + struct tm *lt; + static char timestamp[20]; - lt = localtime(&t); - strftime (timestamp, 20, "%m/%d/%Y %T", lt); - return timestamp; + lt = localtime(&t); + strftime(timestamp, 20, "%m/%d/%Y %T", lt); + return timestamp; } -/*VARARGS*/ -Log(a,b,c,d,e,f,g,h,i) - char *a, *b, *c, *d, *e, *f, *g, *h, *i; + /*VARARGS*/ +Log(a, b, c, d, e, f, g, h, i) + char *a, *b, *c, *d, *e, *f, *g, *h, *i; { time_t now; globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a"); - if ( globalConfPtr->log != NULL ) - { - now = time(0); + if (globalConfPtr->log != NULL) { + now = time(0); fprintf(globalConfPtr->log, "%s ", TimeStamp(now)); fprintf(globalConfPtr->log, a, b, c, d, e, f, g, h, i); @@ -596,21 +584,20 @@ Log(a,b,c,d,e,f,g,h,i) } } -/*VARARGS*/ -LogError(code, a,b,c,d,e,f,g,h,i) -long code; -char *a, *b, *c, *d, *e, *f, *g, *h, *i; + /*VARARGS*/ +LogError(code, a, b, c, d, e, f, g, h, i) + long code; + char *a, *b, *c, *d, *e, *f, *g, *h, *i; { time_t now; globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a"); - if ( globalConfPtr->log != NULL ) - { - now = time(0); + if (globalConfPtr->log != NULL) { + now = time(0); fprintf(globalConfPtr->log, "%s ", TimeStamp(now)); - if ( code ) + if (code) fprintf(globalConfPtr->log, "%s: %s\n", error_table_name(code), error_message(code)); fprintf(globalConfPtr->log, a, b, c, d, e, f, g, h, i); @@ -631,12 +618,11 @@ LogNetDump(dumpPtr) { struct dump hostDump; extern buServerConfP globalConfPtr; - + dump_ntoh(dumpPtr, &hostDump); globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a"); - if ( globalConfPtr->log != NULL ) - { + if (globalConfPtr->log != NULL) { printDump(globalConfPtr->log, &hostDump); fclose(globalConfPtr->log); } diff --git a/src/budb/struct_ops.c b/src/budb/struct_ops.c index ca3b5b236..75c3aca6b 100644 --- a/src/budb/struct_ops.c +++ b/src/budb/struct_ops.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #ifdef AFS_NT40_ENV @@ -39,8 +40,8 @@ printDbHeader(ptr) struct DbHeader *ptr; { printf("version = %d\n", ptr->dbversion); - printf("created = %s", ctime((time_t *)&ptr->created)); - printf("cell = %s\n",ptr->cell); + printf("created = %s", ctime((time_t *) & ptr->created)); + printf("cell = %s\n", ptr->cell); printf("lastDumpId = %u\n", ptr->lastDumpId); printf("lastInstanceId = %d\n", ptr->lastInstanceId); printf("lastTapeId = %d\n", ptr->lastTapeId); @@ -50,18 +51,18 @@ printDump(fid, dptr) FILE *fid; struct dump *dptr; { - fprintf(fid,"id = %u\n", dptr->id); - fprintf(fid,"idHashChain = %d\n", dptr->idHashChain); - fprintf(fid,"name = %s\n", dptr->dumpName); - fprintf(fid,"vsname = %s\n", dptr->volumeSet); - fprintf(fid,"dumpPath = %s\n", dptr->dumpPath); - fprintf(fid,"nameHashChain = %d\n", dptr->nameHashChain); - fprintf(fid,"flags = 0x%x\n", dptr->flags); - fprintf(fid,"parent = %u\n", dptr->parent); - fprintf(fid,"created = %s", ctime((time_t *)&dptr->created)); - fprintf(fid,"nVolumes = %d\n", dptr->nVolumes); + fprintf(fid, "id = %u\n", dptr->id); + fprintf(fid, "idHashChain = %d\n", dptr->idHashChain); + fprintf(fid, "name = %s\n", dptr->dumpName); + fprintf(fid, "vsname = %s\n", dptr->volumeSet); + fprintf(fid, "dumpPath = %s\n", dptr->dumpPath); + fprintf(fid, "nameHashChain = %d\n", dptr->nameHashChain); + fprintf(fid, "flags = 0x%x\n", dptr->flags); + fprintf(fid, "parent = %u\n", dptr->parent); + fprintf(fid, "created = %s", ctime((time_t *) & dptr->created)); + fprintf(fid, "nVolumes = %d\n", dptr->nVolumes); /* printTapeSet(&dptr->tapes); */ - fprintf(fid,"firstTape = %d\n", dptr->firstTape); + fprintf(fid, "firstTape = %d\n", dptr->firstTape); /* printKtcPrincipal(&dptr->dumper); */ } @@ -75,18 +76,25 @@ printDumpEntry(deptr) printf("parent = %u\n", deptr->parent); printf("level = %d\n", deptr->level); printf("flags = 0x%x", deptr->flags); - if (deptr->flags == 0) printf(": Successful"); - if (deptr->flags & BUDB_DUMP_INCOMPLETE) printf(": Incomplete"); - if (deptr->flags & BUDB_DUMP_TAPEERROR) printf(": Tape error"); - if (deptr->flags & BUDB_DUMP_INPROGRESS) printf(": In progress"); - if (deptr->flags & BUDB_DUMP_ABORTED) printf(": Aborted"); - if (deptr->flags & BUDB_DUMP_ADSM) printf(": (ADSM)"); /* XBSA interface to ADSM */ - if (deptr->flags & BUDB_DUMP_BUTA) printf(": (BUTA)"); /* buta dump */ - printf("\n"); + if (deptr->flags == 0) + printf(": Successful"); + if (deptr->flags & BUDB_DUMP_INCOMPLETE) + printf(": Incomplete"); + if (deptr->flags & BUDB_DUMP_TAPEERROR) + printf(": Tape error"); + if (deptr->flags & BUDB_DUMP_INPROGRESS) + printf(": In progress"); + if (deptr->flags & BUDB_DUMP_ABORTED) + printf(": Aborted"); + if (deptr->flags & BUDB_DUMP_ADSM) + printf(": (ADSM)"); /* XBSA interface to ADSM */ + if (deptr->flags & BUDB_DUMP_BUTA) + printf(": (BUTA)"); /* buta dump */ + printf("\n"); printf("volumeSet = %s\n", deptr->volumeSetName); printf("dump path = %s\n", deptr->dumpPath); printf("name = %s\n", deptr->name); - printf("created = %s", ctime((time_t *)&deptr->created)); + printf("created = %s", ctime((time_t *) & deptr->created)); printf("nVolumes = %d\n", deptr->nVolumes); printTapeSet(&deptr->tapes, (deptr->flags & BUDB_DUMP_XBSA_NSS)); @@ -101,14 +109,14 @@ printHashTable(fid, htptr) FILE *fid; struct hashTable *htptr; { - fprintf(fid,"functionType = %d\n", htptr->functionType); - fprintf(fid,"threadOffset = %d\n", htptr->threadOffset); - fprintf(fid,"entries = %d\n", htptr->entries); - fprintf(fid,"length = %d\n", htptr->length); - fprintf(fid,"table = %d\n", htptr->table); - fprintf(fid,"progress = %d\n", htptr->progress); - fprintf(fid,"oldLength = %d\n", htptr->oldLength); - fprintf(fid,"oldTable = %d\n", htptr->oldTable); + fprintf(fid, "functionType = %d\n", htptr->functionType); + fprintf(fid, "threadOffset = %d\n", htptr->threadOffset); + fprintf(fid, "entries = %d\n", htptr->entries); + fprintf(fid, "length = %d\n", htptr->length); + fprintf(fid, "table = %d\n", htptr->table); + fprintf(fid, "progress = %d\n", htptr->progress); + fprintf(fid, "oldLength = %d\n", htptr->oldLength); + fprintf(fid, "oldTable = %d\n", htptr->oldTable); } /* printMemoryHashTable @@ -118,11 +126,11 @@ printMemoryHashTable(fid, mhtptr) FILE *fid; struct memoryHashTable *mhtptr; { - fprintf(fid,"threadOffset = %d\n", mhtptr->threadOffset); - fprintf(fid,"length = %d\n", mhtptr->length); - fprintf(fid,"progress = %d\n", mhtptr->progress); - fprintf(fid,"size = %d\n", mhtptr->size); - fprintf(fid,"oldsize = %d\n", mhtptr->oldSize); + fprintf(fid, "threadOffset = %d\n", mhtptr->threadOffset); + fprintf(fid, "length = %d\n", mhtptr->length); + fprintf(fid, "progress = %d\n", mhtptr->progress); + fprintf(fid, "size = %d\n", mhtptr->size); + fprintf(fid, "oldsize = %d\n", mhtptr->oldSize); } printPrincipal(ptr) @@ -145,20 +153,20 @@ printTape(fid, tptr) FILE *fid; struct tape *tptr; { - fprintf(fid,"name = %s\n", tptr->name); - fprintf(fid,"nameHashChain = %d\n", tptr->nameHashChain); - fprintf(fid,"flags = 0x%x\n", tptr->flags); - fprintf(fid,"written = %s", ctime((time_t *)&tptr->written)); - fprintf(fid,"nMBytes = %d\n", tptr->nMBytes); - fprintf(fid,"nBytes = %d\n", tptr->nBytes); - fprintf(fid,"nFiles = %d\n", tptr->nFiles); - fprintf(fid,"nVolumes = %d\n", tptr->nVolumes); - fprintf(fid,"seq = %d\n", tptr->seq); - fprintf(fid,"dump = %d\n", tptr->dump); - fprintf(fid,"nextTape = %d\n", tptr->nextTape); - fprintf(fid,"firstVol = %d\n", tptr->firstVol); - fprintf(fid,"labelPos = %d\n", tptr->labelpos); - fprintf(fid,"useCount = %d\n", tptr->useCount); + fprintf(fid, "name = %s\n", tptr->name); + fprintf(fid, "nameHashChain = %d\n", tptr->nameHashChain); + fprintf(fid, "flags = 0x%x\n", tptr->flags); + fprintf(fid, "written = %s", ctime((time_t *) & tptr->written)); + fprintf(fid, "nMBytes = %d\n", tptr->nMBytes); + fprintf(fid, "nBytes = %d\n", tptr->nBytes); + fprintf(fid, "nFiles = %d\n", tptr->nFiles); + fprintf(fid, "nVolumes = %d\n", tptr->nVolumes); + fprintf(fid, "seq = %d\n", tptr->seq); + fprintf(fid, "dump = %d\n", tptr->dump); + fprintf(fid, "nextTape = %d\n", tptr->nextTape); + fprintf(fid, "firstVol = %d\n", tptr->firstVol); + fprintf(fid, "labelPos = %d\n", tptr->labelpos); + fprintf(fid, "useCount = %d\n", tptr->useCount); } printTapeEntry(teptr) @@ -166,15 +174,21 @@ printTapeEntry(teptr) { printf("name = %s\n", teptr->name); printf("flags = 0x%x", teptr->flags); - if (teptr->flags & BUDB_TAPE_TAPEERROR) printf(": Error"); - if (teptr->flags & BUDB_TAPE_DELETED) printf(": Deleted"); - if (teptr->flags & BUDB_TAPE_BEINGWRITTEN) printf(": In progress"); - if (teptr->flags & BUDB_TAPE_ABORTED) printf(": Aborted"); - if (teptr->flags & BUDB_TAPE_STAGED) printf(": Staged"); - if (teptr->flags & BUDB_TAPE_WRITTEN) printf(": Successful"); - printf("\n"); - printf("written = %s", ctime((time_t *)&teptr->written)); - printf("expires = %s", cTIME((time_t *)&teptr->expires)); + if (teptr->flags & BUDB_TAPE_TAPEERROR) + printf(": Error"); + if (teptr->flags & BUDB_TAPE_DELETED) + printf(": Deleted"); + if (teptr->flags & BUDB_TAPE_BEINGWRITTEN) + printf(": In progress"); + if (teptr->flags & BUDB_TAPE_ABORTED) + printf(": Aborted"); + if (teptr->flags & BUDB_TAPE_STAGED) + printf(": Staged"); + if (teptr->flags & BUDB_TAPE_WRITTEN) + printf(": Successful"); + printf("\n"); + printf("written = %s", ctime((time_t *) & teptr->written)); + printf("expires = %s", cTIME((time_t *) & teptr->expires)); printf("kBytes Tape Used = %u\n", teptr->useKBytes); printf("nMBytes Data = %d\n", teptr->nMBytes); printf("nBytes Data = %d\n", teptr->nBytes); @@ -188,16 +202,16 @@ printTapeEntry(teptr) printTapeSet(tsptr, nss) struct budb_tapeSet *tsptr; - afs_int32 nss; /* is the tapeserver name an accurate name */ + afs_int32 nss; /* is the tapeserver name an accurate name */ { - printf("Group id = %d\n",tsptr->id ); - printf("tapeServer = %s%s\n", - tsptr->tapeServer, (nss?" (single server)":"")); - printf("format = %s\n",tsptr->format); - printf("maxTapes = %d\n",tsptr->maxTapes); + printf("Group id = %d\n", tsptr->id); + printf("tapeServer = %s%s\n", tsptr->tapeServer, + (nss ? " (single server)" : "")); + printf("format = %s\n", tsptr->format); + printf("maxTapes = %d\n", tsptr->maxTapes); /* printf("a = %d\n",tsptr->a ); */ /* printf("b = %d\n",tsptr->b); */ - printf("Start Tape Seq = %d\n",tsptr->b); + printf("Start Tape Seq = %d\n", tsptr->b); } printVolumeEntry(veptr) @@ -205,20 +219,26 @@ printVolumeEntry(veptr) { printf("name = %s\n", veptr->name); printf("flags = 0x%x", veptr->flags); - if (veptr->flags & BUDB_VOL_TAPEERROR) printf(": Tape Error"); - if (veptr->flags & BUDB_VOL_FILEERROR) printf(": File Error"); - if (veptr->flags & BUDB_VOL_BEINGWRITTEN) printf(": In progress"); - if (veptr->flags & BUDB_VOL_FIRSTFRAG) printf(": First fragment"); - if (veptr->flags & BUDB_VOL_LASTFRAG) printf(": Last fragment"); - if (veptr->flags & BUDB_VOL_ABORTED) printf(": Aborted"); - printf("\n"); + if (veptr->flags & BUDB_VOL_TAPEERROR) + printf(": Tape Error"); + if (veptr->flags & BUDB_VOL_FILEERROR) + printf(": File Error"); + if (veptr->flags & BUDB_VOL_BEINGWRITTEN) + printf(": In progress"); + if (veptr->flags & BUDB_VOL_FIRSTFRAG) + printf(": First fragment"); + if (veptr->flags & BUDB_VOL_LASTFRAG) + printf(": Last fragment"); + if (veptr->flags & BUDB_VOL_ABORTED) + printf(": Aborted"); + printf("\n"); printf("id = %d\n", veptr->id); printf("server = %s\n", veptr->server); printf("partition = %d\n", veptr->partition); printf("tapeSeq = %d\n", veptr->tapeSeq); printf("position = %d\n", veptr->position); - printf("clone = %s", ctime((time_t *)&veptr->clone)); + printf("clone = %s", ctime((time_t *) & veptr->clone)); printf("startByte = %d\n", veptr->startByte); printf("nBytes = %d\n", veptr->nBytes); printf("seq = %d\n", veptr->seq); @@ -226,38 +246,38 @@ printVolumeEntry(veptr) printf("dump = %d\n", veptr->dump); printf("tape = %s\n", veptr->tape); } - + printVolFragment(fid, vfptr) FILE *fid; struct volFragment *vfptr; { - fprintf(fid,"vol = %d\n", vfptr->vol); - fprintf(fid,"sameNameChain = %d\n", vfptr->sameNameChain); - fprintf(fid,"tape = %d\n", vfptr->tape); - fprintf(fid,"sameTapeChain = %d\n", vfptr->sameTapeChain); - fprintf(fid,"position = %d\n", vfptr->position); - fprintf(fid,"clone = %s", ctime((time_t *)&vfptr->clone)); - fprintf(fid,"incTime = %s", ctime((time_t *)&vfptr->incTime)); - fprintf(fid,"startByte = %d\n", vfptr->startByte); - fprintf(fid,"nBytes = %d\n", vfptr->nBytes); - fprintf(fid,"flags = %d\n", vfptr->flags); - fprintf(fid,"sequence = %d\n", vfptr->sequence); + fprintf(fid, "vol = %d\n", vfptr->vol); + fprintf(fid, "sameNameChain = %d\n", vfptr->sameNameChain); + fprintf(fid, "tape = %d\n", vfptr->tape); + fprintf(fid, "sameTapeChain = %d\n", vfptr->sameTapeChain); + fprintf(fid, "position = %d\n", vfptr->position); + fprintf(fid, "clone = %s", ctime((time_t *) & vfptr->clone)); + fprintf(fid, "incTime = %s", ctime((time_t *) & vfptr->incTime)); + fprintf(fid, "startByte = %d\n", vfptr->startByte); + fprintf(fid, "nBytes = %d\n", vfptr->nBytes); + fprintf(fid, "flags = %d\n", vfptr->flags); + fprintf(fid, "sequence = %d\n", vfptr->sequence); } printVolInfo(fid, viptr) FILE *fid; struct volInfo *viptr; { - fprintf(fid,"name = %s\n", viptr->name); - fprintf(fid,"nameHashChain = %d\n", viptr->nameHashChain); - fprintf(fid,"id = %d\n", viptr->id); - fprintf(fid,"server = %s\n", viptr->server); - fprintf(fid,"partition = %d\n", viptr->partition); - fprintf(fid,"flags = 0x%x\n", viptr->flags); - fprintf(fid,"sameNameHead = %d\n", viptr->sameNameHead); - fprintf(fid,"sameNameChain = %d\n", viptr->sameNameChain); - fprintf(fid,"firstFragment = %d\n", viptr->firstFragment); - fprintf(fid,"nFrags = %d\n", viptr->nFrags); + fprintf(fid, "name = %s\n", viptr->name); + fprintf(fid, "nameHashChain = %d\n", viptr->nameHashChain); + fprintf(fid, "id = %d\n", viptr->id); + fprintf(fid, "server = %s\n", viptr->server); + fprintf(fid, "partition = %d\n", viptr->partition); + fprintf(fid, "flags = 0x%x\n", viptr->flags); + fprintf(fid, "sameNameHead = %d\n", viptr->sameNameHead); + fprintf(fid, "sameNameChain = %d\n", viptr->sameNameChain); + fprintf(fid, "firstFragment = %d\n", viptr->firstFragment); + fprintf(fid, "nFrags = %d\n", viptr->nFrags); } @@ -325,7 +345,7 @@ tape_ntoh(netTapePtr, hostTapePtr) dump_ntoh(netDumpPtr, hostDumpPtr) struct dump *netDumpPtr, *hostDumpPtr; { - hostDumpPtr->id = ntohl(netDumpPtr->id); + hostDumpPtr->id = ntohl(netDumpPtr->id); hostDumpPtr->idHashChain = ntohl(netDumpPtr->idHashChain); strcpy(hostDumpPtr->dumpName, netDumpPtr->dumpName); strcpy(hostDumpPtr->dumpPath, netDumpPtr->dumpPath); @@ -429,8 +449,8 @@ tapeSet_hton(hostptr, netptr) struct budb_tapeSet *hostptr, *netptr; { netptr->id = htonl(hostptr->id); - strcpy(netptr->tapeServer, hostptr->tapeServer); - strcpy(netptr->format, hostptr->format); + strcpy(netptr->tapeServer, hostptr->tapeServer); + strcpy(netptr->format, hostptr->format); netptr->maxTapes = htonl(hostptr->maxTapes); netptr->a = htonl(hostptr->a); netptr->b = htonl(hostptr->b); @@ -440,8 +460,8 @@ tapeSet_ntoh(netptr, hostptr) struct budb_tapeSet *netptr, *hostptr; { hostptr->id = ntohl(netptr->id); - strcpy(hostptr->tapeServer, netptr->tapeServer); - strcpy(hostptr->format, netptr->format); + strcpy(hostptr->tapeServer, netptr->tapeServer); + strcpy(hostptr->format, netptr->format); hostptr->maxTapes = ntohl(netptr->maxTapes); hostptr->a = ntohl(netptr->a); hostptr->b = ntohl(netptr->b); @@ -468,7 +488,7 @@ textBlock_ntoh(netptr, hostptr) } textLock_hton(hostptr, netptr) - db_lockP hostptr, netptr; + db_lockP hostptr, netptr; { netptr->type = htonl(hostptr->type); netptr->lockState = htonl(hostptr->lockState); @@ -479,7 +499,7 @@ textLock_hton(hostptr, netptr) } textLock_ntoh(netptr, hostptr) - db_lockP netptr, hostptr; + db_lockP netptr, hostptr; { hostptr->type = ntohl(netptr->type); hostptr->lockState = ntohl(netptr->lockState); @@ -499,7 +519,7 @@ volumeEntry_ntoh(netptr, hostptr) hostptr->partition = ntohl(netptr->partition); hostptr->tapeSeq = ntohl(netptr->tapeSeq); - hostptr->position = ntohl(netptr->position); + hostptr->position = ntohl(netptr->position); hostptr->clone = ntohl(netptr->clone); hostptr->incTime = ntohl(netptr->incTime); hostptr->startByte = ntohl(netptr->startByte); @@ -548,8 +568,9 @@ dumpToBudbDump(dumpPtr, budbDumpPtr) budbDumpPtr->nVolumes = dumpPtr->nVolumes; memcpy(&budbDumpPtr->tapes, &dumpPtr->tapes, sizeof(struct budb_tapeSet)); - copy_ktcPrincipal_to_budbPrincipal(&dumpPtr->dumper, &budbDumpPtr->dumper); - return(0); + copy_ktcPrincipal_to_budbPrincipal(&dumpPtr->dumper, + &budbDumpPtr->dumper); + return (0); } tapeToBudbTape(tapePtr, budbTapePtr) @@ -568,7 +589,7 @@ tapeToBudbTape(tapePtr, budbTapePtr) budbTapePtr->labelpos = tapePtr->labelpos; budbTapePtr->useCount = tapePtr->useCount; budbTapePtr->useKBytes = tapePtr->useKBytes; - return(0); + return (0); } volsToBudbVol(volFragPtr, volInfoPtr, budbVolPtr) @@ -581,7 +602,7 @@ volsToBudbVol(volFragPtr, volInfoPtr, budbVolPtr) budbVolPtr->id = volInfoPtr->id; strcpy(budbVolPtr->server, volInfoPtr->server); budbVolPtr->partition = volInfoPtr->partition; - budbVolPtr->tapeSeq = 0; /* Don't know it so mark invalid */ + budbVolPtr->tapeSeq = 0; /* Don't know it so mark invalid */ budbVolPtr->position = volFragPtr->position; budbVolPtr->clone = volFragPtr->clone; @@ -589,7 +610,7 @@ volsToBudbVol(volFragPtr, volInfoPtr, budbVolPtr) budbVolPtr->startByte = volFragPtr->startByte; budbVolPtr->nBytes = volFragPtr->nBytes; budbVolPtr->seq = volFragPtr->sequence; - return(0); + return (0); } /* ---------------------------------- diff --git a/src/butc/butc_xbsa.c b/src/butc/butc_xbsa.c index 2f6bec203..e2c776444 100644 --- a/src/butc/butc_xbsa.c +++ b/src/butc/butc_xbsa.c @@ -12,7 +12,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #include @@ -30,68 +31,72 @@ extern int debugLevel; char resourceType[20] = "LFS FILE SYSTEM"; #define GOODSTR(s) ((s)?(s):"") -BSA_Int16 (*XBSAInit)(BSA_UInt32 *, SecurityToken *, ObjectOwner *, char **); -BSA_Int16 (*XBSABeginTxn)(BSA_UInt32); -BSA_Int16 (*XBSAEndTxn)(BSA_UInt32, Vote); -BSA_Int16 (*XBSATerminate)(BSA_UInt32); -BSA_Int16 (*XBSAQueryObject)(BSA_UInt32, QueryDescriptor *, ObjectDescriptor *); -BSA_Int16 (*XBSAGetObject)(BSA_UInt32, ObjectDescriptor *, DataBlock *); -BSA_Int16 (*XBSAEndData)(BSA_UInt32); -BSA_Int16 (*XBSACreateObject)(BSA_UInt32, ObjectDescriptor *, DataBlock *); -BSA_Int16 (*XBSADeleteObject)(BSA_UInt32, CopyType, ObjectName *, CopyId *); -BSA_Int16 (*XBSAMarkObjectInactive)(BSA_UInt32, ObjectName *); -BSA_Int16 (*XBSASendData)(BSA_UInt32, DataBlock *); -BSA_Int16 (*XBSAGetData)(BSA_UInt32, DataBlock *); -BSA_Int16 (*XBSAQueryApiVersion)(ApiVersion *); -BSA_Int16 (*XBSAGetEnvironment)(BSA_UInt32, ObjectOwner *, char **); +BSA_Int16(*XBSAInit) (BSA_UInt32 *, SecurityToken *, ObjectOwner *, char **); +BSA_Int16(*XBSABeginTxn) (BSA_UInt32); +BSA_Int16(*XBSAEndTxn) (BSA_UInt32, Vote); +BSA_Int16(*XBSATerminate) (BSA_UInt32); +BSA_Int16(*XBSAQueryObject) (BSA_UInt32, QueryDescriptor *, + ObjectDescriptor *); +BSA_Int16(*XBSAGetObject) (BSA_UInt32, ObjectDescriptor *, DataBlock *); +BSA_Int16(*XBSAEndData) (BSA_UInt32); +BSA_Int16(*XBSACreateObject) (BSA_UInt32, ObjectDescriptor *, DataBlock *); +BSA_Int16(*XBSADeleteObject) (BSA_UInt32, CopyType, ObjectName *, CopyId *); +BSA_Int16(*XBSAMarkObjectInactive) (BSA_UInt32, ObjectName *); +BSA_Int16(*XBSASendData) (BSA_UInt32, DataBlock *); +BSA_Int16(*XBSAGetData) (BSA_UInt32, DataBlock *); +BSA_Int16(*XBSAQueryApiVersion) (ApiVersion *); +BSA_Int16(*XBSAGetEnvironment) (BSA_UInt32, ObjectOwner *, char **); xbsa_error(int rc, struct butx_transactionInfo *info) { switch (rc) { - case BSA_RC_AUTHENTICATION_FAILURE : - ELog(0," XBSA: Authentication failure\n"); + case BSA_RC_AUTHENTICATION_FAILURE: + ELog(0, " XBSA: Authentication failure\n"); break; - case BSA_RC_INVALID_KEYWORD : - ELog(0," XBSA: A specified keyword is invalid\n"); + case BSA_RC_INVALID_KEYWORD: + ELog(0, " XBSA: A specified keyword is invalid\n"); break; - case BSA_RC_TOKEN_EXPIRED : - ELog(0," XBSA: The security token has expired\n"); + case BSA_RC_TOKEN_EXPIRED: + ELog(0, " XBSA: The security token has expired\n"); break; - case ADSM_RC_PSWD_GEN : - if (XBSA_GET_SERVER_TYPE(info->serverType) == XBSA_SERVER_TYPE_ADSM) { - ELog(0," XBSA: Password generation is not supported\n"); + case ADSM_RC_PSWD_GEN: + if (XBSA_GET_SERVER_TYPE(info->serverType) == XBSA_SERVER_TYPE_ADSM) { + ELog(0, " XBSA: Password generation is not supported\n"); } break; - case BSA_RC_BAD_HANDLE : - ELog(0," XBSA: The handle is invalid, %d\n", info->bsaHandle); + case BSA_RC_BAD_HANDLE: + ELog(0, " XBSA: The handle is invalid, %d\n", info->bsaHandle); break; - case BSA_RC_NO_MATCH : - ELog(0," XBSA: There were no matches found for the specified object\n"); + case BSA_RC_NO_MATCH: + ELog(0, + " XBSA: There were no matches found for the specified object\n"); break; - case BSA_RC_MORE_DATA : - ELog(0," XBSA: There were more matches found than expected\n"); + case BSA_RC_MORE_DATA: + ELog(0, " XBSA: There were more matches found than expected\n"); break; - case BSA_RC_NULL_OBJNAME : - ELog(0," XBSA: The object name is null\n"); + case BSA_RC_NULL_OBJNAME: + ELog(0, " XBSA: The object name is null\n"); break; - case BSA_RC_OBJNAME_TOO_LONG : - ELog(0," XBSA: The object name was longer than expected\n"); + case BSA_RC_OBJNAME_TOO_LONG: + ELog(0, " XBSA: The object name was longer than expected\n"); break; - case BSA_RC_DESC_TOO_LONG : - ELog(0," XBSA: The description string was longer than expected\n"); + case BSA_RC_DESC_TOO_LONG: + ELog(0, + " XBSA: The description string was longer than expected\n"); break; - case BSA_RC_OBJINFO_TOO_LONG : - ELog(0," XBSA: The object info string was longer than expected\n"); + case BSA_RC_OBJINFO_TOO_LONG: + ELog(0, + " XBSA: The object info string was longer than expected\n"); break; - case BSA_RC_ABORT_ACTIVE_NOT_FOUND : - ELog(0," XBSA: The specified object was not found\n"); + case BSA_RC_ABORT_ACTIVE_NOT_FOUND: + ELog(0, " XBSA: The specified object was not found\n"); break; - case BSA_RC_NULL_DATABLKPTR : - ELog(0," XBSA: The dataBlockPtr is null\n"); + case BSA_RC_NULL_DATABLKPTR: + ELog(0, " XBSA: The dataBlockPtr is null\n"); break; - case BSA_RC_INVALID_VOTE : - ELog(0," XBSA: The vote variable is invalid\n"); + case BSA_RC_INVALID_VOTE: + ELog(0, " XBSA: The vote variable is invalid\n"); break; } } @@ -102,21 +107,26 @@ xbsa_error(int rc, struct butx_transactionInfo *info) * Get the library version. * XBSAQueryApiVersion */ -afs_int32 xbsa_MountLibrary(struct butx_transactionInfo *info, afs_int32 serverType) +afs_int32 +xbsa_MountLibrary(struct butx_transactionInfo *info, afs_int32 serverType) { void *dynlib; int rc; if (debugLevel > 98) { - printf("\nxbsa_MountLibraray\n"); + printf("\nxbsa_MountLibraray\n"); } switch (serverType) { - case XBSA_SERVER_TYPE_ADSM : + case XBSA_SERVER_TYPE_ADSM: #if defined(AFS_AIX_ENV) - dynlib = dlopen("/usr/lib/libXApi.a(bsashr10.o)", RTLD_NOW | RTLD_LOCAL | RTLD_MEMBER); + dynlib = + dlopen("/usr/lib/libXApi.a(bsashr10.o)", + RTLD_NOW | RTLD_LOCAL | RTLD_MEMBER); if (dynlib == NULL) { - dynlib = dlopen("/usr/lib/libXApi.a(xbsa.o)", RTLD_NOW | RTLD_LOCAL | RTLD_MEMBER); + dynlib = + dlopen("/usr/lib/libXApi.a(xbsa.o)", + RTLD_NOW | RTLD_LOCAL | RTLD_MEMBER); } #elif defined(AFS_SUN5_ENV) dynlib = dlopen("/usr/lib/libXApi.so", RTLD_NOW | RTLD_LOCAL); @@ -124,43 +134,71 @@ afs_int32 xbsa_MountLibrary(struct butx_transactionInfo *info, afs_int32 serverT dynlib = NULL; #endif break; - default : - ELog(0,"xbsa_MountLibrary: The serverType %d is not recognized\n", serverType); - return(BUTX_INVALIDSERVERTYPE); + default: + ELog(0, "xbsa_MountLibrary: The serverType %d is not recognized\n", + serverType); + return (BUTX_INVALIDSERVERTYPE); break; } if (dynlib == NULL) { - ELog(0,"xbsa_MountLibrary: The dlopen call to load the XBSA shared library failed\n"); - return(BUTX_NOLIBRARY); + ELog(0, + "xbsa_MountLibrary: The dlopen call to load the XBSA shared library failed\n"); + return (BUTX_NOLIBRARY); } memset(info, 0, sizeof(struct butx_transactionInfo)); XBSA_SET_SERVER_TYPE(info->serverType, serverType); #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) - XBSAInit = (BSA_Int16(*)(BSA_UInt32 *, SecurityToken *, ObjectOwner *, char **))dlsym((void *)dynlib, "BSAInit"); - XBSABeginTxn = (BSA_Int16(*)(BSA_UInt32))dlsym((void *)dynlib, "BSABeginTxn"); - XBSAEndTxn = (BSA_Int16(*)(BSA_UInt32, Vote))dlsym((void *)dynlib, "BSAEndTxn"); - XBSATerminate = (BSA_Int16(*)(BSA_UInt32))dlsym((void *)dynlib, "BSATerminate"); - XBSAQueryObject = (BSA_Int16(*)(BSA_UInt32, QueryDescriptor *, ObjectDescriptor *))dlsym((void *)dynlib, "BSAQueryObject"); - XBSAGetObject = (BSA_Int16(*)(BSA_UInt32, ObjectDescriptor *, DataBlock *))dlsym((void *)dynlib, "BSAGetObject"); - XBSAEndData = (BSA_Int16(*)(BSA_UInt32))dlsym((void *)dynlib, "BSAEndData"); - XBSACreateObject = (BSA_Int16(*)(BSA_UInt32, ObjectDescriptor *, DataBlock *))dlsym((void *)dynlib, "BSACreateObject"); - XBSAMarkObjectInactive = (BSA_Int16(*)(BSA_UInt32, ObjectName *))dlsym((void *)dynlib, "BSAMarkObjectInactive"); - XBSADeleteObject = (BSA_Int16(*)(BSA_UInt32, CopyType, ObjectName *, CopyId *))dlsym((void *)dynlib, "BSADeleteObject"); - XBSASendData = (BSA_Int16(*)(BSA_UInt32, DataBlock *))dlsym((void *)dynlib, "BSASendData"); - XBSAGetData = (BSA_Int16(*)(BSA_UInt32, DataBlock *))dlsym((void *)dynlib, "BSAGetData"); - XBSAQueryApiVersion = (BSA_Int16(*)(ApiVersion *))dlsym((void *)dynlib, "BSAQueryApiVersion"); - XBSAGetEnvironment = (BSA_Int16(*)(BSA_UInt32, ObjectOwner *, char **))dlsym((void *)dynlib, "BSAGetEnvironment"); - - if (!XBSAInit || !XBSABeginTxn || !XBSAEndTxn || !XBSATerminate || - !XBSAQueryObject || !XBSAGetObject || !XBSAEndData || - !XBSACreateObject || !XBSADeleteObject || !XBSAMarkObjectInactive || - !XBSASendData || !XBSAGetData || !XBSAQueryApiVersion || - !XBSAGetEnvironment) { - ELog(0,"xbsa_MountLibrary: The dlopen call to load the XBSA shared library failed\n"); - return(BUTX_NOLIBRARY); + XBSAInit = (BSA_Int16(*) + (BSA_UInt32 *, SecurityToken *, ObjectOwner *, + char **))dlsym((void *)dynlib, "BSAInit"); + XBSABeginTxn = + (BSA_Int16(*)(BSA_UInt32)) dlsym((void *)dynlib, "BSABeginTxn"); + XBSAEndTxn = + (BSA_Int16(*)(BSA_UInt32, Vote)) dlsym((void *)dynlib, "BSAEndTxn"); + XBSATerminate = + (BSA_Int16(*)(BSA_UInt32)) dlsym((void *)dynlib, "BSATerminate"); + XBSAQueryObject = + (BSA_Int16(*)(BSA_UInt32, QueryDescriptor *, ObjectDescriptor *)) + dlsym((void *)dynlib, "BSAQueryObject"); + XBSAGetObject = + (BSA_Int16(*)(BSA_UInt32, ObjectDescriptor *, DataBlock *)) + dlsym((void *)dynlib, "BSAGetObject"); + XBSAEndData = + (BSA_Int16(*)(BSA_UInt32)) dlsym((void *)dynlib, "BSAEndData"); + XBSACreateObject = + (BSA_Int16(*)(BSA_UInt32, ObjectDescriptor *, DataBlock *)) + dlsym((void *)dynlib, "BSACreateObject"); + XBSAMarkObjectInactive = + (BSA_Int16(*)(BSA_UInt32, ObjectName *)) dlsym((void *)dynlib, + "BSAMarkObjectInactive"); + XBSADeleteObject = + (BSA_Int16(*)(BSA_UInt32, CopyType, ObjectName *, CopyId *)) + dlsym((void *)dynlib, "BSADeleteObject"); + XBSASendData = + (BSA_Int16(*)(BSA_UInt32, DataBlock *)) dlsym((void *)dynlib, + "BSASendData"); + XBSAGetData = + (BSA_Int16(*)(BSA_UInt32, DataBlock *)) dlsym((void *)dynlib, + "BSAGetData"); + XBSAQueryApiVersion = + (BSA_Int16(*)(ApiVersion *)) dlsym((void *)dynlib, + "BSAQueryApiVersion"); + XBSAGetEnvironment = + (BSA_Int16(*)(BSA_UInt32, ObjectOwner *, char **))dlsym((void *) + dynlib, + "BSAGetEnvironment"); + + if (!XBSAInit || !XBSABeginTxn || !XBSAEndTxn || !XBSATerminate + || !XBSAQueryObject || !XBSAGetObject || !XBSAEndData + || !XBSACreateObject || !XBSADeleteObject || !XBSAMarkObjectInactive + || !XBSASendData || !XBSAGetData || !XBSAQueryApiVersion + || !XBSAGetEnvironment) { + ELog(0, + "xbsa_MountLibrary: The dlopen call to load the XBSA shared library failed\n"); + return (BUTX_NOLIBRARY); } XBSAQueryApiVersion(&(info->apiVersion)); @@ -169,26 +207,28 @@ afs_int32 xbsa_MountLibrary(struct butx_transactionInfo *info, afs_int32 serverT /* * Verify the API version */ - if ((info->apiVersion.version == XBSA_TS_VERSION) && - (info->apiVersion.release == XBSA_TS_RELEASE)) { + if ((info->apiVersion.version == XBSA_TS_VERSION) + && (info->apiVersion.release == XBSA_TS_RELEASE)) { /* XOPEN Techincal Standard Level! * We are coded to the Preliminary Spec! Time to go boom! */ - ELog(0,"xbsa_MountLibrary: The XBSAQueryApiVersion call returned an incompatible version, %d %d %d\n", - info->apiVersion.version, info->apiVersion.release, info->apiVersion.level); - return(BUTX_INVALIDVERSION); + ELog(0, + "xbsa_MountLibrary: The XBSAQueryApiVersion call returned an incompatible version, %d %d %d\n", + info->apiVersion.version, info->apiVersion.release, + info->apiVersion.level); + return (BUTX_INVALIDVERSION); } switch (XBSA_GET_SERVER_TYPE(info->serverType)) { - case XBSA_SERVER_TYPE_ADSM : - if ((info->apiVersion.version > XBSA_ADSM_NO_MULT_SERVER_VERSION) || - - (info->apiVersion.version == XBSA_ADSM_NO_MULT_SERVER_VERSION && - info->apiVersion.release > XBSA_ADSM_NO_MULT_SERVER_RELEASE) || - - (info->apiVersion.version == XBSA_ADSM_NO_MULT_SERVER_VERSION && - info->apiVersion.release == XBSA_ADSM_NO_MULT_SERVER_RELEASE && - info->apiVersion.level > XBSA_ADSM_NO_MULT_SERVER_LEVEL)) { + case XBSA_SERVER_TYPE_ADSM: + if ((info->apiVersion.version > XBSA_ADSM_NO_MULT_SERVER_VERSION) + || (info->apiVersion.version == XBSA_ADSM_NO_MULT_SERVER_VERSION + && info->apiVersion.release > + XBSA_ADSM_NO_MULT_SERVER_RELEASE) + || (info->apiVersion.version == XBSA_ADSM_NO_MULT_SERVER_VERSION + && info->apiVersion.release == + XBSA_ADSM_NO_MULT_SERVER_RELEASE + && info->apiVersion.level > XBSA_ADSM_NO_MULT_SERVER_LEVEL)) { /* This version contains the fixes to allow multiple servers */ info->serverType |= XBSA_SERVER_FLAG_MULTIPLE; @@ -201,8 +241,8 @@ afs_int32 xbsa_MountLibrary(struct butx_transactionInfo *info, afs_int32 serverT break; } - return(XBSA_SUCCESS); - + return (XBSA_SUCCESS); + } /* @@ -210,9 +250,9 @@ afs_int32 xbsa_MountLibrary(struct butx_transactionInfo *info, afs_int32 serverT * BSAInit * BSAGetEnvironment */ -afs_int32 xbsa_Initialize(struct butx_transactionInfo *info, - char *bsaObjectOwner, char *appObjectOwner, - char *secToken, char *serverName) +afs_int32 +xbsa_Initialize(struct butx_transactionInfo * info, char *bsaObjectOwner, + char *appObjectOwner, char *secToken, char *serverName) { char envStrs[XBSA_NUM_ENV_STRS][BSA_MAX_DESC]; char *envP[XBSA_NUM_ENV_STRS + 1]; @@ -223,15 +263,16 @@ afs_int32 xbsa_Initialize(struct butx_transactionInfo *info, int rc; if (debugLevel > 98) { - printf("\nxbsa_Initialize bsaObjectOwner='%s' appObjectOwner='%s' " - "secToken=xxxxxx servername='%s'\n", - GOODSTR(bsaObjectOwner), GOODSTR(appObjectOwner), GOODSTR(serverName)); + printf("\nxbsa_Initialize bsaObjectOwner='%s' appObjectOwner='%s' " + "secToken=xxxxxx servername='%s'\n", GOODSTR(bsaObjectOwner), + GOODSTR(appObjectOwner), GOODSTR(serverName)); } if (info->bsaHandle != 0) { /* We already have a handle */ - ELog(0,"xbsa_Initialize: The dlopen call to load the XBSA shared library failed\n"); - return(BUTX_ILLEGALINIT); + ELog(0, + "xbsa_Initialize: The dlopen call to load the XBSA shared library failed\n"); + return (BUTX_ILLEGALINIT); } /* @@ -243,41 +284,44 @@ afs_int32 xbsa_Initialize(struct butx_transactionInfo *info, */ /* Initialize the environment strings */ - for (i=0; iserverType)) { - case XBSA_SERVER_TYPE_ADSM : + case XBSA_SERVER_TYPE_ADSM: if (serverName) { if (strlen(serverName) >= BSA_MAX_DESC) { - ELog(0,"xbsa_Initialize: The serverName was not specified\n"); - return(BUTX_INVALIDSERVERNAME); + ELog(0, + "xbsa_Initialize: The serverName was not specified\n"); + return (BUTX_INVALIDSERVERNAME); } strcpy(info->serverName, serverName); strcpy(envP[0], ADSMServer); - tempStrPtr=envP[0]; - tempStrPtr=tempStrPtr + strlen(ADSMServer); + tempStrPtr = envP[0]; + tempStrPtr = tempStrPtr + strlen(ADSMServer); strcat(tempStrPtr, serverName); envP[1] = NULL; } else { envP[0] = NULL; - ELog(0,"xbsa_Initialize: The serverName was not specified\n"); - return(BUTX_INVALIDSERVERNAME); + ELog(0, "xbsa_Initialize: The serverName was not specified\n"); + return (BUTX_INVALIDSERVERNAME); } break; - default : - ELog(0,"xbsa_Initialize: The serverType %d is not recognized\n", XBSA_GET_SERVER_TYPE(info->serverType)); - return(BUTX_INVALIDSERVERTYPE); + default: + ELog(0, "xbsa_Initialize: The serverType %d is not recognized\n", + XBSA_GET_SERVER_TYPE(info->serverType)); + return (BUTX_INVALIDSERVERTYPE); break; } if (bsaObjectOwner) { if (strlen(bsaObjectOwner) >= BSA_MAX_BSAOBJECT_OWNER) { - ELog(0,"xbsa_Initialize: The bsaObjectOwner is too long; size = %d; name = %s\n", + ELog(0, + "xbsa_Initialize: The bsaObjectOwner is too long; size = %d; name = %s\n", strlen(bsaObjectOwner), bsaObjectOwner); - return(BUTX_INVALIDBSANAME); + return (BUTX_INVALIDBSANAME); } strcpy(info->objOwner.bsaObjectOwner, bsaObjectOwner); } else { @@ -286,9 +330,10 @@ afs_int32 xbsa_Initialize(struct butx_transactionInfo *info, if (appObjectOwner) { if (strlen(appObjectOwner) >= BSA_MAX_APPOBJECT_OWNER) { - ELog(0,"xbsa_Initialize: The appObjectOwner is too long; size = %d; name = %s\n", + ELog(0, + "xbsa_Initialize: The appObjectOwner is too long; size = %d; name = %s\n", strlen(appObjectOwner), appObjectOwner); - return(BUTX_INVALIDAPPNAME); + return (BUTX_INVALIDAPPNAME); } strcpy(info->objOwner.appObjectOwner, appObjectOwner); } else { @@ -297,119 +342,132 @@ afs_int32 xbsa_Initialize(struct butx_transactionInfo *info, if (secToken) { if (strlen(secToken) >= BSA_MAX_TOKEN_SIZE) { - ELog(0,"xbsa_Initialize: The secToken is too long; size = %d; name = %s\n", + ELog(0, + "xbsa_Initialize: The secToken is too long; size = %d; name = %s\n", strlen(secToken), secToken); - return(BUTX_INVALIDSECTOKEN); + return (BUTX_INVALIDSECTOKEN); } strcpy(info->secToken, secToken); } else { info->secToken[0] = NULL; } - rc = (int)XBSAInit(&(info->bsaHandle), &(info->secToken), &(info->objOwner), envP); + rc = (int)XBSAInit(&(info->bsaHandle), &(info->secToken), + &(info->objOwner), envP); if (rc != BSA_RC_SUCCESS) { - ELog(0,"xbsa_Initialize: The XBSAInit call failed with %d\n", rc); + ELog(0, "xbsa_Initialize: The XBSAInit call failed with %d\n", rc); xbsa_error(rc, info); - return(BUTX_INITFAIL); + return (BUTX_INITFAIL); } /* Initialize the environment strings */ - for (i=0; ibsaHandle, &info->objOwner, envP); if (rc != BSA_RC_SUCCESS) { - ELog(0,"xbsa_Initialize: The XBSAGetEnvironment call failed with %d\n", rc); + ELog(0, + "xbsa_Initialize: The XBSAGetEnvironment call failed with %d\n", + rc); xbsa_error(rc, info); - return(BUTX_GETENVFAIL); + return (BUTX_GETENVFAIL); } switch (XBSA_GET_SERVER_TYPE(info->serverType)) { - case XBSA_SERVER_TYPE_ADSM : - for (i=0; imaxObjects = strtol(tempStrPtr,NULL,10); + tempStrPtr = envP[i]; + tempStrPtr = tempStrPtr + strlen(ADSMMaxObject); + info->maxObjects = strtol(tempStrPtr, NULL, 10); if (info->maxObjects <= 0) { - ELog(0,"xbsa_Initialize: The XBSAGetEnvironment call returned an invalid value for MAXOBJ %d\n", + ELog(0, + "xbsa_Initialize: The XBSAGetEnvironment call returned an invalid value for MAXOBJ %d\n", info->maxObjects); - return(BUTX_GETENVFAIL); + return (BUTX_GETENVFAIL); } - } + } } if (info->maxObjects == 0) { - ELog(0,"xbsa_Initialize: The XBSAGetEnvironment call failed to return the MAXOBJ string\n"); - return(BUTX_GETENVFAIL); + ELog(0, + "xbsa_Initialize: The XBSAGetEnvironment call failed to return the MAXOBJ string\n"); + return (BUTX_GETENVFAIL); } - break; + break; } - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } /* * Create a transaction * BSABeginTxn */ -afs_int32 xbsa_BeginTrans(struct butx_transactionInfo *info) +afs_int32 +xbsa_BeginTrans(struct butx_transactionInfo * info) { int rc; if (debugLevel > 98) { - printf("\nxbsa_BeginTrans\n"); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_BeginTrans\n"); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_BeginTrans: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, "xbsa_BeginTrans: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } rc = (int)XBSABeginTxn(info->bsaHandle); if (rc != BSA_RC_SUCCESS) { - ELog(0,"xbsa_BeginTrans: The XBSABeginTxn call failed with %d\n", rc); + ELog(0, "xbsa_BeginTrans: The XBSABeginTxn call failed with %d\n", + rc); xbsa_error(rc, info); - return(BUTX_BEGINTXNFAIL); + return (BUTX_BEGINTXNFAIL); } info->numObjects = 0; - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } /* * End the current transaction * BSAEndTxn */ -afs_int32 xbsa_EndTrans(struct butx_transactionInfo *info) +afs_int32 +xbsa_EndTrans(struct butx_transactionInfo * info) { int rc; if (debugLevel > 98) { - printf("\nxbsa_EndTrans\n"); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_EndTrans\n"); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_EndTrans: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, "xbsa_EndTrans: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } /* terminate the transaction */ rc = (int)XBSAEndTxn(info->bsaHandle, BSAVote_COMMIT); if (rc != BSA_RC_SUCCESS) { - ELog(0,"xbsa_EndTrans: The XBSAEndTxn call failed with %d\n", rc); + ELog(0, "xbsa_EndTrans: The XBSAEndTxn call failed with %d\n", rc); xbsa_error(rc, info); - return(BUTX_ENDTXNFAIL); + return (BUTX_ENDTXNFAIL); } - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } /* @@ -417,78 +475,86 @@ afs_int32 xbsa_EndTrans(struct butx_transactionInfo *info) * End the transaction. * BSATerminate */ -afs_int32 xbsa_Finalize(struct butx_transactionInfo *info) +afs_int32 +xbsa_Finalize(struct butx_transactionInfo * info) { int rc; if (debugLevel > 98) { - printf("\nxbsa_Finalize\n"); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_Finalize\n"); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_Finalize: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, "xbsa_Finalize: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } /* terminate the session */ rc = (int)XBSATerminate(info->bsaHandle); if (rc != BSA_RC_SUCCESS) { - ELog(0,"The XBSATerminate call failed with %d\n", rc); + ELog(0, "The XBSATerminate call failed with %d\n", rc); xbsa_error(rc, info); - return(BUTX_TERMFAIL); + return (BUTX_TERMFAIL); } info->bsaHandle = 0; - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } /* * Query for the object we are looking for. * BSAQueryObject */ -afs_int32 xbsa_QueryObject(struct butx_transactionInfo *info, - char *objectSpaceName, - char *pathName) +afs_int32 +xbsa_QueryObject(struct butx_transactionInfo * info, char *objectSpaceName, + char *pathName) { int rc; QueryDescriptor queryDescriptor; if (debugLevel > 98) { - printf("\nxbsa_QueryObject objectSpaceName='%s' pathnName='%s'\n", - GOODSTR(objectSpaceName), GOODSTR(pathName)); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_QueryObject objectSpaceName='%s' pathnName='%s'\n", + GOODSTR(objectSpaceName), GOODSTR(pathName)); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_QueryObject: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, + "xbsa_QueryObject: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } /* Initialize the query for our dump name */ if (objectSpaceName) { if (strlen(objectSpaceName) >= BSA_MAX_OSNAME) { - ELog(0,"xbsa_QueryObject: The objectSpaceName is too long; size = %d; name = %s\n", + ELog(0, + "xbsa_QueryObject: The objectSpaceName is too long; size = %d; name = %s\n", strlen(objectSpaceName), objectSpaceName); - return(BUTX_INVALIDOBJECTSPNAME); + return (BUTX_INVALIDOBJECTSPNAME); } - strcpy(queryDescriptor.objName.objectSpaceName,objectSpaceName); + strcpy(queryDescriptor.objName.objectSpaceName, objectSpaceName); } else { queryDescriptor.objName.objectSpaceName[0] = NULL; } if (pathName) { if (strlen(pathName) >= BSA_MAX_PATHNAME) { - ELog(0,"xbsa_QueryObject: The pathName is too long; size = %d; name = %s\n", + ELog(0, + "xbsa_QueryObject: The pathName is too long; size = %d; name = %s\n", strlen(pathName), pathName); - return(BUTX_INVALIDPATHNAME); + return (BUTX_INVALIDPATHNAME); } strcpy(queryDescriptor.objName.pathName, pathName); } else { @@ -504,14 +570,17 @@ afs_int32 xbsa_QueryObject(struct butx_transactionInfo *info, queryDescriptor.status = BSAObjectStatus_ACTIVE; strcpy(queryDescriptor.desc, ""); - rc = (int)XBSAQueryObject(info->bsaHandle, &queryDescriptor, &info->curObject); - if (rc == BSA_RC_NO_MORE_DATA) rc = BSA_RC_SUCCESS; /* This is actually a success! */ + rc = (int)XBSAQueryObject(info->bsaHandle, &queryDescriptor, + &info->curObject); + if (rc == BSA_RC_NO_MORE_DATA) + rc = BSA_RC_SUCCESS; /* This is actually a success! */ if (rc != BSA_RC_SUCCESS) { - ELog(0,"xbsa_QueryObject: The xBSAQueryObject call failed with %d\n", rc); + ELog(0, "xbsa_QueryObject: The xBSAQueryObject call failed with %d\n", + rc); xbsa_error(rc, info); - return(BUTX_QUERYFAIL); + return (BUTX_QUERYFAIL); } - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } /* @@ -519,49 +588,58 @@ afs_int32 xbsa_QueryObject(struct butx_transactionInfo *info, * get the object descriptor so we can begin the transfer of data. * BSAGetObject */ -afs_int32 xbsa_ReadObjectBegin(struct butx_transactionInfo *info, char *dataBuffer, - afs_int32 bufferSize, afs_int32 *count, afs_int32 *endOfData) +afs_int32 +xbsa_ReadObjectBegin(struct butx_transactionInfo * info, char *dataBuffer, + afs_int32 bufferSize, afs_int32 * count, + afs_int32 * endOfData) { int rc; DataBlock dataBlock; if (debugLevel > 98) { - printf("\nxbsa_ReadObjectBegin %d Bytes\n", bufferSize); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_ReadObjectBegin %d Bytes\n", bufferSize); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_ReadObjectBegin: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, + "xbsa_ReadObjectBegin: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } if ((bufferSize < 0) || (bufferSize > XBSAMAXBUFFER)) { - ELog(0,"xbsa_ReadObjectBegin: The bufferSize %d is invalid\n", bufferSize); - return(BUTX_INVALIDBUFFERSIZE); + ELog(0, "xbsa_ReadObjectBegin: The bufferSize %d is invalid\n", + bufferSize); + return (BUTX_INVALIDBUFFERSIZE); } if (dataBuffer == NULL) { - ELog(0,"xbsa_ReadObjectBegin: The dataBuffer is NULL\n"); - return(BUTX_INVALIDDATABUFFER); + ELog(0, "xbsa_ReadObjectBegin: The dataBuffer is NULL\n"); + return (BUTX_INVALIDDATABUFFER); } dataBlock.bufferLen = (BSA_UInt16) bufferSize; - dataBlock.numBytes = (BSA_UInt16) 0; + dataBlock.numBytes = (BSA_UInt16) 0; dataBlock.bufferPtr = dataBuffer; *endOfData = 0; rc = (int)XBSAGetObject(info->bsaHandle, &info->curObject, &dataBlock); if ((rc != BSA_RC_MORE_DATA) && (rc != BSA_RC_NO_MORE_DATA)) { - ELog(0,"xbsa_ReadObjectBegin: The XBSAGetObject call failed with %d\n", rc); + ELog(0, + "xbsa_ReadObjectBegin: The XBSAGetObject call failed with %d\n", + rc); xbsa_error(rc, info); - return(BUTX_GETOBJFAIL); + return (BUTX_GETOBJFAIL); } *count = dataBlock.numBytes; - if (rc == BSA_RC_NO_MORE_DATA) *endOfData = 1; - return(XBSA_SUCCESS); + if (rc == BSA_RC_NO_MORE_DATA) + *endOfData = 1; + return (XBSA_SUCCESS); } @@ -569,29 +647,33 @@ afs_int32 xbsa_ReadObjectBegin(struct butx_transactionInfo *info, char *dataBuff * Tell the XBSA Server that this is the end of Data for this object. * BSAEndData() */ -afs_int32 xbsa_ReadObjectEnd(struct butx_transactionInfo *info) +afs_int32 +xbsa_ReadObjectEnd(struct butx_transactionInfo * info) { int rc; if (debugLevel > 98) { - printf("\nxbsa_ReadObjectEnd\n"); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_ReadObjectEnd\n"); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_ReadObjectEnd: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, + "xbsa_ReadObjectEnd: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } rc = (int)XBSAEndData(info->bsaHandle); if (rc != BSA_RC_SUCCESS) { - ELog(0,"xbsa_ReadObjectEnd: XBSAEndData call failed with %d\n", rc); + ELog(0, "xbsa_ReadObjectEnd: XBSAEndData call failed with %d\n", rc); xbsa_error(rc, info); - return(BUTX_ENDDATAFAIL); + return (BUTX_ENDDATAFAIL); } - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } @@ -599,37 +681,43 @@ afs_int32 xbsa_ReadObjectEnd(struct butx_transactionInfo *info) * Create the XBSA Backup Copy Object. * BSACreateObject */ -afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info, - char *objectSpaceName, char *pathName, - char *lGName, afs_hyper_t estimatedSize, - char *objectDescription, char *objectInfo) +afs_int32 +xbsa_WriteObjectBegin(struct butx_transactionInfo * info, + char *objectSpaceName, char *pathName, char *lGName, + afs_hyper_t estimatedSize, char *objectDescription, + char *objectInfo) { int rc; int length; DataBlock dataBlock; if (debugLevel > 98) { - printf("\nxbsa_WriteObjectBegin objectSpacename='%s' pathName='%s' lGName='%s' " - "estimatesSize='0x%x%08x objectDescription='%s' objectInfo='%s'\n", - GOODSTR(objectSpaceName), GOODSTR(pathName), GOODSTR(lGName), - hgethi(estimatedSize), hgetlo(estimatedSize), - GOODSTR(objectDescription), GOODSTR(objectInfo)); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf + ("\nxbsa_WriteObjectBegin objectSpacename='%s' pathName='%s' lGName='%s' " + "estimatesSize='0x%x%08x objectDescription='%s' objectInfo='%s'\n", + GOODSTR(objectSpaceName), GOODSTR(pathName), GOODSTR(lGName), + hgethi(estimatedSize), hgetlo(estimatedSize), + GOODSTR(objectDescription), GOODSTR(objectInfo)); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_WriteObjectBegin: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, + "xbsa_WriteObjectBegin: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } if (objectSpaceName) { if (strlen(objectSpaceName) >= BSA_MAX_OSNAME) { - ELog(0,"xbsa_WriteObjectBegin: The objectSpaceName is too long; size = %d; name = %s\n", + ELog(0, + "xbsa_WriteObjectBegin: The objectSpaceName is too long; size = %d; name = %s\n", strlen(objectSpaceName), objectSpaceName); - return(BUTX_INVALIDOBJECTSPNAME); + return (BUTX_INVALIDOBJECTSPNAME); } strcpy(info->curObject.objName.objectSpaceName, objectSpaceName); } else { @@ -638,9 +726,10 @@ afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info, if (pathName) { if (strlen(pathName) >= BSA_MAX_PATHNAME) { - ELog(0,"xbsa_WriteObjectBegin: The pathName is too long; size = %d; name = %s\n", + ELog(0, + "xbsa_WriteObjectBegin: The pathName is too long; size = %d; name = %s\n", strlen(pathName), pathName); - return(BUTX_INVALIDPATHNAME); + return (BUTX_INVALIDPATHNAME); } strcpy(info->curObject.objName.pathName, pathName); } else { @@ -649,9 +738,10 @@ afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info, if (lGName) { if (strlen(lGName) >= BSA_MAX_LG_NAME) { - ELog(0,"xbsa_WriteObjectBegin: The lGName is too long; size = %d; name = %s\n", + ELog(0, + "xbsa_WriteObjectBegin: The lGName is too long; size = %d; name = %s\n", strlen(lGName), lGName); - return(BUTX_INVALIDLGNAME); + return (BUTX_INVALIDLGNAME); } strcpy(info->curObject.lGName, lGName); } else { @@ -659,13 +749,15 @@ afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info, } if (objectDescription) { - if ( ( (XBSA_GET_SERVER_TYPE(info->serverType) == XBSA_SERVER_TYPE_ADSM) && - (strlen(objectDescription) >= ADSM_MAX_DESC) ) || - ( (XBSA_GET_SERVER_TYPE(info->serverType) != XBSA_SERVER_TYPE_ADSM) && - (strlen(objectDescription) >= BSA_MAX_DESC) ) ) { - ELog(0,"xbsa_WriteObjectBegin: The objectDescription is too long; size = %d; name = %s\n", + if (((XBSA_GET_SERVER_TYPE(info->serverType) == XBSA_SERVER_TYPE_ADSM) + && (strlen(objectDescription) >= ADSM_MAX_DESC)) + || + ((XBSA_GET_SERVER_TYPE(info->serverType) != XBSA_SERVER_TYPE_ADSM) + && (strlen(objectDescription) >= BSA_MAX_DESC))) { + ELog(0, + "xbsa_WriteObjectBegin: The objectDescription is too long; size = %d; name = %s\n", strlen(objectDescription), objectDescription); - return(BUTX_INVALIDOBJDESC); + return (BUTX_INVALIDOBJDESC); } strcpy(info->curObject.desc, objectDescription); } else { @@ -673,13 +765,15 @@ afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info, } if (objectInfo) { - if ( ( (XBSA_GET_SERVER_TYPE(info->serverType) == XBSA_SERVER_TYPE_ADSM) && - (strlen(objectInfo) >= ADSM_MAX_OBJINFO) ) || - ( (XBSA_GET_SERVER_TYPE(info->serverType) != XBSA_SERVER_TYPE_ADSM) && - (strlen(objectInfo) >= BSA_MAX_OBJINFO) ) ) { - ELog(0,"xbsa_WriteObjectBegin: The objectInfo is too long; size = %d; name = %s\n", + if (((XBSA_GET_SERVER_TYPE(info->serverType) == XBSA_SERVER_TYPE_ADSM) + && (strlen(objectInfo) >= ADSM_MAX_OBJINFO)) + || + ((XBSA_GET_SERVER_TYPE(info->serverType) != XBSA_SERVER_TYPE_ADSM) + && (strlen(objectInfo) >= BSA_MAX_OBJINFO))) { + ELog(0, + "xbsa_WriteObjectBegin: The objectInfo is too long; size = %d; name = %s\n", strlen(objectInfo), objectInfo); - return(BUTX_INVALIDOBJINFO); + return (BUTX_INVALIDOBJINFO); } strcpy(info->curObject.objectInfo, objectInfo); } else { @@ -688,13 +782,13 @@ afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info, if (info->numObjects == info->maxObjects) { /* If we've used up Max Objects we must start a new transaction. */ - rc = (int)xbsa_EndTrans(info); + rc = (int)xbsa_EndTrans(info); if (rc != XBSA_SUCCESS) { - return(rc); + return (rc); } rc = (int)xbsa_BeginTrans(info); if (rc != XBSA_SUCCESS) { - return(rc); + return (rc); } } @@ -702,23 +796,25 @@ afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info, dataBlock.numBytes = (BSA_UInt16) 0; dataBlock.bufferPtr = 0; - info->curObject.Owner = info->objOwner; - info->curObject.copyType = BSACopyType_BACKUP; - info->curObject.size.left = hgethi(estimatedSize); + info->curObject.Owner = info->objOwner; + info->curObject.copyType = BSACopyType_BACKUP; + info->curObject.size.left = hgethi(estimatedSize); info->curObject.size.right = hgetlo(estimatedSize); info->curObject.objectType = BSAObjectType_FILE; strcpy(info->curObject.resourceType, resourceType); rc = (int)XBSACreateObject(info->bsaHandle, &info->curObject, &dataBlock); if (rc != BSA_RC_SUCCESS) { - ELog(0,"xbsa_WriteObjectBegin: The XBSACreateObject call failed with %d\n", rc); + ELog(0, + "xbsa_WriteObjectBegin: The XBSACreateObject call failed with %d\n", + rc); xbsa_error(rc, info); - return(BUTX_CREATEOBJFAIL); + return (BUTX_CREATEOBJFAIL); } info->numObjects++; - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } /* @@ -726,31 +822,36 @@ afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info, * BSAMarkObjectInactive() * BSADeleteObject() */ -afs_int32 xbsa_DeleteObject(struct butx_transactionInfo *info, - char *objectSpaceName, char *pathName) +afs_int32 +xbsa_DeleteObject(struct butx_transactionInfo * info, char *objectSpaceName, + char *pathName) { int rc; ObjectName objectName; if (debugLevel > 98) { - printf("\nxbsa_DeleteObject objectSpacename='%s' pathName='%s'\n", - GOODSTR(objectSpaceName), GOODSTR(pathName)); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_DeleteObject objectSpacename='%s' pathName='%s'\n", + GOODSTR(objectSpaceName), GOODSTR(pathName)); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_DeleteObject: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, + "xbsa_DeleteObject: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } if (objectSpaceName) { if (strlen(objectSpaceName) >= BSA_MAX_OSNAME) { - ELog(0,"xbsa_DeleteObject: The objectSpaceName is too long; size = %d; name = %s\n", + ELog(0, + "xbsa_DeleteObject: The objectSpaceName is too long; size = %d; name = %s\n", strlen(objectSpaceName), objectSpaceName); - return(BUTX_INVALIDOBJECTSPNAME); + return (BUTX_INVALIDOBJECTSPNAME); } strcpy(objectName.objectSpaceName, objectSpaceName); } else { @@ -759,9 +860,9 @@ afs_int32 xbsa_DeleteObject(struct butx_transactionInfo *info, if (pathName) { if (strlen(pathName) >= BSA_MAX_PATHNAME) { - ELog(0,"xbsa_DeleteObject: strlen(pathName), pathName\n", + ELog(0, "xbsa_DeleteObject: strlen(pathName), pathName\n", strlen(pathName), pathName); - return(BUTX_INVALIDPATHNAME); + return (BUTX_INVALIDPATHNAME); } strcpy(objectName.pathName, pathName); } else { @@ -769,43 +870,51 @@ afs_int32 xbsa_DeleteObject(struct butx_transactionInfo *info, } rc = (int)XBSAMarkObjectInactive(info->bsaHandle, &objectName); - if (rc != BSA_RC_SUCCESS ) { - ELog(0,"xbsa_DeleteObject: XBSAMarkObjectInactive call failed with %d\n", rc); + if (rc != BSA_RC_SUCCESS) { + ELog(0, + "xbsa_DeleteObject: XBSAMarkObjectInactive call failed with %d\n", + rc); xbsa_error(rc, info); - return((rc==BSA_RC_ABORT_ACTIVE_NOT_FOUND) ? BUTX_DELETENOVOL : BUTX_DELETEOBJFAIL); + return ((rc == + BSA_RC_ABORT_ACTIVE_NOT_FOUND) ? BUTX_DELETENOVOL : + BUTX_DELETEOBJFAIL); } - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } /* * Tell the XBSA Server that this is the end of Data for this object. * BSAEndData() */ -afs_int32 xbsa_WriteObjectEnd(struct butx_transactionInfo *info) +afs_int32 +xbsa_WriteObjectEnd(struct butx_transactionInfo * info) { int rc; if (debugLevel > 98) { - printf("\nxbsa_WriteObjectEnd\n"); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_WriteObjectEnd\n"); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_WriteObjectEnd: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, + "xbsa_WriteObjectEnd: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } rc = (int)XBSAEndData(info->bsaHandle); if (rc != BSA_RC_SUCCESS) { - ELog(0,"xbsa_WriteObjectEnd: XBSAEndData call failed with %d\n", rc); + ELog(0, "xbsa_WriteObjectEnd: XBSAEndData call failed with %d\n", rc); xbsa_error(rc, info); - return(BUTX_ENDDATAFAIL); + return (BUTX_ENDDATAFAIL); } - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } @@ -813,33 +922,38 @@ afs_int32 xbsa_WriteObjectEnd(struct butx_transactionInfo *info) * Write the fileset data to the XBSA server * BSASendData */ -afs_int32 xbsa_WriteObjectData(struct butx_transactionInfo *info, - char *dataBuffer, afs_int32 bufferSize, afs_int32 *count) +afs_int32 +xbsa_WriteObjectData(struct butx_transactionInfo * info, char *dataBuffer, + afs_int32 bufferSize, afs_int32 * count) { int rc; DataBlock dataBlock; if (debugLevel > 98) { - printf("\nxbsa_WriteObjectData %d Bytes\n", bufferSize); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_WriteObjectData %d Bytes\n", bufferSize); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_WriteObjectData: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, + "xbsa_WriteObjectData: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } if ((bufferSize < 0) || (bufferSize > XBSAMAXBUFFER)) { - ELog(0,"xbsa_WriteObjectData: The bufferSize %d is invalid\n", bufferSize); - return(BUTX_INVALIDBUFFERSIZE); + ELog(0, "xbsa_WriteObjectData: The bufferSize %d is invalid\n", + bufferSize); + return (BUTX_INVALIDBUFFERSIZE); } if (dataBuffer == NULL) { - ELog(0,"xbsa_WriteObjectData: The dataBuffer is NULL\n"); - return(BUTX_INVALIDDATABUFFER); + ELog(0, "xbsa_WriteObjectData: The dataBuffer is NULL\n"); + return (BUTX_INVALIDDATABUFFER); } dataBlock.bufferPtr = dataBuffer; @@ -848,12 +962,13 @@ afs_int32 xbsa_WriteObjectData(struct butx_transactionInfo *info, rc = (int)XBSASendData(info->bsaHandle, &dataBlock); if (rc != BSA_RC_SUCCESS) { - ELog(0,"xbsa_WriteObjectData: XBSAEndData call failed with %d\n", rc); + ELog(0, "xbsa_WriteObjectData: XBSAEndData call failed with %d\n", + rc); xbsa_error(rc, info); - return(BUTX_SENDDATAFAIL); + return (BUTX_SENDDATAFAIL); } *count = dataBlock.numBytes; - return(XBSA_SUCCESS); + return (XBSA_SUCCESS); } @@ -861,33 +976,39 @@ afs_int32 xbsa_WriteObjectData(struct butx_transactionInfo *info, * Read the fileset data from the XBSA server * BSAGetData */ -afs_int32 xbsa_ReadObjectData(struct butx_transactionInfo *info, char *dataBuffer, - afs_int32 bufferSize, afs_int32 *count, afs_int32 *endOfData) +afs_int32 +xbsa_ReadObjectData(struct butx_transactionInfo * info, char *dataBuffer, + afs_int32 bufferSize, afs_int32 * count, + afs_int32 * endOfData) { int rc; DataBlock dataBlock; if (debugLevel > 98) { - printf("\nxbsa_ReadObjectData %d Bytes\n", bufferSize); - printf("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", - GOODSTR(info->serverName), GOODSTR(info->objOwner.bsaObjectOwner), - GOODSTR(info->objOwner.appObjectOwner)); + printf("\nxbsa_ReadObjectData %d Bytes\n", bufferSize); + printf + ("serverName='%s' ; bsaObjectOwner='%s' ; appObjectOwner='%s' ; sectoken=xxxxxx\n", + GOODSTR(info->serverName), + GOODSTR(info->objOwner.bsaObjectOwner), + GOODSTR(info->objOwner.appObjectOwner)); } if (info->bsaHandle == 0) { /* We haven't initialized yet! */ - ELog(0,"xbsa_ReadObjectData: No current handle, butx not initialized\n"); - return(BUTX_NOHANDLE); + ELog(0, + "xbsa_ReadObjectData: No current handle, butx not initialized\n"); + return (BUTX_NOHANDLE); } if ((bufferSize < 0) || (bufferSize > XBSAMAXBUFFER)) { - ELog(0,"xbsa_ReadObjectData: The bufferSize %d is invalid\n", bufferSize); - return(BUTX_INVALIDBUFFERSIZE); + ELog(0, "xbsa_ReadObjectData: The bufferSize %d is invalid\n", + bufferSize); + return (BUTX_INVALIDBUFFERSIZE); } if (dataBuffer == NULL) { - ELog(0,"xbsa_ReadObjectData: The dataBuffer is NULL\n"); - return(BUTX_INVALIDDATABUFFER); + ELog(0, "xbsa_ReadObjectData: The dataBuffer is NULL\n"); + return (BUTX_INVALIDDATABUFFER); } dataBlock.bufferLen = (BSA_UInt16) bufferSize; @@ -897,12 +1018,13 @@ afs_int32 xbsa_ReadObjectData(struct butx_transactionInfo *info, char *dataBuffe rc = (int)XBSAGetData(info->bsaHandle, &dataBlock); if ((rc != BSA_RC_MORE_DATA) && (rc != BSA_RC_NO_MORE_DATA)) { - ELog(0,"xbsa_ReadObjectData: XBSAGetData call failed with %d\n", rc); + ELog(0, "xbsa_ReadObjectData: XBSAGetData call failed with %d\n", rc); xbsa_error(rc, info); - return(BUTX_GETDATAFAIL); + return (BUTX_GETDATAFAIL); } *count = dataBlock.numBytes; - if (rc == BSA_RC_NO_MORE_DATA) *endOfData = 1; - return(XBSA_SUCCESS); + if (rc == BSA_RC_NO_MORE_DATA) + *endOfData = 1; + return (XBSA_SUCCESS); } -#endif /*xbsa*/ +#endif /*xbsa */ diff --git a/src/butc/butc_xbsa.h b/src/butc/butc_xbsa.h index c1b8868b5..63c14a5da 100644 --- a/src/butc/butc_xbsa.h +++ b/src/butc/butc_xbsa.h @@ -11,13 +11,13 @@ #define OPENAFS_BUTC_XBSA_H /* The following serverTypes are currently supported by this interface */ -#define XBSA_SERVER_TYPE_NONE 0x00 /* no server, use tape drive */ -#define XBSA_SERVER_TYPE_UNKNOWN 0x01 /* server, don't know which type yet */ -#define XBSA_SERVER_TYPE_ADSM 0x02 /* server type is ADSM */ -#define XBSA_SERVER_TYPE_MASK 0xFF /* for (butx_transactionInfo *)->serverType (byte 1) */ +#define XBSA_SERVER_TYPE_NONE 0x00 /* no server, use tape drive */ +#define XBSA_SERVER_TYPE_UNKNOWN 0x01 /* server, don't know which type yet */ +#define XBSA_SERVER_TYPE_ADSM 0x02 /* server type is ADSM */ +#define XBSA_SERVER_TYPE_MASK 0xFF /* for (butx_transactionInfo *)->serverType (byte 1) */ #ifdef xbsa -#define CONF_XBSA (xbsaType != XBSA_SERVER_TYPE_NONE) /*test if butc is XBSA */ +#define CONF_XBSA (xbsaType != XBSA_SERVER_TYPE_NONE) /*test if butc is XBSA */ #else #define CONF_XBSA 0 #endif @@ -27,16 +27,16 @@ #define XBSA_GET_SERVER_TYPE(server) ((server) & XBSA_SERVER_TYPE_MASK) /* The following serverType flags are currently supported by this interface */ -#define XBSA_SERVER_FLAG_NONE 0x0000 /* don't allow multiple server connections */ -#define XBSA_SERVER_FLAG_MULTIPLE 0x0100 /* allow multiple server connections */ -#define XBSA_SERVER_FLAG_MASK 0xFF00 /* for (butx_transactionInfo *)->serverType (byte 2) */ +#define XBSA_SERVER_FLAG_NONE 0x0000 /* don't allow multiple server connections */ +#define XBSA_SERVER_FLAG_MULTIPLE 0x0100 /* allow multiple server connections */ +#define XBSA_SERVER_FLAG_MASK 0xFF00 /* for (butx_transactionInfo *)->serverType (byte 2) */ #define XBSA_SET_SERVER_FLAG(server, flag) ((server) |= ((flag) & XBSA_SERVER_FLAG_MASK)) #define XBSA_GET_SERVER_FLAG(server) ((server) & XBSA_SERVER_FLAG_MASK) #define XBSA_IS_SERVER_FLAG_SET(server, flag) (XBSA_GET_SERVER_FLAG(server) & flag) -#define XBSAMINBUFFER 1024 /* minimum size is 1KB */ -#define XBSADFLTBUFFER 16384 /* default size is 16KB */ -#define XBSAMAXBUFFER 65535 /* maximum size in 64KB-1; has to fit in 16bit integer */ +#define XBSAMINBUFFER 1024 /* minimum size is 1KB */ +#define XBSADFLTBUFFER 16384 /* default size is 16KB */ +#define XBSAMAXBUFFER 65535 /* maximum size in 64KB-1; has to fit in 16bit integer */ #include @@ -67,22 +67,23 @@ * The spec says bsaHandle should be a long but ADSM has it as a ulong! */ struct butx_transactionInfo { - ApiVersion apiVersion; - u_long bsaHandle; - afs_int32 serverType; /* Type and flags */ - afs_int32 maxObjects; /* max objects/transaction */ - afs_int32 numObjects; /* objects in current trans */ - char serverName[BSA_MAX_DESC]; - SecurityToken secToken; - ObjectOwner objOwner; - ObjectDescriptor curObject; + ApiVersion apiVersion; + u_long bsaHandle; + afs_int32 serverType; /* Type and flags */ + afs_int32 maxObjects; /* max objects/transaction */ + afs_int32 numObjects; /* objects in current trans */ + char serverName[BSA_MAX_DESC]; + SecurityToken secToken; + ObjectOwner objOwner; + ObjectDescriptor curObject; }; -extern afs_int32 xbsa_MountLibrary(struct butx_transactionInfo *info, afs_int32 serverType); +extern afs_int32 xbsa_MountLibrary(struct butx_transactionInfo *info, + afs_int32 serverType); extern afs_int32 xbsa_Initialize(struct butx_transactionInfo *info, - char *bsaObjectOwner, char *appObjectOwner, - char *secToken, char *serverName); + char *bsaObjectOwner, char *appObjectOwner, + char *secToken, char *serverName); extern afs_int32 xbsa_Finalize(struct butx_transactionInfo *info); @@ -91,38 +92,35 @@ extern afs_int32 xbsa_BeginTrans(struct butx_transactionInfo *info); extern afs_int32 xbsa_EndTrans(struct butx_transactionInfo *info); extern afs_int32 xbsa_QueryObject(struct butx_transactionInfo *info, - char *objectSpaceName, char *pathName); + char *objectSpaceName, char *pathName); extern afs_int32 xbsa_ReadObjectBegin(struct butx_transactionInfo *info, - char *dataBuffer, - afs_int32 bufferSize, - afs_int32 *count, - afs_int32 *endOfData); + char *dataBuffer, afs_int32 bufferSize, + afs_int32 * count, + afs_int32 * endOfData); extern afs_int32 xbsa_ReadObjectEnd(struct butx_transactionInfo *info); extern afs_int32 xbsa_WriteObjectBegin(struct butx_transactionInfo *info, - char *objectSpaceName, - char *pathName, - char *lGName, - afs_hyper_t estimatedSize, - char *objectDescription, - char *objectInfo); + char *objectSpaceName, char *pathName, + char *lGName, + afs_hyper_t estimatedSize, + char *objectDescription, + char *objectInfo); extern afs_int32 xbsa_WriteObjectEnd(struct butx_transactionInfo *info); extern afs_int32 xbsa_WriteObjectData(struct butx_transactionInfo *info, - char *dataBuffer, - afs_int32 bufferSize, afs_int32 *count); + char *dataBuffer, afs_int32 bufferSize, + afs_int32 * count); extern afs_int32 xbsa_ReadObjectData(struct butx_transactionInfo *info, - char *dataBuffer, - afs_int32 bufferSize, - afs_int32 *count, - afs_int32 *endOfData); + char *dataBuffer, afs_int32 bufferSize, + afs_int32 * count, + afs_int32 * endOfData); extern afs_int32 xbsa_DeleteObject(struct butx_transactionInfo *info, - char *objectSpaceName, char *pathName); + char *objectSpaceName, char *pathName); -#endif /*xbsa*/ +#endif /*xbsa */ #endif /* OPENAFS_BUTC_XBSA_H */ diff --git a/src/butc/common.h b/src/butc/common.h index 8c1e971da..cfcd88cbb 100644 --- a/src/butc/common.h +++ b/src/butc/common.h @@ -14,25 +14,25 @@ /* describes the information that should be dumped to dump a single volume */ struct tc_dumpDesc { - afs_int32 vid; /* volume to dump */ - afs_int32 partition; /* partition at which to find the volume */ - afs_int32 date; /* date from which to do the dump */ - opaque hostID[16]; /* opaque netaddress, really a sockaddr_in */ + afs_int32 vid; /* volume to dump */ + afs_int32 partition; /* partition at which to find the volume */ + afs_int32 date; /* date from which to do the dump */ + opaque hostID[16]; /* opaque netaddress, really a sockaddr_in */ }; /* define how to restore a volume */ struct tc_restoreDesc { - afs_int32 origVid; /* original volume id */ - afs_int32 vid; /* 0 means allocate new volid */ - afs_int32 partition; /* where to restore the volume */ - afs_int32 flags; /* flags */ - opaque hostID[16]; /* which file server to restore the volume to */ - opaque newName[TC_MAXNAMELEN]; /* new name suffix */ + afs_int32 origVid; /* original volume id */ + afs_int32 vid; /* 0 means allocate new volid */ + afs_int32 partition; /* where to restore the volume */ + afs_int32 flags; /* flags */ + opaque hostID[16]; /* which file server to restore the volume to */ + opaque newName[TC_MAXNAMELEN]; /* new name suffix */ }; /* describes the current status of a dump */ struct tc_dumpStat { - afs_int32 dumpID; /* dump id we're returning */ - afs_int32 bytesDumped; /* bytes dumped so far */ - afs_int32 volumeBeingDumped; /* guess */ - afs_int32 flags; /* true if the dump is done */ + afs_int32 dumpID; /* dump id we're returning */ + afs_int32 bytesDumped; /* bytes dumped so far */ + afs_int32 volumeBeingDumped; /* guess */ + afs_int32 flags; /* true if the dump is done */ }; diff --git a/src/butc/dbentries.c b/src/butc/dbentries.c index edf138562..c67bf318f 100644 --- a/src/butc/dbentries.c +++ b/src/butc/dbentries.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #ifdef AFS_NT40_ENV @@ -45,39 +46,42 @@ dlqlinkT entries_to_flush; int dbWatcherinprogress; -afs_int32 threadEntryDir(anEntry, size, type) - char *anEntry; +afs_int32 +threadEntryDir(anEntry, size, type) + char *anEntry; afs_int32 size, type; { dlqlinkP entryPtr; - char *entry = NULL; - int tried; + char *entry = NULL; + int tried; - for (tried=0; tried<5; tried++) { - entryPtr = (dlqlinkP)malloc(sizeof(dlqlinkT)); - entry = (char *) malloc(size); - if (entryPtr && entry) - break; + for (tried = 0; tried < 5; tried++) { + entryPtr = (dlqlinkP) malloc(sizeof(dlqlinkT)); + entry = (char *)malloc(size); + if (entryPtr && entry) + break; - /* sleep a minute and try again */ - if (entryPtr) free(entryPtr); - if (entry) free(entry); + /* sleep a minute and try again */ + if (entryPtr) + free(entryPtr); + if (entry) + free(entry); - if ((tried > 0) && !dbWatcherinprogress) - return(TC_NOMEMORY); + if ((tried > 0) && !dbWatcherinprogress) + return (TC_NOMEMORY); #ifdef AFS_PTHREAD_ENV - sleep(60); + sleep(60); #else - IOMGR_Sleep(60); + IOMGR_Sleep(60); #endif } - entryPtr->dlq_prev = entryPtr->dlq_next = (dlqlinkP)NULL; - entryPtr->dlq_type = type; + entryPtr->dlq_prev = entryPtr->dlq_next = (dlqlinkP) NULL; + entryPtr->dlq_type = type; entryPtr->dlq_structPtr = entry; memcpy(entry, anEntry, size); - dlqLinkb (&entries_to_flush, entryPtr); - return(0); + dlqLinkb(&entries_to_flush, entryPtr); + return (0); } /* @@ -87,27 +91,29 @@ afs_int32 threadEntryDir(anEntry, size, type) * Watcher thread will free up some memory for it to continue. */ -afs_int32 +afs_int32 threadEntry(anEntry, size, type) - char *anEntry; + char *anEntry; afs_int32 size, type; { dlqlinkP entryPtr; - char *entry = NULL; - int tried; + char *entry = NULL; + int tried; - for (tried=0; tried<5; tried++) { - entryPtr = (dlqlinkP)malloc(sizeof(dlqlinkT)); - entry = (char *) malloc(size); + for (tried = 0; tried < 5; tried++) { + entryPtr = (dlqlinkP) malloc(sizeof(dlqlinkT)); + entry = (char *)malloc(size); if (entryPtr && entry) - break; + break; /* sleep a minute and try again */ - if (entryPtr) free(entryPtr); - if (entry) free(entry); + if (entryPtr) + free(entryPtr); + if (entry) + free(entry); if ((tried > 0) && !dbWatcherinprogress) - return(TC_NOMEMORY); + return (TC_NOMEMORY); #ifdef AFS_PTHREAD_ENV sleep(60); #else @@ -115,36 +121,41 @@ threadEntry(anEntry, size, type) #endif } - entryPtr->dlq_prev = entryPtr->dlq_next = (dlqlinkP)NULL; - entryPtr->dlq_type = type; + entryPtr->dlq_prev = entryPtr->dlq_next = (dlqlinkP) NULL; + entryPtr->dlq_type = type; entryPtr->dlq_structPtr = entry; memcpy(entry, anEntry, size); - dlqLinkb (&savedEntries, (dlqlinkP)entryPtr); - return(0); + dlqLinkb(&savedEntries, (dlqlinkP) entryPtr); + return (0); } /* ------------------------------------------------------------------ */ -afs_int32 useDump(dumpEntryPtr) +afs_int32 +useDump(dumpEntryPtr) struct budb_dumpEntry *dumpEntryPtr; { - afs_int32 code = 0; + afs_int32 code = 0; - code = threadEntry(dumpEntryPtr, sizeof(struct budb_dumpEntry), DLQ_USEDUMP); - return(code); + code = + threadEntry(dumpEntryPtr, sizeof(struct budb_dumpEntry), DLQ_USEDUMP); + return (code); } /* * finishDump * Creates a dump entry (finished) and puts it onto the savedEntries list. */ -afs_int32 finishDump (aDumpEntryPtr) - struct budb_dumpEntry *aDumpEntryPtr; +afs_int32 +finishDump(aDumpEntryPtr) + struct budb_dumpEntry *aDumpEntryPtr; { - afs_int32 code=0; - - code = threadEntry(aDumpEntryPtr, sizeof(struct budb_dumpEntry), DLQ_FINISHDUMP); + afs_int32 code = 0; + + code = + threadEntry(aDumpEntryPtr, sizeof(struct budb_dumpEntry), + DLQ_FINISHDUMP); return (code); } @@ -152,46 +163,53 @@ afs_int32 finishDump (aDumpEntryPtr) * useTape * Creates a tape entry and puts it onto the savedEntries list. */ -afs_int32 useTape (aTapeEntryPtr, dumpID, tapename, tapeSeq, useCount, written, expiration, tapepos) +afs_int32 +useTape(aTapeEntryPtr, dumpID, tapename, tapeSeq, useCount, written, + expiration, tapepos) struct budb_tapeEntry *aTapeEntryPtr; - afs_int32 dumpID; - char *tapename; - afs_int32 tapeSeq; - afs_int32 useCount; - Date written; - Date expiration; - afs_int32 tapepos; + afs_int32 dumpID; + char *tapename; + afs_int32 tapeSeq; + afs_int32 useCount; + Date written; + Date expiration; + afs_int32 tapepos; { afs_int32 code = 0; memset(aTapeEntryPtr, 0, sizeof(struct budb_tapeEntry)); strcpy(aTapeEntryPtr->name, tapename); - aTapeEntryPtr->flags = BUDB_TAPE_BEINGWRITTEN; - aTapeEntryPtr->written = written; /* When label was written */ - aTapeEntryPtr->expires = expiration; - aTapeEntryPtr->seq = tapeSeq; + aTapeEntryPtr->flags = BUDB_TAPE_BEINGWRITTEN; + aTapeEntryPtr->written = written; /* When label was written */ + aTapeEntryPtr->expires = expiration; + aTapeEntryPtr->seq = tapeSeq; aTapeEntryPtr->useCount = useCount; - aTapeEntryPtr->dump = dumpID; + aTapeEntryPtr->dump = dumpID; aTapeEntryPtr->labelpos = tapepos; - - code = threadEntry(aTapeEntryPtr, sizeof(struct budb_tapeEntry), DLQ_USETAPE); - return(code); + + code = + threadEntry(aTapeEntryPtr, sizeof(struct budb_tapeEntry), + DLQ_USETAPE); + return (code); } /* * finishTape * Creates a tape entry (finished) and puts it onto the savedEntries list. */ -afs_int32 finishTape (aTapeEntryPtr, useKBytes) +afs_int32 +finishTape(aTapeEntryPtr, useKBytes) struct budb_tapeEntry *aTapeEntryPtr; - afs_int32 useKBytes; + afs_int32 useKBytes; { - afs_int32 code=0; - - aTapeEntryPtr->flags = BUDB_TAPE_WRITTEN; + afs_int32 code = 0; + + aTapeEntryPtr->flags = BUDB_TAPE_WRITTEN; aTapeEntryPtr->useKBytes = useKBytes; - code = threadEntry(aTapeEntryPtr, sizeof(struct budb_tapeEntry), DLQ_FINISHTAPE); + code = + threadEntry(aTapeEntryPtr, sizeof(struct budb_tapeEntry), + DLQ_FINISHTAPE); return (code); } @@ -199,44 +217,50 @@ afs_int32 finishTape (aTapeEntryPtr, useKBytes) * addVolume * Creates a volume entry and puts it onto the savedEntries list. */ -afs_int32 addVolume(aVolEntryPtr, dumpID, tapename, volname, volid, cloneDate, - startPos, volBytes, fragment, flags) +afs_int32 +addVolume(aVolEntryPtr, dumpID, tapename, volname, volid, cloneDate, startPos, + volBytes, fragment, flags) struct budb_volumeEntry *aVolEntryPtr; afs_int32 dumpID; char *tapename; char *volname; afs_int32 volid; - Date cloneDate; + Date cloneDate; afs_int32 startPos; afs_int32 volBytes; int fragment; afs_int32 flags; { - afs_int32 code = 0; - int allo = 0; + afs_int32 code = 0; + int allo = 0; if (!aVolEntryPtr) { - aVolEntryPtr = (struct budb_volumeEntry *)malloc(sizeof(struct budb_volumeEntry)); - if (!aVolEntryPtr) ERROR_EXIT(TC_NOMEMORY); + aVolEntryPtr = (struct budb_volumeEntry *) + malloc(sizeof(struct budb_volumeEntry)); + if (!aVolEntryPtr) + ERROR_EXIT(TC_NOMEMORY); allo = 1; } - + memset(aVolEntryPtr, 0, sizeof(struct budb_volumeEntry)); strcpy(aVolEntryPtr->name, volname); - aVolEntryPtr->flags = flags; - aVolEntryPtr->id = volid; + aVolEntryPtr->flags = flags; + aVolEntryPtr->id = volid; aVolEntryPtr->position = startPos; - aVolEntryPtr->clone = cloneDate; - aVolEntryPtr->nBytes = volBytes; - aVolEntryPtr->seq = fragment; - aVolEntryPtr->dump = dumpID; + aVolEntryPtr->clone = cloneDate; + aVolEntryPtr->nBytes = volBytes; + aVolEntryPtr->seq = fragment; + aVolEntryPtr->dump = dumpID; strcpy(aVolEntryPtr->tape, tapename); - code = threadEntry(aVolEntryPtr, sizeof(struct budb_volumeEntry), DLQ_VOLENTRY); + code = + threadEntry(aVolEntryPtr, sizeof(struct budb_volumeEntry), + DLQ_VOLENTRY); -error_exit: - if (code && allo) free(aVolEntryPtr); - return(code); + error_exit: + if (code && allo) + free(aVolEntryPtr); + return (code); } /* @@ -246,7 +270,8 @@ error_exit: * A status of DUMP_NORETRYEOT means the tape(s) contains no useful data, * and tapes and volumes should not be added to the DB. */ -afs_int32 flushSavedEntries (status) +afs_int32 +flushSavedEntries(status) afs_int32 status; { dlqlinkP entryPtr; @@ -261,13 +286,15 @@ afs_int32 flushSavedEntries (status) * without adding it to the backup database. */ if (status == DUMP_NORETRYEOT) { - entryPtr = dlqUnlinkb(&savedEntries); - if ( !entryPtr || (entryPtr->dlq_type != DLQ_USETAPE) ) + entryPtr = dlqUnlinkb(&savedEntries); + if (!entryPtr || (entryPtr->dlq_type != DLQ_USETAPE)) ERROR_EXIT(TC_INTERNALERROR); tapePtr = (struct budb_tapeEntry *)entryPtr->dlq_structPtr; - if (tapePtr) free(tapePtr); - if (entryPtr) free(entryPtr); + if (tapePtr) + free(tapePtr); + if (entryPtr) + free(entryPtr); } /* @@ -275,203 +302,213 @@ afs_int32 flushSavedEntries (status) * flush. Volume entries are not added if the volume failed to dump. */ while (entryPtr = dlqUnlinkf(&savedEntries)) { - if ((entryPtr->dlq_type == DLQ_VOLENTRY) && (status != DUMP_SUCCESS)) { + if ((entryPtr->dlq_type == DLQ_VOLENTRY) && (status != DUMP_SUCCESS)) { volPtr = (struct budb_volumeEntry *)entryPtr->dlq_structPtr; - if (volPtr) free(volPtr); - if (entryPtr) free(entryPtr); - } - else { - dlqLinkb (&entries_to_flush, entryPtr); + if (volPtr) + free(volPtr); + if (entryPtr) + free(entryPtr); + } else { + dlqLinkb(&entries_to_flush, entryPtr); } } -error_exit: + error_exit: /* Free anything that remains on dlq */ - dlqTraverseQueue (&savedEntries, free, free); + dlqTraverseQueue(&savedEntries, free, free); return (code); } waitDbWatcher() { - int message = 0; + int message = 0; - while (dbWatcherinprogress || !dlqEmpty(&entries_to_flush)) { - if (!message) { - printf("Updating database\n"); - message++; - } + while (dbWatcherinprogress || !dlqEmpty(&entries_to_flush)) { + if (!message) { + printf("Updating database\n"); + message++; + } #ifdef AFS_PTHREAD_ENV - sleep(2); + sleep(2); #else - IOMGR_Sleep(2); + IOMGR_Sleep(2); #endif - } + } - if (message) { - printf("Updating database - done\n"); - } + if (message) { + printf("Updating database - done\n"); + } } #define MAXVOLUMESTOADD 100 -int addvolumes=1; +int addvolumes = 1; dbWatcher() { - dlqlinkP entryPtr; - struct budb_dumpEntry *dumpPtr; - struct budb_tapeEntry *tapePtr; - struct budb_volumeEntry *volPtr, volumes[MAXVOLUMESTOADD]; - afs_int32 new; - afs_int32 code = 0; - int i, c, addedDump; - - dlqInit(&entries_to_flush); - dlqInit(&savedEntries); - - dbWatcherinprogress = 0; - addedDump = 1; - while (1) { - /*while*/ - /* Add tape and volume enties to the backup database */ - while (entryPtr = dlqUnlinkf(&entries_to_flush)) { - dbWatcherinprogress = 1; - - if (!entryPtr->dlq_structPtr) { - ErrorLog(0, 0, TC_BADQUEUE, 0, - "Warning: Invalid database entry - nota added\n"); - } - else switch (entryPtr->dlq_type) { - case DLQ_USEDUMP: - dumpPtr = (struct budb_dumpEntry *)entryPtr->dlq_structPtr; - /* Now call the database to create the entry */ - code = bcdb_CreateDump(dumpPtr); - if (code) { - if (code == BUDB_DUMPIDEXISTS) { - printf("Dump %s (DumpID %u) already exists in backup database\n", - dumpPtr->name, dumpPtr->id); - } else { - ErrorLog(0, 0, code, 0, - "Warning: Can't create dump %s (DumpID %u) in backup database\n", - dumpPtr->name, dumpPtr->id); - } - } - addedDump = (code ? 0 : 1); - break; - - case DLQ_FINISHDUMP: - dumpPtr = (struct budb_dumpEntry *)entryPtr->dlq_structPtr; - if (addedDump) { - code = bcdb_FinishDump(dumpPtr); - if (code) { - ErrorLog(0, 0, code, 0, - "Warning: Can't finish dump %s (DumpID %u) in backup database\n", + dlqlinkP entryPtr; + struct budb_dumpEntry *dumpPtr; + struct budb_tapeEntry *tapePtr; + struct budb_volumeEntry *volPtr, volumes[MAXVOLUMESTOADD]; + afs_int32 new; + afs_int32 code = 0; + int i, c, addedDump; + + dlqInit(&entries_to_flush); + dlqInit(&savedEntries); + + dbWatcherinprogress = 0; + addedDump = 1; + while (1) { + /*while */ + /* Add tape and volume enties to the backup database */ + while (entryPtr = dlqUnlinkf(&entries_to_flush)) { + dbWatcherinprogress = 1; + + if (!entryPtr->dlq_structPtr) { + ErrorLog(0, 0, TC_BADQUEUE, 0, + "Warning: Invalid database entry - nota added\n"); + } else + switch (entryPtr->dlq_type) { + case DLQ_USEDUMP: + dumpPtr = + (struct budb_dumpEntry *)entryPtr->dlq_structPtr; + /* Now call the database to create the entry */ + code = bcdb_CreateDump(dumpPtr); + if (code) { + if (code == BUDB_DUMPIDEXISTS) { + printf + ("Dump %s (DumpID %u) already exists in backup database\n", dumpPtr->name, dumpPtr->id); - } - } - addedDump = 1; - break; - - case DLQ_USETAPE: - tapePtr = (struct budb_tapeEntry *)entryPtr->dlq_structPtr; - if (addedDump) { - code = bcdb_UseTape(tapePtr, &new); - if (code) { - ErrorLog(0, 0, code, 0, - "Warning: Can't add tape %s of DumpID %u to backup database\n", - tapePtr->name, tapePtr->dump); - } - } - break; - - case DLQ_FINISHTAPE: - tapePtr = (struct budb_tapeEntry *)entryPtr->dlq_structPtr; - if (addedDump) { - code = bcdb_FinishTape(tapePtr, &new); - if (code) { - ErrorLog(0, 0, code, 0, - "Warning: Can't finish tape %s of DumpID %u in backup database\n", - tapePtr->name, tapePtr->dump); - } - } - break; - - case DLQ_VOLENTRY: - /* collect array of volumes to add to the dump */ - for (c=0; c 0) { /* don't read the 1st - already did */ - entryPtr = dlqUnlinkf(&entries_to_flush); /* Get the next entry */ - if (!entryPtr) break; - } - - if (entryPtr->dlq_type != DLQ_VOLENTRY) { - /* Place back onto list and add the vol entries we have */ - dlqLinkf(&entries_to_flush, entryPtr); - entryPtr = (dlqlinkP)0; /* don't want to deallocate below */ - break; - } - - volPtr = (struct budb_volumeEntry *)entryPtr->dlq_structPtr; - if (!volPtr) { - ErrorLog(0, 0, TC_BADQUEUE, 0, - "Warning: Invalid database entry - not added\n"); - break; - } - - memcpy(&volumes[c], volPtr, sizeof(struct budb_volumeEntry)); - free(volPtr); - free(entryPtr); - entryPtr = (dlqlinkP)0; - } - - if (addedDump) { - if (addvolumes) { - code = bcdb_AddVolumes(&volumes[0], c); + } else { + ErrorLog(0, 0, code, 0, + "Warning: Can't create dump %s (DumpID %u) in backup database\n", + dumpPtr->name, dumpPtr->id); + } + } + addedDump = (code ? 0 : 1); + break; + + case DLQ_FINISHDUMP: + dumpPtr = + (struct budb_dumpEntry *)entryPtr->dlq_structPtr; + if (addedDump) { + code = bcdb_FinishDump(dumpPtr); if (code) { - if (code < 0) - addvolumes = 0; - else { - ErrorLog(0, 0, code, 0, - "Warning: Can't add %d volumes to dumpid %u\n", - c, volumes[0].dump); - } + ErrorLog(0, 0, code, 0, + "Warning: Can't finish dump %s (DumpID %u) in backup database\n", + dumpPtr->name, dumpPtr->id); } - } - if (!addvolumes) { - for (i=0; idlq_structPtr; + if (addedDump) { + code = bcdb_UseTape(tapePtr, &new); + if (code) { + ErrorLog(0, 0, code, 0, + "Warning: Can't add tape %s of DumpID %u to backup database\n", + tapePtr->name, tapePtr->dump); + } + } + break; + + case DLQ_FINISHTAPE: + tapePtr = + (struct budb_tapeEntry *)entryPtr->dlq_structPtr; + if (addedDump) { + code = bcdb_FinishTape(tapePtr, &new); + if (code) { + ErrorLog(0, 0, code, 0, + "Warning: Can't finish tape %s of DumpID %u in backup database\n", + tapePtr->name, tapePtr->dump); } - } - } - break; - - default: - ErrorLog(0, 0, 0, 0, - "Warning: dbWatcher: Unrecognized entry type %d\n", - entryPtr->dlq_type); - break; /* ignore */ - } - - if (entryPtr) { - if (entryPtr->dlq_structPtr) - free(entryPtr->dlq_structPtr); - free(entryPtr); - } - entryPtr = (dlqlinkP)0; - dumpPtr = (budb_dumpEntry *)0; - volPtr = (budb_volumeEntry *)0; - tapePtr = (budb_tapeEntry *)0; - } /*while*/ - - dbWatcherinprogress = 0; + } + break; + + case DLQ_VOLENTRY: + /* collect array of volumes to add to the dump */ + for (c = 0; c < MAXVOLUMESTOADD; c++) { + if (c > 0) { /* don't read the 1st - already did */ + entryPtr = dlqUnlinkf(&entries_to_flush); /* Get the next entry */ + if (!entryPtr) + break; + } + + if (entryPtr->dlq_type != DLQ_VOLENTRY) { + /* Place back onto list and add the vol entries we have */ + dlqLinkf(&entries_to_flush, entryPtr); + entryPtr = (dlqlinkP) 0; /* don't want to deallocate below */ + break; + } + + volPtr = + (struct budb_volumeEntry *)entryPtr-> + dlq_structPtr; + if (!volPtr) { + ErrorLog(0, 0, TC_BADQUEUE, 0, + "Warning: Invalid database entry - not added\n"); + break; + } + + memcpy(&volumes[c], volPtr, + sizeof(struct budb_volumeEntry)); + free(volPtr); + free(entryPtr); + entryPtr = (dlqlinkP) 0; + } + + if (addedDump) { + if (addvolumes) { + code = bcdb_AddVolumes(&volumes[0], c); + if (code) { + if (code < 0) + addvolumes = 0; + else { + ErrorLog(0, 0, code, 0, + "Warning: Can't add %d volumes to dumpid %u\n", + c, volumes[0].dump); + } + } + } + if (!addvolumes) { + for (i = 0; i < c; i++) { + code = bcdb_AddVolume(&volumes[i]); + if (code) { + ErrorLog(0, 0, code, 0, + "Warning: Can't add volume %s %u to backup database\n", + volumes[i].name, volumes[i].id); + } + } + } + } + break; + + default: + ErrorLog(0, 0, 0, 0, + "Warning: dbWatcher: Unrecognized entry type %d\n", + entryPtr->dlq_type); + break; /* ignore */ + } + + if (entryPtr) { + if (entryPtr->dlq_structPtr) + free(entryPtr->dlq_structPtr); + free(entryPtr); + } + entryPtr = (dlqlinkP) 0; + dumpPtr = (budb_dumpEntry *) 0; + volPtr = (budb_volumeEntry *) 0; + tapePtr = (budb_tapeEntry *) 0; + } /*while */ + + dbWatcherinprogress = 0; #ifdef AFS_PTHREAD_ENV - sleep(2); + sleep(2); #else - IOMGR_Sleep(2); + IOMGR_Sleep(2); #endif - } + } } diff --git a/src/butc/dump.c b/src/butc/dump.c index a05320d43..7ab911e59 100644 --- a/src/butc/dump.c +++ b/src/butc/dump.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #ifdef AFS_NT40_ENV @@ -53,7 +54,8 @@ extern struct ubik_client *cstruct; dlqlinkT savedEntries; dlqlinkT entries_to_flush; -afs_int32 flushSavedEntries(), finishDump(), finishTape(), useTape(), addVolume(); +afs_int32 flushSavedEntries(), finishDump(), finishTape(), useTape(), +addVolume(); extern struct rx_connection *UV_Bind(); @@ -63,8 +65,8 @@ extern afs_int32 xbsaType; extern afs_int32 groupId; extern afs_int32 BufferSize; extern afs_int32 statusSize; -extern FILE *centralLogIO; -afs_int32 lastPass=0; +extern FILE *centralLogIO; +afs_int32 lastPass = 0; #ifdef xbsa char *butcdumpIdStr = "/backup_afs_volume_dumps"; extern struct butx_transactionInfo butxInfo; @@ -73,10 +75,10 @@ extern char *appObjectOwner; extern char *xbsaSecToken; extern char *xbsalGName; extern char *globalButcLog; -#endif /*xbsa*/ +#endif /*xbsa */ -afs_int32 dataSize; /* Size of data to read on each rx_Read() call */ -afs_int32 tapeblocks; /* Number of 16K tape datablocks in buffer (!CONF_XBSA) */ +afs_int32 dataSize; /* Size of data to read on each rx_Read() call */ +afs_int32 tapeblocks; /* Number of 16K tape datablocks in buffer (!CONF_XBSA) */ /* TBD * @@ -102,35 +104,35 @@ afs_int32 tapeblocks; /* Number of 16K tape datablocks in buffer (!CONF_XBS sprintf(dumpname, "%s (DumpId %u)", name, dbDumpId); #if defined(AFS_NT40_ENV) || (defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN60_ENV)) || defined(AFS_SUN4_ENV) -int localtime_r(time_t *t, struct tm *tm) +int +localtime_r(time_t * t, struct tm *tm) { - memcpy(tm, localtime(t), sizeof(struct tm)); + memcpy(tm, localtime(t), sizeof(struct tm)); } #endif -struct dumpRock -{ +struct dumpRock { /* status only */ - int tapeSeq; - int curVolume; /* index in dumpNode of volume */ - int curVolumeStatus; /* more explicit dump state */ - afs_uint32 curVolStartPos; /* Starting position of the current volume */ - afs_uint32 databaseDumpId; /* real dump id, for db */ - afs_uint32 initialDumpId; /* the initial dump, for appended dumps */ - afs_int32 volumesDumped; /* # volumes successfully dumped */ - afs_int32 volumesFailed; /* # volumes that failed to dump */ - afs_int32 volumesNotDumped; /* # volumes that were not dumped (didn't fail) */ + int tapeSeq; + int curVolume; /* index in dumpNode of volume */ + int curVolumeStatus; /* more explicit dump state */ + afs_uint32 curVolStartPos; /* Starting position of the current volume */ + afs_uint32 databaseDumpId; /* real dump id, for db */ + afs_uint32 initialDumpId; /* the initial dump, for appended dumps */ + afs_int32 volumesDumped; /* # volumes successfully dumped */ + afs_int32 volumesFailed; /* # volumes that failed to dump */ + afs_int32 volumesNotDumped; /* # volumes that were not dumped (didn't fail) */ /* tape management */ - char tapeName[TC_MAXTAPENAMELEN]; - struct butm_tapeInfo *tapeInfoPtr; + char tapeName[TC_MAXTAPENAMELEN]; + struct butm_tapeInfo *tapeInfoPtr; struct butm_tapeLabel tapeLabel; - int wroteLabel; /* If the tape label is written */ + int wroteLabel; /* If the tape label is written */ /* database information */ - struct budb_dumpEntry lastDump; /* the last dump of this volset */ - struct budb_dumpEntry dump; /* current dump */ - struct budb_tapeEntry tape; /* current tape, not used -VA*/ + struct budb_dumpEntry lastDump; /* the last dump of this volset */ + struct budb_dumpEntry dump; /* current dump */ + struct budb_tapeEntry tape; /* current tape, not used -VA */ /* links to existing info */ struct dumpNode *node; @@ -143,55 +145,56 @@ extern int maxpass; afs_int32 tc_EndMargin; afs_int32 tc_KEndMargin; -char *bufferBlock; +char *bufferBlock; /* compute the absolute expiration date */ -afs_int32 calcExpirationDate(afs_int32 expType, afs_int32 expDate, - afs_int32 createTime) +afs_int32 +calcExpirationDate(afs_int32 expType, afs_int32 expDate, afs_int32 createTime) { struct ktime_date kd; - afs_int32 Add_RelDate_to_Time(); + afs_int32 Add_RelDate_to_Time(); - switch ( expType ) - { - case BC_REL_EXPDATE: - /* expiration date is relative to the creation time of the dump. + switch (expType) { + case BC_REL_EXPDATE: + /* expiration date is relative to the creation time of the dump. * This is the only case that requires any work */ Int32To_ktimeRelDate(expDate, &kd); - return(Add_RelDate_to_Time(&kd, createTime)); + return (Add_RelDate_to_Time(&kd, createTime)); break; - case BC_ABS_EXPDATE: - return(expDate); + case BC_ABS_EXPDATE: + return (expDate); break; - case BC_NO_EXPDATE: - default: - return(0); + case BC_NO_EXPDATE: + default: + return (0); } } -afs_int32 curr_bserver = 0; -struct rx_connection *curr_fromconn = (struct rx_connection *)0; +afs_int32 curr_bserver = 0; +struct rx_connection *curr_fromconn = (struct rx_connection *)0; -struct rx_connection *Bind(afs_int32 server) +struct rx_connection * +Bind(afs_int32 server) { - if (curr_fromconn) { - if (curr_bserver == server) /* Keep connection if have it */ - return (curr_fromconn); - - rx_DestroyConnection (curr_fromconn); /* Otherwise get rid of it */ - curr_fromconn = (struct rx_connection *)0; - curr_bserver = 0; - } - - if (server) { - curr_fromconn = UV_Bind (server, AFSCONF_VOLUMEPORT); /* Establish new connection */ - if (curr_fromconn) curr_bserver = server; - } - - return (curr_fromconn); + if (curr_fromconn) { + if (curr_bserver == server) /* Keep connection if have it */ + return (curr_fromconn); + + rx_DestroyConnection(curr_fromconn); /* Otherwise get rid of it */ + curr_fromconn = (struct rx_connection *)0; + curr_bserver = 0; + } + + if (server) { + curr_fromconn = UV_Bind(server, AFSCONF_VOLUMEPORT); /* Establish new connection */ + if (curr_fromconn) + curr_bserver = server; + } + + return (curr_fromconn); } /* notes @@ -205,62 +208,68 @@ struct rx_connection *Bind(afs_int32 server) #define BIGCHUNK 102400 afs_int32 -dumpVolume(struct tc_dumpDesc *curDump, struct dumpRock *dparamsPtr) +dumpVolume(struct tc_dumpDesc * curDump, struct dumpRock * dparamsPtr) { struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr; - struct dumpNode *nodePtr = dparamsPtr->node; - afs_int32 taskId = nodePtr->taskID; - char *buffer; - int fragmentNumber; - afs_int32 volumeFlags; - afs_int32 kRemaining; - afs_int32 rc, code = 0; - afs_int32 toread; + struct dumpNode *nodePtr = dparamsPtr->node; + afs_int32 taskId = nodePtr->taskID; + char *buffer; + int fragmentNumber; + afs_int32 volumeFlags; + afs_int32 kRemaining; + afs_int32 rc, code = 0; + afs_int32 toread; afs_uint32 volBytesRead; afs_uint32 chunkSize; - afs_int32 bytesread; /* rx reads */ - int endofvolume=0; /* Have we read all volume data */ - int indump=0; - int fragmentvolume; - struct volumeHeader hostVolumeHeader; + afs_int32 bytesread; /* rx reads */ + int endofvolume = 0; /* Have we read all volume data */ + int indump = 0; + int fragmentvolume; + struct volumeHeader hostVolumeHeader; - struct rx_call *fromcall = (struct rx_call *)0; + struct rx_call *fromcall = (struct rx_call *)0; struct rx_connection *fromconn; - afs_int32 updatedate, fromtid = 0; - volEntries volumeInfo; - afs_int32 bytesWritten; - afs_uint32 statuscount=statusSize, tsize=0; + afs_int32 updatedate, fromtid = 0; + volEntries volumeInfo; + afs_int32 bytesWritten; + afs_uint32 statuscount = statusSize, tsize = 0; dparamsPtr->curVolumeStatus = DUMP_NOTHING; - fromconn = Bind(htonl(curDump->hostAddr)); /* get connection to the server */ + fromconn = Bind(htonl(curDump->hostAddr)); /* get connection to the server */ /* Determine when the volume was last cloned and updated */ - volumeInfo.volEntries_val = (volintInfo *)0; + volumeInfo.volEntries_val = (volintInfo *) 0; volumeInfo.volEntries_len = 0; - rc = AFSVolListOneVolume(fromconn, curDump->partition, curDump->vid, &volumeInfo); - if (rc) ERROR_EXIT(rc); - updatedate = volumeInfo.volEntries_val[0].updateDate; - curDump->cloneDate = ((curDump->vtype == RWVOL) ? - time(0) : volumeInfo.volEntries_val[0].creationDate); + rc = AFSVolListOneVolume(fromconn, curDump->partition, curDump->vid, + &volumeInfo); + if (rc) + ERROR_EXIT(rc); + updatedate = volumeInfo.volEntries_val[0].updateDate; + curDump->cloneDate = + ((curDump->vtype == + RWVOL) ? time(0) : volumeInfo.volEntries_val[0].creationDate); if (curDump->date >= curDump->cloneDate) - ERROR_EXIT(0); /* not recloned since last dump */ - if (curDump->date > updatedate) { - dparamsPtr->curVolumeStatus = DUMP_NODUMP; /* not modified since last dump */ + ERROR_EXIT(0); /* not recloned since last dump */ + if (curDump->date > updatedate) { + dparamsPtr->curVolumeStatus = DUMP_NODUMP; /* not modified since last dump */ ERROR_EXIT(0); } /* Start the volserver transaction and dump */ - rc = AFSVolTransCreate (fromconn, curDump->vid, curDump->partition, ITBusy, &fromtid); - if (rc) ERROR_EXIT(rc); + rc = AFSVolTransCreate(fromconn, curDump->vid, curDump->partition, ITBusy, + &fromtid); + if (rc) + ERROR_EXIT(rc); fromcall = rx_NewCall(fromconn); - rc = StartAFSVolDump (fromcall, fromtid, curDump->date); - if (rc) ERROR_EXIT(rc); + rc = StartAFSVolDump(fromcall, fromtid, curDump->date); + if (rc) + ERROR_EXIT(rc); dparamsPtr->curVolumeStatus = DUMP_PARTIAL; - dparamsPtr->curVolStartPos = tapeInfoPtr->position; + dparamsPtr->curVolStartPos = tapeInfoPtr->position; /* buffer is place in bufferBlock to write volume data. * butm_writeFileData() assumes the previous BUTM_HDRSIZE bytes @@ -272,26 +281,29 @@ dumpVolume(struct tc_dumpDesc *curDump, struct dumpRock *dparamsPtr) * A volume with more than 1 fragment means the volume will 'span' * 2 or more tapes. */ - for (fragmentNumber=1; !endofvolume; fragmentNumber++) { /*frag*/ - rc = butm_WriteFileBegin(tapeInfoPtr); + for (fragmentNumber = 1; !endofvolume; fragmentNumber++) { /*frag */ + rc = butm_WriteFileBegin(tapeInfoPtr); if (rc) { - ErrorLog(1, taskId, rc, tapeInfoPtr->error, "Can't write FileBegin on tape\n"); - ERROR_EXIT(rc); + ErrorLog(1, taskId, rc, tapeInfoPtr->error, + "Can't write FileBegin on tape\n"); + ERROR_EXIT(rc); } - indump = 1; /* first write to tape */ + indump = 1; /* first write to tape */ /* Create and Write the volume header */ makeVolumeHeader(&hostVolumeHeader, dparamsPtr, fragmentNumber); hostVolumeHeader.contd = ((fragmentNumber == 1) ? 0 : TC_VOLCONTD); volumeHeader_hton(&hostVolumeHeader, buffer); - rc = butm_WriteFileData(tapeInfoPtr, buffer, 1, sizeof(hostVolumeHeader)); + rc = butm_WriteFileData(tapeInfoPtr, buffer, 1, + sizeof(hostVolumeHeader)); if (rc) { - ErrorLog(1, taskId, rc, tapeInfoPtr->error, "Can't write VolumeHeader on tape\n"); - ERROR_EXIT(rc); + ErrorLog(1, taskId, rc, tapeInfoPtr->error, + "Can't write VolumeHeader on tape\n"); + ERROR_EXIT(rc); } - bytesWritten = BUTM_BLOCKSIZE; /* Wrote one tapeblock */ + bytesWritten = BUTM_BLOCKSIZE; /* Wrote one tapeblock */ tsize += bytesWritten; /* Start reading volume data, rx_Read(), and dumping to the tape @@ -300,15 +312,15 @@ dumpVolume(struct tc_dumpDesc *curDump, struct dumpRock *dparamsPtr) * tape; in which case we dump the next fragment on the next tape. */ volBytesRead = 0; - chunkSize = 0; + chunkSize = 0; fragmentvolume = 0; - while (!endofvolume && !fragmentvolume) { /*w*/ + while (!endofvolume && !fragmentvolume) { /*w */ bytesread = 0; /* Check for abort in the middle of writing data */ if (volBytesRead >= chunkSize) { - chunkSize += BIGCHUNK; - if ( checkAbortByTaskId(taskId) ) + chunkSize += BIGCHUNK; + if (checkAbortByTaskId(taskId)) ABORT_EXIT(TC_ABORTEDBYREQUEST); /* set bytes dumped for backup */ @@ -328,137 +340,153 @@ dumpVolume(struct tc_dumpDesc *curDump, struct dumpRock *dparamsPtr) * switch tapes. This allows many small volumes (<16K) to be dumped. */ kRemaining = butm_remainingKSpace(tapeInfoPtr); - if ( (kRemaining < tc_KEndMargin) && - (volBytesRead || (tapeInfoPtr->position > (isafile?3:2))) ) { - fragmentvolume = 1; + if ((kRemaining < tc_KEndMargin) + && (volBytesRead + || (tapeInfoPtr->position > (isafile ? 3 : 2)))) { + fragmentvolume = 1; } /* Guess at how much data to read. So we don't write off end of tape */ if (kRemaining < (tapeblocks * 16)) { - if (kRemaining < 0) { - toread = BUTM_BLKSIZE; - } else { - toread = ((kRemaining/16) + 1) * BUTM_BLKSIZE; - if (toread > dataSize) toread = dataSize; - } + if (kRemaining < 0) { + toread = BUTM_BLKSIZE; + } else { + toread = ((kRemaining / 16) + 1) * BUTM_BLKSIZE; + if (toread > dataSize) + toread = dataSize; + } } /* Read some volume data. */ if (fragmentvolume) { - bytesread = 0; + bytesread = 0; } else { - bytesread = rx_Read(fromcall, buffer, toread); - volBytesRead += bytesread; - if (bytesread != toread) { - /* Make sure were at end of volume and not a communication error */ - rc = rx_Error(fromcall); - if (rc) ERROR_EXIT(rc); - endofvolume = 1; - } + bytesread = rx_Read(fromcall, buffer, toread); + volBytesRead += bytesread; + if (bytesread != toread) { + /* Make sure were at end of volume and not a communication error */ + rc = rx_Error(fromcall); + if (rc) + ERROR_EXIT(rc); + endofvolume = 1; + } } if (fragmentvolume || endofvolume) { - /* Create a volume trailer appending it to this data block */ - makeVolumeHeader(&hostVolumeHeader, dparamsPtr, fragmentNumber); - hostVolumeHeader.contd = (endofvolume ? 0 : TC_VOLCONTD); - hostVolumeHeader.magic = TC_VOLENDMAGIC; - hostVolumeHeader.endTime = (endofvolume ? time(0) : 0); - volumeHeader_hton(&hostVolumeHeader, &buffer[bytesread]); - bytesread += sizeof(hostVolumeHeader); + /* Create a volume trailer appending it to this data block */ + makeVolumeHeader(&hostVolumeHeader, dparamsPtr, + fragmentNumber); + hostVolumeHeader.contd = (endofvolume ? 0 : TC_VOLCONTD); + hostVolumeHeader.magic = TC_VOLENDMAGIC; + hostVolumeHeader.endTime = (endofvolume ? time(0) : 0); + volumeHeader_hton(&hostVolumeHeader, &buffer[bytesread]); + bytesread += sizeof(hostVolumeHeader); } /* Write the datablock out */ /* full data buffer - write it to tape */ - rc = butm_WriteFileData(tapeInfoPtr, buffer, tapeblocks, bytesread); + rc = butm_WriteFileData(tapeInfoPtr, buffer, tapeblocks, + bytesread); if (rc) { - ErrorLog(1, taskId, rc, tapeInfoPtr->error, - "Can't write VolumeData on tape\n"); - ERROR_EXIT(rc); + ErrorLog(1, taskId, rc, tapeInfoPtr->error, + "Can't write VolumeData on tape\n"); + ERROR_EXIT(rc); } bytesWritten = tapeblocks * BUTM_BLOCKSIZE; tsize += bytesWritten; /* Display a status line every statusSize or at end of volume */ - if ( statusSize && - ((tsize >= statuscount) || endofvolume || fragmentvolume) ) { - time_t t = time(0); - struct tm tm; - localtime_r(&t, &tm); - printf("%02d:%02d:%02d: Task %u: %u KB: %s: %u B\n", - tm.tm_hour, tm.tm_min, tm.tm_sec, taskId, - tapeInfoPtr->kBytes, hostVolumeHeader.volumeName, tsize); - statuscount = tsize + statusSize; + if (statusSize + && ((tsize >= statuscount) || endofvolume + || fragmentvolume)) { + time_t t = time(0); + struct tm tm; + localtime_r(&t, &tm); + printf("%02d:%02d:%02d: Task %u: %u KB: %s: %u B\n", + tm.tm_hour, tm.tm_min, tm.tm_sec, taskId, + tapeInfoPtr->kBytes, hostVolumeHeader.volumeName, + tsize); + statuscount = tsize + statusSize; } - } /*w*/ + } /*w */ - /* End the dump before recording it in BUDB as successfully dumped */ - rc = butm_WriteFileEnd(tapeInfoPtr); + /* End the dump before recording it in BUDB as successfully dumped */ + rc = butm_WriteFileEnd(tapeInfoPtr); indump = 0; if (rc) { - ErrorLog(1, taskId, rc, tapeInfoPtr->error, "Can't write FileEnd on tape\n"); - ERROR_EXIT(rc); + ErrorLog(1, taskId, rc, tapeInfoPtr->error, + "Can't write FileEnd on tape\n"); + ERROR_EXIT(rc); } /* Record in BUDB the volume fragment as succcessfully dumped */ - volumeFlags = (( fragmentNumber == 1 ) ? BUDB_VOL_FIRSTFRAG : 0); - if (endofvolume) volumeFlags |= BUDB_VOL_LASTFRAG; + volumeFlags = ((fragmentNumber == 1) ? BUDB_VOL_FIRSTFRAG : 0); + if (endofvolume) + volumeFlags |= BUDB_VOL_LASTFRAG; rc = addVolume(0, dparamsPtr->databaseDumpId, dparamsPtr->tapeName, nodePtr->dumps[dparamsPtr->curVolume].name, nodePtr->dumps[dparamsPtr->curVolume].vid, nodePtr->dumps[dparamsPtr->curVolume].cloneDate, - dparamsPtr->curVolStartPos, - volBytesRead, (fragmentNumber-1), volumeFlags); - if (rc) ABORT_EXIT(rc); + dparamsPtr->curVolStartPos, volBytesRead, + (fragmentNumber - 1), volumeFlags); + if (rc) + ABORT_EXIT(rc); /* If haven't finished dumping the volume, end this * tape and get the next tape. */ if (!endofvolume) { - /* Write an EOT marker. - * Log the error but ignore it since the dump is effectively done. - * Scantape will detect continued volume and not read the EOT. - */ - rc = butm_WriteEOT(tapeInfoPtr); - if (rc) TapeLog(1, taskId, rc, tapeInfoPtr->error, - "Warning: Can't write End-Of-Dump on tape\n"); - - /* Unmount the tape */ - unmountTape(taskId, tapeInfoPtr); - - /* Tell the database the tape is complete (and ok) */ - rc = finishTape(&dparamsPtr->tape, dparamsPtr->tapeInfoPtr->kBytes + - (dparamsPtr->tapeInfoPtr->nBytes ? 1 : 0)); - if (rc) ABORT_EXIT(rc); - - /* get the next tape. Prompt, mount, and add it into the database */ - dparamsPtr->tapeSeq++; - rc = getDumpTape(dparamsPtr, 1, 0); /* interactive - no append */ - if (rc) ABORT_EXIT(rc); - - dparamsPtr->curVolStartPos = tapeInfoPtr->position; + /* Write an EOT marker. + * Log the error but ignore it since the dump is effectively done. + * Scantape will detect continued volume and not read the EOT. + */ + rc = butm_WriteEOT(tapeInfoPtr); + if (rc) + TapeLog(1, taskId, rc, tapeInfoPtr->error, + "Warning: Can't write End-Of-Dump on tape\n"); + + /* Unmount the tape */ + unmountTape(taskId, tapeInfoPtr); + + /* Tell the database the tape is complete (and ok) */ + rc = finishTape(&dparamsPtr->tape, + dparamsPtr->tapeInfoPtr->kBytes + + (dparamsPtr->tapeInfoPtr->nBytes ? 1 : 0)); + if (rc) + ABORT_EXIT(rc); + + /* get the next tape. Prompt, mount, and add it into the database */ + dparamsPtr->tapeSeq++; + rc = getDumpTape(dparamsPtr, 1, 0); /* interactive - no append */ + if (rc) + ABORT_EXIT(rc); + + dparamsPtr->curVolStartPos = tapeInfoPtr->position; } - } /*frag*/ + } /*frag */ dparamsPtr->curVolumeStatus = DUMP_SUCCESS; -error_exit: + error_exit: /* * If we hit the end, see if this is the first volume on the tape or not. * Also, mark the tape as finished if the tape contains other dumps. */ if (HITEOT(code)) { - ErrorLog(2, taskId, code, tapeInfoPtr->error, - "Warning: Dump (%s) hit end-of-tape inferred\n", + ErrorLog(2, taskId, code, tapeInfoPtr->error, + "Warning: Dump (%s) hit end-of-tape inferred\n", nodePtr->dumpSetName); - if (tapeInfoPtr->position == 2) { + if (tapeInfoPtr->position == 2) { dparamsPtr->curVolumeStatus = DUMP_NORETRYEOT; } else { dparamsPtr->curVolumeStatus = DUMP_RETRY; - rc = finishTape(&dparamsPtr->tape, dparamsPtr->tapeInfoPtr->kBytes + - (dparamsPtr->tapeInfoPtr->nBytes ? 1 : 0)); - if (rc) ABORT_EXIT(rc); + rc = finishTape(&dparamsPtr->tape, + dparamsPtr->tapeInfoPtr->kBytes + + (dparamsPtr->tapeInfoPtr->nBytes ? 1 : 0)); + if (rc) + ABORT_EXIT(rc); } } @@ -468,92 +496,98 @@ error_exit: * the end of tape. */ else if (indump) { - rc = butm_WriteFileEnd(tapeInfoPtr); - indump = 0; - if (rc) { - ErrorLog(1, taskId, rc, tapeInfoPtr->error, "Can't write FileEnd on tape\n"); - } + rc = butm_WriteFileEnd(tapeInfoPtr); + indump = 0; + if (rc) { + ErrorLog(1, taskId, rc, tapeInfoPtr->error, + "Can't write FileEnd on tape\n"); + } } if (fromcall) { - rc = rx_EndCall (fromcall, 0); - if (!code) code = rc; + rc = rx_EndCall(fromcall, 0); + if (!code) + code = rc; } if (fromtid) { - afs_int32 rcode; - rc = AFSVolEndTrans (fromconn, fromtid, &rcode); - if (!code) code = (rc ? rc : rcode); + afs_int32 rcode; + rc = AFSVolEndTrans(fromconn, fromtid, &rcode); + if (!code) + code = (rc ? rc : rcode); } - return(code); + return (code); -abort_exit: + abort_exit: dparamsPtr->curVolumeStatus = DUMP_FAILED; ERROR_EXIT(code); } afs_int32 -xbsaDumpVolume(struct tc_dumpDesc *curDump, struct dumpRock *dparamsPtr) +xbsaDumpVolume(struct tc_dumpDesc * curDump, struct dumpRock * dparamsPtr) { #ifdef xbsa struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr; - struct dumpNode *nodePtr = dparamsPtr->node; - char *buffer = bufferBlock; - afs_int32 taskId = nodePtr->taskID; - afs_int32 rc, code = 0; - afs_int32 toread; + struct dumpNode *nodePtr = dparamsPtr->node; + char *buffer = bufferBlock; + afs_int32 taskId = nodePtr->taskID; + afs_int32 rc, code = 0; + afs_int32 toread; afs_uint32 volBytesRead; afs_uint32 chunkSize; - afs_int32 bytesread; /* rx reads */ - int endofvolume=0; /* Have we read all volume data */ - int begindump=0, indump=0; /* if dump transaction started; if dumping data */ - struct volumeHeader hostVolumeHeader; + afs_int32 bytesread; /* rx reads */ + int endofvolume = 0; /* Have we read all volume data */ + int begindump = 0, indump = 0; /* if dump transaction started; if dumping data */ + struct volumeHeader hostVolumeHeader; - struct rx_call *fromcall = (struct rx_call *)0; + struct rx_call *fromcall = (struct rx_call *)0; struct rx_connection *fromconn; - afs_int32 updatedate, fromtid = 0; - volEntries volumeInfo; - afs_int32 bytesWritten; - afs_uint32 statuscount=statusSize, tsize=0, esize; - afs_hyper_t estSize; + afs_int32 updatedate, fromtid = 0; + volEntries volumeInfo; + afs_int32 bytesWritten; + afs_uint32 statuscount = statusSize, tsize = 0, esize; + afs_hyper_t estSize; char dumpIdStr[XBSA_MAX_OSNAME]; char volumeNameStr[XBSA_MAX_PATHNAME]; static char *dumpDescription = "AFS volume dump"; static char *objectDescription = "XBSA - butc"; - + dparamsPtr->curVolumeStatus = DUMP_NOTHING; - fromconn = Bind(htonl(curDump->hostAddr)); /* get connection to the server */ + fromconn = Bind(htonl(curDump->hostAddr)); /* get connection to the server */ /* Determine when the volume was last cloned and updated */ - volumeInfo.volEntries_val = (volintInfo *)0; + volumeInfo.volEntries_val = (volintInfo *) 0; volumeInfo.volEntries_len = 0; - rc = AFSVolListOneVolume(fromconn, curDump->partition, curDump->vid, &volumeInfo); - if (rc) ERROR_EXIT(rc); - updatedate = volumeInfo.volEntries_val[0].updateDate; - curDump->cloneDate = ((curDump->vtype == RWVOL) ? - time(0) : volumeInfo.volEntries_val[0].creationDate); + rc = AFSVolListOneVolume(fromconn, curDump->partition, curDump->vid, + &volumeInfo); + if (rc) + ERROR_EXIT(rc); + updatedate = volumeInfo.volEntries_val[0].updateDate; + curDump->cloneDate = + ((curDump->vtype == + RWVOL) ? time(0) : volumeInfo.volEntries_val[0].creationDate); /* Get the volume size (in KB) and increase by 25%. Then set as a hyper */ esize = volumeInfo.volEntries_val[0].size; - esize += (esize/4)+1; + esize += (esize / 4) + 1; if (curDump->date >= curDump->cloneDate) - ERROR_EXIT(0); /* not recloned since last dump */ - if (curDump->date > updatedate) { - dparamsPtr->curVolumeStatus = DUMP_NODUMP; /* not modified since last dump */ + ERROR_EXIT(0); /* not recloned since last dump */ + if (curDump->date > updatedate) { + dparamsPtr->curVolumeStatus = DUMP_NODUMP; /* not modified since last dump */ ERROR_EXIT(0); } /* Start a new XBSA Transaction */ rc = xbsa_BeginTrans(&butxInfo); if (rc != XBSA_SUCCESS) { - ErrorLog(1, taskId, rc, 0, "Unable to create a new transaction\n"); - ERROR_EXIT(rc); + ErrorLog(1, taskId, rc, 0, "Unable to create a new transaction\n"); + ERROR_EXIT(rc); } - begindump = 1; /* Will need to do an xbsa_EndTrans */ + begindump = 1; /* Will need to do an xbsa_EndTrans */ /* Start the volserver transaction and dump. Once started, the * volume status is "partial dump". Also, the transaction with @@ -561,160 +595,171 @@ xbsaDumpVolume(struct tc_dumpDesc *curDump, struct dumpRock *dparamsPtr) * will time out in 600 seconds. After the first rx_Read, * the transaction is not idle. See GCTrans(). */ - rc = AFSVolTransCreate (fromconn, curDump->vid, curDump->partition, ITBusy, &fromtid); - if (rc) ERROR_EXIT(rc); + rc = AFSVolTransCreate(fromconn, curDump->vid, curDump->partition, ITBusy, + &fromtid); + if (rc) + ERROR_EXIT(rc); fromcall = rx_NewCall(fromconn); - - rc = StartAFSVolDump (fromcall, fromtid, curDump->date); - if (rc) ERROR_EXIT(rc); + + rc = StartAFSVolDump(fromcall, fromtid, curDump->date); + if (rc) + ERROR_EXIT(rc); dparamsPtr->curVolumeStatus = DUMP_PARTIAL; - dparamsPtr->curVolStartPos = tapeInfoPtr->position; + dparamsPtr->curVolStartPos = tapeInfoPtr->position; /* Tell XBSA what the name and size of volume to write */ - strcpy(dumpIdStr, butcdumpIdStr); /* "backup_afs_volume_dumps" */ + strcpy(dumpIdStr, butcdumpIdStr); /* "backup_afs_volume_dumps" */ sprintf(volumeNameStr, "/%d", dparamsPtr->databaseDumpId); strcat(volumeNameStr, "/"); - strcat(volumeNameStr, curDump->name); /* / */ + strcat(volumeNameStr, curDump->name); /* / */ hset32(estSize, esize); - hshlft(estSize, 10); /* Multiply by 1024 so its in KB */ + hshlft(estSize, 10); /* Multiply by 1024 so its in KB */ rc = xbsa_WriteObjectBegin(&butxInfo, dumpIdStr, volumeNameStr, xbsalGName, estSize, dumpDescription, objectDescription); if (rc != XBSA_SUCCESS) { - ErrorLog(1, taskId, rc, 0, - "Unable to begin writing of the fileset data to the server\n"); - ERROR_EXIT(rc); + ErrorLog(1, taskId, rc, 0, + "Unable to begin writing of the fileset data to the server\n"); + ERROR_EXIT(rc); } - indump = 1; /* Will need to do an xbsa_WriteObjectEnd */ + indump = 1; /* Will need to do an xbsa_WriteObjectEnd */ /* Create and Write the volume header */ makeVolumeHeader(&hostVolumeHeader, dparamsPtr, 1); hostVolumeHeader.contd = 0; volumeHeader_hton(&hostVolumeHeader, buffer); - rc = xbsa_WriteObjectData(&butxInfo, buffer, sizeof(struct volumeHeader), &bytesWritten); + rc = xbsa_WriteObjectData(&butxInfo, buffer, sizeof(struct volumeHeader), + &bytesWritten); if (rc != XBSA_SUCCESS) { - ErrorLog(1, taskId, rc, 0, "Unable to write VolumeHeader data to the server\n"); - ERROR_EXIT(rc); + ErrorLog(1, taskId, rc, 0, + "Unable to write VolumeHeader data to the server\n"); + ERROR_EXIT(rc); } /* There is a bug in the ADSM library where the bytesWritten is * not filled in, so we set it as correct anyway. */ bytesWritten = sizeof(struct volumeHeader); if (bytesWritten != sizeof(struct volumeHeader)) { - ErrorLog(1, taskId, rc, 0, - "The size of VolumeHeader written (%d) does not equal its actual size (%d)\n", - bytesWritten, sizeof(struct volumeHeader)); - ERROR_EXIT(TC_INTERNALERROR); + ErrorLog(1, taskId, rc, 0, + "The size of VolumeHeader written (%d) does not equal its actual size (%d)\n", + bytesWritten, sizeof(struct volumeHeader)); + ERROR_EXIT(TC_INTERNALERROR); } - incSize(tapeInfoPtr, sizeof(struct volumeHeader)); /* Increment amount we've written */ + incSize(tapeInfoPtr, sizeof(struct volumeHeader)); /* Increment amount we've written */ tsize += bytesWritten; /* Start reading volume data, rx_Read(), and dumping to the tape * until we've dumped the entire volume (endofvolume == 1). */ volBytesRead = 0; - chunkSize = 0; - while (!endofvolume) { /*w*/ - bytesread = 0; - - /* Check for abort in the middle of writing data */ - if (volBytesRead >= chunkSize) { - chunkSize += BIGCHUNK; - if ( checkAbortByTaskId(taskId) ) - ABORT_EXIT(TC_ABORTEDBYREQUEST); - - /* set bytes dumped for backup */ - lock_Status(); - nodePtr->statusNodePtr->nKBytes = tapeInfoPtr->kBytes; - unlock_Status(); - } - - /* Determine how much data to read in upcoming RX_Read() call */ - toread = dataSize; - - /* Read some volume data. */ - bytesread = rx_Read(fromcall, buffer, toread); - volBytesRead += bytesread; - if (bytesread != toread) { - afs_int32 rcode; - - /* Make sure were at end of volume and not a communication error */ - rc = rx_Error(fromcall); - if (rc) ERROR_EXIT(rc); - - endofvolume = 1; - - /* Create a volume trailer appending it to this data block (if not XBSA) */ - makeVolumeHeader(&hostVolumeHeader, dparamsPtr, 1); - hostVolumeHeader.contd = 0; - hostVolumeHeader.magic = TC_VOLENDMAGIC; - hostVolumeHeader.endTime = time(0); - volumeHeader_hton(&hostVolumeHeader, &buffer[bytesread]); - bytesread += sizeof(hostVolumeHeader); - - /* End the dump and transaction with the volserver. We end it now, before - * we make the XBSA call because if XBSA blocks, we could time out on the - * volserver (After last read, the transaction with the volserver is idle). - */ - rc = rx_EndCall (fromcall, 0); - fromcall = 0; - if (rc) ERROR_EXIT(rc); - - rc = AFSVolEndTrans (fromconn, fromtid, &rcode); - fromtid = 0; - if (rc) ERROR_EXIT(rc); - } - - /* Write the datablock out */ - rc = xbsa_WriteObjectData(&butxInfo, buffer, bytesread, &bytesWritten); - if (rc != XBSA_SUCCESS) { - ErrorLog(1, taskId, rc, 0, "Unable to write data to the server\n"); - ERROR_EXIT(rc); - } - /* There is a bug in the ADSM library where the bytesWritten is - * not filled in, so we set it as correct anyway. - */ - bytesWritten = bytesread; - if (bytesWritten != bytesread) { - ErrorLog(1, taskId, rc, 0, - "The size of data written (%d) does not equal size read (%d)\n", - bytesWritten, bytesread); - ERROR_EXIT(TC_INTERNALERROR); - } - - incSize(tapeInfoPtr, bytesread); /* Increment amount we've written */ - tsize += bytesWritten; - - /* Display a status line every statusSize or at end of volume */ - if ( statusSize && ((tsize >= statuscount) || endofvolume) ) { - time_t t = time(0); - struct tm tm; - localtime_r(&t, &tm); - printf("%02d:%02d:%02d: Task %u: %u KB: %s: %u B\n", - tm.tm_hour, tm.tm_min, tm.tm_sec, taskId, - tapeInfoPtr->kBytes, hostVolumeHeader.volumeName, tsize); - statuscount = tsize + statusSize; - } - } /*w*/ + chunkSize = 0; + while (!endofvolume) { /*w */ + bytesread = 0; + + /* Check for abort in the middle of writing data */ + if (volBytesRead >= chunkSize) { + chunkSize += BIGCHUNK; + if (checkAbortByTaskId(taskId)) + ABORT_EXIT(TC_ABORTEDBYREQUEST); + + /* set bytes dumped for backup */ + lock_Status(); + nodePtr->statusNodePtr->nKBytes = tapeInfoPtr->kBytes; + unlock_Status(); + } + + /* Determine how much data to read in upcoming RX_Read() call */ + toread = dataSize; + + /* Read some volume data. */ + bytesread = rx_Read(fromcall, buffer, toread); + volBytesRead += bytesread; + if (bytesread != toread) { + afs_int32 rcode; + + /* Make sure were at end of volume and not a communication error */ + rc = rx_Error(fromcall); + if (rc) + ERROR_EXIT(rc); + + endofvolume = 1; + + /* Create a volume trailer appending it to this data block (if not XBSA) */ + makeVolumeHeader(&hostVolumeHeader, dparamsPtr, 1); + hostVolumeHeader.contd = 0; + hostVolumeHeader.magic = TC_VOLENDMAGIC; + hostVolumeHeader.endTime = time(0); + volumeHeader_hton(&hostVolumeHeader, &buffer[bytesread]); + bytesread += sizeof(hostVolumeHeader); + + /* End the dump and transaction with the volserver. We end it now, before + * we make the XBSA call because if XBSA blocks, we could time out on the + * volserver (After last read, the transaction with the volserver is idle). + */ + rc = rx_EndCall(fromcall, 0); + fromcall = 0; + if (rc) + ERROR_EXIT(rc); + + rc = AFSVolEndTrans(fromconn, fromtid, &rcode); + fromtid = 0; + if (rc) + ERROR_EXIT(rc); + } + + /* Write the datablock out */ + rc = xbsa_WriteObjectData(&butxInfo, buffer, bytesread, + &bytesWritten); + if (rc != XBSA_SUCCESS) { + ErrorLog(1, taskId, rc, 0, + "Unable to write data to the server\n"); + ERROR_EXIT(rc); + } + /* There is a bug in the ADSM library where the bytesWritten is + * not filled in, so we set it as correct anyway. + */ + bytesWritten = bytesread; + if (bytesWritten != bytesread) { + ErrorLog(1, taskId, rc, 0, + "The size of data written (%d) does not equal size read (%d)\n", + bytesWritten, bytesread); + ERROR_EXIT(TC_INTERNALERROR); + } + + incSize(tapeInfoPtr, bytesread); /* Increment amount we've written */ + tsize += bytesWritten; + + /* Display a status line every statusSize or at end of volume */ + if (statusSize && ((tsize >= statuscount) || endofvolume)) { + time_t t = time(0); + struct tm tm; + localtime_r(&t, &tm); + printf("%02d:%02d:%02d: Task %u: %u KB: %s: %u B\n", tm.tm_hour, + tm.tm_min, tm.tm_sec, taskId, tapeInfoPtr->kBytes, + hostVolumeHeader.volumeName, tsize); + statuscount = tsize + statusSize; + } + } /*w */ /* End the XBSA transaction before recording it in BUDB as successfully dumped */ rc = xbsa_WriteObjectEnd(&butxInfo); indump = 0; if (rc != XBSA_SUCCESS) { - ErrorLog(1, taskId, rc, 0, - "Unable to terminate writing of the volume data to the server"); - ERROR_EXIT(rc); + ErrorLog(1, taskId, rc, 0, + "Unable to terminate writing of the volume data to the server"); + ERROR_EXIT(rc); } rc = xbsa_EndTrans(&butxInfo); begindump = 0; tapeInfoPtr->position++; if (rc != XBSA_SUCCESS) { - ErrorLog(1, taskId, rc, 0, "Unable to terminate the current transaction"); - ERROR_EXIT(rc); + ErrorLog(1, taskId, rc, 0, + "Unable to terminate the current transaction"); + ERROR_EXIT(rc); } /* Record in BUDB the volume fragment as succcessfully dumped */ @@ -722,26 +767,28 @@ xbsaDumpVolume(struct tc_dumpDesc *curDump, struct dumpRock *dparamsPtr) nodePtr->dumps[dparamsPtr->curVolume].name, nodePtr->dumps[dparamsPtr->curVolume].vid, nodePtr->dumps[dparamsPtr->curVolume].cloneDate, - dparamsPtr->curVolStartPos, - volBytesRead, 0/*frag0*/, + dparamsPtr->curVolStartPos, volBytesRead, 0 /*frag0 */ , (BUDB_VOL_FIRSTFRAG | BUDB_VOL_LASTFRAG)); - if (rc) ABORT_EXIT(rc); + if (rc) + ABORT_EXIT(rc); dparamsPtr->curVolumeStatus = DUMP_SUCCESS; -error_exit: + error_exit: /* Cleanup after an error occurs part way into a volume dump */ if (fromcall) { - rc = rx_EndCall (fromcall, 0); - if (!code) code = rc; + rc = rx_EndCall(fromcall, 0); + if (!code) + code = rc; } if (fromtid) { - afs_int32 rcode; - rc = AFSVolEndTrans (fromconn, fromtid, &rcode); - if (!code) code = (rc ? rc : rcode); + afs_int32 rcode; + rc = AFSVolEndTrans(fromconn, fromtid, &rcode); + if (!code) + code = (rc ? rc : rcode); } - + /* If this dump failed, what happens to successive retries * of the volume? How do they get recorded in the XBSA database * (overwritten)? If not, we don't record this in the BUDB database @@ -749,28 +796,29 @@ error_exit: * Also if the volume was never recorded in the DB (partial dump). */ if (indump) { - /* End the Write */ - rc = xbsa_WriteObjectEnd(&butxInfo); - indump = 0; - if (rc != XBSA_SUCCESS) { - ErrorLog(1, taskId, rc, 0, - "Unable to terminate writing of the volume data to the server"); - } - tapeInfoPtr->position++; + /* End the Write */ + rc = xbsa_WriteObjectEnd(&butxInfo); + indump = 0; + if (rc != XBSA_SUCCESS) { + ErrorLog(1, taskId, rc, 0, + "Unable to terminate writing of the volume data to the server"); + } + tapeInfoPtr->position++; } if (begindump) { - /* End the XBSA Transaction */ - rc = xbsa_EndTrans(&butxInfo); - begindump = 0; - if (rc != XBSA_SUCCESS) { - ErrorLog(1, taskId, rc, 0, "Unable to terminate the current transaction"); - } + /* End the XBSA Transaction */ + rc = xbsa_EndTrans(&butxInfo); + begindump = 0; + if (rc != XBSA_SUCCESS) { + ErrorLog(1, taskId, rc, 0, + "Unable to terminate the current transaction"); + } } - return(code); + return (code); -abort_exit: + abort_exit: dparamsPtr->curVolumeStatus = DUMP_FAILED; ERROR_EXIT(code); #endif @@ -791,44 +839,43 @@ abort_exit: * be done for user aborts? */ -afs_int32 dumpPass(struct dumpRock *dparamsPtr, int passNumber) +afs_int32 +dumpPass(struct dumpRock * dparamsPtr, int passNumber) { - struct dumpNode *nodePtr = dparamsPtr->node; + struct dumpNode *nodePtr = dparamsPtr->node; struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr; - afs_int32 taskId = nodePtr->taskID; + afs_int32 taskId = nodePtr->taskID; struct tc_dumpDesc *curDump; - int action, e; + int action, e; afs_int32 code = 0, tcode, dvcode; char ch; char retryPrompt(); struct vldbentry vldbEntry; struct sockaddr_in server; - afs_int32 tapepos; + afs_int32 tapepos; TapeLog(2, taskId, 0, 0, "Starting pass %d\n", passNumber); /* while there are more volumes to dump */ - for (dparamsPtr->curVolume = 0; - dparamsPtr->curVolume < nodePtr->arraySize; - dparamsPtr->curVolume++) - { /*w*/ + for (dparamsPtr->curVolume = 0; dparamsPtr->curVolume < nodePtr->arraySize; dparamsPtr->curVolume++) { /*w */ curDump = &nodePtr->dumps[dparamsPtr->curVolume]; - if (curDump->hostAddr == 0) continue; + if (curDump->hostAddr == 0) + continue; /* set name of current volume being dumped */ lock_Status(); - strcpy(nodePtr->statusNodePtr->volumeName, curDump->name); + strcpy(nodePtr->statusNodePtr->volumeName, curDump->name); unlock_Status(); /* Determine location of the volume. * In case the volume moved has moved. */ - if (passNumber > 1) - { /*pass*/ - tcode = bc_GetEntryByID(cstruct, curDump->vid, curDump->vtype, &vldbEntry); - if (tcode) - { - ErrorLog(0, taskId, tcode, 0, + if (passNumber > 1) { /*pass */ + tcode = + bc_GetEntryByID(cstruct, curDump->vid, curDump->vtype, + &vldbEntry); + if (tcode) { + ErrorLog(0, taskId, tcode, 0, "Volume %s (%u) failed - Can't find volume in VLDB\n", curDump->name, curDump->vid); curDump->hostAddr = 0; @@ -836,59 +883,55 @@ afs_int32 dumpPass(struct dumpRock *dparamsPtr, int passNumber) continue; } - switch (curDump->vtype) - { - case BACKVOL: - if ( !(vldbEntry.flags & BACK_EXISTS) ) - { - ErrorLog(0, taskId, 0, 0, - "Volume %s (%u) failed - Backup volume no longer exists\n", - curDump->name, curDump->vid); - curDump->hostAddr = 0; - dparamsPtr->volumesFailed++; - continue; + switch (curDump->vtype) { + case BACKVOL: + if (!(vldbEntry.flags & BACK_EXISTS)) { + ErrorLog(0, taskId, 0, 0, + "Volume %s (%u) failed - Backup volume no longer exists\n", + curDump->name, curDump->vid); + curDump->hostAddr = 0; + dparamsPtr->volumesFailed++; + continue; + } + /* Fall into RWVOL case */ + + case RWVOL: + for (e = 0; e < vldbEntry.nServers; e++) { /* Find the RW volume */ + if (vldbEntry.serverFlags[e] & ITSRWVOL) + break; + } + break; + + case ROVOL: + /* Try to use the server and partition we found the volume on + * Otherwise, use the first RO volume. + */ + for (e = 0; e < vldbEntry.nServers; e++) { /* Find the RO volume */ + if ((curDump->hostAddr == vldbEntry.serverNumber[e]) + && (curDump->partition == + vldbEntry.serverPartition[e])) + break; + } + + if (e >= vldbEntry.nServers) { /* Didn't find RO volume */ + for (e = 0; e < vldbEntry.nServers; e++) { /* Find the first RO volume */ + if (vldbEntry.serverFlags[e] & ITSROVOL) + break; } - /* Fall into RWVOL case */ - - case RWVOL: - for (e=0; ehostAddr == vldbEntry.serverNumber[e] ) && - (curDump->partition == vldbEntry.serverPartition[e]) ) - break; - } - - if (e >= vldbEntry.nServers) - { /* Didn't find RO volume */ - for (e=0; ename, curDump->vid); - curDump->hostAddr = 0; - continue; - break; } + break; + + default: + ErrorLog(0, taskId, 0, 0, + "Volume %s (%u) failed - Unknown volume type\n", + curDump->name, curDump->vid); + curDump->hostAddr = 0; + continue; + break; + } - if (e >=vldbEntry.nServers) - { - ErrorLog(0, taskId, 0, 0, + if (e >= vldbEntry.nServers) { + ErrorLog(0, taskId, 0, 0, "Volume %s (%u) failed - Can't find volume entry in VLDB\n", curDump->name, curDump->vid); curDump->hostAddr = 0; @@ -899,187 +942,185 @@ afs_int32 dumpPass(struct dumpRock *dparamsPtr, int passNumber) /* Remember the server and partition the volume exists on */ memset(&server, 0, sizeof(server)); server.sin_addr.s_addr = vldbEntry.serverNumber[e]; - server.sin_port = 0; - server.sin_family = AF_INET; + server.sin_port = 0; + server.sin_family = AF_INET; #ifdef STRUCT_SOCKADDR_HAS_SA_LEN - server.sin_len = sizeof(struct sockaddr_in); + server.sin_len = sizeof(struct sockaddr_in); #endif - curDump->hostAddr = HOSTADDR(&server); - curDump->partition = vldbEntry.serverPartition[e]; + curDump->hostAddr = HOSTADDR(&server); + curDump->partition = vldbEntry.serverPartition[e]; /* Determine date from which to do an incremental dump */ - if (nodePtr->parent) - { - tcode = bcdb_FindClone(nodePtr->parent, curDump->name, &curDump->date); - if (tcode) curDump->date = 0; - } - else - { - curDump->date = 0; /* do a full dump */ + if (nodePtr->parent) { + tcode = + bcdb_FindClone(nodePtr->parent, curDump->name, + &curDump->date); + if (tcode) + curDump->date = 0; + } else { + curDump->date = 0; /* do a full dump */ } - } /*pass*/ - - if ( checkAbortByTaskId(taskId) ) + } + /*pass */ + if (checkAbortByTaskId(taskId)) ERROR_EXIT(TC_ABORTEDBYREQUEST); - + /* Establish connection to volume - UV_ routine expects * host address in network order */ if (CONF_XBSA) { - dvcode = xbsaDumpVolume(curDump, dparamsPtr); + dvcode = xbsaDumpVolume(curDump, dparamsPtr); } else { - dvcode = dumpVolume(curDump, dparamsPtr); + dvcode = dumpVolume(curDump, dparamsPtr); } action = dparamsPtr->curVolumeStatus; /* Flush volume and tape entries to the database */ tcode = flushSavedEntries(action); - if (tcode) ERROR_EXIT(tcode); - - switch (action) - { - case DUMP_SUCCESS: - TapeLog(1, taskId, 0, 0, "Volume %s (%u) successfully dumped\n", - curDump->name, curDump->vid); - if (dvcode) - ErrorLog(1, taskId, dvcode, 0, - "Warning: Termination processing error on volume %s (%u)\n", - curDump->name, curDump->vid); + if (tcode) + ERROR_EXIT(tcode); + + switch (action) { + case DUMP_SUCCESS: + TapeLog(1, taskId, 0, 0, "Volume %s (%u) successfully dumped\n", + curDump->name, curDump->vid); + if (dvcode) + ErrorLog(1, taskId, dvcode, 0, + "Warning: Termination processing error on volume %s (%u)\n", + curDump->name, curDump->vid); - curDump->hostAddr = 0; - dparamsPtr->volumesDumped++; - break; - - case DUMP_PARTIAL: - case DUMP_NOTHING: - if (action == DUMP_PARTIAL) - { - ErrorLog(1, taskId, dvcode, 0, - "Volume %s (%u) failed - partially dumped\n", - curDump->name, curDump->vid); - } - else if (dvcode) - { - ErrorLog(0, taskId, dvcode, 0, - "Volume %s (%u) failed\n", curDump->name, curDump->vid); - } + curDump->hostAddr = 0; + dparamsPtr->volumesDumped++; + break; + + case DUMP_PARTIAL: + case DUMP_NOTHING: + if (action == DUMP_PARTIAL) { + ErrorLog(1, taskId, dvcode, 0, + "Volume %s (%u) failed - partially dumped\n", + curDump->name, curDump->vid); + } else if (dvcode) { + ErrorLog(0, taskId, dvcode, 0, "Volume %s (%u) failed\n", + curDump->name, curDump->vid); + } else { + ErrorLog(0, taskId, dvcode, 0, + "Volume %s (%u) not dumped - has not been re-cloned since last dump\n", + curDump->name, curDump->vid); + } + + if (passNumber == maxpass) { + if (!queryoperator) + ch = 'o'; else - { - ErrorLog(0, taskId, dvcode, 0, - "Volume %s (%u) not dumped - has not been re-cloned since last dump\n", - curDump->name, curDump->vid); + ch = retryPrompt(curDump->name, curDump->vid, taskId); + + switch (ch) { + case 'r': /* retry */ + dparamsPtr->curVolume--; /* redump this volume */ + continue; + break; + case 'o': /* omit */ + ErrorLog(1, taskId, 0, 0, "Volume %s (%u) omitted\n", + curDump->name, curDump->vid); + dparamsPtr->volumesFailed++; + break; + case 'a': /* abort */ + TapeLog(1, taskId, 0, 0, "Dump aborted\n"); + ERROR_EXIT(TC_ABORTEDBYREQUEST); + break; + default: + ERROR_EXIT(TC_INTERNALERROR); + break; } + } + break; - if (passNumber == maxpass) - { - if (!queryoperator) - ch = 'o'; - else - ch = retryPrompt(curDump->name, curDump->vid, taskId); - - switch ( ch ) - { - case 'r': /* retry */ - dparamsPtr->curVolume--; /* redump this volume */ - continue; - break; - case 'o': /* omit */ - ErrorLog(1, taskId, 0, 0, "Volume %s (%u) omitted\n", - curDump->name, curDump->vid); - dparamsPtr->volumesFailed++; - break; - case 'a': /* abort */ - TapeLog(1, taskId, 0, 0, "Dump aborted\n"); - ERROR_EXIT(TC_ABORTEDBYREQUEST); - break; - default: - ERROR_EXIT(TC_INTERNALERROR); - break; - } - } - break; - - case DUMP_RETRY: - TapeLog(1, taskId, dvcode, 0, - "Volume %s (%u) hit end-of-tape inferred - will retry on next tape\n", - curDump->name, curDump->vid); + case DUMP_RETRY: + TapeLog(1, taskId, dvcode, 0, + "Volume %s (%u) hit end-of-tape inferred - will retry on next tape\n", + curDump->name, curDump->vid); - /* Get the next tape */ - unmountTape(taskId, tapeInfoPtr); + /* Get the next tape */ + unmountTape(taskId, tapeInfoPtr); - dparamsPtr->tapeSeq++; - tcode = getDumpTape(dparamsPtr, 1, 0); /* interactive - no appends */ - if (tcode) ERROR_EXIT(tcode); + dparamsPtr->tapeSeq++; + tcode = getDumpTape(dparamsPtr, 1, 0); /* interactive - no appends */ + if (tcode) + ERROR_EXIT(tcode); - dparamsPtr->curVolume--; /* redump this volume */ - continue; - break; + dparamsPtr->curVolume--; /* redump this volume */ + continue; + break; - case DUMP_NORETRYEOT: - ErrorLog(1, taskId, 0, 0, "Volume %s (%u) failed - volume larger than tape\n", - curDump->name, curDump->vid); + case DUMP_NORETRYEOT: + ErrorLog(1, taskId, 0, 0, + "Volume %s (%u) failed - volume larger than tape\n", + curDump->name, curDump->vid); - /* rewrite the label on the tape - rewind - no need to switch tapes */ - tcode = butm_Create(tapeInfoPtr, &dparamsPtr->tapeLabel, 1); - if (tcode) { - ErrorLog(0, taskId, tcode, tapeInfoPtr->error, "Can't relabel tape\n"); - - unmountTape(taskId, tapeInfoPtr); - tcode = getDumpTape(dparamsPtr, 1, 0); /* interactive - no appends */ - if (tcode) ERROR_EXIT(tcode); - } - else { /* Record the tape in database */ - tapepos = tapeInfoPtr->position; - tcode = useTape(&dparamsPtr->tape, - dparamsPtr->databaseDumpId, - dparamsPtr->tapeName, - (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b), - dparamsPtr->tapeLabel.useCount, - dparamsPtr->tapeLabel.creationTime, - dparamsPtr->tapeLabel.expirationDate, - tapepos); - } + /* rewrite the label on the tape - rewind - no need to switch tapes */ + tcode = butm_Create(tapeInfoPtr, &dparamsPtr->tapeLabel, 1); + if (tcode) { + ErrorLog(0, taskId, tcode, tapeInfoPtr->error, + "Can't relabel tape\n"); - curDump->hostAddr = 0; - dparamsPtr->volumesFailed++; - break; + unmountTape(taskId, tapeInfoPtr); + tcode = getDumpTape(dparamsPtr, 1, 0); /* interactive - no appends */ + if (tcode) + ERROR_EXIT(tcode); + } else { /* Record the tape in database */ + tapepos = tapeInfoPtr->position; + tcode = + useTape(&dparamsPtr->tape, dparamsPtr->databaseDumpId, + dparamsPtr->tapeName, + (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b), + dparamsPtr->tapeLabel.useCount, + dparamsPtr->tapeLabel.creationTime, + dparamsPtr->tapeLabel.expirationDate, tapepos); + } - case DUMP_NODUMP: - TapeLog(1, taskId, dvcode, 0, - "Volume %s (%u) not dumped - has not been modified since last dump\n", - curDump->name, curDump->vid); + curDump->hostAddr = 0; + dparamsPtr->volumesFailed++; + break; - curDump->hostAddr = 0; - dparamsPtr->volumesNotDumped++; - break; + case DUMP_NODUMP: + TapeLog(1, taskId, dvcode, 0, + "Volume %s (%u) not dumped - has not been modified since last dump\n", + curDump->name, curDump->vid); - default: - ErrorLog(1, taskId, dvcode, 0, "Volume %s (%u) failed\n", - curDump->name, curDump->vid); - ERROR_EXIT(dvcode); - break; + curDump->hostAddr = 0; + dparamsPtr->volumesNotDumped++; + break; + + default: + ErrorLog(1, taskId, dvcode, 0, "Volume %s (%u) failed\n", + curDump->name, curDump->vid); + ERROR_EXIT(dvcode); + break; } - } /*w*/ + } /*w */ -error_exit: + error_exit: /* check if we terminated while processing a volume */ - if (dparamsPtr->curVolume < nodePtr->arraySize) - { - TapeLog(2, taskId, 0, 0, "Terminated while processing Volume %s (%u)\n", - curDump->name, curDump->vid); + if (dparamsPtr->curVolume < nodePtr->arraySize) { + TapeLog(2, taskId, 0, 0, + "Terminated while processing Volume %s (%u)\n", curDump->name, + curDump->vid); } /* print a summary of this pass */ - TapeLog(2, taskId, 0, 0, "End of pass %d: Volumes remaining = %d\n", passNumber, - nodePtr->arraySize - (dparamsPtr->volumesDumped + dparamsPtr->volumesFailed + + TapeLog(2, taskId, 0, 0, "End of pass %d: Volumes remaining = %d\n", + passNumber, + nodePtr->arraySize - (dparamsPtr->volumesDumped + + dparamsPtr->volumesFailed + dparamsPtr->volumesNotDumped)); - return(code); + return (code); } -int Dumper(struct dumpNode *nodePtr) +int +Dumper(struct dumpNode *nodePtr) { - struct dumpRock dparams; + struct dumpRock dparams; struct butm_tapeInfo tapeInfo; int pass; int action; @@ -1087,24 +1128,24 @@ int Dumper(struct dumpNode *nodePtr) afs_int32 code = 0; /* for volume setup */ - struct tc_dumpDesc *dumpDescPtr; - int i; - int failedvolumes = 0; - int dumpedvolumes = 0; - int nodumpvolumes = 0; - char strlevel[5]; - char msg[20]; - char finishedMsg1[50]; - char finishedMsg2[50]; - time_t startTime=0; - time_t endTime=0; - afs_int32 allocbufferSize; + struct tc_dumpDesc *dumpDescPtr; + int i; + int failedvolumes = 0; + int dumpedvolumes = 0; + int nodumpvolumes = 0; + char strlevel[5]; + char msg[20]; + char finishedMsg1[50]; + char finishedMsg2[50]; + time_t startTime = 0; + time_t endTime = 0; + afs_int32 allocbufferSize; extern struct deviceSyncNode *deviceLatch; - extern struct tapeConfig globalTapeConfig; + extern struct tapeConfig globalTapeConfig; extern afs_int32 createDump(); - taskId = nodePtr->taskID; /* Get task Id */ + taskId = nodePtr->taskID; /* Get task Id */ setStatus(taskId, DRIVE_WAIT); EnterDeviceQueue(deviceLatch); clearStatus(taskId, DRIVE_WAIT); @@ -1119,23 +1160,23 @@ int Dumper(struct dumpNode *nodePtr) dlqInit(&savedEntries); if (!CONF_XBSA) { - /* Instantiate the tape module */ - tapeInfo.structVersion = BUTM_MAJORVERSION; - code = butm_file_Instantiate(&tapeInfo, &globalTapeConfig); - if (code) { - ErrorLog(0, taskId, code, tapeInfo.error, "Can't initialize the tape module\n"); - ERROR_EXIT(code); - } + /* Instantiate the tape module */ + tapeInfo.structVersion = BUTM_MAJORVERSION; + code = butm_file_Instantiate(&tapeInfo, &globalTapeConfig); + if (code) { + ErrorLog(0, taskId, code, tapeInfo.error, + "Can't initialize the tape module\n"); + ERROR_EXIT(code); + } } /* check if abort requested while waiting on device latch */ - if ( checkAbortByTaskId(taskId) ) - ERROR_EXIT(TC_ABORTEDBYREQUEST); + if (checkAbortByTaskId(taskId)) + ERROR_EXIT(TC_ABORTEDBYREQUEST); /* Are there volumes to dump */ - if (nodePtr->arraySize == 0) - { - TLog(taskId, "Dump (%s), no volumes to dump\n", nodePtr->dumpSetName); + if (nodePtr->arraySize == 0) { + TLog(taskId, "Dump (%s), no volumes to dump\n", nodePtr->dumpSetName); ERROR_EXIT(0); } @@ -1143,19 +1184,21 @@ int Dumper(struct dumpNode *nodePtr) * dataSize is amount of data to read in each rx_Read() call. */ if (CONF_XBSA) { - /* XBSA dumps have not header */ - dataSize = BufferSize; - allocbufferSize = dataSize + sizeof(struct volumeHeader); + /* XBSA dumps have not header */ + dataSize = BufferSize; + allocbufferSize = dataSize + sizeof(struct volumeHeader); } else { - tapeblocks = BufferSize / BUTM_BLOCKSIZE; /* # of 16K tapeblocks */ - dataSize = (tapeblocks * BUTM_BLKSIZE); - allocbufferSize = BUTM_HDRSIZE + dataSize + sizeof(struct volumeHeader); + tapeblocks = BufferSize / BUTM_BLOCKSIZE; /* # of 16K tapeblocks */ + dataSize = (tapeblocks * BUTM_BLKSIZE); + allocbufferSize = + BUTM_HDRSIZE + dataSize + sizeof(struct volumeHeader); } bufferBlock = NULL; bufferBlock = malloc(allocbufferSize); if (!bufferBlock) { - ErrorLog(0, taskId, TC_NOMEMORY, 0, "Can't allocate BUFFERSIZE for dumps\n"); - ERROR_EXIT(TC_NOMEMORY); + ErrorLog(0, taskId, TC_NOMEMORY, 0, + "Can't allocate BUFFERSIZE for dumps\n"); + ERROR_EXIT(TC_NOMEMORY); } /* Determine the dumpid of the most recent dump of this volumeset and dumplevel @@ -1163,55 +1206,59 @@ int Dumper(struct dumpNode *nodePtr) * routine will then find the newly created dump. */ sprintf(strlevel, "%d", nodePtr->level); - code = bcdb_FindLatestDump(nodePtr->volumeSetName, strlevel, &dparams.lastDump); + code = + bcdb_FindLatestDump(nodePtr->volumeSetName, strlevel, + &dparams.lastDump); if (code) { - if (code != BUDB_NODUMPNAME) { - ErrorLog(0, taskId, code, 0, "Can't read backup database\n"); - ERROR_EXIT(code); - } - memset(&dparams.lastDump, 0, sizeof(dparams.lastDump)); + if (code != BUDB_NODUMPNAME) { + ErrorLog(0, taskId, code, 0, "Can't read backup database\n"); + ERROR_EXIT(code); + } + memset(&dparams.lastDump, 0, sizeof(dparams.lastDump)); } - code = createDump(&dparams); /* enter dump into database */ - if (code) - { + code = createDump(&dparams); /* enter dump into database */ + if (code) { ErrorLog(0, taskId, code, 0, "Can't create dump in database\n"); ERROR_EXIT(code); } - TLog(taskId, "Dump %s (DumpID %u)\n", nodePtr->dumpSetName, dparams.databaseDumpId); + TLog(taskId, "Dump %s (DumpID %u)\n", nodePtr->dumpSetName, + dparams.databaseDumpId); if (!CONF_XBSA) { - /* mount the tape and write its label */ - code = getDumpTape(&dparams, autoQuery, nodePtr->doAppend); + /* mount the tape and write its label */ + code = getDumpTape(&dparams, autoQuery, nodePtr->doAppend); } else { - /* Create a dummy tape to satisfy backup databae */ - code = getXBSATape(&dparams); - tapeInfo.position = 1; + /* Create a dummy tape to satisfy backup databae */ + code = getXBSATape(&dparams); + tapeInfo.position = 1; } if (code) { - /* If didn't write the label, remove dump from the database */ - if ( !dparams.wroteLabel ) { - i = bcdb_deleteDump(dparams.databaseDumpId, 0, 0, 0); - if ( i && (i != BUDB_NOENT) ) - ErrorLog(1, taskId, i, 0, "Warning: Can't delete dump %u from database\n", - dparams.databaseDumpId); - else - dparams.databaseDumpId = 0; - } - ERROR_EXIT(code); /* exit with code from getTape */ + /* If didn't write the label, remove dump from the database */ + if (!dparams.wroteLabel) { + i = bcdb_deleteDump(dparams.databaseDumpId, 0, 0, 0); + if (i && (i != BUDB_NOENT)) + ErrorLog(1, taskId, i, 0, + "Warning: Can't delete dump %u from database\n", + dparams.databaseDumpId); + else + dparams.databaseDumpId = 0; + } + ERROR_EXIT(code); /* exit with code from getTape */ } - + startTime = time(0); - for (pass = 1; pass <= maxpass; pass++) - { - lastPass = (pass == maxpass); + for (pass = 1; pass <= maxpass; pass++) { + lastPass = (pass == maxpass); code = dumpPass(&dparams, pass); - if (code) ERROR_EXIT(code); + if (code) + ERROR_EXIT(code); /* if no failed volumes, we're done */ - if ((dparams.volumesDumped + dparams.volumesFailed + dparams.volumesNotDumped) == - nodePtr->arraySize) break; + if ((dparams.volumesDumped + dparams.volumesFailed + + dparams.volumesNotDumped) == nodePtr->arraySize) + break; } /* @@ -1219,29 +1266,36 @@ int Dumper(struct dumpNode *nodePtr) * Scantape may assume another volume and ask for next tape. */ if (!CONF_XBSA) { - code = butm_WriteEOT(&tapeInfo); - if (code) TapeLog(taskId, code, tapeInfo.error, - "Warning: Can't write end-of-dump on tape\n"); + code = butm_WriteEOT(&tapeInfo); + if (code) + TapeLog(taskId, code, tapeInfo.error, + "Warning: Can't write end-of-dump on tape\n"); } - code = finishTape(&dparams.tape, dparams.tapeInfoPtr->kBytes + - (dparams.tapeInfoPtr->nBytes ? 1 : 0)); - if (code) ERROR_EXIT(code); + code = + finishTape(&dparams.tape, + dparams.tapeInfoPtr->kBytes + + (dparams.tapeInfoPtr->nBytes ? 1 : 0)); + if (code) + ERROR_EXIT(code); code = finishDump(&dparams.dump); - if (code) ERROR_EXIT(code); + if (code) + ERROR_EXIT(code); action = dparams.curVolumeStatus; code = flushSavedEntries(action); - if (code) ERROR_EXIT(code); + if (code) + ERROR_EXIT(code); error_exit: endTime = time(0); Bind(0); - if (bufferBlock) free(bufferBlock); + if (bufferBlock) + free(bufferBlock); if (!CONF_XBSA) { - unmountTape(taskId, &tapeInfo); + unmountTape(taskId, &tapeInfo); } waitDbWatcher(); @@ -1254,80 +1308,73 @@ int Dumper(struct dumpNode *nodePtr) nodePtr->statusNodePtr->volsFailed = failedvolumes; unlock_Status(); - lastPass = 1; /* In case we aborted */ + lastPass = 1; /* In case we aborted */ DUMPNAME(finishedMsg1, nodePtr->dumpSetName, dparams.databaseDumpId); sprintf(finishedMsg2, "%d volumes dumped", dumpedvolumes); - if (failedvolumes) - { - sprintf(msg, ", %d failed", failedvolumes); + if (failedvolumes) { + sprintf(msg, ", %d failed", failedvolumes); strcat(finishedMsg2, msg); } - if (nodumpvolumes) - { - sprintf(msg, ", %d unchanged", nodumpvolumes); + if (nodumpvolumes) { + sprintf(msg, ", %d unchanged", nodumpvolumes); strcat(finishedMsg2, msg); } - if (code == TC_ABORTEDBYREQUEST) - { - ErrorLog(0, taskId, 0, 0, - "%s: Aborted by request. %s\n", finishedMsg1, finishedMsg2); + if (code == TC_ABORTEDBYREQUEST) { + ErrorLog(0, taskId, 0, 0, "%s: Aborted by request. %s\n", + finishedMsg1, finishedMsg2); clearStatus(taskId, ABORT_REQUEST); - setStatus (taskId, ABORT_DONE); - } - else if (code) - { - ErrorLog(0, taskId, code, 0, - "%s: Finished with errors. %s\n", finishedMsg1, finishedMsg2); + setStatus(taskId, ABORT_DONE); + } else if (code) { + ErrorLog(0, taskId, code, 0, "%s: Finished with errors. %s\n", + finishedMsg1, finishedMsg2); setStatus(taskId, TASK_ERROR); - } - else - { + } else { TLog(taskId, "%s: Finished. %s\n", finishedMsg1, finishedMsg2); } lastPass = 0; /* Record how long the dump took */ if (centralLogIO && startTime) { - long timediff; - afs_int32 hrs, min, sec, tmp; - char line[1024]; - struct tm tmstart, tmend; - - localtime_r(&startTime, &tmstart); - localtime_r(&endTime, &tmend); - timediff = (int)endTime - (int)startTime; - hrs = timediff / 3600; - tmp = timediff % 3600; - min = tmp / 60; - sec = tmp % 60; - - sprintf(line, "%-5d %02d/%02d/%04d %02d:%02d:%02d " - "%02d/%02d/%04d %02d:%02d:%02d " - "%02d:%02d:%02d " - "%s %d of %d volumes dumped (%ld KB)\n", - taskId, tmstart.tm_mon+1, tmstart.tm_mday, tmstart.tm_year+1900, - tmstart.tm_hour, tmstart.tm_min, tmstart.tm_sec, - tmend.tm_mon+1, tmend.tm_mday, tmend.tm_year+1900, - tmend.tm_hour, tmend.tm_min, tmend.tm_sec, - hrs, min, sec, nodePtr->volumeSetName, - dumpedvolumes, dumpedvolumes+failedvolumes, - dparams.tapeInfoPtr->kBytes+1); - - fwrite(line, strlen(line), 1, centralLogIO); - fflush(centralLogIO); + long timediff; + afs_int32 hrs, min, sec, tmp; + char line[1024]; + struct tm tmstart, tmend; + + localtime_r(&startTime, &tmstart); + localtime_r(&endTime, &tmend); + timediff = (int)endTime - (int)startTime; + hrs = timediff / 3600; + tmp = timediff % 3600; + min = tmp / 60; + sec = tmp % 60; + + sprintf(line, + "%-5d %02d/%02d/%04d %02d:%02d:%02d " + "%02d/%02d/%04d %02d:%02d:%02d " "%02d:%02d:%02d " + "%s %d of %d volumes dumped (%ld KB)\n", taskId, + tmstart.tm_mon + 1, tmstart.tm_mday, tmstart.tm_year + 1900, + tmstart.tm_hour, tmstart.tm_min, tmstart.tm_sec, + tmend.tm_mon + 1, tmend.tm_mday, tmend.tm_year + 1900, + tmend.tm_hour, tmend.tm_min, tmend.tm_sec, hrs, min, sec, + nodePtr->volumeSetName, dumpedvolumes, + dumpedvolumes + failedvolumes, + dparams.tapeInfoPtr->kBytes + 1); + + fwrite(line, strlen(line), 1, centralLogIO); + fflush(centralLogIO); } setStatus(taskId, TASK_DONE); - FreeNode(taskId); /* free the dump node */ + FreeNode(taskId); /* free the dump node */ LeaveDeviceQueue(deviceLatch); - return(code); + return (code); } -#define BELLTIME 60 /* 60 seconds before a bell rings */ -#define BELLCHAR 7 /* ascii for bell */ +#define BELLTIME 60 /* 60 seconds before a bell rings */ +#define BELLCHAR 7 /* ascii for bell */ /* retryPrompt * prompt the user to decide how to handle a failed volume dump. The @@ -1340,7 +1387,8 @@ int Dumper(struct dumpNode *nodePtr) * character typed by user, one of r, o or a */ -char retryPrompt(char *volumeName, afs_int32 volumeId, afs_uint32 taskId) +char +retryPrompt(char *volumeName, afs_int32 volumeId, afs_uint32 taskId) { afs_int32 start; char ch; @@ -1351,7 +1399,7 @@ char retryPrompt(char *volumeName, afs_int32 volumeId, afs_uint32 taskId) printf("Please select action to be taken for this volume\n"); -again: + again: printf("r - retry, try dumping this volume again\n"); printf("o - omit, this volume from this dump\n"); printf("a - abort, the entire dump\n"); @@ -1362,34 +1410,33 @@ again: fflush(stdout); start = time(0); - while(1) - { + while (1) { #ifdef AFS_PTHREAD_ENV - code = GetResponseKey(5, &ch); /* ch stores key pressed */ + code = GetResponseKey(5, &ch); /* ch stores key pressed */ #else - code = LWP_GetResponseKey(5, &ch); /* ch stores key pressed */ + code = LWP_GetResponseKey(5, &ch); /* ch stores key pressed */ #endif - if (code == 1) - break; /* input is available */ + if (code == 1) + break; /* input is available */ - if ( checkAbortByTaskId(taskId) ) - { + if (checkAbortByTaskId(taskId)) { clearStatus(taskId, OPR_WAIT); - printf("This tape operation has been aborted by the coordinator\n"); + printf + ("This tape operation has been aborted by the coordinator\n"); return 'a'; } - if (time(0) > start + BELLTIME) break; + if (time(0) > start + BELLTIME) + break; } /* otherwise, we should beep again, check for abort and go back, * since the GetResponseKey() timed out. */ - if (code == 1) - break; /* input is available */ + if (code == 1) + break; /* input is available */ } clearStatus(taskId, OPR_WAIT); - if ( ch != 'r' && ch != 'o' && ch != 'a' ) - { + if (ch != 'r' && ch != 'o' && ch != 'a') { printf("Please select one of the 3 options, r, o or a\n"); goto again; } @@ -1398,53 +1445,55 @@ again: } /* For testing: it prints the tape label */ -int printTapeLabel(struct butm_tapeLabel *tl) +int +printTapeLabel(struct butm_tapeLabel *tl) { - printf("Tape Label\n"); - printf(" structVersion = %d\n", tl->structVersion); - printf(" creationTime = %u\n", tl->creationTime); - printf(" expirationDate = %u\n", tl->expirationDate); - printf(" AFSName = %s\n", tl->AFSName); - printf(" cell = %s\n", tl->cell); - printf(" dumpid = %d\n", tl->dumpid); - printf(" useCount = %d\n", tl->useCount); - printf(" comment = %s\n", tl->comment); - printf(" pName = %s\n", tl->pName); - printf(" size = %u\n", tl->size); - printf(" dumpPath = %s\n", tl->dumpPath); + printf("Tape Label\n"); + printf(" structVersion = %d\n", tl->structVersion); + printf(" creationTime = %u\n", tl->creationTime); + printf(" expirationDate = %u\n", tl->expirationDate); + printf(" AFSName = %s\n", tl->AFSName); + printf(" cell = %s\n", tl->cell); + printf(" dumpid = %d\n", tl->dumpid); + printf(" useCount = %d\n", tl->useCount); + printf(" comment = %s\n", tl->comment); + printf(" pName = %s\n", tl->pName); + printf(" size = %u\n", tl->size); + printf(" dumpPath = %s\n", tl->dumpPath); } /* getXBSATape * Create a tape structure to be satisfy the backup database * even though we don't really use a tape with XBSA. */ -int getXBSATape(struct dumpRock *dparamsPtr) +int +getXBSATape(struct dumpRock *dparamsPtr) { - struct dumpNode *nodePtr = dparamsPtr->node; - struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr; + struct dumpNode *nodePtr = dparamsPtr->node; + struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr; struct butm_tapeLabel *tapeLabelPtr = &dparamsPtr->tapeLabel; afs_int32 code = 0; - tc_MakeTapeName(dparamsPtr->tapeName, &nodePtr->tapeSetDesc, dparamsPtr->tapeSeq); + tc_MakeTapeName(dparamsPtr->tapeName, &nodePtr->tapeSetDesc, + dparamsPtr->tapeSeq); - GetNewLabel(tapeInfoPtr, ""/*pName*/, dparamsPtr->tapeName, tapeLabelPtr); + GetNewLabel(tapeInfoPtr, "" /*pName */ , dparamsPtr->tapeName, + tapeLabelPtr); strcpy(tapeLabelPtr->dumpPath, nodePtr->dumpName); - tapeLabelPtr->dumpid = dparamsPtr->databaseDumpId; - tapeLabelPtr->expirationDate = calcExpirationDate(nodePtr->tapeSetDesc.expType, - nodePtr->tapeSetDesc.expDate, - time(0)); + tapeLabelPtr->dumpid = dparamsPtr->databaseDumpId; + tapeLabelPtr->expirationDate = + calcExpirationDate(nodePtr->tapeSetDesc.expType, + nodePtr->tapeSetDesc.expDate, time(0)); /* printTapeLabel(tapeLabelPtr); For testing */ - code = useTape(&dparamsPtr->tape, - dparamsPtr->databaseDumpId, - dparamsPtr->tapeName, - (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b), - tapeLabelPtr->useCount, - tapeLabelPtr->creationTime, - tapeLabelPtr->expirationDate, - 0 /*tape position*/); - return(code); + code = + useTape(&dparamsPtr->tape, dparamsPtr->databaseDumpId, + dparamsPtr->tapeName, + (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b), + tapeLabelPtr->useCount, tapeLabelPtr->creationTime, + tapeLabelPtr->expirationDate, 0 /*tape position */ ); + return (code); } /* getDumpTape @@ -1456,25 +1505,26 @@ int getXBSATape(struct dumpRock *dparamsPtr) * 1 - prompt regardless */ -int getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, - afs_int32 append) +int +getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, + afs_int32 append) { - struct dumpNode *nodePtr = dparamsPtr->node; - struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr; + struct dumpNode *nodePtr = dparamsPtr->node; + struct butm_tapeInfo *tapeInfoPtr = dparamsPtr->tapeInfoPtr; struct butm_tapeLabel *newTapeLabelPtr = &dparamsPtr->tapeLabel; - char AFSTapeName[TC_MAXTAPENAMELEN]; - afs_int32 taskId = nodePtr->taskID; - struct butm_tapeLabel oldTapeLabel; - struct budb_dumpEntry dumpEntry; - struct budb_tapeEntry tapeEntry; + char AFSTapeName[TC_MAXTAPENAMELEN]; + afs_int32 taskId = nodePtr->taskID; + struct butm_tapeLabel oldTapeLabel; + struct budb_dumpEntry dumpEntry; + struct budb_tapeEntry tapeEntry; struct budb_volumeEntry volEntry; - Date oldTapeExpiration, expir; + Date oldTapeExpiration, expir; afs_int32 curTime; afs_int32 doAppend; afs_int32 code = 0; - int askForTape, opcode; - int tapecount = 1; - char strlevel[5]; + int askForTape, opcode; + int tapecount = 1; + char strlevel[5]; afs_int32 tapepos, lastpos; extern struct tapeConfig globalTapeConfig; @@ -1484,66 +1534,64 @@ int getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, dparamsPtr->wroteLabel = 0; /* Keep prompting for a tape until we get it right */ - while (1) - { - /* What the name of the tape would be if not appending to it */ - tc_MakeTapeName(AFSTapeName, &nodePtr->tapeSetDesc, dparamsPtr->tapeSeq); - - doAppend = append; - - if (askForTape) - { - code = PromptForTape((doAppend ? APPENDOPCODE : WRITEOPCODE), - AFSTapeName, dparamsPtr->databaseDumpId, taskId, tapecount); - if (code) ERROR_EXIT(code); + while (1) { + /* What the name of the tape would be if not appending to it */ + tc_MakeTapeName(AFSTapeName, &nodePtr->tapeSetDesc, + dparamsPtr->tapeSeq); + + doAppend = append; + + if (askForTape) { + code = + PromptForTape((doAppend ? APPENDOPCODE : WRITEOPCODE), + AFSTapeName, dparamsPtr->databaseDumpId, taskId, + tapecount); + if (code) + ERROR_EXIT(code); } askForTape = 1; tapecount++; /* open the tape device */ code = butm_Mount(tapeInfoPtr, AFSTapeName); - if (code) - { + if (code) { TapeLog(0, taskId, code, tapeInfoPtr->error, "Can't open tape\n"); goto getNewTape; } /* Read the tape label */ - code = butm_ReadLabel(tapeInfoPtr, &oldTapeLabel, 1); /* rewind */ + code = butm_ReadLabel(tapeInfoPtr, &oldTapeLabel, 1); /* rewind */ if (code) { - if (tapeInfoPtr->error) { - ErrorLog(0, taskId, code, tapeInfoPtr->error, - "Warning: Tape error while reading label (will proceed with dump)\n"); - } - memset(&oldTapeLabel, 0, sizeof(oldTapeLabel)); + if (tapeInfoPtr->error) { + ErrorLog(0, taskId, code, tapeInfoPtr->error, + "Warning: Tape error while reading label (will proceed with dump)\n"); + } + memset(&oldTapeLabel, 0, sizeof(oldTapeLabel)); } /* Check if null tape. Prior 3.3, backup tapes have no dump id */ - if ( (strcmp(oldTapeLabel.AFSName,"") == 0) && (oldTapeLabel.dumpid == 0) ) - { - if (doAppend) - { - TLog(taskId, "Dump not found on tape. Proceeding with initial dump\n"); + if ((strcmp(oldTapeLabel.AFSName, "") == 0) + && (oldTapeLabel.dumpid == 0)) { + if (doAppend) { + TLog(taskId, + "Dump not found on tape. Proceeding with initial dump\n"); doAppend = 0; } - } - else if (doAppend) /* appending */ - { + } else if (doAppend) { /* appending */ /* Check that we don't have a database dump tape */ - if ( databaseTape(oldTapeLabel.AFSName) ) - { - char gotName[BU_MAXTAPELEN+32]; + if (databaseTape(oldTapeLabel.AFSName)) { + char gotName[BU_MAXTAPELEN + 32]; - /* label does not match */ + /* label does not match */ LABELNAME(gotName, &oldTapeLabel); - TLog(taskId, "Can't append to database tape %s\n", gotName); + TLog(taskId, "Can't append to database tape %s\n", gotName); goto getNewTape; } /* Verify that the tape is of version 4 (AFS 3.3) or greater */ - if (oldTapeLabel.structVersion < TAPE_VERSION_4) - { - TLog(taskId, "Can't append: requires tape version %d or greater\n", + if (oldTapeLabel.structVersion < TAPE_VERSION_4) { + TLog(taskId, + "Can't append: requires tape version %d or greater\n", TAPE_VERSION_4); goto getNewTape; } @@ -1551,48 +1599,48 @@ int getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, /* Verify that the last tape of the dump set is in the drive. * volEntry will be zeroed if last dump has no volume entries. */ - code = bcdb_FindLastTape(oldTapeLabel.dumpid, &dumpEntry, &tapeEntry, &volEntry); + code = + bcdb_FindLastTape(oldTapeLabel.dumpid, &dumpEntry, &tapeEntry, + &volEntry); if (code) { - ErrorLog(0, taskId, code, 0, - "Can't append: Can't find last volume of dumpId %u in database\n", + ErrorLog(0, taskId, code, 0, + "Can't append: Can't find last volume of dumpId %u in database\n", oldTapeLabel.dumpid); - printf("Please scan the dump in or choose another tape\n"); - goto getNewTape; + printf("Please scan the dump in or choose another tape\n"); + goto getNewTape; } - lastpos = (volEntry.position ? volEntry.position : tapeEntry.labelpos); + lastpos = + (volEntry.position ? volEntry.position : tapeEntry.labelpos); - if (strcmp(TNAME(&oldTapeLabel),tapeEntry.name)) - { - char expName[BU_MAXTAPELEN+32], gotName[BU_MAXTAPELEN+32]; + if (strcmp(TNAME(&oldTapeLabel), tapeEntry.name)) { + char expName[BU_MAXTAPELEN + 32], gotName[BU_MAXTAPELEN + 32]; TAPENAME(expName, tapeEntry.name, oldTapeLabel.dumpid); LABELNAME(gotName, &oldTapeLabel); - TLog(taskId, + TLog(taskId, "Can't append: Last tape in dump-set is %s, label seen %s\n", expName, gotName); goto getNewTape; } /* After reading the tape label, we now know what it is */ - strcpy (AFSTapeName, oldTapeLabel.AFSName); /* the real name */ - strcpy (tapeInfoPtr->name, oldTapeLabel.AFSName); /* the real name */ + strcpy(AFSTapeName, oldTapeLabel.AFSName); /* the real name */ + strcpy(tapeInfoPtr->name, oldTapeLabel.AFSName); /* the real name */ /* Position after last volume on the tape */ code = butm_SeekEODump(tapeInfoPtr, lastpos); - if (code) - { - ErrorLog(0, taskId, code, tapeInfoPtr->error, - "Can't append: Can't position to end of dump on tape %s\n", + if (code) { + ErrorLog(0, taskId, code, tapeInfoPtr->error, + "Can't append: Can't position to end of dump on tape %s\n", tapeEntry.name); goto getNewTape; } /* Track size of tape - set after seek since seek changes the value */ tapeInfoPtr->kBytes = tapeEntry.useKBytes; - } - else /* not appending */ - { + } else { /* not appending */ + afs_uint32 tapeid; afs_uint32 dmp, parent; struct budb_dumpEntry de, de2; @@ -1601,63 +1649,59 @@ int getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, /* Check if tape name is not what expected - null tapes are acceptable * Don't do check if the tape has a user defined label. */ - if ( dump_namecheck && (strcmp(oldTapeLabel.pName,"")==0) ) - { - if ( strcmp(oldTapeLabel.AFSName,"") && /* not null tape */ - strcmp(oldTapeLabel.AFSName,AFSTapeName) ) /* not expected name */ - { - TLog(taskId, "Tape label expected %s, label seen %s\n", + if (dump_namecheck && (strcmp(oldTapeLabel.pName, "") == 0)) { + if (strcmp(oldTapeLabel.AFSName, "") && /* not null tape */ + strcmp(oldTapeLabel.AFSName, AFSTapeName)) { /* not expected name */ + TLog(taskId, "Tape label expected %s, label seen %s\n", AFSTapeName, oldTapeLabel.AFSName); goto getNewTape; } /* Check that we don't have a database dump tape */ - if ( databaseTape(oldTapeLabel.AFSName) ) - { + if (databaseTape(oldTapeLabel.AFSName)) { /* label does not match */ - TLog(taskId, "Tape label expected %s, can't dump to database tape %s\n", + TLog(taskId, + "Tape label expected %s, can't dump to database tape %s\n", AFSTapeName, oldTapeLabel.AFSName); goto getNewTape; } } /* Verify the tape has not expired - only check if not appending */ - if ( !tapeExpired(&oldTapeLabel) ) { - TLog(taskId, "This tape has not expired\n"); + if (!tapeExpired(&oldTapeLabel)) { + TLog(taskId, "This tape has not expired\n"); goto getNewTape; } /* Given a tape dump with good data, verify we don't overwrite recent dumps * and also verify that the volume will be restorable - if not print warnings */ - if (oldTapeLabel.dumpid) - { + if (oldTapeLabel.dumpid) { /* Do not overwrite a tape that belongs to the dump's dumpset */ - tapeid = (dparamsPtr->initialDumpId ? dparamsPtr->initialDumpId : - dparamsPtr->databaseDumpId); - if (oldTapeLabel.dumpid == tapeid) - { - ErrorLog(0, taskId, 0, 0, + tapeid = + (dparamsPtr->initialDumpId ? dparamsPtr-> + initialDumpId : dparamsPtr->databaseDumpId); + if (oldTapeLabel.dumpid == tapeid) { + ErrorLog(0, taskId, 0, 0, "Can't overwrite tape containing the dump in progress\n"); goto getNewTape; } - + /* Since the dumpset on this tape will be deleted from database, check if * any of the dump's parent-dumps are on this tape. */ - for (dmp=nodePtr->parent; dmp; dmp=de.parent) - { + for (dmp = nodePtr->parent; dmp; dmp = de.parent) { code = bcdb_FindDumpByID(dmp, &de); if (code) { - ErrorLog(0, taskId, 0, 0, - "Warning: Can't find parent dump %u in backup database\n", + ErrorLog(0, taskId, 0, 0, + "Warning: Can't find parent dump %u in backup database\n", dmp); break; } tapeid = (de.initialDumpID ? de.initialDumpID : de.id); if (oldTapeLabel.dumpid == tapeid) { - ErrorLog(0, taskId, 0, 0, + ErrorLog(0, taskId, 0, 0, "Can't overwrite the parent dump %s (DumpID %u)\n", de.name, de.id); goto getNewTape; @@ -1667,36 +1711,38 @@ int getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, /* Since the dumpset on this tape will be deleted from database, check if * any of the dumps in this dumpset are most-recent-dumps. */ - for (dmp=oldTapeLabel.dumpid; dmp; dmp=de.appendedDumpID) { + for (dmp = oldTapeLabel.dumpid; dmp; dmp = de.appendedDumpID) { if (dmp == dparamsPtr->lastDump.id) { memcpy(&de, &dparamsPtr->lastDump, sizeof(de)); memcpy(&de2, &dparamsPtr->lastDump, sizeof(de2)); - } - else { - code = bcdb_FindDumpByID(dmp, &de); - if (code) break; + } else { + code = bcdb_FindDumpByID(dmp, &de); + if (code) + break; sprintf(strlevel, "%d", de.level); - code = bcdb_FindLatestDump(de.volumeSetName, strlevel, &de2); - if (code) continue; + code = + bcdb_FindLatestDump(de.volumeSetName, strlevel, + &de2); + if (code) + continue; } /* If dump on the tape is the latest dump at this level */ if (de.id == de2.id) { - if (strcmp(DUMP_TAPE_NAME,de2.name) == 0) { - ErrorLog(0, taskId, 0, 0, - "Warning: Overwriting most recent dump %s (DumpID %u)\n", - de.name, de.id); - } - else { - ErrorLog(0, taskId, 0, 0, - "Warning: Overwriting most recent dump of the '%s' volumeset: %s (DumpID %u)\n", - de.volumeSetName, de.name, de.id); - } + if (strcmp(DUMP_TAPE_NAME, de2.name) == 0) { + ErrorLog(0, taskId, 0, 0, + "Warning: Overwriting most recent dump %s (DumpID %u)\n", + de.name, de.id); + } else { + ErrorLog(0, taskId, 0, 0, + "Warning: Overwriting most recent dump of the '%s' volumeset: %s (DumpID %u)\n", + de.volumeSetName, de.name, de.id); + } } } - } /* if (oldTapeLabel.dumpid) */ - } /* else not appending */ - + } /* if (oldTapeLabel.dumpid) */ + } /* else not appending */ + /* * Now have the right tape. Create a new label for the tape * Appended labels have the dump's dumpId - labels at beginnings of @@ -1704,17 +1750,19 @@ int getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, * Appended labels do not increment the useCount. * Labels at beginnings of tape use the most future expiration of the dump set. */ - GetNewLabel(tapeInfoPtr, oldTapeLabel.pName, AFSTapeName, newTapeLabelPtr); + GetNewLabel(tapeInfoPtr, oldTapeLabel.pName, AFSTapeName, + newTapeLabelPtr); strcpy(newTapeLabelPtr->dumpPath, nodePtr->dumpName); - newTapeLabelPtr->expirationDate = - calcExpirationDate(nodePtr->tapeSetDesc.expType, nodePtr->tapeSetDesc.expDate, time(0)); - newTapeLabelPtr->dumpid = dparamsPtr->databaseDumpId; + newTapeLabelPtr->expirationDate = + calcExpirationDate(nodePtr->tapeSetDesc.expType, + nodePtr->tapeSetDesc.expDate, time(0)); + newTapeLabelPtr->dumpid = dparamsPtr->databaseDumpId; newTapeLabelPtr->useCount = oldTapeLabel.useCount; if (!doAppend) { newTapeLabelPtr->useCount++; if (dparamsPtr->initialDumpId) { - newTapeLabelPtr->dumpid = dparamsPtr->initialDumpId; + newTapeLabelPtr->dumpid = dparamsPtr->initialDumpId; expir = ExpirationDate(dparamsPtr->initialDumpId); if (expir > newTapeLabelPtr->expirationDate) newTapeLabelPtr->expirationDate = expir; @@ -1723,62 +1771,61 @@ int getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, /* write the label on the tape - rewind if not appending and vice-versa */ code = butm_Create(tapeInfoPtr, newTapeLabelPtr, !doAppend); - if (code) - { - char gotName[BU_MAXTAPELEN+32]; + if (code) { + char gotName[BU_MAXTAPELEN + 32]; LABELNAME(gotName, newTapeLabelPtr); - TapeLog(0, taskId, code, tapeInfoPtr->error, "Can't label tape as %s\n", gotName); + TapeLog(0, taskId, code, tapeInfoPtr->error, + "Can't label tape as %s\n", gotName); goto getNewTape; } - dparamsPtr->wroteLabel = 1; /* Remember we wrote the label */ - tapepos = tapeInfoPtr->position-1; + dparamsPtr->wroteLabel = 1; /* Remember we wrote the label */ + tapepos = tapeInfoPtr->position - 1; strcpy(dparamsPtr->tapeName, TNAME(newTapeLabelPtr)); /* If appending, set dumpentry in the database as appended. */ - if (doAppend) - { - char gotName[BU_MAXTAPELEN+32]; + if (doAppend) { + char gotName[BU_MAXTAPELEN + 32]; nodePtr->tapeSetDesc.b = extractTapeSeq(AFSTapeName); dparamsPtr->dump.tapes.b = nodePtr->tapeSetDesc.b; dparamsPtr->initialDumpId = oldTapeLabel.dumpid; strcpy(nodePtr->tapeSetDesc.format, dumpEntry.tapes.format); - code = bcdb_MakeDumpAppended(dparamsPtr->databaseDumpId, - dparamsPtr->initialDumpId, nodePtr->tapeSetDesc.b); + code = + bcdb_MakeDumpAppended(dparamsPtr->databaseDumpId, + dparamsPtr->initialDumpId, + nodePtr->tapeSetDesc.b); if (code) - ErrorLog(2, taskId, code, 0, + ErrorLog(2, taskId, code, 0, "Warning: Can't append dump %u to dump %u in database\n", - dparamsPtr->databaseDumpId, dparamsPtr->initialDumpId); + dparamsPtr->databaseDumpId, + dparamsPtr->initialDumpId); LABELNAME(gotName, &oldTapeLabel); TLog(taskId, "Appending dump %s (DumpID %u) to tape %s\n", - nodePtr->dumpSetName, dparamsPtr->databaseDumpId, gotName); + nodePtr->dumpSetName, dparamsPtr->databaseDumpId, gotName); } /* If not appending, delete overwritten dump from the database */ - else - { - if ( (oldTapeLabel.structVersion >= TAPE_VERSION_3) && oldTapeLabel.dumpid ) - { - code = bcdb_deleteDump(oldTapeLabel.dumpid, 0, 0, 0); - if ( code && (code != BUDB_NOENT) ) - ErrorLog(0, taskId, code, 0, + else { + if ((oldTapeLabel.structVersion >= TAPE_VERSION_3) + && oldTapeLabel.dumpid) { + code = bcdb_deleteDump(oldTapeLabel.dumpid, 0, 0, 0); + if (code && (code != BUDB_NOENT)) + ErrorLog(0, taskId, code, 0, "Warning: Can't delete old dump %u from database\n", oldTapeLabel.dumpid); } } - code = useTape(&dparamsPtr->tape, - dparamsPtr->databaseDumpId, - dparamsPtr->tapeName, - (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b), - newTapeLabelPtr->useCount, - newTapeLabelPtr->creationTime, - newTapeLabelPtr->expirationDate, - tapepos); + code = + useTape(&dparamsPtr->tape, dparamsPtr->databaseDumpId, + dparamsPtr->tapeName, + (dparamsPtr->tapeSeq + dparamsPtr->dump.tapes.b), + newTapeLabelPtr->useCount, newTapeLabelPtr->creationTime, + newTapeLabelPtr->expirationDate, tapepos); /* * The margin of space to check for end of tape is set to the @@ -1788,7 +1835,7 @@ int getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, * and up to two EOF markers done on close (3 16K blocks + 4 EOF * markers). */ - tc_EndMargin = (3 * 16384 + 4 * globalTapeConfig.fileMarkSize) * 2; + tc_EndMargin = (3 * 16384 + 4 * globalTapeConfig.fileMarkSize) * 2; tc_KEndMargin = tc_EndMargin / 1024; break; @@ -1796,12 +1843,13 @@ int getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag, unmountTape(taskId, tapeInfoPtr); } -error_exit: - return(code); + error_exit: + return (code); } -int makeVolumeHeader(struct volumeHeader *vhptr, struct dumpRock *dparamsPtr, - int fragmentNumber) +int +makeVolumeHeader(struct volumeHeader *vhptr, struct dumpRock *dparamsPtr, + int fragmentNumber) { struct dumpNode *nodePtr = dparamsPtr->node; struct tc_dumpDesc *curDump; @@ -1825,41 +1873,42 @@ int makeVolumeHeader(struct volumeHeader *vhptr, struct dumpRock *dparamsPtr, vhptr->endTime = 0; vhptr->versionflags = CUR_TAPE_VERSION; strcpy(vhptr->dumpSetName, nodePtr->dumpSetName); - strcpy(vhptr->preamble,"H++NAME#"); - strcpy(vhptr->postamble,"T--NAME#"); -error_exit: + strcpy(vhptr->preamble, "H++NAME#"); + strcpy(vhptr->postamble, "T--NAME#"); + error_exit: return (code); } -int volumeHeader_hton(struct volumeHeader *hostPtr, - struct volumeHeader *netPtr) +int +volumeHeader_hton(struct volumeHeader *hostPtr, struct volumeHeader *netPtr) { struct volumeHeader volHdr; - strcpy(volHdr.preamble, hostPtr->preamble); - strcpy(volHdr.postamble, hostPtr->postamble); - strcpy(volHdr.volumeName, hostPtr->volumeName); + strcpy(volHdr.preamble, hostPtr->preamble); + strcpy(volHdr.postamble, hostPtr->postamble); + strcpy(volHdr.volumeName, hostPtr->volumeName); strcpy(volHdr.dumpSetName, hostPtr->dumpSetName); - volHdr.volumeID = htonl(hostPtr->volumeID); - volHdr.server = htonl(hostPtr->server); - volHdr.part = htonl(hostPtr->part); - volHdr.from = htonl(hostPtr->from); - volHdr.frag = htonl(hostPtr->frag); - volHdr.magic = htonl(hostPtr->magic); - volHdr.contd = htonl(hostPtr->contd); - volHdr.dumpID = htonl(hostPtr->dumpID); - volHdr.level = htonl(hostPtr->level); - volHdr.parentID = htonl(hostPtr->parentID); - volHdr.endTime = htonl(hostPtr->endTime); + volHdr.volumeID = htonl(hostPtr->volumeID); + volHdr.server = htonl(hostPtr->server); + volHdr.part = htonl(hostPtr->part); + volHdr.from = htonl(hostPtr->from); + volHdr.frag = htonl(hostPtr->frag); + volHdr.magic = htonl(hostPtr->magic); + volHdr.contd = htonl(hostPtr->contd); + volHdr.dumpID = htonl(hostPtr->dumpID); + volHdr.level = htonl(hostPtr->level); + volHdr.parentID = htonl(hostPtr->parentID); + volHdr.endTime = htonl(hostPtr->endTime); volHdr.versionflags = htonl(hostPtr->versionflags); - volHdr.cloneDate = htonl(hostPtr->cloneDate); + volHdr.cloneDate = htonl(hostPtr->cloneDate); memcpy(netPtr, &volHdr, sizeof(struct volumeHeader)); } /* database related routines */ -afs_int32 createDump(struct dumpRock *dparamsPtr) +afs_int32 +createDump(struct dumpRock *dparamsPtr) { struct dumpNode *nodePtr = dparamsPtr->node; struct budb_dumpEntry *dumpPtr; @@ -1870,38 +1919,38 @@ afs_int32 createDump(struct dumpRock *dparamsPtr) /* id filled in by database */ dumpPtr->parent = nodePtr->parent; - dumpPtr->level = nodePtr->level; - dumpPtr->flags = 0; + dumpPtr->level = nodePtr->level; + dumpPtr->flags = 0; #ifdef xbsa if (CONF_XBSA) { - if (xbsaType == XBSA_SERVER_TYPE_ADSM) { - strcpy(dumpPtr->tapes.tapeServer, butxInfo.serverName); - dumpPtr->flags = BUDB_DUMP_ADSM; - } - if (!(butxInfo.serverType & XBSA_SERVER_FLAG_MULTIPLE)) { - /* The current server (API) doesn't provide the function required - * to specify a server at startup time. For that reason, we can't - * be sure that the server name supplied by the user in the user- - * defined configuration file is correct. We set a flag here so - * we know at restore time that the servername info in the backup - * database may be incorrect. We will not allow a server switch - * at that time, even if the server at restore time supports - * multiple servers. - */ - dumpPtr->flags |= BUDB_DUMP_XBSA_NSS; - } + if (xbsaType == XBSA_SERVER_TYPE_ADSM) { + strcpy(dumpPtr->tapes.tapeServer, butxInfo.serverName); + dumpPtr->flags = BUDB_DUMP_ADSM; + } + if (!(butxInfo.serverType & XBSA_SERVER_FLAG_MULTIPLE)) { + /* The current server (API) doesn't provide the function required + * to specify a server at startup time. For that reason, we can't + * be sure that the server name supplied by the user in the user- + * defined configuration file is correct. We set a flag here so + * we know at restore time that the servername info in the backup + * database may be incorrect. We will not allow a server switch + * at that time, even if the server at restore time supports + * multiple servers. + */ + dumpPtr->flags |= BUDB_DUMP_XBSA_NSS; + } } #endif strcpy(dumpPtr->volumeSetName, nodePtr->volumeSetName); - strcpy(dumpPtr->dumpPath, nodePtr->dumpName); - strcpy(dumpPtr->name, nodePtr->dumpSetName); - dumpPtr->created = 0; /* let database assign it */ - dumpPtr->incTime = 0; /* not really used */ - dumpPtr->nVolumes = 0; + strcpy(dumpPtr->dumpPath, nodePtr->dumpName); + strcpy(dumpPtr->name, nodePtr->dumpSetName); + dumpPtr->created = 0; /* let database assign it */ + dumpPtr->incTime = 0; /* not really used */ + dumpPtr->nVolumes = 0; dumpPtr->initialDumpID = 0; - dumpPtr->tapes.id = groupId; - dumpPtr->tapes.b = 1; + dumpPtr->tapes.id = groupId; + dumpPtr->tapes.b = 1; dumpPtr->tapes.maxTapes = 0; strcpy(dumpPtr->tapes.format, nodePtr->tapeSetDesc.format); @@ -1909,9 +1958,10 @@ afs_int32 createDump(struct dumpRock *dparamsPtr) /* now call the database to create the entry */ code = bcdb_CreateDump(dumpPtr); - if (code == 0) dparamsPtr->databaseDumpId = dumpPtr->id; + if (code == 0) + dparamsPtr->databaseDumpId = dumpPtr->id; - return(code); + return (code); } #ifdef xbsa @@ -1920,65 +1970,72 @@ afs_int32 createDump(struct dumpRock *dparamsPtr) * server as the original server and go back to it each time we pass 0 * as the server. */ -afs_int32 InitToServer(afs_int32 taskId, - struct butx_transactionInfo *butxInfoP, char *server) +afs_int32 +InitToServer(afs_int32 taskId, struct butx_transactionInfo * butxInfoP, + char *server) { - static char origserver[BSA_MAX_DESC]; - static int init=0; - afs_int32 rc, code=0; - - if (!init) { - strcpy(origserver,""); - init = 1; - } - - if (!server) server = origserver; /* return to original server */ - if (strcmp(server,"") == 0) return 0; /* No server, do nothing */ - if (strcmp(butxInfoP->serverName,server) == 0) return 0; /* same server, do nothing */ - if (strcmp(origserver,"") == 0) strcpy(origserver, server);/* remember original server */ - - if (strcmp(butxInfoP->serverName,"") != 0) { - /* If already connected to a server, disconnect from it. - * Check to see if our server does not support switching. - */ - if (!(butxInfo.serverType & XBSA_SERVER_FLAG_MULTIPLE)) { - ErrorLog(0, taskId, TC_BADTASK, 0, - "This version of XBSA libraries does not support switching " - "from server %s to server %s\n", - butxInfoP->serverName, server); - return(TC_BADTASK); - } - - rc = xbsa_Finalize(&butxInfo); - if (rc != XBSA_SUCCESS) { - ErrorLog(0, taskId, rc, 0, - "InitToServer: Unable to terminate the connection to server %s\n", - butxInfoP->serverName); - ERROR_EXIT(rc); - } - } - - /* initialize to the new server */ - rc = xbsa_Initialize(&butxInfo, xbsaObjectOwner, appObjectOwner, xbsaSecToken, server); - if (rc != XBSA_SUCCESS) { - ErrorLog(0, taskId, rc, 0, - "InitToServer: Unable to initialize the XBSA library to server %s\n", - server); - ERROR_EXIT(rc); - } + static char origserver[BSA_MAX_DESC]; + static int init = 0; + afs_int32 rc, code = 0; + + if (!init) { + strcpy(origserver, ""); + init = 1; + } + + if (!server) + server = origserver; /* return to original server */ + if (strcmp(server, "") == 0) + return 0; /* No server, do nothing */ + if (strcmp(butxInfoP->serverName, server) == 0) + return 0; /* same server, do nothing */ + if (strcmp(origserver, "") == 0) + strcpy(origserver, server); /* remember original server */ + + if (strcmp(butxInfoP->serverName, "") != 0) { + /* If already connected to a server, disconnect from it. + * Check to see if our server does not support switching. + */ + if (!(butxInfo.serverType & XBSA_SERVER_FLAG_MULTIPLE)) { + ErrorLog(0, taskId, TC_BADTASK, 0, + "This version of XBSA libraries does not support switching " + "from server %s to server %s\n", butxInfoP->serverName, + server); + return (TC_BADTASK); + } + + rc = xbsa_Finalize(&butxInfo); + if (rc != XBSA_SUCCESS) { + ErrorLog(0, taskId, rc, 0, + "InitToServer: Unable to terminate the connection to server %s\n", + butxInfoP->serverName); + ERROR_EXIT(rc); + } + } + + /* initialize to the new server */ + rc = xbsa_Initialize(&butxInfo, xbsaObjectOwner, appObjectOwner, + xbsaSecToken, server); + if (rc != XBSA_SUCCESS) { + ErrorLog(0, taskId, rc, 0, + "InitToServer: Unable to initialize the XBSA library to server %s\n", + server); + ERROR_EXIT(rc); + } error_exit: - return(code); + return (code); } /* DeleteDump * */ -int DeleteDump(struct deleteDumpIf *ptr) +int +DeleteDump(struct deleteDumpIf *ptr) { afs_int32 taskId; - afs_int32 rc, code=0; + afs_int32 rc, code = 0; afs_uint32 dumpid; afs_int32 index, next, dbTime; budb_volumeList vl; @@ -1987,8 +2044,8 @@ int DeleteDump(struct deleteDumpIf *ptr) char dumpIdStr[XBSA_MAX_OSNAME]; char volumeNameStr[XBSA_MAX_PATHNAME]; afs_int32 i; - int intrans=0; - int allnotfound=1, onenotfound=0; + int intrans = 0; + int allnotfound = 1, onenotfound = 0; extern struct udbHandleS udbHandle; extern struct deviceSyncNode *deviceLatch; @@ -1997,7 +2054,7 @@ int DeleteDump(struct deleteDumpIf *ptr) clearStatus(taskId, DRIVE_WAIT); dumpid = ptr->dumpID; - taskId = ptr->taskId; /* Get task Id */ + taskId = ptr->taskId; /* Get task Id */ printf("\n\n"); TapeLog(2, taskId, 0, 0, "Delete Dump %u\n", dumpid); @@ -2009,143 +2066,153 @@ int DeleteDump(struct deleteDumpIf *ptr) /* Get the dump info for the dump we are deleting */ rc = bcdb_FindDumpByID(dumpid, &dumpEntry); if (rc) { - ErrorLog(0, taskId, rc, 0, "Unable to locate dump ID %u in database\n", dumpid); - setStatus(taskId, TASK_ERROR); - ERROR_EXIT(rc); + ErrorLog(0, taskId, rc, 0, + "Unable to locate dump ID %u in database\n", dumpid); + setStatus(taskId, TASK_ERROR); + ERROR_EXIT(rc); } /* we must make sure that we are configured with the correct type of * XBSA server for this dump delete! Only those dumped to an ADSM server. */ - if ( (xbsaType == XBSA_SERVER_TYPE_ADSM) && - !((dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA))) ) { - ErrorLog(0, taskId, TC_BADTASK, 0, - "The dump %u requested for deletion is incompatible with this instance of butc\n", - dumpid); - setStatus(taskId, TASK_ERROR); - ERROR_EXIT(TC_BADTASK); + if ((xbsaType == XBSA_SERVER_TYPE_ADSM) + && !((dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA)))) { + ErrorLog(0, taskId, TC_BADTASK, 0, + "The dump %u requested for deletion is incompatible with this instance of butc\n", + dumpid); + setStatus(taskId, TASK_ERROR); + ERROR_EXIT(TC_BADTASK); } /* Make sure we are connected to the correct server. If not, switch to it if appropriate */ - if ( (strlen((char *)dumpEntry.tapes.tapeServer) != 0) && - (strcmp((char *)dumpEntry.tapes.tapeServer,butxInfo.serverName) != 0)) { - - /* Check to see if the tapeServer name is trustworthy */ - if ((dumpEntry.flags & (BUDB_DUMP_XBSA_NSS | BUDB_DUMP_BUTA)) && !forcemultiple) { - /* The dump was made with a version of the XBSA interface - * that didn't allow switching of servers, we can't be sure - * that the servername in the backup database is correct. So, - * we will check the servername and log it if they don't match; - * but we will try to do the delete without switching servers. - */ - TLog(taskId, "The dump %d requested for deletion is on server %s " - "but butc is connected to server %s " - "(Attempting to delete the dump anyway)\n", - dumpid, (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName); - } else { - TLog(taskId, "The dump %u requested for deletion is on server %s " - "but butc is connected to server %s " - "(switching servers)\n", - dumpid, (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName); - - rc = InitToServer(taskId, &butxInfo, (char *)dumpEntry.tapes.tapeServer); - if (rc != XBSA_SUCCESS) { - setStatus(taskId, TASK_ERROR); - ERROR_EXIT(rc); - } - } + if ((strlen((char *)dumpEntry.tapes.tapeServer) != 0) + && (strcmp((char *)dumpEntry.tapes.tapeServer, butxInfo.serverName) != + 0)) { + + /* Check to see if the tapeServer name is trustworthy */ + if ((dumpEntry.flags & (BUDB_DUMP_XBSA_NSS | BUDB_DUMP_BUTA)) + && !forcemultiple) { + /* The dump was made with a version of the XBSA interface + * that didn't allow switching of servers, we can't be sure + * that the servername in the backup database is correct. So, + * we will check the servername and log it if they don't match; + * but we will try to do the delete without switching servers. + */ + TLog(taskId, + "The dump %d requested for deletion is on server %s " + "but butc is connected to server %s " + "(Attempting to delete the dump anyway)\n", dumpid, + (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName); + } else { + TLog(taskId, + "The dump %u requested for deletion is on server %s " + "but butc is connected to server %s " + "(switching servers)\n", dumpid, + (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName); + + rc = InitToServer(taskId, &butxInfo, + (char *)dumpEntry.tapes.tapeServer); + if (rc != XBSA_SUCCESS) { + setStatus(taskId, TASK_ERROR); + ERROR_EXIT(rc); + } + } } /* Start a new Transaction */ rc = xbsa_BeginTrans(&butxInfo); if (rc != XBSA_SUCCESS) { - ErrorLog(0, taskId, rc, 0, "Unable to create a new transaction\n"); - setStatus(taskId, TASK_ERROR); - ERROR_EXIT(rc); + ErrorLog(0, taskId, rc, 0, "Unable to create a new transaction\n"); + setStatus(taskId, TASK_ERROR); + ERROR_EXIT(rc); } intrans = 1; /* Query the backup database for list of volumes to delete */ - for (index=next=0; index!=-1; index=next) { - rc = ubik_Call_SingleServer(BUDB_GetVolumes, udbHandle.uh_client, - UF_SINGLESERVER, BUDB_MAJORVERSION, - BUDB_OP_DUMPID, - tapeName, dumpid, - 0, - index, &next, - &dbTime, &vl); - if (rc) { - if (rc == BUDB_ENDOFLIST) break; - ErrorLog(0, taskId, rc, 0, "Can't find volume info for dump %d\n", dumpid); - setStatus(taskId, TASK_ERROR); - ERROR_EXIT(rc); - } - - /* Delete all volumes on the list */ - for (i=0; i #include -RCSID("$Header$"); +RCSID + ("$Header$"); #ifndef AFS_NT40_ENV #include @@ -23,9 +24,9 @@ RCSID("$Header$"); #include extern int debugLevel; -static struct dumpNode *dumpQHeader; /* ptr to head of the dumpNode list */ -static struct dumpNode headNode; /* the dummy header of the node list */ -static afs_int32 maxTaskID; /* the largest task Id allotted so far, this is never reused */ +static struct dumpNode *dumpQHeader; /* ptr to head of the dumpNode list */ +static struct dumpNode headNode; /* the dummy header of the node list */ +static afs_int32 maxTaskID; /* the largest task Id allotted so far, this is never reused */ /* allocTaskId * allocate a dump (task) id @@ -33,30 +34,32 @@ static afs_int32 maxTaskID; /* the largest task Id allotted so far, this is neve afs_int32 allocTaskId() { - return(maxTaskID++); + return (maxTaskID++); } #ifdef notdef -void static DisplayNode(nodePtr) -struct dumpNode *nodePtr; +void static +DisplayNode(nodePtr) + struct dumpNode *nodePtr; { - TapeLog(99, nodePtr->dumpId, "Created dumpNode"); - return; + TapeLog(99, nodePtr->dumpId, "Created dumpNode"); + return; } #endif /* initialize the node list used to keep track of the active dumps */ -void InitNodeList(portOffset) - afs_int32 portOffset; +void +InitNodeList(portOffset) + afs_int32 portOffset; { - maxTaskID = (portOffset * 1000) + 1; /* this is the first task id alotted */ + maxTaskID = (portOffset * 1000) + 1; /* this is the first task id alotted */ headNode.taskID = -1; headNode.next = NULL; headNode.dumps = (struct tc_dumpDesc *)0; headNode.restores = (struct tc_restoreDesc *)0; - dumpQHeader = &headNode; /* noone in the list to start with */ + dumpQHeader = &headNode; /* noone in the list to start with */ } /* CreateNode @@ -68,11 +71,12 @@ void InitNodeList(portOffset) * newNode ptr set to point to a node. */ -void CreateNode(newNode) -struct dumpNode **newNode; +void +CreateNode(newNode) + struct dumpNode **newNode; { /* get space */ - *newNode = (struct dumpNode *) (malloc (sizeof (struct dumpNode))); + *newNode = (struct dumpNode *)(malloc(sizeof(struct dumpNode))); memset(*newNode, 0, sizeof(struct dumpNode)); @@ -84,49 +88,59 @@ struct dumpNode **newNode; } /* free the space allotted to the node with */ -void FreeNode(taskID) -afs_int32 taskID; +void +FreeNode(taskID) + afs_int32 taskID; { - struct dumpNode *oldPtr,*newPtr,*curPtr; + struct dumpNode *oldPtr, *newPtr, *curPtr; int done; curPtr = dumpQHeader; oldPtr = dumpQHeader; - if(curPtr) newPtr = dumpQHeader->next; - else newPtr = NULL; + if (curPtr) + newPtr = dumpQHeader->next; + else + newPtr = NULL; done = 0; - while((!done) && (curPtr != NULL)) { - if(curPtr->taskID == taskID){ + while ((!done) && (curPtr != NULL)) { + if (curPtr->taskID == taskID) { done = 1; oldPtr->next = newPtr; /* free the node and its structures */ - if(curPtr->dumpName) free(curPtr->dumpName); - if(curPtr->volumeSetName) free(curPtr->volumeSetName); - if(curPtr->restores) free(curPtr->restores); - if(curPtr->dumps) free(curPtr->dumps); + if (curPtr->dumpName) + free(curPtr->dumpName); + if (curPtr->volumeSetName) + free(curPtr->volumeSetName); + if (curPtr->restores) + free(curPtr->restores); + if (curPtr->dumps) + free(curPtr->dumps); free(curPtr); - } - else { + } else { oldPtr = curPtr; curPtr = newPtr; - if(newPtr) newPtr = newPtr->next; + if (newPtr) + newPtr = newPtr->next; } } - return ; - + return; + } -afs_int32 GetNthNode(aindex, aresult) -afs_int32 aindex; -afs_int32 *aresult; { +afs_int32 +GetNthNode(aindex, aresult) + afs_int32 aindex; + afs_int32 *aresult; +{ register struct dumpNode *tn; register int i; tn = dumpQHeader->next; - for(i=0;;i++) { - if (!tn) return ENOENT; + for (i = 0;; i++) { + if (!tn) + return ENOENT; /* see if this is the desired node ID */ if (i == aindex) { *aresult = tn->taskID; @@ -138,23 +152,25 @@ afs_int32 *aresult; { } /* return the node with into */ -afs_int32 GetNode(taskID, resultNode) -afs_int32 taskID; -struct dumpNode **resultNode; +afs_int32 +GetNode(taskID, resultNode) + afs_int32 taskID; + struct dumpNode **resultNode; { struct dumpNode *tmpPtr; int done; done = 0; tmpPtr = dumpQHeader; - while((!done) && (tmpPtr != NULL)) { - if(tmpPtr->taskID == taskID) { + while ((!done) && (tmpPtr != NULL)) { + if (tmpPtr->taskID == taskID) { *resultNode = tmpPtr; done = 1; - } - else + } else tmpPtr = tmpPtr->next; } - if (done) return 0; - else return TC_NODENOTFOUND; + if (done) + return 0; + else + return TC_NODENOTFOUND; } diff --git a/src/butc/lwps.c b/src/butc/lwps.c index bf9f149db..441e8f07b 100644 --- a/src/butc/lwps.c +++ b/src/butc/lwps.c @@ -10,7 +10,8 @@ #include #include -RCSID("$Header$"); +RCSID + ("$Header$"); #include #ifdef AFS_NT40_ENV @@ -29,7 +30,7 @@ RCSID("$Header$"); #include #include #include -#include /* PA */ +#include /* PA */ #include #include #include @@ -46,10 +47,10 @@ extern char *opencallout; extern char *closecallout; extern char *whoami; extern char *extractDumpName(); -extern int BufferSize; /* Size in B stored for header info */ +extern int BufferSize; /* Size in B stored for header info */ extern char *restoretofile; -FILE *restoretofilefd; -extern int forcemultiple; +FILE *restoretofilefd; +extern int forcemultiple; /* XBSA Global Parameters */ afs_int32 xbsaType; @@ -57,13 +58,13 @@ afs_int32 xbsaType; struct butx_transactionInfo butxInfo; #endif -struct TapeBlock { /* A 16KB tapeblock */ - char mark[BUTM_HDRSIZE]; /* Header info */ - char data[BUTM_BLKSIZE]; /* data */ +struct TapeBlock { /* A 16KB tapeblock */ + char mark[BUTM_HDRSIZE]; /* Header info */ + char data[BUTM_BLKSIZE]; /* data */ } *bufferBlock; -afs_int32 dataSize; /* Size of data to read on each xbsa_ReadObjectData() call (CONF_XBSA) */ -afs_int32 tapeblocks; /* Number of tape datablocks in buffer (!CONF_XBSA) */ +afs_int32 dataSize; /* Size of data to read on each xbsa_ReadObjectData() call (CONF_XBSA) */ +afs_int32 tapeblocks; /* Number of tape datablocks in buffer (!CONF_XBSA) */ /* notes * Need to re-write to: @@ -74,17 +75,16 @@ afs_int32 tapeblocks; /* Number of tape datablocks in buffer (!CONF_XBSA) * */ /* All the relevant info shared between Restorer and restoreVolume */ -struct restoreParams -{ - struct dumpNode *nodePtr; - afs_int32 frag; - char mntTapeName[BU_MAXTAPELEN]; - afs_int32 tapeID; +struct restoreParams { + struct dumpNode *nodePtr; + afs_int32 frag; + char mntTapeName[BU_MAXTAPELEN]; + afs_int32 tapeID; struct butm_tapeInfo *tapeInfoPtr; }; /* Abort checks are done after each BIGCHUNK of data transfer */ -#define BIGCHUNK 102400 +#define BIGCHUNK 102400 #define HEADER_CHECKS(vhptr, header) \ { \ @@ -106,13 +106,13 @@ struct restoreParams return (0); \ } /* magic */ \ } /* versionflags */ \ -} +} extern FILE *logIO; extern FILE *ErrorlogIO; extern FILE *centralLogIO; extern FILE *lastLogIO; -extern afs_int32 lastPass; /* Set true during last pass of dump */ +extern afs_int32 lastPass; /* Set true during last pass of dump */ extern int debugLevel; extern int autoQuery; extern struct tapeConfig globalTapeConfig; @@ -122,55 +122,78 @@ struct timeval tp; struct timezone tzp; /* forward declaration */ -afs_int32 readVolumeHeader(/*char *buffer,afs_int32 bufloc,(struct volumeHeader *)vhptr*/); +afs_int32 readVolumeHeader( /*char *buffer,afs_int32 bufloc,(struct volumeHeader *)vhptr */ ); /* The on-disk volume header or trailer can differ in size from platform to platform */ struct TapeBlock tapeBlock; -char tapeVolumeHT[sizeof(struct volumeHeader) + 2*sizeof(char)]; +char tapeVolumeHT[sizeof(struct volumeHeader) + 2 * sizeof(char)]; -void -PrintLog(log, error1, error2, str, a,b,c,d,e,f,g,h,i,j) - FILE *log; - afs_int32 error1, error2; - char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; +void +PrintLog(log, error1, error2, str, a, b, c, d, e, f, g, h, i, j) + FILE *log; + afs_int32 error1, error2; + char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; { char *err1, *err2; - fprintf(log, str, a,b,c,d,e,f,g,h,i,j); - if (error1) - { - err2 = "vols"; - switch (error1) - { - case VSALVAGE: err1 = "Volume needs to be salvaged"; break; - case VNOVNODE: err1 = "Bad vnode number quoted"; break; - case VNOVOL: err1 = "Volume not attached, does not exist, or not on line"; break; - case VVOLEXISTS: err1 = "Volume already exists"; break; - case VNOSERVICE: err1 = "Volume is not in service"; break; - case VOFFLINE: err1 = "Volume is off line"; break; - case VONLINE: err1 = "Volume is already on line"; break; - case VDISKFULL: err1 = "Partition is full"; break; - case VOVERQUOTA: err1 = "Volume max quota exceeded"; break; - case VBUSY: err1 = "Volume temporarily unavailable"; break; - case VMOVED: err1 = "Volume has moved to another server"; break; - default: - err1 = (char *)error_message(error1); - err2 = (char *)error_table_name(error1); - break; + fprintf(log, str, a, b, c, d, e, f, g, h, i, j); + if (error1) { + err2 = "vols"; + switch (error1) { + case VSALVAGE: + err1 = "Volume needs to be salvaged"; + break; + case VNOVNODE: + err1 = "Bad vnode number quoted"; + break; + case VNOVOL: + err1 = "Volume not attached, does not exist, or not on line"; + break; + case VVOLEXISTS: + err1 = "Volume already exists"; + break; + case VNOSERVICE: + err1 = "Volume is not in service"; + break; + case VOFFLINE: + err1 = "Volume is off line"; + break; + case VONLINE: + err1 = "Volume is already on line"; + break; + case VDISKFULL: + err1 = "Partition is full"; + break; + case VOVERQUOTA: + err1 = "Volume max quota exceeded"; + break; + case VBUSY: + err1 = "Volume temporarily unavailable"; + break; + case VMOVED: + err1 = "Volume has moved to another server"; + break; + default: + err1 = (char *)error_message(error1); + err2 = (char *)error_table_name(error1); + break; } - if (error1 == -1) fprintf(log, " Possible communication failure"); - else fprintf(log, " %s: %s", err2, err1); - if (error2) fprintf(log, ": %s", error_message(error2)); + if (error1 == -1) + fprintf(log, " Possible communication failure"); + else + fprintf(log, " %s: %s", err2, err1); + if (error2) + fprintf(log, ": %s", error_message(error2)); fprintf(log, "\n"); } fflush(log); } void -TapeLog(debug, task, error1, error2, str, a,b,c,d,e,f,g,h,i,j) - int debug; - afs_int32 task, error1, error2; - char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; +TapeLog(debug, task, error1, error2, str, a, b, c, d, e, f, g, h, i, j) + int debug; + afs_int32 task, error1, error2; + char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; { time_t now; char tbuffer[32], *timestr; @@ -180,34 +203,37 @@ TapeLog(debug, task, error1, error2, str, a,b,c,d,e,f,g,h,i,j) timestr[24] = '\0'; fprintf(logIO, "%s: ", timestr); - if (task) fprintf(logIO, "Task %u: ", task); - PrintLog(logIO, error1, error2, str, a,b,c,d,e,f,g,h,i,j); + if (task) + fprintf(logIO, "Task %u: ", task); + PrintLog(logIO, error1, error2, str, a, b, c, d, e, f, g, h, i, j); if (lastPass && lastLogIO) { - fprintf(lastLogIO, "%s: ", timestr); - if (task) fprintf(lastLogIO, "Task %u: ", task); - PrintLog(lastLogIO, error1, error2, str, a,b,c,d,e,f,g,h,i,j); + fprintf(lastLogIO, "%s: ", timestr); + if (task) + fprintf(lastLogIO, "Task %u: ", task); + PrintLog(lastLogIO, error1, error2, str, a, b, c, d, e, f, g, h, i, + j); } /* Now print to the screen if debug level requires */ if (debug <= debugLevel) - PrintLog(stdout, error1, error2, str, a,b,c,d,e,f,g,h,i,j); + PrintLog(stdout, error1, error2, str, a, b, c, d, e, f, g, h, i, j); } void -TLog(task, str, a,b,c,d,e,f,g,h,i,j) - afs_int32 task; - char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; +TLog(task, str, a, b, c, d, e, f, g, h, i, j) + afs_int32 task; + char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; { /* Sends message to TapeLog and stdout */ - TapeLog (0, task, 0,0, str, a,b,c,d,e,f,g,h,i,j); + TapeLog(0, task, 0, 0, str, a, b, c, d, e, f, g, h, i, j); } -void -ErrorLog(debug, task, error1, error2, str, a,b,c,d,e,f,g,h,i,j) - int debug; - afs_int32 task, error1, error2; - char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; +void +ErrorLog(debug, task, error1, error2, str, a, b, c, d, e, f, g, h, i, j) + int debug; + afs_int32 task, error1, error2; + char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; { time_t now; char tbuffer[32], *timestr; @@ -218,39 +244,42 @@ ErrorLog(debug, task, error1, error2, str, a,b,c,d,e,f,g,h,i,j) fprintf(ErrorlogIO, "%s: ", timestr); /* Print the time and task number */ - if (task) fprintf(ErrorlogIO, "Task %u: ", task); - PrintLog(ErrorlogIO, error1, error2, str, a,b,c,d,e,f,g,h,i,j); + if (task) + fprintf(ErrorlogIO, "Task %u: ", task); + PrintLog(ErrorlogIO, error1, error2, str, a, b, c, d, e, f, g, h, i, j); - TapeLog(debug, task, error1, error2, str, a,b,c,d,e,f,g,h,i,j); + TapeLog(debug, task, error1, error2, str, a, b, c, d, e, f, g, h, i, j); } void -ELog(task, str, a,b,c,d,e,f,g,h,i,j) - afs_int32 task; - char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; +ELog(task, str, a, b, c, d, e, f, g, h, i, j) + afs_int32 task; + char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j; { /* Sends message to ErrorLog, TapeLog and stdout */ - ErrorLog (0, task, 0,0, str, a,b,c,d,e,f,g,h,i,j); + ErrorLog(0, task, 0, 0, str, a, b, c, d, e, f, g, h, i, j); } /* first proc called by anybody who intends to use the device */ -void EnterDeviceQueue(devLatch) -struct deviceSyncNode *devLatch; +void +EnterDeviceQueue(devLatch) + struct deviceSyncNode *devLatch; { ObtainWriteLock(&(devLatch->lock)); devLatch->flags = TC_DEVICEINUSE; } /* last proc called by anybody finishing using the device */ -void LeaveDeviceQueue(devLatch) -struct deviceSyncNode *devLatch; +void +LeaveDeviceQueue(devLatch) + struct deviceSyncNode *devLatch; { devLatch->flags = 0; ReleaseWriteLock(&(devLatch->lock)); } -#define BELLTIME 60 /* 60 seconds before a bell rings */ -#define BELLCHAR 7 /* ascii for bell */ +#define BELLTIME 60 /* 60 seconds before a bell rings */ +#define BELLCHAR 7 /* ascii for bell */ #ifdef AFS_PTHREAD_ENV @@ -267,41 +296,45 @@ struct deviceSyncNode *devLatch; * * STOLEN FROM LWP_WaitForKeystroke() */ -int WaitForKeystroke(int seconds) +int +WaitForKeystroke(int seconds) { - time_t startTime, nowTime; - double timeleft = 1; - struct timeval twait; - - time(&startTime); - twait.tv_sec = 0; - twait.tv_usec = 250; - if (seconds >= 0) - timeleft = seconds; - - do { - /* check if we have a keystroke */ - if (_kbhit()) return 1; - if (timeleft == 0) break; - - /* sleep for LWP_KEYSTROKE_DELAY ms and let other - * process run some*/ - select(0, 0, 0, 0, &twait); - - if (seconds > 0) { /* we only worry about elapsed time if - * not looping forever (seconds < 0) */ - time(&nowTime); - timeleft = seconds - difftime(nowTime, startTime); - } - } while(timeleft > 0); - return 0; + time_t startTime, nowTime; + double timeleft = 1; + struct timeval twait; + + time(&startTime); + twait.tv_sec = 0; + twait.tv_usec = 250; + if (seconds >= 0) + timeleft = seconds; + + do { + /* check if we have a keystroke */ + if (_kbhit()) + return 1; + if (timeleft == 0) + break; + + /* sleep for LWP_KEYSTROKE_DELAY ms and let other + * process run some*/ + select(0, 0, 0, 0, &twait); + + if (seconds > 0) { /* we only worry about elapsed time if + * not looping forever (seconds < 0) */ + time(&nowTime); + timeleft = seconds - difftime(nowTime, startTime); + } + } while (timeleft > 0); + return 0; } #else /* AFS_NT40)ENV */ extern int WaitForKeystroke(int); /* * STOLEN FROM LWP_WaitForKeystroke() */ -int WaitForKeystroke(int seconds) +int +WaitForKeystroke(int seconds) { fd_set rdfds; int code; @@ -318,12 +351,12 @@ int WaitForKeystroke(int seconds) FD_ZERO(&rdfds); FD_SET(fileno(stdin), &rdfds); - if (seconds>=0) { + if (seconds >= 0) { twait.tv_sec = seconds; twait.tv_usec = 0; tp = &twait; } - code = select(1+fileno(stdin), &rdfds, NULL, NULL, tp); + code = select(1 + fileno(stdin), &rdfds, NULL, NULL, tp); return (code == 1) ? 1 : 0; } #endif @@ -339,173 +372,172 @@ int WaitForKeystroke(int seconds) * * STOLEN FROM LWP_GetResponseKey(); */ -int GetResponseKey(int seconds, char *key) +int +GetResponseKey(int seconds, char *key) { - int rc; - - if (key == NULL) return 0; /* need space to store char */ - fflush(stdin); /* flush all existing data and start anew */ - - rc = WaitForKeystroke(seconds); - if (rc == 0) { /* time ran out */ - *key = 0; - return rc; - } - - /* now read the char. */ + int rc; + + if (key == NULL) + return 0; /* need space to store char */ + fflush(stdin); /* flush all existing data and start anew */ + + rc = WaitForKeystroke(seconds); + if (rc == 0) { /* time ran out */ + *key = 0; + return rc; + } + + /* now read the char. */ #ifdef AFS_NT40_ENV - *key = getche(); /* get char and echo it to screen */ + *key = getche(); /* get char and echo it to screen */ #else - *key = getchar(); + *key = getchar(); #endif - return rc; + return rc; } #endif /* AFS_PTHREAD_ENV - -/* FFlushInput - * flush all input - * notes: - * only external clients are in recoverDb.c. Was static. PA - */ + * + * /* FFlushInput + * * flush all input + * * notes: + * * only external clients are in recoverDb.c. Was static. PA + */ FFlushInput() { - int w; + int w; - fflush(stdin); + fflush(stdin); - while(1) { + while (1) { #ifdef AFS_PTHREAD_ENV - w = WaitForKeystroke(0); + w = WaitForKeystroke(0); #else - w = LWP_WaitForKeystroke(0); + w = LWP_WaitForKeystroke(0); #endif /* AFS_PTHREAD_ENV */ - if (w) { + if (w) { #ifdef AFS_NT40_ENV - getche(); + getche(); #else - getchar(); + getchar(); #endif /* AFS_NT40_ENV */ - } else { - return; - } - } + } else { + return; + } + } } -int callOutRoutine(taskId, tapePath, flag, name, dbDumpId, tapecount) - afs_int32 taskId; - char *tapePath; - int flag; - char *name; - afs_uint32 dbDumpId; - int tapecount; +int +callOutRoutine(taskId, tapePath, flag, name, dbDumpId, tapecount) + afs_int32 taskId; + char *tapePath; + int flag; + char *name; + afs_uint32 dbDumpId; + int tapecount; { - afs_int32 count; + afs_int32 count; - afs_int32 code = 0; - int pid; + afs_int32 code = 0; + int pid; - char StapePath[256]; - char ScallOut[256]; - char Scount[10]; - char Sopcode[16]; - char Sdumpid[16]; - char Stape[40]; - char *callOut; + char StapePath[256]; + char ScallOut[256]; + char Scount[10]; + char Sopcode[16]; + char Sdumpid[16]; + char Stape[40]; + char *callOut; - char *CO_argv[10]; - char *CO_envp[1]; + char *CO_argv[10]; + char *CO_envp[1]; - callOut = opencallout; - switch ( flag ) - { - case READOPCODE: - strcpy(Sopcode, "restore"); - break; + callOut = opencallout; + switch (flag) { + case READOPCODE: + strcpy(Sopcode, "restore"); + break; case APPENDOPCODE: - strcpy(Sopcode, "appenddump"); - break; + strcpy(Sopcode, "appenddump"); + break; case WRITEOPCODE: - strcpy(Sopcode, "dump"); - break; + strcpy(Sopcode, "dump"); + break; case LABELOPCODE: - strcpy(Sopcode, "labeltape"); - break; + strcpy(Sopcode, "labeltape"); + break; case READLABELOPCODE: - strcpy(Sopcode, "readlabel"); - break; + strcpy(Sopcode, "readlabel"); + break; case SCANOPCODE: - strcpy(Sopcode, "scantape"); - break; + strcpy(Sopcode, "scantape"); + break; case RESTOREDBOPCODE: - strcpy(Sopcode, "restoredb"); - break; + strcpy(Sopcode, "restoredb"); + break; case SAVEDBOPCODE: - strcpy(Sopcode, "savedb"); - break; + strcpy(Sopcode, "savedb"); + break; case CLOSEOPCODE: - strcpy(Sopcode, "unmount"); - callOut = closecallout; - break; + strcpy(Sopcode, "unmount"); + callOut = closecallout; + break; default: - strcpy(Sopcode, "unknown"); - break; + strcpy(Sopcode, "unknown"); + break; } - - if (!callOut) /* no script to call */ - return 0; - - strcpy(ScallOut, callOut); - CO_argv[0] = ScallOut; - - strcpy(StapePath, tapePath); - CO_argv[1] = StapePath; - - CO_argv[2] = Sopcode; - - if (flag == CLOSEOPCODE) - { - CO_argv[3] = NULL; - } - else - { - sprintf(Scount, "%d", tapecount); - CO_argv[3] = Scount; - - /* The tape label name - special case labeltape */ - if ( !name || (strcmp(name,"") == 0) ) /* no label */ - strcpy(Stape, "none"); - else { /* labeltape */ + + if (!callOut) /* no script to call */ + return 0; + + strcpy(ScallOut, callOut); + CO_argv[0] = ScallOut; + + strcpy(StapePath, tapePath); + CO_argv[1] = StapePath; + + CO_argv[2] = Sopcode; + + if (flag == CLOSEOPCODE) { + CO_argv[3] = NULL; + } else { + sprintf(Scount, "%d", tapecount); + CO_argv[3] = Scount; + + /* The tape label name - special case labeltape */ + if (!name || (strcmp(name, "") == 0)) /* no label */ + strcpy(Stape, "none"); + else { /* labeltape */ #ifdef AFS_NT40_ENV - if (!strcmp(name, TC_NULLTAPENAME)) /* pass "" instead of */ - strcpy(Stape, TC_QUOTEDNULLTAPENAME); - else + if (!strcmp(name, TC_NULLTAPENAME)) /* pass "" instead of */ + strcpy(Stape, TC_QUOTEDNULLTAPENAME); + else #endif - strcpy(Stape, name); - } - CO_argv[4] = Stape; - - /* The tape id */ - if (!dbDumpId) - strcpy(Sdumpid, "none"); - else - sprintf(Sdumpid, "%u", dbDumpId); - CO_argv[5] = Sdumpid; - - CO_argv[6] = NULL; - } - - CO_envp[0] = NULL; - - pid = spawnprocve(callOut, CO_argv, CO_envp, 2); - if (pid < 0) { - ErrorLog(0, taskId, errno, 0, "Call to %s outside routine %s failed\n", - Sopcode, callOut); - return 0; - } - - return(pid); + strcpy(Stape, name); + } + CO_argv[4] = Stape; + + /* The tape id */ + if (!dbDumpId) + strcpy(Sdumpid, "none"); + else + sprintf(Sdumpid, "%u", dbDumpId); + CO_argv[5] = Sdumpid; + + CO_argv[6] = NULL; + } + + CO_envp[0] = NULL; + + pid = spawnprocve(callOut, CO_argv, CO_envp, 2); + if (pid < 0) { + ErrorLog(0, taskId, errno, 0, + "Call to %s outside routine %s failed\n", Sopcode, callOut); + return 0; + } + + return (pid); } /* @@ -515,34 +547,35 @@ int callOutRoutine(taskId, tapePath, flag, name, dbDumpId, tapecount) * (unless a tape is not mounted in the first place). */ unmountTape(taskId, tapeInfoPtr) - afs_int32 taskId; - struct butm_tapeInfo *tapeInfoPtr; + afs_int32 taskId; + struct butm_tapeInfo *tapeInfoPtr; { afs_int32 code; - afs_int32 wcode; + afs_int32 wcode; int cpid, status, rcpid; code = butm_Dismount(tapeInfoPtr); - if (code && (code != BUTM_NOMOUNT)) - ErrorLog(0, taskId, code, (tapeInfoPtr)->error, "Warning: Can't close tape\n"); + if (code && (code != BUTM_NOMOUNT)) + ErrorLog(0, taskId, code, (tapeInfoPtr)->error, + "Warning: Can't close tape\n"); - if (tapemounted && closecallout) - { - setStatus(taskId, CALL_WAIT); + if (tapemounted && closecallout) { + setStatus(taskId, CALL_WAIT); - cpid = callOutRoutine(taskId, globalTapeConfig.device, CLOSEOPCODE, "", 0, 1); - while (cpid) /* Wait until return */ - { + cpid = + callOutRoutine(taskId, globalTapeConfig.device, CLOSEOPCODE, "", + 0, 1); + while (cpid) { /* Wait until return */ status = 0; rcpid = waitpid(cpid, &status, WNOHANG); - if (rcpid > 0) - { - tapemounted = 0; + if (rcpid > 0) { + tapemounted = 0; break; } if (rcpid == -1 && errno != EINTR) { - tapemounted = 0; - com_err(whoami, errno, "Error waiting for callout script to terminate."); + tapemounted = 0; + com_err(whoami, errno, + "Error waiting for callout script to terminate."); break; } #ifdef AFS_PTHREAD_ENV @@ -551,11 +584,11 @@ unmountTape(taskId, tapeInfoPtr) IOMGR_Sleep(1); #endif - if ( checkAbortByTaskId(taskId) ) - { + if (checkAbortByTaskId(taskId)) { TLog(taskId, "Callout routine has been aborted\n"); - if (kill(cpid, SIGKILL)) /* Cancel callout */ - ErrorLog(0, taskId, errno, 0, "Kill of callout process %d failed\n", cpid); + if (kill(cpid, SIGKILL)) /* Cancel callout */ + ErrorLog(0, taskId, errno, 0, + "Kill of callout process %d failed\n", cpid); break; } } @@ -571,36 +604,36 @@ unmountTape(taskId, tapeInfoPtr) void static PrintPrompt(flag, name, dumpid) - int flag; - char *name; + int flag; + char *name; { - char tapename[BU_MAXTAPELEN+32]; - char *dn; + char tapename[BU_MAXTAPELEN + 32]; + char *dn; TAPENAME(tapename, name, dumpid); printf("******* OPERATOR ATTENTION *******\n"); - printf("Device : %s \n",globalTapeConfig.device); + printf("Device : %s \n", globalTapeConfig.device); - switch ( flag ) - { - case READOPCODE: /* mount for restore */ - printf("Please put in tape %s for reading", tapename); + switch (flag) { + case READOPCODE: /* mount for restore */ + printf("Please put in tape %s for reading", tapename); break; - case APPENDOPCODE: /* mount for dump (appends) */ + case APPENDOPCODE: /* mount for dump (appends) */ dn = extractDumpName(name); if (!dn || !dumpid) printf("Please put in last tape of dump set for appending dump"); else - printf("Please put in last tape of dump set for appending dump %s (DumpID %u)", - dn, dumpid); + printf + ("Please put in last tape of dump set for appending dump %s (DumpID %u)", + dn, dumpid); break; - case WRITEOPCODE: /* mount for dump */ - if (strcmp(name,"") == 0) + case WRITEOPCODE: /* mount for dump */ + if (strcmp(name, "") == 0) printf("Please put in tape for writing"); /* The name is what we are going to label the tape as */ @@ -608,30 +641,31 @@ PrintPrompt(flag, name, dumpid) printf("Please put in tape %s for writing", tapename); break; - case LABELOPCODE: /* mount for labeltape */ + case LABELOPCODE: /* mount for labeltape */ printf("Please put in tape to be labelled as %s", tapename); break; - case READLABELOPCODE: /* mount for readlabel */ + case READLABELOPCODE: /* mount for readlabel */ printf("Please put in tape whose label is to be read"); break; - case SCANOPCODE: /* mount for scantape */ - if (strcmp(name,"") == 0) + case SCANOPCODE: /* mount for scantape */ + if (strcmp(name, "") == 0) printf("Please put in tape to be scanned"); else printf("Please put in tape %s for scanning", tapename); break; - case RESTOREDBOPCODE: /* Mount for restoredb */ + case RESTOREDBOPCODE: /* Mount for restoredb */ printf("Please insert a tape %s for the database restore", tapename); break; - case SAVEDBOPCODE: /* Mount for savedb */ - printf("Please insert a writeable tape %s for the database dump", tapename); + case SAVEDBOPCODE: /* Mount for savedb */ + printf("Please insert a writeable tape %s for the database dump", + tapename); break; - default: + default: break; } printf(" and hit return when done\n"); @@ -644,73 +678,73 @@ PrintPrompt(flag, name, dumpid) * notes: * only external clients are in recoverDb.c. Was static PA */ -afs_int32 PromptForTape(flag, name, dbDumpId, taskId, tapecount) - int flag; - char *name; - afs_uint32 dbDumpId; /* Specific dump ID - If non-zero */ - afs_uint32 taskId; - int tapecount; +afs_int32 +PromptForTape(flag, name, dbDumpId, taskId, tapecount) + int flag; + char *name; + afs_uint32 dbDumpId; /* Specific dump ID - If non-zero */ + afs_uint32 taskId; + int tapecount; { register afs_int32 code = 0; - afs_int32 wcode; - afs_int32 start = 0; - char inchr; - int CallOut; - int cpid, status, rcpid; + afs_int32 wcode; + afs_int32 start = 0; + char inchr; + int CallOut; + int cpid, status, rcpid; - if ( checkAbortByTaskId(taskId) ) - ERROR_EXIT(TC_ABORTEDBYREQUEST); + if (checkAbortByTaskId(taskId)) + ERROR_EXIT(TC_ABORTEDBYREQUEST); if (dbDumpId) - TapeLog(2, taskId, 0, 0, "Prompt for tape %s (%u)\n", name, dbDumpId); + TapeLog(2, taskId, 0, 0, "Prompt for tape %s (%u)\n", name, dbDumpId); else - TapeLog(2, taskId, 0, 0, "Prompt for tape %s\n", name); + TapeLog(2, taskId, 0, 0, "Prompt for tape %s\n", name); CallOut = (opencallout ? 1 : 0); - if (CallOut) - { - setStatus(taskId, CALL_WAIT); + if (CallOut) { + setStatus(taskId, CALL_WAIT); - cpid = callOutRoutine(taskId, globalTapeConfig.device, flag, name, dbDumpId, tapecount); - if (cpid == 0) CallOut = 0; /* prompt at screen */ + cpid = + callOutRoutine(taskId, globalTapeConfig.device, flag, name, + dbDumpId, tapecount); + if (cpid == 0) + CallOut = 0; /* prompt at screen */ - while (CallOut) - { /* Check if callout routine finished */ + while (CallOut) { /* Check if callout routine finished */ status = 0; rcpid = waitpid(cpid, &status, WNOHANG); - if (rcpid > 0) - { - if (rcpid != cpid) - wcode = -1; - else if (WIFEXITED(status)) - wcode = WEXITSTATUS(status); - else - wcode = -1; - - if (wcode == 0) - { - break; /* All done */ - } - else if (wcode == 1) - { - ERROR_EXIT(TC_ABORTEDBYREQUEST); /* Abort */ - } - else if ( (flag == READOPCODE) && (wcode == 3) ) { - ERROR_EXIT(TC_SKIPTAPE); /* Restore: skip the tape */ - } + if (rcpid > 0) { + if (rcpid != cpid) + wcode = -1; + else if (WIFEXITED(status)) + wcode = WEXITSTATUS(status); else - { - TLog(taskId, "Callout routine has exited with code %d: will prompt\n", wcode); - CallOut = 0; /* Switch to keyboard input */ + wcode = -1; + + if (wcode == 0) { + break; /* All done */ + } else if (wcode == 1) { + ERROR_EXIT(TC_ABORTEDBYREQUEST); /* Abort */ + } else if ((flag == READOPCODE) && (wcode == 3)) { + ERROR_EXIT(TC_SKIPTAPE); /* Restore: skip the tape */ + } else { + TLog(taskId, + "Callout routine has exited with code %d: will prompt\n", + wcode); + CallOut = 0; /* Switch to keyboard input */ break; } } /* if waitpid experienced an error, we prompt */ if (rcpid == -1 && errno != EINTR) { - com_err(whoami, errno, "Error waiting for callout script to terminate."); - TLog(taskId, "Can't get exit status from callout script. will prompt\n", wcode); - CallOut = 0; - break; + com_err(whoami, errno, + "Error waiting for callout script to terminate."); + TLog(taskId, + "Can't get exit status from callout script. will prompt\n", + wcode); + CallOut = 0; + break; } #ifdef AFS_PTHREAD_ENV sleep(1); @@ -718,55 +752,54 @@ afs_int32 PromptForTape(flag, name, dbDumpId, taskId, tapecount) IOMGR_Sleep(1); #endif - if ( checkAbortByTaskId(taskId) ) - { - printf("This tape operation has been aborted by the coordinator.\n"); + if (checkAbortByTaskId(taskId)) { + printf + ("This tape operation has been aborted by the coordinator.\n"); - if (kill(cpid, SIGKILL)) /* Cancel callout */ - ErrorLog(0, taskId, errno, 0, "Kill of callout process %d failed\n", cpid); + if (kill(cpid, SIGKILL)) /* Cancel callout */ + ErrorLog(0, taskId, errno, 0, + "Kill of callout process %d failed\n", cpid); ERROR_EXIT(TC_ABORTEDBYREQUEST); } } } - if (!CallOut) - { - clearStatus(taskId, CALL_WAIT); - setStatus(taskId, OPR_WAIT); + if (!CallOut) { + clearStatus(taskId, CALL_WAIT); + setStatus(taskId, OPR_WAIT); - PrintPrompt(flag, name, dbDumpId); + PrintPrompt(flag, name, dbDumpId); /* Loop until we get ok to go ahead (or abort) */ - while(1) - { - if ( time(0) > start+BELLTIME ) - { - start = time(0); + while (1) { + if (time(0) > start + BELLTIME) { + start = time(0); FFlushInput(stdin); putchar(BELLCHAR); fflush(stdout); } - #ifdef AFS_PTHREAD_ENV - wcode = GetResponseKey(5, &inchr); /* inchr stores key read */ + wcode = GetResponseKey(5, &inchr); /* inchr stores key read */ #else - wcode = LWP_GetResponseKey(5, &inchr); /* inchr stores key read */ + wcode = LWP_GetResponseKey(5, &inchr); /* inchr stores key read */ #endif - if (wcode == 1) { /* keyboard input is available */ + if (wcode == 1) { /* keyboard input is available */ - if ( (inchr == 'a') || (inchr == 'A') ) { + if ((inchr == 'a') || (inchr == 'A')) { printf("This tape operation has been aborted.\n"); - ERROR_EXIT(TC_ABORTEDBYREQUEST); /* Abort command */ - } else if ( (flag == READOPCODE) && ((inchr == 's') || (inchr == 'S')) ) { + ERROR_EXIT(TC_ABORTEDBYREQUEST); /* Abort command */ + } else if ((flag == READOPCODE) + && ((inchr == 's') || (inchr == 'S'))) { printf("This tape will be skipped.\n"); - ERROR_EXIT(TC_SKIPTAPE); /* Restore: skip the tape */ + ERROR_EXIT(TC_SKIPTAPE); /* Restore: skip the tape */ } - break; /* continue */ + break; /* continue */ } - if ( checkAbortByTaskId(taskId) ) { - printf("This tape operation has been aborted by the coordinator.\n"); + if (checkAbortByTaskId(taskId)) { + printf + ("This tape operation has been aborted by the coordinator.\n"); ERROR_EXIT(TC_ABORTEDBYREQUEST); } } @@ -774,49 +807,48 @@ afs_int32 PromptForTape(flag, name, dbDumpId, taskId, tapecount) } printf("Thanks, now proceeding with tape "); - switch (flag) - { - case RESTOREDBOPCODE: - case READOPCODE: + switch (flag) { + case RESTOREDBOPCODE: + case READOPCODE: printf("reading"); break; - case APPENDOPCODE: + case APPENDOPCODE: printf("append writing"); break; - case SAVEDBOPCODE: - case WRITEOPCODE: + case SAVEDBOPCODE: + case WRITEOPCODE: printf("writing"); break; - case LABELOPCODE: + case LABELOPCODE: printf("labelling"); break; - case READLABELOPCODE: + case READLABELOPCODE: printf("label reading"); break; - case SCANOPCODE: + case SCANOPCODE: printf("scanning"); break; - - default: + + default: printf("unknown"); break; } printf(" operation.\n"); if (!CallOut) - printf("**********************************\n"); + printf("**********************************\n"); TapeLog(2, taskId, 0, 0, "Proceeding with tape operation\n"); tapemounted = 1; -error_exit: + error_exit: clearStatus(taskId, (OPR_WAIT | CALL_WAIT)); - return(code); + return (code); } @@ -834,353 +866,370 @@ afs_int32 VolHeaderToHost(hostVolHeader, tapeVolHeader) struct volumeHeader *hostVolHeader, *tapeVolHeader; { - switch ( ntohl(tapeVolHeader->versionflags) ) - { - case TAPE_VERSION_0: - /* sizes in bytes and fields in host order */ - memcpy(tapeVolHeader, hostVolHeader, sizeof(struct volumeHeader)); - break; + switch (ntohl(tapeVolHeader->versionflags)) { + case TAPE_VERSION_0: + /* sizes in bytes and fields in host order */ + memcpy(tapeVolHeader, hostVolHeader, sizeof(struct volumeHeader)); + break; - case TAPE_VERSION_1: - case TAPE_VERSION_2: - case TAPE_VERSION_3: /* for present */ - case TAPE_VERSION_4: - /* sizes in K and fields in network order */ - /* do the conversion field by field */ - - strcpy(hostVolHeader->preamble, tapeVolHeader->preamble); - strcpy(hostVolHeader->postamble, tapeVolHeader->postamble); - strcpy(hostVolHeader->volumeName, tapeVolHeader->volumeName); - strcpy(hostVolHeader->dumpSetName, tapeVolHeader->dumpSetName); - hostVolHeader->volumeID = ntohl(tapeVolHeader->volumeID); - hostVolHeader->server = ntohl(tapeVolHeader->server); - hostVolHeader->part = ntohl(tapeVolHeader->part); - hostVolHeader->from = ntohl(tapeVolHeader->from); - hostVolHeader->frag = ntohl(tapeVolHeader->frag); - hostVolHeader->magic = ntohl(tapeVolHeader->magic); - hostVolHeader->contd = ntohl(tapeVolHeader->contd); - hostVolHeader->dumpID = ntohl(tapeVolHeader->dumpID); - hostVolHeader->level = ntohl(tapeVolHeader->level); - hostVolHeader->parentID = ntohl(tapeVolHeader->parentID); - hostVolHeader->endTime = ntohl(tapeVolHeader->endTime); - hostVolHeader->versionflags = ntohl(tapeVolHeader->versionflags); - hostVolHeader->cloneDate = ntohl(tapeVolHeader->cloneDate); - break; + case TAPE_VERSION_1: + case TAPE_VERSION_2: + case TAPE_VERSION_3: /* for present */ + case TAPE_VERSION_4: + /* sizes in K and fields in network order */ + /* do the conversion field by field */ + + strcpy(hostVolHeader->preamble, tapeVolHeader->preamble); + strcpy(hostVolHeader->postamble, tapeVolHeader->postamble); + strcpy(hostVolHeader->volumeName, tapeVolHeader->volumeName); + strcpy(hostVolHeader->dumpSetName, tapeVolHeader->dumpSetName); + hostVolHeader->volumeID = ntohl(tapeVolHeader->volumeID); + hostVolHeader->server = ntohl(tapeVolHeader->server); + hostVolHeader->part = ntohl(tapeVolHeader->part); + hostVolHeader->from = ntohl(tapeVolHeader->from); + hostVolHeader->frag = ntohl(tapeVolHeader->frag); + hostVolHeader->magic = ntohl(tapeVolHeader->magic); + hostVolHeader->contd = ntohl(tapeVolHeader->contd); + hostVolHeader->dumpID = ntohl(tapeVolHeader->dumpID); + hostVolHeader->level = ntohl(tapeVolHeader->level); + hostVolHeader->parentID = ntohl(tapeVolHeader->parentID); + hostVolHeader->endTime = ntohl(tapeVolHeader->endTime); + hostVolHeader->versionflags = ntohl(tapeVolHeader->versionflags); + hostVolHeader->cloneDate = ntohl(tapeVolHeader->cloneDate); + break; - default: - return(TC_BADVOLHEADER); + default: + return (TC_BADVOLHEADER); } - return(0); + return (0); } - + afs_int32 ReadVolHeader(taskId, tapeInfoPtr, volHeaderPtr) - afs_int32 taskId; - struct butm_tapeInfo *tapeInfoPtr; - struct volumeHeader *volHeaderPtr; + afs_int32 taskId; + struct butm_tapeInfo *tapeInfoPtr; + struct volumeHeader *volHeaderPtr; { - afs_int32 code = 0; - afs_int32 nbytes; + afs_int32 code = 0; + afs_int32 nbytes; struct volumeHeader volHead; /* Read the volume header */ - code = butm_ReadFileData(tapeInfoPtr, tapeBlock.data, sizeof(tapeVolumeHT), &nbytes); + code = + butm_ReadFileData(tapeInfoPtr, tapeBlock.data, sizeof(tapeVolumeHT), + &nbytes); if (code) { - ErrorLog(0, taskId, code, tapeInfoPtr->error, "Can't read volume header on tape\n"); + ErrorLog(0, taskId, code, tapeInfoPtr->error, + "Can't read volume header on tape\n"); ERROR_EXIT(code); } code = readVolumeHeader(tapeBlock.data, 0L, &volHead); - if (code) - { - ErrorLog(0, taskId, code, 0, "Can't find volume header on tape block\n"); + if (code) { + ErrorLog(0, taskId, code, 0, + "Can't find volume header on tape block\n"); ERROR_EXIT(code); } code = VolHeaderToHost(volHeaderPtr, &volHead); - if (code) - { - ErrorLog(0, taskId, code, 0, "Can't convert volume header\n"); + if (code) { + ErrorLog(0, taskId, code, 0, "Can't convert volume header\n"); ERROR_EXIT(code); } -error_exit: + error_exit: return code; } afs_int32 static GetVolumeHead(taskId, tapeInfoPtr, position, volName, volId) - afs_int32 taskId; - struct butm_tapeInfo *tapeInfoPtr; - afs_int32 position; - char *volName; - afs_int32 volId; + afs_int32 taskId; + struct butm_tapeInfo *tapeInfoPtr; + afs_int32 position; + char *volName; + afs_int32 volId; { afs_int32 code = 0; - struct volumeHeader tapeVolHeader; + struct volumeHeader tapeVolHeader; /* Position directly to the volume and read the header */ if (position) { - code = butm_Seek (tapeInfoPtr, position); + code = butm_Seek(tapeInfoPtr, position); if (code) { - ErrorLog(0, taskId, code, tapeInfoPtr->error, "Can't seek to position %u on tape\n", - position); + ErrorLog(0, taskId, code, tapeInfoPtr->error, + "Can't seek to position %u on tape\n", position); ERROR_EXIT(code); } code = butm_ReadFileBegin(tapeInfoPtr); if (code) { - ErrorLog(0, taskId, code, tapeInfoPtr->error, "Can't read FileBegin on tape\n"); - ERROR_EXIT(code); + ErrorLog(0, taskId, code, tapeInfoPtr->error, + "Can't read FileBegin on tape\n"); + ERROR_EXIT(code); } /* Read the volume header */ code = ReadVolHeader(taskId, tapeInfoPtr, &tapeVolHeader); - if (code) ERROR_EXIT(code); + if (code) + ERROR_EXIT(code); /* Check if volume header matches */ - if (strcmp(tapeVolHeader.volumeName,volName)) ERROR_EXIT(TC_BADVOLHEADER); - if (volId && (tapeVolHeader.volumeID != volId)) ERROR_EXIT(TC_BADVOLHEADER); - if (tapeVolHeader.magic != TC_VOLBEGINMAGIC) ERROR_EXIT(TC_BADVOLHEADER); + if (strcmp(tapeVolHeader.volumeName, volName)) + ERROR_EXIT(TC_BADVOLHEADER); + if (volId && (tapeVolHeader.volumeID != volId)) + ERROR_EXIT(TC_BADVOLHEADER); + if (tapeVolHeader.magic != TC_VOLBEGINMAGIC) + ERROR_EXIT(TC_BADVOLHEADER); } /* Do a sequential search for the volume */ else { - while(1) { + while (1) { code = butm_ReadFileBegin(tapeInfoPtr); if (code) { - ErrorLog(0, taskId, code, tapeInfoPtr->error, "Can't read FileBegin on tape\n"); + ErrorLog(0, taskId, code, tapeInfoPtr->error, + "Can't read FileBegin on tape\n"); ERROR_EXIT(code); } code = ReadVolHeader(taskId, tapeInfoPtr, &tapeVolHeader); - if (code) ERROR_EXIT(TC_VOLUMENOTONTAPE); - + if (code) + ERROR_EXIT(TC_VOLUMENOTONTAPE); + /* Test if we found the volume */ - if ( ( strcmp(tapeVolHeader.volumeName,volName) == 0 ) && - ( !volId || (volId == tapeVolHeader.volumeID) ) ) - break; + if ((strcmp(tapeVolHeader.volumeName, volName) == 0) + && (!volId || (volId == tapeVolHeader.volumeID))) + break; /* skip to the next HW EOF marker */ code = SeekFile(tapeInfoPtr, 1); if (code) { - ErrorLog(0, taskId, code, tapeInfoPtr->error, "Can't seek to next EOF on tape\n"); + ErrorLog(0, taskId, code, tapeInfoPtr->error, + "Can't seek to next EOF on tape\n"); ERROR_EXIT(code); } } } -error_exit: + error_exit: return code; } -afs_int32 GetRestoreTape(taskId, tapeInfoPtr, tname, tapeID, prompt) - afs_int32 taskId; - struct butm_tapeInfo *tapeInfoPtr; - char *tname; - afs_int32 tapeID; - int prompt; +afs_int32 +GetRestoreTape(taskId, tapeInfoPtr, tname, tapeID, prompt) + afs_int32 taskId; + struct butm_tapeInfo *tapeInfoPtr; + char *tname; + afs_int32 tapeID; + int prompt; { struct butm_tapeLabel tapeLabel; - afs_int32 code = 0, rc; - int tapecount = 1; + afs_int32 code = 0, rc; + int tapecount = 1; struct budb_dumpEntry dumpEntry; /* Make sure that the dump/tape is not a XBSA dump */ rc = bcdb_FindDumpByID(tapeID, &dumpEntry); if (!rc && (dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA))) { - ErrorLog(0, taskId, 0, 0, "Volumes from dump %u are XBSA dumps (skipping)\n", tapeID); - ERROR_EXIT(TC_SKIPTAPE); + ErrorLog(0, taskId, 0, 0, + "Volumes from dump %u are XBSA dumps (skipping)\n", tapeID); + ERROR_EXIT(TC_SKIPTAPE); } - while (1) - { - if (prompt) - { - code = PromptForTape (READOPCODE, tname, tapeID, taskId, tapecount); - if (code) ERROR_EXIT(code); + while (1) { + if (prompt) { + code = + PromptForTape(READOPCODE, tname, tapeID, taskId, tapecount); + if (code) + ERROR_EXIT(code); } prompt = 1; - tapecount++; + tapecount++; - code = butm_Mount (tapeInfoPtr, tname); - if (code) - { + code = butm_Mount(tapeInfoPtr, tname); + if (code) { TapeLog(0, taskId, code, tapeInfoPtr->error, "Can't open tape\n"); goto newtape; } code = butm_ReadLabel(tapeInfoPtr, &tapeLabel, 1); - if (code) - { - ErrorLog(0, taskId, code, tapeInfoPtr->error, "Can't read tape label\n"); + if (code) { + ErrorLog(0, taskId, code, tapeInfoPtr->error, + "Can't read tape label\n"); goto newtape; } /* Now check the label to see if the tapename matches or tapeids match */ - if ( strcmp(TNAME(&tapeLabel),tname) || - ((tapeLabel.structVersion >= TAPE_VERSION_3) && - (tapeLabel.dumpid != tapeID)) ) - { - char expectedName[BU_MAXTAPELEN+32], gotName[BU_MAXTAPELEN+32]; + if (strcmp(TNAME(&tapeLabel), tname) + || ((tapeLabel.structVersion >= TAPE_VERSION_3) + && (tapeLabel.dumpid != tapeID))) { + char expectedName[BU_MAXTAPELEN + 32], + gotName[BU_MAXTAPELEN + 32]; TAPENAME(expectedName, tname, tapeID); LABELNAME(gotName, &tapeLabel); - TapeLog(0, taskId, 0, 0, - "Tape label expected %s, label seen %s\n", - expectedName, gotName); + TapeLog(0, taskId, 0, 0, + "Tape label expected %s, label seen %s\n", expectedName, + gotName); goto newtape; } - + break; newtape: unmountTape(taskId, tapeInfoPtr); } -error_exit: + error_exit: return code; } -afs_int32 xbsaRestoreVolumeData(call, rparamsPtr) - register struct rx_call *call; - struct restoreParams *rparamsPtr; +afs_int32 +xbsaRestoreVolumeData(call, rparamsPtr) + register struct rx_call *call; + struct restoreParams *rparamsPtr; { - afs_int32 code=0; + afs_int32 code = 0; #ifdef xbsa - afs_int32 curChunk, rc; + afs_int32 curChunk, rc; afs_uint32 totalWritten; - afs_int32 headBytes, tailBytes, w; - afs_int32 taskId; - struct volumeHeader volTrailer; - afs_int32 vtsize=0; - int found; - struct dumpNode *nodePtr; + afs_int32 headBytes, tailBytes, w; + afs_int32 taskId; + struct volumeHeader volTrailer; + afs_int32 vtsize = 0; + int found; + struct dumpNode *nodePtr; struct tc_restoreDesc *Restore; - afs_int32 bytesRead, tbuffersize, endData=0; - char *buffer = (char *)bufferBlock, tbuffer[256]; + afs_int32 bytesRead, tbuffersize, endData = 0; + char *buffer = (char *)bufferBlock, tbuffer[256]; - nodePtr = rparamsPtr->nodePtr; - Restore = nodePtr->restores; - taskId = nodePtr->taskID; + nodePtr = rparamsPtr->nodePtr; + Restore = nodePtr->restores; + taskId = nodePtr->taskID; /* Read the volume fragment one block at a time until * find a volume trailer */ - curChunk = BIGCHUNK+1; - tbuffersize = 0; + curChunk = BIGCHUNK + 1; + tbuffersize = 0; totalWritten = 0; while (!endData) { - rc = xbsa_ReadObjectData(&butxInfo, buffer, dataSize, &bytesRead, &endData); - if (restoretofile && (bytesRead > 0)) { - fwrite(buffer, bytesRead, 1, restoretofilefd); /* Save to a file */ - } - if (rc != XBSA_SUCCESS) { - ErrorLog(0, taskId, rc, 0, "Unable to read volume data from the server\n"); - ERROR_EXIT(rc); - } - - /* Periodically update status structure and check if should abort */ - curChunk += bytesRead; - if (curChunk > BIGCHUNK) { - curChunk = 0; - lock_Status(); - nodePtr->statusNodePtr->nKBytes = totalWritten/1024; - unlock_Status(); - - if ( checkAbortByTaskId(taskId) ) - ERROR_EXIT(TC_ABORTEDBYREQUEST); - } - - if (!endData && (bytesRead > 0)) { - /* Fill tbuffer up with data from end of buffer and write - * the remainder of buffer out. - */ - if ((tbuffersize == 0) || (bytesRead >= sizeof(tbuffer))) { - /* Write out contents of tbuffer */ - if (tbuffersize) { - w = rx_Write(call, tbuffer, tbuffersize); - if (w != tbuffersize) { - ErrorLog (0, taskId, -1, 0, "Error in RX write: Wrote %d bytes\n", w); - ERROR_EXIT(-1); + rc = xbsa_ReadObjectData(&butxInfo, buffer, dataSize, &bytesRead, + &endData); + if (restoretofile && (bytesRead > 0)) { + fwrite(buffer, bytesRead, 1, restoretofilefd); /* Save to a file */ + } + if (rc != XBSA_SUCCESS) { + ErrorLog(0, taskId, rc, 0, + "Unable to read volume data from the server\n"); + ERROR_EXIT(rc); + } + + /* Periodically update status structure and check if should abort */ + curChunk += bytesRead; + if (curChunk > BIGCHUNK) { + curChunk = 0; + lock_Status(); + nodePtr->statusNodePtr->nKBytes = totalWritten / 1024; + unlock_Status(); + + if (checkAbortByTaskId(taskId)) + ERROR_EXIT(TC_ABORTEDBYREQUEST); + } + + if (!endData && (bytesRead > 0)) { + /* Fill tbuffer up with data from end of buffer and write + * the remainder of buffer out. + */ + if ((tbuffersize == 0) || (bytesRead >= sizeof(tbuffer))) { + /* Write out contents of tbuffer */ + if (tbuffersize) { + w = rx_Write(call, tbuffer, tbuffersize); + if (w != tbuffersize) { + ErrorLog(0, taskId, -1, 0, + "Error in RX write: Wrote %d bytes\n", w); + ERROR_EXIT(-1); + } + totalWritten += w; } - totalWritten += w; - } - /* fill tbuffer with end of buffer */ - bytesRead -= sizeof(tbuffer); - memcpy(tbuffer, buffer+bytesRead, sizeof(tbuffer)); - tbuffersize = sizeof(tbuffer); - /* Write out whatever is left over in buffer */ - if (bytesRead) { - w = rx_Write(call, buffer, bytesRead); - if (w != bytesRead) { - ErrorLog (0, taskId, -1, 0, "Error in RX data write: Wrote %d bytes\n", w); - ERROR_EXIT(-1); + /* fill tbuffer with end of buffer */ + bytesRead -= sizeof(tbuffer); + memcpy(tbuffer, buffer + bytesRead, sizeof(tbuffer)); + tbuffersize = sizeof(tbuffer); + /* Write out whatever is left over in buffer */ + if (bytesRead) { + w = rx_Write(call, buffer, bytesRead); + if (w != bytesRead) { + ErrorLog(0, taskId, -1, 0, + "Error in RX data write: Wrote %d bytes\n", + w); + ERROR_EXIT(-1); + } + totalWritten += w; + bytesRead = 0; } - totalWritten += w; + } else if ((tbuffersize + bytesRead) <= sizeof(tbuffer)) { + /* Copy all of buffer into tbuffer (it will fit) */ + memcpy(tbuffer + tbuffersize, buffer, bytesRead); + tbuffersize += bytesRead; bytesRead = 0; - } - } - else if ((tbuffersize + bytesRead) <= sizeof(tbuffer)) { - /* Copy all of buffer into tbuffer (it will fit) */ - memcpy(tbuffer+tbuffersize, buffer, bytesRead); - tbuffersize += bytesRead; - bytesRead = 0; - } - else { - /* We need to write some of tbuffer out and fill it with buffer */ - int towrite = bytesRead - (sizeof(tbuffer) - tbuffersize); - w = rx_Write(call, tbuffer, towrite); - if (w != towrite) { - ErrorLog (0, taskId, -1, 0, "Error in RX write: Wrote %d bytes\n", w); - ERROR_EXIT(-1); - } - totalWritten += w; - tbuffersize -= w; - - /* Move the data in tbuffer up */ - memcpy(tbuffer, tbuffer+towrite, tbuffersize); + } else { + /* We need to write some of tbuffer out and fill it with buffer */ + int towrite = bytesRead - (sizeof(tbuffer) - tbuffersize); + w = rx_Write(call, tbuffer, towrite); + if (w != towrite) { + ErrorLog(0, taskId, -1, 0, + "Error in RX write: Wrote %d bytes\n", w); + ERROR_EXIT(-1); + } + totalWritten += w; + tbuffersize -= w; - /* Now copy buffer in */ - memcpy(tbuffer+tbuffersize, buffer, bytesRead); - tbuffersize += bytesRead; - bytesRead = 0; - } - } + /* Move the data in tbuffer up */ + memcpy(tbuffer, tbuffer + towrite, tbuffersize); + + /* Now copy buffer in */ + memcpy(tbuffer + tbuffersize, buffer, bytesRead); + tbuffersize += bytesRead; + bytesRead = 0; + } + } } /* Pull the volume trailer from the last two buffers */ - found = FindVolTrailer2(tbuffer, tbuffersize, &headBytes, - buffer, bytesRead, &tailBytes, - &volTrailer); + found = + FindVolTrailer2(tbuffer, tbuffersize, &headBytes, buffer, bytesRead, + &tailBytes, &volTrailer); if (!found) { - ErrorLog(0, taskId, TC_MISSINGTRAILER, 0, "Missing volume trailer\n"); - ERROR_EXIT(TC_MISSINGTRAILER); + ErrorLog(0, taskId, TC_MISSINGTRAILER, 0, "Missing volume trailer\n"); + ERROR_EXIT(TC_MISSINGTRAILER); } /* Now rx_write the data in the last two blocks */ if (headBytes) { - w = rx_Write(call, tbuffer, headBytes); - if (w != headBytes) { - ErrorLog (0, taskId, -1, 0, "Error in RX trail1 write: Wrote %d bytes\n", w); - ERROR_EXIT(-1); - } - totalWritten += w; + w = rx_Write(call, tbuffer, headBytes); + if (w != headBytes) { + ErrorLog(0, taskId, -1, 0, + "Error in RX trail1 write: Wrote %d bytes\n", w); + ERROR_EXIT(-1); + } + totalWritten += w; } if (tailBytes) { - w = rx_Write(call, buffer, tailBytes); - if (w != tailBytes) { - ErrorLog (0, taskId, -1, 0, "Error in RX trail2 write: Wrote %d bytes\n", w); - ERROR_EXIT(-1); - } - totalWritten += w; + w = rx_Write(call, buffer, tailBytes); + if (w != tailBytes) { + ErrorLog(0, taskId, -1, 0, + "Error in RX trail2 write: Wrote %d bytes\n", w); + ERROR_EXIT(-1); + } + totalWritten += w; } error_exit: -#endif /*xbsa*/ +#endif /*xbsa */ return code; } @@ -1189,56 +1238,58 @@ afs_int32 xbsaRestoreVolumeData(call, rparamsPtr) * with */ -afs_int32 restoreVolumeData (call, rparamsPtr) - register struct rx_call *call; - struct restoreParams *rparamsPtr; +afs_int32 +restoreVolumeData(call, rparamsPtr) + register struct rx_call *call; + struct restoreParams *rparamsPtr; { - afs_int32 curChunk; + afs_int32 curChunk; afs_uint32 totalWritten = 0; afs_uint32 tapeID; - afs_int32 code, tcode; - afs_int32 headBytes, tailBytes, w; - afs_int32 taskId; - afs_int32 nbytes; /* # bytes data in last tape block read */ - struct volumeHeader tapeVolTrailer; - int found; - int moretoread; - afs_int32 startRbuf, endRbuf, startWbuf, endWbuf, buf, pbuf, lastbuf; + afs_int32 code, tcode; + afs_int32 headBytes, tailBytes, w; + afs_int32 taskId; + afs_int32 nbytes; /* # bytes data in last tape block read */ + struct volumeHeader tapeVolTrailer; + int found; + int moretoread; + afs_int32 startRbuf, endRbuf, startWbuf, endWbuf, buf, pbuf, lastbuf; struct tc_restoreDesc *Restore; - struct dumpNode *nodePtr; - struct butm_tapeInfo *tapeInfoPtr; - char *origVolName; - afs_int32 origVolID; - - nodePtr = rparamsPtr->nodePtr; - taskId = nodePtr->taskID; - Restore = nodePtr->restores; + struct dumpNode *nodePtr; + struct butm_tapeInfo *tapeInfoPtr; + char *origVolName; + afs_int32 origVolID; + + nodePtr = rparamsPtr->nodePtr; + taskId = nodePtr->taskID; + Restore = nodePtr->restores; tapeInfoPtr = rparamsPtr->tapeInfoPtr; origVolName = Restore[rparamsPtr->frag].oldName; - origVolID = Restore[rparamsPtr->frag].origVid; + origVolID = Restore[rparamsPtr->frag].origVid; /* Read the volume one fragment at a time */ while (rparamsPtr->frag < nodePtr->arraySize) { - /*w*/ - curChunk = BIGCHUNK+1; /* Check if should abort */ + /*w */ + curChunk = BIGCHUNK + 1; /* Check if should abort */ /* Read the volume fragment one block at a time until * find a volume trailer */ moretoread = 1; - startRbuf = 0; - endRbuf = 0; - startWbuf = 0; + startRbuf = 0; + endRbuf = 0; + startWbuf = 0; while (moretoread) { /* Fill the circular buffer with tape blocks * Search for volume trailer in the process. */ buf = startRbuf; do { - code = butm_ReadFileData(tapeInfoPtr, bufferBlock[buf].data, - BUTM_BLKSIZE, &nbytes); + code = + butm_ReadFileData(tapeInfoPtr, bufferBlock[buf].data, + BUTM_BLKSIZE, &nbytes); if (code) { - ErrorLog(0, taskId, code, tapeInfoPtr->error, + ErrorLog(0, taskId, code, tapeInfoPtr->error, "Can't read FileData on tape %s\n", rparamsPtr->mntTapeName); ERROR_EXIT(code); @@ -1250,20 +1301,23 @@ afs_int32 restoreVolumeData (call, rparamsPtr) curChunk = 0; lock_Status(); - nodePtr->statusNodePtr->nKBytes = totalWritten/1024; + nodePtr->statusNodePtr->nKBytes = totalWritten / 1024; unlock_Status(); - if ( checkAbortByTaskId(taskId) ) - ERROR_EXIT(TC_ABORTEDBYREQUEST); + if (checkAbortByTaskId(taskId)) + ERROR_EXIT(TC_ABORTEDBYREQUEST); } /* step to next block in buffer */ pbuf = buf; - buf = ((buf+1) == tapeblocks) ? 0 : (buf+1); + buf = ((buf + 1) == tapeblocks) ? 0 : (buf + 1); /* If this is the end of the volume, the exit the loop */ - if ( (nbytes != BUTM_BLKSIZE) || - (FindVolTrailer(bufferBlock[pbuf].data,nbytes,&tailBytes, &tapeVolTrailer)) ) + if ((nbytes != BUTM_BLKSIZE) + || + (FindVolTrailer + (bufferBlock[pbuf].data, nbytes, &tailBytes, + &tapeVolTrailer))) moretoread = 0; } while (moretoread && (buf != endRbuf)); @@ -1273,20 +1327,21 @@ afs_int32 restoreVolumeData (call, rparamsPtr) */ lastbuf = endWbuf = pbuf; if (!moretoread && (endWbuf != startWbuf)) - endWbuf = (endWbuf==0) ? (tapeblocks-1) : (endWbuf-1); - - for (buf = startWbuf; buf != endWbuf; buf = (((buf+1)==tapeblocks)?0:(buf+1))){ - w = rx_Write(call,bufferBlock[buf].data,BUTM_BLKSIZE); - if (w != BUTM_BLKSIZE) { - ErrorLog (0, taskId, -1, 0, "Error in RX write\n"); + endWbuf = (endWbuf == 0) ? (tapeblocks - 1) : (endWbuf - 1); + + for (buf = startWbuf; buf != endWbuf; + buf = (((buf + 1) == tapeblocks) ? 0 : (buf + 1))) { + w = rx_Write(call, bufferBlock[buf].data, BUTM_BLKSIZE); + if (w != BUTM_BLKSIZE) { + ErrorLog(0, taskId, -1, 0, "Error in RX write\n"); ERROR_EXIT(-1); } totalWritten += BUTM_BLKSIZE; } - + /* Setup pointers to refill buffer */ - startRbuf = ((lastbuf+1) == tapeblocks) ? 0 : (lastbuf+1); - endRbuf = endWbuf; + startRbuf = ((lastbuf + 1) == tapeblocks) ? 0 : (lastbuf + 1); + endRbuf = endWbuf; startWbuf = endWbuf; } @@ -1295,40 +1350,43 @@ afs_int32 restoreVolumeData (call, rparamsPtr) * Seach for the volume trailer in these two blocks. */ if (lastbuf == startWbuf) - found = FindVolTrailer2(NULL, 0 , &headBytes, - bufferBlock[lastbuf].data, nbytes, &tailBytes, - &tapeVolTrailer); + found = + FindVolTrailer2(NULL, 0, &headBytes, + bufferBlock[lastbuf].data, nbytes, &tailBytes, + &tapeVolTrailer); else - found = FindVolTrailer2(bufferBlock[startWbuf].data, BUTM_BLKSIZE, &headBytes, - bufferBlock[lastbuf].data , nbytes , &tailBytes, - &tapeVolTrailer); + found = + FindVolTrailer2(bufferBlock[startWbuf].data, BUTM_BLKSIZE, + &headBytes, bufferBlock[lastbuf].data, nbytes, + &tailBytes, &tapeVolTrailer); if (!found) { - ErrorLog(0, taskId, TC_MISSINGTRAILER, 0, - "Missing volume trailer on tape %s\n", rparamsPtr->mntTapeName); + ErrorLog(0, taskId, TC_MISSINGTRAILER, 0, + "Missing volume trailer on tape %s\n", + rparamsPtr->mntTapeName); ERROR_EXIT(TC_MISSINGTRAILER); } /* Now rx_write the data in the last two blocks */ if (headBytes) { - w = rx_Write(call,bufferBlock[startWbuf].data,headBytes); + w = rx_Write(call, bufferBlock[startWbuf].data, headBytes); if (w != headBytes) { - ErrorLog (0, taskId, -1, 0, "Error in RX write\n"); + ErrorLog(0, taskId, -1, 0, "Error in RX write\n"); ERROR_EXIT(-1); } totalWritten += headBytes; } if (tailBytes) { - w = rx_Write(call,bufferBlock[lastbuf].data,tailBytes); + w = rx_Write(call, bufferBlock[lastbuf].data, tailBytes); if (w != tailBytes) { - ErrorLog (0, taskId, -1, 0, "Error in RX write\n"); + ErrorLog(0, taskId, -1, 0, "Error in RX write\n"); ERROR_EXIT(-1); } totalWritten += tailBytes; } /* Exit the loop if the volume is not continued on next tape */ - if ( !tapeVolTrailer.contd ) - break; /* We've read the entire volume */ + if (!tapeVolTrailer.contd) + break; /* We've read the entire volume */ /* Volume is continued on next tape. * Step to the next volume fragment and prompt for its tape. @@ -1337,408 +1395,441 @@ afs_int32 restoreVolumeData (call, rparamsPtr) */ rparamsPtr->frag++; if (rparamsPtr->frag >= nodePtr->arraySize) - break; + break; unmountTape(taskId, tapeInfoPtr); strcpy(rparamsPtr->mntTapeName, Restore[rparamsPtr->frag].tapeName); - rparamsPtr->tapeID = (Restore[rparamsPtr->frag].initialDumpId ? - Restore[rparamsPtr->frag].initialDumpId : - Restore[rparamsPtr->frag].dbDumpId); - code = GetRestoreTape(taskId, tapeInfoPtr, rparamsPtr->mntTapeName, - rparamsPtr->tapeID, 1); - if (code) ERROR_EXIT(code); + rparamsPtr->tapeID = + (Restore[rparamsPtr->frag]. + initialDumpId ? Restore[rparamsPtr->frag]. + initialDumpId : Restore[rparamsPtr->frag].dbDumpId); + code = + GetRestoreTape(taskId, tapeInfoPtr, rparamsPtr->mntTapeName, + rparamsPtr->tapeID, 1); + if (code) + ERROR_EXIT(code); /* Position to the frag and read the volume header */ - code = GetVolumeHead(taskId, tapeInfoPtr, - Restore[rparamsPtr->frag].position, - origVolName, origVolID); + code = + GetVolumeHead(taskId, tapeInfoPtr, + Restore[rparamsPtr->frag].position, origVolName, + origVolID); if (code) { - ErrorLog(0, taskId, code, 0, "Can't find volume %s (%u) on tape %s\n", - origVolName, origVolID, - rparamsPtr->mntTapeName); + ErrorLog(0, taskId, code, 0, + "Can't find volume %s (%u) on tape %s\n", origVolName, + origVolID, rparamsPtr->mntTapeName); ERROR_EXIT(TC_VOLUMENOTONTAPE); } - } /*w*/ + } /*w */ -error_exit: - return code; + error_exit: + return code; } /* SkipTape * Find all the volumes on a specific tape and mark them to skip. */ SkipTape(Restore, size, index, tapename, tapeid, taskid) - struct tc_restoreDesc *Restore; - afs_int32 size, index, tapeid, taskid; - char *tapename; + struct tc_restoreDesc *Restore; + afs_int32 size, index, tapeid, taskid; + char *tapename; { - afs_int32 i, tid; - - for (i=index; idbDumpId; - - rc = bcdb_FindDumpByID(dumpID, &dumpEntry); - if (rc) { - ErrorLog(0, taskId, rc, 0, "Can't read database for dump %u\n", dumpID); - ERROR_EXIT(rc); - } - - /* ADSM servers restore ADSM and BUTA dumps */ - if ( (xbsaType == XBSA_SERVER_TYPE_ADSM) && - !(dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA)) ) { - ELog(taskId, "The dump requested by this restore operation for the " - "volumeset is incompatible with this instance of butc\n"); - /* Skip the entire dump (one dump per tape) */ - ERROR_EXIT(TC_SKIPTAPE); - } - - /* make sure we are connected to the correct server. */ - if ( (strlen((char *)dumpEntry.tapes.tapeServer) != 0) && - (strcmp((char *)dumpEntry.tapes.tapeServer,butxInfo.serverName) != 0) ) { - if ((dumpEntry.flags & (BUDB_DUMP_XBSA_NSS | BUDB_DUMP_BUTA)) && !forcemultiple) { - TLog(taskId, "Dump %d is on server %s but butc is connected " - "to server %s (attempting to restore)\n", - dumpID, (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName); - } else { - TLog(taskId, "Dump %d is on server %s but butc is connected " - "to server %s (switching servers)\n", - dumpID, (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName); - - rc = InitToServer(taskId, &butxInfo, (char *)dumpEntry.tapes.tapeServer); - if (rc != XBSA_SUCCESS) ERROR_EXIT(TC_SKIPTAPE); - } - } - - /* Start a transaction and query the server for the correct fileset dump */ - rc = xbsa_BeginTrans(&butxInfo); - if (rc != XBSA_SUCCESS) { - ELog(taskId, "Unable to create a new transaction\n"); - ERROR_EXIT(TC_SKIPTAPE); - } - havetrans = 1; - - if (dumpEntry.flags & BUDB_DUMP_BUTA) { /* old buta style names */ - sprintf(dumpIdStr, "/%d", dumpID); - strcpy(volumeNameStr, "/"); - strcat(volumeNameStr, restoreInfo->oldName); - } else { /* new butc names */ - extern char *butcdumpIdStr; - strcpy(dumpIdStr, butcdumpIdStr); - sprintf(volumeNameStr, "/%d", dumpID); - strcat(volumeNameStr, "/"); - strcat(volumeNameStr, restoreInfo->oldName); - } - - rc = xbsa_QueryObject(&butxInfo, dumpIdStr, volumeNameStr); - if (rc != XBSA_SUCCESS) { - ELog(taskId, "Unable to locate object (%s) of dump (%s) on the server\n", - volumeNameStr, dumpIdStr); - ERROR_EXIT(rc); - } - - rc = xbsa_EndTrans(&butxInfo); - havetrans = 0; - if (rc != XBSA_SUCCESS) { - ELog(taskId, "Unable to terminate the current transaction\n"); - ERROR_EXIT(rc); - } - - if ( checkAbortByTaskId(taskId) ) - ERROR_EXIT(TC_ABORTEDBYREQUEST); - - /* Now start a transaction on the volume to restore and read the - * volumeheader. We do this before starting a transaction on - * volserver to restore the volume because the XBSA server may take - * a while to mount and seek to the volume causing the volserver to - * time out. - */ + afs_int32 newServer, newPart, newVolId; + char *newVolName; + int restoreflags, havetrans = 0, startread = 0; + afs_int32 bytesRead, endData = 0; + afs_uint32 dumpID; + struct budb_dumpEntry dumpEntry; + char volumeNameStr[XBSA_MAX_PATHNAME], dumpIdStr[XBSA_MAX_OSNAME]; + struct volumeHeader volHeader, hostVolHeader; + + if (restoretofile) { + restoretofilefd = fopen(restoretofile, "w+"); + } + + dumpID = restoreInfo->dbDumpId; + + rc = bcdb_FindDumpByID(dumpID, &dumpEntry); + if (rc) { + ErrorLog(0, taskId, rc, 0, "Can't read database for dump %u\n", + dumpID); + ERROR_EXIT(rc); + } + + /* ADSM servers restore ADSM and BUTA dumps */ + if ((xbsaType == XBSA_SERVER_TYPE_ADSM) + && !(dumpEntry.flags & (BUDB_DUMP_ADSM | BUDB_DUMP_BUTA))) { + ELog(taskId, + "The dump requested by this restore operation for the " + "volumeset is incompatible with this instance of butc\n"); + /* Skip the entire dump (one dump per tape) */ + ERROR_EXIT(TC_SKIPTAPE); + } + + /* make sure we are connected to the correct server. */ + if ((strlen((char *)dumpEntry.tapes.tapeServer) != 0) + && (strcmp((char *)dumpEntry.tapes.tapeServer, butxInfo.serverName) != + 0)) { + if ((dumpEntry.flags & (BUDB_DUMP_XBSA_NSS | BUDB_DUMP_BUTA)) + && !forcemultiple) { + TLog(taskId, + "Dump %d is on server %s but butc is connected " + "to server %s (attempting to restore)\n", dumpID, + (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName); + } else { + TLog(taskId, + "Dump %d is on server %s but butc is connected " + "to server %s (switching servers)\n", dumpID, + (char *)dumpEntry.tapes.tapeServer, butxInfo.serverName); + + rc = InitToServer(taskId, &butxInfo, + (char *)dumpEntry.tapes.tapeServer); + if (rc != XBSA_SUCCESS) + ERROR_EXIT(TC_SKIPTAPE); + } + } + + /* Start a transaction and query the server for the correct fileset dump */ + rc = xbsa_BeginTrans(&butxInfo); + if (rc != XBSA_SUCCESS) { + ELog(taskId, "Unable to create a new transaction\n"); + ERROR_EXIT(TC_SKIPTAPE); + } + havetrans = 1; + + if (dumpEntry.flags & BUDB_DUMP_BUTA) { /* old buta style names */ + sprintf(dumpIdStr, "/%d", dumpID); + strcpy(volumeNameStr, "/"); + strcat(volumeNameStr, restoreInfo->oldName); + } else { /* new butc names */ + extern char *butcdumpIdStr; + strcpy(dumpIdStr, butcdumpIdStr); + sprintf(volumeNameStr, "/%d", dumpID); + strcat(volumeNameStr, "/"); + strcat(volumeNameStr, restoreInfo->oldName); + } + + rc = xbsa_QueryObject(&butxInfo, dumpIdStr, volumeNameStr); + if (rc != XBSA_SUCCESS) { + ELog(taskId, + "Unable to locate object (%s) of dump (%s) on the server\n", + volumeNameStr, dumpIdStr); + ERROR_EXIT(rc); + } + + rc = xbsa_EndTrans(&butxInfo); + havetrans = 0; + if (rc != XBSA_SUCCESS) { + ELog(taskId, "Unable to terminate the current transaction\n"); + ERROR_EXIT(rc); + } + + if (checkAbortByTaskId(taskId)) + ERROR_EXIT(TC_ABORTEDBYREQUEST); + + /* Now start a transaction on the volume to restore and read the + * volumeheader. We do this before starting a transaction on + * volserver to restore the volume because the XBSA server may take + * a while to mount and seek to the volume causing the volserver to + * time out. + */ rc = xbsa_BeginTrans(&butxInfo); if (rc != XBSA_SUCCESS) { - ELog(taskId, "Unable to create a new transaction\n"); - ERROR_EXIT(TC_SKIPTAPE); + ELog(taskId, "Unable to create a new transaction\n"); + ERROR_EXIT(TC_SKIPTAPE); } havetrans = 1; rc = xbsa_ReadObjectBegin(&butxInfo, (char *)&volHeader, sizeof(volHeader), &bytesRead, &endData); if (restoretofile && (bytesRead > 0)) { - fwrite((char *)&volHeader, bytesRead, 1, restoretofilefd); /* Save to a file */ + fwrite((char *)&volHeader, bytesRead, 1, restoretofilefd); /* Save to a file */ } if (rc != XBSA_SUCCESS) { - ELog(taskId, "Unable to begin reading of the volume from the server\n"); - ERROR_EXIT(rc); + ELog(taskId, + "Unable to begin reading of the volume from the server\n"); + ERROR_EXIT(rc); } startread = 1; if ((bytesRead != sizeof(volHeader)) || endData) { - ELog(taskId,"The size of data read (%d) does not equal the size of data requested (%d)\n", - bytesRead, sizeof(volHeader)); - ERROR_EXIT(TC_BADVOLHEADER); + ELog(taskId, + "The size of data read (%d) does not equal the size of data requested (%d)\n", + bytesRead, sizeof(volHeader)); + ERROR_EXIT(TC_BADVOLHEADER); } /* convert and check the volume header */ rc = VolHeaderToHost(&hostVolHeader, &volHeader); if (rc) { - ErrorLog(0, taskId, code, 0, "Can't convert volume header\n"); + ErrorLog(0, taskId, code, 0, "Can't convert volume header\n"); ERROR_EXIT(rc); } - if ( (strcmp(hostVolHeader.volumeName,restoreInfo->oldName) != 0) || - (restoreInfo->origVid && (hostVolHeader.volumeID != restoreInfo->origVid)) || - (hostVolHeader.magic != TC_VOLBEGINMAGIC) ) - ERROR_EXIT(TC_BADVOLHEADER); - - /* Set up prior restoring volume data */ - newVolName = restoreInfo->newName; - newVolId = restoreInfo->vid; - newServer = restoreInfo->hostAddr; - newPart = restoreInfo->partition; - restoreflags = 0; - if ( (restoreInfo->dumpLevel == 0) || (restoreInfo->flags & RDFLAG_FIRSTDUMP) ) - restoreflags |= RV_FULLRST; - if (!(restoreInfo->flags & RDFLAG_LASTDUMP)) - restoreflags |= RV_OFFLINE; - - if ( checkAbortByTaskId(taskId) ) - ERROR_EXIT(TC_ABORTEDBYREQUEST); - - /* Start the restore of the volume data. This is the code we want to return */ - code = UV_RestoreVolume(htonl(newServer), newPart, - newVolId, newVolName, - restoreflags, - xbsaRestoreVolumeData, - (char *)rparamsPtr); + if ((strcmp(hostVolHeader.volumeName, restoreInfo->oldName) != 0) + || (restoreInfo->origVid + && (hostVolHeader.volumeID != restoreInfo->origVid)) + || (hostVolHeader.magic != TC_VOLBEGINMAGIC)) + ERROR_EXIT(TC_BADVOLHEADER); + + /* Set up prior restoring volume data */ + newVolName = restoreInfo->newName; + newVolId = restoreInfo->vid; + newServer = restoreInfo->hostAddr; + newPart = restoreInfo->partition; + restoreflags = 0; + if ((restoreInfo->dumpLevel == 0) + || (restoreInfo->flags & RDFLAG_FIRSTDUMP)) + restoreflags |= RV_FULLRST; + if (!(restoreInfo->flags & RDFLAG_LASTDUMP)) + restoreflags |= RV_OFFLINE; + + if (checkAbortByTaskId(taskId)) + ERROR_EXIT(TC_ABORTEDBYREQUEST); + + /* Start the restore of the volume data. This is the code we want to return */ + code = + UV_RestoreVolume(htonl(newServer), newPart, newVolId, newVolName, + restoreflags, xbsaRestoreVolumeData, + (char *)rparamsPtr); error_exit: - if (startread) { - rc = xbsa_ReadObjectEnd(&butxInfo); - if (rc != XBSA_SUCCESS) { - ELog(taskId, "Unable to terminate reading of the volume from the server\n"); - ERROR_EXIT(rc); - } - } - - if (havetrans) { - rc = xbsa_EndTrans(&butxInfo); - if (rc != XBSA_SUCCESS) { - ELog(taskId, "Unable to terminate the current transaction\n"); - if (!code) code = rc; - } - } - - if (restoretofile && restoretofilefd) { - fclose(restoretofilefd); - } + if (startread) { + rc = xbsa_ReadObjectEnd(&butxInfo); + if (rc != XBSA_SUCCESS) { + ELog(taskId, + "Unable to terminate reading of the volume from the server\n"); + ERROR_EXIT(rc); + } + } + + if (havetrans) { + rc = xbsa_EndTrans(&butxInfo); + if (rc != XBSA_SUCCESS) { + ELog(taskId, "Unable to terminate the current transaction\n"); + if (!code) + code = rc; + } + } + + if (restoretofile && restoretofilefd) { + fclose(restoretofilefd); + } #endif - return(code); + return (code); } restoreVolume(taskId, restoreInfo, rparamsPtr) - afs_uint32 taskId; - struct tc_restoreDesc *restoreInfo; - struct restoreParams *rparamsPtr; + afs_uint32 taskId; + struct tc_restoreDesc *restoreInfo; + struct restoreParams *rparamsPtr; { - afs_int32 code=0, rc; - afs_int32 newServer, newPart, newVolId; - char *newVolName; - int restoreflags; - afs_uint32 tapeID; - struct butm_tapeInfo *tapeInfoPtr = rparamsPtr->tapeInfoPtr; - struct budb_dumpEntry dumpEntry; - - /* Check if we need a tape and prompt for one if so */ - tapeID = (restoreInfo->initialDumpId ? restoreInfo->initialDumpId : restoreInfo->dbDumpId); - if ( (rparamsPtr->frag == 0) || - (strcmp(restoreInfo->tapeName,rparamsPtr->mntTapeName) != 0) || - (tapeID != rparamsPtr->tapeID) ) { - /* Unmount the previous tape */ - unmountTape(taskId, tapeInfoPtr); - - /* Remember this new tape */ - strcpy(rparamsPtr->mntTapeName, restoreInfo->tapeName); - rparamsPtr->tapeID = tapeID; - - /* Mount a new tape */ - rc = GetRestoreTape(taskId, tapeInfoPtr, rparamsPtr->mntTapeName, - rparamsPtr->tapeID, ((rparamsPtr->frag==0)?autoQuery:1)); - if (rc) ERROR_EXIT(rc); - } - - /* Seek to the correct spot and read the header information */ - rc = GetVolumeHead(taskId, tapeInfoPtr, restoreInfo->position, - restoreInfo->oldName, restoreInfo->origVid); - if (rc) ERROR_EXIT(rc); - - /* Set up prior restoring volume data */ - newVolName = restoreInfo->newName; - newVolId = restoreInfo->vid; - newServer = restoreInfo->hostAddr; - newPart = restoreInfo->partition; - restoreflags = 0; - if ( (restoreInfo->dumpLevel == 0) || (restoreInfo->flags & RDFLAG_FIRSTDUMP) ) - restoreflags |= RV_FULLRST; - if (!(restoreInfo->flags & RDFLAG_LASTDUMP)) - restoreflags |= RV_OFFLINE; - - if ( checkAbortByTaskId(taskId) ) - ERROR_EXIT(TC_ABORTEDBYREQUEST); - - /* Start the restore of the volume data. This is the code we - * want to return. - */ - code = UV_RestoreVolume(htonl(newServer), newPart, - newVolId, newVolName, - restoreflags, - restoreVolumeData, - (char *)rparamsPtr); - - /* Read the FileEnd marker for the volume and step to next FM */ - rc = butm_ReadFileEnd(tapeInfoPtr); - if (rc) { - ErrorLog(0, taskId, rc, tapeInfoPtr->error, "Can't read EOF on tape\n"); - } + afs_int32 code = 0, rc; + afs_int32 newServer, newPart, newVolId; + char *newVolName; + int restoreflags; + afs_uint32 tapeID; + struct butm_tapeInfo *tapeInfoPtr = rparamsPtr->tapeInfoPtr; + struct budb_dumpEntry dumpEntry; + + /* Check if we need a tape and prompt for one if so */ + tapeID = + (restoreInfo->initialDumpId ? restoreInfo-> + initialDumpId : restoreInfo->dbDumpId); + if ((rparamsPtr->frag == 0) + || (strcmp(restoreInfo->tapeName, rparamsPtr->mntTapeName) != 0) + || (tapeID != rparamsPtr->tapeID)) { + /* Unmount the previous tape */ + unmountTape(taskId, tapeInfoPtr); + + /* Remember this new tape */ + strcpy(rparamsPtr->mntTapeName, restoreInfo->tapeName); + rparamsPtr->tapeID = tapeID; + + /* Mount a new tape */ + rc = GetRestoreTape(taskId, tapeInfoPtr, rparamsPtr->mntTapeName, + rparamsPtr->tapeID, + ((rparamsPtr->frag == 0) ? autoQuery : 1)); + if (rc) + ERROR_EXIT(rc); + } + + /* Seek to the correct spot and read the header information */ + rc = GetVolumeHead(taskId, tapeInfoPtr, restoreInfo->position, + restoreInfo->oldName, restoreInfo->origVid); + if (rc) + ERROR_EXIT(rc); + + /* Set up prior restoring volume data */ + newVolName = restoreInfo->newName; + newVolId = restoreInfo->vid; + newServer = restoreInfo->hostAddr; + newPart = restoreInfo->partition; + restoreflags = 0; + if ((restoreInfo->dumpLevel == 0) + || (restoreInfo->flags & RDFLAG_FIRSTDUMP)) + restoreflags |= RV_FULLRST; + if (!(restoreInfo->flags & RDFLAG_LASTDUMP)) + restoreflags |= RV_OFFLINE; + + if (checkAbortByTaskId(taskId)) + ERROR_EXIT(TC_ABORTEDBYREQUEST); + + /* Start the restore of the volume data. This is the code we + * want to return. + */ + code = + UV_RestoreVolume(htonl(newServer), newPart, newVolId, newVolName, + restoreflags, restoreVolumeData, (char *)rparamsPtr); + + /* Read the FileEnd marker for the volume and step to next FM */ + rc = butm_ReadFileEnd(tapeInfoPtr); + if (rc) { + ErrorLog(0, taskId, rc, tapeInfoPtr->error, + "Can't read EOF on tape\n"); + } error_exit: - return(code); + return (code); } /* Restorer * created as a LWP by the server stub, is a pointer to all * the parameters Restorer needs */ -Restorer (newNode) - struct dumpNode *newNode; +Restorer(newNode) + struct dumpNode *newNode; { - afs_int32 code = 0, tcode, rc; + afs_int32 code = 0, tcode, rc; afs_uint32 taskId; afs_uint32 dumpID; - char *newVolName; - struct butm_tapeInfo tapeInfo; + char *newVolName; + struct butm_tapeInfo tapeInfo; struct tc_restoreDesc *Restore; struct tc_restoreDesc *RestoreDesc; - struct restoreParams rparams; + struct restoreParams rparams; int restoreflags; afs_int32 allocbufferSize; time_t startTime, endTime; - afs_int32 goodrestore=0; + afs_int32 goodrestore = 0; taskId = newNode->taskID; setStatus(taskId, DRIVE_WAIT); EnterDeviceQueue(deviceLatch); clearStatus(taskId, DRIVE_WAIT); - + printf("\n\n"); - TLog (taskId, "Restore\n"); + TLog(taskId, "Restore\n"); memset(&tapeInfo, 0, sizeof(tapeInfo)); if (!CONF_XBSA) { - tapeInfo.structVersion = BUTM_MAJORVERSION; - tcode = butm_file_Instantiate (&tapeInfo, &globalTapeConfig); - if (tcode) { - ErrorLog(0, taskId, tcode, tapeInfo.error, - "Can't initialize the tape module\n"); - ERROR_EXIT(tcode); - } + tapeInfo.structVersion = BUTM_MAJORVERSION; + tcode = butm_file_Instantiate(&tapeInfo, &globalTapeConfig); + if (tcode) { + ErrorLog(0, taskId, tcode, tapeInfo.error, + "Can't initialize the tape module\n"); + ERROR_EXIT(tcode); + } } - if ( checkAbortByTaskId(taskId) ) ERROR_EXIT(TC_ABORTEDBYREQUEST); + if (checkAbortByTaskId(taskId)) + ERROR_EXIT(TC_ABORTEDBYREQUEST); memset(&rparams, 0, sizeof(rparams)); - rparams.nodePtr = newNode; + rparams.nodePtr = newNode; rparams.tapeInfoPtr = &tapeInfo; - Restore = newNode->restores; /* Array of vol fragments to restore */ + Restore = newNode->restores; /* Array of vol fragments to restore */ /* Allocate memory in which to restore the volumes data into */ if (CONF_XBSA) { - allocbufferSize = dataSize = BufferSize; + allocbufferSize = dataSize = BufferSize; } else { - /* Must have at least two tape blocks */ - tapeblocks = BufferSize / BUTM_BLOCKSIZE; - if (tapeblocks < 2) tapeblocks = 2; - allocbufferSize = tapeblocks * BUTM_BLOCKSIZE; /* This many full tapeblocks */ + /* Must have at least two tape blocks */ + tapeblocks = BufferSize / BUTM_BLOCKSIZE; + if (tapeblocks < 2) + tapeblocks = 2; + allocbufferSize = tapeblocks * BUTM_BLOCKSIZE; /* This many full tapeblocks */ } bufferBlock = NULL; - bufferBlock = (struct TapeBlock *) malloc(allocbufferSize); - if (!bufferBlock) ERROR_EXIT(TC_NOMEMORY); + bufferBlock = (struct TapeBlock *)malloc(allocbufferSize); + if (!bufferBlock) + ERROR_EXIT(TC_NOMEMORY); memset(bufferBlock, 0, allocbufferSize); startTime = time(0); - for (rparams.frag=0; (rparams.frag < newNode->arraySize); rparams.frag++) { - RestoreDesc = &Restore[rparams.frag]; - - /* Skip the volume if it was requested to */ - if (RestoreDesc->flags & RDFLAG_SKIP) { - if (RestoreDesc->flags & RDFLAG_LASTDUMP) { - /* If the volume was restored, should bring it online */ - } - continue; + for (rparams.frag = 0; (rparams.frag < newNode->arraySize); + rparams.frag++) { + RestoreDesc = &Restore[rparams.frag]; + + /* Skip the volume if it was requested to */ + if (RestoreDesc->flags & RDFLAG_SKIP) { + if (RestoreDesc->flags & RDFLAG_LASTDUMP) { + /* If the volume was restored, should bring it online */ + } + continue; } newVolName = RestoreDesc->newName; /* Make sure the server to restore to is good */ if (!RestoreDesc->hostAddr) { - ErrorLog(0, taskId, 0, 0, "Illegal host ID 0 for volume %s\n", newVolName); + ErrorLog(0, taskId, 0, 0, "Illegal host ID 0 for volume %s\n", + newVolName); ERROR_EXIT(TC_INTERNALERROR); } - if ( checkAbortByTaskId(taskId) ) - ERROR_EXIT(TC_ABORTEDBYREQUEST); + if (checkAbortByTaskId(taskId)) + ERROR_EXIT(TC_ABORTEDBYREQUEST); TapeLog(1, taskId, 0, 0, "Restoring volume %s\n", newVolName); lock_Status(); - strncpy(newNode->statusNodePtr->volumeName, newVolName, BU_MAXNAMELEN); + strncpy(newNode->statusNodePtr->volumeName, newVolName, + BU_MAXNAMELEN); unlock_Status(); /* restoreVolume function takes care of all the related fragments @@ -1746,23 +1837,25 @@ Restorer (newNode) * restored */ if (CONF_XBSA) { - tcode = xbsaRestoreVolume(taskId, RestoreDesc, &rparams); + tcode = xbsaRestoreVolume(taskId, RestoreDesc, &rparams); } else { - tcode = restoreVolume(taskId, RestoreDesc, &rparams); + tcode = restoreVolume(taskId, RestoreDesc, &rparams); } if (tcode) { if (tcode == TC_ABORTEDBYREQUEST) { - ERROR_EXIT(tcode); + ERROR_EXIT(tcode); } else if (tcode == TC_SKIPTAPE) { - afs_uint32 tapeID; - tapeID = (RestoreDesc->initialDumpId ? RestoreDesc->initialDumpId : - RestoreDesc->dbDumpId); - SkipTape(Restore, newNode->arraySize, rparams.frag, - RestoreDesc->tapeName, tapeID, taskId); + afs_uint32 tapeID; + tapeID = + (RestoreDesc->initialDumpId ? RestoreDesc-> + initialDumpId : RestoreDesc->dbDumpId); + SkipTape(Restore, newNode->arraySize, rparams.frag, + RestoreDesc->tapeName, tapeID, taskId); } else { - ErrorLog(0, taskId, tcode, 0, "Can't restore volume %s\n", newVolName); - SkipVolume(Restore, newNode->arraySize, rparams.frag, - RestoreDesc->origVid, taskId); + ErrorLog(0, taskId, tcode, 0, "Can't restore volume %s\n", + newVolName); + SkipVolume(Restore, newNode->arraySize, rparams.frag, + RestoreDesc->origVid, taskId); } rparams.frag--; continue; @@ -1774,73 +1867,68 @@ Restorer (newNode) error_exit: endTime = time(0); if (!CONF_XBSA) { - unmountTape(taskId, &tapeInfo); + unmountTape(taskId, &tapeInfo); } else { #ifdef xbsa - rc = InitToServer(taskId, &butxInfo, 0); /* Return to original server */ + rc = InitToServer(taskId, &butxInfo, 0); /* Return to original server */ #endif } - if (bufferBlock) free(bufferBlock); + if (bufferBlock) + free(bufferBlock); - if (code == TC_ABORTEDBYREQUEST) - { - ErrorLog(0, taskId, 0, 0, "Restore: Aborted by request\n"); + if (code == TC_ABORTEDBYREQUEST) { + ErrorLog(0, taskId, 0, 0, "Restore: Aborted by request\n"); clearStatus(taskId, ABORT_REQUEST); - setStatus (taskId, ABORT_DONE); - } - else if (code) - { - TapeLog(0, taskId, code, 0, "Restore: Finished with errors\n"); + setStatus(taskId, ABORT_DONE); + } else if (code) { + TapeLog(0, taskId, code, 0, "Restore: Finished with errors\n"); setStatus(taskId, TASK_ERROR); - } - else - { - TLog(taskId, "Restore: Finished\n"); + } else { + TLog(taskId, "Restore: Finished\n"); } if (centralLogIO && startTime) { - long timediff; - afs_int32 hrs, min, sec, tmp; - char line[1024]; - struct tm tmstart, tmend; - - localtime_r(&startTime, &tmstart); - localtime_r(&endTime, &tmend); - timediff = (int)endTime - (int)startTime; - hrs = timediff / 3600; - tmp = timediff % 3600; - min = tmp / 60; - sec = tmp % 60; - - sprintf(line, "%-5d %02d/%02d/%04d %02d:%02d:%02d " - "%02d/%02d/%04d %02d:%02d:%02d " - "%02d:%02d:%02d " - "%d of %d volume%s restored\n", - taskId, tmstart.tm_mon+1, tmstart.tm_mday, tmstart.tm_year+1900, - tmstart.tm_hour, tmstart.tm_min, tmstart.tm_sec, - tmend.tm_mon+1, tmend.tm_mday, tmend.tm_year+1900, - tmend.tm_hour, tmend.tm_min, tmend.tm_sec, - hrs, min, sec, - goodrestore, newNode->arraySize, ((newNode->arraySize>1)?"s":"")); - - fwrite(line, strlen(line), 1, centralLogIO); - fflush(centralLogIO); + long timediff; + afs_int32 hrs, min, sec, tmp; + char line[1024]; + struct tm tmstart, tmend; + + localtime_r(&startTime, &tmstart); + localtime_r(&endTime, &tmend); + timediff = (int)endTime - (int)startTime; + hrs = timediff / 3600; + tmp = timediff % 3600; + min = tmp / 60; + sec = tmp % 60; + + sprintf(line, + "%-5d %02d/%02d/%04d %02d:%02d:%02d " + "%02d/%02d/%04d %02d:%02d:%02d " "%02d:%02d:%02d " + "%d of %d volume%s restored\n", taskId, tmstart.tm_mon + 1, + tmstart.tm_mday, tmstart.tm_year + 1900, tmstart.tm_hour, + tmstart.tm_min, tmstart.tm_sec, tmend.tm_mon + 1, + tmend.tm_mday, tmend.tm_year + 1900, tmend.tm_hour, + tmend.tm_min, tmend.tm_sec, hrs, min, sec, goodrestore, + newNode->arraySize, ((newNode->arraySize > 1) ? "s" : "")); + + fwrite(line, strlen(line), 1, centralLogIO); + fflush(centralLogIO); } setStatus(taskId, TASK_DONE); FreeNode(taskId); LeaveDeviceQueue(deviceLatch); - return(code); -} + return (code); +} /* this is just scaffolding, creates new tape label with name */ GetNewLabel(tapeInfoPtr, pName, AFSName, tapeLabel) - struct butm_tapeInfo *tapeInfoPtr; - char *pName, *AFSName; - struct butm_tapeLabel *tapeLabel; + struct butm_tapeInfo *tapeInfoPtr; + char *pName, *AFSName; + struct butm_tapeLabel *tapeLabel; { struct timeval tp; struct timezone tzp; @@ -1849,122 +1937,134 @@ GetNewLabel(tapeInfoPtr, pName, AFSName, tapeLabel) memset(tapeLabel, 0, sizeof(struct butm_tapeLabel)); if (!CONF_XBSA) { - butm_GetSize(tapeInfoPtr, &size); - if ( !size ) size = globalTapeConfig.capacity; + butm_GetSize(tapeInfoPtr, &size); + if (!size) + size = globalTapeConfig.capacity; } else { - size = 0; /* no tape size */ - } - gettimeofday(&tp,&tzp); - - tapeLabel->structVersion = CUR_TAPE_VERSION; - tapeLabel->creationTime = tp.tv_sec; - tapeLabel->size = size; - tapeLabel->expirationDate = 0; /* 1970 sometime */ - tapeLabel->dumpPath[0] = 0; /* no path name */ - tapeLabel->useCount = 0; - strcpy(tapeLabel->AFSName, AFSName); - strcpy(tapeLabel->pName, pName); - strcpy(tapeLabel->cell, globalCellName); - strcpy(tapeLabel->comment, "AFS Backup Software"); - strcpy(tapeLabel->creator.name, "AFS 3.6"); + size = 0; /* no tape size */ + } + gettimeofday(&tp, &tzp); + + tapeLabel->structVersion = CUR_TAPE_VERSION; + tapeLabel->creationTime = tp.tv_sec; + tapeLabel->size = size; + tapeLabel->expirationDate = 0; /* 1970 sometime */ + tapeLabel->dumpPath[0] = 0; /* no path name */ + tapeLabel->useCount = 0; + strcpy(tapeLabel->AFSName, AFSName); + strcpy(tapeLabel->pName, pName); + strcpy(tapeLabel->cell, globalCellName); + strcpy(tapeLabel->comment, "AFS Backup Software"); + strcpy(tapeLabel->creator.name, "AFS 3.6"); strcpy(tapeLabel->creator.instance, ""); - strcpy(tapeLabel->creator.cell, globalCellName); + strcpy(tapeLabel->creator.cell, globalCellName); } /* extracts trailer out of buffer, nbytes is set to total data in buffer - trailer size */ afs_int32 ExtractTrailer(buffer, size, nbytes, volTrailerPtr) - char *buffer; - afs_int32 *nbytes; - afs_int32 size; - struct volumeHeader *volTrailerPtr; -{ - afs_int32 code = 0; - afs_int32 startPos; + char *buffer; + afs_int32 *nbytes; + afs_int32 size; + struct volumeHeader *volTrailerPtr; +{ + afs_int32 code = 0; + afs_int32 startPos; struct volumeHeader tempTrailer; for (startPos = 0; - startPos <= (size - sizeof(struct volumeHeader) + sizeof(tempTrailer.pad)); - startPos++) - { - code = readVolumeHeader(buffer, startPos, &tempTrailer); - if (code == 0) - { + startPos <= + (size - sizeof(struct volumeHeader) + sizeof(tempTrailer.pad)); + startPos++) { + code = readVolumeHeader(buffer, startPos, &tempTrailer); + if (code == 0) { code = VolHeaderToHost(volTrailerPtr, &tempTrailer); - if (code) break; + if (code) + break; - if (nbytes) *nbytes = startPos; - return 1; /* saw the trailer */ + if (nbytes) + *nbytes = startPos; + return 1; /* saw the trailer */ } } - if (nbytes) *nbytes = size/2; - return 0; /* did not see the trailer */ + if (nbytes) + *nbytes = size / 2; + return 0; /* did not see the trailer */ } int FindVolTrailer(buffer, size, dSize, volTrailerPtr) - char *buffer; - afs_int32 size; - struct volumeHeader *volTrailerPtr; - afs_int32 *dSize; /* dataSize */ + char *buffer; + afs_int32 size; + struct volumeHeader *volTrailerPtr; + afs_int32 *dSize; /* dataSize */ { afs_int32 offset, s; afs_int32 code; int found; - + *dSize = size; - if (!buffer) return 0; + if (!buffer) + return 0; - s = sizeof(struct volumeHeader) + sizeof(volTrailerPtr->pad); - if (s > size) s = size; + s = sizeof(struct volumeHeader) + sizeof(volTrailerPtr->pad); + if (s > size) + s = size; - found = ExtractTrailer((buffer+size-s),s,&offset,volTrailerPtr); - if (found) *dSize -= (s - offset); + found = ExtractTrailer((buffer + size - s), s, &offset, volTrailerPtr); + if (found) + *dSize -= (s - offset); return found; } int -FindVolTrailer2(buffera, sizea, dataSizea, bufferb, sizeb, dataSizeb, volTrailerPtr) - char *buffera; - afs_int32 sizea; - afs_int32 *dataSizea; - char *bufferb; - afs_int32 sizeb; - afs_int32 *dataSizeb; - struct volumeHeader *volTrailerPtr; +FindVolTrailer2(buffera, sizea, dataSizea, bufferb, sizeb, dataSizeb, + volTrailerPtr) + char *buffera; + afs_int32 sizea; + afs_int32 *dataSizea; + char *bufferb; + afs_int32 sizeb; + afs_int32 *dataSizeb; + struct volumeHeader *volTrailerPtr; { afs_int32 offset, s; afs_int32 headB, tailB; - int found=0; + int found = 0; - if ( !buffera ) sizea = 0; - if ( !bufferb ) sizeb = 0; + if (!buffera) + sizea = 0; + if (!bufferb) + sizeb = 0; *dataSizea = sizea; *dataSizeb = sizeb; - s = sizeof(struct volumeHeader) + sizeof(volTrailerPtr->pad); + s = sizeof(struct volumeHeader) + sizeof(volTrailerPtr->pad); if (sizeb >= s) { - found = FindVolTrailer(bufferb, sizeb, dataSizeb, volTrailerPtr); + found = FindVolTrailer(bufferb, sizeb, dataSizeb, volTrailerPtr); } else { - tailB = sizeb; - headB = (s - sizeb); /*(s > sizeb)*/ + tailB = sizeb; + headB = (s - sizeb); /*(s > sizeb) */ if (headB > sizea) { headB = sizea; s = headB + tailB; - if (!s) return 0; + if (!s) + return 0; } - + memset(tapeVolumeHT, 0, sizeof(tapeVolumeHT)); - if (headB) memcpy(tapeVolumeHT , buffera + sizea - headB, headB); - if (tailB) memcpy(tapeVolumeHT + headB, bufferb , tailB); - if (ExtractTrailer (tapeVolumeHT, s, &offset, volTrailerPtr)) { + if (headB) + memcpy(tapeVolumeHT, buffera + sizea - headB, headB); + if (tailB) + memcpy(tapeVolumeHT + headB, bufferb, tailB); + if (ExtractTrailer(tapeVolumeHT, s, &offset, volTrailerPtr)) { found = 1; if (offset > headB) { - /* *dataSizea remains unchanged */ - *dataSizeb = offset - headB; + /* *dataSizea remains unchanged */ + *dataSizeb = offset - headB; } else { - *dataSizea -= (headB - offset); /*(headB >= offset)*/ + *dataSizea -= (headB - offset); /*(headB >= offset) */ *dataSizeb = 0; } } @@ -1974,40 +2074,42 @@ FindVolTrailer2(buffera, sizea, dataSizea, bufferb, sizeb, dataSizeb, volTrailer /* Returns true or false depending on whether the tape is expired or not */ -Date ExpirationDate (dumpid) - afs_int32 dumpid; +Date +ExpirationDate(dumpid) + afs_int32 dumpid; { - afs_int32 code; - Date expiration = 0; - struct budb_dumpEntry dumpEntry; - struct budb_tapeEntry tapeEntry; + afs_int32 code; + Date expiration = 0; + struct budb_dumpEntry dumpEntry; + struct budb_tapeEntry tapeEntry; struct budb_volumeEntry volEntry; - - if (dumpid) - { - /* + + if (dumpid) { + /* * Get the expiration date from DB if its there. The expiration of any tape * will be the most future expiration of any dump in the set. Can't use * bcdb_FindTape because dumpid here pertains to the initial dump id. */ - code = bcdb_FindLastTape(dumpid, &dumpEntry, &tapeEntry, &volEntry); - if (!code) expiration = tapeEntry.expires; + code = bcdb_FindLastTape(dumpid, &dumpEntry, &tapeEntry, &volEntry); + if (!code) + expiration = tapeEntry.expires; } - return(expiration); + return (expiration); } -int -tapeExpired (tapeLabelPtr) - struct butm_tapeLabel *tapeLabelPtr; +int +tapeExpired(tapeLabelPtr) + struct butm_tapeLabel *tapeLabelPtr; { - Date expiration; - struct timeval tp; - struct timezone tzp; - + Date expiration; + struct timeval tp; + struct timezone tzp; + expiration = ExpirationDate(tapeLabelPtr->dumpid); - if (!expiration) expiration = tapeLabelPtr->expirationDate; + if (!expiration) + expiration = tapeLabelPtr->expirationDate; - gettimeofday (&tp, &tzp); + gettimeofday(&tp, &tzp); return ((expiration < tp.tv_sec) ? 1 : 0); } @@ -2034,98 +2136,90 @@ updateTapeLabel(labelIfPtr, tapeInfoPtr, newLabelPtr) interactiveFlag = autoQuery; taskId = labelIfPtr->taskId; - while (1) - { - if ( interactiveFlag ) - { - code = PromptForTape(LABELOPCODE, TNAME(newLabelPtr), 0, - labelIfPtr->taskId, tapecount); - if (code) ERROR_EXIT(code); - } - interactiveFlag = 1; - tapecount++; - - /* mount the tape */ - code = butm_Mount(tapeInfoPtr, newLabelPtr->AFSName); - if (code) - { - TapeLog(0, taskId, code, tapeInfoPtr->error, "Can't open tape\n"); - goto newtape; - } - - code = butm_ReadLabel(tapeInfoPtr, &oldLabel, 1); /* will rewind the tape */ - if (!code) - { - tapeIsLabeled = 1; - - if ( (strcmp(newLabelPtr->AFSName,"") != 0) && - (strcmp(oldLabel.pName,"") != 0) ) { - /* We are setting the AFS name, yet tape - * has a permanent name (not allowed). - */ - TLog(taskId, "Can't label. Tape has permanent label '%s'\n", - oldLabel.pName); - goto newtape; - } - - if ( !tapeExpired(&oldLabel) ) - { - if (!queryoperator) - { - TLog(taskId, "This tape has not expired\n"); - goto newtape; - } - if ( Ask("This tape has not expired - proceed") == 0 ) goto newtape; - } - - /* Keep the permanent name */ - if (strcmp(newLabelPtr->pName,"") == 0) - { - strcpy(newLabelPtr->pName, oldLabel.pName); - } - else if (strcmp(newLabelPtr->pName, TC_NULLTAPENAME) == 0) - { - strcpy(newLabelPtr->pName, ""); - } - } - - /* extract useful information from the old label */ - if ( tapeIsLabeled && oldLabel.structVersion >= TAPE_VERSION_3 ) - { - newLabelPtr->dumpid = 0; - newLabelPtr->useCount = oldLabel.useCount + 1; - } - - /* now write the new label */ - code = butm_Create(tapeInfoPtr, newLabelPtr, 1); /* will rewind the tape */ - if (code) - { - ErrorLog(0, taskId, code, tapeInfoPtr->error, "Can't label tape\n"); - goto newtape; - } - - break; - - newtape: - unmountTape(taskId, tapeInfoPtr); + while (1) { + if (interactiveFlag) { + code = + PromptForTape(LABELOPCODE, TNAME(newLabelPtr), 0, + labelIfPtr->taskId, tapecount); + if (code) + ERROR_EXIT(code); + } + interactiveFlag = 1; + tapecount++; + + /* mount the tape */ + code = butm_Mount(tapeInfoPtr, newLabelPtr->AFSName); + if (code) { + TapeLog(0, taskId, code, tapeInfoPtr->error, "Can't open tape\n"); + goto newtape; + } + + code = butm_ReadLabel(tapeInfoPtr, &oldLabel, 1); /* will rewind the tape */ + if (!code) { + tapeIsLabeled = 1; + + if ((strcmp(newLabelPtr->AFSName, "") != 0) + && (strcmp(oldLabel.pName, "") != 0)) { + /* We are setting the AFS name, yet tape + * has a permanent name (not allowed). + */ + TLog(taskId, "Can't label. Tape has permanent label '%s'\n", + oldLabel.pName); + goto newtape; + } + + if (!tapeExpired(&oldLabel)) { + if (!queryoperator) { + TLog(taskId, "This tape has not expired\n"); + goto newtape; + } + if (Ask("This tape has not expired - proceed") == 0) + goto newtape; + } + + /* Keep the permanent name */ + if (strcmp(newLabelPtr->pName, "") == 0) { + strcpy(newLabelPtr->pName, oldLabel.pName); + } else if (strcmp(newLabelPtr->pName, TC_NULLTAPENAME) == 0) { + strcpy(newLabelPtr->pName, ""); + } + } + + /* extract useful information from the old label */ + if (tapeIsLabeled && oldLabel.structVersion >= TAPE_VERSION_3) { + newLabelPtr->dumpid = 0; + newLabelPtr->useCount = oldLabel.useCount + 1; + } + + /* now write the new label */ + code = butm_Create(tapeInfoPtr, newLabelPtr, 1); /* will rewind the tape */ + if (code) { + ErrorLog(0, taskId, code, tapeInfoPtr->error, + "Can't label tape\n"); + goto newtape; + } + + break; + + newtape: + unmountTape(taskId, tapeInfoPtr); } /* delete obsolete information from the database */ - if ( tapeIsLabeled && oldLabel.structVersion >= TAPE_VERSION_3 ) - { - /* delete based on dump id */ - if ( oldLabel.dumpid ) - { - i = bcdb_deleteDump(oldLabel.dumpid, 0, 0, 0); - if ( i && (i != BUDB_NOENT) ) - ErrorLog(0, taskId, i, 0, - "Warning: Can't delete old dump %u from database\n", oldLabel.dumpid); - } - } - -error_exit: + if (tapeIsLabeled && oldLabel.structVersion >= TAPE_VERSION_3) { + /* delete based on dump id */ + if (oldLabel.dumpid) { + i = bcdb_deleteDump(oldLabel.dumpid, 0, 0, 0); + if (i && (i != BUDB_NOENT)) + ErrorLog(0, taskId, i, 0, + "Warning: Can't delete old dump %u from database\n", + oldLabel.dumpid); + } + } + + error_exit: unmountTape(taskId, tapeInfoPtr); - return(code); + return (code); } /* Labeller @@ -2133,62 +2227,60 @@ error_exit: * specified by