pykafs.so: afs_xg.c afs_py.c afs_py.h
python3 compile_pykafs.py build
-afs_xg.c afs_py.c afs_py.h: afs_xg.h ./rxgen/rxgen.pl
- ./rxgen/rxgen.pl afs_xg.h
+AFS_API := afs.h afs_vl.h afs_fs.h afs_cm.h
+
+afs_xg.c afs_py.c afs_py.h: $(AFS_API) ./rxgen/rxgen.pl
+ ./rxgen/rxgen.pl $(AFS_API)
clean:
find \( -name "*~" -o -name "*.o" -o -name "*.so" \) -delete
/* AFS common types
*
- * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
+ * Copyright (C) 2002, 2007, 2014 Red Hat, Inc. All Rights Reserved.
* Written by David Howells (dhowells@redhat.com)
*
* This program is free software; you can redistribute it and/or
#include <netinet/in.h>
-#define AFS_MAXCELLNAME 64 /* maximum length of a cell name */
-#define AFS_MAXVOLNAME 64 /* maximum length of a volume name */
-#define AFSNAMEMAX 256 /* maximum length of a filename plus NUL */
-#define AFSPATHMAX 1024 /* maximum length of a pathname plus NUL */
-#define AFSOPAQUEMAX 1024 /* maximum length of an opaque field */
+#include "rxgen.h"
-typedef uint32_t afs_volid_t;
-typedef uint32_t afs_vnodeid_t;
-typedef uint64_t afs_dataversion_t;
+#define AFS_MAXCELLNAME 64 /* maximum length of a cell name */
+#define AFS_MAXVOLNAME 64 /* maximum length of a volume name */
+#define AFSNAMEMAX 256 /* maximum length of a filename plus NUL */
+#define AFSPATHMAX 1024 /* maximum length of a pathname plus NUL */
+#define AFSOPAQUEMAX 1024 /* maximum length of an opaque field */
-typedef enum {
- AFSVL_RWVOL, /* read/write volume */
- AFSVL_ROVOL, /* read-only volume */
- AFSVL_BACKVOL, /* backup volume */
-} __attribute__((packed)) afs_voltype_t;
+#define MAXTYPES 3
+#define MAXNSERVERS 8
+#define MAXNAMELEN 65
-typedef enum {
- AFS_FTYPE_INVALID = 0,
- AFS_FTYPE_FILE = 1,
- AFS_FTYPE_DIR = 2,
- AFS_FTYPE_SYMLINK = 3,
-} afs_file_type_t;
+#define AFS_RWVOL 0 /* read/write volume */
+#define AFS_ROVOL 1 /* read-only volume */
+#define AFS_BACKVOL 2 /* backup volume */
-typedef enum {
- AFS_LOCK_READ = 0, /* read lock request */
- AFS_LOCK_WRITE = 1, /* write lock request */
-} afs_lock_type_t;
+#define AFS_FTYPE_INVALID 0
+#define AFS_FTYPE_FILE 1
+#define AFS_FTYPE_DIR 2
+#define AFS_FTYPE_SYMLINK 3
-#define AFS_LOCKWAIT (5 * 60) /* time until a lock times out (seconds) */
-
-/*
- * AFS file identifier
- */
-struct afs_fid {
- afs_volid_t vid; /* volume ID */
- afs_vnodeid_t vnode; /* file index within volume */
- unsigned unique; /* unique ID number (file index version) */
-};
-
-/*
- * AFS callback notification
- */
-typedef enum {
- AFSCM_CB_UNTYPED = 0, /* no type set on CB break */
- AFSCM_CB_EXCLUSIVE = 1, /* CB exclusive to CM [not implemented] */
- AFSCM_CB_SHARED = 2, /* CB shared by other CM's */
- AFSCM_CB_DROPPED = 3, /* CB promise cancelled by file server */
-} afs_callback_type_t;
-
-struct afs_callback {
- struct afs_fid fid; /* file identifier */
- unsigned version; /* callback version */
- unsigned expiry; /* time at which expires */
- afs_callback_type_t type; /* type of callback */
-};
-
-#define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */
-
-/*
- * AFS volume information
- */
-struct afs_volume_info {
- afs_volid_t vid; /* volume ID */
- afs_voltype_t type; /* type of this volume */
- afs_volid_t type_vids[5]; /* volume ID's for possible types for this vol */
-
- /* list of fileservers serving this volume */
- size_t nservers; /* number of entries used in servers[] */
- struct {
- struct in_addr addr; /* fileserver address */
- } servers[8];
-};
-
-/*
- * AFS security ACE access mask
- */
-typedef unsigned afs_access_t;
-#define AFS_ACE_READ 0x00000001U /* - permission to read a file/dir */
-#define AFS_ACE_WRITE 0x00000002U /* - permission to write/chmod a file */
-#define AFS_ACE_INSERT 0x00000004U /* - permission to create dirent in a dir */
-#define AFS_ACE_LOOKUP 0x00000008U /* - permission to lookup a file/dir in a dir */
-#define AFS_ACE_DELETE 0x00000010U /* - permission to delete a dirent from a dir */
-#define AFS_ACE_LOCK 0x00000020U /* - permission to lock a file */
-#define AFS_ACE_ADMINISTER 0x00000040U /* - permission to change ACL */
-#define AFS_ACE_USER_A 0x01000000U /* - 'A' user-defined permission */
-#define AFS_ACE_USER_B 0x02000000U /* - 'B' user-defined permission */
-#define AFS_ACE_USER_C 0x04000000U /* - 'C' user-defined permission */
-#define AFS_ACE_USER_D 0x08000000U /* - 'D' user-defined permission */
-#define AFS_ACE_USER_E 0x10000000U /* - 'E' user-defined permission */
-#define AFS_ACE_USER_F 0x20000000U /* - 'F' user-defined permission */
-#define AFS_ACE_USER_G 0x40000000U /* - 'G' user-defined permission */
-#define AFS_ACE_USER_H 0x80000000U /* - 'H' user-defined permission */
+#define AFS_LOCK_READ 0 /* read lock request */
+#define AFS_LOCK_WRITE 1 /* write lock request */
-/*
- * AFS file status information
- */
-struct afs_file_status {
- unsigned if_version; /* interface version */
-#define AFS_FSTATUS_VERSION 1
-
- afs_file_type_t type; /* file type */
- unsigned nlink; /* link count */
- uint64_t size; /* file size */
- afs_dataversion_t data_version; /* current data version */
- uint32_t author; /* author ID */
- uint32_t owner; /* owner ID */
- uint32_t group; /* group ID */
- afs_access_t caller_access; /* access rights for authenticated caller */
- afs_access_t anon_access; /* access rights for unauthenticated caller */
- uint32_t mode; /* UNIX mode */
- struct afs_fid parent; /* parent dir ID for non-dirs only */
- time_t mtime_client; /* last time client changed data */
- time_t mtime_server; /* last time server changed data */
- int32_t lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
-};
-
-/*
- * AFS file status change request
- */
-
-#define AFS_SET_MTIME 0x01 /* set the mtime */
-#define AFS_SET_OWNER 0x02 /* set the owner ID */
-#define AFS_SET_GROUP 0x04 /* set the group ID (unsupported?) */
-#define AFS_SET_MODE 0x08 /* set the UNIX mode */
-#define AFS_SET_SEG_SIZE 0x10 /* set the segment size (unsupported) */
-
-/*
- * AFS volume synchronisation information
- */
-struct afs_volsync {
- time_t creation; /* volume creation time */
-};
-
-/*
- * AFS volume status record
- */
-struct afs_volume_status {
- uint32_t vid; /* volume ID */
- uint32_t parent_id; /* parent volume ID */
- uint8_t online; /* true if volume currently online and available */
- uint8_t in_service; /* true if volume currently in service */
- uint8_t blessed; /* same as in_service */
- uint8_t needs_salvage; /* true if consistency checking required */
- uint32_t type; /* volume type (afs_voltype_t) */
- uint32_t min_quota; /* minimum space set aside (blocks) */
- uint32_t max_quota; /* maximum space this volume may occupy (blocks) */
- uint32_t blocks_in_use; /* space this volume currently occupies (blocks) */
- uint32_t part_blocks_avail; /* space available in volume's partition */
- uint32_t part_max_blocks; /* size of volume's partition */
-};
-
-#define AFS_BLOCK_SIZE 1024
+#define AFS_LOCKWAIT (5 * 60) /* time until a lock times out (seconds) */
#endif /* AFS_H */
VMOVED = 111, /* volume moved to new server - ask this FS where */
};
+/*
+ * AFS file identifier
+ */
+struct AFSFid {
+ uint32_t vid; /* Volume ID */
+ uint32_t vnode; /* File index within volume */
+ uint32_t unique; /* Unique ID number (file index version) */
+};
+
+/*
+ * AFS callback notification
+ */
+#define AFSCM_CB_UNTYPED 0 /* No type set on CB break */
+#define AFSCM_CB_EXCLUSIVE 1 /* CB exclusive to CM [not implemented] */
+#define AFSCM_CB_SHARED 2 /* CB shared by other CM's */
+#define AFSCM_CB_DROPPED 3 /* CB promise cancelled by file server */
+
+struct AFSCallBack {
+ uint32_t CallBackVersion; /* Callback version number */
+ uint32_t ExpirationTime; /* Time when callback expires */
+ uint32_t CallBackType; /* Type of callback */
+};
+
+#define AFSCBMAX 50 /* Maximum callbacks transferred per bulk op */
+
+/*
+ * AFS security ACE access mask
+ */
+#define AFS_ACE_READ 0x00000001U /* - permission to read a file/dir */
+#define AFS_ACE_WRITE 0x00000002U /* - permission to write/chmod a file */
+#define AFS_ACE_INSERT 0x00000004U /* - permission to create dirent in a dir */
+#define AFS_ACE_LOOKUP 0x00000008U /* - permission to lookup a file/dir in a dir */
+#define AFS_ACE_DELETE 0x00000010U /* - permission to delete a dirent from a dir */
+#define AFS_ACE_LOCK 0x00000020U /* - permission to lock a file */
+#define AFS_ACE_ADMINISTER 0x00000040U /* - permission to change ACL */
+#define AFS_ACE_USER_A 0x01000000U /* - 'A' user-defined permission */
+#define AFS_ACE_USER_B 0x02000000U /* - 'B' user-defined permission */
+#define AFS_ACE_USER_C 0x04000000U /* - 'C' user-defined permission */
+#define AFS_ACE_USER_D 0x08000000U /* - 'D' user-defined permission */
+#define AFS_ACE_USER_E 0x10000000U /* - 'E' user-defined permission */
+#define AFS_ACE_USER_F 0x20000000U /* - 'F' user-defined permission */
+#define AFS_ACE_USER_G 0x40000000U /* - 'G' user-defined permission */
+#define AFS_ACE_USER_H 0x80000000U /* - 'H' user-defined permission */
+
+/*
+ * AFS returned file status information (AFS-3 FS/CM Programmer's Ref #5.1.2.3)
+ */
+struct AFSFetchStatus {
+ uint32_t InterfaceVersion; /* Interface version */
+#define AFS_FSTATUS_VERSION 1
+ uint32_t FileType; /* File type */
+ uint32_t LinkCount; /* File hard link count */
+ uint32_t Length; /* File size */
+ uint32_t DataVersion; /* Object's data version */
+ uint32_t Author; /* Author ID */
+ uint32_t Owner; /* Owner ID */
+ uint32_t CallerAccess; /* Access rights for authenticated caller */
+ uint32_t AnonymousAccess; /* Access rights for unauthenticated caller */
+ uint32_t UnixModeBits; /* UNIX file mode mask */
+ uint32_t ParentVnode; /* Parent dir ID */
+ uint32_t ParentUnique; /* Parent dir ID uniquifier */
+ uint32_t SegSize; /* - Not implemented */
+ uint32_t ClientModTime; /* Last time client changed data */
+ uint32_t ServerModTime; /* Last time server changed data */
+ uint32_t Group; /* - Not implemented */
+ uint32_t SyncCounter; /* - Not implemented */
+ uint32_t _64_DataVersion;
+ uint32_t LockCount; /* File size */
+ uint32_t _64_Length;
+ uint32_t spare[1];
+};
+
+/*
+ * AFS update file status request (AFS-3 FS/CM Programmer's Ref #5.1.2.4)
+ */
+struct AFSStoreStatus {
+ uint32_t Mask; /* Mask indicating attributes to change */
+#define AFS_SET_MTIME 0x01 /* Set the mtime */
+#define AFS_SET_OWNER 0x02 /* Set the owner ID */
+#define AFS_SET_GROUP 0x04 /* Set the group ID (unsupported?) */
+#define AFS_SET_MODE 0x08 /* Set the UNIX mode */
+#define AFS_SET_SEG_SIZE 0x10 /* Set the segment size (unsupported) */
+ uint32_t ClientModTime; /* Last time client changed data */
+ uint32_t Owner; /* Owner ID */
+ uint32_t Group; /* - Not implemented */
+ uint32_t UnixModeBits; /* UNIX file mode mask */
+ uint32_t SegSize; /* - Not implemented */
+};
+
+/*
+ * AFS volume synchronisation information (AFS-3 FS/CM Programmer's Ref #5.1.2.2)
+ */
+struct AFSVolSync {
+ uint32_t creation; /* Volume creation time */
+ uint32_t spare[5];
+};
+
+/*
+ * AFS volume status record (AFS-3 FS/CM Programmer's Ref #5.1.2.8)
+ */
+struct AFSFetchVolumeStatus {
+ uint32_t Vid; /* Volume ID */
+ uint32_t ParentId; /* Parent volume ID */
+ uint8_t Online; /* True if volume currently online and available */
+ uint8_t InService; /* True if volume currently in service */
+ uint8_t Blessed; /* Same as in_service */
+ uint8_t NeedsSalvage; /* True if consistency checking required */
+ uint32_t Type; /* Volume type (afs_voltype_t) */
+ uint32_t MinQuota; /* Minimum space set aside (blocks) */
+ uint32_t MaxQuota; /* Maximum space this volume may occupy (blocks) */
+ uint32_t BlocksInUse; /* Space this volume currently occupies (blocks) */
+ uint32_t PartBlocksAvail; /* Space available in volume's partition */
+ uint32_t PartMaxBlocks; /* Size of volume's partition */
+};
+
+/*
+ * AFS volume status update request (AFS-3 FS/CM Programmer's Ref #5.1.2.9)
+ */
+struct AFSStoreVolumeStatus {
+ uint32_t Mask; /* Mask indicating attributes to change */
+ uint32_t MinQuota; /* Minimum space set aside (blocks) */
+ uint32_t MaxQuota; /* Maximum space this volume may occupy (blocks) */
+};
+
+#define AFS_BLOCK_SIZE 1024
+
+/*
+ * Fetch the status information for a file object (AFS-3 FS/CM Programmer's Ref #5.1.3.2)
+ *
+ * Operation: FSFETCHSTATUS
+ */
+extern int RXAFS_FetchStatus(
+ struct rx_connection *z_conn,
+ /*IN*/ const struct AFSFid *a_fidToStatP,
+ /*OUT*/ struct AFSFetchStatus *a_currStatP,
+ /*OUT*/ struct AFSCallBack *a_callBackP,
+ /*OUT*/ struct AFSVolSync *a_volSyncP);
+
#endif /* AFS_FS_H */
/* AFS Volume Location Service client interface
*
- * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
+ * Copyright (C) 2002, 2007, 2014 Red Hat, Inc. All Rights Reserved.
* Written by David Howells (dhowells@redhat.com)
*
* This program is free software; you can redistribute it and/or
VLDELETEENTRY = 502, /* AFS Delete VLDB entry */
VLGETENTRYBYID = 503, /* AFS Get Cache Entry By ID operation ID */
VLGETENTRYBYNAME = 504, /* AFS Get Cache Entry By Name operation ID */
+ VLGETNEWVOLUMEID = 505, /* AFS Generate a new volume ID */
VLPROBE = 514, /* AFS Probe Volume Location Service operation ID */
};
};
/*
- * maps to "struct vldbentry" in vvl-spec.pdf
+ * Flags for struct vldbentry (AFS-3 Vol/VL Server Spec #3.2.6).
*/
-struct afs_vldbentry {
- char name[AFS_MAXVOLNAME + 1]; /* name of volume (with NUL char) */
- afs_voltype_t type; /* volume type */
- unsigned num_servers; /* num servers that hold instances of this vol */
- unsigned clone_id; /* cloning ID */
-
- unsigned flags;
-#define AFS_VLF_RWEXISTS 0x1000 /* R/W volume exists */
-#define AFS_VLF_ROEXISTS 0x2000 /* R/O volume exists */
-#define AFS_VLF_BACKEXISTS 0x4000 /* backup volume exists */
-
- afs_volid_t volume_ids[3]; /* volume IDs */
-
- struct {
- struct in_addr addr; /* server address */
- unsigned partition; /* partition ID on this server */
- unsigned flags; /* server specific flags */
+#define AFS_VLF_RWEXISTS 0x1000 /* R/W volume exists */
+#define AFS_VLF_ROEXISTS 0x2000 /* R/O volume exists */
+#define AFS_VLF_BACKEXISTS 0x4000 /* backup volume exists */
+
#define AFS_VLSF_NEWREPSITE 0x0001 /* unused */
#define AFS_VLSF_ROVOL 0x0002 /* this server holds a R/O instance of the volume */
#define AFS_VLSF_RWVOL 0x0004 /* this server holds a R/W instance of the volume */
#define AFS_VLSF_BACKVOL 0x0008 /* this server holds a backup instance of the volume */
- } servers[8];
+
+/*
+ * AFS Volume Location Database entry (AFS-3 Vol/VL Server Spec #3.3.1).
+ */
+struct vldbentry {
+ char name[MAXNAMELEN]; /* The volume name */
+ uint32_t volumeType; /* The volume type */
+ uint32_t nServers; /* The number of servers having an instance */
+ uint32_t serverNumber[MAXNSERVERS]; /* Server addresses */
+ uint32_t serverPartition[MAXNSERVERS]; /* Partition ID on corresponding servers */
+ uint32_t serverFlags[MAXNSERVERS]; /* Flags for corresponding servers */
+ uint32_t volumeId[MAXTYPES]; /* Volume ID for each type */
+ uint32_t cloneId; /* Cloning operation ID */
+ uint32_t flags; /* Flags indicating presence of fields */
};
/*
- * rpc_vlocation.c
+ * AFS Volume Location Database entry update request (AFS-3 Vol/VL Server Spec #3.3.5).
+ */
+struct VldbUpdateEntry {
+ uint32_t Mask; /* Bit mask indicating fields to be affected */
+ char name[MAXNAMELEN]; /* The volume name */
+ uint32_t volumeType; /* The volume type */
+ uint32_t flags; /* Used in conjunction with Mask to select valid fields */
+ uint32_t ReadOnlyId; /* The read-only ID */
+ uint32_t BackupId; /* The backup ID */
+ uint32_t cloneId; /* The clone ID */
+ uint32_t nModifiedRepsites; /* Number of replication site entries to be changed */
+ uint32_t RepsitesMask[MAXNSERVERS]; /* Bit mask for each rep site */
+ uint32_t RepsitesTargetServer[MAXNSERVERS]; /* Target servers */
+ uint32_t RepsitesTargetPart[MAXNSERVERS]; /* Target server partitions */
+ uint32_t RepsitesNewServer[MAXNSERVERS]; /* New server sites */
+ uint32_t RepsitesNewPart[MAXNSERVERS]; /* New server partitions */
+ uint32_t RepsitesNewFlags[MAXNSERVERS]; /* Flags applying to each new site */
+};
+
+/*
+ * AFS VLDB list query by-attribute filter (AFS-3 Vol/VL Server Spec #3.3.6).
+ */
+struct VldbListByAttributes {
+ uint32_t Mask; /* Bit mask used to select attr fields to match */
+ uint32_t server; /* The server address to match */
+ uint32_t partition; /* The partition ID to match */
+ uint32_t volumetype; /* The volume type to match */
+ uint32_t volumeid; /* The volume ID to match */
+ uint32_t flag; /* Flags concerning these values */
+};
+
+/*
+ * Create a VLDB entry (AFS-3 Vol/VL Server Spec #3.6.1)
+ *
+ * Operation: VLCREATEENTRY
+ */
+extern int VL_CreateEntry(
+ struct rx_connection *z_conn,
+ /*IN*/ const struct vldbentry *newentry);
+
+/*
+ * Delete a VLDB entry (AFS-3 Vol/VL Server Spec #3.6.2)
+ *
+ * Operation: VLDELETEENTRY
+ */
+extern int VL_DeleteEntry(
+ struct rx_connection *z_conn,
+ /*IN*/ uint32_t Volid,
+ /*IN*/ uint32_t voltype);
+
+/*
+ * Get a VLDB entry by ID/type (AFS-3 Vol/VL Server Spec #3.6.3)
+ *
+ * Operation: VLGETENTRYBYID
+ */
+extern int VL_GetEntryByID(
+ struct rx_connection *z_conn,
+ /*IN*/ uint32_t Volid,
+ /*IN*/ uint32_t voltype,
+ /*OUT*/ struct vldbentry *entry);
+
+/*
+ * Get a VLDB entry by volume name (AFS-3 Vol/VL Server Spec #3.6.4)
+ *
+ * Operation: VLGETENTRYBYNAME
+ */
+extern int VL_GetEntryByName(
+ struct rx_connection *z_conn,
+ /*IN*/ const char *volumename, /* Max MAXNAMELEN */
+ /*OUT*/ struct vldbentry *entry);
+
+/*
+ * Generate a new volume ID (AFS-3 Vol/VL Server Spec #3.6.5)
+ *
+ * Operation: VLGETNEWVOLUMEID
+ */
+extern int VL_GetNewVolumeId(
+ struct rx_connection *z_conn,
+ /*IN*/ uint32_t bumpcount,
+ /*OUT*/ uint32_t *newvolumid);
+
+/*
+ * Probe an AFS VL server (AFS-3 Vol/VL Server Spec #3.6.14)
+ *
+ * Operation: VLPROBE
*/
-struct sockaddr_rxrpc;
-extern int afs_VL_call(struct sockaddr *sa, socklen_t salen,
- const void *request, size_t reqlen, void *reply, size_t replen,
- uint32_t *_abort_code);
-extern int afs_VL_abort_to_error(uint32_t abort_code);
-extern int afs_VL_get_entry_by_name(struct sockaddr *sa, socklen_t salen,
- const char *volname,
- struct afs_vldbentry *entry,
- uint32_t *_abort_code);
+extern int VL_Probe(
+ struct rx_connection *z_conn);
#endif /* AFS_VL_H */
+++ /dev/null
-/* AFS-3 RPC Interface definitions.
- *
- * The contents of this file are processed by a script to produce the interface
- * routines.
- *
- * Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells (dhowells@redhat.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public Licence
- * as published by the Free Software Foundation; either version
- * 2 of the Licence, or (at your option) any later version.
- */
-
-#ifndef _AFS_XG_H
-#define _AFS_XG_H
-
-#include "rxgen.h"
-
-#define AFS_VL_PORT 7003 /* volume location service port */
-#define VL_SERVICE 52 /* RxRPC service ID for the Volume Location service */
-#define AFS_CM_PORT 7001 /* AFS file server port */
-#define CM_SERVICE 1 /* AFS File Service ID */
-
-#define AFS_MAXCELLNAME 64 /* maximum length of a cell name */
-#define AFS_MAXVOLNAME 64 /* maximum length of a volume name */
-#define AFSNAMEMAX 256 /* maximum length of a filename plus NUL */
-#define AFSPATHMAX 1024 /* maximum length of a pathname plus NUL */
-#define AFSOPAQUEMAX 1024 /* maximum length of an opaque field */
-
-#define MAXTYPES 3
-#define MAXNSERVERS 8
-#define MAXNAMELEN 65
-
-enum AFSVL_Operations {
- VLCREATEENTRY = 501, /* AFS Create VLDB entry */
- VLDELETEENTRY = 502, /* AFS Delete VLDB entry */
- VLGETENTRYBYID = 503, /* AFS Get Cache Entry By ID operation ID */
- VLGETENTRYBYNAME = 504, /* AFS Get Cache Entry By Name operation ID */
- VLGETNEWVOLUMEID = 505, /* AFS Generate a new volume ID */
- VLPROBE = 514, /* AFS Probe Volume Location Service operation ID */
-};
-
-/*
- * AFS Volume Location Database entry.
- *
- * As defined in AFS-3 Vol/VL Server Spec #3.3.1.
- */
-struct vldbentry {
- char name[MAXNAMELEN]; /* The volume name */
- uint32_t volumeType; /* The volume type */
- uint32_t nServers; /* The number of servers having an instance */
- uint32_t serverNumber[MAXNSERVERS]; /* Server addresses */
- uint32_t serverPartition[MAXNSERVERS]; /* Partition ID on corresponding servers */
- uint32_t serverFlags[MAXNSERVERS]; /* Flags for corresponding servers */
- uint32_t volumeId[MAXTYPES]; /* Volume ID for each type */
- uint32_t cloneId; /* Cloning operation ID */
- uint32_t flags; /* Flags indicating presence of fields */
-};
-
-/*
- * AFS Volume Location Database entry update request.
- *
- * As defined in AFS-3 Vol/VL Server Spec #3.3.5.
- */
-struct VldbUpdateEntry {
- uint32_t Mask; /* Bit mask indicating fields to be affected */
- char name[MAXNAMELEN]; /* The volume name */
- uint32_t volumeType; /* The volume type */
- uint32_t flags; /* Used in conjunction with Mask to select valid fields */
- uint32_t ReadOnlyId; /* The read-only ID */
- uint32_t BackupId; /* The backup ID */
- uint32_t cloneId; /* The clone ID */
- uint32_t nModifiedRepsites; /* Number of replication site entries to be changed */
- uint32_t RepsitesMask[MAXNSERVERS]; /* Bit mask for each rep site */
- uint32_t RepsitesTargetServer[MAXNSERVERS]; /* Target servers */
- uint32_t RepsitesTargetPart[MAXNSERVERS]; /* Target server partitions */
- uint32_t RepsitesNewServer[MAXNSERVERS]; /* New server sites */
- uint32_t RepsitesNewPart[MAXNSERVERS]; /* New server partitions */
- uint32_t RepsitesNewFlags[MAXNSERVERS]; /* Flags applying to each new site */
-};
-
-/*
- * AFS VLDB list query by-attribute filter.
- *
- * As defined in AFS-3 Vol/VL Server Spec #3.3.6.
- */
-struct VldbListByAttributes {
- uint32_t Mask; /* Bit mask used to select attr fields to match */
- uint32_t server; /* The server address to match */
- uint32_t partition; /* The partition ID to match */
- uint32_t volumetype; /* The volume type to match */
- uint32_t volumeid; /* The volume ID to match */
- uint32_t flag; /* Flags concerning these values */
-};
-
-/*
- * Create a VLDB entry (AFS-3 Vol/VL Server Spec #3.6.1)
- *
- * Operation: VLCREATEENTRY
- */
-extern int VL_CreateEntry(
- struct rx_connection *z_conn,
- /*IN*/ const struct vldbentry *newentry);
-
-/*
- * Delete a VLDB entry (AFS-3 Vol/VL Server Spec #3.6.2)
- *
- * Operation: VLDELETEENTRY
- */
-extern int VL_DeleteEntry(
- struct rx_connection *z_conn,
- /*IN*/ uint32_t Volid,
- /*IN*/ uint32_t voltype);
-
-/*
- * Get a VLDB entry by ID/type (AFS-3 Vol/VL Server Spec #3.6.3)
- *
- * Operation: VLGETENTRYBYID
- */
-extern int VL_GetEntryByID(
- struct rx_connection *z_conn,
- /*IN*/ uint32_t Volid,
- /*IN*/ uint32_t voltype,
- /*OUT*/ struct vldbentry *entry);
-
-/*
- * Get a VLDB entry by volume name (AFS-3 Vol/VL Server Spec #3.6.4)
- *
- * Operation: VLGETENTRYBYNAME
- */
-extern int VL_GetEntryByName(
- struct rx_connection *z_conn,
- /*IN*/ const char *volumename, /* Max MAXNAMELEN */
- /*OUT*/ struct vldbentry *entry);
-
-/*
- * Generate a new volume ID (AFS-3 Vol/VL Server Spec #3.6.5)
- *
- * Operation: VLGETNEWVOLUMEID
- */
-extern int VL_GetNewVolumeId(
- struct rx_connection *z_conn,
- /*IN*/ uint32_t bumpcount,
- /*OUT*/ uint32_t *newvolumid);
-
-/*
- * Probe an AFS VL server (AFS-3 Vol/VL Server Spec #3.6.14)
- *
- * Operation: VLPROBE
- */
-extern int VL_Probe(
- struct rx_connection *z_conn);
-
-#endif /* _AFS_XG_H */
my @files = @ARGV;
-while (my $line = <>) {
- # Gather comments for later attachment to subsequent structs and funcs
- if ($line =~ m@^/[*]@) {
- die if $banner;
- $banner = 1;
- @comment = ( $line );
- next;
- }
- if ($banner) {
- die if ($line !~ /^ [*]/);
- push @comment, $line;
- $banner = 0 if ($line =~ m!^ [*]/!);
- next;
- }
+die "No API files specified" unless (@files);
+
+sub parse_header($) {
+ my ($file) = @_;
+ open my $APIHDR, "<$file" || die $file;
+ while (my $line = <$APIHDR>) {
+ # Gather comments for later attachment to subsequent structs and funcs
+ if ($line =~ m@^/[*]@) {
+ die if $banner;
+ $banner = 1;
+ @comment = ( $line );
+ next;
+ }
+ if ($banner) {
+ die if ($line !~ /^ [*]/);
+ push @comment, $line;
+ $banner = 0 if ($line =~ m!^ [*]/!);
+ next;
+ }
- # Extract #defines
- if ($line =~ /^#define\s+([A-Za-z0-9_]+)\s+(.*)/) {
- $constants{$1} = $2 if ($2);
- @comment = ();
- next;
- }
+ # Extract #defines
+ if ($line =~ /^#define\s+([A-Za-z0-9_]+)\s+(.*)/) {
+ $constants{$1} = $2 if ($2);
+ @comment = ();
+ next;
+ }
- # Extract structures
- if ($line =~ /^struct ([a-zA-Z_][a-zA-Z0-9_]*) {/) {
- $struct = "$1";
- $size = 0;
- @members = ( [ @comment ] );
- next;
- }
+ # Extract structures
+ if ($line =~ /^struct ([a-zA-Z_][a-zA-Z0-9_]*) {/) {
+ $struct = "$1";
+ $size = 0;
+ @members = ( [ @comment ] );
+ next;
+ }
- if ($line =~ /};/ && $struct) {
- push @structs, [ $struct, @members ];
- $struct_sizes{$struct} = $size;
- @members = ();
- $struct = 0;
- next;
- }
+ if ($line =~ /};/ && $struct) {
+ push @structs, [ $struct, @members ];
+ $struct_sizes{$struct} = $size;
+ @members = ();
+ $struct = 0;
+ next;
+ }
- # Extract structure members
- if ($struct) {
- # Strip trailing comments
- $line =~ s@\s*/[*][^*]*[*]/$@@;
-
- if ($line =~ /(uint[0-9]+_t|char)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*;/) {
- push @members, [ $1, $2, -1, -1 ];
- $size += 4;
- #print "nonarray $2\n";
- } elsif ($line =~ /(uint[0-9]+_t|char)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\[\s*([^]]+)\s*\]\s*;/) {
- die "No constant for $1" unless exists $constants{$3};
- my $array_size = $constants{$3};
- push @members, [ $1, $2, $array_size, -1 ];
- $size += $array_size * 4;
- #print "array $2\n";
- } else {
- die "Unrecognised struct member";
+ # Extract structure members
+ if ($struct) {
+ # Strip trailing comments
+ $line =~ s@\s*/[*][^*]*[*]/$@@;
+
+ if ($line =~ /(uint[0-9]+_t|char)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*;/) {
+ push @members, [ $1, $2, -1, -1 ];
+ $size += 4;
+ #print "nonarray $2\n";
+ } elsif ($line =~ /(uint[0-9]+_t|char)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\[\s*([^]]+)\s*\]\s*;/) {
+ my $type = $1;
+ my $name = $2;
+ my $array_size = $3;
+ if ($array_size =~ /^[0-9]+$/) {
+ } elsif (exists $constants{$array_size}) {
+ $array_size = $constants{$array_size};
+ } else {
+ die "In struct $struct: No constant for [$array_size]"
+ }
+ push @members, [ $type, $name, $array_size, -1 ];
+ $size += $array_size * 4;
+ #print "array $2\n";
+ } else {
+ die "Unrecognised struct member";
+ }
}
- }
- # Extract functions
- if ($line =~ /^extern\s+int\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\(\s*\n/) {
- #print "func $1\n";
- $func = "$1";
- @members = ( [ @comment ] );
- next;
- }
+ # Extract functions
+ if ($line =~ /^extern\s+int\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*\(\s*\n/) {
+ #print "func $1\n";
+ $func = "$1";
+ @members = ( [ @comment ] );
+ next;
+ }
- # Extract function parameters
- if ($func) {
- my $dir = "";
- my $const = "";
- my $type = "";
- my $name = "";
- my $term = 0;
- my $max = -1;
+ # Extract function parameters
+ if ($func) {
+ my $dir = "";
+ my $const = "";
+ my $type = "";
+ my $name = "";
+ my $term = 0;
+ my $max = -1;
- chomp $line;
+ chomp $line;
- $dir = $1 if ($line =~ s@/[*](IN|OUT|INOUT)[*]/\s+@@);
+ $dir = $1 if ($line =~ s@/[*](IN|OUT|INOUT)[*]/\s+@@);
- if ($line =~ s@/[*]\s+Max ([0-9]+)\s+[*]/@@) {
- $max = $1;
- } elsif ($line =~ s@/[*]\s+Max ([a-zA-Z0-9_]+)\s+[*]/@@) {
- die "No constant for $1" unless exists $constants{$1};
- $max = $constants{$1};
- }
+ if ($line =~ s@/[*]\s+Max ([0-9]+)\s+[*]/@@) {
+ $max = $1;
+ } elsif ($line =~ s@/[*]\s+Max ([a-zA-Z0-9_]+)\s+[*]/@@) {
+ die "No constant for $1" unless exists $constants{$1};
+ $max = $constants{$1};
+ }
- # Strip trailing comments
- $line =~ s@\s*/[*][^*]*[*]/$@@;
- $line =~ s/\s+$//;
+ # Strip trailing comments
+ $line =~ s@\s*/[*][^*]*[*]/$@@;
+ $line =~ s/\s+$//;
- if ($line =~ s/[)];$//) {
- $term = 1;
- } elsif ($line =~ s/,$//) {
- $term = 0;
- } else {
- die "Unexpected line termination '$line'";
- }
+ if ($line =~ s/[)];$//) {
+ $term = 1;
+ } elsif ($line =~ s/,$//) {
+ $term = 0;
+ } else {
+ die "Unexpected line termination '$line'";
+ }
- $line =~ s/\s+$//;
+ $line =~ s/\s+$//;
- $const = $1 if ($line =~ s@^const\s+@@);
+ $const = $1 if ($line =~ s@^const\s+@@);
- #print "\"", $line, "\"\n";
+ #print "\"", $line, "\"\n";
- if ($line =~ /(struct\s+[a-zA-Z_][a-zA-Z0-9_]*|uint[0-9]+_t|char)\s+([*]*)([a-zA-Z_][a-zA-Z0-9_]*)\s*/) {
- $type = $1 . $2;
- $name = $3;
+ if ($line =~ /(struct\s+[a-zA-Z_][a-zA-Z0-9_]*|uint[0-9]+_t|char)\s+([*]*)([a-zA-Z_][a-zA-Z0-9_]*)\s*/) {
+ $type = $1 . $2;
+ $name = $3;
- #print "- ", $name, " ISA ", $type, " ", $dir, "\n";
- push @members, [ $type, $name, -1, $max, $dir ] unless ($1 eq "struct rx_connection");
- } else {
- die "Unhandled RPC call parameter";
- }
+ #print "- ", $name, " ISA ", $type, " ", $dir, "\n";
+ push @members, [ $type, $name, -1, $max, $dir ] unless ($1 eq "struct rx_connection");
+ } else {
+ die "Unhandled RPC call parameter";
+ }
- if ($term) {
- $funcs{$func} = [ @members ];
- @members = ();
- $func = 0;
- next;
+ if ($term) {
+ $funcs{$func} = [ @members ];
+ @members = ();
+ $func = 0;
+ next;
+ }
}
}
+ close($APIHDR);
}
+foreach my $file (@files) {
+ parse_header($file);
+}
+
+print "Extracted ", scalar keys %constants, " constants\n";
+print "Extracted ", scalar @structs, " types\n";
+print "Extracted ", scalar keys %funcs, " functions\n";
+
###############################################################################
#
# Create the output files and emit the file prologues.
print RXOUT "#include <arpa/inet.h>\n";
print RXOUT "#include \"rxgen.h\"\n";
-foreach $_ (@files) {
- print RXOUT "#include \"$_\"\n";
-}
-
open PYHDR, ">afs_py.h" || die "afs_py.h";
print PYHDR "/* AUTOGENERATED */\n";
print PYHDR "#include <Python.h>\n";
print PYHDR "#include <stdint.h>\n";
-print PYHDR "#include \"afs_xg.h\"\n";
+
+foreach $_ (@files) {
+ print RXOUT "#include \"$_\"\n";
+ print PYHDR "#include \"$_\"\n";
+}
open PYOUT, ">afs_py.c" || die "afs_py.c";
print PYOUT "/* AUTOGENERATED */\n";