[BACK]Return to ukfs.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libukfs

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libukfs/ukfs.c between version 1.21 and 1.22

version 1.21, 2009/01/23 19:36:01 version 1.22, 2009/02/11 14:35:58
Line 163  struct ukfs *
Line 163  struct ukfs *
 ukfs_mount(const char *vfsname, const char *devpath, const char *mountpath,  ukfs_mount(const char *vfsname, const char *devpath, const char *mountpath,
         int mntflags, void *arg, size_t alen)          int mntflags, void *arg, size_t alen)
 {  {
           struct stat sb;
         struct ukfs *fs = NULL;          struct ukfs *fs = NULL;
         struct vfsops *vfsops;          struct vfsops *vfsops;
         struct mount *mp = NULL;          struct mount *mp = NULL;
Line 190  ukfs_mount(const char *vfsname, const ch
Line 191  ukfs_mount(const char *vfsname, const ch
         rdonly = mntflags & MNT_RDONLY;          rdonly = mntflags & MNT_RDONLY;
         devfd = open(devpath, rdonly ? O_RDONLY : O_RDWR);          devfd = open(devpath, rdonly ? O_RDONLY : O_RDWR);
         if (devfd != -1) {          if (devfd != -1) {
                 if (flock(devfd, LOCK_NB | (rdonly ? LOCK_SH:LOCK_EX)) == -1) {                  if (fstat(devfd, &sb) == -1) {
                         warnx("ukfs_mount: cannot get %s lock on device",  
                             rdonly ? "shared" : "exclusive");  
                         close(devfd);                          close(devfd);
                         devfd = -1;                          devfd = -1;
                         rv = errno;                          rv = errno;
                         goto out;                          goto out;
                 }                  }
   
                   /*
                    * We do this only for non-block device since the
                    * (NetBSD) kernel allows block device open only once.
                    */
                   if (!S_ISBLK(sb.st_mode)) {
                           if (flock(devfd, LOCK_NB | (rdonly ? LOCK_SH:LOCK_EX))
                               == -1) {
                                   warnx("ukfs_mount: cannot get %s lock on "
                                       "device", rdonly ? "shared" : "exclusive");
                                   close(devfd);
                                   devfd = -1;
                                   rv = errno;
                                   goto out;
                           }
                   } else {
                           close(devfd);
                           devfd = -1;
                   }
         }          }
   
         fs = malloc(sizeof(struct ukfs));          fs = malloc(sizeof(struct ukfs));

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

CVSweb <webmaster@jp.NetBSD.org>