Aligns lsof to the changes made in http://svnweb.freebsd.org/base?view=revision&revision=247602 --- dialects/freebsd/dproc.c.orig 2013-01-02 21:02:09.000000000 +0400 +++ dialects/freebsd/dproc.c 2013-03-20 23:08:58.140282265 +0400 @@ -138,7 +138,12 @@ #endif /* FREEBSDV<2000 */ #if defined(HASFSTRUCT) - static char *pof = (char *)NULL; +#if __FreeBSD_version >= 1000029 + typedef uint8_t pof_t; +#else + typedef char pof_t; +#endif + static pof_t *pof = (pof_t *)NULL; static int pofb = 0; #endif /* defined(HASFSTRUCT) */ @@ -379,17 +384,31 @@ } ofbb = nb; } +#if __FreeBSD_version >= 1000029 +/* + * FreeBSD after head, r247602 has split file entries into array + * filedescent; file structure is fde_file and flags are named + * fde_flags. + */ + for (i = 0; i < nf; i++) { + if (kread((KA_T)&fd.fd_ofiles[i].fde_file, + (char*)&ofb[i], sizeof(ofb[0])) != 0) { + continue; + } + } +#else if (kread((KA_T)fd.fd_ofiles, (char *)ofb, nb)) continue; +#endif #if defined(HASFSTRUCT) if (Fsv & FSV_FG) { - nb = (MALLOC_S)(sizeof(char) * nf); + nb = (MALLOC_S)(sizeof(pof[0]) * nf); if (nb > pofb) { if (!pof) - pof = (char *)malloc(nb); + pof = (pof_t *)malloc(nb); else - pof = (char *)realloc((MALLOC_P *)pof, nb); + pof = (pof_t *)realloc((MALLOC_P *)pof, nb); if (!pof) { (void) fprintf(stderr, "%s: PID %d, no file flag space\n", Pn, p->P_PID); @@ -397,8 +416,19 @@ } pofb = nb; } +#if __FreeBSD_version >= 1000029 + if (fd.fd_ofiles) { + for (i = 0; i < nf; i++) { + if (kread((KA_T)&fd.fd_ofiles[i].fde_flags, + (char *)(&pof[i]), sizeof (pof[0])) != 0) { + pof[i] = 0; + } + } + } +#else if (!fd.fd_ofileflags || kread((KA_T)fd.fd_ofileflags, pof, nb)) zeromem(pof, nb); +#endif } #endif /* defined(HASFSTRUCT) */