[PATCH] Volume serial number
derrell at samba.org
derrell at samba.org
Sat Nov 5 17:22:38 GMT 2005
Nikolai Zhubr <zhubr at mail.ru> writes:
> This is my second attempt to submit this patch,
> the first one seems to stay totally unnoticed.
> Please someone tell me if this is a wrong place
> to come out with patches?
Nikolai,
Thank you for providing the patch! This is a fine place to submit it,
although a better way is via bugzilla.samba.org. Using bugzilla ensures that
it doesn't get forgotten.
Upon initial review, your patch looks clean. A possible issue I see is if the
supplied volume serial number begins with hex digits but erroneously ends with
non-hex characters. It looks like your handle_volume_id() function wont
detect that.
Jeremy, since you typically apply patches in this area, would you like to do
this?
Nikolai, if you don't get a response soon, go ahead and enter this into
bugzilla so it doesn't get lost.
Derrell
> -----------------------------------------------
> I'd like to suggest a patch for adding an option to
> manually specify volume serial number for any share
> (in config file). This is usefull for users of
> commercial applications locked to the volume serial
> number during their activation.
> The attached diff is against 3.0.20b version.
> Please let me know if someone can apply it for
> future 3.x releases or if I have to prepare a
> diff against 4.x branch.
>
> Please CC me when replying, I'm not subscribed.
>
> Thank you.
> --
> Best regards,
> Nikolai Zhubr
>
> --- source/param/loadparm.c.orig Wed Oct 12 21:03:28 2005
> +++ source/param/loadparm.c Wed Oct 19 22:48:28 2005
> @@ -443,6 +443,7 @@
> int iAioReadSize;
> int iAioWriteSize;
> param_opt_struct *param_opt;
> + uint32 iVolumeId;
>
> char dummy[3]; /* for alignment */
> }
> @@ -577,6 +578,7 @@
> 0, /* iAioWriteSize */
>
> NULL, /* Parametric options */
> + 0, /* iVolumeId */
>
> "" /* dummy */
> };
> @@ -606,6 +608,7 @@
> static BOOL handle_acl_compatibility( int snum, const char *pszParmValue, char **ptr);
> static BOOL handle_printing( int snum, const char *pszParmValue, char **ptr);
> static BOOL handle_eventlog( int snum, const char *pszParmValue, char **ptr);
> +static BOOL handle_volume_id( int snum, const char *pszParmValue, char **ptr);
>
> static void set_server_role(void);
> static void set_default_server_announce_type(void);
> @@ -1196,6 +1199,7 @@
> {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
> {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL, FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT},
> {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE },
> + {"volume id", P_STRING, P_LOCAL, &sDefault.iVolumeId, handle_volume_id, NULL, FLAG_ADVANCED | FLAG_SHARE },
> {"fstype", P_STRING, P_LOCAL, &sDefault.fstype, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
> {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE},
> {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
> @@ -2007,6 +2011,7 @@
> FN_LOCAL_INTEGER(lp_allocation_roundup_size, iallocation_roundup_size)
> FN_LOCAL_INTEGER(lp_aio_read_size, iAioReadSize)
> FN_LOCAL_INTEGER(lp_aio_write_size, iAioWriteSize)
> +FN_LOCAL_INTEGER(lp_volume_id, iVolumeId)
> FN_LOCAL_CHAR(lp_magicchar, magic_char)
> FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
> FN_GLOBAL_INTEGER(lp_winbind_max_idle_children, &Globals.winbind_max_idle_children)
> @@ -2923,6 +2928,19 @@
> str_list_free(&Globals.szNetbiosAliases);
> Globals.szNetbiosAliases = str_list_make(pszParmValue, NULL);
> return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
> +}
> +
> +static BOOL handle_volume_id( int snum, const char *pszParmValue, char **ptr)
> +{
> + uint32 temp_serial;
> +
> + if (sscanf(pszParmValue, "%x", &temp_serial) == 0) {
> + DEBUG(2, ("Invalid volume serial number specified: %s\n", pszParmValue));
> + temp_serial = 0;
> + }
> + *(int *)ptr = temp_serial; /* iVolumeId */
> +
> + return True;
> }
>
> /***************************************************************************
> --- source/smbd/trans2.c.orig Wed Oct 12 21:03:26 2005
> +++ source/smbd/trans2.c Wed Oct 19 23:06:40 2005
> @@ -2121,6 +2121,7 @@
> int data_len, len;
> SMB_STRUCT_STAT st;
> char *vname = volume_label(SNUM(conn));
> + uint32 this_volume_id = lp_volume_id(SNUM(conn));
> int snum = SNUM(conn);
> char *fstype = lp_fstype(SNUM(conn));
> int quota_flag = 0;
> @@ -2180,10 +2181,13 @@
> case SMB_INFO_VOLUME:
> /* Return volume name */
> /*
> - * Add volume serial number - hash of a combination of
> - * the called hostname and the service name.
> + * Add volume serial number. If not specified, fallback to
> + * a combination of the called hostname and the service name.
> */
> - SIVAL(pdata,0,str_checksum(lp_servicename(snum)) ^ (str_checksum(get_local_machine_name())<<16) );
> + if (!this_volume_id) {
> + this_volume_id = str_checksum(lp_servicename(snum)) ^ (str_checksum(get_local_machine_name())<<16);
> + }
> + SIVAL(pdata,0,this_volume_id);
> /*
> * Win2k3 and previous mess this up by sending a name length
> * one byte short. I believe only older clients (OS/2 Win9x) use
> @@ -2228,11 +2232,14 @@
> case SMB_FS_VOLUME_INFORMATION:
>
> /*
> - * Add volume serial number - hash of a combination of
> - * the called hostname and the service name.
> + * Add volume serial number. If not specified, fallback to
> + * a combination of the called hostname and the service name.
> */
> - SIVAL(pdata,8,str_checksum(lp_servicename(snum)) ^
> - (str_checksum(get_local_machine_name())<<16));
> + if (!this_volume_id) {
> + this_volume_id = str_checksum(lp_servicename(snum)) ^
> + (str_checksum(get_local_machine_name())<<16);
> + }
> + SIVAL(pdata,8,this_volume_id);
>
> len = srvstr_push(outbuf, pdata+18, vname, -1, STR_UNICODE);
> SIVAL(pdata,12,len);
> --- examples/smb.conf.default.orig Wed Oct 12 21:03:50 2005
> +++ examples/smb.conf.default Wed Oct 19 23:21:24 2005
> @@ -260,6 +260,8 @@
> ; only guest = yes
> ; writable = yes
> ; printable = no
> +; volume = mylabel
> +; volume id = 1234ABCD
>
> # The following two entries demonstrate how to share a directory so that two
> # users can place files there that will be owned by the specific users. In this
More information about the samba-technical
mailing list