>
> On Mon, Oct 13, 2008 at 9:44 AM, Abhishek D. Kulkarni <[EMAIL PROTECTED]>
> wrote:
>>
>> yes, i see how this can get confusing! crossmnt means "don't cross
>> mounts".
>> i didn't update the man page for this option yet -- i will send one
>> soon,
>> if this is good to go in.
>>
>
> I think a name change would be good -- how about skipmntpnt or
> ignoremnt or mntignore or nocrossmnt or ...
>
> ron
>

This patch adds a flag (-x) to specify one filesystem option (like rsync).
the xget server will skip all mount points that have a different device
ID than the originally served parent directory.

also fixed a bug that prevented / from being served by the master.

Signed-off-by: Abhishek Kulkarni <[EMAIL PROTECTED]>

Index: xget.c
===================================================================
--- xget.c      (revision 713)
+++ xget.c      (working copy)
@@ -86,6 +86,7 @@
 int singlefile = 0; /* Flag that indicates whether we are serving a
single file */
 int changeperms = 1;
 int rootonly = 0;
+int skipmnt = 0;
 char *path, *outname;
 int ticksig;
 u64 qpath = 1;
@@ -95,6 +96,7 @@
 time_t starttime;
 time_t endtime;
 time_t servicetime;
+dev_t fs_dev;

 static int netread(Spfile *parent, char *lprefix, char *nprefix, char
*name);
 int netpathread(char *fpath);
@@ -104,7 +106,7 @@

 static void
 usage(char *name) {
-       fprintf(stderr, "usage as the master server: %s [-D debuglevel]
[-p port] [-o] %s",
+       fprintf(stderr, "usage as the master server: %s [-D debuglevel]
[-p port] [-o] [-x] %s",
                name, " file|directory\n");
        fprintf(stderr, "usage as a client         : %s [-D debuglevel]
[-p port] %s %s",
                name, "<-n netaddr> [-s] [-o] <src file | src dir | .> ",
@@ -662,9 +664,14 @@
                        continue;

                snprintf(buf+blen, bsize-blen, "/%s", de->d_name);
-               if (lstat(buf, &st) < 0)
+               if (lstat(buf, &st) < 0) {
+                       sp_uerror(errno);
                        goto error;
+               }

+               if (skipmnt && (st.st_dev != fs_dev))
+                       goto error;
+
                /* skip files other than regular files */
                if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))
                        continue;
@@ -683,7 +690,8 @@
        if (sp_haserror()) {
                sp_rerror(&ename, &ecode);
                debug(Dbgfn, "Error while scanning files for changes: %s\n", 
ename);
-       }
+       } else
+               debug(Dbgfn, "Error: Skipping %s\n", buf);

        if (buf)
                free(buf);
@@ -955,6 +963,9 @@
                sp_uerror(errno);
                goto error;
        }
+
+       if (skipmnt && (st.st_dev != fs_dev))
+               goto error;

        npmode = umode2npmode(st.st_mode);
        if (!rootonly) {
@@ -1036,7 +1047,8 @@
                debug(Dbgfn, "Error: Skipping %s : %s\n",
                      filename, ename);
                sp_werror(NULL, 0);
-       }
+       } else
+               debug(Dbgfn, "Error: Skipping %s\n", filename);

        if (fd > -1)
                close(fd);
@@ -1648,7 +1660,7 @@
        xget_ename = NULL;
        xget_ecode = 0;

-       while ((c = getopt(argc, argv, "D:p:n:w:r:so")) != -1) {
+       while ((c = getopt(argc, argv, "D:p:n:w:r:sox")) != -1) {
                switch (c) {
                case 'p':
                        port = strtol(optarg, &s, 10);
@@ -1675,6 +1687,9 @@
                        rootonly = 1;
                        changeperms = 0;
                        break;
+               case 'x':
+                       skipmnt = 1;
+                       break;
                default:
                        usage(argv[0]);
                }
@@ -1726,13 +1741,18 @@
                        usage(argv[0]);
                }

-               if(stat(argv[i], &st) < 0)
+               if(stat(argv[i], &st) < 0) {
                        sp_uerror(errno);
+                       goto error;
+               }
+
+               if (skipmnt)
+                       fs_dev = st.st_dev;

                len = strlen(argv[i]) + 1;
                path = (char *) malloc(len * sizeof(char));
                snprintf(path, len, "%s", argv[i]);
-               if (path[len-2] == '/')
+               if (path[len-2] == '/' && len > 2)
                        path[len-2] = '\0';

                if (S_ISREG(st.st_mode))

Reply via email to