memalloc_load.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/sh
  2. #############################################################################
  3. #
  4. # The MIT License (MIT)
  5. #
  6. # Copyright (c) 2014 - 2021 VERISILICON
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining a
  9. # copy of this software and associated documentation files (the "Software"),
  10. # to deal in the Software without restriction, including without limitation
  11. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. # and/or sell copies of the Software, and to permit persons to whom the
  13. # Software is furnished to do so, subject to the following conditions:
  14. #
  15. # The above copyright notice and this permission notice shall be included in
  16. # all copies or substantial portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  23. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  24. # DEALINGS IN THE SOFTWARE.
  25. #
  26. #############################################################################
  27. #
  28. # The GPL License (GPL)
  29. #
  30. # Copyright (C) 2014 - 2021 VERISILICON
  31. #
  32. # This program is free software; you can redistribute it and/or
  33. # modify it under the terms of the GNU General Public License
  34. # as published by the Free Software Foundation; either version 2
  35. # of the License, or (at your option) any later version.
  36. #
  37. # This program is distributed in the hope that it will be useful,
  38. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  39. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  40. # GNU General Public License for more details.
  41. #
  42. # You should have received a copy of the GNU General Public License
  43. # along with this program; if not, write to the Free Software Foundation,
  44. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  45. #
  46. #############################################################################
  47. #
  48. # Note: This software is released under dual MIT and GPL licenses. A
  49. # recipient may use this file under the terms of either the MIT license or
  50. # GPL License. If you wish to use only one license not the other, you can
  51. # indicate your decision by deleting one of the above license notices in your
  52. # version of this file.
  53. #
  54. ##############################################################################
  55. #
  56. # Load memalloc
  57. module="memalloc"
  58. device="/dev/memalloc"
  59. mode="666"
  60. echo
  61. if [ ! -e /dev ]
  62. then
  63. mkdir -p /dev/
  64. fi
  65. #insert module
  66. rm_module=`lsmod |grep $module`
  67. if [ ! -z "$rm_module" ]
  68. then
  69. rmmod $module || exit 1
  70. fi
  71. insmod $module.ko $* || exit 1
  72. echo "module $module inserted"
  73. #remove old nod
  74. rm -f $device
  75. #read the major asigned at loading time
  76. major=`cat /proc/devices | grep $module | cut -c1-3`
  77. echo "$module major = $major"
  78. #create dev node
  79. mknod $device c $major 0
  80. echo "node $device created"
  81. #give all 'rw' access
  82. chmod $mode $device
  83. echo "set node access to $mode"
  84. #the end
  85. echo