@@ -645,3 +645,114 @@ struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *vc,
645645 afs_make_call (& vc -> ac , call , GFP_KERNEL );
646646 return (struct afs_addr_list * )afs_wait_for_call_to_complete (call , & vc -> ac );
647647}
648+
649+ /*
650+ * Deliver reply data to a YFSVL.GetCellName operation.
651+ */
652+ static int afs_deliver_yfsvl_get_cell_name (struct afs_call * call )
653+ {
654+ char * cell_name ;
655+ u32 namesz , paddedsz ;
656+ int ret ;
657+
658+ _enter ("{%u,%zu/%u}" ,
659+ call -> unmarshall , iov_iter_count (call -> iter ), call -> count );
660+
661+ switch (call -> unmarshall ) {
662+ case 0 :
663+ afs_extract_to_tmp (call );
664+ call -> unmarshall ++ ;
665+
666+ /* Fall through - and extract the cell name length */
667+ case 1 :
668+ ret = afs_extract_data (call , true);
669+ if (ret < 0 )
670+ return ret ;
671+
672+ namesz = ntohl (call -> tmp );
673+ if (namesz > AFS_MAXCELLNAME )
674+ return afs_protocol_error (call , afs_eproto_cellname_len );
675+ paddedsz = (namesz + 3 ) & ~3 ;
676+ call -> count = namesz ;
677+ call -> count2 = paddedsz - namesz ;
678+
679+ cell_name = kmalloc (namesz + 1 , GFP_KERNEL );
680+ if (!cell_name )
681+ return - ENOMEM ;
682+ cell_name [namesz ] = 0 ;
683+ call -> ret_str = cell_name ;
684+
685+ afs_extract_begin (call , cell_name , namesz );
686+ call -> unmarshall ++ ;
687+
688+ /* Fall through - and extract cell name */
689+ case 2 :
690+ ret = afs_extract_data (call , true);
691+ if (ret < 0 )
692+ return ret ;
693+
694+ afs_extract_discard (call , call -> count2 );
695+ call -> unmarshall ++ ;
696+
697+ /* Fall through - and extract padding */
698+ case 3 :
699+ ret = afs_extract_data (call , false);
700+ if (ret < 0 )
701+ return ret ;
702+
703+ call -> unmarshall ++ ;
704+ break ;
705+ }
706+
707+ _leave (" = 0 [done]" );
708+ return 0 ;
709+ }
710+
711+ static void afs_destroy_yfsvl_get_cell_name (struct afs_call * call )
712+ {
713+ kfree (call -> ret_str );
714+ afs_flat_call_destructor (call );
715+ }
716+
717+ /*
718+ * VL.GetCapabilities operation type
719+ */
720+ static const struct afs_call_type afs_YFSVLGetCellName = {
721+ .name = "YFSVL.GetCellName" ,
722+ .op = afs_YFSVL_GetCellName ,
723+ .deliver = afs_deliver_yfsvl_get_cell_name ,
724+ .destructor = afs_destroy_yfsvl_get_cell_name ,
725+ };
726+
727+ /*
728+ * Probe a volume server for the capabilities that it supports. This can
729+ * return up to 196 words.
730+ *
731+ * We use this to probe for service upgrade to determine what the server at the
732+ * other end supports.
733+ */
734+ char * afs_yfsvl_get_cell_name (struct afs_vl_cursor * vc )
735+ {
736+ struct afs_call * call ;
737+ struct afs_net * net = vc -> cell -> net ;
738+ __be32 * bp ;
739+
740+ _enter ("" );
741+
742+ call = afs_alloc_flat_call (net , & afs_YFSVLGetCellName , 1 * 4 , 0 );
743+ if (!call )
744+ return ERR_PTR (- ENOMEM );
745+
746+ call -> key = vc -> key ;
747+ call -> ret_str = NULL ;
748+ call -> max_lifespan = AFS_VL_MAX_LIFESPAN ;
749+
750+ /* marshall the parameters */
751+ bp = call -> request ;
752+ * bp ++ = htonl (YVLGETCELLNAME );
753+
754+ /* Can't take a ref on server */
755+ trace_afs_make_vl_call (call );
756+ afs_make_call (& vc -> ac , call , GFP_KERNEL );
757+ return (char * )afs_wait_for_call_to_complete (call , & vc -> ac );
758+ }
0 commit comments