static char * SyncDriverListMounts(void) { char *paths = NULL; DynBuf buf; MNTHANDLE mounts; DECLARE_MNTINFO(mntinfo); if ((mounts = OPEN_MNTFILE("r")) == NULL) { return NULL; } DynBuf_Init(&buf); while (GETNEXT_MNTINFO(mounts, mntinfo)) { /* * Skip remote mounts because they are not freezable and opening them * could lead to hangs. See PR 1196785. */ if (SyncDriverIsRemoteFSType(MNTINFO_FSTYPE(mntinfo))) { Debug(LGPFX "Skipping remote filesystem, name=%s, mntpt=%s.\n", MNTINFO_NAME(mntinfo), MNTINFO_MNTPT(mntinfo)); continue; } /* * Add a separator if it's not the first path, and add the path to the * tail of the list. */ if ((DynBuf_GetSize(&buf) != 0 && !DynBuf_Append(&buf, ":", 1)) || !DynBuf_Append(&buf, MNTINFO_MNTPT(mntinfo), strlen(MNTINFO_MNTPT(mntinfo)))) { goto exit; } } if (!DynBuf_Append(&buf, "\0", 1)) { goto exit; } paths = DynBuf_AllocGet(&buf); if (paths == NULL) { Debug(LGPFX "Failed to allocate path list.\n"); } exit: DynBuf_Destroy(&buf); (void) CLOSE_MNTFILE(mounts); return paths; }
static char * SyncDriverListMounts(void) { char *paths = NULL; DynBuf buf; MNTHANDLE mounts; DECLARE_MNTINFO(mntinfo); if ((mounts = OPEN_MNTFILE("r")) == NULL) { return NULL; } DynBuf_Init(&buf); while (GETNEXT_MNTINFO(mounts, mntinfo)) { /* * Add a separator if it's not the first path, and add the path to the * tail of the list. */ if ((DynBuf_GetSize(&buf) != 0 && !DynBuf_Append(&buf, ":", 1)) || !DynBuf_Append(&buf, MNTINFO_MNTPT(mntinfo), strlen(MNTINFO_MNTPT(mntinfo)))) { goto exit; } } if (!DynBuf_Append(&buf, "\0", 1)) { goto exit; } paths = DynBuf_AllocGet(&buf); if (paths == NULL) { Debug(LGPFX "Failed to allocate path list.\n"); } exit: DynBuf_Destroy(&buf); (void) CLOSE_MNTFILE(mounts); return paths; }
void * DynXdr_AllocGet(XDR *xdrs) // IN { DynBuf *buf = &((DynXdrData *) xdrs->x_private)->data; return DynBuf_AllocGet(buf); }