int nfs3svc_decode_renameargs(struct svc_rqst *rqstp, u32 *p, struct nfsd3_renameargs *args) { if (!(p = decode_fh(p, &args->ffh)) || !(p = decode_filename(p, &args->fname, &args->flen)) || !(p = decode_fh(p, &args->tfh)) || !(p = decode_filename(p, &args->tname, &args->tlen))) return 0; return xdr_argsize_check(rqstp, p); }
int nfssvc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd_renameargs *args = rqstp->rq_argp; if (!(p = decode_fh(p, &args->ffh)) || !(p = decode_filename(p, &args->fname, &args->flen)) || !(p = decode_fh(p, &args->tfh)) || !(p = decode_filename(p, &args->tname, &args->tlen))) return 0; return xdr_argsize_check(rqstp, p); }
int nfs3svc_decode_diropargs(struct svc_rqst *rqstp, u32 *p, struct nfsd3_diropargs *args) { if (!(p = decode_fh(p, &args->fh)) || !(p = decode_filename(p, &args->name, &args->len))) return 0; return xdr_argsize_check(rqstp, p); }
int nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, u32 *p, struct nfsd3_createargs *args) { if (!(p = decode_fh(p, &args->fh)) || !(p = decode_filename(p, &args->name, &args->len)) || !(p = decode_sattr3(p, &args->attrs))) return 0; return xdr_argsize_check(rqstp, p); }
int nfssvc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd_linkargs *args) { if (!(p = decode_fh(p, &args->ffh)) || !(p = decode_fh(p, &args->tfh)) || !(p = decode_filename(p, &args->tname, &args->tlen))) return 0; return xdr_argsize_check(rqstp, p); }
int nfssvc_decode_createargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd_createargs *args) { if ( !(p = decode_fh(p, &args->fh)) || !(p = decode_filename(p, &args->name, &args->len))) return 0; p = decode_sattr(p, &args->attrs); return xdr_argsize_check(rqstp, p); }
int nfs3svc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd3_diropargs *args = rqstp->rq_argp; if (!(p = decode_fh(p, &args->fh)) || !(p = decode_filename(p, &args->name, &args->len))) return 0; return xdr_argsize_check(rqstp, p); }
int nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, u32 *p, struct nfsd3_symlinkargs *args) { if (!(p = decode_fh(p, &args->ffh)) || !(p = decode_filename(p, &args->fname, &args->flen)) || !(p = decode_sattr3(p, &args->attrs)) || !(p = decode_pathname(p, &args->tname, &args->tlen))) return 0; return xdr_argsize_check(rqstp, p); }
int nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd3_createargs *args = rqstp->rq_argp; if (!(p = decode_fh(p, &args->fh)) || !(p = decode_filename(p, &args->name, &args->len))) return 0; p = decode_sattr3(p, &args->attrs); return xdr_argsize_check(rqstp, p); }
int nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd3_mknodargs *args = rqstp->rq_argp; if (!(p = decode_fh(p, &args->fh)) || !(p = decode_filename(p, &args->name, &args->len))) return 0; args->ftype = ntohl(*p++); if (args->ftype == NF3BLK || args->ftype == NF3CHR || args->ftype == NF3SOCK || args->ftype == NF3FIFO) p = decode_sattr3(p, &args->attrs); if (args->ftype == NF3BLK || args->ftype == NF3CHR) { args->major = ntohl(*p++); args->minor = ntohl(*p++); } return xdr_argsize_check(rqstp, p); }
int nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd_symlinkargs *args = rqstp->rq_argp; char *base = (char *)p; size_t xdrlen; if ( !(p = decode_fh(p, &args->ffh)) || !(p = decode_filename(p, &args->fname, &args->flen))) return 0; args->tlen = ntohl(*p++); if (args->tlen == 0) return 0; args->first.iov_base = p; args->first.iov_len = rqstp->rq_arg.head[0].iov_len; args->first.iov_len -= (char *)p - base; /* This request is never larger than a page. Therefore, * transport will deliver either: * 1. pathname in the pagelist -> sattr is in the tail. * 2. everything in the head buffer -> sattr is in the head. */ if (rqstp->rq_arg.page_len) { if (args->tlen != rqstp->rq_arg.page_len) return 0; p = rqstp->rq_arg.tail[0].iov_base; } else { xdrlen = XDR_QUADLEN(args->tlen); if (xdrlen > args->first.iov_len - (8 * sizeof(__be32))) return 0; p += xdrlen; } decode_sattr(p, &args->attrs); return 1; }
int nfs3svc_decode_createargs(struct svc_rqst *rqstp, u32 *p, struct nfsd3_createargs *args) { if (!(p = decode_fh(p, &args->fh)) || !(p = decode_filename(p, &args->name, &args->len))) return 0; switch (args->createmode = ntohl(*p++)) { case NFS3_CREATE_UNCHECKED: case NFS3_CREATE_GUARDED: if (!(p = decode_sattr3(p, &args->attrs))) return 0; break; case NFS3_CREATE_EXCLUSIVE: args->verf = p; p += 2; break; default: return 0; } return xdr_argsize_check(rqstp, p); }
int nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd3_symlinkargs *args = rqstp->rq_argp; char *base = (char *)p; size_t dlen; if (!(p = decode_fh(p, &args->ffh)) || !(p = decode_filename(p, &args->fname, &args->flen))) return 0; p = decode_sattr3(p, &args->attrs); args->tlen = ntohl(*p++); args->first.iov_base = p; args->first.iov_len = rqstp->rq_arg.head[0].iov_len; args->first.iov_len -= (char *)p - base; dlen = args->first.iov_len + rqstp->rq_arg.page_len + rqstp->rq_arg.tail[0].iov_len; if (dlen < XDR_QUADLEN(args->tlen) << 2) return 0; return 1; }
int main(int argc,char *argv[]) { int i,j,k,arg=0,satno=0,satname=0,usecatalog=0,imode,m=10; long norb; char *datafile,*catalog,filename[32]; int ia[7]={0,0,0,0,0,0,0}; char line1[70],line2[70],desig[10]; double mjd,sma,perigee,apogee,xno; float mag=0.0,dm; xyz_t r,v; FILE *file; // Decode options while ((arg=getopt(argc,argv,"d:c:i:n:m:"))!=-1) { switch(arg) { case 'd': datafile=optarg; break; case 'c': catalog=optarg; usecatalog=1; break; case 'i': satno=atoi(optarg); break; case 'n': norb=atoi(optarg); if (norb<0) norb=0; break; case 'm': mag=atof(optarg); break; default: return 0; } } // Magnitude offset dm=5.0*log10(1000.0/40000.0); // Reloop stderr freopen("/tmp/stderr.txt","w",stderr); // Decode filename mjd=decode_filename(datafile,&satname); // Read data d=read_data(datafile,mjd); // Write data sprintf(filename,"%06d.xyz",satname); file=fopen(filename,"w"); for (i=0;i<d.n;i++) fprintf(file,"%lf %f %f %f\n",d.p[i].mjd,d.p[i].r.x,d.p[i].r.y,d.p[i].r.z); fclose(file); // Open elements sprintf(filename,"%06d.tle",satname); file=fopen(filename,"w"); // Estimate orbit k=504; if (usecatalog==0) { // Set initial state vector r.x=d.p[k].r.x; r.y=d.p[k].r.y; r.z=d.p[k].r.z; v.x=(d.p[k+1].r.x-d.p[k].r.x)/60.0; v.y=(d.p[k+1].r.y-d.p[k].r.y)/60.0; v.z=(d.p[k+1].r.z-d.p[k].r.z)/60.0; // Estimate initial orbit from elements orb=rv2el(99999,d.p[k].mjd,r,v); strcpy(orb.desig,"14999A"); orb.norb=norb; } else { // Read orbit orb=read_tle(catalog,satno); strcpy(desig,orb.desig); // Propagate imode=init_sgdp4(&orb); imode=satpos_xyz(d.p[k].mjd+2400000.5,&r,&v); orb=rv2el(orb.satno,d.p[k].mjd,r,v); // orb.satno=99999; // strcpy(orb.desig,"14999A"); strcpy(orb.desig,desig); orb.norb=norb; } // Set flags for (j=0;j<d.n;j++) d.p[j].flag=0; for (j=0;j<d.n;j++) d.p[j].flag=1; // Fit orbit for (j=0;j<10;j++) { if (j==1) ia[4]=1; if (j==2) ia[1]=1; if (j==3) ia[0]=1; if (j==4) ia[5]=1; if (j==5) ia[3]=1; if (j==6) ia[2]=1; if (j==7) ia[6]=1; fit(orb,ia); } // Compute orbit size xno=orb.rev*2.0*M_PI/XMNPDA; sma=pow(XKE/xno,2.0/3.0)*XKMPER; perigee=sma*(1.0-orb.ecc)-XKMPER; apogee=sma*(1.0+orb.ecc)-XKMPER; // Format TLE format_tle(orb,line1,line2); fprintf(file,"SO %6d %4.1f %7.0fkm x%7.0fkm\n%s\n%s\n# %d positions, %.1f km rms\n",satname,mag+dm,perigee,apogee,line1,line2,d.nsel,d.rms); printf("SO %6d %4.1f %7.0fkm x%7.0fkm\n%s\n%s\n# %d positions, %.1f km rms\n",satname,mag+dm,perigee,apogee,line1,line2,d.nsel,d.rms); // Close output file fclose(file); return 0; }
static struct dirent *nfs_readdir(struct device_d *dev, DIR *dir) { struct nfs_dir *ndir = (void *)dir; __be32 *p; int ret; int len; struct xdr_stream *xdr = &ndir->stream; again: p = xdr_inline_decode(xdr, 4); if (!p) goto out_overflow; if (*p++ == xdr_zero) { p = xdr_inline_decode(xdr, 4); if (!p) goto out_overflow; if (*p++ == xdr_zero) { void *buf; int len; /* * End of current entries, read next chunk. */ free(ndir->stream.buf); buf = nfs_readdirattr_req(ndir->priv, &len, ndir->cookie); if (!buf) return NULL; xdr_init(&ndir->stream, buf, len); goto again; } return NULL; /* -EINVAL */ } p = xdr_inline_decode(xdr, 4); if (!p) goto out_overflow; ret = decode_filename(xdr, ndir->ent.d_name, &len); if (ret) return NULL; /* * The type (size and byte order) of nfscookie isn't defined in * RFC 1094. This implementation assumes that it's an XDR uint32. */ p = xdr_inline_decode(xdr, 4); if (!p) goto out_overflow; ndir->cookie = be32_to_cpup(p); return &ndir->ent; out_overflow: printf("nfs: overflow error\n"); return NULL; }