svn commit: r290588 - stable/9/usr.sbin/makefs/cd9660

2015-11-09 Thread Garrett Cooper
Author: ngie
Date: Mon Nov  9 08:05:15 2015
New Revision: 290588
URL: https://svnweb.freebsd.org/changeset/base/290588

Log:
  MFstable/10 r290587:
  
  MFC r289687,r289693:
  
  r289687:
  
  Free buffer before returning from cd9660_write_path_table to avoid
  leaking it after returning from the function
  
  PR: 203647
  Submitted by: Thomas Schmitt 
  Coverity CID: 978431
  Sponsored by: EMC / Isilon Storage Division
  
  r289693:
  
  Unbreak makefs -t cd9660 after r289687
  
  buffer_head needs to be freed -- not buffer
  
  Detected by jemalloc, i.e. running makefs failed the arena assert
  because my copy of malloc on CURRENT is compiled with the default
  !MALLOC_PRODUCTION asserts on
  
  Pointyhat to: ngie
  PR: 203647
  Sponsored by: EMC / Isilon Storage Division

Modified:
  stable/9/usr.sbin/makefs/cd9660/cd9660_write.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/usr.sbin/   (props changed)
  stable/9/usr.sbin/makefs/   (props changed)

Modified: stable/9/usr.sbin/makefs/cd9660/cd9660_write.c
==
--- stable/9/usr.sbin/makefs/cd9660/cd9660_write.c  Mon Nov  9 08:03:15 
2015(r290587)
+++ stable/9/usr.sbin/makefs/cd9660/cd9660_write.c  Mon Nov  9 08:05:15 
2015(r290588)
@@ -165,7 +165,7 @@ cd9660_write_path_table(FILE *fd, off_t 
diskStructure.pathTableLength);
unsigned char *buffer;
unsigned char *buffer_head;
-   int len;
+   int len, ret;
path_table_entry temp_entry;
cd9660node *ptcur;
 
@@ -213,8 +213,10 @@ cd9660_write_path_table(FILE *fd, off_t 
ptcur = ptcur->ptnext;
}
 
-   return cd9660_write_filedata(fd, sector, buffer_head,
+   ret = cd9660_write_filedata(fd, sector, buffer_head,
path_table_sectors);
+   free(buffer_head);
+   return ret;
 }
 
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r290590 - stable/9/usr.sbin/makefs

2015-11-09 Thread Garrett Cooper
Author: ngie
Date: Mon Nov  9 09:02:30 2015
New Revision: 290590
URL: https://svnweb.freebsd.org/changeset/base/290590

Log:
  MFstable/10 r290589:
  
  MFC r289203,r290180:
  
  r289203 (by adrian):
  
  makefs: introduce a new option to specify what to round the resulting
  image up to.
  
  From ticket:
  
  While trying to run FreeBSD/mips on some device having very small flash media,
  one is forced to compress file system with mkulzma(8) utility. It is desirable
  to specify small UFS block/fragment sizes like 4096/512 bytes for makefs(8)
  and big compression block size like 65535 bytes to mkulzma at the same time.
  Then one obtains very good comression ratios (like 75% and more) but faces
  the following problem.
  
  geom_uncompress kernel module reports GEOM provider size rounded up to its
  compression block size. Generally, this changes original media size and now
  it fails to match the size of embedded UFS file system that leads to other
  problems, f.e. geom_label kernel module does not like this and skips the
  file system while tasting the GEOM and looking for UFS label.
  
  This makes it impossible to refer to the file system using known UFS label
  instead of something like /dev/map/rootfs.uncompress.
  
  The following patch introduces new command line option "-r roundup" for makefs
  that makes it round up the image to specified block size. Hence, 
geom_uncompress
  does not change GEOM media size for images rounded that way and geom_label
  accepts such GEOMs just fine.
  
  With the patch applied, one can use following commands:
  
  $ makefs -t ffs -r 65536 -o bsize=4096,fsize=512,label=flash 
optimization=space fs.img fs
  $ mkulzma -s 65536 -o fs.img.ulzma fs.img
  
  PR:   bin/203707
  Submitted by: 
  
  r290180:
  
  Follow up to roundup feature addition in r289203
  
  - Rename -r to -R to avoid the clash with makefs -r in NetBSD
  - Note that -R is an FFS-specific option because it's not implemented
