@@ -24,6 +24,15 @@ static const struct svc_fh nfs3svc_null_fh = {
2424 .fh_no_wcc = true,
2525};
2626
27+ /*
28+ * time_delta. {1, 0} means the server is accurate only
29+ * to the nearest second.
30+ */
31+ static const struct timespec64 nfs3svc_time_delta = {
32+ .tv_sec = 1 ,
33+ .tv_nsec = 0 ,
34+ };
35+
2736/*
2837 * Mapping of S_IF* types to NFS file types
2938 */
@@ -1445,30 +1454,51 @@ nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, __be32 *p)
14451454 return 1 ;
14461455}
14471456
1457+ static bool
1458+ svcxdr_encode_fsinfo3resok (struct xdr_stream * xdr ,
1459+ const struct nfsd3_fsinfores * resp )
1460+ {
1461+ __be32 * p ;
1462+
1463+ p = xdr_reserve_space (xdr , XDR_UNIT * 12 );
1464+ if (!p )
1465+ return false;
1466+ * p ++ = cpu_to_be32 (resp -> f_rtmax );
1467+ * p ++ = cpu_to_be32 (resp -> f_rtpref );
1468+ * p ++ = cpu_to_be32 (resp -> f_rtmult );
1469+ * p ++ = cpu_to_be32 (resp -> f_wtmax );
1470+ * p ++ = cpu_to_be32 (resp -> f_wtpref );
1471+ * p ++ = cpu_to_be32 (resp -> f_wtmult );
1472+ * p ++ = cpu_to_be32 (resp -> f_dtpref );
1473+ p = xdr_encode_hyper (p , resp -> f_maxfilesize );
1474+ p = encode_nfstime3 (p , & nfs3svc_time_delta );
1475+ * p = cpu_to_be32 (resp -> f_properties );
1476+
1477+ return true;
1478+ }
1479+
14481480/* FSINFO */
14491481int
14501482nfs3svc_encode_fsinfores (struct svc_rqst * rqstp , __be32 * p )
14511483{
1484+ struct xdr_stream * xdr = & rqstp -> rq_res_stream ;
14521485 struct nfsd3_fsinfores * resp = rqstp -> rq_resp ;
14531486
1454- * p ++ = resp -> status ;
1455- * p ++ = xdr_zero ; /* no post_op_attr */
1456-
1457- if (resp -> status == 0 ) {
1458- * p ++ = htonl (resp -> f_rtmax );
1459- * p ++ = htonl (resp -> f_rtpref );
1460- * p ++ = htonl (resp -> f_rtmult );
1461- * p ++ = htonl (resp -> f_wtmax );
1462- * p ++ = htonl (resp -> f_wtpref );
1463- * p ++ = htonl (resp -> f_wtmult );
1464- * p ++ = htonl (resp -> f_dtpref );
1465- p = xdr_encode_hyper (p , resp -> f_maxfilesize );
1466- * p ++ = xdr_one ;
1467- * p ++ = xdr_zero ;
1468- * p ++ = htonl (resp -> f_properties );
1487+ if (!svcxdr_encode_nfsstat3 (xdr , resp -> status ))
1488+ return 0 ;
1489+ switch (resp -> status ) {
1490+ case nfs_ok :
1491+ if (!svcxdr_encode_post_op_attr (rqstp , xdr , & nfs3svc_null_fh ))
1492+ return 0 ;
1493+ if (!svcxdr_encode_fsinfo3resok (xdr , resp ))
1494+ return 0 ;
1495+ break ;
1496+ default :
1497+ if (!svcxdr_encode_post_op_attr (rqstp , xdr , & nfs3svc_null_fh ))
1498+ return 0 ;
14691499 }
14701500
1471- return xdr_ressize_check ( rqstp , p ) ;
1501+ return 1 ;
14721502}
14731503
14741504/* PATHCONF */
0 commit comments