135dbfba3SDavid Howells /* YFS protocol bits 235dbfba3SDavid Howells * 335dbfba3SDavid Howells * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved. 435dbfba3SDavid Howells * Written by David Howells (dhowells@redhat.com) 535dbfba3SDavid Howells * 635dbfba3SDavid Howells * This program is free software; you can redistribute it and/or 735dbfba3SDavid Howells * modify it under the terms of the GNU General Public Licence 835dbfba3SDavid Howells * as published by the Free Software Foundation; either version 935dbfba3SDavid Howells * 2 of the Licence, or (at your option) any later version. 1035dbfba3SDavid Howells */ 1135dbfba3SDavid Howells 1235dbfba3SDavid Howells #define YFS_FS_SERVICE 2500 1335dbfba3SDavid Howells #define YFS_CM_SERVICE 2501 1435dbfba3SDavid Howells 1535dbfba3SDavid Howells #define YFSCBMAX 1024 1635dbfba3SDavid Howells 1735dbfba3SDavid Howells enum YFS_CM_Operations { 1835dbfba3SDavid Howells YFSCBProbe = 206, /* probe client */ 1935dbfba3SDavid Howells YFSCBGetLock = 207, /* get contents of CM lock table */ 2035dbfba3SDavid Howells YFSCBXStatsVersion = 209, /* get version of extended statistics */ 2135dbfba3SDavid Howells YFSCBGetXStats = 210, /* get contents of extended statistics data */ 2235dbfba3SDavid Howells YFSCBInitCallBackState3 = 213, /* initialise callback state, version 3 */ 2335dbfba3SDavid Howells YFSCBProbeUuid = 214, /* check the client hasn't rebooted */ 2435dbfba3SDavid Howells YFSCBGetServerPrefs = 215, 2535dbfba3SDavid Howells YFSCBGetCellServDV = 216, 2635dbfba3SDavid Howells YFSCBGetLocalCell = 217, 2735dbfba3SDavid Howells YFSCBGetCacheConfig = 218, 2835dbfba3SDavid Howells YFSCBGetCellByNum = 65537, 2935dbfba3SDavid Howells YFSCBTellMeAboutYourself = 65538, /* get client capabilities */ 3035dbfba3SDavid Howells YFSCBCallBack = 64204, 3135dbfba3SDavid Howells }; 3235dbfba3SDavid Howells 3330062bd1SDavid Howells enum YFS_FS_Operations { 3430062bd1SDavid Howells YFSFETCHACL = 64131, /* YFS Fetch file ACL */ 3530062bd1SDavid Howells YFSFETCHSTATUS = 64132, /* YFS Fetch file status */ 3630062bd1SDavid Howells YFSSTOREACL = 64134, /* YFS Store file ACL */ 3730062bd1SDavid Howells YFSSTORESTATUS = 64135, /* YFS Store file status */ 3830062bd1SDavid Howells YFSREMOVEFILE = 64136, /* YFS Remove a file */ 3930062bd1SDavid Howells YFSCREATEFILE = 64137, /* YFS Create a file */ 4030062bd1SDavid Howells YFSRENAME = 64138, /* YFS Rename or move a file or directory */ 4130062bd1SDavid Howells YFSSYMLINK = 64139, /* YFS Create a symbolic link */ 4230062bd1SDavid Howells YFSLINK = 64140, /* YFS Create a hard link */ 4330062bd1SDavid Howells YFSMAKEDIR = 64141, /* YFS Create a directory */ 4430062bd1SDavid Howells YFSREMOVEDIR = 64142, /* YFS Remove a directory */ 4530062bd1SDavid Howells YFSGETVOLUMESTATUS = 64149, /* YFS Get volume status information */ 4630062bd1SDavid Howells YFSSETVOLUMESTATUS = 64150, /* YFS Set volume status information */ 4730062bd1SDavid Howells YFSSETLOCK = 64156, /* YFS Request a file lock */ 4830062bd1SDavid Howells YFSEXTENDLOCK = 64157, /* YFS Extend a file lock */ 4930062bd1SDavid Howells YFSRELEASELOCK = 64158, /* YFS Release a file lock */ 5030062bd1SDavid Howells YFSLOOKUP = 64161, /* YFS lookup file in directory */ 5130062bd1SDavid Howells YFSFLUSHCPS = 64165, 5230062bd1SDavid Howells YFSFETCHOPAQUEACL = 64168, 5330062bd1SDavid Howells YFSWHOAMI = 64170, 5430062bd1SDavid Howells YFSREMOVEACL = 64171, 5530062bd1SDavid Howells YFSREMOVEFILE2 = 64173, 5630062bd1SDavid Howells YFSSTOREOPAQUEACL2 = 64174, 5730062bd1SDavid Howells YFSINLINEBULKSTATUS = 64536, /* YFS Fetch multiple file statuses with errors */ 5830062bd1SDavid Howells YFSFETCHDATA64 = 64537, /* YFS Fetch file data */ 5930062bd1SDavid Howells YFSSTOREDATA64 = 64538, /* YFS Store file data */ 6030062bd1SDavid Howells YFSUPDATESYMLINK = 64540, 6130062bd1SDavid Howells }; 6230062bd1SDavid Howells 6335dbfba3SDavid Howells struct yfs_xdr_u64 { 6435dbfba3SDavid Howells __be32 msw; 6535dbfba3SDavid Howells __be32 lsw; 6635dbfba3SDavid Howells } __packed; 6735dbfba3SDavid Howells 6835dbfba3SDavid Howells static inline u64 xdr_to_u64(const struct yfs_xdr_u64 x) 6935dbfba3SDavid Howells { 7035dbfba3SDavid Howells return ((u64)ntohl(x.msw) << 32) | ntohl(x.lsw); 7135dbfba3SDavid Howells } 7235dbfba3SDavid Howells 7335dbfba3SDavid Howells static inline struct yfs_xdr_u64 u64_to_xdr(const u64 x) 7435dbfba3SDavid Howells { 7535dbfba3SDavid Howells return (struct yfs_xdr_u64){ .msw = htonl(x >> 32), .lsw = htonl(x) }; 7635dbfba3SDavid Howells } 7735dbfba3SDavid Howells 7835dbfba3SDavid Howells struct yfs_xdr_vnode { 7935dbfba3SDavid Howells struct yfs_xdr_u64 lo; 8035dbfba3SDavid Howells __be32 hi; 8135dbfba3SDavid Howells __be32 unique; 8235dbfba3SDavid Howells } __packed; 8335dbfba3SDavid Howells 8435dbfba3SDavid Howells struct yfs_xdr_YFSFid { 8535dbfba3SDavid Howells struct yfs_xdr_u64 volume; 8635dbfba3SDavid Howells struct yfs_xdr_vnode vnode; 8735dbfba3SDavid Howells } __packed; 8830062bd1SDavid Howells 8930062bd1SDavid Howells 9030062bd1SDavid Howells struct yfs_xdr_YFSFetchStatus { 9130062bd1SDavid Howells __be32 type; 9230062bd1SDavid Howells __be32 nlink; 9330062bd1SDavid Howells struct yfs_xdr_u64 size; 9430062bd1SDavid Howells struct yfs_xdr_u64 data_version; 9530062bd1SDavid Howells struct yfs_xdr_u64 author; 9630062bd1SDavid Howells struct yfs_xdr_u64 owner; 9730062bd1SDavid Howells struct yfs_xdr_u64 group; 9830062bd1SDavid Howells __be32 mode; 9930062bd1SDavid Howells __be32 caller_access; 10030062bd1SDavid Howells __be32 anon_access; 10130062bd1SDavid Howells struct yfs_xdr_vnode parent; 10230062bd1SDavid Howells __be32 data_access_protocol; 10330062bd1SDavid Howells struct yfs_xdr_u64 mtime_client; 10430062bd1SDavid Howells struct yfs_xdr_u64 mtime_server; 10530062bd1SDavid Howells __be32 lock_count; 10630062bd1SDavid Howells __be32 abort_code; 10730062bd1SDavid Howells } __packed; 10830062bd1SDavid Howells 10930062bd1SDavid Howells struct yfs_xdr_YFSCallBack { 11030062bd1SDavid Howells __be32 version; 11130062bd1SDavid Howells struct yfs_xdr_u64 expiration_time; 11230062bd1SDavid Howells __be32 type; 11330062bd1SDavid Howells } __packed; 11430062bd1SDavid Howells 11530062bd1SDavid Howells struct yfs_xdr_YFSStoreStatus { 11630062bd1SDavid Howells __be32 mask; 11730062bd1SDavid Howells __be32 mode; 11830062bd1SDavid Howells struct yfs_xdr_u64 mtime_client; 11930062bd1SDavid Howells struct yfs_xdr_u64 owner; 12030062bd1SDavid Howells struct yfs_xdr_u64 group; 12130062bd1SDavid Howells } __packed; 12230062bd1SDavid Howells 12330062bd1SDavid Howells struct yfs_xdr_RPCFlags { 12430062bd1SDavid Howells __be32 rpc_flags; 12530062bd1SDavid Howells } __packed; 12630062bd1SDavid Howells 12730062bd1SDavid Howells struct yfs_xdr_YFSVolSync { 12830062bd1SDavid Howells struct yfs_xdr_u64 vol_creation_date; 12930062bd1SDavid Howells struct yfs_xdr_u64 vol_update_date; 13030062bd1SDavid Howells struct yfs_xdr_u64 max_quota; 13130062bd1SDavid Howells struct yfs_xdr_u64 blocks_in_use; 13230062bd1SDavid Howells struct yfs_xdr_u64 blocks_avail; 13330062bd1SDavid Howells } __packed; 13430062bd1SDavid Howells 13530062bd1SDavid Howells enum yfs_volume_type { 13630062bd1SDavid Howells yfs_volume_type_ro = 0, 13730062bd1SDavid Howells yfs_volume_type_rw = 1, 13830062bd1SDavid Howells }; 13930062bd1SDavid Howells 14030062bd1SDavid Howells #define yfs_FVSOnline 0x1 14130062bd1SDavid Howells #define yfs_FVSInservice 0x2 14230062bd1SDavid Howells #define yfs_FVSBlessed 0x4 14330062bd1SDavid Howells #define yfs_FVSNeedsSalvage 0x8 14430062bd1SDavid Howells 14530062bd1SDavid Howells struct yfs_xdr_YFSFetchVolumeStatus { 14630062bd1SDavid Howells struct yfs_xdr_u64 vid; 14730062bd1SDavid Howells struct yfs_xdr_u64 parent_id; 14830062bd1SDavid Howells __be32 flags; 14930062bd1SDavid Howells __be32 type; 15030062bd1SDavid Howells struct yfs_xdr_u64 max_quota; 15130062bd1SDavid Howells struct yfs_xdr_u64 blocks_in_use; 15230062bd1SDavid Howells struct yfs_xdr_u64 part_blocks_avail; 15330062bd1SDavid Howells struct yfs_xdr_u64 part_max_blocks; 15430062bd1SDavid Howells struct yfs_xdr_u64 vol_copy_date; 15530062bd1SDavid Howells struct yfs_xdr_u64 vol_backup_date; 15630062bd1SDavid Howells } __packed; 15730062bd1SDavid Howells 15830062bd1SDavid Howells struct yfs_xdr_YFSStoreVolumeStatus { 15930062bd1SDavid Howells __be32 mask; 16030062bd1SDavid Howells struct yfs_xdr_u64 min_quota; 16130062bd1SDavid Howells struct yfs_xdr_u64 max_quota; 16230062bd1SDavid Howells struct yfs_xdr_u64 file_quota; 16330062bd1SDavid Howells } __packed; 164*5edc22ccSMarc Dionne 165*5edc22ccSMarc Dionne enum yfs_lock_type { 166*5edc22ccSMarc Dionne yfs_LockNone = -1, 167*5edc22ccSMarc Dionne yfs_LockRead = 0, 168*5edc22ccSMarc Dionne yfs_LockWrite = 1, 169*5edc22ccSMarc Dionne yfs_LockExtend = 2, 170*5edc22ccSMarc Dionne yfs_LockRelease = 3, 171*5edc22ccSMarc Dionne yfs_LockMandatoryRead = 0x100, 172*5edc22ccSMarc Dionne yfs_LockMandatoryWrite = 0x101, 173*5edc22ccSMarc Dionne yfs_LockMandatoryExtend = 0x102, 174*5edc22ccSMarc Dionne }; 175