@@ -1256,18 +1256,27 @@ fio_symlink(fio_location location, const char* target, const char* link_path, bo
12561256{
12571257if (fio_is_remote (location ))
12581258{
1259- fio_header hdr ;
12601259size_t target_len = strlen (target )+ 1 ;
12611260size_t link_path_len = strlen (link_path )+ 1 ;
1262- hdr .cop = FIO_SYMLINK ;
1263- hdr .handle = -1 ;
1264- hdr .size = target_len + link_path_len ;
1265- hdr .arg = overwrite ?1 :0 ;
1261+ fio_header hdr = {
1262+ .cop = FIO_SYMLINK ,
1263+ .handle = -1 ,
1264+ .size = target_len + link_path_len ,
1265+ .arg = overwrite ?1 :0 ,
1266+ };
12661267
12671268IO_CHECK (fio_write_all (fio_stdout ,& hdr ,sizeof (hdr )),sizeof (hdr ));
12681269IO_CHECK (fio_write_all (fio_stdout ,target ,target_len ),target_len );
12691270IO_CHECK (fio_write_all (fio_stdout ,link_path ,link_path_len ),link_path_len );
12701271
1272+ IO_CHECK (fio_read_all (fio_stdin ,& hdr ,sizeof (hdr )),sizeof (hdr ));
1273+ Assert (hdr .cop == FIO_SYMLINK );
1274+
1275+ if (hdr .arg != 0 )
1276+ {
1277+ errno = hdr .arg ;
1278+ return -1 ;
1279+ }
12711280return 0 ;
12721281}
12731282else
@@ -1280,17 +1289,22 @@ fio_symlink(fio_location location, const char* target, const char* link_path, bo
12801289}
12811290
12821291static void
1283- fio_symlink_impl (int out , char * buf ,bool overwrite )
1292+ fio_symlink_impl (const char * target , const char * link_path ,bool overwrite , int out )
12841293{
1285- char * linked_path = buf ;
1286- char * link_path = buf + strlen (buf )+ 1 ;
1294+ fio_header hdr = {
1295+ .cop = FIO_SYMLINK ,
1296+ .handle = -1 ,
1297+ .size = 0 ,
1298+ .arg = 0 ,
1299+ };
12871300
12881301if (overwrite )
12891302remove_file_or_dir (link_path );
12901303
1291- if (symlink (linked_path ,link_path ))
1292- elog (ERROR ,"Could not create symbolic link \"%s\": %s" ,
1293- link_path ,strerror (errno ));
1304+ if (symlink (target ,link_path )!= 0 )
1305+ hdr .arg = errno ;
1306+
1307+ IO_CHECK (fio_write_all (out ,& hdr ,sizeof (hdr )),sizeof (hdr ));
12941308}
12951309
12961310/* Rename file */
@@ -3428,7 +3442,7 @@ fio_communicate(int in, int out)
34283442fio_rename_impl (buf ,buf + strlen (buf )+ 1 ,out );
34293443break ;
34303444case FIO_SYMLINK :/* Create symbolic link */
3431- fio_symlink_impl (out ,buf ,hdr .arg > 0 ? true : false );
3445+ fio_symlink_impl (buf ,buf + strlen ( buf ) + 1 ,hdr .arg == 1 , out );
34323446break ;
34333447case FIO_REMOVE :/* Remove file or directory (TODO: Win32) */
34343448fio_remove_impl (buf ,hdr .arg == 1 ,out );