samba client

jacky_pan at wistron.com.cn jacky_pan at wistron.com.cn
Wed May 8 02:38:39 GMT 2002


dear all,

I am trying to porting samba client to PDA(uclinux).I downloaded the source
code(including server and client side) from cvs.uclinux.org, and compiled the
client section successfully with little modification.But I meet some trouble
when running a command like "smbmount //192.168.1.5/public /home/mp100x/".I
compare the source code between uclinux.org and samba.org,find there are some
differences between them.

smbmount.c of uclinux.org:
00   static void send_fs_socket(char *service, char *mount_point, struct
cli_state *c)
01   {
02        int fd, closed = 0, res = 1;
03        pid_t parentpid = getppid();
04        struct smb_conn_opt conn_options;
05
06        memset(&conn_options, 0, sizeof(conn_options));
07
08        while (1) {
09             if ((fd = open(mount_point, O_RDONLY)) < 0) {
10                  fprintf(stderr, "mount.smbfs: can't open %s\n",
mount_point);
11                  break;
12             }
13
14             ......
15
16             res = ioctl(fd, SMB_IOC_NEWCONN, &conn_options);
17             if (res != 0) {
18                  fprintf(stderr, "mount.smbfs: ioctl failed, res=%d\n", res);
19                  break;
20             }
21
22             ......
23             }
24
25             close(fd);
26
27   #ifndef SMBFS_DEBUG
28             /* Close all open files if we haven't done so yet. */
29             if (!closed) {
30                  ......
31             }
32   #endif
33
34             /* Wait for a signal from smbfs ... */
35             CatchSignal(SIGUSR1, &usr1_handler);
36             pause();
37   #ifdef SMBFS_DEBUG
38             DEBUG(2,("mount.smbfs: got signal, getting new socket\n"));
39   #endif
40             c = do_connection(service);
41        }
42
43        smb_umount(mount_point);
44        DEBUG(2,("mount.smbfs: exit\n"));
45        exit(1);
46   }

when running at line 36, the process is blocked to wait a signal of SIGUSR1 from
 smbfs.
I don't know the smbfs send the signal to the process.The process can't continue
 if I don't write a command "kill -USR1 pid" in a terminal.
And I find "while (!c) {" in line 00393 in smbmount.c of samba.org(see
below).But there is no the same sentence in smbmount.c of uclinux.org.

smbmount.c of samba.org:

static void send_fs_socket( char *    service, char *    mount_point, struct
cli_state *    c )
00313 {
00314         int fd, closed = 0, res = 1;
00315         pid_t parentpid = getppid();
00316         struct smb_conn_opt conn_options;
00317
00318         memset(&conn_options, 0, sizeof(conn_options));
00319
00320         while (1) {
00321                 if ((fd = open(mount_point, O_RDONLY)) < 0) {
00322                         DEBUG(0,("mount.smbfs[%d]: can't open %s\n",
00323                                  getpid(), mount_point));
00324                         break;
00325                 }

          ......

00340                 res = ioctl(fd, SMB_IOC_NEWCONN, &conn_options);
00341                 if (res != 0) {
00342                         DEBUG(0,("mount.smbfs[%d]: ioctl failed,
res=%d\n",
00343                                  getpid(), res));
00344                         close(fd);
00345                         break;
00346                 }

               ......

00357                 close(fd);
00358
00359                 /* This looks wierd but we are only closing the userspace
00360                    side, the connection has already been passed to smbfs
and
00361                    it has increased the usage count on the socket.
00362
00363                    If we don't do this we will "leak" sockets and memory
on
00364                    each reconnection we have to make. */
00365                 cli_shutdown(c);
00366                 free(c);
00367                 c = NULL;
00368
00369                 if (!closed) {

                    ......

00388                         closed = 1;
00389                 }
00390
00391                 /* Wait for a signal from smbfs ... but don't continue
00392                    until we actually get a new connection. */
00393                 while (!c) {
00394                         CatchSignal(SIGUSR1, &usr1_handler);
00395                         pause();
00396                         DEBUG(2,("mount.smbfs[%d]: got signal, getting new
 socket\n", getpid()));
00397                         c = do_connection(service);
00398                 }
00399         }
00400
00401         smb_umount(mount_point);
00402         DEBUG(2,("mount.smbfs[%d]: exit\n", getpid()));
00403         exit(1);
00404 }


Could someone give me some suggestion or some other information to help
understand the samba client source code.
Any reply are appreciated! Please reply the mail directly because I am not a
subscriber of the maillist.

Thanks very much.

Jacky







More information about the smb-clients mailing list