+void
+temp_file_name(char *buf)
+{
+ struct ucwlib_context *ctx = ucwlib_thread_context();
+ int cnt = ++ctx->temp_counter;
+ int pid = getpid();
+ if (ctx->thread_id == pid)
+ sprintf(buf, "%s%d-%d", temp_prefix, pid, cnt);
+ else
+ sprintf(buf, "%s%d-%d-%d", temp_prefix, pid, ctx->thread_id, cnt);
+}
+
+struct fastbuf *
+bopen_tmp_file(struct fb_params *params)
+{
+ char name[TEMP_FILE_NAME_LEN];
+ temp_file_name(name);
+ struct fastbuf *fb = bopen_file(name, O_RDWR | O_CREAT | O_TRUNC, params);
+ bconfig(fb, BCONFIG_IS_TEMP_FILE, 1);
+ return fb;
+}
+