Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-08

Cannot save file to NFS mounted path

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leonardo M. Ramé

Hi, I'm using TFileStream to save files. It works without issues when writing to my filesystem, but hangs (does not return) when the path is a mounted NFS one.

I must add the user has write permissions on the mounted path, in fact before posting this I've tried creating a text file without using TFileStream and it worked without an issue, so I assume the problem is with TFileStream:

     // This works:
     AssignFile(f, '/mnt/data_vultr/documents/test.txt');
     {$I-}
     Rewrite(f);
     {$I+}
     if IOResult =0 then
     begin
       System.WriteLn(f, 'aaaa');
       System.WriteLn(f, 'bbb');
     end;
     System.Close(f);
     // this doesn't work
     lFileStream := TFileStream.Create(lFile, fmCreate);
     AMemStream.Position := 0;
     lFileStream.CopyFrom(AMemStream,AMemStream.Size);

The program is a CGI running on Ubuntu Server 14.04 x64. Lazarus 1.7 compiled from trunk on 2016-05-13 (SVN 52282M) FPC 3.1.1

Regards,

Leonardo M. Ramé Medical IT - Griensu S.A. Av. Colón 636 - Piso 8 Of. A X5000EPT -- Córdoba Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19 Cel.: +54 9 (011) 40871877

Reply by email

Mattias Gaertner
to Leonardo M. Ramé: Hi, I'm using TFileStream to save files. It works without issues when writing to my…
Show quoted text 25 lines
[...] mounted NFS one. I must add the user has write permissions on the mounted path, in fact before posting this I've tried creating a text file without using TFileStream and it worked without an issue, so I assume the problem is with TFileStream: // This works: AssignFile(f, '/mnt/data_vultr/documents/test.txt'); {$I-} Rewrite(f); {$I+} if IOResult =0 then begin System.WriteLn(f, 'aaaa'); System.WriteLn(f, 'bbb'); end; System.Close(f); // this doesn't work lFileStream := TFileStream.Create(lFile, fmCreate);
Try
lFileStream := TFileStream.Create(lFile, fmCreate or fmShareDenyNone);

NFS often does not support locking.

AMemStream.Position := 0; lFileStream.CopyFrom(AMemStream,AMemStream.Size);

Mattias

Reply by email

Leonardo M. Ramé
to Mattias Gaertner
Mattias Gaertner wrote 35 lines
On Thu, 4 Aug 2016 07:59:14 -0300 Leonardo M. Ramé wrote: > [...] > mounted NFS one. > > I must add the user has write permissions on the mounted path, in fact > before posting this I've tried creating a text file without using > TFileStream and it worked without an issue, so I assume the problem is > with TFileStream: > > // This works: > > AssignFile(f, '/mnt/data_vultr/documents/test.txt'); > {$I-} > Rewrite(f); > {$I+} > if IOResult =0 then > begin > System.WriteLn(f, 'aaaa'); > System.WriteLn(f, 'bbb'); > end; > System.Close(f); > > > // this doesn't work > > lFileStream := TFileStream.Create(lFile, fmCreate); Try lFileStream := TFileStream.Create(lFile, fmCreate or fmShareDenyNone); NFS often does not support locking. > AMemStream.Position := 0; > lFileStream.CopyFrom(AMemStream,AMemStream.Size);

I'll try that, meanwhile it worked using this:

       var lBinaryFile: file;
       ...
       lFile := '/path/to/mounted/nfs/file.bin';
       AssignFile(lBinaryFile, lFile);
       {$I-}
       Rewrite(lBinaryFile);
       {$I+}
       if IOResult = 0 then
       begin
         BlockWrite(lBinaryFile, AMemStream.Memory, AMemStream.Size);
         System.Close(lBinaryFile);
       end;

Regards,

Reply by email