[samba3] lib/util_file.c unused functions?
John E. Malmberg
wb8tyw at qsl.net
Thu Aug 17 14:49:47 GMT 2006
Because OpenVMS does some file operations different than UNIX, it
appears that I need to replace some of routines in util_file.c with ones
specific to OpenVMS.
In looking at some of the routines that I would need to replace, I can
not find that SAMBA V3 is currently even using them.
These routines are:
file_lock, file_unlock, startfilepwent, and endfilepwent.
And the routine do_file_lock appears to be only used by
I would appreciate if someone could let me know if I have missed any
other usages of these routines.
For some background on the differences:
On OpenVMS, the older C library that I need to use does not support
fcntl() style locking.
For locking an entire file, as pdb_smbpasswd does, this can be done on
the call to open() or fopen() through extensions where on OpenVMS these
calls take additional arguments. This difference can be hidden from the
UNIX code in pdb_smbpasswd by compile time macros.
The other issues with the util_file routines is that stat()/fstat()
return the number of bytes that the file takes up, which on OpenVMS may
be more bytes than the amount of data that would be read from the file,
and that read() will stop at record boundaries for some file organizations.
OpenVMS editors output text files like smb.conf as a collection of
records, not as a stream of bytes. And each record contains meta-data
bytes. Unless the file is opened in binary mode, this meta-data is not
[Having that meta-data is a useful speedup on CPUs with block move
instructions like VAX]
OpenVMS also supports files that are just streams of bytes, but it would
be a major inconvenience to the user base to force them to convert their
files after leaving their favorite editor.
Which means that a stat() on the smb.conf (or other text file) on
OpenVMS will always show a larger byte count than what is present.
And for what ever reasons have been lost to time, but are likely related
to taking advantage of block move instructions, when the OpenVMS C
library issues a read() to a file in "record" format, it will only read
a single record.
Also, for record formated files, On OpenVMS the record delimiter of a \n
or other value is not stored in the file data. Instead there is are
flags in the file header which indicate what delimiter(s) if any to add
to the file when outputting it to a display or a printer.
OpenVMS text files get tagged to be terminated with a '\r'. And when
the OpenVMS C library issues a read() for a record from such a file, it
appends a '\r' to the record.
So while it is not a lot of code to change, it still is a difference
that I need to track.
wb8tyw at qsl.net
Personal Opinion Only
More information about the samba-technical