in cd9660 today
  - Rename the roundup variable to "roundup-size" in the manpage and help
text for consistency with other variables.
  - Bump .Dd (missed in r289203)
  
  PR: 203707
  Differential Revision: https://reviews.freebsd.org/D3959
  Reviewed by: adrian (earlier patch), emaste
  Sponsored by: EMC / Isilon Storage Division

Modified:
  stable/9/usr.sbin/makefs/ffs.c
  stable/9/usr.sbin/makefs/makefs.8
  stable/9/usr.sbin/makefs/makefs.c
  stable/9/usr.sbin/makefs/makefs.h
Directory Properties:
  stable/9/   (props changed)
  stable/9/usr.sbin/   (props changed)
  stable/9/usr.sbin/makefs/   (props changed)

Modified: stable/9/usr.sbin/makefs/ffs.c
==
--- stable/9/usr.sbin/makefs/ffs.c  Mon Nov  9 08:59:55 2015
(r290589)
+++ stable/9/usr.sbin/makefs/ffs.c  Mon Nov  9 09:02:30 2015
(r290590)
@@ -410,6 +410,10 @@ ffs_validate(const char *dir, fsnode *ro
/* round up to the next block */
fsopts->size = roundup(fsopts->size, ffs_opts->bsize);
 
+   /* round up to requested block size, if any */
+   if (fsopts->roundup > 0)
+   fsopts->size = roundup(fsopts->size, fsopts->roundup);
+
/* calculate density if necessary */
if (ffs_opts->density == -1)
ffs_opts->density = fsopts->size / fsopts->inodes + 1;

Modified: stable/9/usr.sbin/makefs/makefs.8
==
--- stable/9/usr.sbin/makefs/makefs.8   Mon Nov  9 08:59:55 2015
(r290589)
+++ stable/9/usr.sbin/makefs/makefs.8   Mon Nov  9 09:02:30 2015
(r290590)
@@ -35,7 +35,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 16, 2013
+.Dd October 29, 2015
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -53,6 +53,7 @@
 .Op Fl m Ar maximum-size
 .Op Fl N Ar userdb-dir
 .Op Fl o Ar fs-options
+.Op Fl R Ar roundup-size
 .Op Fl S Ar sector-size
 .Op Fl s Ar image-size
 .Op Fl t Ar fs-type
@@ -195,6 +196,14 @@ Deprecated.
 See the
 .Fl Z
 flag.
+.It Fl R Ar roundup-size
+Round the image up to
+.Ar roundup-size .
+.Ar roundup-size
+should be a multiple of the file system block size.
+This option only applies to the
+.Sy ffs
+file system type.
 .It Fl S Ar sector-size
 Set the file system sector size to
 .Ar sector-size .

Modified: stable/9/usr.sbin/makefs/makefs.c
==
--- stable/9/usr.sbin/makefs/makefs.c   Mon Nov  9 08:59:55 2015
(r290589)
+++ stable/9/usr.sbin/makefs/makefs.c   Mon Nov  9 09:02:30 2015
(r290590)
@@ -113,7 +113,7 @@ main(int argc, char *argv[])
start_time.tv_sec = start.tv_sec;
start_time.tv_nsec = start.tv_usec * 1000;
 
-   while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:ps:S:t:xZ")) != -1) 
{
+   while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:pr:s:S:t:xZ")) != 
-1) {
switch (ch) {
 
case 'B':
@@ -209,6 +2

svn commit: r290593 - stable/9/usr.sbin/makefs/cd9660

2015-11-09 Thread Garrett Cooper
Author: ngie
Date: Mon Nov  9 09:05:09 2015
New Revision: 290593
URL: https://svnweb.freebsd.org/changeset/base/290593

Log:
  MFstable/10 r290591:
  
  MFC r289899:
  
  Import the fix from NetBSD kern/48852 (sic) to fix rockridge encoding of
  device nodes
  
  In particular, use st_rdev (the device type), not st_dev (the device inode),
  and fix the comparison to be correct with the st_rdev field
  
  Bug 203648
  Submitted by: Thomas Schmitt 
  Coverity CID: 1008927
  Sponsored by: EMC / Isilon Storage Division

Modified:
  stable/9/usr.sbin/makefs/cd9660/iso9660_rrip.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/usr.sbin/   (props changed)
  stable/9/usr.sbin/makefs/   (props changed)

Modified: stable/9/usr.sbin/makefs/cd9660/iso9660_rrip.c
==
--- stable/9/usr.sbin/makefs/cd9660/iso9660_rrip.c  Mon Nov  9 09:04:11 
2015(r290592)
+++ stable/9/usr.sbin/makefs/cd9660/iso9660_rrip.c  Mon Nov  9 09:05:09 
2015(r290593)
@@ -1,4 +1,4 @@
-/* $NetBSD: iso9660_rrip.c,v 1.11 2012/04/29 13:32:21 joerg Exp $  */
+/* $NetBSD: iso9660_rrip.c,v 1.14 2014/05/30 13:14:47 martin Exp $ */
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -656,13 +656,14 @@ cd9660node_rrip_pn(struct ISO_SUSP_ATTRI
pn_field->attr.rr_entry.PN.h.length[0] = 20;
pn_field->attr.rr_entry.PN.h.version[0] = 1;
 
-   if (sizeof (fnode->inode->st.st_dev) > 32)
-   cd9660_bothendian_dword((uint64_t)fnode->inode->st.st_dev >> 32,
+   if (sizeof (fnode->inode->st.st_rdev) > 4)
+   cd9660_bothendian_dword(
+   (uint64_t)fnode->inode->st.st_rdev >> 32,
pn_field->attr.rr_entry.PN.high);
else
cd9660_bothendian_dword(0, pn_field->attr.rr_entry.PN.high);
 
-   cd9660_bothendian_dword(fnode->inode->st.st_dev & 0x,
+   cd9660_bothendian_dword(fnode->inode->st.st_rdev & 0x,
pn_field->attr.rr_entry.PN.low);
return 1;
 }
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r290596 - stable/9/usr.sbin/makefs

2015-11-09 Thread Garrett Cooper
Author: ngie
Date: Mon Nov  9 09:23:13 2015
New Revision: 290596
URL: https://svnweb.freebsd.org/changeset/base/290596

Log:
  MFstable/10 r290595:
  
  MFC r290264:
  
  Limit isoLevel to 1 and 2 to avoid segfaulting when isoLevel is set to 3 by
  dereferencing a NULL function pointer
  
  Add some asserts to ensure that isolevel is always either 1 or 2.
  
  PR: 203645
  Reported by: Thomas Schmitt 
  Sponsored by: EMC / Isilon Storage Division

Modified:
  stable/9/usr.sbin/makefs/cd9660.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/usr.sbin/   (props changed)
  stable/9/usr.sbin/makefs/   (props changed)

Modified: stable/9/usr.sbin/makefs/cd9660.c
==
--- stable/9/usr.sbin/makefs/cd9660.c   Mon Nov  9 09:22:11 2015
(r290595)
+++ stable/9/usr.sbin/makefs/cd9660.c   Mon Nov  9 09:23:13 2015
(r290596)
@@ -296,8 +296,8 @@ cd9660_parse_opts(const char *option, fs
int rv;
/* Set up allowed options - integer options ONLY */
option_t cd9660_options[] = {
-   { "l", &diskStructure.isoLevel, 1, 3, "ISO Level" },
-   { "isolevel", &diskStructure.isoLevel, 1, 3, "ISO Level" },
+   { "l", &diskStructure.isoLevel, 1, 2, "ISO Level" },
+   { "isolevel", &diskStructure.isoLevel, 1, 2, "ISO Level" },
{ "verbose",  &diskStructure.verbose_level, 0, 2,
  "Turns on verbose output" },
{ "v", &diskStructure.verbose_level, 0 , 2,
@@ -1055,6 +1055,7 @@ cd9660_rename_filename(cd9660node *iter,
if (diskStructure.verbose_level > 0)
printf("Rename_filename called\n");
 
+   assert(1 <= diskStructure.isoLevel && diskStructure.isoLevel <= 2);
/* TODO : A LOT of chanes regarding 8.3 filenames */
if (diskStructure.isoLevel == 1)
maxlength = 8;
@@ -1730,6 +1731,7 @@ cd9660_joliet_convert_filename(const cha
 static int
 cd9660_convert_filename(const char *oldname, char *newname, int is_file)
 {
+   assert(1 <= diskStructure.isoLevel && diskStructure.isoLevel <= 2);
/* NEW */
cd9660_filename_conversion_functor conversion_function = 0;
if (diskStructure.isoLevel == 1)
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r290598 - stable/9/usr.sbin/makefs/ffs

2015-11-09 Thread Garrett Cooper
Author: ngie
Date: Mon Nov  9 09:24:28 2015
New Revision: 290598
URL: https://svnweb.freebsd.org/changeset/base/290598

Log:
  MFstable/10 r290597:
  
  MFC r290268:
  
  Sync minor whitespace / type changes in ffs_csum_swap and ffs_sb_swap with
  src/sys/ufs/ffs/ffs_bswap.c@1.39
  
  Obtained from: NetBSD
  Sponsored by: EMC / Isilon Storage Division

Modified:
  stable/9/usr.sbin/makefs/ffs/ffs_bswap.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/usr.sbin/   (props changed)
  stable/9/usr.sbin/makefs/   (props changed)

Modified: stable/9/usr.sbin/makefs/ffs/ffs_bswap.c
==
--- stable/9/usr.sbin/makefs/ffs/ffs_bswap.cMon Nov  9 09:23:35 2015
(r290597)
+++ stable/9/usr.sbin/makefs/ffs/ffs_bswap.cMon Nov  9 09:24:28 2015
(r290598)
@@ -67,7 +67,7 @@ void ffs_csumtotal_swap(struct csum_tota
 void
 ffs_sb_swap(struct fs *o, struct fs *n)
 {
-   int i;
+   size_t i;
u_int32_t *o32, *n32;
 
/*
@@ -97,7 +97,7 @@ ffs_sb_swap(struct fs *o, struct fs *n)
n->fs_csaddr = bswap64(o->fs_csaddr);
n->fs_pendingblocks = bswap64(o->fs_pendingblocks);
n->fs_pendinginodes = bswap32(o->fs_pendinginodes);
-   
+
/* These fields overlap with the second half of the
 * historic FS_42POSTBLFMT postbl table
 */
@@ -171,9 +171,9 @@ ffs_dinode2_swap(struct ufs2_dinode *o, 
 void
 ffs_csum_swap(struct csum *o, struct csum *n, int size)
 {
-   int i;
+   size_t i;
u_int32_t *oint, *nint;
-   
+
oint = (u_int32_t*)o;
nint = (u_int32_t*)n;
 
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r290600 - stable/9/usr.sbin/makefs/ffs

2015-11-09 Thread Garrett Cooper
Author: ngie
Date: Mon Nov  9 09:29:38 2015
New Revision: 290600
URL: https://svnweb.freebsd.org/changeset/base/290600

Log:
  MFstable/10 r290599:
  
  MFC r266930,r289225:
  
  r266930 (by jmg):
  
  convert to using the _daddr_t types like newfs was...
  
  Put the superblock in the correct possition for UFS2... There is a bug
  in FFS that if we don't put it here (for UFS2), it will forcefully
  relocate the superblock, and I believe cause data loss..
  
  I have a fix for that, but w/ how many releases are broken, we won't be
  able to switch to the better _FLOPPY (block 0) for this for a while..
  
  r289225 (by sbruno):
  
  makefs(8) leaves sblock.fs_providersize uninitialized (zero) that can be 
easily
  checked with dumpfs(8). This may lead to other problems, f.e. geom_label 
kernel
  module sanity checks do not like zero fs_old_size value and skips such UFS1
  file system while tasting (fs_old_size derives from sblock.fs_providersize).
  
  PR:   203704
  Submitted by: eu...@grosbein.net
  Reviewed by:  marcel

Modified:
  stable/9/usr.sbin/makefs/ffs/mkfs.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/usr.sbin/   (props changed)
  stable/9/usr.sbin/makefs/   (props changed)

Modified: stable/9/usr.sbin/makefs/ffs/mkfs.c
==
--- stable/9/usr.sbin/makefs/ffs/mkfs.c Mon Nov  9 09:28:34 2015
(r290599)
+++ stable/9/usr.sbin/makefs/ffs/mkfs.c Mon Nov  9 09:29:38 2015
(r290600)
@@ -248,15 +248,16 @@ ffs_mkfs(const char *fsys, const fsinfo_
exit(21);
}
sblock.fs_fsbtodb = ilog2(sblock.fs_fsize / sectorsize);
-   sblock.fs_size = fssize = dbtofsb(&sblock, fssize);
+   sblock.fs_size = sblock.fs_providersize = fssize =
+   dbtofsb(&sblock, fssize);
 
if (Oflag <= 1) {
sblock.fs_magic = FS_UFS1_MAGIC;
sblock.fs_sblockloc = SBLOCK_UFS1;
-   sblock.fs_nindir = sblock.fs_bsize / sizeof(int32_t);
+   sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs1_daddr_t);
sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs1_dinode);
sblock.fs_maxsymlinklen = ((NDADDR + NIADDR) *
-   sizeof (int32_t));
+   sizeof (ufs1_daddr_t));
sblock.fs_old_inodefmt = FS_44INODEFMT;
sblock.fs_old_cgoffset = 0;
sblock.fs_old_cgmask = 0x;
@@ -272,15 +273,11 @@ ffs_mkfs(const char *fsys, const fsinfo_
sblock.fs_old_nrpos = 1;
} else {
sblock.fs_magic = FS_UFS2_MAGIC;
-#if 0 /* XXX makefs is used for small filesystems. */
sblock.fs_sblockloc = SBLOCK_UFS2;
-#else
-   sblock.fs_sblockloc = SBLOCK_UFS1;
-#endif
-   sblock.fs_nindir = sblock.fs_bsize / sizeof(int64_t);
+   sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs2_daddr_t);
sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs2_dinode);
sblock.fs_maxsymlinklen = ((NDADDR + NIADDR) *
-   sizeof (int64_t));
+   sizeof (ufs2_daddr_t));
}
 
sblock.fs_sblkno =
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"


svn commit: r290608 - stable/9/sys/dev/usb/net

2015-11-09 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Nov  9 11:27:31 2015
New Revision: 290608
URL: https://svnweb.freebsd.org/changeset/base/290608

Log:
  MFC r290441:
  Fix for unaligned IP-header.
  
  The mbuf length fields must be set before m_adj() is called else
  m_adj() will not always adjust the mbuf and an unaligned read
  exception can trigger inside the network stack. This can happen on
  platforms where unaligned reads are not supported. Adjust a length
  check to include the 2-byte ethernet alignment while at it.

Modified:
  stable/9/sys/dev/usb/net/if_cdce.c
  stable/9/sys/dev/usb/net/if_urndis.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/net/if_cdce.c
==
--- stable/9/sys/dev/usb/net/if_cdce.c  Mon Nov  9 11:24:59 2015
(r290607)
+++ stable/9/sys/dev/usb/net/if_cdce.c  Mon Nov  9 11:27:31 2015
(r290608)
@@ -1381,6 +1381,7 @@ cdce_ncm_bulk_read_callback(struct usb_x
 
/* check if we have a buffer */
if (m) {
+   m->m_len = m->m_pkthdr.len = temp + ETHER_ALIGN;
m_adj(m, ETHER_ALIGN);
 
usbd_copy_out(pc, offset, m->m_data, temp);

Modified: stable/9/sys/dev/usb/net/if_urndis.c
==
--- stable/9/sys/dev/usb/net/if_urndis.cMon Nov  9 11:24:59 2015
(r290607)
+++ stable/9/sys/dev/usb/net/if_urndis.cMon Nov  9 11:27:31 2015
(r290608)
@@ -848,7 +848,7 @@ urndis_bulk_read_callback(struct usb_xfe
DPRINTF("invalid ethernet size "
"%u < %u\n", msg.rm_datalen, 
(unsigned)sizeof(struct ether_header));
goto tr_setup;
-   } else if (msg.rm_datalen > (uint32_t)MCLBYTES) {
+   } else if (msg.rm_datalen > (uint32_t)(MCLBYTES - 
ETHER_ALIGN)) {
ifp->if_ierrors++;
DPRINTF("invalid ethernet size "
"%u > %u\n",
@@ -862,6 +862,7 @@ urndis_bulk_read_callback(struct usb_xfe
 
/* check if we have a buffer */
if (m != NULL) {
+   m->m_len = m->m_pkthdr.len = msg.rm_datalen + 
ETHER_ALIGN;
m_adj(m, ETHER_ALIGN);
 
usbd_copy_out(pc, offset + msg.rm_dataoffset +
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"